2015-07-02 23:53:26 +00:00
|
|
|
/*
|
2015-07-15 10:48:49 +00:00
|
|
|
* Author: SilentSpike
|
2015-08-08 11:24:49 +00:00
|
|
|
* Sets local client to the given spectator state (virtually)
|
2015-08-01 17:10:11 +00:00
|
|
|
* To physically handle a spectator see ace_spectator_fnc_stageSpectator
|
|
|
|
*
|
2015-08-08 11:24:49 +00:00
|
|
|
* Client will be able to communicate in ACRE/TFAR as appropriate
|
2015-08-01 17:10:11 +00:00
|
|
|
* The spectator interface will be opened/closed
|
2015-07-02 23:53:26 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-10-04 12:52:54 +00:00
|
|
|
* 0: Spectator state of local client <BOOL> (default: true)
|
|
|
|
* 1: Force interface <BOOL> (default: true)
|
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:
|
2015-08-08 11:24:49 +00:00
|
|
|
* [true] call ace_spectator_fnc_setSpectator
|
2015-07-02 23:53:26 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-10-04 12:52:54 +00:00
|
|
|
params [["_set",true,[true]], ["_force",true,[true]]];
|
2015-07-02 23:53:26 +00:00
|
|
|
|
2015-08-08 11:24:49 +00:00
|
|
|
// Only clients can be spectators
|
2015-09-11 14:58:26 +00:00
|
|
|
if (!hasInterface) exitWith {};
|
2015-07-09 20:20:09 +00:00
|
|
|
|
2015-08-23 16:50:11 +00:00
|
|
|
// Exit if no change
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_set isEqualTo GVAR(isSet)) exitWith {};
|
2015-08-23 16:50:11 +00:00
|
|
|
|
2015-08-03 20:38:44 +00:00
|
|
|
// Handle common addon audio
|
2015-11-13 12:59:46 +00:00
|
|
|
if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {
|
|
|
|
EGVAR(hearing,disableVolumeUpdate) = _set;
|
|
|
|
EGVAR(hearing,deafnessDV) = 0;
|
|
|
|
};
|
2015-08-03 20:38:44 +00:00
|
|
|
if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator};
|
2015-08-08 11:24:49 +00:00
|
|
|
if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[player, _set] call TFAR_fnc_forceSpectator};
|
2015-08-03 20:38:44 +00:00
|
|
|
|
2015-07-02 23:53:26 +00:00
|
|
|
if (_set) then {
|
2015-08-23 16:50:11 +00:00
|
|
|
// Initalize camera variables
|
|
|
|
GVAR(camBoom) = 0;
|
|
|
|
GVAR(camDolly) = [0,0];
|
|
|
|
GVAR(camGun) = false;
|
|
|
|
|
|
|
|
// Initalize display variables
|
|
|
|
GVAR(ctrlKey) = false;
|
|
|
|
GVAR(heldKeys) = [];
|
|
|
|
GVAR(heldKeys) resize 255;
|
|
|
|
GVAR(mouse) = [false,false];
|
|
|
|
GVAR(mousePos) = [0.5,0.5];
|
|
|
|
|
|
|
|
// Update units before opening to support pre-set camera unit
|
|
|
|
[] call FUNC(updateUnits);
|
|
|
|
|
2015-09-09 22:21:49 +00:00
|
|
|
// Initalize the camera objects
|
|
|
|
GVAR(freeCamera) = "Camera" camCreate (ASLtoATL GVAR(camPos));
|
|
|
|
GVAR(unitCamera) = "Camera" camCreate [0,0,0];
|
|
|
|
GVAR(targetCamera) = "Camera" camCreate [0,0,0];
|
|
|
|
|
|
|
|
// Initalize view
|
|
|
|
GVAR(unitCamera) camSetTarget GVAR(targetCamera);
|
|
|
|
GVAR(unitCamera) camCommit 0;
|
2015-08-23 16:50:11 +00:00
|
|
|
[] call FUNC(transitionCamera);
|
|
|
|
|
|
|
|
// Close map and clear radio
|
|
|
|
openMap [false,false];
|
|
|
|
clearRadio;
|
|
|
|
|
|
|
|
// Disable BI damage effects
|
|
|
|
BIS_fnc_feedback_allowPP = false;
|
|
|
|
|
|
|
|
// Close any open dialogs
|
|
|
|
while {dialog} do {
|
|
|
|
closeDialog 0;
|
|
|
|
};
|
|
|
|
|
2015-09-25 10:51:13 +00:00
|
|
|
[{
|
|
|
|
// Create the display
|
|
|
|
(findDisplay 46) createDisplay QGVAR(interface);
|
2015-10-04 12:52:54 +00:00
|
|
|
|
|
|
|
// If not forced, make esc end spectator
|
|
|
|
if (_this) then {
|
|
|
|
(findDisplay 12249) displayAddEventHandler ["KeyDown", {
|
|
|
|
if (_this select 1 == 1) then {
|
|
|
|
[false] call ace_spectator_fnc_setSpectator;
|
|
|
|
true
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
}, !_force] call EFUNC(common,execNextFrame);
|
2015-08-23 16:50:11 +00:00
|
|
|
|
|
|
|
// Cache and disable nametag settings
|
|
|
|
if (["ace_nametags"] call EFUNC(common,isModLoaded)) then {
|
|
|
|
GVAR(nametagSettingCache) = [EGVAR(nametags,showPlayerNames), EGVAR(nametags,showNamesForAI)];
|
|
|
|
EGVAR(nametags,showPlayerNames) = 0;
|
|
|
|
EGVAR(nametags,showNamesForAI) = false;
|
|
|
|
};
|
2015-07-02 23:53:26 +00:00
|
|
|
} else {
|
2015-08-23 16:50:11 +00:00
|
|
|
// Close any open dialogs (could be interrupts)
|
|
|
|
while {dialog} do {
|
|
|
|
closeDialog 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Kill the display
|
|
|
|
(findDisplay 12249) closeDisplay 0;
|
|
|
|
|
|
|
|
// Terminate camera
|
2015-09-09 22:21:49 +00:00
|
|
|
GVAR(freeCamera) cameraEffect ["terminate", "back"];
|
|
|
|
camDestroy GVAR(freeCamera);
|
|
|
|
camDestroy GVAR(unitCamera);
|
|
|
|
camDestroy GVAR(targetCamera);
|
2015-08-23 16:50:11 +00:00
|
|
|
|
|
|
|
clearRadio;
|
|
|
|
|
|
|
|
// Return to player view
|
|
|
|
player switchCamera "internal";
|
|
|
|
|
|
|
|
// Enable BI damage effects
|
|
|
|
BIS_fnc_feedback_allowPP = true;
|
|
|
|
|
|
|
|
// Cleanup camera variables
|
|
|
|
GVAR(camBoom) = nil;
|
|
|
|
GVAR(camDolly) = nil;
|
|
|
|
GVAR(camGun) = nil;
|
2015-09-09 22:21:49 +00:00
|
|
|
GVAR(freeCamera) = nil;
|
|
|
|
GVAR(unitCamera) = nil;
|
|
|
|
GVAR(targetCamera) = nil;
|
2015-08-23 16:50:11 +00:00
|
|
|
|
|
|
|
// Cleanup display variables
|
|
|
|
GVAR(ctrlKey) = nil;
|
|
|
|
GVAR(heldKeys) = nil;
|
|
|
|
GVAR(mouse) = nil;
|
|
|
|
GVAR(mousePos) = nil;
|
|
|
|
|
|
|
|
// Reset nametag settings
|
|
|
|
if (["ace_nametags"] call EFUNC(common,isModLoaded)) then {
|
|
|
|
EGVAR(nametags,showPlayerNames) = GVAR(nametagSettingCache) select 0;
|
|
|
|
EGVAR(nametags,showNamesForAI) = GVAR(nametagSettingCache) select 1;
|
|
|
|
GVAR(nametagSettingCache) = nil;
|
|
|
|
};
|
2015-07-02 23:53:26 +00:00
|
|
|
};
|
|
|
|
|
2015-08-23 16:50:11 +00:00
|
|
|
// Reset interruptions
|
|
|
|
GVAR(interrupts) = [];
|
|
|
|
|
2015-08-03 20:38:44 +00:00
|
|
|
// Mark spectator state for reference
|
|
|
|
GVAR(isSet) = _set;
|
2015-08-02 11:47:26 +00:00
|
|
|
|
2015-08-08 11:24:49 +00:00
|
|
|
["spectatorSet",[_set]] call EFUNC(common,localEvent);
|