changeset 1695:33df22a5e376

Player::ReceiveSpecialAttackEffect finishing cleanup, special attack type enum created
author Grumpy7
date Sun, 22 Sep 2013 10:44:42 +0200
parents 5ead2688a227
children 7d99124bccd8
files Monsters.cpp Monsters.h Player.cpp Player.h
diffstat 4 files changed, 114 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/Monsters.cpp	Sun Sep 22 10:04:33 2013 +0200
+++ b/Monsters.cpp	Sun Sep 22 10:44:42 2013 +0200
@@ -894,7 +894,7 @@
                     int str_len=0;
                     int str_pos=0;
                     pInfos[curr_rec_num].uSpecialAttackLevel=1;
-                    pInfos[curr_rec_num].uSpecialAttackType=0;
+                    pInfos[curr_rec_num].uSpecialAttackType=(SPECIAL_ATTACK_TYPE)0;
                     str_len=strlen(test_string);
                     if (str_len>1)
                         {
@@ -908,7 +908,7 @@
                                 break;
                                 }
                             }
-                        pInfos[curr_rec_num].uSpecialAttackType=ParseSpecialAttack(test_string);
+                        pInfos[curr_rec_num].uSpecialAttackType=(SPECIAL_ATTACK_TYPE)ParseSpecialAttack(test_string);
                         }
                     }
                     break;
--- a/Monsters.h	Sun Sep 22 10:04:33 2013 +0200
+++ b/Monsters.h	Sun Sep 22 10:44:42 2013 +0200
@@ -82,6 +82,33 @@
   MONSTER_SUPERTYPE_8 = 0x8,
 };
 
+enum SPECIAL_ATTACK_TYPE : unsigned __int8
+{
+  SPECIAL_ATTACK_NONE = 0,
+  SPECIAL_ATTACK_CURSE = 1,
+  SPECIAL_ATTACK_WEAK = 2,
+  SPECIAL_ATTACK_SLEEP = 3,
+  SPECIAL_ATTACK_DRUNK = 4,
+  SPECIAL_ATTACK_INSANE = 5,
+  SPECIAL_ATTACK_POISON1 = 6,
+  SPECIAL_ATTACK_POISON2 = 7,
+  SPECIAL_ATTACK_POISON3 = 8,
+  SPECIAL_ATTACK_DISEASE1 = 9,
+  SPECIAL_ATTACK_DISEASE2 = 10,
+  SPECIAL_ATTACK_DISEASE3 = 11,
+  SPECIAL_ATTACK_PARALYZED = 12,
+  SPECIAL_ATTACK_UNCONSCIOUS = 13,
+  SPECIAL_ATTACK_DEAD = 14,
+  SPECIAL_ATTACK_PETRIFIED = 15,
+  SPECIAL_ATTACK_ERADICATED = 16,
+  SPECIAL_ATTACK_BREAK_ANY = 17,
+  SPECIAL_ATTACK_BREAK_ARMOR = 18,
+  SPECIAL_ATTACK_BREAK_WEAPON = 19,
+  SPECIAL_ATTACK_STEAL = 20,
+  SPECIAL_ATTACK_AGING = 21,
+  SPECIAL_ATTACK_MANA_DRAIN = 22,
+  SPECIAL_ATTACK_FEAR = 23,
+};
 
 
 /*  187 */
@@ -114,7 +141,7 @@
   unsigned __int8 uAIType;
   HostilityRadius uHostilityType;
   char field_12;
-  unsigned __int8 uSpecialAttackType;
+  SPECIAL_ATTACK_TYPE uSpecialAttackType;
   unsigned __int8 uSpecialAttackLevel;
   unsigned __int8 uAttack1Type;
   unsigned __int8 uAttack1DamageDiceRolls;
--- a/Player.cpp	Sun Sep 22 10:04:33 2013 +0200
+++ b/Player.cpp	Sun Sep 22 10:44:42 2013 +0200
@@ -2268,85 +2268,78 @@
 }
 
 //----- (0048DCF6) --------------------------------------------------------
