Merge pull request #1 from jonpas/refuelFixes

Refuel Fixes and Additions
Thx @jonpas
This commit is contained in:
Hawk 2015-08-17 16:03:43 +02:00
commit 1bba0681c8
18 changed files with 299 additions and 259 deletions

View File

@ -1,51 +1,59 @@
#define REFUEL_ACTION_DISTANCE 4.5
#define MACRO_REFUEL_ACTIONS \
class ACE_Actions : ACE_Actions { \
class ACE_MainActions : ACE_MainActions { \
class ACE_Actions: ACE_Actions { \
class ACE_MainActions: ACE_MainActions { \
class GVAR(Refuel) { \
displayName = CSTRING(Refuel); \
distance = REFUEL_ACTION_DISTANCE; \
condition = "true"; \
statement = ""; \
showDisabled = 0; \
priority = 2; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
class GVAR(TakeNozzle) { \
displayName = CSTRING(TakeNozzle); \
distance = REFUEL_ACTION_DISTANCE; \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \
statement = QUOTE([ARR_3(_player,_target,objNull)] call FUNC(TakeNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
}; \
class GVAR(Return) { \
displayName = CSTRING(Return); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canConnectNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(returnNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
}; \
class GVAR(CheckFuel) { \
displayName = CSTRING(CheckFuel); \
distance = REFUEL_ACTION_DISTANCE; \
condition = QUOTE(([ARR_2(_player,_target)] call FUNC(getFuel) >= 0) && {(_target distance _player) < REFUEL_ACTION_DISTANCE}); \
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(Return); \
distance = REFUEL_ACTION_DISTANCE; \
condition = QUOTE([ARR_1(_player)] call FUNC(canConnectNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(connectNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
}; \
}; \
};
}; \
};
#define MACRO_CONNECT_ACTIONS \
class ACE_Actions { \
class ACE_MainActions { \
displayName = ECSTRING(interaction,MainAction); \
selection = ""; \
distance = 10; \
class ACE_Actions { \
class ACE_MainActions { \
class GVAR(Refuel) { \
displayName = CSTRING(Refuel); \
distance = REFUEL_ACTION_DISTANCE; \
condition = "true"; \
class GVAR(connect) { \
displayName = CSTRING(connect); \
distance = REFUEL_ACTION_DISTANCE; \
condition = QUOTE([ARR_1(_player)] call FUNC(canConnectNozzle)); \
statement = ""; \
showDisabled = 0; \
priority = 2; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
class GVAR(Connect) { \
displayName = CSTRING(Connect); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canConnectNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(connectNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
}; \
class GVAR(Disconnect) { \
displayName = CSTRING(Disconnect); \
distance = REFUEL_ACTION_DISTANCE; \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canDisconnect)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(disconnect)); \
exceptions[] = {"isNotInside"}; \
@ -53,33 +61,26 @@
}; \
class GVAR(TurnOff) { \
displayName = CSTRING(TurnOff); \
distance = REFUEL_ACTION_DISTANCE; \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTurnOff)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(turnOff)); \
statement = QUOTE([_target] call DFUNC(turnOff)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
}; \
}; \
};
}; \
};
// does not work
#define MACRO_NOZZLE_ACTIONS \
class ACE_Actions { \
class ACE_MainActions { \
displayName = ECSTRING(interaction,MainAction); \
selection = ""; \
distance = 2; \
condition = "true"; \
class GVAR(TakeNozzle) { \
displayName = CSTRING(TakeNozzle); \
distance = REFUEL_ACTION_DISTANCE; \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \
statement = QUOTE([ARR_3(_player,_target,_target)] call FUNC(TakeNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
}; \
}; \
};
class ACE_Actions { \
class ACE_MainActions { \
displayName = CSTRING(TakeNozzle); \
distance = 2; \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \
statement = QUOTE([ARR_3(_player,_target,_target)] call FUNC(TakeNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_refuel_interact.paa); \
}; \
};
class CfgVehicles {
class ACE_Module;
@ -116,7 +117,8 @@ class CfgVehicles {
class Sign_Sphere10cm_F;
class ACE_refuel_fuelNozzle : Sign_Sphere10cm_F {
// TODO replace with custom model
XEH_ENABLED;
MACRO_NOZZLE_ACTIONS
};
class All;

View File

@ -2,6 +2,7 @@
ADDON = false;
PREP(canCheckFuel);
PREP(canConnectNozzle);
PREP(canDisconnect);
PREP(canRefuel);
@ -13,9 +14,10 @@ PREP(connectNozzleAction);
PREP(disconnect);
PREP(getFuel);
PREP(moduleRefuelSettings);
PREP(refuel);
PREP(returnNozzle);
PREP(setFuel);
PREP(takeNozzle);
PREP(turnOff);
PREP(refuel);
ADDON = true;

View File

@ -0,0 +1,23 @@
/*
* Author: Jonpas
* Checks if unit can check fuel.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Can Check Fuel <BOOL>
*
* Example:
* [unit, target] call ace_refuel_fnc_canCheckFuel
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
true

View File

@ -17,9 +17,9 @@
#include "script_component.hpp"
private ["_nozzle"];
params ["_unit"];
params ["_unit", "_target"];
_nozzle = _unit getVariable QGVAR(nozzle);
if (isNil "_nozzle") exitWith {false};
if (isNil "_nozzle" || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
true

View File

@ -19,7 +19,7 @@
private ["_nozzle", "_sink", "_fueling"];
params ["_unit", "_nozzleHolder"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_nozzleHolder distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_nozzleHolder distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
_nozzle = _nozzleHolder getVariable [QGVAR(nozzle), objNull];
if (isNull _nozzle) exitWith {false};

View File

@ -17,9 +17,9 @@
private ["_fuel"];
params ["_unit", "_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_target distance _unit) > 7}) exitWith {false};
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
_fuel = [_unit, _target] call FUNC(getFuel);
_fuel = [_target] call FUNC(getFuel);
if (_fuel > 0 || {_fuel == -1}) exitWith {true};
false

View File

@ -18,7 +18,7 @@
params ["_unit", "_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
// Check if the fuel source is already in use
!(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])}

View File

@ -16,7 +16,6 @@
*/
#include "script_component.hpp"
private ["_nozzle", "_fueling"];
params ["_unit", "_nozzleHolder"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_nozzleHolder distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};

View File

@ -18,9 +18,7 @@
private ["_fuel", "_type"];
params ["_unit", "_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_target distance _unit) > 7}) exitWith {0};
_fuel = [_unit, _target] call FUNC(getFuel);
_fuel = [_target] call FUNC(getFuel);
[
5,
@ -40,4 +38,3 @@ _fuel = [_unit, _target] call FUNC(getFuel);
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -81,14 +81,6 @@ _weaponSelect = _unit getVariable QGVAR(selectedWeaponOnRefuel);
_unit selectWeapon _weaponSelect;
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
_source = _nozzle getVariable QGVAR(source);
if (_source == _target) exitWith {
_source setVariable [QGVAR(isConnected), false, true];
ropeDestroy (_nozzle getVariable QGVAR(rope));
deleteVehicle _nozzle;
_unit setVariable [QGVAR(isRefueling), false];
};
_nozzle attachTo [_target, _endPosTestOffset];
_nozzle setVariable [QGVAR(sink), _target, true];
_nozzle setVariable [QGVAR(fueling), 1, true];

View File

@ -1,28 +1,26 @@
/*
* Author: GitHawk
* Get the remaining fuel amount
* Author: GitHawk, Jonpas
* Get the remaining fuel amount.
*
* Arguments:
* 0: The unit <OBJECT>
* 1: The target <OBJECT>
* 0: Target <OBJECT>
*
* Return Value:
* Fuel left (in liters) <NUMBER>
*
* Example:
* [unit, target] call ace_refuel_fnc_getFuel
* [target] call ace_refuel_fnc_getFuel
*
* Public: No
*/
#include "script_component.hpp"
private ["_fuel"];
params ["_unit", "_target"];
params ["_target"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit}) exitWith {0};
_fuel = _target getVariable [QGVAR(currentFuelCargo), nil];
_fuel = _target getVariable [QGVAR(currentFuelCargo), -2];
if (_fuel == -2) then {
if (isNil "_fuel") then {
_fuel = getNumber (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(fuelCargo));
_target setVariable [QGVAR(currentFuelCargo), _fuel, true];
};

View File

@ -40,7 +40,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
_nozzle setVariable [QGVAR(sink), objNull];
[_pfID] call cba_fnc_removePerFrameHandler;
};
_fuelInSource = [_unit, _source] call FUNC(getFuel);
_fuelInSource = [_source] call FUNC(getFuel);
if (_fuelInSource == 0) exitWith {
[LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured);
_nozzle setVariable [QGVAR(fueling), 0, true];

View File

@ -0,0 +1,39 @@
/*
* Author: GitHawk et.al., Jonpas
* Returns the nozzle back to source vehicle.
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Returned Nozzle <BOOL>
*
* Example:
* [player] call ace_refuel_fnc_returnNozzle
*
* Public: No
*/
#include "script_component.hpp"
private ["_nozzle"];
params ["_unit", "_target"];
_source = _nozzle getVariable QGVAR(source);
_nozzle = _unit getVariable QGVAR(nozzle);
if (_source != _target || {isNil "_nozzle"}) exitWith {false};
_unit setVariable [QGVAR(nozzle), nil];
detach _nozzle;
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
_unit selectWeapon (_unit getVariable QGVAR(selectedWeaponOnRefuel));
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
_unit setVariable [QGVAR(isRefueling), false];
_target setVariable [QGVAR(isConnected), false, true];
ropeDestroy (_nozzle getVariable QGVAR(rope));
deleteVehicle _nozzle;
true

View File

@ -31,23 +31,13 @@ if (isNull _nozzle) then { // func is called on fuel truck
// TODO add pickup animation ?
[{
params ["_unit", "_target", "_endPosTestOffset"];
params ["_unit", "_target"];
_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];
// TODO action is only local
_action = [QGVAR(TakeNozzleFromGround),
localize LSTRING(TakeNozzle),
QUOTE(PATHTOF(ui\icon_refuel_interact.paa)),
{params ["_nozzle", "_unit"]; [ARR_3(_unit,_nozzle,_nozzle)] call DFUNC(TakeNozzle); true},
{params ["_nozzle", "_unit"]; [ARR_2(_unit,_nozzle)] call FUNC(canTakeNozzle)},
{},
[]
] call EFUNC(interact_menu,createAction);
[_newNozzle, 0, [], _action] call EFUNC(interact_menu,addActionToObject);
_rope = ropeCreate [_target, _endPosTestOffset, _newNozzle, [0, 0, 0], 12];
// Create rope with offset -1 to prevent wrapping over interaction base point
_rope = ropeCreate [_target, [0, 0, -1], _newNozzle, [0, 0, 0], 12];
_newNozzle setVariable [QGVAR(source), _target, true];
_newNozzle setVariable [QGVAR(rope), _rope, true];

View File

@ -1,26 +1,20 @@
/*
* Author: GitHawk
* Check if a unit can turn off a fuel nozzle
* Turn off a fuel nozzle
*
* Arguments:
* 0: The unit <OBJECT>
* 1: The object holding the nozzle <OBJECT>
* 0: The object holding the nozzle <OBJECT>
*
* Return Value:
* Can turn off <BOOL>
* None
*
* Example:
* [player, nozzle] call ace_refuel_fnc_canTurnOff
* [player, nozzle] call ace_refuel_fnc_turnOff
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_nozzleHolder"];
params ["_nozzleHolder"];
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_nozzleHolder distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false};
_nozzle = _nozzleHolder getVariable QGVAR(nozzle);
_nozzle setVariable [QGVAR(fueling), 0];
true
(_nozzleHolder getVariable QGVAR(nozzle)) setVariable [QGVAR(fueling), 0];

View File

@ -1,3 +1 @@
#include "\z\ace\addons\refuel\script_component.hpp"
#define REFUEL_ACTION_DISTANCE 4.5

View File

@ -10,3 +10,6 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define REFUEL_ACTION_DISTANCE 7

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Refuel">
<Key ID="STR_ACE_Refuel_RefuelSettings_Module_DisplayName">
@ -45,15 +45,18 @@
<English>How many liters does a stationary object e.g. a fuel station hold? -1 is infinite.</English>
<German>Wieviele Liter enthält ein stationäres Objekt z.B. eine Tankstelle? -1 bedeutet unendlich.</German>
</Key>
<Key ID="STR_ACE_Refuel_TakeNozzle">
<Key ID="STR_ACE_Refuel_Refuel">
<English>Refuel</English>
</Key>
<Key ID="STR_ACE_Refuel_TakeNozzle">
<English>Take fuel nozzle</English>
<German>Zapfpistole nehmen</German>
</Key>
<Key ID="STR_ACE_Refuel_Connect">
<Key ID="STR_ACE_Refuel_Connect">
<English>Connect fuel nozzle</English>
<German>Zapfpistole anschließen</German>
</Key>
<Key ID="STR_ACE_Refuel_Disconnect">
<Key ID="STR_ACE_Refuel_Disconnect">
<English>Disconnect fuel nozzle</English>
<German>Zapfpistole entfernen</German>
</Key>