ACE3/addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf

68 lines
2.0 KiB
Plaintext
Raw Normal View History

2015-08-23 17:32:46 +00:00
/*
* Author: PabstMirror
* Finds a free cargo seat, searching non FFV first
*
* Arguments:
* 0: The Vehicle <OBJECT>
*
* Return Value:
* ARRAY [seat index <NUMBER>, is FFV <BOOL>]
*
* Example:
* [car1] call ACE_captives_fnc_findEmptyNonFFVCargoSeat
*
* Public: No
*/
2015-08-15 02:29:01 +00:00
#include "script_component.hpp"
params ["_vehicle"];
2015-08-23 17:32:46 +00:00
TRACE_1("params", _vehicle);
2015-08-15 02:29:01 +00:00
_vehicleConfig = configFile >> "CfgVehicles" >> (typeOf _vehicle);
_proxyOrder = getArray (_vehicleConfig >> "getInProxyOrder");
_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);
_isCargoProxy = ((getText (_turretConfig >> "proxyType")) == "CPCargo") && {isNumber (_turretConfig >> "proxyIndex")};
if (_isCargoProxy) then {
_proxyCargoIndex = getNumber (_turretConfig >> "proxyIndex");
_cargoIndex = _proxyOrder find _proxyCargoIndex;
_ffvCargoIndexes pushBack _cargoIndex;
};
} forEach (allTurrets [_vehicle, true]);
//Find Empty Seats:
_occupiedSeats = [];
{
_x params ["", "", "_xIndex"];
if (_xIndex > -1) then {_occupiedSeats pushBack _xIndex;};
} forEach (fullCrew _vehicle);
TRACE_3("Searching for empty seat",_realCargoCount,_ffvCargoIndexes,_occupiedSeats);
2015-08-23 17:32:46 +00:00
_emptyCargoSeatReturn = [-1, false];
//First seach for non-ffv seats:
2015-08-15 02:29:01 +00:00
for "_index" from 0 to (_realCargoCount - 1) do {
if ((!(_index in _ffvCargoIndexes)) && {!(_index in _occupiedSeats)}) exitWith {
2015-08-23 17:32:46 +00:00
_emptyCargoSeatReturn = [_index, false];
};
};
//Only use FFV if none found:
if (_emptyCargoSeatReturn isEqualTo [-1, false]) then {
for "_index" from 0 to (_realCargoCount - 1) do {
if (!(_index in _occupiedSeats)) exitWith {
_emptyCargoSeatReturn = [_index, true];
};
2015-08-15 02:29:01 +00:00
};
};
_emptyCargoSeatReturn