changeset 1852:979380004db2

Actor::AI_SpellAttack, extracting common code from different mastery levels
author Grumpy7
date Sun, 13 Oct 2013 11:44:15 +0200
parents 80e897fc2438
children 4ae5b7e7a920
files Actor.cpp
diffstat 1 files changed, 156 insertions(+), 464 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sun Oct 13 11:17:09 2013 +0200
+++ b/Actor.cpp	Sun Oct 13 11:44:15 2013 +0200
@@ -203,8 +203,8 @@
 void __fastcall Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel)
 {
   Actor *v5; // esi@1
-  unsigned int v6; // edi@1
-  unsigned int v7; // eax@1
+  unsigned int realPoints; // edi@1
+  unsigned int masteryLevel; // eax@1
   int v8; // edi@16
   int v9; // edi@17
   signed int v10; // ecx@22
@@ -323,8 +323,8 @@
   LODWORD(v120) = uActorID;
   v5 = &pActors[uActorID];
   v117 = pDir;
-  v6 = uSkillLevel & 0x3F;
-  v7 = SkillToMastery(uSkillLevel);
+  realPoints = uSkillLevel & 0x3F;
+  masteryLevel = SkillToMastery(uSkillLevel);
   if ( uSpellID <= 47 )
   {
     if ( uSpellID != 47 )
@@ -345,51 +345,28 @@
               {
                 if ( uSpellID != 17 )
                   return;
-                if ( (signed int)v7 <= 0 )
+
+                if (masteryLevel == 0)
                 {
                   v8 = 0;
-                  v5->pActorBuffs[15].Apply(
-                    pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335),
-                    v7,
-                    0,
-                    0,
-                    0);
-                  return;
                 }
-                if ( (signed int)v7 <= 2 )
+                else if (masteryLevel == 1 || masteryLevel == 2)
                 {
-                  v9 = 300 * v6;
+                  v9 = 300 * realPoints;
+                  v8 = v9 + 3840;
                 }
-                else
+                else if (masteryLevel == 3 )
                 {
-                  if ( v7 != 3 )
-                  {
-                    if ( v7 == 4 )
-                    {
-                      v8 = 3600 * (v6 + 64);
-                      v5->pActorBuffs[15].Apply(
-                        pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335),
-                        v7,
-                        0,
-                        0,
-                        0);
-                      return;
-                    }
-                    v8 = 0;
-                    v5->pActorBuffs[15].Apply(
-                      pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335),
-                      v7,
-                      0,
-                      0,
-                      0);
-                    return;
-                  }
-                  v9 = 900 * v6;
+                  v9 = 900 * realPoints;
+                  v8 = v9 + 3840;
                 }
-                v8 = v9 + 3840;
+                else if (masteryLevel == 4 ) 
+                {
+                  v8 = 3600 * (realPoints + 64);
+                }
                 v5->pActorBuffs[15].Apply(
                   pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335),
-                  v7,
+                  masteryLevel,
                   0,
                   0,
                   0);
@@ -711,64 +688,26 @@
           }
           return;
         }
-        if ( (signed int)v7 > 0 )
+
+        if (masteryLevel == 0)
+        {
+          v39 = 0;
+        }
+        else if (masteryLevel == 1 || masteryLevel == 2)
         {
-          if ( (signed int)v7 <= 2 )
-          {
-            v39 = 60 * (v6 + 60);
-            v5->pActorBuffs[19].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335),
-              v7,
-              0,
-              0,
-              0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFF3C1Eu);
-            v40 = 8 * LODWORD(v120);
-            LOBYTE(v40) = PID(OBJECT_Actor,LOBYTE(v120));
-            v99 = v40;
-            v98 = (SoundID)10040;
-            pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-            return;
-          }
-          if ( v7 == 3 )
-          {
-            v39 = 180 * (v6 + 20);
-            v5->pActorBuffs[19].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335),
-              v7,
-              0,
-              0,
-              0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFF3C1Eu);
-            v40 = 8 * LODWORD(v120);
-            LOBYTE(v40) = PID(OBJECT_Actor,LOBYTE(v120));
-            v99 = v40;
-            v98 = (SoundID)10040;
-            pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-            return;
-          }
-          if ( v7 == 4 )
-          {
-            v39 = 240 * (v6 + 15);
-            v5->pActorBuffs[19].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335),
-              v7,
-              0,
-              0,
-              0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFF3C1Eu);
-            v40 = 8 * LODWORD(v120);
-            LOBYTE(v40) = PID(OBJECT_Actor,LOBYTE(v120));
-            v99 = v40;
-            v98 = (SoundID)10040;
-            pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-            return;
-          }
+          v39 = 60 * (realPoints + 60);
         }
