#============================================================================== # ▼ NPC Patrol # -- Last Updated: 2012.09.14 # -- Level: Nothing # -- Requires: n/a # -- Collaboration: Yami, Archeia_Nessiah #============================================================================== $imported = {} if $imported.nil? $imported["YN-NPCPATROL"] = true #============================================================================== # ▼ Updates # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # 2012.12.18 - Started and Finished Script. # #============================================================================== # ▼ Introduction # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # This is a script that returns an old, but useful, function of RPG Maker 2003. # You can set events to keep moving to an area back and forth until they hit a # a block. Very useful for Soldier NPCs that loves patrolling. # #============================================================================== # ▼ Instructions # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # Add the following through Event Control -> Comment on the desired event you # want to patrol. # # To move horizontally: <patrol hor> # To move vertically: <patrol ver> # # To install this script, open up your script editor and copy/paste this script # to an open slot below ▼ Materials but above ▼ Main. Remember to save. # #============================================================================== # ▼ Compatibility # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that # it will run with RPG Maker VX without adjusting. #============================================================================== class Game_Event < Game_Character def note begin data = [] @page.list.each do |item| next unless item && (item.code == 108 || item.code == 408) data.push(item.parameters[0]) end return data rescue return [] end end def patrol_hor?; note.include?("<patrol hor>"); end def patrol_ver?; note.include?("<patrol ver>"); end alias yami_patrol_event_update_self_movement update_self_movement def update_self_movement yami_patrol_event_update_self_movement if @stop_count > stop_count_threshold if patrol_hor? set_direction([6,4].sample) unless [6,4].include?(@direction) set_direction(4) if @direction == 6 && !passable?(@x, @y, 6) set_direction(6) if @direction == 4 && !passable?(@x, @y, 4) move_forward return end #--- if patrol_ver? set_direction([8,2].sample) unless [8,2].include?(@direction) set_direction(2) if @direction == 8 && !passable?(@x, @y, 8) set_direction(8) if @direction == 2 && !passable?(@x, @y, 2) move_forward return end end end end