Improved unit switching

This commit is contained in:
SilentSpike 2015-07-17 18:54:19 +01:00
parent 832fa1e832
commit 10c1c26c69
3 changed files with 10 additions and 9 deletions

View File

@ -170,7 +170,6 @@ class GVAR(interface) {
onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface));
};
class unitRefresh: RscButtonMenu {
style = 2;
x = 0;
y = safeZoneH - TOOL_H * 3;
w = TOOL_W * 2;

View File

@ -299,8 +299,7 @@ switch (toLower _mode) do {
_newMode = [2,2,1] select GVAR(camMode);
};
GVAR(camUnit) = _newUnit;
[_newMode] call FUNC(updateView);
[_newMode,_newUnit] call FUNC(updateView);
};
};
};

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
params [["_newMode",GVAR(camMode)]];
params [["_newMode",GVAR(camMode)],["_newUnit",GVAR(camUnit)]];
// Reset gun cam if mode is changing
if (_newMode != GVAR(camMode)) then {
@ -11,6 +11,7 @@ if (_newMode != GVAR(camMode)) then {
// When no units available to spectate, exit to freecam
if (GVAR(unitList) isEqualTo []) then {
GVAR(camMode) = 0;
GVAR(camUnit) = objNull;
};
if (GVAR(camMode) == 0) then { // Free
@ -21,21 +22,23 @@ if (GVAR(camMode) == 0) then { // Free
cameraEffectEnableHUD false;
} else {
// First ensure valid unit is selected
if !(GVAR(camUnit) in GVAR(unitList)) then {
GVAR(camUnit) = GVAR(unitList) select floor(random(count GVAR(unitList)));
if !(_newUnit in GVAR(unitList)) then {
_newUnit = GVAR(unitList) select floor(random(count GVAR(unitList)));
};
if (GVAR(camMode) == 1) then { // Internal
// Handle gun cam
if (GVAR(gunCam)) then {
GVAR(camUnit) switchCamera "gunner";
_newUnit switchCamera "gunner";
} else {
GVAR(camUnit) switchCamera "internal";
_newUnit switchCamera "internal";
};
} else { // External
GVAR(camUnit) switchCamera "external";
_newUnit switchCamera "external";
};
GVAR(camUnit) = _newUnit;
// Terminate camera view
GVAR(camera) cameraEffect ["terminate", "back"];
cameraEffectEnableHUD true;