Fix spectator respawn template for types 0 and 1

Type 0 worked, but the mission didn't end when all players were killed.
Type 1 didn't work because isPlayer isn't true for seagulls. So spectator virtual state is now entirely unassociated from objects in the game.
This commit is contained in:
SilentSpike 2015-08-08 12:24:49 +01:00
parent 57bda372f0
commit e59f0ce822
4 changed files with 22 additions and 26 deletions

View File

@ -80,7 +80,7 @@ switch (toLower _mode) do {
clearRadio; clearRadio;
// Return to player view // Return to player view
_unit switchCamera "internal"; player switchCamera "internal";
// Enable BI damage effects // Enable BI damage effects
BIS_fnc_feedback_allowPP = true; BIS_fnc_feedback_allowPP = true;

View File

@ -21,6 +21,11 @@
params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]]; params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]];
private ["_vision","_pos"]; private ["_vision","_pos"];
// End mission when all are dead with respawn type "None"
if ((_respawn == 0) && {{alive _x} count allPlayers <= 0}) exitWith {
[["endDeath",false],"BIS_fnc_endMission"] call EFUNC(common,execRemoteFnc);
};
if (isNull _killer) then {_killer = _unit}; if (isNull _killer) then {_killer = _unit};
_vision = [-2,-1] select (sunOrMoon < 1); _vision = [-2,-1] select (sunOrMoon < 1);
_pos = (getPosATL _unit) vectorAdd [0,0,5]; _pos = (getPosATL _unit) vectorAdd [0,0,5];
@ -29,11 +34,11 @@ if (alive _unit) then {
if (_respawn == 1) then { if (_respawn == 1) then {
[_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit); [_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit);
[2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes);
[_unit] call FUNC(setSpectator); [true] call FUNC(setSpectator);
} else { } else {
[_unit,false] call FUNC(setSpectator); [false] call FUNC(setSpectator);
}; };
} else { } else {
[2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes);
[_unit] call FUNC(setSpectator); [true] call FUNC(setSpectator);
}; };

View File

@ -1,48 +1,42 @@
/* /*
* Author: SilentSpike * Author: SilentSpike
* Sets target player to the given spectator state (virtually) * Sets local client to the given spectator state (virtually)
* To physically handle a spectator see ace_spectator_fnc_stageSpectator * To physically handle a spectator see ace_spectator_fnc_stageSpectator
* *
* Player will be able to communicate in ACRE/TFAR as appropriate * Client will be able to communicate in ACRE/TFAR as appropriate
* The spectator interface will be opened/closed * The spectator interface will be opened/closed
* *
* Arguments: * Arguments:
* 0: Unit to put into spectator state <OBJECT> * 0: Spectator state of local client <BOOL> <OPTIONAL>
* 1: Spectator state <BOOL> <OPTIONAL>
* *
* Return Value: * Return Value:
* None <NIL> * None <NIL>
* *
* Example: * Example:
* [player, true] call ace_spectator_fnc_setSpectator * [true] call ace_spectator_fnc_setSpectator
* *
* Public: Yes * Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", ["_set",true,[true]]]; params [["_set",true,[true]]];
// Only run for player units // Only clients can be spectators
if !(isPlayer _unit) exitWith {}; if !(hasInterface) exitWith {};
if !(local _unit) exitwith {
[[_unit, _set], QFUNC(setSpectator), _unit] call EFUNC(common,execRemoteFnc);
};
// Handle common addon audio // Handle common addon audio
if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = _set}; if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = _set};
if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator}; if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator};
if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator}; if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[player, _set] call TFAR_fnc_forceSpectator};
if (_set) then { if (_set) then {
["open"] call FUNC(handleInterface); ["open"] call FUNC(handleInterface);
} else { } else {
["close",_unit] call FUNC(handleInterface); ["close"] call FUNC(handleInterface);
}; };
// Mark spectator state for reference // Mark spectator state for reference
_unit setVariable [QGVAR(isSet), _set, true];
GVAR(isSet) = _set; GVAR(isSet) = _set;
["spectatorSet",[_set,_unit]] call EFUNC(common,localEvent); ["spectatorSet",[_set]] call EFUNC(common,localEvent);

View File

@ -7,7 +7,7 @@
* Upon unstage, units will be moved to the position they were in upon staging * Upon unstage, units will be moved to the position they were in upon staging
* *
* Arguments: * Arguments:
* 0: Unit to put into spectator stage <OBJECT> * 0: Unit to put into spectator stage <OBJECT> <OPTIONAL>
* 1: Spectator stage <BOOL> <OPTIONAL> * 1: Spectator stage <BOOL> <OPTIONAL>
* *
* Return Value: * Return Value:
@ -21,19 +21,16 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", ["_set",true,[true]]]; params [["_unit",player,[objNull]], ["_set",true,[true]]];
// No change, no service (but allow spectators to be reset) // No change, no service (but allow spectators to be reset)
if !(_set || (GETVAR(_unit,GVAR(isStaged),false))) exitWith {}; if !(_set || (GETVAR(_unit,GVAR(isStaged),false))) exitWith {};
// Only run for player units
if !(isPlayer _unit) exitWith {};
if !(local _unit) exitwith { if !(local _unit) exitwith {
[[_unit, _set], QFUNC(stageSpectator), _unit] call EFUNC(common,execRemoteFnc); [[_unit, _set], QFUNC(stageSpectator), _unit] call EFUNC(common,execRemoteFnc);
}; };
// Prevent player falling into water // Prevent unit falling into water
_unit enableSimulation !_set; _unit enableSimulation !_set;
// Move to/from group as appropriate // Move to/from group as appropriate