Fix infantry rangefinders (again)

This commit is contained in:
VKing 2016-01-21 14:44:23 +01:00
parent bf5eb78788
commit 4406f270e2
3 changed files with 13 additions and 11 deletions

View File

@ -6,7 +6,7 @@
* 0: Measurement Accuracy (default: 1) <NUMBER> * 0: Measurement Accuracy (default: 1) <NUMBER>
* 1: Maximum measure distance (default: 5000) <NUMBER> * 1: Maximum measure distance (default: 5000) <NUMBER>
* 2: Minimum measure distance (default: 0) <NUMBER> * 2: Minimum measure distance (default: 0) <NUMBER>
* 3: Update display (default: true) <BOOL> * 3: Blank display on range error (default: false) <BOOL>
* *
* Return value: * Return value:
* Measured distance <NUMBER> * Measured distance <NUMBER>
@ -15,7 +15,7 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_accuracy",1], ["_maxDistance",5000], ["_minDistance",0],["_update",true]]; params [["_accuracy",1], ["_maxDistance",5000], ["_minDistance",0], ["_blank",false]];
disableSerialization; disableSerialization;
private _dlgRangefinder = uiNamespace getVariable ["ACE_dlgRangefinder", displayNull]; private _dlgRangefinder = uiNamespace getVariable ["ACE_dlgRangefinder", displayNull];
@ -37,13 +37,15 @@ if (_distance == 0) then {
_distance = (round (_distance/_accuracy)) * _accuracy; _distance = (round (_distance/_accuracy)) * _accuracy;
}; };
if (_update) then { // Change the display if the range is out of bounds
// Display the minimum or maximum distance with an * if out of bounds if (_distance >= _maxDistance || _distance <= _minDistance) then {
if (_distance >= _maxDistance || _distance <= _minDistance) then { if (_blank) then {
(_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber) + "*"; (_dlgRangefinder displayCtrl 1713151) ctrlSetText "----";
} else { } else {
(_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber); (_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber) + "*";
}; };
} else {
(_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber);
}; };
_distance _distance

View File

@ -17,12 +17,14 @@ params ["_vehicle", "_turret"];
private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath); private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);
// Update display for infantry rangefinders
if (_vehicle == ACE_player) exitWith {[5,5500,25,true] call FUNC(getRange)};
private _distance = [ private _distance = [
getNumber (_turretConfig >> QGVAR(DistanceInterval)), getNumber (_turretConfig >> QGVAR(DistanceInterval)),
getNumber (_turretConfig >> QGVAR(MaxDistance)), getNumber (_turretConfig >> QGVAR(MaxDistance)),
getNumber (_turretConfig >> QGVAR(MinDistance)) getNumber (_turretConfig >> QGVAR(MinDistance))
] call FUNC(getRange); ] call FUNC(getRange);
// call FUNC(updateRangeHUD);
if !(!GVAR(enabled) && FUNC(canUseFCS)) exitWith {}; if !(!GVAR(enabled) && FUNC(canUseFCS)) exitWith {};

View File

@ -17,8 +17,6 @@ params ["_vehicle", "_turret", "_distance", ["_showHint", false], ["_playSound",
private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath); private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);
// call FUNC(updateRangeHUD);
if (isNil "_distance") then { if (isNil "_distance") then {
_distance = [ _distance = [
getNumber (_turretConfig >> QGVAR(DistanceInterval)), getNumber (_turretConfig >> QGVAR(DistanceInterval)),
@ -56,7 +54,7 @@ if (ACE_time - GVAR(time) > 1 && GVAR(time) != -1 && isNil {_this select 2}) the
private _timeToLive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "timeToLive"); private _timeToLive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "timeToLive");
private _simulationStep = getNumber (configFile >> "CfgAmmo" >> _ammo >> "simulationStep"); private _simulationStep = getNumber (configFile >> "CfgAmmo" >> _ammo >> "simulationStep");
private _initSpeedCoef = getNumber (configFile >> "CfgWeapons" >> _weapon >> "initSpeed"); private _initSpeedCoef = getNumber (configFile >> "CfgWeapons" >> _weapon >> "initSpeed");
private _simulationType = getNumber (configFile >> "CfgAmmo" >> _ammo >> "simulation"); private _simulationType = getText (configFile >> "CfgAmmo" >> _ammo >> "simulation");
// More BIS fix // More BIS fix
if (_simulationType == "shotBullet") then { if (_simulationType == "shotBullet") then {