Jump to content
Sign in to follow this  
CorporateHammer

Help with 3 trigger setup for kill targets within 30 sec.

Recommended Posts

What I would like to do is have players kill 4 guards in 30 sec. if failed set task to fail and sound alarm spawning reinforcements or if successful set task successful and delete the alarm trigger.

So I have 4 guards with // group1=group this // in init

task called Guardkills

1 trigger "noReturn" - this set for blufor present a point of no return so to speak

2nd trigger " alarm1_1" condition // opfor , present , this && triggerActivated noReturn; // On ACT // if (({alive _x} count units group1) < 1) then {deleteVehicle alarm1, Guardkills setTaskState "SUCCEEDED"};// Countdown 31 for min, mid, max

3rd trigger "alarm1" condition // once, present, opfor , this && triggerActivated noReturn; // On ACT // code to spawn AI; deleteVehicle alarm1_1; Guardkills setTaskState "FAILED";

Timeout 34 min, mid, max. This trigger sounds an alarm once set

For some reason this is not working. Maybe I'm taking too complex of an approach I don't know. My theory I guess is trigger the point of no return which sets off both opfor triggers at that point as 4 opfor guards are present. So if killed 4 guards within the 31 secound countdown it should trigger task successful and delete the trigger with the reinforcements before it fires and also wouldnt fire due to opfor needing to be present the whole 34 sec to fire.

Any help, tips, or flat out thats just wrong would be greatly appreciated.

Share this post


Link to post
Share on other sites

Scripting this would be 1000x easier IMHO.

//some triggered event
0 = [] execVM "guardsDead.sqf";

//guardsDead.sqf

glb_flagVar = false;
_timer = [] spawn { sleep 30; glb_flagVar = true; };

waitUntil { ({alive _x} count (units group1) isEqualTo 0) || scriptDone _timer};

if (glb_flagVar) then
{
  //play alarm
}
else
{
  //success
};

Edited by JShock

Share this post


Link to post
Share on other sites

Thanks. Really trying to grasp scripts so I guess I tend to think of over complicated ways to do stuff LOL. Will give your advise a go and Thanks.

Share this post


Link to post
Share on other sites

Made small error in the code I provided, fixed above.

Share this post


Link to post
Share on other sites

Many thanks for your time, thought maybe i was doing something wrong LOL and was about to post what i was trying. Will give it another go.

---------- Post added at 07:17 ---------- Previous post was at 05:22 ----------

well I'm having some trouble and may very well be on me. Couple questions,

1. _timer = [] spawn { sleep 30; glb_flagVar = true; }; this creates a local variable timer that counts to 30 then sets glb_flagVar to true correct ?

2. waitUntil { ({alive _x} count (units group1) isEqualTo 0) || scriptDone _timer}; then this runs and continues to the if statement right ?

I guess I'm wondering if

1. if (glb_flagVar) means if glb_flagVar is true ?

I"m also curious about the waituntil , could there be a way to do the count of units alive in group after the timer gets to 30 then use the global variable glb_flagVar in the 2 trigger conditions ? 1 trigger goes off if false or the other goes off if true ?

Sorry, again your code may very well be on point I guess I don't have the knowledge to do what I'm wanting to do.

Share this post


Link to post
Share on other sites

To your first #1, yes that is correct, to be a bit more specific it runs the code in a scheduled environment, in basic terms it runs that code in the background and continues the script.

To the #2, waitUntil suspends the script, so until either all the units in the group are dead or the "timer" is complete, the script will stay on that waitUntil.

For the second #1, yes that is correct.

To your last bit, this script handles both conditions at the same time, if one or the other is completed, at which point a variable is checked, if that variable value was changed, do something, else, do something different. So basically, you will need a single trigger that is whatever trigger and condition (i.e. Blufor present) that you want the timer to start, and in the onAct of that trigger, put the script call line I gave at the top of my example code.

Share this post


Link to post
Share on other sites

I get your point KK and it makes sense, but he is saying count at <1 and my example is checking at equal to 0, so I don't think there is an issue there.

Share this post


Link to post
Share on other sites

ok thank you again. makes much more sense esp. the part about the timer or variable changing, cleared allot up for me.

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  

×