Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials
Reload this Page [Essentials script] Better Random Move Routes for NPCs

Notices
For all updates, view the main page.

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.



Reply
 
Thread Tools
  #1    
Old October 2nd, 2014 (08:31 AM). Edited October 2nd, 2014 by mej71.
mej71's Avatar
mej71 mej71 is offline
 
Join Date: Mar 2014
Location: Omnipresence
Gender: Male
Posts: 715
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).
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 11:23 PM.