ACE3/addons/spectator/functions/fnc_respawnTemplate.sqf
SilentSpike 1b12d37284 Replace spectator respawn changes with a template
Hacking the BI respawn framework to support a spectator setting was intrusive and limiting. Instead of using a setting, I've opted to introduce a new respawn template that can be used within BI's respawn framework. The benefits of this approach are:
- Compatibility isn't a concern, that responsibility is shifted onto mission designers.
- Mission designers can use the functionality of the BI framework alongside the spectator system (combining templates, using different templates for different sides, etc.).
- If a custom respawn framework is used, then this doesn't change anything. Custom frameworks are still fully supported via the public functions provided.
- Remains simple to set up, just requires a description.ext edit
2015-08-04 23:21:10 +01:00

40 lines
1.1 KiB
Plaintext

/*
* Author: SilentSpike
* The ace_spectator respawn template, handles killed + respawn
* Can be used via BI's respawn framework, see:
* 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>
*
* Public: No
*/
#include "script_component.hpp"
params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]];
private ["_vision","_pos"];
if (isNull _killer) then {_killer = _unit};
_vision = [-2,-1] select (sunOrMoon < 1);
_pos = (getPosATL _unit) vectorAdd [0,0,5];
if (alive _unit) then {
if (_respawn == 1) then {
[_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit);
[2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes);
[_unit] call FUNC(setSpectator);
} else {
[_unit,false] call FUNC(setSpectator);
};
} else {
[2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes);
[_unit] call FUNC(setSpectator);
};