Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
authorWuzzy <Wuzzy2@mail.ru>
Sun, 02 Sep 2018 01:25:37 +0200
changeset 13739 bbea77a8dff9
parent 13738 2ac3658a2a13
child 13740 94bf5f976e3e
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme) Fixes 210.
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
--- a/ChangeLog.txt	Sun Sep 02 00:07:33 2018 +0200
+++ b/ChangeLog.txt	Sun Sep 02 01:25:37 2018 +0200
@@ -32,6 +32,7 @@
  * Limit hedgehog health to 268435455 to prevent some bugs
  * Fix Sudden Death starting in the second turn of a round rather than the first
  * Prevent voices from being spoken directly before a victory voice
+ * Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
 
 Frontend:
  + Add setting to disable audio dampening when losing window focus
--- a/hedgewars/uGearsHandlersMess.pas	Sun Sep 02 00:07:33 2018 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Sep 02 01:25:37 2018 +0200
@@ -307,9 +307,28 @@
         AddVisualGear(bubbleX, bubbleY, vgtBubble)
 else if Random(12) = 0 then
         AddVisualGear(bubbleX, bubbleY, vgtBubble);
+// Insta-delete gear and skip drowning animation if water is 100% opaque
 if (not SuddenDeathDmg and (WaterOpacity > $FE))
-or (SuddenDeathDmg and (SDWaterOpacity > $FE))
-or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then
+or (SuddenDeathDmg and (SDWaterOpacity > $FE)) then
+    begin
+    // Teleport gear to a suitable position for the damage tag in the water
+    if (WorldEdge = weSea) and (hwRound(Gear^.X) - Gear^.Radius < leftX) then
+        begin
+        if (hwRound(Gear^.X) - Gear^.Radius > leftX - 90) then
+            Gear^.X := Gear^.X - _90
+        end
+    else if (WorldEdge = weSea) and (hwRound(Gear^.X) + Gear^.Radius > rightX) then
+        begin
+        if (hwRound(Gear^.X) - Gear^.Radius < rightX + 90) then
+            Gear^.X := Gear^.X + _90
+        end
+    else
+        Gear^.Y := int2hwFloat(Gear^.Radius + cWaterLine + cVisibleWater);
+    DeleteGear(Gear);
+    exit;
+    end;
+// Delete normally if gear is outside of visible range
+if (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then
     DeleteGear(Gear);
 end;
 
--- a/hedgewars/uGearsList.pas	Sun Sep 02 00:07:33 2018 +0200
+++ b/hedgewars/uGearsList.pas	Sun Sep 02 01:25:37 2018 +0200
@@ -868,8 +868,8 @@
             begin
             t:= max(Gear^.Damage, Gear^.Health);
             Gear^.Damage:= t;
-            if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then
-                spawnHealthTagForHH(Gear, t);
+            // Display hedgehog damage in water
+            spawnHealthTagForHH(Gear, t);
             end;
 
         team:= Gear^.Hedgehog^.Team;