2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-11-02 12:56:59 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
|
|
|
* Inserts entry in the muzzle velocity vs. temperature interpolation table
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* temperature - <NUMBER>
|
|
|
|
* muzzle velocity - <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2016-11-02 12:56:59 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [10, 800] call ace_atragmx_fnc_insert_muzzle_velocity_data
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
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);
|