Rope training: Simplify final challenge, remove mines
authorWuzzy <Wuzzy2@mail.ru>
Sat, 15 Dec 2018 03:07:20 +0100
changeset 14455 df366c5b8440
parent 14454 fd34b9037c69
child 14456 a077aac9df01
Rope training: Simplify final challenge, remove mines
share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua	Sat Dec 15 01:57:09 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua	Sat Dec 15 03:07:20 2018 +0100
@@ -9,7 +9,7 @@
 	- Multiple shots / rope re-use to go over water hazard
 	- Drop grenade from rope
 	- Special rules when you only got 1 rope (i.e. when the rope is officially used up)
-	- Rope around obstacles and mines
+	- Rope around obstacles
 ]]
 
 HedgewarsScriptLoad("/Scripts/Locale.lua")
@@ -32,7 +32,6 @@
 -- Gears
 local hog
 local ropeGear
-local mines = {}
 
 -- Status vars
 local ropeSelected = false	-- rope was selected the first time, used for msg
@@ -47,6 +46,7 @@
 
 -- "Constants"
 local initHogHealth = 50
+local initHogHealthFinal = 1
 local teamName = loc("Wannabe Ropers")
 
 local girderData = {
@@ -61,28 +61,6 @@
 	{3809, 1375, 0}, -- post-water gate
 }
 
-local mineData = {
-	{1261, 549},
-	{1395, 554},
-	{1719, 458},
-	{1489, 558},
-	{1686, 565},
-	{1581, 561},
-	{1904, 539},
-	{2047, 539},
-	{2226, 608},
-	{2387, 541},
-	{2523, 396},
-	{2899, 324},
-	{3428, 546},
-	{3373, 546},
-	{3271, 546},
-	{3123, 545},
-	{3012, 544},
-	{2907, 544},
-	{2793, 543},
-}
-
 local targetData = {
 	-- 1: Start
 	{504, 1215},
@@ -129,23 +107,20 @@
 
 end
 
--- The final challenge is to rope through a mined obstacle course with only 1 rope.
+-- The final challenge is to rope through an obstacle course with only 1 rope.
 -- If the player screws up, this functinon will restart it.
-local function resetMineChallenge(setPos)
+local function resetFinalChallenge(setPos)
 	if setPos == nil then
 		setPos = true
 	end
-	SetHealth(hog, initHogHealth)
+	SetHealth(hog, initHogHealthFinal)
 	AddAmmo(hog, amRope, 1)
-	for gear, _ in pairs(mines) do
-		DeleteGear(gear)
-	end
+	SetGearVelocity(hog, 0, 0)
 
-	for m=1, #mineData do
-		AddGear(mineData[m][1], mineData[m][2], gtMine, 0, 0, 0, 0)
-	end
 	if setPos then
+		PlaySound(sndWarp)
 		SetGearPosition(hog, cpX, cpY)
+		AddVisualGear(cpX, cpY, vgtExplosion, 0, false)
 		FollowGear(hog)
 	end
 end
@@ -164,6 +139,8 @@
 		PlaceGirder(unpack(girderData[g]))
 	end
 
+	PlaceSprite(1678, 546, sprTargetBee, 0)
+
 	------ BARRELS ------
 	local barrels = {}
 	table.insert(barrels, AddGear(1370, 1223, gtExplosives, 0, 0, 0, 0))
@@ -175,11 +152,6 @@
 		SetHealth(barrels[b], 1)
 	end
 
-	------ MINES ------
-	for m=1, #mineData do
-		AddGear(mineData[m][1], mineData[m][2], gtMine, 0, 0, 0, 0)
-	end
-
 	------ FIRST TARGET ------
 	currentTarget = 1
 	AddGear(targetData[currentTarget][1], targetData[currentTarget][2], gtTarget, 0, 0, 0, 0)
@@ -206,9 +178,6 @@
 		ctrl, 2, 7500)
 		wasFirstTurn = true
 	end
-	if isInMineChallenge then
-		resetMineChallenge()
-	end
 end
 
 function onGameTick()
@@ -242,7 +211,7 @@
 			loc("Swing: [Left]/[Right]").."|"..
 			loc("Release rope: [Attack]"), 2, 15000)
 			ropeAttached = true
-		elseif currentTarget > 1 and not (currentTarget == 6 and barrelsBoom) then
+		elseif currentTarget > 1 and (not (currentTarget == 6 and barrelsBoom)) then
 			HideMission()
 		end
 	end
