diff --git a/GameVersion.cpp b/GameVersion.cpp index 188b1f64..0c953d23 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -23,12 +23,12 @@ INT16 zVersionLabel[256] = { L"Beta v. 0.98" }; #else //RELEASE BUILD VERSION - INT16 zVersionLabel[256] = { L"Release v1.13.328" }; + INT16 zVersionLabel[256] = { L"Release v1.13.332" }; #endif -INT8 czVersionNumber[16] = { "Build 06.07.02" }; +INT8 czVersionNumber[16] = { "Build 06.07.06" }; INT16 zTrackingNumber[16] = { L"Z" }; diff --git a/Tactical/Inventory Choosing.cpp b/Tactical/Inventory Choosing.cpp index 52a09ebe..a848efeb 100644 --- a/Tactical/Inventory Choosing.cpp +++ b/Tactical/Inventory Choosing.cpp @@ -2627,13 +2627,42 @@ UINT16 SelectStandardArmyGun( UINT8 uiGunLevel ) if (!ItemIsLegal(usGunIndex)) //Madd: check for tons of guns usGunIndex = -1; + //Check to avoid an endless loop looking for "normal" guns if (usGunIndex == -1) { - //Madd: there better be something from the original JA2 guns here somewhere (biggunlist=0) or else this will probably cause an endless loop - if ( uiGunLevel < ARMY_GUN_LEVELS ) - uiGunLevel++; - else - uiGunLevel--; + //Madd: there better be something from the original JA2 guns here somewhere (biggunlist=0)! + int numTries = 0; + //Try 5 more times... + while (numTries < 5 && usGunIndex == -1) + { + uiChoice = Random(pGunChoiceTable[ uiGunLevel ].ubChoices); + usGunIndex = pGunChoiceTable[ uiGunLevel ].bItemNo[ uiChoice ]; + + if (!ItemIsLegal(usGunIndex)) //Madd: check for tons of guns + usGunIndex = -1; + + numTries++; + } + + if (usGunIndex == -1) //We still haven't found one! Start just looping through the guns then + { + for (int i=0;iusAttackingWeapon = pSoldier->inv[HANDPOS].usItem; @@ -155,9 +157,17 @@ void CalcBestShot(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestShot, BOOLEAN shootUns continue; // next merc // if this opponent is not currently in sight (ignore known but unseen!) - if ((pSoldier->bOppList[pOpponent->ubID] != SEEN_CURRENTLY && !shootUnseen) || - (shootUnseen && gbPublicOpplist[pSoldier->bTeam][pOpponent->ubID] != SEEN_CURRENTLY) ) + if ((pSoldier->bOppList[pOpponent->ubID] != SEEN_CURRENTLY && !shootUnseen)) //guys we can't see + { + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("CalcBestShot: soldier = %d, target = %d, skip guys we can't see, shootUnseen = %d, personal opplist = %d",pSoldier->ubID, pOpponent->ubID, shootUnseen, pSoldier->bOppList[pOpponent->ubID])); continue; // next opponent + } + if ((pSoldier->bOppList[pOpponent->ubID] != SEEN_CURRENTLY && gbPublicOpplist[pSoldier->bTeam][pOpponent->ubID] != SEEN_CURRENTLY)) // guys nobody sees + { + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("CalcBestShot: soldier = %d, target = %d, skip guys nobody sees, shootUnseen = %d, public opplist = %d",pSoldier->ubID, pOpponent->ubID, shootUnseen,gbPublicOpplist[pSoldier->bTeam][pOpponent->ubID])); + continue; // next opponent + } + // Special stuff for Carmen the bounty hunter if (pSoldier->bAttitude == ATTACKSLAYONLY && pOpponent->ubProfile != SLAY) diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index 57959fec..d327baab 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -4026,19 +4026,23 @@ bCanAttack = FALSE; { case AI_ACTION_FIRE_GUN: memcpy(&BestAttack,&BestShot,sizeof(BestAttack)); + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: best attack = firing a gun"); break; case AI_ACTION_TOSS_PROJECTILE: memcpy(&BestAttack,&BestThrow,sizeof(BestAttack)); + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: best attack = tossing a grenade"); break; case AI_ACTION_THROW_KNIFE: case AI_ACTION_KNIFE_MOVE: + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: best attack = stab with a knife"); memcpy(&BestAttack,&BestStab,sizeof(BestAttack)); break; default: // set to empty + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: best attack = no good attack"); memset( &BestAttack, 0, sizeof( BestAttack ) ); break; } @@ -4060,6 +4064,7 @@ bCanAttack = FALSE; fAllowCoverCheck = TRUE; if ( PreRandom( 10 ) > BestAttack.ubChanceToReallyHit ) { + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: can't hit so screw the attack"); // screw the attack! ubBestAttackAction = AI_ACTION_NONE; } @@ -4090,6 +4095,7 @@ bCanAttack = FALSE; sBestCover = NOWHERE; #endif + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: DECIDE BETWEEN ATTACKING AND DEFENDING (TAKING COVER)"); ////////////////////////////////////////////////////////////////////////// // IF NECESSARY, DECIDE BETWEEN ATTACKING AND DEFENDING (TAKING COVER) ////////////////////////////////////////////////////////////////////////// @@ -4155,15 +4161,19 @@ bCanAttack = FALSE; DebugAI( tempstr ); #endif + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: if his defensive instincts win out, forget all about the attack"); // if his defensive instincts win out, forget all about the attack if (iDefense > iOffense) ubBestAttackAction = AI_ACTION_NONE; } + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("DecideActionBlack: is attack still desirable? ubBestAttackAction = %d",ubBestAttackAction)); + // if attack is still desirable (meaning it's also preferred to taking cover) if (ubBestAttackAction != AI_ACTION_NONE) { + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: attack is still desirable (meaning it's also preferred to taking cover)"); // if we wanted to be REALLY mean, we could look at chance to hit and decide whether // to shoot at the head... @@ -4254,6 +4264,7 @@ bCanAttack = FALSE; pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 1 && (pSoldier->bTeam != gbPlayerNum || pSoldier->bRTPCombat == RTP_COMBAT_AGGRESSIVE) ) { + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: ENOUGH APs TO BURST, RANDOM CHANCE OF DOING SO"); ubBurstAPs = CalcAPsToBurst( CalcActionPoints( pSoldier ), &(pSoldier->inv[BestAttack.bWeaponIn]) ); @@ -4316,6 +4327,7 @@ bCanAttack = FALSE; (( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 1 && BestAttack.ubAimTime != BURSTING ) || Weapon[pSoldier->inv[BestAttack.bWeaponIn].usItem].NoSemiAuto) ) { + DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"DecideActionBlack: ENOUGH APs TO AUTOFIRE, RANDOM CHANCE OF DOING SO"); pSoldier->bDoAutofire = 0; do {