diff Actor.cpp @ 1858:d7c028a6a084

Actor::AI_SpellAttack removing unnecessary temporary vars
author Grumpy7
date Mon, 14 Oct 2013 02:12:01 +0200
parents f357e4cbd169
children f135ff4decbb
line wrap: on
line diff
--- a/Actor.cpp	Mon Oct 14 00:58:05 2013 +0200
+++ b/Actor.cpp	Mon Oct 14 02:12:01 2013 +0200
@@ -206,53 +206,21 @@
   unsigned int realPoints; // edi@1
   unsigned int masteryLevel; // eax@1
   int v8; // edi@16
-  int v9; // edi@17
   signed int v10; // ecx@22
-  signed int v11; // eax@29
-  __int16 *v12; // edi@30
-  int v13; // ecx@34
-  int v14; // edx@34
-  int v15; // eax@34
-  AIDirection *v16; // esi@34
-  unsigned __int16 v17; // di@34
-  //int v18; // eax@34
   int v19; // edi@34
   int v20; // eax@35
-  int v21; // eax@39
-  SoundID v22; // eax@39
   signed int v23; // eax@41
-  double v24; // st7@49
-  float v25; // ST5C_4@50
-  int v26; // eax@50
-  double v27; // st7@50
   double v28; // st6@50
-  float v29; // ST4C_4@51
   int v30; // esi@50
   int v31; // ST3C_4@51
   unsigned int v32; // edi@51
-  char *v33; // eax@54
-  unsigned __int16 v34; // ax@57
-  signed int v35; // ecx@58
   signed int v36; // eax@67
-  signed int v37; // eax@68
-  signed __int64 v38; // qtt@69
   int v39; // ecx@75
-  int v40; // eax@79
-  int v41; // ecx@90
   int v42; // ecx@91
-  int v43; // eax@95
   int v44; // ecx@100
-  int v45; // ecx@101
-  int v46; // eax@105
   int v48; // ecx@110
-  char v49; // zf@123
-  int v50; // eax@127
   int v51; // ecx@130
-  int v52; // eax@132
-  int v53; // ecx@137
   int v54; // ecx@138
-  int v55; // eax@142
-  SpellBuff *v56; // esi@143
   Player *v57; // esi@145
   int v58; // eax@146
   int v59; // edi@146
@@ -260,70 +228,33 @@
   int v61; // edi@146
   int v62; // eax@146
   signed int v63; // edi@146
-  signed int v64; // edi@147
-  int v65; // eax@151
-  char *v66; // eax@160
-  int v67; // edi@167
   int v68; // edi@168
-  int v69; // eax@171
   signed int v70; // ecx@172
-  signed int v71; // eax@179
-  __int16 *v72; // edi@180
-  int v73; // ecx@184
-  int v74; // edx@184
-  int v75; // eax@184
-  AIDirection *v76; // esi@184
-  unsigned __int16 v77; // di@184
-  //int v78; // eax@184
   int v79; // edx@185
   int v80; // eax@185
-  int v81; // eax@189
-  unsigned __int16 v82; // ax@190
-  int v83; // ecx@192
-  int v84; // edx@192
-  int v85; // eax@192
-  AIDirection *v86; // esi@192
-  unsigned __int16 v87; // di@192
-  __int16 v88; // ax@192
   signed int v89; // ecx@192
-  //int v90; // eax@192
   signed int v91; // eax@200
-  int v92; // eax@201
-  int v93; // ecx@207
   int v94; // ecx@208
-  int v95; // eax@212
   int v96; // ecx@217
-  int v97; // eax@221
-  SoundID v98; // [sp-18h] [bp-E8h]@79
-  signed int v99; // [sp-14h] [bp-E4h]@39
-  signed int v105; // [sp+4h] [bp-CCh]@23
-  signed int v107; // [sp+4h] [bp-CCh]@42
-  signed int v108; // [sp+4h] [bp-CCh]@173
   int pitch; // [sp+2Ch] [bp-A4h]@51
-  float v110; // [sp+30h] [bp-A0h]@50
   int v111; // [sp+38h] [bp-98h]@41
