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-01-08 21:22:52 +00:00
|
|
|
* This function handles creating both random and targeted fragments as well
|
|
|
|
* as handling some of the performance optimizations.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2024-01-18 02:50:20 +00:00
|
|
|
* 0: ASL position of projectile. <ARRAY>
|
|
|
|
* 1: Velocity of projectile <ARRAY>
|
|
|
|
* 2: Projectile CfgAmmo classname <STRING>
|
|
|
|
* 3: getShotParents of projectile at EH <ARRAY>
|
2024-01-13 06:35:22 +00:00
|
|
|
*
|
2024-01-08 21:22:52 +00:00
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2024-02-14 22:50:09 +00:00
|
|
|
* [getPosASL _projectile, velocity _projectile, typeOf _projectile, getShotParents _projectile] call ace_frag_fnc_doFrag;
|
2024-01-08 21:22:52 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2024-01-15 05:08:37 +00:00
|
|
|
TRACE_1("begin doFrag",_this);
|
2024-01-11 01:47:05 +00:00
|
|
|
params [
|
2024-01-18 02:50:20 +00:00
|
|
|
"_posASL",
|
|
|
|
"_velocity",
|
|
|
|
"_ammo",
|
|
|
|
"_shotParents"
|
2024-01-08 21:22:52 +00:00
|
|
|
];
|
2024-01-09 03:41:31 +00:00
|
|
|
|
2024-01-16 21:49:20 +00:00
|
|
|
// Don't let a single object cause all fragmentation events
|
2024-01-15 22:27:29 +00:00
|
|
|
_shotParents params ["_shotParentVic"];
|
2024-01-16 21:49:20 +00:00
|
|
|
if (_shotParentVic getVariable [QGVAR(obj_nextFragTime), -1] > CBA_missionTime) exitWith {
|
2024-01-11 00:51:38 +00:00
|
|
|
TRACE_1("vehicleTimeExit",_shotParentVic);
|
2024-01-09 03:41:31 +00:00
|
|
|
};
|
2024-01-16 21:49:20 +00:00
|
|
|
_shotParentVic setVariable [QGVAR(obj_nextFragTime), CBA_missionTime + ACE_FRAG_HOLDOFF_VEHICLE];
|
2024-01-08 21:22:52 +00:00
|
|
|
|
2024-01-13 06:35:22 +00:00
|
|
|
// Check normal round timeout and adjust _max frags
|
2024-01-15 21:18:42 +00:00
|
|
|
private _timeSinceLastFrag = CBA_missionTime - GVAR(lastFragTime);
|
2024-01-18 02:50:20 +00:00
|
|
|
if (_timeSinceLastFrag < ACE_FRAG_HOLDOFF || {_posASL isEqualTo [0, 0, 0] || _ammo isEqualTo ""}) exitWith {
|
2024-01-15 21:18:42 +00:00
|
|
|
TRACE_3("timeExit",_timeSinceLastFrag,CBA_missionTime,GVAR(lastFragTime));
|
2024-01-09 03:41:31 +00:00
|
|
|
};
|
2024-02-08 23:11:36 +00:00
|
|
|
private _maxFragCount = round linearConversion [ACE_FRAG_COUNT_MIN_TIME, ACE_FRAG_COUNT_MAX_TIME, _timeSinceLastFrag, ACE_FRAG_COUNT_MIN, ACE_FRAG_COUNT_MAX, true];
|
2024-01-15 21:18:42 +00:00
|
|
|
TRACE_3("willFrag",_timeSinceLastFrag,CBA_missionTime,_maxFragCount);
|
2024-01-09 03:41:31 +00:00
|
|
|
|
2024-01-09 20:00:43 +00:00
|
|
|
private _ammoArr = [_ammo] call FUNC(getFragInfo);
|
2024-01-08 21:22:52 +00:00
|
|
|
_ammoArr params ["_fragRange", "_fragVel", "_fragTypes", "_modFragCount"];
|
2024-01-15 21:18:42 +00:00
|
|
|
// For low frag rounds limit the # of frags created
|
2024-02-08 23:11:36 +00:00
|
|
|
if (_modFragCount < ACE_FRAG_LOW_FRAG_MOD_COUNT) then {
|
2024-01-15 21:18:42 +00:00
|
|
|
_maxFragCount = _modFragCount * ACE_FRAG_LOW_FRAG_COEFF;
|
|
|
|
GVAR(lastFragTime) = CBA_missionTime - ACE_FRAG_LOW_FRAG_HOLDOFF_REDUCTION;
|
2024-01-12 07:50:01 +00:00
|
|
|
} else {
|
|
|
|
GVAR(lastFragTime) = CBA_missionTime;
|
|
|
|
};
|
2024-01-13 06:35:22 +00:00
|
|
|
// Offset for ground clearance
|
2024-01-15 21:18:42 +00:00
|
|
|
private _heightATL = (ASLToATL _posASL)#2;
|
|
|
|
if (_heightATL < ACE_FRAG_MIN_GROUND_OFFSET) then {
|
2024-02-14 23:14:43 +00:00
|
|
|
_posASL = _posASL vectorAdd [0, 0, ACE_FRAG_MIN_GROUND_OFFSET - (0 min _heightATL)];
|
2024-01-08 21:22:52 +00:00
|
|
|
};
|
|
|
|
|
2024-02-08 23:11:36 +00:00
|
|
|
TRACE_3("fnc_doFragTargeted IF",_fragRange,_timeSinceLastFrag,GVAR(fragSimComplexity));
|
2024-01-15 21:18:42 +00:00
|
|
|
if (GVAR(fragSimComplexity) != 1 && _fragRange > 3) then {
|
|
|
|
_maxFragCount = _maxFragCount - ([_posASL, _fragVel, _fragRange, _maxFragCount, _fragTypes, _modFragCount, _shotParents] call FUNC(doFragTargeted));
|
2024-01-08 21:22:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-15 21:18:42 +00:00
|
|
|
if (GVAR(fragSimComplexity) > 0) then {
|
|
|
|
[_posASL, _velocity, _heightATL, _fragTypes, _maxFragCount, _shotParents] call FUNC(doFragRandom);
|
2024-01-15 19:42:45 +00:00
|
|
|
};
|