
calvin624":2q8djxft said:I'd like some feedback on one of my maps please peeps:
![]()
Â
#==============================================================================
# ** Anti Event Lag System
#------------------------------------------------------------------------------
# Zeriab
# Version 1.2 - No spriteset modification
# 2008-08-10 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Requirements :
# Â
# Â If you have the SDK : Version 2.0+, Part I, II
# Â Does not require the SDK
#------------------------------------------------------------------------------
# * Version History :
#
# Â Version 0.8 -------------------------------------------------- (2007-09-03)
# Â Â - First release
#
# Â Version 0.81 ------------------------------------------------- (2007-09-05)
# Â Â - Overwrote Game_Map's passable? method for faster collision detection
#
# Â Version 0.9 -------------------------------------------------- (2007-09-12)
# Â Â - Support for the Non-SDK patch
# Â Â - Support for defining whether an event will always be updated or never
# Â Â Â be updated by defining name patterns.
#
# Â Version 1.0 -------------------------------------------------- (2007-09-24)
# Â - Fixed compatibility issue with Blizzard's Caterpillar script
# Â - Overwrote more methods scanning for events on a specific tile
# Â - Support for defining whether an event will always be updated or never
# Â Â Â be updated by specifying the event's id and map_id
# Â - Some structural changes.
# Â - Integrated the Non-SDK patch into the main script
#
# Â Version 1.05 ------------------------------------------------- (2007-11-18)
# Â - Fixed bug where sprites might not be disposed when changing scene.
#
# Â Version 1.1 -------------------------------------------------- (2008-04-10)
# Â - Added declaration to which common events to update
#
# Â Version 1.15 ------------------------------------------------- (2008-06-19)
# Â - Added automatic detection of which common events to update (optional)
#
# Â Version 1.2 -------------------------------------------------- (2008-07-04)
# Â - Fixed a case where an event could be registered twice causing transparent
# Â Â Â events to look less transparent.
#------------------------------------------------------------------------------
# * Description :
#
# Â This script was designed to reduce lag by changing the data structure of
# Â the events in the Game_Map class and update the functionality accordingly
# Â A goal of this script is not to change the normal event behavior, so
# Â implementing it into a project should not effect previous events. It might
# Â effect custom scripts.
#------------------------------------------------------------------------------
# * License :
#
# Â Copyright (C) 2007, 2008 Â Zeriab
#
# Â This program is free software: you can redistribute it and/or modify
# Â it under the terms of the GNU Lesser Public License as published by
# Â the Free Software Foundation, either version 3 of the License, or
# Â (at your option) any later version.
#
# Â This program is distributed in the hope that it will be useful,
# Â but WITHOUT ANY WARRANTY; without even the implied warranty of
# Â MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Â See the
# Â GNU Lesser Public License for more details.
#
# Â For the full license see <http://www.gnu.org/licenses/>
# Â The GNU General Public License: [url=http://www.gnu.org/licenses/gpl.txt]http://www.gnu.org/licenses/gpl.txt[/url]
# Â The GNU Lesser General Public License: [url=http://www.gnu.org/licenses/lgpl.txt]http://www.gnu.org/licenses/lgpl.txt[/url]
#------------------------------------------------------------------------------
# * Compatibility :
#
# Â This is SDK compliant. It is written for SDK version 2.3.
# Â It requires SDK 2.0+ if you are using the SDK
# Â The Non-SDK patch is integrated so you can run it without the SDK
# Â
# Â The following methods has been overwritten:
# Â Â * Game_Character.passable?
# Â Â * Game_Map.passable?
# Â Â * Game_Map.update_events
# Â Â * Game_Player.check_event_trigger_here
# Â Â * Game_Player.check_event_trigger_there
# Â Â * Game_Player.check_event_trigger_touch
#
# Â The following methods have been aliased
# Â Â * Game_Event.jump
# Â Â * Game_Event.moveto
# Â Â * Game_Event.move_down
# Â Â * Game_Event.move_left
# Â Â * Game_Event.move_right
# Â Â * Game_Event.move_up
# Â Â * Game_Event.move_lower_left
# Â Â * Game_Event.move_lower_right
# Â Â * Game_Event.move_upper_left
# Â Â * Game_Event.move_upper_right
# Â Â * Game_Map.setup
#------------------------------------------------------------------------------
# * Instructions :
#
# Â Place this script just below the SDK if you are using the SDK.
# Â Place this script just below the default if using the Non-SDK Patch
# Â
# Â default scripts
# Â (SDK)
# Â Zeriab's Anti Event Lag System
# Â (custom scripts)
# Â main
#
# Â ~ Game_Map ~
# Â There are 4 constants you can change at will in the top of the
# Â Game_Map class: (You don't have to ;))
# Â
# Â ALWAYS_UPDATE ~ The default is false
# Â -------------------------------
# Â You can set this to true if you want all events to be update always
# Â This a slower option, but events behave like they do without the script.
# Â You will still benifit from the faster collision detection and fewer sprites
# Â This has higher priority than the event specific features. I.e never_update
#
# Â BUFFER_SIZE ~ The default is 2
# Â -------------------------
# Â You can increase or decrease the buffer size by altering this value.
# Â The greater this value the greater area around the visible area is updated
# Â at the price of potential more lag.
# Â The lower this value the smaller area around the visible area is update
# Â with the potential of less lag.
# Â Too low a value may get the sprites to sort of 'freeze' in the outskirts
# Â of the screen.
# Â Bigger sprites requires bigger buffer to prevent this.
# Â
# Â TILES_VERTICAL ~ The default is 15
# Â -----------------------------
# Â Specifies how many tiles there are vertical
# Â I included the option to change this value if you want to alter
# Â the size of the game window.
# Â If you for example want 800x600 I suggest changing this value to 20
#
# Â TILES_HORIZONTAL ~ The default is 20
# Â -------------------------------
# Â Specifies how many tiles there are horizontal
# Â I included the option to change this value if you want to alter
# Â the size of the game window.
# Â If you for example want 800x600 I suggest changing this value to 27
# Â
# Â LIMIT_COMMON_EVENTS - The default is true
# Â -----------------------------
# Â You can see this to false if you want all common events updated.
# Â This constant only has an effect during the upstart of the program. Changing
# Â it during the game will have no effect.
# Â If it is set to false you can safely ignore the following three constants
#
# Â SPECIFY_COMMON_EVENTS_MANUALLY - The default is false
# Â -----------------------------
# Â Specifies whether you want to enter which common events should be updated
# Â manually. If this is set to false you can safely ignore
# Â COMMON_EVENTS_TO_UPDATE while COMMON_EVENT_FILEPATH is of importance.
# Â Vice-versa is COMMON_EVENTS_TO_UPDATE important and COMMON_EVENT_FILEPATH
# Â safe to ignore if SPECIFY_COMMON_EVENTS_MANUALLY is set to true.
# Â If this is set to false which common events to update will be atomatically
# Â detected.
# Â As a general rule of thumb: Only change this to true if you have problems
# Â with the automatic detection or you want to prevent certain common events
# Â with autorun or parallel process as trigger.
#
# Â COMMON_EVENTS_TO_UPDATE
# Â -----------------------------
# Â This constant is an array of common event ids. Only the common events with
# Â the ids specified in the array will be updated. The ids are the numbers
# Â shown in the database with any leading 0s removed. In general only common
# Â events which have autorun or parallel process needs to be updated.
# Â It will have no effect if SPECIFY_COMMON_EVENTS_MANUALLY is false
# Â Let's say we want the common events 005, 009 and 020 to be updated. First we
# Â will remove the leading 0s and get 5, 9 and 20. Next we will put them in the
# Â array and get as end result:
#
# Â Â COMMON_EVENTS_TO_UPDATE = [5, 9, 20]
#
# Â If we had put [005, 009, 020] as the array we would have gotten an error
# Â when starting the game.
# Â If we now want to update common event 045 we would add 45 to the array:
#
# Â Â COMMON_EVENTS_TO_UPDATE = [5, 9, 20, 45]
#
#
# Â COMMON_EVENT_FILEPATH - The default is 'Data/CommonEvents.rxdata'
# Â -----------------------------
# Â Specifies the relative file path (To the directory of where the Game.exe is)
# Â to where the common events are stored.
# Â Only change this if you have changed the name or place of the
# Â CommonEvents.rxdata file.
# Â It will have no effect if SPECIFY_COMMON_EVENTS_MANUALLY is true
#
#
# Â ~ Game_Event ~
# Â Next we come to the Constants in Game_Event. They are given above the
# Â Game_Map code. They have been split from the other Game_Event code for
# Â Easier access:
#
# Â SPECIAL_UPDATE_IDS
# Â ------------------
# Â This constant contains a hash where you can specify how specific events
# Â should be updated. Special update ids has priority over name patterns.
# Â The keys are all a 2-elements array. [Map_ID, Event_ID]
# Â The value is either an 'A' for always update or 'N' for never update.
# Â Here is an example:
#
# Â Â SPECIAL_UPDATE_IDS = {[1,1]=>'A',
# Â Â Â Â Â Â Â Â Â Â Â Â Â [1,2]=>'N'}
# Â
# Â Notice the first line [1,1]=>'A'
# Â It means that the event with id 1 on map 1 will always be updated.
#
# Â Notice the first line [1,2]=>'N'
# Â It means that the event with id 2 on map 1 will never be updated.
# Â Let's say we wanted the event with id 5 on map 3 to always be updated.
# Â This can be achieved by adding [5,3]=>'A' to the hash:
#
# Â Â SPECIAL_UPDATE_IDS = {[1,1]=>'A',
# Â Â Â Â Â Â Â Â Â Â Â Â Â [1,2]=>'N',
# Â Â Â Â Â Â Â Â Â Â Â Â Â [5,3]=>'A'}
#
#
# Â NEVER_UPDATE_NAME_PATTERNS
# Â --------------------------
# Â Here you can specify any number of patterns which will be checked when a
# Â new map is loaded. Any events which matches at least one of the patterns
# Â given here will never be updated.
# Â A pattern is assumed to be either a String or a RegExp. In the case of a
# Â String name.include?(string) is used. Otherwise the =~ operator is used
# Â Note: The never_update feature has higher priority than the always_update.
# Â If an event's name matches both a always update pattern and a never_update
# Â pattern it will never update.
#
# Â ALWAYS_UPDATE_NAME_PATTERNS
# Â ---------------------------
# Â Here you can specify any number of patterns which will be checked when a
# Â new map is loaded. Any events which matches at least one of the patterns
# Â given here will always be updated.
# Â Note: The always_update feature has lower priority than the never_update.
# Â If an event's name matches both a always update pattern and a never_update
# Â pattern it will never update.
#==============================================================================
Â
if Module.constants.include?('SDK')
 #----------------------------------------------------------------------------
 # * SDK Log Script
 #----------------------------------------------------------------------------
 SDK.log('Anti Event Lag System', 'Zeriab', 1.2, '2008-06-25')
 SDK.check_requirements(2.0)
