mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
ATragMX - Utilize 'C1 vs. Distance' data in the range card output
This commit is contained in:
parent
d3dbb77510
commit
30fedc9ece
@ -27,6 +27,7 @@ PREP(init);
|
|||||||
PREP(initGunList);
|
PREP(initGunList);
|
||||||
PREP(insert_c1_ballistic_coefficient_data);
|
PREP(insert_c1_ballistic_coefficient_data);
|
||||||
PREP(insert_muzzle_velocity_data);
|
PREP(insert_muzzle_velocity_data);
|
||||||
|
PREP(lookup_c1_ballistic_coefficient);
|
||||||
PREP(parse_input);
|
PREP(parse_input);
|
||||||
PREP(read_gun_list_entries_from_config);
|
PREP(read_gun_list_entries_from_config);
|
||||||
PREP(recalculate_c1_ballistic_coefficient);
|
PREP(recalculate_c1_ballistic_coefficient);
|
||||||
|
@ -27,4 +27,9 @@ _solutionInput set [ 8, round(_solutionInput select 4)];
|
|||||||
_solutionInput set [13, _targetRange];
|
_solutionInput set [13, _targetRange];
|
||||||
_solutionInput set [17, true];
|
_solutionInput set [17, true];
|
||||||
|
|
||||||
|
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||||
|
private _c1 = [_targetRange] call FUNC(lookup_c1_ballistic_coefficient);
|
||||||
|
_solutionInput set [14, _c1];
|
||||||
|
};
|
||||||
|
|
||||||
private _result = _solutionInput call FUNC(calculate_solution);
|
private _result = _solutionInput call FUNC(calculate_solution);
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Author: Ruthberg
|
||||||
|
* Lookup the correct C1 ballistic coefficient in the c1 ballistic coefficient vs. distance interpolation table
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* Target Range <NUMBER>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* C1 ballistic coefficient <NUMBER
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* call ace_atragmx_fnc_lookup_c1_ballistic_coefficient
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_targetRange"];
|
||||||
|
|
||||||
|
private _lookupTable = [];
|
||||||
|
{
|
||||||
|
if ((_x select 1) > 0) then {
|
||||||
|
_lookupTable pushBack _x;
|
||||||
|
};
|
||||||
|
} forEach (GVAR(workingMemory) select 19);
|
||||||
|
|
||||||
|
private _lookupTableSize = count _lookupTable;
|
||||||
|
if (_lookupTableSize < 2) exitWith { (GVAR(workingMemory) select 15) };
|
||||||
|
_lookupTable sort true;
|
||||||
|
|
||||||
|
private _lowerIndex = -1;
|
||||||
|
private _upperIndex = -1;
|
||||||
|
|
||||||
|
for "_index" from 1 to (_lookupTableSize - 1) do {
|
||||||
|
_upperIndex = _index;
|
||||||
|
_lowerIndex = _upperIndex - 1;
|
||||||
|
if (((_lookupTable select _index) select 0) >= _targetRange) exitWith { (GVAR(workingMemory) select 15) };
|
||||||
|
};
|
||||||
|
|
||||||
|
private _lowerDistance = (_lookupTable select _lowerIndex) select 0;
|
||||||
|
private _upperDistance = (_lookupTable select _upperIndex) select 0;
|
||||||
|
private _lowerC1 = (_lookupTable select _lowerIndex) select 1;
|
||||||
|
private _upperC1 = (_lookupTable select _upperIndex) select 1;
|
||||||
|
private _c1 = _lowerC1;
|
||||||
|
if (_lowerDistance != _upperDistance) then {
|
||||||
|
private _slope = (_upperC1 - _lowerC1) / (_upperDistance - _lowerDistance);
|
||||||
|
_c1 = _lowerC1 + (_targetRange - _lowerDistance) * _slope;
|
||||||
|
};
|
||||||
|
_c1 = 0.1 max _c1 min 2.0;
|
||||||
|
|
||||||
|
_c1
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Ruthberg
|
* Author: Ruthberg
|
||||||
* Recalculates the c1 ballistic coefficient based on the c1 ballistic coefficient vs. distance interpolation input
|
* Recalculates the c1 ballistic coefficient based on the current target range
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* parse input <BOOL>
|
* parse input <BOOL>
|
||||||
@ -22,36 +22,7 @@ if (_parseInput) then {
|
|||||||
[] call FUNC(parse_input);
|
[] call FUNC(parse_input);
|
||||||
};
|
};
|
||||||
|
|
||||||
private _lookupTable = [];
|
private _c1 = [GVAR(targetRange) select GVAR(currentTarget)] call FUNC(lookup_c1_ballistic_coefficient);
|
||||||
{
|
|
||||||
if ((_x select 1) > 0) then {
|
|
||||||
_lookupTable pushBack _x;
|
|
||||||
};
|
|
||||||
} forEach (GVAR(workingMemory) select 19);
|
|
||||||
|
|
||||||
private _lookupTableSize = count _lookupTable;
|
|
||||||
if (_lookupTableSize < 2) exitWith {};
|
|
||||||
_lookupTable sort true;
|
|
||||||
|
|
||||||
private _lowerIndex = -1;
|
|
||||||
private _upperIndex = -1;
|
|
||||||
|
|
||||||
for "_index" from 1 to (_lookupTableSize - 1) do {
|
|
||||||
_upperIndex = _index;
|
|
||||||
_lowerIndex = _upperIndex - 1;
|
|
||||||
if (((_lookupTable select _index) select 0) >= (GVAR(targetRange) select GVAR(currentTarget))) exitWith {};
|
|
||||||
};
|
|
||||||
|
|
||||||
private _lowerDistance = (_lookupTable select _lowerIndex) select 0;
|
|
||||||
private _upperDistance = (_lookupTable select _upperIndex) select 0;
|
|
||||||
private _lowerC1 = (_lookupTable select _lowerIndex) select 1;
|
|
||||||
private _upperC1 = (_lookupTable select _upperIndex) select 1;
|
|
||||||
private _c1 = _lowerC1;
|
|
||||||
if (_lowerDistance != _upperDistance) then {
|
|
||||||
private _slope = (_upperC1 - _lowerC1) / (_upperDistance - _lowerDistance);
|
|
||||||
_c1 = _lowerC1 + ((GVAR(targetRange) select GVAR(currentTarget)) - _lowerDistance) * _slope;
|
|
||||||
};
|
|
||||||
_c1 = 0.1 max _c1 min 2.0;
|
|
||||||
|
|
||||||
if (_c1 != GVAR(workingMemory) select 15) then {
|
if (_c1 != GVAR(workingMemory) select 15) then {
|
||||||
GVAR(workingMemory) set [15, _c1];
|
GVAR(workingMemory) set [15, _c1];
|
||||||
|
Loading…
Reference in New Issue
Block a user