This repository has been archived by the owner on Feb 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
InitServer.sqf
736 lines (601 loc) · 28.6 KB
/
InitServer.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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
if (!isServer) exitWith {};
private ["_useEscapeSurprises", "_useRandomStartPos", "_useAmmoDepots", "_useSearchLeader", "_useMotorizedSearchGroup", "_useVillagePatrols", "_useMilitaryTraffic", "_useAmbientInfantry", "_useSearchChopper", "_useRoadBlocks", "_guardsExist", "_guardsAreArmed", "_guardLivesLong"];
private ["_debugEscapeSurprises", "_debugAmmoDepots", "_debugSearchLeader", "_showGroupDiagnostics", "_debugVillagePatrols", "_debugMilitaryTraffic", "_debugAmbientInfantry", "_debugGarbageCollector", "_debugRoadBlocks"];
private ["_enemyMinSkill", "_enemyMaxSkill", "_searchChopperSearchTimeMin", "_searchChopperRefuelTimeMin", "_enemySpawnDistance", "_playerGroup", "_enemyFrequency", "_comCenGuardsExist", "_fenceRotateDir", "_scriptHandle"];
// Developer Variables
_useRandomStartPos = true;
_useEscapeSurprises = true;
_useAmmoDepots = (paramsArray select 9 == 1);
_useSearchLeader = true;
_useMotorizedSearchGroup = true;
_useVillagePatrols = (paramsArray select 10 == 1);
_useMilitaryTraffic = true;
_useAmbientInfantry = true;
_useSearchChopper = (paramsArray select 6 == 1);
_useRoadBlocks = (paramsArray select 8 == 1);
_guardsExist = true;
_comCenGuardsExist = true;
_guardsAreArmed = true;
_guardLivesLong = false;
// Debug Variables
_debugEscapeSurprises = false;
_debugAmmoDepots = false;
_debugSearchLeader = false;
_debugVillagePatrols = false;
_debugMilitaryTraffic = false;
_debugAmbientInfantry = false;
_debugGarbageCollector = false;
_debugRoadBlocks = false;
drn_var_Escape_debugMotorizedSearchGroup = false;
drn_var_Escape_debugDropChoppers = false;
drn_var_Escape_debugReinforcementTruck = false;
drn_var_Escape_debugSearchChopper = false;
drn_var_Escape_DebugSearchGroup = false;
drn_var_Escape_debugCivilEnemy = false;
_showGroupDiagnostics = false;
// Game Control Variables, do not edit!
drn_var_Escape_AllPlayersDead = false;
drn_var_Escape_MissionComplete = false;
publicVariable "drn_var_Escape_AllPlayersDead";
publicVariable "drn_var_Escape_MissionComplete";
_enemyMinSkill = (paramsArray select 0) / 5;
_enemyMaxSkill = (paramsArray select 0) / 5 + 0.2;
drn_var_Escape_enemyMinSkill = _enemyMinSkill;
drn_var_Escape_enemyMaxSkill = _enemyMaxSkill;
_searchChopperSearchTimeMin = (5 + random 10);
_searchChopperRefuelTimeMin = (5 + random 10);
waituntil {!isnil "bis_fnc_init"};
_enemyFrequency = (paramsArray select 1);
_enemySpawnDistance = (paramsArray select 5);
drn_searchAreaMarkerName = "drn_searchAreaMarker";
// Choose a start position
if (_useRandomStartPos) then {
drn_startPos = [] call drn_fnc_Escape_FindGoodPos;
}
else {
drn_startPos = getPos ((call drn_fnc_Escape_GetPlayers) select 0);
};
publicVariable "drn_startPos";
// Build start position
_fenceRotateDir = random 360;
_scriptHandle = [drn_startPos, _fenceRotateDir] execVM "Scripts\Escape\BuildStartPos.sqf";
waitUntil {scriptDone _scriptHandle};
sleep 0.25;
drn_fenceIsCreated = true;
publicVariable "drn_fenceIsCreated";
call compile preprocessFileLineNumbers "Scripts\DRN\VillageMarkers\InitVillageMarkers.sqf";
[_enemyFrequency] call compile preprocessFileLineNumbers "Scripts\Escape\UnitClasses.sqf";
_playerGroup = group ((call drn_fnc_Escape_GetPlayers) select 0);
if (_useEscapeSurprises) then {
[_enemyMinSkill, _enemyMaxSkill, _enemyFrequency, _debugEscapeSurprises] execVM "Scripts\Escape\EscapeSurprises.sqf";
};
if (_showGroupDiagnostics) then {
[] execVM "Scripts\DRN\Diagnostics\MonitorEmptyGroups.sqf";
};
// Initialize communication centers
if (true) then {
private ["_communicationCenterMarkers", "_comCenNo", "_comCenMarkerNames", "_markerCoreName", "_markerName", "_instanceNo", "_marker", "_minEnemies", "_maxEnemies", "_chosenComCenIndexes", "_index", "_comCenPositions", "_comCenItem", "_distanceBetween", "_currentPos", "_tooClose", "_pos", "_scriptHandle"];
call compile preprocessFileLineNumbers ("Scripts\Escape\CommunicationCenterMarkers" + worldName + ".sqf");
_comCenMarkerNames = [];
_comCenNo = 1;
_markerCoreName = "drn_var_communicationCenter";
_markerName = _markerCoreName + str _comCenNo;
_chosenComCenIndexes = [];
_distanceBetween = 1500;
while {count _chosenComCenIndexes < 5} do {
_index = floor random count drn_arr_communicationCenterMarkers;
_currentPos = (drn_arr_communicationCenterMarkers select _index) select 0;
// North west
if (count _chosenComCenIndexes == 0) then {
while {_currentPos select 0 > (getMarkerPos "center") select 0 || _currentPos select 1 < (getMarkerPos "center") select 1} do {
_index = floor random count drn_arr_communicationCenterMarkers;
_currentPos = (drn_arr_communicationCenterMarkers select _index) select 0;
};
};
// North east
if (count _chosenComCenIndexes == 1) then {
while {_currentPos select 0 < (getMarkerPos "center") select 0 || _currentPos select 1 < (getMarkerPos "center") select 1} do {
_index = floor random count drn_arr_communicationCenterMarkers;
_currentPos = (drn_arr_communicationCenterMarkers select _index) select 0;
};
};
// South east
if (count _chosenComCenIndexes == 2) then {
while {_currentPos select 0 < (getMarkerPos "center") select 0 || _currentPos select 1 > (getMarkerPos "center") select 1} do {
_index = floor random count drn_arr_communicationCenterMarkers;
_currentPos = (drn_arr_communicationCenterMarkers select _index) select 0;
};
};
// South west
if (count _chosenComCenIndexes == 3) then {
while {_currentPos select 0 > (getMarkerPos "center") select 0 || _currentPos select 1 > (getMarkerPos "center") select 1} do {
_index = floor random count drn_arr_communicationCenterMarkers;
_currentPos = (drn_arr_communicationCenterMarkers select _index) select 0;
};
};
if (!(_index in _chosenComCenIndexes)) then {
_currentPos = (drn_arr_communicationCenterMarkers select _index) select 0;
_tooClose = false;
{
_pos = (drn_arr_communicationCenterMarkers select _x) select 0;
if (_pos distance _currentPos < _distanceBetween) then {
_tooClose = true;
};
if (_useRandomStartPos && _currentPos distance drn_startPos < _distanceBetween) then {
_tooClose = true;
};
} foreach _chosenComCenIndexes;
if (!_tooClose) then {
_chosenComCenIndexes set [count _chosenComCenIndexes, _index];
};
};
};
// Unmark this if you want communication centers everywhere
/*
_i = 0;
{
_chosenComCenIndexes set [_i, _i];
_i = _i + 1;
} foreach drn_arr_communicationCenterMarkers;
*/
_instanceNo = 0;
switch (_enemyFrequency) do
{
case 1: // 1-2 players
{
_minEnemies = 2;
_maxEnemies = 4;
};
case 2: // 3-5 players
{
_minEnemies = 12;
_maxEnemies = 16;
};
default // 6-8 players
{
_minEnemies = 16;
_maxEnemies = 24;
};
};
_comCenPositions = [];
{
private ["_index"];
private ["_pos", "_dir"];
_index = _x;
_comCenItem = drn_arr_communicationCenterMarkers select _index;
_pos = _comCenItem select 0;
_dir = _comCenItem select 1;
_comCenPositions set [count _comCenPositions, _pos];
_scriptHandle = [_pos, _dir, drn_arr_ComCenStaticWeapons, drn_arr_ComCenParkedVehicles] execVM "Scripts\Escape\BuildCommunicationCenter.sqf";
waitUntil {scriptDone _scriptHandle};
_marker = createMarker ["drn_CommunicationCenterMapMarker" + str _instanceNo, _pos];
_marker setMarkerType "Faction_INS";
_marker = createMarkerLocal ["drn_CommunicationCenterPatrolMarker" + str _instanceNo, _pos];
_marker setMarkerShapeLocal "ELLIPSE";
_marker setMarkerAlpha 0;
_marker setMarkerSizeLocal [75, 75];
_instanceNo = _instanceNo + 1;
} foreach _chosenComCenIndexes;
if (_comCenGuardsExist) then {
_scriptHandle = [_playerGroup, "drn_CommunicationCenterPatrolMarker", east, "INS", 4, _minEnemies, _maxEnemies, _enemyMinSkill, _enemyMaxSkill, _enemySpawnDistance] execVM "Scripts\DRN\DynamicGuardedLocations\InitGuardedLocations.sqf";
waitUntil {scriptDone _scriptHandle};
};
drn_var_Escape_communicationCenterPositions = _comCenPositions;
publicVariable "drn_var_Escape_communicationCenterPositions";
// Initialize armor defence at communication centers
if (_comCenGuardsExist) then {
[_playerGroup, _comCenPositions, _enemySpawnDistance, _enemyFrequency] call drn_fnc_Escape_InitializeComCenArmor;
};
};
// Initialize ammo depots
if (_useAmmoDepots) then {
[_enemyMinSkill, _enemyMaxSkill, _debugAmmoDepots, _enemySpawnDistance, _playerGroup, _enemyFrequency] spawn {
private ["_enemyMinSkill", "_enemyMaxSkill", "_debugAmmoDepots", "_enemySpawnDistance", "_playerGroup", "_enemyFrequency"];
private ["_playerGroup", "_minEnemies", "_maxEnemies", "_bannedPositions", "_scriptHandle"];
_enemyMinSkill = _this select 0;
_enemyMaxSkill = _this select 1;
_debugAmmoDepots = _this select 2;
_enemySpawnDistance = _this select 3;
_playerGroup = _this select 4;
_enemyFrequency = _this select 5;
_bannedPositions = + drn_var_Escape_communicationCenterPositions + [drn_startPos, getMarkerPos "drn_insurgentAirfieldMarker"];
drn_var_Escape_ammoDepotPositions = _bannedPositions call drn_fnc_Escape_FindAmmoDepotPositions;
publicVariable "drn_var_Escape_ammoDepotPositions";
for "_i" from 0 to (count drn_var_Escape_ammoDepotPositions) - 1 do {
sleep 1;
[drn_var_Escape_ammoDepotPositions select _i, drn_arr_Escape_AmmoDepot_StaticWeaponClasses, drn_arr_Escape_AmmoDepot_ParkedVehicleClasses] call drn_fnc_Escape_BuildAmmoDepot;
};
switch (_enemyFrequency) do
{
case 1: // 1-2 players
{
_minEnemies = 6;
_maxEnemies = 8;
};
case 2: // 3-5 players
{
_minEnemies = 8;
_maxEnemies = 12;
};
default // 6-8 players
{
_minEnemies = 12;
_maxEnemies = 18;
};
};
_scriptHandle = [_playerGroup, "drn_AmmoDepotPatrolMarker", east, "INS", 3, _minEnemies, _maxEnemies, _enemyMinSkill, _enemyMaxSkill, _enemySpawnDistance, _debugAmmoDepots] execVM "Scripts\DRN\DynamicGuardedLocations\InitGuardedLocations.sqf";
waitUntil {scriptDone _scriptHandle};
};
};
// Initialize search leader
if (_useSearchLeader) then {
[drn_searchAreaMarkerName, _debugSearchLeader] execVM "Scripts\Escape\SearchLeader.sqf";
};
// Create motorized search group
if (_useMotorizedSearchGroup) then {
[_enemyFrequency, _enemyMinSkill, _enemyMaxSkill] spawn {
private ["_enemyFrequency", "_enemyMinSkill", "_enemyMaxSkill"];
private ["_spawnSegment"];
_enemyFrequency = _this select 0;
_enemyMinSkill = _this select 1;
_enemyMaxSkill = _this select 2;
_spawnSegment = [(call drn_fnc_Escape_GetPlayerGroup), 1500, 2000] call drn_fnc_Escape_FindSpawnSegment;
while {(str _spawnSegment) == """NULL"""} do {
_spawnSegment = [(call drn_fnc_Escape_GetPlayerGroup), 1500, 2000] call drn_fnc_Escape_FindSpawnSegment;
sleep 1;
};
[getPos _spawnSegment, drn_searchAreaMarkerName, _enemyFrequency, _enemyMinSkill, _enemyMaxSkill, drn_var_Escape_debugMotorizedSearchGroup] execVM "Scripts\Escape\CreateMotorizedSearchGroup.sqf";
};
};
// Start garbage collector
[_playerGroup, 750, _debugGarbageCollector] spawn drn_fnc_CL_RunGarbageCollector;
// Run initialization for scripts that need the players to be gathered at the start position
[_useVillagePatrols, _useMilitaryTraffic, _useAmbientInfantry, _debugVillagePatrols, _debugMilitaryTraffic, _debugAmbientInfantry, _enemyMinSkill, _enemyMaxSkill, _enemySpawnDistance, _enemyFrequency, _useRoadBlocks, _debugRoadBlocks] spawn {
private ["_useVillagePatrols", "_useMilitaryTraffic", "_useAmbientInfantry", "_debugVillagePatrols", "_debugMilitaryTraffic", "_debugAmbientInfantry", "_enemyMinSkill", "_enemyMaxSkill", "_enemySpawnDistance", "_enemyFrequency", "_useRoadBlocks", "_debugRoadBlocks"];
private ["_fnc_OnSpawnAmbientInfantryGroup", "_fnc_OnSpawnAmbientInfantryUnit", "_scriptHandle"];
private ["_playerGroup", "_minEnemiesPerGroup", "_maxEnemiesPerGroup", "_fnc_OnSpawnGroup"];
_useVillagePatrols = _this select 0;
_useMilitaryTraffic = _this select 1;
_useAmbientInfantry = _this select 2;
_debugVillagePatrols = _this select 3;
_debugMilitaryTraffic = _this select 4;
_debugAmbientInfantry = _this select 5;
_enemyMinSkill = _this select 6;
_enemyMaxSkill = _this select 7;
_enemySpawnDistance = _this select 8;
_enemyFrequency = _this select 9;
_useRoadBlocks = _this select 10;
_debugRoadBlocks = _this select 11;
waitUntil {[drn_startPos] call drn_fnc_Escape_AllPlayersOnStartPos};
_playerGroup = group ((call drn_fnc_Escape_GetPlayers) select 0);
if (_useVillagePatrols) then {
switch (_enemyFrequency) do
{
case 1: // 1-2 players
{
_minEnemiesPerGroup = 2;
_maxEnemiesPerGroup = 4;
};
case 2: // 3-5 players
{
_minEnemiesPerGroup = 3;
_maxEnemiesPerGroup = 6;
};
default // 6-8 players
{
_minEnemiesPerGroup = 4;
_maxEnemiesPerGroup = 8;
};
};
_fnc_OnSpawnGroup = {
{
_x call drn_fnc_Escape_OnSpawnGeneralSoldierUnit;
} foreach units _this;
};
_scriptHandle = [(units _playerGroup) select 0, east, drn_arr_Escape_InfantryTypes, _minEnemiesPerGroup, _maxEnemiesPerGroup, 5000, _enemyMinSkill, _enemyMaxSkill, _enemySpawnDistance + 250, _fnc_OnSpawnGroup, _debugVillagePatrols] execVM "Scripts\DRN\VillagePatrols\InitVillagePatrols.sqf";
waitUntil {scriptDone _scriptHandle};
};
// Initialize ambient infantry groups
if (_useAmbientInfantry) then {
_fnc_OnSpawnAmbientInfantryUnit = {
_this setVehicleAmmo (0.3 + random 0.7);
_this removeWeapon "ItemGPS";
_this removeWeapon "ItemMap";
_this removeWeapon "ItemCompass";
if (random 100 > 75) then {
_this addWeapon "ItemMap";
if (random 100 >= 10) then {
_this addWeapon "ItemCompass";
};
};
};
_fnc_OnSpawnAmbientInfantryGroup = {
private ["_unit", "_enemyUnit", "_i"];
private ["_scriptHandle"];
_unit = units _this select 0;
while {!(isNull _unit)} do {
_enemyUnit = _unit findNearestEnemy (getPos _unit);
if (!(isNull _enemyUnit)) exitWith {
for [{_i = (count waypoints _this) - 1}, {_i >= 0}, {_i = _i - 1}] do {
deleteWaypoint [_this, _i];
};
_scriptHandle = [_this, drn_searchAreaMarkerName, (getPos _enemyUnit), drn_var_Escape_DebugSearchGroup] execVM "Scripts\DRN\SearchGroup\SearchGroup.sqf";
_this setVariable ["drn_scriptHandle", _scriptHandle];
};
sleep 5;
};
};
private ["_infantryTypes"];
private ["_infantryGroupsCount", "_radius", "_groupsPerSqkm"];
switch (_enemyFrequency) do
{
case 1: // 1-2 players
{
_minEnemiesPerGroup = 2;
_maxEnemiesPerGroup = 3;
_groupsPerSqkm = 1;
};
case 2: // 3-5 players
{
_minEnemiesPerGroup = 2;
_maxEnemiesPerGroup = 8;
_groupsPerSqkm = 1.2;
};
default // 6-8 players
{
_minEnemiesPerGroup = 2;
_maxEnemiesPerGroup = 12;
_groupsPerSqkm = 1.4;
};
};
_radius = (_enemySpawnDistance + 500) / 1000;
_infantryGroupsCount = round (_groupsPerSqkm * _radius * _radius * 3.141592);
[_playerGroup, east, drn_arr_Escape_InfantryTypes, _infantryGroupsCount, _enemySpawnDistance + 200, _enemySpawnDistance + 500, _minEnemiesPerGroup, _maxEnemiesPerGroup, _enemyMinSkill, _enemyMaxSkill, 750, _fnc_OnSpawnAmbientInfantryUnit, _fnc_OnSpawnAmbientInfantryGroup, _debugAmbientInfantry] execVM "Scripts\DRN\AmbientInfantry\AmbientInfantry.sqf";
sleep 0.25;
};
// Initialize the Escape military and civilian traffic
if (_useMilitaryTraffic) then {
private ["_vehiclesPerSqkm", "_radius", "_vehiclesCount", "_fnc_onSpawnCivilian", "_vehicleClasses"];
// Civilian traffic
switch (_enemyFrequency) do
{
case 1: // 1-3 players
{
_vehiclesPerSqkm = 1.6;
};
case 2: // 4-6 players
{
_vehiclesPerSqkm = 1.4;
};
default // 7-8 players
{
_vehiclesPerSqkm = 1.2;
};
};
_radius = _enemySpawnDistance + 500;
_vehiclesCount = round (_vehiclesPerSqkm * (_radius / 1000) * (_radius / 1000) * 3.141592);
_fnc_onSpawnCivilian = {
private ["_vehicle", "_crew"];
_vehicle = _this select 0;
_crew = _this select 1;
//_vehiclesGroup = _result select 2;
{
{
_x removeWeapon "ItemMap";
} foreach _crew; // foreach crew
_x addeventhandler ["killed",{
if ((_this select 1) in (call drn_fnc_Escape_GetPlayers)) then {
drn_var_Escape_SearchLeader_civilianReporting = true;
publicVariable "drn_var_Escape_SearchLeader_civilianReporting";
(_this select 1) addScore -4;
[name (_this select 1) + " has killed a civilian."] call drn_fnc_CL_ShowCommandTextAllClients;
}
}];
} foreach _crew;
if (random 100 < 20) then {
private ["_index", "_weaponItem"];
_index = floor random count drn_arr_CivilianCarWeapons;
_weaponItem = drn_arr_CivilianCarWeapons select _index;
_vehicle addWeaponCargoGlobal [_weaponItem select 0, 1];
_vehicle addMagazineCargoGlobal [_weaponItem select 1, _weaponItem select 2];
};
};
[_playerGroup, civilian, drn_arr_Escape_MilitaryTraffic_CivilianVehicleClasses, _vehiclesCount, _enemySpawnDistance, _radius, 0.5, 0.5, _fnc_onSpawnCivilian, _debugMilitaryTraffic] execVM "Scripts\DRN\MilitaryTraffic\MilitaryTraffic.sqf";
sleep 0.25;
// Enemy military traffic
switch (_enemyFrequency) do
{
case 1: // 1-3 players
{
_vehiclesPerSqkm = 0.6;
};
case 2: // 4-6 players
{
_vehiclesPerSqkm = 0.8;
};
default // 7-8 players
{
_vehiclesPerSqkm = 1;
};
};
_radius = _enemySpawnDistance + 500;
_vehiclesCount = round (_vehiclesPerSqkm * (_radius / 1000) * (_radius / 1000) * 3.141592);
[_playerGroup, east, drn_arr_Escape_MilitaryTraffic_EnemyVehicleClasses, _vehiclesCount, _enemySpawnDistance, _radius, _enemyMinSkill, _enemyMaxSkill, drn_fnc_Escape_TrafficSearch, _debugMilitaryTraffic] execVM "Scripts\DRN\MilitaryTraffic\MilitaryTraffic.sqf";
sleep 0.25;
};
if (_useRoadBlocks) then {
private ["_areaPerRoadBlock", "_maxEnemySpawnDistanceKm", "_roadBlockCount"];
private ["_fnc_OnSpawnInfantryGroup", "_fnc_OnSpawnMannedVehicle"];
_fnc_OnSpawnInfantryGroup = {{_x call drn_fnc_Escape_OnSpawnGeneralSoldierUnit;} foreach units _this;};
_fnc_OnSpawnMannedVehicle = {{_x call drn_fnc_Escape_OnSpawnGeneralSoldierUnit;} foreach (_this select 1);};
switch (_enemyFrequency) do {
case 1: {
_areaPerRoadBlock = 4.19;
};
case 2: {
_areaPerRoadBlock = 3.14;
};
default {
_areaPerRoadBlock = 2.5;
};
};
_maxEnemySpawnDistanceKm = (_enemySpawnDistance + 500) / 1000;
_roadBlockCount = round ((_maxEnemySpawnDistanceKm * _maxEnemySpawnDistanceKm * 3.141592) / _areaPerRoadBlock);
if (_roadBlockCount < 1) then {
_roadBlockCount = 1;
};
[_playerGroup, east, drn_arr_Escape_InfantryTypes, drn_arr_Escape_RoadBlock_MannedVehicleTypes, _roadBlockCount, _enemySpawnDistance, _enemySpawnDistance + 500, 500, 300, _fnc_OnSpawnInfantryGroup, _fnc_OnSpawnMannedVehicle, _debugRoadBlocks] execVM "Scripts\DRN\RoadBlocks\RoadBlocks.sqf";
sleep 0.25;
};
};
// Create search chopper
if (_useSearchChopper) then {
private ["_scriptHandle"];
_scriptHandle = [getMarkerPos "drn_searchChopperStartPosMarker", east, drn_searchAreaMarkerName, _searchChopperSearchTimeMin, _searchChopperRefuelTimeMin, _enemyMinSkill, _enemyMaxSkill, [], drn_var_Escape_debugSearchChopper] execVM "Scripts\Escape\CreateSearchChopper.sqf";
waitUntil {scriptDone _scriptHandle};
};
// Spawn creation of start position settings
[drn_startPos, _enemyMinSkill, _enemyMaxSkill, _guardsAreArmed, _guardsExist, _guardLivesLong, _enemyFrequency, _fenceRotateDir] spawn {
private ["_startPos", "_enemyMinSkill", "_enemyMaxSkill", "_guardsAreArmed", "_guardsExist", "_guardLivesLong", "_enemyFrequency", "_fenceRotateDir"];
private ["_i", "_guard", "_guardGroup", "_marker", "_guardCount", "_guardGroups", "_unit", "_createNewGroup", "_guardPos"];
_startPos = _this select 0;
_enemyMinSkill = _this select 1;
_enemyMaxSkill = _this select 2;
_guardsAreArmed = _this select 3;
_guardsExist = _this select 4;
_guardLivesLong = _this select 5;
_enemyFrequency = _this select 6;
_fenceRotateDir = _this select 7;
// Spawn guard
_guardGroup = createGroup east;
_guardPos = [_startPos, [(_startPos select 0) - 4, (_startPos select 1) + 4, 0], _fenceRotateDir] call drn_fnc_CL_RotatePosition;
(drn_arr_Escape_StartPositionGuardTypes select floor (random count drn_arr_Escape_StartPositionGuardTypes)) createUnit [_guardPos, _guardGroup, "", (0.5), "CAPTAIN"];
_guard = units _guardGroup select 0;
_guard disableAI "MOVE";
_guard setDir _fenceRotateDir + 125;
_guard setVehicleAmmo 0.3 + random 0.7;
_guard removeWeapon "ItemMap";
_guard removeWeapon "ItemCompass";
_guard removeWeapon "ItemGPS";
_guard setSkill _enemyMinSkill + random (_enemyMaxSkill - _enemyMinSkill);
_guard addMagazine drn_var_Escape_InnerFenceGuardSecondaryWeaponMagazine;
_guard addMagazine drn_var_Escape_InnerFenceGuardSecondaryWeaponMagazine;
_guard addMagazine drn_var_Escape_InnerFenceGuardSecondaryWeaponMagazine;
if (random 100 < 50) then {
_guard addMagazine drn_var_Escape_InnerFenceGuardSecondaryWeaponMagazine;
};
_guard addWeapon drn_var_Escape_InnerFenceGuardSecondaryWeapon;
if (random 100 < 40) then {
_guard addweapon "NVGoggles";
};
// Spawn more guards
_marker = createMarkerLocal ["drn_guardAreaMarker", _startPos];
_marker setMarkerAlpha 0;
_marker setMarkerShapeLocal "ELLIPSE";
_marker setMarkerSizeLocal [50, 50];
if (_guardsExist) then {
_guardCount = (4 + (_enemyFrequency)) + floor (random 2);
}
else {
_guardCount = 0;
};
_guardGroups = [];
_createNewGroup = true;
for [{_i = 0}, {_i < _guardCount}, {_i = _i + 1}] do {
private ["_pos"];
_pos = [_marker] call drn_fnc_CL_GetRandomMarkerPos;
while {_pos distance _startPos < 10} do {
_pos = [_marker] call drn_fnc_CL_GetRandomMarkerPos;
};
if (_createNewGroup) then {
_guardGroup = createGroup east;
_guardGroups set [count _guardGroups, _guardGroup];
_createNewGroup = false;
};
(drn_arr_Escape_StartPositionGuardTypes select floor (random count drn_arr_Escape_StartPositionGuardTypes)) createUnit [_pos, _guardGroup, "", (0.5), "CAPTAIN"];
if (count units _guardGroup >= 2) then {
_createNewGroup = true;
};
};
{
_guardGroup = _x;
_guardGroup setFormDir floor (random 360);
{
_unit = _x; //(units _guardGroup) select 0;
_unit removeWeapon "ItemMap";
_unit removeWeapon "ItemCompass";
_unit removeWeapon "ItemGPS";
if (random 100 < 40) then {
_unit addweapon "NVGoggles";
};
_unit setSkill _enemyMinSkill + random (_enemyMaxSkill - _enemyMinSkill);
_unit removeMagazines "Handgrenade_East";
if (_guardsAreArmed) then {
_unit setVehicleAmmo 0.3 + random 0.7;
}
else {
removeAllWeapons _unit;
};
} foreach units _guardGroup;
[_guardGroup, _marker] execVM "Scripts\DRN\SearchGroup\SearchGroup.sqf";
} foreach _guardGroups;
sleep 0.5;
drn_startPos = _startPos;
publicVariable "drn_startPos";
// Start thread that waits for escape to start
[_guardGroups, _startPos] spawn {
private ["_guardGroups", "_startPos"];
_guardGroups = _this select 0;
_startPos = _this select 1;
sleep 5;
while {isNil "drn_escapeHasStarted"} do {
// If any member of the group is to far away from fence, then escape has started
{
if (!(_x getVariable ["drn_var_initializing", true])) then {
if ((_x distance _startPos) > 25 && (_x distance _startPos) < 150) exitWith {
drn_escapeHasStarted = true;
publicVariable "drn_escapeHasStarted";
};
};
} foreach call drn_fnc_Escape_GetPlayers;
// If any player have picked up a weapon, escape has started
{
if (!(_x getVariable ["drn_var_initializing", true])) then {
if (_x hasWeapon "ItemMap") then {
if (count weapons _x > 4 || count magazines _x > 0) exitWith {
drn_escapeHasStarted = true;
publicVariable "drn_escapeHasStarted";
};
}
else {
if (count weapons _x > 2 || count magazines _x > 0) exitWith {
drn_escapeHasStarted = true;
publicVariable "drn_escapeHasStarted";
};
};
};
} foreach call drn_fnc_Escape_GetPlayers;
sleep 1;
};
// ESCAPE HAS STARTED
{
_x setCaptive false;
} foreach call drn_fnc_Escape_GetPlayers;
sleep (5 + random 7);
{
private ["_guardGroup"];
_guardGroup = _x;
{
_guardGroup reveal _x;
} foreach call drn_fnc_Escape_GetPlayers;
} foreach _guardGroups;
};
if (_guardLivesLong) then {
sleep (30 + floor (random 40));
}
else {
sleep 5;
};
// Guard passes out
_guard setDamage 1;
};