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
|
disableSerialization;
MenuAction = -1;
mouseButtonUp = -1;
_display = _this select 0;
_map = _display displayCtrl 15001;
_spawn = objNull;
_availableSpawn = [];
_markers = [];
_markerIndex = 0;
_ta = "";
_lastSpawnUpdate = 0;
//--- Prevent AI from moving to the temp spawn.
{_x disableAI "MOVE"} forEach (units clientTeam);
//--- Wait until the player respawned.
waitUntil {alive player};
//--- Position the player at the temp location during his respawn.
player setPos ([getMarkerPos Format["%1TempRespawnMarker",sideJoinedText],1,10] Call GetRandomPosition);
if (leader(group player) != player) then {(group player) selectLeader player};
//--- Call the pre respawn routine.
(player) Call PreRespawnHandler;
//--- Spawn a countdown thread.
respawnDone = false;
_handleTimer = [] Spawn {
if (isNil 'respawnStatus') then {respawnStatus = 'WFBE_RESPAWNDELAY' Call GetNamespace};
while {respawnStatus >= 0} do {
sleep 1;
respawnStatus = respawnStatus - 1;
};
respawnDone = true;
};
//--- Run the main respawn thread.
while {!respawnDone} do {
//--- Exit the thread if the client died.
if !(alive player) exitWith {};
//--- Loadout Selection.
ctrlSetText [15004, if (WFBE_RespawnDefaultGear) then {localize "STR_WF_RESPAWN_GearDefault"} else {localize "STR_WF_RESPAWN_GearCurrent"}]; //changed-MrNiceGuy
//--- Preloading Status.
ctrlSetText [15005, if (WFBE_EnablePreload) then {localize "STR_WF_RESPAWN_PreloadYes"} else {localize "STR_WF_RESPAWN_PreloadNo"}]; //changed-MrNiceGuy
//--- Update the respawn info.
if (time - _lastSpawnUpdate > 2) then {
_lastSpawnUpdate = time;
_lastAvailableSpawn = _availableSpawn;
_availableSpawn = [sideJoined,deathLocation] Call GetRespawnAvailable;
//--- First launch.
if (isNull _spawn) then {
_spawn = _availableSpawn select 0;
_ta = ["TempAnim",getPos _spawn,"Select",1.4,"ColorBlue",1.4,1.8] Spawn MarkerAnim;
respawnName = [typeOf _spawn, 'displayName'] Call GetConfigInfo;
};
//--- Properly update the client's map - Update removal.
_found = false;
{
if !(_x in _availableSpawn) then {
_mid = _x getVariable 'WFBE_IDRMarker';
_markers = _markers - [_mid];
deleteMarkerLocal _mid;
_x setVariable ['WFBE_IDRMarker',nil];
if (_x == _spawn && !_found) then {
_found = true;
_spawn = ([_x, _availableSpawn] Call SortByDistance) select 0;
terminate _ta;
deleteMarkerLocal "TempAnim";
_ta = ["TempAnim",getPos _spawn,"Select",1.4,"ColorBlue",1.4,1.8] Spawn MarkerAnim;
respawnName = [typeOf _spawn, 'displayName'] Call GetConfigInfo;
};
};
} forEach _lastAvailableSpawn;
//--- Properly update the client's map - Update add.
{
if !(_x in _lastAvailableSpawn) then {
_markerName = Format ["respawnMarker%1",_markerIndex];
_markers = _markers + [_markerName];
createMarkerLocal [_markerName,getPos _x];
_markerName setMarkerTypeLocal "Select";
_markerName setMarkerColorLocal "ColorYellow";
_markerName setMarkerSizeLocal [1,1];
_markerIndex = _markerIndex + 1;
_x setVariable ['WFBE_IDRMarker',_markerName];
};
} forEach _availableSpawn;
};
//--- Update the respawn timer.
ctrlSetText [15003,Format [localize "STR_WF_RESPAWN_Status",respawnStatus,respawnName]];
//--- The client has clicked on the map.
if (mouseButtonUp == 0) then {
mouseButtonUp = -1;
if (count _availableSpawn > 1) then {
_position = _map PosScreenToWorld[mouseX,mouseY];
_sorted = [_position,_availableSpawn] Call SortByDistance;
if ((_sorted select 0) distance _position < 500) then {
_spawn = _sorted select 0;
activeAnimMarker = false;
terminate _ta;
deleteMarkerLocal "TempAnim";
_ta = ["TempAnim",getPos _spawn,"Select",1.4,"ColorBlue",1.4,1.8] Spawn MarkerAnim;
respawnName = [typeOf _spawn, 'displayName'] Call GetConfigInfo;
};
};
};
sleep 0.1;
};
//--- If the spawn is null, we use the HQ.
if (isNull _spawn) then {
_hq = (sideJoinedText) Call GetSideHQ;
_spawn = _hq;
};
//--- Pre-render.
if (WFBE_EnablePreload) then {
ctrlSetText [15003,localize 'STR_WF_RESPAWN_Preload'];
waitUntil{preloadCamera (getPos _spawn) || !(alive player)};
};
//--- Execute on respawn code only if the player's alive.
if (alive player) then {
[player,_spawn] Call OnRespawnHandler;
};
//--- Terminate the threads & cleaning.
{deleteMarkerLocal _x} forEach _markers;
{_x setVariable ['WFBE_IDRMarker',nil]} forEach _availableSpawn;
if !(isNil "DeathCamera") then {
DeathCamera cameraEffect["TERMINATE","BACK"];
camDestroy DeathCamera;
};
"dynamicBlur" ppEffectEnable false;
"colorCorrections" ppEffectEnable false;
[currentFX] Spawn FX;
terminate _ta;
if !(scriptDone _handleTimer) then {terminate _handleTimer};
deleteMarkerLocal "TempAnim";
activeAnimMarker = false;
playerDead = false;
respawnDone = nil;
respawnName = nil;
respawnStatus = nil;
closeDialog 0;
//--- Enable AI movement again.
{_x enableAI "MOVE"} forEach (units clientTeam);
hint (localize "STR_WF_INFO_RespawnInfo");
|