diff Player.cpp @ 816:cfc65feef029

* Player Recovery Times * Player Attack fixes * Debug log to timers
author Nomad
date Tue, 26 Mar 2013 12:40:27 +0200
parents 7bb33867d2cb
children 5e3f4bf3b8e6
line wrap: on
line diff
--- a/Player.cpp	Tue Mar 26 06:40:04 2013 +0200
+++ b/Player.cpp	Tue Mar 26 12:40:27 2013 +0200
@@ -7,6 +7,7 @@
 #include "AudioPlayer.h"
 #include "Party.h"
 #include "GUIButton.h"
+#include "Log.h"
 #include "LOD.h"
 #include "Monsters.h" 
 #include "GUIWindow.h"
@@ -22,6 +23,7 @@
 #include "Autonotes.h"
 #include "Awards.h"
 #include "texts.h"
+
 #include "mm7_data.h"
 
 
@@ -111,6 +113,23 @@
 
 
 
+unsigned short base_recovery_times_per_weapon_type[12] =
+{
+  100,  // PLAYER_SKILL_STAFF   && Unarmed withoud skill
+   90,  // PLAYER_SKILL_SWORD   && Unarmed with skill
+   60,  // PLAYER_SKILL_DAGGER
+  100,  // PLAYER_SKILL_AXE
+   80,  // PLAYER_SKILL_SPEAR
+  100,  // PLAYER_SKILL_BOW
+   80,  // PLAYER_SKILL_MACE
+   30,  // PLAYER_SKILL_BLASTER
+   10,  // PLAYER_SKILL_SHIELD
+   10,  // PLAYER_SKILL_LEATHER
+   20,  // PLAYER_SKILL_CHAIN
+   30   // PLAYER_SKILL_PLATE
+};
+
+
 
 //----- (00490913) --------------------------------------------------------
 signed int __cdecl PlayerCreation_ComputeAttributeBonus()
@@ -2763,7 +2782,7 @@
     v34 = v4;
     goto LABEL_62;
   }
-  if ( HasItemEquipped(EQUIP_TWO_HANDED) )
+  if ( HasItemEquipped(EQUIP_MAIN_HAND) )
   {
     v6 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uMainHand-1];
     v7 = v6->uItemID;
@@ -3327,23 +3346,22 @@
 }
 
 //----- (0048D62C) --------------------------------------------------------