-int Player::ReceiveSpecialAttackEffect(int a2, Actor *pActor)  //TODO check this with IDA to see what the uninitialized vars are supposed to contain
-{
+int Player::ReceiveSpecialAttackEffect( int attType, struct Actor *pActor )
+{
+  SPECIAL_ATTACK_TYPE attTypeCast = (SPECIAL_ATTACK_TYPE) attType;
   signed int v3; // edi@1
   signed int v4; // ebx@1
   int v6; // eax@2
   int v8; // eax@8
   int v10; // eax@8
   int v11; // ebx@8
-  signed int v12; // edx@9
   ItemGen *v13; // eax@9
-  int v14; // edx@16
-  int v16; // edx@26
-  signed int v19; // edx@38
   int v22; // eax@49
   signed int v23; // ebx@49
   void *v27; // ecx@76
-  enum CHARACTER_ATTRIBUTE_TYPE v40; // [sp-4h] [bp-A4h]@4
   char v46[140]; // [sp+Ch] [bp-94h]@13
   unsigned int v47; // [sp+98h] [bp-8h]@1
   ItemGen* v48; // [sp+9Ch] [bp-4h]@1
 
   v4 = 0;
   v47 = 0;
-  switch ( a2 )
-  {
-    case 1:
+  switch ( attTypeCast )
+  {
+    case SPECIAL_ATTACK_CURSE:
       v6 = GetActualWillpower();
       v11 = GetParameterBonus(v6);
       break;
-    case 2:
-    case 3:
-    case 4:
-    case 9:
-    case 10:
-    case 11:
-    case 13:
-    case 21:
+    case SPECIAL_ATTACK_WEAK:
+    case SPECIAL_ATTACK_SLEEP:
+    case SPECIAL_ATTACK_DRUNK:
+    case SPECIAL_ATTACK_DISEASE1:
+    case SPECIAL_ATTACK_DISEASE2:
+    case SPECIAL_ATTACK_DISEASE3:
+    case SPECIAL_ATTACK_UNCONSCIOUS:
+    case SPECIAL_ATTACK_AGING:
       v6 = GetActualEndurance();
       v11 = GetParameterBonus(v6);
       break;
-    case 5:
-    case 12:
-    case 23:
-      v40 = (CHARACTER_ATTRIBUTE_TYPE)14;
-      v11 = GetActualResistance(v40);
+    case SPECIAL_ATTACK_INSANE:
+    case SPECIAL_ATTACK_PARALYZED:
+    case SPECIAL_ATTACK_FEAR:
+      v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
       break;
-    case 15:
-      v40 = (CHARACTER_ATTRIBUTE_TYPE)13;
-      v11 = GetActualResistance(v40);
+    case SPECIAL_ATTACK_PETRIFIED:
+      v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
       break;
-    case 6:
-    case 7:
-    case 8:
-    case 14:
-    case 16:
-      v40 = (CHARACTER_ATTRIBUTE_TYPE)15;
-      v11 = GetActualResistance(v40);
+    case SPECIAL_ATTACK_POISON1:
+    case SPECIAL_ATTACK_POISON2:
+    case SPECIAL_ATTACK_POISON3:
+    case SPECIAL_ATTACK_DEAD:
+    case SPECIAL_ATTACK_ERADICATED:
+      v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
       break;
-    case 22:
+    case SPECIAL_ATTACK_MANA_DRAIN:
       v8 = GetActualWillpower();
       v10 = GetActualIntelligence();
       v11 = (GetParameterBonus(v10) + GetParameterBonus(v8)) / 2;
       break;
-    case 17:
+    case SPECIAL_ATTACK_BREAK_ANY:
       for (int i = 0; i < 138; i++)
       {
         v13 = &this->pInventoryItemList[i];
         if ( v13->uItemID > 0 && v13->uItemID <= 134 && !v13->IsBroken())
-          v46[v4++] = v12;
+          v46[v4++] = i;
       }
       if ( !v4 )
         return 0;
       v48 = &this->pInventoryItemList[v46[rand() % v4]];
       v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod);
       break;
-    case 18:
+    case SPECIAL_ATTACK_BREAK_ARMOR:
       for (int i = 0; i < 16; i++ )
       {
-        if ( HasItemEquipped((ITEM_EQUIP_TYPE)v14) )
+        if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) )
         {
           if ( i == EQUIP_ARMOUR )
             v46[v4++] = this->pEquipment.uArmor - 1;
@@ -2359,16 +2352,16 @@
       v48 = &this->pInventoryItemList[v46[rand() % v4]];
       v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod);
       break;
-    case 19:
+    case SPECIAL_ATTACK_BREAK_WEAPON:
       for (int i = 0; i < 16; i++ )
       {
-        if ( HasItemEquipped((ITEM_EQUIP_TYPE)v16) )
+        if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) )
         {
-          if ( v16 == EQUIP_BOW )
+          if ( i == EQUIP_BOW )
             v46[v4++] = LOBYTE(this->pEquipment.uBow) - 1;
-          if ( (v16 == EQUIP_OFF_HAND || v16 == EQUIP_MAIN_HAND)
-            && (GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v16) == EQUIP_OFF_HAND || GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v16) == EQUIP_MAIN_HAND) )
-            v46[v4++] = this->pEquipment.pIndices[v16] - 1;
+          if ( (i == EQUIP_OFF_HAND || i == EQUIP_MAIN_HAND)
+            && (GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_OFF_HAND || GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_MAIN_HAND) )
+            v46[v4++] = this->pEquipment.pIndices[i] - 1;
         }
       }
       if ( !v4 )
@@ -2376,7 +2369,7 @@
       v48 = &this->pInventoryItemList[v46[rand() % v4]];
       v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod);
       break;
-    case 20:
+    case SPECIAL_ATTACK_STEAL:
       for ( int i = 0; i < 126; i++ )
       {
         int ItemPosInList = this->pInventoryMatrix[i];
@@ -2385,7 +2378,7 @@
           ItemGen* v21 = &this->pInventoryItemList[ItemPosInList - 1];
           if ( v21->uItemID > 0 && v21->uItemID <= 134 )
           {
-              v46[v4++] = v19;
+              v46[v4++] = i;
           }
         }
       }
