From 3e3ed12503ed1f8e6110164642248c4db5f76c87 Mon Sep 17 00:00:00 2001 From: lambdatiger Date: Wed, 10 Jan 2024 19:47:05 -0600 Subject: [PATCH] Final submunition code cull --- addons/frag/XEH_PREP.hpp | 2 - addons/frag/functions/fnc_doFrag.sqf | 3 +- addons/frag/functions/fnc_doSpall.sqf | 14 ++--- addons/frag/functions/fnc_fired.sqf | 64 ----------------------- addons/frag/functions/fnc_initRound.sqf | 5 +- addons/frag/functions/fnc_shouldFrag.sqf | 22 ++------ addons/frag/functions/fnc_submunition.sqf | 40 -------------- addons/frag/initSettings.inc.sqf | 4 -- 8 files changed, 9 insertions(+), 145 deletions(-) delete mode 100644 addons/frag/functions/fnc_fired.sqf delete mode 100644 addons/frag/functions/fnc_submunition.sqf diff --git a/addons/frag/XEH_PREP.hpp b/addons/frag/XEH_PREP.hpp index 339cbff61c..326ccc82a5 100644 --- a/addons/frag/XEH_PREP.hpp +++ b/addons/frag/XEH_PREP.hpp @@ -11,13 +11,11 @@ PREP(dev_clearTraces); PREP(dev_switchUnitHandle); // Base -PREP(fired); PREP(initRound); // Frag PREP(addBlackList); PREP(initBlackList); -PREP(submunition); PREP(shouldFrag); PREP(getFragInfo); PREP(doFrag); diff --git a/addons/frag/functions/fnc_doFrag.sqf b/addons/frag/functions/fnc_doFrag.sqf index 74bd5a1746..5b6d5b5d4d 100644 --- a/addons/frag/functions/fnc_doFrag.sqf +++ b/addons/frag/functions/fnc_doFrag.sqf @@ -20,8 +20,7 @@ * Public: No */ TRACE_1("",_this); -/*params ["_args", ["_isSubMunit", false, [false]]]; -_args*/ params [ +params [ ["_proj", objNull, [objNull]], ["_posASL", [0,0,0], [[]], [3]], ["_vel", [0,0,0] , [[]], [3]], diff --git a/addons/frag/functions/fnc_doSpall.sqf b/addons/frag/functions/fnc_doSpall.sqf index da9624da77..5a30c0bb74 100644 --- a/addons/frag/functions/fnc_doSpall.sqf +++ b/addons/frag/functions/fnc_doSpall.sqf @@ -19,12 +19,9 @@ TRACE_1("",_this); params [ "_projectile", ["_hitObj", objNull], -// "", ["_lPosASL", [0, 0, 0]], ["_lVel", [0, 0, 0]], ["_sNorm", [0, 0, 0]], -// "", -// "", ["_surfaceType", ""], ["_ammo", "", [""]], ["_shotParents", [objNull, objNull], [[]]], @@ -70,16 +67,14 @@ private _spallPos = +_lPosASL; if (terrainIntersectASL [_lPosASL vectorAdd _unitStep, _lPosASL]) exitWith { TRACE_3("terrainIntersect",_lPosASL,_unitStep,_lPosASL); }; - +// Passed all exitWiths +GVAR(lastSpallTime) = CBA_missionTime; +// check for less than 30 between norm and projectile (120 of 90 deg offset) if (120 > acos ((vectorNormalized _lVelUnit) vectorDotProduct _sNorm)) then { _spallPos = _spallPos vectorAdd (_unitStep vectorMultiply 5); }; -// Passed all exit withs -GVAR(lastSpallTime) = CBA_missionTime; - -// step through for "_i" from 1 to 20 do { private _nPos = _spallPos vectorAdd _unitStep; @@ -98,8 +93,6 @@ if GVAR(dbgSphere) then { }; #endif -// Select spalled fragment spawner - private _spawnSize = switch (true) do { case (_deltaMomentum < 3): { "_spall_tiny" }; @@ -109,7 +102,6 @@ private _spawnSize = switch (true) do default { "_spall_huge" }; }; -// Spawn spalled fragments private _spallSpawner = createVehicle [ "ace_frag_" + _material + _spawnSize, ASLToATL _spallPos, diff --git a/addons/frag/functions/fnc_fired.sqf b/addons/frag/functions/fnc_fired.sqf deleted file mode 100644 index 182ee70c24..0000000000 --- a/addons/frag/functions/fnc_fired.sqf +++ /dev/null @@ -1,64 +0,0 @@ -#include "script_component.hpp" -/* - * Author: nou, jaynus, PabstMirror, Lambda.Tiger - * Called from the unified fired EH for all. - * If spall is not enabled (default), then cache and only track those that will actually trigger fragmentation. - * - * Arguments: - * None. Parameters inherited from EFUNC(common,firedEH) - * - * Return Value: - * None - * - * Example: - * [clientFiredBIS-XEH] call ace_frag_fnc_fired - * - * Public: No - */ - -//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"]; - -if (isNil "_ammo" || - {_ammo isEqualTo "" || - {isNil "_projectile" || - {isNull _projectile}}}) exitWith { - TRACE_2("bad ammo or projectile",_projectile,_ammo); -}; - -/******* _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(fragSimComplexity)> 0}) then { - _projectile addEventHandler ["SubmunitionCreated", {_this call FUNC(submunition)}]; -}; - -private _shouldSpall = _ammo call FUNC(shouldSpall); - -if (GVAR(spallEnabled) && {_shouldSpall}) then -{_projectile addEventHandler [ - "HitPart", - { - if (isServer) then { - [LINKFUNC(doSpall), _this] call CBA_fnc_execNextFrame; - } else { - [QGVAR(spall_eh), [_this]] call CBA_fnc_serverEvent; - }; - } - ]; -}; \ No newline at end of file diff --git a/addons/frag/functions/fnc_initRound.sqf b/addons/frag/functions/fnc_initRound.sqf index 37be4c0024..14502036c5 100644 --- a/addons/frag/functions/fnc_initRound.sqf +++ b/addons/frag/functions/fnc_initRound.sqf @@ -24,16 +24,14 @@ if (_ammo isEqualTo "" || {isNull _projectile}) exitWith { }; private _shouldFrag = _ammo call FUNC(shouldFrag); -_shouldFrag params ["_doFrag"]; - if (_doFrag) then { - // wait for frag damage to kill units before spawning fragments _projectile addEventHandler [ "Explode", { params ["_proj"]; private _shotParents = getShotParents _proj; private _ammo = typeOf _proj; + // wait for frag damage to kill units before spawning fragments if (isServer) then { [ FUNC(doFrag), @@ -51,7 +49,6 @@ if (_doFrag) then { private _shouldSpall = _ammo call FUNC(shouldSpall); - if (GVAR(spallEnabled) && {_shouldSpall}) then { _projectile addEventHandler [ diff --git a/addons/frag/functions/fnc_shouldFrag.sqf b/addons/frag/functions/fnc_shouldFrag.sqf index fbfb32b9f8..1a5a92c119 100644 --- a/addons/frag/functions/fnc_shouldFrag.sqf +++ b/addons/frag/functions/fnc_shouldFrag.sqf @@ -8,9 +8,7 @@ * 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 + * _shouldFrag Should the specific round fragment * * Example: * ["B_556x45_Ball"] call ace_frag_fnc_shouldFrag; @@ -23,8 +21,8 @@ params ["_ammo"]; private _shouldFrag = GVAR(shouldFragCache) get _ammo; if !(isNil "_shouldFrag") exitWith {_shouldFrag}; -// two arguments, 1st for munition should frag, 2nd for -_shouldFrag = [true, false]; + +_shouldFrag = true; private _skip = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(skip)); private _force = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(force)); @@ -35,21 +33,9 @@ private _indirectRange = getNumber(configFile >> "cfgAmmo" >> _ammo >> "indirect if (_skip == 1 || (_force == 0 && {_explosive < 0.5 || {_indirectHit < 3 || {_indirectRange < 5 && _indirectHit < _indirectRange}}})) then { TRACE_5("No frag",_ammo,_skip, _explosive, _indirectRange, _indirectHit); - _shouldFrag set [0, false]; + _shouldFrag = false; }; -/*if (GVAR(fragSimComplexity) > 1) then { - private _hasSubmunit = if (isText (configFile >> "cfgAmmo" >> _ammo >> "submunitionAmmo")) then { - "" isNotEqualTo getText (configFile >> "cfgAmmo" >> _ammo >> "submunitionAmmo"); - } else - { - [] isNotEqualTo getArray (configFile >> "cfgAmmo" >> _ammo >> "submunitionAmmo"); - }; - - _shouldFrag set [1, _hasSubmunit]; - TRACE_2("Submunition" ,_ammo, _hasSubmunit); -};*/ - GVAR(shouldFragCache) set [_ammo, _shouldFrag]; _shouldFrag \ No newline at end of file diff --git a/addons/frag/functions/fnc_submunition.sqf b/addons/frag/functions/fnc_submunition.sqf deleted file mode 100644 index ed046151e3..0000000000 --- a/addons/frag/functions/fnc_submunition.sqf +++ /dev/null @@ -1,40 +0,0 @@ -#include "script_component.hpp" -/* - * Author: Lambda.Tiger - * This function adds event handlers for submunition fragmentation. - * It begins by confirming fragmentation and submunition fragmentation is - * enabled, requests cached (or live calculated) ammo information array. - * and uses that information to add event handlers as needed to the given - * submunition. - * - * Arguments: - * Inherits from BI SubmunitionCraeted EH - * - * Return Value: - * none - * - * Example: - * ["", _submunitionProjectile] call ace_frag_submunition - * - * Public: No - */ - -if !GVAR(enabled) exitWith {}; -// params ["_projectile", "_submunitionProjectile", "_pos", "_velocity"]; -params ["", "_submunitionProjectile"]; - -private _shouldFrag = GVAR(shouldFragCache) getOrDefaultCall [typeOf _submunitionProjectile, FUNC(shouldFrag), true]; -_shouldFrag params ["_doFrag", "_doSubmunit"]; - - -if (_doFrag) then { - _submunitionProjectile addEventHandler ["Explode", {[_this, true] call FUNC(doFrag)}]; -}; - -if (_doSubmunit) then { - _submunitionProjectile addEventHandler ["SubmunitionCreated", {_this call FUNC(submunition)}]; -}; - -#ifdef DEBUG_MODE_DRAW - [_submunitionProjectile] call FUNC(dev_addRound); -#endif \ No newline at end of file diff --git a/addons/frag/initSettings.inc.sqf b/addons/frag/initSettings.inc.sqf index 6d44d8061a..29841cae57 100644 --- a/addons/frag/initSettings.inc.sqf +++ b/addons/frag/initSettings.inc.sqf @@ -28,17 +28,14 @@ private _category = format ["ACE %1", localize LSTRING(Module_DisplayName)]; [ QGVAR(fragSimComplexity), "LIST", [LSTRING(FragMode), LSTRING(FragMode_Desc)], -// ["Fragmentation mode", "Sets how fragments are generated"], [_category, LSTRING(Frag)], [[2, 1, 0], [LSTRING(FragMode_Opt2),LSTRING(FragMode_Opt1),LSTRING(FragMode_Opt0)], 2], -// [[2, 1, 0], ["Targeted & random fragmentation","Random fragmentation","Unit targeted fragmentation"], 2], true ] call CBA_fnc_addSetting; [ QGVAR(atLeastOne), "CHECKBOX", [LSTRING(MinFrag), LSTRING(MinFrag_Desc)], -// ["At least one round hit", "Spawn at least one fragment for units in fragmentation range, up to maximum fragments"], [_category, LSTRING(Frag)], true ] call CBA_fnc_addSetting; @@ -46,7 +43,6 @@ private _category = format ["ACE %1", localize LSTRING(Module_DisplayName)]; [ QGVAR(BlackList), "EDITBOX", [LSTRING(DefBlackList), LSTRING(DefBlackList_Desc)], -// ["Fragmentation BlackList", "Array of ammo classnames strings to blackist fragmentation for."], [_category, LSTRING(Frag)], QUOTE(['B_556x45_Ball']), true,