2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-04-11 21:40:46 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
|
|
|
* Calculates the target range and updates the output fields
|
|
|
|
*
|
|
|
|
* Arguments:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-04-11 21:40:46 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-04-11 21:40:46 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _angle = parseNumber(ctrlText 7012);
|
2016-11-02 12:56:59 +00:00
|
|
|
private _targetSize = abs(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
|
|
|
};
|
2016-09-04 14:44:22 +00:00
|
|
|
private _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
|
|
|
};
|
2016-11-02 12:56:59 +00:00
|
|
|
private _estRange = abs(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
|
|
|
|
2016-11-02 12:56:59 +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
|
|
|
|
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: {
|
2016-11-02 12:56:59 +00:00
|
|
|
if (_estRange > 0) then {
|
|
|
|
_imageSize = atan(_targetSize / _estRange);
|
|
|
|
};
|
2017-06-08 13:31:51 +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: {
|
2016-11-02 12:56:59 +00:00
|
|
|
if (tan(_imageSize) != 0) then {
|
|
|
|
_estRange = _targetSize / tan(_imageSize);
|
|
|
|
};
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2015-04-07 20:44:26 +00:00
|
|
|
ctrlSetText [7013, Str(Round(_estRange))];
|
|
|
|
};
|
2015-04-06 13:51:59 +00:00
|
|
|
};
|