diff mm7_2.cpp @ 1441:b67a3e0d6fc3

Слияние
author Ritor1
date Sat, 27 Jul 2013 09:36:55 +0600
parents 468f434a8d8a 2423bc2af692
children a8b1bbac95d4
line wrap: on
line diff
--- a/mm7_2.cpp	Sat Jul 27 09:36:29 2013 +0600
+++ b/mm7_2.cpp	Sat Jul 27 09:36:55 2013 +0600
@@ -572,6 +572,7 @@
     v4 /= 2;
     goto LABEL_24;
   }
+  __debugbreak(); // warning C4700: uninitialized local variable 'v27' used
   if ( uDialogueType == 88 )
     num_monsters = 2 * v4;
   else
@@ -715,7 +716,7 @@
         {
           UI_CreateEndConversationButton();
           dialog_menu_id = HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT;
-          sub_4B3AD4(in_current_building_type);
+          InitializaDialogueOptions_Shops(in_current_building_type);
         }
         else
         {
@@ -724,20 +725,20 @@
             pVideoPlayer->_4BF5B2();
 //LABEL_28:
             dialog_menu_id = HOUSE_DIALOGUE_MAIN;
-            sub_4B3B42(in_current_building_type);
+            InitializaDialogueOptions(in_current_building_type);
             return 1;
           }
           pVideoPlayer->_4BF5B2();
           UI_CreateEndConversationButton();
           dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN;
-          sub_4B3A72(in_current_building_type);
+          InitializaDialogueOptions_Tavern(in_current_building_type);
         }
         return 1;
       }
       pVideoPlayer->_4BF5B2();
       UI_CreateEndConversationButton();
 	  dialog_menu_id = HOUSE_DIALOGUE_MAIN;
-	  sub_4B3B42(in_current_building_type);
+	  InitializaDialogueOptions(in_current_building_type);
 	  return 1;
     }
     pDialogueNPCCount = 0;
@@ -2339,6 +2340,7 @@
   LOWORD(v7) = v5 & 0xE0;
   v12 = v7 + v11;
   LOWORD(v7) = v8 & 0xE0;
+  __debugbreak(); // warning C4700: uninitialized local variable 'v10' used
   return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00)
                                                                     + (v5 & 0x1C00)
                                                                     + v9
@@ -2993,9 +2995,9 @@
     case 0x80:  return 3;     // Master
     case 0x40:  return 2;     // Expert
     case 0x00:  return 1;     // Normal
-    default:
-      assert(false);
-  }
+  }
+  assert(false);
+  return 0;
 }
 
 //----- (0045828B) --------------------------------------------------------
@@ -3342,33 +3344,29 @@
 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8;
 
 //----- (004621DA) --------------------------------------------------------
-int __fastcall int_get_vector_length(signed int a1, signed int a2, signed int a3)
+int int_get_vector_length(signed int x, signed int y, signed int z)
 {
   signed int v3; // eax@2
-  signed int v4; // eax@3
-  signed int v5; // esi@4
-  signed int v6; // esi@6
-
-  if ( a1 < a2 )
-  {
-    v3 = a1;
-    a1 = a2;
-    a2 = v3;
-  }
-  v4 = a3;
-  if ( a1 < a3 )
-  {
-    v5 = a1;
-    a1 = a3;
-    v4 = v5;
-  }
-  if ( a2 < v4 )
-  {
-    v6 = a2;
-    a2 = v4;
-    v4 = v6;
-  }
-  return (11 * a2 >> 5) + a1 + (v4 >> 2);
+
+  if ( x < y )
+  {
+    v3 = x;
+    x = y;
+    y = v3;
+  }
+  if ( x < z )
+  {
+    v3 = x;
+    x = z;
+    z = v3;
+  }
+  if ( y < z )
+  {
+    v3 = y;
+    y = z;
+    z = v3;
+  }
+  return (11 * y >> 5) + x + (z >> 2);
 }
 
 OPENFILENAMEA ofn;
@@ -5369,7 +5367,7 @@
   assert(sizeof(IndoorCamera) == 0x50);
   assert(sizeof(Bloodsplat) == 0x28);
   assert(sizeof(BloodsplatContainer) == 0xA0C);
