2015-04-11 21:40:46 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
|
|
|
* Calculates the target range and updates the output fields
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Example:
|
2016-07-20 04:15:18 +00:00
|
|
|
* call ace_atragmx_fnc_calculate_target_range_assist
|
2015-04-11 21:40:46 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-04-06 13:51:59 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_targetSize", "_imageSize", "_angle", "_estRange"];
|
|
|
|
|
|
|
|
_angle = parseNumber(ctrlText 7012);
|
|
|
|
_targetSize = parseNumber(ctrlText 7010);
|
2015-04-08 09:08:28 +00:00
|
|
|
if (GVAR(rangeAssistUseTargetHeight)) then {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = _targetSize * cos(_angle);
|
2015-04-06 13:51:59 +00:00
|
|
|
};
|
2015-04-08 09:08:28 +00:00
|
|
|
switch (GVAR(rangeAssistTargetSizeUnit)) do {
|
2015-04-07 21:09:32 +00:00
|
|
|
case 0: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = _targetSize * 0.0254;
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 1: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = _targetSize * 0.3048;
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 2: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = _targetSize * 0.01;
|
|
|
|
};
|
2015-04-06 13:51:59 +00:00
|
|
|
};
|
|
|
|
_imageSize = parseNumber(ctrlText 7011);
|
2015-04-08 09:08:28 +00:00
|
|
|
switch (GVAR(rangeAssistImageSizeUnit)) do {
|
2015-04-07 21:09:32 +00:00
|
|
|
case 0: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_imageSize = _imageSize / 6400 * 360;
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 1: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_imageSize = _imageSize / 60;
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 2: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_imageSize = _imageSize / 60 / 1.047;
|
|
|
|
};
|
2015-04-06 13:51:59 +00:00
|
|
|
};
|
|
|
|
_estRange = parseNumber(ctrlText 7013);
|
2015-04-17 22:11:53 +00:00
|
|
|
if (GVAR(currentUnit) == 1) then {
|
2015-04-07 20:44:26 +00:00
|
|
|
_estRange = _estRange / 1.0936133;
|
2015-04-06 13:51:59 +00:00
|
|
|
};
|
|
|
|
|
2015-04-07 21:09:32 +00:00
|
|
|
switch (_this) do {
|
|
|
|
case 0: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = tan(_imageSize) * _estRange;
|
2015-04-07 21:09:32 +00:00
|
|
|
|
2015-04-08 09:08:28 +00:00
|
|
|
if (GVAR(rangeAssistUseTargetHeight)) then {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = _targetSize / cos(_angle);
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
|
2015-04-08 09:08:28 +00:00
|
|
|
switch (GVAR(rangeAssistTargetSizeUnit)) do {
|
2015-04-07 21:09:32 +00:00
|
|
|
case 0: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = _targetSize / 0.0254;
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 1: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = _targetSize / 0.3048;
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 2: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_targetSize = _targetSize / 0.01;
|
|
|
|
};
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
|
2015-04-07 20:44:26 +00:00
|
|
|
ctrlSetText [7010, Str(Round(_targetSize * 100) / 100)];
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 1: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_imageSize = atan(_targetSize / _estRange);
|
2015-04-07 21:09:32 +00:00
|
|
|
|
2015-04-08 09:08:28 +00:00
|
|
|
switch (GVAR(rangeAssistImageSizeUnit)) do {
|
2015-04-07 21:09:32 +00:00
|
|
|
case 0: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_imageSize = _imageSize * 6400 / 360;
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 1: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_imageSize = _imageSize * 60;
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 2: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_imageSize = _imageSize * 60 * 1.047;
|
|
|
|
};
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
|
2015-04-07 20:44:26 +00:00
|
|
|
ctrlSetText [7011, Str(Round(_imageSize * 100) / 100)];
|
|
|
|
};
|
2015-04-07 21:09:32 +00:00
|
|
|
case 2: {
|
2015-04-07 20:44:26 +00:00
|
|
|
_estRange = _targetSize / tan(_imageSize);
|
2015-04-07 21:09:32 +00:00
|
|
|
|
2015-04-07 20:44:26 +00:00
|
|
|
ctrlSetText [7013, Str(Round(_estRange))];
|
|
|
|
};
|
2015-04-06 13:51:59 +00:00
|
|
|
};
|