end
Â
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if !Module.constants.include?('SDK') || SDK.enabled?('Anti Event Lag System')
Â
#==============================================================================
# ** Constants for the anti lag script
#==============================================================================
Â
class Game_Map
 ALWAYS_UPDATE = false
 BUFFER_SIZE = 2
 TILES_VERTICAL = 15
 TILES_HORIZONTAL = 20
 LIMIT_COMMON_EVENTS = true
 SPECIFY_COMMON_EVENTS_MANUALLY = false
 # If you want to specify which common events to update
 COMMON_EVENTS_TO_UPDATE = []
 # If you want the script to automatically read the common events and find
 # out which to update. Must be the path to the CommonEvents.rxdata
 COMMON_EVENT_FILEPATH = 'Data/CommonEvents.rxdata'
end
Â
class Game_Event
 SPECIAL_UPDATE_IDS = {}
 NEVER_UPDATE_NAME_PATTERNS = ['[N]'] # [N] in the event name => not updated
 #ALWAYS_UPDATE_NAME_PATTERNS = ['[A]'] # [A] in the event name => always updated
 ALWAYS_UPDATE_NAME_PATTERNS = ['[A]', 'WorldMap Time', 'Vehicle Memory', 'Reflection']
end
Â
#==============================================================================
# ** Automatic configuration generation
#==============================================================================
class Game_Map
 if LIMIT_COMMON_EVENTS && !SPECIFY_COMMON_EVENTS_MANUALLY
  # Find the common events which needs to be updated
  COMMON_EVENTS_TO_UPDATE = []
  # Load the common events
  common_events = load_data(COMMON_EVENT_FILEPATH)
  # Go through the common events
  for common_event in common_events.compact
   # Check if there is a need for the common event to update
   if common_event.trigger > 0
    # C
    COMMON_EVENTS_TO_UPDATE << common_event.id
   end
  end
 end
end
Â
#==============================================================================
# ** Game_Map
#==============================================================================
Â
class Game_Map
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader :event_map
 #--------------------------------------------------------------------------
 # * Alias Listings
 #--------------------------------------------------------------------------
 alias_method :zeriab_antilag_gmmap_setup,  :setup
 #--------------------------------------------------------------------------
 # * Setup
 #--------------------------------------------------------------------------
 def setup(*args)
  # Makes an event map as a hash
  @event_map = {}
  # Original Setup
  zeriab_antilag_gmmap_setup(*args)
  # Go through each event
  for event in @events.values
   # Check how the event should be updated
   event.check_update
  end
 end
Â
 #--------------------------------------------------------------------------
 # * Update Events ~ Overwritten to only updating visible and special events
 #--------------------------------------------------------------------------
 def update_events
  # Runs through the events
  for event in @events.values
   # checks if the event is visible or needs to be updated
   if ALWAYS_UPDATE || event.need_update?
    event.update
   end
  end
 end
Â
 # Only overwrite this method if common events should be limited
 if LIMIT_COMMON_EVENTS
  #--------------------------------------------------------------------------
  # * Update Common Events ~ Updates only the necessary common events
  #--------------------------------------------------------------------------
  def update_common_events
   for i in COMMON_EVENTS_TO_UPDATE
    @common_events[i].update
   end
  end
 end
 Â
 #--------------------------------------------------------------------------
 # * Called when an event has been moved with it's old x and y coordinate
 #  Used to update its position in the event_map
 #--------------------------------------------------------------------------
 def move_event(old_x,old_y,event)
  # Checks if the event has moved to a new position.
  return if old_x == event.x && old_y == event.y
  # Removes the event from its old position
  remove_event(old_x, old_y, event)
  # Adds the event to its new position
  add_event(event.x,event.y,event)
 end
Â
 #--------------------------------------------------------------------------
 # * Adds an event to the event_map at the given x and y coordinate
 #--------------------------------------------------------------------------
 def add_event(x,y,event)
  # Checks if there are not any events on the specific tile
  if @event_map[[x,y]].nil?
   # Sets the position on the map to be an array containing the given
   # event. (In case there are placed additional events on this tile)
   @event_map[[x,y]] = [event]
  else
   # Adds the event to the array of events on the specific tile
   @event_map[[x,y]] << event
  end
 end
Â
 #--------------------------------------------------------------------------
 # * Removes an event from the event_map with the given x and y coordinate
 #--------------------------------------------------------------------------
 def remove_event(x,y,event)
  # Checks if there actually are an event on the given coordinates
  return if @event_map[[x,y]].nil?
  # Checks whether or not there are more events than the given event on
  # with the given coordinates
  if @event_map[[x,y]].size > 1
   # Deletes the events from the array of events
   @event_map[[x,y]].delete(event)
  else
   # Deletes the key along with the corresponding value from the hashmap
   # since there are no other events on the tile.
   @event_map.delete([x,y])
  end
 end
Â
 #--------------------------------------------------------------------------
 # * Gets min_x, max_x, min_y and max_y including the buffer-size
 # Returns min_x, max_x, min_y, max_y  (tile-coordinates)
 # Returns a Rect if 'true' is given as the argument
 #-------------------------------------------------------------------------- Â
 def get_tile_area(rect = false)
  # Gets the upper left x and y tile-coordinate
  x = $game_map.display_x / 128
  y = $game_map.display_y / 128
  # Computes the min and max coordinates when considering the buffer-size
  min_x = x - BUFFER_SIZE
  min_y = y - BUFFER_SIZE
  max_x = x + TILES_HORIZONTAL + BUFFER_SIZE
  max_y = y + TILES_VERTICAL + BUFFER_SIZE
  # Makes sure the min and max coordinates are within the map
  if min_x < 0
   min_x = 0
  end
  if max_x >= $game_map.width
   max_x = $game_map.width - 1
  end
  if min_y < 0
   min_y = 0
  end
  if max_y >= $game_map.height
   max_y = $game_map.height - 1
  end
  # Checks if the return should be a Rect
  if rect
   # Returns the result as a Rect
   return Rect.new(min_x, min_y, max_x - min_x, max_y - min_y)
  else
   # Returns the result as the min and max coordinates
   return min_x, max_x, min_y, max_y
  end
 end
Â
 #--------------------------------------------------------------------------
 # * Checks if the tile with the given x and y coordinate is visible.
 #  Takes the buffer size into account.
 #--------------------------------------------------------------------------
 def visible?(x,y)
  min_x = $game_map.display_x / 128
  min_y = $game_map.display_y / 128
  if x >= min_x - BUFFER_SIZE && x <= min_x + BUFFER_SIZE + TILES_HORIZONTAL &&
    y >= min_y - BUFFER_SIZE && y <= min_y + BUFFER_SIZE + TILES_VERTICAL
   return true
  end
  return false
 end
