From 4419fbf021ff63eaa3d59deff3895dbd88091643 Mon Sep 17 00:00:00 2001 From: commy2 Date: Thu, 11 Oct 2018 23:21:26 +0200 Subject: [PATCH 1/5] CBA_fnc_currentUnit report UAV entity when controlling UAV --- addons/common/fnc_currentUnit.sqf | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/common/fnc_currentUnit.sqf b/addons/common/fnc_currentUnit.sqf index 713514337..7ce63326f 100644 --- a/addons/common/fnc_currentUnit.sqf +++ b/addons/common/fnc_currentUnit.sqf @@ -16,4 +16,14 @@ Author: ---------------------------------------------------------------------------- */ SCRIPT(currentUnit); -missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player] +private _unit = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player]; + +private _uav = getConnectedUAV _unit; +if (isNull _uav) exitWith {_unit}; + +private _temp = UAVControl _uav; +_temp = _temp param [(_temp find _unit) + 1]; + +if (_temp isEqualTo "DRIVER") exitWith {driver _uav}; +if (_temp isEqualTo "GUNNER") exitWith {gunner _uav}; +_unit From 1cb13744207d678088aab79bb4a4c993b447cdd6 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 12 Oct 2018 14:09:33 +0200 Subject: [PATCH 2/5] use controlled entity to read visionMode --- addons/common/fnc_currentUnit.sqf | 12 +-------- addons/events/fnc_addPlayerEventHandler.sqf | 27 +++++++++++++++++++-- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/addons/common/fnc_currentUnit.sqf b/addons/common/fnc_currentUnit.sqf index 7ce63326f..713514337 100644 --- a/addons/common/fnc_currentUnit.sqf +++ b/addons/common/fnc_currentUnit.sqf @@ -16,14 +16,4 @@ Author: ---------------------------------------------------------------------------- */ SCRIPT(currentUnit); -private _unit = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player]; - -private _uav = getConnectedUAV _unit; -if (isNull _uav) exitWith {_unit}; - -private _temp = UAVControl _uav; -_temp = _temp param [(_temp find _unit) + 1]; - -if (_temp isEqualTo "DRIVER") exitWith {driver _uav}; -if (_temp isEqualTo "GUNNER") exitWith {gunner _uav}; -_unit +missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player] diff --git a/addons/events/fnc_addPlayerEventHandler.sqf b/addons/events/fnc_addPlayerEventHandler.sqf index c3e22fbae..16db769bb 100644 --- a/addons/events/fnc_addPlayerEventHandler.sqf +++ b/addons/events/fnc_addPlayerEventHandler.sqf @@ -129,10 +129,12 @@ if (_id != -1) then { GVAR(oldCameraView) = ""; GVAR(oldFeatureCamera) = ""; GVAR(oldVisibleMap) = false; + GVAR(oldUAVControl) = []; + GVAR(controlledEntity) = objNull; GVAR(playerEHInfo) pushBack addMissionEventHandler ["EachFrame", {call FUNC(playerEH_EachFrame)}]; [QFUNC(playerEH_EachFrame), { - private _player = call CBA_fnc_currentUnit; + private _player = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player]; if !(_player isEqualTo GVAR(oldUnit)) then { [QGVAR(unitEvent), [_player, GVAR(oldUnit)]] call CBA_fnc_localEvent; GVAR(oldUnit) = _player; @@ -189,7 +191,28 @@ if (_id != -1) then { [QGVAR(turretEvent), [_player, _data]] call CBA_fnc_localEvent; }; - _data = currentVisionMode _player; + // handle controlling UAV, UAV entity needed for visionMode + _data = UAVControl getConnectedUAV _player; + if (_data isEqualTo GVAR(oldUAVControl)) then { + _data = GVAR(controlledEntity); + } else { + GVAR(oldUAVControl) = _data; + + private _role = _data param [(_data find _player) + 1]; + if (_role isEqualTo "DRIVER") then { + GVAR(controlledEntity) = driver getConnectedUAV _player; + } else { + if (_role isEqualTo "GUNNER") then { + GVAR(controlledEntity) = gunner getConnectedUAV _player; + } else { + GVAR(controlledEntity) = _player; + }; + }; + + _data = GVAR(controlledEntity); + }; + + _data = currentVisionMode GVAR(controlledEntity); if !(_data isEqualTo GVAR(oldVisionMode)) then { GVAR(oldVisionMode) = _data; [QGVAR(visionModeEvent), [_player, _data]] call CBA_fnc_localEvent; From 101edb58b7b3e1d2437465739fb9521c74da71fd Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 12 Oct 2018 14:12:13 +0200 Subject: [PATCH 3/5] use controlled entity to read visionMode --- addons/events/fnc_addPlayerEventHandler.sqf | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/addons/events/fnc_addPlayerEventHandler.sqf b/addons/events/fnc_addPlayerEventHandler.sqf index 16db769bb..32053bc61 100644 --- a/addons/events/fnc_addPlayerEventHandler.sqf +++ b/addons/events/fnc_addPlayerEventHandler.sqf @@ -193,23 +193,19 @@ if (_id != -1) then { // handle controlling UAV, UAV entity needed for visionMode _data = UAVControl getConnectedUAV _player; - if (_data isEqualTo GVAR(oldUAVControl)) then { - _data = GVAR(controlledEntity); - } else { + if !(_data isEqualTo GVAR(oldUAVControl)) then { GVAR(oldUAVControl) = _data; private _role = _data param [(_data find _player) + 1]; - if (_role isEqualTo "DRIVER") then { + if (_role isEqualTo "DRIVER") exitWith { GVAR(controlledEntity) = driver getConnectedUAV _player; - } else { - if (_role isEqualTo "GUNNER") then { - GVAR(controlledEntity) = gunner getConnectedUAV _player; - } else { - GVAR(controlledEntity) = _player; - }; }; - _data = GVAR(controlledEntity); + if (_role isEqualTo "GUNNER") exitWith { + GVAR(controlledEntity) = gunner getConnectedUAV _player; + }; + + GVAR(controlledEntity) = _player; }; _data = currentVisionMode GVAR(controlledEntity); From 050baf1f9b20e2951e4c3b99097340e407d4c4ab Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 12 Oct 2018 14:27:09 +0200 Subject: [PATCH 4/5] fix a thing --- addons/events/fnc_addPlayerEventHandler.sqf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/events/fnc_addPlayerEventHandler.sqf b/addons/events/fnc_addPlayerEventHandler.sqf index 32053bc61..fd8d899b3 100644 --- a/addons/events/fnc_addPlayerEventHandler.sqf +++ b/addons/events/fnc_addPlayerEventHandler.sqf @@ -192,11 +192,12 @@ if (_id != -1) then { }; // handle controlling UAV, UAV entity needed for visionMode - _data = UAVControl getConnectedUAV _player; + _data = [_player, UAVControl getConnectedUAV _player]; if !(_data isEqualTo GVAR(oldUAVControl)) then { GVAR(oldUAVControl) = _data; - private _role = _data param [(_data find _player) + 1]; + _data = _data select 1; + private _role = _data param [(_data find _player) + 1, ""]; if (_role isEqualTo "DRIVER") exitWith { GVAR(controlledEntity) = driver getConnectedUAV _player; }; From 02101faf6a3220259a5f4d70dce9e31cf68c1e30 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 12 Oct 2018 14:40:47 +0200 Subject: [PATCH 5/5] optimize --- addons/events/fnc_addPlayerEventHandler.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/events/fnc_addPlayerEventHandler.sqf b/addons/events/fnc_addPlayerEventHandler.sqf index fd8d899b3..a0f5b5629 100644 --- a/addons/events/fnc_addPlayerEventHandler.sqf +++ b/addons/events/fnc_addPlayerEventHandler.sqf @@ -138,6 +138,7 @@ if (_id != -1) then { if !(_player isEqualTo GVAR(oldUnit)) then { [QGVAR(unitEvent), [_player, GVAR(oldUnit)]] call CBA_fnc_localEvent; GVAR(oldUnit) = _player; + GVAR(oldUAVControl) = []; // force update }; private _data = group _player; @@ -192,11 +193,10 @@ if (_id != -1) then { }; // handle controlling UAV, UAV entity needed for visionMode - _data = [_player, UAVControl getConnectedUAV _player]; + _data = UAVControl getConnectedUAV _player; if !(_data isEqualTo GVAR(oldUAVControl)) then { GVAR(oldUAVControl) = _data; - _data = _data select 1; private _role = _data param [(_data find _player) + 1, ""]; if (_role isEqualTo "DRIVER") exitWith { GVAR(controlledEntity) = driver getConnectedUAV _player;