2024-01-11 20:01:50 +00:00
|
|
|
#include "..\script_component.hpp"
|
2024-01-08 21:22:52 +00:00
|
|
|
/*
|
|
|
|
* Author: Lambda.Tiger
|
2024-01-18 01:40:12 +00:00
|
|
|
* This function initialize projectile tracking of a round so that it's path
|
|
|
|
* can be drawn in debug mode. It may optionally include hit / explode /
|
|
|
|
* deflected event handlers that spawn color coded spheres on each event,
|
|
|
|
* green / red / blue, respectively.
|
2024-01-08 21:22:52 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2024-02-16 02:59:58 +00:00
|
|
|
* 0: Projectile to be tracked <OBJECT>
|
|
|
|
* 1: Add projectile hit/explode/defelceted event handlers <BOOL> (default: true)
|
|
|
|
* 2: Should the round track be blue. True results in blue traces, false in red <BOOL> (default: true)
|
2024-01-08 21:22:52 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2024-02-14 22:50:09 +00:00
|
|
|
* Nothing Useful
|
2024-01-08 21:22:52 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2024-03-29 00:33:56 +00:00
|
|
|
* [_projectile, false, false] call ace_frag_dev_addRound
|
2024-01-08 21:22:52 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2024-01-18 01:40:12 +00:00
|
|
|
|
2024-01-08 21:22:52 +00:00
|
|
|
params [
|
2024-01-15 19:13:59 +00:00
|
|
|
"_projectile",
|
2024-01-18 02:50:20 +00:00
|
|
|
["_addProjectileEventHandlers", true],
|
2024-02-16 02:59:58 +00:00
|
|
|
["_isTraceBlue", true]
|
2024-01-08 21:22:52 +00:00
|
|
|
];
|
|
|
|
|
2024-02-16 02:59:58 +00:00
|
|
|
if (_isTraceBlue) then {
|
2024-02-14 22:50:09 +00:00
|
|
|
GVAR(dev_trackLines) set [getObjectID _projectile, [[getPosATL _projectile], [0, 0, 1, 1]]];
|
2024-01-15 19:13:59 +00:00
|
|
|
} else {
|
2024-02-14 22:50:09 +00:00
|
|
|
GVAR(dev_trackLines) set [getObjectID _projectile, [[getPosATL _projectile], [1, 0, 0, 1]]];
|
2024-01-08 21:22:52 +00:00
|
|
|
};
|
2024-01-18 01:40:12 +00:00
|
|
|
|
2024-01-15 20:39:41 +00:00
|
|
|
// event handler to track round and cleanup when round is "dead"
|
2024-01-08 21:22:52 +00:00
|
|
|
[
|
|
|
|
{
|
2024-02-17 19:04:19 +00:00
|
|
|
if (isGamePaused || accTime == 0) exitWith {};
|
2024-02-14 23:56:05 +00:00
|
|
|
params ["_projectile", "_handle"];
|
2024-02-16 02:59:58 +00:00
|
|
|
|
2024-01-15 19:13:59 +00:00
|
|
|
if (!alive _projectile) exitWith {
|
2024-03-29 00:59:49 +00:00
|
|
|
_handle call CBA_fnc_removePerFrameHandler;
|
2024-01-08 21:22:52 +00:00
|
|
|
};
|
2024-02-16 02:59:58 +00:00
|
|
|
|
2024-02-14 23:56:05 +00:00
|
|
|
private _projectileArray = GVAR(dev_trackLines) get (getObjectID _projectile);
|
2024-02-16 02:59:58 +00:00
|
|
|
|
2024-02-14 23:56:05 +00:00
|
|
|
if (isNil "_projectileArray") exitWith {
|
2024-03-29 00:59:49 +00:00
|
|
|
_handle call CBA_fnc_removePerFrameHandler;
|
2024-02-14 23:56:05 +00:00
|
|
|
};
|
2024-02-16 02:59:58 +00:00
|
|
|
|
2024-01-15 19:13:59 +00:00
|
|
|
(_projectileArray#0) pushBack getPosATL _projectile;
|
2024-01-08 21:22:52 +00:00
|
|
|
},
|
|
|
|
0,
|
2024-02-14 23:56:05 +00:00
|
|
|
_projectile
|
2024-01-08 21:22:52 +00:00
|
|
|
] call CBA_fnc_addPerFrameHandler;
|
|
|
|
|
2024-01-15 19:13:59 +00:00
|
|
|
if (!_addProjectileEventHandlers) exitWith {};
|
2024-01-08 21:22:52 +00:00
|
|
|
|
2024-01-15 19:13:59 +00:00
|
|
|
_projectile addEventHandler [
|
2024-01-08 21:22:52 +00:00
|
|
|
"HitPart",
|
|
|
|
{
|
2024-01-15 19:13:59 +00:00
|
|
|
params ["_projectile", "", "", "_posASL"];
|
|
|
|
private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
|
|
|
|
_posArr pushBack ASLtoATL _posASL;
|
|
|
|
if (GVAR(dbgSphere)) then {
|
2024-01-08 21:22:52 +00:00
|
|
|
[_posASL, "green"] call FUNC(dev_sphereDraw);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-01-15 19:13:59 +00:00
|
|
|
_projectile addEventHandler [
|
2024-01-08 21:22:52 +00:00
|
|
|
"Explode",
|
|
|
|
{
|
2024-01-15 19:13:59 +00:00
|
|
|
params ["_projectile", "_posASL"];
|
|
|
|
private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
|
|
|
|
_posArr pushBack ASLtoATL _posASL;
|
|
|
|
if (GVAR(dbgSphere)) then {
|
2024-01-08 21:22:52 +00:00
|
|
|
[_posASL, "red"] call FUNC(dev_sphereDraw);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-01-15 19:13:59 +00:00
|
|
|
_projectile addEventHandler [
|
2024-01-08 21:22:52 +00:00
|
|
|
"Deflected",
|
|
|
|
{
|
2024-01-15 19:13:59 +00:00
|
|
|
params ["_projectile", "_posASL"];
|
|
|
|
private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
|
|
|
|
_posArr pushBack ASLtoATL _posASL;
|
|
|
|
if (GVAR(dbgSphere)) then {
|
2024-01-08 21:22:52 +00:00
|
|
|
[_posASL, "blue"] call FUNC(dev_sphereDraw);
|
|
|
|
};
|
|
|
|
}
|
2024-01-15 19:13:59 +00:00
|
|
|
];
|