Â
 #--------------------------------------------------------------------------
 # * Get Designated Position Event ID
 #   x      : x-coordinate
 #   y      : y-coordinate
 #--------------------------------------------------------------------------
 def check_event(x, y)
  # Retrives the events on the specified tile
  events = event_map[[x,y]]
  unless events.nil?
   # Loop through events on tile
   for event in events
    if event.x == x and event.y == y
     return event.id
    end
   end
  end
 end
Â
 #--------------------------------------------------------------------------
 # * Determine if Passable
 #   x      : x-coordinate
 #   y      : y-coordinate
 #   d      : direction (0,2,4,6,8,10)
 #          *  0,10 = determine if all directions are impassable
 #   self_event : Self (If event is determined passable)
 #--------------------------------------------------------------------------
 def passable?(x, y, d, self_event = nil)
  # If coordinates given are outside of the map
  unless valid?(x, y)
   # impassable
   return false
  end
  # Change direction (0,2,4,6,8,10) to obstacle bit (0,1,2,4,8,0)
  bit = (1 << (d / 2 - 1)) & 0x0f
  # Retrives the events on the specified tile
  events = event_map[[x,y]]
  unless events.nil?
   # Loop through events on tile
   for event in events
    # If tiles other than self are consistent with coordinates
    if event.tile_id >= 0 and event != self_event and not event.through
     # If obstacle bit is set
     if @passages[event.tile_id] & bit != 0
      # impassable
      return false
     # If obstacle bit is set in all directions
     elsif @passages[event.tile_id] & 0x0f == 0x0f
      # impassable
      return false
     # If priorities other than that are 0
     elsif @priorities[event.tile_id] == 0
      # passable
      return true
     end
    end
   end
  end
  # Loop searches in order from top of layer
  for i in [2, 1, 0]
   # Get tile ID
   tile_id = data[x, y, i]
   # Tile ID acquistion failure
   if tile_id == nil
    # impassable
    return false
   # If obstacle bit is set
   elsif @passages[tile_id] & bit != 0
    # impassable
    return false
   # If obstacle bit is set in all directions
   elsif @passages[tile_id] & 0x0f == 0x0f
    # impassable
    return false
   # If priorities other than that are 0
   elsif @priorities[tile_id] == 0
    # passable
    return true
   end
  end
  # passable
  return true
 end
end
Â
#==============================================================================
# ** Game_Character
#==============================================================================
Â
class Game_Character
 #--------------------------------------------------------------------------
 # * Determine if Passable (Overwrite)
 #   x : x-coordinate
 #   y : y-coordinate
 #   d : direction (0,2,4,6,8)
 #     * 0 = Determines if all directions are impassable (for jumping)
 #--------------------------------------------------------------------------
 def passable?(x, y, d)
  # Get new coordinates
  new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  # If coordinates are outside of map
  unless $game_map.valid?(new_x, new_y)
   # impassable
   return false
  end
  # If through is ON
  if @through
   # passable
   return true
  end
  # If unable to leave first move tile in designated direction
  unless $game_map.passable?(x, y, d, self)
   # impassable
   return false
  end
  # If unable to enter move tile in designated direction
  unless $game_map.passable?(new_x, new_y, 10 - d)
   # impassable
   return false
  end
  # If player coordinates are consistent with move destination
  if $game_player.x == new_x and $game_player.y == new_y
   # If through is OFF
   unless $game_player.through
    # If your own graphic is the character
    if @character_name != ""
     # impassable
     return false
    end
   end
  end
  # Checks for events on the new position
  events = $game_map.event_map[[new_x,new_y]]
  if events.nil?
   # passable
   return true
  end
  # Loop all events on the tile
  for event in events
   # If event coordinates are consistent with move destination
   if event.x == new_x and event.y == new_y
    # If through is OFF
    unless event.through
     # If self is event
     if self != $game_player
      # impassable
      return false
     end
     # With self as the player and partner graphic as character
     if event.character_name != ""
      # impassable
      return false
     end
    end
   end
  end
  # passable
  return true
 end
end
Â
#==============================================================================
# ** Game_Event
#==============================================================================
Â
class Game_Event
 # The method to alias and overwrite
 AX = [:jump, :moveto, :move_down, :move_left, :move_right, :move_up,
  :move_lower_left, :move_lower_right, :move_upper_left, :move_upper_right]
 for method in AX
  # Aliases the old method
  new_method_as_string = 'zeriab_antilag_gmtev_' + method.to_s
  new_method = new_method_as_string
  alias_method(new_method, method)
 Â
  # Overwrites the old method
PROG = <<FIN
  def #{method}(*args)
   old_x = @x
   old_y = @y
   #{new_method}(*args)
   unless old_x == @x && old_y == @y
    $game_map.move_event(old_x, old_y, self)
   end
  end
FIN
  # Evaluates the method definition
  eval(PROG)
 end
Â
 #--------------------------------------------------------------------------
 # * Always_update property (is false by default) priority under never_update
 #--------------------------------------------------------------------------
 attr_writer :always_update
 def always_update
  @always_update = false  if @always_update.nil?
  return @always_update
 end
Â
 #--------------------------------------------------------------------------
 # * Never_update property (is false by default) priority over always_update
 #--------------------------------------------------------------------------
 attr_writer :never_update
 def never_update
  @never_update = false  if @never_update.nil?
  return @never_update
 end
Â
 #--------------------------------------------------------------------------
 # * Need Update method. Fast checks here.
 #--------------------------------------------------------------------------
 def need_update?
  return false if never_update
  return true if always_update
  return true if $game_map.visible?(x, y)
  return true if @move_type == 3
  return @trigger == 3 || @trigger == 4
 end
Â
 #--------------------------------------------------------------------------
 # * Checks how the event should be updated.
 #--------------------------------------------------------------------------
 def check_update
  name = @event.name
  # Checks if the event is never to be updated. (For decoration)
  for pattern in NEVER_UPDATE_NAME_PATTERNS
   if (pattern.is_a?(String) && name.include?(pattern)) ||
    !(pattern =~ name).nil?
    self.never_update = true
   end
  end
  # Checks if the event is to be always updated.
  for pattern in ALWAYS_UPDATE_NAME_PATTERNS
   if (pattern.is_a?(String) && name.include?(pattern)) ||
    !(pattern =~ name).nil?
    self.always_update = true
   end
  end
  # Checks for special update for the particular id (overrules the patterns)
  special_update = SPECIAL_UPDATE_IDS[[@map_id,@id]]
  unless special_update.nil?
   # Checks if it never should be updated
   if special_update.downcase == 'n'
    self.never_update = true
    self.always_update = false
   # Checks if it always should be updated
   elsif special_update.downcase == 'a'
    self.always_update = true
    self.never_update = false
   end
  end
 end
end
Â
#==============================================================================
# ** Game_Event
#==============================================================================
Â
class Game_Player
 #--------------------------------------------------------------------------
 # * Same Position Starting Determinant
 #--------------------------------------------------------------------------
 def check_event_trigger_here(triggers)
  result = false
  # If event is running
  if $game_system.map_interpreter.running?
   return result
  end
  # Retrives the events on the specified tile
  events = $game_map.event_map[[@x,@y]]
  unless events.nil?
   # Loop through events on tile
   for event in events
    # If event triggers are consistent
    if triggers.include?(event.trigger)
     # If starting determinant is same position event (other than jumping)
     if not event.jumping? and event.over_trigger?
      event.start
      result = true
     end
    end
   end
  end
  return result
 end
 #--------------------------------------------------------------------------
 # * Front Event Starting Determinant
 #--------------------------------------------------------------------------
 def check_event_trigger_there(triggers)
  result = false
  # If event is running
  if $game_system.map_interpreter.running?
   return result
  end
  # Calculate front event coordinates
  new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  # Retrives the events on the specified tile
  events = $game_map.event_map[[new_x,new_y]]
  unless events.nil?
   # Loop through events on tile
   for event in events
    # If event triggers are consistent
    if triggers.include?(event.trigger)
     # If starting determinant is front event (other than jumping)
     if not event.jumping? and not event.over_trigger?
      event.start
      result = true
     end
    end
   end
  end
  # If fitting event is not found
  if result == false
   # If front tile is a counter
   if $game_map.counter?(new_x, new_y)
    # Calculate 1 tile inside coordinates
    new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
    new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
    # Retrives the events on the specified tile
    events = $game_map.event_map[[new_x,new_y]]
    unless events.nil?
     # Loop through events on tile
     for event in events
      # If event triggers are consistent
      if triggers.include?(event.trigger)
       # If starting determinant is front event (other than jumping)
       if not event.jumping? and not event.over_trigger?
        event.start
        result = true
       end
      end
     end
    end
   end
  end
  return result
 end
 #--------------------------------------------------------------------------
 # * Touch Event Starting Determinant
 #--------------------------------------------------------------------------
 def check_event_trigger_touch(x, y)
  result = false
  # If event is running
  if $game_system.map_interpreter.running?
   return result
  end
  # Retrives the events on the specified tile
  events = $game_map.event_map[[x,y]]
  unless events.nil?
   # Loop through events on tile
   for event in events
    # If event coordinates and triggers are consistent
    if [1,2].include?(event.trigger)
     # If starting determinant is front event (other than jumping)
     if not event.jumping? and not event.over_trigger?
      event.start
      result = true
     end
    end
   end
  end
  return result
 end
