mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
handleKilled and handleRespawn
This commit is contained in:
parent
6596bbdb0a
commit
01a5ab619e
@ -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";
|
||||
|
||||
|
@ -13,6 +13,8 @@ PREP(drawMines3D);
|
||||
PREP(drawTracks2D);
|
||||
PREP(drawUnits2D);
|
||||
PREP(drawUnits3D);
|
||||
PREP(handleKilled);
|
||||
PREP(handleRespawn);
|
||||
PREP(killed);
|
||||
PREP(map);
|
||||
PREP(moduleSpectator);
|
||||
|
29
addons/spectator/functions/fnc_handleKilled.sqf
Normal file
29
addons/spectator/functions/fnc_handleKilled.sqf
Normal 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];
|
17
addons/spectator/functions/fnc_handleRespawn.sqf
Normal file
17
addons/spectator/functions/fnc_handleRespawn.sqf
Normal 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);
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user