changeset 1685:2a309997c42f

Player::StealFromShop started cleanup, fixing a few errors caused by not commiting everything
author Grumpy7
date Sat, 21 Sep 2013 12:38:43 +0200
parents f84b8b2a875c
children df30a0c901e5
files Items.cpp Player.cpp Player.h mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h
diffstat 7 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/Items.cpp	Fri Sep 20 10:51:42 2013 +0200
+++ b/Items.cpp	Sat Sep 21 12:38:43 2013 +0200
@@ -2388,7 +2388,7 @@
 
 bool ItemGen::IsRegularEnchanmentForAttribute( CHARACTER_ATTRIBUTE_TYPE attrToGet )
 {
-  auto bonusList = ItemGen::specialBonusMap.find(this->uSpecEnchantmentType);
+  auto bonusList = ItemGen::specialBonusMap.find(this->uEnchantmentType);
   if (bonusList == ItemGen::specialBonusMap.end())
   {
     return false;
--- a/Player.cpp	Fri Sep 20 10:51:42 2013 +0200
+++ b/Player.cpp	Sat Sep 21 12:38:43 2013 +0200
@@ -60,6 +60,9 @@
 
 
 
+std::array<int, 5> StealingMasteryBonuses = {0, 100, 200, 300, 500};
+std::array<int, 5> StealingRandomBonuses = {-200, -100, 0, 100, 200};
+std::array<int, 5> StealingEnchantmentBonusForSkill = {0, 2, 4, 6, 10};
 
 
 
@@ -2022,12 +2025,12 @@
   bool result; // eax@13
 
   if ( !itemToSteal
-    || this->pConditions[16]
-    || this->pConditions[14]
-    || this->pConditions[15]
-    || this->pConditions[4]
-    || this->pConditions[13]
-    || this->pConditions[2] )
+    || this->IsEradicated()
+    || this->IsDead()
+    || this->IsPertified()
+    || this->pConditions[Condition_Drunk]
+    || this->IsUnconcious()
+    || this->IsAsleep() )
   {
     result = 0;
   }
@@ -2040,7 +2043,7 @@
     v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType;
     if ( !pItemsTable->pItems[itemToSteal->uItemID].uEquipType || v10 == 1 || v10 == 2 )
       itemvalue *= 3;
-    v11 = dword_4EDEB4[rand() % 100 / 20] + v7 * dword_4EDEA0[v8];
+    v11 = StealingRandomBonuses[rand() % 100 / 20] + v7 * StealingMasteryBonuses[v8];
     *a6 = 100 * (reputation + a3) + itemvalue + (a5 != 0 ? 0x1F4 : 0);
     if ( rand() % 100 >= 5 )
     {
@@ -2108,9 +2111,8 @@
     v7 = v6 & 0x3F;
     v8 = SkillToMastery(v6);
     v9 = rand();
-    v28 = 4 * v8;
-    v30 = dword_4EDEA0[v8];
-    v29 = dword_4EDEB4[v9 % 100 / 20];
+    v30 = StealingMasteryBonuses[v8];
+    v29 = StealingRandomBonuses[v9 % 100 / 20];
     v10 = v5->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation);
     if ( rand() % 100 < 5 || v10 > v29 + v7 * v30 || (_steal_perma = 2, BYTE2(v5->uAttributes) & 8) )
     {
@@ -2132,7 +2134,7 @@
             do
             {
               --v7;
-              v19 += rand() % dword_4EDEC4[v28 / 4] + 1;
+              v19 += rand() % StealingEnchantmentBonusForSkill[v8] + 1;
             }
             while ( v7 );
           }
@@ -7949,6 +7951,11 @@
   return pConditions[Condition_Paralyzed] != 0;
 }
 
+bool Player::IsDrunk()
+{
+  return pConditions[Condition_Drunk] != 0;
+}
+
 void Player::SetCursed( bool state )
 {
   pConditions[Condition_Cursed] = state;
--- a/Player.h	Fri Sep 20 10:51:42 2013 +0200
+++ b/Player.h	Sat Sep 21 12:38:43 2013 +0200
@@ -613,6 +613,7 @@
   bool IsUnconcious();
   bool IsAsleep();
   bool IsParalyzed();
+  bool IsDrunk();
 
   void SetCursed(bool state);
   void SetWeak(bool state);
--- a/mm7_5.cpp	Fri Sep 20 10:51:42 2013 +0200
+++ b/mm7_5.cpp	Sat Sep 21 12:38:43 2013 +0200
@@ -3052,7 +3052,7 @@
           OnChestLeftClick();
           continue;
         case UIMSG_InventoryLeftClick:
-          OnInventoryLeftClick();
+          pPlayers[uActiveCharacter]->OnInventoryLeftClick();
           continue;
         case UIMSG_MouseLeftClickInGame:
           if ( !pRenderer->pRenderD3D )
--- a/mm7_6.cpp	Fri Sep 20 10:51:42 2013 +0200
+++ b/mm7_6.cpp	Sat Sep 21 12:38:43 2013 +0200
@@ -767,7 +767,7 @@
   if ( a3 )
     v8 = pPlayer->GetRangedAttack();
   else
-    v8 = pPlayer->GetActualAttack(0);
+    v8 = pPlayer->GetActualAttack(false);
   v9 = rand() % (v7 + 2 * v8 + 30);
   if ( a3 == 2 )
   {
--- a/mm7_data.cpp	Fri Sep 20 10:51:42 2013 +0200
+++ b/mm7_data.cpp	Sat Sep 21 12:38:43 2013 +0200
@@ -783,9 +783,6 @@
  3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 4, 0, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3,
  3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3,
 }};
-std::array<int, 777> dword_4EDEA0; // weak
-std::array<int, 777> dword_4EDEB4; // weak
-std::array<int, 777> dword_4EDEC4; // weak
 _UNKNOWN unk_4EDF40; // weak
 std::array<unsigned int, 2> pHiredNPCsIconsOffsetsX = {489, 559};
 std::array<unsigned int, 2> pHiredNPCsIconsOffsetsY = {152, 152};
--- a/mm7_data.h	Fri Sep 20 10:51:42 2013 +0200
+++ b/mm7_data.h	Sat Sep 21 12:38:43 2013 +0200
@@ -511,9 +511,6 @@
 extern std::array<std::array<unsigned char, 8>, 110> SoundSetAction; // weak
 extern std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing;
 extern std::array< std::array<char, 37>, 36> byte_4ED970_skill_learn_ability_by_class_table;
-extern std::array<int, 777> dword_4EDEA0; // weak
-extern std::array<int, 777> dword_4EDEB4; // weak
-extern std::array<int, 777> dword_4EDEC4; // weak
 extern _UNKNOWN unk_4EDF40; // weak
 extern std::array<unsigned int, 2> pHiredNPCsIconsOffsetsX;
 extern std::array<unsigned int, 2> pHiredNPCsIconsOffsetsY;