-  assert(sizeof(stru167) == 0x18);
+  assert(sizeof(TrailParticle) == 0x18);
   assert(sizeof(EventIndex) == 0xC);
   assert(sizeof(_2devent) == 0x34);
   assert(sizeof(stru176) == 0x20);
@@ -5777,7 +5775,7 @@
       outdoor_grid_band_2 = 15;
       outdoor_grid_band_3 = 20;
       pOutdoorCamera->shading_dist_mist = 8192;
-      pOutdoorCamera->bNoSky = 0;
+      pOutdoorCamera->bNoSky = false;
       LOBYTE(viewparams->field_20) = 0;
     }
     mipmapping_terrain_mm1 = 1024;
@@ -5791,7 +5789,11 @@
     mipmapping_building_mm3 = 4096;
     pOutdoorCamera->shading_dist_shademist = 4096;
     pOutdoorCamera->outdoor_no_wavy_water = 0;
-    sub_47F4D3(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3);
+    //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3);
+    {
+      pOutdoorCamera->outdoor_grid_band_3 = outdoor_grid_band_3;
+      pOutdoorCamera->uPickDepth = outdoor_grid_band_3 * 512;
+    }
   }
   else
   {
@@ -6361,8 +6363,8 @@
   char *v11; // edx@20
   unsigned __int16 v12; // ax@23
   int v13; // eax@27
-  //unsigned int v14; // ebx@33
-  //unsigned __int16 v15; // ax@35
+  unsigned int v14; // ebx@33
+  unsigned __int16 v15; // ax@35
   int v16; // eax@36
   unsigned int v17; // eax@37
   __int16 v18; // di@37
@@ -6472,15 +6474,15 @@
   unsigned int v122; // eax@260
   char *v123; // edx@261
   int v124; // eax@267
-  //int v125; // [sp-20h] [bp-4Ch]@28
-  //signed int v126; // [sp-1Ch] [bp-48h]@27
-  //unsigned int v127; // [sp-18h] [bp-44h]@27
-  //signed int v128; // [sp-14h] [bp-40h]@27
-  //signed int v129; // [sp-10h] [bp-3Ch]@27
-  //int v130; // [sp-Ch] [bp-38h]@27
-  //unsigned int v131; // [sp-8h] [bp-34h]@27
+  int v125; // [sp-20h] [bp-4Ch]@28
+  signed int v126; // [sp-1Ch] [bp-48h]@27
+  unsigned int v127; // [sp-18h] [bp-44h]@27
+  signed int v128; // [sp-14h] [bp-40h]@27
+  signed int v129; // [sp-10h] [bp-3Ch]@27
+  int v130; // [sp-Ch] [bp-38h]@27
+  unsigned int v131; // [sp-8h] [bp-34h]@27
   char v132; // [sp-8h] [bp-34h]@131
-  //int v133; // [sp-4h] [bp-30h]@27
+  int v133; // [sp-4h] [bp-30h]@27
   char v134; // [sp-4h] [bp-30h]@131
   signed int v135; // [sp-4h] [bp-30h]@217
   int v136; // [sp+Ch] [bp-20h]@208
@@ -6534,13 +6536,13 @@
 
   v6 = v2->uType;
   v7 = v2->uType;
-  if ( v2->uType > 3060 )
-  {
-    if ( v2->uType > 6090 )
+  if ( v7 > 3060 )
+  {
+    if ( v7 > 6090 )
     {
-      if ( v2->uType > 8090 )
+      if ( v7 > 8090 )
       {
-        if ( v2->uType == 9010 )
+        if ( v7 == 9010 )
           goto LABEL_247;
         if ( v7 != 9030 )
         {
@@ -6562,88 +6564,13 @@
                 ++v146;
                 v144 += 56;
                 if ( v146 >= (signed int)v99 )
-                {
-                  v46 = 0;
-                  v2->uObjectDescID = v46;
-                  if ( v46 == (short)v32 )
-                    SpriteObject::OnInteraction(v153);
-                  v100 = v2->field_61;
-                  v101 = v2->vPosition.z;
-                  v2->uSpriteFrameID = v32;
-                  v102 = 8 * v153;
-                  v103 = v2->vPosition.y;
-                  LOBYTE(v102) = PID(OBJECT_Item,v153);
-                  v2->vVelocity.x = v32;
-                  v2->vVelocity.y = v32;
-                  v104 = v2->vPosition.x;
-                  v2->vVelocity.z = v32;
-                  v149 = v102;
-                  stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
-                  if ( HIBYTE(v3->uFlags) & 1 )
-                    array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
-                  v105 = v2->uSoundID;
-                  if ( v105 == (short)v32 )
-                    v47 = 0;
-                  else
-                    v47 = (signed __int16)v105 + 4;
-                  v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-                  pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
-                  return 0;
-                }
+                  goto LABEL_195;
               }
-              v46 = v146;
-              v2->uObjectDescID = v46;
-              if ( v46 == (short)v32 )
-                SpriteObject::OnInteraction(v153);
-              v100 = v2->field_61;
-              v101 = v2->vPosition.z;
-              v2->uSpriteFrameID = v32;
-              v102 = 8 * v153;
-              v103 = v2->vPosition.y;
-              LOBYTE(v102) = PID(OBJECT_Item,v153);
-              v2->vVelocity.x = v32;
-              v2->vVelocity.y = v32;
-              v104 = v2->vPosition.x;
-              v2->vVelocity.z = v32;
-              v149 = v102;
-              stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
-              if ( HIBYTE(v3->uFlags) & 1 )
-                array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
-              v105 = v2->uSoundID;
-              if ( v105 == (short)v32 )
-                v47 = 0;
-              else
-                v47 = (signed __int16)v105 + 4;
-              v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-              pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
-              return 0;
+              goto LABEL_80;
             }
+LABEL_195:
             v46 = 0;
-            v2->uObjectDescID = v46;
-            if ( v46 == (short)v32 )
-              SpriteObject::OnInteraction(v153);
-            v100 = v2->field_61;
-            v101 = v2->vPosition.z;
-            v2->uSpriteFrameID = v32;
-            v102 = 8 * v153;
-            v103 = v2->vPosition.y;
-            LOBYTE(v102) = PID(OBJECT_Item,v153);
-            v2->vVelocity.x = v32;
-            v2->vVelocity.y = v32;
-            v104 = v2->vPosition.x;
-            v2->vVelocity.z = v32;
-            v149 = v102;
-            stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
-            if ( HIBYTE(v3->uFlags) & 1 )
-            array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
-            v105 = v2->uSoundID;
-            if ( v105 == (short)v32 )
-              v47 = 0;
-            else
-              v47 = (signed __int16)v105 + 4;
-            v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-            pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
-            return 0;
+            goto LABEL_196;
           }
           goto LABEL_93;
         }
@@ -6665,10 +6592,7 @@
         if ( v151 != OBJECT_Actor)
         {
           if ( v6 != 9030 || v2->spell_skill != 4 )
-          {
-            SpriteObject::OnInteraction(v153);
-            return 0;
-          }
+            goto LABEL_246;
           v2->_46BEF1_apply_spells_aoe();
 LABEL_233:
           if ( !v138 )
@@ -6705,12 +6629,19 @@
               v114 = (signed __int16)v113 + 4;
             else
               v114 = 0;
+            v133 = 0;
+            v131 = 0;
+            v130 = v114;
             v115 = 8 * v153;
+            v129 = 0;
+            v128 = -1;
             LOBYTE(v115) = PID(OBJECT_Item,v153);
-            v116 = v143 + 1;
-            pAudioPlayer->PlaySound((SoundID)v116, v115, 0, -1, 0, 0, 0, 0);
-            return 0;
+            v127 = 0;
+            v126 = v115;
+            v116 = v143;
+            goto LABEL_269;
           }
+LABEL_246:
           SpriteObject::OnInteraction(v153);
           return 0;
         }
@@ -6761,8 +6692,12 @@
                     pActors[v108].uAIState = Standing;
                     pActors[v108].UpdateAnimation();
                   }
