From e7fe0407226852eb97f6d921b82c0a4b022fdca2 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Wed, 14 Sep 2016 07:07:40 +0000 Subject: [PATCH] CalcChanceToHitGun, CalcNewChanceToHitGun: set fCantSeeTarget = true when shooting at empty invisible tile git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8301 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Weapons.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index d2e10210..4432a1cd 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -5313,12 +5313,19 @@ UINT32 CalcNewChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi iSightRange = 0; if (ubTargetID != NOBODY && pSoldier->aiData.bOppList[ubTargetID] == SEEN_CURRENTLY || gbPublicOpplist[pSoldier->bTeam][ubTargetID] == SEEN_CURRENTLY) + { iSightRange = SoldierToSoldierLineOfSightTest( pSoldier, MercPtrs[ubTargetID], TRUE, NO_DISTANCE_LIMIT, pSoldier->bAimShotLocation, false ); - if (iSightRange == 0) { // didn't do a bodypart-based test or can't see specific body part aimed at + } + if (iSightRange == 0) + { + // didn't do a bodypart-based test or can't see specific body part aimed at iSightRange = SoldierTo3DLocationLineOfSightTest( pSoldier, sGridNo, pSoldier->bTargetLevel, pSoldier->bTargetCubeLevel, TRUE, NO_DISTANCE_LIMIT, false ); } - if (ubTargetID != NOBODY && iSightRange == 0) { // Can't see the target but we still need to know what the sight range would be if we could so we can deal with cover penalties - iSightRange = SoldierToSoldierLineOfSightTest( pSoldier, MercPtrs[ubTargetID], TRUE, NO_DISTANCE_LIMIT, pSoldier->bAimShotLocation, false, true ); + if (iSightRange == 0) + { + // Can't see the target but we still need to know what the sight range would be if we could so we can deal with cover penalties + if (ubTargetID != NOBODY) + iSightRange = SoldierToSoldierLineOfSightTest( pSoldier, MercPtrs[ubTargetID], TRUE, NO_DISTANCE_LIMIT, pSoldier->bAimShotLocation, false, true ); fCantSeeTarget = true; } @@ -5672,9 +5679,11 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTime, fCoverObscured = true; } - if (ubTargetID != NOBODY && iSightRange == 0 ) - { // Can't see the target but we still need to know what the sight range would be if we could so we can deal with cover penalties - iSightRange = SoldierToSoldierLineOfSightTest( pSoldier, MercPtrs[ubTargetID], TRUE, NO_DISTANCE_LIMIT, pSoldier->bAimShotLocation, false, true ); + if (iSightRange == 0 ) + { + // Can't see the target but we still need to know what the sight range would be if we could so we can deal with cover penalties + if (ubTargetID != NOBODY) + iSightRange = SoldierToSoldierLineOfSightTest( pSoldier, MercPtrs[ubTargetID], TRUE, NO_DISTANCE_LIMIT, pSoldier->bAimShotLocation, false, true ); fCantSeeTarget = true; fCoverObscured = false; }