@@ -34,26 +34,28 @@ marceldev89
34
34
35
35
private _logic = param [0 , objNull , [objNull , []]];
36
36
private _operation = param [1 , " " , [" " ]];
37
- private _args = param [2 , objNull , [objNull , [], " " , 0 , true , false ]];
37
+ private _args = param [2 , [] , [objNull , [], " " , 0 , true , false ]];
38
38
39
39
private _result = true ;
40
40
41
+ diag_log format [" ###### %1: _logic: %2, _operation: %3, _args: %4" , " ALIVE_fnc_artillery" , _logic , _operation , _args ];
42
+
41
43
switch (_operation ) do {
42
44
case " init" : {
43
45
_logic setVariable [" super" , SUPERCLASS];
44
46
_logic setVariable [" class" , MAINCLASS];
45
47
46
48
// Defaults
47
- _logic setVariable [" group" , grpNull ];
49
+ /* _logic setVariable ["group", grpNull]; */
48
50
_logic setVariable [" moveToPos" , objNull ];
49
- _logic setVariable [" fireMission" , objNull ];
51
+ _logic setVariable [" fireMission" , [] ];
50
52
};
51
53
52
54
/* ***************
53
55
** PROPERTIES **
54
56
****************/
55
57
case " fireMission" : {
56
- if (isNull _args ) then {
58
+ if (count _args == 0 ) then {
57
59
_result = _logic getVariable [" fireMission" , objNull ];
58
60
} else {
59
61
private _position = _args param [0 , [0 ,0 ,0 ], [[]], 3 ];
@@ -87,11 +89,13 @@ switch (_operation) do {
87
89
*************/
88
90
case " execute" : {
89
91
private _group = _logic getVariable [" group" , grpNull ];
90
- private _units = (units _group ) select {vehicle _x ! = _x && {gunner _x == _x }};
92
+ private _units = (units _group ) select {vehicle _x ! = _x && {gunner ( vehicle _x ) == _x }};
91
93
private _fireMission = _logic getVariable [" fireMission" , objNull ];
94
+ private _fireMissionPos = [_fireMission , " position" ] call ALIVE_fnc_hashGet ;
92
95
[_fireMission , " units" , _units ] call ALIVE_fnc_hashSet ;
93
96
[_fireMission , " unitIndex" , 0 ] call ALIVE_fnc_hashSet ;
94
97
[_fireMission , " roundsShot" , 0 ] call ALIVE_fnc_hashSet ;
98
+ _units doWatch _fireMissionPos ;
95
99
96
100
_logic setVariable [" fireMission" , _fireMission ];
97
101
};
@@ -130,7 +134,7 @@ switch (_operation) do {
130
134
};
131
135
case " hasFireMission" : {
132
136
private _fireMission = _logic getVariable [" fireMission" , objNull ];
133
- _result = (! isNull _fireMission );
137
+ _result = (count _fireMission > 0 );
134
138
};
135
139
case " isFireMissionComplete" : {
136
140
private _fireMission = _logic getVariable [" fireMission" , objNull ];
@@ -144,19 +148,21 @@ switch (_operation) do {
144
148
};
145
149
case " inRange" : {
146
150
private _fireMission = _logic getVariable [" fireMission" , objNull ];
151
+ private _position = [_fireMission , " position" ] call ALIVE_fnc_hashGet ;
152
+ private _roundType = [_fireMission , " roundType" ] call ALIVE_fnc_hashGet ;
147
153
private _group = _logic getVariable [" group" , grpNull ];
148
- private _units = (units _group ) select {vehicle _x ! = _x && {gunner _x == _x }};
149
- _result = _position inRangeOfArtillery [_units , _fireMission select 1 ];
154
+ private _units = (units _group ) select {vehicle _x ! = _x && {gunner ( vehicle _x ) == _x }};
155
+ _result = _position inRangeOfArtillery [_units , _roundType ];
150
156
};
151
157
case " move" : {
152
158
private _group = _logic getVariable [" group" , grpNull ];
153
159
private _position = [];
154
160
155
- if (! isNull _args && {count _args == 3 }) then {
156
- _logic setVariable [" moveToPos" , _args ];
157
- _position = _args ;
158
- } else {
161
+ if (count _args == 0 ) then {
159
162
_position = _logic getVariable [" moveToPos" , objNull ];
163
+ } else {
164
+ _position = _args param [0 , [0 ,0 ,0 ], [[]], 3 ];
165
+ _logic setVariable [" moveToPos" , _position ];
160
166
};
161
167
162
168
_group setVariable [" sup_artillery_inPosition" , false ];
@@ -167,8 +173,39 @@ switch (_operation) do {
167
173
_waypoint setWaypointSpeed " NORMAL" ;
168
174
_waypoint setWaypointStatements [
169
175
" true" ,
170
- " (group _this ) setVariable ['sup_artillery_inPosition', true]"
176
+ " (group this ) setVariable ['sup_artillery_inPosition', true]"
171
177
];
178
+ diag_log format [" _group: %1, _position: %2, _waypoint: %3" , _group , _position , _waypoint ];
179
+ };
180
+ case " spawn" : {
181
+ private _position = position _logic ;
182
+ private _type = _logic getVariable [" artillery_type" , " " ];
183
+ private _callsign = _logic getVariable [" artillery_callsign" , " " ];
184
+ private _code = _logic getVariable [" artillery_code" , " " ];
185
+
186
+ private _side = _type call ALIVE_fnc_classSide ;
187
+ private _group = createGroup _side ;
188
+
189
+ for " _i" from 0 to 2 do {
190
+ // TODO: Spawn vehicles in proper fancy formation (see CfgFormations)
191
+ private _vehiclePosition = _position getPos [15 * _i , (getDir _logic ) * _i ];
192
+ private _vehicle = createVehicle [_type , _vehiclePosition , [], 0 , " NONE" ];
193
+ _vehicle setDir (getDir _logic );
194
+ _vehicle lock true ;
195
+ [_vehicle , _group ] call BIS_fnc_spawnCrew ;
196
+ };
197
+
198
+ _group setVariable [" logic" , _logic ];
199
+ _logic setVariable [" group" , _group ];
200
+
201
+ if (isNil " ALIVE_sup_artillery_stateMachine" ) then {
202
+ ALIVE_sup_artillery_stateMachine_list = [];
203
+ ALIVE_sup_artillery_stateMachine = [
204
+ configFile >> " ArtilleryStateMachine"
205
+ ] call CBA_statemachine_fnc_createFromConfig ;
206
+ };
207
+
208
+ ALIVE_sup_artillery_stateMachine_list pushBack _logic ;
172
209
};
173
210
174
211
/* *****************
@@ -194,7 +231,12 @@ switch (_operation) do {
194
231
[_logic , " execute" ] call MAINCLASS;
195
232
};
196
233
case " onReturnToBase" : {
197
- [_logic , " move" , position _logic ] call MAINCLASS; // TODO: Find (best) RTB position
234
+ private _group = _logic getVariable [" group" , grpNull ];
235
+ private _units = (units _group ) select {vehicle _x ! = _x && {gunner (vehicle _x ) == _x }};
236
+ _units doWatch objNull ;
237
+
238
+ _logic setVariable [" fireMission" , []];
239
+ [_logic , " move" , [position _logic ]] call MAINCLASS; // TODO: Find (best) RTB position
198
240
};
199
241
};
200
242
0 commit comments