finding the character's destination

Started by chucklas, Thu 07/02/2013 03:30:08

Previous topic - Next topic

chucklas

I can't seem to be able to find this anywhere, but while a character is walking from one place to another (and it is not blocking)is it possible to know exactly what the final destination coordinates of the character are?

Slasher

The coordinates of a player, normally, are taken from the center of its feet.

If you want to check players x y you can use this code.

Hover mouse over player when it has stopped moving, this will Display the players x y position.
Code: AGS

function room_RepExec()
{
 if (Character.GetAtScreenXY(mouse.x, mouse.y) == player) 
{
  Display("The player is at %d,%d.", player.x, player.y);
}
}





chucklas

Thanks for the idea, but that isn't what I was asking about.  Let me clarify.  If I click at a certain location and my character begins walking toward that location and encounters different terrain along the way, the walking view changes.  When the view changes, the character stops walking.  I would like for the character to not stop walking, instead to change view and then proceed to the intended destination.  I cannot find a way to know the destination (not the current location).  I hope that is clear.

Billbis

You can store mouse.x and mouse.y when player clic. When view changes, you process another clic on the stored coordinates.

chucklas

Quote from: Billbis on Thu 07/02/2013 13:03:47
You can store mouse.x and mouse.y when player clic. When view changes, you process another clic on the stored coordinates.

Yeah, this seems to be the best solution that I have come up with.  I was hoping it that there was a way to see the stored value.  While a character is walking, all of the waypoints that are generated have to be stored somewhere...feature perhaps?  :)

Khris

The built-in walking is a pretty closed system unfortunately.

Another idea, although it's quite convoluted: you could dynamically alter all the viewframes in the player's walking view. That way the player won't stop, then resume walking.

chucklas

HAHA.  Nice Khris.  I would have never thought of that.  This is perhaps the best way for me to handle this.  It will require a lot of work up front, but I think it will look the best for my purposes. 

I have seen that it is a closed system, I think it is unfortunate that we can't have that single coordinate though.  I imagine it would come in handy for a lot of things people want to do.  I don't need all the waypoints...etc.  Anyway, thanks for the idea.

Crimson Wizard

#7
Quote from: chucklas on Thu 07/02/2013 13:07:38
I was hoping it that there was a way to see the stored value.  While a character is walking, all of the waypoints that are generated have to be stored somewhere...feature perhaps?  :)
This information will be erased anyway as soon as character stops, as in your case, so you would not be able to use it, I think.
Anyway, I added the note for future, just in case: http://www.adventuregamestudio.co.uk/forums/index.php?issue=374.0

In your case this see to be rather a problem of making smooth transition between automatic view changes.
E: well, Khris gave some idea already.
BTW, I don't know why this is made in such a way that character stops if new walkable area requires him to change a view. :-/

chucklas

I can take note of the coordinates right before the view switches to not lose them. 

If there is a way to not have him stop when the view switches, I am open to that too. 

Specifically, this is what I am doing:

I am reserving a walkable area (in this case 15) for all rooms for a certain terrain (I might use 14 later for another...etc.).  I will always use this number area in every room in the game when this type of terrain is used.  Then, in my global script I check the current walkable area (based on the character's x/y coordinates).  If it is number 15, I switch the view.  If they are in that view and not on walkable are 15, I change it back to the normal walking view.  Each time the view changes, the character stops walking. 

Is there a way to switch the view without the character stopping?  That would also solve my problem.

Khris

That's the thing, there isn't.
The reason for this is probably that the new view might have a different number of frames in its loops, so switching it mid-walk could result in AGS trying to display a non-existant frame.

I coded analog controls once and made the character switch to the run view and back mid-movement by calculating the respective frame number. It's quite trivial to implement actually.

As for your current problem, I'd add code to on_mouse_click that checks for mouse.Mode being eModeWalkto and stores the click coords in two variables.
When the character enters or leaves the view, after their NormalView was changed, they get sent to those coordinates to make them resume their path.

It isn't going to look nice, but it'll work until you implement the dynamic sprite stuff.

chucklas

I agree Khris.  For what I am doing, the dyanmic sprite stuff is perfect as it will be seamless.  Even if I could have the destination coordinates as I hoped, it would still look choppy as the character stops and starts again.  Thanks for the help.  Consider this one worked out.  :)  Thanks again!

SMF spam blocked by CleanTalk