ACE3/addons/atragmx/functions/fnc_calculate_target_range_assist.sqf

83 lines
2.1 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
private ["_targetSize", "_imageSize", "_angle", "_estRange"];
_angle = parseNumber(ctrlText 7012);
_targetSize = parseNumber(ctrlText 7010);
if (GVAR(rangeAssistUseTargetHeight)) then {
2015-04-07 20:44:26 +00:00
_targetSize = _targetSize * cos(_angle);
};
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;
};
};
_imageSize = parseNumber(ctrlText 7011);
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;
};
};
_estRange = parseNumber(ctrlText 7013);
if (GVAR(currentUnit) != 2) then {
2015-04-07 20:44:26 +00:00
_estRange = _estRange / 1.0936133;
};
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
if (GVAR(rangeAssistUseTargetHeight)) then {
2015-04-07 20:44:26 +00:00
_targetSize = _targetSize / cos(_angle);
};
2015-04-07 21:09:32 +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
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))];
};
};