gameboi 10 Posted September 3, 2015 Hi. I have a scenario where an AI infantry man runs towards a gun, and mans it. This is activated by a synced trigger. In that trigger I have in the field "ON ACT" this code: waitUntil{ !isnull(gunner Mk1)}; nul = [Mk1, "t1", "t2", "t3", "t4", "t5", "t6", 600] execVM "randomfire.sqf"; But that's not working. The script "randomfire.sqf" executes immedatily. Sleep doesn't work either. It's not allowed for to place sleep or the waituntil keyword in the SQF file itself. So I must have it delayed in the trigger itself. Also, "COUNTDOWN" and "TIMEOUT" is not useful either as it delays (or counts down) the entire triggering of the trigger. The trigger needs to triggered right away (so the ai unit runs towards a gun) but the activation of the custom script after it has reached gun must be delayed until the gun has been manned. Thanks and cheer everybody! Share this post Link to post Share on other sites
bull_a 44 Posted September 3, 2015 No need to synchronize the trigger for triggering the event. Things to do: 1. Desynchronize the trigger, unless its synchronized to a waypoint (if it synced to the gun, it doesnt do anything). 2. In the trigger 'condition' field write the following: !(isNull (gunner Mk1)) && !(alive Mk1) 3. In the 'on activation' field write the following: _nul = [Mk1, "t1", "t2", "t3", "t4", "t5", "t6", 600] execVM "randomfire.sqf"; 4. Set the 'Countdown' or 'Timeout' to number values at your descretion Hope that helps, Bull Share this post Link to post Share on other sites
gameboi 10 Posted September 3, 2015 No need to synchronize the trigger for triggering the event. Things to do: 1. Desynchronize the trigger, unless its synchronized to a waypoint (if it synced to the gun, it doesnt do anything). 2. In the trigger 'condition' field write the following: !(isNull (gunner Mk1)) && !(alive Mk1) 3. In the 'on activation' field write the following: _nul = [Mk1, "t1", "t2", "t3", "t4", "t5", "t6", 600] execVM "randomfire.sqf"; 4. Set the 'Countdown' or 'Timeout' to number values at your descretion Hope that helps, Bull Thank but that's not it. Here's what's going on: A) Trigger is scyned with a waypoint. This will trigger an infantry AI to man a turret 20 meters away. B) After A has been fullfilled, then the execVM should take place in that same trigger in the ON ACT field. Setting a delay will will only delay the AI unit to move to the gun it oughtta man. So that's not it. The gunner needs to move straight away. Here's the code. Note I solved it by a waitUntil command in the scirpt itself for now. It's also possible offcourse that delaying the ON ACT, or some code in the ON ACT field such as an execVM command is not possible at all! The wait until command doesn't work in there. //Random location fire script. Place code below in the "ON ACT" field of the trigger, after placing a number of named markers on the map for that specific trigger. //nul = [Gun1,"markerArray",60] execVM "randomfire.sqf"; //In ON ACT.: /* markerArray = ["t1", "t2", "t3"]; nul = [Mk1, markerArray, 6000] execVM "randomfire.sqf"; */ private ["_gunname","_markerArray","_fortime", "_gunnername", "_targetToFireAt"]; if (!isServer) exitWith {}; _gunname = _this select 0; //Maybe the gunner needs to come from elsewhere to man it first. So wait until it has manned the gun. waitUntil {!isNull gunner _gunname}; _gunnername = gunner _gunname; _markerArray = _this select 1; _fortime = _this select 2; while {_fortime > 0} do { if (!alive _gunnername) exitwith {}; _targetToFireAt = _markerArray call BIS_fnc_selectRandom; _gunname doWatch (getmarkerpos _targetToFireAt); _gunname action ["useWeapon", _gunname, _gunnername, 1]; sleep ceil(random 3); //At 0 the gunner doesn't seem to shoot. Or he shoots only once. _fortime = _fortime - 1; _gunname setvehicleammo 1; }; Share this post Link to post Share on other sites
Ranwer135 308 Posted September 4, 2015 some code in the ON ACT field such as an execVM command is not possible at all! Doubt it...Check your ".rpt" file or use -ShowScriptErrors Share this post Link to post Share on other sites
gameboi 10 Posted September 4, 2015 Doubt it...Check your ".rpt" file or use -ShowScriptErrors I mean DELAYING an execVM command. I forgot a word or two. But I'll try your latest advice! OK I made a simple test with this: markerArray = ["t1", "t2", "t3"]; waitUntil {!isNull gunner Mk1}; hint "gunner arrived"; The error in the rpt file I get is: 11:23:24 Suspending not allowed in this context 11:23:24 Error in expression < = ["t1", "t2", "t3"]; waitUntil {!isNull gunner Mk1}; hint "gunner arri> 11:23:24 Error position: <!isNull gunner Mk1}; hint "gunner arri> 11:23:24 Error Generic error in expression So suspending functions like "sleep" and "waitUntil" is not allowed int he ON ACT field. That's the conclusion that I'd draw from this. Share this post Link to post Share on other sites
Ranwer135 308 Posted September 4, 2015 Then run sleep or waitUntil in a .sqf, but execute it via the trigger. (Reason being, is that anything within the editor will initialize it all at once. So waitUntil and sleep are practically useless within the editor, unless in a .sqf) Share this post Link to post Share on other sites
Greenfist 1863 Posted September 4, 2015 Well, you can always spawn a new scheduled scope from trigger/init and use sleep there. 0 = this spawn {sleep 5; hint "I slept, but now I'm awake!"; 0 = _this execVM "yourscript.sqf"} But of course, going straight to a script is simpler, unless you're just doing a quick test in the editor. Share this post Link to post Share on other sites
gameboi 10 Posted September 4, 2015 Then run sleep or waitUntil in a .sqf, but execute it via the trigger. (Reason being, is that anything within the editor will initialize it all at once. So waitUntil and sleep are practically useless within the editor, unless in a .sqf) Yes exactly Ranwer135. I did exactly that at one point as suspending commands are not allowed in many places fo the editor, the ON ACT field of a trigger being one of them. I was just hoping I overlooked something :). Well, you can always spawn a new scheduled scope from trigger/init and use sleep there.0 = this spawn {sleep 5; hint "I slept, but now I'm awake!"; _this = execVM "yourscript.sqf"}But of course, going straight to a script is simpler, unless you're just doing a quick test in the editor. No, you can't use sleep in the ON ACT field of a trigger. I moved it to the script as you can read in the comment above and the script code itself. I think it's solved quite elegantly. See my remark to Ranwer135 for the scope of my query here. It's basically solved. I wish to thank you all for participating. Have a wonderful weekend! Share this post Link to post Share on other sites
Greenfist 1863 Posted September 4, 2015 No, you can't use sleep in the ON ACT field of a trigger. I moved it to the script as you can read in the comment above and the script code itself. I think it's solved quite elegantly. See my remark to Ranwer135 for the scope of my query here. It's basically solved. I know you already solved it, but I was just pointing out a way you CAN use sleep in the on act field. But moving it to the script is much more elegant obviously. Share this post Link to post Share on other sites
gameboi 10 Posted September 4, 2015 I know you already solved it, but I was just pointing out a way you CAN use sleep in the on act field. But moving it to the script is much more elegant obviously. Wait a minute. I think somethitng is wrong with my Arma 3. I'm gettng this RPT error when I have placed only 1 infantry guy. No triggers no nothing, just one guy: 13:41:51 Starting mission: 13:41:51 Mission file: test 13:41:51 Mission world: Stratis 13:41:51 Mission directory: C:\Users\Administrator\Documents\Arma 3 - Other Profiles\Tengu\missions\test.Stratis\ 13:41:53 Attempt to override final function - bis_functions_list 13:41:53 Attempt to override final function - bis_functions_listpreinit 13:41:53 Attempt to override final function - bis_functions_listpostinit 13:41:53 Attempt to override final function - bis_functions_listrecompile 13:41:53 Attempt to override final function - bis_fnc_missiontaskslocal 13:41:53 Attempt to override final function - bis_fnc_missionconversationslocal 13:41:53 Attempt to override final function - bis_fnc_missionflow 13:41:54 "Tengu/BIS_fnc_log: [BIS_fnc_loop] "Initialized"" 13:41:54 No owner 13:41:54 Error in expression </*--------------------------------------> 13:41:54 Error position: </*--------------------------------------> 13:41:54 Error Invalid number in expression 13:41:54 Error in expression </*--------------------------------------> 13:41:54 Error position: </*--------------------------------------> 13:41:54 Error Invalid number in expression 13:41:56 No owner 13:41:56 Error in expression </*--------------------------------------> 13:41:56 Error position: </*--------------------------------------> 13:41:56 Error Invalid number in expression 13:41:56 Error in expression </*--------------------------------------> 13:41:56 Error position: </*--------------------------------------> 13:41:56 Error Invalid number in expression 13:41:57 No owner 13:41:57 Error in expression </*--------------------------------------> 13:41:57 Error position: </*--------------------------------------> 13:41:57 Error Invalid number in expression 13:41:57 Error in expression </*--------------------------------------> 13:41:57 Error position: </*--------------------------------------> 13:41:57 Error Invalid number in expression Something is wrong. Share this post Link to post Share on other sites
gameboi 10 Posted September 4, 2015 It was CBA messing. Updated to 2.0. But nevertheless, suspending, therefore "sleep" is not allowed in the ON ACT field. I just tried again. Here's the proof I just did 30 seconds ago (again). 14:13:59 Suspending not allowed in this context 14:13:59 Error in expression <hint "test"; sleep 2; hint "another test";> 14:13:59 Error position: <sleep 2; hint "another test";> 14:13:59 Error Generic error in expression So quite a lesson learned here for me. Share this post Link to post Share on other sites
Greenfist 1863 Posted September 4, 2015 If you spawn the code like I mentioned, the sleep works: 0 = [] spawn {hint "hello";sleep 5;hint "hello again"}; All the scopes in the editor (inits, triggers, console) run in an non-scheduled enviroment. I.e. executed immediately. So no sleep allowed. But spawn creates a new independent scope, so sleep will work. Share this post Link to post Share on other sites
gameboi 10 Posted September 4, 2015 If you spawn the code like I mentioned, the sleep works: 0 = [] spawn {hint "hello";sleep 5;hint "hello again"}; All the scopes in the editor (inits, triggers, console) run in an non-scheduled enviroment. I.e. executed immediately. So no sleep allowed. But spawn creates a new independent scope, so sleep will work. Ah I see. I'll remember this for the next time. The moments of using either call or spawn is too andvanced for me as of now. I'm a beginner. This is my first attempt. But thanks! Share this post Link to post Share on other sites