mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #3347 from GitHawk/refuel_removedTruck
Handling disconnect and removal of fuel truck
This commit is contained in:
commit
911cba81b7
@ -1,3 +1,7 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
["medical_onUnconscious", {_this call FUNC(handleUnconscious)}] call EFUNC(common,addEventHandler);
|
["medical_onUnconscious", {_this call FUNC(handleUnconscious)}] call EFUNC(common,addEventHandler);
|
||||||
|
|
||||||
|
if (isServer) then {
|
||||||
|
addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleDisconnect)}];
|
||||||
|
};
|
||||||
|
@ -15,6 +15,7 @@ PREP(connectNozzleAction);
|
|||||||
PREP(disconnect);
|
PREP(disconnect);
|
||||||
PREP(dropNozzle);
|
PREP(dropNozzle);
|
||||||
PREP(getFuel);
|
PREP(getFuel);
|
||||||
|
PREP(handleDisconnect);
|
||||||
PREP(handleKilled);
|
PREP(handleKilled);
|
||||||
PREP(handleUnconscious);
|
PREP(handleUnconscious);
|
||||||
PREP(makeJerryCan);
|
PREP(makeJerryCan);
|
||||||
|
@ -77,7 +77,7 @@ _endPosTestOffset set [2, (_startingOffset select 2)];
|
|||||||
{
|
{
|
||||||
params ["_args"];
|
params ["_args"];
|
||||||
_args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_target", objNull, [objNull]], ["_endPosTestOffset", [0,0,0], [[]], 3]];
|
_args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_target", objNull, [objNull]], ["_endPosTestOffset", [0,0,0], [[]], 3]];
|
||||||
_unit setVariable [QGVAR(nozzle), nil];
|
_unit setVariable [QGVAR(nozzle), nil, true];
|
||||||
_unit setVariable [QGVAR(isRefueling), false];
|
_unit setVariable [QGVAR(isRefueling), false];
|
||||||
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
|
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
|
||||||
REFUEL_UNHOLSTER_WEAPON
|
REFUEL_UNHOLSTER_WEAPON
|
||||||
|
26
addons/refuel/functions/fnc_handleDisconnect.sqf
Normal file
26
addons/refuel/functions/fnc_handleDisconnect.sqf
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Author: GitHawk
|
||||||
|
* Cleans up refuel
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Player <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [player] call ace_refuel_fnc_handleDisconnect
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params [["_disconnectedPlayer", objNull, [objNull]]];
|
||||||
|
|
||||||
|
if (isNull _disconnectedPlayer) exitWith {};
|
||||||
|
|
||||||
|
private _nozzle = _disconnectedPlayer getVariable [QGVAR(nozzle), objNull];
|
||||||
|
|
||||||
|
if (isNull _nozzle) exitWith {};
|
||||||
|
|
||||||
|
[_disconnectedPlayer, _nozzle] call FUNC(dropNozzle);
|
@ -32,5 +32,5 @@ if (_actionID != -1) then {
|
|||||||
_unit removeAction _actionID;
|
_unit removeAction _actionID;
|
||||||
_unit setVariable [QGVAR(isRefueling), false, true];
|
_unit setVariable [QGVAR(isRefueling), false, true];
|
||||||
_unit setVariable [QGVAR(ReleaseActionID), nil];
|
_unit setVariable [QGVAR(ReleaseActionID), nil];
|
||||||
_unit setVariable [QGVAR(nozzle), nil];
|
_unit setVariable [QGVAR(nozzle), nil, true];
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ if (isNull _nozzle || {_source != _target}) exitWith {false};
|
|||||||
{
|
{
|
||||||
params ["_args"];
|
params ["_args"];
|
||||||
_args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_target", objNull, [objNull]]];
|
_args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_target", objNull, [objNull]]];
|
||||||
_unit setVariable [QGVAR(nozzle), nil];
|
_unit setVariable [QGVAR(nozzle), nil, true];
|
||||||
detach _nozzle;
|
detach _nozzle;
|
||||||
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
|
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
|
||||||
REFUEL_UNHOLSTER_WEAPON
|
REFUEL_UNHOLSTER_WEAPON
|
||||||
|
@ -53,7 +53,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
|
|||||||
|
|
||||||
private _newNozzle = "ACE_refuel_fuelNozzle" createVehicle position _unit;
|
private _newNozzle = "ACE_refuel_fuelNozzle" createVehicle position _unit;
|
||||||
_newNozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
|
_newNozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
|
||||||
_unit setVariable [QGVAR(nozzle), _newNozzle];
|
_unit setVariable [QGVAR(nozzle), _newNozzle, true];
|
||||||
|
|
||||||
private _rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, -0.20, 0.12], REFUEL_HOSE_LENGTH];
|
private _rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, -0.20, 0.12], REFUEL_HOSE_LENGTH];
|
||||||
_newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true];
|
_newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true];
|
||||||
@ -95,7 +95,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
|
|||||||
} else {
|
} else {
|
||||||
_nozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
|
_nozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
|
||||||
};
|
};
|
||||||
_unit setVariable [QGVAR(nozzle), _nozzle];
|
_unit setVariable [QGVAR(nozzle), _nozzle, true];
|
||||||
|
|
||||||
_unit setVariable [QGVAR(isRefueling), true];
|
_unit setVariable [QGVAR(isRefueling), true];
|
||||||
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
||||||
@ -125,18 +125,24 @@ if (isNull _nozzle) then { // func is called on fuel truck
|
|||||||
};
|
};
|
||||||
if !(_nozzle getVariable [QGVAR(jerryCan), false]) then {
|
if !(_nozzle getVariable [QGVAR(jerryCan), false]) then {
|
||||||
[{
|
[{
|
||||||
private ["_nozzle"];
|
|
||||||
params ["_args", "_pfID"];
|
params ["_args", "_pfID"];
|
||||||
_args params ["_unit", "_source", "_endPosOffset"];
|
_args params [["_unit", player, [objNull]], ["_source", objNull, [objNull]], ["_endPosOffset", [0, 0, 0], [[]], 3]];
|
||||||
|
_args params ["", "", "", ["_nozzle", _unit getVariable [QGVAR(nozzle), objNull], [objNull]]];
|
||||||
if (_unit distance (_source modelToWorld _endPosOffset) > (REFUEL_HOSE_LENGTH - 2)) exitWith {
|
if (isNull _source || {_unit distance (_source modelToWorld _endPosOffset) > (REFUEL_HOSE_LENGTH - 2)} || {!alive _source}) exitWith {
|
||||||
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
|
|
||||||
if !(isNull _nozzle) then {
|
if !(isNull _nozzle) then {
|
||||||
[_unit, _nozzle] call FUNC(dropNozzle);
|
[_unit, _nozzle] call FUNC(dropNozzle);
|
||||||
REFUEL_UNHOLSTER_WEAPON
|
REFUEL_UNHOLSTER_WEAPON
|
||||||
|
|
||||||
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
|
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
|
||||||
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
|
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);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
[_pfID] call cba_fnc_removePerFrameHandler;
|
[_pfID] call cba_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user