ACE3/addons/atragmx/functions/fnc_parse_input.sqf
2015-04-08 11:05:28 +02:00

75 lines
3.0 KiB
Plaintext

#include "script_component.hpp"
GVAR(temperature) set [GVAR(currentTarget), parseNumber(ctrlText 200)];
GVAR(barometricPressure) set [GVAR(currentTarget), 0 max parseNumber(ctrlText 210)];
GVAR(relativeHumidity) set [GVAR(currentTarget), (0 max parseNumber(ctrlText 220) min 100) / 100];
GVAR(windSpeed) set [GVAR(currentTarget), 0 max abs(parseNumber(ctrlText 300)) min 50];
GVAR(windDirection) set [GVAR(currentTarget), 1 max Round(parseNumber(ctrlText 310)) min 12];
GVAR(inclinationAngle) set [GVAR(currentTarget), -60 max parseNumber(ctrlText 320) min 60];
GVAR(targetSpeed) set [GVAR(currentTarget), 0 max abs(parseNumber(ctrlText 330)) min 50];
GVAR(targetRange) set [GVAR(currentTarget), 0 max abs(parseNumber(ctrlText 340)) min 4000];
private ["_boreHeight", "_bulletMass", "_airFriction", "_muzzleVelocity"];
_boreHeight = parseNumber(ctrlText 100);
_bulletMass = parseNumber(ctrlText 110);
if (EGVAR(advanced_ballistics,AdvancedBallistics) && EGVAR(advanced_ballistics,AdvancedAirDragEnabled)) then {
_airFriction = 0.1 max parseNumber(ctrlText 120) min 2;
} else {
_airFriction = parseNumber(ctrlText 120) / -1000;
};
_muzzleVelocity = parseNumber(ctrlText 130);
if (GVAR(currentUnit) == 1) then
{
_boreHeight = _boreHeight * 2.54;
_bulletMass = _bulletMass * 0.06479891;
_muzzleVelocity = _muzzleVelocity / 3.2808399;
};
_boreHeight = 0.1 max _boreHeight min 10;
_bulletMass = 1 max _bulletMass min 100;
_muzzleVelocity = 100 max _muzzleVelocity min 1400;
(GVAR(workingMemory) select GVAR(currentTarget)) set [5, _boreHeight];
(GVAR(workingMemory) select GVAR(currentTarget)) set [12, _bulletMass];
if (EGVAR(advanced_ballistics,AdvancedBallistics) && EGVAR(advanced_ballistics,AdvancedAirDragEnabled)) then {
(GVAR(workingMemory) select GVAR(currentTarget)) set [15, _airFriction];
} else {
(GVAR(workingMemory) select GVAR(currentTarget)) set [4, _airFriction];
};
(GVAR(workingMemory) select GVAR(currentTarget)) set [1, _muzzleVelocity];
private ["_elevationCur", "_elevationCur", "_elevationScopeStep", "_windageScopeStep"];
_elevationCur = parseNumber(ctrlText 402);
_windageCur = parseNumber(ctrlText 412);
switch ((GVAR(currentScopeUnit) select GVAR(currentTarget))) do
{
case 0:
{
_elevationCur = _elevationCur * 3.38;
_windageCur = _windageCur * 3.38;
};
case 2:
{
_elevationCur = _elevationCur / 1.047;
_windageCur = _windageCur / 1.047;
};
case 3:
{
_elevationScopeStep = ((GVAR(workingMemory) select GVAR(currentTarget)) select 7);
_windageScopeStep = ((GVAR(workingMemory) select GVAR(currentTarget)) select 8);
_elevationCur = _elevationCur * _elevationScopeStep;
_windageCur = _windageCur * _windageScopeStep;
};
};
(GVAR(workingMemory) select GVAR(currentTarget)) set [10, _elevationCur];
(GVAR(workingMemory) select GVAR(currentTarget)) set [11, _windageCur];
[] call FUNC(update_gun);
[] call FUNC(update_atmosphere);
[] call FUNC(update_target);