From f4cbb59720c37cd003038b97b1af45d19a92adab Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Wed, 9 Aug 2017 14:32:16 +0000 Subject: [PATCH] - DisplayLoadScreenWithID: use strcmp to correctly compare strings - CalcThrownChanceToHit: fix integer calculation - CalcBestThrow: allow CTH bonus for mortars, new less restrictive CTH check to allow attack git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8443 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Loading Screen.cpp | 2 +- Tactical/Weapons.cpp | 2 +- TacticalAI/Attacks.cpp | 42 ++++++++++++++++++------------------------ 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Loading Screen.cpp b/Loading Screen.cpp index cf9278e7..d5da574d 100644 --- a/Loading Screen.cpp +++ b/Loading Screen.cpp @@ -360,7 +360,7 @@ void DisplayLoadScreenWithID( UINT8 ubLoadScreenID ) vs_desc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE | VSURFACE_CREATE_FROMPNG_FALLBACK; szSector = szSectorMap [gWorldSectorY][gWorldSectorX]; - const BOOLEAN fExternalLS = (szSector != NULL && szSector != "N") && ((DAY <= ubLoadScreenID && ubLoadScreenID <= NIGHT_ALT) || (ubLoadScreenID == UNDERGROUND)); + const BOOLEAN fExternalLS = (szSector != NULL && strcmp(szSector, "N") != 0) && ((DAY <= ubLoadScreenID && ubLoadScreenID <= NIGHT_ALT) || (ubLoadScreenID == UNDERGROUND)); if (fExternalLS) { diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index f2afd105..8d9fbd98 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -10523,7 +10523,7 @@ UINT32 CalcThrownChanceToHit(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi if ( Item[ usHandItem ].mortar ) { if (HAS_SKILL_TRAIT( pSoldier, HEAVY_WEAPONS_NT )) - iChance += (gSkillTraitValues.sCtHModifierMortar * max( 0, ((100 - gSkillTraitValues.ubHWMortarCtHPenaltyReduction * NUM_SKILL_TRAITS( pSoldier, HEAVY_WEAPONS_NT ))/100))); + iChance += gSkillTraitValues.sCtHModifierMortar * max( 0, 100 - gSkillTraitValues.ubHWMortarCtHPenaltyReduction * NUM_SKILL_TRAITS( pSoldier, HEAVY_WEAPONS_NT )) / 100; else iChance += gSkillTraitValues.sCtHModifierMortar; // -60% for untrained mercs } diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index 0301e4c2..059ca7c4 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -1441,9 +1441,8 @@ void CalcBestThrow(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestThrow) //SendFmtMsg("CalcBestThrow=%d APs=%d mat=%d gno=%d", ubChanceToHit, ubRawAPCost, ubMaxPossibleAimTime, sGridNo); } - // mortars are inherently quite inaccurate, don't get proximity bonus - // rockets can go right past people too so... - if (!Item[usInHand].mortar && EXPLOSIVE_GUN( usInHand ) ) + // no bonus for RPGs as they can miss too much + if ( !EXPLOSIVE_GUN( usInHand ) ) { // special 50% to Hit bonus: this reflects that even if a tossed item // misses by a bit, it's still likely to affect the intended target(s) @@ -1502,29 +1501,24 @@ void CalcBestThrow(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestThrow) } } - // this is try to minimize enemies wasting their (limited) toss attacks: - switch( ubDiff ) + // this is try to minimize enemies wasting their (limited) toss attacks: + UINT8 ubMinChanceToReallyHit; + + if( usGrenade != NOTHING && Item[usGrenade].flare ) { - case 0: - case 1: - // don't use unless have a 70% chance to hit - if (pBestThrow->ubChanceToReallyHit < 70) - { - pBestThrow->ubPossible = FALSE; - } - break; - case 2: - case 3: - case 4: - // don't use unless have a 50% chance to hit - if (pBestThrow->ubChanceToReallyHit < 50) - { - pBestThrow->ubPossible = FALSE; - } - break; - default: - break; + ubMinChanceToReallyHit = 30; } + else + { + // 80-40% depending on soldier difficulty + ubMinChanceToReallyHit = 80 - 10 * ubDiff; + } + + if( pBestThrow->ubChanceToReallyHit < ubMinChanceToReallyHit ) + { + pBestThrow->ubPossible = FALSE; + } + //if(pBestThrow->ubPossible)SendFmtMsg("CalcBestThrow;\r\n ID=%d Loc=%d APs=%d Ac=%d AcData=%d Al=%d, SM=%d, LAc=%d, NAc=%d AT=%d\r\n AP?=%d,%d,%d/%d BS=%d", pSoldier->ubID, pSoldier->sGridNo, pSoldier->bActionPoints, pSoldier->aiData.bAction, pSoldier->aiData.usActionData, pSoldier->aiData.bAlertStatus, pBestThrow->bScopeMode, pSoldier->aiData.bLastAction, pSoldier->aiData.bNextAction, pBestThrow->ubAimTime, pBestThrow->ubAPCost, CalcAPCostForAiming(pSoldier, pBestThrow->sTarget, (INT8)pBestThrow->ubAimTime), CalcTotalAPsToAttack(pSoldier, pBestThrow->sTarget, TRUE, pBestThrow->ubAimTime), CalcTotalAPsToAttack(pSoldier, pBestThrow->sTarget, FALSE, pBestThrow->ubAimTime), pBestThrow->ubStance); DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"calcbestthrow done"); }