2015-04-05 21:28:12 +00:00
|
|
|
/*
|
2015-04-06 06:05:28 +00:00
|
|
|
* Author: PabstMirror
|
|
|
|
* DEV function to build mortar tables, very cpu intensive (never used durring normal gameplay)
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Muzzle Velocity <NUMBER>
|
|
|
|
* 1: Air Friction <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* <Data in clipboard>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [100, -0.0001] spawn ace_mk6mortar_fnc_dev_buildTable; //spawn (scheduled) is slower
|
|
|
|
* [100, -0.0001] call ace_mk6mortar_fnc_dev_buildTable; //faster, but will lock while processing
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-04-05 21:28:12 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-04-06 06:05:28 +00:00
|
|
|
|
2015-04-05 21:28:12 +00:00
|
|
|
private ["_muzzleVelocity", "_airFriction", "_stillInRange", "_currentRange", "_increasePerRow", "_outputArray", "_rangeToHit", "_lineElevation", "_lineHeightElevation", "_lineTimeOfFlight", "_lineCrosswindDeg", "_lineHeadwindMeters", "_lineTailWindMeters", "_lineTempDec", "_lineTempInc", "_lineAirDensDec", "_lineAirDensInc", "_result", "_outputString"];
|
|
|
|
|
|
|
|
_muzzleVelocity = _this select 0;
|
|
|
|
_airFriction = _this select 1;
|
|
|
|
_stillInRange = true;
|
|
|
|
_currentRange = 100;
|
|
|
|
_increasePerRow = 50;
|
|
|
|
_outputArray = [];
|
|
|
|
|
|
|
|
|
2015-04-24 18:26:09 +00:00
|
|
|
//[_rangeToHit, _lineElevation, _lineHeightElevation, _lineHeightTimeDelta, _lineTimeOfFlight, _lineCrosswindDeg, _lineHeadwindMeters, _lineTailWindMeters, _lineTempDec, _lineTempInc, _lineAirDensDec, _lineAirDensInc]
|
2015-04-05 21:28:12 +00:00
|
|
|
|
|
|
|
while {_stillInRange} do {
|
2015-04-06 06:05:28 +00:00
|
|
|
_result = [_muzzleVelocity, _currentRange, _airFriction] call FUNC(dev_simulateCalcRangeTableLine);
|
|
|
|
if (_result isEqualTo []) then {
|
|
|
|
_stillInRange = false;
|
|
|
|
} else {
|
2015-04-08 00:19:08 +00:00
|
|
|
if (_airFriction == 0) then {
|
|
|
|
_result set [4, 0];
|
|
|
|
_result set [5, 0];
|
|
|
|
_result set [6, 0];
|
|
|
|
_result set [7, 0];
|
|
|
|
_result set [8, 0];
|
|
|
|
_result set [9, 0];
|
|
|
|
_result set [10, 0];
|
|
|
|
};
|
|
|
|
if ((_result select 1) < 88) then {
|
2015-04-06 06:05:28 +00:00
|
|
|
_outputArray pushBack [
|
|
|
|
([(_result select 0), "meters", false] call FUNC(dev_formatNumber)),
|
|
|
|
([(_result select 1), "mil", true] call FUNC(dev_formatNumber)),
|
|
|
|
([(_result select 2), "mil", true] call FUNC(dev_formatNumber)),
|
|
|
|
([(_result select 3), "sec", false] call FUNC(dev_formatNumber)),
|
2015-04-24 18:26:09 +00:00
|
|
|
([(_result select 4), "sec", false] call FUNC(dev_formatNumber)),
|
|
|
|
([(_result select 5), "milPrecise", true] call FUNC(dev_formatNumber)),
|
2015-04-06 06:05:28 +00:00
|
|
|
([(_result select 6), "metersprecise", false] call FUNC(dev_formatNumber)),
|
|
|
|
([(_result select 7), "metersprecise", false] call FUNC(dev_formatNumber)),
|
|
|
|
([(_result select 8), "metersprecise", false] call FUNC(dev_formatNumber)),
|
|
|
|
([(_result select 9), "metersprecise", false] call FUNC(dev_formatNumber)),
|
2015-04-24 18:26:09 +00:00
|
|
|
([(_result select 10), "metersprecise", false] call FUNC(dev_formatNumber)),
|
|
|
|
([(_result select 11), "metersprecise", false] call FUNC(dev_formatNumber))
|
2015-04-06 06:05:28 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
_currentRange = _currentRange + _increasePerRow;
|
2015-04-05 21:28:12 +00:00
|
|
|
};
|
2015-04-06 06:05:28 +00:00
|
|
|
hintSilent str _currentRange;
|
2015-04-05 21:28:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//handle floating point rounding errors
|
2015-04-24 18:26:09 +00:00
|
|
|
_outputString = format ["case ((abs(_muzzleVelocity - %1) < 0.00001) && {(abs(_airFriction - %2) < 0.00001)}): {
|
2015-04-05 21:28:12 +00:00
|
|
|
[
|
|
|
|
", _muzzleVelocity, _airFriction];
|
|
|
|
|
|
|
|
{
|
2015-04-06 06:05:28 +00:00
|
|
|
if (_forEachIndex < ((count _outputArray) - 1)) then {
|
|
|
|
_outputString = _outputString + format ["%1,
|
2015-04-05 21:28:12 +00:00
|
|
|
", _x];
|
2015-04-06 06:05:28 +00:00
|
|
|
} else {
|
|
|
|
_outputString = _outputString + format ["%1
|
|
|
|
]
|
2015-04-05 21:28:12 +00:00
|
|
|
};", _x];
|
2015-04-06 06:05:28 +00:00
|
|
|
};
|
2015-04-05 21:28:12 +00:00
|
|
|
} forEach _outputArray;
|
|
|
|
|
|
|
|
copyToClipboard _outputString;
|
2015-04-08 00:19:08 +00:00
|
|
|
rangeTableOutput = _outputString;
|
2015-04-05 21:28:12 +00:00
|
|
|
|
|
|
|
hint "done";
|