[XP] Lagless Path Finder

Started by Blizzard, February 09, 2013, 09:22:06 am

Previous topic - Next topic

finalholylight

Yes, you're right, it gets stuck when move to location next to the stair, I can not move after that.

Blizzard

Alright, then it's most probably what KK20 mentioned. I'll fix it later today, it's a quick fix.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

finalholylight

Ow, Blizzard, you forgot fixing the script ~.~

Blizzard

April 10, 2013, 02:00:27 pm #23 Last Edit: April 11, 2013, 10:37:03 am by Blizzard
When I saw this in the list of unread topics, I totally realized that. I can't remember why this topic wasn't in an open tab anymore so I remember to fix this. I'll do it tomorrow when I get home from work.

EDIT: Fixed.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Terv

July 14, 2013, 10:47:40 am #24 Last Edit: July 14, 2013, 11:39:20 am by Terv
Any chance you'll add a success/failure proc so you can give the event further intructions if it has reached its destination or split a path up in several waypoints, like in F0's script? Looks kind of wierd if NPCs in a city wall-hug all the time instead of using the sidewalk :^_^':
Also they would be able to sideline vexatious heroes blocking their path.

Of course this could be done by constantly checking x/y or if the event is still moving, but I guess that'd be rather performance heavy to do for 3+ events, especially if fps is a precious resource.

Blizzard

July 14, 2013, 01:33:37 pm #25 Last Edit: July 14, 2013, 01:46:47 pm by Blizzard
I didn't like F0's implementation, especially since it was bound to scripting and not events. Use this in a parallel process instead:

Code: from the instructions
#   In order to check if a character has a dynamic path calculation for a
#   target, use following script call:
#  
#     character.has_path_target?
#  
#   Example:
#    
#     if $game_map.events[23].has_path_target?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Terv

July 14, 2013, 04:47:45 pm #26 Last Edit: July 14, 2013, 05:25:09 pm by Terv
Is it possible to determine whether a character has a non-dynamic calculation as well? I.e. hasn't made it to the destination yet.

Blizzard

You could use this:

character.moving?


But there is no distinction between a character moving by normal events and through the path finder.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Terv

July 14, 2013, 06:26:58 pm #28 Last Edit: July 14, 2013, 07:16:03 pm by Terv
Yup I decided to use moving? combined with a range check to be sure it's not the player or another NPC causing the character not to move anymore. Thanks for your time :up:

Edit: Could you explain what exactly clear_path_target does? Is it supposed to stop a character while pathfinding, or just stop updating the target coords?

Blizzard

July 15, 2013, 02:39:18 am #29 Last Edit: July 15, 2013, 02:40:23 am by Blizzard
I forgot. I'll go check. xD

EDIT: It will abort the path finding and moving completely.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Terv

I've found this command to stop pathfinding, however the event will still finish its way to the last coordinates. In order to stop movement too you have to use an empty Set Move Route event command (just in case someone else stumbles upon this).

phionabrie

Is there a way to call this script from inside another script instead of from an event?  I'd love to add it to the custom controls to allow for movement by mouse, but I'm not sure how to set it up.

Blizzard

Yes, you can simply use the same script calls from the instructions within another script.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

phionabrie

I tried adding this script call at the end of  the updates module of the custom commands area in "Tons of Add-ons":
  if @game_map = true
     if key == 'Mouse Left'
     PathFinder.dyn_request(0, x, y)
     end
  end

When I try to play test I get an error message: Script 'Path Finder' line 422:SystemStackError occurred.  stack level too deep

Am I just completely wrong in how to do the script call or is there something else I have to change as well?

Blizzard

Use either of these two:

if @game_map

if @game_map == true
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

phionabrie

Tried it both ways, still got the error, then realized I had two copies of the path finder installed.... *reminds self not to do scripting at 3am*

Still can't get the pathfinder to work with the mouse, but no error message, so not sure how to fix it.  Would the script order matter?  Or where exactly in the custom commands script I added the script call?  If you have any pointers I'd appreciate it.

Blizzard

The mouse enhancement for this script should definitely be under it. You could use my Mouse Controller script in conjunction with the $game_map.display_x and $game_map.display.y variables and the click position to get some sort of mouse-to-map translation and then (after some more calculation) you can pass the coordinates to the path finder.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

phionabrie

Appears what I'm trying to do is too far above my scripting ability.  Thanks for trying to help.

Terv

July 27, 2013, 08:16:12 pm #38 Last Edit: July 28, 2013, 11:12:05 am by Terv
Found them bugs:


  • dynamic calls behave oddly. I made sure I'm calling them only once. dyn_request: the pathfinding event is swaying like after a dozen glasses Scotch as soon as there's an obstacle to be circumvented. dyn_find: way to target is fine but the event doesn't stop there (range 1) but keeps circling around it (this is also true for dyn_request).



Call used: PathFinder._____(@event_id, $game_player, 1)

A screen from a new map in your demo (dyn_request):
Spoiler: ShowHide


Lagless Path Finder Bugs.zip

Blizzard

July 28, 2013, 03:40:25 am #39 Last Edit: July 29, 2013, 04:08:51 pm by Blizzard
I'll take a look at it. But keep in mind that the moving is used as movement route so naturally when you change the page, it's gone.

EDIT: Fixed it. Nvm about the page changing, the character should still continue on its path because either way with dyn_request the path is recalculated after every step.

EDIT: Actually wait, dyn_find seems broken.

EDIT: Alright, I fixed it all. One of the problems was caused by the recent "fix" due to passability, but now it doesn't work in the opposite scenario when you want to get closer to a non-passable position so I have included an optional parameter after RANGE to determine whether the next neighbor has to be passable or not when using RANGE.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.