diff Player.cpp @ 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
line wrap: on
line diff
--- 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;