diff --git a/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf b/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf index 5c74927e46..69a71c63ca 100644 --- a/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf +++ b/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf @@ -46,8 +46,8 @@ if (_lastFireMode != -1) then { [{ private ["_chargeText", "_currentChargeMode", "_currentFireMode", "_display", "_elevDeg", "_elevationDiff", "_lookVector", "_notGunnerView", "_realAzimuth", "_realElevation", "_upVectorDir", "_useMils", "_weaponDir"]; - PARAMS_2(_args,_pfID); - EXPLODE_2_PVT(_args,_mortarVeh,_fireModes); + params ["_args", "_pfID"]; + _args params ["_mortarVeh", "_fireModes"]; if ((vehicle ACE_player) != _mortarVeh) then { [_pfID] call CBA_fnc_removePerFrameHandler; @@ -80,7 +80,19 @@ if (_lastFireMode != -1) then { //(looking at the sky VS looking at ground will radicaly change fire direction because BIS) _realAzimuth = -1; _realElevation = -1; - if ((ctrlText (_display displayCtrl 173)) == "--") then { + + private _useRealWeaponDir = (ctrlText (_display displayCtrl 173)) == "--"; + if (_useRealWeaponDir && {(_mortarVeh ammo (currentWeapon _mortarVeh)) == 0}) then { + // With no ammo, distance display will be empty, but gun will still fire at wonky angle if aimed at ground + private _testSeekerPosASL = AGLtoASL (positionCameraToWorld [0,0,0]); + private _testSeekerDir = _testSeekerPosASL vectorFromTo (AGLtoASL (positionCameraToWorld [0,0,1])); + private _laserRange = [_testSeekerPosASL, _testSeekerDir, _mortarVeh] call EFUNC(laser,shootRay); + _laserRange params ["", ["_rayDistance", -5]]; // ToDo: move shootRay to common + TRACE_2("",_rayDistance,viewDistance); + _useRealWeaponDir = _rayDistance > viewDistance; // If we are looking at infinity (based on viewDistance) + }; + + if (_useRealWeaponDir) then { //No range (looking at sky), it will follow weaponDir: _weaponDir = _mortarVeh weaponDirection (currentWeapon _mortarVeh); _realAzimuth = (_weaponDir select 0) atan2 (_weaponDir select 1);