Mouse script that's more than 1 tile at a time

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Can anyone point me in the direction of a mouse script whereby you click a spot and the character moves all the way there?

Vlue's mouse system only moves one tile at a time.

Jet's may do this but it's not compatible with Yanfly's Save Engine, so I have never been able to check it out.

I know that such a mouse script exists for XP (Amaranth and Aldorlea), but there only seem to be just the 2 above in the Ace Master Script List.

Thanks
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Falcao's script might something for you to look at, but I read somewhere that he has other problems with eventing.


Basically pathfinding is one of the more complex functions in any game - that's the reason why most scripts don't have pathfinding utilities included, but are single-step only.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Oh dear.  That's a shame.  Thanks for the info.

I'll leave the thread open for a bit in case anyone has any other ideas.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've converted our XP script to Ace, but it would take a bit of work to pull it out into it's own script (it's merged with the RTP scripts). Also, I couldn't guarantee it'd work with Yanfly's Save Engine either.


When I get time (*sigh*) I will provide the script. That means it won't happen anytime soon, so you should keep looking.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
That would be really kind of you if you could do that.  I'll keep looking as well.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
Optimal path finding is complex in terms of cpu time. Getting it to run fast enough on XP is not easy. Conceptually there are some fairly simple algorithms.

The pathfinding in Aldorlea assumes you want to go in the direction of the mouse click rather than going specifically to that tile. This is an easier problem to solve and my algorithm is much faster as it never calculates more than one move into the future.

It is an option you can consider.

*hugs*
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Zeriab

So you have a script that will work in Ace?  If so, I would have thought that this would be fine for what I have in mind.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I believe Zeriab wrote the mouse script for Aldorlea, which is why he knows so much about its behaviour. (And if that's the case, it also goes one tile at a time).
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
1,970
Reaction score
846
First Language
French
No no no definitely not one tile at a time, it would be a nightmare lol especially since I don't exactly come up with small areas in general. :)
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
The one for Aldorlea is for XP, which is why I asked Zeriab if the one he referred to was for Ace
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Ah, of course. My mistake - I misread Zeriab's post. Sorry.


I'm working on getting our XP -> Ace converted script out into its own files. Give me a couple of days. But keep looking in the meantime - I've seen at least three other Ace mouse scripts, I think.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I'm working on getting our XP -> Ace converted script out into its own files. Give me a couple of days.
That would be brilliant if you could.  I shall keep looking in the meantime.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
I referred to the XP script I wrote specifically for Aldorlea. The script structure for the menus is fundamentally different from other mouse scripts I've seen. IMO it gives a higher degree of control at the cost of specific implementations required for each scene. Add a new scene? Until you add mouse functionality, you cannot interact with it.
The only thing I have for Ace is a partly converted mouse script of my XP implementation. These two are without my map pathfinding so you can't really use them for that >_>
Modern Algebra has made a pathfinding script for VX (>:D) which he also ported to Ace I think. You can try searching for that or see if any Ace mouse system use it.

@shaz:
I store the position of the tile clicked on (goal tile), then whenever the character can move (arrow keys) it calculates one move ahead, not more. A purely greedy system which keeps doing it until it hits an obstruction or the player tries to move with the keyboard. You can see pretty much the entire algorithm in the spoiler.

Code:
  ##  # Retrieve next pathfinding move  #  def pathfind_next_move    # Find possible moves    possible_moves = []    possible_moves << 4 if @goto_x < @x && passable?(@x, @y, 4)    possible_moves << 6 if @goto_x > @x && passable?(@x, @y, 6)    possible_moves << 8 if @goto_y < @y && passable?(@x, @y, 8)    possible_moves << 2 if @goto_y > @y && passable?(@x, @y, 2)    if possible_moves.empty?      # No possible moves => pathfinding finished      @pathfinding = false      if (@goto_x - @x).abs + (@goto_y - @y).abs <= 0        # At destination        check_event_trigger_here([0])      else        # The destination may be right next to us so try to face and trigger it        # if possible.        possible_moves << 4 if @goto_x < @x        possible_moves << 6 if @goto_x > @x        possible_moves << 8 if @goto_y < @y        possible_moves << 2 if @goto_y > @y        unless possible_moves.include?(direction)          # Try to turn towards the goal          turn = possible_moves[rand(possible_moves.size)]          change_direction(turn)        end        # Calculate next tile        new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)        new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)        # Actions are prolonged one tile when facing counters        dist = $game_map.counter?(new_x, new_y) ? 2 : 1        if (@goto_x - @x).abs + (@goto_y - @y).abs <= dist          # Check action and contact triggers.          # Note the case where this could case a faulty trigger cannot occur          # due to the map design.          check_event_trigger_there([0,1,2])        else          # Only check contact trigger (event + player)          check_event_trigger_there([1,2])        end      end    else      # Choose a possible move at random      move = possible_moves[rand(possible_moves.size)]      pathfinding_move(move)    end  end
*hugs*
 - Zeriab
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Is it basically the same as algorithm used in the "approach" move routes? Where you might end up walking back and forth if you just happen to be standing behind a fairly large obstacle that spans a few tiles across.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That's interesting - so instead of pathfinding, which might take you BACKWARDS to go around a large obstacle to reach a target on the other side, your script would take you TOWARDS the obstacle and stop when you hit it?


The pathfinding in our script (originally done by Near Fantastica and SephirothSpawn) is easy for me to follow, though I've seen a couple of scripts that look like they're less involved, but I have trouble understanding them. I haven't encountered any lagging in Ace like we used to have in early versions of the XP script, as I've added a Graphics.update every now and then, and Ace runs at a higher frame rate.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
@Tsu:

Nope, it is different, you'll only walk forwards. "Approach" may at any time cause a move to occur in a different direction.

@Shaz:

Yup, A hit occurs if you cannot process further towards the goal. I.e. if you have to do a lot of move_up and move_left to reach a goal then being blocked only on move_up it will move_left.

I guess it's worth noting that when I made the algorithm going BACKWARDS could have been a huge deal.

We had monsters (events) which approached the player. If player suddenly changed direction on a miss-click you could get caught.

*hugs*
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Great.

thank you so much for this.  Much appreciated.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

If you have issues with the script, post in the script's thread.  If you find it doesn't do what you want, report this post and ask for the thread to be reopened.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top