Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
authorWuzzy <Wuzzy2@mail.ru>
Wed, 28 Nov 2018 01:44:43 +0100
changeset 14330 bd2bbd607f5e
parent 14329 5da99c43b96f
child 14331 ddcc5dd7a805
Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua	Wed Nov 28 00:49:46 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua	Wed Nov 28 01:44:43 2018 +0100
@@ -313,23 +313,34 @@
         end
     end
 
-    if TurnTimeLeft==0 and mt_hurt then
+    if (TurnTimeLeft==0 or band(GetState(mutant), gstHHDriven) == 0) and mt_hurt then
         mt_hurt = false
     end
 
-    if mt_hurt and mutant~=nil then
+    -- Mutant's disease
+    -- Hurt Mutant during its turn time
+    -- Mutant's health is safe in ready phase
+    if mt_hurt and mutant~=nil and ReadyTimeLeft == 0 then
         timer = timer + 1
-            if timer > disease_timer then
-                timer = 0
-                SetHealth(mutant, GetHealth(mutant)-disease )
-                AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true)
-                    if GetHealth(mutant)<=0 then
-                        SetHealth(mutant,0)
-                        mt_hurt= false
-                        setGearValue(mutant,"SelfDestruct",true)
-                        EndTurn()
-                    end
+        if timer > disease_timer then
+            timer = 0
+            local h = GetHealth(mutant)-disease
+            SetHealth(mutant, h)
+            -- Low health warning
+            if h <= 75 then
+                PlaySound(sndPoisonMoan, mutant)
+            elseif h <= 150 then
+                PlaySound(sndPoisonCough, mutant)
             end
+            local tag = AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true)
+            SetVisualGearValues(tag, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(mutant)))
+            if GetHealth(mutant)<=0 then
+                SetHealth(mutant,0)
+                mt_hurt= false
+                setGearValue(mutant,"SelfDestruct",true)
+                EndTurn()
+            end
+        end
     end
 
 end