Skip to content

Commit

Permalink
Merge pull request #3064 from GitHawk/refuel
Browse files Browse the repository at this point in the history
Adaptation of fnc_makeJerryCan to new interact_menu
  • Loading branch information
PabstMirror committed Jan 1, 2016
2 parents 40e85f8 + d16417a commit 32b4416
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 41 deletions.
6 changes: 3 additions & 3 deletions addons/refuel/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class CfgVehicles {
XEH_ENABLED;
MACRO_NOZZLE_ACTIONS
displayName = QGVAR(fuelNozzle);
scope = 2;
scopeCurator = 2;
scope = 1;
scopeCurator = 1;
model = "\A3\Structures_F_Heli\VR\Helpers\Sign_sphere10cm_F.p3d";
};

Expand Down Expand Up @@ -615,7 +615,7 @@ class CfgVehicles {
// Src: http://helicopters.axlegeeks.com/l/61/Boeing-AH-64-Apache 375 gal = 1420L
// Src: https://en.wikipedia.org/wiki/Mil_Mi-8 3700l
// Src: Google Ka-52 1870L
// Src: http://www.airforce-technology.com/projects/hind/ 1500kg / 0.81 L/kg = 1851L
// Src: http://www.airforce-technology.com/projects/hind/ 1500kg / 0.81 kg/L = 1851L
// Src: https://en.wikipedia.org/wiki/MD_Helicopters_MH-6_Little_Bird 242L
// Src: http://www.globalsecurity.org/military/world/europe/aw159-specs.htm 1004L
// Src: https://en.wikipedia.org/wiki/AgustaWestland_AW101 3 * 1074L = 3222L
Expand Down
39 changes: 19 additions & 20 deletions addons/refuel/functions/fnc_makeJerryCan.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@ private ["_actions", "_action"];
params ["_target", ["_fuelAmount", 20]];

if (isNull _target ||
{_target isKindOf "AllVehicles"}) exitWith {};
{_target isKindOf "AllVehicles"} ||
{_target getVariable [QGVAR(jerryCan), false]}) exitWith {};

[_target, _fuelAmount] call FUNC(setFuel);
_target setVariable [QGVAR(jerryCan), true, true];
_target setVariable [QGVAR(source), _target, true];

_actions = [];
// 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, [], _action] call EFUNC(interact_menu,addActionToObject);

// Add pickup
_action = [QGVAR(PickUpNozzle),
localize LSTRING(TakeNozzle),
Expand All @@ -36,7 +49,7 @@ _action = [QGVAR(PickUpNozzle),
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
[_target, 0, [QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);

// Add turnOn
_action = [QGVAR(TurnOn),
Expand All @@ -48,7 +61,7 @@ _action = [QGVAR(TurnOn),
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
[_target, 0, [QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);

// Add turnOff
_action = [QGVAR(TurnOff),
Expand All @@ -60,7 +73,7 @@ _action = [QGVAR(TurnOff),
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
[_target, 0, [QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);

// Add disconnect
_action = [QGVAR(Disconnect),
Expand All @@ -72,18 +85,4 @@ _action = [QGVAR(Disconnect),
[],
[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);
[_target, 0, [QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
4 changes: 2 additions & 2 deletions addons/refuel/functions/fnc_refuel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
params ["_args", "_pfID"];
_args params ["_source", "_sink", "_unit", "_nozzle", "_rate", "_startFuel", "_maxFuel", "_connectFromPoint", "_connectToPoint"];

_fueling = _nozzle getVariable [QGVAR(isRefueling), false];
if (!alive _source || {!alive _sink}) exitWith {
[objNull, _nozzle] call FUNC(dropNozzle);
_nozzle setVariable [QGVAR(isConnected), false, true];
Expand All @@ -38,7 +37,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
[_pfID] call cba_fnc_removePerFrameHandler;
};
_tooFar = ((_sink modelToWorld _connectToPoint) distance (_source modelToWorld _connectFromPoint)) > (REFUEL_HOSE_LENGTH - 2);
if (_tooFar) exitWith {
if (_tooFar && {!(_nozzle getVariable [QGVAR(jerryCan), false])}) exitWith {
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);

[objNull, _nozzle] call FUNC(dropNozzle);
Expand All @@ -49,6 +48,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
};

_finished = false;
_fueling = _nozzle getVariable [QGVAR(isRefueling), false];
if (_fueling) then {
_fuelInSource = [_source] call FUNC(getFuel);
if (_fuelInSource == 0) exitWith {
Expand Down
36 changes: 21 additions & 15 deletions addons/refuel/functions/fnc_takeNozzle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ if (isNull _nozzle) then { // func is called on fuel truck
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
if (_nozzle getVariable [QGVAR(jerryCan), false]) then {
_nozzle attachTo [_unit, [0,1,0], "pelvis"];
} else {
_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];
Expand Down Expand Up @@ -122,20 +126,22 @@ if (isNull _nozzle) then { // func is called on fuel truck
_target = _nozzle getVariable QGVAR(source);
_endPosOffset = _nozzle getVariable QGVAR(attachPos);
};
[{
private ["_nozzle"];
params ["_args", "_pfID"];
_args params ["_unit", "_source", "_endPosOffset"];
if !(_nozzle getVariable [QGVAR(jerryCan), false]) then {
[{
private ["_nozzle"];
params ["_args", "_pfID"];
_args params ["_unit", "_source", "_endPosOffset"];

if (_unit distance (_source modelToWorld _endPosOffset) > (REFUEL_HOSE_LENGTH - 2)) exitWith {
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
[_unit, _nozzle] call FUNC(dropNozzle);
REFUEL_UNHOLSTER_WEAPON
if (_unit distance (_source modelToWorld _endPosOffset) > (REFUEL_HOSE_LENGTH - 2)) exitWith {
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
[_unit, _nozzle] call FUNC(dropNozzle);
REFUEL_UNHOLSTER_WEAPON

[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
};
[_pfID] call cba_fnc_removePerFrameHandler;
};
[_pfID] call cba_fnc_removePerFrameHandler;
};
}, 0, [_unit, _target, _endPosOffset]] call cba_fnc_addPerFrameHandler;
}, 0, [_unit, _target, _endPosOffset]] call cba_fnc_addPerFrameHandler;
};
2 changes: 1 addition & 1 deletion addons/refuel/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "\z\ace\addons\main\script_macros.hpp"

#define REFUEL_INFINITE_FUEL -1
#define REFUEL_ACTION_DISTANCE 37
#define REFUEL_ACTION_DISTANCE 7
#define REFUEL_HOSE_LENGTH 12

#define REFUEL_HOLSTER_WEAPON \
Expand Down

0 comments on commit 32b4416

Please sign in to comment.