Add air plane underwater sound and add water splashes
authorWuzzy <Wuzzy2@mail.ru>
Thu, 11 Jul 2019 06:24:03 +0200
changeset 15235 4576e41c0692
parent 15234 b96868956514
child 15236 c10e9261ab9c
Add air plane underwater sound and add water splashes
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
hedgewars/uSound.pas
hedgewars/uTypes.pas
share/hedgewars/Data/Sounds/planewater.ogg
--- a/ChangeLog.txt	Thu Jul 11 05:44:43 2019 +0200
+++ b/ChangeLog.txt	Thu Jul 11 06:24:03 2019 +0200
@@ -109,6 +109,7 @@
  + Animate drill rockets
  + New idle shoryuken animation
  + Scatter molotov cocktail pieces
+ + Add water effects for air plane
  * Fix speech bubbles overlapping in the wrong order
  * Fix wrong ice beam angle if it goes diagonally up out of map through world wrap
  * Fix double water splash when flying saucer drowns
@@ -165,6 +166,7 @@
  + sndYoohoo has been split to sndYoohoo and sndKiss
  + Voice files sndPoisonCough and sndPoisonMoan are now optional (fall back to Default voicepack)
  + Add taunt: sndFlyAway / Flyaway.ogg: When hedgehog flies off the map
+ + Add underwater sound for airplane
  + Tweak some taunts: sndFirstBlood, sndLeaveMeAlone, sndCutItOut
  * Fix English voicepack selection of team being overwritten when playing in non-English locale
 
--- a/hedgewars/uGearsHandlersMess.pas	Thu Jul 11 05:44:43 2019 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Jul 11 06:24:03 2019 +0200
@@ -3079,6 +3079,8 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepAirAttackWork(Gear: PGear);
+var uw, nuw: boolean;
+    tmpFloat: hwFloat;
 begin
     AllInactive := false;
     Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag;
@@ -3095,7 +3097,7 @@
         Gear^.dX := Gear^.dX + int2hwFloat(Gear^.Damage * Gear^.Tag);
         if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
             FollowGear^.State:= FollowGear^.State or gstSubmersible;
-        if (Gear^.SoundChannel <> -1) then
+        if (Gear^.SoundChannel <> -1) and (WorldEdge <> weSea) then
             begin
             StopSoundChan(Gear^.SoundChannel, 4000);
             Gear^.SoundChannel := -1;
@@ -3118,8 +3120,35 @@
             StopSoundChan(Gear^.SoundChannel);
             Gear^.SoundChannel := -1;
             end;
-        DeleteGear(Gear)
-        end
+        DeleteGear(Gear);
+        exit;
+        end;
+
+    uw := (Gear^.Karma <> 0); // Was plane underwater last tick?
+    nuw := CheckCoordInWater(hwRound(Gear^.X) + Gear^.Radius * Gear^.Tag, hwRound(Gear^.Y)); // Is plane underwater now?
+
+    // if water entered or left
+    if nuw <> uw then
+        begin
+        tmpFloat:= Gear^.dX;
+        Gear^.dX := cAirPlaneSpeed * Gear^.Tag;
+        AddSplashForGear(Gear, false);
+        Gear^.dX := tmpFloat;
+        StopSoundChan(Gear^.SoundChannel);
+        if nuw then
+            begin
+            Gear^.SoundChannel := LoopSound(sndPlaneWater);
+            StopSoundChan(Gear^.SoundChannel, 4000);
+            Gear^.SoundChannel := -1;
+            Gear^.Karma := 1;
+            end
+        else
+            begin
+            Gear^.SoundChannel := LoopSound(sndPlane);
+            Gear^.Karma := 0;
+            end;
+        end;
+
 end;
 
 procedure doStepAirAttack(Gear: PGear);
@@ -3158,7 +3187,17 @@
                 cGravity) * Gear^.Tag;
 
     Gear^.doStep := @doStepAirAttackWork;
-    Gear^.SoundChannel := LoopSound(sndPlane, 4000);
+
+    if (WorldEdge = weSea) then
+        begin
+        Gear^.SoundChannel := LoopSound(sndPlaneWater, 4000);
+        Gear^.Karma := 1;
+        end
+    else
+        begin
+        Gear^.SoundChannel := LoopSound(sndPlane, 4000);
+        Gear^.Karma := 0;
+        end;
 
 end;
 
@@ -3473,6 +3512,7 @@
         exit
         end;
 
+    // particles
     if (GameTicks and $3F) = 0 then
         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
 end;
--- a/hedgewars/uGearsList.pas	Thu Jul 11 05:44:43 2019 +0200
+++ b/hedgewars/uGearsList.pas	Thu Jul 11 06:24:03 2019 +0200
@@ -607,6 +607,9 @@
                 gear^.Health:= 6;
                 gear^.Damage:= 30;
                 gear^.Z:= cHHZ+2;
+                gear^.Karma:= 0; // for sound effect: 0 = normal, 1 = underwater
+                gear^.Radius:= 150;
+                gear^.Density:= _19;
                 gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF
                 end;
      gtAirBomb: begin
--- a/hedgewars/uSound.pas	Thu Jul 11 05:44:43 2019 +0200
+++ b/hedgewars/uSound.pas	Thu Jul 11 06:24:03 2019 +0200
@@ -331,7 +331,8 @@
             (FileName:                 'Ouch.ogg'; Path: ptVoices; AltPath: ptNone),// sndOuch
             (FileName:                  'Hmm.ogg'; Path: ptVoices; AltPath: ptNone),// sndHmm
             (FileName:                 'Kiss.ogg'; Path: ptSounds; AltPath: ptNone),// sndKiss
-            (FileName:              'Flyaway.ogg'; Path: ptVoices; AltPath: ptNone) // sndFlyAway
+            (FileName:              'Flyaway.ogg'; Path: ptVoices; AltPath: ptNone),// sndFlyAway
+            (FileName:           'planewater.ogg'; Path: ptSounds; AltPath: ptNone) // sndPlaneWater
             );
 
 
--- a/hedgewars/uTypes.pas	Thu Jul 11 05:44:43 2019 +0200
+++ b/hedgewars/uTypes.pas	Thu Jul 11 06:24:03 2019 +0200
@@ -158,7 +158,7 @@
             sndLandGun, sndCaseImpact, sndExtraDamage, sndFirePunchHit, sndGrenade, sndThisOneIsMine,
             sndWhatThe, sndSoLong, sndOhDear, sndGonnaGetYou, sndDrat, sndBugger, sndAmazing,
             sndBrilliant, sndExcellent, sndFire, sndWatchThis, sndRunAway, sndRevenge, sndCutItOut,
-            sndLeaveMeAlone, sndOuch, sndHmm, sndKiss, sndFlyAway);
+            sndLeaveMeAlone, sndOuch, sndHmm, sndKiss, sndFlyAway, sndPlaneWater);
 
     // Available ammo types to be used by hedgehogs
     TAmmoType  = (amNothing, amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, amPickHammer, // 6
Binary file share/hedgewars/Data/Sounds/planewater.ogg has changed