-int Player::GetEquippedItemEquipType(unsigned int uEquipSlot)
-{
-  return pItemsTable->pItems[pInventoryItems[pEquipment.pIndices[uEquipSlot]-1].uItemID].uEquipType;
+ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot)
+{
+  return pItemsTable->pItems[pInventoryItems[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uEquipType;
 }
 
 //----- (0048D651) --------------------------------------------------------
-int Player::GetEquippedItemSkillType(enum ITEM_EQUIP_TYPE uEquipSlot)
-{
-  return pItemsTable->pItems[pInventoryItems[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uSkillType;
+PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot)
+{
+  return (PLAYER_SKILL_TYPE)pItemsTable->pItems[pInventoryItems[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uSkillType;
 }
 
 //----- (0048D676) --------------------------------------------------------
 bool Player::IsUnarmed()
 {
-  return HasItemEquipped(EQUIP_TWO_HANDED) != 1
-      && (HasItemEquipped(EQUIP_ONE_OR_TWO_HANDS) != 1
-       || GetEquippedItemEquipType(0) == EQUIP_SHIELD);
+  return HasItemEquipped(EQUIP_MAIN_HAND) != EQUIP_MAIN_HAND &&
+        !(HasItemEquipped(EQUIP_OFF_HAND) == EQUIP_MAIN_HAND && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD);
 }
 
 //----- (0048D6AA) --------------------------------------------------------
@@ -3797,9 +3815,9 @@
       {
         if ( HasItemEquipped((ITEM_EQUIP_TYPE)v14) )
         {
-          if ( v15 == 3 )
+          if ( v15 == EQUIP_ARMOUR )
             v46[v4++] = LOBYTE(v5->pEquipment.uBody) - 1;
-          if ( (!v15 || v15 == 1) && GetEquippedItemEquipType(v15) == 4 )
+          if ( (!v15 || v15 == 1) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v15) == 4 )
             v46[v4++] = *((char *)&v5->pEquipment.uOffHand + 4 * v15) - 1;
         }
         v14 = v15 + 1;
@@ -3815,7 +3833,7 @@
           if ( v17 == 2 )
             v46[v4++] = LOBYTE(v5->pEquipment.uBow) - 1;
           if ( (!v17 || v17 == 1)
-            && (!GetEquippedItemEquipType(v17) || GetEquippedItemEquipType(v17) == 1) )
+            && (!GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v17) || GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v17) == 1) )
             v46[v4++] = *((char *)&v5->pEquipment.uOffHand + 4 * v17) - 1;
         }
         v16 = v17 + 1;
@@ -4052,211 +4070,160 @@
 }
 
 //----- (0048E1B5) --------------------------------------------------------
-int Player::GetAttackRecoveryTime(int a2)
-{
-  unsigned int v2; // ebx@1
-  char *v3; // edi@1
-  Player *v4; // esi@1
-  int v5; // eax@3
-  int v6; // eax@3
-  int v7; // eax@6
-  int v8; // eax@9
-  int v9; // eax@9
-  int v10; // eax@10
-  int v11; // edx@13
-  int v12; // ecx@14
-  int v13; // eax@15
-  int v14; // ebx@18
-  int v15; // eax@18
-  double v16; // st7@21
-  double v17; // st7@22
-  unsigned __int16 v18; // cx@27
-  Player *v19; // ecx@28
-  int v20; // eax@30
-  int v21; // eax@30
-  int v22; // eax@30
-  int v23; // ecx@30
-  unsigned int v24; // eax@30
-  int v25; // eax@31
-  int v26; // ebx@32
-  int v27; // eax@32
-  unsigned __int16 *v28; // ebx@36
-  int v29; // eax@42
-  int v30; // edi@43
-  signed int v31; // eax@49
-  int v32; // ecx@50
-  int result; // eax@54
-  float v34; // [sp+8h] [bp-38h]@27
-  float v35; // [sp+Ch] [bp-34h]@18
-  float v36; // [sp+10h] [bp-30h]@21
-  float v37; // [sp+14h] [bp-2Ch]@21
-  float v38; // [sp+18h] [bp-28h]@27
-  int v39; // [sp+1Ch] [bp-24h]@31
-  int v40; // [sp+20h] [bp-20h]@1
-  int v41; // [sp+24h] [bp-1Ch]@1
-  unsigned int v42; // [sp+28h] [bp-18h]@14
-  int v43; // [sp+2Ch] [bp-14h]@1
-  int v44; // [sp+30h] [bp-10h]@1
-  int v45; // [sp+34h] [bp-Ch]@1
-  int v46; // [sp+38h] [bp-8h]@1
-  int v47; // [sp+3Ch] [bp-4h]@1
-
-  v2 = 0;
-  v3 = 0;
-  v4 = this;
-  v47 = (unsigned __int16)word_4EDED8[0];
-  v43 = 0;
-  v45 = 0;
-  v40 = 0;
-  v41 = 0;
-  v44 = 0;
-  v46 = 0;
-  if ( a2 )
+int Player::GetAttackRecoveryTime(bool bRangedAttack)
+{
+  ItemGen  *weapon = nullptr;
+  ItemDesc *weapon_desc = nullptr;
+  uint      weapon_recovery = base_recovery_times_per_weapon_type[0];
+  if (bRangedAttack)
   {
     if ( !HasItemEquipped(EQUIP_BOW) )
       goto LABEL_17;
-    v5 = (int)&v4->pInventoryItems[v4->pEquipment.uBow-1];
-    v46 = v5;
-    v3 = (char *)&pItemsTable->pItems[*(int *)v5].pIconName;
-    v6 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]];
-    goto LABEL_4;
-  }
-  if ( IsUnarmed() == 1 )
-  {
-    LOBYTE(v7) = GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-    if ( v7 )
-    {
-      v6 = (unsigned __int16)word_4EDED8[1];
-LABEL_4:
-      v47 = v6;
+    weapon = &pInventoryItems[pEquipment.uBow - 1];
+    weapon_desc = &pItemsTable->pItems[weapon->uItemID];
+    weapon_recovery = base_recovery_times_per_weapon_type[weapon_desc->uSkillType];
+    goto LABEL_17;
+  }
+  else if ( IsUnarmed() == 1 )
+  {
+    if (GetActualSkillLevel(PLAYER_SKILL_UNARMED))
+    {
+      weapon_recovery = base_recovery_times_per_weapon_type[1];
       goto LABEL_17;
     }
   }
-  if ( HasItemEquipped(EQUIP_TWO_HANDED) )
-  {
-    v8 = (int)&v4->pInventoryItems[v4->pEquipment.uMainHand-1];
-    v46 = v8;
-    v9 = *(int *)v8;
-    v3 = (char *)&pItemsTable->pItems[v9].pIconName;
-    if ( v3[28] == 12 )
-      v10 = *(&pSpellDatas[0].uExpertLevelRecovery + 10 * *((int *)&pSpellDatas[66].uNormalLevelRecovery + v9));
+
+  if ( HasItemEquipped(EQUIP_MAIN_HAND) )
+  {
+    weapon = &pInventoryItems[pEquipment.uMainHand - 1];
+    weapon_desc = &pItemsTable->pItems[weapon->uItemID];
+    if (weapon_desc->uEquipType == EQUIP_WAND)
+    {
+      __debugbreak();  // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
+      __debugbreak();  // looks like wands were two-handed weapons once, or supposed to be. should not get here now
+      weapon_recovery = pSpellDatas[wand_spell_ids[weapon->uItemID - ITEM_WAND_FIRE]].uExpertLevelRecovery;
+    }
     else
-      v10 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]];
-    v47 = v10;
-  }
-  if ( HasItemEquipped((ITEM_EQUIP_TYPE)0) )
-  {
-    v12 = (int)&v4->pInventoryItems[v4->pEquipment.uOffHand-1];
-    v42 = (unsigned __int16)word_4EDED8[pItemsTable->pItems[*(int *)v12].uSkillType];
-    if ( (signed int)v42 > v47 )
-    {
-      v13 = *(int *)v12;
-      v46 = v12;
-      v3 = (char *)(v11 + 48 * v13);
-      v47 = v42;
-    }
-    v2 = 0;
-  }
+      weapon_recovery = base_recovery_times_per_weapon_type[weapon_desc->uSkillType];
+  }
+  if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD) // ADD: shield check because shield recovery is added later and can be accidentally doubled
+  {
+    auto v12 = &pInventoryItems[pEquipment.uOffHand - 1];
+    auto v12_desc = &pItemsTable->pItems[v12->uItemID];
+    if (base_recovery_times_per_weapon_type[v12_desc->uSkillType] > weapon_recovery)
+    {
+      weapon = &pInventoryItems[pEquipment.uOffHand - 1];
+      weapon_desc = &pItemsTable->pItems[weapon->uItemID];
+      weapon_recovery = base_recovery_times_per_weapon_type[pItemsTable->pItems[weapon->uItemID].uSkillType];
+    }
+  }
+
 LABEL_17:
