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

Use unitTurret command #1380

Merged
merged 2 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
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);
jonpas marked this conversation as resolved.
Show resolved Hide resolved
[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);
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
[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;
jonpas marked this conversation as resolved.
Show resolved Hide resolved

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