ASA death02: Don't set hero health if enemy hurts itself
authorWuzzy <Wuzzy2@mail.ru>
Fri, 01 Nov 2019 23:35:01 +0100
changeset 15505 5eda4d7056bc
parent 15504 e3bf91fbd3f8
child 15506 5a30396f8fb2
ASA death02: Don't set hero health if enemy hurts itself
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Fri Nov 01 12:42:31 2019 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Fri Nov 01 23:35:01 2019 +0100
@@ -123,12 +123,14 @@
 
 function onGearDelete(gear)
 	if isHog(gear) then
-		-- Set health to 100 (with heal effect, if health was smaller)
-		local healthDiff = 100 - GetHealth(hero.gear)
-		if healthDiff > 1 then
-			HealHog(hero.gear, healthDiff, true, 0x00FF00FF)
-		else
-			SetHealth(hero.gear, 100)
+		if CurrentHedgehog == hero.gear then
+			-- Set health to 100 (with heal effect, if health was smaller)
+			local healthDiff = 100 - GetHealth(hero.gear)
+			if healthDiff > 1 then
+				HealHog(hero.gear, healthDiff, true, 0x00FF00FF)
+			else
+				SetHealth(hero.gear, 100)
+			end
 		end
 		local deadHog = getHog(gear)
 		if deadHog.weapon == amMortar then
@@ -155,7 +157,7 @@
 end
 
 function onGearDamage(gear, damage)
-	if isHog(gear) and GetHealth(hero.gear) then
+	if isHog(gear) and GetHealth(hero.gear) and CurrentHedgehog == hero.gear then
 		local bonusHealth = div(damage, 3)
 		HealHog(hero.gear, bonusHealth, true, 0xFF0000FF)
 	end