ACE3/addons/frag/functions/fnc_initRound.sqf

58 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-01-09 00:06:57 +00:00
#include "script_component.hpp"
/*
* Author: Lambda.Tiger
* This function adds rounds using their config init EH
2024-01-09 00:06:57 +00:00
* Arguments:
* 0: _projectile <OBJECT> - The object created
2024-01-09 00:06:57 +00:00
*
* Return Value:
* None
2024-01-09 00:06:57 +00:00
*
* Example:
* [_proj] call ace_frag_fnc_initRound;
2024-01-09 00:06:57 +00:00
*
* Public: No
*/
params ["_projectile"];
private _ammo = typeOf _projectile;
if (isNil "_ammo" ||
2024-01-09 00:06:57 +00:00
{_ammo isEqualTo "" ||
{isNil "_projectile" ||
{isNull _projectile}}}) exitWith {
TRACE_2("bad ammo or projectile",_ammo,_projectile);
2024-01-09 00:06:57 +00:00
};
2024-01-09 00:06:57 +00:00
private _shouldFrag = _ammo call FUNC(shouldFrag);
_shouldFrag params ["_doFrag"];
2024-01-09 00:06:57 +00:00
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;
};
}
];
};
private _shouldSpall = _ammo call FUNC(shouldSpall);
if (GVAR(spallEnabled) && {_shouldSpall}) then
{
_projectile addEventHandler [
2024-01-09 00:06:57 +00:00
"HitPart",
{
if (isServer) then {
[LINKFUNC(doSpallMomentum), _this] call CBA_fnc_execNextFrame;
} else {
[QGVAR(spall_eh), [_this]] call CBA_fnc_serverEvent;
};
2024-01-09 00:06:57 +00:00
}
];
};