-        v39 = 0;
+        else if (masteryLevel == 3 )
+        {
+          v39 = 180 * (realPoints + 20);
+        }
+        else if (masteryLevel == 4 ) 
+        {
+          v39 = 240 * (realPoints + 15);
+        }
         v5->pActorBuffs[19].Apply(
           pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335),
-          v7,
+          masteryLevel,
           0,
           0,
           0);
@@ -788,68 +727,30 @@
           goto LABEL_159;
         if ( uSpellID != 46 )
           return;
-        if ( (signed int)v7 > 0 )
+
+        if (masteryLevel == 0)
+        {
+          v42 = 0;
+        }
+        else if (masteryLevel == 1 || masteryLevel == 2)
         {
-          if ( (signed int)v7 <= 2 )
-          {
-            v41 = 300 * v6;
-            v42 = v41 + 3840;
-            v5->pActorBuffs[17].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335),
-              v7,
-              v6 + 5,
-              0,
-              0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-            v43 = 8 * LODWORD(v120);
-            LOBYTE(v43) = PID(OBJECT_Actor,LOBYTE(v120));
-            v99 = v43;
-            v98 = (SoundID)14010;
-            pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-            return;
-          }
-          if ( v7 == 3 )
-          {
-            v41 = 900 * v6;
-            v42 = v41 + 3840;
-            v5->pActorBuffs[17].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335),
-              v7,
-              v6 + 5,
-              0,
-              0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-            v43 = 8 * LODWORD(v120);
-            LOBYTE(v43) = PID(OBJECT_Actor,LOBYTE(v120));
-            v99 = v43;
-            v98 = (SoundID)14010;
-            pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-            return;
-          }
-          if ( v7 == 4 )
-          {
-            v41 = 1200 * v6;
-            v42 = v41 + 3840;
-            v5->pActorBuffs[17].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335),
-              v7,
-              v6 + 5,
-              0,
-              0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-            v43 = 8 * LODWORD(v120);
-            LOBYTE(v43) = PID(OBJECT_Actor,LOBYTE(v120));
-            v99 = v43;
-            v98 = (SoundID)14010;
-            pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-            return;
-          }
+          v41 = 300 * realPoints;
+          v42 = v41 + 3840;
         }
-        v42 = 0;
+        else if (masteryLevel == 3 )
+        {
+          v41 = 900 * realPoints;
+          v42 = v41 + 3840;
+        }
+        else if (masteryLevel == 4 ) 
+        {
+          v41 = 1200 * realPoints;
+          v42 = v41 + 3840;
+        }
         v5->pActorBuffs[17].Apply(
           pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335),
-          v7,
-          v6 + 5,
+          masteryLevel,
+          realPoints + 5,
           0,
           0);
         pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
@@ -860,70 +761,29 @@
         pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
         return;
       }
-      if ( (signed int)v7 <= 0 )
+
+      if (masteryLevel == 0)
       {
         v44 = 0;
-        v5->pActorBuffs[16].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335),
-          v7,
-          v6 + 5,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x5C310Eu);
-        v46 = 8 * LODWORD(v120);
-        LOBYTE(v46) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v46;
-        v98 = (SoundID)13040;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
       }
