ACE3/addons/frag/functions/fnc_dev_addRound.sqf
lambdatiger 3c1e912787 Initial commit:
- Added new ammo cfg types
 - Added new caching functions
 - Added dev functions
 - Transfered core system to vanilla projectile EHs
 - Added stringtable sub categories
 - Reworked fragmenting and spalling to us submunitions
   - Frag
     - Implemented system around chance to hit
     - Switched from hitbox estimation to hitting specific HPs
     - Updated chance to miss method based on solid angle hit chance
     - Split random & targeted frag to their own subfunctions
   - Spall
     - Uses a system of estimated momentum changes to generate spall
2024-01-08 15:22:52 -06:00

114 lines
2.8 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Lambda.Tiger
* This function adds a round to be traced
*
* Arguments:
* 0: Projectile <OBJECT>
* 1: Add projectile event handlers <BOOL>
* 2: Is the round blue <BOOL>
*
* Return Value:
* None
*
* Example:
* [_proj, false, false] call ace_frag_dev_addRound;
*
* Public: No
*/
params [
"_proj",
["_addEHs", true, [false]],
["_sidePlayer", true, [false]]
];
/// track round on each frame
// Create entry in position array from hashmap
private _pID = getObjectID _proj;
if (GVAR(fadeRounds)) then
{
if (_sidePlayer) then
{
GVAR(dev_trackLines) set [_pID, [__FADE_INIT, [getposATL _proj], [0, 0, 1, __FADE_INIT]]];
} else
{
GVAR(dev_trackLines) set [_pID, [__FADE_INIT, [getposATL _proj], [1, 0.5, 0, __FADE_INIT]]];
};
// add fading factor
[LINKFUNC(dev_fadeRound), __FADE_INTERVAL, [_pID]] call CBA_fnc_addPerFrameHandler;
} else
{
if (_sidePlayer) then
{
GVAR(dev_trackLines) set [_pID, [1, [getposATL _proj], [0, 0, 1, 1]]];
} else
{
GVAR(dev_trackLines) set [_pID, [1, [getposATL _proj], [1, 0, 0, 1]]];
};
};
// eventhandler to track round and cleanup when round is "dead"
[
{
if (isGamePaused) exitWith {};
params ["_par", "_h"];
_par params ["_proj"];
if (!alive _proj) exitWith
{
[_h] call CBA_fnc_removePerFrameHandler;
};
private _arr = GVAR(dev_trackLines) getOrDefault [(getObjectID _proj), -1];
if (typeName _arr == "SCALAR") exitWith {};
(_arr#1) pushBack getPosATL _proj;
if (_arr#0 <= 0) exitWith
{
[_h] call CBA_fnc_removePerFrameHandler;
};
},
0,
[_proj]
] call CBA_fnc_addPerFrameHandler;
if (!_addEHs) exitWith {};
// Add hitpart eventHandler
_proj addEventHandler [
"HitPart",
{
params ["_proj", "", "", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1;
_arr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then
{
[_posASL, "green"] call FUNC(dev_sphereDraw);
};
}
];
// Add explode eventHandler
_proj addEventHandler [
"Explode",
{
params ["_proj", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1;
_arr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then
{
[_posASL, "red"] call FUNC(dev_sphereDraw);
};
}
];
// Add deflected eventHandler
_proj addEventHandler [
"Deflected",
{
params ["_proj", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1;
_arr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then
{
[_posASL, "blue"] call FUNC(dev_sphereDraw);
};
}
];