mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Captives - rewrite findEmptyNonFFVCargoSeat (#4348)
Simplify func using `fullCrew` Fix #4339 also switch hard `ERROR(` macro to `WARNING(`
This commit is contained in:
parent
39ffdff920
commit
b81ccca3f7
@ -27,7 +27,7 @@ if ((isNull _target) && {_unit getVariable [QGVAR(isEscorting), false]}) then {
|
|||||||
};
|
};
|
||||||
} forEach (attachedObjects _unit);
|
} forEach (attachedObjects _unit);
|
||||||
};
|
};
|
||||||
if ((isNull _target) || {(vehicle _target) != _target} || {!(_target getVariable [QGVAR(isHandcuffed), false])}) exitWith {ERROR("");};
|
if ((isNull _target) || {(vehicle _target) != _target} || {!(_target getVariable [QGVAR(isHandcuffed), false])}) exitWith {WARNING("");};
|
||||||
|
|
||||||
if (isNull _vehicle) then {
|
if (isNull _vehicle) then {
|
||||||
//Looking at a captive unit, search for nearby vehicles with valid seats:
|
//Looking at a captive unit, search for nearby vehicles with valid seats:
|
||||||
@ -44,7 +44,7 @@ if (isNull _vehicle) then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isNull _vehicle) exitWith {ERROR("");};
|
if (isNull _vehicle) exitWith {WARNING("Could not find vehicle to load captive");};
|
||||||
|
|
||||||
_unit setVariable [QGVAR(isEscorting), false, true];
|
_unit setVariable [QGVAR(isEscorting), false, true];
|
||||||
[QGVAR(moveInCaptive), [_target, _vehicle], [_target]] call CBA_fnc_targetEvent;
|
[QGVAR(moveInCaptive), [_target, _vehicle], [_target]] call CBA_fnc_targetEvent;
|
||||||
|
@ -18,50 +18,22 @@
|
|||||||
params ["_vehicle"];
|
params ["_vehicle"];
|
||||||
TRACE_1("params", _vehicle);
|
TRACE_1("params", _vehicle);
|
||||||
|
|
||||||
_vehicleConfig = configFile >> "CfgVehicles" >> (typeOf _vehicle);
|
private _vehicleConfig = configFile >> "CfgVehicles" >> (typeOf _vehicle);
|
||||||
|
|
||||||
_proxyOrder = getArray (_vehicleConfig >> "getInProxyOrder");
|
scopeName "main";
|
||||||
_transportSoldier = getNumber (_vehicleConfig >> "transportSoldier");
|
|
||||||
_realCargoCount = if (isArray (_vehicleConfig >> "getInProxyOrder")) then {count _proxyOrder} else {_transportSoldier};
|
|
||||||
|
|
||||||
//Find FFV turrets:
|
|
||||||
_ffvCargoIndexes = [];
|
|
||||||
{
|
{
|
||||||
_turretConfig = [_vehicleConfig, _x] call EFUNC(common,getTurretConfigPath);
|
_x params ["_unit", "_role", "_cargoIndex", "_turretPath", "_isPersonTurret"];
|
||||||
_isCargoProxy = ((getText (_turretConfig >> "proxyType")) == "CPCargo") && {isNumber (_turretConfig >> "proxyIndex")};
|
if ((isNull _unit) && {_role == "cargo"} && {_cargoIndex > -1} && {!_isPersonTurret}) then {
|
||||||
|
[_cargoIndex, false] breakOut "main";
|
||||||
if (_isCargoProxy) then {
|
|
||||||
_proxyCargoIndex = getNumber (_turretConfig >> "proxyIndex");
|
|
||||||
_cargoIndex = _proxyOrder find _proxyCargoIndex;
|
|
||||||
_ffvCargoIndexes pushBack _cargoIndex;
|
|
||||||
};
|
};
|
||||||
} forEach (allTurrets [_vehicle, true]);
|
} forEach (fullCrew [_vehicle, "", true]);
|
||||||
|
|
||||||
//Find Empty Seats:
|
|
||||||
_occupiedSeats = [];
|
|
||||||
{
|
{
|
||||||
_x params ["", "", "_xIndex"];
|
_x params ["_unit", "_role", "_cargoIndex", "_turretPath", "_isPersonTurret"];
|
||||||
if (_xIndex > -1) then {_occupiedSeats pushBack _xIndex;};
|
if ((isNull _unit) && {_cargoIndex > -1}) then {
|
||||||
} forEach (fullCrew _vehicle);
|
[_cargoIndex, true] breakOut "main";
|
||||||
|
|
||||||
TRACE_3("Searching for empty seat",_realCargoCount,_ffvCargoIndexes,_occupiedSeats);
|
|
||||||
|
|
||||||
_emptyCargoSeatReturn = [-1, false];
|
|
||||||
|
|
||||||
//First seach for non-ffv seats:
|
|
||||||
for "_index" from 0 to (_realCargoCount - 1) do {
|
|
||||||
if ((!(_index in _ffvCargoIndexes)) && {!(_index in _occupiedSeats)}) exitWith {
|
|
||||||
_emptyCargoSeatReturn = [_index, false];
|
|
||||||
};
|
};
|
||||||
};
|
} forEach (fullCrew [_vehicle, "", true]);
|
||||||
|
|
||||||
//Only use FFV if none found:
|
[-1, false]
|
||||||
if (_emptyCargoSeatReturn isEqualTo [-1, false]) then {
|
|
||||||
for "_index" from 0 to (_realCargoCount - 1) do {
|
|
||||||
if (!(_index in _occupiedSeats)) exitWith {
|
|
||||||
_emptyCargoSeatReturn = [_index, true];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
_emptyCargoSeatReturn
|
|
||||||
|
@ -20,7 +20,7 @@ params ["_unit","_state"];
|
|||||||
TRACE_2("params",_unit,_state);
|
TRACE_2("params",_unit,_state);
|
||||||
|
|
||||||
if (!local _unit) exitWith {
|
if (!local _unit) exitWith {
|
||||||
ERROR("running setHandcuffed on remote unit");
|
WARNING("running setHandcuffed on remote unit");
|
||||||
};
|
};
|
||||||
|
|
||||||
if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
|
if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
|
||||||
@ -35,7 +35,7 @@ if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if ((_unit getVariable [QGVAR(isHandcuffed), false]) isEqualTo _state) exitWith {
|
if ((_unit getVariable [QGVAR(isHandcuffed), false]) isEqualTo _state) exitWith {
|
||||||
ERROR("setHandcuffed: current state same as new");
|
WARNING("setHandcuffed: current state same as new");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_state) then {
|
if (_state) then {
|
||||||
|
@ -20,7 +20,7 @@ params ["_unit","_state"];
|
|||||||
TRACE_2("params",_unit,_state);
|
TRACE_2("params",_unit,_state);
|
||||||
|
|
||||||
if (!local _unit) exitWith {
|
if (!local _unit) exitWith {
|
||||||
ERROR("running surrender on remote unit");
|
WARNING("running surrender on remote unit");
|
||||||
};
|
};
|
||||||
|
|
||||||
if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
|
if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
|
||||||
@ -35,12 +35,12 @@ if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) exitWith {
|
if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) exitWith {
|
||||||
ERROR("Surrender: current state same as new");
|
WARNING("Surrender: current state same as new");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_state) then {
|
if (_state) then {
|
||||||
if ((vehicle _unit) != _unit) exitWith {ERROR("Cannot surrender while mounted");};
|
if ((vehicle _unit) != _unit) exitWith {WARNING("Cannot surrender while mounted");};
|
||||||
if (_unit getVariable [QGVAR(isHandcuffed), false]) exitWith {ERROR("Cannot surrender while handcuffed");};
|
if (_unit getVariable [QGVAR(isHandcuffed), false]) exitWith {WARNING("Cannot surrender while handcuffed");};
|
||||||
|
|
||||||
_unit setVariable [QGVAR(isSurrendering), true, true];
|
_unit setVariable [QGVAR(isSurrendering), true, true];
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
params ["_target","_vehicle"];
|
params ["_target","_vehicle"];
|
||||||
TRACE_2("params",_target,_vehicle);
|
TRACE_2("params",_target,_vehicle);
|
||||||
|
|
||||||
_getSeat = [_vehicle] call FUNC(findEmptyNonFFVCargoSeat);
|
private _getSeat = [_vehicle] call FUNC(findEmptyNonFFVCargoSeat);
|
||||||
TRACE_1("free cargo seat",_getSeat);
|
TRACE_1("free cargo seat",_getSeat);
|
||||||
_getSeat params ["_cargoIndex"];
|
_getSeat params ["_cargoIndex"];
|
||||||
if (_cargoIndex == -1) exitWith {ERROR("cargo index -1");};
|
if (_cargoIndex == -1) exitWith {WARNING("cargo index -1");};
|
||||||
|
|
||||||
_target moveInCargo [_vehicle, _cargoIndex];
|
_target moveInCargo [_vehicle, _cargoIndex];
|
||||||
_target assignAsCargoIndex [_vehicle, _cargoIndex];
|
_target assignAsCargoIndex [_vehicle, _cargoIndex];
|
||||||
|
Loading…
Reference in New Issue
Block a user