diff Player.cpp @ 1547:778916dfa666

Player::GetRangedDamageString fix + some small chnages
author Grumpy7
date Sat, 07 Sep 2013 06:51:56 +0200
parents 5cf28ec7322d
children 5a3afcaa6717
line wrap: on
line diff
--- a/Player.cpp	Sat Sep 07 05:23:16 2013 +0200
+++ b/Player.cpp	Sat Sep 07 06:51:56 2013 +0200
@@ -266,7 +266,7 @@
     if (item_idx)
     {
       item_id = pOwnItems[item_idx - 1].uItemID;
-      if ( item_id != 64 && item_id != 65 ) //blaster& blaster rifle
+      if ( item_id != ITEM_BLASTER && item_id != ITEM_LASER_RIFLE ) //blaster& blaster rifle
           return false;
     }
   }
@@ -2079,7 +2079,7 @@
 
   v1 = this;
   v2 = *(int *)&this->pInventoryItemList[this->pEquipment.uMainHand-1];
-  if ( v2 < 64 || v2 > 65 )
+  if ( v2 < ITEM_BLASTER || v2 > ITEM_LASER_RIFLE )
   {
     v4 = GetActualAccuracy();
     v5 = GetParameterBonus(v4);
@@ -2229,7 +2229,7 @@
   if ( pEquipment.uMainHand)
       {
       itemid= pOwnItems[this->pEquipment.uMainHand-1].uItemID;
-      if ( itemid < 64 || itemid > 65 ) //blasters
+      if ( itemid < ITEM_BLASTER || itemid > ITEM_LASER_RIFLE ) //blasters
           {
           min_damage = GetMeleeDamageMinimal();
           max_damage = GetMeleeDamageMaximal();
@@ -2273,44 +2273,44 @@
     int max_damage; // eax@3
 
     static char player__getrangeddamagestring_static_buff[40]; // idb
-    if ( pEquipment.uMainHand)
-        {
-        itemid= pOwnItems[this->pEquipment.uMainHand-1].uItemID;
-        if ( itemid < 64 || itemid > 65 ) //blasters
-            {
-            min_damage = GetRangedDamageMin();
-            max_damage = GetRangedDamageMax();
-            }
-        else
-            {  //for blasters
-            min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 1);
-            max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 1);
-            }
-        if ( max_damage )
-            {
-            if ( min_damage == max_damage )
-                {
-                sprintf(player__getrangeddamagestring_static_buff, "%d", min_damage);
-                }
-            else
-                {
-                sprintf(player__getrangeddamagestring_static_buff, "%d - %d", min_damage, max_damage);
-                }
-            }
-        else
-            {
-            strcpy(player__getrangeddamagestring_static_buff, "N/A");
-            }
-
-        if (( itemid >= 135 )&&( itemid <= 159 )) //wands
-            {
-            strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand"
-            }
-        }
+
+    if (pEquipment.uMainHand >= 0)
+    {
+      itemid = pOwnItems[this->pEquipment.uMainHand-1].uItemID;
+    }
+
+    if (pEquipment.uMainHand >= 0 && ( itemid >= 135 ) && ( itemid <= 159 ))
+    {
+      strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand"
+      return player__getrangeddamagestring_static_buff;
+    }
+    else if (pEquipment.uMainHand >= 0 && (itemid == ITEM_BLASTER || itemid == ITEM_LASER_RIFLE))
+    {
+      min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 1);
+      max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 1);
+    }
     else
-        strcpy(player__getrangeddamagestring_static_buff, "N/A");
+    {
+      min_damage = GetRangedDamageMin();
+      max_damage = GetRangedDamageMax();
+    }
+    if ( max_damage > 0)
+    {
+      if ( min_damage == max_damage )
+      {
+        sprintf(player__getrangeddamagestring_static_buff, "%d", min_damage);
+      }
+      else
+      {
+        sprintf(player__getrangeddamagestring_static_buff, "%d - %d", min_damage, max_damage);
+      }
+    }
+    else
+    {
+      strcpy(player__getrangeddamagestring_static_buff, "N/A");
+    }
     return player__getrangeddamagestring_static_buff;
-    }
+}
 
 //----- (0048D45A) --------------------------------------------------------
 bool Player::CanTrainToNextLevel()
@@ -4854,7 +4854,7 @@
       {
         if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].Broken()))
         {
-          int curr_item = pOwnItems[pEquipment.pIndices[j]].uItemID;
+          int curr_item = pOwnItems[pEquipment.pIndices[j] - 1].uItemID;
           PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType;
           int currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
           int multiplier = 0;
@@ -4913,10 +4913,10 @@
     {
       if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
       {
-        int currItemIndex = this->pEquipment.pIndices[i] - 1;
-        if ( pItemsTable->pItems[currItemIndex].uEquipType <= EQUIP_MAIN_HAND)
+        ItemDesc currItem = pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID];
+        if ( currItem.uEquipType <= EQUIP_MAIN_HAND)
         {
-          PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemIndex].uSkillType;
+          PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItem.uSkillType;
           int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType);
           if (currItemSkillType == PLAYER_SKILL_BLASTER)
           {
@@ -4948,7 +4948,7 @@
         int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType);
         if ( currentItemSkillType == PLAYER_SKILL_BOW )
         {
-          int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 0, 0, 0, 0);
+          int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 1, 1, 1);
           return multiplier * (currentItemSkillLevel & 0x3F);
         }
         else if ( currentItemSkillType == PLAYER_SKILL_BLASTER )