ACE3/addons/spectator/functions/fnc_respawnTemplate.sqf
SilentSpike 2a9358ab03 Fix virtual spectator breaking if template active (#5466)
* Simplify virtual spectator code
* Rename camTarget GVAR for linter
* Fix respawn template breaking virtual spectators
2017-08-30 16:36:53 +01:00

43 lines
1.4 KiB
Plaintext

/*
* Author: SilentSpike
* The ace_spectator respawn template, compatible with types 1,2,3,4 & 5
*
* Handles killed and respawned events as per BI's respawn framework:
* https://community.bistudio.com/wiki/Arma_3_Respawn
*
* Arguments:
* 0: Corpse/New Unit <OBJECT>
* 1: Killer/Old Unit <OBJECT>
* 2: Respawn Type <NUMBER>
* 3: Respawn Delay <NUMBER>
*
* Return Value:
* None <NIL>
*
* Example:
* [bob, kevin, 3, 6] call ace_spectator_fnc_respawnTemplate
*
* Public: No
*/
#include "script_component.hpp"
params [["_newCorpse",objNull,[objNull]], ["_oldKiller",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]];
// Compatibility handled via spectator display XEH
if (_respawn in [0,1,4,5]) exitWith {
// This only applies to respawn type 1 (BIRD/SPECTATOR)
// Remove the seagull (not actually the player, a CfgNonAIVehicles object)
if (typeOf _newCorpse == "seagull") then { deleteVehicle _newCorpse; };
};
// Virtual spectators should be ignored by the template (otherwise they break)
if (_newCorpse isKindOf QGVAR(virtual)) exitWith {};
// If player died while already in spectator, ignore
if (!GVAR(isSet) || {alive _newCorpse}) then {
// Negligible respawn delay can result in entering spectator after respawn
// So we just use this value rather than living state of the unit
[playerRespawnTime > 1] call FUNC(setSpectator);
};