fixed moving npc and flying in forbidden area in ice01
authorPeriklis Ntanasis <pntanasis@gmail.com>
Mon, 02 Dec 2013 04:35:02 +0200
changeset 9734 da2cb993fd61
parent 9733 37f84780eb14
child 9735 6312152d92ad
fixed moving npc and flying in forbidden area in ice01
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Mon Dec 02 03:07:28 2013 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Mon Dec 02 04:35:02 2013 +0200
@@ -193,6 +193,7 @@
 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
 	AddEvent(onHeroFinalStep, {hero.gear}, heroFinalStep, {hero.gear}, 0)
 	AddEvent(onAntiFlyArea, {hero.gear}, antiFlyArea, {hero.gear}, 1)
+	AddEvent(onAntiFlyAreaVelocity, {hero.gear}, antiFlyAreaVelocity, {hero.gear}, 1)
 	AddEvent(onNonAntiFlyArea, {hero.gear}, nonAntiFlyArea, {hero.gear}, 1)
 	AddEvent(onThantaDeath, {bandit1.gear}, thantaDeath, {bandit1.gear}, 0)
 	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
@@ -341,6 +342,13 @@
 	return false
 end
 
+function onAntiFlyAreaVelocity(gear)
+	if not hero.dead and GetY(gear) < 1300 then
+		return true
+	end
+	return false
+end
+
 function onNonAntiFlyArea(gear)
 	if not hero.dead and (GetX(gear) < 860 and GetY(gear) > 1400) and heroAtAntiFlyArea then
 		return true
@@ -395,17 +403,19 @@
 
 function antiFlyArea(gear)
 	heroAtAntiFlyArea = true
-	if TurnTimeLeft < -1 then
-		heroVisitedAntiFlyArea = true
-		TurnTimeLeft = 0	
+	if not heroVisitedAntiFlyArea then
+		TurnTimeLeft = 0        
 		FollowGear(hero.gear)
-		AddAmmo(hero.gear, amJetpack, 0)
-		AnimSwitchHog(bandit1.gear)	
+		AnimSwitchHog(bandit1.gear)     
 		FollowGear(hero.gear)
 		TurnTimeLeft = 0
-	else
-		AddAmmo(hero.gear, amJetpack, 0)	
-	end
+	end	
+	AddAmmo(hero.gear, amJetpack, 0)
+	heroVisitedAntiFlyArea = true
+end
+
+function antiFlyAreaVelocity(gear)
+	SetGearVelocity(hero.gear, 0, 0)
 end
 
 function nonAntiFlyArea(gear)
@@ -468,6 +478,8 @@
     end
     if anim == dialog02 then
 		actionsOnWin()
+	else
+		AnimSwitchHog(hero.gear)
 	end
 end