+  uint armour_recovery = 0;
   if ( HasItemEquipped(EQUIP_ARMOUR) )
   {
-    v14 = pItemsTable->pItems[*(int *)&v4->pInventoryItems[v4->pEquipment.uBody-1]].uSkillType;
-    SkillToMastery(v4->pActiveSkills[9]);
-    v15 = (unsigned __int16)word_4EDED8[v14];
-    v35 = 1.0;
-    v43 = v15;
-    if ( v14 == 9 )
-    {
-      v36 = 0.0;
+    auto armour_skill_type = pItemsTable->pItems[pInventoryItems[pEquipment.uBody - 1].uItemID].uSkillType;
+    uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type];
+
+    float armour_recovery_multipliers[4];
+    if (armour_skill_type == PLAYER_SKILL_LEATHER)
+    {
+      armour_recovery_multipliers[0] = 1.0f;
+      armour_recovery_multipliers[1] = 0;
+      armour_recovery_multipliers[2] = 0;
+      armour_recovery_multipliers[3] = 0;
+    }
+    else if (armour_skill_type == PLAYER_SKILL_CHAIN)
+    {
+      armour_recovery_multipliers[0] = 1.0f;
+      armour_recovery_multipliers[1] = 0.5f;
+      armour_recovery_multipliers[2] = 0;
+      armour_recovery_multipliers[3] = 0;
+    }
+    else if (armour_skill_type == PLAYER_SKILL_PLATE)
+    {
+      armour_recovery_multipliers[0] = 1.0f;
+      armour_recovery_multipliers[1] = 0.5f;
+      armour_recovery_multipliers[2] = 0.5f;
+      armour_recovery_multipliers[3] = 0;
     }
     else
     {
-      if ( v14 != 10 )
-      {
-        if ( v14 != 11 )
-        {
-          v36 = 1.0;
-          v37 = 1.0;
-          v16 = 1.0;
-LABEL_27:
-          v18 = v4->pActiveSkills[v14];
-          v38 = v16;
-          v43 = (signed __int64)((double)v43 * *(&v34 + SkillToMastery(v18)));
-          v2 = 0;
-          goto LABEL_28;
-        }
-        v17 = 0.5;
-        v36 = 0.5;
-LABEL_26:
-        v37 = v17;
-        v16 = 0.0;
-        goto LABEL_27;
-      }
-      v36 = 0.5;
-    }
-    v17 = 0.0;
-    goto LABEL_26;
-  }
-LABEL_28:
-  if ( HasItemEquipped((ITEM_EQUIP_TYPE)v2) && v19->GetEquippedItemEquipType(v2) == 4 )
-  {
-    v20 = 9 * v4->pEquipment.uOffHand;
-    v35 = 1.0;
-    v21 = 3 * *(int *)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * v20 + 5];
-    v36 = 0.0;
-    v22 = pItemsTable->pItems[16 * v21 / 0x30u].uSkillType;
-    v37 = 0.0;
-    v23 = (unsigned __int16)word_4EDED8[v22];
-    v38 = 0.0;
-    v45 = v23;
-    v24 = SkillToMastery(v4->pActiveSkills[v22]);
-    v45 = (signed __int64)((double)v45 * *(&v34 + v24));
-  }
-  v25 = GetActualSpeed();
-  v39 = _48EA1B_get_static_effect(v25);
-  v42 = v2;
-  if ( v3 != (char *)v2 )
-  {
-    v26 = (unsigned __int8)v3[29];
-    LOBYTE(v27) = GetActualSkillLevel((enum PLAYER_SKILL_TYPE)(unsigned __int8)v3[29]);
-    if ( v27 && (v26 == 1 || v26 == 3 || v26 == 5) )
-    {
-      v28 = &v4->pActiveSkills[v26];
-      if ( (signed int)SkillToMastery(*v28) >= 2 )
-        v40 = *(char *)v28 & 0x3F;
-    }
-    v2 = 0;
-    if ( v3[29] == 7 )
-      v42 = 1;
-  }
-  if ( a2 == v2 )
-  {
-    if ( v42 == v2 )
-    {
-      LOBYTE(v29) = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER);
-      if ( v29 != v2 )
-      {
-        v30 = v29 & 0x3F;
-        v44 = v29 & 0x3F;
-        if ( (signed int)SkillToMastery(v29) >= 4 )
-          v44 += v30;
-      }
-    }
-  }
-  if ( SHIDWORD(v4->pPlayerBuffs[7].uExpireTime) >= (signed int)v2
-    && (SHIDWORD(v4->pPlayerBuffs[7].uExpireTime) > (signed int)v2 || LODWORD(v4->pPlayerBuffs[7].uExpireTime) > v2) )
+      assert(false && "Unknown armour type"); // what kind of armour is that?
+      armour_recovery_multipliers[0] = 1.0f;
+      armour_recovery_multipliers[1] = 1.0f;
+      armour_recovery_multipliers[2] = 1.0f;
+      armour_recovery_multipliers[3] = 1.0f;
+    }
+
+    uint skill_mastery = SkillToMastery(pActiveSkills[armour_skill_type]);
+    armour_recovery = base_armour_recovery * armour_recovery_multipliers[skill_mastery - 1];
+  }
+
+  uint shield_recovery = 0;
+  if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD)
+  {
+    float shield_recovery_multipliers[4] = {1, 0, 0, 0};
+
+    auto shield = &pInventoryItems[pEquipment.uOffHand - 1];
+    auto skill_type = pItemsTable->pItems[shield->uItemID].uSkillType;
+
+    uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type];
+    shield_recovery = shield_base_recovery * SkillToMastery(pActiveSkills[skill_type]);
+  }
+
+  uint player_speed_recovery_reduction = _48EA1B_get_static_effect(GetActualSpeed()),
+       sword_axe_bow_recovery_reduction = 0;
+  bool shooting_laser = false;
+  if (weapon_desc)
+  {
+    if (GetActualSkillLevel((PLAYER_SKILL_TYPE)weapon_desc->uSkillType) &&
+        (weapon_desc->uSkillType == PLAYER_SKILL_SWORD || weapon_desc->uSkillType == PLAYER_SKILL_AXE || weapon_desc->uSkillType == PLAYER_SKILL_BOW) )
+    {
+      if (SkillToMastery(pActiveSkills[weapon_desc->uSkillType]) >= 2 )  // Expert   Sword, Axe & Bow   reduce recovery
+        sword_axe_bow_recovery_reduction = pActiveSkills[weapon_desc->uSkillType] & 0x3F;
+    }
+    if (weapon_desc->uSkillType == PLAYER_SKILL_BLASTER)
+      shooting_laser = true;
+  }
+
+  uint armsmaster_recovery_reduction = 0;
+  if (!bRangedAttack && !shooting_laser)
+  {
+    if (uint armsmaster_level = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER))
+    {
+      armsmaster_recovery_reduction = armsmaster_level & 0x3F;
+      if (SkillToMastery(armsmaster_level) >= 4)
+        armsmaster_recovery_reduction *= 2;
+    }
+  }
+
+  uint v41 = 0;
+  if (pPlayerBuffs[PLAYER_BUFF_7].uExpireTime > 0)
     v41 = 25;