@@ -257,6 +226,18 @@
 	else
 		SetInputMask(band(GetInputMask(), bnot(gmAttack)))
 	end
+	if isInFinalChallenge then
+		local dX, dY = GetGearVelocity(CurrentHedgehog)
+		local x, y = GetGearPosition(CurrentHedgehog)
+		if band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and GetAmmoCount(CurrentHedgehog, amRope) == 0 and
+				GetFlightTime(CurrentHedgehog) == 0 and (not ropeGear) and
+				math.abs(dX) < 5 and math.abs(dY) < 5 and
+				(x < 3417 or y > 471) then
+			AddCaption(loc("Your rope is gone! Try again!"))
+			resetFinalChallenge()
+			PlaySound(sndWarp)
+		end
+	end
 end
 
 function onGameTick20()
@@ -271,8 +252,6 @@
 function onGearAdd(gear)
 	if GetGearType(gear) == gtRope then
 		ropeGear = gear
-	elseif GetGearType(gear) == gtMine then
-		mines[gear] = true
 	elseif GetGearType(gear) == gtGrenade then
 		if not ropeGear then
 			DeleteGear(gear)
@@ -289,8 +268,8 @@
 		end
 		FollowGear(hog)
 		AddCaption(loc("Your hedgehog has been revived!"))
-		if isInMineChallenge then
-			resetMineChallenge(false)
+		if isInFinalChallenge then
+			resetFinalChallenge(false)
 		end
 	end
 end
@@ -332,7 +311,7 @@
 			loc("Step 3: Drop the grenade").."| |"..
 			loc("Drop weapon (while on rope): [Long Jump]"), 2, 20000)
 			AddAmmo(hog, amBaseballBat, 0)
-			SpawnAmmoCrate(1849, 920, amGrenade, 100)
+			SpawnAmmoCrate(1849, 920, amGrenade, AMMO_INFINITE)
 		elseif currentTarget == 6 then
 			ShowMission(loc("Basic Rope Training"), loc("Finite Ropes"),
 			loc("So far, you had infinite ropes, but in the|real world, ropes are usually limited.").."|"..
@@ -341,14 +320,13 @@
 			loc("If you miss a shot while trying to|re-attach, your rope is gone, too!").."| |"..
 			loc("Final Challenge:").." |"..
 			loc("Reach and destroy the final target to win.").."|"..
-			loc("You only get 1 rope this time, don't waste it!").."|"..
-			loc("Avoid the mines!").."|"..
-			loc("Skip your turn to try again."), 2, 25000)
+			loc("You only get 1 rope this time, don't waste it!"),
+			2, 25000)
 			eraseGirder(4)
 			eraseGirder(5)
 			AddAmmo(hog, amRope, 1)
-			AddAmmo(hog, amSkip, 100)
-			isInMineChallenge = true
+			SetHealth(hog, initHogHealthFinal)
+			isInFinalChallenge = true
 		elseif currentTarget == 7 then
 			ShowMission(loc("Basic Rope Training"), loc("Training complete!"),
 			loc("Congratulations!"), 0, 0)
@@ -373,7 +351,7 @@
 		if not barrelsBoom then
 			barrelsBoom = true
 			AddAmmo(hog, amGrenade, 0)
-			AddAmmo(hog, amBaseballBat, 100)
+			AddAmmo(hog, amBaseballBat, AMMO_INFINITE)
 			eraseGirder(2)
 			eraseGirder(3)
 			ShowMission(loc("Basic Rope Training"),
@@ -398,8 +376,6 @@
 			ctrl, 2, 13000)
 			ropeAttached = false
 		end
-	elseif GetGearType(gear) == gtMine then
-		mines[gear] = nil
 	elseif GetGearType(gear) == gtCase then
 		eraseGirder(6)
 		eraseGirder(7)
@@ -411,13 +387,6 @@
 	SetAmmo(amBaseballBat, 9, 0, 0, 1)
 end
 
-function onHogAttack(ammoType)
-	-- Allow to manually reset final challenge with skip
-	if ammoType == amSkip then
-		resetMineChallenge()
-	end
-end
-
 function onAttack()
 	if GetCurAmmoType() == amGrenade and not ropeGear then
 		AddCaption(loc("You have to drop the grenade from rope!"), 0xFF4000FF, capgrpMessage)