2024-01-11 20:01:50 +00:00
|
|
|
#include "..\script_component.hpp"
|
2024-01-08 21:22:52 +00:00
|
|
|
/*
|
2024-01-09 17:54:52 +00:00
|
|
|
* Author: Jaynus, NouberNou, Lambda.Tiger
|
2024-03-03 01:17:38 +00:00
|
|
|
* This function creates fragments randomly spreading out from an explosion.
|
|
|
|
* This function will spawn 5, 10, or 15 fragments depending on the
|
2024-01-13 06:35:22 +00:00
|
|
|
*
|
2024-01-08 21:22:52 +00:00
|
|
|
* Arguments:
|
2024-02-16 03:03:12 +00:00
|
|
|
* 0: Position (posASL) of fragmenting projectile <ARRAY>
|
|
|
|
* 1: Velocity of the fragmenting projectile <ARRAY>
|
|
|
|
* 2: Height (AGL) of the fragmenting projectile <NUMBER>
|
|
|
|
* 3: Type of fragments to generate <ARRAY>
|
|
|
|
* 4: Remaining fragment budget <NUMBER>
|
|
|
|
* 5: Shot parents <ARRAY>
|
2024-01-13 06:35:22 +00:00
|
|
|
*
|
2024-01-08 21:22:52 +00:00
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2024-01-15 19:42:45 +00:00
|
|
|
* [getPosASL _proj, 800, 50, 50, [], 1, [player, player]] call ace_frag_fnc_doFragRandom;
|
2024-01-08 21:22:52 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2024-03-01 18:51:21 +00:00
|
|
|
|
2024-03-03 01:17:38 +00:00
|
|
|
params ["_posASL", "_fragVelocity", "_heightATL", "_fragType", "_maxFragCount", "_shotParents"];
|
|
|
|
TRACE_6("doFragRandom",_posASL,_fragVelocity,_heightATL,_fragType,_maxFragCount,_shotParents);
|
2024-01-08 21:22:52 +00:00
|
|
|
|
2024-01-18 02:50:20 +00:00
|
|
|
// See CfgAmmoFragSpawner for different frag types
|
2024-01-08 21:22:52 +00:00
|
|
|
private _hMode = switch (true) do {
|
2024-03-03 01:17:38 +00:00
|
|
|
case (_heightATL > 10): {"_top"};
|
|
|
|
case (_heightATL > 5): {"_hi"};
|
2024-01-08 21:22:52 +00:00
|
|
|
default {"_mid"};
|
|
|
|
};
|
|
|
|
|
2024-02-08 23:11:36 +00:00
|
|
|
private _type = [QGVAR(def_small_), QGVAR(def_tiny_)] select (_fragType isNotEqualTo [] && {"ace_frag_tiny" isEqualTo (_fragType#0)});
|
2024-01-08 21:22:52 +00:00
|
|
|
|
2024-01-15 21:18:42 +00:00
|
|
|
_maxFragCount = switch (true) do {
|
|
|
|
case (_maxFragCount <= 5): {"5"};
|
|
|
|
case (_maxFragCount <= 10): {"10"};
|
2024-01-08 21:22:52 +00:00
|
|
|
default {"15"};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Spawn the fragment spawner
|
2024-01-15 21:18:42 +00:00
|
|
|
private _fragSpawner = createVehicle [_type + _maxFragCount + _hMode, ASLToATL _posASL, [], 0, "CAN_COLLIDE"];
|
2024-01-09 03:41:52 +00:00
|
|
|
_fragSpawner setVectorDirandUp [[0,0,1], [1,0,0]];
|
2024-01-15 19:42:45 +00:00
|
|
|
_fragSpawner setVelocity _fragVelocity;
|
2024-01-08 21:22:52 +00:00
|
|
|
_fragSpawner setShotParents _shotParents;
|
|
|
|
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
2024-03-03 04:28:41 +00:00
|
|
|
systemChat ("frag random objectID: " + getObjectID _proj);
|
2024-01-10 05:17:08 +00:00
|
|
|
#endif
|
|
|
|
#ifdef DEBUG_MODE_DRAW
|
2024-01-10 06:55:33 +00:00
|
|
|
_fragSpawner addEventHandler [
|
|
|
|
"SubmunitionCreated",
|
|
|
|
{
|
|
|
|
params ["","_subProj"];
|
|
|
|
[_subProj, "green", true] call FUNC(dev_trackObj);
|
|
|
|
}
|
|
|
|
];
|
|
|
|
if (GVAR(dbgSphere)) then {
|
2024-01-11 00:51:38 +00:00
|
|
|
[_posASL] call FUNC(dev_sphereDraw);
|
2024-01-10 06:55:33 +00:00
|
|
|
};
|
2024-01-15 19:42:45 +00:00
|
|
|
#endif
|