diff Player.cpp @ 1080:9456f2ed5ff9

getskillbonus continue cleaning
author Gloval
date Sat, 25 May 2013 23:50:56 +0400
parents 48168499f52e
children 7033eb155558
line wrap: on
line diff
--- a/Player.cpp	Sat May 25 18:46:48 2013 +0100
+++ b/Player.cpp	Sat May 25 23:50:56 2013 +0400
@@ -1085,7 +1085,8 @@
         PlaySound((PlayerSpeech)25, 0);
         break;
     case Condition_Sleep:
-        if ( a3 == 1 &&(HasEnchantedItemEquipped(22)||WearsItem(505, 3))) 
+        if ( a3 == 1 &&(HasEnchantedItemEquipped(22)||
+            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR))) 
             return 0;
         break;
 
@@ -1098,7 +1099,9 @@
 
     case Condition_Insane:
         if ( a3 == 1
-            && (HasEnchantedItemEquipped(19) || WearsItem(505, 3) || WearsItem(530, 6)) )
+            && (HasEnchantedItemEquipped(19) || 
+            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
+                          WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_BELT)) )
             return 0;
 
         PlaySound((PlayerSpeech)29, 0);
@@ -1115,8 +1118,8 @@
                     pParty->pPartyBuffs[13].Reset();
                 }
             if ( HasEnchantedItemEquipped(21)
-                || WearsItem(505, 3)
-                || WearsItem(530, 6) )
+                || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR)
+                || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_BELT) )
                 //goto LABEL_76;
                 return 0;
             }
@@ -1138,7 +1141,9 @@
                 return 0;
                 }
 
-            if ( HasEnchantedItemEquipped(18) ||WearsItem(505, 3) || WearsItem(530, 6) )
+            if ( HasEnchantedItemEquipped(18) ||
+                WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
+                WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_BELT) )
                 return 0;
             }
         PlaySound((PlayerSpeech)28, 0);
@@ -1154,7 +1159,10 @@
                 return 0;
                 }
 
-            if ( HasEnchantedItemEquipped(20)|| WearsItem(505, 3)|| WearsItem(507, 16)||WearsItem(530, 6))
+            if ( HasEnchantedItemEquipped(20)|| 
+                WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR)|| 
+                WearsItem(ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY)||
+                WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_BELT))
                 return 0;
             }
         break;
@@ -1180,7 +1188,10 @@
     case Condition_Pertified:
         if ( a3 == 1
             &&((pParty->pPartyBuffs[13].uExpireTime > 0i64)
-            || HasEnchantedItemEquipped(23)|| WearsItem(520, 16) || WearsItem(505, 3) || WearsItem(530, 6)) )
+            || HasEnchantedItemEquipped(23)|| 
+            WearsItem(ITEM_RELIC_KELEBRIM, EQIUP_ANY) || 
+            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
+            WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_BELT)) )
 
             return 0;
         PlaySound((PlayerSpeech)34, 0);
@@ -3249,7 +3260,7 @@
 {
   auto i = pEquipment.pIndices[uEquipIndex];
   if (i)
-    return ~(pInventoryItems[i - 1].uAttributes & ITEM_BROKEN);
+    return ~(pOwnItems[i - 1].uAttributes & ITEM_BROKEN);
   else 
     return false;
 }
@@ -3260,7 +3271,7 @@
   for (uint i = 0; i < 16; ++i)
   {
     if (HasItemEquipped((ITEM_EQUIP_TYPE)i) &&
-      pInventoryItems[i].uSpecEnchantmentType == uEnchantment)
+      pOwnItems[pEquipment.pIndices[i]-1].uSpecEnchantmentType == uEnchantment)
       //  *(int *)&this->field_1F6[36 * pEquipment[i] + 6] != uEnchantment)
       return true;
   }
@@ -3268,16 +3279,16 @@
 }
 
 //----- (0048D709) --------------------------------------------------------
