2016-11-02 12:56:59 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
|
|
|
* Recalculates the muzzle velocity based on the muzzle velocity vs. temperature interpolation input
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* parse input <BOOL>
|
|
|
|
* update display <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2016-11-02 12:56:59 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* call ace_atragmx_fnc_recalculate_muzzle_velocity
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["_parseInput", "_updateDisplay"];
|
|
|
|
|
|
|
|
if (_parseInput) then {
|
|
|
|
[] call FUNC(parse_input);
|
|
|
|
};
|
|
|
|
|
|
|
|
private _lookupTable = [];
|
|
|
|
{
|
|
|
|
if ((_x select 1) > 0) then {
|
|
|
|
_lookupTable pushBack _x;
|
|
|
|
};
|
|
|
|
} forEach (GVAR(workingMemory) select 18);
|
|
|
|
|
|
|
|
private _lookupTableSize = count _lookupTable;
|
|
|
|
if (_lookupTableSize < 2) exitWith {};
|
|
|
|
_lookupTable sort true;
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _lowerIndex = -1;
|
|
|
|
private _upperIndex = -1;
|
2016-11-02 12:56:59 +00:00
|
|
|
for "_index" from 1 to (_lookupTableSize - 1) do {
|
|
|
|
_upperIndex = _index;
|
|
|
|
_lowerIndex = _upperIndex - 1;
|
2016-11-16 13:20:44 +00:00
|
|
|
if (((_lookupTable select _index) select 0) >= GVAR(temperature)) exitWith {};
|
2016-11-02 12:56:59 +00:00
|
|
|
};
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _lowerTemperature = (_lookupTable select _lowerIndex) select 0;
|
|
|
|
private _upperTemperature = (_lookupTable select _upperIndex) select 0;
|
|
|
|
private _lowerMuzzleVelocity = (_lookupTable select _lowerIndex) select 1;
|
|
|
|
private _upperMuzzleVelocity = (_lookupTable select _upperIndex) select 1;
|
|
|
|
private _muzzleVelocity = _lowerMuzzleVelocity;
|
2016-11-16 13:20:44 +00:00
|
|
|
if (_lowerTemperature != _upperTemperature) then {
|
|
|
|
private _slope = (_upperMuzzleVelocity - _lowerMuzzleVelocity) / (_upperTemperature - _lowerTemperature);
|
|
|
|
_muzzleVelocity = _lowerMuzzleVelocity + (GVAR(temperature) - _lowerTemperature) * _slope;
|
|
|
|
};
|
|
|
|
_muzzleVelocity = 100 max _muzzleVelocity min 1400;
|
2016-11-02 12:56:59 +00:00
|
|
|
|
|
|
|
if (_muzzleVelocity != GVAR(workingMemory) select 1) then {
|
|
|
|
GVAR(workingMemory) set [1, _muzzleVelocity];
|
|
|
|
if (_updateDisplay) then {
|
|
|
|
call FUNC(update_gun);
|
|
|
|
call FUNC(update_gun_ammo_data);
|
|
|
|
};
|
|
|
|
};
|