-  v31 = 0;
-  if ( v46 != v2 )
-  {
-    v32 = *(int *)(v46 + 12);
-    if ( v32 == 59 || v32 == 41 || *(int *)v46 == 500 )
-      v31 = 20;
-  }
-  result = v47 + v43 + v45 - v44 - v31 - v41 - v40 - v39;
-  if ( result < 0 )
-    result = 0;
-  return result;
+
+  uint weapon_enchantment_recovery_reduction = 0;
+  if ( weapon  )
+  {
+    if (weapon->uSpecEnchantmentType == 59 ||
+        weapon->uSpecEnchantmentType == 41 ||
+        weapon->uSpecEnchantmentType == 500)
+      weapon_enchantment_recovery_reduction = 20;
+  }
+
+
+  int recovery = weapon_recovery +
+                 armour_recovery +
+                 shield_recovery
+                 - armsmaster_recovery_reduction
+                 - weapon_enchantment_recovery_reduction
+                 - v41
+                 - sword_axe_bow_recovery_reduction
+                 - player_speed_recovery_reduction;
+
+  if (recovery < 0)
+    recovery = 0;
+  return recovery;
 }
 
 //----- (0048E4F8) --------------------------------------------------------
@@ -4553,43 +4520,44 @@
 }
 
 //----- (0048E8F5) --------------------------------------------------------