-  float v112; // [sp+3Ch] [bp-94h]@49
   int v113; // [sp+40h] [bp-90h]@41
   int v114; // [sp+48h] [bp-88h]@41
   SpriteObject a1; // [sp+4Ch] [bp-84h]@1
   int v116; // [sp+BCh] [bp-14h]@49
-  AIDirection *v117; // [sp+C0h] [bp-10h]@1
   int v118; // [sp+C4h] [bp-Ch]@29
   float v119; // [sp+C8h] [bp-8h]@48
   float v120; // [sp+CCh] [bp-4h]@1
   int spellnuma; // [sp+D8h] [bp+8h]@29
   int spellnumb; // [sp+D8h] [bp+8h]@48
   float spellnumc; // [sp+D8h] [bp+8h]@50
-  signed int spellnumd; // [sp+D8h] [bp+8h]@53
   int spellnume; // [sp+D8h] [bp+8h]@179
   int a1a; // [sp+E0h] [bp+10h]@34
-  signed int a1b; // [sp+E0h] [bp+10h]@145
   int a1c; // [sp+E0h] [bp+10h]@184
 
 
   LODWORD(v120) = uActorID;
   v5 = &pActors[uActorID];
-  v117 = pDir;
   realPoints = uSkillLevel & 0x3F;
   masteryLevel = SkillToMastery(uSkillLevel);
 
@@ -344,38 +275,29 @@
     case 90:
     case 97:
       a1.uType = stru_4E3ACC[uSpellID].uType;
-      v119 = 0.0;
-      v82 = 0;
+      a1.uObjectDescID = 0;
       for (int i = 0; i < pObjectList->uNumObjects; i++)
       {
         if (a1.uType == pObjectList->pObjects[i].uObjectID)
         {
-          v82 = i;
+          a1.uObjectDescID = i;
           break;
         }
       }
-      a1.uObjectDescID = v82;
       a1.stru_24.Reset();
       a1.spell_id = uSpellID;
-      v83 = v5->vPosition.x;
-      v84 = v5->vPosition.y;
       a1.spell_level = uSkillLevel;
-      a1.vPosition.x = v83;
-      v85 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
-      v86 = v117;
-      v87 = LOWORD(v117->uYawAngle);
+      a1.vPosition.x = v5->vPosition.x;
       a1.spell_skill = 0;
-      a1.vPosition.y = v84;
-      a1.vPosition.z = v85;
-      a1.uFacing = v87;
+      a1.vPosition.y = v5->vPosition.y;
+      a1.vPosition.z = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
+      a1.uFacing = LOWORD(pDir->uYawAngle);
       a1.uSoundID = 0;
       a1.uAttributes = 0;
-      v88 = pIndoor->GetSector(v83, v84, v85);
-      v89 = v86->uDistance;
-      a1.uSectorID = v88;
-      LODWORD(v119) = v89;
+      v89 = pDir->uDistance;
+      a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
       a1.uSpriteFrameID = 0;
-      a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120));
+      a1.spell_caster_pid = PID(OBJECT_Actor, uActorID);
       a1.spell_target_pid = 0;
       if ((double)v89 < 307.2 )
         a1.field_60_distance_related_prolly_lod = 0;
@@ -388,41 +310,27 @@
 
       a1.field_61 = 2;
       v91 = a1.Create(
-        v86->uYawAngle,
-        v86->uPitchAngle,
+        pDir->uYawAngle,
+        pDir->uPitchAngle,
         pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
         0);
       if ( v91 != -1 )
       {
-        v92 = 8 * v91;
-        LOBYTE(v92) = v92 | 2;
-        v99 = v92;
-        v22 = (SoundID)word_4EE088_sound_ids[uSpellID];
-        v98 = v22;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], PID(OBJECT_Item, v91), 0, -1, 0, 0, 0, 0);
         return;
       }
       return;
       break;
 
-
-    case 5:
-      if (masteryLevel == 0)
-      {
-        v39 = 0;
-      }
-      else if (masteryLevel == 1 || masteryLevel == 2)
-      {
+    case 5: 
+      if (masteryLevel == 1 || masteryLevel == 2)
         v39 = 60 * (realPoints + 60);
-      }
       else if (masteryLevel == 3 )
