Moved macros to function
Fixed MP bugs
Changed class history of nozzle
This commit is contained in:
IngoKauffmann 2015-08-22 13:34:24 +02:00
parent 22576f938e
commit 8b53b4f0d0
15 changed files with 78 additions and 38 deletions

View File

@ -133,10 +133,14 @@ class CfgVehicles {
};
};
class Sign_Sphere10cm_F;
class ACE_refuel_fuelNozzle : Sign_Sphere10cm_F {
class ThingX;
class ACE_refuel_fuelNozzle : ThingX {
XEH_ENABLED;
MACRO_NOZZLE_ACTIONS
displayName = QGVAR(fuelNozzle);
scope = 2;
scopeCurator = 2;
model = "\A3\Structures_F_Heli\VR\Helpers\Sign_sphere10cm_F.p3d";
};
class All;

View File

@ -13,6 +13,7 @@ PREP(checkFuel);
PREP(connectNozzle);
PREP(connectNozzleAction);
PREP(disconnect);
PREP(dropNozzle);
PREP(getFuel);
PREP(handleKilled);
PREP(handleUnconscious);

View File

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

View File

@ -24,8 +24,8 @@
private ["_nozzle", "_actionID"];
params ["_unit", "_target"];
_nozzle = _unit getVariable QGVAR(nozzle);
if (isNil "_nozzle") exitWith {};
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if (isNull _nozzle) exitWith {};
GVAR(placeAction) = PLACE_WAITING;

View File

@ -94,6 +94,9 @@ _endPosTestOffset set [2, (_startingOffset select 2)];
_nozzle setVariable [QGVAR(isConnected), true, true];
_target setVariable [QGVAR(nozzle), _nozzle, true];
_source = _nozzle getVariable QGVAR(source);
_source setVariable [QGVAR(fuelCounter), [_source] call FUNC(getFuel)];
[_unit, _target, _nozzle, _endPosTestOffset] call FUNC(refuel);
},
"",

View File

@ -24,6 +24,7 @@ if (isNull _sink) exitWith {};
_sink setVariable [QGVAR(nozzle), objNull, true];
_nozzle setVariable [QGVAR(sink), objNull, true];
REFUEL_DETACH_NOZZLE
_nozzle setVariable [QGVAR(isConnected), false, true];
[objNull, _nozzle, true] call FUNC(dropNozzle);
[_unit, objNull, _nozzle] call FUNC(takeNozzle);

View File