-                  pActors[v108].pActorBuffs[v136].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335),
-                    v152, v150, 0, 0);
+                  pActors[v108].pActorBuffs[v136].Apply(
+                    pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335),
+                    v152,
+                    v150,
+                    0,
+                    0);
                 }
               }
               else
@@ -6799,67 +6734,11 @@
             ++v52;
             v94 += 56;
             if ( v52 >= (signed int)v93 )
-            {
-              v95 = 0;
-              v2->uObjectDescID = v95;
-              if ( v95 == (short)v9 )
-                SpriteObject::OnInteraction(v153);
-              v96 = v2->uSoundID;
-              v2->vVelocity.z = v9;
-              v2->vVelocity.y = v9;
-              v2->vVelocity.x = v9;
-              v2->uSpriteFrameID = v9;
-              if ( v96 == (short)v9 )
-                v97 = 0;
-              else
-                v97 = (signed __int16)v96 + 4;
-              v92 = v153;
-              v124 = 8 * v92;
-              LOBYTE(v124) = v124 | 2;
-              v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-              pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-              return 0;
-            }
+              goto LABEL_181;
           }
-          v95 = v52;
-          v2->uObjectDescID = v95;
-          if ( v95 == (short)v9 )
-            SpriteObject::OnInteraction(v153);
-          v96 = v2->uSoundID;
-          v2->vVelocity.z = v9;
-          v2->vVelocity.y = v9;
-          v2->vVelocity.x = v9;
-          v2->uSpriteFrameID = v9;
-          if ( v96 == (short)v9 )
-            v97 = 0;
-          else
-            v97 = (signed __int16)v96 + 4;
-          v92 = v153;
-          v124 = 8 * v92;
-          LOBYTE(v124) = v124 | 2;
-          v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-          pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-          return 0;
+          goto LABEL_202;
         }
