mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add camera cycling function
This commit is contained in:
parent
2c1e346cca
commit
37ffdab2ca
@ -13,4 +13,14 @@ class ACE_Settings {
|
||||
value = 0;
|
||||
values[] = {CSTRING(sides_player), CSTRING(sides_friendly), CSTRING(sides_hostile), CSTRING(sides_all)};
|
||||
};
|
||||
class GVAR(restrictModes) {
|
||||
typeName = "SCALAR";
|
||||
value = 0;
|
||||
values[] = {CSTRING(modes_all), CSTRING(modes_unit), CSTRING(modes_free), CSTRING(modes_internal), CSTRING(modes_external)};
|
||||
};
|
||||
class GVAR(restrictVisions) {
|
||||
typeName = "SCALAR";
|
||||
value = 0;
|
||||
values[] = {CSTRING(modes_all), CSTRING(visions_nv), CSTRING(visions_ti), "$STR_Special_None"};
|
||||
};
|
||||
};
|
||||
|
@ -12,8 +12,10 @@
|
||||
[FUNC(checkUnits), 2] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(trackUnits), 20] call CBA_fnc_addPerFrameHandler;
|
||||
};*/
|
||||
GVAR(availableModes) = [[0,1,2], [1,2], [0], [1], [2]] select GVAR(restrictModes);
|
||||
GVAR(availableVisions) = [[-2,-1,0,1], [-2,-1], [-2,0,1], [-2]] select GVAR(restrictVisions);
|
||||
|
||||
if GVAR(system) then {
|
||||
if (GVAR(system)) then {
|
||||
// Add event handlers to correctly enter spectator upon death
|
||||
player addEventHandler ["Killed", FUNC(handleKilled)];
|
||||
player addEventHandler ["Respawn", FUNC(handleRespawn)];
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(cycleCamera);
|
||||
PREP(handleCamera);
|
||||
PREP(handleCompass);
|
||||
PREP(handleInterface);
|
||||
@ -18,6 +19,9 @@ PREP(toggleInterface);
|
||||
PREP(updateUnits);
|
||||
|
||||
// Permanent variables
|
||||
GVAR(availableModes) = [0,1,2];
|
||||
GVAR(availableVisions) = [-2,-1,0,1];
|
||||
|
||||
GVAR(camMode) = 0;
|
||||
GVAR(camPan) = 0;
|
||||
GVAR(camPos) = [worldSize * 0.5,worldSize * 0.5,20];
|
||||
|
47
addons/spectator/functions/fnc_cycleCamera.sqf
Normal file
47
addons/spectator/functions/fnc_cycleCamera.sqf
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author: SilentSpike
|
||||
* Cycle through the spectator camera vision/view/units in steps
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Camera mode steps <NUMBER>
|
||||
* 1: Camera unit steps <NUMBER>
|
||||
* 2: Vision mode steps <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None <NIL>
|
||||
*
|
||||
* Example:
|
||||
* [0, -1] call ace_spectator_fnc_cycleCamera
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params [["_stepMode",0], ["_stepUnit",0], ["_stepVision",0]];
|
||||
private ["_modes","_visions","_iMode","_iVision","_countModes","_countVisions","_newMode","_newVision","_newUnit"];
|
||||
|
||||
_modes = GVAR(availableModes);
|
||||
_visions = GVAR(availableVisions);
|
||||
|
||||
// Get current index
|
||||
_iMode = abs(_modes find GVAR(camMode));
|
||||
_iVision = abs(_visions find GVAR(camVision));
|
||||
|
||||
_countModes = count _modes;
|
||||
_countVisions = count _visions;
|
||||
|
||||
// Step index by step number (lopp ends)
|
||||
_iMode = (_iMode + _stepMode) % _countModes;
|
||||
if (_iMode < 0) then { _iMode = _countModes + _iMode; };
|
||||
|
||||
_iVision = (_iVision + _stepVision) % _countVisions;
|
||||
if (_iVision < 0) then { _iVision = _countVisions + _iVision; };
|
||||
|
||||
// Get value at new index
|
||||
_newMode = _modes select _iMode;
|
||||
_newVision = _visions select _iVision;
|
||||
|
||||
_newUnit = GVAR(camUnit);
|
||||
|
||||
[_newMode, _newUnit, _newVision] call FUNC(transitionCamera);
|
@ -189,7 +189,7 @@ switch (toLower _mode) do {
|
||||
GVAR(camBoom) set [1,true];
|
||||
};
|
||||
case 49: { // N
|
||||
|
||||
[nil,nil,1] call FUNC(cycleCamera);
|
||||
};
|
||||
case 50: { // M
|
||||
[_display,nil,nil,nil,true] call FUNC(toggleInterface);
|
||||
@ -200,7 +200,7 @@ switch (toLower _mode) do {
|
||||
// Freecam attachment here, if in external then set cam pos and attach
|
||||
};
|
||||
case 200: { // Up arrow
|
||||
[[2,0,1] select GVAR(camMode)] call FUNC(transitionCamera);
|
||||
[-1] call FUNC(cycleCamera);
|
||||
};
|
||||
case 203: { // Left arrow
|
||||
|
||||
@ -209,7 +209,7 @@ switch (toLower _mode) do {
|
||||
|
||||
};
|
||||
case 208: { // Down arrow
|
||||
[[1,2,0] select GVAR(camMode)] call FUNC(transitionCamera);
|
||||
[1] call FUNC(cycleCamera);
|
||||
};
|
||||
};
|
||||
|
||||
@ -260,9 +260,11 @@ switch (toLower _mode) do {
|
||||
_newMode = [2,2,1] select GVAR(camMode);
|
||||
};
|
||||
|
||||
if (_newMode in GVAR(availableModes)) then {
|
||||
[_newMode,_newUnit] call FUNC(transitionCamera);
|
||||
};
|
||||
};
|
||||
};
|
||||
case "onunitsupdate": {
|
||||
_args params ["_tree"];
|
||||
private ["_curSelData","_cachedGrps","_grp","_sNode","_gNode","_uNode"];
|
||||
|
@ -27,6 +27,11 @@
|
||||
|
||||
params [["_newMode",GVAR(camMode)], ["_newUnit",GVAR(camUnit)], ["_newVision",GVAR(camVision)]];
|
||||
|
||||
if !(_newMode in GVAR(availableModes)) exitWith {
|
||||
[1] call FUNC(cycleCamera);
|
||||
[nil, _newUnit, _newVision] call FUNC(transitionCamera);
|
||||
};
|
||||
|
||||
// When no units available to spectate, exit to freecam
|
||||
if (GVAR(unitList) isEqualTo []) then {
|
||||
_newMode = 0;
|
||||
|
@ -43,16 +43,38 @@
|
||||
<Key ID="STR_ACE_Spectator_sides_all">
|
||||
<English>All sides</English>
|
||||
</Key>
|
||||
|
||||
<Key ID="STR_ACE_Spectator_End_DisplayName">
|
||||
<English>End Mission</English>
|
||||
<Polish>Zakończ misję</Polish>
|
||||
<Czech>Konec mise</Czech>
|
||||
<Key ID="STR_ACE_Spectator_modes_DisplayName">
|
||||
<English>Camera modes</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_End_Description">
|
||||
<English>End mission when all players dead (default BIS behaviour)?</English>
|
||||
<Polish>Zakończ misję kiedy wszyscy gracze będą martwi (domyślne zachowanie BIS)?</Polish>
|
||||
<Czech>Ukončit misi když umřou všichni hráči (výchozí BIS chování)?</Czech>
|
||||
<Key ID="STR_ACE_Spectator_modes_Description">
|
||||
<English>Camera modes that can be used.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_modes_all">
|
||||
<English>All</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_modes_free">
|
||||
<English>Free only</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_modes_internal">
|
||||
<English>Internal only</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_modes_external">
|
||||
<English>External only</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_modes_unit">
|
||||
<English>Internal and external</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_visions_DisplayName">
|
||||
<English>Vision modes</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_visions_Description">
|
||||
<English>Vision modes that can be used.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_visions_nv">
|
||||
<English>Night vision</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Spectator_visions_ti">
|
||||
<English>Thermal Imaging</English>
|
||||
</Key>
|
||||
|
||||
<!-- Interface strings -->
|
||||
|
Loading…
Reference in New Issue
Block a user