From 5aa763f0c639ce5411114642fa950b0bc41d0f80 Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Sat, 6 Feb 2016 17:59:54 -0300 Subject: [PATCH] Apply the ufeh to ACE_Overheating --- addons/overheating/CfgEventHandlers.hpp | 8 ------- addons/overheating/XEH_postInit.sqf | 9 ++++++++ addons/overheating/functions/fnc_firedEH.sqf | 22 +++++++------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/addons/overheating/CfgEventHandlers.hpp b/addons/overheating/CfgEventHandlers.hpp index 7e4e0b35c7..7f43c8b903 100644 --- a/addons/overheating/CfgEventHandlers.hpp +++ b/addons/overheating/CfgEventHandlers.hpp @@ -10,14 +10,6 @@ class Extended_PostInit_EventHandlers { }; }; -class Extended_FiredBIS_EventHandlers { - class CAManBase { - class GVAR(Overheat) { - clientFiredBIS = QUOTE(_this call FUNC(firedEH)); - }; - }; -}; - class Extended_Take_EventHandlers { class CAManBase { class GVAR(UnjamReload) { diff --git a/addons/overheating/XEH_postInit.sqf b/addons/overheating/XEH_postInit.sqf index 76cdb090bb..38c0298b0f 100644 --- a/addons/overheating/XEH_postInit.sqf +++ b/addons/overheating/XEH_postInit.sqf @@ -36,3 +36,12 @@ GVAR(cacheWeaponData) setText QGVAR(cacheWeaponData); // Schedule cool down calculation of player weapons at (infrequent) regular intervals [] call FUNC(updateTemperatureThread); + +["SettingsInitialized", { + // Register fire event handler + ["firedPlayer", DFUNC(firedEH)] call EFUNC(common,addEventHandler); + // Only add eh to non local players if dispersion is enabled + if (GVAR(overheatingDispersion)) then { + ["firedPlayerNonLocal", DFUNC(firedEH)] call EFUNC(common,addEventHandler); + }; +}] call EFUNC(common,addEventHandler); diff --git a/addons/overheating/functions/fnc_firedEH.sqf b/addons/overheating/functions/fnc_firedEH.sqf index b37e87c66d..604a2bb31d 100644 --- a/addons/overheating/functions/fnc_firedEH.sqf +++ b/addons/overheating/functions/fnc_firedEH.sqf @@ -1,15 +1,9 @@ /* * Author: Commy2 and esteldunedain - * Handle weapon fire + * Handle weapon fire. Called from the unified fired EH 1- always for the local player 2- and for non local players if dispersion is simulated. * * Argument: - * 0: unit - Object the event handler is assigned to - * 1: weapon - Fired weapon - * 2: muzzle - Muzzle that was used - * 3: mode - Current mode of the fired weapon - * 4: ammo - Ammo used - * 5: magazine - magazine name which was used - * 6: projectile - Object of the projectile that was shot + * None. Parameters inherited from EFUNC(common,firedEH) * * Return value: * None @@ -18,15 +12,13 @@ */ #include "script_component.hpp" +//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"]; +TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret); + BEGIN_COUNTER(firedEH); -params ["_unit", "_weapon", "_muzzle", "", "_ammo", "", "_projectile"]; -TRACE_5("params",_unit,_weapon,_muzzle,_ammo,_projectile); - -if (((!GVAR(overheatingDispersion)) && {_unit != ACE_player}) //If no dispersion, only run when local - || {!([_unit] call EFUNC(common,isPlayer))} //Ignore AI - || {(_unit distance ACE_player) > 3000} //Ignore far away shots - || {(_muzzle != (primaryWeapon _unit)) && {_muzzle != (handgunWeapon _unit)}}) exitWith { // Only rifle or pistol muzzles (ignore grenades / GLs) +if ((_unit distance ACE_player) > 3000 //Ignore far away shots + || {(_muzzle != (primaryWeapon _unit)) && {_muzzle != (handgunWeapon _unit)}}) exitWith { // Only rifle or pistol muzzles (ignore grenades / GLs) END_COUNTER(firedEH); };