-        v95 = 0;
-        v2->uObjectDescID = v95;
-        if ( v95 == (short)v9 )
-          SpriteObject::OnInteraction(v153);
-        v96 = v2->uSoundID;
-        v2->vVelocity.z = v9;
-        v2->vVelocity.y = v9;
-        v2->vVelocity.x = v9;
-        v2->uSpriteFrameID = v9;
-        if ( v96 == (short)v9 )
-          v97 = 0;
-        else
-          v97 = (signed __int16)v96 + 4;
-        v92 = v153;
-        v124 = 8 * v92;
-        LOBYTE(v124) = v124 | 2;
-        v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-        pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-        return 0;
+        goto LABEL_181;
       }
       v79 = v7 == 8030;
     }
@@ -6911,22 +6790,34 @@
             v2->uObjectDescID = v58;
             if ( !v58 )
               SpriteObject::OnInteraction(v153);
+            v14 = v153;
             v2->vVelocity.z = 0;
             v2->vVelocity.y = 0;
             v2->vVelocity.x = 0;
             v2->uSpriteFrameID = 0;
             sub_43A97E(v153, v145);
-            //v15 = v2->uSoundID;
-            if ( v2->uSoundID == (short)v9 )
+LABEL_35:
+            v15 = v2->uSoundID;
+            if ( v15 == (short)v9 )
               v16 = 0;
             else
-              v16 = (signed __int16)v2->uSoundID + 4;
-            v92 = v153;
+              v16 = (signed __int16)v15 + 4;
+            v133 = v9;
+            v131 = v9;
+            v130 = v16;
+            v92 = v14;
+LABEL_267:
             v124 = 8 * v92;
+            v129 = v9;
+            v128 = -1;
             LOBYTE(v124) = v124 | 2;
-            v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-            pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9);
-            return 0;
+            v127 = v9;
+            v126 = v124;
+LABEL_268:
+            v116 = word_4EE088_sound_ids[v2->spell_id - 1];
+LABEL_269:
+            v125 = v116 + 1;
+            goto LABEL_29;
           }
           v59 = v6 + 2;
           v60 = pObjectList->uNumObjects;
@@ -6975,17 +6866,10 @@
             while ( v141 );
           }
 LABEL_160:
-          SpriteObject::OnInteraction(v153);
-          if ( v2->uSoundID == (short)v9 )
-            v16 = 0;
-          else
-            v16 = (signed __int16)v2->uSoundID + 4;
-          v92 = v153;
-          v124 = 8 * v92;
-          LOBYTE(v124) = v124 | 2;
-          v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-          pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9);
-          return 0;
+          v14 = v153;
+LABEL_34:
+          SpriteObject::OnInteraction(v14);
+          goto LABEL_35;
         }
         if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) )
           return 1;
@@ -7018,6 +6902,7 @@
         v134 = 0;
         v72 = v153;
         v132 = 0;
+LABEL_132:
         v73 = v2->vPosition.z;
         v74 = v2->vPosition.y;
         v75 = PID(OBJECT_Item,v72);
