-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sqf
443 lines (351 loc) · 14.4 KB
/
init.sqf
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
private ["_useRevive"];
private ["_volume", "_dynamicWeather", "_isJipPlayer"];
private ["_showIntro", "_showPlayerMapAndCompass", "_fog", "_playerIsImmortal", "_playersEnteredWorld"];
call compileFinal preprocessFileLineNumbers "FAR_revive\FAR_revive_init.sqf";
addHijackAction =
{
private ["_object", "_screenMsg", "_scriptToCall"];
_object = _this select 0;
_screenMsg = _this select 1;
_scriptToCall = _this select 2;
if (isNull _object) exitWith {};
_object addaction [_screenMsg, _scriptToCall, [], 1.5, true, false, "", "_this distance _target <= 3"];
};
addHealAtMedicalBuildingAction =
{
private ["_object", "_screenMsg", "_scriptToCall"];
_object = _this select 0;
_screenMsg = _this select 1;
_scriptToCall = _this select 2;
if (isNull _object) exitWith {};
_object addaction [_screenMsg, _scriptToCall, [], 1.5, true, false, "", "(_this distance _target < 4) && (damage _this > 0.0)"];
};
_isJipPlayer = false;
if (!isServer && isNull player) then
{
_isJipPlayer = true;
};
// Developer Variables
_useRevive = true;
_showIntro = true;
// Debug Variables
_showPlayerMapAndCompass = false;
_playerIsImmortal = false; // Only works for unit p1
// Initialization
drn_var_Escape_firstPreloadDone = false;
drn_var_Escape_playerEnteredWorld = false;
onPreloadFinished {
if (!drn_var_Escape_firstPreloadDone) then {
drn_var_Escape_firstPreloadDone = true;
if (!isNull player) then {
drn_var_Escape_playerEnteredWorld = true;
removeAllWeapons player;
removeAllItems player;
};
};
};
if (isServer) then {
drn_var_Escape_hoursSkipped = 0;
if (isMultiplayer) then {
private ["_hour"];
if (paramsArray select 2 == 24) then {
_hour = floor random 24;
}
else {
_hour = paramsArray select 2;
};
drn_var_Escape_hoursSkipped = _hour - (date select 3);
publicVariable "drn_var_Escape_hoursSkipped";
setDate [date select 0, date select 1, date select 2, _hour, 0];
};
};
_volume = soundVolume;
enableSaving [true, true];
0 fadeSound 0;
enableRadio false;
0 cutText ["", "BLACK FADED"];
if (isDedicated && _useRevive) then {
//server execVM "revive_init.sqf";
};
if (!isDedicated) then {
waitUntil {!isNull player};
player setCaptive true;
};
if (_playerIsImmortal) then {
p1 allowDamage false;
};
// Initialization
drn_arr_JipSpawnPos = [];
call compile preprocessFileLineNumbers "Scripts\DRN\CommonLib\CommonLib.sqf";
call drn_fnc_CL_InitParams;
call compile preprocessFileLineNumbers "Scripts\Escape\Functions.sqf";
call compile preprocessFileLineNumbers "Scripts\Escape\AIskills.sqf";
[_isJipPlayer] call compile preprocessFileLineNumbers "Briefing.sqf";
call compile preprocessFileLineNumbers "scripts\Init_UPSMON.sqf";
//_dynamicWeather = (paramsArray select 3);
execVM "Scripts\Escape\RandomWeather.sqf";
setTerrainGrid (paramsArray select 4);
/*switch (_dynamicWeather) do {
case 0: { execVM "Scripts\Escape\StaticWeatherEffects.sqf"; }; // Dynamic weather off
case 1: { [0.1, 0.1, 0, [random 8, random 8]] execVM "Scripts\DRN\DynamicWeatherEffects\DynamicWeatherEffects.sqf"; }; // Dynamic weather (start clear)
default {
// Dynamic weather (start random)
if (random 100 < 50) then {
_fog = random 0.2;
}
else {
_fog = random 0.9;
};
[_fog] execVM "Scripts\DRN\DynamicWeatherEffects\DynamicWeatherEffects.sqf";
};
};*/
// Server Initialization
if (isServer) then {
execVM "ServerInitialization.sqf";
if (isDedicated) exitWith {};
};
waitUntil {drn_var_Escape_playerEnteredWorld};
// Report to all other clients (and server) that player has entered the world
if (isNil "drn_var_Escape_syncronizationDone") then {
switch (str player) do {
case "p1": {
drn_var_Escape_playerEnteredWorld_p1 = true;
publicVariable "drn_var_Escape_playerEnteredWorld_p1";
};
case "p2": {
drn_var_Escape_playerEnteredWorld_p2 = true;
publicVariable "drn_var_Escape_playerEnteredWorld_p2";
};
case "p3": {
drn_var_Escape_playerEnteredWorld_p3 = true;
publicVariable "drn_var_Escape_playerEnteredWorld_p3";
};
case "p4": {
drn_var_Escape_playerEnteredWorld_p4 = true;
publicVariable "drn_var_Escape_playerEnteredWorld_p4";
};
case "p5": {
drn_var_Escape_playerEnteredWorld_p5 = true;
publicVariable "drn_var_Escape_playerEnteredWorld_p5";
};
case "p6": {
drn_var_Escape_playerEnteredWorld_p6 = true;
publicVariable "drn_var_Escape_playerEnteredWorld_p6";
};
case "p7": {
drn_var_Escape_playerEnteredWorld_p7 = true;
publicVariable "drn_var_Escape_playerEnteredWorld_p7";
};
case "p8": {
drn_var_Escape_playerEnteredWorld_p8 = true;
publicVariable "drn_var_Escape_playerEnteredWorld_p8";
};
default {
player sideChat "This should never happen!";
};
};
_playersEnteredWorld = 1;
while {(count call drn_fnc_Escape_GetPlayers != _playersEnteredWorld)} do {
if (_showIntro) then {
0 cutText ["", "BLACK FADED"];
};
sleep 0.5;
_playersEnteredWorld = 0;
if (!isNil "drn_var_Escape_playerEnteredWorld_p1") then {
_playersEnteredWorld = _playersEnteredWorld + 1;
};
if (!isNil "drn_var_Escape_playerEnteredWorld_p2") then {
_playersEnteredWorld = _playersEnteredWorld + 1;
};
if (!isNil "drn_var_Escape_playerEnteredWorld_p3") then {
_playersEnteredWorld = _playersEnteredWorld + 1;
};
if (!isNil "drn_var_Escape_playerEnteredWorld_p4") then {
_playersEnteredWorld = _playersEnteredWorld + 1;
};
if (!isNil "drn_var_Escape_playerEnteredWorld_p5") then {
_playersEnteredWorld = _playersEnteredWorld + 1;
};
if (!isNil "drn_var_Escape_playerEnteredWorld_p6") then {
_playersEnteredWorld = _playersEnteredWorld + 1;
};
if (!isNil "drn_var_Escape_playerEnteredWorld_p7") then {
_playersEnteredWorld = _playersEnteredWorld + 1;
};
if (!isNil "drn_var_Escape_playerEnteredWorld_p8") then {
_playersEnteredWorld = _playersEnteredWorld + 1;
};
};
};
drn_var_Escape_syncronizationDone = true;
publicVariable "drn_var_Escape_syncronizationDone";
waitUntil {!isNil "drn_var_Escape_FunctionsInitializedOnServer"};
[] call drn_fnc_Escape_AskForTimeSynchronization;
// Player Initialization
removeAllWeapons player;
removeAllItems player;
player addWeapon "ItemRadio";
player addWeapon "ItemWatch";
player addWeapon "ItemMap";
drn_fnc_Escape_DisableLeaderSetWaypoints = {
if (!visibleMap) exitwith {};
{
player groupSelectUnit [_x, false];
} foreach units group player;
};
// If multiplayer, then disable the cheating "move to" waypoint feature.
if (isMultiplayer) then {
[] spawn {
waitUntil {!isNull(findDisplay 46)};
// (findDisplay 46) displayAddEventHandler ["KeyDown","_nil=[_this select 1] call drn_fnc_Escape_DisableLeaderSetWaypoints"];
(findDisplay 46) displayAddEventHandler ["MouseButtonDown","_nil=[_this select 1] call drn_fnc_Escape_DisableLeaderSetWaypoints"];
};
};
if (!isMultiplayer) then {
{
/*
_x setCaptive true;
removeAllWeapons _x;
removeAllItems _x;
_x addWeapon "ItemRadio";
_x addWeapon "ItemWatch";
_x addWeapon "ItemMap";
*/
if (_x != p1) then {
deleteVehicle _x;
};
} foreach units group player;
};
// Run start sequence for all players
if (!isNull player) then {
[_volume, _showIntro, _showPlayerMapAndCompass, _isJipPlayer, _useRevive] spawn {
private ["_volume", "_showIntro", "_showPlayerMapAndCompass", "_isJipPlayer", "_useRevive"];
private ["_marker"];
_volume = _this select 0;
_showIntro = _this select 1;
_showPlayerMapAndCompass = _this select 2;
_isJipPlayer = _this select 3;
_useRevive = _this select 4;
waitUntil {!(isNil "drn_startPos")};
waitUntil {!(isNil "drn_fenceIsCreated")};
if (_isJipPlayer) then {
private ["_anotherPlayer"];
_anotherPlayer = (call drn_fnc_Escape_GetPlayers) select 0;
if (player == _anotherPlayer) then {
_anotherPlayer = (call drn_fnc_Escape_GetPlayers) select 1;
};
"drn_arr_JipSpawnPos" addPublicVariableEventHandler {
private ["_unitID", "_pos"];
_unitID = drn_arr_JipSpawnPos select 0;
_pos = drn_arr_JipSpawnPos select 1;
if (_unitID == str player) then {
player setPos _pos;
};
};
drn_fnc_Escape_AskForJipPos = [str player];
publicVariable "drn_fnc_Escape_AskForJipPos";
[] spawn {
private ["_marker"];
// Communication center markers
waitUntil {!isNil "drn_var_Escape_communicationCenterPositions"};
for "_i" from 0 to (count drn_var_Escape_communicationCenterPositions) - 1 do {
_marker = createMarkerLocal ["drn_Escape_ComCenJipMarker" + str _i, (drn_var_Escape_communicationCenterPositions select _i)];
_marker setMarkerType "Flag_CSAT";
};
// Ammo depot markers
waitUntil {!isNil "drn_var_Escape_ammoDepotPositions"};
for "_i" from 0 to (count drn_var_Escape_ammoDepotPositions) - 1 do {
_marker = createMarkerLocal ["drn_Escape_AmmoDepotJipMarker" + str _i, (drn_var_Escape_ammoDepotPositions select _i)];
_marker setMarkerType "o_installation";
};
// Extraction marker
if (!isNil "drn_var_Escape_ExtractionMarkerPos") then {
_marker = createMarkerLocal ["drn_visibleGoalJipMarker", drn_var_Escape_ExtractionMarkerPos];
_marker setMarkerType "Flag_NATO";
};
};
}
else {
sleep 1;
if (_showIntro) then {
["<t size='0.9'>" + "Engima of Ostgota Ops presents" + "</t>",0.02,0.3,2,-1,0,3010] spawn bis_fnc_dynamicText;
};
if (isMultiplayer) then {
player setPos [(drn_startPos select 0) + (random 4) - 2, (drn_startPos select 1) + (random 6) - 3, 0];
}
else {
{
_x setPos [(drn_startPos select 0) + (random 4) - 2, (drn_startPos select 1) + (random 6) - 3, 0];
_x disableAI "MOVE";
} foreach units group player;
};
while {!([drn_startPos] call drn_fnc_Escape_AllPlayersOnStartPos) && (isNil "drn_escapeHasStarted")} do {
sleep 0.1;
};
if (_showIntro) then {
0 cutText ["", "BLACK FADED"];
sleep 2.75;
0 cutText ["", "BLACK FADED"];
sleep 2.75;
["<t size='1'>" + "Escape Stratis" + "</t>",0.02,0.3,3,-1,0,3011] spawn bis_fnc_dynamicText;
["<t size='0.6'>" + "A port of 'Escape Chernarus'" + "</t>",0.02,0.4,3,-1,0,3012] spawn bis_fnc_dynamicText;
["<t size='0.5'>" + "by Vormulac and Hyperz" + "</t>",0.02,0.5,3,-1,0,3013] spawn bis_fnc_dynamicText;
0 cutText ["", "BLACK FADED"];
sleep 2.75;
0 cutText ["", "BLACK FADED"];
sleep 2.75;
0 cutText ["", "BLACK FADED"];
["Somewhere on", "Stratis", str (date select 2) + "/" + str (date select 1) + "/" + str (date select 0) + " " + str (date select 3) + ":00"] spawn BIS_fnc_infoText;
};
};
1 fadeSound _volume;
if (_showIntro && !_isJipPlayer) then {
sleep 2;
};
if (_showPlayerMapAndCompass) then {
_marker = createMarkerLocal ["drn_startPosMarker", drn_startPos];
_marker setMarkerType "Warning";
player additem "ItemCompass";
player assignItem "ItemCompass";
}
else {
player unassignItem "ItemMap";
player removeItem "ItemMap";
player unassignItem "ItemCompass";
player removeItem "ItemCompass";
player unassignItem "itemGPS";
player removeItem "itemGPS";
player unassignItem "NVGoggles";
player removeItem "NVGoggles";
};
enableRadio true;
if (!_isJipPlayer) then {
[_useRevive] spawn {
private ["_useRevive"];
_useRevive = _this select 0;
sleep 10;
if (_useRevive && !isDedicated) then {
//server execVM "revive_init.sqf";
};
// Only show this on non ported missions
if (worldName == "Chernarus") then {
sleep 20;
[name player + "! Please tell me about your Escape Chernarus experience on the BIS Forum or at Armaholic.com! Thank you, and enjoy the mission!", true] call drn_fnc_CL_ShowTitleTextLocal;
};
};
};
// Set position again (a fix for the bug that makes players run away after server restart and before fence is built by server)
player setPos [(drn_startPos select 0) + (random 4) - 2, (drn_startPos select 1) + (random 6) - 3, 0];
sleep 0.1;
player setVariable ["drn_var_initializing", false, true];
waitUntil {!(isNil "drn_escapeHasStarted")};
if (_isJipPlayer && _useRevive) then {
//server execVM "revive_init.sqf";
};
{
_x setCaptive false;
_x enableAI "MOVE";
} foreach units group player;
};
};
if (true) exitWith {};