mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added canCheckFuel for check fuel condition, removed extra spaces
This commit is contained in:
parent
4dc8747430
commit
9ad8718762
@ -25,7 +25,7 @@
|
|||||||
}; \
|
}; \
|
||||||
class GVAR(CheckFuel) { \
|
class GVAR(CheckFuel) { \
|
||||||
displayName = CSTRING(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)); \
|
statement = QUOTE([ARR_2(_player,_target)] call FUNC(checkFuel)); \
|
||||||
exceptions[] = {"isNotInside"}; \
|
exceptions[] = {"isNotInside"}; \
|
||||||
icon = PATHTOF(ui\icon_refuel_interact.paa); \
|
icon = PATHTOF(ui\icon_refuel_interact.paa); \
|
||||||
@ -47,7 +47,7 @@
|
|||||||
icon = PATHTOF(ui\icon_refuel_interact.paa); \
|
icon = PATHTOF(ui\icon_refuel_interact.paa); \
|
||||||
class GVAR(Connect) { \
|
class GVAR(Connect) { \
|
||||||
displayName = CSTRING(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)); \
|
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(connectNozzle)); \
|
||||||
exceptions[] = {"isNotInside"}; \
|
exceptions[] = {"isNotInside"}; \
|
||||||
icon = PATHTOF(ui\icon_refuel_interact.paa); \
|
icon = PATHTOF(ui\icon_refuel_interact.paa); \
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
ADDON = false;
|
ADDON = false;
|
||||||
|
|
||||||
|
PREP(canCheckFuel);
|
||||||
PREP(canConnectNozzle);
|
PREP(canConnectNozzle);
|
||||||
PREP(canDisconnect);
|
PREP(canDisconnect);
|
||||||
PREP(canRefuel);
|
PREP(canRefuel);
|
||||||
|
23
addons/refuel/functions/fnc_canCheckFuel.sqf
Normal file
23
addons/refuel/functions/fnc_canCheckFuel.sqf
Normal 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
|
@ -19,7 +19,7 @@
|
|||||||
private ["_nozzle", "_sink", "_fueling"];
|
private ["_nozzle", "_sink", "_fueling"];
|
||||||
params ["_unit", "_nozzleHolder"];
|
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];
|
_nozzle = _nozzleHolder getVariable [QGVAR(nozzle), objNull];
|
||||||
if (isNull _nozzle) exitWith {false};
|
if (isNull _nozzle) exitWith {false};
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
private ["_fuel"];
|
private ["_fuel"];
|
||||||
params ["_unit", "_target"];
|
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};
|
if (_fuel > 0 || {_fuel == -1}) exitWith {true};
|
||||||
|
|
||||||
false
|
false
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
params ["_unit", "_target"];
|
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
|
// Check if the fuel source is already in use
|
||||||
!(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])}
|
!(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])}
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
private ["_fuel", "_type"];
|
private ["_fuel", "_type"];
|
||||||
params ["_unit", "_target"];
|
params ["_unit", "_target"];
|
||||||
|
|
||||||
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_target distance _unit) > 7}) exitWith {0};
|
_fuel = [_target] call FUNC(getFuel);
|
||||||
|
|
||||||
_fuel = [_unit, _target] call FUNC(getFuel);
|
|
||||||
|
|
||||||
[
|
[
|
||||||
5,
|
5,
|
||||||
@ -40,4 +38,3 @@ _fuel = [_unit, _target] call FUNC(getFuel);
|
|||||||
{true},
|
{true},
|
||||||
["isnotinside"]
|
["isnotinside"]
|
||||||
] call EFUNC(common,progressBar);
|
] call EFUNC(common,progressBar);
|
||||||
|
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
* Author: GitHawk
|
* Author: GitHawk, Jonpas
|
||||||
* Get the remaining fuel amount
|
* Get the remaining fuel amount.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: The unit <OBJECT>
|
* 0: Target <OBJECT>
|
||||||
* 1: The target <OBJECT>
|
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Fuel left (in liters) <NUMBER>
|
* Fuel left (in liters) <NUMBER>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [unit, target] call ace_refuel_fnc_getFuel
|
* [target] call ace_refuel_fnc_getFuel
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_fuel"];
|
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 (isNil "_fuel") then {
|
||||||
|
|
||||||
if (_fuel == -2) then {
|
|
||||||
_fuel = getNumber (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(fuelCargo));
|
_fuel = getNumber (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(fuelCargo));
|
||||||
_target setVariable [QGVAR(currentFuelCargo), _fuel, true];
|
_target setVariable [QGVAR(currentFuelCargo), _fuel, true];
|
||||||
};
|
};
|
||||||
|
@ -24,13 +24,13 @@ if (isNull _sink) exitWith {};
|
|||||||
_rate = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(flowRate)) * GVAR(rate);
|
_rate = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(flowRate)) * GVAR(rate);
|
||||||
_maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(fuelCapacity));
|
_maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(fuelCapacity));
|
||||||
|
|
||||||
[{
|
[{
|
||||||
private ["_source", "_sink", "_fuelInSource", "_fuelInSink", "_finished", "_fueling"];
|
private ["_source", "_sink", "_fuelInSource", "_fuelInSink", "_finished", "_fueling"];
|
||||||
params ["_args", "_pfID"];
|
params ["_args", "_pfID"];
|
||||||
_args params ["_unit", "_nozzle", "_rate", "_startFuel", "_maxFuel"];
|
_args params ["_unit", "_nozzle", "_rate", "_startFuel", "_maxFuel"];
|
||||||
|
|
||||||
_fueling = _nozzle getVariable [QGVAR(fueling), 0];
|
_fueling = _nozzle getVariable [QGVAR(fueling), 0];
|
||||||
|
|
||||||
_source = _nozzle getVariable [QGVAR(source), objNull];
|
_source = _nozzle getVariable [QGVAR(source), objNull];
|
||||||
_sink = _nozzle getVariable [QGVAR(sink), objNull];
|
_sink = _nozzle getVariable [QGVAR(sink), objNull];
|
||||||
if (isNull _source || {isNull _sink} || {(_source distance _sink) > 10}) exitWith {
|
if (isNull _source || {isNull _sink} || {(_source distance _sink) > 10}) exitWith {
|
||||||
@ -40,7 +40,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
|
|||||||
_nozzle setVariable [QGVAR(sink), objNull];
|
_nozzle setVariable [QGVAR(sink), objNull];
|
||||||
[_pfID] call cba_fnc_removePerFrameHandler;
|
[_pfID] call cba_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
_fuelInSource = [_unit, _source] call FUNC(getFuel);
|
_fuelInSource = [_source] call FUNC(getFuel);
|
||||||
if (_fuelInSource == 0) exitWith {
|
if (_fuelInSource == 0) exitWith {
|
||||||
[LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured);
|
[LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured);
|
||||||
_nozzle setVariable [QGVAR(fueling), 0, true];
|
_nozzle setVariable [QGVAR(fueling), 0, true];
|
||||||
@ -53,7 +53,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
|
|||||||
_finished = true;
|
_finished = true;
|
||||||
[LSTRING(Hint_Empty), 2, _unit] call EFUNC(common,displayTextStructured);
|
[LSTRING(Hint_Empty), 2, _unit] call EFUNC(common,displayTextStructured);
|
||||||
};
|
};
|
||||||
|
|
||||||
_fuelInSink = fuel _sink + ( _rate / _maxFuel);
|
_fuelInSink = fuel _sink + ( _rate / _maxFuel);
|
||||||
if (_fuelInSink > 1) then {
|
if (_fuelInSink > 1) then {
|
||||||
_fuelInSink = 1;
|
_fuelInSink = 1;
|
||||||
@ -66,7 +66,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
|
|||||||
_sink setFuel _fuelInSink;
|
_sink setFuel _fuelInSink;
|
||||||
};
|
};
|
||||||
[_unit, _source, _fuelInSource] call FUNC(setFuel);
|
[_unit, _source, _fuelInSource] call FUNC(setFuel);
|
||||||
|
|
||||||
if (_finished || {_fueling == 0}) exitWith {
|
if (_finished || {_fueling == 0}) exitWith {
|
||||||
if (_fueling == 0) then {
|
if (_fueling == 0) then {
|
||||||
[LSTRING(Hint_Stopped), 2, _unit] call EFUNC(common,displayTextStructured);
|
[LSTRING(Hint_Stopped), 2, _unit] call EFUNC(common,displayTextStructured);
|
||||||
@ -74,8 +74,8 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
|
|||||||
_nozzle setVariable [QGVAR(fueling), 0, true];
|
_nozzle setVariable [QGVAR(fueling), 0, true];
|
||||||
[_pfID] call cba_fnc_removePerFrameHandler;
|
[_pfID] call cba_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
// display flickers even at 1 second intervals
|
// display flickers even at 1 second intervals
|
||||||
//["displayTextStructured", [_unit], [[localize LSTRING(Hint_FuelProgress), round((_fuelInSink - _startFuel) * _maxFuel)], 2, _unit]] call EFUNC(common,targetEvent);
|
//["displayTextStructured", [_unit], [[localize LSTRING(Hint_FuelProgress), round((_fuelInSink - _startFuel) * _maxFuel)], 2, _unit]] call EFUNC(common,targetEvent);
|
||||||
//[[LSTRING(Hint_FuelProgress), round((_fuelInSink - _startFuel) * _maxFuel)], 2, _unit] call EFUNC(common,displayTextStructured);
|
//[[LSTRING(Hint_FuelProgress), round((_fuelInSink - _startFuel) * _maxFuel)], 2, _unit] call EFUNC(common,displayTextStructured);
|
||||||
}, 1, [_unit, _nozzle, _rate, fuel _target, _maxFuel]] call cba_fnc_addPerFrameHandler;
|
}, 1, [_unit, _nozzle, _rate, fuel _target, _maxFuel]] call cba_fnc_addPerFrameHandler;
|
||||||
|
Loading…
Reference in New Issue
Block a user