2015-07-02 23:53:26 +00:00
|
|
|
/*
|
|
|
|
* Author: voiper, SilentSpike
|
|
|
|
* Sets local player to the given spectator state
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-07-04 23:49:47 +00:00
|
|
|
* 0: Spectator camera target <OBJECT>
|
|
|
|
* 1: New spectator state <BOOL> <OPTIONAL>
|
2015-07-02 23:53:26 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-07-04 23:49:47 +00:00
|
|
|
* None <NIL>
|
2015-07-02 23:53:26 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, _killer] call ace_spectator_fnc_setSpectator
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
_unit = player;
|
2015-07-04 23:49:47 +00:00
|
|
|
_target = _this select 0;
|
|
|
|
_set = if (count _this > 1) then {_this select 1} else {true};
|
2015-07-02 23:53:26 +00:00
|
|
|
|
|
|
|
if (_set isEqualTo (_unit getVariable [QGVAR(isSpectator), false])) exitWith {};
|
|
|
|
|
2015-07-03 12:13:02 +00:00
|
|
|
// Prevent player falling into water
|
|
|
|
_unit enableSimulation !_set;
|
2015-07-02 23:53:26 +00:00
|
|
|
|
|
|
|
if (_set) then {
|
2015-07-04 18:41:18 +00:00
|
|
|
// Move and hide the player ASAP to avoid being seen
|
2015-07-03 12:13:02 +00:00
|
|
|
_unit setPosASL (getMarkerPos QGVAR(respawn));
|
|
|
|
[_unit] joinSilent grpNull;
|
|
|
|
|
2015-07-04 18:41:18 +00:00
|
|
|
// Ghosts can't talk
|
|
|
|
[_unit, "isSpectator"] call EFUNC(common,hideUnit);
|
2015-07-03 12:13:02 +00:00
|
|
|
[_unit, "isSpectator"] call EFUNC(common,muteUnit);
|
2015-07-02 23:53:26 +00:00
|
|
|
|
|
|
|
if !(GVAR(modulePos)) then {
|
|
|
|
if !(isNull _target) then {
|
|
|
|
GVAR(startingPos) = getPosATL _target;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
["Init", [true]] call FUNC(camera);
|
|
|
|
} else {
|
|
|
|
// Code to exit spectator and "respawn" player goes here (WIP)
|
|
|
|
["Exit"] call FUNC(camera);
|
2015-07-03 12:13:02 +00:00
|
|
|
|
2015-07-04 18:41:18 +00:00
|
|
|
// Physical beings can talk
|
|
|
|
[_unit, "isSpectator"] call EFUNC(common,unhideUnit);
|
2015-07-03 12:13:02 +00:00
|
|
|
[_unit, "isSpectator"] call EFUNC(common,unmuteUnit);
|
2015-07-04 23:07:51 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
};
|
2015-07-02 23:53:26 +00:00
|
|
|
};
|
|
|
|
|
2015-07-03 12:13:02 +00:00
|
|
|
// Handle common addon audio
|
2015-07-04 18:41:18 +00:00
|
|
|
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 (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator};
|
2015-07-03 12:13:02 +00:00
|
|
|
|
2015-07-02 23:53:26 +00:00
|
|
|
// Spectators ignore damage (vanilla and ace_medical)
|
|
|
|
_unit allowDamage !_set;
|
2015-07-05 00:01:27 +00:00
|
|
|
_unit setVariable [QEGVAR(medical,allowDamage), !_set];
|
2015-07-02 23:53:26 +00:00
|
|
|
|
|
|
|
// Mark spectator state for external reference
|
2015-07-05 00:01:27 +00:00
|
|
|
_unit setVariable [QGVAR(isSpectator), _set];
|
2015-07-02 23:53:26 +00:00
|
|
|
|
|
|
|
["spectatorChanged",[_set]] call EFUNC(common,localEvent);
|