From e6c2916a1455ff28135496d46bcacbf2830b60f8 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sat, 12 Sep 2015 13:42:31 +0100 Subject: [PATCH] Fix spectator template for negligible respawnDelay When the value of respawn delay is 0 the timing of the killed and respawn events can be a little strange and result in spectator being entered but never exited. The respawn template should just do nothing when the delay is so small. --- addons/spectator/functions/fnc_respawnTemplate.sqf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/spectator/functions/fnc_respawnTemplate.sqf b/addons/spectator/functions/fnc_respawnTemplate.sqf index b808c43eab..d903e3ecc4 100644 --- a/addons/spectator/functions/fnc_respawnTemplate.sqf +++ b/addons/spectator/functions/fnc_respawnTemplate.sqf @@ -21,15 +21,17 @@ params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]]; private ["_vision","_pos"]; -// End mission when all are dead with respawn type "None" +// When all are dead with respawn type "None" the mission should end if ((_respawn == 0) && {{alive _x} count allPlayers <= 0}) exitWith { [["endDeath",false],"BIS_fnc_endMission"] call EFUNC(common,execRemoteFnc); }; +// Some environment information can be used for the initial camera attributes if (isNull _killer) then {_killer = _unit}; _vision = [-2,-1] select (sunOrMoon < 1); _pos = (getPosATL _unit) vectorAdd [0,0,5]; +// Enter/exit spectator based on the respawn type and whether killed/respawned if (alive _unit) then { if (_respawn == 1) then { [_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit); @@ -39,6 +41,9 @@ if (alive _unit) then { [false] call FUNC(setSpectator); }; } else { + // Negligible respawn delay can result in entering spectator after respawn + if (playerRespawnTime <= 1) exitWith {}; + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); [true] call FUNC(setSpectator); };