2015-08-13 17:33:55 +00:00
|
|
|
/*
|
|
|
|
* Author: GitHawk
|
2015-08-20 20:10:26 +00:00
|
|
|
* Take a fuel nozzle either from a fuel truck/station or from the ground.
|
2015-08-13 17:33:55 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-20 20:10:26 +00:00
|
|
|
* 0: Unit <OBJECT>
|
2015-08-21 20:43:45 +00:00
|
|
|
* 1: Fuel Truck <OBJECT>
|
2015-08-20 20:10:26 +00:00
|
|
|
* 2: Nozzle <OBJECT> (optional)
|
2015-08-13 17:33:55 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-14 01:18:54 +00:00
|
|
|
* None
|
2015-08-13 17:33:55 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2015-08-21 20:43:45 +00:00
|
|
|
* [player, fuelTruck] call ace_refuel_fnc_takeNozzle
|
|
|
|
* [player, objNull, nozzle] call ace_refuel_fnc_takeNozzle
|
2015-08-13 17:33:55 +00:00
|
|
|
*
|
2015-08-14 01:18:54 +00:00
|
|
|
* Public: No
|
2015-08-13 17:33:55 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-05-12 15:11:35 +00:00
|
|
|
params [
|
|
|
|
["_unit", objNull, [objNull]],
|
|
|
|
["_target", objNull, [objNull]],
|
|
|
|
["_nozzle", objNull, [objNull]]
|
|
|
|
];
|
2015-08-13 17:33:55 +00:00
|
|
|
|
2015-08-18 21:18:32 +00:00
|
|
|
REFUEL_HOLSTER_WEAPON
|
2015-08-13 17:33:55 +00:00
|
|
|
|
2016-02-02 14:03:06 +00:00
|
|
|
private _endPosOffset = [0, 0, 0];
|
2015-08-13 17:33:55 +00:00
|
|
|
if (isNull _nozzle) then { // func is called on fuel truck
|
2016-01-14 19:07:53 +00:00
|
|
|
_endPosOffset = getArray (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(hooks));
|
2015-08-17 22:42:35 +00:00
|
|
|
if (count _endPosOffset == 2) then {
|
|
|
|
if (_unit distance (_target modelToWorld (_endPosOffset select 0)) < _unit distance (_target modelToWorld (_endPosOffset select 1))) then {
|
|
|
|
_endPosOffset = _endPosOffset select 0;
|
|
|
|
} else {
|
|
|
|
_endPosOffset = _endPosOffset select 1;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
_endPosOffset = _endPosOffset select 0;
|
|
|
|
};
|
2015-08-21 20:43:45 +00:00
|
|
|
[
|
|
|
|
2,
|
|
|
|
[_unit, _target, _endPosOffset],
|
|
|
|
{
|
|
|
|
params ["_args"];
|
2016-05-12 15:11:35 +00:00
|
|
|
_args params [
|
|
|
|
["_unit", objNull, [objNull]],
|
|
|
|
["_target", objNull, [objNull]],
|
|
|
|
["_endPosOffset", [0, 0, 0], [[]], 3]
|
|
|
|
];
|
2015-08-21 20:43:45 +00:00
|
|
|
|
2016-02-02 14:03:06 +00:00
|
|
|
private _newNozzle = "ACE_refuel_fuelNozzle" createVehicle position _unit;
|
|
|
|
_newNozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
|
2016-02-19 16:24:32 +00:00
|
|
|
_unit setVariable [QGVAR(nozzle), _newNozzle, true];
|
2015-08-13 17:33:55 +00:00
|
|
|
|
2016-02-26 09:46:12 +00:00
|
|
|
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];
|
|
|
|
};
|
2015-08-21 20:43:45 +00:00
|
|
|
_newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true];
|
|
|
|
_newNozzle setVariable [QGVAR(source), _target, true];
|
2016-05-12 15:11:35 +00:00
|
|
|
|
|
|
|
[_target, "blockEngine", "ACE_Refuel", true] call EFUNC(common,statusEffect_set);
|
|
|
|
_target setVariable [QGVAR(isConnected), true, true];
|
2015-11-23 18:28:51 +00:00
|
|
|
_target setVariable [QGVAR(ownedNozzle), _newNozzle, true];
|
2015-08-16 22:55:26 +00:00
|
|
|
|
2016-05-12 15:11:35 +00:00
|
|
|
[_unit, "forceWalk", "ACE_refuel", true] call EFUNC(common,statusEffect_set);
|
2015-08-21 20:43:45 +00:00
|
|
|
_unit setVariable [QGVAR(isRefueling), true];
|
2016-02-02 14:03:06 +00:00
|
|
|
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
2015-08-21 20:43:45 +00:00
|
|
|
if (_actionID != -1) then {
|
|
|
|
_unit removeAction _actionID;
|
|
|
|
};
|
|
|
|
_actionID = _unit addAction [
|
|
|
|
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
|
2016-01-19 15:34:59 +00:00
|
|
|
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); REFUEL_UNHOLSTER_WEAPON',
|
2015-08-21 20:43:45 +00:00
|
|
|
nil,
|
|
|
|
20,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
"",
|
|
|
|
'!isNull (_target getVariable [QGVAR(nozzle), objNull])'
|
|
|
|
];
|
|
|
|
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
|
|
|
|
},
|
|
|
|
"",
|
|
|
|
localize LSTRING(TakeNozzleAction),
|
|
|
|
{true},
|
|
|
|
["isnotinside"]
|
|
|
|
] call EFUNC(common,progressBar);
|
2016-02-26 09:46:12 +00:00
|
|
|
} else { // func is called on muzzle either connected or on ground
|
2015-08-21 20:43:45 +00:00
|
|
|
[
|
|
|
|
2,
|
|
|
|
[_unit, _nozzle],
|
|
|
|
{
|
|
|
|
params ["_args"];
|
2016-05-12 15:11:35 +00:00
|
|
|
_args params [
|
|
|
|
["_unit", objNull, [objNull]],
|
|
|
|
["_nozzle", objNull, [objNull]]
|
|
|
|
];
|
|
|
|
|
2015-12-21 16:54:52 +00:00
|
|
|
if (_nozzle getVariable [QGVAR(jerryCan), false]) then {
|
|
|
|
_nozzle attachTo [_unit, [0,1,0], "pelvis"];
|
|
|
|
} else {
|
2016-02-02 14:03:06 +00:00
|
|
|
_nozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
|
2015-12-21 16:54:52 +00:00
|
|
|
};
|
2016-02-19 16:24:32 +00:00
|
|
|
_unit setVariable [QGVAR(nozzle), _nozzle, true];
|
2015-08-21 20:43:45 +00:00
|
|
|
|
2016-05-12 15:11:35 +00:00
|
|
|
[_unit, "forceWalk", "ACE_refuel", true] call EFUNC(common,statusEffect_set);
|
2015-08-21 20:43:45 +00:00
|
|
|
_unit setVariable [QGVAR(isRefueling), true];
|
2016-02-02 14:03:06 +00:00
|
|
|
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
2015-08-21 20:43:45 +00:00
|
|
|
if (_actionID != -1) then {
|
|
|
|
_unit removeAction _actionID;
|
|
|
|
};
|
|
|
|
_actionID = _unit addAction [
|
|
|
|
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
|
2016-01-19 15:34:59 +00:00
|
|
|
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); REFUEL_UNHOLSTER_WEAPON',
|
2015-08-21 20:43:45 +00:00
|
|
|
nil,
|
|
|
|
20,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
"",
|
|
|
|
'!isNull (_target getVariable [QGVAR(nozzle), objNull])'
|
|
|
|
];
|
|
|
|
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
|
|
|
|
},
|
|
|
|
"",
|
|
|
|
localize LSTRING(TakeNozzleAction),
|
|
|
|
{true},
|
|
|
|
["isnotinside"]
|
|
|
|
] call EFUNC(common,progressBar);
|
2015-08-20 20:10:26 +00:00
|
|
|
|
|
|
|
_target = _nozzle getVariable QGVAR(source);
|
|
|
|
_endPosOffset = _nozzle getVariable QGVAR(attachPos);
|
2015-08-13 17:33:55 +00:00
|
|
|
};
|
2015-12-21 16:54:52 +00:00
|
|
|
if !(_nozzle getVariable [QGVAR(jerryCan), false]) then {
|
|
|
|
[{
|
|
|
|
params ["_args", "_pfID"];
|
2016-05-12 15:11:35 +00:00
|
|
|
_args params [
|
|
|
|
["_unit", player, [objNull]],
|
|
|
|
["_source", objNull, [objNull]],
|
|
|
|
["_endPosOffset", [0, 0, 0], [[]], 3],
|
|
|
|
["_nozzle", _unit getVariable [QGVAR(nozzle), objNull], [objNull]]
|
|
|
|
];
|
|
|
|
|
2016-02-19 16:24:32 +00:00
|
|
|
if (isNull _source || {_unit distance (_source modelToWorld _endPosOffset) > (REFUEL_HOSE_LENGTH - 2)} || {!alive _source}) exitWith {
|
2015-12-21 16:54:52 +00:00
|
|
|
if !(isNull _nozzle) then {
|
|
|
|
[_unit, _nozzle] call FUNC(dropNozzle);
|
|
|
|
REFUEL_UNHOLSTER_WEAPON
|
2015-08-20 20:10:26 +00:00
|
|
|
|
2016-01-19 15:34:59 +00:00
|
|
|
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
|
2016-02-19 16:24:32 +00:00
|
|
|
if (isNull _source || {!alive _source}) then {
|
|
|
|
private _rope = _nozzle getVariable [QGVAR(rope), objNull];
|
|
|
|
if !(isNull _rope) then {
|
|
|
|
ropeDestroy _rope;
|
|
|
|
};
|
|
|
|
deleteVehicle _nozzle;
|
|
|
|
} else {
|
|
|
|
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
|
|
|
|
};
|
2015-12-21 16:54:52 +00:00
|
|
|
};
|
|
|
|
[_pfID] call cba_fnc_removePerFrameHandler;
|
2015-08-20 20:10:26 +00:00
|
|
|
};
|
2015-12-21 16:54:52 +00:00
|
|
|
}, 0, [_unit, _target, _endPosOffset]] call cba_fnc_addPerFrameHandler;
|
|
|
|
};
|