From bfb3fa851c692fd6e1886586de4175bad9640d5f Mon Sep 17 00:00:00 2001 From: lambdatiger Date: Mon, 8 Jan 2024 18:06:57 -0600 Subject: [PATCH] added fnc_initRound --- addons/frag/XEH_PREP.hpp | 7 +-- addons/frag/XEH_postInit.sqf | 4 +- addons/frag/functions/fnc_initRound.sqf | 62 +++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 addons/frag/functions/fnc_initRound.sqf diff --git a/addons/frag/XEH_PREP.hpp b/addons/frag/XEH_PREP.hpp index d46ebd25ab..855cfdd8d9 100644 --- a/addons/frag/XEH_PREP.hpp +++ b/addons/frag/XEH_PREP.hpp @@ -10,10 +10,13 @@ PREP(dev_drawTrace); PREP(dev_clearTraces); PREP(dev_switchUnitHandle); +// Base +PREP(fired); +PREP(initRound); + // Frag PREP(addBlackList); PREP(initBlackList); -PREP(fired); PREP(submunition); PREP(shouldFrag); PREP(fragInfo); @@ -25,8 +28,6 @@ PREP(doFragRandom); PREP(shouldSpall); PREP(doSpall); PREP(doSpallMomentum); - -// * Other */ //PREP(spallHP); Look at me !*! // Explosive Reflection diff --git a/addons/frag/XEH_postInit.sqf b/addons/frag/XEH_postInit.sqf index 94b2247e94..6bd79cc101 100644 --- a/addons/frag/XEH_postInit.sqf +++ b/addons/frag/XEH_postInit.sqf @@ -7,13 +7,13 @@ [] call FUNC(initBlackList); }; - if (hasInterface) then { + /*if (hasInterface) then { ["ace_firedPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler; ["ace_firedPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler; }; ["ace_firedNonPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler; - ["ace_firedNonPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler; + ["ace_firedNonPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler;*/ // Debug info #ifdef DEBUG_MODE_FULL diff --git a/addons/frag/functions/fnc_initRound.sqf b/addons/frag/functions/fnc_initRound.sqf new file mode 100644 index 0000000000..4571dde8a5 --- /dev/null +++ b/addons/frag/functions/fnc_initRound.sqf @@ -0,0 +1,62 @@ +#include "script_component.hpp" +/* + * Author: Lambda.Tiger + * This function checks whether an ammunition type should cause fragmentation + * and whether any submunitions exist + * + * Arguments: + * 0: _ammo - cfgAmmo type of ammo to check + * + * Return Value: + * _shouldFrag + * 0 - Should the specific round fragment + * 1 - Does the munition have a child submunition + * + * Example: + * ["B_556x45_Ball"] call ace_frag_fnc_shouldFrag; + * + * Public: No + */ + params ["_projectile"]; +private _ammo = typeOf _proj; +systemChat (str _ammo + " " + str _projectile); + if (isNil "_ammo" || + {_ammo isEqualTo "" || + {isNil "_projectile" || + {isNull _projectile}}}) exitWith { + WARNING("bad ammo or 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"]; + +if (_doFrag) then { + // wait for frag damage to kill units before spawning fragments + _projectile addEventHandler ["Explode", { + if (isServer) then { + [FUNC(doFrag), [_this]] call CBA_fnc_execNextFrame; + } else { + [QGVAR(frag_eh), [_this]] call CBA_fnc_serverEvent; + }; + } + ]; +}; + +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 [ + "HitPart", + { + [LINKFUNC(doSpallMomentum), _this] call CBA_fnc_execNextFrame; + [QGVAR(spall_eh), [_this]] call CBA_fnc_serverEvent; + } + ]; +}; \ No newline at end of file