A little Message from the Author

Hello Everyone! Listed below are some valuable scripts that you can use in your rpg games. Note that I did not made this scripts. They are simply scripts that are distributed in the internet that I had gathered here. Please give credits to the author of this scripts if you intend to use them in your rpg maker project. Hope you enjoy making your game!

Click the Title of the script to view the script's content.

_______________________________________________RPG Maker VX Scripts Collections________________________________________

Add a Simple Mini Map


Add a mini map in the game, you can add just its orientation in the game screen.


Start copying here:


#==============================================================================
# MiniMap
#==============================================================================
# Author  : OriginalWij
# Version : 1.0
#==============================================================================

#==============================================================================
# NOTE: This newest version is the ONLY supported version!
#
# v1.0
# - Initial release
#==============================================================================

#==============================================================================
# Config
#==============================================================================

module OW_MM
  # Global MiniMap DISABLE switch [switch ID] (default = 1)
  SWITCH = 21
  # Map name tag to DISABLE MiniMap (default = '[NOMINI]')
  NO_MM = '[NOMINI]'
  # MiniMap parameters (default = [6, 6, 100, 136, 104])
  #   syntax: [x, y, z, width, height]
  PARAM = [375, 6, 100, 136, 104]
  # Expanded size multiplier (default = 3.0)
  # (PARAM[3] * EXPANDED & PARAM[4] * EXPANDED)
  EXPANDED = 3.0
  # MiniMap refresh rate [in frames] (default = 2; minimum = 1)
  # [raise this slightly to lower lag on some slower PCs]
  REFRESH = 2
  # MiniMap pixels separate? (default = true)
  # [false = no spaces between pixels & can use smaller pixel size below]
  SEPARATE = true
  # MiniMap object-pixel size [in pixels] (default = 5)
  # [minimum = 4 if SEPARATE = true; minimum = 2 if SEPARATE = false]
  PIXEL = 5
  # Show vehicles on MiniMap initial setting (default = true)
  # [use $game_map.show_vehicles = true/false to toggle in-game]
  VEHICLES = true
  # MiniMap colors
  #   syntax: Color.new(red, green, blue, alpha)
  CLR_B = Color.new(  0, 160, 160, 192) # border [Color.new(0, 0, 0, 0) = none]
  CLR_P = Color.new(225, 225, 225, 160) # passable tile
  CLR_I = Color.new(  0,   0,   0, 160) # impassable tile
  CLR_C = Color.new(  0, 128,   0, 192) # player character
  CLR_F = Color.new(  0, 255,   0, 192) # player character border (frame)
  CLR_V = Color.new(128, 255,   0, 192) # vehicles
  # Event Colors [place ONE of the tags defined below in a comment in an event]
  #   syntax: CLR_E['[tag]'] = [Color.new(r, g, b, a), trigger]
  #     trigger = 0 ... always show
  #     trigger > 0 ... show only when switch on/true [trigger = switch_ID]
  #     trigger < 0 ... show only when party has item [trigger = -(item_ID)]
  CLR_E = {} # <-- do NOT modify!
  CLR_E['[NPC]']   = [Color.new(  0,  64, 255, 160), 0] # NPC's
  CLR_E['[CHEST]'] = [Color.new(255, 128,   0, 160), 2] # chests
  CLR_E['[MOB]']   = [Color.new(255,   0,   0, 160), 0] # monsters
  CLR_E['[SHOP]']  = [Color.new(255, 192,   0, 160), 0] # shops
  CLR_E['[EXIT]']  = [Color.new(192,   0, 255, 160), 0] # teleports
  # START CUSTOM TAGS
  CLR_E['[SWITCH]'] = [Color.new(  0, 255, 255, 160), -21] # switches
  # END CUSTOM TAGS
end

#==============================================================================
# Game_Map
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # Public Instance Variables                                           [New]
  #--------------------------------------------------------------------------
  attr_accessor :expanded
  attr_accessor :show_vehicles
  #--------------------------------------------------------------------------
  # Initialize                                                          [Mod]
  #--------------------------------------------------------------------------
  alias ow_minimap_game_map_initialize initialize unless $@
  def initialize
    @expanded = false
    @show_vehicles = OW_MM::VEHICLES
    ow_minimap_game_map_initialize
  end
  #--------------------------------------------------------------------------
  # Get Map Name                                                        [New]
  #--------------------------------------------------------------------------
  def map_name
    name = load_data("Data/MapInfos.rvdata")[@map_id].name
    return name
  end
  #--------------------------------------------------------------------------
  # Show Minimap?                                                       [New]
  #--------------------------------------------------------------------------
  def show_minimap?
    return false if self.map_name.include?(OW_MM::NO_MM)
    return false if $game_switches[OW_MM::SWITCH]
    return true
  end
end

#==============================================================================
# Game_Event
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # Public Instance Variables                                           [New]
  #--------------------------------------------------------------------------
  attr_reader   :page
  #--------------------------------------------------------------------------
  # Get Comment                                                         [New]
  #--------------------------------------------------------------------------
  def comment?(comment, return_data = false)
    if !@list.nil?
      for i in 0...@list.size
        next if @list[i].code != 108 and @list[i].code != 408
        if @list[i].parameters[0].include?(comment)
          return return_data ? @list[i].parameters[0] : true
        end
      end
    end
    return return_data ? nil : false
  end
