Merge pull request #4629 from acemod/fixRefuelShooting

Prevent switching to weapon while carrying fuel nozzle
This commit is contained in:
jonpas 2016-11-13 00:13:48 +01:00 committed by GitHub
commit d69b48bac5
4 changed files with 36 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,11 @@ if (_nozzle getVariable [QGVAR(jerryCan), false]) exitWith {};
["_nozzle", (_args select 0) getVariable [QGVAR(nozzle), objNull], [objNull]]
];
if (!(_unit getVariable [QGVAR(isRefueling), false])) exitWith {
TRACE_1("player not isRefueling",_unit);
[_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);