-      {
         v39 = 180 * (realPoints + 20);
-      }
       else if (masteryLevel == 4 ) 
-      {
         v39 = 240 * (realPoints + 15);
-      }
+      else
+        v39 = 0;
       v5->pActorBuffs[19].Apply(
         pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335),
         masteryLevel,
@@ -430,11 +338,7 @@
         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);
+      pAudioPlayer->PlaySound((SoundID)10040, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 9:
@@ -451,133 +355,104 @@
         v23 = 12;
       else if (masteryLevel == 4)
         v23 = 14;
-      v119 = 0.0;
       spellnumb = 0;
-      if ( v23 > 0 )
+      for ( int i = 0; i < v23; i++)
       {
-        v24 = (double)v118;
-        v118 = v23;
-        v112 = v24;
-        v116 = PID(OBJECT_Actor,LODWORD(v120));
-        do
+        v28 = (double)spellnumb;
+        v30 = rand() % 1000;
+        spellnumc = v30 + pParty->vPosition.z - v114;
+        v120 = v28 * v28;
+        v119 = spellnumb * spellnumb;
+        if ( sqrt(spellnumc * spellnumc + v119 + v120) <= 1.0 )
         {
-          v26 = rand();
-          v27 = (double)spellnumb;
-          v110 = v27;
-          v28 = (double)SLODWORD(v119);
-          v30 = v26 % 1000;
-          v25 = (double)v114;
-          spellnumc = (double)(v26 % 1000) + v112 - v25;
-          v120 = v28 * v28;
-          v119 = v27 * v27;
-          if ( sqrt(spellnumc * spellnumc + v119 + v120) <= 1.0 )
+          v32 = 0;
+          pitch = 0;
+        }
+        else
+        {
+          v31 = (signed __int64)sqrt(v119 + v120);
+          v32 = stru_5C6E00->Atan2(spellnumb, (int)v28);
+          pitch = stru_5C6E00->Atan2(v31, (int)spellnumc);
+        }
+        a1.stru_24.Reset();
+        a1.uType = stru_4E3ACC[9].uType;
+        a1.uObjectDescID = 0;
+        for (int i = 0; i < pObjectList->uNumObjects; i++)
+        {
+          if (pObjectList->pObjects[i].uObjectID == a1.uType)
           {
-            v32 = 0;
-            pitch = 0;
-          }
-          else
-          {
-            v31 = (signed __int64)sqrt(v119 + v120);
-            v29 = v28;
-            v32 = stru_5C6E00->Atan2((signed __int64)v110, (signed __int64)v29);
-            pitch = stru_5C6E00->Atan2(v31, (signed __int64)spellnumc);
-          }
-          a1.stru_24.Reset();
-          a1.uType = stru_4E3ACC[9].uType;
-          v34 = 0;
-          for (int i = 0; i < pObjectList->uNumObjects; i++)
-          {
-            if (pObjectList->pObjects[i].uObjectID == a1.uType)
-            {
-              v34 = i;
-              break;
-            }
+            a1.uObjectDescID = i;
+            break;
           }
-          a1.uObjectDescID = v34;
-          a1.spell_level = uSkillLevel;
-          a1.vPosition.x = v111;
-          a1.vPosition.y = v113;
-          a1.vPosition.z = v30 + v114;
-          a1.spell_id = SPELL_FIRE_METEOR_SHOWER;
-          a1.spell_skill = 0;
-          a1.uAttributes = 0;
-          a1.uSectorID = 0;
-          a1.uSpriteFrameID = 0;
-          a1.spell_caster_pid = v116;
-          a1.spell_target_pid = 0;
-          a1.field_60_distance_related_prolly_lod = stru_50C198._427546(v30 + 2500);
-          a1.uFacing = v32;
-          a1.uSoundID = 0;
-          v35 = v117->uDistance;
-          LODWORD(v119) = v117->uDistance;
-          if ((double)v119 < 307.2 )
-            a1.field_60_distance_related_prolly_lod = 0;
-          else if ( v119 < 1024 )
-            a1.field_60_distance_related_prolly_lod = 1;
-          else if ( v119 < 2560 )
-            a1.field_60_distance_related_prolly_lod = 2;
-          else 
-            a1.field_60_distance_related_prolly_lod = 3;
-          a1.field_61 = 2;
-          v36 = a1.Create(
-            v32,
-            pitch,
-            pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-            0);
-          if ( v36 != -1 )
-          {
-            v37 = 8 * v36;
-            LOBYTE(v37) = v37 | 2;
-            pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[9], v37, 0, -1, 0, 0, 0, 0);
-          }
-          spellnumb = rand() % 1024 - 512;
-          v38 = rand();
-          v49 = v118-- == 1;
-          LODWORD(v119) = (unsigned __int64)(v38 % 1024) - 512;
         }
-        while ( !v49 );
+        a1.spell_level = uSkillLevel;
+        a1.vPosition.x = pParty->vPosition.x;
+        a1.vPosition.y = pParty->vPosition.y;
+        a1.vPosition.z = v30 + v114;
+        a1.spell_id = SPELL_FIRE_METEOR_SHOWER;
+        a1.spell_skill = 0;
+        a1.uAttributes = 0;
+        a1.uSectorID = 0;
+        a1.uSpriteFrameID = 0;
+        a1.spell_caster_pid = PID(OBJECT_Actor, uActorID);
+        a1.spell_target_pid = 0;
+        a1.field_60_distance_related_prolly_lod = stru_50C198._427546(v30 + 2500);
+        a1.uFacing = v32;
+        a1.uSoundID = 0;
+        if (pDir->uDistance < 307.2 )
+          a1.field_60_distance_related_prolly_lod = 0;
+        else if ( pDir->uDistance < 1024 )
+          a1.field_60_distance_related_prolly_lod = 1;
+        else if ( pDir->uDistance < 2560 )
+          a1.field_60_distance_related_prolly_lod = 2;
+        else 
+          a1.field_60_distance_related_prolly_lod = 3;
+        a1.field_61 = 2;
+        v36 = a1.Create(
+          v32,
+          pitch,
+          pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
+          0);
+        if ( v36 != -1 )
+        {
+          pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[9], PID(OBJECT_Item, v36), 0, -1, 0, 0, 0, 0);
+        }
+        spellnumb = rand() % 1024 - 512;
       }
       return;
       break;
 
