event for game win spacecampaign
authorPeriklis Ntanasis <pntanasis@gmail.com>
Tue, 30 Jul 2013 13:52:53 +0300
branchspacecampaign
changeset 9394 ccc2a2099370
parent 9392 0dd0adee6831
child 9396 fb56c2225f25
event for game win
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Tue Jul 30 13:19:15 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Tue Jul 30 13:52:53 2013 +0300
@@ -6,12 +6,9 @@
 -- able to use only the ice gun for this mission.
 
 -- TODO
--- maybe use rope challenge to go there
--- add checkpoints
+-- TEST TEST AND MORE TEST
+-- increase health in checkpoint 3
 -- fix the stats
--- manually set the frozen hogs to last frozen for fixed number of turns
--- SetState(bandit1.gear,bor(GetState(bandit1.gear),gstFrozen))
--- SetEffect(bandit1.gear,heFrozen,9999999)
 
 HedgewarsScriptLoad("/Scripts/Locale.lua")
 HedgewarsScriptLoad("/Scripts/Animate.lua")
@@ -191,6 +188,7 @@
 	AddEvent(onAntiFlyArea, {hero.gear}, antiFlyArea, {hero.gear}, 1)
 	AddEvent(onNonAntiFlyArea, {hero.gear}, nonAntiFlyArea, {hero.gear}, 1)
 	AddEvent(onThantaDeath, {bandit1.gear}, thantaDeath, {bandit1.gear}, 1)
+	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 1)
 	
 	AddAmmo(hero.gear, amJetpack, 99)
 	AddAmmo(bandit1.gear, amBazooka, 5)
@@ -370,6 +368,14 @@
 	return false
 end
 
+function onHeroWin(gear)
+	if (not hero.dead and not bandit1.dead) and (GetX(hero.gear)>=GetX(bandit1.gear)-15 and GetX(hero.gear)<=GetX(bandit1.gear)+15)
+		and (GetY(hero.gear)>=GetY(bandit1.gear)-15 and GetY(hero.gear)<=GetY(bandit1.gear)+15) then
+		return true
+	end
+	return false
+end
+
 -------------- OUTCOMES ------------------
 
 function antiFlyArea(gear)
@@ -421,6 +427,12 @@
 	EndGame()
 end
 
+function heroWin(gear)
+	SendStat('siGameResult', loc("Congratulations, you got the part!"))
+	-- more custom stats
+	EndGame()
+end
+
 -------------- ANIMATIONS ------------------
 
 function Skipanim(anim)