////////////////////////////////////////////////////////////////// // Function file for Armed Assault 2 // Original scripts created by: BI // Modified by: Wolffy.au // Created: 20090627 // Version: 20090627 - Initial release // Contact: // Purpose: Move static targets side to side // Usage: nul = [ target, optional distance ] execVM "scripts\MovingTarget\Init.sqf"; /////////////////////////////////////////////////////////////////// if (!isServer) then exitWith{}; private ["_tgt", "_gap", "_dir", "_start", "_startX", "_startY", "_inc", "_i", "_xg", "_yg", "_newX", "_newY"]; _tgt = _this select 0; _gap = _this select 1; if (isNil("_gap")) then {_gap = 60;}; _dir = direction _tgt; _inc = 0.1 + (1 / ((_tgt distance player) / 2)); _start = position _tgt; _startX = _start select 0; _startY = _start select 1; _i = _dir; _xg = _gap * 0.5 *(cos _i); _yg = _gap * 0.5 * (sin _i); _newX = _startX + _xg; _newY = _startY + _yg; while {true} do { for [{_x=0},{_x<=(_tgt distance [_newX, _newY])},{_x=_x+_inc}] do { _xg = _x * (cos _i); _yg = _x * (sin _i); _tgt setPos [_startX + _xg, _startY + _yg]; sleep 0.01; }; sleep random 30; _tgt setDamage 0; _start = position _tgt; _startX = _start select 0; _startY = _start select 1; _i = _dir + 180; _xg = _gap * (cos _i); _yg = _gap * (sin _i); _newX = _startX + _xg; _newY = _startY + _yg; for [{_x=0},{_x<=(_tgt distance [_newX, _newY])},{_x=_x+_inc}] do { _xg = _x * (cos _i); _yg = _x * (sin _i); _tgt setPos [_startX + _xg, _startY + _yg]; sleep 0.01; }; sleep random 30; _tgt setDamage 0; _start = position _tgt; _startX = _start select 0; _startY = _start select 1; _i = _dir; _xg = _gap * (cos _i); _yg = _gap * (sin _i); _newX = _startX + _xg; _newY = _startY + _yg; };