2015-08-04 21:11:34 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, kevin, 3, 6] call ace_spectator_fnc_respawnTemplate
|
|
|
|
*
|
2015-08-04 21:11:34 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]];
|
|
|
|
|
2015-09-12 12:42:31 +00:00
|
|
|
// Some environment information can be used for the initial camera attributes
|
2015-08-04 21:11:34 +00:00
|
|
|
if (isNull _killer) then {_killer = _unit};
|
2016-09-04 14:44:22 +00:00
|
|
|
private _vision = [-2,-1] select (sunOrMoon < 1);
|
|
|
|
private _pos = (getPosATL _unit) vectorAdd [0,0,5];
|
2015-08-04 21:11:34 +00:00
|
|
|
|
2015-09-12 12:42:31 +00:00
|
|
|
// Enter/exit spectator based on the respawn type and whether killed/respawned
|
2015-08-04 21:11:34 +00:00
|
|
|
if (alive _unit) then {
|
|
|
|
if (_respawn == 1) then {
|
2015-10-04 15:19:47 +00:00
|
|
|
[_unit] call FUNC(stageSpectator);
|
2015-08-04 21:11:34 +00:00
|
|
|
[2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes);
|
2015-08-08 11:24:49 +00:00
|
|
|
[true] call FUNC(setSpectator);
|
2015-08-04 21:11:34 +00:00
|
|
|
} else {
|
2015-08-08 11:24:49 +00:00
|
|
|
[false] call FUNC(setSpectator);
|
2015-08-04 21:11:34 +00:00
|
|
|
};
|
|
|
|
} else {
|
2015-09-12 12:42:31 +00:00
|
|
|
// Negligible respawn delay can result in entering spectator after respawn
|
|
|
|
if (playerRespawnTime <= 1) exitWith {};
|
|
|
|
|
2015-08-04 21:11:34 +00:00
|
|
|
[2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes);
|
2015-08-08 11:24:49 +00:00
|
|
|
[true] call FUNC(setSpectator);
|
2015-08-04 21:11:34 +00:00
|
|
|
};
|