Finding Existing Script: Fix for Event Random Movement

Kest

The Ecstasy of Gold
Veteran
Joined
Dec 4, 2014
Messages
148
Reaction score
24
First Language
English
I'm looking for a script that someone already made, but don't remember its name or the author.

This script fixes random movement for events, so those events don't waste movement turns butting their heads against walls and other impassable tiles. I was checking major sites like Yanfly, Hime, Galv, Yami, etc. but I just cannot find it! Is anyone here familiar with this?
 
Last edited by a moderator:

Funplayer

Self proclaimed sponge.
Veteran
Joined
Oct 9, 2013
Messages
120
Reaction score
35
First Language
English
Primarily Uses
I wrote some code that will fix your problem.

Paste below materials above main in your scripting list.

class Game_Character #-------------------------------------------------------------------------- # * Move at Random #-------------------------------------------------------------------------- def move_random # This is important, in case the random movement breaks the game stack. @fun_random_recursion_count = 0 if @fun_random_recursion_count.nil? @fun_random_recursion_count += 1 d = 2 + rand(4) * 2 @move_succeed = passable?(@x, @y, d) if @move_succeed set_direction(d) @x = $game_map.round_x_with_direction(@x, d) @y = $game_map.round_y_with_direction(@y, d) @real_x = $game_map.x_with_direction(@x, reverse_dir(d)) @real_y = $game_map.y_with_direction(@y, reverse_dir(d)) increase_steps elsif @fun_random_recursion_count < 10 move_random end @fun_random_recursion_count -= 1 if @fun_random_recursion_count > 0 endend This isn't perfect by any means, but its actually better than the current one for moving randomly if you don't want to break your random moving path.  

Random movement involves telling it to move straight, in a random direction.  It does not take a direction, it just does things.

If you tell an npc to "move random" in the npc dialog, you sometimes end up with an npc STILL walking straight into walls over and over, because the code is tied to a "move forward" call in random intervals as well.  I can however fix this as well, because the "Game_Event" class also contains a series of directional movement controllers, a hierarchy to dictate default movements you configure using the game making software.

Code:
  # Replace Thisclass Game_Event < Game_Character  #--------------------------------------------------------------------------  # * Move Type : Random  #--------------------------------------------------------------------------  def move_type_random    case rand(6)    when 0..1;  move_random    when 2..4;  move_forward    when 5;     @stop_count = 0    end  endend# With This if you want the "forward" directional movement to stop.class Game_Event < Game_Character  #--------------------------------------------------------------------------  # * Move Type : Random  #--------------------------------------------------------------------------  def move_type_random    case rand(6)    when 0..4;  move_random    when 5;     @stop_count = 0    end  endend
 
Last edited by a moderator:

Kest

The Ecstasy of Gold
Veteran
Joined
Dec 4, 2014
Messages
148
Reaction score
24
First Language
English
Thanks, I wasn't expecting someone to go through that much trouble.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top