Skip to content

Commit

Permalink
Show correct elev for mortar with no ammo (#4478)
Browse files Browse the repository at this point in the history
Fix #3757
  • Loading branch information
PabstMirror authored Oct 7, 2016
1 parent 1756ca2 commit ef9fd92
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ef9fd92

Please sign in to comment.