From 8f5ac3a9351a62fb00494fdde70ea248d5422b59 Mon Sep 17 00:00:00 2001 From: Flugente Date: Tue, 30 Jul 2013 18:17:54 +0000 Subject: [PATCH] Fix: NCTH throws error if not firing at soldier git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6261 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Weapons.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index ba119f93..8ce8eb90 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -12145,10 +12145,14 @@ FLOAT CalcNewChanceToHitBaseTargetBonus(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pTar fBaseModifier += fTempPenalty; } - - // Target has high Agility or Experience and is therefore harder to hit - FLOAT fTempPenalty = (FLOAT)__max((pTarget->stats.bExpLevel*10), pTarget->stats.bAgility); - fBaseModifier += (fTempPenalty * gGameCTHConstants.BASE_AGILE_TARGET) / 100; + + // Flugente: there needs to be a target... + if ( pTarget ) + { + // Target has high Agility or Experience and is therefore harder to hit + FLOAT fTempPenalty = (FLOAT)__max((pTarget->stats.bExpLevel*10), pTarget->stats.bAgility); + fBaseModifier += (fTempPenalty * gGameCTHConstants.BASE_AGILE_TARGET) / 100; + } // INVIS TARGET if (fCantSeeTarget)