////////////////////////////////////////////////////////////////// // Function file for Armed Assault // Created by: (AEF)Wolffy.au [2CAV] // Created: 20090419 // Version: 20090625 - Changelog: // - Changed: Added optional max distance parameter // - Changed: Centre based on start position // - Changed: Random idle time has 1/3 fixed amount // - Added: ... // - Added: Moving to building positions (Tophe) // Version: 20090425 - Changelog: // - Changed: Shorter startup time // - Changed: Weighted random actions changed to random movement // followed by random animation. // - Changed: SL's will not wander around the camp as it // affected other members of group. // - Changed: Move to Camp uses random buildingPos // - Changed: Minor cosmetic distances // - Changed: Move randomly limited to _distance from startpos // - Removed: Two very long animations until I work out how to // cancel a running animation // - Removed: Minimum 30 sec idle time between movements // Version: 20090420 - Initial release // Contact: http://www.aef-hq.com.au // Purpose: Animate CARELESS AI infantry group /////////////////////////////////////////////////////////////////// if (!isServer) exitWith{}; _grp = _this select 0; _dist = _this select 1; if (isNil "_dist") then {_dist = (count units _grp) * 2;}; fRandBldgPos = { ////////////////////////////////////////////////////////////////// // The following code is an extract from Random Building Position Script v1.0 by Tophe of Östgöta Ops ////////////////////////////////////////////////////////////////// _bldgs = _this select 0; _bldgpos = []; _i = 0; { _y = _x buildingPos _i; while {format["%1", _y] != "[0,0,0]"} do { _bldgpos = _bldgpos + [_y]; _i = _i + 1; _y = _x buildingPos _i; }; _i = 0; } forEach _bldgs; _bldgpos = _bldgpos select floor(random(count _bldgpos)); _bldgpos; ////////////////////////////////////////////////////////////////// }; { sleep random 2; [_x, _dist] spawn { private ["_action","_sleep"]; _unit = _this select 0; _dist = _this select 1; _startpos = position leader _unit; _change = 90; _unit setBehaviour "CARELESS"; _unit setSpeedMode "LIMITED"; _sactions = [ "AmovPsitMstpSlowWrflDnon", "AmovPsitMstpSlowWrflDnon_Smoking", "AmovPsitMstpSlowWrflDnon_WeaponCheck1", "AmovPsitMstpSlowWrflDnon_WeaponCheck2" ]; _actions = [ "AmovPercMstpSlowWrflDnon", "AmovPercMstpSlowWrflDnon_seeWatch", // "AmovPercMstpSlowWrflDnon_talking", "AmovPercMstpSlowWrflDnon_turnL", "AmovPercMstpSlowWrflDnon_turnR", "AmovPercMstpSnonWnonDnon_Ease", "AmovPercMstpSnonWnonDnon_exercisePushup", "AmovPercMstpSnonWnonDnon_exercisekneeBendA", "AmovPercMstpSnonWnonDnon_exercisekneeBendB", "AmovPercMstpSnonWnonDnon_seeWatch", // "AmovPercMstpSnonWnonDnon_talking", "AmovPercMwlkSnonWnonDf" ]; _actions = _actions + [ "ActsPercMstpSlowWrflDnon_Listening", "ActsPercMstpSlowWrflDnon_Lolling", "ActsPercMstpSlowWrflDnon_Talking1" ]; scopeName "main"; while {alive _unit && behaviour _unit == "CARELESS"} do { _action = floor(random 4); //player sideChat format["%1 of 3", _action]; // random move action switch (_action) do { case 0: { // move to building _pos = position _unit; _camps = nearestObjects [_pos, ["Camp","Buildings"], _dist * 2]; _bldgpos = [_camps] call fRandBldgPos; _unit doMove _bldgpos; }; case 1: { // move to startpos _pos = position _unit; _newpos = _startpos; if (format["%1", _newpos] != "[0,0,0]") then { _gap = 1 + (random 3); _i = random 360; _xg = (_gap * (sin _i)); _yg = (_gap * (cos _i)); _x_rot = (_newpos select 0) + _xg; _y_rot = (_newpos select 1) + _yg; _newpos = [ _x_rot, _y_rot]; _unit doMove _newpos; }; }; case 2: { // move randomly if (leader _unit != _unit) then { _pos = position _unit; _newpos = _pos; _gap = random _dist; _i = random 360; _xg = (_gap * (sin _i)); _yg = (_gap * (cos _i)); _x_rot = (_newpos select 0) + _xg; _y_rot = (_newpos select 1) + _yg; _newpos = [ _x_rot, _y_rot]; _unit doMove _newpos; }; }; case 3: { // move to another unit if (leader _unit != _unit) then { _grp = group _unit; _meet select floor(random count units _grp); _unit doMove position _meet; }; }; }; waitUntil{unitReady _unit || moveToCompleted _unit || moveToFailed _unit}; _action = floor(random 2); //player globalChat format["%1 of 1", _action]; // random animation _sleep = (_change / 3) + random (_change * 2 / 3); switch (_action) do { case 0: { // play random sitting action _unit playMove (_sactions select floor(random count _sactions)); _sleep = (_change * 2 / 3) + random (_change / 3); }; case 1: { // play random standing action _unit playMove (_actions select floor(random count _actions)); }; }; for "_i" from 1 to _sleep do { if (behaviour _unit == "CARELESS") then { sleep 1; } else { breakTo "main"; }; }; }; //hint format["%1", behaviour _unit]; if (alive _unit) then {group _unit setBehaviour "AWARE";}; _unit playMove "null"; }; } forEach units group _grp;