ACE3/addons/advanced_ballistics/functions/fnc_calculateAmmoTemperatureVelocityShift.sqf

37 lines
1.2 KiB
Plaintext
Raw Normal View History

/*
* Author: Ruthberg
*
* Calculates the ammo temperature induced muzzle velocity shift
*
* Arguments:
2015-05-08 15:20:56 +00:00
* 0: muzzle velocity shift lookup table - m/s <ARRAY>
2015-04-07 19:54:29 +00:00
* 1: temperature - degrees celcius <NUMBER>
*
* Return Value:
2015-04-07 19:54:29 +00:00
* 0: muzzle velocity shift - m/s <NUMBER>
*
* Return value:
* None
*/
2015-04-05 19:08:55 +00:00
#include "script_component.hpp"
2015-05-08 15:20:56 +00:00
private ["_muzzleVelocityShiftTable", "_temperature", "_muzzleVelocityShift", "_temperatureIndexA", "_temperatureIndexB", "_temperatureRatio"];
_muzzleVelocityShiftTable = _this select 0;
_temperature = _this select 1;
2015-04-05 19:08:55 +00:00
2015-05-08 15:20:56 +00:00
if (count _muzzleVelocityShiftTable != 11) exitWith { 0 };
2015-04-05 19:08:55 +00:00
_temperatureIndexA = floor((_temperature + 15) / 5);
_temperatureIndexA = 0 max _temperatureIndexA;
_temperatureIndexA = _temperatureIndexA min 10;
_temperatureIndexB = ceil((_temperature + 15) / 5);
_temperatureIndexB = 0 max _temperatureIndexB;
_temperatureIndexB = _temperatureIndexB min 10;
_temperatureRatio = ((_temperature + 15) / 5) - floor((_temperature + 15) / 5);
2015-05-08 15:20:56 +00:00
_muzzleVelocityShift = (_muzzleVelocityShiftTable select _temperatureIndexA) * (1 - _temperatureRatio) + (_muzzleVelocityShiftTable select _temperatureIndexB) * _temperatureRatio;
2015-04-05 19:08:55 +00:00
_muzzleVelocityShift