ASA: Searching in the dust: Fix incorrect crate content display after collecting device part
authorWuzzy <almikes@aol.com>
Mon, 25 Sep 2017 23:48:56 +0200
changeset 12526 6115bf1156ec
parent 12525 767920fd03a1
child 12527 b0492168f1ad
ASA: Searching in the dust: Fix incorrect crate content display after collecting device part
ChangeLog.txt
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
--- a/ChangeLog.txt	Mon Sep 25 23:04:15 2017 +0200
+++ b/ChangeLog.txt	Mon Sep 25 23:48:56 2017 +0200
@@ -197,7 +197,10 @@
  + A few campaign missions now save your personal best successes (e.g. fastest finish in Hard Flying) which get shown after you finish them agin
  + Add skip to a few missions where it doesn't hurt
  + Menu: Show 2 flowers over fully completed planets (with side missions)
+ + Allow skipping in some missions
  * Remove checkpoints in: Getting to the device and Searching in the dust. There was a good chance for these missions to become unwinnable
+ * Searching in the dust: Fix Hog Solo dropping straight down when roping near smuggler
+ * Searching in the dust: Fix incorrect messages after collecting device part
  * Hard Flying: Fix ending in a Lua error
  * The First Stop: Fix stats screen showing teams twice
  * Killing The Specialists: Fix killing hog with Deagle gave you chance to use another weapon in same turn
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua	Mon Sep 25 23:04:15 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua	Mon Sep 25 23:48:56 2017 +0200
@@ -45,8 +45,8 @@
 local girderY = 1630
 local girderX = 3350
 -- win crates
-local btorch2 = {}
-local girder = {}
+local btorch2 = { gear = nil, destroyed = false, deleted = false}
+local girder = { gear = nil, destroyed = false, deleted = false}
 -- hogs
 local hero = {}
 local ally = {}
@@ -141,15 +141,16 @@
 	AddAmmo(smuggler3.gear, amRope, 2)
 
 	-- spawn crates
-	SpawnAmmoCrate(btorch2X, btorch2Y, amBlowTorch)
 	SpawnAmmoCrate(btorch3X, btorch3Y, amBlowTorch)
 	SpawnUtilityCrate(rope1X, rope1Y, amRope)
 	SpawnUtilityCrate(rope2X, rope2Y, amRope)
 	SpawnUtilityCrate(rope3X, rope3Y, amRope)
 	SpawnUtilityCrate(portalX, portalY, amPortalGun)
-	SpawnUtilityCrate(girderX, girderY, amGirder)
+	SpawnHealthCrate(3300, 970)
 
-	SpawnHealthCrate(3300, 970)
+	-- the win crates, collect both to win
+	btorch2.gear = SpawnAmmoCrate(btorch2X, btorch2Y, amBlowTorch)
+	girder.gear = SpawnUtilityCrate(girderX, girderY, amGirder)
 
 	-- adding mines - BOOM!
 	AddGear(1280, 460, gtMine, 0, 0, 0, 0)
@@ -233,35 +234,35 @@
 	SetAmmo(amPortalGun, 0, 0, 0, 1)
 	SetAmmo(amGirder, 0, 0, 0, 3)
 	SetAmmo(amSkip, 9, 0, 0, 1)
-end
 
-function onGearAdd(gear)
-	if GetGearType(gear) == gtCase then
-		if GetX(gear) == btorch2X and GetY(gear) == btorch2Y then
-			btorch2.gear = gear
-			btorch2.destroyed = false
-			btorch2.deleted = false
-		elseif GetX(gear) == girderX and GetY(gear) == girderY then
-			girder.gear = gear
-			girder.destroyed = false
-			girder.deleted = false
-		end
-	end
-end
-
-function onGearDamage(gear, damage)
-	if gear == girder.gear then
-		girder.destroyed = true
-	elseif gear == btorch2.gear then
-		btorch2.destroyed = true
-	end
+	SetAmmo(amTeleport, 9, 0, 0, 1)
 end
 
 function onGearDelete(gear)
+	local foundDeviceCrateCandidate = function(candidate_crate_table, other_crate_table)
+		candidate_crate_table.deleted = true
+		-- Evaluates to false if crate has been collected
+		if (band(GetGearMessage(candidate_crate_table.gear), gmDestroy) == 0) then
+			candidate_crate_table.destroyed = true
+		end
+
+		if cratesFound == 0 then
+			-- First win crate collected:
+			-- Turn the other crate into a fake crate; this will “contain” the device.
+			SetGearPos(other_crate_table.gear, bor(GetGearPos(other_crate_table.gear), 0x8))
+		elseif cratesFound == 1 then
+			-- Second win crate collected:
+			-- This crate contains the anti-gravity part! VICTORY!
+			PlaySound(sndShotgunReload)
+			-- It's displayed as if collecting a normal ammo/utility crate. :-)
+			AddCaption(loc("Anti-Gravity Device Part (+1)"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
+		end
+	end
+
 	if gear == girder.gear then
-		girder.deleted = true
+		foundDeviceCrateCandidate(girder, btorch2)
 	elseif gear == btorch2.gear then
-		btorch2.deleted = true
+		foundDeviceCrateCandidate(btorch2, girder)
 	end
 	if gear == hero.gear then
 		hero.dead = true
@@ -487,7 +488,8 @@
 	elseif cratesFound == 1 then
 		-- end game
 		saveCompletedStatus(5)
-		AnimSay(hero.gear, loc("Hooray!"), SAY_SHOUT, 5000)
+		AnimSay(hero.gear, loc("I found it! Hooray!"), SAY_SHOUT, 5000)
+		PlaySound(sndVictory, hero.gear)
 		SendStat(siGameResult, loc("Congratulations, you won!"))
 		SendStat(siCustomAchievement, loc("To win the game you had to collect the 2 crates with no specific order."))
 		SendStat(siPlayerKills,'1',teamC.name)