DEADSOFTWARE

Game: Fix missing sound from the bubble effect in liquids
authorDmitry D. Chernov <blackdoomer@yandex.ru>
Mon, 10 Apr 2023 01:09:38 +0000 (11:09 +1000)
committerDmitry D. Chernov <blackdoomer@yandex.ru>
Mon, 10 Apr 2023 01:09:38 +0000 (11:09 +1000)
src/game/g_monsters.pas
src/game/g_player.pas
src/game/g_triggers.pas
src/game/g_weapons.pas

index 3d9e43d2a279aebff18278c46f3db96cf3a3a373..d8adad853402974c802ba9bfbd3f58761809835e 100644 (file)
@@ -2468,7 +2468,7 @@ var
   a, b, sx, sy, wx, wy, oldvelx: Integer;
   st: Word;
   o, co: TObj;
-  fall: Boolean;
+  fall, bubbles: Boolean;
   mon: TMonster;
   mit: PMonster;
   it: TMonsterGrid.Iter;
@@ -2476,6 +2476,7 @@ label
   _end;
 begin
   fall := True;
+  bubbles := True;
 
 // Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup
   if (gLMSRespawn > LMS_RESPAWN_NONE) then exit;
@@ -2574,23 +2575,23 @@ begin
 
 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
   if WordBool(st and MOVE_INWATER) and (Random(32) = 0) then
+  begin
     case FMonsterType of
       MONSTER_FISH:
-        if Random(4) = 0 then
+        if Random(4) <> 0 then bubbles := False else
           g_GFX_Bubbles(FObj.X+FObj.Rect.X + Random(FObj.Rect.Width),
                         FObj.Y+FObj.Rect.Y + Random(4), 1, 0, 0);
       MONSTER_ROBO, MONSTER_BARREL:
         g_GFX_Bubbles(FObj.X+FObj.Rect.X + Random(FObj.Rect.Width),
                       FObj.Y+FObj.Rect.Y + Random(4), 1, 0, 0);
-      else begin
+      else
         g_GFX_Bubbles(FObj.X+FObj.Rect.X + Random(FObj.Rect.Width-4),
                       FObj.Y+FObj.Rect.Y + Random(4), 5, 4, 4);
-        if Random(2) = 0 then
-          g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
-        else
-          g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
-      end;
     end;
+    if bubbles then if Random(2) = 0
+      then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
+      else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
+  end;
 
 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
   if FMonsterType = MONSTER_BARREL then
@@ -3462,13 +3463,14 @@ var
   a, b, sx, sy, oldvelx: Integer;
   st: Word;
   o, co: TObj;
-  fall: Boolean;
+  fall, bubbles: Boolean;
 label
   _end;
 begin
   sx := 0; // SHUT UP COMPILER
   sy := 0;
   fall := True;
+  bubbles := True;
 
 // Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup
   if (gLMSRespawn > LMS_RESPAWN_NONE) then exit;
@@ -3535,23 +3537,23 @@ begin
 
 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
   if WordBool(st and MOVE_INWATER) and (Random(32) = 0) then
+  begin
     case FMonsterType of
       MONSTER_FISH:
-        if Random(4) = 0 then
+        if Random(4) <> 0 then bubbles := False else
           g_GFX_Bubbles(FObj.X+FObj.Rect.X + Random(FObj.Rect.Width),
                         FObj.Y+FObj.Rect.Y + Random(4), 1, 0, 0);
       MONSTER_ROBO, MONSTER_BARREL:
         g_GFX_Bubbles(FObj.X+FObj.Rect.X + Random(FObj.Rect.Width),
                       FObj.Y+FObj.Rect.Y + Random(4), 1, 0, 0);
-      else begin
+      else
         g_GFX_Bubbles(FObj.X+FObj.Rect.X + Random(FObj.Rect.Width-4),
                       FObj.Y+FObj.Rect.Y + Random(4), 5, 4, 4);
-        if Random(2) = 0 then
-          g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
-        else
-          g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
-      end;
     end;
+    if bubbles then if Random(2) = 0
+      then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
+      else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
+  end;
 
 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
   if FMonsterType = MONSTER_BARREL then
