ACE3/addons/atragmx/functions/fnc_insert_muzzle_velocity_data.sqf
ulteq 3f4564605b ATragMX - Implemented missing features
* Muzzle Velocity vs. Temperature Interpolation
* C1 Ballistic Coefficient vs. Distance Interpolation
* Coriolis and Spin drift output
* Options menu
* Truing Drop
---------------------------------
* Overworked default gun profiles
---------------------------------
* Fixed the Cancel buttons on the gun-, atmosphere- and target columns.
* Fixed some muzzle velocity entries in the default gun list.
* Fixed divide by zero error in the target range estimator
2016-11-07 16:40:34 +01:00

42 lines
1.1 KiB
Plaintext

/*
* Author: Ruthberg
* Inserts entry in the muzzle velocity vs. temperature interpolation table
*
* Arguments:
* temperature - <NUMBER>
* muzzle velocity - <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [10, 800] call ace_atragmx_fnc_insert_muzzle_velocity_data
*
* Public: No
*/
#include "script_component.hpp"
params ["_temperature", "_muzzleVelocity"];
private _insertIndex = 0;
private _minDiff = 1000;
{
if (_minDiff > 0 && {(((GVAR(workingMemory) select 18) select _forEachIndex) select 1) == 0}) then {
_insertIndex = _forEachIndex;
_minDiff = 0;
};
private _t = ((GVAR(workingMemory) select 18) select _forEachIndex) select 0;
private _diff = abs(_temperature - _t);
if (_diff == 0) exitWith {
_insertIndex = _forEachIndex;
};
if (_diff < _minDiff) then {
_insertIndex = _forEachIndex;
_minDiff = _diff;
};
} forEach (GVAR(workingMemory) select 18);
(GVAR(workingMemory) select 18) set [_insertIndex, [_temperature, 0 max _muzzleVelocity min 1400]];
call FUNC(update_muzzle_velocity_data);