changeset 1549:5a3afcaa6717

Player::CalculateMeleeDamageTo removed labels, ifdowhile patterns changed to for cycles, magic numbers to enum values, fixing gibbet being only undead slaying
author Grumpy7
date Sat, 07 Sep 2013 09:16:55 +0200
parents 2ae7139dde11
children cdb7fafede0c
files Player.cpp
diffstat 1 files changed, 55 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Sat Sep 07 08:17:49 2013 +0200
+++ b/Player.cpp	Sat Sep 07 09:16:55 2013 +0200
@@ -1904,154 +1904,99 @@
   v34 = 0;
   v32 = 0;
   v28 = 0;
-  if ( IsUnarmed() == 1 )
+  if ( IsUnarmed() )
   {
     v32 = rand() % 3 + 1;
 LABEL_61:
     v34 = v4;
-    goto LABEL_62;
-  }
+  }
+  else
+  {
   if ( HasItemEquipped(EQUIP_MAIN_HAND) )
   {
-    v6 = (ItemGen *)&v5->pInventoryItemList[v5->pEquipment.uMainHand-1];
+      v6 = &this->pInventoryItemList[v5->pEquipment.uMainHand-1];
     v7 = v6->uItemID;
-    v8 = v6->uItemID;
-    v9 = pItemsTable->pItems[v8].uDamageDice;
-    if ( pItemsTable->pItems[v8].uSkillType == PLAYER_SKILL_SPEAR && !v5->pEquipment.uShield )
+      v9 = pItemsTable->pItems[v7].uDamageDice;
+      if ( pItemsTable->pItems[v7].uSkillType == PLAYER_SKILL_SPEAR && !v5->pEquipment.uShield )
       ++v9;
-    v30 = pItemsTable->pItems[v8].uDamageRoll;
-    if ( v9 > 0 )
-    {
-      v33 = v9;
-      do
+      v30 = pItemsTable->pItems[v7].uDamageRoll;
+      for (int i = 0; i < v9; i++)
       {
         v10 = rand();
-        v11 = v33-- == 1;
         v28 += v10 % v30 + 1;
       }
-      while ( !v11 );
-    }
-    v12 = pItemsTable->pItems[v8].uDamageMod + v28;
-    if ( !uTargetActorID )
-      goto LABEL_28;
+      v12 = pItemsTable->pItems[v7].uDamageMod + v28;
+      if ( uTargetActorID > 0)
+      {
     v13 = v6->uSpecEnchantmentType;
-    if ( v13 == 64 || v7 == 507 || v7 == 508 || v7 == 527 )
-    {
-      v14 = (MONSTER_SUPERTYPE)1;
-    }
-    else
-    {
-      if ( v13 == 39 )
-      {
-        v26 = MONSTER_SUPERTYPE_KREEGAN;
-      }
-      else
-      {
-        if ( v13 == 40 )
+        if ( MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_UNDEAD) && (v13 == 64 || v7 == ITEM_ARTIFACT_GHOULSBANE || v7 == ITEM_ARTIFACT_GIBBET || v7 == ITEM_RELIC_JUSTICE) )
+        {
+          v12 *= 2;
+        }
+        else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_KREEGAN) && ( v13 == 39 || v7 == ITEM_ARTIFACT_GIBBET))
         {
-          v26 = MONSTER_SUPERTYPE_DRAGON;
+          v12 *= 2;
         }
-        else
+        else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_DRAGON) && ( v13 == 40 || v7 == ITEM_ARTIFACT_GIBBET))
         {
-          if ( v13 == 63 || v7 == 517 )
-          {
-            v26 = MONSTER_SUPERTYPE_ELF;
-          }
-          else
-          {
-            if ( v13 != 65 )
-            {
-LABEL_28:
+          v12 *= 2;
+        }
+        else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_TITAN) && ( v13 == 65 ))
+        {
+          v12 *= 2;
+        }
+      }
               if ( (signed int)SkillToMastery(v5->pActiveSkills[2]) >= 3
                 && pItemsTable->pItems[v6->uItemID].uSkillType == 2
                 && rand() % 100 < 10 )
                 v12 *= 3;
               v32 = v12;
