Da
Ally
Nome Script: KMS Minimap
Versione: N/D
Autore/i: tomy, traduzione EN by Mr. Bubble
Informazioni:
Con lo script รจ possibile visualizzare l'HUD della mini mappa in cima allo schermo di gioco =)
Screenshots:
Istruzioni:
Inserite lo script sotto Material.
Istruzioni all'interno dello script.
Script:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ โ Minimap - KMS_MiniMap โ VXAce โ
#_/ โ Last update : 2012/01/08 (TOMY@Kamesoft) โ
#_/ โ Website: http://ytomy.sakura.ne.jp/
#_/ โ Translated by Mr. Bubble
#_/----------------------------------------------------------------------------
#_/ Adds a minimap display.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# This script is plug-and-play, but various customization options are available.
#
# To complete disable the minimap on a specific map, add [NOMAP] to the
# beginning of map name. You can also use the tag <minimap hide> in the notebox.
#----------------------------------------------------------------------------
# Map Notetags
#----------------------------------------------------------------------------
# Map notetags are added to "Note" boxes. Right-click a map and select
# Map Properties to find the "Note" box for maps.
#
# <minimap hide>
# Completely disables the minimap on a specific map. [NOMAP] can also be
# added to the beginning of map names for the same effect.
#----------------------------------------------------------------------------
# Event Comment Tags
#----------------------------------------------------------------------------
# Since events do not have noteboxes, comment tags are used instead. Open the
# event, create a new event command, go to Tab 1, and click the "Comment..."
# event command. A box will open up allowing you to enter tags.
#
# <minimap wall>
# Add this tag to an event's comment to change its minimap color to the
# same as an impassable tile.
#
# <minimap move>
# Add this tag to an event's comment to have them blink in the minimap.
#
# <minimap obj n>
# Add this tag to an event's comment to have them blink in the minimap with
# a specified color where n is the OBJ value defined in OBJECT_COLOR which
# is found in the customization module below.
#----------------------------------------------------------------------------
# Usage Notes
#----------------------------------------------------------------------------
# Impassable events will not appear as the correct color in the minimap.
# This effect is intended. If you want an event to appear as impassable
# on the minimap, add the tag <minimap wall> to an event's comment.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# โ
BEGIN Setting โ
#==============================================================================
module KMS_MiniMap
# * Minimap Display Toggle Button
# Set to nil to disable this function
SWITCH_BUTTON = :Z
# * Minimap Size and Position (x, y, width, height)
MAP_RECT = Rect.new(364, 20, 160, 120)
# * Minimap z-layer Priority
# Glitchy if this value is set too high
MAP_Z = 0
# * Minimap Grid Size
# A size of 3 or higher is recommended
GRID_SIZE = 5
# * Mini-Map Color Settings
FOREGROUND_COLOR = Color.new(224, 224, 255, 160) # Foreground (passable)
BACKGROUND_COLOR = Color.new( 0, 0, 160, 160) # Background (not passable)
POSITION_COLOR = Color.new(255, 0, 0, 192) # Current Position color
MOVE_EVENT_COLOR = Color.new(255, 160, 0, 192) # Moving event color
VEHICLE_COLOR = Color.new( 96, 128, 0, 192) # Vehicle color
# * Object Color Presets
# Create custom color resets for events tagged with the corresponding label
OBJECT_COLOR = [
Color.new( 0, 128, 0, 192), # OBJ 1
Color.new( 0, 160, 160, 192), # OBJ 2
Color.new(160, 0, 160, 192), # OBJ 3
] # <- Do not delete this line
# * Minimap Blinking Frequency
# Values 5~8 are recommended
BLINK_LEVEL = 7
# * Minimap Cache Setting
# This script creates a cache for each map. If the number of cached
# maps exceed CACHE_NUM, oldest cached maps are deleted.
CACHE_NUM = 10
end
#==============================================================================
# โ END Setting โ
#==============================================================================
$imported = {} if $imported == nil
$imported["KMS_MiniMap"] = true
module KMS_MiniMap
# ใใใใใ้่กจ็คบ
REGEX_NO_MINIMAP_NOTE = /<(?:ใใใใใ|MINIMAP)s*(?:้่กจ็คบ|HIDE)>/i
REGEX_NO_MINIMAP_NAME = /[NOMAP]/i
# ้ๅฎณ็ฉ
REGEX_WALL_EVENT = /<(?:ใใใใใ|MINIMAP)s*(?:ๅฃ|้ๅฎณ็ฉ|WALL)>/i
# ็งปๅใคใใณใ
REGEX_MOVE_EVENT = /<(?:ใใใใใ|MINIMAP)s*(?:็งปๅ|MOVE)>/i
# ใชใใธใงใฏใ
REGEX_OBJECT = /<(?:ใใใใใ|MINIMAP)s+OBJ(?:ECT)?s*(d+)>/i
end
# *****************************************************************************
#==============================================================================
# โก KMS_Commands
#==============================================================================
module KMS_Commands
module_function
#--------------------------------------------------------------------------
# โ ใใใใใใ่กจ็คบ
#--------------------------------------------------------------------------
def self.show_minimap
$game_system.minimap_show = true
end
#--------------------------------------------------------------------------
# โ ใใใใใใ้ ใ
#--------------------------------------------------------------------------
def self.hide_minimap
$game_system.minimap_show = false
end
#--------------------------------------------------------------------------
# โ ใใใใใ่กจ็คบ็ถๆ
ใฎๅๅพ
#--------------------------------------------------------------------------
def self.minimap_showing?
return $game_system.minimap_show
end
#--------------------------------------------------------------------------
# โ ใใใใใใใชใใฌใใทใฅ
#--------------------------------------------------------------------------
def self.refresh_minimap
return unless $scene.is_a?(Scene_Map)
$game_map.refresh if $game_map.need_refresh
$scene.refresh_minimap
end
#--------------------------------------------------------------------------
# โ ใใใใใใฎใชใใธใงใฏใใๆดๆฐ
#--------------------------------------------------------------------------
def self.update_minimap_object
return unless $scene.is_a?(Scene_Map)
$game_map.refresh if $game_map.need_refresh
$scene.update_minimap_object
end
end
#==============================================================================
# โ Game_Interpreter
#==============================================================================
class Game_Interpreter
# ใคใใณใใณใใณใใใ็ดๆฅใณใใณใใๅฉใใใใใซใใ
include KMS_Commands
end
#==============================================================================
# โ RPG::Map
#==============================================================================
class RPG::Map
#--------------------------------------------------------------------------
# โ ใใใใใใฎใญใฃใใทใฅ็ๆ
#--------------------------------------------------------------------------
def create_minimap_cache
@__minimap_show = true
note.each_line { |line|
if line =~ KMS_MiniMap::REGEX_NO_MINIMAP_NOTE # ใใใ้่กจ็คบ
@__minimap_show = false
end
}
end
#--------------------------------------------------------------------------
# โ ใใใใใ่กจ็คบ
#--------------------------------------------------------------------------
def minimap_show?
create_minimap_cache if @__minimap_show.nil?
return @__minimap_show
end
end
#==============================================================================
# โ RPG::MapInfo
#==============================================================================
class RPG::MapInfo
#--------------------------------------------------------------------------
# โ ใใใๅๅๅพ
#--------------------------------------------------------------------------
def name
return @name.gsub(/[.*]/) { "" }
end
#--------------------------------------------------------------------------
# โ ใชใชใธใใซใใใๅๅๅพ
#--------------------------------------------------------------------------
def original_name
return @name
end
#--------------------------------------------------------------------------
# โ ใใใใใใฎใญใฃใใทใฅ็ๆ
#--------------------------------------------------------------------------
def create_minimap_cache
@__minimap_show = !(@name =~ KMS_MiniMap::REGEX_NO_MINIMAP_NAME)
end
#--------------------------------------------------------------------------
# โ ใใใใใ่กจ็คบ
#--------------------------------------------------------------------------
def minimap_show?
create_minimap_cache if @__minimap_show == nil
return @__minimap_show
end
end
#==============================================================================
# โ Game_System
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# โ ๅ
ฌ้ใคใณในใฟใณในๅคๆฐ
#--------------------------------------------------------------------------
attr_accessor :minimap_show
#--------------------------------------------------------------------------
# โ ใชใใธใงใฏใๅๆๅ
#--------------------------------------------------------------------------
alias initialize_KMS_MiniMap initialize
def initialize
initialize_KMS_MiniMap
@minimap_show = true
end
end
#==============================================================================
# โ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# โ ๅฎๆฐ
#--------------------------------------------------------------------------
MINIMAP_FADE_NONE = 0 # ใใใใใ ใใงใผใใชใ
MINIMAP_FADE_IN = 1 # ใใใใใ ใใงใผใใคใณ
MINIMAP_FADE_OUT = 2 # ใใใใใ ใใงใผใใขใฆใ
#--------------------------------------------------------------------------
# โ ๅ
ฌ้ใคใณในใฟใณในๅคๆฐ
#--------------------------------------------------------------------------
attr_accessor :minimap_fade
#--------------------------------------------------------------------------
# โ ใใใใใใ่กจ็คบใใใ
#--------------------------------------------------------------------------
def minimap_show?
return $data_mapinfos[map_id].minimap_show? && @map.minimap_show?
end
#--------------------------------------------------------------------------
# โ ใใใใใใใใงใผใใคใณ
#--------------------------------------------------------------------------
def fadein_minimap
@minimap_fade = MINIMAP_FADE_IN
end
#--------------------------------------------------------------------------
# โ ใใใใใใใใงใผใใขใฆใ
#--------------------------------------------------------------------------
def fadeout_minimap
@minimap_fade = MINIMAP_FADE_OUT
end
end
#==============================================================================
# โ Game_Event
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# โ ใใใใใ็จใฎใญใฃใใทใฅใไฝๆ
#--------------------------------------------------------------------------
def __create_minimap_cache
@__last_page = @page
@__minimap_wall_event = false
@__minimap_move_event = false
@__minimap_object_type = -1
@page.list.each { |cmd|
# ๆณจ้ไปฅๅคใซๅฐ้ใใใ้ข่ฑ
break unless [108, 408].include?(cmd.code)
# ๆญฃ่ฆ่กจ็พๅคๅฎ
case cmd.parameters[0]
when KMS_MiniMap::REGEX_WALL_EVENT
@__minimap_wall_event = true
when KMS_MiniMap::REGEX_MOVE_EVENT
@__minimap_move_event = true
when KMS_MiniMap::REGEX_OBJECT
@__minimap_object_type = $1.to_i
end
}
end
private :__create_minimap_cache
#--------------------------------------------------------------------------
# โ ใฐใฉใใฃใใฏใใใใ
#--------------------------------------------------------------------------
def graphic_exist?
return (character_name != "" || tile_id > 0)
end
#--------------------------------------------------------------------------
# โ ้ๅฎณ็ฉใ
#--------------------------------------------------------------------------
def is_minimap_wall_event?
if @__minimap_wall_event.nil? || @__last_page != @page
__create_minimap_cache
end
return @__minimap_wall_event
end
#--------------------------------------------------------------------------
# โ ็งปๅใคใใณใใ
#--------------------------------------------------------------------------
def is_minimap_move_event?
if @__minimap_move_event.nil? || @__last_page != @page
__create_minimap_cache
end
return @__minimap_move_event
end
#--------------------------------------------------------------------------
# โ ใใใใใใชใใธใงใฏใใ
#--------------------------------------------------------------------------
def is_minimap_object?
if @__minimap_object_type.nil? || @__last_page != @page
__create_minimap_cache
end
return @__minimap_object_type > 0
end
#--------------------------------------------------------------------------
# โ ใใใใใใชใใธใงใฏใใฟใคใ
#--------------------------------------------------------------------------
def minimap_object_type
if @__minimap_object_type.nil? || @__last_page != @page
__create_minimap_cache
end
return @__minimap_object_type
end
end
#==============================================================================
# โก Game_MiniMap
#------------------------------------------------------------------------------
# ใใใใใใๆฑใใฏใฉในใงใใ
#==============================================================================
class Game_MiniMap
#--------------------------------------------------------------------------
# โ ๆง้ ไฝ
#--------------------------------------------------------------------------
Point = Struct.new(:x, :y)
Size = Struct.new(:width, :height)
PassageCache = Struct.new(:map_id, :table, :scan_table)
#--------------------------------------------------------------------------
# โ ใฏใฉในๅคๆฐ
#--------------------------------------------------------------------------
@@passage_cache = [] # ้่กใใฉใฐใใผใใซใญใฃใใทใฅ
#--------------------------------------------------------------------------
# โ ใชใใธใงใฏใๅๆๅ
#--------------------------------------------------------------------------
def initialize(tilemap)
@map_rect = KMS_MiniMap::MAP_RECT
@grid_size = [KMS_MiniMap].max
@x = 0
@y = 0
@grid_num = Point.new(
(@map_rect.width + @grid_size - 1) / @grid_size,
(@map_rect.height + @grid_size - 1) / @grid_size
)
@draw_grid_num = Point.new(@grid_num.x + 2, @grid_num.y + 2)
@draw_range_begin = Point.new(0, 0)
@draw_range_end = Point.new(0, 0)
@tilemap = tilemap
@last_x = $game_player.x
@last_y = $game_player.y
@showing = false
@hiding = false
create_sprites
refresh
end
#--------------------------------------------------------------------------
# โ ในใใฉใคใไฝๆ
#--------------------------------------------------------------------------
def create_sprites
@viewport = Viewport.new(@map_rect)
@viewport.z = KMS_MiniMap::MAP_Z
# ใใใใใใใตใคใบ่จ็ฎ
@bmp_size = Size.new(
(@grid_num.x + 2) * @grid_size,
(@grid_num.y + 2) * @grid_size
)
@buf_bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)
# ใใใ็จในใใฉใคใไฝๆ
@map_sprite = Sprite.new(@viewport)
@map_sprite.x = -@grid_size
@map_sprite.y = -@grid_size
@map_sprite.z = 0
@map_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)
# ใชใใธใงใฏใ็จในใใฉใคใไฝๆ
@object_sprite = Sprite_MiniMapIcon.new(@viewport)
@object_sprite.x = -@grid_size
@object_sprite.y = -@grid_size
@object_sprite.z = 1
@object_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)
# ็พๅจไฝ็ฝฎในใใฉใคใไฝๆ
@position_sprite = Sprite_MiniMapIcon.new
@position_sprite.x = @map_rect.x + @grid_num.x / 2 * @grid_size
@position_sprite.y = @map_rect.y + @grid_num.y / 2 * @grid_size
@position_sprite.z = @viewport.z + 2
bitmap = Bitmap.new(@grid_size, @grid_size)
bitmap.fill_rect(bitmap.rect, KMS_MiniMap::POSITION_COLOR)
@position_sprite.bitmap = bitmap
end
#--------------------------------------------------------------------------
# โ ่งฃๆพ
#--------------------------------------------------------------------------
def dispose
@buf_bitmap.dispose
@map_sprite.bitmap.dispose
@map_sprite.dispose
@object_sprite.bitmap.dispose
@object_sprite.dispose
@position_sprite.bitmap.dispose
@position_sprite.dispose
@viewport.dispose
end
#--------------------------------------------------------------------------
# โ ๅฏ่ฆ็ถๆ
ๅๅพ
#--------------------------------------------------------------------------
def visible
return @map_sprite.visible
end
#--------------------------------------------------------------------------
# โ ๅฏ่ฆ็ถๆ
่จญๅฎ
#--------------------------------------------------------------------------
def visible=(value)
@viewport.visible = value
@map_sprite.visible = value
@object_sprite.visible = value
@position_sprite.visible = value
end
#--------------------------------------------------------------------------
# โ ไธ้ๆๅบฆๅๅพ
#--------------------------------------------------------------------------
def opacity
return @map_sprite.opacity
end
#--------------------------------------------------------------------------
# โ ไธ้ๆๅบฆ่จญๅฎ
#--------------------------------------------------------------------------
def opacity=(value)
@map_sprite.opacity = value
@object_sprite.opacity = value
@position_sprite.opacity = value
end
#--------------------------------------------------------------------------
# โ ใชใใฌใใทใฅ
#--------------------------------------------------------------------------
def refresh
update_draw_range
update_passage_table
update_object_list
update_position
draw_map
draw_object
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# โ ใใงใผใใคใณ
#--------------------------------------------------------------------------
def fadein
@showing = true
@hiding = false
end
#--------------------------------------------------------------------------
# โ ใใงใผใใขใฆใ
#--------------------------------------------------------------------------
def fadeout
@showing = false
@hiding = true
end
#--------------------------------------------------------------------------
# โ ใญใผๅ
ฅๅๆดๆฐ
#--------------------------------------------------------------------------
def update_input
return if KMS_MiniMap::SWITCH_BUTTON.nil?
if Input.trigger?(KMS_MiniMap::SWITCH_BUTTON)
if opacity < 255 && !@showing
fadein
elsif opacity > 0 && !@hiding
fadeout
end
end
end
#--------------------------------------------------------------------------
# โ ๆ็ป็ฏๅฒๆดๆฐ
#--------------------------------------------------------------------------
def update_draw_range
range = []
(2).times { |i| range[i] = @draw_grid_num[i] / 2 }
@draw_range_begin.x = $game_player.x - range[0]
@draw_range_begin.y = $game_player.y - range[1]
@draw_range_end.x = $game_player.x + range[0]
@draw_range_end.y = $game_player.y + range[1]
end
#--------------------------------------------------------------------------
# โ ้่กๅฏๅฆใใผใใซๆดๆฐ
#--------------------------------------------------------------------------
def update_passage_table
cache = get_passage_table_cache
@passage_table = cache.table
@passage_scan_table = cache.scan_table
update_around_passage_table
end
#--------------------------------------------------------------------------
# โ ้่กๅฏๅฆใใผใใซใฎใญใฃใใทใฅใๅๅพ
#--------------------------------------------------------------------------
def get_passage_table_cache
map_id = $game_map.map_id
cache = @@passage_cache.find { |c| c.map_id == map_id }
# ใญใฃใใทใฅใในใใใๆฐ่ฆไฝๆ
if cache == nil
cache = PassageCache.new(map_id)
cache.table = Table.new($game_map.width, $game_map.height)
cache.scan_table = Table.new(
($game_map.width + @draw_grid_num.x - 1) / @draw_grid_num.x,
($game_map.height + @draw_grid_num.y - 1) / @draw_grid_num.y
)
end
# ็ด่ฟใฎใญใฃใใทใฅใฏๅ
้ ญใซ็งปๅใใๅคใใญใฃใใทใฅใฏๅ้ค
@@passage_cache.unshift(cache)
@@passage_cache.delete_at(KMS_MiniMap::CACHE_NUM)
return cache
end
#--------------------------------------------------------------------------
# โ ้่กๅฏๅฆใใผใใซใฎใญใฃใใทใฅใใฏใชใข
#--------------------------------------------------------------------------
def clear_passage_table_cache
return if @passage_scan_table == nil
table = @passage_scan_table
@passage_scan_table = Table.new(table.xsize, table.ysize)
end
#--------------------------------------------------------------------------
# โ ้่กๅฏๅฆใใผใใซใฎๆข็ดข
# x, y : ๆข็ดขไฝ็ฝฎ
#--------------------------------------------------------------------------
def scan_passage(x, y)
dx = x / @draw_grid_num.x
dy = y / @draw_grid_num.y
# ๆข็ดขๆธใฟ
return if @passage_scan_table[dx, dy] == 1
# ใใใ็ฏๅฒๅค
return unless dx.between?(0, @passage_scan_table.xsize - 1)
return unless dy.between?(0, @passage_scan_table.ysize - 1)
rx = (dx * @draw_grid_num.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' />...((dx + 1) * @draw_grid_num.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' />
ry = (dy * @draw_grid_num.y)...((dy + 1) * @draw_grid_num.y)
mw = $game_map.width - 1
mh = $game_map.height - 1
# ๆข็ดข็ฏๅฒๅ
ใฎ้่กใใผใใซใ็ๆ
rx.each { |x|
next unless x.between?(0, mw)
ry.each { |y|
next unless y.between?(0, mh)
# ้่กๆนๅใใฉใฐไฝๆ
# (โใโใโใโ ใฎ้ ใซ 1, 2, 4, 8 ใๅฏพๅฟ)
flag = 0
[2, 4, 6, 8].each{ |d|
flag |= 1 << (d / 2 - 1) if $game_map.passable?(x, y, d)
}
@passage_table[x, y] = flag
}
}
@passage_scan_table[dx, dy] = 1
end
#--------------------------------------------------------------------------
# โ ๅจ่พบใฎ้่กๅฏๅฆใใผใใซๆดๆฐ
#--------------------------------------------------------------------------
def update_around_passage_table
gx = @draw_grid_num.x
gy = @draw_grid_num.y
dx = $game_player.x - gx / 2
dy = $game_player.y - gy / 2
scan_passage(dx, dy)
scan_passage(dx + gx, dy)
scan_passage(dx, dy + gy)
scan_passage(dx + gx, dy + gy)
end
#--------------------------------------------------------------------------
# โ ใชใใธใงใฏใไธ่ฆงๆดๆฐ
#--------------------------------------------------------------------------
def update_object_list
events = $game_map.events.values
# WALL
@wall_events = events.find_all { |e| e.is_minimap_wall_event? }
# MOVE
@move_events = events.find_all { |e| e.is_minimap_move_event? }
# OBJ
@object_list = events.find_all { |e| e.is_minimap_object? }
end
#--------------------------------------------------------------------------
# โ ไฝ็ฝฎๆดๆฐ
#--------------------------------------------------------------------------
def update_position
# ็งปๅ้็ฎๅบ
pt = Point.new($game_player.x, $game_player.y)
ox = ($game_player.real_x - pt.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size
oy = ($game_player.real_y - pt.y) * @grid_size
@viewport.ox = ox
@viewport.oy = oy
# ็งปๅใใฆใใใใใใๅๆ็ป
if pt.x != @last_x || pt.y != @last_y
draw_map
@last_x = pt.x
@last_y = pt.y
end
end
#--------------------------------------------------------------------------
# โ ๆ็ป็ฏๅฒๅ
ๅคๅฎ
#--------------------------------------------------------------------------
def in_draw_range?(x, y)
rb = @draw_range_begin
re = @draw_range_end
return (x.between?(rb.x, re.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> && y.between?(rb.y, re.y))
end
#--------------------------------------------------------------------------
# โ ใใใ็ฏๅฒๅ
ๅคๅฎ
#--------------------------------------------------------------------------
def in_map_range?(x, y)
mw = $game_map.width
mh = $game_map.height
return (x.between?(0, mw - 1) && y.between?(0, mh - 1))
end
#--------------------------------------------------------------------------
# โ ใใใๆ็ป
#--------------------------------------------------------------------------
def draw_map
update_around_passage_table
bitmap = @map_sprite.bitmap
bitmap.fill_rect(bitmap.rect, KMS_MiniMap::BACKGROUND_COLOR)
draw_map_foreground(bitmap)
draw_map_move_event(bitmap)
end
#--------------------------------------------------------------------------
# โ ้่กๅฏ่ฝ้ ๅใฎๆ็ป
#--------------------------------------------------------------------------
def draw_map_foreground(bitmap)
range_x = (@draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' />..(@draw_range_end.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' />
range_y = (@draw_range_begin.y)..(@draw_range_end.y)
map_w = $game_map.width - 1
map_h = $game_map.height - 1
rect = Rect.new(0, 0, @grid_size, @grid_size)
range_x.each { |x|
next unless x.between?(0, map_w)
range_y.each { |y|
next unless y.between?(0, map_h)
next if @passage_table[x, y] == 0
next if @wall_events.find { |e| e.x == x && e.y == y } # ๅฃ
# ใฐใชใใๆ็ปใตใคใบ็ฎๅบ
rect.set(0, 0, @grid_size, @grid_size)
rect.x = (x - @draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size
rect.y = (y - @draw_range_begin.y) * @grid_size
flag = @passage_table[x, y]
if flag & 0x01 == 0 # ไธ้่กไธ่ฝ
rect.height -= 1
end
if flag & 0x02 == 0 # ๅทฆ้่กไธ่ฝ
rect.x += 1
rect.width -= 1
end
if flag & 0x04 == 0 # ๅณ้่กไธ่ฝ
rect.width -= 1
end
if flag & 0x08 == 0 # ไธ้่กไธ่ฝ
rect.y += 1
rect.height -= 1
end
bitmap.fill_rect(rect, KMS_MiniMap::FOREGROUND_COLOR)
}
}
end
#--------------------------------------------------------------------------
# โ ็งปๅใคใใณใใฎๆ็ป
#--------------------------------------------------------------------------
def draw_map_move_event(bitmap)
rect = Rect.new(0, 0, @grid_size, @grid_size)
@move_events.each { |e|
rect.x = (e.x - @draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size
rect.y = (e.y - @draw_range_begin.y) * @grid_size
bitmap.fill_rect(rect, KMS_MiniMap::MOVE_EVENT_COLOR)
}
end
#--------------------------------------------------------------------------
# โ ใขใใกใผใทใงใณๆดๆฐ
#--------------------------------------------------------------------------
def update_animation
if @showing
# ใใงใผใใคใณ
self.opacity += 16
if opacity == 255
@showing = false
end
elsif @hiding
# ใใงใผใใขใฆใ
self.opacity -= 16
if opacity == 0
@hiding = false
self.visible = false
end
end
end
#--------------------------------------------------------------------------
# โ ใชใใธใงใฏใๆ็ป
#--------------------------------------------------------------------------
def draw_object
# ไธๆบๅ
bitmap = @object_sprite.bitmap
bitmap.clear
rect = Rect.new(0, 0, @grid_size, @grid_size)
# ใชใใธใงใฏใๆ็ป
@object_list.each { |obj|
next unless in_draw_range?(obj.x, obj.y)
color = KMS_MiniMap::OBJECT_COLOR[obj.minimap_object_type - 1]
next if color.nil?
rect.x = (obj.real_x - @draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size
rect.y = (obj.real_y - @draw_range_begin.y) * @grid_size
bitmap.fill_rect(rect, color)
}
# ไนใ็ฉๆ็ป
$game_map.vehicles.each { |vehicle|
next if vehicle.transparent
rect.x = (vehicle.real_x - @draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size
rect.y = (vehicle.real_y - @draw_range_begin.y) * @grid_size
bitmap.fill_rect(rect, KMS_MiniMap::VEHICLE_COLOR)
}
end
#--------------------------------------------------------------------------
# โ ๆดๆฐ
#--------------------------------------------------------------------------
def update
update_input
return if !visible || opacity == 0
update_draw_range
update_position
update_animation
draw_object
@map_sprite.update
@object_sprite.update
@position_sprite.update
end
end
#==============================================================================
# โก Sprite_MiniMapIcon
#------------------------------------------------------------------------------
# ใใใใใ็จใขใคใณใณใฎใฏใฉในใงใใ
#==============================================================================
class Sprite_MiniMapIcon < Sprite
DURATION_MAX = 60
#--------------------------------------------------------------------------
# โ ใชใใธใงใฏใๅๆๅ
# viewport : ใใฅใผใใผใ
#--------------------------------------------------------------------------
def initialize(viewport = nil)
super(viewport)
@duration = DURATION_MAX / 2
end
#--------------------------------------------------------------------------
# โ ใใฌใผใ ๆดๆฐ
#--------------------------------------------------------------------------
def update
super
@duration += 1
if @duration == DURATION_MAX
@duration = 0
end
update_effect
end
#--------------------------------------------------------------------------
# โ ใจใใงใฏใใฎๆดๆฐ
#--------------------------------------------------------------------------
def update_effect
self.color.set(255, 255, 255,
(@duration - DURATION_MAX / 2).abs * KMS_MiniMap::BLINK_LEVEL
)
end
end
#==============================================================================
# โ Spriteset_Map
#==============================================================================
class Spriteset_Map
attr_reader :minimap
#--------------------------------------------------------------------------
# โ ใชใใธใงใฏใๅๆๅ
#--------------------------------------------------------------------------
alias initialize_KMS_MiniMap initialize
def initialize
initialize_KMS_MiniMap
create_minimap
end
#--------------------------------------------------------------------------
# โ ใใใใใใฎไฝๆ
#--------------------------------------------------------------------------
def create_minimap
return unless $game_map.minimap_show?
@minimap = Game_MiniMap.new(@tilemap)
@minimap.visible = $game_system.minimap_show
end
#--------------------------------------------------------------------------
# โ ่งฃๆพ
#--------------------------------------------------------------------------
alias dispose_KMS_MiniMap dispose
def dispose
dispose_KMS_MiniMap
dispose_minimap
end
#--------------------------------------------------------------------------
# โ ใใใใใใฎ่งฃๆพ
#--------------------------------------------------------------------------
def dispose_minimap
@minimap.dispose unless @minimap.nil?
end
#--------------------------------------------------------------------------
# โ ใใฌใผใ ๆดๆฐ
#--------------------------------------------------------------------------
alias update_KMS_MiniMap update
def update
update_KMS_MiniMap
update_minimap
end
#--------------------------------------------------------------------------
# โ ใใใใใๆดๆฐ
#--------------------------------------------------------------------------
def update_minimap
return if @minimap.nil?
# ่กจ็คบๅๆฟ
@minimap.visible = $game_system.minimap_show
# ใใงใผใๅคๅฎ
case $game_map.minimap_fade
when Game_Map::MINIMAP_FADE_IN
@minimap.fadein
$game_map.minimap_fade = Game_Map::MINIMAP_FADE_NONE
when Game_Map::MINIMAP_FADE_OUT
@minimap.fadeout
$game_map.minimap_fade = Game_Map::MINIMAP_FADE_NONE
end
@minimap.update
end
#--------------------------------------------------------------------------
# โ ใใใใใๅ
จไฝใใชใใฌใใทใฅ
#--------------------------------------------------------------------------
def refresh_minimap
return if @minimap.nil?
@minimap.clear_passage_table_cache
@minimap.refresh
end
#--------------------------------------------------------------------------
# โ ใใใใใใฎใชใใธใงใฏใใๆดๆฐ
#--------------------------------------------------------------------------
def update_minimap_object
@minimap.update_object_list unless @minimap.nil?
end
end
#==============================================================================
# โ Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# โ ๅ ดๆ็งปๅๅพใฎๅฆ็
#--------------------------------------------------------------------------
alias post_transfer_KMS_MiniMap post_transfer
def post_transfer
refresh_minimap
post_transfer_KMS_MiniMap
end
#--------------------------------------------------------------------------
# โ ใใใใใๅ
จไฝใใชใใฌใใทใฅ
#--------------------------------------------------------------------------
def refresh_minimap
@spriteset.refresh_minimap
end
#--------------------------------------------------------------------------
# โ ใใใใใใฎใชใใธใงใฏใใๆดๆฐ
#--------------------------------------------------------------------------
def update_minimap_object
@spriteset.update_minimap_object
end
end
Note dell'Autore:
Termini e condizioni d'uso sullo script, nel sito dell'autore:
http://ytomy.sakura.ne.jp/tkool/rpgtech/rules.html]http://ytomy.sakura....tech/rules.html