changeset 1929:4cce1e24b7e7

DamageMonsterFromParty moved initial damage source logic to an if and a switch
author Grumpy7
date Wed, 23 Oct 2013 00:02:06 -0700
parents 4fa815c2112d
children df4e27f2a541
files Actor.cpp
diffstat 1 files changed, 129 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Tue Oct 22 23:18:41 2013 -0700
+++ b/Actor.cpp	Wed Oct 23 00:02:06 2013 -0700
@@ -3635,43 +3635,31 @@
   if ( PID_TYPE(a1) == OBJECT_Item)
   {
     v4 = &pSpriteObjects[PID_ID(a1)];
-    //uDamageAmount = (int)v4;
     v61 = v4->field_60_distance_related_prolly_lod;
     a1 = v4->spell_caster_pid;
-    //v54 = v4->field_58_pid;
   }
-  //v5 = a1 & 7;
-  //uPlayerID = a1 >> 3;
   if (PID_TYPE(a1) != OBJECT_Player)
     return;
 
   assert(PID_ID(abs(a1)) < 4);
   auto player = &pParty->pPlayers[PID_ID(a1)];
   pMonster = &pActors[uActorID_Monster_];
-  //uPlayerID = pMonster->IsAlive();
   if (pMonster->IsNotAlive())
     return;
 
   pMonster->uAttributes |= 0xC000;
   if ( pMonster->uAIState == Fleeing )
     pMonster->uAttributes |= 0x20000u;
-  //v57 = 0;
-  //v53 = 0;
-  //v58 = 0;
   bool hit_will_stun = false,
        hit_will_paralyze = false;
   if ( !v4 )
   {
-    //v51 = (unsigned __int64 *)player->pEquipment.uMainHand;
     int main_hand_idx = player->pEquipment.uMainHand;
     v59 = 1;
     if ( player->HasItemEquipped(EQUIP_MAIN_HAND) )
     {
       auto main_hand_skill = player->GetMainHandItem()->GetPlayerSkillType();
-      //v55 = pItemsTable->pItems[player->pInventoryItems[main_hand_idx - 1].uItemID].uSkillType;
-      //v28 = SkillToMastery(player->pActiveSkills[v55]);
       auto main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]);
-      //uDamageAmount = v28;
       switch (main_hand_skill)
       {
         case PLAYER_SKILL_STAFF:
@@ -3698,183 +3686,154 @@
     }
     v50 = pMonster->pMonsterInfo.uID;
     a2 = 4;
-    //v27 = player->CalculateMeleeDamageTo(0, 0, v50);
     uDamageAmount = player->CalculateMeleeDamageTo(false, false, v50);
-    //if ( !v57 )
-    if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
-    {
-      player->PlaySound(SPEECH_52, 0);
-      return;
-    }
-    goto LABEL_69;
-    //goto LABEL_69;
-  }
-
-
-  v19 = v4->spell_id == SPELL_DARK_SOULDRINKER;
-  v61 = v4->field_60_distance_related_prolly_lod;
-  if ( !v19 )
-  {
-    //v9 = (SpriteObject *)uDamageAmount;
-	v50 = pParty->vPosition.x - v4->vPosition.x;
-    //v55 = abs(v50);
-    pMonsterName = (char *)(pParty->vPosition.y - v4->vPosition.y);
-    //v51 = (unsigned __int64 *)abs((int)pMonsterName);
-    pPlayerName = (char *)(pParty->vPosition.z - v4->vPosition.z);
-    v52 = abs((int)pPlayerName);
-    v61 = abs(v50);
-    v10 = abs(v50);
-    v11 = (int)abs((int)pMonsterName);
-    v12 = v52;
-    if ( v10 < v11)
-    {
-      v10 = (int)v11;
-      v11 = v10;
-    }
-    if ( v10 < v52 )
-    {
-      v13 = v10;
-      v10 = v52;
-      v12 = v13;
-    }
-    if ( v11 < (signed int)v12 )
-    {
-      v14 = v12;
-      v12 = v11;
-      v11 = v14;
-    }
-    //uPlayerID = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10;
-    v61 = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10;
-    if ( v61 >= 2560 )
-    {
-      if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) )
-        return;
-      v61 = 2;
-    }
-    else
-    {
-      v61 = 1;
-    }
-    //v4 = (SpriteObject *)uDamageAmount;
-  }
-
-  v15 = v4->spell_id;
-  if ( v15 == SPELL_LASER_PROJECTILE )
-  {
-    v16 = player->pActiveSkills[7];
-    v61 = 1;
-    if ( (signed int)SkillToMastery(v16) >= 3 )
-      a4 = player->pActiveSkills[7] & 0x3F;
-    a2 = 4;
-    uDamageAmount = player->CalculateMeleeDamageTo(true, true, 0);
     if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
     {
       player->PlaySound(SPEECH_52, 0);
       return;
     }
-    goto LABEL_69;
   }
