[Script] [RPGXP] [Scene] Minimap Pro 66RPG
[chapter]Giới Thiệu[/chapter]
Đây là một dạng minimap có thể sử dụng cho cả Tileset map và Panorama map.
[chapter]Tính Năng[/chapter]
có chức năng tự tìm đường rất hay, nhưng tớ khuyên chỉ nên sử dụng chức năng tìm đường của nó cho Tileset map vì nó còn nhiều thiếu xót.:thoaimai:
[chapter]Screenshot:[/chapter]


[chapter]Demo[/chapter]
[chapter]Hướng Dẫn:[/chapter]
Ấn W để bật/tắt minimap
Thêm "." vào sau mỗi tên NPC khi tạo game để hiển thị trên minimap

[chapter]Điều Khoản Sử Dụng[/chapter]
Ko dùng cho dự án thương mại
[chapter]Credit:[/chapter]
Trong Demo
Nguồn : 66RPG.COM
Đây là một dạng minimap có thể sử dụng cho cả Tileset map và Panorama map.
[chapter]Tính Năng[/chapter]
có chức năng tự tìm đường rất hay, nhưng tớ khuyên chỉ nên sử dụng chức năng tìm đường của nó cho Tileset map vì nó còn nhiều thiếu xót.:thoaimai:
[chapter]Screenshot:[/chapter]


[chapter]Demo[/chapter]
http://www.mediafire.com/?gpp4j4g0dqtzoa0
[chapter]Hướng Dẫn:[/chapter]
Ấn W để bật/tắt minimap
Thêm "." vào sau mỗi tên NPC khi tạo game để hiển thị trên minimap

