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.
|
2024-03-03 04:46:55 +00:00
|
|
|
* This function will spawn 5, 10, or 15 fragments.
|
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>
|
2024-03-05 04:19:38 +00:00
|
|
|
* 2: Type of fragments to generate <ARRAY>
|
|
|
|
* 3: Remaining fragment budget <NUMBER>
|
|
|
|
* 4: Shot parents <ARRAY>
|
2024-01-13 06:35:22 +00:00
|
|
|
*
|
2024-01-08 21:22:52 +00:00
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2024-03-29 00:33:56 +00:00
|
|
|
* [getPosASL _projectile, 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-05 04:19:38 +00:00
|
|
|
params ["_posASL", "_fragVelocity", "_fragType", "_maxFragCount", "_shotParents"];
|
|
|
|
TRACE_5("doFragRandom",_posASL,_fragVelocity,_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-03-05 04:19:38 +00:00
|
|
|
private _heightATL = (ASLToATL _posASL)#2;
|
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"};
|
2024-04-14 02:20:06 +00:00
|
|
|
case (_heightATL > 4): {"_high"};
|
2024-01-08 21:22:52 +00:00
|
|
|
default {"_mid"};
|
|
|
|
};
|
|
|
|
|
2024-04-14 02:20:06 +00:00
|
|
|
private _type = [QGVAR(random_small_), QGVAR(random_tiny_)] select (_fragType isNotEqualTo [] && {"ace_frag_tiny" == (_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-03-29 00:05:41 +00:00
|
|
|
private _randDir = random 360;
|
|
|
|
_fragSpawner setVectorDirandUp [[0,0,-1], [cos _randDir, sin _randDir,0]];
|
2024-04-14 02:20:06 +00:00
|
|
|
_fragSpawner setVelocity [0, 0, -0.5*_fragVelocity];
|
2024-01-08 21:22:52 +00:00
|
|
|
_fragSpawner setShotParents _shotParents;
|
|
|
|
|
2024-04-14 02:20:06 +00:00
|
|
|
TRACE_2("spawnedRandomFragmenter",typeOf _fragSpawner,getObjectID _fragSpawner);
|
2024-01-10 05:17:08 +00:00
|
|
|
#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
|