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)); onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface));
}; };
class unitRefresh: RscButtonMenu { class unitRefresh: RscButtonMenu {
style = 2;
x = 0; x = 0;
y = safeZoneH - TOOL_H * 3; y = safeZoneH - TOOL_H * 3;
w = TOOL_W * 2; w = TOOL_W * 2;

View File

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

View File

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