Short-range Warp/Jump

First post. Hello touchofdeath :)

This code was written in/for DragonEclipse. I’m not sure how compatability with different versions is, so if anyone knows how this would go with other versions, please comment so more people can use the code. Thank you.

This code alters the warp spell already in-place. It makes it so that if you set the map of the warp to 0, the x value becomes how far forward you warp on the same map, and the y value becomes how far backwards you warp on the same map. This works like a jump/blink/teleport. If an object is in the way, or you would jump off the maps edge, the jump is shortened so that you can still jump to the tile before that point.

WARNING: You may need to add many new “Blocked” attributes to the tiles on your maps , so that players can’t simply jump over one row of blocked squares into a place where they shouldn’t be able to walk. If you’re trying to tweak this in any way and have troubles with it just send me a message and I’ll try and help if I can (though I’m not even close to pro).

All server-side.

  1. In modCombat, under this:

Public Sub CastSpell(ByVal Index As Long, ByVal spellslot As Long, ByVal target As Long, ByVal targetType As Byte)

Dim spellnum As Long

Dim MPCost As Long

Dim LevelReq As Long

Dim mapnum As Long

Dim Vital As Long

Dim DidCast As Boolean

Dim ClassReq As Long

Dim AccessReq As Long

Dim i As Long

Dim AoE As Long

Dim Range As Long

Dim VitalType As Byte

Dim increment As Boolean

Dim x As Long, y As Long

add


Dim xt As Long

Dim yt As Long

  1. Then in the same Module, directly under this:

		 Case SPELL_TYPE_WARP

		 SendAnimation mapnum, Spell(spellNum).SpellAnim, GetPlayerX(Index), GetPlayerY(Index)

		 PlayerWarp Index, Spell(spellNum).Map, Spell(spellNum).x, Spell(spellNum).y

add this


		 'Code to warp short distances, using x as forward and y as backwards, while map is set to 0 (in warp spells).

		 If Spell(spellNum).Map = 0 Then

		 If Player(Index).Dir = 0 Then

		 xt = Player(Index).x

		 yt = Player(Index).y - (Spell(spellNum).x) + (Spell(spellNum).y)

		 If xt > Map(mapnum).MaxX Then xt = Map(mapnum).MaxX

		 If yt > Map(mapnum).MaxY Then yt = Map(mapnum).MaxY

		 If xt < 1 Then xt = 1

		 If yt < 1 Then yt = 1

		 If Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE Then

			 SetPlayerX Index, xt

			 SetPlayerY Index, yt

			 SendPlayerXYToMap Index

		 Else

			 If yt < Player(Index).y Then

				 Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE

				 yt = yt + 1

				 Loop

				 If yt < Player(Index).y Then

				 SetPlayerX Index, xt

				 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

				 End If

			 Else

			 If yt > Player(Index).y Then

				 Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE

				 yt = yt - 1

				 Loop

				 If yt > Player(Index).y Then

				 SetPlayerX Index, xt

				 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

				 End If

			 End If

			 End If

		 End If

		 End If

		 If Player(Index).Dir = 1 Then

		 xt = Player(Index).x

		 yt = Player(Index).y + (Spell(spellNum).x) - (Spell(spellNum).y)

		 If xt > Map(mapnum).MaxX Then xt = Map(mapnum).MaxX

		 If yt > Map(mapnum).MaxY Then yt = Map(mapnum).MaxY

		 If xt < 1 Then xt = 1

		 If yt < 1 Then yt = 1

		 If Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE Then

		 SetPlayerX Index, xt

		 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

		 Else

			 If yt < Player(Index).y Then

				 Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE

				 yt = yt + 1

				 Loop

				 If yt < Player(Index).y Then

				 SetPlayerX Index, xt

				 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

				 End If

			 Else

			 If yt > Player(Index).y Then

				 Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE

				 yt = yt - 1

				 Loop

				 If yt > Player(Index).y Then

				 SetPlayerX Index, xt

				 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

				 End If

			 End If

			 End If

		 End If

		 End If

		 If Player(Index).Dir = 2 Then

		 xt = Player(Index).x - (Spell(spellNum).x) + (Spell(spellNum).y)

		 yt = Player(Index).y

		 If xt > Map(mapnum).MaxX Then xt = Map(mapnum).MaxX

		 If yt > Map(mapnum).MaxY Then yt = Map(mapnum).MaxY

		 If xt < 1 Then xt = 1

		 If yt < 1 Then yt = 1

		 If Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE Then

		 SetPlayerX Index, xt

		 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

		 Else

			 If xt < Player(Index).x Then

				 Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE

				 xt = xt + 1

				 Loop

				 If xt < Player(Index).x Then

				 SetPlayerX Index, xt

				 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

				 End If

			 Else

			 If xt > Player(Index).x Then

				 Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE

				 xt = xt - 1

				 Loop

				 If xt > Player(Index).x Then

				 SetPlayerX Index, xt

				 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

				 End If

			 End If

			 End If

		 End If

		 End If

		 If Player(Index).Dir = 3 Then

		 xt = Player(Index).x + (Spell(spellNum).x) - (Spell(spellNum).y)

		 yt = Player(Index).y

		 If xt > Map(mapnum).MaxX Then xt = Map(mapnum).MaxX

		 If yt > Map(mapnum).MaxY Then yt = Map(mapnum).MaxY

		 If xt < 1 Then xt = 1

		 If yt < 1 Then yt = 1

		 If Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE Then

		 SetPlayerX Index, xt

		 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

		 Else

			 If xt < Player(Index).x Then

				 Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE

				 xt = xt + 1

				 Loop

				 If xt < Player(Index).x Then

				 SetPlayerX Index, xt

				 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

				 End If

			 Else

			 If xt > Player(Index).x Then

				 Do Until Map(mapnum).Tile(xt, yt).Type = TILE_TYPE_WALKABLE

				 xt = xt - 1

				 Loop

				 If xt > Player(Index).x Then

				 SetPlayerX Index, xt

				 SetPlayerY Index, yt

				 SendPlayerXYToMap Index

				 End If

			 End If

			 End If

		 End If

		 End If

	 End If

