2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2017-09-29 20:00:47 +00:00
|
|
|
/*
|
|
|
|
* Author: 654wak654
|
|
|
|
* Returns a list of vehicles near given unit that the unit can be a passenger in.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
2020-11-15 18:57:27 +00:00
|
|
|
* 1: Distance <NUMBER><OPTIONAL>
|
|
|
|
* 2: Restriceted to cargo only <BOOL><OPTIONAL>
|
2017-09-29 20:00:47 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Nearest vehicles with a free seat <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
2020-11-15 18:57:27 +00:00
|
|
|
* [cursorObject] call ace_common_fnc_nearestVehiclesFreeSeat
|
2017-09-29 20:00:47 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
2020-11-15 18:57:27 +00:00
|
|
|
params ["_unit", ["_distance", 10], ["_cargoOnly", false]];
|
2017-09-29 20:00:47 +00:00
|
|
|
|
|
|
|
private _nearVehicles = nearestObjects [_unit, ["Car", "Air", "Tank", "Ship_F", "Pod_Heli_Transport_04_crewed_base_F"], _distance];
|
2019-09-05 20:56:53 +00:00
|
|
|
_nearVehicles select {
|
|
|
|
// Filter cargo seats that will eject unconscious units (e.g. quad bike)
|
2021-02-18 18:58:08 +00:00
|
|
|
private _canSitInCargo = (!(_unit getVariable ['ACE_isUnconscious', false])) || {(getNumber (configOf _x >> "ejectDeadCargo")) == 0};
|
2020-11-15 18:57:27 +00:00
|
|
|
((fullCrew [_x, "", true]) findIf {
|
|
|
|
_x params ["_body", "_role", "_cargoIndex"];
|
|
|
|
(isNull _body) // seat empty
|
|
|
|
&& {_role != "DRIVER"} // not driver seat
|
|
|
|
&& {_canSitInCargo || {_cargoIndex == -1}} // won't be ejected (uncon)
|
|
|
|
&& {(!_cargoOnly) || {_cargoIndex != -1}} // not restricted (captive)
|
|
|
|
}) > -1
|
2019-09-05 20:56:53 +00:00
|
|
|
}
|