Prevent switching to weapon while carrying fuel nozzle - fix #4601

This commit is contained in:
jonpas 2016-11-02 18:44:39 +01:00 committed by Glowbal
parent e73d20f3c3
commit c2e933355d
4 changed files with 35 additions and 0 deletions

View File

@ -14,6 +14,7 @@ PREP(dropNozzle);
PREP(getFuel);
PREP(handleDisconnect);
PREP(handleKilled);
PREP(handlePlayerWeaponChanged);
PREP(handleUnconscious);
PREP(makeJerryCan);
PREP(maxDistanceDropNozzle);

View File

@ -1,6 +1,7 @@
#include "script_component.hpp"
["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler;
["weapon", FUNC(handlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler;
if (isServer) then {
addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleDisconnect)}];

View File

@ -0,0 +1,29 @@
/*
* Author: Jonpas
* Drops nozzle or jerry can when selecting a weapon.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon <STRING> (unused)
*
* Return Value:
* None
*
* Example:
* [_unit, "gun"] call ace_refuel_fnc_handlePlayerWeaponChanged;
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
// Drop nozzle/jerry can when selecting a non-primary weapon
if (_unit getVariable [QGVAR(isRefueling), false]) then {
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
[_unit, _nozzle] call FUNC(dropNozzle);
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
};
};

View File

@ -33,6 +33,10 @@ if (_nozzle getVariable [QGVAR(jerryCan), false]) exitWith {};
["_nozzle", (_args select 0) getVariable [QGVAR(nozzle), objNull], [objNull]]
];
if (_unit getVariable [QGVAR(isRefueling), false]) exitWith {
[_pfID] call CBA_fnc_removePerFrameHandler;
};
if (isNull _source || {_unit distance (_source modelToWorld _endPosOffset) > (REFUEL_HOSE_LENGTH - 2)} || {!alive _source}) exitWith {
if !(isNull _nozzle) then {
[_unit, _nozzle] call FUNC(dropNozzle);