2015-04-11 21:40:46 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
|
|
|
* Calculates the fireing solution and updates the result input/output fields
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Example:
|
2016-07-20 04:15:18 +00:00
|
|
|
* call ace_atragmx_fnc_calculate_target_solution
|
2015-04-11 21:40:46 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-04-06 13:51:59 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-04-06 18:46:33 +00:00
|
|
|
[] call FUNC(parse_input);
|
2015-04-06 13:51:59 +00:00
|
|
|
|
|
|
|
private ["_scopeBaseAngle"];
|
2015-04-16 16:14:32 +00:00
|
|
|
_scopeBaseAngle = (GVAR(workingMemory) select 3);
|
2015-04-06 13:51:59 +00:00
|
|
|
|
2015-04-17 22:11:53 +00:00
|
|
|
private ["_bulletMass", "_bulletDiameter", "_boreHeight", "_airFriction", "_barrelTwist", "_muzzleVelocity", "_bc", "_dragModel", "_atmosphereModel", "_twistDirection"];
|
2015-04-16 16:14:32 +00:00
|
|
|
_bulletMass = GVAR(workingMemory) select 12;
|
2015-04-17 22:11:53 +00:00
|
|
|
_bulletDiameter = GVAR(workingMemory) select 13;
|
2015-04-16 16:14:32 +00:00
|
|
|
_boreHeight = GVAR(workingMemory) select 5;
|
|
|
|
_airFriction = GVAR(workingMemory) select 4;
|
2015-04-17 22:11:53 +00:00
|
|
|
_barrelTwist = GVAR(workingMemory) select 14;
|
2015-04-16 16:14:32 +00:00
|
|
|
_muzzleVelocity = GVAR(workingMemory) select 1;
|
|
|
|
_bc = GVAR(workingMemory) select 15;
|
|
|
|
_dragModel = GVAR(workingMemory) select 16;
|
|
|
|
_atmosphereModel = GVAR(workingMemory) select 17;
|
2015-04-06 13:51:59 +00:00
|
|
|
|
2015-04-17 22:11:53 +00:00
|
|
|
_twistDirection = 0;
|
|
|
|
if (_barrelTwist > 0) then {
|
|
|
|
_twistDirection = 1;
|
|
|
|
} else {
|
|
|
|
if (_barrelTwist < 0) then {
|
|
|
|
_twistDirection = -1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
_barrelTwist = abs(_barrelTwist);
|
|
|
|
|
|
|
|
private ["_altitude", "_temperature", "_barometricPressure", "_relativeHumidity"];
|
|
|
|
_altitude = GVAR(altitude);
|
2015-04-16 16:14:32 +00:00
|
|
|
_temperature = GVAR(temperature);
|
|
|
|
_barometricPressure = GVAR(barometricPressure);
|
|
|
|
_relativeHumidity = GVAR(relativeHumidity);
|
2015-04-17 22:11:53 +00:00
|
|
|
if (!GVAR(atmosphereModeTBH)) then {
|
2015-05-29 09:18:40 +00:00
|
|
|
_barometricPressure = 1013.25 * (1 - (0.0065 * _altitude) / (273.15 + _temperature + 0.0065 * _altitude)) ^ 5.255754495;
|
2015-04-17 22:11:53 +00:00
|
|
|
_relativeHumidity = 50;
|
2015-04-06 13:51:59 +00:00
|
|
|
};
|
|
|
|
|
2015-04-17 22:11:53 +00:00
|
|
|
private ["_bulletLength", "_stabilityFactor"];
|
2015-05-08 11:56:38 +00:00
|
|
|
_bulletLength = 45.72;
|
2015-04-17 22:11:53 +00:00
|
|
|
_stabilityFactor = 1.5;
|
2015-04-25 11:34:47 +00:00
|
|
|
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
2015-04-17 22:11:53 +00:00
|
|
|
if (_bulletDiameter > 0 && _bulletLength > 0 && _bulletMass > 0 && _barrelTwist > 0) then {
|
2015-05-08 11:56:38 +00:00
|
|
|
_stabilityFactor = [_bulletDiameter, _bulletLength, _bulletMass, _barrelTwist * 10, _muzzleVelocity, _temperature, _barometricPressure] call EFUNC(advanced_ballistics,calculateStabilityFactor);
|
2015-04-17 22:11:53 +00:00
|
|
|
};
|
2015-04-06 13:51:59 +00:00
|
|
|
};
|
2015-04-17 22:11:53 +00:00
|
|
|
|
2015-04-18 13:08:54 +00:00
|
|
|
private ["_latitude", "_directionOfFire", "_windSpeed1", "_windSpeed2", "_windDirection", "_inclinationAngle", "_targetSpeed", "_targetRange"];
|
2015-04-17 22:11:53 +00:00
|
|
|
_latitude = GVAR(latitude) select GVAR(currentTarget);
|
|
|
|
_directionOfFire = GVAR(directionOfFire) select GVAR(currentTarget);
|
2015-04-18 13:08:54 +00:00
|
|
|
_windSpeed1 = GVAR(windSpeed1) select GVAR(currentTarget);
|
|
|
|
_windSpeed2 = GVAR(windSpeed2) select GVAR(currentTarget);
|
2015-04-17 22:11:53 +00:00
|
|
|
_windDirection = GVAR(windDirection) select GVAR(currentTarget);
|
|
|
|
_inclinationAngle = GVAR(inclinationAngle) select GVAR(currentTarget);
|
|
|
|
_targetSpeed = GVAR(targetSpeed) select GVAR(currentTarget);
|
|
|
|
_targetRange = GVAR(targetRange) select GVAR(currentTarget);
|
2015-04-06 13:51:59 +00:00
|
|
|
|
2015-04-16 16:14:32 +00:00
|
|
|
private ["_result"];
|
2015-04-06 13:51:59 +00:00
|
|
|
_result = [_scopeBaseAngle, _bulletMass, _boreHeight, _airFriction, _muzzleVelocity, _temperature, _barometricPressure, _relativeHumidity, 1000,
|
2015-04-19 20:30:13 +00:00
|
|
|
[_windSpeed1, _windSpeed2], _windDirection, _inclinationAngle, _targetSpeed, _targetRange, _bc, _dragModel, _atmosphereModel, false, _stabilityFactor, _twistDirection, _latitude, _directionOfFire] call FUNC(calculate_solution);
|
2015-04-06 13:51:59 +00:00
|
|
|
|
2015-04-08 09:05:28 +00:00
|
|
|
GVAR(elevationOutput) set [GVAR(currentTarget), _result select 0];
|
2015-04-18 13:08:54 +00:00
|
|
|
GVAR(windage1Output) set [GVAR(currentTarget), (_result select 1) select 0];
|
|
|
|
GVAR(windage2Output) set [GVAR(currentTarget), (_result select 1) select 1];
|
2015-04-08 09:05:28 +00:00
|
|
|
GVAR(leadOutput) set [GVAR(currentTarget), _result select 2];
|
|
|
|
GVAR(tofOutput) set [GVAR(currentTarget), _result select 3];
|
|
|
|
GVAR(velocityOutput) set [GVAR(currentTarget), _result select 4];
|
2015-04-06 13:51:59 +00:00
|
|
|
|
2015-04-06 18:46:33 +00:00
|
|
|
[] call FUNC(update_result);
|