@@ -34,26 +34,28 @@ marceldev89
3434
3535private _logic = param [0 , objNull , [objNull , []]];
3636private _operation = param [1 , " " , [" " ]];
37- private _args = param [2 , objNull , [objNull , [], " " , 0 , true , false ]];
37+ private _args = param [2 , [] , [objNull , [], " " , 0 , true , false ]];
3838
3939private _result = true ;
4040
41+ diag_log format [" ###### %1: _logic: %2, _operation: %3, _args: %4" , " ALIVE_fnc_artillery" , _logic , _operation , _args ];
42+
4143switch (_operation ) do {
4244 case " init" : {
4345 _logic setVariable [" super" , SUPERCLASS];
4446 _logic setVariable [" class" , MAINCLASS];
4547
4648 // Defaults
47- _logic setVariable [" group" , grpNull ];
49+ /* _logic setVariable ["group", grpNull]; */
4850 _logic setVariable [" moveToPos" , objNull ];
49- _logic setVariable [" fireMission" , objNull ];
51+ _logic setVariable [" fireMission" , [] ];
5052 };
5153
5254 /* ***************
5355 ** PROPERTIES **
5456 ****************/
5557 case " fireMission" : {
56- if (isNull _args ) then {
58+ if (count _args == 0 ) then {
5759 _result = _logic getVariable [" fireMission" , objNull ];
5860 } else {
5961 private _position = _args param [0 , [0 ,0 ,0 ], [[]], 3 ];
@@ -87,11 +89,13 @@ switch (_operation) do {
8789 *************/
8890 case " execute" : {
8991 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 }};
9193 private _fireMission = _logic getVariable [" fireMission" , objNull ];
94+ private _fireMissionPos = [_fireMission , " position" ] call ALIVE_fnc_hashGet ;
9295 [_fireMission , " units" , _units ] call ALIVE_fnc_hashSet ;
9396 [_fireMission , " unitIndex" , 0 ] call ALIVE_fnc_hashSet ;
9497 [_fireMission , " roundsShot" , 0 ] call ALIVE_fnc_hashSet ;
98+ _units doWatch _fireMissionPos ;
9599
96100 _logic setVariable [" fireMission" , _fireMission ];
97101 };
@@ -130,7 +134,7 @@ switch (_operation) do {
130134 };
131135 case " hasFireMission" : {
132136 private _fireMission = _logic getVariable [" fireMission" , objNull ];
133- _result = (! isNull _fireMission );
137+ _result = (count _fireMission > 0 );
134138 };
135139 case " isFireMissionComplete" : {
136140 private _fireMission = _logic getVariable [" fireMission" , objNull ];
@@ -144,19 +148,21 @@ switch (_operation) do {
144148 };
145149 case " inRange" : {
146150 private _fireMission = _logic getVariable [" fireMission" , objNull ];
151+ private _position = [_fireMission , " position" ] call ALIVE_fnc_hashGet ;
152+ private _roundType = [_fireMission , " roundType" ] call ALIVE_fnc_hashGet ;
147153 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 ];
150156 };
151157 case " move" : {
152158 private _group = _logic getVariable [" group" , grpNull ];
153159 private _position = [];
154160
155- if (! isNull _args && {count _args == 3 }) then {
156- _logic setVariable [" moveToPos" , _args ];
157- _position = _args ;
158- } else {
161+ if (count _args == 0 ) then {
159162 _position = _logic getVariable [" moveToPos" , objNull ];
163+ } else {
164+ _position = _args param [0 , [0 ,0 ,0 ], [[]], 3 ];
165+ _logic setVariable [" moveToPos" , _position ];
160166 };
161167
162168 _group setVariable [" sup_artillery_inPosition" , false ];
@@ -167,8 +173,39 @@ switch (_operation) do {
167173 _waypoint setWaypointSpeed " NORMAL" ;
168174 _waypoint setWaypointStatements [
169175 " true" ,
170- " (group _this ) setVariable ['sup_artillery_inPosition', true]"
176+ " (group this ) setVariable ['sup_artillery_inPosition', true]"
171177 ];
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 ;
172209 };
173210
174211 /* *****************
@@ -194,7 +231,12 @@ switch (_operation) do {
194231 [_logic , " execute" ] call MAINCLASS;
195232 };
196233 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
198240 };
199241};
200242
0 commit comments