ACE3/addons/atragmx/functions/fnc_calculate_target_range_assist.sqf

100 lines
2.4 KiB
Plaintext
Raw Normal View History

/*
* Author: Ruthberg
* Calculates the target range and updates the output fields
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
2016-07-20 04:15:18 +00:00
* call ace_atragmx_fnc_calculate_target_range_assist
*
* Public: No
*/
#include "script_component.hpp"
private _angle = parseNumber(ctrlText 7012);
private _targetSize = abs(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;
};
};
private _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;
};
};
private _estRange = abs(parseNumber(ctrlText 7013));
if (GVAR(currentUnit) == 1) 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) && cos(_angle) != 0) 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: {
if (_estRange > 0) then {
_imageSize = atan(_targetSize / _estRange);
};
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: {
if (tan(_imageSize) != 0) then {
_estRange = _targetSize / tan(_imageSize);
};
2015-04-07 20:44:26 +00:00
ctrlSetText [7013, Str(Round(_estRange))];
};
};