2024-01-09 00:06:57 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
/*
|
|
|
|
* Author: Lambda.Tiger
|
2024-01-09 03:38:15 +00:00
|
|
|
* This function adds rounds using their config init EH
|
|
|
|
|
2024-01-09 00:06:57 +00:00
|
|
|
* Arguments:
|
2024-01-09 03:38:15 +00:00
|
|
|
* 0: _projectile <OBJECT> - The object created
|
2024-01-09 00:06:57 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2024-01-09 03:38:15 +00:00
|
|
|
* None
|
2024-01-09 00:06:57 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2024-01-09 03:38:15 +00:00
|
|
|
* [_proj] call ace_frag_fnc_initRound;
|
2024-01-09 00:06:57 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2024-01-09 03:55:02 +00:00
|
|
|
params [
|
2024-01-09 23:25:09 +00:00
|
|
|
["_projectile", objNull, [objNull]]
|
2024-01-09 03:55:02 +00:00
|
|
|
];
|
2024-01-09 03:38:15 +00:00
|
|
|
|
|
|
|
private _ammo = typeOf _projectile;
|
2024-01-09 03:55:02 +00:00
|
|
|
if (_ammo isEqualTo "" || {isNull _projectile}) exitWith {
|
2024-01-09 03:38:15 +00:00
|
|
|
TRACE_2("bad ammo or projectile",_ammo,_projectile);
|
2024-01-09 00:06:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private _shouldFrag = _ammo call FUNC(shouldFrag);
|
2024-01-09 03:38:15 +00:00
|
|
|
_shouldFrag params ["_doFrag"];
|
2024-01-09 00:06:57 +00:00
|
|
|
|
|
|
|
if (_doFrag) then {
|
|
|
|
// wait for frag damage to kill units before spawning fragments
|
2024-01-09 03:55:02 +00:00
|
|
|
_projectile addEventHandler [
|
2024-01-09 23:25:09 +00:00
|
|
|
"Explode",
|
|
|
|
{
|
|
|
|
params ["_proj"];
|
|
|
|
private _shotParents = getShotParents _proj;
|
|
|
|
private _ammo = typeOf _proj;
|
2024-01-09 00:06:57 +00:00
|
|
|
if (isServer) then {
|
2024-01-09 23:25:09 +00:00
|
|
|
[
|
|
|
|
FUNC(doFrag),
|
2024-01-10 23:41:13 +00:00
|
|
|
_this + [_ammo, _shotParents]
|
2024-01-09 23:25:09 +00:00
|
|
|
] call CBA_fnc_execNextFrame;
|
2024-01-09 00:06:57 +00:00
|
|
|
} else {
|
2024-01-09 23:25:09 +00:00
|
|
|
[
|
|
|
|
QGVAR(frag_eh),
|
2024-01-10 23:41:13 +00:00
|
|
|
_this + [_ammo, _shotParents]
|
2024-01-09 23:25:09 +00:00
|
|
|
] call CBA_fnc_serverEvent;
|
2024-01-09 00:06:57 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private _shouldSpall = _ammo call FUNC(shouldSpall);
|
|
|
|
|
|
|
|
if (GVAR(spallEnabled) && {_shouldSpall}) then
|
2024-01-09 03:38:15 +00:00
|
|
|
{
|
2024-01-09 23:25:09 +00:00
|
|
|
_projectile addEventHandler [
|
2024-01-09 00:06:57 +00:00
|
|
|
"HitPart",
|
|
|
|
{
|
2024-01-10 23:41:13 +00:00
|
|
|
params ["_proj", "_hitObj", "",
|
|
|
|
"_posASL", "_vel", "_sNorm", "",
|
|
|
|
"", "_surfType"
|
|
|
|
];
|
2024-01-09 23:25:09 +00:00
|
|
|
private _shotPrnt = getShotParents _proj;
|
|
|
|
private _ammo = typeOf _proj;
|
2024-01-10 23:41:13 +00:00
|
|
|
private _vUp = vectorUp _proj;
|
2024-01-09 03:38:15 +00:00
|
|
|
if (isServer) then {
|
2024-01-09 23:25:09 +00:00
|
|
|
[
|
2024-01-10 21:47:50 +00:00
|
|
|
LINKFUNC(doSpall),
|
2024-01-10 01:03:12 +00:00
|
|
|
[_proj, _hitObj, _posASL, _vel, _sNorm, _surfType, _ammo, _shotPrnt, _vUp]
|
2024-01-09 23:25:09 +00:00
|
|
|
] call CBA_fnc_execNextFrame;
|
2024-01-09 03:38:15 +00:00
|
|
|
} else {
|
2024-01-09 23:25:09 +00:00
|
|
|
[
|
|
|
|
QGVAR(spall_eh),
|
2024-01-10 01:03:12 +00:00
|
|
|
[_proj, _hitObj, _posASL, _vel, _sNorm, _surfType, _ammo, _shotPrnt, _vUp]
|
2024-01-09 23:25:09 +00:00
|
|
|
] call CBA_fnc_serverEvent;
|
2024-01-09 03:38:15 +00:00
|
|
|
};
|
2024-01-09 00:06:57 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|