Clean up Sudden Death messages and animations in Battalion
authorWuzzy <Wuzzy2@mail.ru>
Mon, 08 Apr 2019 15:27:40 +0200
changeset 14788 458a8c4e65ca
parent 14787 cbdfc5b1d5b8
child 14789 185f07ec4d12
Clean up Sudden Death messages and animations in Battalion - Remove SD warning (redundant with engine) - Play poison moan sounds - Hide damage tag if no damage
share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua	Mon Apr 08 14:55:52 2019 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua	Mon Apr 08 15:27:40 2019 +0200
@@ -944,6 +944,9 @@
 ]]--
 
 function onSuddenDeathDamage(hog)
+  if GetEffect(hog, heInvulnerable) ~= 0 then
+    return
+  end
   local hp = GetHealth(hog)
   local maxHp = getHogInfo(hog, 'maxHp')
   local newHp = 0
@@ -975,8 +978,16 @@
     hpDec = hp - newHp
 
     SetHealth(hog, newHp)
-    local effect = AddVisualGear(GetX(hog), GetY(hog) +cratePickupGap, vgtHealthTag, hpDec, false)
-    SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, msgColor)
+    if hpDec > 0 then
+      local r = math.random(1, 2)
+      if r == 1 then
+         PlaySound(sndPoisonCough, hog, true)
+      else
+         PlaySound(sndPoisonMoan, hog, true)
+      end
+      local effect = AddVisualGear(GetX(hog), GetY(hog) +cratePickupGap, vgtHealthTag, hpDec, false)
+      SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, msgColor)
+    end
   end
 end
 
@@ -1444,12 +1455,6 @@
 
   if suddenDeath == true then
     onSuddenDeathTurn()
-  else
-    local RoundsTillSD = (SuddenDeathTurns+2) - (TotalRounds+1)
-    -- Show SD reminder every couple of turns, and in the first turn
-    if (not firstTurnOver) or (RoundsTillSD <= 6) or (RoundsTillSD <= 25 and RoundsTillSD % 5 == 0) or (RoundsTillSD % 10 == 0) then
-        AddCaption(string.format(loc("Rounds until Sudden Death: %d"), RoundsTillSD), capcolDefault, capgrpGameState)
-    end
   end
 
   -- Generate new weapons for last hog if it's still alive