mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Spall - Don't throw script errors in doSpall if input is bad (#6322)
- Fix #5614 - Don't run tracking siumlation on small calibre ammo that won't ever spall
This commit is contained in:
parent
fa98316424
commit
b1526ccb86
@ -22,7 +22,10 @@ private _initialData = GVAR(spallHPData) select (_hitData select 0);
|
|||||||
_initialData params ["_hpId", "_object", "_roundType", "_round", "_curPos", "_velocity"];
|
_initialData params ["_hpId", "_object", "_roundType", "_round", "_curPos", "_velocity"];
|
||||||
|
|
||||||
private _hpData = (_hitData select 1) select _hitPartDataIndex;
|
private _hpData = (_hitData select 1) select _hitPartDataIndex;
|
||||||
(_hpData select 0) removeEventHandler ["hitPart", _hpId];
|
private _objectHit = _hpData param [0, objNull];
|
||||||
|
TRACE_1("",_objectHit);
|
||||||
|
if ((isNil "_objectHit") || {isNull _objectHit}) exitWith {WARNING_1("Problem with hitPart data - bad object [%1]",_objectHit);};
|
||||||
|
_objectHit removeEventHandler ["hitPart", _hpId];
|
||||||
|
|
||||||
private _caliber = getNumber (configFile >> "CfgAmmo" >> _roundType >> "caliber");
|
private _caliber = getNumber (configFile >> "CfgAmmo" >> _roundType >> "caliber");
|
||||||
private _explosive = getNumber (configFile >> "CfgAmmo" >> _roundType >> "explosive");
|
private _explosive = getNumber (configFile >> "CfgAmmo" >> _roundType >> "explosive");
|
||||||
@ -54,6 +57,7 @@ if (_exit) exitWith {};
|
|||||||
private _unitDir = vectorNormalized _velocity;
|
private _unitDir = vectorNormalized _velocity;
|
||||||
private _pos = _hpData select 3;
|
private _pos = _hpData select 3;
|
||||||
private _spallPos = [];
|
private _spallPos = [];
|
||||||
|
if ((isNil "_pos") || {!(_pos isEqualTypeArray [0,0,0])}) exitWith {WARNING_1("Problem with hitPart data - bad pos [%1]",_pos);};
|
||||||
for "_i" from 0 to 100 do {
|
for "_i" from 0 to 100 do {
|
||||||
private _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i));
|
private _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i));
|
||||||
private _pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1)));
|
private _pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1)));
|
||||||
@ -80,9 +84,9 @@ if (_explosive > 0) then {
|
|||||||
private _gC = getNumber (configFile >> "CfgAmmo" >> _roundType >> QGVAR(GURNEY_C));
|
private _gC = getNumber (configFile >> "CfgAmmo" >> _roundType >> QGVAR(GURNEY_C));
|
||||||
if (_gC == 0) then {_gC = 2440; _warn = true;};
|
if (_gC == 0) then {_gC = 2440; _warn = true;};
|
||||||
|
|
||||||
if (_warn) then {
|
// if (_warn) then {
|
||||||
WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_roundType); //TODO: turn this off when we get closer to release
|
// WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_roundType); //TODO: turn this off when we get closer to release
|
||||||
};
|
// };
|
||||||
|
|
||||||
private _fragPower = (((_m / _c) + _k) ^ - (1 / 2)) * _gC;
|
private _fragPower = (((_m / _c) + _k) ^ - (1 / 2)) * _gC;
|
||||||
_spallPolar set [0, _fragPower * 0.66];
|
_spallPolar set [0, _fragPower * 0.66];
|
||||||
@ -91,6 +95,7 @@ if (_explosive > 0) then {
|
|||||||
// diag_log text format ["SPALL POWER: %1", _spallPolar select 0];
|
// diag_log text format ["SPALL POWER: %1", _spallPolar select 0];
|
||||||
private _spread = 15 + (random 25);
|
private _spread = 15 + (random 25);
|
||||||
private _spallCount = 5 + (random 10);
|
private _spallCount = 5 + (random 10);
|
||||||
|
TRACE_1("",_spallCount);
|
||||||
for "_i" from 1 to _spallCount do {
|
for "_i" from 1 to _spallCount do {
|
||||||
private _elev = ((_spallPolar select 2) - _spread) + (random (_spread * 2));
|
private _elev = ((_spallPolar select 2) - _spread) + (random (_spread * 2));
|
||||||
private _dir = ((_spallPolar select 1) - _spread) + (random (_spread * 2));
|
private _dir = ((_spallPolar select 1) - _spread) + (random (_spread * 2));
|
||||||
|
@ -24,19 +24,6 @@ private _shouldAdd = GVAR(cacheRoundsTypesToTrack) getVariable _ammo;
|
|||||||
if (isNil "_shouldAdd") then {
|
if (isNil "_shouldAdd") then {
|
||||||
TRACE_1("no cache for round",_ammo);
|
TRACE_1("no cache for round",_ammo);
|
||||||
|
|
||||||
if (!EGVAR(common,settingsInitFinished)) exitWith {
|
|
||||||
//Just incase fired event happens before settings init, don't want to set cache wrong if spall setting changes
|
|
||||||
TRACE_1("Settings not init yet - exit without setting cache",_ammo);
|
|
||||||
_shouldAdd = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (GVAR(spallEnabled)) exitWith {
|
|
||||||
//Always want to run whenever spall is enabled?
|
|
||||||
_shouldAdd = true;
|
|
||||||
TRACE_2("SettingCache[spallEnabled]",_ammo,_shouldAdd);
|
|
||||||
GVAR(cacheRoundsTypesToTrack) setVariable [_ammo, _shouldAdd];
|
|
||||||
};
|
|
||||||
|
|
||||||
//Read configs and test if it would actually cause a frag, using same logic as FUNC(pfhRound)
|
//Read configs and test if it would actually cause a frag, using same logic as FUNC(pfhRound)
|
||||||
private _skip = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(skip));
|
private _skip = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(skip));
|
||||||
private _explosive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive");
|
private _explosive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive");
|
||||||
@ -45,7 +32,15 @@ if (isNil "_shouldAdd") then {
|
|||||||
private _fragPower = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirecthit") * (sqrt (getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")));
|
private _fragPower = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirecthit") * (sqrt (getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")));
|
||||||
|
|
||||||
_shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}};
|
_shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}};
|
||||||
TRACE_6("SettingCache[willFrag?]",_skip,_explosive,_indirectRange,_force,_fragPower,_shouldAdd);
|
|
||||||
|
if (GVAR(spallEnabled) && {!_shouldAdd}) then {
|
||||||
|
private _caliber = getNumber (configFile >> "CfgAmmo" >> _ammo >> "caliber");
|
||||||
|
if !(_caliber >= 2.5 || {(_explosive > 0 && {_indirectRange >= 1})}) exitWith {}; // from check in doSpall: line 34
|
||||||
|
TRACE_1("Won't frag, but will spall",_caliber);
|
||||||
|
_shouldAdd = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
TRACE_6("Setting Cache",_skip,_explosive,_indirectRange,_force,_fragPower,_shouldAdd);
|
||||||
GVAR(cacheRoundsTypesToTrack) setVariable [_ammo, _shouldAdd];
|
GVAR(cacheRoundsTypesToTrack) setVariable [_ammo, _shouldAdd];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Author: ACE-Team
|
* Author: ACE-Team
|
||||||
*
|
* Handles the HitPart event
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* None
|
* None
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Author: ACE-Team
|
* Author: ACE-Team
|
||||||
*
|
* Add HitPart EventHandler to objects in the projectile's path
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* None
|
* None
|
||||||
|
Loading…
Reference in New Issue
Block a user