summaryrefslogtreecommitdiffstats
path: root/Client/FSM/updateavailableactions.fsm
blob: ca1ee4c452eb936f479605778fb18b8bff14b3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*%FSM<COMPILE "D:\ArmA2\FSM Editor Personal Edition\scriptedFSM.cfg, updateavailableactions">*/
/*%FSM<HEAD>*/
/*
item0[] = {"Init",0,4346,64.986191,-133.045959,154.986206,-83.046036,0.000000,"Init"};
item1[] = {"Update_Client_Ac",2,250,-66.836029,-56.267544,23.163887,-6.267582,0.000000,"Update Client" \n "Actions"};
item2[] = {"End",1,250,-207.023727,26.287281,-117.023697,76.287277,0.000000,"End"};
item3[] = {"Loop",4,218,65.605347,-56.267605,155.605377,-6.267574,0.000000,"Loop"};
item4[] = {"Gameover",4,218,-64.280334,28.850353,25.719648,78.850410,0.000000,"Gameover"};
link0[] = {0,3};
link1[] = {1,3};
link2[] = {1,4};
link3[] = {3,1};
link4[] = {4,2};
globals[] = {0.000000,0,0,0,0,640,480,1,38,6316128,1,-317.581665,500.648590,697.417725,-204.557556,596,657,1};
window[] = {0,-1,-1,-1,-1,802,25,1285,25,1,614};
*//*%FSM</HEAD>*/
class FSM
{
  fsmName = "updateavailableactions";
  class States
  {
    /*%FSM<STATE "Init">*/
    class Init
    {
      name = "Init";
      init = /*%FSM<STATEINIT""">*/"_lastUpdate = time;" \n
       "_txt = '';" \n
       "_handle = nil;" \n
       "_ft = 'WFBE_FASTTRAVEL' Call GetNamespace;" \n
       "_ftr = 'WFBE_FASTTRAVELRANGE' Call GetNamespace;" \n
       "_mhqbr = 'WFBE_MHQBUILDINGRANGE' Call GetNamespace;" \n
       "_pur = 'WFBE_PURCHASEUNITSRANGE' Call GetNamespace;" \n
       "_pura = 'WFBE_PURCHASEUNITSRANGEAIR' Call GetNamespace;" \n
       "_ccr = 'WFBE_COMMANDCENTERRANGE' Call GetNamespace;" \n
       "_pgr = 'WFBE_PURCHASEGEARRANGE' Call GetNamespace;" \n
       "_rptr = 'WFBE_REPAIRTRUCKRANGE' Call GetNamespace;" \n
       "_spr = 'WFBE_SERVICEPOINTRANGE' Call GetNamespace;" \n
       "_tpr = 'WFBE_TOWNBUILDPROTECTIONRANGE' Call GetNamespace;" \n
       "_tcr = 'WFBE_TOWNCAPTURERANGE' Call GetNamespace;" \n
       "_is = 'WFBE_INCOMESYSTEM' Call GetNamespace;" \n
       "_ac = 'WFBE_ARTILLERYCOMPUTER' Call GetNamespace;" \n
       "_buygearfrom = missionNamespace getVariable ""WFBE_TOWNGEAR"";" \n
       "_acenabled = false;" \n
       "" \n
       "_fastTravel = false;" \n
       "" \n
       "_commandCenter = objNull;" \n
       "" \n
       "_typeRepair = Format['WFBE_%1REPAIRTRUCKS',sideJoinedText] Call GetNamespace;" \n
       "" \n
       "//--- Keep actions updated (GUI). - changed-MrNiceGuy " \n
       "12450 cutRsc [""OptionsAvailable"",""PLAIN"",0];" \n
       "_icons = [" \n
       """Client\Images\icon_wf_building_mhq.paa"",       //mhq deployable" \n
       """Client\Images\icon_wf_building_barracks.paa"",  //barracks " \n
       """Client\Images\icon_wf_building_gear.paa"",      //gear avail" \n
       """Client\Images\icon_wf_building_lvs.paa"",       //lvsp" \n
       """Client\Images\icon_wf_building_hvs.paa"",       //hvsp" \n
       """Client\Images\icon_wf_building_air.paa"",       //helipad" \n
       """Client\Images\icon_wf_building_hangar.paa"",    //hangar" \n
       """Client\Images\icon_wf_building_repair.paa"",    //rearm | repair | refuel" \n
       """Client\Images\icon_wf_building_firstaid.paa"",  //heal " \n
       """Client\Images\icon_wf_support_fasttravel.paa"", //fast travel" \n
       """Client\Images\icon_wf_building_cc.paa"",        //command center" \n
       """Client\Images\icon_wf_building_aa_radar.paa"",  //AA radar" \n
       """Client\Images\icon_wf_building_am_radar.paa"",  //ARTY radar" \n
       """Client\Images\icon_wf_support_transport.paa"",  //transport" \n
       """Client\Images\icon_wf_support_supplydrop.paa"", //supply drop" \n
       """Client\Images\icon_wf_support_artilery.paa"",   //ARTY" \n
       """Client\Images\icon_wf_support_mortar.paa"",     //ARTY - mortar" \n
       """Client\Images\icon_wf_support_cas.paa"",        //CAS" \n
       """Client\Images\icon_wf_support_uav.paa""         //UAV" \n
       "];" \n
       "" \n
       "_buildings = (sideJoinedText) Call GetSideStructures;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Loop">*/
        class Loop
        {
          priority = 0.000000;
          to="Update_Client_Ac";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _lastUpdate > 5 || WFBE_ForceUpdate) && !gameOver"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Update_Client_Ac">*/
    class Update_Client_Ac
    {
      name = "Update_Client_Ac";
      init = /*%FSM<STATEINIT""">*/"_buildings = (sideJoinedText) Call GetSideStructures;" \n
       "_base = (sideJoinedText) Call GetSideHQ;" \n
       "_upgrades = (sideJoinedText) Call GetSideUpgrades;" \n
       "	" \n
       "_purchaseRange = if (commandInRange) then {_ccr} else {_pur};" \n
       "	" \n
       "_nearTown = [player,towns] Call SortByDistance;" \n
       "_closest = _nearTown select 0;" \n
       "" \n
       "if (!isNull(commanderTeam) && paramHighCommand) then {" \n
       "	if (commanderTeam == group player) then {" \n
       "		{if !(isNil '_x') then {if !(_x in (hcAllGroups player)) then {player HCSetGroup [_x]}}} forEach clientTeams;" \n
       "	};" \n
       "};" \n
       "" \n
       "//--- Boundaries are limited ?" \n
       "if (paramBoundaries) then {" \n
       "	_isOnMap = Call BoundariesIsOnMap;" \n
       "	if !(_isOnMap && alive player) then {" \n
       "		if !(paramBoundariesRunning) then {_handle = [] Spawn BoundariesHandleOnMap};" \n
       "	} else {" \n
       "		if !(isNil '_handle') then {terminate _handle;_handle = nil};" \n
       "		paramBoundariesRunning = false;" \n
       "	};" \n
       "};" \n
       "" \n
       "//--- Map info." \n
       "if (visibleMap) then {" \n
       "	if (!isNull commanderTeam) then {_txt = format [localize 'STR_WF_Commander',name (leader commanderTeam)]} else {_txt = format [localize 'STR_WF_Commander',localize 'STR_WF_AI']};" \n
       "	_txt = _txt + '  ' + Format [localize ""STR_WF_Income"",Call GetPlayerFunds,(sideJoined) Call GetIncome];" \n
       "	if (_is in [3,4]) then {_txt = _txt + Format["" (%1%2)"", Call Compile Format[""%1CommanderPercent"",sideJoined],""%""]};" \n
       "	if !(paramMoneyOnly) then {_txt = _txt + '  ' + localize 'STR_WF_UPGRADE_Supply' + ': '+ str((sideJoined) Call GetSideSupply)};" \n
       "	(findDisplay 12 displayCtrl 116) ctrlSetText _txt;" \n
       "};" \n
       "" \n
       "//--- HQ." \n
       "if !(isNull _base) then {hqInRange = if ((player distance _base < _mhqbr)&&(alive _base)&&(player distance _closest > _tpr)) then {true} else {false}};" \n
       "" \n
       "barracksInRange = if (isNull (['BARRACKSTYPE',_buildings,_purchaseRange,sideJoined,player] Call BuildingInRange)) then {false} else {true};" \n
       "gearInRange = if (isNull (['BARRACKSTYPE',_buildings,_pgr,sideJoined,player] Call BuildingInRange)) then {false} else {true};" \n
       "if !(gearInRange) then {" \n
       "	if (_buygearfrom in [1,2,3]) then {" \n
       "		_lookfor = switch (_buygearfrom) do { case 1:{WFCAMP}; case 2:{WFDEPOT}; case 3:{WFCAMP + WFDEPOT}; default{[]}};" \n
       "		_nObjects = nearestObjects [player, _lookfor, 5];" \n
       "		_nObject = if (count _nObjects > 0) then {_nObjects select 0} else {objNull};" \n
       "		if !(isNull _nObject) then {" \n
       "			_sideID = _nObject getVariable ""sideID"";" \n
       "			if !(isNil '_sideID') then {" \n
       "				if (!gearInRange && sideID == _sideID) then {gearInRange = true} else {gearInRange = false};" \n
       "			};" \n
       "		};" \n
       "	};" \n
       "};" \n
       "" \n
       "lightInRange = if (isNull (['LIGHTTYPE',_buildings,_purchaseRange,sideJoined,player] Call BuildingInRange)) then {false} else {true};" \n
       "heavyInRange = if (isNull (['HEAVYTYPE',_buildings,_purchaseRange,sideJoined,player] Call BuildingInRange)) then {false} else {true};" \n
       "aircraftInRange = if (isNull (['AIRCRAFTTYPE',_buildings,_purchaseRange,sideJoined,player] Call BuildingInRange)) then {false} else {true};" \n
       "serviceInRange = if (isNull (['SERVICEPOINTTYPE',_buildings,_spr,sideJoined,player] Call BuildingInRange)) then {false} else {true};" \n
       "" \n
       "if !(serviceInRange) then {" \n
       "	_checks = (getPos player) nearEntities[_typeRepair,_rptr];" \n
       "	if (count _checks > 0) then {serviceInRange = true};" \n
       "};" \n
       "" \n
       "if (paramAARadar) then {" \n
       "	_checks = [sideJoined, Format [""WFBE_%1AARADARTYPE"",sideJoinedText] Call GetNamespace,_buildings] Call GetFactories;" \n
       "	if (count _checks > 0) then {antiAirRadarInRange = true} else {antiAirRadarInRange = false};" \n
       "};" \n
       "" \n
       "//--- Town Depot." \n
       "_nObjects = nearestObjects [vehicle player, WFDEPOT,('WFBE_TOWNPURCHASERANGE' Call GetNamespace)];" \n
       "_nObject = if (count _nObjects > 0) then {_nObjects select 0} else {objNull};" \n
       "if (!isNull _nObject) then {" \n
       "	_sideID = _nObject getVariable ""sideID"";" \n
       "	if !(isNil ""_sideID"") then {" \n
       "		if (_sideID == sideID) then {if (vehicle player distance _nObject < _tcr) then {serviceInRange = true;depotInRange = true} else {depotInRange = false}};" \n
       "	};" \n
       "} else {depotInRange = false};" \n
       "" \n
       "_checks = ['COMMANDCENTERTYPE',_buildings,_ccr,sideJoined,player] Call BuildingInRange;" \n
       "_commandCenter = _checks;" \n
       "commandInRange = if (isNull _checks) then {false} else {true};" \n
       "" \n
       "//--- Airport." \n
       "if (paramHangars) then {" \n
       "	_sorted = [player,Airfields] Call SortByDistance;" \n
       "	if (count _sorted > 0) then {" \n
       "		if ((_sorted select 0) distance player < _pura && alive(_sorted select 0)) then {hangarInRange = true} else {hangarInRange = false};" \n
       "	} else {hangarInRange = false};" \n
       "};" \n
       "" \n
       "//--- Fast Travel." \n
       "if ((_ft > 0) && commandInRange) then {" \n
       "	_fastTravel = false;" \n
       "	_isDeployed = (sideJoinedText) Call GetSideHQDeployed;" \n
       "	if (_upgrades select 12 > 0) then {" \n
       "		if (player distance _base < _ftr && alive _base && _isDeployed) then {_fastTravel = true} else {" \n
       "			_closest = _nearTown select 0;" \n
       "			_sideID = _closest getVariable 'sideID';" \n
       "			if (player distance _closest < _ftr && _sideID == sideID) then {_fastTravel = true} else {" \n
       "				if (!isNull _commandCenter) then {" \n
       "					if (player distance _commandCenter < _ftr) then {_fastTravel = true};" \n
       "				};" \n
       "			};" \n
       "		};	" \n
       "	};	" \n
       "};" \n
       "" \n
       "//--- AC." \n
       "if (_ac == 1 && !_acenabled && !WF_A2_Vanilla) then {" \n
       "	if ((_upgrades select 10) == 3) then {Call Compile ""enableEngineArtillery true;"";_acenabled = true};" \n
       "};" \n
       "" \n
       "_usable = [hqInRange,barracksInRange,gearInRange,lightInRange,heavyInRange,aircraftInRange,hangarInRange,serviceInRange,serviceInRange,_fastTravel,commandInRange,antiAirRadarInRange];" \n
       "" \n
       "_c = 0;" \n
       "if (isNull ([""currentCutDisplay""] call BIS_FNC_GUIget)) then {12450 cutRsc[""OptionsAvailable"",""PLAIN"",0]};" \n
       "{" \n
       "	if (_x) then {" \n
       "		(([""currentCutDisplay""] call BIS_FNC_GUIget) DisplayCtrl (3500 + _c)) CtrlSetText (_icons select _c);" \n
       "	} else {" \n
       "		(([""currentCutDisplay""] call BIS_FNC_GUIget) DisplayCtrl (3500 + _c)) CtrlSetText """";" \n
       "	};" \n
       "	_c = _c + 1;" \n
       "}forEach _usable;" \n
       "" \n
       "if (WFBE_ForceUpdate) then {WFBE_ForceUpdate  = false};" \n
       "_lastUpdate = time;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Gameover">*/
        class Gameover
        {
          priority = 0.000000;
          to="End";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"gameOver"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Loop">*/
        class Loop
        {
          priority = 0.000000;
          to="Update_Client_Ac";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _lastUpdate > 5 || WFBE_ForceUpdate) && !gameOver"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "End">*/
    class End
    {
      name = "End";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
      };
    };
    /*%FSM</STATE>*/
  };
  initState="Init";
  finalStates[] =
  {
    "End"
  };
};
/*%FSM</COMPILE>*/