Continental supplies: Upside-Down World special now works in cave maps as well
authorWuzzy <Wuzzy2@mail.ru>
Fri, 04 May 2018 01:39:22 +0200
changeset 13382 03e4d9b5b09c
parent 13381 f7631fb4c584
child 13383 c53530142442
Continental supplies: Upside-Down World special now works in cave maps as well In cave maps, the hog is teleported just below the border. A bit of land is erased, too.
share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Fri May 04 01:01:40 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Fri May 04 01:39:22 2018 +0200
@@ -1906,10 +1906,29 @@
 	elseif(CS.ANTARCTICA_SPECIAL == 1 and GetCurAmmoType() == amPickHammer and band(GetState(CurrentHedgehog),gstAttacked)==0)
 	then
 		EndTurnCS(10)
-		SetGearPosition(CurrentHedgehog,GetX(CurrentHedgehog),0)
-		ParseCommand("hjump")
-		SetGearVelocity(CurrentHedgehog, 0, 100000000)
+		local dx, dy = GetGearVelocity(CurrentHedgehog)
+		local isLeft = dx < 0
+		-- Cave map / map has border
+		if not MapHasBorder() then
+			-- Place hog at Y = 0
+			SetGearPosition(CurrentHedgehog, GetX(CurrentHedgehog), 0)
+			ParseCommand("hjump")
+			SetGearVelocity(CurrentHedgehog, 0, 100000000)
 
+		-- Open air map
+		else
+			-- Place hog just below the top border, erase a bit of land as well
+			local x = GetX(CurrentHedgehog)
+			Explode(x, TopY + 6, 32, EXPLNoDamage + EXPLDoNotTouchAny + EXPLNoGfx)
+			Explode(x, TopY + 20, 24, EXPLNoDamage + EXPLDoNotTouchAny)
+			SetGearPosition(CurrentHedgehog, x, TopY + 26)
+			local dx, dy = GetGearVelocity(CurrentHedgehog)
+			SetGearVelocity(CurrentHedgehog, 0, dy)
+			ParseCommand("hjump")
+		end
+		if isLeft then
+			HogTurnLeft(CurrentHedgehog, true)
+		end
 		PlaySound(sndPiano8)
 		PlaySound(sndWarp)