end
Â
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end
Â
unless Module.constants.include?('SDK')
 #============================================================================
 # * Compatibility :
 #
 #  This will probably not be compatible with scripts extending or modifying
 #  the overwritten methods.
 # Â
 #  The following methods has been overwritten:
 #   * Game_Map.update
 #============================================================================
Â
 #============================================================================
 # ** Game_Map
 #============================================================================
 class Game_Map
  #--------------------------------------------------------------------------
  # * Update Common Events
  #--------------------------------------------------------------------------
  def update_common_events
   for common_event in @common_events.values
    common_event.update
   end
  end
  #------------------------------------------------------------------------
  # * Frame Update Overwrite
  #------------------------------------------------------------------------
  def update
   # Refresh map if necessary
   if $game_map.need_refresh
    refresh
   end
   # If scrolling
   if @scroll_rest > 0
    # Change from scroll speed to distance in map coordinates
    distance = 2 ** @scroll_speed
    # Execute scrolling
    case @scroll_direction
    when 2  # Down
     scroll_down(distance)
    when 4  # Left
     scroll_left(distance)
    when 6  # Right
     scroll_right(distance)
    when 8  # Up
     scroll_up(distance)
    end
    # Subtract distance scrolled
    @scroll_rest -= distance
   end
   # Update map event
   update_events
   # Update common event
   update_common_events
   # Manage fog scrolling
   @fog_ox -= @fog_sx / 8.0
   @fog_oy -= @fog_sy / 8.0
   # Manage change in fog color tone
   if @fog_tone_duration >= 1
    d = @fog_tone_duration
    target = @fog_tone_target
    @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
    @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
    @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
    @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
    @fog_tone_duration -= 1
   end
   # Manage change in fog opacity level
   if @fog_opacity_duration >= 1
    d = @fog_opacity_duration
    @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
    @fog_opacity_duration -= 1
   end
  end
 end
