2024-01-11 20:01:50 +00:00
|
|
|
#include "..\script_component.hpp"
|
2024-01-09 00:06:57 +00:00
|
|
|
/*
|
|
|
|
* Author: Lambda.Tiger
|
2024-01-18 02:46:15 +00:00
|
|
|
* This function adds projectile explode and hitPart event handlers and is
|
|
|
|
* intended to be called from an projectile config init event handler.
|
|
|
|
*
|
2024-01-09 00:06:57 +00:00
|
|
|
* Arguments:
|
2024-01-18 02:46:15 +00:00
|
|
|
* 0: The projectile to be initialized <OBJECT>
|
2024-01-13 06:35:22 +00:00
|
|
|
*
|
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-18 03:39:54 +00:00
|
|
|
* [_projectile] call ace_frag_fnc_initRound;
|
2024-01-09 00:06:57 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2024-01-18 00:53:45 +00:00
|
|
|
|
|
|
|
TRACE_1("ACE_Frag rndInit",_this);
|
2024-02-16 03:03:12 +00:00
|
|
|
if (!isServer) exitWith {};
|
2024-03-03 04:33:40 +00:00
|
|
|
params ["_projectile"];
|
2024-01-18 00:53:45 +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
|
|
|
};
|
|
|
|
|
2024-01-18 00:53:45 +00:00
|
|
|
if (GVAR(enabled) && {_ammo call FUNC(shouldFrag)}) then {
|
2024-01-09 03:55:02 +00:00
|
|
|
_projectile addEventHandler [
|
2024-01-09 23:25:09 +00:00
|
|
|
"Explode",
|
|
|
|
{
|
2024-01-18 03:39:54 +00:00
|
|
|
params ["_projectile", "_posASL", "_velocity"];
|
2024-01-18 05:13:31 +00:00
|
|
|
private _shotParents = _projectile getVariable [QGVAR(shotParent), getShotParents _projectile];
|
2024-01-18 03:39:54 +00:00
|
|
|
private _ammo = typeOf _projectile;
|
2024-01-11 01:47:05 +00:00
|
|
|
// wait for frag damage to kill units before spawning fragments
|
2024-01-11 21:44:15 +00:00
|
|
|
[
|
|
|
|
FUNC(doFrag),
|
2024-01-18 02:46:15 +00:00
|
|
|
[_posASL, _velocity, _ammo, _shotParents]
|
2024-01-11 21:44:15 +00:00
|
|
|
] call CBA_fnc_execNextFrame;
|
2024-01-13 06:35:22 +00:00
|
|
|
if (GVAR(reflectionsEnabled)) then {
|
|
|
|
[_posASL, _ammo] call FUNC(doReflections);
|
|
|
|
};
|
2024-01-09 00:06:57 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-01-18 00:53:45 +00:00
|
|
|
if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then {
|
2024-01-09 23:25:09 +00:00
|
|
|
_projectile addEventHandler [
|
2024-01-09 00:06:57 +00:00
|
|
|
"HitPart",
|
|
|
|
{
|
2024-02-16 03:03:12 +00:00
|
|
|
params ["_projectile", "_hitObject", "", "_posASL", "_velocity", "_surfNorm", "", "", "_surfType"];
|
2024-03-03 05:55:32 +00:00
|
|
|
// starting v2.18 it may be faster to use the instigator parameter, the same as the second entry shotParents, to recreate _shotParent
|
|
|
|
// The "explode" EH does not get the same parameter
|
2024-01-18 03:39:54 +00:00
|
|
|
private _shotParent = getShotParents _projectile;
|
|
|
|
private _ammo = typeOf _projectile;
|
|
|
|
private _vectorUp = vectorUp _projectile;
|
2024-01-15 05:08:37 +00:00
|
|
|
/*
|
2024-02-16 03:03:12 +00:00
|
|
|
* Wait a frame to see what happens to the round, may result in
|
2024-01-15 05:08:37 +00:00
|
|
|
* multiple hits / slowdowns getting shunted to the first hit
|
|
|
|
*/
|
2024-01-11 21:44:15 +00:00
|
|
|
[
|
2024-01-15 00:46:52 +00:00
|
|
|
FUNC(doSpall),
|
2024-01-18 03:39:54 +00:00
|
|
|
[_projectile, _hitObject, _posASL, _velocity, _surfNorm, _surfType, _ammo, _shotParent, _vectorUp]
|
2024-01-11 22:13:02 +00:00
|
|
|
] call CBA_fnc_execNextFrame;
|
|
|
|
}
|
2024-01-09 00:06:57 +00:00
|
|
|
];
|
2024-01-15 00:46:52 +00:00
|
|
|
};
|
2024-01-15 05:08:37 +00:00
|
|
|
#ifdef DEBUG_MODE_DRAW
|
2024-02-14 22:50:09 +00:00
|
|
|
if (GVAR(debugOptions) && {_ammo call FUNC(shouldFrag) || {_ammo call FUNC(shouldSpall)}}) then {
|
2024-01-15 05:08:37 +00:00
|
|
|
[_projectile, "red", true] call FUNC(dev_trackObj);
|
|
|
|
};
|
|
|
|
#endif
|
2024-01-18 02:46:15 +00:00
|
|
|
TRACE_1("initExit",_ammo);
|