-  if ( v15 != SPELL_BOW_ARROW )
+  else
   {
-    if ( v15 == SPELL_101 )
+    v19 = v4->spell_id == SPELL_DARK_SOULDRINKER;
+    v61 = v4->field_60_distance_related_prolly_lod;
+    if ( !v19 )
     {
-      a2 = 0;
-      v18 = player->CalculateRangedDamageTo(0);
-      v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
-      v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
-      uDamageAmount = v18;
-      if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
-        uDamageAmount >>= 1;
-      v59 = 1;
-      if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
+	    v50 = pParty->vPosition.x - v4->vPosition.x;
+      pMonsterName = (char *)(pParty->vPosition.y - v4->vPosition.y);
+      pPlayerName = (char *)(pParty->vPosition.z - v4->vPosition.z);
+      v52 = abs((int)pPlayerName);
+      v61 = abs(v50);
+      v10 = abs(v50);
+      v11 = (int)abs((int)pMonsterName);
+      v12 = v52;
+      if ( v10 < v11)
+      {
+        v10 = (int)v11;
+        v11 = v10;
+      }
+      if ( v10 < v52 )
       {
-        player->PlaySound(SPEECH_52, 0);
-        return;
+        v13 = v10;
+        v10 = v52;
+        v12 = v13;
+      }
+      if ( v11 < (signed int)v12 )
+      {
+        v14 = v12;
+        v12 = v11;
+        v11 = v14;
       }
-      goto LABEL_69;
+      v61 = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10;
+      if ( v61 >= 2560 )
+      {
+        if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) )
+          return;
+        v61 = 2;
+      }
+      else
+      {
+        v61 = 1;
+      }
     }
