ASA, Getting to the device: Add fake crate for the device part with proper collect message
authorWuzzy <almikes@aol.com>
Tue, 26 Sep 2017 00:41:30 +0200
changeset 12528 7b32e83aaf48
parent 12527 b0492168f1ad
child 12529 89d3c3ebc925
ASA, Getting to the device: Add fake crate for the device part with proper collect message
ChangeLog.txt
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
--- a/ChangeLog.txt	Mon Sep 25 23:55:53 2017 +0200
+++ b/ChangeLog.txt	Tue Sep 26 00:41:30 2017 +0200
@@ -198,7 +198,9 @@
  + 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
+ * Getting to the device: Add real crate and correct message for collecting device part
+ * Getting to the device: Remove checkpoints. There was a good chance for these missions to become unwinnable
+ * Searching in the dust: Remove checkpoints. See above.
  * 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
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Mon Sep 25 23:55:53 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Tue Sep 26 00:41:30 2017 +0200
@@ -28,10 +28,13 @@
 	[dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assassins before they attack back").."|"..minesTimeText, 1, 4000},
 }
 -- crates
+local girderCrate = {name = amGirder, x = 1680, y = 1160}
+
 local eagleCrate = {name = amDEagle, x = 1680, y = 1650}
-local girderCrate =	{name = amGirder, x = 1680, y = 1160}
+
+local weaponCrate = { x = 1320, y = 1870}
+local deviceCrate = { gear = nil, x = 1360, y = 1870}
 local ropeCrate = {name = amRope, x = 1400, y = 1870}
-local weaponCrate = { x = 1360, y = 1870}
 -- hogs
 local hero = {}
 local green1 = {}
@@ -125,7 +128,7 @@
 	end
 
 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
-	AddEvent(onDeviceCrates, {hero.gear}, deviceCrates, {hero.gear}, 0)
+	AddEvent(onDeviceCrates, {hero.gear}, deviceCrateEvent, {hero.gear}, 0)
 
 	-- Hog Solo and GB weapons
 	AddAmmo(hero.gear, amSwitch, 100)
@@ -185,7 +188,10 @@
 	-- place crates
 	SpawnUtilityCrate(girderCrate.x, girderCrate.y, girderCrate.name)
 	SpawnAmmoCrate(eagleCrate.x, eagleCrate.y, eagleCrate.name)
-	SpawnUtilityCrate(ropeCrate.x, ropeCrate.y, ropeCrate.name)
+	deviceCrate.gear = SpawnFakeUtilityCrate(deviceCrate.x, deviceCrate.y, false, false) -- anti-gravity device
+	-- Rope crate is placed after device crate has been collected.
+	-- This is done so it is impossible the player can rope before getting
+	-- the device part.
 
 	if tookPartInBattle then
 		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amWatermelon)
@@ -248,6 +254,14 @@
 		hero.dead = true
 	elseif gear == green1.bot then
 		green1.dead = true
+	elseif gear == deviceCrate.gear then
+		if band(GetGearMessage(gear), gmDestroy) ~= 0 then
+			PlaySound(sndShotgunReload)
+			AddCaption(loc("Anti-Gravity Device Part (+1)"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmostate)
+			deviceCrate.collected = true
+			-- Spawn rope crate
+			SpawnUtilityCrate(ropeCrate.x, ropeCrate.y, ropeCrate.name)
+		end
 	end
 end
 
@@ -289,7 +303,7 @@
 end
 
 function onDeviceCrates(gear)
-	if not hero.dead and GetY(hero.gear)>1850 and GetX(hero.gear)>1340 and GetX(hero.gear)<1640 then
+	if not hero.dead and deviceCrate.collected and StoppedGear(hero.gear) then
 		return true
 	end
 	return false
@@ -341,8 +355,8 @@
 	end
 end
 
-function deviceCrates(gear)
-	EndTurn(true)
+function deviceCrateEvent(gear)
+	SetGearMessage(hero.gear, 0)
 	if not tookPartInBattle then
 		AddAnim(dialog03)
 	else
@@ -438,7 +452,7 @@
 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
 	-- DIALOG03 - At crates, hero learns that Captain Lime is bad
 	AddSkipFunction(dialog03, Skipanim, {dialog03})
-	table.insert(dialog03, {func = AnimWait, args = {hero.gear, 4000}})
+	table.insert(dialog03, {func = AnimWait, args = {hero.gear, 1250}})
 	table.insert(dialog03, {func = FollowGear, args = {hero.gear}})
 	table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Hooray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}})
 	table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}})