Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Short-range Warp/Jump


akash47
 Share

Recommended Posts

First post. Hello touchofdeath ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

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

```

2) 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 ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) 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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)
Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...