OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: Grimfist on 19 Feb 2009, 17:04:55

Title: Civilian Death counting trigger.
Post 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.
Title: Re: Civilian Death counting trigger.
Post by: Trexian on 19 Feb 2009, 17:15:35
Perhaps add a "killed" eventhandler to each civilian, then for the code part, increment a global variable by 1?
Title: Re: Civilian Death counting trigger.
Post by: Grimfist on 19 Feb 2009, 17:24:32
I am sorry but i do not understand, i am not good with scripts.
Title: Re: Civilian Death counting trigger.
Post by: Wolfrug on 19 Feb 2009, 17:47:29
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:

Code: [Select]
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

Code: [Select]
GRIM_CivKilled = 0;
in it. Then, in the END#2 trigger, you've simply got the Condition:
Code: [Select]
GRIM_CivKilled > 14
(more than 14 civilians killed).

Should do it :)

Wolfrug out.
Title: Re: Civilian Death counting trigger.
Post by: Trexian on 19 Feb 2009, 17:52:30
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....
Title: Re: Civilian Death counting trigger.
Post by: Grimfist on 19 Feb 2009, 18:03:21
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.
Title: Re: Civilian Death counting trigger.
Post by: Sparticus76 on 20 Feb 2009, 07:43:49
I know you have the solution, but another option is to create trigger1 covering the map, activated by civilians present, once, Type : none,
Condition :
Code: [Select]
thisOnActivation :
Code: [Select]
numofcivs = count thislist
Then create trigger2 covering the whole map, activated by civilians present, once, Type : End #1,
Condition :
Code: [Select]
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.

Title: Re: Civilian Death counting trigger.
Post by: Wolfrug on 20 Feb 2009, 10:29:03
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.
Title: Re: Civilian Death counting trigger.
Post by: Sparticus76 on 20 Feb 2009, 11:12:22
I just tried it out and you are 100% correct there Wolfrug. Empty vehicles are counted as civilians.
Title: Re: Civilian Death counting trigger.
Post by: Worldeater on 20 Feb 2009, 11:49:28
Another problem might be dead soldiers. IIRC they turn to civilians as well.
Title: Re: Civilian Death counting trigger.
Post by: Sparticus76 on 21 Feb 2009, 00:50:38
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.