Skip to content

Commit

Permalink
Merge pull request #1313 from CBATeam/playerEventDriverTurret
Browse files Browse the repository at this point in the history
Events - Player events will report driver seat as turret [-1]
  • Loading branch information
commy2 committed Mar 28, 2020
2 parents 6b3fc30 + 39f5dae commit 2d0a54a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 2d0a54a

Please sign in to comment.