-    case 15:
-      if (masteryLevel <= 1)
-        v10 = 3;
-      else if (masteryLevel == 2 )
+    case 15:if (masteryLevel == 2 )
         v10 = 5;
       else if (masteryLevel == 3 )
         v10 = 7;
       else if (masteryLevel == 4 ) 
         v10 = 9;
+      else 
+        v10 = 3;
       spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
       a1.uType = stru_4E3ACC[15].uType;
       v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1);
-      v11 = 0;
+      a1.uObjectDescID = 0;
       for (unsigned int i = 0; i < pObjectList->uNumObjects; i++)
       {
         if (stru_4E3ACC[15].uType == pObjectList->pObjects[i].uObjectID)
         {
-          v11 = i;
+          a1.uObjectDescID = i;
           break;
         }
       }
-      a1.uObjectDescID = v11;
       a1.stru_24.Reset();
       a1.spell_id = SPELL_AIR_SPARKS;
-      v13 = v5->vPosition.x;
-      v14 = v5->vPosition.y;
       a1.spell_level = uSkillLevel;
-      a1.vPosition.x = v13;
-      v15 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
-      v16 = v117;
-      v17 = LOWORD(v117->uYawAngle);
+      a1.vPosition.x = v5->vPosition.x;
       a1.spell_skill = 0;
-      a1.vPosition.y = v14;
-      a1.vPosition.z = v15;
-      a1.uFacing = v17;
+      a1.vPosition.y = v5->vPosition.y;
+      a1.vPosition.z = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
+      a1.uFacing = pDir->uYawAngle;
       a1.uSoundID = 0;
       a1.uAttributes = 0;
-      a1.uSectorID = pIndoor->GetSector(v13, v14, v15);
+      a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
       a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120));
       a1.uSpriteFrameID = 0;
       a1.spell_target_pid = 0;
