Fix pre-spectator position saving

When staging a spectator (physically applying the spectator state) the unit position is saved for potential later restoration. This shouldn't be done multiple times since the function can be called again to reset staged units.
This commit is contained in:
SilentSpike 2015-08-03 00:24:36 +01:00
parent b87b4ea16a
commit 98b088f26f
2 changed files with 8 additions and 3 deletions

View File

@ -15,4 +15,6 @@
#include "script_component.hpp"
params ["_unit","_oldUnit"];
[_unit,false] call FUNC(setSpectator);

View File

@ -40,13 +40,16 @@ _unit enableSimulation !_set;
[_unit, _set, QGVAR(isStaged), side group _unit] call EFUNC(common,switchToGroupSide);
if (_set) then {
// Move and hide the player ASAP to avoid being seen
GVAR(oldPos) = getPosATL _unit;
_unit setPos (getMarkerPos QGVAR(respawn));
// Position should only be saved on first entry
if !(GETVAR(_unit,GVAR(isStaged),false)) then {
GVAR(oldPos) = getPosATL _unit;
};
// Ghosts can't talk
[_unit, QGVAR(isStaged)] call EFUNC(common,hideUnit);
[_unit, QGVAR(isStaged)] call EFUNC(common,muteUnit);
_unit setPos (getMarkerPos QGVAR(respawn));
} else {
// Physical beings can talk
[_unit, QGVAR(isStaged)] call EFUNC(common,unhideUnit);