2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-18 21:18:32 +00:00
|
|
|
/*
|
|
|
|
* Author: GitHawk
|
2023-02-17 02:06:11 +00:00
|
|
|
* Check if a unit can turn on a fuel nozzle.
|
2015-08-18 21:18:32 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-20 20:10:26 +00:00
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Nozzle <OBJECT>
|
2023-02-17 02:06:11 +00:00
|
|
|
* 2: Refuel container <BOOL> (default: false)
|
2015-08-18 21:18:32 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Can turn on <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
2015-08-20 20:10:26 +00:00
|
|
|
* [player, nozzle] call ace_refuel_fnc_canTurnOn
|
2015-08-18 21:18:32 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2023-02-17 02:06:11 +00:00
|
|
|
params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_refuelContainer", false, [false]]];
|
2015-08-18 21:18:32 +00:00
|
|
|
|
|
|
|
if (isNull _unit ||
|
2015-08-20 20:10:26 +00:00
|
|
|
{isNull _nozzle} ||
|
2015-08-18 21:18:32 +00:00
|
|
|
{!(_unit isKindOf "CAManBase")} ||
|
|
|
|
{!local _unit} ||
|
2015-08-20 20:10:26 +00:00
|
|
|
{(_nozzle distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
|
2015-08-18 21:18:32 +00:00
|
|
|
|
2023-02-17 02:06:11 +00:00
|
|
|
private _source = _nozzle getVariable [QGVAR(source), objNull];
|
|
|
|
private _sink = _nozzle getVariable [QGVAR(sink), objNull];
|
|
|
|
|
|
|
|
if (isNull _source || {isNull _sink}) exitWith {false};
|
|
|
|
|
|
|
|
private _isSinkFull = if (_refuelContainer) then {
|
|
|
|
([_sink] call FUNC(getCapacity)) in [REFUEL_DISABLED_FUEL, REFUEL_INFINITE_FUEL, [_sink] call FUNC(getFuel)]
|
|
|
|
} else {
|
|
|
|
fuel _sink == 1
|
|
|
|
};
|
|
|
|
|
2015-08-20 20:10:26 +00:00
|
|
|
!(_nozzle getVariable [QGVAR(isRefueling), false]) &&
|
2023-02-17 02:06:11 +00:00
|
|
|
{(([_source] call FUNC(getCapacity)) == REFUEL_INFINITE_FUEL) || {[_source] call FUNC(getFuel) > 0}} && // Make sure the source has fuel
|
|
|
|
{!_isSinkFull} && // Make sure the sink isn't full
|
|
|
|
{!(_refuelContainer && {_source == _sink})}; // No endless container ot itself loop
|