-bool Player::WearsItem(int a1, signed int a2)
-{
+bool Player::WearsItem( int item_id, ITEM_EQUIP_TYPE equip_type )
+    {
 
   int v6; // esi@5
 
-  if ( a2 >= 16 )
+  if ( equip_type >= 16 )
   {
     v6 = 0;
     while ( !HasItemEquipped((ITEM_EQUIP_TYPE)v6)
-         || *(int *)&this->pInventoryItems[pEquipment.pIndices[v6] - 1].uItemID != a1 )
+         || this->pInventoryItems[pEquipment.pIndices[v6] - 1].uItemID != item_id )
     {
       ++v6;
       if ( (signed int)v6 >= 16 )
@@ -3285,7 +3296,7 @@
     }
     return 1;
   }
-  if ( HasItemEquipped((ITEM_EQUIP_TYPE)a2) && pInventoryItems[pEquipment.pIndices[a2 - 1]].uItemID == a1 )
+  if ( HasItemEquipped(equip_type) && pInventoryItems[pEquipment.pIndices[equip_type - 1]].uItemID == item_id )
     return 1;
   return 0;
 }
@@ -5690,7 +5701,7 @@
   int v67; // [sp+18h] [bp-14h]@104
   int v68; // [sp+1Ch] [bp-10h]@69
   PlayerEquipment *v69; // [sp+20h] [bp-Ch]@1
-  int v70; // [sp+24h] [bp-8h]@1
+  int skill_bonus; // [sp+24h] [bp-8h]@1
   ITEM_EQUIP_TYPE v71; // [sp+28h] [bp-4h]@1
   int a1; // [sp+34h] [bp+8h]@21
   int a1a; // [sp+34h] [bp+8h]@74
@@ -5700,7 +5711,7 @@
   int lvl_avl[4];
 
   v2 = this;
-  v70 = 0;
+  skill_bonus = 0;
   v69 = 0;
   multiplier =0;
   arm_bonus =0;
@@ -5809,7 +5820,7 @@
                for ( i = 0; i < (signed int)v52; ++i )
                    {
                    if ( lvl_avl[i] )
-                       v70 += v53;
+                       skill_bonus += v53;
                    }
 
                }
@@ -5829,24 +5840,105 @@
           for ( j = 0; j < (signed int)v57; ++j )
               {
               if ( lvl_avl[j] )
-                  v70 += v58;
+                  skill_bonus += v58;
               }
           }
-      return v70;
+      return skill_bonus;
 
     
       }
 
+  if (a2 == CHARACTER_ATTRIBUTE_ATTACK)
+  {
+
+  if ( v2->IsUnarmed() == 1 )
+      {
+      v33 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
+      v34 = v33;
+      if ( !v33 )
+          return skill_bonus;
+      if ( SkillToMastery(v33) >= 3 )
+          multiplier = 2;
+      else 
+          multiplier=1;
+      v30 = multiplier * (v34 & 0x3F);
+      return arm_bonus + v30;
+      }
+  v35 = (ITEM_EQUIP_TYPE)0;
+  v68 = 0;
+  for (i=0; i<16 ; ++i)
+      {
+      if ( v2->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
+          {
+          v37 = v2->pEquipment.pIndices[i]-1;
+          if ( pItemsTable->pItems[v37].uEquipType <= EQUIP_MAIN_HAND)
+              break;
+          }
+      }
+  if ( i >= 16 )
+      return skill_bonus;
+  
+  v38 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v37].uSkillType;
+  a1a = v2->GetActualSkillLevel(v38);
+  v39=  SkillToMastery(a1a);
+  v71 = (ITEM_EQUIP_TYPE)0;
+  switch (v38)
+      {
+  case PLAYER_SKILL_STAFF:
+      v71 = (ITEM_EQUIP_TYPE)1;
+      if ( v39 == 4 )
+          {
+          v40 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
+          v41 = v40;
+
+          if ( v40 )
+              {
+              if ( SkillToMastery(v40) >= 3 )
+                  multiplier = 2;
+              else 
+                  multiplier=1;
+              v68 = multiplier * (v41 & 0x3F);
+              }
+          }
+      break;
+  case PLAYER_SKILL_SWORD:
+  case PLAYER_SKILL_DAGGER:
+  case PLAYER_SKILL_AXE:
+  case PLAYER_SKILL_SPEAR:
+  case PLAYER_SKILL_MACE:
+            v71 = (ITEM_EQUIP_TYPE)1;
+        break;
+  case PLAYER_SKILL_BLASTER:
+
+      switch (v39)
+          {
+      case 0: multiplier=1; break;
+      case 1: multiplier=3; break;
+      case 3: multiplier=3; break;
+      case 4: multiplier=5; break;
+          }
+      v5 = multiplier;
+      return v5 * (a1a & 0x3F);
+      break;
+      }
+
+
+  
+  v30 = v68 + v71 * (a1a & 0x3F);
+  return (int)((char *)v69 + v30);
+
+  }
+
+
   if ( a2 != 9 )
   {
-    if ( a2 != CHARACTER_ATTRIBUTE_ATTACK )
-    {
+   
       if ( a2 <= CHARACTER_ATTRIBUTE_ATTACK )
-        return v70;
+        return skill_bonus;
       if ( a2 > CHARACTER_ATTRIBUTE_MELEE_DMG_MAX )
       {
         if ( a2 != CHARACTER_ATTRIBUTE_RANGED_ATTACK )
-          return v70;
+          return skill_bonus;
         v71 = (ITEM_EQUIP_TYPE)0;
         v9 = &v2->pEquipment;
         while ( 1 )
@@ -5866,7 +5958,7 @@
           v71 = (ITEM_EQUIP_TYPE)((int)v71 + 1);
           v9 = (PlayerEquipment *)((char *)v9 + 4);
           if ( (signed int)v71 >= 16 )
-            return v70;
+            return skill_bonus;
         }
         v14 = a1;
         v15 = 1;
@@ -5889,7 +5981,7 @@
         LOBYTE(v18) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
         v14 = v18;
         if ( !v18 )
-          return v70;
+          return skill_bonus;
         v15 = 0;
         v19 = SkillToMastery(v18);
         if ( (signed int)v19 < 3 )
@@ -5917,7 +6009,7 @@
         }
         v20 = (ITEM_EQUIP_TYPE)((int)v20 + 1);
         if ( (signed int)v20 >= 16 )
-          return v70;
+          return skill_bonus;
       }
       v71 = (ITEM_EQUIP_TYPE)0;
       v23 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v22].uSkillType;
