win event spacecampaign
authorPeriklis Ntanasis <pntanasis@gmail.com>
Thu, 22 Aug 2013 19:57:07 +0300
branchspacecampaign
changeset 9562 241ffe433c3d
parent 9560 5872edd6864e
child 9564 114c79f10dcc
win event
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua	Thu Aug 22 03:21:30 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua	Thu Aug 22 19:57:07 2013 +0300
@@ -123,6 +123,9 @@
 	AnimWait(hero.gear, 3000)
 	FollowGear(hero.gear)
 	
+	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
+	AddEvent(onEnemiesDeath, {hero.gear}, enemiesDeath, {hero.gear}, 0)
+	
 	-- add crates
 	SpawnAmmoCrate(portalCrate.x, portalCrate.y, amPortalGun)
 	SpawnAmmoCrate(cakeCrate.x, cakeCrate.y, amCake)
@@ -201,6 +204,21 @@
 	return false
 end
 
+function onEnemiesDeath(gear)
+	local allDead = true
+	if professor.dead then
+		for i=1,table.getn(thugs) do
+			if GetHealth(thugs[i]) then
+				allDead = false
+				break
+			end
+		end
+	else
+		allDead = false
+	end
+	return allDead
+end
+
 -------------- ACTIONS ------------------
 
 function heroDeath(gear)
@@ -211,6 +229,16 @@
 	EndGame()
 end
 
+function enemiesDeath(gear)
+	SendStat('siGameResult', loc("Congratulations, you won!")) --1
+	SendStat('siCustomAchievement', loc("You have successfuly eliminated Professor Hogevil")) --11
+	SendStat('siCustomAchievement', loc("You have rescued H and Dr. Cornelius")) --11
+	SendStat('siCustomAchievement', loc("You have acquired the device")) --11
+	SendStat('siPlayerKills','1',teamA.name)
+	SendStat('siPlayerKills','0',teamC.name)
+	EndGame()
+end
+
 -------------- ANIMATIONS ------------------
 
 function Skipanim(anim)
@@ -221,4 +249,5 @@
 
 function AnimationSetup()
 	-- TODO ADD DIALOGS
+	
 end