Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Darian

1
Yes that makes sense to me, that could be the reason!
Would be cool if you could have a look :)
Thank you!
2
I found something! :)
With cases it seems to work:

class Cycle
 
  def initialize
    @s = Proc.new { print 'Waypoint Reached!'}
    @f = Proc.new { print 'Failed!  ' }
    @range = 0
    @phase = 1
  end
 
  def update

    case @phase
   
    when 1
      Pathfind.new(Node.new(2, 3), 1, @range, @s, @f)
      @phase = 2
     
    when 2 
      Pathfind.new(Node.new(3, 6), 1, @range, @s, @f)
      @phase = 3
     
    when 3
      Pathfind.new(Node.new(4, 10), 1, @range, @s, @f)
      @phase = 4
    end
   
  end

end

Now it works. But strangely, though it's phase = 4 at the end the character keeps still walking between the last two waypoints. Could you explain this? That's strange...
3
Yes, I had the same experience. The third pathfinding order doesn't work. I tried several variants with switches, but it doesn't help either.

It would be great if you could try something with your more advanced scripting skills :)
Thank you!
4
Ok for better explaining I modified your script game example and uploaded it here:
http://www.filedropper.com/advancedpathfindingdarian

Here's the script:

class Cycle
 
  def initialize
    @s = Proc.new { print 'Waypoint Reached!'}
    @f = Proc.new { print 'Failed!  ' }
    @range = 0
    @first_switch = "on"
  end
 
  def update
   
    if @first_switch == "on"
      p "phase for the first two waypoints"
      Pathfind.new(Node.new(2, 3), 1, @range, @s, @f)
      Pathfind.new(Node.new(3, 6), 1, @range, Proc.new { @second_switch = "on" }, @f)
      @first_switch = "off"
      #@second_switch = "on" # WHEN activating this line, the third waypoint works.
    end
   
    if @second_switch == "on"
      p "phase for the third waypoint"
      Pathfind.new(Node.new(4, 10), 1, @range, @s, @f)
      @second_switch = "off"
    end
   
  end

end


I've implented the Cycle in the Scene_Map (and update Methode there).
There are 3 waypoints on the map: These three little sand spots which will be visited from north to south.
The third waypoint won't be reached. It will only work when I set the switch manually in line 17 (removing the comment).
Why is this? :)

Thank you very much for your time!!
5
I'm now trying "to do waypoints" with your script.

Example: I simply put two commands in two lines like this:

Pathfind.new(Node.new(Mouse.tile_x, Mouse.tile_y), @char_id)
Pathfind.new(Node.new(Mouse.tile_x, Mouse.tile_y+6), @char_id)

So it works well, the character goes first to the tile where the mouse is and then 6 tiles more south.

But when executing the same piece of code later again in my script, the character just doesn't move. I can't explain this - what is wrong?

EDIT: Moreover is there perhaps another way to do waypoints with your scripts?
6
Great, Thank you!! I'll try it out :)
7
Thanks again for the fast reply!
I fully understand your situation.
Okay, so before I will start scripting or ask someone else do you - or someone else here - know another pathfinding script which supports 8 directional movement?

Foreverzer0, could you please just tell me how I can add the option for the success argument here (when calling it not via an event):
#Pathfind.new(Node.new(x, y), *args)
Pathfind.new(Node.new(8, 6), 13)


That would help me a bit :)

EDIT: I got it!! :)
			s = Proc.new { print 'Goal Reached!'}
f = Proc.new { print 'Failed!' }
#pathfind(x, y, id, range, s, f)
Pathfind.new(Node.new(Mouse.tile_x, Mouse.tile_y), 13, 0, s, f)

Nevertheless a pathfinding system with 8 movement would be cool. If anyone knows something where to find it, please let me know.

8
Thank you! I think I found it.
And it works :)

#Pathfind.new(Node.new(x, y), *args)
Pathfind.new(Node.new(8, 6), 13)


Two questions:
1) How can implement the success and fail argument there?
2) Following situation:
Legend:
O = free tile
S = starting point
E = end point
P = walked path

OOS
OOO
EOO


So when executing this situation, then the path is the following:
OOS
OOP
EPP

So the event goes straight down and then left. I would like to see rather a diagonal pattern:

OOS
OPO
EOO


How can I enable this? I would like to have the most direct way, especially when walking short distances. It seems to be that the algorithm doesn't include diagonal movement? How can I implement this :)

Thanks for your quick help!




9
Great script!
It works perfectly for me in an event and when using it via "call script" in the RMXP.
I'm new to the RGSS and I'm currently writing one of my first own scripts (a battle system).

So I would like to use this cool Pathfinding script there, but I don't know how to include it.
For my own script I've a class containing an initialize-methode and an update-methode. But where and how do I have to include this Pathfinding script? (I've of course pasted it above MAIN and as said before it works perfectly inside an event calling it.)

Could you please give me the lines so I can use the
pathfind(x, y, id, range, s, f)

like in an event?

Thank you! :)