end
Â
module XAS_BA_ENEMY
#
#ENEMY_ATTACK_SKILL = the id of the skill for a normal attack
#
ENEMY_ATTACK_SKILL = 1
end
module XAS_ACTION
attr_reader :action
attr_reader :erased
##################################################################################
# nah/fern kämper ki
#
################################################################################
def allki(fskill,ffs,skill,fs,heal,freq,healper,skilltime,speed,se,fr)
if @firsttime == nil
@timer = 0
@timers = 0
@runbackt = 0
@firsttime = 0
@wait = 0
end
if @wait == 0
attack_off
@timers += 1
@timer += 1
speed(speed)
give_near_actor
enemy = self.battler
enemylowhp = enemy.maxhp * healper / 100
abstand = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if self.battler.hp <= enemylowhp and heal != 0 and @timers > skilltime
shoot(heal)
@timers = 0
elsif @runbackt < 20 and self.battler.hp <= enemylowhp
speed(speed+0.5)
attack_off
flee_from_actor
@runbackt += 1
elsif $game_map.events[@enemytaget] != nil or @enemytaget == -1
if @enemytaget == -1
ziel = $game_player
else
ziel = $game_map.events[@enemytaget]
end
abstande = (self.x - ziel.x).abs + (self.y - ziel.y).abs
if abstande <= 2
if @timers > skilltime # wenn skilltimefacher tackt
@timers = 0
random = rand(100)
if random > 30 and skill != 0
spe_on(1,fs)
shoot(skill)
@wait = Database_Bullet::SUFLAGS[skill].to_i
elsif @timer > freq and freq != 0 # wenn einfacher tackt
@timer = 0
@wait = 14 * (6-speed)
turn_to_actor
if se != 0
$game_system.se_play(RPG::AudioFile.new(se,80,fr))
end
attack_on
end
end
elsif self.x == ziel.x or self.y == ziel.y
if abstande <= 9 and @timers > skilltime and fskill != 0
@timers = 0
random = rand(100)
if random > 30
spe_on(2,ffs)
turn_to_actor
shoot(fskill)
@wait = Database_Bullet::SUFLAGS[fskill].to_i
end
end
else
attack_off
find_to_actor
end
end
else
@wait -= 1
end
end
##################################################################################
# KI nah/fern kämpfer END
#
################################################################################
##################################################################################
# fernkämper ki
#
################################################################################
def fkeki(askill,skill1,fs1,skill2,fs2,heal,freq,healper,skilltime,speed,se,fr)
if @firsttime == nil
@timer = 0
@timers = 0
@runbackt = 0
@firsttime = 0
@repeatrun = 0
@getroffen = self.battler.maxhp
@wait = 0
end
if @wait == 0
attack_off
@repeatrun += 1
@timers += 1
@timer += 1
if @repeatrun > 400
@runbackt = 0
end
speed(speed)
give_near_actor
enemy = self.battler
enemylowhp = enemy.maxhp * healper / 100
abstand = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if abstand <= 2 and @runbackt < 20 and enemy.hp < @getroffen
speed(speed+0.5)
attack_off
flee_from_actor
@runbackt += 1
@getroffen = enemy.hp
elsif self.battler.hp <= enemylowhp and heal != 0 and @timers > skilltime
shoot(heal)
@wait = Database_Bullet::SUFLAGS[heal].to_i
@timers = 0
elsif @runbackt < 20 and enemy.hp <= enemylowhp
speed(speed+0.5)
attack_off
flee_from_actor
@runbackt += 1
elsif $game_map.events[@enemytaget] != nil or @enemytaget == -1
if @enemytaget == -1
ziel = $game_player
else
ziel = $game_map.events[@enemytaget]
end
abstande = (self.x - ziel.x).abs + (self.y - ziel.y).abs
if self.x == ziel.x or self.y == ziel.y and abstande <= 7
if @timers > skilltime # wenn skilltimefacher tackt
@timers = 0
random = rand(100)
if random > 80 and skill2 != 0
spe_on(2,fs2)
turn_to_actor
shoot(skill2)
@wait = Database_Bullet::SUFLAGS[skill2].to_i
elsif random >40 and skill1 != 0
spe_on(1,fs1)
turn_to_actor
shoot(skill1)
@wait = Database_Bullet::SUFLAGS[skill1].to_i
elsif @timer > freq # wenn einfacher tackt
@timer = 0
turn_to_actor
if se != 0
$game_system.se_play(RPG::AudioFile.new(se,80,fr))
end
stateattack_on(askill)
@wait = Database_Bullet::SUFLAGS[askill].to_i
end
end
else
attack_off
find_to_actor
end
end
else
@wait -= 1
end
end
##################################################################################
# KI fernkämpfer END
#
################################################################################
##################################################################################
# kämper ki
#
################################################################################
def keki(skill1,fs1,skill2,fs2,heal,freq,healper,skilltime,speed,se,fr)
if @firsttime == nil
@timer = 0
@timers = 0
@runbackt = 0
@firsttime = 0
@wait = 0
end
if @wait == 0
attack_off
@timers += 1
@timer += 1
speed(speed)
give_near_actor
enemy = self.battler
enemylowhp = enemy.maxhp * healper / 100
abstand = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if self.battler.hp <= enemylowhp and heal != 0 and @timers > skilltime
shoot(heal)
@timers = 0
elsif @runbackt < 20 and self.battler.hp <= enemylowhp
speed(speed+0.5)
attack_off
flee_from_actor
@runbackt += 1
elsif $game_map.events[@enemytaget] != nil or @enemytaget == -1
if @enemytaget == -1
ziel = $game_player
else
ziel = $game_map.events[@enemytaget]
end
abstande = (self.x - ziel.x).abs + (self.y - ziel.y).abs
if abstande <= 2
if @timers > skilltime # wenn skilltimefacher tackt
@timers = 0
random = rand(100)
if random > 80 and skill2 != 0
spe_on(2,fs2)
shoot(skill2)
@wait = Database_Bullet::SUFLAGS[skill2].to_i
elsif random >40 and skill1 != 0
spe_on(1,fs1)
shoot(skill1)
@wait = Database_Bullet::SUFLAGS[skill1].to_i
elsif @timer > freq and freq != 0 # wenn einfacher tackt
@timer = 0
turn_to_actor
@wait = 14 * (6-speed)
if se != 0
$game_system.se_play(RPG::AudioFile.new(se,80,fr))
end
attack_on
end
end
else
attack_off
find_to_actor
end
end
else
@wait -= 1
end
end
##################################################################################
# KI kämpfer END
#
################################################################################
def give_near_actor
@abstand2 = 0
for event in $game_map.events.values
if event.battler != nil
if event.battler.is_a?(Game_Actor)
abstand = (self.x - event.x).abs + (self.y - event.y).abs
if @abstand2 == 0 or abstand < @abstand2
@abstand2 = abstand
@actorid = event.id
end
end
end
end
abstandp = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if @abstand2 < abstandp and @abstand2 != 0 #and @actorid != 0
@enemytaget = @actorid
else
@enemytaget = -1
end
end
def check_enemys
#if $game_map.events[@taget] == nil
# @taget = 0
@abstand = 0
# end
for event in $game_map.events.values
if event.battler != nil
if event.battler.is_a?(Game_Enemy)
abstand = (self.x - event.x).abs + (self.y - event.y).abs
abstandp = ($game_player.x - event.x).abs + ($game_player.y - event.y).abs
if @abstand == 0 or abstand < @abstand
if abstandp < $game_variables[XAS_BA::SENSOR_VAR]
@abstand = abstand
@taget = event.id
end
end
end
end
end
end
def turn_to_actor
#if @abstand2 == nil
@abstand2 = 0
# end
for event in $game_map.events.values
if event.battler != nil
if event.battler.is_a?(Game_Actor)
abstand = (self.x - event.x).abs + (self.y - event.y).abs
if @abstand2 == 0 or abstand < @abstand2
if abstand < $game_variables[XAS_BA::SENSOR_VAR]
@abstand2 = abstand
@actorid = event.id
end
end
end
end
end
abstandp = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if @abstand2 < abstandp and @abstand2 != 0 #and @actorid != 0
turn_toward_event(@actorid)
else
turn_toward_player
end
end
def turn_away_from_actor
#if @abstand2 == nil
@abstand2 = 0
# end
for event in $game_map.events.values
if event.battler != nil
if event.battler.is_a?(Game_Actor)
abstand = (self.x - event.x).abs + (self.y - event.y).abs
if @abstand2 == 0 or abstand < @abstand2
if abstand < $game_variables[XAS_BA::SENSOR_VAR]
@abstand2 = abstand
@actorid = event.id
end
end
end
end
end
abstandp = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if @abstand2 < abstandp and @abstand2 != 0 #and @actorid != 0
turn_away_from_event(@actorid)
else
turn_away_from_player
end
end
def find_to_player
if jumping? or moving?
return
end
x = self.x
y = self.y
turn_toward_player
if passable?(x,y,@direction)
move_toward_player
move_forward
else
turn_right_or_left_90
if passable?(x,y,@direction)
move_forward
else
turn_180
if passable?(x,y,@direction)
move_forward
else
#move_away_from_player
end
end
end
end
def find_to_actor
if jumping? or moving?
return
end
x = self.x
y = self.y
turn_to_actor
if passable?(x,y,@direction)
move_to_actor
move_forward
else
turn_right_or_left_90
if passable?(x,y,@direction)
move_forward
else
turn_180
if passable?(x,y,@direction)
move_forward
else
move_away_from_actor
end
end
end
end
def find_to_enemy
if jumping? or moving?
return
end
x = self.x
y = self.y
turn_toward_enemy
if passable?(x,y,@direction)
move_to_enemy
move_forward
else
turn_right_or_left_90
if passable?(x,y,@direction)
move_forward
else
turn_180
if passable?(x,y,@direction)
move_forward
else
move_away_from_enemy
end
end
end
end
def flee_from_player
if jumping? or moving?
return
end
x = self.x
y = self.y
turn_away_from_player
if passable?(x,y,@direction)
move_away_from_player
move_forward
else
turn_right_or_left_90
if passable?(x,y,@direction)
move_forward
else
turn_180
if passable?(x,y,@direction)
move_forward
else
move_toward_player
end
end
end
end
def flee_from_actor
if jumping? or moving?
return
end
x = self.x
y = self.y
turn_away_from_actor
if passable?(x,y,@direction)
move_away_from_actor
move_forward
else
turn_right_or_left_90
if passable?(x,y,@direction)
move_forward
else
turn_180
if passable?(x,y,@direction)
move_forward
else
move_to_actor
end
end
end
end
def flee_from_enemy
if jumping? or moving?
return
end
x = self.x
y = self.y
turn_away_from_enemy
if passable?(x,y,@direction)
move_away_from_enemy
move_forward
else
turn_right_or_left_90
if passable?(x,y,@direction)
move_forward
else
turn_180
if passable?(x,y,@direction)
move_forward
else
move_to_enemy
end
end
end
end
def move_to_actor
if jumping? or moving?
return
end
#if @abstand2 == nil
@abstand2 = 0
# end
for event in $game_map.events.values
if event.battler != nil
if event.battler.is_a?(Game_Actor)
abstand = (self.x - event.x).abs + (self.y - event.y).abs
if @abstand2 == 0 or abstand < @abstand2
if abstand < $game_variables[XAS_BA::SENSOR_VAR]
@abstand2 = abstand
@actorid = event.id
end
end
end
end
end
abstandp = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if @abstand2 < abstandp and @abstand2 != 0 #and @actorid != 0
move_toward_event(@actorid)
else
move_toward_player
end
end
def move_away_from_actor
if jumping? or moving?
return
end
#if @abstand2 == nil
@abstand2 = 0
# end
for event in $game_map.events.values
if event.battler != nil
if event.battler.is_a?(Game_Actor)
abstand = (self.x - event.x).abs + (self.y - event.y).abs
if @abstand2 == 0 or abstand < @abstand2
if abstand < $game_variables[XAS_BA::SENSOR_VAR]
@abstand2 = abstand
@actorid = event.id
end
end
end
end
end
abstandp = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if @abstand2 < abstandp and @abstand2 != 0 #and @actorid != 0
move_away_from_event(@actorid)
else
move_away_from_player
end
end
def turn_toward_event(id)
# Get difference in player coordinates
if $game_map.events[id] != nil
sx = @x - $game_map.events[id].x
sy = @y - $game_map.events[id].y
# If coordinates are equal
if sx == 0 and sy == 0
return
end
# If horizontal distance is longer
if sx.abs > sy.abs
# Turn to the right or left towards player
sx > 0 ? turn_left : turn_right
# If vertical distance is longer
else
# Turn up or down towards player
sy > 0 ? turn_up : turn_down
end
end
end
def turn_away_from_event(id)
# Get difference in player coordinates
if $game_map.events[id] != nil
sx = @x - $game_map.events[id].x
sy = @y - $game_map.events[id].y
# If coordinates are equal
if sx == 0 and sy == 0
return
end
# If horizontal distance is longer
if sx.abs > sy.abs
# Turn to the right or left away from player
sx > 0 ? turn_right : turn_left
# If vertical distance is longer
else
# Turn up or down away from player
sy > 0 ? turn_down : turn_up
end
end
end
def move_toward_event(id)
if $game_map.events[id] != nil
sx = @x - $game_map.events[id].x
sy = @y - $game_map.events[id].y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx > abs_sy
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
else
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
end
end
def move_away_from_event(id)
if $game_map.events[id] != nil
sx = @x - $game_map.events[id].x
sy = @y - $game_map.events[id].y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx
if sx < 0 and sy > 0
move_lower_left
elsif sx > 0 and sy > 0
move_lower_right
elsif sx > 0 and sy < 0
move_upper_right
elsif sx < 0 and sy < 0
move_upper_left
elsif sx < 0
move_left
elsif sx > 0
move_right
elsif sy > 0
move_down
elsif sy < 0
move_up
end
end
end
end
end
class Game_Event < Game_Character
attr_reader :collision_attack
def img_act_exist?
begin
RPG::Cache.character(@page.graphic.character_name + "_Act" , @page.graphic.character_hue)
rescue
return false
end
return true
end
def img_spe_exist?(e,g)
begin
y = e.to_s
x = g.to_s
RPG::Cache.character(@page.graphic.character_name + "_[" + x + "]spe" + y , @page.graphic.character_hue)
rescue
return false
end
return true
end
def spe_on(e,g)
y = e.to_s
x = g.to_s
if img_spe_exist?(e,g)
@character_name = @page.graphic.character_name + "_[" + x + "]spe" + y
end
end
def spe1_on
@character_name = @page.graphic.character_name + "_spe1"
end
def spe2_on
@character_name = @page.graphic.character_name + "_spe2"
end
def spe3_on
@character_name = @page.graphic.character_name + "_spe3"
end
def spe_off
@character_name = @page.graphic.character_name
end
def stateattack_on(x)
if self.battler.is_a?(Game_Enemy) and
(self.battler.states.include?(XAS::MUTE_ID) or
self.battler.states.include?(XAS::SEALATTACK_ID))
@collision_attack = false
self.battler.damage = XAS::SEALED_TEXT
self.battler.damage_pop = true
return false
end
shoot(x)
# @collision_attack = true
if img_act_exist?
@character_name = @page.graphic.character_name + "_Act"
end
end
def attack_on
if self.battler.is_a?(Game_Enemy) and
(self.battler.states.include?(XAS::MUTE_ID) or
self.battler.states.include?(XAS::SEALATTACK_ID))
#@collision_attack = false
self.battler.damage = XAS::SEALED_TEXT
self.battler.damage_pop = true
return false
end
shoot(XAS_BA_ENEMY::ENEMY_ATTACK_SKILL)
@collision_attack = true
if img_act_exist?
@character_name = @page.graphic.character_name + "_Act"
end
end
end
Â
#################################################################################
#################################################################################
############################### Resolution #####################################
#################################################################################
#################################################################################
#========================================================================
# Script written by Renan Tsuneo Hangai Junior
#========================================================================
#========================================================================
Â
class Game_Window
 Â
 WINDOW_WIDTH  = 1280 Â
 WINDOW_HEIGHT = 960 Â
 FULLSCREEN = false
