Updated debug dump functions for ease of use

This commit is contained in:
lambdatiger 2024-01-11 17:58:47 -06:00
parent 1cf901703a
commit 40810f282f
2 changed files with 46 additions and 63 deletions

View File

@ -1,81 +1,78 @@
#define DEBUG_MODE_FULL
#include "..\script_component.hpp"
/*
* Author: ACE-Team
*
* Author: ACE-Team, Lambda.Tiger
* This function will dump every ammo config that would generate ace_frag
* fragements that doesn't have
*
* Arguments:
* None
* 0: Log ammo types that wouldn't normall frag
* 1: Force a CSV format
*
* Return Value:
* None
*
* Example:
* call ace_frag_fnc_dev_debugAmmo
* [] call ace_frag_fnc_dev_debugAmmo
*
* Public: No
*/
params [
["_debugMissing", true, [false]],
["_debugForce", false, [false]],
["_debugSkippedFragPower", 30, [0]]
["_csvFormat", false, [false]]
];
diag_log text format ["~~~~~~~~~~~~~Start [%1]~~~~~~~~~~~~~", _this];
private _allMagsConfigs = configProperties [configFile >> "CfgMagazines", "isClass _x", true];
private _allAmmoConfigs = configProperties [configFile >> "cfgAmmo", "isClass _x && !('ace_frag' in configName _x)", true];
private _processedCfgAmmos = [];
if (_csvFormat) then {
diag_log text format ["ammo,gurney_c,gurney_m,gurney_k,gurney_gC,_fragTypes,_fragCount"];
};
private _printCount = 0;
{
private _ammo = toLower getText (_x >> "ammo");
private _ammo = tolower configName _x;
if (_ammo != "" && {!(_ammo in _processedCfgAmmos)}) then {
_processedCfgAmmos pushBack _ammo;
//Ignore mines/bombs
if (_ammo isKindOf "TimeBombCore") exitWith {};
//if (_ammo isKindOf "TimeBombCore") exitWith {};
_ammoConfig = configFile >> "CfgAmmo" >> _ammo;
private _ammoConfig = _x;
private _shoulFrag = [_ammo] call FUNC(shouldFrag);
//Read configs and test if it would actually cause a frag, using same logic as FUNC(pfhRound)
private _skip = getNumber (_ammoConfig >> QGVAR(skip));
private _explosive = getNumber (_ammoConfig >> "explosive");
private _indirectRange = getNumber (_ammoConfig >> "indirectHitRange");
private _force = getNumber (_ammoConfig >> QGVAR(force));
private _fragPower = getNumber (_ammoConfig >> "indirecthit") * (sqrt ((getNumber (_ammoConfig >> "indirectHitRange"))));
private _shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}};
if (_shouldAdd) then {
if (_debugForce && {((getNumber(_ammoConfig >> "hit")) < 5) || {_fragPower < 10}}) then {
diag_log text format ["Ammo [%1] from Mag [%2] - Weak but will still frag!", _ammo, configName _x];
diag_log text format [" - _force=%1,_fragPower=%2", _force, _fragPower];
};
if (_shoulFrag || _debugForce) then {
private _warn = false;
_fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES));
private _fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES));
if (_fragTypes isEqualTo []) then {_warn = true;};
_c = getNumber(_ammoConfig >> QGVAR(CHARGE));
private _c = getNumber(_ammoConfig >> QGVAR(CHARGE));
if (_c == 0) then {_warn = true;};
_m = getNumber(_ammoConfig >> QGVAR(METAL));
private _m = getNumber(_ammoConfig >> QGVAR(METAL));
if (_m == 0) then {_warn = true;};
_k = getNumber(_ammoConfig >> QGVAR(GURNEY_K));
private _k = getNumber(_ammoConfig >> QGVAR(GURNEY_K));
if (_k == 0) then {_warn = true;};
_gC = getNumber(_ammoConfig >> QGVAR(GURNEY_C));
private _gC = getNumber(_ammoConfig >> QGVAR(GURNEY_C));
if (_gC == 0) then {_warn = true;};
if (_debugMissing && {_warn}) then {
diag_log text format ["Ammo [%1] from Mag [%2] MISSING frag configs:", _ammo, configName _x];
diag_log text format [" - _c=%1,_m=%2,_k=%3,_gC=%4,_fragTypes=%5", _c, _m, _k, _gC, _fragTypes];
};
} else {
if ((_fragPower > _debugSkippedFragPower) && {isArray (_ammoConfig >> QGVAR(CLASSES))}) then {
diag_log text format ["Ammo [%1] from Mag [%2] has frag configs but will NOT frag:", _ammo, configName _x];
diag_log text format ["- skip=%1,explosive=%2,indirectHitRange=%3,force=%4,fragPower=%5", _skip, _explosive, _indirectRange, _force, _fragPower];
private _fragCount = getNumber (_ammoConfig >> QGVAR(fragCount));
if (_fragCount == 0) then {_fragCount = 200; _warn = true;};
if (_warn) then {
INC(_printCount);
if (_csvFormat) then {
diag_log text format ["%7,%1,%2,%3,%4,%5,%6", _c, _m, _k, _gC, _fragTypes, _fragCount, _ammo];
} else {
diag_log text format ["Ammo [%1] MISSING frag configs:", _ammo];
diag_log text format [" _c=%1,_m=%2,_k=%3,_gC=%4,_fragTypes=%5,_fragCount=%6", _c, _m, _k, _gC, _fragTypes, _fragCount];
};
};
};
};
} forEach _allMagsConfigs;
} forEach _allAmmoConfigs;
diag_log text format ["~~~~~~~~~~~~~End [%1-%2]~~~~~~~~~~~~~", count _allMagsConfigs, count _processedCfgAmmos];
diag_log text format ["~~~~~~~~~~~~~~End [%1-%2]~~~~~~~~~~~~~~", count _allAmmoConfigs, count _processedCfgAmmos];
diag_log text format ["~~~~~~~~~~~~~~Printed: %1~~~~~~~~~~~", _printCount];

