Properly play Valkyries music in Rope Knock Challenge (no more music overlap)
authorWuzzy <Wuzzy2@mail.ru>
Fri, 26 Oct 2018 04:30:47 +0200
changeset 13977 e340ce5500d7
parent 13976 2828ec67c47c
child 13978 3ae88a9f9dca
Properly play Valkyries music in Rope Knock Challenge (no more music overlap)
share/hedgewars/Data/Missions/Challenge/User_Mission_-_Rope_Knock_Challenge.lua
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_Rope_Knock_Challenge.lua	Fri Oct 26 04:07:35 2018 +0200
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_Rope_Knock_Challenge.lua	Fri Oct 26 04:30:47 2018 +0200
@@ -6,6 +6,7 @@
 local hogsKilled = 0
 local finishTime
 local ouchies = false
+local valkyriesTimer = -1
 
 local HogData =	{
 					{"amn",			"NinjaFull",false},
@@ -85,6 +86,8 @@
 end
 
 function GameOverMan()
+	StopMusicSound(sndRideOfTheValkyries)
+	valkyriesTimer = -1
 	missionWon = false
 	ProtectEnemies()
 	ShowMission(loc("Rope-knocking Challenge"), loc("Challenge over!"), loc("Oh no! Just try again!"), -amSkip, 0)
@@ -242,10 +245,21 @@
 
 end
 
+function onGameTick20()
+	if (valkyriesTimer > 0) then
+		valkyriesTimer = valkyriesTimer - 20
+		if valkyriesTimer <= 0 then
+			StopMusicSound(sndRideOfTheValkyries)
+		end
+	end
+end
+
 function onGearDamage(gear, damage)
 
 	if gear == hhs[0] then
 		ouchies = true
+		StopMusicSound(sndRideOfTheValkyries)
+		valkyriesTimer = -1
 		ProtectEnemies()
 	end
 
@@ -260,7 +274,9 @@
 		SetTeamLabel(playerTeamName, tostring(GetKillScore()))
 
 		if hogsKilled == 15 then
-			PlaySound(sndRideOfTheValkyries)
+			PlayMusicSound(sndRideOfTheValkyries)
+			-- Time in ms after which to return to normal music
+			valkyriesTimer = 20000
 		elseif hogsKilled == 16 then
 			finishTime = TurnTimeLeft
 			GG()