@@ -592,10 +467,10 @@
       {
         do
         {
-          a1.uFacing = v19 + LOWORD(v16->uYawAngle);
+          a1.uFacing = v19 + LOWORD(pDir->uYawAngle);
           v20 = a1.Create(
             (signed __int16)a1.uFacing,
-            v16->uPitchAngle,
+            pDir->uPitchAngle,
             pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
             0);
           v19 += v118;
@@ -604,36 +479,21 @@
       }
       if ( v20 != -1 )
       {
-        v21 = 8 * v20;
-        LOBYTE(v21) = v21 | 2;
-        v99 = v21;
-        v22 = (SoundID)word_4EE088_sound_ids[15];
-        v98 = v22;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[15], PID(OBJECT_Item, v20), 0, -1, 0, 0, 0, 0);
         return;
       }
       return;
       break;
 
     case 17:
-      if (masteryLevel == 0)
-      {
+      if (masteryLevel == 1 || masteryLevel == 2)
+        v8 = 300 * realPoints + 3840;
+      else if (masteryLevel == 3 )
+        v8 = 900 * realPoints + 3840;
+      else if (masteryLevel == 4 ) 
+        v8 = 3600 * (realPoints + 64);
+      else
         v8 = 0;
-      }
-      else if (masteryLevel == 1 || masteryLevel == 2)
-      {
-        v9 = 300 * realPoints;
-        v8 = v9 + 3840;
-      }
-      else if (masteryLevel == 3 )
-      {
-        v9 = 900 * realPoints;
-        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),
         masteryLevel,
@@ -643,24 +503,14 @@
       return;
 
     case 38:
-      if (masteryLevel == 0)
-      {
-        v44 = 0;
-      }
-      else if (masteryLevel == 1 || masteryLevel == 2)
-      {
-        v45 = 300 * realPoints;
-        v44 = v45 + 3840;
-      }
+      if (masteryLevel == 1 || masteryLevel == 2)
+        v44 = 300 * realPoints + 3840;
       else if (masteryLevel == 3 )
-      {
-        v45 = 900 * realPoints;
-        v44 = v45 + 3840;
-      }
+        v44 = 900 * realPoints + 3840;
       else if (masteryLevel == 4 ) 
-      {
         v44 = 3600 * (realPoints + 64);
-      }
+      else
+          v44 = 0;
       v5->pActorBuffs[16].Apply(
         pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335),
         masteryLevel,
@@ -668,33 +518,18 @@
         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);
+      pAudioPlayer->PlaySound((SoundID)13040, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 46:
-      if (masteryLevel == 0)
-      {
-        v42 = 0;
-      }
-      else if (masteryLevel == 1 || masteryLevel == 2)
-      {
-        v41 = 300 * realPoints;
-        v42 = v41 + 3840;
-      }
+      if (masteryLevel == 1 || masteryLevel == 2)
+        v42 = 300 * realPoints + 3840;
       else if (masteryLevel == 3 )
-      {
-        v41 = 900 * realPoints;
-        v42 = v41 + 3840;
-      }
+        v42 = 900 * realPoints + 3840;
       else if (masteryLevel == 4 ) 
-      {
-        v41 = 1200 * realPoints;
-        v42 = v41 + 3840;
-      }
+        v42 = 1200 * realPoints + 3840;
+      else
+        v42 = 0;
       v5->pActorBuffs[17].Apply(
         pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335),
         masteryLevel,
@@ -702,60 +537,33 @@
         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);
+      pAudioPlayer->PlaySound((SoundID)14010, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0);
       return;
       break;
 
     case 47:
-      if (masteryLevel == 0)
-      {
-        LOWORD(v48) = 0;
-      }
-      else if (masteryLevel == 1 || masteryLevel == 2)
-      {
+      if (masteryLevel == 1 || masteryLevel == 2)
         v48 = 2 * realPoints + 40;
-      }
       else if (masteryLevel == 3 )
-      {
         v48 = 3 * realPoints + 60;
-      }
       else if (masteryLevel == 4 ) 
-      {
-        LOWORD(v48) = 2 * (3 * realPoints + 60);
-      }
+        v48 = 2 * (3 * realPoints + 60);
+      else
+        v48 = 0;
       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));