View File

@ -2,7 +2,8 @@
/*
* Author: Lambda.Tiger, based on fnc_dev_debugAmmo by "ACE-Team"
* Dumps all ammo types to see if there's any reason to spawn fragments
* given power, distance, and lifetime of each fragement
* given power, distance, and lifetime of each fragement. Good for grasping
* the values used in shouldFrag to cull non-fragementing rounds
*
* Arguments:
* 0: _dispAll <BOOL> - Display rounds that will never frag (power < 5).
@ -22,7 +23,7 @@ params [["_dispAll", false, [false]], ["_minFrgPowRng", 35, [123]]];
#define DT 0.01
private _allMagsConfigs = configProperties [configFile >> "cfgAmmo", "isClass _x && !('ace' in configName _x)", true];
private _allAmmoConfigs = configProperties [configFile >> "cfgAmmo", "isClass _x && !('ace_frag' in configName _x)", true];
private _processedCfgAmmos = [];
@ -38,21 +39,9 @@ diag_log text "//****************** fragCalcDump Beg ******************//";
// calculating hit range
private _skip = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(skip));
private _force = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(force));
private _explosive = getNumber (configFile >> "cfgAmmo" >> _ammo >> "explosive");
private _indirectHit = getNumber(configFile >> "cfgAmmo" >> _ammo >> "indirectHit");
private _indirectRange = getNumber(configFile >> "cfgAmmo" >> _ammo >> "indirectHitRange");
_shouldFrag = [_ammo] call FUNC(shouldFrag);
_shouldFrag = if (_skip == 1 || (_force == 0 && {_explosive < 0.5 || {_indirectHit < 3
|| {_indirectRange < 5 && _indirectHit < _indirectRange}}})) then {
false;
} else {
true;
};
// Gunery equation from frago
// Gunery equation
private _c = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(CHARGE));
if (_c == 0) then {_c = 1;};
private _m = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(METAL));
@ -62,7 +51,7 @@ diag_log text "//****************** fragCalcDump Beg ******************//";
private _gC = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(GURNEY_C));
if (_gC == 0) then {_gC = 2440;};
private _fragCount = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(fragCount));
if (_fragCount == 0) then {_fragCount = 200; _warn = true};
if (_fragCount == 0) then {_fragCount = 200;};
private _velocity = 0.8 * _gC * sqrt (_c /(_m + _c * _k));
// number of shrapnel to send a direction
@ -71,20 +60,17 @@ diag_log text "//****************** fragCalcDump Beg ******************//";
if (_nSkip || _dispALl) then
{
diag_log text format ["Ammo type: %1", _ammo];
diag_log text format ["Ammo type: %1 | Should frag: %2", _ammo, _shouldFrag];
diag_log text format [" Indirect hit range: %1", _indirectHitRange];
diag_log text format [" Frag sqrtPower: %1", _fragPowerSqrt];
diag_log text format [" Frag range: %1", _fragRange];
diag_log text format [" Frag speed range: %1", _fragPowerSpeedRange];
diag_log text format [" Number frags: %1", _count];
diag_log text " ~~~ Fragments ~~~";
INC(_nPrinted);
};
_processedCfgAmmos pushBack _ammo;
} forEach _allMagsConfigs;
} forEach _allAmmoConfigs;
diag_log text "//****************** fragCalcDump End ******************//";
diag_log text format ["//********************** printed %1 *********************//", _nPrinted];