Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refuel for non-AllVehicle objects #5151

Merged
merged 8 commits into from
May 29, 2017
13 changes: 13 additions & 0 deletions addons/refuel/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,19 @@ class CfgVehicles {
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
};

// Helper object for non-AllVehicles objects
class GVAR(helper): Helicopter_Base_F {
author = "Beswick.T";
scope = 1;
model = QPATHTOF(data\helper.p3d);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an actual model or just an empty dummy? One can use model = "-"; instead for no model.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an empty dummy. Tried and it doesn't work with "-", just gives an error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

model = "\A3\Weapons_f\empty";

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will give that a shot 1 min

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to work juuuust fine

class ACE_Actions {};
damageEffect = "";
destrType = "";
class HitPoints {};
class Turrets {};
class TransportItems {};
};

/* // Barrels found in config \
BarrelHelper: Misc_thing 100
BarrelBase: BarrelHelper 100
Expand Down
Binary file added addons/refuel/data/helper.p3d
Binary file not shown.
2 changes: 1 addition & 1 deletion addons/refuel/functions/fnc_checkFuel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
private _fuel = [_target] call FUNC(getFuel);

[
5,
REFUEL_PROGRESS_DURATION * 2.5,
[_unit, _target, _fuel],
{
params ["_args"];
Expand Down
2 changes: 1 addition & 1 deletion addons/refuel/functions/fnc_connectNozzleAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ _endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply
_endPosTestOffset set [2, (_startingOffset select 2)];

[
2,
REFUEL_PROGRESS_DURATION,
[_unit, _nozzle, _target, _endPosTestOffset],
{
params ["_args"];
Expand Down
4 changes: 4 additions & 0 deletions addons/refuel/functions/fnc_maxDistanceDropNozzle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ if (_nozzle getVariable [QGVAR(jerryCan), false]) exitWith {};
if !(isNull _rope) then {
ropeDestroy _rope;
};
private _helper = _target getVariable [QGVAR(helper), objNull];
if !(isNull _helper) then {
deleteVehicle _helper;
};
deleteVehicle _nozzle;
} else {
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
Expand Down
2 changes: 1 addition & 1 deletion addons/refuel/functions/fnc_readFuelCounter.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];

[
2,
REFUEL_PROGRESS_DURATION,
[_unit, _target],
{
params ["_args"];
Expand Down
4 changes: 4 additions & 0 deletions addons/refuel/functions/fnc_reset.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ if !(isNil "_nozzle") then {
if !(isNull _rope) then {
ropeDestroy _rope;
};
private _helper = _target getVariable [QGVAR(helper), objNull];
if !(isNull _helper) then {
deleteVehicle _helper;
};

{
[QGVAR(resetLocal), [_x, _nozzle], _x] call CBA_fnc_targetEvent;
Expand Down
6 changes: 5 additions & 1 deletion addons/refuel/functions/fnc_returnNozzle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private _source = _nozzle getVariable QGVAR(source);
if (isNull _nozzle || {_source != _target}) exitWith {false};

[
2,
REFUEL_PROGRESS_DURATION,
[_unit, _nozzle, _target],
{
params ["_args"];
Expand All @@ -46,6 +46,10 @@ if (isNull _nozzle || {_source != _target}) exitWith {false};
if !(isNull _rope) then {
ropeDestroy _rope;
};
private _helper = _target getVariable [QGVAR(helper), objNull];
if !(isNull _helper) then {
deleteVehicle _helper;
};
deleteVehicle _nozzle;

[_target, "blockEngine", "ACE_Refuel", false] call EFUNC(common,statusEffect_set);
Expand Down
23 changes: 17 additions & 6 deletions addons/refuel/functions/fnc_takeNozzle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
_endPosOffset = _endPosOffset select 0;
};
[
2,
REFUEL_PROGRESS_DURATION,
[_unit, _target, _endPosOffset],
{
params ["_args"];
Expand All @@ -53,11 +53,22 @@ 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];

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];
private _ropeTarget = _target;
if (!(_target isKindOf "AllVehicles")) then {
private _helper = QGVAR(helper) createVehicle [0,0,0];
hideObjectGlobal _helper;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind this has to run on the server, there is an event in common that can handle the locality:

[QEGVAR(common,hideObjectGlobal), [_helper, true]] call CBA_fnc_serverEvent;

if ((getText (configFile >> "CfgVehicles" >> typeOf _target >> "simulation")) isEqualTo "thingX") then {
_helper attachTo [_target, [0,0,0]];
} else {
_helper setPosWorld (getPosWorld _target);
_helper setDir (getDir _target);
_helper setVectorUp (vectorUp _target);
};
_target setVariable [QGVAR(helper), _helper, true];
_ropeTarget = _helper;
};
private _rope = ropeCreate [_ropeTarget, _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];

Expand Down Expand Up @@ -93,7 +104,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
] call EFUNC(common,progressBar);
} else { // func is called on muzzle either connected or on ground
[
2,
REFUEL_PROGRESS_DURATION,
[_unit, _nozzle],
{
params ["_args"];
Expand Down
2 changes: 1 addition & 1 deletion addons/refuel/functions/fnc_turnOff.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]];

[
2,
REFUEL_PROGRESS_DURATION,
[_unit, _nozzle],
{
params ["_args"];
Expand Down
2 changes: 1 addition & 1 deletion addons/refuel/functions/fnc_turnOn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]];

[
2,
REFUEL_PROGRESS_DURATION,
[_unit, _nozzle],
{
params ["_args"];
Expand Down
1 change: 1 addition & 0 deletions addons/refuel/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define REFUEL_INFINITE_FUEL -10
#define REFUEL_ACTION_DISTANCE 7
#define REFUEL_HOSE_LENGTH 12
#define REFUEL_PROGRESS_DURATION 2

#define REFUEL_HOLSTER_WEAPON \
_unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit]; \
Expand Down