end

#==============================================================================
# Game_Vehicle
#==============================================================================

class Game_Vehicle < Game_Character
  #--------------------------------------------------------------------------
  # Public Instance Variables                                           [New]
  #--------------------------------------------------------------------------
  attr_reader   :map_id
end

#==============================================================================
# Game_MiniMap                                                            [New]
#==============================================================================

class Game_MiniMap
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize
    @refresh = [OW_MM::REFRESH, 1].max
    refresh
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh(map_id = $game_map.map_id)
    dispose_minimap
    @map_id, @mm_rect = map_id, OW_MM::PARAM
    rx, ry, rw, rh = @mm_rect[0], @mm_rect[1], @mm_rect[3], @mm_rect[4]
    rw *= OW_MM::EXPANDED if $game_map.expanded
    rh *= OW_MM::EXPANDED if $game_map.expanded
    rect = Rect.new(rx, ry, rw, rh)
    @px = [OW_MM::PIXEL, (OW_MM::SEPARATE ? 4 : 2)].max
    @px *= OW_MM::EXPANDED if $game_map.expanded
    w, h = rw + 4, rh + 4
    @lx = $game_map.loop_horizontal? ? 3 : 1
    @ly = $game_map.loop_vertical? ? 3 : 1
    bw, bh = $game_map.width * @lx * @px + rw, $game_map.height * @ly * @px + rh
    # Create & Draw Border
    @border = Sprite.new
    @border.x, @border.y = rx - 2, ry - 2
    @border.bitmap = Bitmap.new(w, h)
    @border.bitmap.fill_rect(@border.bitmap.rect, OW_MM::CLR_B)
    @border.bitmap.clear_rect(2, 2, w - 4, h - 4)
    # Create Map Layer
    @map = Sprite.new
    @map.x, @map.y = rx, ry
    @map.z = @mm_rect[2]
    @map.bitmap = Bitmap.new(bw, bh)
    @map.src_rect = rect
    # Create Event Layer
    @events = Sprite.new
    @events.x, @events.y = rx, ry
    @events.z = @mm_rect[2] + 1
    @events.bitmap = Bitmap.new(bw, bh)
    @events.src_rect = rect
    # Create & Draw Player
    pb = Bitmap.new(@px, @px)
    pb.fill_rect(pb.rect, OW_MM::CLR_F)
    pb.fill_rect(pb.rect.x + 1, pb.rect.y + 1, @px - 2, @px - 2, OW_MM::CLR_C)
    @player = Sprite_Base.new
    size = [rect.width.to_f / @px.to_f / 2.0, rect.height.to_f / @px.to_f / 2.0]
    @player.x, @player.y = rx + size[0] * @px, ry + size[1] * @px
    @player.z = @mm_rect[2] + 2
    @player.bitmap = pb
    # Draw MiniMap
    draw_map
    draw_events
    @map.src_rect.x = @events.src_rect.x = $game_player.real_x * @px / 256
    @map.src_rect.y = @events.src_rect.y = $game_player.real_y * @px / 256
  end
  #--------------------------------------------------------------------------
  # Update
  #--------------------------------------------------------------------------
  def update
    if @old_map_id != @map_id or @old_vtype != $game_player.vehicle_type
      @old_map_id = @map_id
      @old_vtype = $game_player.vehicle_type
      dispose_minimap
      refresh
    end
    if Graphics.frame_count % @refresh == 0
      draw_events
      xa = @lx > 1 ? ($game_map.width * 256) : 0
      ya = @ly > 1 ? ($game_map.height * 256) : 0
      mx = ($game_player.real_x + xa) * @px / 256
      my = ($game_player.real_y + ya) * @px / 256
      @map.src_rect.x = @events.src_rect.x = mx
      @map.src_rect.y = @events.src_rect.y = my
      if @border.visible and @border.opacity != $game_map.screen.brightness
        sb = $game_map.screen.brightness
        @border.opacity = @map.opacity = @events.opacity = @player.opacity = sb
      end
    end
  end
  #--------------------------------------------------------------------------
  # Dispose MiniMap
  #--------------------------------------------------------------------------
  def dispose_minimap
    (@border.bitmap.dispose; @border.dispose) unless @border.nil?
    (@map.bitmap.dispose; @map.dispose) unless @map.nil?
    (@events.bitmap.dispose; @events.dispose) unless @events.nil?
    (@player.bitmap.dispose; @player.dispose) unless @player.nil?
  end
  #--------------------------------------------------------------------------
  # Draw Map
  #--------------------------------------------------------------------------
  def draw_map
    bitmap = @map.bitmap
    bitmap.clear
    bitmap.fill_rect(bitmap.rect, OW_MM::CLR_I)
    w = $game_map.expanded ? @mm_rect[3] * OW_MM::EXPANDED : @mm_rect[3]
    h = $game_map.expanded ? @mm_rect[4] * OW_MM::EXPANDED : @mm_rect[4]
    rw, rh = w / 2, h / 2
    ($game_map.width * @lx).times do |x|
      ($game_map.height * @ly).times do |y|
        cx, cy = x % $game_map.width, y % $game_map.height
        case $game_player.vehicle_type
        when 0; next unless $game_map.boat_passable?(cx, cy)   # Boat
        when 1; next unless $game_map.ship_passable?(cx, cy)   # Ship
        when 2; next unless $game_map.airship_land_ok?(cx, cy) # Airship
        else                                                   # Player
          unless $game_player.passable?(cx, cy)
            ev = $game_map.events_xy(cx, cy)
            next if !ev.empty? and ev[0].page.move_type == 0
            next if !$game_player.pos?(cx, cy) and ev.empty?
          end
        end
        px, os = (OW_MM::SEPARATE ? @px - 2 : @px), (OW_MM::SEPARATE ? 1 : 0)
        rect = Rect.new(rw + @px * x + os, rh + @px * y + os, px, px)
        bitmap.fill_rect(rect, OW_MM::CLR_P)
      end
    end
  end
  #--------------------------------------------------------------------------
  # Draw Events
  #--------------------------------------------------------------------------
  def draw_events
    # Get Tagged Events
    @tag_events = {}
    for event in $game_map.events.values
      for key in OW_MM::CLR_E.keys
        comment = event.comment?(key, true)
        unless comment.nil?
          @tag_events[key] = [] if @tag_events[key].nil?
          @tag_events[key] << event
          break
        end
      end
    end
    # Draw Tagged Events
    bitmap = @events.bitmap
    bitmap.clear
    px, os = (OW_MM::SEPARATE ? @px - 2 : @px), (OW_MM::SEPARATE ? 1 : 0)
    rect = Rect.new(0, 0, px, px)
    w = $game_map.expanded ? @mm_rect[3] * OW_MM::EXPANDED / 2 : @mm_rect[3] / 2
    h = $game_map.expanded ? @mm_rect[4] * OW_MM::EXPANDED / 2 : @mm_rect[4] / 2
    @tag_events.each do |key, events|
      color = OW_MM::CLR_E[key][0]
      next if events.nil? or color.nil?
      if OW_MM::CLR_E[key][1] > 0    # switch trigger
        next unless $game_switches[OW_MM::CLR_E[key][1]]
      elsif OW_MM::CLR_E[key][1] < 0 # item trigger
        item = $data_items[OW_MM::CLR_E[key][1].abs]
        next if $game_party.item_number(item) < 1
      end
      events.each do |event|
        rect.x = w + (event.real_x * @px / 256) + os
        rect.y = h + (event.real_y * @px / 256) + os
        @lx.times do |lx| @ly.times { |ly|
          ax = (($game_map.width * 256) * @px / 256) * lx
          ay = (($game_map.height * 256) * @px / 256) * ly
          bitmap.fill_rect(rect.x + ax, rect.y + ay, px, px, color) }
        end
      end
    end
    # Draw Vehicles
    if $game_map.show_vehicles
      for vehicle in $game_map.vehicles
        next unless vehicle.map_id == $game_map.map_id
        rect.x = w + (vehicle.real_x * @px / 256) + os
        rect.y = h + (vehicle.real_y * @px / 256) + os
        @lx.times do |lx| @ly.times { |ly|
          ax = (($game_map.width * 256) * @px / 256) * lx
          ay = (($game_map.height * 256) * @px / 256) * ly
          bitmap.fill_rect(rect.x + ax, rect.y + ay, px, px, OW_MM::CLR_V) }
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # Get Visibility
  #--------------------------------------------------------------------------
  def visible
    return @border.visible
  end
  #--------------------------------------------------------------------------
  # Set Visibility
  #--------------------------------------------------------------------------
  def visible=(bool)
    @border.visible = @map.visible = @events.visible = @player.visible = bool
  end
end

#==============================================================================
# Spriteset_Map
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # Initialize                                                          [Mod]
  #--------------------------------------------------------------------------
  alias ow_minimap_spriteset_map_initialize initialize unless $@
  def initialize
    @minimap = Game_MiniMap.new
    ow_minimap_spriteset_map_initialize
  end
  #--------------------------------------------------------------------------
  # Dispose                                                             [Mod]
  #--------------------------------------------------------------------------
  alias ow_minimap_spriteset_map_dispose dispose unless $@
  def dispose
    @minimap.dispose_minimap; minimap = nil
    ow_minimap_spriteset_map_dispose
  end
  #--------------------------------------------------------------------------
  # Update                                                              [Mod]
  #--------------------------------------------------------------------------
  alias ow_minimap_spriteset_map_update update unless $@
  def update
    @minimap.visible = $game_map.show_minimap?
    @minimap.update if @minimap.visible
    @minimap.refresh if @old_expanded != $game_map.expanded
    @old_expanded = $game_map.expanded
    ow_minimap_spriteset_map_update
  end
end