summaryrefslogtreecommitdiffstats
path: root/Client/GUI/GUI_ArtilleryMenu.sqf
blob: 82aec12690a6cdfe05a3a2fa0d12a7706a342023 (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
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

private ["_canFT","_startPoint","_closest","_sorted","_buildings","_checks","_sideID","_camps","_allCamps","_locations","_skip","_FTLocations","_markerName","_markers","_i","_lastUpdate","_base","_isDeployed","_currentLevel","_commander","_enable","_callPos","_travelingWith","_destination","_compass","_GPS","_pad","_radio","_watch","_locationPosition","_camera","_delay","_obj","_nukeMarker","_fireTime","_status","_txt","_units","_currentUpgrades","_funds","_lastRange","_display","_ftr","_marker","_area","_map","_pard","_IDCS"];
disableSerialization;

_display = _this select 0;
_lastRange = artyRange;
_lastUpdate = 0;
_listBox = 17019;

sliderSetRange[17005,10,'WFBE_MAXARTILLERYAREA' Call GetNamespace];
sliderSetPosition[17005,artyRange];

ctrlSetText [17025,localize "STR_WF_ArtilleryOverview" + " :"];

_markers = [];
_FTLocations = [];
_checks = [];
_fireTime = 0;
_status = 0;
_canFT = false;
_forceReload = true;
_ft = 'WFBE_FASTTRAVEL' Call GetNamespace;
_ftr = 'WFBE_FASTTRAVELRANGE' Call GetNamespace;
_startPoint = objNull;

_marker = "artilleryMarker";
createMarkerLocal [_marker,artyPos];
_marker setMarkerTypeLocal "mil_destroy";
_marker setMarkerColorLocal "ColorRed";
_marker setMarkerSizeLocal [1,1];

_area = "artilleryAreaMarker";
createMarkerLocal [_area,artyPos];
_area setMarkerShapeLocal "Ellipse";
_area setMarkerColorLocal "ColorRed";
_area setMarkerSizeLocal [artyRange,artyRange];

_map = _display DisplayCtrl 17002;
_listboxControl = _display DisplayCtrl _listBox;

_pard = 'WFBE_PARADELAY' Call GetNamespace;
{lbAdd[17008,_x]} forEach (Format ["WFBE_%1_ARTILLERY_DESC",sideJoinedText] Call GetNamespace);
lbSetCurSel[17008,0];

_IDCS = [17005,17006,17007,17008];
if !(paramArty) then {{ctrlEnable [_x,false]} forEach _IDCS};

{ctrlEnable [_x, false]} forEach [17010,17011,17012,17013,17014,17015,17017,17018,17020];

MenuAction = -1;
mouseButtonUp = -1;
_currentValue = -1;
_currentFee = -1;
_currentSpecial = "";
_currentFee = -1;

//--- Support List.
_lastSel = -1;
_addToList = [localize 'STR_WF_FastTravel',localize 'STR_WF_ICBM',localize 'STR_WF_Paradrop_Ammo',localize 'STR_WF_Paradrop_Vehicle',localize 'STR_WF_Paratroop',localize 'STR_WF_UnitCam',localize 'STR_WF_UAV',localize 'STR_WF_UAV_Destroy',localize 'STR_WF_UAV_RemoteControl'];
_addToListID = ["Fast_Travel","ICBM","Paradrop_Ammo","Paradrop_Vehicle","Paratroopers","Units_Camera","UAV","UAV_Destroy","UAV_Remote_Control"];
_addToListFee = [0,150000,9500,3500,8500,0,12500,0,0];
_addToListInterval = [0,1000,800,600,900,0,0,0,0];

for '_i' from 0 to count(_addToList)-1 do {
	lbAdd [_listBox,_addToList select _i];
	lbSetValue [_listBox, _i, _i];
};

lbSort _listboxControl;

//--- Artillery Mode.
_mode = 'WFBE_V_ARTILLERYMINMAP' Call GetNamespace;
if (isNil '_mode') then {_mode = 2;['WFBE_V_ARTILLERYMINMAP',_mode,true] Call SetNamespace};
_trackingArray = [];
_trackingArrayID = [];
_lastArtyUpdate = -60;
_minRange = 100;
_maxRange = 200;
_requestMarkerTransition = false;
_requestRangedList = true;
_startLoad = true;

//--- Startup coloration.
with uinamespace do {
	currentBEDialog = _display;
	switch (_mode) do {
		case 0: {(currentBEDialog displayCtrl 17023) ctrlSetTextColor [1,1,1,1]};
		case 1: {(currentBEDialog displayCtrl 17023) ctrlSetTextColor [0,0.635294,0.909803,1]};
		case 2: {(currentBEDialog displayCtrl 17023) ctrlSetTextColor [0.6,0.850980,0.917647,1]};
	};
};

lbSetCurSel[_listbox, 0];

_textAnimHandler = [] spawn {};

while {alive player && dialog} do {
	if (side player != sideJoined) exitWith {deleteMarkerLocal _marker;deleteMarkerLocal _area;{deleteMarkerLocal _x} forEach _markers;closeDialog 0};
	if (!dialog) exitWith {deleteMarkerLocal _marker;deleteMarkerLocal _area;{deleteMarkerLocal _x} forEach _markers};
	
	_currentUpgrades = (sideJoinedText) Call GetSideUpgrades;
	
	if (_ft > 0) then {
		//--- TODO: Travel fee, mod parameter > FT free or pay, do a clt fct.
		_currentLevel = _currentUpgrades select 12;
		if (time - _lastUpdate > 15 && _currentLevel > 0) then {
			{deleteMarkerLocal _x} forEach _markers;
			_markers = [];
			_FTLocations = [];
			_canFT = false;
			_startPoint = objNull;
			_lastUpdate = time;
			_base = (sideJoinedText) Call GetSideHQ;
			_isDeployed = (sideJoinedText) Call GetSideHQDeployed;
			if (player distance _base < _ftr && alive _base && vehicle player != _base && _isDeployed) then {
				_canFT = true;
				_startPoint = _base;
			} else {
				_sorted = [player,towns] Call SortByDistance;
				_closest = _sorted select 0;
				_sideID = _closest getVariable "sideID";
				_camps = [_closest,sideJoined] Call GetFriendlyCamps;
				_allCamps = _closest getVariable "camps";
				if (_sideID == sideID && player distance _closest < _ftr && (count _camps == count _allCamps)) then {_canFT = true;_startPoint = _closest} else {
					_buildings = (sideJoinedText) Call GetSideStructures;
					_checks = [sideJoined,Format ["WFBE_%1COMMANDCENTERTYPE",sideJoinedText] Call GetNamespace,_buildings] Call GetFactories;
					if (count _checks > 0) then {
						_sorted = [player,_checks] Call SortByDistance;
						_closest = _sorted select 0;
						if (player distance _closest < _ftr) then {
							_canFT = true;
							_closest = _sorted select 0;
							_startPoint = _closest;			
						};
					};
				};
			};
			if (!canMove (vehicle player)) then {_canFT = false};
			if (_canFT) then {
				_buildings = (sideJoinedText) Call GetSideStructures;
				_checks = [sideJoined,Format ["WFBE_%1COMMANDCENTERTYPE",sideJoinedText] Call GetNamespace,_buildings] Call GetFactories;
				_locations = towns + _checks;
				if (alive _base && _isDeployed) then {_locations = _locations + [_base]};
				_i = 0;
				_fee = 0;
				_funds = if (_ft == 2) then {Call GetPlayerFunds} else {0};
				{
					if (_x distance player <= ('WFBE_FASTTRAVELMAXRANGE' Call GetNamespace) && _x distance player > _ftr) then {
						_skip = false;
						if (_x in towns) then {
							_sideID = _x getVariable "sideID";
							_camps = [_x,sideJoined] Call GetFriendlyCamps;
							_allCamps = _x getVariable "camps";
							if (_sideID != sideID || (count _camps != count _allCamps)) then {_skip = true};
							if (_ft == 2) then {
								_fee = round(((_x distance player)/1000) * ('WFBE_FASTTRAVELPRICEKM' Call GetNamespace));
								if (_funds < _fee) then {_skip = true};
							};
						};
						if !(_skip) then {
							_FTLocations = _FTLocations + [_x];
							_markerName = Format ["FTMarker%1",_i];
							_markers = _markers + [_markerName];
							createMarkerLocal [_markerName,getPos _x];
							_markerName setMarkerTypeLocal "mil_circle";
							_markerName setMarkerColorLocal "ColorYellow";
							_markerName setMarkerSizeLocal [1,1];
							//--- Fee, Cheap marker stuff, TBD: Add prompt or something.
							if (_ft == 2) then {
								_markerName = Format ["FTMarker%1%1",_i];
								_markers = _markers + [_markerName];
								createMarkerLocal [_markerName,[(getPos _x select 0)-5,(getPos _x select 1)+75]];
								_markerName setMarkerTypeLocal "mil_circle";
								_markerName setMarkerColorLocal "ColorYellow";
								_markerName setMarkerSizeLocal [0,0];
								_markerName setMarkerTextLocal Format ["$ %1.",_fee];
							};
							_i = _i + 1;
						};
					};
				} forEach _locations;
			};
		};
	};
	
	_currentSel = lbCurSel(_listBox);
	
	//--- Special changed or a reload is requested.
	if (_currentSel != _lastSel || _forceReload) then {
		_currentValue = lbValue[_listBox, _currentSel];
		
		_currentSpecial = _addToListID select _currentValue;
		_currentFee = _addToListFee select _currentValue;
		_currentInterval = _addToListInterval select _currentValue;

		_forceReload = false;
		_controlEnable = false;
		
	_funds = Call GetPlayerFunds;
	
		ctrlSetText[17021,Format ["%1: $%2.",localize 'STR_WF_Price',_currentFee]];
		
		//--- Enabled or disabled?
		switch (_currentSpecial) do {
			case "Fast_Travel": {
				if (_ft > 0) then {
					_currentLevel = _currentUpgrades select 12;
					_controlEnable = if (count _FTLocations > 0 && _currentLevel > 0) then {true} else {false};
				};
			};
			case "ICBM": {
	if (paramICBM) then {
		_commander = false;
		if (!isNull(commanderTeam)) then {
			if (commanderTeam == group player) then {_commander = true};
		};
		_currentLevel = _currentUpgrades select 11;
					_controlEnable = if (_currentLevel > 0 && _commander && _funds >= _currentFee) then {true} else {false};
	};
			};
			case "Paratroopers": {
	_currentLevel = _currentUpgrades select 4;
				_controlEnable = if (_funds >= _currentFee && _currentLevel > 0 && time - lastParaCall > _currentInterval) then {true} else {false};
			};
			case "Paradrop_Ammo": {
				_currentLevel = _currentUpgrades select 16;
				_controlEnable = if (_funds >= _currentFee && _currentLevel > 0 && time - lastSupplyCall > _currentInterval) then {true} else {false};
			};
			case "Paradrop_Vehicle": {
				_currentLevel = _currentUpgrades select 16;
				_controlEnable = if (_funds >= _currentFee && _currentLevel > 0 && time - lastSupplyCall > _currentInterval) then {true} else {false};
			};
			case "UAV": {
	_currentLevel = _currentUpgrades select 5;
				_controlEnable = if (_funds >= _currentFee && _currentLevel > 0 && !(alive playerUAV)) then {true} else {false};
			};
			case "UAV_Destroy": {
				_controlEnable = if (alive playerUAV) then {true} else {false};
			};
			case "UAV_Remote_Control": {
				_controlEnable = if (alive playerUAV) then {true} else {false};
			};
			case "Units_Camera": {
				_controlEnable = commandInRange;
			};
		};
	
		ctrlEnable[17020, _controlEnable];
	};
	
	//--- Action triggered.
	if (MenuAction == 20) then {
		MenuAction = -1;
		
		//--- Output.
		switch (_currentSpecial) do {
			case "Fast_Travel": {
				MenuAction = 7;
				if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
				_textAnimHandler = [17022,localize 'STR_WF_ClickOnMap',10,"1da4fd"] spawn SetControlFadeAnim;
			};
			case "ICBM": {
				MenuAction = 8;
				if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
				_textAnimHandler = [17022,localize 'STR_WF_ClickOnMap',10,"1da4fd"] spawn SetControlFadeAnim;
			};
			case "Paratroopers": {
				MenuAction = 3;
				if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
				_textAnimHandler = [17022,localize 'STR_WF_ClickOnMap',10,"1da4fd"] spawn SetControlFadeAnim;
			};
			case "Paradrop_Ammo": {
				MenuAction = 10;
				if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
				_textAnimHandler = [17022,localize 'STR_WF_ClickOnMap',10,"1da4fd"] spawn SetControlFadeAnim;
			};
			case "Paradrop_Vehicle": {
				MenuAction = 9;
				
				if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
				_textAnimHandler = [17022,localize 'STR_WF_ClickOnMap',10,"1da4fd"] spawn SetControlFadeAnim;
			};
			case "UAV": {
				closeDialog 0;
				ExecVM "Client\Module\UAV\uav.sqf";
			};
			case "UAV_Destroy": {
				if !(isNull playerUAV) then {
					{_x setDammage 1} forEach (crew playerUAV);
					playerUAV setDammage 1;
					playerUAV = objNull;
				};
			};
			case "UAV_Remote_Control": {
				closeDialog 0;
				ExecVM "Client\Module\UAV\uav.sqf";
			};
			case "Units_Camera": {
				closeDialog 0;
				createDialog "RscUnitCamera";
			};
		};
		
		_forceReload = true;
	};
	
	artyRange = floor (sliderPosition 17005);
	if (_lastRange != artyRange) then {_area setMarkerSizeLocal [artyRange,artyRange];};
	
	if (mouseButtonUp == 0) then {
		mouseButtonUp = -1;
		//--- Set Artillery Marker on map.
		if (MenuAction == 1) then {
			MenuAction = -1;
			artyPos = _map posScreenToWorld[mouseX,mouseY];
			_marker setMarkerPosLocal artyPos;
			_area setMarkerPosLocal artyPos;
			_requestRangedList = true;
		};
		//--- Paratroops.
		if (MenuAction == 3) then {
			MenuAction = -1;
			_forceReload = true;
			if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
			[17022] Call SetControlFadeAnimStop;
			_callPos = _map posScreenToWorld[mouseX,mouseY];
			if (!surfaceIsWater _callPos) then {
				lastParaCall = time;
				-(_currentFee) Call ChangePlayerFunds;
				WFBE_RequestSpecial = ['SRVFNCREQUESTSPECIAL',["Paratroops",sideJoined,_callPos,clientTeam]];
				publicVariable 'WFBE_RequestSpecial';
				if (isHostedServer) then {['SRVFNCREQUESTSPECIAL',["Paratroops",sideJoined,_callPos,clientTeam]] Spawn HandleSPVF};
				hint (localize "STR_WF_Paratroop_Info");
			};
		};
		//--- Fast Travel.
		if (MenuAction == 7) then {
			MenuAction = -1;
			_forceReload = true;
			if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
			[17022] Call SetControlFadeAnimStop;
			_callPos = _map PosScreenToWorld[mouseX,mouseY];
			_sorted = [_callPos,_FTLocations] Call SortByDistance;
			if (_callPos distance (_sorted select 0) < 500) then {
				closeDialog 0;
				deleteMarkerLocal _marker;
				deleteMarkerLocal _area;
				
				_destination = _sorted select 0;
				
				if (_ft == 2) then {
					_fee = round(((player distance _destination)/1000) * ('WFBE_FASTTRAVELPRICEKM' Call GetNamespace));
					-(_fee) Call ChangePlayerFunds;
				};
				
				_travelingWith = [];
				{if (_x distance _startPoint < _ftr && !(_x in _travelingWith) && canMove _x && !(vehicle _x isKindOf "StaticWeapon") && !stopped _x && !((currentCommand _x) in ["WAIT","STOP"])) then {_travelingWith = _travelingWith + [vehicle _x]}} forEach units (group player);
				
				ForceMap true;
				_compass = shownCompass;
				_GPS = shownGPS;
				_pad = shownPad;
				_radio = shownRadio;
				_watch = shownWatch;

				showCompass false;
				showGPS false;
				showPad false;
				showRadio false;
				showWatch false;

				mapAnimClear;
				mapAnimCommit;

				_locationPosition = getPos _destination;
				_camera = "camera" camCreate _locationPosition;
				_camera camSetDir 0;
				_camera camSetFov 1;
				_camera cameraEffect["Internal","TOP"];

				_camera camSetTarget _locationPosition;
				_camera camSetPos [_locationPosition select 0,(_locationPosition select 1) + 2,100];
				_camera camCommit 0;
				
				mapAnimAdd [0,0.05,GetPos _startPoint];
				mapAnimCommit;
				
				_delay = ((_startPoint distance _destination) / 50) * ('WFBE_FASTTRAVELTIMECOEF' Call GetNamespace);
				mapAnimAdd [_delay,.18,getPos _destination];
				mapAnimCommit;
				
				waitUntil {mapAnimDone || !alive player};
				_skip = false;
				if (!alive player) then {_skip = true};
				if (!_skip) then {
					{[_x,_locationPosition,120] Call PlaceSafe} forEach _travelingWith;
				};
				sleep 1;
				
				ForceMap false;
				showCompass _compass;
				showGPS _GPS;
				showPad _pad;
				showRadio _radio;
				showWatch _watch;
				
				_camera cameraEffect["TERMINATE","BACK"];
				camDestroy _camera;
			};
		};
		//--- ICBM Strike.
		if (MenuAction == 8) then {
			_forceReload = true;
			if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
			[17022] Call SetControlFadeAnimStop;
			MenuAction = -1;
			-_currentFee Call ChangePlayerFunds;
			_callPos = _map PosScreenToWorld[mouseX,mouseY];
			_obj = "HeliHEmpty" createVehicle _callPos;
			_nukeMarker = createMarkerLocal ["icbmstrike", position _obj];
			_nukeMarker setMarkerTypeLocal "mil_warning";
			_nukeMarker setMarkerTextLocal "ICBM";
			_nukeMarker setMarkerColorLocal "ColorRed";
			[_obj,_nukeMarker] Spawn NukeIncomming;
		};
		//--- Vehicle Paradrop.
		if (MenuAction == 9) then {
			_forceReload = true;
			if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
			[17022] Call SetControlFadeAnimStop;
			MenuAction = -1;
			lastSupplyCall = time;
			-_currentFee Call ChangePlayerFunds;
			_callPos = _map PosScreenToWorld[mouseX,mouseY];
			WFBE_RequestSpecial = ['SRVFNCREQUESTSPECIAL',["ParaVehi",sideJoined,_callPos,clientTeam]];
			publicVariable 'WFBE_RequestSpecial';
			if (isHostedServer) then {['SRVFNCREQUESTSPECIAL',["ParaVehi",sideJoined,_callPos,clientTeam]] Spawn HandleSPVF};
		};
		//--- Ammo Paradrop.
		if (MenuAction == 10) then {
			_forceReload = true;
			if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
			[17022] Call SetControlFadeAnimStop;
			MenuAction = -1;
			lastSupplyCall = time;
			-_currentFee Call ChangePlayerFunds;
			_callPos = _map PosScreenToWorld[mouseX,mouseY];
			WFBE_RequestSpecial = ['SRVFNCREQUESTSPECIAL',["ParaAmmo",sideJoined,_callPos,clientTeam]];
			publicVariable 'WFBE_RequestSpecial';
			if (isHostedServer) then {['SRVFNCREQUESTSPECIAL',["ParaAmmo",sideJoined,_callPos,clientTeam]] Spawn HandleSPVF};
		};
	};
	
	//--- Update the Artillery Status.
	if (paramArty) then {
		_fireTime = (Format["WFBE_FIREMISSIONTIMEOUT%1",(_currentUpgrades select 10)] Call GetNamespace);
		_status = round(_fireTime - (time - fireMissionTime));
		_txt = if (time - fireMissionTime > _fireTime) then {Format['%1: <br /> %2',localize 'STR_WF_Status',localize 'STR_WF_Available']} else {Format ['%1: <br /> %2 %3',localize 'STR_WF_Status',_status,localize 'STR_WF_Seconds']};
		(_display displayCtrl 17016) ctrlSetStructuredText (parseText _txt);
		_enable = if (_status > 0) then {false} else {true};
		ctrlEnable [17007,_enable];
	};
	
	//--- Request Fire Mission.
	if (MenuAction == 2) then {
		MenuAction = -1;
		_units = [Group player,false,lbCurSel(17008),sideJoinedText] Call GetTeamArtillery;
		if (Count _units > 0) then {
			fireMissionTime = time;
			[GetMarkerPos "artilleryMarker",lbCurSel(17008)] Spawn RequestFireMission;
		} else {
			hint (localize "STR_WF_NoArty");
		};			
	};
	
	//--- Arty Combo Change or Script init.
	if (MenuAction == 200 || _startLoad) then {
		MenuAction = -1;
		
		_index = lbCurSel(17008);
		_minRange = (Format ["WFBE_%1_ARTILLERY_MINRANGES",sideJoined] Call GetNamespace) select _index;
		_maxRange = (Format ["WFBE_%1_ARTILLERY_MAXRANGES",sideJoined] Call GetNamespace) select _index;

		_trackingArray = [group player,true,lbCurSel(17008),sideJoined] Call GetTeamArtillery;
		
		_requestMarkerTransition = true;
		_requestRangedList = true;
		_startLoad = false;
	};
	
	//--- Focus on an artillery cannon.
	if (MenuAction == 60) then {
		MenuAction = -1;
		
		ctrlMapAnimClear _map;
		_map ctrlMapAnimAdd [1,.475,getPos(_trackingArray select (lnbCurSelRow 17024))];
		ctrlMapAnimCommit _map;
	};
	
	//--- Flush on change.
	if (_requestMarkerTransition) then {
		_requestMarkerTransition = false;
		
		{
			_track = (_x select 0);
			_vehicle = (_x select 1);

			_vehicle setVariable ['WFBE_A_Tracked', nil];
			deleteMarkerLocal Format ["WFBE_A_Large%1",_track];
			deleteMarkerLocal Format ["WFBE_A_Small%1",_track];
		} forEach _trackingArrayID;
		_trackingArrayID = [];
	};
	
	//--- Artillery List.
	if (paramArty && (_requestRangedList || time - _lastArtyUpdate > 3)) then {
		_requestRangedList = false;
		
		//--- No need to update the list all the time.
		if (time - _lastArtyUpdate > 5) then {
			_lastArtyUpdate = time;
			_trackingArray = [group player,true,lbCurSel(17008),sideJoined] Call GetTeamArtillery;
		};
		
		//--- Clear & Fill;
		lnbClear 17024;
		_i = 0;
		{
			_distance = _x distance (getMarkerPos _marker);
			_color = [0, 0.875, 0, 0.8];
			_text = "In Range";
			if (_distance > _maxRange) then {_color = [0.875, 0, 0, 0.8];_text = "Out of Range"};
			if (_distance <= _minRange) then {_color = [0.875, 0.5, 0, 0.8];_text = "Too close"};
			lnbAddRow [17024,[[typeOf _x, 'displayName'] Call GetConfigInfo,_text]];
			lnbSetPicture [17024,[_i,0],[typeOf _x, 'picture'] Call GetConfigInfo];
			
			lnbSetColor [17024,[_i,0],_color];
			lnbSetColor [17024,[_i,1],_color];
			
			_i = _i + 1;
		} forEach _trackingArray;
	};
	
	//--- Artillery map toggle.
	if (MenuAction == 40) then {
		MenuAction = -1;
		if (_mode == -1) then {_mode = 0};
		_mode = if (_mode == 2) then {0} else {_mode + 1};
		with uinamespace do {
			switch (_mode) do {
				case 0: {(currentBEDialog displayCtrl 17023) ctrlSetTextColor [1,1,1,1]};
				case 1: {(currentBEDialog displayCtrl 17023) ctrlSetTextColor [0,0.635294,0.909803,1]};
				case 2: {(currentBEDialog displayCtrl 17023) ctrlSetTextColor [0.6,0.850980,0.917647,1]};
	};
		};
	
		if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};
		_textAnimHandler = [17022,localize 'STR_WF_ArtilleryMinimapInfo',7,"f05555"] spawn SetControlFadeAnim;
		
		['WFBE_V_ARTILLERYMINMAP',_mode,true] Call SetNamespace;
		
		_requestMarkerTransition = true;
	};
	
	//--- Update artillery display.
	if (_mode != -1) then {
	
		//--- Nothing.
		if (_mode == 0) then {
			_requestMarkerTransition = true;
			_mode = -1;
		};
			
		//--- Filled Content.
		if (_mode == 1 || _mode == 2) then {
			//--- Remove if dead or null or sel changed.
			{
				_track = (_x select 0);
				_vehicle = (_x select 1);
				
				if !(alive _vehicle) then {
					deleteMarkerLocal Format ["WFBE_A_Large%1",_track];
					deleteMarkerLocal Format ["WFBE_A_Small%1",_track];
				};
			} forEach _trackingArrayID;
			
			//--- No need to update the marker all the time.
			if (time - _lastArtyUpdate > 5) then {
				_lastArtyUpdate = time;
				_trackingArray = [group player,true,lbCurSel(17008),sideJoined] Call GetTeamArtillery;
			};
			
			//--- Live Feed.
			_trackingArrayID = [];
			{
				_track = _x getVariable 'WFBE_A_Tracked';
				if (isNil '_track') then {
					_track = buildingMarker;
					buildingMarker = buildingMarker + 1;
					_x setVariable ['WFBE_A_Tracked', _track];
					_dmarker = Format ["WFBE_A_Large%1",_track];
					createMarkerLocal [_dmarker, getPos _x];
					_dmarker setMarkerColorLocal "ColorBlue";
					_dmarker setMarkerShapeLocal "ELLIPSE";
					_brush = "SOLID";
					if (_mode == 1) then {_brush = "SOLID"};
					if (_mode == 2) then {_brush = "BORDER"};
					_dmarker setMarkerBrushLocal _brush;
					_dmarker setMarkerAlphaLocal 0.4;
					_dmarker setMarkerSizeLocal [_maxRange,_maxRange];
					_dmarker = Format ["WFBE_A_Small%1",_track];
					createMarkerLocal [_dmarker, getPos _x];
					_dmarker setMarkerColorLocal "ColorBlack";
					_dmarker setMarkerShapeLocal "ELLIPSE";
					_dmarker setMarkerBrushLocal "SOLID";
					_dmarker setMarkerAlphaLocal 0.4;
					_dmarker setMarkerSizeLocal [_minRange,_minRange];
				} else {
					_dmarker = Format ["WFBE_A_Large%1",_track];
					_dmarker setMarkerPosLocal (getPos _x);
					_dmarker = Format ["WFBE_A_Small%1",_track];
					_dmarker setMarkerPosLocal (getPos _x);
				};
				_trackingArrayID = _trackingArrayID + [[_track,_x]];
			} forEach _trackingArray;
		};
	};
	
	_lastRange = artyRange;
	_lastSel = lbCurSel(_listbox);
	sleep 0.1;
};

deleteMarkerLocal _marker;
deleteMarkerLocal _area;
{deleteMarkerLocal _x} forEach _markers;

if !(scriptDone _textAnimHandler) then {terminate _textAnimHandler};

//--- Remove Markers.
{
	_track = (_x select 0);
	_vehicle = (_x select 1);
	
	_vehicle setVariable ['WFBE_A_Tracked', nil];

	deleteMarkerLocal Format ["WFBE_A_Large%1",_track];
	deleteMarkerLocal Format ["WFBE_A_Small%1",_track];
} forEach _trackingArrayID;