From 68d4c9bbd80ed2e6528244569c79676b87295bd1 Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:54:45 +0300 Subject: init --- Client/GUI/GUI_Menu_Respawn.sqf | 161 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 Client/GUI/GUI_Menu_Respawn.sqf (limited to 'Client/GUI/GUI_Menu_Respawn.sqf') diff --git a/Client/GUI/GUI_Menu_Respawn.sqf b/Client/GUI/GUI_Menu_Respawn.sqf new file mode 100644 index 0000000..4425fab --- /dev/null +++ b/Client/GUI/GUI_Menu_Respawn.sqf @@ -0,0 +1,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"); \ No newline at end of file -- cgit v1.3.1