More than 16 Walkable areas?

Started by Vince Twelve, Fri 15/12/2006 06:33:27

Previous topic - Next topic

Vince Twelve

Is there a way to simulate more than 16 Walkable areas?

Here's the problem: I have a bunch of objects that can be moved around to several (36 to be precise) non-overlapping areas in the room by the player. 

The player character can also walk among each of these objects, so I wanted to make the character walk around rather than through each of these objects.  I figured I could make the objects into solid characters so that AGS would automatically remove a small portion of walkable area at the base of each making the character walk around them.  This works fine for some objects.  However, a few objects are oddly shaped.  One, for example, is long and thin and laying at an angle in relation to the camera which messes up the walk behind.  Another object is propped up on a tripod.  The character can walk underneath the back leg in a way that he shouldn't.

So: I figured I could fix this by making an adequately large circle-shaped walkable area at each of the places where an object could be moved.  Then, I could turn on and off that walkable area as needed to keep the character from walking underneath the object.  A simple solution that would have the intended effect.  However, with 36 possible object locations and 16 maximum walkable areas I'm at a loss for what to do.

I tried making the walkable areas in groups and turning them on and off while the character is walking, so that the correct ones would turn on if the character came near, but the walking path is generated at the moment you click so the character can walk right into a walkable area that was turned off just after clicking and get himself stuck.

To complicate things: The game has multiple playable characters who may be moving simultaneously...  ::)

Any ideas?

SSH

You could do it by scripting your own walking route algorithm, I should think.
12

Khris

Quote from: Vince Twelve on Fri 15/12/2006 06:33:27I tried making the walkable areas in groups and turning them on and off while the character is walking, so that the correct ones would turn on if the character came near, but the walking path is generated at the moment you click so the character can walk right into a walkable area that was turned off just after clicking and get himself stuck.
I think the whole issue can be solved by solving this part of it:
-Create a region that consists of 36 circles, one at every circular walkable area part, but with a slightly bigger radius (big enough that one of the players x- and y-movement steps is covered)
-In the room's rep_ex (where walkable areas are turned on and off I guess) add code that checks if the player has just walked onto the region or isn't on a region at all and disable walkable areas only if one of the two is the case.
The player shouldn't get stuck this way.

Maybe all that isn't even necessary, storing the mouse coordinates in on_mouse_click and using player.Walk(storedx, storedy); right after disabling/enabling the walkable areas could suffice.

Radiant

You might try using characters rather than objects.

Can the objects go at fixed places or anywhere? If the former, you can make the NPCs avoid those places regardless of whether an object is there.

For the PC, you can split the room in half and use walkable 1-16 in the left half as well as in the right half, thus giving you 32 walkable areas; make the left half of the room region#1 and the right half region#2, and if the player steps on region #1 set the walkables as appropriate for the left half of the room. And vice versa.

Vince Twelve

SSH: That doesn't sound very appetizing.  I'm fairly certain that I could, after more work than I'd like, create my own pathfinding algorithm, but I'm not sure how I would be able to implement it so that the character followed that path.  Seems like more work than I'd like for such a small game.  But I'll keep it in mind.  Unless you have some more tips in that direction.

KhrisMUC: I'm not entirely sure I understand your suggestion.  I get the region thing, but the problem is that turning the regions off before clicking could potentially strand the player, since he might be standing on a region which has the number as the one being turned off.  And if you turn the regions off after clicking, the character can walk straight into a region that will be turned off after the click, again stranding the player.

Maybe I'm not fully understanding your solution.  Could you clarify?

Radiant:  I have made them characters, sorry for the confusion.  I mentioned it in my first post, but continued calling them objects (so as not to confuse them with the playable characters).  However, the default way that AGS handles characters in terms of removing a walkable area around their base is insufficient.

Also, as noted above, their are several fixed places (36 of them) where the objects can be placed.  And to clarify, there are six playable characters that can all walk around the whole scrolling room.  I just want them to not be able to walk close to one of the objects.

Splitting the room in half and using every walkable area (some for two and some for three different possible locations since I need 36 all-in-all) still creates the problem that a player may be standing on a walkable area that has the same number as the walkable area surrounding one of the objects that needs to be removed.  This would strand the player before he even started walking.

SSH

Can't you just never let them walk where an object might ever be? I guess perhaps your "holes" int he walkable are too big for that... also, don't forget PlaceOnWalkableArea or whatever its called. Just check if your characters have somehow ever ended off the areas, then get them to move on to one, before processing any walk-click. Also, you could split the screen into geographical areas:

0123
4567
89AB
CDEF


Then, if your guy walks from 0 to 3, you turn off the appropriate potential object walkables in areas   0,1,2 and 3. If he goes from 2 to B, you turn off 2,3,6,7,A,B as appropriate.  All before doing the ProcessClick.

Actually, you'd need 17 for the example I gave, as you'd always leave one on, but that can be fudged...

A route finder would be easy if all your "obstacles" in the walkable area are convex, i.e. no dead ends, just things to avoid. And also if when you click somewhere, you just want the player to go next to that object/space, not necessarily to exactly where you click: The algorithm could be something like:

1. Determine which direction I am going... NE, SW, etc.
2. Head N or S as appropriate until I reach my final y coord, or hit an obstacle
3. Now try moving E/W as appropriate towards the goal, until reach x or hit obstacle.
4. If I cannot reach close enough to goal by repeating 2 & 3, back-up by size of largest obstacle and try again.
5. Repeat 4 until tried backing up twice and failed.

You could make the change of region also stop and restart the character's walk. You'd obviously need to keep a note of where he was going to start with.

12

SMF spam blocked by CleanTalk