11#include < \x\alive\addons\sup_artillery\script_component.hpp>
2- SCRIPT(CAS );
2+ SCRIPT(Artillery );
33
44/* ----------------------------------------------------------------------------
5- Function: ALIVE_fnc_CQB
5+ Function: ALIVE_fnc_Artillery
66Description:
7- XXXXXXXXXX
7+ Artillery module.
88
99Parameters:
1010Nil or Object - If Nil, return a new instance. If Object, reference an existing instance.
@@ -21,37 +21,182 @@ Boolean - enabled - Enabled or disable module
2121Parameters:
2222none
2323
24- Description:
25- CQB Module! Detailed description to follow
26-
2724Examples:
28- [_logic, "factions", ["OPF_F"] call ALiVE_fnc_CQB;
29- [_logic, "houses", _nonStrategicHouses] call ALiVE_fnc_CQB;
30- [_logic, "spawnDistance", 500] call ALiVE_fnc_CQB;
31- [_logic, "active", true] call ALiVE_fnc_CQB;
3225
3326See Also:
34- - <ALIVE_fnc_CQBInit>
3527
3628Author:
37- Wolffy, Highhead
29+ marceldev89
3830---------------------------------------------------------------------------- */
3931
40- #define SUPERCLASS nil
41-
42- private [" _logic" ," _operation" ," _args" ];
43-
44- PARAMS_1(_logic );
45- DEFAULT_PARAM(1 ,_operation ," " );
46- DEFAULT_PARAM(2 ,_args ,nil );
32+ #define SUPERCLASS ALIVE_fnc_baseClass
33+ #define MAINCLASS ALIVE_fnc_artillery
34+
35+ private _logic = param [0 , objNull , [objNull , []]];
36+ private _operation = param [1 , " " , [" " ]];
37+ private _args = param [2 , objNull , [objNull , [], " " , 0 , true , false ]];
38+
39+ private _result = true ;
40+
41+ switch (_operation ) do {
42+ case " init" : {
43+ [] call ALIVE_fnc_artillery_init ;
44+ };
45+
46+ /* ***************
47+ ** PROPERTIES **
48+ ****************/
49+ case " fireMission" : {
50+ if (isNull _args ) then {
51+ _result = [_logic , " fireMission" ] call ALIVE_fnc_hashGet ;
52+ } else {
53+ private _position = _args param [0 , [0 ,0 ,0 ], [[]], 3 ];
54+ private _roundType = _args param [1 , " " , [" " ]];
55+ private _roundCount = _args param [2 , 1 , [1 ]];
56+ private _delay = _args param [3 , 5 , [1 ]];
57+ private _dispersion = _args param [4 , 50 , [1 ]];
58+
59+ private _fireMission = [] call ALIVE_fnc_hashCreate ;
60+ [_fireMission , " position" , _position ] call ALIVE_fnc_hashSet ;
61+ [_fireMission , " roundType" , _roundType ] call ALIVE_fnc_hashSet ;
62+ [_fireMission , " roundCount" , _roundCount ] call ALIVE_fnc_hashSet ;
63+ [_fireMission , " delay" , _delay ] call ALIVE_fnc_hashSet ;
64+ [_fireMission , " dispersion" , _dispersion ] call ALIVE_fnc_hashSet ;
65+ // Defaults
66+ [_fireMission , " units" , []] call ALIVE_fnc_hashSet ;
67+ [_fireMission , " unitIndex" , - 1 ] call ALIVE_fnc_hashSet ;
68+ [_fireMission , " roundsShot" , - 1 ] call ALIVE_fnc_hashSet ;
69+ [_fireMission , " nextRoundTime" , - 1 ] call ALIVE_fnc_hashSet ;
70+
71+ [_logic , " fireMission" , _fireMission ] call ALIVE_fnc_hashSet ;
72+ };
73+ };
74+ case " position" : {
75+ private _group = [_logic , " group" ] call ALIVE_fnc_hashGet ;
76+ _result = position (leader _group );
77+ };
78+
79+ /* ************
80+ ** METHODS **
81+ *************/
82+ case " execute" : {
83+ private _group = [_logic , " group" ] call ALIVE_fnc_hashGet ;
84+ private _units = (units _group ) select {vehicle _x ! = _x && {gunner _x == _x }};
85+ private _fireMission = [_logic , " fireMission" ] call ALIVE_fnc_hashGet ;
86+ [_fireMission , " units" , _units ] call ALIVE_fnc_hashSet ;
87+ [_fireMission , " unitIndex" , 0 ] call ALIVE_fnc_hashSet ;
88+ [_fireMission , " roundsShot" , 0 ] call ALIVE_fnc_hashSet ;
89+ [_logic , " fireMission" , _fireMission ] call ALIVE_fnc_hashSet ; // TODO: Is this needed?
90+ };
91+ case " fire" : {
92+ private _fireMission = [_logic , " fireMission" ] call ALIVE_fnc_hashGet ;
93+ private _roundsShot = [_fireMission , " roundsShot" ] call ALIVE_fnc_hashGet ;
94+ private _units = [_fireMission , " units" ] call ALIVE_fnc_hashGet ;
95+ private _unitIndex = [_fireMission , " unitIndex" ] call ALIVE_fnc_hashGet ;
96+ private _unit = _units select _unitIndex ;
97+ private _position = [_fireMission , " position" ] call ALIVE_fnc_hashGet ;
98+ private _roundType = [_fireMission , " roundType" ] call ALIVE_fnc_hashGet ;
99+ private _delay = [_fireMission , " delay" ] call ALIVE_fnc_hashGet ;
100+
101+ _unit doArtilleryFire [
102+ _position ,
103+ _roundType ,
104+ 1
105+ ];
106+
107+ if ((_unitIndex + 1 ) > ((count _units ) - 1 )) then {
108+ _unitIndex = 0 ;
109+ } else {
110+ _unitIndex = _unitIndex + 1 ;
111+ };
112+
113+ [_fireMission , " nextRoundTime" , time + _delay ] call ALIVE_fnc_hashSet ;
114+ [_fireMission , " unitIndex" , _unitIndex ] call ALIVE_fnc_hashSet ;
115+ [_fireMission , " roundsShot" , _roundsShot + 1 ] call ALIVE_fnc_hashSet ;
116+ [_logic , " fireMission" , _fireMission ] call ALIVE_fnc_hashSet ; // TODO: Is this needed?
117+ };
118+ case " fireNextRound" : {
119+ private _fireMission = [_logic , " fireMission" ] call ALIVE_fnc_hashGet ;
120+ private _nextRoundTime = [_fireMission , " nextRoundTime" ] call ALIVE_fnc_hashGet ;
121+ _result = (time >= _nextRoundTime );
122+ };
123+ case " hasFireMission" : {
124+ private _fireMission = [_logic , " fireMission" ] call ALIVE_fnc_hashGet ;
125+ _result = (count _fireMission == 3 );
126+ };
127+ case " isFireMissionComplete" : {
128+ private _fireMission = [_logic , " fireMission" ] call ALIVE_fnc_hashGet ;
129+ private _roundCount = [_fireMission , " roundCount" ] call ALIVE_fnc_hashGet ;
130+ private _roundsShot = [_fireMission , " roundsShot" ] call ALIVE_fnc_hashGet ;
131+ _result = (_roundsShot >= _roundCount );
132+ };
133+ case " inPosition" : {
134+ private _group = [_logic , " group" ] call ALIVE_fnc_hashGet ;
135+ _result = _group getVariable [" sup_artillery_inPosition" , false ];
136+ };
137+ case " inRange" : {
138+ private _fireMission = [_logic , " fireMission" ] call ALIVE_fnc_hashGet ;
139+ private _group = [_logic , " group" ] call ALIVE_fnc_hashGet ;
140+ private _units = (units _group ) select {vehicle _x ! = _x && {gunner _x == _x }};
141+ _result = _position inRangeOfArtillery [_units , _fireMission select 1 ];
142+ };
143+ case " move" : {
144+ private _group = [_logic , " group" ] call ALIVE_fnc_hashGet ;
145+ private _position = [];
146+
147+ if (! isNull _args && {count _args == 3 }) then {
148+ [_logic , " moveToPos" , _args ] call ALIVE_fnc_hashSet ;
149+ _position = _args ;
150+ } else {
151+ _position = [_logic , " moveToPos" ] call ALIVE_fnc_hashGet ;
152+ };
153+
154+ private _waypoint = _group addWaypoint [_position , 0 ];
155+ _waypoint setWaypointType " MOVE" ;
156+ _waypoint setWaypointBehaviour " SAFE" ;
157+ _waypoint setWaypointSpeed " NORMAL" ;
158+ _waypoint setWaypointStatements [
159+ " true" ,
160+ " (group _this) setVariable ['sup_artillery_inPosition', true]"
161+ ];
162+
163+ _group setVariable [" sup_artillery_inPosition" , false ];
164+ };
165+
166+ /* *****************
167+ ** STATEMACHINE **
168+ ******************/
169+ case " onIdle" : {
170+ private _group = [_logic , " group" ] call ALIVE_fnc_hashGet ;
171+ _group setVariable [" sup_artillery_inPosition" , true ];
172+ [_logic , " moveToPos" , objNull ] call ALIVE_fnc_hashSet ;
173+
174+ };
175+ case " onActive" : {
176+ if (! ([_logic , " inRange" ] call MAINCLASS)) then {
177+ [_logic , " moveToPos" , [0 ,0 ,0 ]] call ALIVE_fnc_hashSet ; // TODO: Figure out best firing position
178+ };
179+ };
180+ case " onFire" : {
181+ [_logic , " fire" ] call MAINCLASS;
182+ };
183+ case " onMove" : {
184+ [_logic , " move" ] call MAINCLASS;
185+ };
186+ case " onExecute" : {
187+ [_logic , " execute" ] call MAINCLASS;
188+ };
189+ case " onReturnToBase" : {
190+ [_logic , " move" , [0 ,0 ,0 ]] call MAINCLASS; // TODO: Find (best) RTB position
191+ };
192+ };
193+
194+ // TODO: Give this legacy stuff a place
47195ALIVE_coreLogic = _logic ;
48196_position = getposATL ALIVE_coreLogic;
49197_callsign = _logic getvariable [" artillery_callsign" ," EAGLE ONE" ];
50198_type = _logic getvariable [" artillery_type" ," B_Heli_Attack_01_F" ];
51199_ordnace = _logic getvariable [" artillery_ordnace" ,[" HE" , 30 ]];
52200 ARTYPOS = _position ; PublicVariable " ARTYPOS" ;
53201
54-
55-
56-
57-
202+ _result ;
0 commit comments