From 41d758567ed95b9ddef6355a4955a00341951bd8 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 31 Aug 2016 15:12:40 -0500 Subject: [PATCH] Chemlights cleanup (#4304) --- addons/chemlights/XEH_postInit.sqf | 6 +++--- .../chemlights/functions/fnc_compileChemlightMenu.sqf | 2 +- addons/chemlights/functions/fnc_isIRClass.sqf | 2 +- addons/chemlights/functions/fnc_removeIR.sqf | 4 ++-- addons/chemlights/functions/fnc_throwEH.sqf | 9 +++++++-- addons/chemlights/functions/fnc_throwIR.sqf | 11 ++++++++--- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/addons/chemlights/XEH_postInit.sqf b/addons/chemlights/XEH_postInit.sqf index d35fc951b2..6b22de4a3c 100644 --- a/addons/chemlights/XEH_postInit.sqf +++ b/addons/chemlights/XEH_postInit.sqf @@ -2,6 +2,6 @@ if (!hasInterface) exitWith {}; -["firedPlayer", DFUNC(throwEH)] call EFUNC(common,addEventHandler); -["firedPlayerNonLocal", DFUNC(throwEH)] call EFUNC(common,addEventHandler); -["firedNonPlayer", DFUNC(throwEH)] call EFUNC(common,addEventHandler); +["ace_firedPlayer", DFUNC(throwEH)] call CBA_fnc_addEventHandler; +// ["ace_firedPlayerNonLocal", DFUNC(throwEH)] call CBA_fnc_addEventHandler; +// ["ace_firedNonPlayer", DFUNC(throwEH)] call CBA_fnc_addEventHandler; diff --git a/addons/chemlights/functions/fnc_compileChemlightMenu.sqf b/addons/chemlights/functions/fnc_compileChemlightMenu.sqf index e3c7d12bbd..74b0a154c9 100644 --- a/addons/chemlights/functions/fnc_compileChemlightMenu.sqf +++ b/addons/chemlights/functions/fnc_compileChemlightMenu.sqf @@ -5,7 +5,7 @@ * Arguments: * 0: Vehicle * 1: Player - * 3: Parameters + * 2: Parameters * * Return value: * None diff --git a/addons/chemlights/functions/fnc_isIRClass.sqf b/addons/chemlights/functions/fnc_isIRClass.sqf index a56b7f9b32..69643a89fe 100644 --- a/addons/chemlights/functions/fnc_isIRClass.sqf +++ b/addons/chemlights/functions/fnc_isIRClass.sqf @@ -3,7 +3,7 @@ * Check if an ammo classname is an IR chemlight. * * Arguments: - * 1: Projectile or ammo classname or + * 0: Projectile or ammo classname or * * Return Value: * Is IR chemlight? diff --git a/addons/chemlights/functions/fnc_removeIR.sqf b/addons/chemlights/functions/fnc_removeIR.sqf index e1ab10fe99..b7f6a0001e 100644 --- a/addons/chemlights/functions/fnc_removeIR.sqf +++ b/addons/chemlights/functions/fnc_removeIR.sqf @@ -3,8 +3,8 @@ * Kill chemlight and any dummy objects attached to it. * * Arguments: - * 1: Chemlight object - * 2: Light marker vehicle + * 0: Chemlight object + * 1: Light marker vehicle * * Return Value: * None diff --git a/addons/chemlights/functions/fnc_throwEH.sqf b/addons/chemlights/functions/fnc_throwEH.sqf index 1a03881b6c..18215c9846 100644 --- a/addons/chemlights/functions/fnc_throwEH.sqf +++ b/addons/chemlights/functions/fnc_throwEH.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" -params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"]; +params ["_unit", "_weapon", "", "", "_ammo", "", "_projectile"]; if ((_weapon != "Throw") || {!(_ammo isKindOf ["Chemlight_base", configFile >> "CfgAmmo"])}) exitWith {}; @@ -27,6 +27,11 @@ if (isNull _projectile) then { if (local _unit) then { if ([_ammo] call FUNC(isIRClass)) then { - [{_this call FUNC(throwIR)}, [_projectile, _ammo]] call CBA_fnc_execNextFrame; + // Handle advancedThrowing: + if ((ace_player getVariable [QEGVAR(advancedThrowing,activeThrowable), objNull]) == _projectile) then { + [_projectile, _ammo, true] call FUNC(throwIR); // direct call if we are priming with adv throw + } else { + [{_this call FUNC(throwIR)}, [_projectile, _ammo]] call CBA_fnc_execNextFrame; + }; }; }; diff --git a/addons/chemlights/functions/fnc_throwIR.sqf b/addons/chemlights/functions/fnc_throwIR.sqf index d93a62e72f..0148b0d669 100644 --- a/addons/chemlights/functions/fnc_throwIR.sqf +++ b/addons/chemlights/functions/fnc_throwIR.sqf @@ -3,8 +3,9 @@ * Create and throw IR chemlight. * * Arguments: - * 1: Original throw projectile - * 2: Class of projectile + * 0: Original throw projectile + * 1: Class of projectile + * 2: Adv throw (default: false) * * Return Value: * None @@ -17,7 +18,7 @@ #include "script_component.hpp" -params ["_projectile", "_ammo"]; +params ["_projectile", "_ammo", ["_replaceAdvThrowable", false]]; private _config = configFile >> "CfgAmmo" >> _ammo; private _dummyClass = getText (_config >> "ACE_Chemlight_IR"); @@ -29,3 +30,7 @@ private _dummy = _dummyClass createVehicle _pos; _dummy setPosATL _pos; [_dummy, 90, 0] call BIS_fnc_setPitchBank; _dummy setVelocity _velocity; + +if (_replaceAdvThrowable) then { + ace_player setVariable [QEGVAR(advancedThrowing,activeThrowable), _dummy]; +};