From 113ac0f370033359a7c899629584dcf856e3ec00 Mon Sep 17 00:00:00 2001 From: IngoKauffmann Date: Sat, 21 Nov 2015 23:24:24 +0100 Subject: [PATCH] Minor improvements fnc_reset is still WIP --- addons/refuel/XEH_preInit.sqf | 1 + addons/refuel/functions/fn_reset.sqf | 51 +++++++++++++++++++ .../functions/fnc_connectNozzleAction.sqf | 2 +- addons/refuel/functions/fnc_returnNozzle.sqf | 1 + addons/refuel/functions/fnc_takeNozzle.sqf | 1 + 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 addons/refuel/functions/fn_reset.sqf diff --git a/addons/refuel/XEH_preInit.sqf b/addons/refuel/XEH_preInit.sqf index 7fd31122d6..5250f09f11 100644 --- a/addons/refuel/XEH_preInit.sqf +++ b/addons/refuel/XEH_preInit.sqf @@ -21,6 +21,7 @@ PREP(makeJerryCan); PREP(moduleRefuelSettings); PREP(readFuelCounter); PREP(refuel); +PREP(reset); PREP(returnNozzle); PREP(setFuel); PREP(takeNozzle); diff --git a/addons/refuel/functions/fn_reset.sqf b/addons/refuel/functions/fn_reset.sqf new file mode 100644 index 0000000000..f27e0e9613 --- /dev/null +++ b/addons/refuel/functions/fn_reset.sqf @@ -0,0 +1,51 @@ +/* + * Author: GitHawk + * Resets a fuel vehicle in case is got bugged + * + * Arguments: + * 0: Fuel truck + * + * Return Value: + * None + * + * Example: + * [truck] call ace_refuel_fnc_reset + * + * Public: No + */ +#include "script_component.hpp" + +params ["_target"]; + +if !(local _target) then { + [[_target, ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]], "{(_this select 0) setHitPointDamage (_this select 1)}", _sink] call EFUNC(common,execRemoteFnc); +} else { + _target setHitPointDamage ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]; +}; +_target setVariable [QGVAR(engineHit), nil, true]; +_target setVariable [QGVAR(isConnected), false, true]; + +_nozzle = _target getVariable [QGVAR(nozzle), nil]; +if !(isNil "_nozzle") then { + _nozzleTarget = _nozzle getVariable [QGVAR(sink), nil]; + if !(isNil "_nozzleTarget") then { + _nozzleTarget setVariable [QGVAR(nozzle), nil, true]; + }; + + _rope = _nozzle getVariable [QGVAR(rope), nil]; + if !(isNil "_rope") then { + ropeDestroy _rope; + }; + + { + // FIXME needs to be done locally + _actionID = _x getVariable [QGVAR(ReleaseActionID), -1]; + if (_actionID != -1) then { + _x removeAction _actionID; + _x setVariable [QGVAR(isRefueling), false, true]; + _x setVariable [QGVAR(ReleaseActionID), nil]; + }; + } count allPlayers; + deleteVehicle _nozzle; +}; +_target getVariable [QGVAR(nozzle), nil, true]; diff --git a/addons/refuel/functions/fnc_connectNozzleAction.sqf b/addons/refuel/functions/fnc_connectNozzleAction.sqf index 2c35296b9e..42190aacc6 100644 --- a/addons/refuel/functions/fnc_connectNozzleAction.sqf +++ b/addons/refuel/functions/fnc_connectNozzleAction.sqf @@ -95,7 +95,7 @@ _endPosTestOffset set [2, (_startingOffset select 2)]; _target setVariable [QGVAR(nozzle), _nozzle, true]; _source = _nozzle getVariable QGVAR(source); - _source setVariable [QGVAR(fuelCounter), [_source] call FUNC(getFuel)]; + _source setVariable [QGVAR(fuelCounter), [_source] call FUNC(getFuel), true]; [_unit, _target, _nozzle, _endPosTestOffset] call FUNC(refuel); }, diff --git a/addons/refuel/functions/fnc_returnNozzle.sqf b/addons/refuel/functions/fnc_returnNozzle.sqf index 429dd9666c..6de80a8468 100644 --- a/addons/refuel/functions/fnc_returnNozzle.sqf +++ b/addons/refuel/functions/fnc_returnNozzle.sqf @@ -43,6 +43,7 @@ if (isNull _nozzle || {_source != _target}) exitWith {false}; }; _target setVariable [QGVAR(isConnected), false, true]; + _target setVariable [QGVAR(nozzle), nil, 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 70fcb43dc0..221984ba77 100644 --- a/addons/refuel/functions/fnc_takeNozzle.sqf +++ b/addons/refuel/functions/fnc_takeNozzle.sqf @@ -61,6 +61,7 @@ if (isNull _nozzle) then { // func is called on fuel truck _newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true]; _newNozzle setVariable [QGVAR(source), _target, true]; _newNozzle setVariable [QGVAR(rope), _rope, true]; + _target setVariable [QGVAR(nozzle), _newNozzle, true]; _unit setVariable [QGVAR(isRefueling), true]; _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];