11waitUntil {
2- {
3- _animation = _x getVariable [" AIO_animation" , [[], [], [], [],3 + time ]];
4- _animation params [" _positions" , " _finalDirection" , [" _customCondition" , []], [" _customAnimation" , []], " _finishTime" ]; // _positions: positions to pass through;
5- _condFail = (vehicle _x ! = _x || time > _finishTime );
6- _condSuccess = true ;
7- _codeFail = {};
8- _codeSuccess = {};
9- _params = [];
10- if ! (_customCondition isEqualTo []) then {
11- _params = _customCondition select 4 ;
12- _condFail = _condFail || (_params call (_customCondition select 0 ));
13- _codeFail = _customCondition select 1 ;
14- _condSuccess = _params call (_customCondition select 2 );
15- _codeSuccess = _customCondition select 3 ;
16- };
17- if (_condFail ) then {
18- _x enableAI " MOVE" ;
19- _params call _codeFail ;
20- AIO_animatedUnits = AIO_animatedUnits - [_x ];
21- } else {
22- _x disableAI " MOVE" ;
23- _x doWatch objNull ;
24- if ! (_positions isEqualTo []) then {
25- _currentPos = getPosWorld _x ;
26- _nextPos = _positions select 0 ;
27- _x moveTo _nextPos ;
28- if (_currentPos distance2D _nextPos < ((((speed _x )/ 7.2 ) min 2 ) max 1 )) then { // _unit has reached the position
29- ((_x getVariable [" AIO_animation" , [[], []]]) select 0 ) deleteAt 0 ;
30- } else {
31- _dir = 1 ; // used only for backward move, such as dragging
32- if (_customAnimation isEqualTo []) then {
33- _x playActionNow " SlowF" ;
2+ if (isGamePaused ) then {
3+ {
4+ _animation = _x getVariable [" AIO_animation" , [[], [], [], [],3 + time ]];
5+ _animation params [" _positions" , " _finalDirection" , [" _customCondition" , []], [" _customAnimation" , []], " _finishTime" ]; // _positions: positions to pass through;
6+ _condFail = (vehicle _x ! = _x || time > _finishTime );
7+ _condSuccess = true ;
8+ _codeFail = {};
9+ _codeSuccess = {};
10+ _params = [];
11+ if ! (_customCondition isEqualTo []) then {
12+ _params = _customCondition select 4 ;
13+ _condFail = _condFail || (_params call (_customCondition select 0 ));
14+ _codeFail = _customCondition select 1 ;
15+ _condSuccess = _params call (_customCondition select 2 );
16+ _codeSuccess = _customCondition select 3 ;
17+ };
18+ if (_condFail ) then {
19+ _x enableAI " MOVE" ;
20+ _params call _codeFail ;
21+ AIO_animatedUnits = AIO_animatedUnits - [_x ];
22+ } else {
23+ _x disableAI " MOVE" ;
24+ _x doWatch objNull ;
25+ if ! (_positions isEqualTo []) then {
26+ _currentPos = getPosWorld _x ;
27+ _nextPos = _positions select 0 ;
28+ _x moveTo _nextPos ;
29+ if (_currentPos distance2D _nextPos < ((((speed _x )/ 7.2 ) min 2 ) max 1 )) then { // _unit has reached the position
30+ ((_x getVariable [" AIO_animation" , [[], []]]) select 0 ) deleteAt 0 ;
3431 } else {
35- _customAnimation params [" _anim" , " _reverse" ];
36- _dir = _reverse ;
37- _x playMoveNow _anim ;
38- };
39-
40- // this part rotates the unit
41- _watchDir = _nextPos vectorDiff _currentPos ;
42- _watchDir set [2 ,0 ];
43- _watchDir = (vectorNormalized _watchDir ) apply {_x * _dir };
44- if (_watchDir isEqualTo [0 ,0 ,0 ]) then {_watchDir = [0 ,1 ,0 ]};
45- _vecDir = vectorDir _x ;
46- _accTime = accTime ;
47- _angle = _accTime * acos (_vecDir vectorCos _watchDir );
48- _turn = 1 ;
49- if (_angle > 0 ) then {
50- _turn = [- _accTime ,_accTime ] select (((_x getRelDir _nextPos ) + - 180 * (_dir - 1 )/ 2 ) mod 360 > 180 );
51-
52- if (_angle > 5 * _accTime ) then {
53- _newDir = [_vecDir , 5 * _turn ] call BIS_fnc_rotateVector2D ;
54- _x setVectorDir _newDir ;
32+ _dir = 1 ; // used only for backward move, such as dragging
33+ if (_customAnimation isEqualTo []) then {
34+ _x playActionNow " SlowF" ;
5535 } else {
56- _x setVectorDir _watchDir ;
36+ _customAnimation params [" _anim" , " _reverse" ];
37+ _dir = _reverse ;
38+ _x playMoveNow _anim ;
5739 };
58- };
59- };
60- } else {
61- if (_customAnimation isEqualTo []) then {
62- if ! (_condSuccess ) exitWith {};
63- if (_finalDirection isEqualTo []) exitWith {
64- _x enableAI " MOVE" ;
65- _params call _codeSuccess ;
66- AIO_animatedUnits = AIO_animatedUnits - [_x ];
67- };
68- if (_finalDirection isEqualTo [0 ,0 ,0 ]) then {_finalDirection = [0 ,1 ,0 ]};
69- _vecDir = vectorDir _x ;
70- _angle = acos (_vecDir vectorCos _finalDirection );
71- if (_angle > 0 ) then {
40+
41+ // this part rotates the unit
42+ _watchDir = _nextPos vectorDiff _currentPos ;
43+ _watchDir set [2 ,0 ];
44+ _watchDir = (vectorNormalized _watchDir ) vectorMultiply _dir ;
45+ if (_watchDir isEqualTo [0 ,0 ,0 ]) then {_watchDir = [0 ,1 ,0 ]};
46+ _vecDir = vectorDir _x ;
47+ _accTime = accTime ;
48+ _angle = _accTime * acos (_vecDir vectorCos _watchDir );
7249 _turn = 1 ;
73- _vecDirX = _vecDir select 0 ;
74- _vecDirY = _vecDir select 1 ;
75- _watchDirX = _finalDirection select 0 ;
76- _watchDirY = _finalDirection select 1 ;
77- if (_watchDirY * _vecDirY >= 0 ) then {
78- if (_watchDirX >= _vecDirX ) then {_turn = - 1 } else {_turn = 1 };
79- } else {
80- if (_watchDirX * _vecDirX >= 0 ) then {if (_vecDirX >= 0 ) then {_turn = - 1 } else {_turn = 1 }} else {
81- if (abs (_watchDirX )<= abs (_vecDirX )) then {_turn = - 1 } else {_turn = 1 };
82- if (_vecDirX < 0 ) then {_turn = - 1 * _turn };
50+ if (_angle > 0 ) then {
51+ _turn = [- _accTime ,_accTime ] select (((_x getRelDir _nextPos ) + - 180 * (_dir - 1 )/ 2 ) mod 360 > 180 );
52+
53+ if (_angle > 5 * _accTime ) then {
54+ _newDir = [_vecDir , 5 * _turn ] call BIS_fnc_rotateVector2D ;
55+ _x setVectorDir _newDir ;
56+ } else {
57+ _x setVectorDir _watchDir ;
8358 };
8459 };
85- if (_vecDirY < 0 ) then {_turn = - 1 * _turn };
86- if (_angle > 5 ) then {
87- _newDir = [_vecDir , 5 * _turn ] call BIS_fnc_rotateVector2D ;
88- _x setVectorDir _newDir ;
60+ };
61+ } else {
62+ if (_customAnimation isEqualTo []) then {
63+ if ! (_condSuccess ) exitWith {};
64+ if (_finalDirection isEqualTo []) exitWith {
65+ _x enableAI " MOVE" ;
66+ _params call _codeSuccess ;
67+ AIO_animatedUnits = AIO_animatedUnits - [_x ];
68+ };
69+ if (_finalDirection isEqualTo [0 ,0 ,0 ]) then {_finalDirection = [0 ,1 ,0 ]};
70+ _vecDir = vectorDir _x ;
71+ _angle = acos (_vecDir vectorCos _finalDirection );
72+ if (_angle > 0 ) then {
73+ _turn = 1 ;
74+ _vecDirX = _vecDir select 0 ;
75+ _vecDirY = _vecDir select 1 ;
76+ _watchDirX = _finalDirection select 0 ;
77+ _watchDirY = _finalDirection select 1 ;
78+ if (_watchDirY * _vecDirY >= 0 ) then {
79+ if (_watchDirX >= _vecDirX ) then {_turn = - 1 } else {_turn = 1 };
80+ } else {
81+ if (_watchDirX * _vecDirX >= 0 ) then {if (_vecDirX >= 0 ) then {_turn = - 1 } else {_turn = 1 }} else {
82+ if (abs (_watchDirX )<= abs (_vecDirX )) then {_turn = - 1 } else {_turn = 1 };
83+ if (_vecDirX < 0 ) then {_turn = - 1 * _turn };
84+ };
85+ };
86+ if (_vecDirY < 0 ) then {_turn = - 1 * _turn };
87+ if (_angle > 5 ) then {
88+ _newDir = [_vecDir , 5 * _turn ] call BIS_fnc_rotateVector2D ;
89+ _x setVectorDir _newDir ;
90+ } else {
91+ _x setVectorDir _finalDirection ;
92+ };
8993 } else {
90- _x setVectorDir _finalDirection ;
94+ if (_condSuccess ) then {
95+ _x enableAI " MOVE" ;
96+ _params call _codeSuccess ;
97+ AIO_animatedUnits = AIO_animatedUnits - [_x ];
98+ };
9199 };
92100 } else {
93- if (_condSuccess ) then {
101+ if (_condSuccess ) exitWith {
94102 _x enableAI " MOVE" ;
95103 _params call _codeSuccess ;
96104 AIO_animatedUnits = AIO_animatedUnits - [_x ];
97105 };
106+ _anim = _customAnimation select 0 ;
107+ _x playMoveNow _anim ;
98108 };
99- } else {
100- if (_condSuccess ) exitWith {
101- _x enableAI " MOVE" ;
102- _params call _codeSuccess ;
103- AIO_animatedUnits = AIO_animatedUnits - [_x ];
104- };
105- _anim = _customAnimation select 0 ;
106- _x playMoveNow _anim ;
107109 };
108110 };
109- };
110- } forEach AIO_animatedUnits ;
111+ } forEach AIO_animatedUnits ;
112+ };
111113 false
112114};
0 commit comments