Author Topic: jumping, crawling and swimming.  (Read 14521 times)

Pickledtezcat

  • Rogueliker
  • ***
  • Posts: 62
  • Karma: +0/-0
    • View Profile
    • Pickledtezcat Game Development Blog
jumping, crawling and swimming.
« on: February 13, 2014, 11:38:50 PM »
Has anyone tried any non standard movement methods, such as jumping over pits crawling through tunnels or swimming in flooded areas?

I'm curious about how others might handle that.

implementation would obviously be different in systems that have more than one movement point per turn, and those which allow the player and monsters to move multiple squares.
A blog about my 3d Roguelike: http://pickleddevblog.blogspot.kr/

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: jumping, crawling and swimming.
« Reply #1 on: February 14, 2014, 02:27:40 AM »
In Sil there's an ability that lets you jump over pits.

In Brogue you can move through deep water freely, but items in your inventory constantly float away, so you have to choose between going around, letting your items get spread all across the water, or taking a long time to catch each one as it floats away.

Pickledtezcat

  • Rogueliker
  • ***
  • Posts: 62
  • Karma: +0/-0
    • View Profile
    • Pickledtezcat Game Development Blog
Re: jumping, crawling and swimming.
« Reply #2 on: February 14, 2014, 04:02:34 AM »
Well I'm using a multiple movement points system with a star pathfinding. I want to allow jumping but I have to stop the player and monsters from making turns in mid air, or jumping round corners. Also they shouldnt jump in to impassable tiles.
A blog about my 3d Roguelike: http://pickleddevblog.blogspot.kr/

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: jumping, crawling and swimming.
« Reply #3 on: February 14, 2014, 04:34:17 AM »
One good way to do that is to break the jump action into multiple turns.  Have the game remember the direction the actor chose to jump in, and every time their turn comes up, automatically move them in that direction until the jump ends or they collide with an obstacle.

You could also make the whole action that take place in a single turn.  Check every space between the actor and their destination, if it's all clear, move them to the target space.

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: jumping, crawling and swimming.
« Reply #4 on: February 14, 2014, 05:17:45 AM »
If multiple movement points system means you have more than one move every turn then use one of the moves for every square they pass through

Pickledtezcat

  • Rogueliker
  • ***
  • Posts: 62
  • Karma: +0/-0
    • View Profile
    • Pickledtezcat Game Development Blog
Re: jumping, crawling and swimming.
« Reply #5 on: February 14, 2014, 05:46:29 AM »
One good way to do that is to break the jump action into multiple turns.  Have the game remember the direction the actor chose to jump in, and every time their turn comes up, automatically move them in that direction until the jump ends or they collide with an obstacle.

You could also make the whole action that take place in a single turn.  Check every space between the actor and their destination, if it's all clear, move them to the target space.

That would be a good way of handling jumping with single movement.
At the moment I use bresenhams line for navigation and if the line is interupted by impassable tiles, then do an a star search. I'm thinking of using the line for jumping too, so I can check if the jump is straight and then just skip the a star check and return no path if the jump is invalid.

I'm wondering how to deal with failed jumps. Would it even be a good idea?
A blog about my 3d Roguelike: http://pickleddevblog.blogspot.kr/

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: jumping, crawling and swimming.
« Reply #6 on: February 14, 2014, 06:01:21 AM »
Does the player make every step of their turn individually, or do they select their destination and let the pathfinding system figure out how to get there?

Pickledtezcat

  • Rogueliker
  • ***
  • Posts: 62
  • Karma: +0/-0
    • View Profile
    • Pickledtezcat Game Development Blog
Re: jumping, crawling and swimming.
« Reply #7 on: February 14, 2014, 07:12:50 AM »
Real time pathfinding visualization to the moused over square and when you find a route you like left click to confirm to initiate movement. If the path is invalid no path is shown and nothing happens when you left click.

edit: by failed jumps I mean having a chance to fall if the distance is too far.
I'm thinking of having a jumping skill, or basing jump distance on an attribute or having a chance to clear a jump based on an attribute.
« Last Edit: February 14, 2014, 10:30:24 AM by Pickledtezcat »
A blog about my 3d Roguelike: http://pickleddevblog.blogspot.kr/

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: jumping, crawling and swimming.
« Reply #8 on: February 14, 2014, 12:00:07 PM »
If you're only allowing actors to jump to targets no more than two to three tiles away then it isn't too hard to solve.  If the direction of each move is either the same direction or off by one (assuming standard roguelike 8-directional movement) then the jump can be said to follow a straight line.

So a jump that goes N, NE, NE would be acceptable because north and northeast are "adjacent" directions.  A NE, N, NW jump wouldn't be okay because northeast and northwest aren't adjacent.

If you want to allow jumps longer than three spaces then this method starts to break down and you'll have to do something more complicated.

I wouldn't include a possibility of failing to make your jump if I were you.  It'd be a really unnecessary source of frustration.

