From ec87dd51e6c3ba1df97acfdd7d0192e803bf0512 Mon Sep 17 00:00:00 2001 From: ChrisL Date: Thu, 17 Jul 2008 00:16:16 +0000 Subject: [PATCH] SpaceViking's random number and CTH adjustments. OIV Graphic alignment correction. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2242 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Standard Gaming Platform/Random.cpp | 15 ++++++++++++++- Tactical/Interface Panels.cpp | 14 ++++++++++++-- Tactical/Weapons.cpp | 8 ++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Standard Gaming Platform/Random.cpp b/Standard Gaming Platform/Random.cpp index abbb4521..36119b65 100644 --- a/Standard Gaming Platform/Random.cpp +++ b/Standard Gaming Platform/Random.cpp @@ -78,8 +78,21 @@ UINT32 PreRandom( UINT32 uiRange ) //Go to the next index. guiPreRandomIndex++; - if( guiPreRandomIndex >= (UINT32)MAX_PREGENERATED_NUMS ) + //if( guiPreRandomIndex >= (UINT32)MAX_PREGENERATED_NUMS ) + // guiPreRandomIndex = 0; + // WDS 07/06/2008 fix prerandom + if (guiPreRandomIndex == MAX_PREGENERATED_NUMS / 2) { + // [0..(MAX_PREGENERATED_NUMS/2) -1] + for( unsigned idx = 0; idx < MAX_PREGENERATED_NUMS / 2; ++idx ) { + guiPreRandomNums[ idx ] = rand(); + } + } else if (guiPreRandomIndex >= (UINT32)MAX_PREGENERATED_NUMS ) { + // MAX_PREGENERATED_NUMS/2 .. MAX_PREGENERATED_NUMS-1] + for( unsigned idx = MAX_PREGENERATED_NUMS / 2; idx < MAX_PREGENERATED_NUMS; ++idx ) { + guiPreRandomNums[ idx ] = rand(); + } guiPreRandomIndex = 0; + } return uiNum; } diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index d22cd6b2..765e1230 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -3476,7 +3476,13 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason ) invWidth = 314; //InitItemStackPopup( gpSMCurrentMerc, (UINT8)uiHandPos, SM_ITEMDESC_START_X, SM_ITEMDESC_START_Y, SM_ITEMDESC_WIDTH, SM_ITEMDESC_HEIGHT ); - InitItemStackPopup( gpSMCurrentMerc, (UINT8)uiHandPos, 248, INV_INTERFACE_START_Y, invWidth, ( SCREEN_HEIGHT - INV_INTERFACE_START_Y ) ); + //CHRISL: In OIV mode, we don't want to offset the keyring popup. + UINT8 inv_interface_start_x; + if(UsingNewInventorySystem() == false) + inv_interface_start_x = 213; + else + inv_interface_start_x = 248; + InitItemStackPopup( gpSMCurrentMerc, (UINT8)uiHandPos, inv_interface_start_x, INV_INTERFACE_START_Y, invWidth, ( SCREEN_HEIGHT - INV_INTERFACE_START_Y ) ); } } @@ -6373,7 +6379,11 @@ void BeginKeyPanelFromKeyShortcut( ) if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) return; - InitKeyRingPopup( pSoldier, 35, sStartYPosition, sWidth, sHeight ); + //CHRISL: In OIV mode, we don't want to offset the keyring popup. + if(UsingNewInventorySystem() == false) + InitKeyRingPopup( pSoldier, 0, sStartYPosition, sWidth, sHeight ); + else + InitKeyRingPopup( pSoldier, 35, sStartYPosition, sWidth, sHeight ); } diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 3d88c364..2b680bf4 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -1717,7 +1717,9 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) } // big penalty to hit - if(uiHitChance < 30) + // WDS 07/06/2008 fix randoms + //if(uiHitChance < 30) + if(uiHitChance <= 30) uiHitChance = MINCHANCETOHIT; else uiHitChance -= 30; @@ -1750,7 +1752,9 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) } #endif - fGonnaHit = uiDiceRoll <= uiHitChance; + // WDS 07/06/2008 fix randoms + //fGonnaHit = uiDiceRoll <= uiHitChance; + fGonnaHit = uiDiceRoll = uiHitChance; // GET TARGET XY VALUES ConvertGridNoToCenterCellXY( sTargetGridNo, &sXMapPos, &sYMapPos );