From cdd0c4c013bfdc75ed9489341db7a00b7c9bfdb5 Mon Sep 17 00:00:00 2001 From: IngoKauffmann Date: Tue, 18 Aug 2015 23:18:32 +0200 Subject: [PATCH] Next few things Clean up Removed MP issues Added macros for reused code Added death handling Added unconscious handling Added fueling restart --- addons/refuel/CfgEventHandlers.hpp | 22 ++++++ addons/refuel/CfgVehicles.hpp | 14 +++- addons/refuel/README.md | 11 +++ addons/refuel/XEH_postInit.sqf | 3 + addons/refuel/XEH_preInit.sqf | 4 + addons/refuel/XEH_respawn.sqf | 11 +++ addons/refuel/config.cpp | 2 +- addons/refuel/functions/fnc_canCheckFuel.sqf | 3 +- addons/refuel/functions/fnc_canTakeNozzle.sqf | 6 +- addons/refuel/functions/fnc_canTurnOff.sqf | 5 +- addons/refuel/functions/fnc_canTurnOn.sqf | 31 ++++++++ addons/refuel/functions/fnc_handleKilled.sqf | 26 +++++++ .../functions/fnc_handleUnconscious.sqf | 29 +++++++ addons/refuel/functions/fnc_refuel.sqf | 75 ++++++++++--------- addons/refuel/functions/fnc_returnNozzle.sqf | 5 +- addons/refuel/functions/fnc_takeNozzle.sqf | 15 +--- addons/refuel/functions/fnc_turnOff.sqf | 2 +- addons/refuel/functions/fnc_turnOn.sqf | 20 +++++ addons/refuel/script_component.hpp | 23 +++++- addons/refuel/stringtable.xml | 4 + 20 files changed, 250 insertions(+), 61 deletions(-) create mode 100644 addons/refuel/README.md create mode 100644 addons/refuel/XEH_postInit.sqf create mode 100644 addons/refuel/XEH_respawn.sqf create mode 100644 addons/refuel/functions/fnc_canTurnOn.sqf create mode 100644 addons/refuel/functions/fnc_handleKilled.sqf create mode 100644 addons/refuel/functions/fnc_handleUnconscious.sqf create mode 100644 addons/refuel/functions/fnc_turnOn.sqf diff --git a/addons/refuel/CfgEventHandlers.hpp b/addons/refuel/CfgEventHandlers.hpp index b928bc2de6..f1a9f1a3c8 100644 --- a/addons/refuel/CfgEventHandlers.hpp +++ b/addons/refuel/CfgEventHandlers.hpp @@ -3,3 +3,25 @@ class Extended_PreInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; + +class Extended_Respawn_EventHandlers { + class CAManBase { + class ADDON { + respawn = QUOTE(call COMPILE_FILE(XEH_respawn)); + }; + }; +}; + +class Extended_Killed_EventHandlers { + class CAManBase { + class ADDON { + killed = QUOTE(_this call FUNC(handleKilled)); + }; + }; +}; \ No newline at end of file diff --git a/addons/refuel/CfgVehicles.hpp b/addons/refuel/CfgVehicles.hpp index c5e797ef2e..0e7aacafa0 100644 --- a/addons/refuel/CfgVehicles.hpp +++ b/addons/refuel/CfgVehicles.hpp @@ -52,6 +52,13 @@ exceptions[] = {"isNotInside"}; \ icon = PATHTOF(ui\icon_refuel_interact.paa); \ }; \ + class GVAR(TurnOn) { \ + displayName = CSTRING(TurnOn); \ + condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTurnOn)); \ + statement = QUOTE([_target] call DFUNC(turnOn)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ class GVAR(Disconnect) { \ displayName = CSTRING(Disconnect); \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canDisconnect)); \ @@ -89,7 +96,7 @@ class CfgVehicles { displayName = CSTRING(RefuelSettings_Module_DisplayName); icon = QUOTE(PATHTOF(ui\icon_module_refuel.paa)); category = "ACE"; - function = QUOTE(DFUNC(moduleRefuelSettings)); + function = QFUNC(moduleRefuelSettings); functionPriority = 1; isGlobal = 0; isTriggerActivated = 0; @@ -451,7 +458,6 @@ class CfgVehicles { }; class ReammoBox_F; - class Slingload_01_Base_F : ReammoBox_F { class ACE_Actions { class ACE_MainActions { @@ -494,7 +500,7 @@ class CfgVehicles { transportFuel = 0; //50k MACRO_REFUEL_ACTIONS GVAR(hooks[]) = {{0,0,-1}}; - GVAR(fuelCargo) = INFINITE_FUEL; + GVAR(fuelCargo) = REFUEL_INFINITE_FUEL; }; class Land_fs_feed_F : House_Small_F { @@ -502,7 +508,7 @@ class CfgVehicles { transportFuel = 0; //50k MACRO_REFUEL_ACTIONS GVAR(hooks[]) = {{-0.4,0.022,-.23}}; - GVAR(fuelCargo) = INFINITE_FUEL; + GVAR(fuelCargo) = REFUEL_INFINITE_FUEL; }; /* // Barrels from rhs? diff --git a/addons/refuel/README.md b/addons/refuel/README.md new file mode 100644 index 0000000000..6e3d226693 --- /dev/null +++ b/addons/refuel/README.md @@ -0,0 +1,11 @@ +ace_refuel +=============== + +The Refuel module introduces ability to refuel vehicles on different realistic levels. + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [GitHawk] (https://github.com/GitHawk) +- [Jonpas] (https://github.com/jonpas) diff --git a/addons/refuel/XEH_postInit.sqf b/addons/refuel/XEH_postInit.sqf new file mode 100644 index 0000000000..682ebaf094 --- /dev/null +++ b/addons/refuel/XEH_postInit.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +["medical_onUnconscious", {_this call FUNC(handleOnUnconscious)}] call EFUNC(common,addEventHandler); diff --git a/addons/refuel/XEH_preInit.sqf b/addons/refuel/XEH_preInit.sqf index a30a4b82e1..d330a88a6e 100644 --- a/addons/refuel/XEH_preInit.sqf +++ b/addons/refuel/XEH_preInit.sqf @@ -8,16 +8,20 @@ PREP(canDisconnect); PREP(canRefuel); PREP(canTakeNozzle); PREP(canTurnOff); +PREP(canTurnOn); PREP(checkFuel); PREP(connectNozzle); PREP(connectNozzleAction); PREP(disconnect); PREP(getFuel); +PREP(handleKilled); +PREP(handleUnconscious); PREP(moduleRefuelSettings); PREP(refuel); PREP(returnNozzle); PREP(setFuel); PREP(takeNozzle); PREP(turnOff); +PREP(turnOn); ADDON = true; diff --git a/addons/refuel/XEH_respawn.sqf b/addons/refuel/XEH_respawn.sqf new file mode 100644 index 0000000000..39225f2521 --- /dev/null +++ b/addons/refuel/XEH_respawn.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" + +private ["_unit"]; + +_unit = _this select 0; + +if !(local _unit) exitWith {}; + +[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); +_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; +_unit setVariable [QGVAR(isRefueling), false]; diff --git a/addons/refuel/config.cpp b/addons/refuel/config.cpp index fe5363ecd5..6140cefe8c 100644 --- a/addons/refuel/config.cpp +++ b/addons/refuel/config.cpp @@ -12,6 +12,6 @@ class CfgPatches { }; }; +#include "ACE_Settings.hpp" #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -#include "ACE_Settings.hpp" \ No newline at end of file diff --git a/addons/refuel/functions/fnc_canCheckFuel.sqf b/addons/refuel/functions/fnc_canCheckFuel.sqf index 6d75f49675..b61681ebea 100644 --- a/addons/refuel/functions/fnc_canCheckFuel.sqf +++ b/addons/refuel/functions/fnc_canCheckFuel.sqf @@ -21,5 +21,6 @@ params ["_unit", "_target"]; !(isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || + {!alive _target} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE} || - {(_target call FUNC(getFuel) == INFINITE_FUEL)}) + {(_target call FUNC(getFuel) == REFUEL_INFINITE_FUEL)}) diff --git a/addons/refuel/functions/fnc_canTakeNozzle.sqf b/addons/refuel/functions/fnc_canTakeNozzle.sqf index b939778ce8..7e1ad25c3f 100644 --- a/addons/refuel/functions/fnc_canTakeNozzle.sqf +++ b/addons/refuel/functions/fnc_canTakeNozzle.sqf @@ -18,6 +18,10 @@ 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} || + {!alive _target} || + {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false}; !(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])} diff --git a/addons/refuel/functions/fnc_canTurnOff.sqf b/addons/refuel/functions/fnc_canTurnOff.sqf index c16b8308fd..4ed1b1aa3b 100644 --- a/addons/refuel/functions/fnc_canTurnOff.sqf +++ b/addons/refuel/functions/fnc_canTurnOff.sqf @@ -18,6 +18,9 @@ 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}; !(isNull (_nozzleHolder getVariable [QGVAR(nozzle), objNull])) && {(_nozzleHolder getVariable QGVAR(nozzle)) getVariable [QGVAR(isRefueling), false]} diff --git a/addons/refuel/functions/fnc_canTurnOn.sqf b/addons/refuel/functions/fnc_canTurnOn.sqf new file mode 100644 index 0000000000..1f81b31ba9 --- /dev/null +++ b/addons/refuel/functions/fnc_canTurnOn.sqf @@ -0,0 +1,31 @@ +/* + * Author: GitHawk + * Check if a unit can turn on a fuel nozzle + * + * Arguments: + * 0: The unit + * 1: The object holding the nozzle + * + * Return Value: + * Can turn on + * + * Example: + * [player, truck] call ace_refuel_fnc_canTurnOn + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_nozzleHolder"]; + +if (isNull _unit || + {!(_unit isKindOf "CAManBase")} || + {!local _unit} || + {(_nozzleHolder distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false}; + +private "_nozzle"; + +_nozzle = _nozzleHolder getVariable [QGVAR(nozzle), objNull]; +(!isNull _nozzle) && + {!(_nozzle getVariable [QGVAR(isRefueling), false])} && + {[_nozzle getVariable QGVAR(source)] call FUNC(getFuel) != 0} diff --git a/addons/refuel/functions/fnc_handleKilled.sqf b/addons/refuel/functions/fnc_handleKilled.sqf new file mode 100644 index 0000000000..7fd8247aab --- /dev/null +++ b/addons/refuel/functions/fnc_handleKilled.sqf @@ -0,0 +1,26 @@ +/* + * Author: GitHawk, Jonpas + * Handles medical on set dead event. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [unit] call ace_refuel_fnc_handleKilled + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +if (!local _unit) exitWith {}; + +_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; +_nozzle = _unit setVariable [QGVAR(nozzle), objNull]; +if !(isNull _nozzle) then { + REFUEL_UNIT_DROP_NOZZLE +}; diff --git a/addons/refuel/functions/fnc_handleUnconscious.sqf b/addons/refuel/functions/fnc_handleUnconscious.sqf new file mode 100644 index 0000000000..0a331bb337 --- /dev/null +++ b/addons/refuel/functions/fnc_handleUnconscious.sqf @@ -0,0 +1,29 @@ +/* + * Author: GitHawk, Jonpas + * Handles medical on unconscious event. + * + * Arguments: + * 0: Unit + * 1: Is Unconscious + * + * Return Value: + * None + * + * Example: + * [unit, true] call ace_refuel_fnc_handleUnconscious + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_isUnconscious"]; + +if (!local _unit || {!_isUnconscious}) exitWith {}; + +private "_nozzle"; + +[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); +_nozzle = _unit setVariable [QGVAR(nozzle), objNull]; +if !(isNull _nozzle) then { + REFUEL_UNIT_DROP_NOZZLE +}; diff --git a/addons/refuel/functions/fnc_refuel.sqf b/addons/refuel/functions/fnc_refuel.sqf index faf4f5883d..37990c7f16 100644 --- a/addons/refuel/functions/fnc_refuel.sqf +++ b/addons/refuel/functions/fnc_refuel.sqf @@ -25,7 +25,7 @@ _rate = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(flo _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(fuelCapacity)); [{ - private ["_source", "_sink", "_fuelInSource", "_fuelInSink", "_finished", "_fueling"]; + private ["_source", "_sink", "_tooFar", "_fuelInSource", "_fuelInSink", "_finished", "_fueling"]; params ["_args", "_pfID"]; _args params ["_unit", "_nozzle", "_rate", "_startFuel", "_maxFuel"]; @@ -34,48 +34,55 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f _source = _nozzle getVariable [QGVAR(source), objNull]; _sink = _nozzle getVariable [QGVAR(sink), objNull]; if (isNull _source || - {isNull _sink} || - {(_sink distance (_source modelToWorld (_nozzle getVariable [QGVAR(attachPos), [0,0,0]]))) > 10} || {!alive _source} || + {isNull _sink} || {!alive _sink}) exitWith { - [LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured); - detach _nozzle; - _nozzle setPosATL [(getPosATL _nozzle) select 0,(getPosATL _nozzle) select 1, 0]; - _nozzle setVelocity [0, 0, 0]; + REFUEL_DROP_NOZZLE(_nozzle) _nozzle setVariable [QGVAR(isConnected), false, true]; - _nozzle setVariable [QGVAR(isRefueling), false, true]; _nozzle setVariable [QGVAR(sink), objNull, true]; _sink setVariable [QGVAR(nozzle), objNull, true]; [_pfID] call cba_fnc_removePerFrameHandler; }; - _fuelInSource = [_source] call FUNC(getFuel); - if (_fuelInSource == 0) exitWith { - [LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured); - _nozzle setVariable [QGVAR(isRefueling), false, true]; + _tooFar = (_sink distance (_source modelToWorld (_nozzle getVariable [QGVAR(attachPos), [0,0,0]]))) > 10; + if (_tooFar) exitWith { + [LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured); + + REFUEL_DROP_NOZZLE(_nozzle) + _nozzle setVariable [QGVAR(isConnected), false, true]; + _nozzle setVariable [QGVAR(sink), objNull, true]; + _sink setVariable [QGVAR(nozzle), objNull, true]; [_pfID] call cba_fnc_removePerFrameHandler; }; - _finished = false; - if !(_fuelInSource == INFINITE_FUEL) then { - _fuelInSource = _fuelInSource - _rate; - }; - if (_fuelInSource < 0 && {_fuelInSource > -1}) then { - _fuelInSource = 0; - _finished = true; - [LSTRING(Hint_Empty), 2, _unit] call EFUNC(common,displayTextStructured); - }; - _fuelInSink = fuel _sink + ( _rate / _maxFuel); - if (_fuelInSink > 1) then { - _fuelInSink = 1; - _finished = true; - [LSTRING(Hint_Completed), 2, _unit] call EFUNC(common,displayTextStructured); + _finished = false; + if (_fueling) then { + _fuelInSource = [_source] call FUNC(getFuel); + if (_fuelInSource == 0) exitWith { + [LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured); + _nozzle setVariable [QGVAR(isRefueling), false, true]; + }; + if !(_fuelInSource == REFUEL_INFINITE_FUEL) then { + _fuelInSource = _fuelInSource - _rate; + }; + if (_fuelInSource < 0 && {_fuelInSource > -1}) then { + _fuelInSource = 0; + _finished = true; + [LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured); + }; + + _fuelInSink = fuel _sink + ( _rate / _maxFuel); + if (_fuelInSink > 1) then { + _fuelInSink = 1; + _finished = true; + [LSTRING(Hint_Completed), 2, _unit] call EFUNC(common,displayTextStructured); + }; + if !(local _sink) then { + [[_sink, _fuelInSink], QUOTE({(_this select 0) setFuel (_this select 1)}), _sink] call EFUNC(common,execRemoteFnc); + } else { + _sink setFuel _fuelInSink; + }; + [_unit, _source, _fuelInSource] call FUNC(setFuel); }; - if !(local _sink) then { - [[_sink, _fuelInSink], QUOTE({(_this select 0) setFuel (_this select 1)}), _sink] call EFUNC(common,execRemoteFnc); - } else { - _sink setFuel _fuelInSink; - }; - [_unit, _source, _fuelInSource] call FUNC(setFuel); if (_finished || {!_fueling}) exitWith { if !(_fueling) then { @@ -83,8 +90,4 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f }; _nozzle setVariable [QGVAR(isRefueling), false, true]; }; - - // display flickers even at 1 second intervals - //["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); }, 1, [_unit, _nozzle, _rate, fuel _target, _maxFuel]] call cba_fnc_addPerFrameHandler; diff --git a/addons/refuel/functions/fnc_returnNozzle.sqf b/addons/refuel/functions/fnc_returnNozzle.sqf index 21571282e6..0423574576 100644 --- a/addons/refuel/functions/fnc_returnNozzle.sqf +++ b/addons/refuel/functions/fnc_returnNozzle.sqf @@ -27,10 +27,9 @@ if (isNil "_nozzle" || {_source != _target}) exitWith {false}; _unit setVariable [QGVAR(nozzle), nil]; detach _nozzle; [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); -_unit selectWeapon (_unit getVariable QGVAR(selectedWeaponOnRefuel)); -_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; -_unit setVariable [QGVAR(isRefueling), false]; +REFUEL_UNHOLSTER_WEAPON +_unit setVariable [QGVAR(isRefueling), false]; _target setVariable [QGVAR(isConnected), false, true]; ropeDestroy (_nozzle getVariable QGVAR(rope)); deleteVehicle _nozzle; diff --git a/addons/refuel/functions/fnc_takeNozzle.sqf b/addons/refuel/functions/fnc_takeNozzle.sqf index 7699c9797c..27234239b8 100644 --- a/addons/refuel/functions/fnc_takeNozzle.sqf +++ b/addons/refuel/functions/fnc_takeNozzle.sqf @@ -22,8 +22,7 @@ params ["_unit", "_target", "_nozzle"]; [_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus); -_unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit]; -_unit action ["SwitchWeapon", _unit, _unit, 99]; +REFUEL_HOLSTER_WEAPON if (isNull _nozzle) then { // func is called on fuel truck _endPosOffset = getArray (configFile >> "CfgVehicles" >> typeOf _target >> "ace_refuel_hooks"); @@ -60,16 +59,8 @@ if (isNull _nozzle) then { // func is called on fuel truck if (_unit distance (_source modelToWorld _endPosOffset) > 10) exitWith { _nozzle = _unit getVariable [QGVAR(nozzle), objNull]; if !(isNull _nozzle) then { - detach _nozzle; - _nozzle setPosATL [(getPosATL _unit) select 0,(getPosATL _unit) select 1, 0]; - _nozzle setVelocity [0,0,0]; - _nozzle setVariable [QGVAR(isRefueling), false, true]; - _unit setVariable [QGVAR(isRefueling), false]; - _unit setVariable [QGVAR(nozzle), objNull]; - - _weaponSelect = _unit getVariable QGVAR(selectedWeaponOnRefuel); - _unit selectWeapon _weaponSelect; - _unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; + REFUEL_UNIT_DROP_NOZZLE + REFUEL_UNHOLSTER_WEAPON [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); [LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured); diff --git a/addons/refuel/functions/fnc_turnOff.sqf b/addons/refuel/functions/fnc_turnOff.sqf index 7637399878..8600b22646 100644 --- a/addons/refuel/functions/fnc_turnOff.sqf +++ b/addons/refuel/functions/fnc_turnOff.sqf @@ -9,7 +9,7 @@ * None * * Example: - * [player, nozzle] call ace_refuel_fnc_turnOff + * [tank] call ace_refuel_fnc_turnOff * * Public: No */ diff --git a/addons/refuel/functions/fnc_turnOn.sqf b/addons/refuel/functions/fnc_turnOn.sqf new file mode 100644 index 0000000000..8492540cbd --- /dev/null +++ b/addons/refuel/functions/fnc_turnOn.sqf @@ -0,0 +1,20 @@ +/* + * Author: GitHawk + * Turn on a fuel nozzle + * + * Arguments: + * 0: The object holding the nozzle + * + * Return Value: + * None + * + * Example: + * [tank] call ace_refuel_fnc_turnOn + * + * Public: No + */ +#include "script_component.hpp" + +params ["_nozzleHolder"]; + +(_nozzleHolder getVariable QGVAR(nozzle)) setVariable [QGVAR(isRefueling), true, true]; diff --git a/addons/refuel/script_component.hpp b/addons/refuel/script_component.hpp index fb0afb9ba4..f30389ba72 100644 --- a/addons/refuel/script_component.hpp +++ b/addons/refuel/script_component.hpp @@ -11,5 +11,26 @@ #include "\z\ace\addons\main\script_macros.hpp" -#define INFINITE_FUEL -1 +#define REFUEL_INFINITE_FUEL -1 #define REFUEL_ACTION_DISTANCE 7 + +#define REFUEL_DROP_NOZZLE(obj) \ + detach _nozzle; \ + _nozzle setPosATL [(getPosATL obj) select 0,(getPosATL obj) select 1, 0]; \ + _nozzle setVelocity [0,0,0]; \ + _nozzle setVariable [QGVAR(isRefueling), false, true]; + + +#define REFUEL_UNIT_DROP_NOZZLE \ + REFUEL_DROP_NOZZLE(_unit) \ + _unit setVariable [QGVAR(isRefueling), false]; \ + _unit setVariable [QGVAR(nozzle), objNull]; + +#define REFUEL_HOLSTER_WEAPON \ + _unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit]; \ + _unit action ["SwitchWeapon", _unit, _unit, 99]; + +#define REFUEL_UNHOLSTER_WEAPON \ + _weaponSelect = _unit getVariable QGVAR(selectedWeaponOnRefuel); \ + _unit selectWeapon _weaponSelect; \ + _unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; diff --git a/addons/refuel/stringtable.xml b/addons/refuel/stringtable.xml index 61adcc0890..276771f669 100644 --- a/addons/refuel/stringtable.xml +++ b/addons/refuel/stringtable.xml @@ -65,6 +65,10 @@ Stop fueling Betankung anhalten + + Start fueling + Betankung beginnen + %1 Liters fueled %1 Liters getankt