ACE3/addons/frag/functions/fnc_initRound.sqf

80 lines
2.1 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", objNull, [objNull]]
];
private _ammo = typeOf _projectile;
if (_ammo isEqualTo "" || {isNull _projectile}) exitWith {
TRACE_2("bad ammo or projectile",_ammo,_projectile);
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",
{
params ["_proj"];
private _shotParents = getShotParents _proj;
private _ammo = typeOf _proj;
2024-01-09 00:06:57 +00:00
if (isServer) then {
[
FUNC(doFrag),
2024-01-10 05:17:08 +00:00
[_this + [_ammo, _shotParents]]
] call CBA_fnc_execNextFrame;
2024-01-09 00:06:57 +00:00
} else {
[
QGVAR(frag_eh),
[_this + [_ammo, _shotParents]]
] call CBA_fnc_serverEvent;
2024-01-09 00:06:57 +00:00
};
}
];
};
private _shouldSpall = _ammo call FUNC(shouldSpall);
if (GVAR(spallEnabled) && {_shouldSpall}) then
{
_projectile addEventHandler [
2024-01-09 00:06:57 +00:00
"HitPart",
{
params ["_proj", "_hitObj", "",
"_posASL", "_vel", "_sNorm", "",
2024-01-09 23:36:36 +00:00
"", "_surfType"
];
private _shotPrnt = getShotParents _proj;
private _ammo = typeOf _proj;
private _vUp = vectorUp _proj;
if (isServer) then {
[
LINKFUNC(doSpallMomentum),
[_proj, _hitObj, _posASL, _vel, _sNorm, _surfType, _ammo, _shotPrnt, _vUp]
] call CBA_fnc_execNextFrame;
} else {
[
QGVAR(spall_eh),
[_proj, _hitObj, _posASL, _vel, _sNorm, _surfType, _ammo, _shotPrnt, _vUp]
] call CBA_fnc_serverEvent;
};
2024-01-09 00:06:57 +00:00
}
];
};