[chapter]Điều Khoản Sử Dụng[/chapter]
Ko dùng cho dự án thương mại
[chapter]Credit:[/chapter]
Trong Demo
Nguồn : 66RPG.COM
Comments
:vuonvai:
THAM GIA GROUP CỦA TTC TRÊN FACEBOOK
gợi ý: thêm path finding vào
[size=medium]0.00 Cash send như thế lào? :pangpang:[/size]
:uynhnhau:
Bỏ chức năng tìm đường thì bạn vào script Window_Micromap trong demo, dòng 22 có lệnh Sửa lại Là ok !
Còn làm mất con trỏ chuột thì bạn có thể thay thế 1 file ảnh trong xuốt nào đó vào thư mục hình ảnh của con trỏ củng được, khỏi chỉnh sửa gì nhiều nhưng còn có thể giữ lại được chức năng hiển thị tọa độ trên minimap :thoaimai:
Còn nếu ko chịu thì để mai tớ chỉnh lại giúp cho, bây giờ buồn ngũ quá..oa oa:vuonvai:
Của bạn đây ! đầu tiên là xóa các script này trong demo :
1.module Mouse
2.Find_Path(4) *
3.Find_Path(8) *
Đấy là những script chuột và script tìm đường, bạn ko cần nó nữa nên xóa đi,ko để lag game, sao đó thay thế script Window_Micromap(*) bằng toàn bộ script sao :
[php]#==============================================================================
# ■ THIẾT LẬP MINIMAP
#==============================================================================
module Micro_Map
X = 70 # Tọa độ X Windown
Y = 50 # Tọa độ Y Windown
WIDTH = 500 # Chiều Ngang Windown
HEIGHT = 380 # Chiều Dọc Windown
OPACITY = 200 # Độ mờ Windown
CONTENTS_OPACITY = 255 # Độ mờ viền Windown
FOG = false # Bật/Tắt Fog
PANORAMA = true # Bật/Tắt Panorama
PANORAMA_KEY = false # Cái này tớ ko biết là gì, nhưng cứ để mặc định vậy
end
#==============================================================================
# ■ Game_Character
#
# 处理角色的类。本类作为 Game_Player 类与 Game_Event
# 类的超级类使用。
#==============================================================================
class Game_Character
#
# ● 定义实例变量
#
attr_reader :move_speed
attr_accessor :move_key
attr_accessor :through
end
#==============================================================================
# ■ Game_Event
#
# 处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
# 在 Game_Map 类的内部使用。
#==============================================================================
class Game_Event < Game_Character
#
# ● 取得名字
#
def name
return @event.name
end
end
#==============================================================================
# ■ Window_Micromap
#
# 显示小地图的窗口。
#==============================================================================
class Window_Micromap < Window_Base
#
# ● 定义实例变量
#
attr_accessor :visible_key
#
# ● 初始化窗口
#
def initialize
super(Micro_Map::X,Micro_Map::Y,Micro_Map::WIDTH,Micro_Map::HEIGHT)
self.contents = Bitmap.new(width - 32, height- 32)
self.opacity = Micro_Map::OPACITY
self.contents_opacity = Micro_Map::CONTENTS_OPACITY
self.visible = false
@visible_key = true
self.z = 9000
@actor = nil
@event = nil
@path = []
@route = []
@array = []
@step = 1
@wait_count = 6 - $game_player.move_speed
@path_count = 0
refresh
end
#
# ● 设置窗口大小
#
def key(k)
@visible_key = k
$game_player.move_key = !k
return
end
#
# ● 设置窗口大小
#
def set(x,y,w,h)
self.x = x
self.y = y
self.width = w
self.height = h
self.contents = Bitmap.new(width - 32, height- 32)
refresh
end
#
# ● 初始化
#
def setup
@path = []
@route = []
@array = []
@path_count = 0
@mini_map = Sprite.new
@mini_map.visible = false
@mini_map.bitmap = Bitmap.new($game_map.width * 32,$game_map.height * 32)
@stdx = ((self.width - 32) * 1.00 / $game_map.width * 1.00)
@stdy = ((self.height - 32) * 1.00 / $game_map.height * 1.00)
@path_line = Sprite.new
@path_line.z = 9997
@path_line.x = self.x
@path_line.y = self.y
@path_line.bitmap = Bitmap.new(self.width, self.height)
end
#
# ● 释放位图
#
def dispose
@mini_map.dispose
@path_line.bitmap.dispose
@path_line.dispose
if @actor != nil
@actor.dispose
end
if @event != nil
@event.dispose
end
if @tilemap != nil
@tilemap.dispose
end
end
#
# ● 描绘地图
# stretch_blt(dest_rect, src_bitmap, src_rect[, opacity])
# 传送 src_bitmap 的矩形 src_rect(Rect)到该位图的矩形 dest_rect(Rect)。
# opacity 指定其不透明度,范围为 0 ~ 255。
# 0~383 --- 自动元件
# > 383 --- 基本元件
#
def draw_map
@mini_map.bitmap.clear
if Micro_Map::PANORAMA == true
# 描绘远景平面
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
@panorama_bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
dest_rect = Rect.new(0,0,32*$game_map.width,32*$game_map.height)
@mini_map.bitmap.stretch_blt(dest_rect,@panorama_bitmap,@panorama_bitmap.rect)
end
# 描绘元件
@tilemap = Sprite.new
@tilemap.visible = false
@tilemap.bitmap = RPG::Cache.tileset($game_map.tileset_name)
if Micro_Map::PANORAMA_KEY == false
for mx in 0...$game_map.width
for my in 0...$game_map.height
for ml in 0..2
id = $game_map.data[mx,my,ml]
# 如果是自动元件
if id <= 383 && id != 0
if id.between?(48*1,48*1+47)
num = 0
elsif id.between?(48*2,48*2+47)
num = 1
elsif id.between?(48*3,48*3+47)
num = 2
elsif id.between?(48*4,48*4+47)
num = 3
elsif id.between?(48*5,48*5+47)
num = 4
elsif id.between?(48*6,48*6+47)
num = 5
elsif id.between?(48*7,48*7+47)
num = 6
end
src_bitmap = RPG::Cache.autotile($game_map.autotile_names[num])
src_rect = Rect.new(32,80,32,32)
tw = 32
th = 32
tx = mx*tw
ty = my*th
dest_rect = Rect.new(tx,ty,tw,th)
@mini_map.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
else # 否则是基本元件
src_bitmap = @tilemap.bitmap
row = ((id - 384) / 8)
column = (id - 384 - 8 * row)
sx = column * 32
sy = row * 32
src_rect = Rect.new(sx,sy,32,32)
tw = 32
th = 32
tx = mx*tw
ty = my*th
dest_rect = Rect.new(tx,ty,tw,th)
@mini_map.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
end
end
end
end
end
# 转换为窗口地图
src_bitmap = @mini_map.bitmap
src_rect = @mini_map.bitmap.rect
dest_rect = Rect.new(0,0,self.width - 32,self.height - 32)
self.contents.stretch_blt(dest_rect,src_bitmap,src_rect)
self.contents.blur(1, 20)
if Micro_Map::FOG == true
# 描绘雾平面
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
@fog_bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
dest_rect = Rect.new(0,0,32*$game_map.width,32*$game_map.height)
self.contents.stretch_blt(dest_rect,@fog_bitmap,@fog_bitmap.rect,50)
end
end
#
# ● 描绘主角
#
def draw_actor
if @actor != nil
@actor.dispose
@actor = Sprite.new
@actor.x = self.x
@actor.y = self.y
@actor.visible = self.visible
@actor.bitmap = Bitmap.new(self.width-8, self.height-16)
@actor.z = 9997
else
@actor = Sprite.new
@actor.x = self.x
@actor.y = self.y
@actor.visible = self.visible
@actor.bitmap = Bitmap.new(self.width-8, self.height-16)
@actor.z = 9997
@actor.bitmap.blur(1, 20)
end
@actor.bitmap.clear
src_bitmap = RPG::Cache.picture("npc")
src_rect = Rect.new(0,0,src_bitmap.width/3,src_bitmap.height)
tx = ($game_player.x*@stdx).floor + 16
ty = ($game_player.y*@stdy).floor + 16
tw = 6
th = 6
dest_rect = Rect.new(tx,ty,tw,th)
@actor.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
end
#
# ● 描绘事件
#
def draw_event
if @event != nil
@event.dispose
@event = Sprite.new
@event.x = self.x
@event.y = self.y
@event.visible = self.visible
@event.bitmap = Bitmap.new(self.width - 8, self.height - 16)
@event.z = 9997
else
@event = Sprite.new
@event.x = self.x
@event.y = self.y
@event.visible = self.visible
@event.bitmap = Bitmap.new(self.width - 8, self.height - 16)
@event.z = 9997
@event.bitmap.blur(1, 20)
end
@event.bitmap.clear
for e in $game_map.events.values
if !e.name.include?(".")
next
end
src_bitmap = RPG::Cache.picture("npc")
src_rect = Rect.new(12,0,src_bitmap.width/3,src_bitmap.height)
tx = (e.x*@stdx).floor + 16
ty = (e.y*@stdy).floor + 16
tw = 6
th = 6
dest_rect = Rect.new(tx,ty,tw,th)
@event.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
end
end
#
# ● 描绘路径
#
def draw_path
nx = $game_player.x
ny = $game_player.y
nt = 0
src_bitmap = RPG::Cache.picture("npc")
src_rect = Rect.new(24,0,src_bitmap.width/3,src_bitmap.height)
loop do
tw = 6
th = 6
tx = (nx*@stdx).floor + 16
ty = (ny*@stdy).floor + 16
dest_rect = Rect.new(tx,ty,tw,th)
case @path[nt]
when 1
nt += 1
nx -= 1
ny += 1
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
when 2
nt += 1
ny += 1
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
when 3
nt += 1
nx += 1
ny += 1
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
when 4
nt += 1
nx -= 1
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
when 6
nt += 1
nx += 1
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
when 7
nt += 1
nx -= 1
ny -= 1
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
when 8
nt += 1
ny -= 1
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
when 9
nt += 1
nx += 1
ny -= 1
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
when nil
@path_line.bitmap.stretch_blt(dest_rect,src_bitmap,src_rect)
@path_line.bitmap.blur(1, 20)
break
end
end
end
#
# ● 刷新
#
def refresh
self.contents.clear
setup
draw_map
draw_actor
draw_event
end
#
# ● 清除
#
def clear
@path_line.visible = false
end
#
# ● 开始分析路径
#
def analyse_path
if @wait_count > 0
@wait_count -= 1
return
end
mouse_x, mouse_y = Mouse.get_mouse_pos
if Mouse.trigger?(Mouse::LEFT) && self.visible == true && Micro_Map::KEY == true
@path = []
@route = []
@array = []
@path_count = 0
@path_line.bitmap.clear
mx = [[0,(((mouse_x-self.x) / @stdx)-0.4).floor].max,$game_map.width-1].min
my = [[0,(((mouse_y-self.y) / @stdy)-0.4).floor].max,$game_map.height-1].min
if [mx,my] == [$game_player.x,$game_player.y]
return
end
if $game_player.passable?(mx,my,0) == false
return
end
nx = $game_player.x
ny = $game_player.y
tx = mx
ty = my
for i in 0..$game_map.width
for j in 0..$game_map.height
if $game_player.passable?(i,j,5)
tp = [i,j]
break
end
end
end
object_route = @find.find_short_path(tx,ty,tp[0],tp[1])
step = [0]
for i in step
if object_route == []
return
end
@route = @find.find_short_path(nx,ny,tx,ty)
@array = exchange_path([nx,ny],@route)
if @array != []
if @array[@array.size-1] != [mx,my]
nx = @array[@array.size-1][0]
ny = @array[@array.size-1][1]
tx = mx
ty = my
step.push(i+1)
else
for s in @route
@path += s
end
end
end
end
draw_path
@path_count = 0
return
end
unless $game_player.moving? or $game_system.map_interpreter.running? or
$game_temp.message_window_showing
if @path != []
case @path[@path_count]
when 1
$game_player.through = true
$game_player.move_lower_left
@wait_count = 6 - $game_player.move_speed
@path_count += 1
$game_player.through = false
when 2
$game_player.through = true
$game_player.move_down
@wait_count = 6 - $game_player.move_speed
@path_count += 1
$game_player.through = false
when 3
$game_player.through = true
$game_player.move_lower_right
@wait_count = 6 - $game_player.move_speed
@path_count += 1
$game_player.through = false
when 4
$game_player.through = true
$game_player.move_left
@wait_count = 6 - $game_player.move_speed
@path_count += 1
$game_player.through = false
when 6
$game_player.through = true
$game_player.move_right
@wait_count = 6 - $game_player.move_speed
@path_count += 1
$game_player.through = false
when 7
$game_player.through = true
$game_player.move_upper_left
@wait_count = 6 - $game_player.move_speed
@path_count += 1
$game_player.through = false
when 8
$game_player.through = true
$game_player.move_up
@wait_count = 6 - $game_player.move_speed
@path_count += 1
$game_player.through = false
when 9
$game_player.through = true
$game_player.move_upper_right
@wait_count = 6 - $game_player.move_speed
@path_count += 1
$game_player.through = false
when nil
@path = []
@route = []
@array = []
@step = 1
@path_count = 0
@path_line.bitmap.clear
end
end
end
end
#
# ● 路劲转换
#
def exchange_path(pos,arg)
nx = pos[0]
ny = pos[1]
array = []
for i in 0..arg.size
case arg
when 1
nx -= 1
ny += 1
array.push([nx,ny])
when 2
ny += 1
array.push([nx,ny])
when 3
nx += 1
ny += 1
array.push([nx,ny])
when 4
nx -= 1
array.push([nx,ny])
when 6
nx += 1
array.push([nx,ny])
when 7
nx -= 1
ny -= 1
array.push([nx,ny])
when 8
ny -= 1
array.push([nx,ny])
when 9
nx += 1
ny -= 1
array.push([nx,ny])
when nil
return array
end
end
end
#
# ● 刷亮主角
#
def update
if @visible_key == false
return
end
case @step
when 1
#get_mini_position
when 2
analyse_path
end
run = []
for e in $game_map.events.values
if e.starting == true
run.push(e)
end
end
if run != []
run = []
self.visible = false
@actor.visible = false
@event.visible = false
return
end
if self.visible == true
@path_line.visible = true
$game_player.move_key = false
end
draw_actor
draw_event
if self.visible == false
end
if Input.trigger?(Input::R) && run == []
self.visible = !self.visible
if self.visible == false
$game_player.move_key = true
else
$game_player.move_key = false
end
@actor.visible = !@actor.visible
@event.visible = !@event.visible
end
end
end[/php]
Chúc bạn thành công :chaychay:
chụp cái ảnh báo lỗi lên đi bạn !