summaryrefslogtreecommitdiffstats
path: root/Common/Init/Init_Camp.sqf
blob: 9a31709d98cc670ca5c5fb525b39477a6b97dc27 (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
Private ['_camp','_camps','_flagPole','_index','_marker','_supplyValue','_town'];

_camp = _this select 0;
_town = _this select 1;

waitUntil {townModeSet};
if (isNull _town && !isNull _camp) exitWith {
	if (isServer) then {
		if (isNil 'EastMHQ' || isNil 'WestMHQ') exitWith {};
		(getPos _camp) Spawn {
			Private ["_defenses"];
			waitUntil {commonInitComplete};
			_defenses = _this nearEntities[('WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace),250];
			{deleteVehicle _x} forEach _defenses;
		};
		deleteVehicle _camp;
	};
};
if ((str _town) in TownTemplate) exitWith {
	if (isServer) then {
		if (isNil 'EastMHQ' || isNil 'WestMHQ') exitWith {};
		diag_log Format ["[WFBE (INIT)][frameno:%3 | ticktime:%4] Init_Camp: Removing camp %1 (%2) since the town is removed in the towns templates.",_camp,str _town,diag_frameno,diag_tickTime];
		(getPos _camp) Spawn {
			Private ["_defenses"];
			waitUntil {commonInitComplete};
			_defenses = _this nearEntities[('WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace),250];
			{deleteVehicle _x} forEach _defenses;
		};
		deleteVehicle _camp;
	};
};

waitUntil{initJIP};
if !(paramKeepCamps) exitWith{
	diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Camp: Removing camp %3 due to a parameter (Town: %4) - [Done]",diag_frameno,diag_tickTime,_camp,_town];
	(getPos _camp) Spawn {
		Private ["_defenses"];
		waitUntil {commonInitComplete};
		_defenses = _this nearEntities[('WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace),250];
		{deleteVehicle _x} forEach _defenses;
	};
	deleteVehicle _camp;
};

if (isNull _camp) exitWith {diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Camp: Camp removed (Town is null) - [Done]",diag_frameno,diag_tickTime];};

_camps = _town getVariable "camps";
if (isNil "_camps") then {_town setVariable ["camps",[]]};
_camps = _town getVariable "camps";
_camps = _camps + [_camp];
_town setVariable ["camps",_camps];
_camp setVariable ['town',_town];

diag_log Format["[WFBE (INIT)][frameno:%3 | ticktime:%4] Init_Camp: Camp '%1' of town '%2' initialization - [Done]",str _camp,str _town,diag_frameno,diag_tickTime];

waitUntil {commonInitComplete};

if (local player) then {
	waitUntil {clientInitComplete};

	_index = _camps find _camp;
	_marker = Format["%1Camp%2",str _town,_index];
	createMarkerLocal [_marker,getPos _camp];
	_marker setMarkerTypeLocal "Strongpoint";
	_marker setMarkerSizeLocal [0.5,0.5];	
	_marker setMarkerColorLocal ("Resistance" Call GetMarkerColoration);
};

if (isServer) then {
	if (isNil 'EastMHQ' || isNil 'WestMHQ') exitWith {};
	
	sleep 10;

	_supplyValue = 0;
	if (isNil {_camp getVariable "sideID"}) then {_camp setVariable ["sideID",RESISTANCEID,true]};
	/* OA Camps are made of kryptonite */
	if (WF_A2_Arrowhead || WF_A2_CombinedOps) then {_camp addEventHandler ['handleDamage',{false}]};
	if (isNil {_camp getVariable "supplyValue"}) then {
		waitUntil {_supplyValue = _town getVariable "supplyValue"; !isNil "_supplyValue"};
		_camp setVariable ["supplyValue",_supplyValue,true];
		_flagPole = WFFLAG createVehicle getPos _camp;
		waitUntil {serverInitComplete && townInit};
		[_camp,_town,_flagPole] ExecFSM 'Server\FSM\updatecamp.fsm';
	};
};