More fixes to make jerryCan work

This commit is contained in:
Githawk 2015-12-21 17:54:52 +01:00
parent d9e7a43bf7
commit ebb28177b1
5 changed files with 76 additions and 73 deletions

View File

@ -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

View File

@ -20,60 +20,13 @@ 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 = [];
// 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),
@ -84,8 +37,52 @@ _action = [QGVAR(Refuel),
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE] call EFUNC(interact_menu,createAction);
[_target, 0, [], _action] call EFUNC(interact_menu,addActionToObject);
[_target, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject);
{
[_target, 0, [QGVAR(Refuel)], _x select 0] call EFUNC(interact_menu,addActionToObject);
} forEach _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);
[_target, 0, [QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
// 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);
[_target, 0, [QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
// 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);
[_target, 0, [QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
// 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);
[_target, 0, [QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);

View File

@ -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];
@ -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);
@ -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 {

View File

@ -93,7 +93,11 @@ if (isNull _nozzle) then { // func is called on fuel truck
private ["_actionID"];
params ["_args"];
_args params ["_unit", "_nozzle"];
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];
@ -122,7 +126,8 @@ if (isNull _nozzle) then { // func is called on fuel truck
_target = _nozzle getVariable QGVAR(source);
_endPosOffset = _nozzle getVariable QGVAR(attachPos);
};
[{
if !(_nozzle getVariable [QGVAR(jerryCan), false]) then {
[{
private ["_nozzle"];
params ["_args", "_pfID"];
_args params ["_unit", "_source", "_endPosOffset"];
@ -138,4 +143,5 @@ if (isNull _nozzle) then { // func is called on fuel truck
};
[_pfID] call cba_fnc_removePerFrameHandler;
};
}, 0, [_unit, _target, _endPosOffset]] call cba_fnc_addPerFrameHandler;
}, 0, [_unit, _target, _endPosOffset]] call cba_fnc_addPerFrameHandler;
};

View File

@ -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 \