@@ -2413,125 +2406,117 @@
         break;
     }
 
-    switch ( a2 )
-    {
-      case 1:
+    switch ( attTypeCast )
+    {
+      case SPECIAL_ATTACK_CURSE:
         SetCondition(Condition_Cursed, 1);
         pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 2:
+      case SPECIAL_ATTACK_WEAK:
         SetCondition(Condition_Weak, 1);
         pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 3:
+      case SPECIAL_ATTACK_SLEEP:
         SetCondition(Condition_Sleep, 1);
         pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 23:
-        SetCondition(Condition_Fear, 1);
-        pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0);
-        pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
-        return 1;
-        break;
-      case 4:
+      case SPECIAL_ATTACK_DRUNK:
         SetCondition(Condition_Drunk, 1);
         pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 5:
+      case SPECIAL_ATTACK_INSANE:
         SetCondition(Condition_Insane, 1);
         pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 6:
+      case SPECIAL_ATTACK_POISON1:
         SetCondition(Condition_Poison1, 1);
         pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 7:
+      case SPECIAL_ATTACK_POISON2:
         SetCondition(Condition_Poison2, 1);
         pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 8:
+      case SPECIAL_ATTACK_POISON3:
         SetCondition(Condition_Poison3, 1);
         pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 9:
+      case SPECIAL_ATTACK_DISEASE1:
         SetCondition(Condition_Disease1, 1);
         pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 10:
+      case SPECIAL_ATTACK_DISEASE2:
         SetCondition(Condition_Disease2, 1);
         pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 11:
+      case SPECIAL_ATTACK_DISEASE3:
         SetCondition(Condition_Disease3, 1);
         pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 12:
+      case SPECIAL_ATTACK_PARALYZED:
         SetCondition(Condition_Paralyzed, 1);
         pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 15:
+      case SPECIAL_ATTACK_UNCONSCIOUS:
+        SetCondition(Condition_Unconcious, 1);
+        pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0);
+        pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
+        return 1;
+        break;
+      case SPECIAL_ATTACK_DEAD:
+        SetCondition(Condition_Dead, 1);
+        pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0);
+        pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
+        return 1;
+        break;
+      case SPECIAL_ATTACK_PETRIFIED:
         SetCondition(Condition_Pertified, 1);
         pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 13:
-        SetCondition(Condition_Unconcious, 1);
-        pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0);
-        pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
-        return 1;
-        break;
-      case 14:
-        SetCondition(Condition_Dead, 1);
-        pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0);
-        pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
-        return 1;
-        break;
-      case 16:
+      case SPECIAL_ATTACK_ERADICATED:
         SetCondition(Condition_Eradicated, 1);
         pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 17:
-      case 18:
-      case 19:
-        if ( v48->uAttributes & ITEM_ENCHANTED )
+      case SPECIAL_ATTACK_BREAK_ANY:
+      case SPECIAL_ATTACK_BREAK_ARMOR:
+      case SPECIAL_ATTACK_BREAK_WEAPON:
+        if ( !(v48->uAttributes & ITEM_ENCHANTED) )
         {
-          pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
-          return 1;
+          PlaySound(SPEECH_40, 0);
+          v48->SetBroken();
+          pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0);
         }
-        PlaySound(SPEECH_40, 0);
-        v48->SetBroken();
-        pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 20:
+      case SPECIAL_ATTACK_STEAL:
         PlaySound(SPEECH_40, 0);
         v27 = pActor->array_000234;
         if ( pActor->array_000234[0].uItemID )
@@ -2549,20 +2534,26 @@
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 21:
+      case SPECIAL_ATTACK_AGING:
         PlaySound(SPEECH_42, 0);
         ++this->sAgeModifier;
         pAudioPlayer->PlaySound((SoundID)226, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
-      case 22:
+      case SPECIAL_ATTACK_MANA_DRAIN:
         PlaySound(SPEECH_41, 0);
         this->sMana = 0;
         pAudioPlayer->PlaySound((SoundID)226, 0, 0, -1, 0, 0, 0, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
         return 1;
         break;
+      case SPECIAL_ATTACK_FEAR:
+        SetCondition(Condition_Fear, 1);
+        pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0);
+        pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
+        return 1;
+        break;
       default:
         return 0;
     }
--- a/Player.h	Sun Sep 22 10:04:33 2013 +0200
+++ b/Player.h	Sun Sep 22 10:44:42 2013 +0200
@@ -518,7 +518,7 @@
   int StealFromActor(unsigned int uActorID, int _steal_perm, int reputation);
   void Heal(int amount);
   int ReceiveDamage(signed int amount, DAMAGE_TYPE dmg_type);
-  int _48DCF6(int a2, struct Actor *pActor);
+  int ReceiveSpecialAttackEffect(int attType, struct Actor *pActor);
   unsigned int GetSpellSchool(unsigned int uSpellID);
   int GetAttackRecoveryTime(bool bRangedAttack);
   int GetMaxHealth();