@@ -7032,9 +6917,14 @@
           v78 = 0;
         else
           v78 = (signed __int16)v77 + 4;
-        v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-        pAudioPlayer->PlaySound((SoundID)v116, v75, v66, -1, v66, v78, v66, v66);
-        return 0;
+        v133 = v66;
+        v131 = v66;
+        v130 = v78;
+        v129 = v66;
+        v128 = -1;
+        v127 = v66;
+        v126 = v75;
+        goto LABEL_268;
       }
       if ( v7 == 4090 )
       {
@@ -7115,23 +7005,7 @@
         v134 = 0;
         v72 = v153;
         v132 = v2->field_61;
-        v73 = v2->vPosition.z;
-        v74 = v2->vPosition.y;
-        v75 = PID(OBJECT_Item,v72);
-        v2->vVelocity.z = v66;
-        v2->vVelocity.y = v66;
-        v76 = v2->vPosition.x;
-        v2->vVelocity.x = v66;
-        v2->uSpriteFrameID = v66;
-        stru_50FE08.Add(v75, 512, v76, v74, v73, v132, v134);
-        v77 = v2->uSoundID;
-        if ( v77 == (short)v66 )
-          v78 = 0;
-        else
-          v78 = (signed __int16)v77 + 4;
-        v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-        pAudioPlayer->PlaySound((SoundID)v116, v75, v66, -1, v66, v78, v66, v66);
-        return 0;
+        goto LABEL_132;
       }
       if ( v7 == 4100 || v7 == 6010 )
         goto LABEL_93;
@@ -7197,33 +7071,21 @@
           v9 = 0;
           v10 = 0;
           if ( (signed int)v8 <= 0 )
-          {
-            v12 = 0;
-            goto LABEL_24;
-          }
+            goto LABEL_23;
           v11 = (char *)&pObjectList->pObjects->uObjectID;
           break;
         case 545:
         case 550:
           if ( v2->stru_24.uItemID != 405 && v2->stru_24.uSpecEnchantmentType != 3 )
           {
+            v14 = v153;
             v9 = 0;
             v2->vVelocity.z = 0;
             v2->vVelocity.y = 0;
             v2->vVelocity.x = 0;
             v2->uSpriteFrameID = 0;
             sub_43A97E(v153, v145);
-            SpriteObject::OnInteraction(v153);
-            if ( v2->uSoundID == (short)v9 )
-              v16 = 0;
-            else
-              v16 = (signed __int16)v2->uSoundID + 4;
-            v92 = v153;
-            v124 = 8 * v92;
-            LOBYTE(v124) = v124 | 2;
-            v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-            pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v16, v9, v9);
-            return 0;
+            goto LABEL_34;
           }
           v17 = pObjectList->uNumObjects;
           v18 = 0;
@@ -7252,6 +7114,7 @@
         v11 += 56;
         if ( v10 >= (signed int)v8 )
         {
+LABEL_23:
           v12 = 0;
           goto LABEL_24;
         }
@@ -7267,12 +7130,7 @@
       v2->vVelocity.x = 0;
       v2->uSpriteFrameID = 0;
       if ( !v44 )
-      {
-        v13 = 8 * v153;
-        LOBYTE(v13) = PID(OBJECT_Item,v153);
-        pAudioPlayer->PlaySound((SoundID)8, v13, v9, -1, v9, v9, v9, v9);
-        return 0;
-      }
+        goto LABEL_27;
     }
     return 0;
   }
@@ -7307,49 +7165,13 @@
         ++v52;
         v53 += 56;
         if ( v52 >= (signed int)v51 )
-        {
-          v95 = 0;
-          v2->uObjectDescID = v95;
-          if ( v95 == (short)v9 )
-            SpriteObject::OnInteraction(v153);
-          v96 = v2->uSoundID;
-          v2->vVelocity.z = v9;
-          v2->vVelocity.y = v9;
-          v2->vVelocity.x = v9;
-          v2->uSpriteFrameID = v9;
-          if ( v96 == (short)v9 )
-            v97 = 0;
-          else
-            v97 = (signed __int16)v96 + 4;
-          v92 = v153;
-          v124 = 8 * v92;
-          LOBYTE(v124) = v124 | 2;
-          v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-          pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-          return 0;
-        }
+          goto LABEL_181;
       }