-      v99 = v50;
-      v98 = (SoundID)14020;
-      pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
+      pAudioPlayer->PlaySound((SoundID)14020, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 51:
-      if (masteryLevel == 0)
-      {
-        v54 = 0;
-      }
-      else if (masteryLevel == 1 || masteryLevel == 2)
-      {
-        v53 = 300 * realPoints;
-        v54 = v53 + 3840;
-      }
+      if (masteryLevel == 1 || masteryLevel == 2)
+        v54 = 300 * realPoints + 3840;
       else if (masteryLevel == 3 )
-      {
-        v53 = 900 * realPoints;
-        v54 = v53 + 3840;
-      }
+        v54 = 900 * realPoints + 3840;
       else if (masteryLevel == 4 ) 
-      {
-        v53 = 1200 * realPoints;
-        v54 = v53 + 3840;
-      }
+        v54 = 1200 * realPoints + 3840;
+      else
+        v54 = 0;
       v5->pActorBuffs[18].Apply(
         pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335),
         masteryLevel,
@@ -763,11 +571,7 @@
         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);
+      pAudioPlayer->PlaySound((SoundID)14060, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 73:
@@ -782,11 +586,7 @@
         0,
         0);
       pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u);
-      v52 = 8 * LODWORD(v120);
-      LOBYTE(v52) = PID(OBJECT_Actor,LOBYTE(v120));
-      v99 = v52;
-      v98 = (SoundID)16060;
-      pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
+      pAudioPlayer->PlaySound((SoundID)16060, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 77:
@@ -794,11 +594,7 @@
       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);
-      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);
+      pAudioPlayer->PlaySound((SoundID)14020, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 80:
@@ -809,12 +605,12 @@
       for (int i = 1; i <= 4; i++)
       {
         v57 = pPlayers[i];
-        v58 = (v57)->GetActualWillpower();
-        v59 = (v57)->GetParameterBonus(v58);
-        v60 = (v57)->GetActualIntelligence();
-        v61 = ((v57)->GetParameterBonus(v60) + v59) >> 1;
-        v62 = (v57)->GetActualLuck();
-        v63 = v61 + (v57)->GetParameterBonus(v62) + 30;
+        v58 = v57->GetActualWillpower();
+        v59 = v57->GetParameterBonus(v58);
+        v60 = v57->GetActualIntelligence();
+        v61 = (v57->GetParameterBonus(v60) + v59) / 2;
+        v62 = v57->GetActualLuck();
+        v63 = v61 + v57->GetParameterBonus(v62) + 30;
         if ( rand() % v63 < 30 )
         {
           for (int k = 0; k < v57->pPlayerBuffs.size(); k++)
@@ -824,21 +620,11 @@
           pOtherOverlayList->_4418B1(11210, i + 99, 0, 65536);
         }
       }
-      v65 = 8 * LODWORD(v120);
-      LOBYTE(v65) = PID(OBJECT_Actor,LOBYTE(v120));
-      v99 = v65;
-      v22 = (SoundID)word_4EE088_sound_ids[80];
-      v98 = v22;
-      pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
+      pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[80], PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 85:
-      if (masteryLevel == 0)
-      {
-        LOWORD(realPoints) = uSkillLevel;
-        v96 = 0;
-      }
-      else if (masteryLevel == 1 || masteryLevel == 2)
+       if (masteryLevel == 1 || masteryLevel == 2)
       {
         v96 = 300 * realPoints + 3840;
       }
@@ -852,6 +638,11 @@
         v96 = 1200 * realPoints + 3840;
         LOWORD(realPoints) = 4 * realPoints;
       }
+      else
+      {
+        LOWORD(realPoints) = uSkillLevel;
+        v96 = 0;
+      }
       v5->pActorBuffs[13].Apply(
         pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335),
         masteryLevel,
@@ -859,33 +650,18 @@
         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);
