diff --git a/addons/frag/XEH_postInit.sqf b/addons/frag/XEH_postInit.sqf index 6bd79cc101..f50279ce8a 100644 --- a/addons/frag/XEH_postInit.sqf +++ b/addons/frag/XEH_postInit.sqf @@ -17,16 +17,11 @@ // Debug info #ifdef DEBUG_MODE_FULL - if (hasInterface && GVAR(debugOptions)) then - { - private _h = [LINKFUNC(dev_drawTrace), 0] call CBA_fnc_addPerFrameHandler; - missionNamespace setVariable [QGVAR(dev_drawPFEH), _h]; - ["unit", LINKFUNC(dev_switchUnitHandle), true] call CBA_fnc_addPlayerEventHandler; - [objNull, ace_player] call FUNC(dev_switchUnitHandle); - ["ace_firedPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler; - ["ace_firedNonPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler; - ["ace_firedPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler; - ["ace_firedNonPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler; + if (hasInterface && GVAR(debugOptions)) then { + private _h = [LINKFUNC(dev_drawTrace), 0] call CBA_fnc_addPerFrameHandler; + missionNamespace setVariable [QGVAR(dev_drawPFEH), _h]; + ["unit", LINKFUNC(dev_switchUnitHandle), true] call CBA_fnc_addPlayerEventHandler; + [objNull, ace_player] call FUNC(dev_switchUnitHandle); }; #endif }] call CBA_fnc_addEventHandler; diff --git a/addons/frag/cfgAmmoBaseEH.hpp b/addons/frag/cfgAmmoBaseEH.hpp index f76d01b807..050a7d769d 100644 --- a/addons/frag/cfgAmmoBaseEH.hpp +++ b/addons/frag/cfgAmmoBaseEH.hpp @@ -1,6 +1,6 @@ #define ACE_FRAG_ADD_EH class EventHandlers {\ class ADDON {\ - init = QUOTE(_this call FUNC(initRound));\ + init = QUOTE(_this call FUNC(initRound););\ };\ } @@ -9,7 +9,8 @@ class Bo_Mk82: BombCore { ACE_FRAG_ADD_EH; }; -class BulletCore; +// We need this since autocannons generally inherit from BulletBase +class BulletCore; class BulletBase: BulletCore { ACE_FRAG_ADD_EH; }; diff --git a/addons/frag/functions/fnc_initRound.sqf b/addons/frag/functions/fnc_initRound.sqf index 4571dde8a5..fc13bba93f 100644 --- a/addons/frag/functions/fnc_initRound.sqf +++ b/addons/frag/functions/fnc_initRound.sqf @@ -1,37 +1,32 @@ #include "script_component.hpp" /* * Author: Lambda.Tiger - * This function checks whether an ammunition type should cause fragmentation - * and whether any submunitions exist - * + * This function adds rounds using their config init EH + * Arguments: - * 0: _ammo - cfgAmmo type of ammo to check + * 0: _projectile - The object created * * Return Value: - * _shouldFrag - * 0 - Should the specific round fragment - * 1 - Does the munition have a child submunition + * None * * Example: - * ["B_556x45_Ball"] call ace_frag_fnc_shouldFrag; + * [_proj] call ace_frag_fnc_initRound; * * Public: No */ - params ["_projectile"]; -private _ammo = typeOf _proj; -systemChat (str _ammo + " " + str _projectile); - if (isNil "_ammo" || +params ["_projectile"]; + +private _ammo = typeOf _projectile; +if (isNil "_ammo" || {_ammo isEqualTo "" || {isNil "_projectile" || {isNull _projectile}}}) exitWith { - WARNING("bad ammo or projectile"); + TRACE_2("bad ammo or projectile",_ammo,_projectile); }; -/******* _shouldFrag format *****/ -// 0: doFragmnent - will the piece fragment -// 1: hasSubmuntion - will the round create submunitions + private _shouldFrag = _ammo call FUNC(shouldFrag); -_shouldFrag params ["_doFrag", "_doSubmunit"]; +_shouldFrag params ["_doFrag"]; if (_doFrag) then { // wait for frag damage to kill units before spawning fragments @@ -45,18 +40,19 @@ if (_doFrag) then { ]; }; -if (_doSubmunit && {GVAR(enSubMunit)> 0}) then { - _projectile addEventHandler ["SubmunitionCreated", {_this call FUNC(submunition)}]; -}; private _shouldSpall = _ammo call FUNC(shouldSpall); if (GVAR(spallEnabled) && {_shouldSpall}) then -{_projectile addEventHandler [ +{ + _projectile addEventHandler [ "HitPart", { - [LINKFUNC(doSpallMomentum), _this] call CBA_fnc_execNextFrame; - [QGVAR(spall_eh), [_this]] call CBA_fnc_serverEvent; + if (isServer) then { + [LINKFUNC(doSpallMomentum), _this] call CBA_fnc_execNextFrame; + } else { + [QGVAR(spall_eh), [_this]] call CBA_fnc_serverEvent; + }; } ]; }; \ No newline at end of file