# HG changeset patch # User Grumpy7 # Date 1379782090 -7200 # Node ID df30a0c901e54c0c8765e94ba2ec796872b7d6a4 # Parent 2a309997c42f8dea4e5f8d3df5cb7401a31dbdb2 Player::StealFromShop finishing cleanup diff -r 2a309997c42f -r df30a0c901e5 Player.cpp --- a/Player.cpp Sat Sep 21 12:38:43 2013 +0200 +++ b/Player.cpp Sat Sep 21 18:48:10 2013 +0200 @@ -60,9 +60,9 @@ -std::array StealingMasteryBonuses = {0, 100, 200, 300, 500}; -std::array StealingRandomBonuses = {-200, -100, 0, 100, 200}; -std::array StealingEnchantmentBonusForSkill = {0, 2, 4, 6, 10}; +std::array StealingMasteryBonuses = {0, 100, 200, 300, 500}; //dword_4EDEA0 +std::array StealingRandomBonuses = {-200, -100, 0, 100, 200}; //dword_4EDEB4 +std::array StealingEnchantmentBonusForSkill = {0, 2, 4, 6, 10}; //dword_4EDEC4 @@ -2014,15 +2014,14 @@ } //----- (0048D76C) -------------------------------------------------------- -bool Player::StealFromShop(ItemGen *itemToSteal, int a3, int reputation, int a5, int *a6) //check stealing in IDA pro once I get home. The whole thing looks odd, dword_4EDEB4 and dword_4EDEA0 are never filled, might be a bug, might me on purpose +int Player::StealFromShop( ItemGen *itemToSteal, int extraStealDifficulty, int reputation, int a5, int *fineIfFailed ) //returns an int, but is the return value is compared to zero, so might change to bool { unsigned __int16 v6; // cx@8 int v7; // edi@8 unsigned int v8; // ebx@8 unsigned int itemvalue; // esi@8 int v10; // eax@8 - int v11; // edi@12 - bool result; // eax@13 + int currMaxItemValue; // edi@12 if ( !itemToSteal || this->IsEradicated() @@ -2032,7 +2031,7 @@ || this->IsUnconcious() || this->IsAsleep() ) { - result = 0; + return 0; } else { @@ -2041,23 +2040,33 @@ v8 = SkillToMastery(v6); itemvalue = itemToSteal->GetValue(); v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType; - if ( !pItemsTable->pItems[itemToSteal->uItemID].uEquipType || v10 == 1 || v10 == 2 ) + if ( v10 == 0 || v10 == 1 || v10 == 2 ) itemvalue *= 3; - v11 = StealingRandomBonuses[rand() % 100 / 20] + v7 * StealingMasteryBonuses[v8]; - *a6 = 100 * (reputation + a3) + itemvalue + (a5 != 0 ? 0x1F4 : 0); + currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8]; + *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue; + if (a5) + { + *fineIfFailed += 500; + } if ( rand() % 100 >= 5 ) { - if ( *a6 > v11 ) - result = *a6 - v11 < 500; + if ( *fineIfFailed > currMaxItemValue ) + if (*fineIfFailed - currMaxItemValue < 500) + { + return 1; + } + else + { + return 0; + } else - result = 2; + return 2; } else { - result = 0; - } - } - return result; + return 0; + } + } } // 4EDEA0: using guessed type int dword_4EDEA0[]; // 4EDEB4: using guessed type int dword_4EDEB4[]; diff -r 2a309997c42f -r df30a0c901e5 Player.h --- a/Player.h Sat Sep 21 12:38:43 2013 +0200 +++ b/Player.h Sat Sep 21 18:48:10 2013 +0200 @@ -514,7 +514,7 @@ bool HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex); bool HasEnchantedItemEquipped(int uEnchantment); bool WearsItem(int item_id, ITEM_EQUIP_TYPE equip_type); - bool StealFromShop(struct ItemGen *a2, int a3, int a4, int a5, int *a6); + int StealFromShop( ItemGen *itemToSteal, int a3, int reputation, int a5, int *fineIfFailed); int StealFromActor(unsigned int uActorID, int _steal_perm, int reputation); void Heal(int amount); int ReceiveDamage(signed int amount, DAMAGE_TYPE dmg_type);