• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Better Random Move Routes for NPCs

1,224
Posts
10
Years
  • Moves the desired NPC in a (seemingly) more natural move route. Moves in a random direction still, but continues that path for a random number between 1 and 4.

    Basically, just add this in a new section

    Code:
    def pbBetterRandom(eventid)
      character = get_character(eventid)
        # If no character exists
        if character == nil
          # Continue
          return true
        end
        $game_player.update
        $game_screen.update
        numToMove=rand(5)
        direction=rand(4)+1
        directionpass=direction*2
        if numToMove>0
          numToMove.times do
            character.through=false
            if character.passable?(character.x,character.y,directionpass)
              pbMoveRoute(character,[direction])
            end
          end 
        end
    end

    Make you event look like this one. Should be parallel process, the "23" should coordinate to your desired event, and have a Wait X frames command before that. The wait command makes sure the event doesn't move overly fast.

    Can be called for a different event than it's placed on (for instance, I could keep my example event but change the 23 to 22, and event 22 would move instead).
     
    Last edited:
    Back
    Top