ACE3/addons/frag/functions/fnc_shouldFrag.sqf

53 lines
1.5 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Lambda.Tiger
* This function checks whether an ammunition type should create fragments.
*
* Arguments:
* 0: Ammo classname <STRING>
*
* Return Value:
* An array containing <ARRAY>
* 0: Should the ammo class generate fragments <BOOL>
* 1: Should the ammo class create submunitions that may fragment <BOOL>
*
* Example:
* "B_556x45_Ball" call ace_frag_fnc_shouldFrag
*
* Public: No
*/
params ["_ammo"];
private _shouldFrag = GVAR(shouldFragCache) get _ammo;
if (!isNil "_shouldFrag") exitWith {_shouldFrag};
_shouldFrag = true;
private _ammoConfig = configFile >> "CfgAmmo" >> _ammo;
private _skip = getNumber (_ammoConfig >> QGVAR(skip));
if (_skip == 1) then {
_shouldFrag = false;
TRACE_1("No frag: skip",_skip);
};
private _force = getNumber (_ammoConfig >> QGVAR(force));
if (_shouldFrag && !_force) then {
private _explosive = getNumber (_ammoConfig >> "explosive");
if (_explosive < 0.5) exitWith {
_shouldFrag = false;
TRACE_3("No frag: _explosive",_skip,_force,_explosive);
};
private _indirectHit = getNumber (_ammoConfig >> "indirectHit");
private _indirectRange = getNumber (_ammoConfig >> "indirectHitRange");
if (_indirectHit * sqrt(_indirectRange) < 35 || _indirectRange < 4.5) then {
_shouldFrag = false;
TRACE_5("No frag",_ammo,_skip,_explosive,_indirectRange,_indirectHit);
};
};
GVAR(shouldFragCache) set [_ammo, _shouldFrag];
_shouldFrag