@@ -5979,89 +6071,8 @@
         v71 = (ITEM_EQUIP_TYPE)1;
       goto LABEL_55;
     }
-    if ( v2->IsUnarmed() == 1 )
-    {
-      LOBYTE(v33) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-      v34 = v33;
-      if ( !v33 )
-        return v70;
-      if ( (signed int)SkillToMastery(v33) >= 3 )
-        v5 = 2;
-      v30 = v5 * (v34 & 0x3F);
-      return (int)((char *)v69 + v30);
-    }
-    v35 = (ITEM_EQUIP_TYPE)0;
-    v68 = 0;
-    while ( 1 )
-    {
-      if ( v2->HasItemEquipped(v35) )
-      {
-        v37 = v2->pInventoryItems[v35].uItemID;
-        if ( pItemsTable->pItems[v37].uEquipType <= 1u )
-          break;
-      }
-      v35 = (ITEM_EQUIP_TYPE)((int)v35 + 1);
-      if ( (signed int)v35 >= 16 )
-        return v70;
-    }
-    v38 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v37].uSkillType;
-    LOBYTE(v39) = v2->GetActualSkillLevel(v38);
-    a1a = v39;
-    SkillToMastery(v39);
-    v71 = (ITEM_EQUIP_TYPE)0;
-    if ( v38 )
-    {
-      if ( (signed int)v38 > 0 )
-      {
-        if ( (signed int)v38 <= 4 || v38 == 6 )
-        {
-          v71 = (ITEM_EQUIP_TYPE)1;
-        }
-        else
-        {
-          if ( v38 == 7 )
-          {
-            if ( (signed int)SkillToMastery(a1a) < 4 )
-            {
-              if ( (signed int)SkillToMastery(a1a) < 3 )
-              {
-                if ( (signed int)SkillToMastery(a1a) < 2 )
-                  return v5 * (a1a & 0x3F);
-                v63 = 2;
-              }
-              else
-              {
-                v63 = 3;
-              }
-            }
-            else
-            {
-              v63 = 5;
-            }
-            v5 = v63;
-            return v5 * (a1a & 0x3F);
-          }
-        }
-      }
-    }
-    else
-    {
-      v71 = (ITEM_EQUIP_TYPE)1;
-      if ( (signed int)SkillToMastery(a1a) >= 4 )
-      {
-        LOBYTE(v40) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-        v41 = v40;
-        if ( v40 )
-        {
-          if ( (signed int)SkillToMastery(v40) >= 3 )
-            v5 = 2;
-          v68 = v5 * (v41 & 0x3F);
-        }
-      }
-    }
-    v30 = v68 + v71 * (a1a & 0x3F);
-    return (int)((char *)v69 + v30);
-  }
+    
+  
   
 }