From c4ef630b1e5f7ea4ee704f2333a7d1dabe5bc20a Mon Sep 17 00:00:00 2001 From: TheMagnetar Date: Mon, 5 Feb 2018 22:01:03 +0100 Subject: [PATCH] Fixes --- .../fnc_updateAvailableDevicesPosition.sqf | 1 + .../functions/fnc_createHelmetCam.sqf | 2 +- .../functions/fnc_createUavCam.sqf | 4 +-- addons/bft_devices/functions/fnc_ifUpdate.sqf | 2 +- .../functions/fnc_remoteControlUAV.sqf | 34 ++++++++++++++++++- .../functions/fnc_updateHCamList.sqf | 4 +-- .../functions/fnc_updateUAVList.sqf | 2 +- 7 files changed, 41 insertions(+), 8 deletions(-) diff --git a/addons/bft/functions/fnc_updateAvailableDevicesPosition.sqf b/addons/bft/functions/fnc_updateAvailableDevicesPosition.sqf index 3ac5e1e23d..708e90a761 100644 --- a/addons/bft/functions/fnc_updateAvailableDevicesPosition.sqf +++ b/addons/bft/functions/fnc_updateAvailableDevicesPosition.sqf @@ -40,6 +40,7 @@ if (_startNewLoop) then { // start a new position update loop GVAR(positionUpdatePFEH) = [{ { + systemChat format ["updating position"]; if (ACE_time - (AD_GET_TIME(_x)) >= (AD_GET_REFRESH_RATE(_x))) then { if (AD_GET_DEVICE_STATE_VALUE(_x) isEqualTo STATE_NORMAL) then { private _deviceOwner = AD_GET_OWNER(_x); diff --git a/addons/bft_devices/functions/fnc_createHelmetCam.sqf b/addons/bft_devices/functions/fnc_createHelmetCam.sqf index a9051b455c..34ac719627 100644 --- a/addons/bft_devices/functions/fnc_createHelmetCam.sqf +++ b/addons/bft_devices/functions/fnc_createHelmetCam.sqf @@ -28,7 +28,7 @@ private _targetOffSet = []; // see if given unit name is still in the list of units with valid helmet cams { if (_data == str _x) exitWith {_newHost = _x;}; -} count GVAR(hCamList); +} forEach GVAR(hCamList); call { // should unit not be in a vehicle diff --git a/addons/bft_devices/functions/fnc_createUavCam.sqf b/addons/bft_devices/functions/fnc_createUavCam.sqf index fe1acbf27c..53cf659974 100644 --- a/addons/bft_devices/functions/fnc_createUavCam.sqf +++ b/addons/bft_devices/functions/fnc_createUavCam.sqf @@ -35,7 +35,7 @@ private _uav = objNull; private _uavDeviceData = _x select 1; _uav = D_GET_OWNER(_uavDeviceData); }; -} count GVAR(UAVlist); +} forEach GVAR(UAVlist); // remove exisitng UAV cameras [] call FUNC(deleteUAVcam); @@ -79,7 +79,7 @@ if (!alive _uav) exitWith {false}; }; GVAR(UAVcams) pushBack [_uav,_renderTarget,_cam,_camPosMemPt,_camDirMemPt]; }; -} count _uavCams; +} forEach _uavCams; // set up event handler if !(GVAR(UAVcams) isEqualTo []) exitWith { diff --git a/addons/bft_devices/functions/fnc_ifUpdate.sqf b/addons/bft_devices/functions/fnc_ifUpdate.sqf index 597fd2cb94..7002753f76 100644 --- a/addons/bft_devices/functions/fnc_ifUpdate.sqf +++ b/addons/bft_devices/functions/fnc_ifUpdate.sqf @@ -550,7 +550,7 @@ if (isNil "_mode") then { }; // ---------------------------------- }; -} forEach ([_settings] call CBA_fnc_hashKeys); +} forEach (_settings select 1); // update scale and world position if we have to. If so, fill in the blanks and make the changes if ((!isNil "_targetMapScale") || (!isNil "_targetMapWorldPos")) then { diff --git a/addons/bft_devices/functions/fnc_remoteControlUAV.sqf b/addons/bft_devices/functions/fnc_remoteControlUAV.sqf index d3e0dd624c..75d05ddc75 100644 --- a/addons/bft_devices/functions/fnc_remoteControlUAV.sqf +++ b/addons/bft_devices/functions/fnc_remoteControlUAV.sqf @@ -21,11 +21,43 @@ // see if there is a selected UAV and if it is alive before continuing if (isNil QGVAR(actUav) || {!alive GVAR(actUav)}) exitWith {false}; +private _hasUavTraining = ace_player getVariable ["ACE_uavOperator", false]; +if (!_hasUavTraining) exitWith { + ["UAV","Action denied. You lack required training.",5] call FUNC(addNotification); + false +}; + // make sure there is noone currently controlling the gunner seat // unfortunately this fails as soon as there is a driver connected as only one unit is returned using UAVControl and it will alwasys be the driver if present. // see http://feedback.arma3.com/view.php?id=23693 if (UAVControl GVAR(actUav) select 1 != "GUNNER") then { // see if there is actually a gunner AI that we can remote control + + if (count (crew GVAR(actUav)) >= 2) then { + [] call FUNC(ifClose); + ace_player remoteControl (gunner GVAR(actUav)); + GVAR(actUav) switchCamera "Gunner"; + GVAR(uavViewActive) = true; + } else { + if (!("DRIVER" in uavControl GVAR(actUav))) then { + if (count (crew GVAR(actUav)) >= 1) then { + [] call FUNC(ifClose); + ace_player remoteControl ((crew GVAR(actUav)) select 0); + GVAR(actUav) switchCamera "INTERNAL"; + GVAR(uavViewActive) = true; + }; + }; + }; + + if (GVAR(uavViewActive)) then { + [{ + if (cameraOn != (_this select 0) || !GVAR(uavViewActive)) then { + [_this select 1] call CBA_fnc_removePerFrameHandler; + GVAR(uavViewActive) = false; + }; + },0,GVAR(actUav)] call CBA_fnc_addPerFrameHandler; + }; + /* private _uavGunner = gunner GVAR(actUav); if (!isNull _uavGunner) then { [] call FUNC(ifClose); @@ -42,7 +74,7 @@ if (UAVControl GVAR(actUav) select 1 != "GUNNER") then { } else { // show notification ["UAV","No gunner optics available",5] call FUNC(addNotification); - }; + };*/ } else { // show notification ["UAV","Another user has control",5] call FUNC(addNotification); diff --git a/addons/bft_devices/functions/fnc_updateHCamList.sqf b/addons/bft_devices/functions/fnc_updateHCamList.sqf index 4ff30ae5e3..260b9d2b05 100644 --- a/addons/bft_devices/functions/fnc_updateHCamList.sqf +++ b/addons/bft_devices/functions/fnc_updateHCamList.sqf @@ -31,7 +31,7 @@ private _validSides = []; if ([_deviceEncryptionKey, [_x] call EFUNC(bft,getEncryptionKey)] call EFUNC(bft,encryptionKeyMatch)) then { _validSides pushBack _x; }; -} count ["WEST","EAST","GUER","CIV"]; +} forEach ["WEST","EAST","GUER","CIV"]; // compile list of units with the ACE_HelmetCam item private _hcamList = []; @@ -41,7 +41,7 @@ private _hcamList = []; _hcamList pushBack _x; }; }; -} count allUnits; +} forEach allUnits; GVAR(hCamList) = _hcamList; diff --git a/addons/bft_devices/functions/fnc_updateUAVList.sqf b/addons/bft_devices/functions/fnc_updateUAVList.sqf index 566ef249c9..b4e7633cf8 100644 --- a/addons/bft_devices/functions/fnc_updateUAVList.sqf +++ b/addons/bft_devices/functions/fnc_updateUAVList.sqf @@ -40,6 +40,6 @@ GVAR(UAVlist) = []; GVAR(UAVlist) pushBack [_uavDevice,_uavDeviceData]; }; }; -} count allUnitsUAV; +} forEach allUnitsUAV; true