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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
/*%FSM<COMPILE "D:\ArmA2\FSM Editor Personal Edition\scriptedFSM.cfg, supplytruck">*/
/*%FSM<HEAD>*/
/*
item0[] = {"Truck_Init",0,250,-171.242203,-13.536451,-81.242249,36.463646,0.000000,"Truck Init"};
item1[] = {"Truck_End",1,250,-303.115265,388.653168,-213.115280,438.653076,0.000000,"Truck End"};
item2[] = {"Truck_is__dead_",4,218,-302.663574,272.303101,-212.663345,322.302917,1.000000,"Truck is " \n "dead?"};
item3[] = {"Global__Checks",3,250,-170.493988,177.490768,-80.494026,227.490891,0.000000,"Global" \n " Checks"};
item4[] = {"Loop",8,218,-171.007660,71.851631,-81.007713,121.851631,0.000000,"Loop"};
item5[] = {"Can__Move_",4,218,-300.051117,178.466248,-210.051086,228.466232,0.000000,"Can " \n "Move?"};
item6[] = {"Check__Locations",2,250,-299.279907,73.958237,-209.971802,123.266243,0.000000,"Check" \n " Locations"};
item7[] = {"Deliver_",4,218,-170.476105,272.373291,-80.476044,322.373322,0.000000,"Deliver?"};
item8[] = {"Delivery",2,250,-170.157013,387.966614,-80.156998,437.966614,0.000000,"Delivery"};
item9[] = {"",7,210,49.830540,409.317871,57.830544,417.317871,0.000000,""};
item10[] = {"",7,210,49.565125,92.576248,57.565128,100.576248,0.000000,""};
item11[] = {"Destination_",4,218,-53.444309,177.966080,36.555691,227.966080,0.000000,"Destination?"};
item12[] = {"Reload",2,250,-46.849068,102.598534,43.150940,152.598419,0.000000,"Reload"};
link0[] = {0,4};
link1[] = {2,1};
link2[] = {3,2};
link3[] = {3,5};
link4[] = {3,7};
link5[] = {3,11};
link6[] = {4,3};
link7[] = {5,6};
link8[] = {6,4};
link9[] = {7,8};
link10[] = {8,9};
link11[] = {9,10};
link12[] = {10,4};
link13[] = {11,12};
link14[] = {12,4};
globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-459.421387,124.502724,528.344360,-109.468002,726,906,1};
window[] = {2,-1,-1,-1,-1,921,175,1135,175,3,744};
*//*%FSM</HEAD>*/
class FSM
{
fsmName = "supplytruck";
class States
{
/*%FSM<STATE "Truck_Init">*/
class Truck_Init
{
name = "Truck_Init";
init = /*%FSM<STATEINIT""">*/"_side = _this select 0;" \n
"_sideText = str _side;" \n
"" \n
"_type = Format ['WFBE_%1SUPPLYTRUCK',_sideText] Call GetNamespace;" \n
"_crew = Format [""WFBE_%1SOLDIER"",_sideText] Call GetNamespace;" \n
"_hq = (_sideText) Call GetSideHQ;" \n
"_vehicle = [_type,(GetPos _hq),_side,true] Call CreateVehi;" \n
"_team = CreateGroup _side;" \n
"_driver = [_crew,_team,(getpos _vehicle),_side] Call CreateMan;" \n
"[_driver] AllowGetIn true;" \n
"_driver MoveInDriver _vehicle;" \n
"[Format[""WFBE_%1_AISupplyTrucks"",_sideText],(Format[""WFBE_%1_AISupplyTrucks"",_sideText] Call GetNamespace) + [_vehicle],true] Call SetNamespace;" \n
"[_vehicle,GetPos _hq,30,50,true,false,true] Call PlaceNear;" \n
"" \n
"[_sideText,'VehiclesCreated',1] Call UpdateStatistics;" \n
"[_sideText,'UnitsCreated',1] Call UpdateStatistics;" \n
"" \n
"_spt = Format[""WFBE_%1SERVICEPOINTTYPE"",_sideText] Call GetNamespace;" \n
"" \n
"_SV = 1000;" \n
"_currentSV = 0;" \n
"_maxSV = 0;" \n
"_timer = 0;" \n
"_closest = objNull;" \n
"_sp = _hq;" \n
"_lastDestination = _hq;" \n
"_isDelivering = false;" \n
"_lastCheck = time;" \n
"_lastDelivery = time;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Loop">*/
class Loop
{
priority = 0.000000;
to="Global__Checks";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"time - _lastCheck > 15"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Truck_End">*/
class Truck_End
{
name = "Truck_End";
init = /*%FSM<STATEINIT""">*/"if (alive _driver) then {_driver setDammage 1};" \n
"(_vehicle) spawn { sleep 120;if (alive _this) then {_this setDammage 1}};" \n
"[Format[""WFBE_%1_AISupplyTrucks"",_sideText],(Format[""WFBE_%1_AISupplyTrucks"",_sideText] Call GetNamespace) - [_vehicle],true] Call SetNamespace;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Global__Checks">*/
class Global__Checks
{
name = "Global__Checks";
init = /*%FSM<STATEINIT""">*/"if (fuel _vehicle < 0.4) then {_vehicle setFuel 1};" \n
"_destinations = [];" \n
"{" \n
" _locationSide = (_x getVariable ""sideID"") Call GetSideFromID;" \n
" if (_locationSide == _side) then {_destinations = _destinations + [_x]};" \n
"} forEach towns;" \n
"" \n
"_hq = (_sideText) Call GetSideHQ;" \n
"if (_vehicle Distance _hq < 70 || _vehicle Distance _sp < 70) then {_SV = 1000;_lastDelivery = time};" \n
"" \n
"_timer = _timer + 15;" \n
"if (_timer > 30) then {_isDelivering = false;_timer = 0};" \n
"if (time - _lastDelivery > 600) then {_vehicle setDammage 1};" \n
"_lastCheck = time;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Truck_is__dead_">*/
class Truck_is__dead_
{
priority = 1.000000;
to="Truck_End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!(alive _driver)||!(alive _vehicle)|| isNull _driver || isNull _vehicle || !canMove _vehicle"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Deliver_">*/
class Deliver_
{
priority = 0.000000;
to="Delivery";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"_vehicle distance _closest < 60;"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Destination_">*/
class Destination_
{
priority = 0.000000;
to="Reload";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"count _destinations < 1"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Can__Move_">*/
class Can__Move_
{
priority = 0.000000;
to="Check__Locations";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"count _destinations > 0 && !_isDelivering"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Check__Locations">*/
class Check__Locations
{
name = "Check__Locations";
init = /*%FSM<STATEINIT""">*/"_loc = [leader _team,_destinations] Call SortByDistance;" \n
"_closest = _loc select 0;" \n
"_possibleLoc = objNull;" \n
"_skip = false;" \n
"_isDelivering = true;" \n
"{" \n
" _currentSV = _x getVariable ""supplyValue"";" \n
" _maxSV = _x getVariable ""maxSupplyValue"";" \n
" if (_currentSV < _maxSV && !_skip && _x !=_lastDestination) then {_closest = _x;_skip = true};" \n
"} forEach _loc;" \n
"" \n
"_currentSV = _closest getVariable ""supplyValue"";" \n
"if (_SV <= _currentSV) then {" \n
" _skip = false;" \n
" {" \n
" _currentSV = _x getVariable ""supplyValue"";" \n
" if (_currentSV > _SV && !_skip && _x distance _vehicle < _hq distance _vehicle && _lastDestination != _x) then {_possibleLoc = _x;_skip = true};" \n
" } forEach _loc;" \n
" if (isNull _possibleLoc) then {_possibleLoc = _hq};" \n
"};" \n
"" \n
"if (!isNull _possibleLoc) then {" \n
" _closest = _possibleLoc;" \n
" if (_possibleLoc == _hq) then {" \n
" _buildings = (str _side) Call GetSideStructures;" \n
" _checks = [_side,_spt,_buildings] Call GetFactories;" \n
" if (count _checks > 0) then {" \n
" _sorted = [_vehicle,_checks] Call SortByDistance;" \n
" _nearest = _sorted select 0;" \n
" _deployed = (str _side) Call GetSideHQDeployed;" \n
" if (_nearest distance _vehicle < _vehicle distance _hq || !_deployed || getDammage _hq >= 1) then {_closest = _nearest;_sp = _nearest};" \n
" };" \n
" };" \n
"};" \n
"" \n
"driver _vehicle doMove ([GetPos _closest,10,20] Call GetRandomPosition);"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Loop">*/
class Loop
{
priority = 0.000000;
to="Global__Checks";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"time - _lastCheck > 15"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Delivery">*/
class Delivery
{
name = "Delivery";
init = /*%FSM<STATEINIT""">*/"_isDelivering = false;" \n
"_lastDestination = _closest;" \n
"if (_closest in towns) then {" \n
" _currentSV = _closest getVariable ""supplyValue"";" \n
" _maxSV = _closest getVariable ""maxSupplyValue"";" \n
" _sideDeliver = (_closest getVariable ""sideID"") Call GetSideFromID;" \n
" _upgrades = (_sideText) Call GetSideUpgrades;" \n
" _increaseOf = (Format[""WFBE_MAXSUPPLYTRUCKSSV%1"",_upgrades select 6] Call GetNamespace);" \n
" _requireChange = false;" \n
" if (_SV > _currentSV && _sideDeliver == _side) then {_currentSV = _currentSV + _increaseOf;_requireChange = true};" \n
" if (_currentSV > _maxSV) then {_currentSV = _maxSV;_requireChange = true};" \n
" if (_requireChange) then {_closest setVariable [""supplyValue"",_currentSV,true]};" \n
" _SV = _currentSV;" \n
"};" \n
"" \n
"_lastDelivery = time;" \n
"_closest = objNull;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Loop">*/
class Loop
{
priority = 0.000000;
to="Global__Checks";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"time - _lastCheck > 15"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Reload">*/
class Reload
{
name = "Reload";
init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Loop">*/
class Loop
{
priority = 0.000000;
to="Global__Checks";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"time - _lastCheck > 15"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
};
initState="Truck_Init";
finalStates[] =
{
"Truck_End"
};
};
/*%FSM</COMPILE>*/
|