2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-07-10 22:09:20 +00:00
|
|
|
/*
|
|
|
|
* Author: joko // Jonas
|
2016-01-16 14:04:22 +00:00
|
|
|
* Cache the shot data for a given weapon/mag/ammo combination.
|
|
|
|
* Will use the config that has the highest priority.
|
2015-07-10 22:09:20 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-08-30 05:35:58 +00:00
|
|
|
* 0: Weapon <STRING>
|
|
|
|
* 1: Magazine <STRING>
|
|
|
|
* 2: Ammo <STRING>
|
2015-07-10 22:09:20 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2016-01-16 14:04:22 +00:00
|
|
|
* Shot Config <ARRAY>:
|
2015-08-30 05:35:58 +00:00
|
|
|
* 0: Angle <Number>
|
|
|
|
* 1: Range <Number>
|
|
|
|
* 2: Damage <Number>
|
2022-08-01 17:32:02 +00:00
|
|
|
* 3: Offset <Number>
|
2015-07-10 22:09:20 +00:00
|
|
|
*
|
2021-10-30 21:42:03 +00:00
|
|
|
* Example:
|
2022-08-01 17:32:02 +00:00
|
|
|
* ["cannon_125mm","Sh_125mm_APFSDS_T_Green","24Rnd_125mm_APFSDS_T_Green"] call ace_overpressure_fnc_getOverPressureValues
|
2016-01-16 14:04:22 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2015-07-10 22:09:20 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-30 21:40:53 +00:00
|
|
|
params ["_weapon", "_ammo", "_magazine"];
|
2015-08-30 21:10:03 +00:00
|
|
|
TRACE_3("Parameter",_weapon,_magazine,_ammo);
|
2015-08-30 05:35:58 +00:00
|
|
|
|
2022-08-01 17:32:02 +00:00
|
|
|
// Check cache for weapon/ammo/mag combo
|
|
|
|
private _return = GVAR(cacheHash) get _this;
|
|
|
|
if (!isNil "_return") exitWith {
|
|
|
|
TRACE_3("CacheHit",_weapon,_magazine,_ammo);
|
|
|
|
_return
|
|
|
|
};
|
|
|
|
|
2015-08-30 05:35:58 +00:00
|
|
|
// get Priority Array from Config
|
2016-01-16 14:04:22 +00:00
|
|
|
private _array = [
|
2015-11-06 19:02:54 +00:00
|
|
|
getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(priority)),
|
|
|
|
getNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(priority)),
|
|
|
|
getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(priority))
|
2015-08-30 05:35:58 +00:00
|
|
|
];
|
|
|
|
|
2016-01-16 14:04:22 +00:00
|
|
|
(_array call CBA_fnc_findMax) params ["", ["_indexOfMaxPriority", 0, [0]]];
|
2015-09-06 17:34:46 +00:00
|
|
|
|
2016-01-16 14:04:22 +00:00
|
|
|
TRACE_2("Priority Array",_array,_indexOfMaxPriority);
|
2015-09-06 17:34:46 +00:00
|
|
|
|
2015-08-30 05:35:58 +00:00
|
|
|
// create the Config entry Point
|
2016-01-16 14:04:22 +00:00
|
|
|
private _config = [
|
2015-08-30 05:35:58 +00:00
|
|
|
(configFile >> "CfgWeapons" >> _weapon),
|
|
|
|
(configFile >> "CfgMagazines" >> _magazine),
|
2015-08-30 20:59:27 +00:00
|
|
|
(configFile >> "CfgAmmo" >> _ammo)
|
2016-01-16 14:04:22 +00:00
|
|
|
] select _indexOfMaxPriority;
|
2015-08-30 21:10:03 +00:00
|
|
|
TRACE_1("ConfigPath",_config);
|
2015-08-30 05:35:58 +00:00
|
|
|
|
2022-08-01 17:32:02 +00:00
|
|
|
// get the Variables out of the Configs and populate return array with them
|
|
|
|
_return = [
|
2015-08-30 05:35:58 +00:00
|
|
|
(getNumber (_config >> QGVAR(angle))),
|
2024-06-20 20:30:33 +00:00
|
|
|
(getNumber (_config >> QGVAR(range))),
|
2022-08-01 17:32:02 +00:00
|
|
|
(getNumber (_config >> QGVAR(damage))),
|
|
|
|
(getNumber (_config >> QGVAR(offset)))
|
2015-08-30 05:35:58 +00:00
|
|
|
];
|
2016-01-16 14:04:22 +00:00
|
|
|
|
2022-08-01 17:32:02 +00:00
|
|
|
GVAR(cacheHash) set [_this, _return];
|
|
|
|
TRACE_2("Return",_this,_return);
|
2015-08-30 05:35:58 +00:00
|
|
|
|
|
|
|
_return
|