evans d [16aa] 12 Posted August 31, 2014 Hello all, The problem's as it sounds. I have an 8 man AI squad in Kamino on the range and I've setup a small firing range for them to practice at. I have 8 different scripts (named "kaminoRange1 through 8.sqf") with the following code: while {!blueNearKamino} do { _maxTime = 5; _minTime = 2; _sleepTime = (random (_maxTime - _minTime)) + _minTime; _target1 = [kaminoTarget1,kaminoTarget2,kaminoTarget3,kaminoTarget4,kaminoTarget5,kaminoTarget6,kaminoTarget7,kaminoTarget8] call BIS_fnc_selectRandom; sleep _sleepTime; kaminoSoldier1 doTarget _target1; sleep _sleepTime; kaminoLogic action ["useWeapon",kaminoSoldier1,kaminoSoldier1,0]; sleep 1; }; Note: The different scripts have corresponding numbers for their variables (e.g: kaminoSoldier2, _target4, etc) The problem with this is that, while it works, it looks ugly having essentially the same script called 8 times (nul = execVM "scripts\kaminoRange1.sqf; nul = execVM "scripts\kaminoRange2.sqf; nul = execVM "scripts\kaminoRange3.sqf; etc") What I'd like to do is condense those 8 scripts into 1. I've tried using the good old boolean "&&" method: while {x} do { code1; }; && { code2; }; But that doesn't work. I then tried the following method: while {x} do { { code1 }; { code2 }; }; but that doesn't work either. I then tried to make functions to solve the problem and then referencing them in the loop: while {x} do { call function1; call function2; }; And while this kind of works, it waits to cycle through each function before getting to the next one (it waits for function 1 to finish, complete with sleeps, before moving to function 2). Simply making lots of loops: while {x} do { code1 }; while {x} do { code2 }; Only fires code1, and doesn't move onto code2. Can anyone think of a way to make this code work simultaneously? Share this post Link to post Share on other sites
f2k sel 164 Posted August 31, 2014 call like this, changing the name of the shooter and his tartgets null=[kaminoSoldier1,[kaminoTarget1,kaminoTarget2,kaminoTarget3,kaminoTarget4,kaminoTarget5,kaminoTarget6,kaminoTarget7,kaminoTarget8]] execvm "kaminoRange.sqf"; _unit = _this select 0; _targets = _this select 1; while {!blueNearKamino and alive _unit} do { _maxTime = 5; _minTime = 2; _sleepTime = (random (_maxTime - _minTime)) + _minTime; _target1 = _targets call BIS_fnc_selectRandom; sleep _sleepTime; _unit doTarget _target1; sleep _sleepTime; kaminoLogic action ["useWeapon",_unit,_unit,0]; sleep 1; }; Share this post Link to post Share on other sites
evans d [16aa] 12 Posted August 31, 2014 Cheers F2K. This'll be a great foundation! Share this post Link to post Share on other sites