Final submunition code cull

This commit is contained in:
lambdatiger 2024-01-10 19:47:05 -06:00
parent a079f61ded
commit 3e3ed12503
8 changed files with 9 additions and 145 deletions

View File

@ -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);

View File

@ -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]],

View File

@ -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,

View File

@ -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;
};
}
];
};

View File

@ -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 [

View File

@ -8,9 +8,7 @@
* 0: _ammo <STRING> - cfgAmmo type of ammo to check
*
* Return Value:
* _shouldFrag <ARRAY>
* 0 - Should the specific round fragment
* 1 - Does the munition have a child submunition
* _shouldFrag Should the specific round fragment <BOOL>
*
* 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

View File

@ -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

View File

@ -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,