2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-01-01 08:33:08 +00:00
|
|
|
/*
|
|
|
|
* Author: nou, jaynus, PabstMirror
|
2016-02-06 20:12:28 +00:00
|
|
|
* Called from the unified fired EH for all.
|
2016-01-01 08:33:08 +00:00
|
|
|
* If spall is not enabled (default), then cache and only track those that will actually trigger fragmentation.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2016-02-06 20:12:28 +00:00
|
|
|
* None. Parameters inherited from EFUNC(common,firedEH)
|
2016-01-01 08:33:08 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2016-01-01 08:33:08 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [clientFiredBIS-XEH] call ace_frag_fnc_fired
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-11 18:24:19 +00:00
|
|
|
|
2016-02-06 20:12:28 +00:00
|
|
|
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
|
2024-02-05 17:04:24 +00:00
|
|
|
TRACE_10("firedEH:",_unit,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile,_vehicle,_gunner,_turret);
|
2015-01-11 18:24:19 +00:00
|
|
|
|
2016-02-06 20:12:28 +00:00
|
|
|
private _shouldAdd = GVAR(cacheRoundsTypesToTrack) getVariable _ammo;
|
2016-01-01 08:33:08 +00:00
|
|
|
if (isNil "_shouldAdd") then {
|
2016-02-06 20:12:28 +00:00
|
|
|
TRACE_1("no cache for round",_ammo);
|
2016-01-01 08:33:08 +00:00
|
|
|
|
|
|
|
//Read configs and test if it would actually cause a frag, using same logic as FUNC(pfhRound)
|
2016-02-06 20:12:28 +00:00
|
|
|
private _skip = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(skip));
|
|
|
|
private _explosive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive");
|
|
|
|
private _indirectRange = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
|
|
|
|
private _force = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(force));
|
2016-10-26 22:16:31 +00:00
|
|
|
private _fragPower = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirecthit") * (sqrt (getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")));
|
2016-01-01 08:33:08 +00:00
|
|
|
|
|
|
|
_shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}};
|
2018-05-09 15:08:26 +00:00
|
|
|
|
|
|
|
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);
|
2016-02-06 20:12:28 +00:00
|
|
|
GVAR(cacheRoundsTypesToTrack) setVariable [_ammo, _shouldAdd];
|
2016-01-01 08:33:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (_shouldAdd) then {
|
2017-04-11 15:33:56 +00:00
|
|
|
// firedMan will have nil "_gunner", so just check _unit; for firedVehicle we want to check _gunner
|
|
|
|
private _localShooter = if (isNil "_gunner") then {local _unit} else {local _gunner};
|
|
|
|
TRACE_4("",_localShooter,_unit,_ammo,_projectile);
|
|
|
|
if (!_localShooter) exitWith {};
|
2017-12-23 00:34:35 +00:00
|
|
|
if (_weapon == "Put") exitWith {}; // Ignore explosives placed without ace_explosives
|
2017-04-11 15:33:56 +00:00
|
|
|
|
|
|
|
// Skip if less than 0.5 second from last shot
|
|
|
|
if ((CBA_missionTime - (_unit getVariable [QGVAR(lastTrack), -1])) < 0.5) exitWith {};
|
|
|
|
_unit setVariable [QGVAR(lastTrack), CBA_missionTime];
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2016-02-06 20:12:28 +00:00
|
|
|
[_unit, _ammo, _projectile] call FUNC(addPfhRound);
|
2016-01-01 08:33:08 +00:00
|
|
|
};
|