Fix: if DYNAMIC_IMP_PROFILE_COST is TRUE, the IMP cost is too high(by sun_alf)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8831 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2020-06-30 20:23:25 +00:00
parent 8119662904
commit 9f167f16c6
4 changed files with 11 additions and 12 deletions
+8 -9
View File
@@ -323,7 +323,7 @@ void BtnIMPConfirmYes(GUI_BUTTON *btn,INT32 reason)
// silversurfer: We need to store the profile cost here because right now our new IMP doesn't occupy a slot yet.
// However function iGetProfileCost() will already calculate price including that slot. We would charge too much money after the IMP is created below.
INT32 iIMPCost = GetProfileCost(TRUE);
INT32 iIMPCost = GetProfileCost(TRUE, FALSE);
if( LaptopSaveInfo.iCurrentBalance < iIMPCost )
{
// not enough
@@ -1565,7 +1565,7 @@ BOOLEAN LoadImpCharacter( STR nickName )
// silversurfer: Store current IMP cost. Function iGetProfileCost() already takes the new slot into account.
// If we create the IMP first we would charge too much.
INT32 iIMPCost = GetProfileCost(FALSE);
INT32 iIMPCost = GetProfileCost(FALSE, TRUE);
// Flugente: as we do not store the cost of the gear in the IMP file, we have to determine the cost here
iIMPCost += max(0, GetEquippedGearCost( &gMercProfiles[iProfileId] ) - gGameExternalOptions.iIMPProfileCost );
@@ -1763,19 +1763,18 @@ void GiveIMPItems( MERCPROFILESTRUCT *pProfile, INT8 abilityValue, UINT8 typeInd
}
// SANDRO - Function to determine actual cost of profile
INT32 GetProfileCost( BOOLEAN aWithGearCost )
INT32 GetProfileCost( BOOLEAN aWithGearCost, BOOLEAN profileSlotAllocated )
{
// Flugente: aditional imp gear cost
INT32 impgearcost = aWithGearCost ? GetIMPGearCost() : 0;
INT32 impProfileCost = gGameExternalOptions.iIMPProfileCost;
if (gGameExternalOptions.fDynamicIMPProfileCost)
{
// silversurfer: When we create an IMP he doesn't occupy a slot yet so we need to add 1 to get the correct price in advance.
INT32 iIMPProfileCost = gGameExternalOptions.iIMPProfileCost * (CountFilledIMPSlots() + 1);
if ( iIMPProfileCost + impgearcost >= gGameExternalOptions.iIMPProfileCost )
return iIMPProfileCost + impgearcost;
// sun_alf: if the IMP profile already occupies a slot, CountFilledIMPSlots() return the number we want to multiply on,
// but if a slot is not allocated still, we need to add 1 to get the correct price in advance.
impProfileCost *= profileSlotAllocated ? CountFilledIMPSlots() : CountFilledIMPSlots() + 1;
}
return gGameExternalOptions.iIMPProfileCost + impgearcost;
return impProfileCost + impgearcost;
}
+1 -1
View File
@@ -71,7 +71,7 @@ void ResetIMPCharactersEyesAndMouthOffsets( UINT8 ubMercProfileID );
BOOLEAN ImpExists ( STR fileName );
INT32 GetProfileCost( BOOLEAN aWithGearCost ); // added by SANDRO
INT32 GetProfileCost( BOOLEAN aWithGearCost, BOOLEAN profileSlotAllocated ); // added by SANDRO
void MakeProfileInvItemAnySlot( MERCPROFILESTRUCT *pProfile, UINT16 usItem, UINT8 ubStatus, UINT8 ubHowMany );
+1 -1
View File
@@ -401,7 +401,7 @@ void BtnIMPMainPageBeginCallback(GUI_BUTTON *btn,INT32 reason)
}
else
{
if( LaptopSaveInfo.iCurrentBalance < GetProfileCost(FALSE) ) // SANDRO - changed to find actual profile cost in IMPConfirm
if( LaptopSaveInfo.iCurrentBalance < GetProfileCost(FALSE, FALSE) ) // SANDRO - changed to find actual profile cost in IMPConfirm
{
DoLapTopMessageBox( MSG_BOX_IMP_STYLE, pImpPopUpStrings[ 3 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, BeginMessageBoxCallBack);
}
+1 -1
View File
@@ -351,7 +351,7 @@ void PrintImpText( void )
//LoadAndDisplayIMPText( LAPTOP_SCREEN_UL_X + 160, LAPTOP_SCREEN_WEB_UL_Y + 145, ( 200 ), IMP_CON_3 , FONT12ARIAL, FONT_WHITE, TRUE, 0);
// SANDRO - changed to show exact cost of profile
CHAR16 chPayCost[1000];
swprintf( chPayCost, gzIMPProfileCostText[ 0 ], GetProfileCost(TRUE) );
swprintf( chPayCost, gzIMPProfileCostText[ 0 ], GetProfileCost(TRUE, FALSE) );
DisplayWrappedString( LAPTOP_SCREEN_UL_X + 160, LAPTOP_SCREEN_WEB_UL_Y + 145, ( 200 ), 2, FONT12ARIAL, FONT_WHITE, chPayCost,FONT_BLACK,FALSE,LEFT_JUSTIFIED);
break;