Salty Bear 2 Posted June 17, 2017 I am executing this code in a .sqf using execVM via a trigger, but waitUntil isn't working. That is, after _cnt == 0 (after I kill all the units in the _ambushers group), the script does not continue. However, if after killing _ambushers, if I reexecute the script via the debug console in-game, then it seems to work just fine - it skips the first titleText and goes right into the code below waitUntil {_cnt == 0}. But the whole point of waitUntil is to NOT have to reexecute anything. What gives? Is it a waitUntil issue, or a count issue? What am I doing wrong? _ambushers = group ambusher; _cnt = count units _ambushers; if (_cnt > 0) then { titleText ["CREWMAN: TOOK YOU LONG ENOUGH! SHOOT THEM!", "PLAIN DOWN", 4]; titleFadeOut 1; }; waitUntil {_cnt == 0}; sleep 2; if (alive crewman) then { toolkitbox addItemCargo ["Toolkit",1]; titleText ["CREWMAN: Whew! Thanks for your help, guys.", "PLAIN DOWN", 4]; titleFadeOut 1; sleep 6; titleText ["CREWMAN: There is a repair kit in my equipment box. Take it for your truck. Just in case.", "PLAIN DOWN", 4]; titleFadeOut 1; sleep 6; ["tsk03","SUCCEEDED"] call BIS_fnc_taskSetState; sleep 3; ["tsk02b","ASSIGNED"] call BIS_fnc_taskSetState; } else { titleText ["PLAYER: He's dead. Looks like we failed.", "PLAIN DOWN", 4]; titleFadeOut 1; sleep 6; ["tsk03","FAILED"] call BIS_fnc_taskSetState; sleep 3; ["tsk02b","ASSIGNED"] call BIS_fnc_taskSetState; }; Share this post Link to post Share on other sites
jshock 513 Posted June 17, 2017 When you run "count units _ambushers" and put it in the "_cnt" variable, "_cnt" stays the same as when you initially do it, so if _cnt doesn't equal zero when you reach the waitUntil you have an infinite loop that will never exit. Do this instead: _ambushers = group ambusher; _cnt = count units _ambushers; if (_cnt > 0) then { titleText ["CREWMAN: TOOK YOU LONG ENOUGH! SHOOT THEM!", "PLAIN DOWN", 4]; titleFadeOut 1; }; waitUntil {(count units _ambushers) == 0}; ..... 1 Share this post Link to post Share on other sites
Salty Bear 2 Posted June 17, 2017 Thank you! It works! Sometimes I run into the problem where the last ambusher runs away, and I can't kill him in order to advance the script. If you have any suggestions, I'd be very grateful. Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted June 17, 2017 15 minutes ago, Salty Bear said: Thank you! It works! Sometimes I run into the problem where the last ambusher runs away, and I can't kill him in order to advance the script. If you have any suggestions, I'd be very grateful. Check if the unit is fleeing. waitUntil {(count units _ambushers) == 0 OR (count units _ambushers < 3 AND {fleeing _x} count units _ambushers isequalTo count units _ambushers)}; This would continue if ambusher group has less than 3 left and they're all fleeing. Cheers Share this post Link to post Share on other sites
Salty Bear 2 Posted June 17, 2017 Wow thanks so much! I didn't know that "fleeing" was a thing. I will give it a try. Share this post Link to post Share on other sites