-      v95 = v52;
-      v2->uObjectDescID = v95;
-      if ( v95 == (short)v9 )
-        SpriteObject::OnInteraction(v153);
-      v96 = v2->uSoundID;
-      v2->vVelocity.z = v9;
-      v2->vVelocity.y = v9;
-      v2->vVelocity.x = v9;
-      v2->uSpriteFrameID = v9;
-      if ( v96 == (short)v9 )
-        v97 = 0;
-      else
-        v97 = (signed __int16)v96 + 4;
-      v92 = v153;
-      v124 = 8 * v92;
-      LOBYTE(v124) = v124 | 2;
-      v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-      pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-      return 0;
+      goto LABEL_202;
     }
+LABEL_181:
     v95 = 0;
+LABEL_182:
     v2->uObjectDescID = v95;
     if ( v95 == (short)v9 )
       SpriteObject::OnInteraction(v153);
@@ -7362,12 +7184,11 @@
       v97 = 0;
     else
       v97 = (signed __int16)v96 + 4;
+    v133 = v9;
+    v131 = v9;
+    v130 = v97;
     v92 = v153;
-    v124 = 8 * v92;
-    LOBYTE(v124) = v124 | 2;
-    v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-    pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-   return 0;
+    goto LABEL_267;
   }
   if ( v7 == 1100 )
     goto LABEL_93;
@@ -7410,10 +7231,16 @@
     v2->uSpriteFrameID = 0;
     v147 = v38;
     stru_50FE08.Add(v38, 512, v40, v39, v37, 0, 0);
-    if ( HIBYTE(v3->uFlags) & 1 )
-      array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, 0, v3->uParticleTrailColor);
-    pAudioPlayer->PlaySound((SoundID)8, v147, 0, -1, 0, 0, 0, 0);
-    return 0;
+    if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+      trail_particle_generator.GenerateTrailParticles(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v3->uParticleTrailColor);
+    v133 = 0;
+    v131 = 0;
+    v130 = 0;
+    v129 = 0;
+    v128 = -1;
+    v127 = 0;
+    v126 = v147;
+    goto LABEL_28;
   }
   v27 = v26 - 410;
   if ( !v27 )
@@ -7442,36 +7269,11 @@
           ++v146;
           v140 += 56;
           if ( v146 >= (signed int)v31 )
-          {
-            v46 = 0;
-            v2->uObjectDescID = v46;
-            if ( v46 == (short)v32 )
-              SpriteObject::OnInteraction(v153);
-            v100 = v2->field_61;
-            v101 = v2->vPosition.z;
-            v2->uSpriteFrameID = v32;
-            v102 = 8 * v153;
-            v103 = v2->vPosition.y;
-            LOBYTE(v102) = PID(OBJECT_Item,v153);
-            v2->vVelocity.x = v32;
-            v2->vVelocity.y = v32;
-            v104 = v2->vPosition.x;
-            v2->vVelocity.z = v32;
-            v149 = v102;
-            stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
-            if ( HIBYTE(v3->uFlags) & 1 )
-              array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
-            v105 = v2->uSoundID;
-            if ( v105 == (short)v32 )
-              v47 = 0;
-            else
-              v47 = (signed __int16)v105 + 4;
-            v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-            pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
-            return 0;
-          }
+            goto LABEL_195;
         }
+LABEL_80:
         v46 = v146;
+LABEL_196:
         v2->uObjectDescID = v46;
         if ( v46 == (short)v32 )
           SpriteObject::OnInteraction(v153);
@@ -7487,43 +7289,27 @@
         v2->vVelocity.z = v32;
         v149 = v102;
         stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
-        if ( HIBYTE(v3->uFlags) & 1 )
-          array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
+        if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+          trail_particle_generator.GenerateTrailParticles(
+            v2->vPosition.x,
+            v2->vPosition.y,
+            v2->vPosition.z,
+            v3->uParticleTrailColor);
         v105 = v2->uSoundID;
         if ( v105 == (short)v32 )
           v47 = 0;
         else
           v47 = (signed __int16)v105 + 4;
-        v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-        pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
-        return 0;
+        v133 = v32;
+        v131 = v32;
+        v130 = v47;
+        v129 = v32;
+        v128 = -1;
+        v127 = v32;
+        v126 = v149;
+        goto LABEL_268;
       }
