# HG changeset patch # User Wuzzy # Date 1548105449 -3600 # Node ID 8bd005067f4ac33813f9a69bc67ec80f86fe094f # Parent 4aec7d17ef7d14dddaaa191ab03e3996aee2dd32 Play "Flawless" voice when winning target practice mission with perfect accuracy diff -r 4aec7d17ef7d -r 8bd005067f4a share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua --- a/share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua Mon Jan 21 21:06:55 2019 +0100 +++ b/share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua Mon Jan 21 22:17:29 2019 +0100 @@ -300,6 +300,9 @@ elseif score == 9 then spawnTarget(2930,1500) elseif score == 10 then + -- The "tricky" target. + -- It spawns behind a wall + -- and needs at least 2 shots. AddCaption(loc("This one's tricky.")); spawnTarget(700,720) elseif score == 11 then @@ -383,8 +386,16 @@ SaveMissionVar("Won", "true") AddCaption(loc("Victory!"), capcolDefault, capgrpGameState) ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0) - -- Also let the hogs shout "victory!" - PlaySound(sndVictory, CurrentHedgehog) + -- Play voice + if shots-1 <= score then + -- Flawless victory condition: Only 1 shot more than targets + -- (1 shot per "normal" target + 2 shots for the "tricky" target) + PlaySound(sndFlawless, CurrentHedgehog) + else + -- "Normal" victory + PlaySound(sndVictory, CurrentHedgehog) + end + FollowGear(CurrentHedgehog) -- Unselect sniper rifle and disable hog controls @@ -408,6 +419,7 @@ local accuracy local accuracy_int if shots > 0 then + -- NOTE: 100% accuracy is not possible due to the "tricky" target. accuracy = (score/shots)*100 accuracy_int = div(score*100, shots) end diff -r 4aec7d17ef7d -r 8bd005067f4a share/hedgewars/Data/Scripts/TargetPractice.lua --- a/share/hedgewars/Data/Scripts/TargetPractice.lua Mon Jan 21 21:06:55 2019 +0100 +++ b/share/hedgewars/Data/Scripts/TargetPractice.lua Mon Jan 21 22:17:29 2019 +0100 @@ -265,7 +265,12 @@ SaveMissionVar("Won", "true") AddCaption(loc("You have destroyed all targets!"), capcolDefault, capgrpGameState) ShowMission(params.missionTitle, loc("Aiming practice"), loc("Congratulations! You have destroyed all targets within the time."), 0, 0) - PlaySound(sndVictory, player) + if shots <= scored then + -- No misses! + PlaySound(sndFlawless, player) + else + PlaySound(sndVictory, player) + end SetEffect(player, heInvulnerable, 1) SetState(player, bor(GetState(player), gstWinner)) time_goal = TurnTimeLeft