ACE3/addons/atragmx/functions/fnc_calculate_target_range_assist.sqf
Dedmen Miller e2ac18a05d [WIP] Fix script errors reporting wrong line numbers (#6407)
* advanced_ballistics

* advanced_fatigue

* advanced_throwing

* ai

* aircraft

* arsenal

* atragmx

* attach

* backpacks

* ballistics

* captives

* cargo

* chemlights

* common

* concertina_wire

* cookoff

* dagr

* disarming

* disposable

* dogtags

* dragging

* explosives

* fastroping

* fcs

* finger

* frag

* gestures

* gforces

* goggles

* grenades

* gunbag

* hearing

* hitreactions

* huntir

* interact_menu

* interaction

* inventory

* kestrel4500

* laser

* laserpointer

* logistics_uavbattery

* logistics_wirecutter

* magazinerepack

* map

* map_gestures

* maptools

* markers

* medical

* medical_ai

* medical_blood

* medical_menu

* microdagr

* minedetector

* missileguidance

* missionmodules

* mk6mortar

* modules

* movement

* nametags

* nightvision

* nlaw

* optics

* optionsmenu

* overheating

* overpressure

* parachute

* pylons

* quickmount

* rangecard

* rearm

* recoil

* refuel

* reload

* reloadlaunchers

* repair

* respawn

* safemode

* sandbag

* scopes

* slideshow

* spectator

* spottingscope

* switchunits

* tacticalladder

* tagging

* trenches

* tripod

* ui

* vector

* vehiclelock

* vehicles

* viewdistance

* weaponselect

* weather

* winddeflection

* yardage450

* zeus

* arsenal defines.hpp

* optionals

* DEBUG_MODE_FULL 1

* DEBUG_MODE_FULL 2

* Manual fixes

* Add SQF Validator check for #include after block comment

* explosives fnc_openTimerUI

* fix uniqueItems
2018-09-17 14:19:29 -05:00

100 lines
2.4 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Ruthberg
* Calculates the target range and updates the output fields
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* call ace_atragmx_fnc_calculate_target_range_assist
*
* Public: No
*/
private _angle = parseNumber(ctrlText 7012);
private _targetSize = abs(parseNumber(ctrlText 7010));
if (GVAR(rangeAssistUseTargetHeight)) then {
_targetSize = _targetSize * cos(_angle);
};
switch (GVAR(rangeAssistTargetSizeUnit)) do {
case 0: {
_targetSize = _targetSize * 0.0254;
};
case 1: {
_targetSize = _targetSize * 0.3048;
};
case 2: {
_targetSize = _targetSize * 0.01;
};
};
private _imageSize = parseNumber(ctrlText 7011);
switch (GVAR(rangeAssistImageSizeUnit)) do {
case 0: {
_imageSize = _imageSize / 6400 * 360;
};
case 1: {
_imageSize = _imageSize / 60;
};
case 2: {
_imageSize = _imageSize / 60 / 1.047;
};
};
private _estRange = abs(parseNumber(ctrlText 7013));
if (GVAR(currentUnit) == 1) then {
_estRange = _estRange / 1.0936133;
};
switch (_this) do {
case 0: {
_targetSize = tan(_imageSize) * _estRange;
if (GVAR(rangeAssistUseTargetHeight) && cos(_angle) != 0) then {
_targetSize = _targetSize / cos(_angle);
};
switch (GVAR(rangeAssistTargetSizeUnit)) do {
case 0: {
_targetSize = _targetSize / 0.0254;
};
case 1: {
_targetSize = _targetSize / 0.3048;
};
case 2: {
_targetSize = _targetSize / 0.01;
};
};
ctrlSetText [7010, Str(Round(_targetSize * 100) / 100)];
};
case 1: {
if (_estRange > 0) then {
_imageSize = atan(_targetSize / _estRange);
};
switch (GVAR(rangeAssistImageSizeUnit)) do {
case 0: {
_imageSize = _imageSize * 6400 / 360;
};
case 1: {
_imageSize = _imageSize * 60;
};
case 2: {
_imageSize = _imageSize * 60 * 1.047;
};
};
ctrlSetText [7011, Str(Round(_imageSize * 100) / 100)];
};
case 2: {
if (tan(_imageSize) != 0) then {
_estRange = _targetSize / tan(_imageSize);
};
ctrlSetText [7013, Str(Round(_estRange))];
};
};