+      pAudioPlayer->PlaySound((SoundID)17070, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 86:
-      if (masteryLevel == 0)
-      {
-        v94 = 0;
-      } 
-      else if (masteryLevel == 1 || masteryLevel == 2)
-      {
-        v93 = 300 * realPoints;
-        v94 = v93 + 3840;
-      }
+      if (masteryLevel == 1 || masteryLevel == 2)
+        v94 = 300 * realPoints + 3840;
       else if (masteryLevel == 3)
-      {
-        v93 = 900 * realPoints;
-        v94 = v93 + 3840;
-      }
-      else // if (v7 == 4)
-      {
-        v93 = 1200 * realPoints;
-        v94 = v93 + 3840;
-      }
+        v94 = 900 * realPoints + 3840;
+      else if (masteryLevel == 4)
+        v94 = 1200 * realPoints + 3840;
+      else
+        v94 = 0;
       v5->pActorBuffs[14].Apply(
         pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335),
         masteryLevel,
@@ -893,52 +669,43 @@
         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);
+      pAudioPlayer->PlaySound((SoundID)17080, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
       return;
 
     case 93:
-      v70 = 3;
       if (masteryLevel == 2)
-        v108 = 5;
+        v70 = 5;
       else if (masteryLevel == 3)
-        v108 = 7;
+        v70 = 7;
       else if (masteryLevel == 4)
-        v108 = 9;
+        v70 = 9;
+      else
+        v70 = 3;
 
       spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
       a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType;
       v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1);
-      v71 = 0;
+      a1.uObjectDescID = 0;
       for (int i = 0; i < pObjectList->uNumObjects; i++)
       {
         if (pObjectList->pObjects[i].uObjectID == stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType)
         {
-          v71 = i;
+          a1.uObjectDescID = i;
           break;
         }
       }
-      a1.uObjectDescID = v71;
       a1.stru_24.Reset();
       a1.spell_id = SPELL_DARK_SHARPMETAL;
-      v73 = v5->vPosition.x;
-      v74 = v5->vPosition.y;
       a1.spell_level = uSkillLevel;
-      a1.vPosition.x = v73;
-      v75 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
-      v76 = v117;
-      v77 = LOWORD(v117->uYawAngle);
+      a1.vPosition.x = v5->vPosition.x;
       a1.spell_skill = 0;
-      a1.vPosition.y = v74;
-      a1.vPosition.z = v75;
-      a1.uFacing = v77;
+      a1.vPosition.y = v5->vPosition.y;
+      a1.vPosition.z = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
+      a1.uFacing = pDir->uYawAngle;
       a1.uSoundID = 0;
       a1.uAttributes = 0;
-      a1.uSectorID = pIndoor->GetSector(v73, v74, v75);
-      a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120));
+      a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
+      a1.spell_caster_pid = PID(OBJECT_Actor, uActorID);
       a1.uSpriteFrameID = 0;
       a1.spell_target_pid = 0;
       a1.field_60_distance_related_prolly_lod = 3;
@@ -951,11 +718,11 @@
       {
         do
         {
-          v79 = v76->uYawAngle;
-          a1.uFacing = a1c + LOWORD(v76->uYawAngle);
+          v79 = pDir->uYawAngle;
+          a1.uFacing = a1c + LOWORD(pDir->uYawAngle);
           v80 = a1.Create(
             v79,
-            v76->uPitchAngle,
+            pDir->uPitchAngle,
             pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
             0);
           a1c += v116;
@@ -964,28 +731,19 @@
       }
       if ( v80 != -1 )
       {
-        v81 = 8 * v80;
-        LOBYTE(v81) = v81 | 2;
-        v99 = v81;
-        v22 = (SoundID)word_4EE088_sound_ids[93];
-        v98 = v22;
-        pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0);
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[93], PID(OBJECT_Item, v80), 0, -1, 0, 0, 0, 0);
         return;
       }
+      return;
+      break;
 
     case 95:
       if (masteryLevel == 0)
         v68 = 0;
       else if (masteryLevel == 1 || (masteryLevel == 2) || (masteryLevel == 3))
-      {
-        v67 = 900 * realPoints;
-        v68 = v67 + 3840;
-      }
+        v68 = 300 * realPoints + 3840;
       else
-      {
-        v67 = 300 * realPoints;
-        v68 = v67 + 3840;
-      }
+        v68 = 900 * realPoints + 3840;
       v5->pActorBuffs[20].Apply(
         pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335),
         masteryLevel,
@@ -993,11 +751,7 @@
         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);
+      pAudioPlayer->PlaySound((SoundID)18060, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
       return;
   }