-      if ( (signed int)v7 <= 2 )
+      else if (masteryLevel == 1 || masteryLevel == 2)
       {
-        v45 = 300 * v6;
+        v45 = 300 * realPoints;
+        v44 = v45 + 3840;
       }
-      else
+      else if (masteryLevel == 3 )
       {
-        if ( v7 != 3 )
-        {
-          if ( v7 == 4 )
-          {
-            v44 = 3600 * (v6 + 64);
-            v5->pActorBuffs[16].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335),
-              v7,
-              v6 + 5,
-              0,
-              0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x5C310Eu);
-            v46 = 8 * LODWORD(v120);
-            LOBYTE(v46) = PID(OBJECT_Actor,LOBYTE(v120));
-            v99 = v46;
-            v98 = (SoundID)13040;
-            pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-            return;
-          }
-          v44 = 0;
-          v5->pActorBuffs[16].Apply(
-            pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335),
-            v7,
-            v6 + 5,
-            0,
-            0);
-          pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x5C310Eu);
-          v46 = 8 * LODWORD(v120);
-          LOBYTE(v46) = PID(OBJECT_Actor,LOBYTE(v120));
-          v99 = v46;
-          v98 = (SoundID)13040;
-          pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-          return;
-        }
-        v45 = 900 * v6;
+        v45 = 900 * realPoints;
+        v44 = v45 + 3840;
       }
-      v44 = v45 + 3840;
+      else if (masteryLevel == 4 ) 
+      {
+        v44 = 3600 * (realPoints + 64);
+      }
       v5->pActorBuffs[16].Apply(
         pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335),
-        v7,
-        v6 + 5,
+        masteryLevel,
+        realPoints + 5,
         0,
         0);
       pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x5C310Eu);
@@ -934,47 +794,24 @@
       pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
       return;
     }
-    if ( (signed int)v7 > 0 )
+
+    if (masteryLevel == 0)
+    {
+      LOWORD(v48) = 0;
+    }
+    else if (masteryLevel == 1 || masteryLevel == 2)
     {
-      if ( (signed int)v7 <= 2 )
-      {
-        v48 = 2 * v6 + 40;
-        v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, v7, v48, 0, 0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-        v50 = 8 * LODWORD(v120);
-        LOBYTE(v50) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v50;
-        v98 = (SoundID)14020;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 3 )
-      {
-        v48 = 3 * v6 + 60;
-        v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, v7, v48, 0, 0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-        v50 = 8 * LODWORD(v120);
-        LOBYTE(v50) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v50;
-        v98 = (SoundID)14020;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 4 )
-      {
-        LOWORD(v48) = 2 * (3 * v6 + 60);
-        v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, v7, v48, 0, 0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-        v50 = 8 * LODWORD(v120);
-        LOBYTE(v50) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v50;
-        v98 = (SoundID)14020;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
+      v48 = 2 * realPoints + 40;
+    }
+    else if (masteryLevel == 3 )
+    {
+      v48 = 3 * realPoints + 60;
     }
-    LOWORD(v48) = 0;
-    v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, v7, v48, 0, 0);
+    else if (masteryLevel == 4 ) 
+    {
+      LOWORD(v48) = 2 * (3 * realPoints + 60);
+    }
+    v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, masteryLevel, v48, 0, 0);
     pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
     v50 = 8 * LODWORD(v120);
     LOBYTE(v50) = PID(OBJECT_Actor,LOBYTE(v120));
@@ -1033,14 +870,14 @@
         goto LABEL_159;
       if ( uSpellID == 73 )
       {
-        if ( (signed int)v7 <= 0 || (signed int)v7 > 4 )
+        if ( (signed int)masteryLevel <= 0 || (signed int)masteryLevel > 4 )
           v51 = 0;
         else
-          v51 = 3600 * v6;
+          v51 = 3600 * realPoints;
         v5->pActorBuffs[21].Apply(
           pParty->uTimePlayed + (signed int)(signed __int64)((double)(v51 << 7) * 0.033333335),
-          v7,
-          v6,
+          masteryLevel,
+          realPoints,
           0,
           0);
         pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u);
