From 22576f938ef21c39280180b3375880439fa585be Mon Sep 17 00:00:00 2001 From: IngoKauffmann Date: Fri, 21 Aug 2015 22:43:45 +0200 Subject: [PATCH] Added dropping and progress bars --- addons/refuel/CfgVehicles.hpp | 30 ++++-- addons/refuel/XEH_preInit.sqf | 2 + addons/refuel/functions/fnc_canCheckFuel.sqf | 2 +- .../refuel/functions/fnc_canConnectNozzle.sqf | 2 +- .../refuel/functions/fnc_canReturnNozzle.sqf | 4 +- addons/refuel/functions/fnc_checkFuel.sqf | 4 +- addons/refuel/functions/fnc_connectNozzle.sqf | 2 +- .../functions/fnc_connectNozzleAction.sqf | 40 +++++--- addons/refuel/functions/fnc_disconnect.sqf | 5 +- addons/refuel/functions/fnc_getFuel.sqf | 2 +- addons/refuel/functions/fnc_handleKilled.sqf | 2 +- .../functions/fnc_handleUnconscious.sqf | 2 +- addons/refuel/functions/fnc_makeJerryCan.sqf | 89 ++++++++++++++++++ .../functions/fnc_moduleRefuelSettings.sqf | 2 + .../refuel/functions/fnc_readFuelCounter.sqf | 37 ++++++++ addons/refuel/functions/fnc_refuel.sqf | 6 +- addons/refuel/functions/fnc_returnNozzle.sqf | 44 ++++++--- addons/refuel/functions/fnc_setFuel.sqf | 18 ++-- addons/refuel/functions/fnc_takeNozzle.sqf | 93 ++++++++++++++----- addons/refuel/functions/fnc_turnOff.sqf | 16 +++- addons/refuel/functions/fnc_turnOn.sqf | 22 ++++- addons/refuel/script_component.hpp | 10 +- addons/refuel/stringtable.xml | 40 +++++++- 23 files changed, 378 insertions(+), 96 deletions(-) create mode 100644 addons/refuel/functions/fnc_makeJerryCan.sqf create mode 100644 addons/refuel/functions/fnc_readFuelCounter.sqf diff --git a/addons/refuel/CfgVehicles.hpp b/addons/refuel/CfgVehicles.hpp index 94c8632ee2..91947db0d6 100644 --- a/addons/refuel/CfgVehicles.hpp +++ b/addons/refuel/CfgVehicles.hpp @@ -16,6 +16,20 @@ exceptions[] = {"isNotInside"}; \ icon = PATHTOF(ui\icon_refuel_interact.paa); \ }; \ + class GVAR(CheckFuelCounter) { \ + displayName = CSTRING(CheckFuelCounter); \ + condition = "true"; \ + statement = QUOTE([ARR_2(_player,_target)] call FUNC(readFuelCounter)); \ + exceptions[] = {"isNotInside"}; \ + icon = PATHTOF(ui\icon_refuel_interact.paa); \ + }; \ + class GVAR(CheckFuel) { \ + displayName = CSTRING(CheckFuel); \ + 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); \ + }; \ class GVAR(Connect) { \ displayName = CSTRING(Connect); \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canConnectNozzle)); \ @@ -30,13 +44,6 @@ exceptions[] = {"isNotInside"}; \ icon = PATHTOF(ui\icon_refuel_interact.paa); \ }; \ - class GVAR(CheckFuel) { \ - displayName = CSTRING(CheckFuel); \ - 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); \ - }; \ }; \ }; \ }; @@ -76,7 +83,7 @@ class GVAR(PickUpNozzle) { \ displayName = CSTRING(TakeNozzle); \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \ - statement = QUOTE([ARR_3(_player,_target,_target)] call FUNC(TakeNozzle)); \ + statement = QUOTE([ARR_3(_player,objNull,_target)] call FUNC(TakeNozzle)); \ exceptions[] = {"isNotInside"}; \ icon = PATHTOF(ui\icon_refuel_interact.paa); \ }; \ @@ -203,16 +210,19 @@ class CfgVehicles { class Ship_F : Ship { MACRO_CONNECT_ACTIONS GVAR(fuelCapacity) = 2000; + GVAR(flowRate) = 4; }; class Boat_Civil_01_base_F : Ship_F { GVAR(fuelCapacity) = 200; }; - class Boat_F : Ship_F {}; + class Boat_F : Ship_F { + GVAR(flowRate) = 1; + }; class Boat_Armed_01_base_F : Boat_F { - GVAR(fuelCapacity) = 1000; + GVAR(fuelCapacity) = 300; }; class Rubber_duck_base_F : Boat_F { GVAR(fuelCapacity) = 30; diff --git a/addons/refuel/XEH_preInit.sqf b/addons/refuel/XEH_preInit.sqf index bc9caebd86..9ed818f046 100644 --- a/addons/refuel/XEH_preInit.sqf +++ b/addons/refuel/XEH_preInit.sqf @@ -16,7 +16,9 @@ PREP(disconnect); PREP(getFuel); PREP(handleKilled); PREP(handleUnconscious); +PREP(makeJerryCan); PREP(moduleRefuelSettings); +PREP(readFuelCounter); PREP(refuel); PREP(returnNozzle); PREP(setFuel); diff --git a/addons/refuel/functions/fnc_canCheckFuel.sqf b/addons/refuel/functions/fnc_canCheckFuel.sqf index bc29c23bf4..a1584ea333 100644 --- a/addons/refuel/functions/fnc_canCheckFuel.sqf +++ b/addons/refuel/functions/fnc_canCheckFuel.sqf @@ -10,7 +10,7 @@ * Can Check Fuel * * Example: - * [unit, target] call ace_refuel_fnc_canCheckFuel + * [player, truck] call ace_refuel_fnc_canCheckFuel * * Public: No */ diff --git a/addons/refuel/functions/fnc_canConnectNozzle.sqf b/addons/refuel/functions/fnc_canConnectNozzle.sqf index b87cb88237..5c6bdce502 100644 --- a/addons/refuel/functions/fnc_canConnectNozzle.sqf +++ b/addons/refuel/functions/fnc_canConnectNozzle.sqf @@ -10,7 +10,7 @@ * Can Connect Nozzle * * Example: - * [unit, tank] call ace_refuel_fnc_canConnectNozzle + * [player, tank] call ace_refuel_fnc_canConnectNozzle * * Public: No */ diff --git a/addons/refuel/functions/fnc_canReturnNozzle.sqf b/addons/refuel/functions/fnc_canReturnNozzle.sqf index f3cb2a65e7..139c921d34 100644 --- a/addons/refuel/functions/fnc_canReturnNozzle.sqf +++ b/addons/refuel/functions/fnc_canReturnNozzle.sqf @@ -4,13 +4,13 @@ * * Arguments: * 0: Unit - * 1: Target + * 1: Fuel truck * * Return Value: * Can Return Nozzle * * Example: - * [unit, tank] call ace_refuel_fnc_canReturnNozzle + * [player, fuelTruck] call ace_refuel_fnc_canReturnNozzle * * Public: No */ diff --git a/addons/refuel/functions/fnc_checkFuel.sqf b/addons/refuel/functions/fnc_checkFuel.sqf index 0f26453920..b50e9a8171 100644 --- a/addons/refuel/functions/fnc_checkFuel.sqf +++ b/addons/refuel/functions/fnc_checkFuel.sqf @@ -10,7 +10,7 @@ * None * * Example: - * [unit, target] call ace_refuel_fnc_checkFuel + * [player, fuelTruck] call ace_refuel_fnc_checkFuel * * Public: No */ @@ -34,7 +34,7 @@ _fuel = [_target] call FUNC(getFuel); true }, {true}, - localize LSTRING(CheckFuel), + localize LSTRING(CheckFuelAction), {true}, ["isnotinside"] ] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/fnc_connectNozzle.sqf b/addons/refuel/functions/fnc_connectNozzle.sqf index 261527bc3f..6f87c70303 100644 --- a/addons/refuel/functions/fnc_connectNozzle.sqf +++ b/addons/refuel/functions/fnc_connectNozzle.sqf @@ -11,7 +11,7 @@ * None * * Example: - * [unit, target] call ace_refuel_fnc_connectNozzle + * [player, tank] call ace_refuel_fnc_connectNozzle * * Public: No */ diff --git a/addons/refuel/functions/fnc_connectNozzleAction.sqf b/addons/refuel/functions/fnc_connectNozzleAction.sqf index 44d0f4ebf4..74bbe5b506 100644 --- a/addons/refuel/functions/fnc_connectNozzleAction.sqf +++ b/addons/refuel/functions/fnc_connectNozzleAction.sqf @@ -71,17 +71,33 @@ _closeInDistance = (_closeInDistance - 0.0085); _endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance); _endPosTestOffset set [2, (_startingOffset select 2)]; -// TODO put animation and delayed connect ? +[ + 2, + [_unit, _nozzle, _target, _endPosTestOffset], + { + private "_actionID"; + params ["_args"]; + _args params ["_unit", "_nozzle", "_target", "_endPosTestOffset"]; + _unit setVariable [QGVAR(nozzle), nil]; + _unit setVariable [QGVAR(isRefueling), false]; + [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + REFUEL_UNHOLSTER_WEAPON + _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _unit removeAction _actionID; + _unit setVariable [QGVAR(ReleaseActionID), nil]; + }; -_unit setVariable [QGVAR(nozzle), nil]; -_unit setVariable [QGVAR(isRefueling), false]; -[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); -REFUEL_UNHOLSTER_WEAPON + detach _nozzle; + _nozzle attachTo [_target, _endPosTestOffset]; + _nozzle setVariable [QGVAR(sink), _target, true]; + _nozzle setVariable [QGVAR(isConnected), true, true]; + _target setVariable [QGVAR(nozzle), _nozzle, true]; -detach _nozzle; -_nozzle attachTo [_target, _endPosTestOffset]; -_nozzle setVariable [QGVAR(sink), _target, true]; -_nozzle setVariable [QGVAR(isConnected), true, true]; -_target setVariable [QGVAR(nozzle), _nozzle, true]; - -[_unit, _target, _nozzle, _endPosTestOffset] call FUNC(refuel); + [_unit, _target, _nozzle, _endPosTestOffset] call FUNC(refuel); + }, + "", + localize LSTRING(ConnectAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/fnc_disconnect.sqf b/addons/refuel/functions/fnc_disconnect.sqf index 69205d13e4..d529b0f821 100644 --- a/addons/refuel/functions/fnc_disconnect.sqf +++ b/addons/refuel/functions/fnc_disconnect.sqf @@ -10,7 +10,7 @@ * None * * Example: - * [unit, truck] call ace_refuel_fnc_disconnect + * [player, nozzle] call ace_refuel_fnc_disconnect * * Public: No */ @@ -24,7 +24,6 @@ if (isNull _sink) exitWith {}; _sink setVariable [QGVAR(nozzle), objNull, true]; _nozzle setVariable [QGVAR(sink), objNull, true]; -REFUEL_DROP_NOZZLE(_nozzle) -_unit setVariable [QGVAR(nozzle), _nozzle]; +REFUEL_DETACH_NOZZLE [_unit, objNull, _nozzle] call FUNC(takeNozzle); diff --git a/addons/refuel/functions/fnc_getFuel.sqf b/addons/refuel/functions/fnc_getFuel.sqf index 038119bd46..9bbb4987be 100644 --- a/addons/refuel/functions/fnc_getFuel.sqf +++ b/addons/refuel/functions/fnc_getFuel.sqf @@ -9,7 +9,7 @@ * Fuel left (in liters) * * Example: - * [target] call ace_refuel_fnc_getFuel + * [fuelTruck] call ace_refuel_fnc_getFuel * * Public: No */ diff --git a/addons/refuel/functions/fnc_handleKilled.sqf b/addons/refuel/functions/fnc_handleKilled.sqf index ab1ee8a132..f61f4c0eae 100644 --- a/addons/refuel/functions/fnc_handleKilled.sqf +++ b/addons/refuel/functions/fnc_handleKilled.sqf @@ -9,7 +9,7 @@ * None * * Example: - * [unit] call ace_refuel_fnc_handleKilled + * [player] call ace_refuel_fnc_handleKilled * * Public: No */ diff --git a/addons/refuel/functions/fnc_handleUnconscious.sqf b/addons/refuel/functions/fnc_handleUnconscious.sqf index 65c47b2610..0fc66288e8 100644 --- a/addons/refuel/functions/fnc_handleUnconscious.sqf +++ b/addons/refuel/functions/fnc_handleUnconscious.sqf @@ -10,7 +10,7 @@ * None * * Example: - * [unit, true] call ace_refuel_fnc_handleUnconscious + * [player, true] call ace_refuel_fnc_handleUnconscious * * Public: No */ diff --git a/addons/refuel/functions/fnc_makeJerryCan.sqf b/addons/refuel/functions/fnc_makeJerryCan.sqf new file mode 100644 index 0000000000..3df209196d --- /dev/null +++ b/addons/refuel/functions/fnc_makeJerryCan.sqf @@ -0,0 +1,89 @@ +/* + * Author: GitHawk + * Makes an object into a jerry can. + * + * Arguments: + * 0: Target + * 1: Fuel amount (in liters) + * + * Return Value: + * None + * + * Example: + * [can] call ace_refuel_fnc_makeJerryCan + * + * Public: No + */ +#include "script_component.hpp" + +private ["_actions", "_action"]; +params ["_target", ["_fuelAmount", 20]]; + +if (isNull _target || + {_target isKindOf "AllVehicles"}) exitWith {}; + +[_target, _fuelAmount] call FUNC(setFuel); +_target setVariable [QGVAR(source), _target, true]; + +_actions = []; +// Add pickup +_action = [QGVAR(PickUpNozzle), + localize LSTRING(TakeNozzle), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {[_player, objNull, _target] call FUNC(TakeNozzle)}, + {[_player, _target] call FUNC(canTakeNozzle)}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); +_actions pushBack [_action, [], _target]; + +// Add turnOn +_action = [QGVAR(TurnOn), + localize LSTRING(TurnOn), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {[_player, _target] call FUNC(turnOn)}, + {[_player, _target] call FUNC(canTurnOn)}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); +_actions pushBack [_action, [], _target]; + +// Add turnOff +_action = [QGVAR(TurnOff), + localize LSTRING(TurnOff), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {[_player, _target] call FUNC(turnOff)}, + {[_player, _target] call FUNC(canTurnOff)}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); +_actions pushBack [_action, [], _target]; + +// Add disconnect +_action = [QGVAR(Disconnect), + localize LSTRING(Disconnect), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {[_player, _target] call FUNC(disconnect)}, + {[_player, _target] call FUNC(canDisconnect)}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); +_actions pushBack [_action, [], _target]; + +// Main Action +_action = [QGVAR(Refuel), + localize LSTRING(Refuel), + QUOTE(PATHTOF(ui\icon_refuel_interact.paa)), + {}, + {true}, + {}, + [], + [0, 0, 0], + REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction); + +[_target, 0] call EFUNC(interact_menu,addMainAction); +[_target, 0, ["ACE_MainActions"], [_action, _actions, _target]] call EFUNC(interact_menu,addActionToObject); diff --git a/addons/refuel/functions/fnc_moduleRefuelSettings.sqf b/addons/refuel/functions/fnc_moduleRefuelSettings.sqf index 3a6faeeab6..6cdc78b9f7 100644 --- a/addons/refuel/functions/fnc_moduleRefuelSettings.sqf +++ b/addons/refuel/functions/fnc_moduleRefuelSettings.sqf @@ -20,3 +20,5 @@ params ["_logic", "_units", "_activated"]; if !(_activated) exitWith {}; [_logic, QGVAR(rate), "rate"] call EFUNC(common,readSettingFromModule); + +diag_log text format ["[ACE]: Refuel Module Initialized with flow rate: %1", GVAR(rate)]; diff --git a/addons/refuel/functions/fnc_readFuelCounter.sqf b/addons/refuel/functions/fnc_readFuelCounter.sqf new file mode 100644 index 0000000000..af95c044e3 --- /dev/null +++ b/addons/refuel/functions/fnc_readFuelCounter.sqf @@ -0,0 +1,37 @@ +/* + * Author: GitHawk + * Reads the fuel counter. + * + * Arguments: + * 0: Unit + * 1: Fuel Truck + * + * Return Value: + * None + * + * Example: + * [player, fuelTruck] call ace_refuel_fnc_readFuelCounter + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_target"]; + +[ + 2, + [_unit, _target], + { + private ["_currentFuel", "_fuelCounter"]; + params ["_args"]; + _args params ["_unit", "_target"]; + + _currentFuel = [_target] call FUNC(getFuel); + _fuelCounter = 0.01 * round (100 * ((_target getVariable [QGVAR(fuelCounter), _currentFuel]) - _currentFuel)); + [[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured); + }, + "", + localize LSTRING(CheckFuelCounterAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/fnc_refuel.sqf b/addons/refuel/functions/fnc_refuel.sqf index 2b33784aa1..4993ad4758 100644 --- a/addons/refuel/functions/fnc_refuel.sqf +++ b/addons/refuel/functions/fnc_refuel.sqf @@ -31,7 +31,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f _fueling = _nozzle getVariable [QGVAR(isRefueling), false]; if (!alive _source || {!alive _sink}) exitWith { - REFUEL_DROP_NOZZLE(_nozzle) + REFUEL_DROP_NOZZLE _nozzle setVariable [QGVAR(isConnected), false, true]; _nozzle setVariable [QGVAR(sink), objNull, true]; _sink setVariable [QGVAR(nozzle), objNull, true]; @@ -41,7 +41,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f if (_tooFar) exitWith { [LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured); - REFUEL_DROP_NOZZLE(_nozzle) + REFUEL_DROP_NOZZLE _nozzle setVariable [QGVAR(isConnected), false, true]; _nozzle setVariable [QGVAR(sink), objNull, true]; _sink setVariable [QGVAR(nozzle), objNull, true]; @@ -75,7 +75,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f } else { _sink setFuel _fuelInSink; }; - [_unit, _source, _fuelInSource] call FUNC(setFuel); + [_source, _fuelInSource] call FUNC(setFuel); }; if (_finished) exitWith { diff --git a/addons/refuel/functions/fnc_returnNozzle.sqf b/addons/refuel/functions/fnc_returnNozzle.sqf index a167d308c0..8a9916c39e 100644 --- a/addons/refuel/functions/fnc_returnNozzle.sqf +++ b/addons/refuel/functions/fnc_returnNozzle.sqf @@ -4,19 +4,19 @@ * * Arguments: * 0: Unit - * 1: Target + * 1: Fuel Truck * * Return Value: * Returned Nozzle * * Example: - * [player] call ace_refuel_fnc_returnNozzle + * [player, fuelTruck] call ace_refuel_fnc_returnNozzle * * Public: No */ #include "script_component.hpp" -private ["_nozzle", "_dummy"]; +private ["_nozzle", "_dummy", "_actionID"]; params ["_unit", "_target"]; _nozzle = _unit getVariable QGVAR(nozzle); @@ -24,17 +24,35 @@ _source = _nozzle getVariable QGVAR(source); if (isNil "_nozzle" || {_source != _target}) exitWith {false}; -_unit setVariable [QGVAR(nozzle), nil]; -detach _nozzle; -[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); -REFUEL_UNHOLSTER_WEAPON +[ + 2, + [_unit, _nozzle, _target], + { + private "_actionID"; + params ["_args"]; + _args params ["_unit", "_nozzle", "_target"]; + _unit setVariable [QGVAR(nozzle), nil]; + detach _nozzle; + [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + REFUEL_UNHOLSTER_WEAPON + _unit setVariable [QGVAR(isRefueling), false]; + _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _unit removeAction _actionID; + _unit setVariable [QGVAR(ReleaseActionID), nil]; + }; -_unit setVariable [QGVAR(isRefueling), false]; -_target setVariable [QGVAR(isConnected), false, true]; -ropeDestroy (_nozzle getVariable QGVAR(rope)); -deleteVehicle _nozzle; + _target setVariable [QGVAR(isConnected), false, true]; + ropeDestroy (_nozzle getVariable QGVAR(rope)); + deleteVehicle _nozzle; -_target setHitPointDamage ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]; -_target setVariable [QGVAR(engineHit), nil, true]; + _target setHitPointDamage ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]; + _target setVariable [QGVAR(engineHit), nil, true]; + }, + "", + localize LSTRING(ConnectAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); true diff --git a/addons/refuel/functions/fnc_setFuel.sqf b/addons/refuel/functions/fnc_setFuel.sqf index 2e0608e573..a182d463ae 100644 --- a/addons/refuel/functions/fnc_setFuel.sqf +++ b/addons/refuel/functions/fnc_setFuel.sqf @@ -3,26 +3,22 @@ * Set the remaining fuel amount. * * Arguments: - * 0: Unit - * 1: Target - * 2: Amount (in liters) + * 0: Fuel Truck + * 1: Amount (in liters) * * Return Value: * None * * Example: - * [unit, target] call ace_refuel_fnc_getFuel + * [fuelTruck, 42] call ace_refuel_fnc_setFuel * * Public: No */ #include "script_component.hpp" private ["_maxFuel"]; -params ["_unit", "_target", "_fuel"]; +params ["_target", "_fuel"]; -if (isNull _unit || - {isNull _target} || - {!(_unit isKindOf "CAManBase")} || - {!local _unit} || - {(_target distance _unit) > 7}) exitWith {}; +if (isNull _target || + {isNil "_fuel"}) exitWith {}; -_target setVariable [QGVAR(currentFuelCargo), (getNumber (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(fuelCargo))) min _fuel, true]; +_target setVariable [QGVAR(currentFuelCargo), _fuel, true]; diff --git a/addons/refuel/functions/fnc_takeNozzle.sqf b/addons/refuel/functions/fnc_takeNozzle.sqf index 615b24d073..99557a5842 100644 --- a/addons/refuel/functions/fnc_takeNozzle.sqf +++ b/addons/refuel/functions/fnc_takeNozzle.sqf @@ -4,14 +4,15 @@ * * Arguments: * 0: Unit - * 1: Target + * 1: Fuel Truck * 2: Nozzle (optional) * * Return Value: * None * * Example: - * [unit, target, truck] call ace_refuel_fnc_takeNozzle + * [player, fuelTruck] call ace_refuel_fnc_takeNozzle + * [player, objNull, nozzle] call ace_refuel_fnc_takeNozzle * * Public: No */ @@ -24,8 +25,6 @@ params ["_unit", "_target", ["_nozzle", objNull]]; REFUEL_HOLSTER_WEAPON -// TODO add pickup animation - _endPosOffset = [0, 0, 0]; if (isNull _nozzle) then { // func is called on fuel truck _target setVariable [QGVAR(engineHit), _target getHitPointDamage "HitEngine", true]; @@ -42,24 +41,78 @@ if (isNull _nozzle) then { // func is called on fuel truck } else { _endPosOffset = _endPosOffset select 0; }; + [ + 2, + [_unit, _target, _endPosOffset], + { + private ["_newNozzle", "_rope", "_actionID"]; + params ["_args"]; + _args params ["_unit", "_target", "_endPosOffset"]; - [{ - params ["_unit", "_target", "_endPosOffset"]; - _newNozzle = "ACE_refuel_fuelNozzle" createVehicle position _unit; - _newNozzle attachTo [_unit, [-0.02,-0.05,0], "righthandmiddle1"]; // TODO replace with right coordinates for real model - _unit setVariable [QGVAR(nozzle), _newNozzle]; + _newNozzle = "ACE_refuel_fuelNozzle" createVehicle position _unit; + _newNozzle attachTo [_unit, [-0.02,-0.05,0], "righthandmiddle1"]; // TODO replace with right coordinates for real model + _unit setVariable [QGVAR(nozzle), _newNozzle]; - _rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, 0, 0], 12]; - _newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true]; - _newNozzle setVariable [QGVAR(source), _target, true]; - _newNozzle setVariable [QGVAR(rope), _rope, true]; - }, [_unit, _target, _endPosOffset], 2, 0] call EFUNC(common,waitAndExecute); + _rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, 0, 0], 12]; + _newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true]; + _newNozzle setVariable [QGVAR(source), _target, true]; + _newNozzle setVariable [QGVAR(rope), _rope, true]; + + _unit setVariable [QGVAR(isRefueling), true]; + _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _unit removeAction _actionID; + }; + _actionID = _unit addAction [ + format ["%1", localize ELSTRING(dragging,Drop)], + 'params ["_unit"]; _nozzle = _unit getVariable QGVAR(nozzle); REFUEL_UNIT_DROP_NOZZLE', + nil, + 20, + false, + true, + "", + '!isNull (_target getVariable [QGVAR(nozzle), objNull])' + ]; + _unit setVariable [QGVAR(ReleaseActionID), _actionID]; + }, + "", + localize LSTRING(TakeNozzleAction), + {true}, + ["isnotinside"] + ] call EFUNC(common,progressBar); } else { // func is called in muzzle either connected or on ground - [{ - params ["_unit", "_nozzle"]; - _nozzle attachTo [_unit, [-0.02,-0.05,0], "righthandmiddle1"]; // TODO replace with right coordinates for real model - _unit setVariable [QGVAR(nozzle), _nozzle]; - }, [_unit, _nozzle], 2, 0] call EFUNC(common,waitAndExecute); + [ + 2, + [_unit, _nozzle], + { + private ["_actionID"]; + params ["_args"]; + _args params ["_unit", "_nozzle"]; + _nozzle attachTo [_unit, [-0.02,-0.05,0], "righthandmiddle1"]; // TODO replace with right coordinates for real model + _unit setVariable [QGVAR(nozzle), _nozzle]; + + _unit setVariable [QGVAR(isRefueling), true]; + _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _unit removeAction _actionID; + }; + _actionID = _unit addAction [ + format ["%1", localize ELSTRING(dragging,Drop)], + 'params ["_unit"]; _nozzle = _unit getVariable QGVAR(nozzle); REFUEL_UNIT_DROP_NOZZLE', + nil, + 20, + false, + true, + "", + '!isNull (_target getVariable [QGVAR(nozzle), objNull])' + ]; + _unit setVariable [QGVAR(ReleaseActionID), _actionID]; + }, + "", + localize LSTRING(TakeNozzleAction), + {true}, + ["isnotinside"] + ] call EFUNC(common,progressBar); _target = _nozzle getVariable QGVAR(source); _endPosOffset = _nozzle getVariable QGVAR(attachPos); @@ -81,5 +134,3 @@ if (isNull _nozzle) then { // func is called on fuel truck [_pfID] call cba_fnc_removePerFrameHandler; }; }, 0, [_unit, _target, _endPosOffset]] call cba_fnc_addPerFrameHandler; - -_unit setVariable [QGVAR(isRefueling), true]; diff --git a/addons/refuel/functions/fnc_turnOff.sqf b/addons/refuel/functions/fnc_turnOff.sqf index aae508ab3c..115c1eabe2 100644 --- a/addons/refuel/functions/fnc_turnOff.sqf +++ b/addons/refuel/functions/fnc_turnOff.sqf @@ -18,5 +18,17 @@ params ["_unit", "_nozzle"]; -_nozzle setVariable [QGVAR(isRefueling), false, true]; -[LSTRING(Hint_Stopped), 1.5, _unit] call EFUNC(common,displayTextStructured); +[ + 2, + [_unit, _nozzle], + { + params ["_args"]; + _args params ["_unit", "_nozzle"]; + _nozzle setVariable [QGVAR(isRefueling), false, true]; + [LSTRING(Hint_Stopped), 1.5, _unit] call EFUNC(common,displayTextStructured); + }, + "", + localize LSTRING(TurnOffAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/functions/fnc_turnOn.sqf b/addons/refuel/functions/fnc_turnOn.sqf index 2cba278ed8..819fad4529 100644 --- a/addons/refuel/functions/fnc_turnOn.sqf +++ b/addons/refuel/functions/fnc_turnOn.sqf @@ -10,7 +10,7 @@ * None * * Example: - * [nozzle] call ace_refuel_fnc_turnOn + * [player, nozzle] call ace_refuel_fnc_turnOn * * Public: No */ @@ -18,5 +18,21 @@ params ["_unit", "_nozzle"]; -_nozzle setVariable [QGVAR(isRefueling), true, true]; -[LSTRING(Hint_Started), 1.5, _unit] call EFUNC(common,displayTextStructured); +[ + 2, + [_unit, _nozzle], + { + private "_source"; + params ["_args"]; + _args params ["_unit", "_nozzle"]; + _nozzle setVariable [QGVAR(isRefueling), true, true]; + [LSTRING(Hint_Started), 1.5, _unit] call EFUNC(common,displayTextStructured); + + _source = _nozzle getVariable QGVAR(source); + _source setVariable [QGVAR(fuelCounter), [_source] call FUNC(getFuel)]; + }, + "", + localize LSTRING(TurnOnAction), + {true}, + ["isnotinside"] +] call EFUNC(common,progressBar); diff --git a/addons/refuel/script_component.hpp b/addons/refuel/script_component.hpp index f30389ba72..dc701cd00a 100644 --- a/addons/refuel/script_component.hpp +++ b/addons/refuel/script_component.hpp @@ -14,15 +14,17 @@ #define REFUEL_INFINITE_FUEL -1 #define REFUEL_ACTION_DISTANCE 7 -#define REFUEL_DROP_NOZZLE(obj) \ +#define REFUEL_DETACH_NOZZLE \ 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_DROP_NOZZLE \ + REFUEL_DETACH_NOZZLE \ + _nozzle setPosATL [(getPosATL _nozzle) select 0, (getPosATL _nozzle) select 1, 0];\ + _nozzle setVelocity [0, 0, 0]; #define REFUEL_UNIT_DROP_NOZZLE \ - REFUEL_DROP_NOZZLE(_unit) \ + REFUEL_DROP_NOZZLE \ _unit setVariable [QGVAR(isRefueling), false]; \ _unit setVariable [QGVAR(nozzle), objNull]; diff --git a/addons/refuel/stringtable.xml b/addons/refuel/stringtable.xml index 85e1df86bb..ec4c57f76e 100644 --- a/addons/refuel/stringtable.xml +++ b/addons/refuel/stringtable.xml @@ -21,10 +21,18 @@ Take fuel nozzle Zapfpistole nehmen + + Taking fuel nozzle ... + Nehme Zapfpistole ... + Connect fuel nozzle Zapfpistole anschließen + + Connecting fuel nozzle ... + Zapfpistole anschließen ... + Disconnect fuel nozzle Zapfpistole entfernen @@ -34,8 +42,12 @@ Anschließen - Check remaining fuel ... - Verbleibenden Kraftstoff überprüfen ... + Check remaining fuel + Verbleibenden Kraftstoff überprüfen + + + Checking remaining fuel ... + Überprüfe verbleibenden Kraftstoff ... There are %1 liters left. @@ -43,7 +55,7 @@ There is no fuel left. - Es ist kein Treibstoff übrig. + Es ist kein Kraftstoff übrig. Cancel @@ -55,12 +67,20 @@ Stop fueling - Betankung anhalten + Betankung stoppen + + + Stopping fueling ... + Stoppe Betankung ... Start fueling Betankung beginnen + + Starting fueling ... + Beginne Betankung ... + %1 Liters fueled %1 Liters getankt @@ -89,5 +109,17 @@ Return fuel nozzle Zapfpistole zurückstecken + + Check fuel counter + Tankuhr ansehen + + + >Checking fuel counter ... + Betrachte Tankuhr ... + + + %1 liters have been fueled. + %1 Liter wurden getankt. +