OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: Grimfist on 19 Feb 2009, 17:04:55
-
Hi,
i would like to have a trigger (it will cover all of map), or a script that detects how many civilians have died/being killed.
it is for a co-op mission so if 15 civvies die then it forces END #2.
here is what i already have: http://www.armaholic.com/forums.php?m=posts&p=46411&n=last#bottom
Ty in advance,
Grim.
-
Perhaps add a "killed" eventhandler to each civilian, then for the code part, increment a global variable by 1?
-
I am sorry but i do not understand, i am not good with scripts.
-
Multiplayer issue :)
What Trexian is saying is that you should attach an eventHandler (http://www.ofpec.com/COMREF/index.php?action=details&id=6) to each civilian, and then count up a global variable (which you need to make global in scope by some magic command that I don't know since I don't live in MP land). For instance, in each civilian's init field write:
this addeventhandler ["killed", {GRIM_CivKilled = GRIM_CivKilled + 1; publicVariable "GRIM_CivKilled"}];
in the Init.sqf or someplace else you've then created the global variable GRIM_CivKilled by putting
GRIM_CivKilled = 0;
in it. Then, in the END#2 trigger, you've simply got the Condition:
GRIM_CivKilled > 14
(more than 14 civilians killed).
Should do it :)
Wolfrug out.
-
Whew!
Lucky for you, somebody more experienced showed up. :D
Also, have you grabbed this new guide?
(right-click, save as) ;)
ftp://ftp.armedassault.info/armad/docs/Armed-Assault_Editing-Guide_Deluxe_Edition_by_Mr-Murray_EN.7z
It has some great information.
The eventhandler is triggered when that civ is killed. When that happens, it will increment the dead civilian counter.
Your trigger can repeatedly then check if the dead civs > 15 then end2.
Again, I'm still very much n00bish at this, but it seems like it might work.
Oh, and I have no idea about MP either....
-
hmm ty both of u, but where can i find this magic command thing.
i am going to try it now.
WOW - it works ty very much.
-
I know you have the solution, but another option is to create trigger1 covering the map, activated by civilians present, once, Type : none,
Condition :
this
OnActivation :
numofcivs = count thislist
Then create trigger2 covering the whole map, activated by civilians present, once, Type : End #1,
Condition :
count thislist == numofcivs - 15
The first trigger counts the number of civilians at the start and creates a variable called "numofcivs" that equals the initial amount of civilans on the map.
The second trigger..triggers when count of its list (the whole map of civilians) is equal to the "numofcivs" variable minus 15, meaning that 15 civilians have been killed. Although they could have died from anything, not only your guys shooting them.
-
Problem is empty vehicles are also counted among civilians, so a civilian-counting trigger would, I think, also include all the abandoned (not destroyed) vehicles scattered around the map...
I might be mistaken however!
Wolfrug out.
-
I just tried it out and you are 100% correct there Wolfrug. Empty vehicles are counted as civilians.
-
Another problem might be dead soldiers. IIRC they turn to civilians as well.
-
I tested it with dead soldiers while I was testing the empty vehicle theory, but dead soldiers didn't effect the civilian count for some reason. Although if you use an "killed" event handler, and check the sides from the output of that event handler when you kill a guy, the killed guy is side civ...so I dunno why it's not counting dead dudes.