and that’s it. Hopefully it helps someone on the way to making their dream game, or at least helps someone on the way to understanding Eclipse a little better. I gained most of my understanding so far from the tutorials made by this community, so I’m glad I can finally pay a little back :)

Looks nice but wrong place…

The post should be in Source 😉

Knew I’d stuff it up somehow :P sorry for that guys.

Nice, might add this in to my Engine but as a separate option xD Did you rip this from dragon eclipse then?

:) no, the warp spell is part of dragon eclipse, and it sends you to a new map at a set x and y. I wanted a jump spell, so I made this, and added it to warp because i felt it would be better to make the already-existing spell-type more versatile rather than create a new spell-type and leave warp with limited functionality.

Nice, is this wrote for a dx7 or dx8 engine?

Oh wait nevermind xD

I think dragon eclipse is directx8

Just had to fix up the final block of code. Had a little error at the bottom. I included this:


				    SendAnimation GetPlayerMap(Index), Spell(spellNum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, Index

				    DidCast = True

which means the animation would’ve happened twice.

It is but looking over the code quickly it looks like it should work for dx7 with small changes and what not, I’ll try it today xD

xD its working on both… that has nothing to do with the graphic drawing just the sending animation but thats an fast change 😉

Beat me too it once again ;) Are you ever off your computer? XD

No 😉

I work from my home haha

yeah, I’d love a more fluid jump for physical skill, but I need to take a closer look at how movement works first, and find a way to get tickcount in there…. for the moment I’m just settling for covering up with a fancy jump animation :P

Thanks a lot! Will be using this.

It would be nice if you could get an image (which could be a shade or something) going through the path you’re jumping.

it is c++?

it is c++?

No. Dragon Eclipse is written in VB6, as are most engine here.

No. Drachen Eclipse is written in VB6, as are most engine here.

You mean Dragon Eclipse?

You mean Dragon Eclipse?

Gah ._.

Log in to reply