summaryrefslogtreecommitdiffstats
path: root/Server/FSM/missions.fsm
blob: ecc3b98a36fe30175a997e5454b80875dbb3c0c3 (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
/*%FSM<COMPILE "D:\ArmA2\FSM Editor Personal Edition\scriptedFSM.cfg, missions">*/
/*%FSM<HEAD>*/
/*
item0[] = {"Init",0,4346,-74.017166,-296.043274,15.982856,-246.043442,0.000000,"Init"};
item1[] = {"End",1,250,-198.827713,-59.197983,-108.827713,-9.198011,0.000000,"End"};
item2[] = {"Update_Time",2,250,-73.728622,-145.167450,16.271379,-95.167450,0.000000,"Update Time"};
item3[] = {"Loop",4,218,-74.092773,-224.973862,15.907227,-174.973846,0.000000,"Loop"};
item4[] = {"Gameover",4,218,-197.991501,-144.482101,-107.991493,-94.482101,0.000000,"Gameover"};
item5[] = {"Create",4,218,-73.431000,-64.188675,16.568987,-14.188683,1.000000,"Create"};
item6[] = {"Assign_a_Mission",2,250,72.904373,-65.024872,162.904373,-15.024889,0.000000,"Assign a" \n "Mission"};
item7[] = {"Skip",2,250,186.627869,-224.739502,276.627808,-174.739502,0.000000,"Skip"};
item8[] = {"_",8,218,215.894943,-49.973213,248.197006,-28.404099,0.000000,""};
link0[] = {0,3};
link1[] = {2,3};
link2[] = {2,4};
link3[] = {2,5};
link4[] = {3,2};
link5[] = {4,1};
link6[] = {5,6};
link7[] = {6,8};
link8[] = {7,3};
link9[] = {8,7};
globals[] = {0.000000,0,0,0,0,640,480,1,14,6316128,1,-348.696289,348.696289,188.145477,-327.791229,834,617,1};
window[] = {0,-1,-1,-1,-1,762,25,1438,25,1,852};
*//*%FSM</HEAD>*/
class FSM
{
  fsmName = "missions";
  class States
  {
    /*%FSM<STATE "Init">*/
    class Init
    {
      name = "Init";
      init = /*%FSM<STATEINIT""">*/"_maxmissionswest = 'WFBE_MISSIONSMAXIMUM_WEST' Call GetNamespace;" \n
       "_maxmissionseast = 'WFBE_MISSIONSMAXIMUM_EAST' Call GetNamespace;" \n
       "_randomizer = 'WFBE_MISSIONSRANDOMIZER' Call GetNamespace;" \n
       "_timeout = 'WFBE_MISSIONSTIMEOUT' Call GetNamespace;" \n
       "_canReuseAfter = 'WFBE_MISSIONSREUSABILITY' Call GetNamespace;" \n
       "_totalMissions = count('WFBE_M_CONTENT' Call GetNamespace) - 1;" \n
       "" \n
       "_lastUpdate = 0;" \n
       "_lastMissionAssignedTime = -6000;" \n
       "_lastMissionsIndex = [];" \n
       "['_WFBE_M_RUNNINGMISSIONS_WEST',0,true] Call SetNamespace;" \n
       "['_WFBE_M_RUNNINGMISSIONS_EAST',0,true] Call SetNamespace;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Loop">*/
        class Loop
        {
          priority = 0.000000;
          to="Update_Time";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!gameOver && time - _lastUpdate > 30"/*%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 "Update_Time">*/
    class Update_Time
    {
      name = "Update_Time";
      init = /*%FSM<STATEINIT""">*/"_lastUpdate = time;" \n
       "" \n
       "_runningMissionsWest = '_WFBE_M_RUNNINGMISSIONS_WEST' Call GetNamespace;" \n
       "_runningMissionsEast = '_WFBE_M_RUNNINGMISSIONS_EAST' Call GetNamespace;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Create">*/
        class Create
        {
          priority = 1.000000;
          to="Assign_a_Mission";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!gameOver && time - _lastMissionAssignedTime >= _timeout && (_runningMissionsWest < _maxmissionswest || _runningMissionsEast < _maxmissionseast)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%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_Time";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!gameOver && time - _lastUpdate > 30"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Assign_a_Mission">*/
    class Assign_a_Mission
    {
      name = "Assign_a_Mission";
      init = /*%FSM<STATEINIT""">*/"//--- Retrieve an updated version of the missions array." \n
       "_missions = 'WFBE_M_CONTENT' Call GetNamespace;" \n
       "_missionAssigned = false;" \n
       "" \n
       "//--- Retrieve a 'free' mission." \n
       "_i = -1;" \n
       "while {_i < 0} do {" \n
       "	_r = round (random _totalMissions);" \n
       "	if !(_r in _lastMissionsIndex) then {_i = _r};" \n
       "};" \n
       "" \n
       "//--- Retrieve the current mission content." \n
       "_mission = (_missions select _i);" \n
       "" \n
       "//--- Can we run it?" \n
       "_go = false;" \n
       "if ((_mission select 5) == civilian) then {if (_runningMissionsWest < _maxmissionswest && _runningMissionsEast < _maxmissionseast) then {_go = true}};" \n
       "if ((_mission select 5) == west) then {if (_runningMissionsWest < _maxmissionswest) then {_go = true}};" \n
       "if ((_mission select 5) == east) then {if (_runningMissionsEast < _maxmissionseast) then {_go = true}};" \n
       "" \n
       "if (_go) then {" \n
       "	_islandHeader = (_mission select 0) select 0;" \n
       "	//--- All" \n
       "	if (_islandHeader == '*') then {" \n
       "		_go = true;" \n
       "	} else {" \n
       "		if (_islandHeader == '!') then {" \n
       "			//--- If island not in." \n
       "			if !(worldName in (_mission select 0)) then {_go = true};" \n
       "		} else {" \n
       "			//--- If island in." \n
       "			if (worldName in (_mission select 0)) then {_go = true};" \n
       "		};" \n
       "	};" \n
       "};" \n
       "" \n
       "//--- Go?" \n
       "if (_go) then {" \n
       "	//--- Check for the mission condition (Compile it)." \n
       "	if (Call Compile (_mission select 4)) then {" \n
       "		[_mission select 2,_mission select 3,_mission select 5] ExecVM (_mission select 1);" \n
       "" \n
       "		//--- Randomize the next mission delay." \n
       "		_lastMissionAssignedTime = (time)+random(_randomizer)-random(_randomizer);" \n
       "" \n
       "		//--- Select the mission type (both, west ,east)" \n
       "		switch (_mission select 5) do {" \n
       "			case civilian: {['_WFBE_M_RUNNINGMISSIONS_WEST',_runningMissionsWest + 1, true] Call SetNamespace;['_WFBE_M_RUNNINGMISSIONS_EAST',_runningMissionsEast + 1, true] Call SetNamespace};" \n
       "			case west: {['_WFBE_M_RUNNINGMISSIONS_WEST',_runningMissionsWest + 1, true] Call SetNamespace};" \n
       "			case east: {['_WFBE_M_RUNNINGMISSIONS_EAST',_runningMissionsEast + 1, true] Call SetNamespace};" \n
       "		};" \n
       "		" \n
       "		//--- Increment Mission index (it will apply to the getter, no need to set again)." \n
       "		_mission set [3,(_mission select 3) + 1];" \n
       "" \n
       "		//--- Push (i.e limit 4, [1,2,3,4] add 5 >> [5,1,2,3])." \n
       "		for [{_z = (count _lastMissionsIndex)},{_z > 0},{_z = _z - 1}] do {" \n
       "			_lastMissionsIndex set [_z, (_lastMissionsIndex select (_z - 1))];" \n
       "		};" \n
       "		" \n
       "		//--- Resize if we're above the limit." \n
       "		_lastMissionsIndex set [0, _i];" \n
       "		if (count _lastMissionsIndex >= _canReuseAfter) then {" \n
       "			_lastMissionsIndex resize (_canReuseAfter - 1);" \n
       "		};" \n
       "	};" \n
       "};"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "_">*/
        class _
        {
          priority = 0.000000;
          to="Skip";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Skip">*/
    class Skip
    {
      name = "Skip";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Loop">*/
        class Loop
        {
          priority = 0.000000;
          to="Update_Time";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!gameOver && time - _lastUpdate > 30"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
  };
  initState="Init";
  finalStates[] =
  {
    "End",
  };
};
/*%FSM</COMPILE>*/