Z

  • Rogueliker
  • ***
  • Posts: 905
  • Karma: +0/-0
    • View Profile
    • Z's Roguelike Stuff
Re: jumping, crawling and swimming.
« Reply #9 on: February 14, 2014, 12:48:16 PM »
In my VoI, jumping is modelled as throwing oneself. It is implemented using roughly the same routines as ranged attacks. And it can be used as a ranged attack, too.

Pickledtezcat

  • Rogueliker
  • ***
  • Posts: 62
  • Karma: +0/-0
    • View Profile
    • Pickledtezcat Game Development Blog
Re: jumping, crawling and swimming.
« Reply #10 on: February 14, 2014, 01:13:19 PM »
A blog about my 3d Roguelike: http://pickleddevblog.blogspot.kr/

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: jumping, crawling and swimming.
« Reply #11 on: February 15, 2014, 04:21:53 AM »
In my VoI, jumping is modelled as throwing oneself. It is implemented using roughly the same routines as ranged attacks. And it can be used as a ranged attack, too.

That's a good idea.

Pickledtezcat

  • Rogueliker
  • ***
  • Posts: 62
  • Karma: +0/-0
    • View Profile
    • Pickledtezcat Game Development Blog
Re: jumping, crawling and swimming.
« Reply #12 on: February 15, 2014, 07:21:21 AM »
Jumping in to someone and knocking them down would be a very interesting addition to the usual repertoire of attacks.
It reminds me of the Death From Above attack in battletech. What happens if you miss? Random Scatter? Could enemies be displaced by such an attack, or would the player stop short of the target square?

How are pit traps handled in general? Do they always lead down to the next level? In a case where you have multiple movement points per turn would it be a good idea to trigger the pit part way through someone's movement, or only trigger it if they actually land on the pit square at the end of their movement? Can pits be spotted? Do they look different from other tiles?

I'm using a 3d engine so I'll actually have to make pits take physical form (I've seen 3d RPGs in the past that just used a textured black plane to represent a pit, maybe that would work).

Do you think I should include a routine to make sure that if you fall to the level below there's no pit in that square? I guess unless pits are really common it would be unlikely.
A blog about my 3d Roguelike: http://pickleddevblog.blogspot.kr/

Pickledtezcat

  • Rogueliker
  • ***
  • Posts: 62
  • Karma: +0/-0
    • View Profile
    • Pickledtezcat Game Development Blog
Re: jumping, crawling and swimming.
« Reply #13 on: February 16, 2014, 03:01:17 PM »
Well, anyway, I've gone ahead and sketched out the code for jumping, It'll add squares recursively in the direction of the mouse pointer, if the jump is in one of the cardinal directions.
It'll add the squares out to the position of the mouse pointer, and check as it does so if they are in the dictionary of movable squares (including flyable or swim-able squares). If the last square is a land square and the other squares were viable, it will return a visual path and the player can confirm it. Otherwise no path is returned and the jump is impossible.

For swimming I'm going to have to add a "is_swimming" property to the character (monster or player) and allow them to move normally through the water at walk speed. They will have to spend a turn to enter the water and to get out. They won't be able to attack or use items when swimming (unless they are an aquatic creature) and there will be some chance of items becoming damaged. It makes me think it would be a good idea to have a pack item which can store some inventory, which can be thrown like a thrown attack. It would be possible to throw it much further than you could jump, so it might be good to throw a pack of scrolls or whatever across the water first before swimming.

I'll have to be careful with how the code handles both situations, as I don't want the player to count as swimming when they jumped over a small area of water. I think having jumps occur only within one movement phase, while swims require at least three will stop any crossover. The "is_swimming" property will be added when the player goes in to the water and be removed on the turn they come out. It'll help to handle the animations for the 3d models too. If the character is swimming they can't jump, and can't move on to any non water square without doing a leave water action, which they can do if adjacent to a land tile. It may still be possible to loot corpses found in the water, or search adjacent squares for loose items.

I'm really looking forward to a player swimming down a long flooded corridor and rounding a corner to see a giant pike fish, or whatever swimming towards them. Maybe they can find a nearby ledge to get out of the water, or maybe they can swim back around the corner to where hopefully their companions are waiting with ranged weapons ready to shoot the big fish. Maybe they could get some lovely fresh fish out of the encounter.

I had thought of adding crawling, for moving through areas blocked with spiderwebs, etc... but I think I'll just follow the usual trope of having to destroy them using fire or weapon attacks.
A blog about my 3d Roguelike: http://pickleddevblog.blogspot.kr/

Paul Jeffries

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 257
  • Karma: +1/-0
    • View Profile
    • Vitruality.com
Re: jumping, crawling and swimming.
« Reply #14 on: February 16, 2014, 11:33:13 PM »
POWDER has jumping as a special ability gained through wearing jump boots or by eating a monster with the intrinsic.  It works as a two-tile move that can cross over pits or monsters in the way.  It also sort-of has swimming, although its only implemented as a % chance of sinking (and thereby taking drowning damage) when moving over liquid tiles.