-bool Player::Recover(signed int a2)
-{
-  Player *v2; // esi@1
+bool Player::Recover(int dt)
+{
+  //Player *v2; // esi@1
   signed __int64 v3; // qax@1
-  bool result; // eax@4
-
-  v2 = this;
-  v3 = (signed __int64)((double)(a2 * _48EA46_calc_special_bonus_by_items(17)) * 0.01 + (double)a2);
-  if ( v2->uTimeToRecovery - (signed int)v3 > 0 )
-  {
-    v2->uTimeToRecovery -= v3;
-    result = 1;
+  //bool result; // eax@4
+
+  //v2 = this;
+  v3 = (signed __int64)((double)(dt * _48EA46_calc_special_bonus_by_items(17)) * 0.01 + (double)dt);
+
+  Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery);
+
+  if (uTimeToRecovery > v3)
+  {
+    uTimeToRecovery -= v3;
+    return true;
   }
   else
   {
-    v2->uTimeToRecovery = 0;
-    viewparams->bRedrawGameUI = 1;
-    if ( !uActiveCharacter )
+    uTimeToRecovery = 0;
+    viewparams->bRedrawGameUI = true;
+    if (!uActiveCharacter)
       uActiveCharacter = pParty->GetNextActiveCharacter();
-    result = 0;
-  }
-  return result;
+    return false;
+  }
 }
 
 //----- (0048E96A) --------------------------------------------------------
