Added canCheckFuel for check fuel condition, removed extra spaces

This commit is contained in:
jonpas 2015-08-17 01:57:05 +02:00
parent 4dc8747430
commit 9ad8718762
9 changed files with 47 additions and 28 deletions

View File

@ -25,7 +25,7 @@
}; \
class GVAR(CheckFuel) { \
displayName = CSTRING(CheckFuel); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(getFuel) >= 0); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canCheckFuel)); \
statement = QUOTE([ARR_2(_player,_target)] call FUNC(checkFuel)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
@ -47,7 +47,7 @@
icon = PATHTOF(ui\icon_refuel_interact.paa); \
class GVAR(Connect) { \
displayName = CSTRING(Connect); \
condition = QUOTE([ARR_1(_player)] call FUNC(canConnectNozzle)); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canConnectNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(connectNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \

View File

@ -2,6 +2,7 @@
ADDON = false;
PREP(canCheckFuel);
PREP(canConnectNozzle);
PREP(canDisconnect);
PREP(canRefuel);

View File

@ -0,0 +1,23 @@
/*
* Author: Jonpas
* Checks if unit can check fuel.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Can Check Fuel <BOOL>
*
* Example:
* [unit, target] call ace_refuel_fnc_canCheckFuel
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
true

View File

@ -19,7 +19,7 @@
private ["_nozzle", "_sink", "_fueling"];
params ["_unit", "_nozzleHolder"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_nozzleHolder distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_nozzleHolder distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
_nozzle = _nozzleHolder getVariable [QGVAR(nozzle), objNull];
if (isNull _nozzle) exitWith {false};

View File

@ -17,9 +17,9 @@
private ["_fuel"];
params ["_unit", "_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
_fuel = [_unit, _target] call FUNC(getFuel);
_fuel = [_target] call FUNC(getFuel);
if (_fuel > 0 || {_fuel == -1}) exitWith {true};
false

View File

@ -18,7 +18,7 @@
params ["_unit", "_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
// Check if the fuel source is already in use
!(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])}

View File

@ -18,9 +18,7 @@
private ["_fuel", "_type"];
params ["_unit", "_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_target distance _unit) > 7}) exitWith {0};
_fuel = [_unit, _target] call FUNC(getFuel);
_fuel = [_target] call FUNC(getFuel);
[
5,
@ -40,4 +38,3 @@ _fuel = [_unit, _target] call FUNC(getFuel);
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -1,28 +1,26 @@
/*
* Author: GitHawk
* Get the remaining fuel amount
* Author: GitHawk, Jonpas
* Get the remaining fuel amount.
*
* Arguments:
* 0: The unit <OBJECT>
* 1: The target <OBJECT>
* 0: Target <OBJECT>
*
* Return Value:
* Fuel left (in liters) <NUMBER>
*
* Example:
* [unit, target] call ace_refuel_fnc_getFuel
* [target] call ace_refuel_fnc_getFuel
*
* Public: No
*/
#include "script_component.hpp"
private ["_fuel"];
params ["_unit", "_target"];
params ["_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit}) exitWith {0};
_fuel = _target getVariable [QGVAR(currentFuelCargo), nil];
_fuel = _target getVariable [QGVAR(currentFuelCargo), -2];
if (_fuel == -2) then {
if (isNil "_fuel") then {
_fuel = getNumber (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(fuelCargo));
_target setVariable [QGVAR(currentFuelCargo), _fuel, true];
};

View File

@ -40,7 +40,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
_nozzle setVariable [QGVAR(sink), objNull];
[_pfID] call cba_fnc_removePerFrameHandler;
};
_fuelInSource = [_unit, _source] call FUNC(getFuel);
_fuelInSource = [_source] call FUNC(getFuel);
if (_fuelInSource == 0) exitWith {
[LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured);
_nozzle setVariable [QGVAR(fueling), 0, true];