@@ -1053,7 +890,7 @@
       }
       if ( uSpellID == 77 )
       {
-        v5->sCurrentHP += 5 * v6 + 10;
+        v5->sCurrentHP += 5 * realPoints + 10;
         if ( v5->sCurrentHP >= (signed int)v5->pMonsterInfo.uHP )
           v5->sCurrentHP = LOWORD(v5->pMonsterInfo.uHP);
         pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u);
@@ -1070,68 +907,29 @@
         return;
       goto LABEL_159;
     }
-    if ( (signed int)v7 > 0 )
+    if (masteryLevel == 0)
+    {
+      v54 = 0;
+    }
+    else if (masteryLevel == 1 || masteryLevel == 2)
     {
-      if ( (signed int)v7 <= 2 )
-      {
-        v53 = 300 * v6;
-        v54 = v53 + 3840;
-        v5->pActorBuffs[18].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335),
-          v7,
-          v6 + 5,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-        v55 = 8 * LODWORD(v120);
-        LOBYTE(v55) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v55;
-        v98 = (SoundID)14060;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 3 )
-      {
-        v53 = 900 * v6;
-        v54 = v53 + 3840;
-        v5->pActorBuffs[18].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335),
-          v7,
-          v6 + 5,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-        v55 = 8 * LODWORD(v120);
-        LOBYTE(v55) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v55;
-        v98 = (SoundID)14060;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 4 )
-      {
-        v53 = 1200 * v6;
-        v54 = v53 + 3840;
-        v5->pActorBuffs[18].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335),
-          v7,
-          v6 + 5,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
-        v55 = 8 * LODWORD(v120);
-        LOBYTE(v55) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v55;
-        v98 = (SoundID)14060;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
+      v53 = 300 * realPoints;
+      v54 = v53 + 3840;
     }
-    v54 = 0;
+    else if (masteryLevel == 3 )
+    {
+      v53 = 900 * realPoints;
+      v54 = v53 + 3840;
+    }
+    else if (masteryLevel == 4 ) 
+    {
+      v53 = 1200 * realPoints;
+      v54 = v53 + 3840;
+    }
     v5->pActorBuffs[18].Apply(
       pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335),
-      v7,
-      v6 + 5,
+      masteryLevel,
+      realPoints + 5,
       0,
       0);
     pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
@@ -1144,68 +942,29 @@
   }
   if ( uSpellID == 85 )
   {
-    if ( (signed int)v7 > 0 )
+    if (masteryLevel == 0)
+    {
+      LOWORD(realPoints) = uSkillLevel;
+      v96 = 0;
+    }
+    else if (masteryLevel == 1 || masteryLevel == 2)
     {
-      if ( (signed int)v7 <= 2 )
-      {
-        v96 = 300 * v6 + 3840;
-        v5->pActorBuffs[13].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335),
-          v7,
-          v6,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
-        v97 = 8 * LODWORD(v120);
-        LOBYTE(v97) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v97;
-        v98 = (SoundID)17070;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 3 )
-      {
-        LOWORD(v6) = 3 * v6;
-        v96 = 900 * (uSkillLevel & 0x3F) + 3840;
-        v5->pActorBuffs[13].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335),
-          v7,
-          v6,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
-        v97 = 8 * LODWORD(v120);
-        LOBYTE(v97) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v97;
-        v98 = (SoundID)17070;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 4 )
-      {
-        v96 = 1200 * v6 + 3840;
-        LOWORD(v6) = 4 * v6;
-        v5->pActorBuffs[13].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335),
-          v7,
-          v6,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
-        v97 = 8 * LODWORD(v120);
-        LOBYTE(v97) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v97;
-        v98 = (SoundID)17070;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
+      v96 = 300 * realPoints + 3840;
     }