-void Player::SetRecoveryTime(signed int sRecoveryTime)
-{
-  signed int v2; // edx@1
-
-  v2 = sRecoveryTime;
-  if ( sRecoveryTime < 0 )
-    v2 = 0;
-  if ( v2 > this->uTimeToRecovery )
-    this->uTimeToRecovery = v2;
-  if ( pPlayers[uActiveCharacter] == this && !some_active_character )
+void Player::SetRecoveryTime(signed int rec)
+{
+  assert(rec > 0);
+
+  if (rec > uTimeToRecovery)
+    uTimeToRecovery = rec;
+
+  if (pPlayers[uActiveCharacter] == this && !some_active_character)
     uActiveCharacter = pParty->GetNextActiveCharacter();
-  viewparams->bRedrawGameUI = 1;
+
+  viewparams->bRedrawGameUI = true;
 }
 // 50C0C4: using guessed type int some_active_character;
 
@@ -4626,33 +4594,31 @@
 //----- (0048EA46) --------------------------------------------------------
 int Player::_48EA46_calc_special_bonus_by_items(int a2)
 {
-  int v2; // edi@1
   int v3; // esi@1
   int v4; // edx@2
   int v5; // eax@3
   char *v6; // eax@4
 
-  v2 = 0;
   v3 = 0;
   while ( 1 )
   {
     if ( !HasItemEquipped((ITEM_EQUIP_TYPE)v3) )
       goto LABEL_11;
-    v5 = pEquipment.uOffHand  - 1;            // BUG
-                                                // v5 = _this->cEquippedItems.uOffHand - 1;
+    v5 = pEquipment.pIndices[v3]  - 1;
     if ( a2 != 17 )
-      break;
+    {
+      if ( a2 != 24 || this->pInventoryItems[v5].uSpecEnchantmentType != 24 )
+        goto LABEL_11;
+      return 5;
+    }
     v6 = (char *)this + 36 * v5;
     if ( *((int *)v6 + 133) == 533 || *((int *)v6 + 136) == 17 )
       return 50;
 LABEL_11:
     ++v3;
     if ( (signed int)v3 >= 16 )
-      return v2;
-  }
-  if ( a2 != 24 || this->pInventoryItems[v5].uSpecEnchantmentType != 24 )
-    goto LABEL_11;
-  return 5;
+      return 0;
+  }
 }
 
 //----- (0048EAAE) --------------------------------------------------------