Â
  # Fixes viewports?
  # Viewports wide 640 will be treated as width of the screen
  # Viewports in height 480 will be treated as height of the screen
  # Note to scripters ---------------- ----------------
  # By using this script and leave below true, use the method:
  # Viewport.new (x, y, width, height, force_fix)
  # Where if you do not define force_fix will always be true
  # If you leave false, will not fix the standard
 # -----------------------------------------------------
Â
 VIEWPORT_FIX = true
Â
 attr_reader :x
 attr_reader :y
 attr_reader :width
 attr_reader :height
Â
 def initialize
  @gpps = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
  @title = "\0" * 256
  @gpps.call("Game", "Title", "", @title, 256, ".\\Game.ini")
  @title.delete!("\0")
  @set_resolution  = Win32API.new('Display.dll', 'SetResolution', 'III', '')
  @set_window_long  = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
  @set_window_pos  = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
  @gsm        = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
  @gcr        = Win32API.new('user32', 'GetClientRect', 'LP', 'I')
  @window      = Win32API.new('user32', 'FindWindow', 'PP', 'I').call("RGSS Player", @title)
  @kbe        = Win32API.new('user32', 'keybd_event', 'LLLL', '')
  @gaks       = Win32API.new('user32', 'GetAsyncKeyState', 'L', 'I')
  @gks        = Win32API.new('user32', 'GetKeyState', 'L', 'I')
  @default_size = self.size
  @width = WINDOW_WIDTH
  @height = WINDOW_HEIGHT
  if @default_size[0] < @width or @default_size[1] < @height
   print("Necessário uma resolução de vÃdeo de no mÃnimo #{@width} x #{@height}")
   exit
  end
  @x = (self.size[0] / 2) - (@width / 2)
  @y = (self.size[1] / 2) - (@height / 2)
  @height_add = 26
  @width_add = 6
  @state = "normal"
  if FULLSCREEN
   self.fullscreen
  else
   self.center
  end
 end
Â
 def x=(valor)
  @x = valor
  @set_window_long.call(@window, -16, 0x14CA0000)
  @set_window_pos.call(@window, 0, @x, @y, @width + @width_add, @height + @height_add, 0)
 end
Â
 def y=(valor)
  @y = valor
  @set_window_long.call(@window, -16, 0x14CA0000)
  @set_window_pos.call(@window, 0, @x, @y, @width + @width_add, @height + @height_add, 0)
 end
Â
 def fullscreen
  return if @state == "full"
  @window_size = self.asize
  @state = "full"
  @set_window_long.call(@window, -16, 0x14000000)
  @set_window_pos.call(@window, -1, -1, -1, @width + 2, @height + 2, 64)
  @set_resolution.call(@width, @height, 4)
 end
Â
 def normal
  return if @state == "normal"
  @window_size = self.asize
  @state = "normal"
  @set_resolution.call(@default_size[0], @default_size[1], 4)
  @set_window_long.call(@window, -16, 0x14CA0000)
  @set_window_pos.call(@window, 0, @x, @y, @width + @width_add, @height + @height_add, 0)
 end
Â
 def center
  @x = self.size[0] / 2 - (@width / 2)
  @y = self.size[1] / 2 - (@height / 2)
  @set_window_long.call(@window, -16, 0x14CA0000)
  @set_window_pos.call(@window, 0, @x, @y, @width + @width_add, @height + @height_add, 0)
 end
Â
 def size
  width = @gsm.call(0)
  height = @gsm.call(1)
  return width, height
 end
Â
 def asize
  rect = [0, 0, 0, 0].pack('l4')
  @gcr.call(@window, rect)
  width, height = rect.unpack('l4')[2..3]
  return width, height
 end
Â
 def trigger?(key)
  return (@gaks.call(key) & 0x01 == 1)
 end
Â
 def pressed?(key)
  return (not @gks.call(key).between?(0, 1))
 end
Â
 def update
  @kbe.call(18, 0, 2, 0)
  if self.trigger?(115) or self.pressed?(115)
   exit
  end
  if self.trigger?(122)
   self.change
   Graphics.update
   sleep(0.1)
   Graphics.update
  end
 end
Â
 def change
  if @state == "normal"
   self.fullscreen
  else
   self.normal
  end
 end
Â
end
Â
if Game_Window::VIEWPORT_FIX
Â
 class Viewport
 Â
  alias resolution_viewport_initialize initialize
 Â
  def initialize(x, y, w, h, fix=true)
   if fix
    if w == 640
     w = 1280
    end
    if h == 480
     h = 960
    end
   end
   resolution_viewport_initialize(x, y, w, h)
  end
 Â
 end
Â
end
Â
module Graphics
Â
 class << self
 Â
  alias game_resolution_graphics_update update
 Â
  def update
   game_resolution_graphics_update
   $window.update
  end
Â
 end
Â
end
Â
$window = Game_Window.new
Â
class Game_Player < Game_Character
Â
 CENTER_X = ($window.width / 2 - 16) * 4
 CENTER_Y = ($window.height / 2 - 16) * 4
 Â
 def center(x, y)
  @@center_x = ($window.width / 2 - 16) * 4
  @@center_y = ($window.height / 2 - 16) * 4
  maxsizex = ($window.width / 32.0) # .ceil
  maxsizey = ($window.height / 32.0) # .ceil
  max_x = (($game_map.width - maxsizex) * 128).to_i
  max_y = (($game_map.height - maxsizey) * 128).to_i
  $game_map.display_x = [0, [x * 128 - @@center_x, max_x].min].max
  $game_map.display_y = [0, [y * 128 - @@center_y, max_y].min].max
 end
Â
end
Â
class Game_Map
Â
 #--------------------------------------------------------------------------
 # - Scroll para Baixo
 #
 #   distance : distância do scroll
 #--------------------------------------------------------------------------
Â
 def scroll_down(distance)
  @display_y = [@display_y + distance, (self.height * 128) - ($window.height * 4)].min
 end
Â
 #--------------------------------------------------------------------------
 # - Scroll para Direita
 #
 #   distance : distância do scroll
 #--------------------------------------------------------------------------
Â
 def scroll_right(distance)
  @display_x = [@display_x + distance, (self.width * 128) - ($window.width * 4)].min
 end
