mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
77c2b99ee5
Using the "external" view is limited by the server difficulty setting. Instead the spectator external camera has been replaced with an oribtal camera as was originally planned to be added alongside the default views.
137 lines
3.7 KiB
Plaintext
137 lines
3.7 KiB
Plaintext
/*
|
|
* Author: SilentSpike
|
|
* Sets local client to the given spectator state (virtually)
|
|
* To physically handle a spectator see ace_spectator_fnc_stageSpectator
|
|
*
|
|
* Client will be able to communicate in ACRE/TFAR as appropriate
|
|
* The spectator interface will be opened/closed
|
|
*
|
|
* Arguments:
|
|
* 0: Spectator state of local client <BOOL> <OPTIONAL>
|
|
*
|
|
* Return Value:
|
|
* None <NIL>
|
|
*
|
|
* Example:
|
|
* [true] call ace_spectator_fnc_setSpectator
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
params [["_set",true,[true]]];
|
|
|
|
// Only clients can be spectators
|
|
if !(hasInterface) exitWith {};
|
|
|
|
// Exit if no change
|
|
if (_set isEqualTo GVAR(isSet)) exitwith {};
|
|
|
|
// Handle common addon audio
|
|
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 {[player, _set] call TFAR_fnc_forceSpectator};
|
|
|
|
if (_set) then {
|
|
// 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];
|
|
GVAR(treeSel) = objNull;
|
|
|
|
// Update units before opening to support pre-set camera unit
|
|
[] call FUNC(updateUnits);
|
|
|
|
// 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;
|
|
[] 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;
|
|
};
|
|
|
|
// Create the display
|
|
(findDisplay 46) createDisplay QGVAR(interface);
|
|
|
|
// 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;
|
|
};
|
|
} else {
|
|
// Close any open dialogs (could be interrupts)
|
|
while {dialog} do {
|
|
closeDialog 0;
|
|
};
|
|
|
|
// Kill the display
|
|
(findDisplay 12249) closeDisplay 0;
|
|
|
|
// Terminate camera
|
|
GVAR(freeCamera) cameraEffect ["terminate", "back"];
|
|
camDestroy GVAR(freeCamera);
|
|
camDestroy GVAR(unitCamera);
|
|
camDestroy GVAR(targetCamera);
|
|
|
|
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;
|
|
GVAR(freeCamera) = nil;
|
|
GVAR(unitCamera) = nil;
|
|
GVAR(targetCamera) = nil;
|
|
|
|
// Cleanup display variables
|
|
GVAR(ctrlKey) = nil;
|
|
GVAR(heldKeys) = nil;
|
|
GVAR(mouse) = nil;
|
|
GVAR(mousePos) = nil;
|
|
GVAR(treeSel) = 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;
|
|
};
|
|
};
|
|
|
|
// Reset interruptions
|
|
GVAR(interrupts) = [];
|
|
|
|
// Mark spectator state for reference
|
|
GVAR(isSet) = _set;
|
|
|
|
["spectatorSet",[_set]] call EFUNC(common,localEvent);
|