From 8b4a5309503e36baa67b410e2d593fa5de6abeec Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 18 Mar 2019 12:06:08 -0500 Subject: [PATCH] Handle invalid memPointGunOptic (CUP_BM21_Base) --- addons/artillerytables/functions/fnc_turretChanged.sqf | 7 ++++++- addons/artillerytables/functions/fnc_turretPFEH.sqf | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/artillerytables/functions/fnc_turretChanged.sqf b/addons/artillerytables/functions/fnc_turretChanged.sqf index 1e9dd5bd55..74ecb8788a 100644 --- a/addons/artillerytables/functions/fnc_turretChanged.sqf +++ b/addons/artillerytables/functions/fnc_turretChanged.sqf @@ -45,6 +45,11 @@ if ((alive _player) && {_showGunLaying > 0} && {_player == gunner _vehicle}) the private _useAltElevation = (_showGunLaying == 2) || {(["Mortar_01_base_F", "rhs_2b14_82mm_Base", "RHS_M252_Base", "CUP_B_M1129_MC_MK19_Desert", "LIB_GrWr34", "LIB_BM37"] findIf {_typeOf isKindOf _x}) > -1;}; + // If the memory point is invalid, then the turret will always use real weapon dir (tankOrCar.cpp Line 1550 _isOpticsTargetValid will always be false) (e.g. CUP BM21) + private _memoryPointGunnerOptics = getText (_turretCfg >> "memoryPointGunnerOptics"); + private _invalidGunnerMem = (_vehicle selectionPosition [_memoryPointGunnerOptics, "Memory"]) isEqualTo [0,0,0]; + if (_invalidGunnerMem) then { INFO_3("[%1-%2] turret's memoryPointGunnerOptics invalid [%3]",typeOf _vehicle,_turret,_memoryPointGunnerOptics); }; + private _weaponsTurret = _vehicle weaponsTurret _turret; if ((count _weaponsTurret) != 1) then { WARNING_2("not singular weapon in turret - %1 - %2",_typeOf,_turret); }; private _weapon = _weaponsTurret param [0, ""]; @@ -55,7 +60,7 @@ if ((alive _player) && {_showGunLaying > 0} && {_player == gunner _vehicle}) the _fireModes sort true; _fireModes = _fireModes apply {_x select 1}; - GVAR(pfID) = [LINKFUNC(turretPFEH), 0, [_vehicle, _turret, _fireModes, _useAltElevation, _turretAnimBody]] call CBA_fnc_addPerFrameHandler; + GVAR(pfID) = [LINKFUNC(turretPFEH), 0, [_vehicle, _turret, _fireModes, _useAltElevation, _turretAnimBody, _invalidGunnerMem]] call CBA_fnc_addPerFrameHandler; TRACE_1("added pfEH",GVAR(pfID)); diff --git a/addons/artillerytables/functions/fnc_turretPFEH.sqf b/addons/artillerytables/functions/fnc_turretPFEH.sqf index 5ebabc85f5..d0070d082a 100644 --- a/addons/artillerytables/functions/fnc_turretPFEH.sqf +++ b/addons/artillerytables/functions/fnc_turretPFEH.sqf @@ -14,7 +14,7 @@ * * Public: No */ -(_this select 0) params ["_vehicle", "_turret", "_fireModes", "_useAltElevation", "_turretAnimBody"]; +(_this select 0) params ["_vehicle", "_turret", "_fireModes", "_useAltElevation", "_turretAnimBody", "_invalidGunnerMem"]; if (shownArtilleryComputer && {GVAR(disableArtilleryComputer)}) then { // Still Don't like this solution, but it works @@ -56,7 +56,7 @@ private _useRealWeaponDir = if ((isNull (_display displayCtrl 173)) || {(_vehicl private _realElevation = asin (_weaponDir select 2); private _realAzimuth = 0; -if (_useRealWeaponDir) then { +if (_useRealWeaponDir || _invalidGunnerMem) then { // No range (looking at sky), it will follow weaponDir: _realAzimuth = (_weaponDir select 0) atan2 (_weaponDir select 1) } else {