Â
end
Â
class Tilemap
 #--------------------------------------------------------------------------
  attr_accessor :tileset
  attr_accessor :tileset
  attr_accessor :autotiles
  attr_accessor :map_data
  attr_accessor :flash_data
  attr_accessor :priorities
  attr_accessor :visible
  attr_accessor :ox
  attr_accessor :oy
 #--------------------------------------------------------------------------
 def initialize(viewport)
  @map = []
  width, height = $game_map.width * 32, $game_map.height * 32
  for p in 0...2
   @map[p] = Sprite.new(viewport)
   @map[p].bitmap = Bitmap.new(width, height )
  end
  @map[0].z = 0
  @map[1].z = 3000
  @tileset_tile_width = 32
  @tileset_tile_height = 32
  @tileset = nil
  @autotiles = []
  @autotiles2 = []
  @map_data = nil
  @data = nil
  @flash_data = nil
  @priorities = nil
  @visible = true
  @ox = 0
  @oy = 0
 end
 #--------------------------------------------------------------------------
 def update
  if @data != @map_data
   refresh
  end
 end
 def ox=(valor)
  return if @ox == valor
  @ox = valor
  for p in 0...2
   @map[p].ox = @ox
  end
 end
 def oy=(valor)
  return if @oy == valor
  @oy = valor
  for p in 0...2
   @map[p].oy = @oy
  end
 end
 #--------------------------------------------------------------------------
 def refresh
  @data = @map_data
  generate_autotiles2
  for p in 0..5
   for z in 0...@map_data.zsize
    for x in 0...@map_data.xsize
     for y in 0...@map_data.ysize
      id = @map_data[x,y,z]
      next if @priorities[id] != p
      refresh_autotiles(x,y,p,id) if id < 384
      refresh_tileset(x,y,p,id) if id >= 384
     end
    end
   end
  end
 end
 #--------------------------------------------------------------------------
 def refresh_autotiles(x,y,p,id)
  p = [p, 1].min
  if id >= 48 and id <= 95
   sy = id - 48
   sy /= 8
   sx = id - 48
   sx = sx - (8 * sy)
   src_rect = Rect.new(sx*32, sy*32, 32, 32)
   @map[p].bitmap.blt(x*32, y*32, @autotiles2[0], src_rect)
  end
 end
 #--------------------------------------------------------------------------
 def refresh_tileset(x,y,p,id)
  p = [p, 1].min
  sy = id - 384
  sy /= 8
  sx = id - 384
  sx = sx - (8 * sy)
  src_rect = Rect.new(sx*32, sy*32, 32, 32)
  @map[p].bitmap.blt(x*32, y*32, @tileset, src_rect)
 end
 #--------------------------------------------------------------------------
 def dispose
  for p in 0...2
   @map[p].bitmap.dispose
  end
 end
 #======================================
 #  ■Generates Autotiles
 #  By: Fuso
 #  Generates the tiles used by the game (can be seen in the editor by
 #  doubleclicking an autotile field), from the images given as
 #  resources.
 #======================================
 def generate_autotiles2(ats = @autotiles, frame_id = 0)
  h = 32
  w = 32
  for at in 0..6
   @autotiles2[at] = Bitmap.new(@tileset_tile_width * 8, @tileset_tile_height * 6) if @autotiles2[at].nil?
   break if at >= @autotiles.size
   # Generate the 16 tiles containing water and a number of corners.
   # Each bit in i will represent whether or not a certain corner will be filled in.
   for i in 0...16
    @autotiles2[at].blt(i % 8 * w,       i / 8 * h,       ats[at], Rect.new(frame_id * 3 * w + w,      2 * h, w,    h)) if i < 15
    @autotiles2[at].blt(i % 8 * w,       i / 8 * h,       ats[at], Rect.new(frame_id * 3 * w + 2 * w,    0,    w / 2, h / 2)) if i & 0x1 == 0x1
    @autotiles2[at].blt(i % 8 * w + w / 2, i / 8 * h,       ats[at], Rect.new(frame_id * 3 * w + 5 * w / 2, 0,    w / 2, h / 2)) if i & 0x2 == 0x2
    @autotiles2[at].blt(i % 8 * w + w / 2, i / 8 * h + h / 2, ats[at], Rect.new(frame_id * 3 * w + 5 * w / 2, h / 2, w / 2, h / 2)) if i & 0x4 == 0x4
    @autotiles2[at].blt(i % 8 * w,       i / 8 * h + h / 2, ats[at], Rect.new(frame_id * 3 * w + 2 * w,    h / 2, w / 2, h / 2)) if i & 0x8 == 0x8
   end
   # Generate the 16 tiles containing a certain whole strip + up to 2 corners.
   # The two most signifant bits will hold the direction of the strip and the other
   # two bits whether or not the remaining 2 corners will be filled in.
   for i in 0...16
    d = i / 4
    # The strip.
    #@autotiles2[at].blt(i % 8 * w + (d==3 ? w / 2 : 0), 2 * h + i / 8 * h + (d==4 ? h / 2 : 0), ats[at],
    #  Rect.new(d == 0 ? 0 : d == 2 ? 5 * d / 4 : d, d == 1 ? h : d == 3 ? 7 * h / 4 : 2 * h,
    #        (d&3 + 1) * w / 2, (4 - d&3) * h / 2))
    @autotiles2[at].blt(i % 8 * w, (2 + i / 8) * h, ats[at], Rect.new(frame_id * 3 * w + d == 0 ? 0 : d == 2 ? 2 * w : w, d == 1 ? h : d == 3 ? 3 * h : 2 * h, w, h))
    l1 = (d + 1)%4
    l2 = (d + 2)%4
    x1 = (l1 == 1 or l1 == 2) ? w / 2 : 0
    x2 = (l2 == 1 or l2 == 2) ? w / 2 : 0
    y1 = l1/2 * h / 2
    y2 = l2/2 * h / 2
    @autotiles2[at].blt(i % 8 * w + x1, (2 + i / 8) * h + y1, ats[at], Rect.new(frame_id * 3 * w + 2 * w + x1, y1, w / 2,  h / 2)) if i & 0x1 == 0x1
    @autotiles2[at].blt(i % 8 * w + x2, (2 + i / 8) * h + y2, ats[at], Rect.new(frame_id * 3 * w + 2 * w + x2, y2, w / 2,  h / 2)) if i & 0x2 == 0x2
   end
   # The "double-strip" tiles.
   @autotiles2[at].blt(0,    4 * h,      ats[at], Rect.new(frame_id * 3 * w + 0,       2 * h,       w,    h))
   @autotiles2[at].blt(w / 2, 4 * h,      ats[at], Rect.new(frame_id * 3 * w + 5 * w / 2, 2 * h,       w / 2, h))
   @autotiles2[at].blt(w,    4 * h,      ats[at], Rect.new(frame_id * 3 * w + w,       h,          w,    h))
   @autotiles2[at].blt(w,    4 * h + h /2, ats[at], Rect.new(frame_id * 3 * w + w,       3 * h + h / 2, w, h / 2))
   for i in 0...4
    @autotiles2[at].blt((2 + 2 * i)%8 * w, (4 + i/3) * h, ats[at], Rect.new(frame_id * 3 * w + ((i == 1 or i == 2) ? 2 * w : 0), ((i&2) + 1) * h, w, h))
    @autotiles2[at].blt((3 + 2 * i)%8 * w, (4 + i/3) * h, ats[at], Rect.new(frame_id * 3 * w + ((i == 1 or i == 2) ? 2 * w : 0), ((i&2) + 1) * h, w, h))
    l = (i + 2)%4
    x = (l == 1 or l == 2) ? w / 2 : 0
    y = l/2 * h / 2
    @autotiles2[at].blt((3 + 2 * i)%8 * w + x, (4 + i/3) * h + y, ats[at], Rect.new(frame_id * 3 * w + 2 * w + x, y, w / 2,  h / 2))
   end
   for i in 0...4
    @autotiles2[at].blt((i + 2) * w, 5 * h, ats[at], Rect.new(frame_id * 3 * w + i/2 * 2 * w, (i == 1 or i == 2) ? 3 * h : h, w, h))
    l = (i + 3) % 4
    dx = (l == 3 ? w / 2 : 0)
    dy = (l == 2 ? h / 2 : 0)
    tx = (l < 2 ? 0 : 2 * w)
    ty = (l == 0 ? 0 : l == 3 ? 0 : 2 * h)
    @autotiles2[at].blt((i + 2) * w + dx, 5 * h + dy, ats[at], Rect.new(frame_id * 3 * w + tx + dx, h + ty + dy, w - l%2 * w / 2, h / 2 + l%2 * h / 2))
   end
   # The final two squares which is simply the upper left one and possiby a merge of the
   # inner corners, we'll make them both the first tile for now.
   @autotiles2[at].blt(6 * w, 5 * h, ats[at], Rect.new(0, 0, w, h))
   @autotiles2[at].blt(7 * w, 5 * h, ats[at], Rect.new(0, 0, w, h))
  end
 end