index 38bb86a299228cfdd06c61bf01973c1aad915da4..1021d36f9646582ff5ae7bd918314e853b7a1a1a 100644 (file)
@@ -2299,8 +2299,13 @@ begin
         end;
 
       if t = HIT_WATER then
+      begin
         g_GFX_Bubbles(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
                       FObj.Y+PLAYER_RECT.Y-4, value div 2, 8, 4);
+        if Random(2) = 0
+          then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
+          else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
+      end;
     end;
 
   // Áóôåð óðîíà:
@@ -5373,10 +5378,9 @@ begin
       else if (FAir mod 31 = 0) and not blockmon then
       begin
         g_GFX_Bubbles(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2), FObj.Y+PLAYER_RECT.Y-4, 5+Random(6), 8, 4);
-        if Random(2) = 0 then
-          g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
-        else
-          g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
+        if Random(2) = 0
+          then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
+          else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
       end;
     end else if FAir < AIR_DEF then
       FAir := AIR_DEF;
@@ -6477,10 +6481,9 @@ begin
   begin
     g_GFX_Bubbles(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)+Random(3)-1,
                   Obj.Y+Obj.Rect.Height+8, 1, 8, 4);
-    if Random(2) = 0 then
-      g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
-    else
-      g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
+    if Random(2) = 0
+      then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
+      else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
     Exit;
   end;
 
index 9afef5d07f739b05a05d2c2791d62d9f94c34414..e9fa513f7c6243b3bfac35dfee694d45266a30ad 100644 (file)
@@ -884,7 +884,13 @@ begin
       TRIGGER_EFFECT_DLIQUID: g_GFX_SimpleWater(X, Y, 1, VX, VY, 5, CR, CG, CB);
       TRIGGER_EFFECT_BLOOD: g_GFX_Blood(X, Y, 1, VX, VY, 0, 0, CR, CG, CB);
       TRIGGER_EFFECT_SPARK: g_GFX_Spark(X, Y, 1, GetAngle2(VX, VY), 0, 0);
-      TRIGGER_EFFECT_BUBBLE: g_GFX_Bubbles(X, Y, 1, 0, 0);
+      TRIGGER_EFFECT_BUBBLE:
+      begin
+        g_GFX_Bubbles(X, Y, 1, 0, 0);
+        if not Silent then if Random(2) = 0
+          then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', X, Y)
+          else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', X, Y);
+      end;
     end;
   end;
 
index 6e65496ee606b7b1a207c95905ee72042be409f2..f0fe29114071a4c6b9f5ce2f9b64ec678d387e77 100644 (file)
@@ -2277,19 +2277,20 @@ begin
 
           // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
             if WordBool(st and MOVE_INWATER) then
-              g_GFX_Bubbles(Obj.X+(Obj.Rect.Width div 2),
-                            Obj.Y+(Obj.Rect.Height div 2),
-                            1+Random(3), 16, 16)
-            else
-              if g_Frames_Get(_id, 'FRAMES_SMOKE') then
-              begin
-                Anim := TAnimation.Create(_id, False, 3);
-                Anim.Alpha := 150;
-                g_GFX_OnceAnim(Obj.X-14+Random(9),
-                               Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
-                               Anim, ONCEANIM_SMOKE);
-                Anim.Free();
-              end;
+            begin
+              g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
+              if Random(2) = 0
+                then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', cx, cy)
+                else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', cx, cy);
+            end
+            else if g_Frames_Get(_id, 'FRAMES_SMOKE') then
+            begin
+              Anim := TAnimation.Create(_id, False, 3);
+              Anim.Alpha := 150;
+              g_GFX_OnceAnim(Obj.X-14+Random(9), cy-20+Random(9),
+                             Anim, ONCEANIM_SMOKE);
+              Anim.Free();
+            end;
 
           // Ïîïàëè â êîãî-òî èëè â ñòåíó:
             if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
@@ -2412,7 +2413,12 @@ begin
                 end;
               end
               else
+              begin
                 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
+                if Random(2) = 0
+                  then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', cx, cy)
+                  else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', cx, cy);
+              end;
               ShotType := 0;
               Continue;
             end;