Cache details on respawn (not at postInit)

This commit is contained in:
SilentSpike 2015-07-05 00:07:51 +01:00
parent c09314027f
commit 5e7c094c98
3 changed files with 22 additions and 11 deletions

View File

@ -1,14 +1,19 @@
#include "script_component.hpp"
// Add interaction menu exception
["isNotSpectating", {!((_this select 0) getVariable [QGVAR(isSpectator), false])}] call EFUNC(common,addCanInteractWithCondition);
// Run spectator framework if enabled
["SettingsInitialized", {
if !GVAR(enabled) exitWith {};
//check if respawn is set up properly
_fail = if (getNumber (missionConfigFile >> "respawn") != 3 && getText (missionConfigFile >> "respawn") != "Base") then {true} else {false};
if (_fail) exitWith {
_text = "[ACE_Spectator] ERROR: This mission does not have respawn set up properly. Add 'respawn=3' or 'respawn=""BASE""' to description.ext.";
systemChat _text;
diag_log text _text;
_errorMsg = "This mission does not have respawn set up properly. Add 'respawn=3' or 'respawn=""BASE""' to description.ext.";
["[ACE_Spectator] ERROR", _errorMsg, {}] call EFUNC(common,errorMessage);
diag_log text format ["[ACE_Spectator] ERROR: %1", _errorMsg];
};
if (GVAR(endMission) && isServer) then {
@ -22,11 +27,6 @@
if !(hasInterface) exitWith {};
// Add interaction menu exception
["isNotSpectating", {!((_this select 0) getVariable [QGVAR(isSpectator), false])}] call EFUNC(common,addCanInteractWithCondition);
GVAR(playerSide) = side (group player);
if GVAR(tracking) then {
[FUNC(checkUnits), 2] call CBA_fnc_addPerFrameHandler;
[FUNC(trackUnits), 20] call CBA_fnc_addPerFrameHandler;

View File

@ -30,6 +30,8 @@ _this = _this select 1;
switch _mode do {
case "Init": {
0 fadeSound 0;
999999 cutText ["", "BLACK FADED", 0];
GVAR(noEscape) = if (count _this > 0) then {
_this select 0

View File

@ -28,6 +28,10 @@ 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;
@ -42,8 +46,6 @@ if (_set) then {
};
};
0 fadeSound 0;
999999 cutText ["", "BLACK FADED", 0];
["Init", [true]] call FUNC(camera);
} else {
// Code to exit spectator and "respawn" player goes here (WIP)
@ -52,6 +54,13 @@ if (_set) then {
// Physical beings can talk
[_unit, "isSpectator"] call EFUNC(common,unhideUnit);
[_unit, "isSpectator"] call EFUNC(common,unmuteUnit);
// Don't create groups unless necessary (arma has a group limit)
if (isNull GVAR(cachedGroup)) then {
[_unit] joinSilent (createGroup GVAR(cachedSide));
} else {
[_unit] joinSilent GVAR(cachedGroup);
};
};
// Handle common addon audio
@ -64,6 +73,6 @@ _unit allowDamage !_set;
_unit setVariable [QGVAR(medical,allowDamage), !_set];
// Mark spectator state for external reference
[_unit,QGVAR(isSpectator),_set] call EFUNC(common,setVariableJIP);
_unit setVariable [QGVAR(isSpectator),_set];
["spectatorChanged",[_set]] call EFUNC(common,localEvent);