-    LOWORD(v6) = uSkillLevel;
-    v96 = 0;
+    else if (masteryLevel == 3 )
+    {
+      LOWORD(realPoints) = 3 * realPoints;
+      v96 = 900 * (uSkillLevel & 0x3F) + 3840;
+    }
+    else if (masteryLevel == 4 ) 
+    {
+      v96 = 1200 * realPoints + 3840;
+      LOWORD(realPoints) = 4 * realPoints;
+    }
     v5->pActorBuffs[13].Apply(
       pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335),
-      v7,
-      v6,
+      masteryLevel,
+      realPoints,
       0,
       0);
     pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
@@ -1218,68 +977,29 @@
   }
   if ( uSpellID == 86 )
   {
-    if ( (signed int)v7 > 0 )
+    if (masteryLevel == 0)
+    {
+      v94 = 0;
+    } 
+    else if (masteryLevel == 1 || masteryLevel == 2)
     {
-      if ( (signed int)v7 <= 2 )
-      {
-        v93 = 300 * v6;
-        v94 = v93 + 3840;
-        v5->pActorBuffs[14].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335),
-          v7,
-          v6 + 5,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
-        v95 = 8 * LODWORD(v120);
-        LOBYTE(v95) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v95;
-        v98 = (SoundID)17080;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 3 )
-      {
-        v93 = 900 * v6;
-        v94 = v93 + 3840;
-        v5->pActorBuffs[14].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335),
-          v7,
-          v6 + 5,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
-        v95 = 8 * LODWORD(v120);
-        LOBYTE(v95) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v95;
-        v98 = (SoundID)17080;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 4 )
-      {
-        v93 = 1200 * v6;
-        v94 = v93 + 3840;
-        v5->pActorBuffs[14].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335),
-          v7,
-          v6 + 5,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
-        v95 = 8 * LODWORD(v120);
-        LOBYTE(v95) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v95;
-        v98 = (SoundID)17080;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
+      v93 = 300 * realPoints;
+      v94 = v93 + 3840;
     }
-    v94 = 0;
+    else if (masteryLevel == 3)
+    {
+      v93 = 900 * realPoints;
+      v94 = v93 + 3840;
+    }
+    else // if (v7 == 4)
+    {
+      v93 = 1200 * realPoints;
+      v94 = v93 + 3840;
+    }
     v5->pActorBuffs[14].Apply(
       pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335),
-      v7,
-      v6 + 5,
+      masteryLevel,
+      realPoints + 5,
       0,
       0);
     pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
@@ -1299,49 +1019,21 @@
       v49 = uSpellID == 97;
       goto LABEL_158;
     }
-    if ( (signed int)v7 > 0 )
+    if (masteryLevel == 0)
+      v68 = 0;
+    else if (masteryLevel == 1 || (masteryLevel == 2) || (masteryLevel == 3))
     {
-      if ( (signed int)v7 <= 3 )
-      {
-        v67 = 300 * v6;
-        v68 = v67 + 3840;
-        v5->pActorBuffs[20].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335),
-          v7,
-          0,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x7E7E7Eu);
-        v69 = 8 * LODWORD(v120);
-        LOBYTE(v69) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v69;
-        v98 = (SoundID)18060;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
-      if ( v7 == 4 )
-      {
-        v67 = 900 * v6;
-        v68 = v67 + 3840;
-        v5->pActorBuffs[20].Apply(
-          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335),
-          v7,
-          0,
-          0,
-          0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x7E7E7Eu);
-        v69 = 8 * LODWORD(v120);
-        LOBYTE(v69) = PID(OBJECT_Actor,LOBYTE(v120));
-        v99 = v69;
-        v98 = (SoundID)18060;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
-        return;
-      }
+      v67 = 900 * realPoints;
+      v68 = v67 + 3840;
     }
-    v68 = 0;
+    else
+    {
+      v67 = 300 * realPoints;
+      v68 = v67 + 3840;
+    }
     v5->pActorBuffs[20].Apply(
       pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335),
-      v7,
+      masteryLevel,
       0,
       0,
       0);