#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
#==============================================================================
# ■ 縮小地图的表示+地图显示地图名和坐标 (ver 1.19)
# by ピニョン clum-sea
# 修改by精灵使者
#
#修正了在某些模版下读档产生的Window_base中x和y为nil的错误。
#修正了大地图下的can't create bitmap的错误
#修改了事件静止状态的时候事件图形发生的BUG和色调出现的严重错误。
#修正了色调同步的时候viewport黑块的BUG。
#增加了小地图和大地图的色调同步(感谢orzfly的viewport脚本)
#增加了刷新速度,解决了从菜单返回地图的卡bug(地图重新生成的时候引起的)
#解决了F12引起的dispose error错误(真累死我了……)
#继续添加了变量的入口,改进了地图的事件效果和事件算法。
#增加了小地图不显示主角的开关,防止某些特殊场合显示主角
#增添了雾图形的描绘,完善了自动元件的算法。调整了地图的z坐标。
#继续增添一些变量的入口,减少了XY坐标的刷新量,优化了BLUR的效果。
#增加了小地图模糊效果,感谢忧雪の伤
#添加了一些变量入口,增加了坐标背景图等
#整合了小地图和坐标两个脚本,请去掉显示地图名的原始脚本(可以退休了)
#去掉了一些老版本使用的旧常量,修正了窗口皮肤和初始可见变量,增添了
#手动刷新开关。
#增添了事件图等,完善了一些开关和变量
#修正了场所移动的时候远景图变黑的问题,感谢忧雪の伤
#精灵再度更新:支持地图的远景图显示(如果有的话)
#冬夜更新说明
#更改了小地图的位置,Q是开启小地图跟随开关
#更新了场所移动时地图的不同步,更新了战斗后的地图不同步
#小地图默认成为false,只在第一次登入时是,以后跟随开关的指示
#修正了由于小地图变化引起的不能转换问题,修整了房间内的地图原先的那个羁押功能
#==============================================================================
#==============================================================================
# □ 前期定义
#==============================================================================
module PLAN_Map_Window
WIN_WIDTH = 250 # 地图的宽度
WIN_HEIGHT = 200 # 地图的高度
ZOOM = 7.0 # 地图的放缩比例
WINDOWSKIN = "" # 自定义地图窗口素材,如果留空则是默认的
ON_OFF_KEY = Input::A # 打开地图的按钮,A就是键盘的Z键
SWITCH = 490 # 禁用地图功能的开关,默认这个就是打开100号
# 开关则禁止使用地图功能,关闭则可以使用地图功能
WINDOW_MOVE = true # 窗口中的地图跟随移动,(true:跟随, false:固定)
OPACITY = 255 # 窗口的透明度
C_OPACITY = 255 # 地图的透明度
VISIBLE = false # 最初是否可见(如果是事件标题请置false)
SWITCH_KEY = Input::L # Q键锁定/解锁小地图(可以用上下左右切换小地图的位置)
MAP_VISIBLE = 491 # 地图/地图名显示开关状态
MAP_SWITCH = 492 # 地图锁定开关状态
MAP_DIRECTION = 11 # 地图方向变量
MINI_MAP = [30,30] # 小地图和中地图范围
LARGE_MAP = [70,70] # 中地图和大地图范围
EXTRA_MAP = [800,800] # 超过地图所能显示范围的上限
MINIMAP_ZOOM = 0.5 # 小地图相对于放缩比的比率
LARGEMAP_ZOOM = 1.5 # 大地图相对于放所比的比率
COVER_SWITCH = true # 是否图块遮掩的时候不显示主角
MANUAL_REFRESH = 12 # 手动刷新事件开关号
# ,打开即刷新一次,无需手动关闭
MOVE_REFRESH = 493 # 事件移动时刷新小地图事件开关号
#(效果较好,但耗费内存,请谨慎开启!)
# 可以和手动刷新事件开关配合使用
AUTO_REFRESH = 494 # 所有小地图事件强制刷新开关号
#(效果最好,严重耗费内存,请谨慎开启!)
WINDOW_XY = MAP_VISIBLE # XY坐标窗口开关(和默认地图开关相同,如果不需要
# 相同请单独设置开关号
MAPNAME_COLOR =
Color.new(255, 255, 255) # 地图名颜色,如果是其他颜色请指定
XYNAME_COLOR =
Color.new(192, 224, 255) # XY名字的颜色,如果是其他颜色请指定
XYNUMBER_COLOR =
Color.new(255, 255, 255) # XY数字的颜色,如果是其他颜色请指定
XY_OPACITY = 0 # XY窗口的透明度,默认完全透明
XY_B_OPACITY = 0 # XY窗口背景的透明度,默认完全透明
XY_C_OPACITY = 255 # XY窗口内容的透明度,默认完全不透明
XYBACK_PNG = "" # XY背景图片文件名(注:背景图片会遮挡小地图)
XYBACK_OPATITY = 192 # XY背景透明度(建议透明,否则会完全盖住)
XY_WORD_X = "X:" # 表示X坐标的用语
XY_WORD_Y = "Y:" # 表示Y坐标的用语
BLUR = true # 柔化开关,对地图统一柔化
NO_ACTOR_SWITCH = 495 # 不显示主角的开关
ACTOR_MOVE = false # 主角走路开关(会占用些许内存,请谨慎开启)
end
#=============================================================================
# ■ Bitmap重定义
#=============================================================================
class Bitmap
def blur(strength = 1, opacity = 10)
(-strength).upto(strength) do |x|
(-strength).upto(strength) do |y|
next if x.zero? and y.zero?
src_rect = Rect.new(0, 0, width - x, height - y)
blt(x, y, self, src_rect, opacity)
end
end
end
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
attr_accessor :map_visible # 地图的表示状态
attr_accessor :xy_visible # XY地图的表示状态
attr_accessor :back_visible # 背景图表示状态
end
#==============================================================================
# ■ Window_XY
#------------------------------------------------------------------------------
# 显示坐标的窗口。
#==============================================================================
class Window_xy < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 280, 96)
@mapnames = load_data("Data/MapInfos.rxdata")
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = PLAN_Map_Window::XY_B_OPACITY
self.opacity = PLAN_Map_Window::XY_OPACITY
self.contents.font.bold = true
self.contents_opacity = PLAN_Map_Window::XY_C_OPACITY
self.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
refresh if self.visible
@x = $game_player.x
@y = $game_player.y
@id = $game_map.map_id
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if $game_switches[PLAN_Map_Window::WINDOW_XY]
@x = $game_player.x
@y = $game_player.y
@id = $game_map.map_id
self.contents.clear
map_name = @mapnames[@id].name
self.contents.font.color = PLAN_Map_Window::MAPNAME_COLOR
self.contents.draw_text(0, 0, 175, 32, map_name,1)
self.contents.font.color = PLAN_Map_Window::XYNAME_COLOR
self.contents.draw_text(0, 32, 175, 32, PLAN_Map_Window::XY_WORD_X)
self.contents.font.color = PLAN_Map_Window::XYNUMBER_COLOR
self.contents.draw_text(0, 32, 80, 32, @x.to_s,2)
self.contents.font.color = PLAN_Map_Window::XYNAME_COLOR
self.contents.draw_text(95, 32, 175, 32, PLAN_Map_Window::XY_WORD_Y)
self.contents.font.color = PLAN_Map_Window::XYNUMBER_COLOR
self.contents.draw_text(0, 32, 175, 32, @y.to_s,2)
end
end
#--------------------------------------------------------------------------
# ● 判断文字刷新。节约内存用
#--------------------------------------------------------------------------
def judge
return true if @x != $game_player.x
return true if @y != $game_player.y
return true if @id != $game_map.map_id
return false
end
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
alias plan_map_window_main main unless $@
def main
$minimap = false
@map_window = Window_Map.new
@xy_window = Window_xy.new
@xy_window.x = 640 - 230
@xy_window.y = 480 - 101
@xy_window.z = 1500
@map_window.z = 1000
vx = @map_window.x + 16
vy = @map_window.y + 16
vw = @map_window.contents.width
vh = @map_window.contents.height
@viewport = Viewport.new(vx,vy,vw,vh)
@sprite = Sprite.new(@viewport)
@sprite.bitmap = $sprite_bitmap.clone
@sprite.tone = $game_screen.tone.clone
@sprite.opacity = PLAN_Map_Window::C_OPACITY
@viewport.z = @map_window.z
@viewport.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
@xy_window.opacity = PLAN_Map_Window::XY_OPACITY
@xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
@xy_window.refresh if @xy_window.visible
@map_window.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
@back = Sprite.new
unless PLAN_Map_Window::XYBACK_PNG.empty?
@back.bitmap = Bitmap.new("Graphics/Pictures/"+PLAN_Map_Window::XYBACK_PNG)
@back.x = 640 - 16 - @back.bitmap.width
@back.y = 480 - 16 - @back.bitmap.height
@back.z = 1250
end
@back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
@back.opacity = PLAN_Map_Window::XYBACK_OPATITY
plan_map_window_main
@map_window.dispose
@xy_window.dispose
@back.dispose
@sprite.dispose
@viewport.dispose
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
alias plan_map_window_update update unless $@
def update
$game_temp.map_visible = @map_window.visible
$game_temp.xy_visible = @xy_window.visible
$game_temp.back_visible = @back.visible
@xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
@xy_window.refresh if (@xy_window.judge and @xy_window.visible)
@back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
plan_map_window_update
if PLAN_Map_Window::VISIBLE and !@first_open
@map_window.visible = true
$game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
@xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
@xy_window.refresh if @xy_window.visible
@back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
$map_close = false
@first_open = true
end
if $game_switches[PLAN_Map_Window::SWITCH]
if @map_window.visible
@map_window.visible = false
$game_switches[PLAN_Map_Window::MAP_VISIBLE]= false
$game_switches[PLAN_Map_Window::MAP_SWITCH] = false
$game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
$map_close = true
end
else
if $map_close
@map_window.visible = true
$game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
@xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
@xy_window.refresh if @xy_window.visible
@back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
$map_close = false
end
if !$game_temp.in_battle
if Input.trigger?(PLAN_Map_Window::ON_OFF_KEY)
if @map_window.visible
$game_system.se_play($data_system.cancel_se)
@map_window.visible = false
$game_switches[PLAN_Map_Window::MAP_VISIBLE]= false
$game_switches[PLAN_Map_Window::MAP_SWITCH] = false
$game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
else
$game_system.se_play($data_system.decision_se)
@map_window.visible = true
$game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
@xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
@xy_window.refresh if @xy_window.visible
@back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
end
end
if Input.trigger?(PLAN_Map_Window::SWITCH_KEY)
if @map_window.visible
if $game_switches[PLAN_Map_Window::MAP_SWITCH]
$game_system.se_play($data_system.cancel_se)
$game_switches[PLAN_Map_Window::MAP_SWITCH] = false
$game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
else
$game_system.se_play($data_system.decision_se)
$game_switches[PLAN_Map_Window::MAP_SWITCH] = true
end
end
end
end
end
@map_window.update if @map_window.visible
vx = @map_window.x + 16
vy = @map_window.y + 16
vw = @map_window.contents.width
vh = @map_window.contents.height
@viewport.rect = Rect.new(vx,vy,vw,vh)
@sprite.bitmap = $sprite_bitmap.clone
@sprite.tone = $game_screen.tone.clone
@viewport.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
@sprite.update if @viewport.visible
end
#--------------------------------------------------------------------------
# ● 场所移动的变化
#--------------------------------------------------------------------------
alias plan_map_window_transfer_player transfer_player unless $@
def transfer_player
old_map_id = $game_map.map_id
plan_map_window_transfer_player
if old_map_id != $game_map.map_id
GC.start
@map_window.visible = false
@viewport.visible = false
@map_window.dispose
@sprite.dispose
@viewport.dispose
@map_window = Window_Map.new
vx = @map_window.x + 16
vy = @map_window.y + 16
vw = @map_window.contents.width
vh = @map_window.contents.height
@viewport = Viewport.new(vx,vy,vw,vh)
@sprite = Sprite.new(@viewport)
@sprite.bitmap = $sprite_bitmap.clone
@sprite.tone = $game_screen.tone.clone
@sprite.opacity = PLAN_Map_Window::C_OPACITY
@viewport.z = @map_window.z
@viewport.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
end
end
end
#==============================================================================
# ■ Window_Map
#==============================================================================
class Window_Map < Window_Base
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize
$direction = $game_variables[PLAN_Map_Window::MAP_DIRECTION]
if $win_x != nil
x = $win_x
y = $win_y
else
case $direction
when 0
x = 8
y = 8
$win_x = x
$win_y = y
when 1
x = 382
y = 8
$win_x = x
$win_y = y
when 2
x = 8
y = 280 - 8
$win_x = x
$win_y = y
when 3
x = 382
y = 280 - 8
$win_x = x
$win_y = y
end
end
w = PLAN_Map_Window::WIN_WIDTH
h = PLAN_Map_Window::WIN_HEIGHT
$minimap = true
super(x, y, w, h)
$minimap = false
self.contents = Bitmap.new(width - 32, height - 32)
$sprite_bitmap = Bitmap.new(width - 32, height - 32)
self.opacity = PLAN_Map_Window::OPACITY
self.contents_opacity = 0
self.z = 1000
@map_data = $game_map.data
@tileset = RPG::Cache.tileset($game_map.tileset_name)
@autotiles = []
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@old_event = $game_map.events
@old_real_x = $game_player.real_x
@old_real_y = $game_player.real_y
@old_char_name = $game_party.actors[0].character_name if $game_party.actors.size > 0
@old_pattern = $game_player.pattern if $game_party.actors.size > 0
@old_panorama = $game_map.panorama_name
@old_fog = $game_map.fog_name
if $game_map.width > PLAN_Map_Window::LARGE_MAP[0] or $game_map.height > PLAN_Map_Window::LARGE_MAP[1]
$ZOOM = PLAN_Map_Window::LARGEMAP_ZOOM * PLAN_Map_Window::ZOOM
else
if $game_map.width < PLAN_Map_Window::MINI_MAP[0] or $game_map.height < PLAN_Map_Window::MINI_MAP[1]
$ZOOM = PLAN_Map_Window::MINIMAP_ZOOM * PLAN_Map_Window::ZOOM
else
$ZOOM = PLAN_Map_Window::ZOOM
end
end
@panorama = make_panorama
@all_map = make_all_map
@make_event = make_event
@all_fog = make_fog
self.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
unless PLAN_Map_Window::WINDOWSKIN.empty?
self.windowskin = RPG::Cache.windowskin(PLAN_Map_Window::WINDOWSKIN)
end
refresh
end
#--------------------------------------------------------------------------
# ● 自动元件相关
#--------------------------------------------------------------------------
def make_one_autotile(id)
one_autotile = Bitmap.new(32,32)
case id
# 中间的空白部分
when 0 : w = 2 ; h = 4 ; #中间空白
# 四周的方框
when 1 : w = 0 ; h = 0 ; #左上
when 2 : w = 1 ; h = 0 ; #右上
when 3 : w = 0 ; h = 1 ; #左下
when 4 : w = 1 ; h = 1 ; #右下
# 四周的边角
when 5 : w = 4 ; h = 0 ; #左上
when 6 : w = 5 ; h = 0 ; #右上
when 7 : w = 4 ; h = 1 ; #左下
when 8 : w = 5 ; h = 1 ; #右下
# 四周的直线
when 9 : w = 0 ; h = 4 ; #左边
when 10 : w = 5 ; h = 4 ; #右边
when 11 : w = 2 ; h = 2 ; #上边
when 12 : w = 2 ; h = 7 ; #下边
end
src_rect = Rect.new(w * 16, h * 16, 16, 16)
one_autotile.blt(0,0,@autotiles[@tile_num / 48],src_rect)
return one_autotile
end
def make_autotile(id)
full_autotile = Bitmap.new(32,32)
autotile_table = [0,0,0,0]
case id
# 左上右上左下右下
when 0 : autotile_table = [ 0, 0, 0, 0 ]
when 1 : autotile_table = [ 5, 0, 0, 0 ]
when 2 : autotile_table = [ 0, 6, 0, 0 ]
when 3 : autotile_table = [ 5, 6, 0, 0 ]
when 4 : autotile_table = [ 0, 0, 0, 8 ]
when 5 : autotile_table = [ 5, 0, 0, 8 ]
when 6 : autotile_table = [ 0, 6, 0, 8 ]
when 7 : autotile_table = [ 5, 6, 0, 8 ]
when 8 : autotile_table = [ 0, 0, 7, 0 ]
when 9 : autotile_table = [ 5, 0, 7, 0 ]
when 10 : autotile_table = [ 0, 6, 7, 0 ]
when 11 : autotile_table = [ 5, 6, 7, 0 ]
when 12 : autotile_table = [ 0, 0, 7, 8 ]
when 13 : autotile_table = [ 5, 0, 7, 8 ]
when 14 : autotile_table = [ 0, 6, 7, 8 ]
when 15 : autotile_table = [ 5, 6, 7, 8 ]
when 16 : autotile_table = [ 9, 0, 9, 0 ]
when 17 : autotile_table = [ 9, 6, 9, 0 ]
when 18 : autotile_table = [ 9, 0, 9, 8 ]
when 19 : autotile_table = [ 9, 6, 9, 8 ]
when 20 : autotile_table = [ 11, 11, 0, 0 ]
when 21 : autotile_table = [ 11, 11, 0, 8 ]
when 22 : autotile_table = [ 11, 11, 7, 0 ]
when 23 : autotile_table = [ 11, 11, 7, 8 ]
when 24 : autotile_table = [ 0, 10, 0, 10 ]
when 25 : autotile_table = [ 0, 10, 7, 10 ]
when 26 : autotile_table = [ 5, 10, 0, 10 ]
when 27 : autotile_table = [ 5, 10, 7, 10 ]
when 28 : autotile_table = [ 0, 0, 12, 12 ]
when 29 : autotile_table = [ 5, 0, 12, 12 ]
when 30 : autotile_table = [ 0, 6, 12, 12 ]
when 31 : autotile_table = [ 5, 6, 12, 12 ]
when 32 : autotile_table = [ 9, 10, 9, 10 ]
when 33 : autotile_table = [ 11, 11, 12, 12 ]
when 34 : autotile_table = [ 1, 11, 9, 0 ]
when 35 : autotile_table = [ 1, 11, 9, 8 ]
when 36 : autotile_table = [ 11, 2, 0, 10 ]
when 37 : autotile_table = [ 11, 2, 7, 10 ]
when 38 : autotile_table = [ 0, 10, 12, 4 ]
when 39 : autotile_table = [ 5, 10, 12, 4 ]
when 40 : autotile_table = [ 9, 0, 3, 12 ]
when 41 : autotile_table = [ 9, 6, 3, 12 ]
when 42 : autotile_table = [ 1, 2, 9, 10 ]
when 43 : autotile_table = [ 1, 11, 3, 12 ]
when 44 : autotile_table = [ 9, 10, 3, 4 ]
when 45 : autotile_table = [ 11, 2, 12, 4 ]
when 46 : autotile_table = [ 1, 2, 3, 4 ]
when 47 : autotile_table = [ 1, 2, 3, 4 ]
end
one_autotile1 = make_one_autotile(autotile_table[0])
one_autotile2 = make_one_autotile(autotile_table[1])
one_autotile3 = make_one_autotile(autotile_table[2])
one_autotile4 = make_one_autotile(autotile_table[3])
src_rect = Rect.new( 0, 0,16,16)
full_autotile.blt( 0, 0,one_autotile1,src_rect)
full_autotile.blt(16, 0,one_autotile2,src_rect)
full_autotile.blt( 0,16,one_autotile3,src_rect)
full_autotile.blt(16,16,one_autotile4,src_rect)
return full_autotile
end
#--------------------------------------------------------------------------
# ● 缩小图做成
#--------------------------------------------------------------------------
def make_all_map
load_backup = $ret_bitmap.nil? ? false : !$ret_bitmap.disposed?
if ($game_map.map_id == $old_map_id) and load_backup
ret_bitmap = $ret_bitmap.clone
else
all_map = Bitmap.new($game_map.width * 32, $game_map.height * 32)
for y in 0...$game_map.height
for x in 0...$game_map.width
for z in 0...3
@tile_num = @map_data[x, y, z]
next if @tile_num == nil
if @tile_num < 384
if @tile_num >= 48
@tile_num -= 48
tile_id = @tile_num % 48
src_rect = Rect.new(0,0,32,32)
autotile = make_autotile(tile_id)
all_map.blt(x * 32, y * 32, autotile , src_rect)
end
else
@tile_num -= 384
src_rect = Rect.new(@tile_num % 8 * 32, @tile_num / 8 * 32, 32, 32)
all_map.blt(x * 32, y * 32, @tileset, src_rect)
end
end
end
end
w = ($game_map.width / $ZOOM) * 32
h = ($game_map.height / $ZOOM) * 32
ret_bitmap = Bitmap.new(w, h)
src_rect = Rect.new(0, 0, all_map.width, all_map.height)
dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
ret_bitmap.stretch_blt(dest_rect, all_map, src_rect)
$ret_bitmap = ret_bitmap.clone
$old_map_id = $game_map.map_id
end
all_map.dispose unless all_map.nil?
autotile.dispose unless autotile.nil?
return ret_bitmap
end
#--------------------------------------------------------------------------
# ● 远景图做成
#--------------------------------------------------------------------------
def make_panorama
all_panorama = RPG::Cache.panorama($game_map.panorama_name,$game_map.panorama_hue).clone
w = ($game_map.width / $ZOOM) * 32
h = ($game_map.height / $ZOOM) * 32
ret_bitmap = Bitmap.new(w, h)
src_rect = Rect.new(0, 0, all_panorama.width, all_panorama.height)
dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
ret_bitmap.stretch_blt(dest_rect, all_panorama, src_rect)
all_panorama.dispose
return ret_bitmap
end
#--------------------------------------------------------------------------
# ● 缩小事件做成
#--------------------------------------------------------------------------
def make_event
all_event = Bitmap.new($game_map.width * 32, $game_map.height * 32)
for event in $game_map.events.values
x = event.x
y = event.y
@tile_id = event.tile_id
@character_name = event.character_name
@character_hue = event.character_hue
@direction = event.direction
@pattern = event.pattern
[url=home.php?mod=space&uid=316553]@opacity[/url] = event.opacity
if @character_name != ""
temp_b = RPG::Cache.character(@character_name,@character_hue).clone
@cw = temp_b.width / 4
@ch = temp_b.height / 4
sx = @pattern * @cw
sy = (@direction - 2) / 2 * @ch
src_rect = Rect.new(sx,sy,@cw,@ch)
all_event.blt(((x * 32)-((@cw-32)/2)), ((y * 32) - (@ch-32)), temp_b, src_rect ,@opacity)
temp_b.dispose
elsif @tile_id != 0
@tile_id -= 384
src_rect = Rect.new(@tile_id % 8 * 32, @tile_id / 8 * 32, 32, 32)
all_event.blt(x * 32, y * 32, @tileset, src_rect)
end
end
w = ($game_map.width / $ZOOM) * 32
h = ($game_map.height / $ZOOM) * 32
ret_bitmap = Bitmap.new(w, h)
src_rect = Rect.new(0, 0, all_event.width, all_event.height)
dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
ret_bitmap.stretch_blt(dest_rect, all_event, src_rect)
all_event.dispose
return ret_bitmap
end
#--------------------------------------------------------------------------
# ● 移动事件判断
#--------------------------------------------------------------------------
def event_move_judge
moving = false
if $game_switches[PLAN_Map_Window::MOVE_REFRESH]
for event in $game_map.events.values
event_old = @old_event[event.id]
moving = true if event.moving? or event.jumping?
moving = true if event.character_name != event_old.character_name
moving = true if event.character_hue != event_old.character_hue
moving = true if event.tile_id != event_old.tile_id
moving = true if event.direction != event_old.direction
moving = true if event.pattern != event_old.pattern
moving = true if event.opacity != event_old.opacity
end
end
moving = true if $game_switches[PLAN_Map_Window::AUTO_REFRESH]
if $game_switches[PLAN_Map_Window::MANUAL_REFRESH]
moving = true
$game_switches[PLAN_Map_Window::MANUAL_REFRESH] = false
end
@old_event = $game_map.events
return moving
end
#--------------------------------------------------------------------------
# ● 雾图形做成
#--------------------------------------------------------------------------
def make_fog
all_fog = Bitmap.new($game_map.width * 32, $game_map.height * 32)
fog_name = $game_map.fog_name
fog_hue = $game_map.fog_hue
fog_bitmap = RPG::Cache.fog(fog_name, fog_hue).clone
num_x = $game_map.width * 32 / fog_bitmap.width
num_y = $game_map.height * 32 / fog_bitmap.height
for x in 0..num_x
for y in 0..num_y
src_rect = Rect.new(0, 0, fog_bitmap.width, fog_bitmap.height)
all_fog.blt((x * fog_bitmap.width),(y * fog_bitmap.height),
fog_bitmap,src_rect)
end
end
w = ($game_map.width / $ZOOM) * 32
h = ($game_map.height / $ZOOM) * 32
ret_bitmap = Bitmap.new(w, h)
src_rect = Rect.new(0, 0, all_fog.width, all_fog.height)
dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
ret_bitmap.stretch_blt(dest_rect, all_fog, src_rect,50)
return ret_bitmap
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.x = $win_x.nil? ? 0 : $win_x
self.y = $win_y.nil? ? 0 : $win_y
self.z = 1000
@small_map = false
if $game_map.width < PLAN_Map_Window::LARGE_MAP[0] or $game_map.height < PLAN_Map_Window::LARGE_MAP[1]
#这个是当地图大小宽和高小于指定大小时才改变大小,限制小地图窗口大小
if $game_map.width < PLAN_Map_Window::MINI_MAP[0] or $game_map.height < PLAN_Map_Window::MINI_MAP[1]
#这同时限制了变换小地图的大小,防止因为地图宽长无法切换
self.width = [@all_map.width,PLAN_Map_Window::WIN_WIDTH].min
self.height = [@all_map.height,PLAN_Map_Window::WIN_HEIGHT].min
self.contents = Bitmap.new(width-32, height-32)
#让改变的小地图X坐标紧贴边缘
if self.x + self.width > 250
self.x = 625 - self.width
end
#让改变的小地图Y左边紧贴边缘
if self.y + self.height > 380
self.y = 470 - self.height
end
@small_map = true
end
end
if self.windowskin == nil
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
one_tile_size = 32 / $ZOOM
x = $game_player.real_x - 64 * (self.contents.width / one_tile_size)
y = $game_player.real_y - 64 * (self.contents.height / one_tile_size)
x = x * one_tile_size / 128
y = y * one_tile_size / 128
px = 0
py = 0
half_width = self.contents.width * 128 / 2
rest_width = ($game_map.width * 128 - $game_player.real_x) * one_tile_size
rev_x = 0
if @all_map.width < self.contents.width
rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
rev_x -= (self.contents.width - @all_map.width) / 2
x += rev_x
elsif half_width > $game_player.real_x * one_tile_size
rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
x += rev_x
elsif half_width > rest_width
rev_x = -((half_width - rest_width) / 128)
x += rev_x
end
half_height = self.contents.height * 128 / 2
rest_height = ($game_map.height * 128 - $game_player.real_y) * one_tile_size
rev_y = 0
if @all_map.height < self.contents.height
rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
rev_y -= (self.contents.height - @all_map.height) / 2
y += rev_y
elsif half_height > $game_player.real_y * one_tile_size
rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
y += rev_y
elsif half_height > rest_height
rev_y = -((half_height - rest_height) / 128)
y += rev_y
end
src_rect = Rect.new(x, y, self.contents.width, self.contents.height)
$sprite_bitmap.blt(0, 0, @panorama, src_rect)
$sprite_bitmap.blt(0, 0, @all_map, src_rect)
$sprite_bitmap.blt(0, 0, @make_event, src_rect)
$sprite_bitmap.blt(0, 0, @all_fog, src_rect)
if PLAN_Map_Window::WINDOW_MOVE
w = self.x - 32 .. self.x + self.width + 32
h = self.y - 64 .. self.y + self.height + 64
if w === $game_player.screen_x and h === $game_player.screen_y
if !@small_map
case self.x
when 8; self.x = 382
when 382; self.x = 8
end
case self.y
when 272; self.y = 8
when 8; self.y = 272
end
else
case self.x
when 625 - self.width ;self.x = 8
when 8; self.x = 625 - self.width
end
case self.y
when 470 - self.height; self.y = 8
when 8; self.y = 470 - self.height
end
end
end
end
#主角位置
if $game_party.actors.size > 0
if $game_switches[PLAN_Map_Window::NO_ACTOR_SWITCH]
$sprite_bitmap.blur if PLAN_Map_Window::BLUR
return
end
if PLAN_Map_Window::COVER_SWITCH
for i in [2, 1, 0]
tile = @map_data[$game_player.x, $game_player.y, i]
next if tile == 0
if $game_map.priorities[tile] > 0
$sprite_bitmap.blur if PLAN_Map_Window::BLUR
return
end
end
end
actor = $game_party.actors[0]
if actor.character_name == "" or $game_player.opacity == 0
$sprite_bitmap.blur if PLAN_Map_Window::BLUR
return
end
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue).clone
width = bitmap.width/ 4
height = bitmap.height / 4
pattern = $game_player.pattern
sx = PLAN_Map_Window::ACTOR_MOVE ? pattern * width : 0
sy = ($game_player.direction - 2) / 2 * height
#原始行走图大小矩形
src_rect = Rect.new(sx, sy, width, height)
if $ZOOM > 7
w = width / 5
h = height / 5
else
w = width / $ZOOM
h = height / $ZOOM
end
x = self.contents.width / 2 - w / 2 + one_tile_size / 2 - rev_x
y = self.contents.height / 2 - h / 2 - rev_y
#小地图上的行走图大小
dest_rect = Rect.new(x, y, w, h)
$sprite_bitmap.stretch_blt(dest_rect, bitmap, src_rect, $game_player.opacity)
bitmap.dispose
end
$sprite_bitmap.blur if PLAN_Map_Window::BLUR
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def update
super
if @old_real_x != $game_player.real_x or @old_real_y != $game_player.real_y or
@old_real_direction != $game_player.direction
refresh
@old_real_x = $game_player.real_x
@old_real_y = $game_player.real_y
@old_real_direction = $game_player.direction
end
if $game_party.actors.size > 0
if @old_char_name != $game_party.actors[0].character_name
refresh
@old_char_name = $game_party.actors[0].character_name
end
end
if PLAN_Map_Window::ACTOR_MOVE and @old_pattern != $game_player.pattern
refresh
@old_pattern = $game_player.pattern
end
if event_move_judge
@make_event = make_event
refresh
end
if @old_panorama != $game_map.panorama_name
@panorama = make_panorama
refresh
@old_panorama = $game_map.panorama_name
end
if @old_fog != $game_map.fog_name
@all_fog = make_fog
refresh
@old_fog = $game_map.fog_name
end
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
super
@panorama.dispose unless @panorama.disposed?
@all_map.dispose unless @all_map.disposed?
@make_event.dispose unless @make_event.disposed?
@all_fog.dispose unless @all_fog.disposed?
end
end
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
# 处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#==============================================================================
class Game_Player < Game_Character
alias plan_map_window_update update
def update
plan_map_window_update
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# 如果方向键被按下、主角就朝那个方向移动
case Input.dir4
when 2
if $game_switches[PLAN_Map_Window::MAP_SWITCH]
$win_x = 8
$win_y = 8
$direction = 0
$game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
end
when 4
if $game_switches[PLAN_Map_Window::MAP_SWITCH]
$win_x = 382
$win_y = 8
$direction = 1
$game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
end
when 6
if $game_switches[PLAN_Map_Window::MAP_SWITCH]
$win_x = 8
$win_y = 280 - 8
$direction = 2
$game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
end
when 8
if $game_switches[PLAN_Map_Window::MAP_SWITCH]
$win_x = 382
$win_y = 280 - 8
$direction = 3
$game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
end
end
end
end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 游戏中全部窗口的超级类。
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 初始化对像
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的宽
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super()
@windowskin_name = $game_system.windowskin_name
if !$minimap
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
self.x = x.nil? ? 0 : x
self.y = y.nil? ? 0 : y
self.width = width
self.height = height
self.z = 100
end
end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================