From f2d401b76912f75d1b0df3eb1df2f1cbd428cbbf Mon Sep 17 00:00:00 2001 From: MaddMugsy Date: Mon, 28 Aug 2006 17:46:44 +0000 Subject: [PATCH] -minor fix: PickARandomLaunchable now looks at the HighestPlayerProgress percentage, so early enemy GLs won't use thermobarics git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@482 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Items.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index b06d219c..f39ecbd2 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -7342,6 +7342,23 @@ INT8 FindRemoteControl( SOLDIERTYPE * pSoldier ) return( NO_SLOT ); } +UINT16 LowestLaunchableCoolness(UINT16 launcherIndex) +{ + UINT16 i = 0; + UINT16 lowestCoolness = 999; + + for( i = 0; i < MAXITEMS; i++ ) + { + if ( Item[i].usItemClass == 0 ) + break; + + if( ValidLaunchable( i, launcherIndex ) && Item[i].ubCoolness <= lowestCoolness ) + { + lowestCoolness = Item[i].ubCoolness; + } + } + return lowestCoolness; +} UINT16 PickARandomLaunchable(UINT16 itemIndex) { @@ -7349,7 +7366,7 @@ UINT16 PickARandomLaunchable(UINT16 itemIndex) UINT16 usNumMatches = 0; UINT16 usRandom = 0; UINT16 i = 0; - + UINT16 lowestCoolness = LowestLaunchableCoolness(itemIndex); //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("PickARandomLaunchable: itemIndex = %d", itemIndex)); while( !usNumMatches ) @@ -7358,8 +7375,8 @@ UINT16 PickARandomLaunchable(UINT16 itemIndex) { if ( Item[i].usItemClass == 0 ) break; - - if( ValidLaunchable( i, itemIndex ) ) + //Madd: quickfix: make it not choose best grenades right away. + if( ValidLaunchable( i, itemIndex ) && Item[i].ubCoolness <= max(HighestPlayerProgressPercentage()/10,lowestCoolness) ) usNumMatches++; } } @@ -7371,7 +7388,7 @@ UINT16 PickARandomLaunchable(UINT16 itemIndex) if ( Item[i].usItemClass == 0 ) break; - if( ValidLaunchable( i, itemIndex ) ) + if( ValidLaunchable( i, itemIndex ) && Item[i].ubCoolness <= max(HighestPlayerProgressPercentage()/10,lowestCoolness) ) { if( usRandom ) usRandom--;