@@ -4877,7 +4843,7 @@
       v31 = *(&v6->pEquipment.uOffHand + v65) - 1;
       if ( v3 == 9 )
       {
-        v32 = GetEquippedItemEquipType(v65);
+        v32 = GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v65);
         if ( v32 >= 3 )
         {
           if ( v32 <= 11 )
@@ -5438,9 +5404,9 @@
   {
     if ( IsUnarmed() != 1 )
     {
-      if ( v6->HasItemEquipped(EQUIP_TWO_HANDED) )
-      {
-        v22 = this->GetEquippedItemEquipType(1u);
+      if ( v6->HasItemEquipped(EQUIP_MAIN_HAND) )
+      {
+        v22 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND);
         if ( v22 >= 0 )
         {
           if ( v22 <= 2 )
@@ -5461,7 +5427,7 @@
           }
         }
       }
-      if ( a3 || !v6->HasItemEquipped((ITEM_EQUIP_TYPE)0) || (v28 = v27->GetEquippedItemEquipType(0), v28 < 0) || v28 > 2 )
+      if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v28 = v27->GetEquippedItemEquipType(EQUIP_OFF_HAND), v28 < 0) || v28 > 2 )
         return v5 + v62 + v61;
       v15 = pItemsTable->pItems[v29].uDamageMod;
       v14 = pItemsTable->pItems[v29].uDamageDice * pItemsTable->pItems[v29].uDamageRoll;
@@ -5485,16 +5451,16 @@
       v5 = 0;
       return v5 + v62 + v61;
     }
-    if ( v6->HasItemEquipped(EQUIP_TWO_HANDED) )
-    {
-      v17 = this->GetEquippedItemEquipType(1u);
+    if ( v6->HasItemEquipped(EQUIP_MAIN_HAND) )
+    {
+      v17 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND);
       if ( v17 >= 0 )
       {
         if ( v17 <= 2 )
           v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uMainHand-1]].uDamageMod;
       }
     }
-    if ( a3 || !v6->HasItemEquipped((ITEM_EQUIP_TYPE)0) || (v19 = v18->GetEquippedItemEquipType(0), v19 < 0) || v19 > 2 )
+    if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v19 = v18->GetEquippedItemEquipType(EQUIP_OFF_HAND), v19 < 0) || v19 > 2 )
       return v5 + v62 + v61;
     v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uOffHand-1];
     goto LABEL_365;
@@ -5506,9 +5472,9 @@
       v5 = 1;
       return v5 + v62 + v61;
     }
-    if ( v6->HasItemEquipped(EQUIP_TWO_HANDED) )
-    {
-      v9 = this->GetEquippedItemEquipType(1u);
+    if ( v6->HasItemEquipped(EQUIP_MAIN_HAND) )
+    {
+      v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND);
       if ( v9 >= 0 )
       {
         if ( v9 <= 2 )
@@ -5522,7 +5488,7 @@
         }
       }
     }
-    if ( a3 || !v6->HasItemEquipped((ITEM_EQUIP_TYPE)0) || (v12 = v11->GetEquippedItemEquipType(0), v12 < 0) || v12 > 2 )
+    if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v12 = v11->GetEquippedItemEquipType(EQUIP_OFF_HAND), v12 < 0) || v12 > 2 )
       return v5 + v62 + v61;
     v14 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uOffHand].uItemID].uDamageMod;
     v15 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uOffHand].uItemID].uDamageDice;