Merge pull request #3430 from GitHawk/refuel_ropeImprovement

Refuel improvements
This commit is contained in:
Thomas Kooi 2016-02-27 12:40:50 +01:00
commit adcfec6ff0
10 changed files with 39 additions and 14 deletions

View File

@ -19,8 +19,13 @@
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
private _engine = false;
if (_target isKindOf "AllVehicles") then {
_engine = isEngineOn _target;
};
!(isNull _nozzle ||
{isEngineOn _target} ||
{_engine} ||
{(_target distance _unit) > REFUEL_ACTION_DISTANCE} ||
{!isNull (_target getVariable [QGVAR(nozzle), objNull])}) // TODO verify cant connect multiple fuel lines

View File

@ -125,7 +125,12 @@ _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), true];
private _fuel = [_source] call FUNC(getFuel);
if (_fuel == REFUEL_INFINITE_FUEL) then {
_source setVariable [QGVAR(fuelCounter), 0, true];
} else {
_source setVariable [QGVAR(fuelCounter), _fuel, true];
};
[_unit, _target, _nozzle, _endPosTestOffset] call FUNC(refuel);
},

View File

@ -11,12 +11,14 @@
* Example:
* [fuelTruck] call ace_refuel_fnc_getFuel
*
* Public: No
* Public: Yes
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]]];
if (isNull _target) exitWith {0};
private _fuel = _target getVariable QGVAR(currentFuelCargo);
if (isNil "_fuel") then {

View File

@ -26,8 +26,13 @@ params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
_args params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
private _currentFuel = [_target] call FUNC(getFuel);
private _fuelCounter = 0.01 * round (100 * ((_target getVariable [QGVAR(fuelCounter), _currentFuel]) - _currentFuel));
[[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured);
if (_currentFuel == REFUEL_INFINITE_FUEL) then {
private _fuelCounter = 0.01 * round (100 * (_target getVariable [QGVAR(fuelCounter), 0]));
[[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured);
} else {
private _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),

View File

@ -59,8 +59,10 @@ private _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >>
};
if !(_fuelInSource == REFUEL_INFINITE_FUEL) then {
_fuelInSource = _fuelInSource - _rate;
} else {
_source setVariable [QGVAR(fuelCounter), (_source getVariable [QGVAR(fuelCounter), 0]) + _rate, true];
};
if (_fuelInSource < 0 && {_fuelInSource > -1}) then {
if (_fuelInSource < 0 && {_fuelInSource > REFUEL_INFINITE_FUEL}) then {
_fuelInSource = 0;
_finished = true;
[LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured);

View File

@ -32,8 +32,8 @@ if !(isNil "_nozzle") then {
_nozzleTarget setVariable [QGVAR(nozzle), nil, true];
};
private _rope = _nozzle getVariable [QGVAR(rope), nil];
if !(isNil "_rope") then {
private _rope = _nozzle getVariable [QGVAR(rope), objNull];
if !(isNull _rope) then {
ropeDestroy _rope;
};

View File

@ -42,7 +42,10 @@ if (isNull _nozzle || {_source != _target}) exitWith {false};
_target setVariable [QGVAR(isConnected), false, true];
_target setVariable [QGVAR(ownedNozzle), nil, true];
ropeDestroy (_nozzle getVariable QGVAR(rope));
private _rope = _nozzle getVariable [QGVAR(rope), objNull];
if !(isNull _rope) then {
ropeDestroy _rope;
};
deleteVehicle _nozzle;
if !(local _target) then {

View File

@ -12,7 +12,7 @@
* Example:
* [fuelTruck, 42] call ace_refuel_fnc_setFuel
*
* Public: No
* Public: Yes
*/
#include "script_component.hpp"

View File

@ -55,10 +55,13 @@ if (isNull _nozzle) then { // func is called on fuel truck
_newNozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
_unit setVariable [QGVAR(nozzle), _newNozzle, true];
private _rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, -0.20, 0.12], REFUEL_HOSE_LENGTH];
if (_target isKindOf "AllVehicles") then {
// Currently ropeCreate requires its first parameter to be a real vehicle
private _rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, -0.20, 0.12], REFUEL_HOSE_LENGTH];
_newNozzle setVariable [QGVAR(rope), _rope, true];
};
_newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true];
_newNozzle setVariable [QGVAR(source), _target, true];
_newNozzle setVariable [QGVAR(rope), _rope, true];
_target setVariable [QGVAR(ownedNozzle), _newNozzle, true];
_unit setVariable [QGVAR(isRefueling), true];
@ -83,7 +86,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
{true},
["isnotinside"]
] call EFUNC(common,progressBar);
} else { // func is called in muzzle either connected or on ground
} else { // func is called on muzzle either connected or on ground
[
2,
[_unit, _nozzle],

View File

@ -16,7 +16,7 @@
#include "\z\ace\addons\main\script_macros.hpp"
#define REFUEL_INFINITE_FUEL -1
#define REFUEL_INFINITE_FUEL -10
#define REFUEL_ACTION_DISTANCE 7
#define REFUEL_HOSE_LENGTH 12