ACF1: Force player to press jump to confirm difficulty dialog
authorWuzzy <almikes@aol.com>
Sat, 30 Sep 2017 01:45:01 +0200
changeset 12609 a45f8eec6869
parent 12608 1d33d66e40a7
child 12610 d05a159e7874
ACF1: Force player to press jump to confirm difficulty dialog To prevent the player from accidentally making a choice too early
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua	Sat Sep 30 00:59:12 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua	Sat Sep 30 01:45:01 2017 +0200
@@ -40,7 +40,7 @@
 targetsDestroyed = 0
 targsWave = 1
 tTime = -1
-difficulty = 0
+difficulty = 1
 
 cannibalVisible = false
 cannibalKilles = false
@@ -90,7 +90,7 @@
 
 function SkipDamageAnim(anim)
   SwitchHog(youngh)
-  SetInputMask(0xFFFFFFFF)
+  AnimSetInputMask(0xFFFFFFFF)
 end
 
 function SkipOnShroom()
@@ -446,13 +446,10 @@
   EraseSprite(rope2GirderX, rope2GirderY, sprAmGirder, 6)
 end
 
-function CheckChoice()
-  return difficulty ~= 0
-end
-
 function DoChoice()
+  PlaySound(sndPlaced)
   difficultyChoice = false
-  SetInputMask(0xFFFFFFFF)
+  AnimSetInputMask(0xFFFFFFFF)
   StartChallenge(120000 + chalTries * 20000)
 end
 
@@ -578,11 +575,25 @@
   ShowMission(loc("First Blood"), loc("The Crate Frenzy"), loc("Collect the crates within the time limit!|If you fail, you'll have to try again."), 1, 5000)
 end
 
+function ChoiceDialog()
+  local dstr
+  if difficulty == 2 then
+    dstr = loc("Difficulty: Hard")
+  else
+    dstr = loc("Difficulty: Easy")
+  end
+  ShowMission(loc("First Blood"), loc("The Torment"),
+    loc("Your next task is to collect some crates by using the rope!") .. "|" ..
+    loc("Press [Left] and [Right] to change the difficulty.") .. "| |" ..
+    dstr .. "| |" ..
+    loc("Press [Jump] to begin."),
+    0, 300000)
+end
+
 function SetChoice()
-  SetInputMask(band(0xFFFFFFFF, bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLJump+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon)))
+  AnimSetInputMask(0)
   difficultyChoice = true
-  ShowMission(loc("First Blood"), loc("The Torment"), loc("Select difficulty: [Left] - easier or [Right] - harder"), 0, 300000)
-  AddEvent(CheckChoice, {}, DoChoice, {}, 0)
+  ChoiceDialog()
 end
 
 function SetTime(time)
@@ -764,13 +775,20 @@
 
 function onLeft()
   if difficultyChoice == true then
-    difficulty = 1
+    if difficulty ~= 1 then
+       difficulty = 1
+    else
+       difficulty = 2
+    end
+    PlaySound(sndSwitchHog)
+    ChoiceDialog()
   end
 end
+onRight = onLeft
 
-function onRight()
+function onLJump()
   if difficultyChoice == true then
-    difficulty = 2
+    DoChoice()
   end
 end
-
+onHJump = onLJump