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
|
/*%FSM<COMPILE "F:\ArmA2\FSM Editor Personal Edition\scriptedFSM.cfg, updatesupply">*/
/*%FSM<HEAD>*/
/*
item0[] = {"Init",0,250,-64.944939,-176.579712,25.055046,-126.579880,0.000000,"Init"};
item1[] = {"Check_Towns",2,250,-66.836029,-56.267544,23.163887,-6.267582,0.000000,"Check Towns"};
item2[] = {"End",1,250,-218.006683,15.304325,-128.006653,65.304314,0.000000,"End"};
item3[] = {"Loop",4,218,65.605347,-56.267605,155.605377,-6.267574,0.000000,"Loop"};
item4[] = {"Truck_is_Dead",4,218,-216.668854,-56.267559,-126.668869,-6.267574,1.000000,"Truck is" \n "Dead"};
item5[] = {"Truck_Check",2,4346,66.545509,15.865158,156.545563,65.865219,0.000000,"Truck Check"};
item6[] = {"Has_Driver",4,218,-66.545601,15.865162,23.454397,65.865189,0.000000,"Has Driver"};
item7[] = {"_",8,218,-37.459465,-108.411957,-3.868937,-87.498108,0.000000,""};
link0[] = {0,7};
link1[] = {1,3};
link2[] = {1,4};
link3[] = {1,6};
link4[] = {3,1};
link5[] = {4,2};
link6[] = {5,3};
link7[] = {6,5};
link8[] = {7,1};
globals[] = {0.000000,0,0,0,0,640,480,1,29,6316128,1,-395.307037,395.306915,167.465607,-285.572937,588,519,1};
window[] = {0,-1,-1,-1,-1,745,56,1316,111,1,606};
*//*%FSM</HEAD>*/
class FSM
{
fsmName = "updatesupply";
class States
{
/*%FSM<STATE "Init">*/
class Init
{
name = "Init";
init = /*%FSM<STATEINIT""">*/"_vehicle = _this select 0;" \n
"_side = _this select 1;" \n
"_driver = driver _vehicle;" \n
"_lastDriver = driver _vehicle;" \n
"" \n
"_SV = 1000;" \n
"_currentSV = 0;" \n
"_maxSV = 0;" \n
"_timer = 0;" \n
"_exit = false;" \n
"_canDeliver = false;" \n
"_hq = (sideJoinedText) Call GetSideHQ;" \n
"_lastDestination = _hq;" \n
"_delRange = 'WFBE_DELIVERYRANGE' Call GetNamespace;" \n
"_fpsp = 'WFBE_FUNDSPERSUPPLYPOINT' Call GetNamespace;" \n
"_spsp = 'WFBE_SCOREPERSUPPLYPOINT' Call GetNamespace;" \n
"" \n
"_lastUpdate = time;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "_">*/
class _
{
priority = 0.000000;
to="Check_Towns";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "Check_Towns">*/
class Check_Towns
{
name = "Check_Towns";
init = /*%FSM<STATEINIT""">*/"if (!alive _vehicle || isNull _vehicle) then {_exit = true}; " \n
"" \n
"_driver = driver _vehicle;" \n
"_hasDriver = false;" \n
"_playerInVehicle = false;" \n
"if (!IsNull _driver) then {" \n
" if (Alive _driver) then {_hasDriver = true};" \n
" if (isPlayer _driver) then {_playerInVehicle = true};" \n
"};" \n
"" \n
"_lastDriver = _driver;" \n
"_lastUpdate = time;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Truck_is_Dead">*/
class Truck_is_Dead
{
priority = 1.000000;
to="End";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"gameOver || _exit"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Has_Driver">*/
class Has_Driver
{
priority = 0.000000;
to="Truck_Check";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"_hasDriver && !gameOver && !_exit"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "Loop">*/
class Loop
{
priority = 0.000000;
to="Check_Towns";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"time - _lastUpdate > 3 && !gameOver && !_exit"/*%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>*/
/*%FSM<STATE "Truck_Check">*/
class Truck_Check
{
name = "Truck_Check";
init = /*%FSM<STATEINIT""">*/"if (!isNull _driver) then {" \n
" if (_driver != _lastDriver) then {" \n
" _lastDriver = _driver;" \n
" if (_playerInVehicle) then {" \n
" _txt = localize ""STR_WF_INFO_Supply_Full"";" \n
" if (_SV != 1000) then {_txt = Format [localize ""STR_WF_INFO_Supply_Status"",_SV]};" \n
" hint _txt;" \n
" };" \n
" };" \n
"};" \n
" " \n
"_hq = (sideJoinedText) Call GetSideHQ;" \n
"_isDeployed = (sideJoinedText) Call GetSideHQDeployed;" \n
"if (_vehicle Distance _hq < 70 && _SV != 1000 && getDammage _hq < 1 && _isDeployed) then {_SV = 1000;_vehicle setFuel 1;_lastDestination = _hq;if (_playerInVehicle) then {hint (localize ""STR_WF_INFO_Supply_Full"")}};" \n
"" \n
"if (_SV != 1000) then {" \n
" _buildings = (sideJoinedText) Call GetSideStructures;" \n
" _checks = [sideJoined,Format [""WFBE_%1SERVICEPOINTTYPE"",sideJoinedText] Call GetNamespace,_buildings] Call GetFactories;" \n
" if (count _checks > 0) then {" \n
" _sorted = [_vehicle,_checks] Call SortByDistance;" \n
" _nearest = _sorted select 0;" \n
" if (_vehicle distance _nearest < 70) then {_SV = 1000;_vehicle setFuel 1;_lastDestination = _nearest;if (_playerInVehicle) then {hint (localize ""STR_WF_INFO_Supply_Full"")}};" \n
" };" \n
"};" \n
"" \n
"_loc = [_vehicle,towns] Call SortByDistance;" \n
"_closest = _loc select 0;" \n
"_name = _closest getVariable ""name"";" \n
"_locationSide = (_closest getVariable ""sideID"") Call GetSideFromID;" \n
"" \n
"_canDeliver = if (_locationSide == _side) then {true} else {false};" \n
"" \n
"if ((_vehicle Distance _closest < _delRange)&&(_canDeliver)&&(_lastDestination != _closest)) then {" \n
" _lastDestination = _closest;" \n
" _currentSV = _closest getVariable ""supplyValue"";" \n
" _maxSV = _closest getVariable ""maxSupplyValue"";" \n
" if (_SV > _currentSV) then {" \n
" if (_currentSV != _maxSV) then {" \n
" _upgrades = (sideJoinedText) Call GetSideUpgrades;" \n
" _increaseOf = (Format[""WFBE_MAXSUPPLYTRUCKSSV%1"",_upgrades select 6] Call GetNamespace);" \n
" _currentSV = _currentSV + _increaseOf;" \n
" if (_currentSV > _maxSV) then {_currentSV = _maxSV};" \n
" _closest setVariable [""supplyValue"",_currentSV,true];" \n
" };" \n
" _SV = _currentSV;" \n
" _funds = _SV * _fpsp * 2;" \n
" hint Format[localize ""STR_WF_INFO_Supply_Deliver"",_name,_SV,_maxSV,_funds];" \n
" _funds Call ChangePlayerFunds;" \n
" } else {" \n
" hint Format[localize ""STR_WF_INFO_Supply_Equal"",_name,_currentSV,_maxSV];" \n
" _SV = _currentSV;" \n
" };" \n
" WFBE_RequestChangeScore = ['SRVFNCREQUESTCHANGESCORE',[player,score player + _spsp]];" \n
" publicVariable 'WFBE_RequestChangeScore';" \n
" if (isHostedServer) then {['SRVFNCREQUESTCHANGESCORE',[player,score player + _spsp]] Spawn HandleSPVF};" \n
"};"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "Loop">*/
class Loop
{
priority = 0.000000;
to="Check_Towns";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"time - _lastUpdate > 3 && !gameOver && !_exit"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
};
initState="Init";
finalStates[] =
{
"End"
};
};
/*%FSM</COMPILE>*/
|