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

Events - Player events will report driver seat as turret [-1] #1313

Merged
merged 3 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions addons/events/fnc_addPlayerEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ private _id = switch (_type) do {
};
case "turretweapon": {
if (_applyRetroactively) then {
[GVAR(oldUnit), (vehicle GVAR(oldUnit)) currentWeaponTurret (GVAR(oldUnit) call CBA_fnc_turretPath), ""] call _function;
private _vehicle = vehicle GVAR(oldUnit);
private _turret = [];
if (GVAR(oldUnit) != _vehicle) then {
_turret = ([[-1]] + allTurrets [_vehicle, true]) select {_vehicle turretUnit _x == GVAR(oldUnit)} param [0, []];
};
[GVAR(oldUnit), _vehicle currentWeaponTurret _turret, ""] call _function;
};
[QGVAR(turretWeaponEvent), _function] call CBA_fnc_addEventHandler // return id
};
Expand Down Expand Up @@ -95,7 +100,12 @@ private _id = switch (_type) do {
};
case "turret": {
if (_applyRetroactively) then {
[GVAR(oldUnit), GVAR(oldUnit) call CBA_fnc_turretPath, []] call _function;
private _vehicle = vehicle GVAR(oldUnit);
private _turret = [];
if (GVAR(oldUnit) != _vehicle) then {
_turret = ([[-1]] + allTurrets [_vehicle, true]) select {_vehicle turretUnit _x == GVAR(oldUnit)} param [0, []];
};
[GVAR(oldUnit), _turret, []] call _function;
};
[QGVAR(turretEvent), _function] call CBA_fnc_addEventHandler // return id
};
Expand Down
3 changes: 2 additions & 1 deletion addons/events/fnc_playerEvent.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ if (!isNull getConnectedUAV _unit) then {

private _turret = [];
if (_unit != _vehicle) then {
_turret = allTurrets [_vehicle, true] select {_vehicle turretUnit _x == _unit} param [0, []];
// Unlike CBA_fnc_turretPath, this will return [-1] when player is driver
_turret = ([[-1]] + allTurrets [_vehicle, true]) select {_vehicle turretUnit _x == _unit} param [0, []];
};

private _state = [
Expand Down