Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Heretic86 on April 29, 2015, 08:02:29 pm

Title: [XP] Heretic's NPCs on Event Tiles
Post by: Heretic86 on April 29, 2015, 08:02:29 pm
NPCs on Event Tiles XP
Authors: Heretic
Version: 1.0
Type: Custom Movement System
Key Term: Custom Movement System



Introduction

This script will allow NPC Events to move on Event Tiles the same way as the Player can!  You can fully control which NPCs move on which Event Tiles.  Events can now also be allowed through other Events without being allowed through Impassable Map Tiles.


Features




Screenshots

Spoiler: ShowHide
(http://downloads.chaos-project.com/heretic86/images/NPCSonEventTiles.jpg)

The Cat in this image is moving on Clouds made from Events!  It is also properly constrained by the Tiles of those Cloud Event Tiles.



Demo

http://downloads.chaos-project.com/heretic86/MP/ModularPassable.exe

NOTE: This Demo contains many Modular Passable scripts.


Script

Place below Modular Passable  (http://forum.chaos-project.com/index.php/topic,14986.0.html) (Required)
Place below Collision Optimizer (Optional)
Place below Loop Maps (Optional)

Spoiler: ShowHide
#===============================================================================
#
#           HERETIC'S NPCS ON EVENT TILES [XP]
#           Version 1.0
#           Tuesday, October 21st, 2014
#
#===============================================================================
#
# ---  Requirements and Installation  ---
#
# *** REQUIRES HERETICS MODULAR PASSABLE SCRIPT ***
#
# This script should be placed below Heretics Modular Passable.
# Heretics Modular Passable should be placed just below the real SDK
# It should work fine as long as it is between Modular Passable and Main.
# Place below Heretics Caterpillar 2.0+ if you use it.
#
# Definition: NPC - Non Player Character.  Any Event with a Character Graphic.
#
#
# ---  Features  ---
#
# - Allows NPC movement on Event Tiles with proper movement restrictions
# - Has Options for FLAT so that Small Characters do not Glitch on Event Tiles
# - Customizable AUTO Features with two Options to do a lot of work for you
# - Force Z-Index PER PAGE to fix Event Tile "Glitches" with small Characters
#
#
# ---  Summary  ----
#
# The features made available to you by this script provides you with an
# exceptionally high degree of control over where specific characters can
# and can not go.
#
# This script will allow NPCs to move on Events with graphics from the Tileset
# like the Player would.  Normally, NPCs are NOT allowed to move around on
# any other Event unless one of them is Through.  This script will allow NPCs
# to move on those Events with Terrain Graphics and get their Passage settings
# from the Tile that the Event uses, not from the Event itself.
#
# This allows you to create Dynamic Enviornments, and ensure the movement and
# passages work as expected.  If you create a Bridge out of Events, your NPCs
# will be able to move around on that Bridge just like the Player.  If the
# Player can't walk off of the side of a Bridge, then your NPCs, although
# being able to move on the Tile Event, wont be able to walk off the side
# of the Event Bridge either, but will be able to move on your Event Bridge
# just like the Player can.
#
# This script eliminates the need for using Through on Events in Dynamic
# Enviornments.  Through can cause as many problems as it solves.  By enabling
# Through on an Event, the Player will either no longer be able to move as
# expected, or would be able to walk through your NPCs.  That is what this
# script fixes and allows you to do.
#
#
# ---  Configurations  ---
#
# You can FORCE any Character to have a specified behavior by using Comments!
#
# The Comment needs to be in the first 10 Lines on EACH PAGE you want to
# force a behavior on.  The 10 Line Limit is controlled in the required
# Modular Passable Script under COMMENT_LIMIT, not in this script.
#
# @>Comment: \some_option
#
# Comment Configurations must use the FIRST LINE of a Comment.  Additional
# lines are not checked.  Each Comment Line and Script Line will count against
# the COMMENT_LIMIT of 10 (by Default).
#
# The PER PAGE feature allows you to specify different behaviors on each
# page of an Event.  It is the same as Page 1 having X graphic and Through, but
# Page 2 has a different graphic and different Through settings.  Trust me, it
# saves you a LOT of work by not requiring everything to be made with scripts.
#
#
#
# -----  Event Tile Comment Config  -----
#
# - Apply these Comments to Events with Tile Graphics (Event Tiles)
#
# \allow_npc - Allows Events with Tile Graphics (Event Tiles) to have NPCs
#              move about on them.  Passage is set by the Tile Passages.
# \deny_npc  - Will prevent NPCs from trying to move about on them, regardless
#              of passage settings, unless Through is turned on.  
#              Use with Auto Options to prevent Auto Allow
# \flat      - Will force any Event to render as FLAT on the ground which
#              prevents Glitches from smaller characters
# \no_flat   - Prevents specified Event Tiles from Automatically being set
#              to Flat, under the OPTIONS CONFIG, which is useful for Events
#              with Non Priority Tiles on top of Priority Map Tiles, as
#              those Priority Map Tiles will display above the Event
#
# NOTE: Other Scripts can overide \allow_npc and \deny_npc if those Scripts
#       determine Passage based on Terrain Tags, and those Terrain Tags are
#       excluded in HNOET_EXCLUDE_TAGS or hnoet_extra_no_pass_conditions?
#       is aliased by another Script for other reasons to Exclude an
#       Event from being allowed passage, however that solution may create
#       a dependancy on this script.
#
#
#
# -----  NPC Comment Config  -----
#
# - Apply these Comments to NPCs, a.k.a. Events with Characters
#
# \no_event_tiles - Prevents NPCs with this Comment from moving on Events
#                   that normally allow NPC movement on them
#
# NOTE: \flat can also be used for NPCs also.  NPCs shouldnt need to use
#       the \no_flat Comment as they are not checked by Auto.  It might
#       be useful to give a Dead NPC a \flat comment if you want your
#       players to walk on top of those NPCs.
#
#
# -----  Forced Z-Index (\force_z[int])  -----
#
# - Forced Z-Index will ignore height and not add 32 to every Event's Z-Index
#   which is what causes the "Glitch".  This will not make Event Tiles display
#   as Flat.  It is most useful on Characters that "Glitch" because they
#   are too small, but can be used anywhere.  It is unaffected by AUTO settings.
#
#   I recommend using multiples of 32 for proper rendering.  Since 32 will
#   not fix the "Glitch", add an additional 32 to the Z-Index so the total
#   for Events with Character Graphics that are 32 pixels high or smaller
#   will come out to 64.  Of course, you can modify as needed for Event
#   Stacking or any other needs you have.  The recommendation is a base
#   upon which to build off of for fixing the "Glitch".
#   Standard height is 63, or height of 32 + 31.
#
#   If Enterbrain wanted to fix this, they should have changed this:
#   - return z + ((height > 32) ? 31 : 0)
#
#   to this for Small Characters to display properly on Event Tiles in their
#   Screen Z method:
#   - return z + 31
#
#   Example of a Non Glitchy Small Character:
#   @>Comment:\force_z[64] - Displays in front of a Standard Player
#   @>Comment:\force_z[63] - Displays behind Player but in front of Cat Actors
#
#   The Forced Z-Index Fix offered by this script allows you a much higher
#   degree of control instead of the proposed fix above.  This allows you
#   to position any Event exactly where you want in Z-Space, except below
#   the terrain without a very very negative number.
#
# NOTE: Although this can be applied to Event Tiles, I don't recommend it
#       unless you fully understand Screen Z.  Forcing Z-Indexes will also
#       compeltely ignore any Tile Priorities that an Event Tile may hold
#       so you will have to compensate for this if you use Priority Tiles
#       and force the containing Events Z-Index.  Of course this is also
#       what offers a very high degree of control, and this is its price.
#
#
# ---  Script Calls  ---
#
# These commands are all Event Commands.  They can be called in a Move Route
# or by going through the $game_map.events[event_id].command way.
#
# flat       - Forces this Event to render as Flat
# no_flat    - Prevents this Event from being made Flat by Auto.  Removes Flat
# clear_flat - Allows the script to handle Flat properties normally
# allow_npc  - Makes Events with Tiles to allow Event Characters to pass
# deny_npc   - Prohibits Event Tiles from having NPCs move about on them
# clear_npc  - Allows the script to handle these according to Auto settings
#
# Example: $game_map.events[21].allow_npc
#
# no_event_tiles - Prevents this NPC from moving around on Events with Tiles
#                  that have been allowed passage by this script.
#
# Example: $game_map.events[51].no_event_tiles = true
#
#
# NOTE: These Commands can not be performed on the Player.
#
# NOTE: When called from Set Move Route -> Script, you may need to use
#       self.property = value as property = value only creates a local
#       variable and fails to call the referenced method.  This applies
#       to self.flat=, self.no_flat=, self.allow_npc=, and self.deny_npc=
#
#
#
# ---  Mapping  ----
#
# There are two ways you can use this script.  You can use a Positive or
# a Negative approach.  A Positive approach would be to only allow specific
# tiles to have NPCs move about on them.  A Negative approach would do the
# opposite and start by allowing all NPCs on all Event Tiles, then to deny
# only specific NPCs from movement.
#
# FLAT: One of the reasons I think Enterbrain decided not to let NPCs run
# around on Event Tiles was due to a Glitch.  The Glitch does not happen
# with characters 32 pixels high or taller, but does happen on smaller
# characters like cats and mice, etc.  When a Tile is set in the Map, it
# renders as Flat so that small and large characters can move about on them
# which looks correct.  When a Tile is handed to an Event and the Event has
# that Graphic, the Event makes that Tile "stand up", like a human would.
# This causes the small characters to Glitch when they try to move about
# on an Event with a Tile Graphic, and the reason FLAT and AUTO FLAT features
# were implemented.  If you want a small character like a mouse to move on
# an Event Tile, set that Event Tile as flat, or just let AUTO do it for you.
#
#
# ---  AUTO Features  ---
#
# The AUTO features will let the script do the work for you.  AUTO FLAT will
# check for any Tile Priorities, and only set FLAT to Events with Tiles that
# do not have any Priorities.  Priority Tiles are Tiles with the Stars that
# appear over events and create the Illusion of 3D enviornments.  Combining
# the AUTO features with the Positive / Negative Optional way of using this
# script is where the allow and deny features come from.  You can prevent
# Events with Tiles from automatically being set to flat by the script
# simply by using a \no_flat Comment.  Likewise, Event Tiles that have
# a \deny_npc Comment will not be autmatically configured by the script
# to allow NPC movements on them.  Basically, they allow you to override
# the automatic features.
#
# The AUTO_ALLOW_NPCS feature was created so the script will allow NPCs to
# move about on all Events with Tile Graphics, regardless of Priority.
#
# AUTO features are set as Constants because they should not be changed during
# the course of your game.  Making changes to these AUTO values will not be
# noticable immediately until you restart your game.  Hence the need to make
# these Constants and not a System Option for you.
#
#
#
# NOTE: NPCs are STILL not allowed to move through Events with NO GRAPHICS
#       unless one of the two Events has Through turned on.  I left this
#       as is intentionally as a means for you to have control over where
#       NPCs are allowed to go.  You can give an Event with NO GRAPHICS
#       an \allow_npc Comment, but this works exactly the same as setting
#       that Event with No Graphics as Through.
#
#
# ---  NPCs on Event Tiles Flat and Force Z ---
#
# If your short NPCs appearing underneath an Event with a Tile, there are TWO
# ways to fix this.  Make the Tile Event appear as Flat (Auto or Comment), or
# give the short NPC a Forced Z of 63 by using a \force_z[63] Comment.  By
# using a \force_z[63] Comment on the short NPC, it will be calculated as
# a Tall NPC and should also prevent the Glitch.
#
# NOTE: Short NPC's are defined as having a Graphic Height < 32 pixels.
#
#
# ---  Version History  ---
#
# Version 1.0 - Tuesday, October 21st, 2014 - Initial Release
#
#
# ---  Options  ---
#
# AUTO_FLAT_EVENT_TILES - This Option has 3 settings: 0, 1, and 2.  
# - 0: Disabled
#       * Event Tiles must have a \flat Comment to display as Flat
# - 1: Auto for \allow_npc Comment
#      * Recommended Setting
#      * Automatically makes Tile Events with a \allow_npc Comment to render
#        as Flat so that Character Graphics that are 32 pixels or smaller
#        do not Glitch as they move around on this Event Tile.
# - 2: Auto for ALL Event Tiles
#      * Recommended only for New Game Creations
#      * Any Event with a Tile where that Tile has a Priority of 0 will
#        be made to render as Flat, unless the Event has a \no_flat Comment
#        to prevent automatically making it render as Flat.
#
# AUTO_ALLOW_NPCS_ON_EVENT_TILES
# - TRUE:  Enabled
#     * Recommended only for New Game Creations and New Projects
#     * All Events are checked for Tile Graphics with a Any Priority will
#       allow NPCs to move about on these Events like the Player would.
# - FALSE: Disabled
#     * Recommended Setting for games that have existing maps
#     * Allows NPCs to move about on ALL Events with Tile Graphics without
#       having to add a \allow_npc Comment to each Event Page.
#
# HNOET_EXCLUDE_TAGS
# - Array [] of Terrain Tags to not automatically add \npc_allow to Event Tiles
# - Useful for making this Script compatible with any other script that may
#   adjust the way NPCs move over Event Tiles.  It allows the other Script
#   to make its own checks without interference from this Script.
# - Check is made in a Method for other Scripters to add any additional checks
#   to alter conditions for what their Scripts allow and deny passage on.
#
#
# ---  OPTIONS CONFIG  ----

# AUTO_FLAT_EVENT_TILES:
#   0 - Off (Default)
#   1 - Only Flat for \allow_npc Comment Pages w/ 0 Priority Tiles (Recommended)
#   2 - ALL Event Tiles with 0 Priority are made Flat
AUTO_FLAT_EVENT_TILES = 1  

# AUTO_ALLOW_NPCS_ON_EVENT_TILES:
#   true  - Allows ANY NPC on Events with Tiles unless \deny_npc Comment
#   false - Denies ALL NPCs unless one of the two Events is Through (Default)
#           Other conditions can still be checked to allow Passage, such
#           as an \allow_npc Comment for Events to be made Passable
AUTO_ALLOW_NPCS_ON_EVENT_TILES = false

# HNOET_EXCLUDE_TAGS - Array of Terrain Tags to NOT Auto-Make Passable
HNOET_EXCLUDE_TAGS = [7, 5, 6, 1]

# Terrain Tag 7 in the "Collection" means "Ladder" so no auto pass, not needed
# Terrain Tags 5 and 6 are used for Stairs with Diagonal Stairs Deluxe Script
# Terrain Tag 1 in the "Collection" means "Downhill Ice" passage handled there

# Check for Modular Passable Script - REQUIRED - DO NOT EDIT
unless $Modular_Passable
 print "Fatal Error: Heretics NPCs on Event Tiles script\n",
       "requires Heretics Modular Passable Script!\n\n",
       "Modular Passable is Not Available or is below this script.\n",
       "Modular Passable MUST be above this script.\n\n",
       "The Game will now Exit"
 exit
end

#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
 #--------------------------------------------------------------------------
 # * Event Tile Not Passable? - Game_Map
 #   - If an Event has a Tile and isnt Through, passage determined by bits
 #   - Inverse Logic: -1 * -1 = 1
 #   - Returns TRUE if a Tile is Not Passable
 #     x          : x-coordinate
 #     y          : y-coordinate
 #     d          : direction (0,2,4,6,8,10)
 #                  *  0,10 = determine if all directions are impassable
 #                  10 is used for Jumping
 #     bit        : obstacle bit for specific direction passage
 #     event      : iteration of each event in all events to be checked
 #     self_event : Self (If event is determined passable)
 #     result     : true or false passed as an arg by Aliases  
 #--------------------------------------------------------------------------
 alias hnoet_event_tile_not_passable? event_tile_not_passable?
 def event_tile_not_passable?(x,y,d,bit,event,self_event = nil, result = nil)
   # Ignore other results and check for any No Event Tiles properties
   if not event.through and self_event and not self_event.through and
      self_event.no_event_tiles
     # Impassable
     return true
   end
   # Call Original or other Aliases with new Results
   hnoet_event_tile_not_passable?(x, y, d, bit, event, self_event, result)
 end
end


#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
 #--------------------------------------------------------------------------
 # * Public Instance Variables - Game_Character
 #  - NOTE: attr_readers have been given Setter Methods, so no attr_accessor
 #  - NOTE: Call the setter methods with self.property if used on self
 #--------------------------------------------------------------------------
 attr_accessor :no_event_tiles           # Prevent Characters on Event Tiles  
 attr_accessor :force_z                  # Forces Z-Index at Int specified
 attr_reader   :flat                     # Force Event to render as Flat
 attr_reader   :no_flat                  # Prevent Flat Event render  
 # If Heretic's Loop Maps is installed
 if Game_Map.method_defined?(:map_loop_passable?)
   #--------------------------------------------------------------------------
   # * Screen Z - Game_Character
   #  - Get Screen Z-Coordinates
   #  - This adjusts the Z-Index for Looping Maps prior to other adjustments
   #     height : character height
   #--------------------------------------------------------------------------
   alias hnoet_loop_map_screen_z screen_z unless $@
   def screen_z(height = 0)
     # Call other Aliases of Screen_Z for Initial Z Value
     z = hnoet_loop_map_screen_z(height)
     # Return Unadjusted \z_sub Value if \z_sub (Caterpillar compatability)
     return z if @z_sub and z < 0
     # Correct Z Index If Map Loops Vertical
     return ($game_map.loop_vertical? and not @always_on_top) ?
       z % ($game_map.height * 32.0) : z
   end    
 end  
 #--------------------------------------------------------------------------
 # * Screen Z - Get Screen Z-Coordinates - Game_Character
 #     height : character height
 #  - Allows forcing any Event with Terrain Tiles to render as Flat
 #  - Can be Prohibited by using a \no_flat Comment on a Page
 #  - Forced Z-Index ignores height and uses your value
 #  - Forced Z-Index does NOT cause Terrain Tiles to "Stand Up" because
 #    this does NOT add 32 to the Z-Index automatically (Causes the "Glitch")
 #  - Forced Z-Index does NOT allow Events to display below the Terrain
 #  - The @z_flat, @z_add, and @z_sub are all properties are features
 #    made by Heretics Caterpillar and checked for compatability
 #--------------------------------------------------------------------------
 alias hnoet_screen_z screen_z unless $@
 def screen_z(height = 0)
   # If Always On Top is Turned off and not a Prevent Flag
   unless @always_on_top or @no_flat or @z_flat or @z_add or @z_sub
     # If \flat Comment or Auto Flat Options for \allow_npc or Terrains
     return 0 if @flat
     # If a FORCED Z-Index is specified
     if @force_z
       # Calculate Z-Index from real coordinates and map display position
       z = (@real_y - $game_map.display_y + 3) / 4 + @force_z
       # Return Adjusted Values and prevent Negatives
       return (z < 0 ? 0 : z)
     end
   end
   # Return Original or other Aliases
   return hnoet_screen_z(height)
 end
 
 #--------------------------------------------------------------------------
 # * Flat - Setter Method - Game_Character
 #     value : new value, true or false
 #  - Sets value and clears opposing property
 #  - call with self.flat, not just flat, as that becomes a local variable
 #    if called from within Set Move Route -> Script
 #--------------------------------------------------------------------------
 def flat=(value)
   # Sets value to property
   @flat = value
   # Clear the No Flat property
   @no_flat = nil
 end
 #--------------------------------------------------------------------------
 # * No Flat - Setter Method - Game_Character
 #     value : new value, true or false  
 #  - Sets to true and clears opposing property
 #  - Overrides Auto Configs and prevents Events with Tile Graphics from
 #    being given a @flat property automatically.
 #  - call with self.flat, not just flat, as that becomes a local variable
 #    if called from within Set Move Route -> Script
 #--------------------------------------------------------------------------
 def no_flat=(value)
   # Sets value to property
   @no_flat = true
   # Clear the No Flat property
   @flat = nil
 end
 #--------------------------------------------------------------------------
 # * Clear Flat - Game_Character
 #  - Clears both properties due to setter methods
 #--------------------------------------------------------------------------
 def clear_flat
   # Clear the Flat property
   @flat = nil
   # Clear the No Flat property
   @no_flat = nil
 end  
 #--------------------------------------------------------------------------
 # * NPC Extra No Pass Conditions? - Game_Character
 #     event  : the Event with a Tile that is being checked
 #     result : results of additional Aliases of this method
 #  - Returns True if Conditions met, thus denying NPC Event Tile Passage
 #  - Done to increase compatability with other Scripts
 #  - Allows for Order of Scripts to be not required because "result" will
 #    let you override checks made here
 #  - Can be Aliased to add your own Conditions
 #--------------------------------------------------------------------------
 def hnoet_extra_no_pass_conditions?(event, result = nil)
   # If an Alias has determined a differing Exclusion, return it
   return result if not result.nil?
   # If Terrain Tag is Excluded from allowing Passage
   if HNOET_EXCLUDE_TAGS.include?($game_map.terrain_tags[event.tile_id])
     # Dont Allow NPC Passage on this Excluded Terrain Tag, check elsewhere
     return true
   end
 end
 #--------------------------------------------------------------------------
 # * Event Not Passable? - Game_Character
 #  - This method allows NPCs to move across Events with Tiles
 #  - Inverse Logic: -1 * -1 = 1  
 #  - Tile Obstale Bits of Event now determines passage
 #  - Event Pages with Tiles can allow Event (NPC) Interaction based on
 #    the Obstacle Bits of the Tile if the Event has a \allow_npc Comment
 #    on that Page
 #  - NPCs can be Prohibited from moving by using a \no_event_tiles Comment
 #    on the NPC's Event Page
 #     x      : x-coordinate
 #     y      : y-coordinate
 #     d      : direction (0,2,4,6,8)
 #              * 0 = Determines if all directions are impassable (for jumping)
 #     new_x  : Target X Coordinate
 #     new_y  : Target Y Coordinate
 #     event  : Event being checked against in iteration loop
 #     result : results of other Aliases passed as an argument
 #--------------------------------------------------------------------------
 alias hnoet_event_not_passable? event_not_passable? unless $@
 def event_not_passable?(x, y, d, new_x, new_y, event, result = nil)
   # If this is an Event and is not the Player or Event Through (RTP Script)
   if self != $game_player
     # Impassable - There is a Flag that prohibits movement on Event Tile
     return true if event.deny_npc
   end
   # If target Event has an \allow_npc Comment or Flag and self is a NPC
   if result.nil? and event.allow_npc and @character_name != "" and
      not hnoet_extra_no_pass_conditions?(event)
     # If Target Event is an Event Tile (Event using a Graphic from the Map)
     if event.tile_id > 0
       # Change direction (0,2,4,6,8,10) to obstacle bit (0,1,2,4,8,0)
       bit = (1 << (d / 2 - 1)) & 0x0f
       # If obstacle bit is not set
       unless $game_map.passages[tile_id] & bit != 0 or
              $game_map.passages[tile_id] & 0x0f == 0x0f
         # Passable - Tile Passages say that Movement is allowed
         result = false
       end
     # Event does not have a Tile ID
     else
       # Passable - Event has an \allow_npc Flag and self is an NPC
       result = false
     end
   end
   # Call Original or other Aliases
   hnoet_event_not_passable?(x, y, d, new_x, new_y, event, result)
 end
end

#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
 #--------------------------------------------------------------------------
 # * Public Instance Variables - Game_Event
 #  Note: attr_reader have been given Setter Methods, call with self.
 #        if called from Set Move Route -> Script
 #--------------------------------------------------------------------------
 attr_reader   :allow_npc                # Allows NPCs on Event Tiles
 attr_reader   :deny_npc                 # Prevents NPCs on these Event Tiles
 #--------------------------------------------------------------------------
 # * Allow NPC - Setter Method - Game_Event
 #     value : new value, true or false
 #  - Sets value and clears opposing property
 #  - call with self.allow_npc = true / false, not just allow_npc = as that
 #    becomes a local variable if called from within Set Move Route -> Script
 #--------------------------------------------------------------------------
 def allow_npc=(value)
   # Assign value to Allow NPC property
   @allow_npc = value
   # Clear the value of the opposing property
   @deny_npc = nil
 end
 #--------------------------------------------------------------------------
 # * Deny NPC - Setter Method - Game_Event
 #     value : new value, true or false
 #  - Sets value and clears opposing property
 #  - Overrides Auto Configs and prevents Events with Tile Graphics from
 #    allowing NPC movement on them
 #  - self.deny_npc = true / false not just deny_npc = as that
 #    becomes a local variable if called from within Set Move Route -> Script
 #--------------------------------------------------------------------------
 def deny_npc=(value)  
   # Assign value to Deny NPC property
   @deny_npc = value
   # Clear the value of the opposing property
   @allow_npc = nil
 end
 #--------------------------------------------------------------------------
 # * Clear NPC - Game_Event
 #  - Clears both properties due to setter methods
 #--------------------------------------------------------------------------
 def clear_npc
   # Clear the Allow NPC property
   @allow_npc = nil
   # Clear the Deny NPC property
   @deny_npc = nil
 end
 #--------------------------------------------------------------------------
 # * Reset Page Comment Config - Game_Event
 #  - Resets Instance Variables
 #--------------------------------------------------------------------------
 alias reset_hnoet_page_comment_config reset_page_comment_config unless $@
 def reset_page_comment_config
   # Reset to set again by Comment Conditions
   @allow_npc = nil
   @deny_npc = nil
   @no_event_tiles = nil
   @flat = nil
   @no_flat = nil
   @force_z = nil
   # Runs Original or Other Aliases of this method
   reset_hnoet_page_comment_config
 end  
 #--------------------------------------------------------------------------
 # * Check Comment Page Config - Game_Event
 #     comment : the Comment to be checked to adjust Page Properties
 #     count   : integer of which List of Event Commands is checked
 #  - Called when an Event changes Pages, not when they stay the same
 #  - Checks the Comment for each of these configurations
 #  - Allows altering the internal counter for incrementation if an Alias
 #    finds something specific to its configuration.
 #  - Returns count when a Comment is found to prevent checks by other Aliases  
 #
 #  Note: When aliasing, please return the value of count, even if modified.
 #--------------------------------------------------------------------------
 alias check_hnoet_page_comment_config check_page_comment_config unless $@
 def check_page_comment_config(comment, count)
   # Looks for "\allow_npc" in the Comments (Use on Tile Events)
   comment.gsub(/^\\allow_npc\z/i){@allow_npc = true; @deny_npc = nil;
     return count;}
   # Looks for "\deny_npc" in the Comments (Use on Tile Events)
   comment.gsub(/^\\deny_npc\z/i){@deny_npc = true; @allow_npc = nil;
     return count;}
   # Looks for "\no_event_tiles" in the Comments (Use on Character Events)
   comment.gsub(/^\\no_event_tiles\z/i){@no_event_tiles = true;
     return count;}
   # Looks for "\flat" in the Comments (Use on Tile Events)
   comment.gsub(/^\\flat\z/i){@flat = true; @no_flat = nil;
    return count;}
   # Looks for "\no_flat" in the Comments (Use on Tile Events)
   comment.gsub(/^\\no_flat\z/i){@no_flat = true; @flat = nil;
     return count;}
   # Looks for "\force_z[int] in Comments (Use on Anyone, Negatives Allowed)
   comment.gsub(/\\force_z\[([-]?[0-9]+)\]/i){@force_z = $1.to_i;
     return count;}
   # Pass Args to Original or other Aliases and Return count
   return check_hnoet_page_comment_config(comment, count)
 end  
 #--------------------------------------------------------------------------
 # * Refresh - Game_Event
 #  - Can set to make ALL Events with Non Priority Tiles display as Flat
 #  - This will set @flat to TRUE if an Event has a Terrain Tile
 #    and System Option for Auto is set to TRUE
 #--------------------------------------------------------------------------
 alias make_events_auto_flat_refresh refresh unless $@
 def refresh
   # Initial State of current @page before Refresh
   page = @page    
   # Call Original or Other Aliases of Refresh (also Resets values to Page)
   make_events_auto_flat_refresh
   # If Event Not Erased and Page has changed
   unless @erased or page == @page
     # If this Event has a Non Priority Map Tile
     if @tile_id > 0
       # Auto Assign @allow_npc Flags to Events with Tiles for Tile Passage
       if AUTO_ALLOW_NPCS_ON_EVENT_TILES and not @deny_npc and
          not hnoet_extra_no_pass_conditions?(self)
         # Allows NPCs to move on this Event Tile
         @allow_npc = true
       end
       # If Tile this Event is using does not have a Priority
       if $game_map.priorities[@tile_id] == 0
         # If \no_flat Comment is not present or forced by Script Call
         unless @no_flat or hnoet_extra_no_pass_conditions?(self)
           # Auto Assign Flat Flags if Option is Set
           case AUTO_FLAT_EVENT_TILES
           when 1  # Makes only Events with \allow_npc Comments set to Flat
             @flat = true if @allow_npc
           when 2  # Makes ALL Events with Non Priority Map Tiles set to Flat
             @flat = true
           end
         end
       end
     end
   end
 end
end



Instructions

Just add a Comment to an Event Tile that says:
@>Comment: \allow_npc

All NPCs will now be able to move on this Event Tile.  This can be done Automatically as well.

There are a lot more options that you can use that allows some NPCs to not use Event Tiles, or to allow even \event_through NPCs to also move on Event Tiles.  Its all in the Documentation.


Compatibility

No known issues at this time.


Credits and Thanks




Author's Notes

This script may sound useless at first, until you try to make your maps more dynamic, or have specific uses for Events Tiles that conflict with NPC Movement.  Even the feature to allow Events to move through other Events and still be constrained by the Tiles of the Map is a major feature.  Trust me, you want this.