Character stuck randomly.

Started by Midian Design, Tue 04/08/2009 20:08:20

Previous topic - Next topic

Midian Design

Someone trying JJ Gun said that the character without reason stuck, he can talk, look, but not walk anymore.
I use AGS 3.1 in 1024x768, walkpath are really simple and big and so... If someone knows this issue.... :)
Thank You.
The Game: http://www.adventuregamestudio.co.uk/games.php?action=detail&id=1192

Pumaman

You'll have to be more specific than that. In which room did he get stuck? Where in that room? Can you post a screenshot of the room's walkable areas?

Midian Design

Oh sorry, we talk a lot about in the completed forum and I forgot :D

It stuck randomly, doesn't matter if there's a big box or a line 8 px height.
I played the game from the start to the end and nothing happens, I do it again and stuck in a room, but there's people in this forum saying that stuck every 2 rooms... very annoing :(

Gilbert

Hmmm. Are the rooms scrolling ones? If the room is very large you may experience some problems.


Midian Design

There are very large rooms, but it stuck also in non-scrolling rooms.

Midian Design

Ok, there's a lot of people with this problem (in hi res games).

I found this code by WHAM:
Code: ags

int walkies = 1;

function repeatedly_execute() {

int areanumber = GetWalkableAreaAt(player.x - GetViewportX(), player.y - GetViewportY());

// When ego walks off a walkable area
if (areanumber == 0) {
// First force him to move one pixel left
  if (walkies == 1) {
  cEgo.Move(cEgo.x - 2, cEgo.y, eBlock, eAnywhere);
  walkies = 0; } 
  // And if that didn't work, two pixels to the right.
  else {
  cEgo.Move(cEgo.x + 4, cEgo.y, eBlock, eAnywhere);  
  walkies = 1;
  }
} 
// When all is right again, reset the rig.
else if (areanumber != 0) {
  walkies = 1;
}
}


But it doesn't work until I set borders to the edges (0,768, 1024 or larger).
Before the new edges, EGO gets stuck and the code doesn't work, with 0 border it's ok (don't ask me why).

I modify
Code: ags

  cEgo.Move(cEgo.x - 2, cEgo.y, eBlock, eAnywhere);

with
Code: ags

  cEgo.Move(cEgo.x + 2, cEgo.y + 2, eBlock, eAnywhere);


And it seems perfect for my case.

Pleeeeeease fix this issue in hi-res games when you can  ;) It works but it's not a perfect solution  :)

Vince Twelve

#6
Yeah, Chris, I had one person email me a while back who was playing Linus Bruckman (which is just one big scrolling room in 640x480) who said she could not play the game because the player would keep getting stuck.  She sent me a save file and sure enough, the player character was off the walkable area.  I tried repeatedly to get the player character to do this, but was unsuccessful. But she said it happened every time she played the game.  Even with her telling me exactly where she clicked to cause it, I couldn't get it to happen on my machine and no one else ever complained about it.

Is there something about how certain CPUs calculate or something that could throw off a pathfinding algorithm?

Edit to add: Linus has one walkable area total.  It is very simple -- a paralellogram with a few smaller paralellograms cut out for the pedestals in the room -- and never gets narrower than, at a guess, 30 pixels.

Matti

I had these problems too on my old machine (don't know about my current). It was hi-res and the character sometimes got stuck at the corners or borders of perfectly normal and very basic walkeable areas. If I wouldn't have lost my game anyway I would've started a similar thread here.

Pumaman

#8
Quote from: MD on Fri 07/08/2009 08:18:01
But it doesn't work until I set borders to the edges (0,768, 1024 or larger).
Before the new edges, EGO gets stuck and the code doesn't work, with 0 border it's ok (don't ask me why).

Wait a minute, where were the room edges before you moved them?

I remember some problems a while back with the pathfinder, where it turned out that the cause was that the room edges weren't set properly and that was causing the issue.

Basically, when a character finishes moving somewhere, the pathfinder automatically checks to make sure that they have finished up on a walkable area. If not, it moves the character a couple of pixels until it is.

HOWEVER, it will never move the character outside of the room edges (this was because it could accidentally move you a couple of pixels across the room edge and activate the Player Walks Off Right type events).

Therefore if you don't set the room edges properly, you'll find that the character can get stuck when they are walking outside of the edges.

Can you try removing that extra script code you've added, and just making sure the room edges are correct, and see if the problem still happens?

jumpjack

#9
Reopening this ancient thread to propose a generic solution.

Adding this statements inside repeatedly_execute() function in global script should fix the issue:

Code: ags
 if (GetWalkableAreaAtRoom(  player.x,  player.y) == 0) {
   cEgo.PlaceOnWalkableArea()
}

This places the player in closest walkable area as soon the player itself is detected as being out of any walkable area.

eri0o

#10
Ahn, the path finding algorithm has been completely rewritten since and this should not happen anymore afaik.

Bug reports without a way to actually reproduce makes them not useful. There's a template for bug reports where the information that makes them easier to act is mentioned.

For this specific case, an export of the walkable area that is problematic would be a reasonable way to reproduce, and mention of the AGS version and operating system where the issue occurs would be also useful.


SMF spam blocked by CleanTalk