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

Common / Medical - Fix loading patients into turret only seats #7980

Merged
merged 2 commits into from
Nov 15, 2020
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
18 changes: 17 additions & 1 deletion addons/common/functions/fnc_loadPersonLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,23 @@ if ((_vehicle emptyPositions "cargo" > 0) && {!(_unit getVariable ['ACE_isUncons
_unit moveInCargo _vehicle;
_slotsOpen = true;
} else {
if (_vehicle emptyPositions "gunner" > 0) then {
// Check if an empty turret is available
// This already excludes FFV seats, which count as cargo positions
private _turrets = fullCrew [_vehicle, "turret", true];
private _index = _turrets findIf {isNull (_x#0)};
if (_index >= 0) exitWith {
_unit moveInTurret [_vehicle, _turrets#_index#3];
_slotsOpen = true;
};

// Check if the commander seat is available
if (_vehicle emptyPositions "commander" > 0) exitWith {
_unit moveInCommander _vehicle;
_slotsOpen = true;
};

// Lastly, check if the gunner seat is available
if (_vehicle emptyPositions "gunner" > 0) exitWith {
_unit moveInGunner _vehicle;
_slotsOpen = true;
};
Expand Down
2 changes: 1 addition & 1 deletion addons/common/functions/fnc_nearestVehiclesFreeSeat.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ private _nearVehicles = nearestObjects [_unit, ["Car", "Air", "Tank", "Ship_F",
_nearVehicles select {
// Filter cargo seats that will eject unconscious units (e.g. quad bike)
((_x emptyPositions "cargo" > 0) && {!(_unit getVariable ['ACE_isUnconscious', false])} || {(getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "ejectDeadCargo")) == 0})
|| {_x emptyPositions "gunner" > 0}
|| {{isNull (_x#0)} count fullCrew [_x, "", true] > _x emptyPositions "driver"}
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
}
10 changes: 10 additions & 0 deletions addons/common/functions/fnc_unloadPersonLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ unassignVehicle _unit;
TRACE_1("Ejecting", alive _unit);
_unit action ["Eject", vehicle _unit];

// Failsafe - sometimes eject alone doesn't work, but moveOut does
[{
params ["_unit"];

if (vehicle _unit != _unit) then {
TRACE_1("failsafe",_unit);
moveOut _unit;
};
}, [_unit], 1] call CBA_fnc_waitAndExecute;

[{
params ["_unit", "_emptyPos"];
(alive _unit) && {(vehicle _unit) != _unit}
Expand Down