From 762fb79c0950f5eb9bfb6d17678a30d8d4584909 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Sun, 3 Jul 2016 09:53:56 +0000 Subject: [PATCH] CalcEffVolume fix: sleeping state check Attacks fix: 100 AP system for HitRate calculation EstimatePath fix: ignore person at destination if we are estimating path cost FindFlankingSpot: use full search range git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8265 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/PATHAI.cpp | 4 +++- Tactical/opplist.cpp | 11 ++++++----- TacticalAI/Attacks.cpp | 16 ++++++++++++---- TacticalAI/FindLocations.cpp | 4 ++-- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index f3eac262..eeafd4dd 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -4433,7 +4433,9 @@ INT32 PlotPath( SOLDIERTYPE *pSold, INT32 sDestGridNo, INT8 bCopyRoute, INT8 bPl // distance limit to reduce the cost of plotting a path to a location we can't reach // For now, use known hight adjustment - if ( gfRecalculatingExistingPathCost || FindBestPath( pSold, sDestGridNo, pSold->pathing.bLevel, usMovementMode, bCopyRoute, 0 ) ) + // sevenfm: ignore person at destination if we are estimating path cost + if ( gfRecalculatingExistingPathCost || FindBestPath( pSold, sDestGridNo, pSold->pathing.bLevel, usMovementMode, bCopyRoute, gfEstimatePath ? PATH_IGNORE_PERSON_AT_DEST : 0 ) ) + //if ( gfRecalculatingExistingPathCost || FindBestPath( pSold, sDestGridNo, pSold->pathing.bLevel, usMovementMode, bCopyRoute, 0 ) ) { // if soldier would be STARTING to run then he pays a penalty since it takes time to // run full speed diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp index de7a1a84..73b379c0 100644 --- a/Tactical/opplist.cpp +++ b/Tactical/opplist.cpp @@ -6332,11 +6332,12 @@ UINT8 CalcEffVolume(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT8 ubN iEffVolume -= 5; } - if (pSoldier->bAssignment == SLEEPING ) - { - // decrease effective volume since we're asleep! - iEffVolume -= 5; - } + //if (pSoldier->bAssignment == SLEEPING ) + if( pSoldier->flags.fMercAsleep ) + { + // decrease effective volume since we're asleep! + iEffVolume -= 5; + } // check for floor/roof difference if (bLevel > pSoldier->pathing.bLevel) diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index b3f5ab78..abef54b4 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -421,7 +421,9 @@ void CalcBestShot(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestShot, BOOLEAN shootUns //sprintf(tempstr,"Vs. %s, at AimTime %d, ubChanceToHit = %d",ExtMen[pOpponent->ubID].GetName(),ubAimTime,ubChanceToHit); //PopMessage(tempstr); - iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); + // sevenfm: 100 AP system + iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime * APBPConstants[AP_CLICK_AIM]); + //iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); //NumMessage("hitRate = ",iHitRate); // if aiming for this amount of time produces a better hit rate @@ -446,7 +448,9 @@ void CalcBestShot(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestShot, BOOLEAN shootUns ubChanceToHit = ubChanceToHit2; } Assert( ubRawAPCost > 0); - iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); + // sevenfm: 100AP system + iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime * APBPConstants[AP_CLICK_AIM]); + //iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); iBestHitRate = iHitRate; ubBestAimTime = ubAimTime; ubBestChanceToHit = ubChanceToHit; @@ -1665,7 +1669,9 @@ void CalcBestStab(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestStab, BOOLEAN fBladeAt if (ubRawAPCost < 1) ubRawAPCost = ubMinAPCost; - iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); + // sevenfm: 100AP system + iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime * APBPConstants[AP_CLICK_AIM]); + //iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); //NumMessage("hitRate = ",iHitRate); // if aiming for this amount of time produces a better hit rate @@ -1845,7 +1851,9 @@ void CalcTentacleAttack(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestStab ) if (ubRawAPCost < 1) ubRawAPCost = ubMinAPCost; - iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); + // sevenfm: 100AP system + iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime * APBPConstants[AP_CLICK_AIM]); + //iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); //NumMessage("hitRate = ",iHitRate); // if aiming for this amount of time produces a better hit rate diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index aba17996..fd64ce57 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -2553,9 +2553,9 @@ INT32 FindFlankingSpot(SOLDIERTYPE *pSoldier, INT32 sPos, INT8 bAction ) DebugMsg ( TOPIC_JA2AI , DBG_LEVEL_3 , String("FindFlankingSpot: direction to loc = %d, dir to flank = %d", sDir , sDesiredDir )); - for (sYOffset = -sMaxUp + 1; sYOffset <= sMaxDown - 1; sYOffset++) + for (sYOffset = -sMaxUp; sYOffset <= sMaxDown; sYOffset++) { - for (sXOffset = -sMaxLeft + 1; sXOffset <= sMaxRight - 1; sXOffset++) + for (sXOffset = -sMaxLeft; sXOffset <= sMaxRight; sXOffset++) { // calculate the next potential gridno sGridNo = pSoldier->sGridNo + sXOffset + (MAXCOL * sYOffset);