Skip to content

Commit

Permalink
Use new unitTurret command
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Oct 16, 2020
1 parent 79c04b6 commit dde05e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
7 changes: 6 additions & 1 deletion addons/common/fnc_turretPath.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ params [["_unit", objNull, [objNull]]];

private _vehicle = vehicle _unit;

(allTurrets [_vehicle, true] select {(_vehicle turretUnit _x) isEqualTo _unit}) param [0, []]
private _turret = _vehicle unitTurret _unit;

// driver will be returned as [] to be consistant with previous behaviour
if (_turret isEqualTo [-1]) exitWith { [] };

_turret
10 changes: 2 additions & 8 deletions addons/events/fnc_addPlayerEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ private _id = switch (_type) do {
case "turretweapon": {
if (_applyRetroactively) then {
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, []];
};
private _turret = _vehicle unitTurret GVAR(oldUnit);
[GVAR(oldUnit), _vehicle currentWeaponTurret _turret, ""] call _function;
};
[QGVAR(turretWeaponEvent), _function] call CBA_fnc_addEventHandler // return id
Expand Down Expand Up @@ -101,10 +98,7 @@ private _id = switch (_type) do {
case "turret": {
if (_applyRetroactively) then {
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, []];
};
private _turret = _vehicle unitTurret GVAR(oldUnit);
[GVAR(oldUnit), _turret, []] call _function;
};
[QGVAR(turretEvent), _function] call CBA_fnc_addEventHandler // return id
Expand Down
7 changes: 2 additions & 5 deletions addons/events/fnc_playerEvent.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ if (!isNull getConnectedUAV _unit) then {
};
};

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

private _state = [
_unit, group _unit, leader _unit,
Expand Down

0 comments on commit dde05e7

Please sign in to comment.