Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBA_fnc_currentUnit report UAV entity when controlling UAV #1005

Merged
merged 6 commits into from
Nov 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions addons/events/fnc_addPlayerEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,16 @@ 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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change still necessary? I mean.. I like the performance gain..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it just to compensate for the loss due to this.

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;
Expand Down Expand Up @@ -189,7 +192,24 @@ 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 {
GVAR(oldUAVControl) = _data;

private _role = _data param [(_data find _player) + 1, ""];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the wiki page wrong?
https://community.bistudio.com/wiki/UAVControl
_data should be 2 element array. find _player should always return 0.

Copy link
Contributor Author

@commy2 commy2 Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the wiki page wrong?

Always.

Drone with turret + driver/pilot looks like this:
[object1, "DRIVER", object2, "GUNNER"]
In MP, it can be controlled by multiple people. Therefore #0 is not necessarily the local player.

if (_role isEqualTo "DRIVER") exitWith {
GVAR(controlledEntity) = driver getConnectedUAV _player;
};

if (_role isEqualTo "GUNNER") exitWith {
GVAR(controlledEntity) = gunner getConnectedUAV _player;
};

GVAR(controlledEntity) = _player;
};

_data = currentVisionMode GVAR(controlledEntity);
if !(_data isEqualTo GVAR(oldVisionMode)) then {
GVAR(oldVisionMode) = _data;
[QGVAR(visionModeEvent), [_player, _data]] call CBA_fnc_localEvent;
Expand Down