-              goto LABEL_33;
-            }
-            v26 = MONSTER_SUPERTYPE_TITAN;
-          }
-        }
-      }
-      v14 = v26;
-    }
-    if ( MonsterStats::BelongsToSupertype(uTargetActorID, v14) )
-      v12 *= 2;
-    goto LABEL_28;
-  }
-LABEL_33:
+    }
   v29 = 0;
   if ( !a3 )
   {
-    if ( v5->HasItemEquipped((ITEM_EQUIP_TYPE)0) )
+      if ( v5->HasItemEquipped(EQUIP_OFF_HAND) )
     {
       v15 = (ItemGen *)&v5->pInventoryItemList[v5->pEquipment.uShield - 1];
       v16 = v15->uItemID;
-      v17 = v15->uItemID;
-      if ( pItemsTable->pItems[v17].uEquipType != 4 )
-      {
-        v31 = pItemsTable->pItems[v17].uDamageRoll;
-        if ( (signed int)pItemsTable->pItems[v17].uDamageDice > 0 )
-        {
-          v35 = pItemsTable->pItems[v17].uDamageDice;
-          do
-          {
-            v18 = rand() % v31;
-            v11 = v35-- == 1;
-            v29 += v18 + 1;
-          }
-          while ( !v11 );
-        }
-        v4 = pItemsTable->pItems[v17].uDamageMod + v29;
-        if ( !uTargetActorID )
-          goto LABEL_57;
-        v19 = v15->uSpecEnchantmentType;
-        if ( v19 == 64 || v16 == 507 || v16 == 508 || v16 == 527 )
+        if ( pItemsTable->pItems[v16].uEquipType != EQUIP_SHIELD )
         {
-          v20 = (MONSTER_SUPERTYPE)1;
-        }
-        else
-        {
-          if ( v19 == 39 )
+          v31 = pItemsTable->pItems[v16].uDamageRoll;
+          v35 = pItemsTable->pItems[v16].uDamageDice;
+          for (int i = 0; i < v35; i++)
           {
-            v27 = MONSTER_SUPERTYPE_KREEGAN;
+            v10 = rand();
+            v29 += v10 % v31 + 1;
           }
-          else
+          v4 = pItemsTable->pItems[v16].uDamageMod + v29;
+          if ( uTargetActorID > 0)
           {
-            if ( v19 == 40 )
+        v19 = v15->uSpecEnchantmentType;
+            if ( MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_UNDEAD) && (v19 == 64 || v16 == ITEM_ARTIFACT_GHOULSBANE || v16 == ITEM_ARTIFACT_GIBBET || v16 == ITEM_RELIC_JUSTICE) )
             {
-              v27 = MONSTER_SUPERTYPE_DRAGON;
+              v4 *= 2;
             }
-            else
+            else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_KREEGAN) && ( v19 == 39 || v16 == ITEM_ARTIFACT_GIBBET))
+            {
+              v4 *= 2;
+            }
+            else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_DRAGON) && ( v19 == 40 || v16 == ITEM_ARTIFACT_GIBBET))
             {
-              if ( v19 == 63 || v16 == 517 )
-              {
-                v27 = MONSTER_SUPERTYPE_ELF;
-              }
-              else
-              {
-                if ( v19 != 65 )
-                {
-LABEL_57:
+              v4 *= 2;
+            }
+            else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_TITAN) && ( v19 == 65 ))
+            {
+              v4 *= 2;
+            }
+          }
                   if ( pItemsTable->pItems[v15->uItemID].uSkillType == PLAYER_SKILL_DAGGER
                     && SkillToMastery(v5->pActiveSkills[2] >= 3u)
                     && rand() % 100 < 10 )
                     v4 *= 3;
-                  goto LABEL_61;
-                }
-                v27 = MONSTER_SUPERTYPE_TITAN;
-              }
-            }
-          }
-          v20 = v27;
         }
-        if ( MonsterStats::BelongsToSupertype(uTargetActorID, v20) )
-          v4 *= 2;
-        goto LABEL_57;
-      }
-    }
-  }
-LABEL_62:
+      }
+    }
+  }
   v21 = v32 + v34;
   if ( !a2 )
   {
@@ -5373,7 +5318,7 @@
     }
   }
 
-  assert(false);
+  return (PLAYER_SKILL_TYPE)37;
 }