handleKilled and handleRespawn

This commit is contained in:
SilentSpike 2015-07-05 00:49:47 +01:00
parent 6596bbdb0a
commit 01a5ab619e
5 changed files with 56 additions and 19 deletions

View File

@ -33,15 +33,9 @@
[FUNC(trackUnits), 20] call CBA_fnc_addPerFrameHandler;
};
player addEventHandler ["Killed", {
[player] joinSilent grpNull;
if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = true};
_delay = getNumber (missionConfigFile >> "respawnDelay");
_delay fadeSound 0;
999999 cutText ["", "BLACK", _delay];
}];
player addEventHandler ["Respawn", FUNC(setSpectator)];
// Add event handlers to correctly enter spectator upon death
player addEventHandler ["Killed", FUNC(handleKilled)];
player addEventHandler ["Respawn", FUNC(handleRespawn)];
#include "initKeybinds.sqf";

View File

@ -13,6 +13,8 @@ PREP(drawMines3D);
PREP(drawTracks2D);
PREP(drawUnits2D);
PREP(drawUnits3D);
PREP(handleKilled);
PREP(handleRespawn);
PREP(killed);
PREP(map);
PREP(moduleSpectator);

View File

@ -0,0 +1,29 @@
/*
* Author: SilentSpike
* Cache necessary details and initalize spectator on death
*
* Arguments:
* 0: Corpse <OBJECT>
* 1: Killer <OBJECT>
*
* Return Value:
* None <NIL>
*
* Public: No
*/
#include "script_component.hpp"
private ["_unit","_killer","_delay"];
_unit = _this select 0;
_killer = _this select 1;
//Cache resettable info first
GVAR(cachedGroup) = group _unit;
GVAR(cachedSide) = side GVAR(cachedGroup);
[_unit] joinSilent grpNull;
if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = true};
_delay = getNumber (missionConfigFile >> "respawnDelay");
_delay fadeSound 0;
999999 cutText ["", "BLACK", _delay];

View File

@ -0,0 +1,17 @@
/*
* Author: SilentSpike
* Start the spectator camera spectator on respawn
*
* Arguments:
* 0: Corpse <OBJECT>
* 1: Killer <OBJECT>
*
* Return Value:
* None <NIL>
*
* Public: No
*/
#include "script_component.hpp"
[_this select 1] call FUNC(setSpectator);

View File

@ -3,12 +3,11 @@
* Sets local player to the given spectator state
*
* Arguments:
* 0: Player unit (unused, result of EH) <OBJECT>
* 1: Spectator camera target <OBJECT>
* 2: New spectator state <BOOL> <OPTIONAL>
* 0: Spectator camera target <OBJECT>
* 1: New spectator state <BOOL> <OPTIONAL>
*
* Return Value:
* nil
* None <NIL>
*
* Example:
* [player, _killer] call ace_spectator_fnc_setSpectator
@ -19,8 +18,8 @@
#include "script_component.hpp"
_unit = player;
_target = _this select 1;
_set = if (count _this > 2) then {_this select 2} else {true};
_target = _this select 0;
_set = if (count _this > 1) then {_this select 1} else {true};
if (_set isEqualTo (_unit getVariable [QGVAR(isSpectator), false])) exitWith {};
@ -28,10 +27,6 @@ if (_set isEqualTo (_unit getVariable [QGVAR(isSpectator), false])) exitWith {};
_unit enableSimulation !_set;
if (_set) then {
//Cache resettable info first
GVAR(cachedGroup) = group _unit;
GVAR(cachedSide) = side GVAR(cachedGroup);
// Move and hide the player ASAP to avoid being seen
_unit setPosASL (getMarkerPos QGVAR(respawn));
[_unit] joinSilent grpNull;