mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Initial enter/exit function implementation
This commit is contained in:
parent
91ca532496
commit
ff4fce3950
@ -42,41 +42,6 @@
|
||||
999999 cutText ["", "BLACK", _delay];
|
||||
}];
|
||||
|
||||
player addEventHandler ["Respawn", {
|
||||
// Move the player ASAP
|
||||
player setPosATL GVAR(penPos);
|
||||
|
||||
if (!isNil QGVAR(cam)) then {["Exit"] call FUNC(camera)};
|
||||
if (isClass (configFile >> "CfgPatches" >> "ace_hearing")) then {EGVAR(hearing,disableVolumeUpdate) = true};
|
||||
if (isClass (configFile >> "CfgPatches" >> "acre_sys_radio")) then {[true] call acre_api_fnc_setSpectator};
|
||||
if (isClass (configFile >> "CfgPatches" >> "task_force_radio")) then {[player, true] call TFAR_fnc_forceSpectator};
|
||||
|
||||
if !GVAR(modulePos) then {
|
||||
_corpse = _this select 1;
|
||||
if (!isNil "_corpse") then {
|
||||
if (!isNull _corpse) then {
|
||||
GVAR(startingPos) = getPosATL _corpse;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Disable damage (vanilla and ace_medical)
|
||||
player allowDamage false;
|
||||
player setVariable ["ace_medical_allowDamage", false];
|
||||
|
||||
// Hide the player
|
||||
[player] joinSilent grpNull;
|
||||
hideObjectGlobal player;
|
||||
|
||||
// Prevent drowning and vision blur
|
||||
if (surfaceisWater GVAR(penPos)) then {
|
||||
player forceAddUniform "U_B_Wetsuit";
|
||||
player addVest "V_RebreatherB";
|
||||
};
|
||||
|
||||
0 fadeSound 0;
|
||||
999999 cutText ["", "BLACK FADED", 0];
|
||||
["Init", [true]] call FUNC(camera);
|
||||
}];
|
||||
player addEventHandler ["Respawn", FUNC(setSpectator)];
|
||||
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
@ -19,6 +19,7 @@ PREP(map);
|
||||
PREP(moduleSpectator);
|
||||
PREP(overlay);
|
||||
PREP(respawn);
|
||||
PREP(setSpectator);
|
||||
PREP(sideColour);
|
||||
PREP(status);
|
||||
PREP(trackUnits);
|
||||
|
71
addons/spectator/functions/fnc_setSpectator.sqf
Normal file
71
addons/spectator/functions/fnc_setSpectator.sqf
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Author: voiper, SilentSpike
|
||||
* 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>
|
||||
*
|
||||
* Return Value:
|
||||
* nil
|
||||
*
|
||||
* Example:
|
||||
* [player, _killer] call ace_spectator_fnc_setSpectator
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
_unit = player;
|
||||
_target = _this select 1;
|
||||
_set = if (count _this > 2) then {_this select 2} else {true};
|
||||
|
||||
if (_set isEqualTo (_unit getVariable [QGVAR(isSpectator), false])) exitWith {};
|
||||
|
||||
// Spectators aren't physical entities (todo: this command has to be executed on the server)
|
||||
_unit hideObjectGlobal _set;
|
||||
|
||||
if (isClass (configFile >> "CfgPatches" >> "ace_hearing")) then {EGVAR(hearing,disableVolumeUpdate) = _set};
|
||||
if (isClass (configFile >> "CfgPatches" >> "acre_sys_radio")) then {[_set] call acre_api_fnc_setSpectator};
|
||||
if (isClass (configFile >> "CfgPatches" >> "task_force_radio")) then {[_unit, _set] call TFAR_fnc_forceSpectator};
|
||||
|
||||
if (_set) then {
|
||||
// Move the player ASAP to avoid being seen
|
||||
_unit setPosATL GVAR(penPos);
|
||||
|
||||
if !(GVAR(modulePos)) then {
|
||||
if !(isNull _target) then {
|
||||
GVAR(startingPos) = getPosATL _target;
|
||||
};
|
||||
};
|
||||
|
||||
// Spectators shouldn't show in group UI
|
||||
[_unit] joinSilent grpNull;
|
||||
|
||||
// Prevent drowning and vision blur
|
||||
if (surfaceisWater GVAR(penPos)) then {
|
||||
_unit forceAddUniform "U_B_Wetsuit";
|
||||
_unit addVest "V_RebreatherB";
|
||||
};
|
||||
|
||||
// Dead men can't talk
|
||||
[_unit, "isSpectator"] call EFUNC(common,muteUnit);
|
||||
|
||||
0 fadeSound 0;
|
||||
999999 cutText ["", "BLACK FADED", 0];
|
||||
["Init", [true]] call FUNC(camera);
|
||||
} else {
|
||||
// Code to exit spectator and "respawn" player goes here (WIP)
|
||||
["Exit"] call FUNC(camera);
|
||||
};
|
||||
|
||||
// Spectators ignore damage (vanilla and ace_medical)
|
||||
_unit allowDamage !_set;
|
||||
_unit setVariable ["ace_medical_allowDamage", !_set];
|
||||
|
||||
// Mark spectator state for external reference
|
||||
[_unit,QGVAR(isSpectator),_set] call EFUNC(common,setVariableJIP);
|
||||
|
||||
["spectatorChanged",[_set]] call EFUNC(common,localEvent);
|
Loading…
Reference in New Issue
Block a user