ACE3/addons/frag/functions/fnc_fired.sqf
lambdatiger 3c1e912787 Initial commit:
- Added new ammo cfg types
 - Added new caching functions
 - Added dev functions
 - Transfered core system to vanilla projectile EHs
 - Added stringtable sub categories
 - Reworked fragmenting and spalling to us submunitions
   - Frag
     - Implemented system around chance to hit
     - Switched from hitbox estimation to hitting specific HPs
     - Updated chance to miss method based on solid angle hit chance
     - Split random & targeted frag to their own subfunctions
   - Spall
     - Uses a system of estimated momentum changes to generate spall
2024-01-08 15:22:52 -06:00

60 lines
1.8 KiB
Plaintext

#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 {
WARNING("bad ammo or projectile");
};
/******* _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(enSubMunit)> 0}) then {
_projectile addEventHandler ["SubmunitionCreated", {_this call FUNC(submunition)}];
};
private _shouldSpall = _ammo call FUNC(shouldSpall);
if (GVAR(spallEnabled) && {_shouldSpall}) then
{_projectile addEventHandler [
"HitPart",
{
[LINKFUNC(doSpallMomentum), _this] call CBA_fnc_execNextFrame;
[QGVAR(spall_eh), [_this]] call CBA_fnc_serverEvent;
}
];
};