end
Â
class Spriteset_Map
 #--------------------------------------------------------------------------
 def initialize
  width, height  = $window.size
  @viewport1 = Viewport.new(0, 0, width, height)
  @viewport_panormas = []
  for i in 1..4
   x = ((i - 1) % 2) * 640
   y = ((i - 1) / 2) * 480
   v = Viewport.new(x, y, 640, 480)
   v.z = @viewport1.z - 1
   @viewport_panormas.push(v)
  end
  @viewport_fogs = []
  for i in 1..4
   x = ((i - 1) % 2) * 640
   y = ((i - 1) / 2) * 480
   v = Viewport.new(x, y, 640, 480)
   v.z = @viewport1.z + 1
   @viewport_fogs.push(v)
  end
  @viewport2 = Viewport.new(0, 0, width, height)
  @viewport3 = Viewport.new(0, 0, width, height)
  @viewport2.z = 200
  @viewport3.z = 5000
  @tilemap = Tilemap.new(@viewport1)
  @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  for i in 0..6
   autotile_name = $game_map.autotile_names[i]
   @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  end
  @tilemap.map_data = $game_map.data
  @tilemap.priorities = $game_map.priorities
  @panoramas = []
  panorama = Plane.new(@viewport_panormas[0])
  panorama.z = -1000
  @panoramas.push(panorama)
  panorama = Plane.new(@viewport_panormas[1])
  panorama.z = -1000
  @panoramas.push(panorama)
  panorama = Plane.new(@viewport_panormas[2])
  panorama.z = -1000
  @panoramas.push(panorama)
  panorama = Plane.new(@viewport_panormas[3])
  panorama.z = -1000
  @panoramas.push(panorama)
  @fogs = []
  fog = Plane.new(@viewport_fogs[0])
  fog.z = 3000
  @fogs.push(fog)
  fog = Plane.new(@viewport_fogs[1])
  fog.z = 3000
  @fogs.push(fog)
  fog = Plane.new(@viewport_fogs[2])
  fog.z = 3000
  @fogs.push(fog)
  fog = Plane.new(@viewport_fogs[3])
  fog.z = 3000
  @fogs.push(fog)
  @character_sprites = []
  for i in $game_map.events.keys.sort
   sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
   @character_sprites.push(sprite)
  end
  @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  @weather = RPG::Weather.new(@viewport1)
  @picture_sprites = []
  for i in 1..50
   @picture_sprites.push(Sprite_Picture.new(@viewport2,
    $game_screen.pictures[i]))
  end
  @timer_sprite = Sprite_Timer.new
  update
 end
Â
 #--------------------------------------------------------------------------
 # - Display
 #--------------------------------------------------------------------------
Â
 def dispose
 Â
  @tilemap.tileset.dispose
  for i in 0..6
   @tilemap.autotiles[i].dispose
  end
  @tilemap.dispose
 Â
  for panorama in @panoramas
   panorama.dispose
  end
 Â
  for fog in @fogs
   fog.dispose
  end
 Â
  for sprite in @character_sprites
   sprite.dispose
  end
 Â
  @weather.dispose
 Â
  for sprite in @picture_sprites
   sprite.dispose
  end
 Â
  @timer_sprite.dispose
 Â
  @viewport1.dispose
  for v in @viewport_panormas + @viewport_fogs
   v.dispose
  end
  @viewport2.dispose
  @viewport3.dispose
 end
Â
 #--------------------------------------------------------------------------
 # - Frame Update
 #--------------------------------------------------------------------------
Â
 def update
 Â
  if @panorama_name != $game_map.panorama_name or
   @panorama_hue != $game_map.panorama_hue
   @panorama_name = $game_map.panorama_name
   @panorama_hue = $game_map.panorama_hue
   if @panorama_bitmap != nil
    @panorama_bitmap.dispose
    @panorama_bitmap = nil
   end
   if @panorama_name != ""
    @panorama_bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
    for p in @panoramas
     p.bitmap = @panorama_bitmap
    end
   end
   Graphics.frame_reset
  end
  #
  if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
   @fog_name = $game_map.fog_name
   @fog_hue = $game_map.fog_hue
   if @fog_bitmap != nil
    @fog_bitmap.dispose
    @fog_bitmap = nil
   end
   if @fog_name != ""
    @fog_bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
    for p in @fogs
     p.bitmap = @fog_bitmap
    end
   end
   Graphics.frame_reset
  end
 Â
  @tilemap.ox = $game_map.display_x / 4
  @tilemap.oy = $game_map.display_y / 4
  @tilemap.update
 Â
  for i in [email=0...@panoramas.size]0...@panoramas.size[/email]
   panorama = @panoramas[i]
   rwadd = (i % 2) * (@panorama_bitmap.nil? ? 0 : 640 - @panorama_bitmap.width)
   rhadd = (i / 2) * (@panorama_bitmap.nil? ? 0 : 480 - @panorama_bitmap.height)
   panorama.ox = $game_map.display_x / 8 + rwadd
   panorama.oy = $game_map.display_y / 8 + rhadd
  end
  for i in [email=0...@fogs.size]0...@fogs.size[/email]
   fog = @fogs[i]
  Â
   fog.zoom_x = $game_map.fog_zoom / 100.0
   fog.zoom_y = $game_map.fog_zoom / 100.0
   fog.opacity = $game_map.fog_opacity
   fog.blend_type = $game_map.fog_blend_type
   rwadd = (i % 2) * (@fog_bitmap.nil? ? 0 : (@fog_bitmap.width) / 2)
   rhadd = (i / 2) * 480
   fog.ox = $game_map.display_x / 4 + $game_map.fog_ox + rwadd
   fog.oy = $game_map.display_y / 4 + $game_map.fog_oy + rhadd
   fog.tone = $game_map.fog_tone
  end
 Â
  for sprite in @character_sprites
   sprite.update
  end
 Â
  @weather.type = $game_screen.weather_type
  @weather.max = $game_screen.weather_max
  @weather.ox = $game_map.display_x / 4
  @weather.oy = $game_map.display_y / 4
  @weather.update
 Â
  for sprite in @picture_sprites
   sprite.update
  end
 Â
  @timer_sprite.update
 Â
  @viewport1.tone = $game_screen.tone
  @viewport1.ox = $game_screen.shake
  for v in @viewport_panormas + @viewport_fogs
   v.tone = $game_screen.tone
   v.ox = $game_screen.shake
  end
 Â
  @viewport3.color = $game_screen.flash_color
 Â
  @viewport1.update
  @viewport3.update
 end
end
#_________________________________________________
# MOG_Animated Panorama V1.3
#_________________________________________________
# By Moghunter
# [url=http://www.atelier-rgss.com]http://www.atelier-rgss.com[/url]
#_________________________________________________
# Deixa o panorama animado, animando-o por frames.
# É necessário ter as imagens extras dos frames para que a
#animação ocorra.
#EXP de nomeação
#
#Nuvem.png (Frame 1)(Essa é a imagem do Database)
#Nuvem0.png (Frame 2)
#Nuvem1.png (Frame 3)
#Nuvem2.png (Frame 4)
#Etc...
#_________________________________________________
module MOG
#Velocidade da animação
PANOREFRESH = 5
end
$mogscript = {} if $mogscript == nil
$mogscript["anime_panorama"] = true
class Spriteset_Map
alias mog14_initialize initialize
def initialize
@panospeed = 0
@panoframes = 0
mog14_initialize
end
alias mog14_update update
def update
mog14_update
@panospeed += 1
if @panospeed > MOG::PANOREFRESH
@panospeed = 0
@panoframes += 1
end
if @panorama.bitmap != nil
@panorama.bitmap = RPG::Cache.panorama(@panorama_name + @panoframes.to_s, @panorama_hue) rescue nil
end
if @panorama.bitmap == nil
@panoframes = 0
@panorama.bitmap = RPG::Cache.panorama(@panorama_name + @panoframes.to_s, @panorama_hue) rescue nada
end
end
def nada
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
end
end
module XAS_RESPAWN
#
#A=>B
#A = ENEMY ID
#B = RESPAWN DELAY
#Enemy will only respawn if you give them a delay time (it can be 0)
#
TIME = {
2 => 1
}
# The enemy will spawn at any passable point (normaly they spawn at the start point)
RANDOM_SPAWN = [
2
]
# The enemy will spawn at the dying point (normaly they spawn at the start point)
DYING_SPAWN = [
3
]
end
class Game_Event < Game_Character
include XRXS_BattlerAttachment
alias xrxs64c_update2 update
def update
if @collapse_wait_count.to_i > 0
@collapse_wait_count -= 1
if @collapse_wait_count == 0
@collapse_wait_count = nil
if @waittime == nil
@waittime = XAS_RESPAWN::TIME[self.battler.id]
if @waittime == nil
$game_map.remove_token(self)
end
else
@waittime -= 1
if @waittime == 0
if XAS_RESPAWN::RANDOM_SPAWN.include?(self.battler.id)
until @pass == true
x = rand($game_map.width)
y = rand($game_map.width)
if passable?(x, y, 0)
@pass = true
end
end
moveto(x,y)
@pass = false
else
unless XAS_RESPAWN::DYING_SPAWN.include?(self.battler.id)
moveto(@event.x, @event.y)
end
end
self.battler.recover_all
self.collapse_done = false
$scene.spriteset.refresh
@waittime = nil
end
end
end
return
end
update_sensor
xrxs64c_update2
if self.battler != nil
self.battler.remove_states_auto
end
if self.collapse_duration.to_i > 0
@through = true
end
if self.collapse_done
@opacity = 0
@collapse_wait_count = 32
return
end
end
end
class Spriteset_Map
def refresh
$game_map.need_refresh = true
unless @character_sprites == nil
for sprite in @character_sprites
sprite.dispose
end
end
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
end
end
class Scene_Map
attr_accessor :spriteset
end