@ -0,0 +1,32 @@
/*
* Author: GitHawk
* Detaches the fuel nozzle, drops it and removes player variables.
*
* Arguments:
* 0: Unit <OBJECT> (optional)
* 1: Nozzle <OBJECT>
* 2: Disconnect Only <BOOL>
*
* Return Value:
* None
*
* Example:
* [player, nozzle, false] call ace_refuel_fnc_dropNozzle
* [objNull, nozzle, false] call ace_refuel_fnc_dropNozzle
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_nozzle", ["_disconnectOnly", false]];
detach _nozzle;
_nozzle setVariable [QGVAR(isRefueling), false, true];
if (_disconnectOnly) exitWith {};
_nozzle setVelocity [0, 0, 0];
_nozzle setPosATL [(getPosATL _nozzle) select 0, (getPosATL _nozzle) select 1, 0.05];
if (isNull _unit) exitWith {};
_unit setVariable [QGVAR(isRefueling), false, true];
_unit setVariable [QGVAR(nozzle), objNull, true];

View File

@ -22,5 +22,5 @@ if (!local _unit) exitWith {};
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
REFUEL_UNIT_DROP_NOZZLE
[_unit, _nozzle] call FUNC(dropNozzle);
};

View File

@ -25,5 +25,5 @@ private "_nozzle";
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
REFUEL_UNIT_DROP_NOZZLE
[_unit, _nozzle] call FUNC(dropNozzle);
};

View File

@ -31,7 +31,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
_fueling = _nozzle getVariable [QGVAR(isRefueling), false];
if (!alive _source || {!alive _sink}) exitWith {
REFUEL_DROP_NOZZLE
[objNull, _nozzle] call FUNC(dropNozzle);
_nozzle setVariable [QGVAR(isConnected), false, true];
_nozzle setVariable [QGVAR(sink), objNull, true];
_sink setVariable [QGVAR(nozzle), objNull, true];
@ -41,7 +41,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
if (_tooFar) exitWith {
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
REFUEL_DROP_NOZZLE
[objNull, _nozzle] call FUNC(dropNozzle);
_nozzle setVariable [QGVAR(isConnected), false, true];
_nozzle setVariable [QGVAR(sink), objNull, true];
_sink setVariable [QGVAR(nozzle), objNull, true];
@ -64,18 +64,22 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
[LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured);
};
_fuelInSink = fuel _sink + ( _rate / _maxFuel);
_fuelInSink = (_unit getVariable [QGVAR(tempFuel), _startFuel]) + ( _rate / _maxFuel);
if (_fuelInSink > 1) then {
_fuelInSink = 1;
_finished = true;
[LSTRING(Hint_Completed), 2, _unit] call EFUNC(common,displayTextStructured);
};
_unit setVariable [QGVAR(tempFuel), _fuelInSink];
if !(local _sink) then {
[[_sink, _fuelInSink], QUOTE({(_this select 0) setFuel (_this select 1)}), _sink] call EFUNC(common,execRemoteFnc);
[[_sink, _fuelInSink], "{(_this select 0) setFuel (_this select 1)}", _sink] call EFUNC(common,execRemoteFnc);
} else {
_sink setFuel _fuelInSink;
};
[_source, _fuelInSource] call FUNC(setFuel);
} else {
_unit setVariable [QGVAR(tempFuel), fuel _sink];
};
if (_finished) exitWith {

View File

@ -19,10 +19,10 @@
private ["_nozzle", "_dummy", "_actionID"];
params ["_unit", "_target"];
_nozzle = _unit getVariable QGVAR(nozzle);
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
_source = _nozzle getVariable QGVAR(source);
if (isNil "_nozzle" || {_source != _target}) exitWith {false};
if (isNull _nozzle || {_source != _target}) exitWith {false};
[
2,
@ -46,11 +46,15 @@ if (isNil "_nozzle" || {_source != _target}) exitWith {false};
ropeDestroy (_nozzle getVariable QGVAR(rope));
deleteVehicle _nozzle;
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];
},
"",
localize LSTRING(ConnectAction),
localize LSTRING(ReturnAction),
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -28,7 +28,11 @@ REFUEL_HOLSTER_WEAPON
_endPosOffset = [0, 0, 0];
if (isNull _nozzle) then { // func is called on fuel truck
_target setVariable [QGVAR(engineHit), _target getHitPointDamage "HitEngine", true];
if !(local _target) then {
[[_target, ["HitEngine", 1]], "{(_this select 0) setHitPointDamage (_this select 1)}", _sink] call EFUNC(common,execRemoteFnc);
} else {
_target setHitPointDamage ["HitEngine", 1];
};
_target setVariable [QGVAR(isConnected), true, true];
_endPosOffset = getArray (configFile >> "CfgVehicles" >> typeOf _target >> "ace_refuel_hooks");
@ -65,7 +69,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
};
_actionID = _unit addAction [
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
'params ["_unit"]; _nozzle = _unit getVariable QGVAR(nozzle); REFUEL_UNIT_DROP_NOZZLE',
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON',
nil,
20,
false,
@ -98,7 +102,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
};
_actionID = _unit addAction [
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
'params ["_unit"]; _nozzle = _unit getVariable QGVAR(nozzle); REFUEL_UNIT_DROP_NOZZLE',
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON',
nil,
20,
false,
@ -125,7 +129,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
if (_unit distance (_source modelToWorld _endPosOffset) > 10) exitWith {
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
REFUEL_UNIT_DROP_NOZZLE
[_unit, _nozzle] call FUNC(dropNozzle);
REFUEL_UNHOLSTER_WEAPON
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);

View File

@ -27,9 +27,6 @@ params ["_unit", "_nozzle"];
_args params ["_unit", "_nozzle"];
_nozzle setVariable [QGVAR(isRefueling), true, true];
[LSTRING(Hint_Started), 1.5, _unit] call EFUNC(common,displayTextStructured);
_source = _nozzle getVariable QGVAR(source);
_source setVariable [QGVAR(fuelCounter), [_source] call FUNC(getFuel)];
},
"",
localize LSTRING(TurnOnAction),

View File

@ -14,20 +14,6 @@
#define REFUEL_INFINITE_FUEL -1
#define REFUEL_ACTION_DISTANCE 7
#define REFUEL_DETACH_NOZZLE \
detach _nozzle; \
_nozzle setVariable [QGVAR(isRefueling), false, true];
#define REFUEL_DROP_NOZZLE \
REFUEL_DETACH_NOZZLE \
_nozzle setPosATL [(getPosATL _nozzle) select 0, (getPosATL _nozzle) select 1, 0];\
_nozzle setVelocity [0, 0, 0];
#define REFUEL_UNIT_DROP_NOZZLE \
REFUEL_DROP_NOZZLE \
_unit setVariable [QGVAR(isRefueling), false]; \
_unit setVariable [QGVAR(nozzle), objNull];
#define REFUEL_HOLSTER_WEAPON \
_unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit]; \
_unit action ["SwitchWeapon", _unit, _unit, 99];

View File

@ -109,6 +109,10 @@
<English>Return fuel nozzle</English>
<German>Zapfpistole zurückstecken</German>
</Key>
<Key ID="STR_ACE_Refuel_ReturnAction">
<English>Returning fuel nozzle ...</English>
<German>Stecke Zapfpistole zurück ...</German>
</Key>
<Key ID="STR_ACE_Refuel_CheckFuelCounter">
<English>Check fuel counter</English>
<German>Tankuhr ansehen</German>