Jump to content
Sign in to follow this  
Arkon2

Dead in Trigger

Recommended Posts

Hi,

I want a trigger to tell me when a certain number of Opfor are dead - the total number in the trigger will vary - been trying:

{!alive _X} count thislist > 0

With Opfor Present Repeatedly

It goes off if I remove ! fine...

Any help welcome

Cheers

Edited by Arkon2

Share this post


Link to post
Share on other sites
Dead units are civilian, so it can be a problem.

Hi, Przemek_kondor

Thanks for the reply,

Yes I'm aware of that, but i can just stand there and kill a few people and nothing happens...

Edited by Arkon2

Share this post


Link to post
Share on other sites

if the condition is 'opfor present' then you have to check for the ones that are alive, cause the dead ones aren't very present.

Share this post


Link to post
Share on other sites

Przemek_kondor

Master gamawa

Ok,

So, we don't know how many will be alive (as there are people coming and going all the time) - and if we did, how would that tell us how may are dead...

How should we check for this?

(What we are after is a trigger that will tell us when (say 5) Opfor are dead out of an unknown total.)

Share this post


Link to post
Share on other sites

You could add a 'killed' eventhandler, and within it have

if side east then { variable +1; };

or something similar.

Share this post


Link to post
Share on other sites
You could add a 'killed' eventhandler, and within it have

if side east then { variable +1; };

or something similar.

Good idea Reimann! :ok:

I've tested this method:

1.create a trigger in editor and name it trg;

2.put the trigger trg in "NOBODY", "REPEATEDLY", "PRESENT"

3. in the 'Activation' field delete the 'this' condition and write:

start == 1   //the trigger initialize it when the variable 'start' is equals to 1

4.in the 'On activation' field put this code:

//remove a "killed" eventhandler to prevent duplication and add an eventhandler for each unit present in the trigger at the trigger's initialization
{ _x removeEventHandler ["killed",0]; _x addEventHandler ["killed", {(_this select 0) execVM "check.sqf"}] } forEach thislist;

//reset the 'start' variable to permit the trigger's reinitialization after a while
start = 0; 

5.write a .sqf file, name it 'check.sqf' and put in it this code:

//check to see if the unit is still present in the trigger's area
if(_this in ((getPos trg) nearObjects ["SoldierEB",50])) then {
	death = death + 1;
};

P.S. the second parameter of the function 'nearObjects' MUST be equals to the radius of the trigger; in mine case it's 50

6.write a 'Init.sqf' file and put in it this code:

//initialize the 'start' variable
start = 0;

//permit the permanent trigger's reinitialization after one second (to refresh the thislist of the trigger itself)
while {true} do {
sleep 1;
start = 1;
}

7. create a trigger in editor, delete in the 'Activation' field the 'this' condition and write 'death == numberOfDeath' (where numberOfDeath must be the number of death of East units PRESENT IN THE TRIGGER you want to achieve)

I know it's complicated to explain but I assure it is simple to do and it works for sure because I've tested it ;)

Edited by goliath86

Share this post


Link to post
Share on other sites
Good idea Reimann! :ok:

I've tested this method:

1.create a trigger in editor and name it trg;

2.put the trigger trg in "NOBODY", "REPEATEDLY", "PRESENT"

3. in the 'Activation' field delete the 'this' condition and write:

start == 1   //the trigger initialize it when the variable 'start' is equals to 1

4.in the 'On activation' field put this code:

//remove a "killed" eventhandler to prevent duplication and add an eventhandler for each unit present in the trigger at the trigger's initialization
{ _x removeEventHandler ["killed",0]; _x addEventHandler ["killed", {(_this select 0) execVM "check.sqf"}] } forEach thislist;

//reset the 'start' variable to permit the trigger's reinitialization after a while
start = 0; 

5.write a .sqf file, name it 'check.sqf' and put in it this code:

//check to see if the unit is still present in the trigger's area
if(_this in ((getPos trg) nearObjects ["SoldierEB",50])) then {
	death = death + 1;
};

P.S. the second parameter of the function 'nearObjects' MUST be equals to the radius of the trigger; in mine case it's 50

6.write a 'Init.sqf' file and put in it this code:

//initialize the 'start' variable
start = 0;

//permit the permanent trigger's reinitialization after one second (to refresh the thislist of the trigger itself)
while {true} do {
sleep 1;
start = 1;
}

7. create a trigger in editor, delete in the 'Activation' field the 'this' condition and write 'death == numberOfDeath' (where numberOfDeath must be the number of death of East units PRESENT IN THE TRIGGER you want to achieve)

I know it's complicated to explain but I assure it is simple to do and it works for sure because I've tested it ;)

Thanks for all your effort.

Does this cover new units who arrive after the trigger's initialization who are susequently killed whilst within it?

Anyways, I'll try it out later tonight and get back to you tomorrow...

Arkon2

Edited by Arkon2

Share this post


Link to post
Share on other sites

Does this cover new units who arrive after the trigger's initialization who are susequently killed whilst within it?

Yes, it cover new units who arrive after the trigger initialization. The trigger activate itself when it reaches the number of killed unit (inside in the trigger's area) that you have set. If a unit is not present in the trigger's area and die, its 'killed' eventhandler don't start.

Only killed enemy unit in the trigger's area increment the number of victim you have set for the trigger to activate. :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×