-    if ( v15 == SPELL_EARTH_BLADES )
-    {
-      a4 = 5 * v4->spell_level;
-      a2 = player->GetSpellSchool(0x27u);
-      v21 = v4->spell_level;
-      v50 = pMonster->sCurrentHP;
-      pMonsterName = (char *)v4->spell_skill;
-      v22 = _43AFE3_calc_spell_damage(39, v21, v4->spell_skill, v50);
-      v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
-      v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
-      uDamageAmount = v22;
-      if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
-        uDamageAmount >>= 1;
-      v59 = 0;
-LABEL_67:
-      if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
-      {
-        player->PlaySound(SPEECH_52, 0);
-        return;
-      }
-      goto LABEL_69;
-    }
-    if ( v15 == SPELL_EARTH_STUN )
+
+    switch (v4->spell_id)
     {
-      uDamageAmount = 0;
-      a2 = 4;
-      hit_will_stun = 1;
-      if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
-      {
-        player->PlaySound(SPEECH_52, 0);
-        return;
-      }
-      goto LABEL_69;
+      case SPELL_LASER_PROJECTILE:
+        v16 = player->pActiveSkills[7];
+        v61 = 1;
+        if ( (signed int)SkillToMastery(v16) >= 3 )
+          a4 = player->pActiveSkills[7] & 0x3F;
+        a2 = 4;
+        uDamageAmount = player->CalculateMeleeDamageTo(true, true, 0);
+        if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
+        {
+          player->PlaySound(SPEECH_52, 0);
+          return;
+        }
+        break;
+      case SPELL_101:
+        a2 = 0;
+        v18 = player->CalculateRangedDamageTo(0);
+        v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
+        v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
+        uDamageAmount = v18;
+        if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
+          uDamageAmount >>= 1;
+        v59 = 1;
+        if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
+        {
+          player->PlaySound(SPEECH_52, 0);
+          return;
+        }
+        break;
+      case SPELL_EARTH_BLADES:
+        a4 = 5 * v4->spell_level;
+        a2 = player->GetSpellSchool(0x27u);
+        v21 = v4->spell_level;
+        v50 = pMonster->sCurrentHP;
+        pMonsterName = (char *)v4->spell_skill;
+        v22 = _43AFE3_calc_spell_damage(39, v21, v4->spell_skill, v50);
+        v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0;
+        v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0;
+        uDamageAmount = v22;
+        if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
+          uDamageAmount >>= 1;
+        v59 = 0;
+        if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
+        {
+          player->PlaySound(SPEECH_52, 0);
+          return;
+        }
+        break;
+      case SPELL_EARTH_STUN:
+        uDamageAmount = 0;
+        a2 = 4;
+        hit_will_stun = 1;
+        if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
+        {
+          player->PlaySound(SPEECH_52, 0);
+          return;
+        }
+        break;
+      case SPELL_BOW_ARROW:
+        v50 = pMonster->word_000086_some_monster_id;
+        a2 = 4;
+        uDamageAmount = player->CalculateRangedDamageTo(v50);
+        if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 )
+          uDamageAmount /= 2;
+        v59 = 1;
+        if ( v4->stru_24.uItemID != 0 && v4->stru_24.uSpecEnchantmentType == 3 )  //of carnage
+        {
+          a2 = 0;
+        }
+        else if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
+        {
+          player->PlaySound(SPEECH_52, 0);
+          return;
+        }
+        break;
+
+      default:
+        a2 = player->GetSpellSchool(v4->spell_id);
+        v25 = v4->spell_level;
+        v26 = v4->spell_id;
+        v50 = pMonster->sCurrentHP;
+        pMonsterName = (char *)v4->spell_skill;
+        v59 = 0;
+        uDamageAmount = _43AFE3_calc_spell_damage(v26, v25, v4->spell_skill, v50);
+        break;
     }
-    a2 = player->GetSpellSchool(v4->spell_id);
-    v25 = v4->spell_level;
-    v26 = v4->spell_id;
-    v50 = pMonster->sCurrentHP;
-    pMonsterName = (char *)v4->spell_skill;
-    //v27 = _43AFE3_calc_spell_damage(v26, v25, (signed int)pMonsterName, v50);
-    v59 = 0;
-    //v57 = (PlayerEquipment *)1;
-//LABEL_65:
-    uDamageAmount = _43AFE3_calc_spell_damage(v26, v25, v4->spell_skill, v50);
-    //if ( !v57 )
-    //  goto LABEL_67;
-    goto LABEL_69;
   }
-  v50 = pMonster->word_000086_some_monster_id;
-  a2 = 4;
-  v17 = player->CalculateRangedDamageTo(v50);
-  v19 = v4->stru_24.uItemID == 0;
-  uDamageAmount = v17;
-  v57 = 0;
-  if ( !v19 && v4->stru_24.uSpecEnchantmentType == 3 )
-  {
-    a2 = 0;
-    v57 = (PlayerEquipment *)1;
-  }
-  if ( SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) >= 0
-    && (SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) > 0 || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) )
-    uDamageAmount >>= 1;
-  v59 = 1;
-//LABEL_66:
-  if ( !v57 )
-  {
-    if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) )
-    {
-      player->PlaySound(SPEECH_52, 0);
-      return;
-    }
-    goto LABEL_69;
-  }
-LABEL_69:
+
   if (player->IsWeak())
-    uDamageAmount /= 1;
-  if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 )
+    uDamageAmount /= 2;
+  if ( pMonster->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 )
     uDamageAmount = 0;
   v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount);
-  if ( !v4 && player->IsUnarmed() && (signed __int64)player->pPlayerBuffs[6].uExpireTime > 0 )
+  if ( !v4 && player->IsUnarmed() && player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime > 0 )
   {
-    v50 = player->pPlayerBuffs[6].uPower;
+    v50 = player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uPower;
     v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50);
     v61 += v29;
   }