-      v46 = 0;
-      v2->uObjectDescID = v46;
-      if ( v46 == (short)v32 )
-      SpriteObject::OnInteraction(v153);
-      v100 = v2->field_61;
-      v101 = v2->vPosition.z;
-      v2->uSpriteFrameID = v32;
-      v102 = 8 * v153;
-      v103 = v2->vPosition.y;
-      LOBYTE(v102) = PID(OBJECT_Item,v153);
-      v2->vVelocity.x = v32;
-      v2->vVelocity.y = v32;
-      v104 = v2->vPosition.x;
-      v2->vVelocity.z = v32;
-      v149 = v102;
-      stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
-      if ( HIBYTE(v3->uFlags) & 1 )
-        array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v32, v3->uParticleTrailColor);
-      v105 = v2->uSoundID;
-      if ( v105 == (short)v32 )
-        v47 = 0;
-      else
-        v47 = (signed __int16)v105 + 4;
-      v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-      pAudioPlayer->PlaySound((SoundID)v116, v149, v32, -1, v32, v47, v32, v32);
-      return 0;
+      goto LABEL_195;
     }
     return 1;
   }
@@ -7544,67 +7330,13 @@
         ++v52;
         v123 += 56;
         if ( v52 >= (signed int)v122 )
-        {
-          v95 = 0;
-          v2->uObjectDescID = v95;
-          if ( v95 == (short)v9 )
-            SpriteObject::OnInteraction(v153);
-          v96 = v2->uSoundID;
-          v2->vVelocity.z = v9;
-          v2->vVelocity.y = v9;
-          v2->vVelocity.x = v9;
-          v2->uSpriteFrameID = v9;
-          if ( v96 == (short)v9 )
-            v97 = 0;
-          else
-            v97 = (signed __int16)v96 + 4;
-          v92 = v153;
-          v124 = 8 * v92;
-          LOBYTE(v124) = v124 | 2;
-          v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-          pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-          return 0;
-        }
+          goto LABEL_181;
       }
+LABEL_202:
       v95 = v52;
-      v2->uObjectDescID = v95;
-      if ( v95 == (short)v9 )
-        SpriteObject::OnInteraction(v153);
-      v96 = v2->uSoundID;
-      v2->vVelocity.z = v9;
-      v2->vVelocity.y = v9;
-      v2->vVelocity.x = v9;
-      v2->uSpriteFrameID = v9;
-      if ( v96 == (short)v9 )
-        v97 = 0;
-      else
-        v97 = (signed __int16)v96 + 4;
-      v92 = v153;
-      v124 = 8 * v92;
-      LOBYTE(v124) = v124 | 2;
-      v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-      pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-      return 0;
+      goto LABEL_182;
     }
-    v95 = 0;
-    v2->uObjectDescID = v95;
-    if ( v95 == (short)v9 )
-      SpriteObject::OnInteraction(v153);
-    v96 = v2->uSoundID;
-    v2->vVelocity.z = v9;
-    v2->vVelocity.y = v9;
-    v2->vVelocity.x = v9;
-    v2->uSpriteFrameID = v9;
-    if ( v96 == (short)v9 )
-      v97 = 0;
-    else
-      v97 = (signed __int16)v96 + 4;
-    v92 = v153;
-    v124 = 8 * v92;
-    LOBYTE(v124) = v124 | 2;
-    v116 = word_4EE088_sound_ids[v2->spell_id] + 1;
-    pAudioPlayer->PlaySound((SoundID)v116, v124, v9, -1, v9, v97, v9, v9);
-   return 0;
+    goto LABEL_181;
   }
   v117 = v6 + 1;
   v118 = pObjectList->uNumObjects;
@@ -7636,8 +7368,19 @@
   v2->vVelocity.y = 0;
   v2->vVelocity.x = 0;
   v2->uSpriteFrameID = 0;
+LABEL_27:
+  v133 = v9;
+  v131 = v9;
+  v130 = v9;
   v13 = 8 * v153;
+  v129 = v9;
+  v128 = -1;
   LOBYTE(v13) = PID(OBJECT_Item,v153);
-  pAudioPlayer->PlaySound((SoundID)8, v13, v9, -1, v9, v9, v9, v9);
+  v127 = v9;
+  v126 = v13;
+LABEL_28:
+  v125 = 8;
+LABEL_29:
+  pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
   return 0;
 }