设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2971|回复: 5
打印 上一主题 下一主题

[转载] 刷新无须图片的迷你地图显示

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
134 小时
注册时间
2009-3-29
帖子
470
跳转到指定楼层
1
发表于 2011-8-25 01:27:20 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
一直搜藏在我的U盘多年了,本人   纯属转载

无须图片的迷你地图脚本

Woratana [原作者]
RPG Maker VX  

  SWITCH_NO_MINIMAP = 10 #  打开这个开关的话就不显示迷你地图
   
  MAP_RECT = [430, 20, 97, 96] # 迷你地图的大小和位置
  [X, Y, Width, Height]
   你可以用调用脚本的方法任意改变他:
   $game_system.minimap = [X, Y, Width, Height]
  MAP_Z = 0 # 迷你地图的Z轴
   增加这个数值,如果迷你地图显示在某些物体下面的话(被覆盖)。
  GRID_SIZE = 8 # 引导大小,建议数值大于3.
  
  MINIMAP_BORDER_COLOR = Color.new(0, 0, 0, 255) # 色彩设定
   Color.new(Red, Green, Blue, Opacity)
  MINIMAP_BORDER_SIZE = 3
  
  FOREGROUND_COLOR = Color.new(255, 255, 255, 255) # 可通过物颜色
  BACKGROUND_COLOR = Color.new(0, 0, 0, 100) # 不可通过物颜色
  USE_OUTLINE_PLAYER = true # 是否描绘的角色?
  PLAYER_OUTLINE_COLOR = Color.new(0, 0, 0, 255) # 角色颜色
  USE_OUTLINE_EVENT = true # 是否描绘特殊事件?(如商人、敌人NPC等)
  EVENT_OUTLINE_COLOR = Color.new(0, 0, 0, 255) # 特殊事件颜色

这里修改主角颜色  你可以输入 0 - 255 的可选色彩范围 (红, 绿, 蓝, 透明度)
PLAYER_COLOR = Color.new(0, 0, 255, 255) # 角色颜色设定

这里修改事件颜色  你可以输入 0 - 255 的可选色彩范围 (红, 绿, 蓝, 透明度)
  OBJECT_COLOR['npc'] = Color.new(255,255,255,255)
  OBJECT_COLOR['treasure'] = Color.new(255,255,0,255)
  OBJECT_COLOR['enemy'] = Color.new(255,0,0,255)
  OBJECT_COLOR['merchant'] = Color.new(255,150,0,255)
  OBJECT_COLOR['teleport'] = Color.new(255,0,255,255)
  OBJECT_COLOR['rest'] = Color.new(0,255,0,255)

事件里注释:
NPC 非主角控制人物 enemy敌人 treasure宝物 merchant商人 teleport传送 door门   REST   休息


脚本:


  1. #===============================================================
  2. # ● [VX] ?迷你地图 ? □
  3. # * 无须图片的迷你地图脚本,浪使者倾情汉化 *
  4. #--------------------------------------------------------------
  5. # ? by Woratana [原作者]
  6. # ? 用于 RPG Maker VX  
  7. # ? 最近更新: 09/09/2008
  8. # ? 版本: 1.1 Beta
  9. #--------------------------------------------------------------
  10. # ? 特别感谢: KGC 的 XP 迷你地图脚本,
  11. # 没有他的迷你地图脚本,这个就不会被做出来.
  12. # 精灵使者更新:请在注释的第一行写入关键字,关键字可以在下面添加。
  13. #--------------------------------------------------------------

  14. module MiniMap
  15.   #===========================================================================
  16.   # [START]迷你地图脚本设置部分 地图名前+[NOMAP] 不显示
  17.   #---------------------------------------------------------------------------
  18.   SWITCH_NO_MINIMAP = 10 #  打开这个开关的话就不显示迷你地图
  19.    
  20.   MAP_RECT = [430, 20, 97, 96] # 迷你地图的大小和位置
  21.   # [X, Y, Width, Height]
  22.   # 你可以用调用脚本的方法任意改变他:
  23.   # $game_system.minimap = [X, Y, Width, Height]

  24.   MAP_Z = 0 # 迷你地图的Z轴
  25.   # 增加这个数值,如果迷你地图显示在某些物体下面的话(被覆盖)。

  26.   GRID_SIZE = 8 # 引导大小,建议数值大于3.
  27.   
  28.   MINIMAP_BORDER_COLOR = Color.new(0, 0, 0, 255) # 色彩设定
  29.   # Color.new(Red, Green, Blue, Opacity)
  30.   MINIMAP_BORDER_SIZE = 3
  31.   
  32.   FOREGROUND_COLOR = Color.new(255, 255, 255, 255) # 可通过物颜色
  33.   BACKGROUND_COLOR = Color.new(0, 0, 0, 100) # 不可通过物颜色

  34.   USE_OUTLINE_PLAYER = true # 是否描绘的角色?
  35.   PLAYER_OUTLINE_COLOR = Color.new(0, 0, 0, 255) # 角色颜色
  36.   USE_OUTLINE_EVENT = true # 是否描绘特殊事件?(如商人、敌人NPC等)
  37.   EVENT_OUTLINE_COLOR = Color.new(0, 0, 0, 255) # 特殊事件颜色
  38.   
  39.   PLAYER_COLOR = Color.new(0, 0, 255, 255) # 角色颜色设定
  40.   #---------------------------------------------------------------------------

  41.   OBJECT_COLOR = {} # 不要改变或删除这一行!
  42.   #===============================================================
  43.   # * 设置关键字和颜色
  44.   #---------------------------------------------------------------
  45.   # ** 例如:
  46.   # OBJECT_COLOR['keyword'] = Color.new(Red, Green, Blue, Opacity)
  47.   #-------------------------------------------------------------
  48.   # * 'keyword': 你想放到公共事件里来显示的颜色
  49.   # ** 标记: 'keyword' 是很关键的!
  50.   # * Color.new(...): 你需要的颜色
  51.   # 你可输入 0 - 255 的可选色彩范围 (Red, Green, Blue, Opacity)
  52.   #-------------------------------------------------------------
  53.   OBJECT_COLOR['npc'] = Color.new(255,255,255,255)
  54.   OBJECT_COLOR['treasure'] = Color.new(255,255,0,255)
  55.   OBJECT_COLOR['enemy'] = Color.new(255,0,0,255)
  56.   OBJECT_COLOR['merchant'] = Color.new(255,150,0,255)
  57.   OBJECT_COLOR['teleport'] = Color.new(255,0,255,255)
  58.   OBJECT_COLOR['rest'] = Color.new(0,255,0,255)
  59.   #===========================================================================
  60.   # * [说明] 标签:
  61.   #---------------------------------------------------------------------------
  62.   # 改变这些关闭迷你地图 & 或设置显示迷你地图~
  63.   # TAG_EVENT的关键字和OBJECT_COLOR关键字要对应。
  64.   #-----------------------------------------------------------------------
  65.   TAG_NO_MINIMAP = '[NOMAP]'
  66.   TAG_EVENT = ["npc","enemy","treasure","merchant","teleport","rest"]
  67.   #---------------------------------------------------------------------------
  68.   # NPC 非主角控制人物 enemy敌人 treasure宝物 merchant商人 teleport传送 door门
  69.   # REST   休息
  70.   #---------------------------------------------------------------------------
  71.   # [END] 迷你地图脚本设置部分
  72.   #===========================================================================
  73.   
  74.   def self.refresh
  75.     if $scene.is_a?(Scene_Map)
  76.       $scene.spriteset.minimap.refresh
  77.     end
  78.   end
  79.   
  80.   def self.update_object
  81.     if $scene.is_a?(Scene_Map)
  82.       $scene.spriteset.minimap.update_object_list
  83.     end
  84.   end
  85. end

  86. #==============================================================================
  87. # ■ RPG::MapInfo
  88. #==============================================================================
  89. class RPG::MapInfo
  90.   def name
  91.     return @name.gsub(/\[.*\]/) { }
  92.   end

  93.   def original_name
  94.     return @name
  95.   end

  96.   def show_minimap?
  97.     return [email protected]?(MiniMap::TAG_NO_MINIMAP)
  98.   end
  99. end
  100. #==============================================================================
  101. # ■ Game_System
  102. #==============================================================================
  103. class Game_System
  104.   attr_accessor :minimap
  105.   alias wora_minimap_gamsys_ini initialize
  106.   
  107.   def initialize
  108.     wora_minimap_gamsys_ini
  109.     @minimap = MiniMap::MAP_RECT
  110.   end
  111.   
  112.   def show_minimap
  113.     return !$game_switches[MiniMap::SWITCH_NO_MINIMAP]
  114.   end
  115. end
  116. #==============================================================================
  117. # ■ Game_Map
  118. #==============================================================================
  119. class Game_Map
  120.   alias wora_minimap_gammap_setup setup
  121.   def setup(map_id)
  122.     wora_minimap_gammap_setup(map_id)
  123.     @db_info = load_data('Data/MapInfos.rvdata') if @db_info.nil?
  124.     @map_info = @db_info[map_id]
  125.   end
  126.   
  127.   def show_minimap?
  128.     return @map_info.show_minimap?
  129.   end
  130. end
  131. #==============================================================================
  132. # ■ Game_Event
  133. #==============================================================================
  134. class Game_Event < Game_Character
  135.   def mm_comment?(comment, return_comment = false )
  136.     if [email protected]?
  137.       for i in [email protected] - 1
  138.         next if @list[i].code != 108
  139.         if comment.include?(@list[i].parameters[0])
  140.           return @list[i].parameters[0] if return_comment
  141.           return true
  142.         end
  143.       end
  144.     end
  145.     return '' if return_comment
  146.     return false
  147.   end
  148. end

  149. #==============================================================================
  150. # ■ Game_MiniMap
  151. #------------------------------------------------------------------------------
  152. class Game_MiniMap
  153.   def initialize(tilemap)
  154.     @tilemap = tilemap
  155.     refresh
  156.   end

  157.   def dispose
  158.     @border.bitmap.dispose
  159.     @border.dispose
  160.     @map_sprite.bitmap.dispose
  161.     @map_sprite.dispose
  162.     @object_sprite.bitmap.dispose
  163.     @object_sprite.dispose
  164.     @position_sprite.bitmap.dispose
  165.     @position_sprite.dispose
  166.   end

  167.   def visible
  168.     return @map_sprite.visible
  169.   end

  170.   def visible=(value)
  171.     @map_sprite.visible = value
  172.     @object_sprite.visible = value
  173.     @position_sprite.visible = value
  174.     @border.visible = value
  175.   end

  176.   def refresh
  177.     @mmr = $game_system.minimap
  178.     map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
  179.     grid_size = [MiniMap::GRID_SIZE, 1].max

  180.     @x = 0
  181.     @y = 0
  182.     @size = [map_rect.width / grid_size, map_rect.height / grid_size]

  183.     @border = Sprite.new
  184.     @border.x = map_rect.x - MiniMap::MINIMAP_BORDER_SIZE
  185.     @border.y = map_rect.y - MiniMap::MINIMAP_BORDER_SIZE
  186.     b_width = map_rect.width + (MiniMap::MINIMAP_BORDER_SIZE * 2)
  187.     b_height = map_rect.height + (MiniMap::MINIMAP_BORDER_SIZE * 2)
  188.     @border.bitmap = Bitmap.new(b_width, b_height)
  189.     @border.bitmap.fill_rect(@border.bitmap.rect, MiniMap::MINIMAP_BORDER_COLOR)
  190.     @border.bitmap.clear_rect(MiniMap::MINIMAP_BORDER_SIZE, MiniMap::MINIMAP_BORDER_SIZE,
  191.     @border.bitmap.width - (MiniMap::MINIMAP_BORDER_SIZE * 2),
  192.     @border.bitmap.height - (MiniMap::MINIMAP_BORDER_SIZE * 2))
  193.    
  194.     @map_sprite = Sprite.new
  195.     @map_sprite.x = map_rect.x
  196.     @map_sprite.y = map_rect.y
  197.     @map_sprite.z = MiniMap::MAP_Z
  198.     bitmap_width = $game_map.width * grid_size + map_rect.width
  199.     bitmap_height = $game_map.height * grid_size + map_rect.height
  200.     @map_sprite.bitmap = Bitmap.new(bitmap_width, bitmap_height)
  201.     @map_sprite.src_rect = map_rect

  202.     @object_sprite = Sprite.new
  203.     @object_sprite.x = map_rect.x
  204.     @object_sprite.y = map_rect.y
  205.     @object_sprite.z = MiniMap::MAP_Z + 1
  206.     @object_sprite.bitmap = Bitmap.new(bitmap_width, bitmap_height)
  207.     @object_sprite.src_rect = map_rect

  208.     @position_sprite = Sprite_Base.new
  209.     @position_sprite.x = map_rect.x + @size[0] / 2 * grid_size
  210.     @position_sprite.y = map_rect.y + @size[1] / 2 * grid_size
  211.     @position_sprite.z = MiniMap::MAP_Z + 2
  212.    
  213.     bitmap = Bitmap.new(grid_size, grid_size)
  214.     # Player's Outline
  215.     if MiniMap::USE_OUTLINE_PLAYER and MiniMap::GRID_SIZE >= 3
  216.       bitmap.fill_rect(bitmap.rect, MiniMap::PLAYER_OUTLINE_COLOR)
  217.       brect = Rect.new(bitmap.rect.x + 1, bitmap.rect.y + 1, bitmap.rect.width - 2,
  218.         bitmap.rect.height - 2)
  219.       bitmap.clear_rect(brect)
  220.     else
  221.       brect = bitmap.rect
  222.     end
  223.    
  224.     bitmap.fill_rect(brect, MiniMap::PLAYER_COLOR)
  225.     @position_sprite.bitmap = bitmap

  226.     draw_map
  227.     update_object_list
  228.     draw_object
  229.     update_position
  230.   end

  231.   def draw_map
  232.     bitmap = @map_sprite.bitmap
  233.     bitmap.fill_rect(bitmap.rect, MiniMap::BACKGROUND_COLOR)
  234.     map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
  235.     grid_size = [MiniMap::GRID_SIZE, 1].max
  236.    
  237.     $game_map.width.times do |i|
  238.       $game_map.height.times do |j|
  239.         if !$game_map.passable?(i, j)
  240.           next
  241.         end
  242.         rect = Rect.new(map_rect.width / 2 + grid_size * i,
  243.           map_rect.height / 2 + grid_size * j,
  244.           grid_size, grid_size)
  245.         if grid_size >= 3
  246.           if !$game_map.passable?(i, j)
  247.             rect.height -= 1
  248.             rect.x += 1
  249.             rect.width -= 1
  250.             rect.width -= 1
  251.             rect.y += 1
  252.             rect.height -= 1
  253.           end
  254.         end
  255.         bitmap.fill_rect(rect, MiniMap::FOREGROUND_COLOR)
  256.       end
  257.     end
  258.   end

  259.     def update_object_list
  260.     @object_list = {}
  261.     $game_map.events.values.each do |e|
  262.       comment = e.mm_comment?(MiniMap::TAG_EVENT, true)
  263.       if comment != ''
  264.         #type = comment.gsub(/#{MiniMap::TAG_EVENT}/){}.gsub(/\s+/){}
  265.         type = comment
  266.         @object_list[type] = [] if @object_list[type].nil?
  267.         @object_list[type] << e
  268.       end
  269.     end
  270.   end

  271.   def draw_object
  272.     bitmap = @object_sprite.bitmap
  273.     bitmap.clear
  274.     map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
  275.     grid_size = [MiniMap::GRID_SIZE, 1].max
  276.     rect = Rect.new(0, 0, grid_size, grid_size)
  277.     mw = map_rect.width / 2
  278.     mh = map_rect.height / 2

  279.     @object_list.each do |key, events|
  280.       color = MiniMap::OBJECT_COLOR[key]
  281.       next if events.nil? or color.nil?
  282.       events.each do |obj|
  283.         #if !obj.character_name.empty?
  284.           rect.x = mw + obj.real_x * grid_size / 256
  285.           rect.y = mh + obj.real_y * grid_size / 256
  286.           # Event's Outline
  287.           if MiniMap::USE_OUTLINE_EVENT and MiniMap::GRID_SIZE >= 3
  288.             bitmap.fill_rect(rect, MiniMap::EVENT_OUTLINE_COLOR)
  289.             brect = Rect.new(rect.x + 1, rect.y + 1, rect.width - 2,
  290.             rect.height - 2)
  291.             bitmap.clear_rect(brect)
  292.           else
  293.             brect = bitmap.rect
  294.           end
  295.           bitmap.fill_rect(brect, color)
  296.         #end
  297.       end
  298.     end
  299.   end

  300.   def update
  301.     if @mmr != $game_system.minimap
  302.       dispose
  303.       refresh
  304.     end
  305.     update_object_list
  306.     draw_object
  307.     update_position
  308.     if @map_sprite.visible
  309.       @map_sprite.update
  310.       @object_sprite.update
  311.       @position_sprite.update
  312.     end
  313.   end

  314.   def update_position
  315.     map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
  316.     grid_size = [MiniMap::GRID_SIZE, 1].max
  317.     sx = $game_player.real_x * grid_size / 256
  318.     sy = $game_player.real_y * grid_size / 256
  319.     @map_sprite.src_rect.x = sx
  320.     @map_sprite.src_rect.y = sy
  321.     @object_sprite.src_rect.x = sx
  322.     @object_sprite.src_rect.y = sy
  323.   end
  324. end
  325. #==============================================================================
  326. # ■ Spriteset_Map
  327. #------------------------------------------------------------------------------
  328. class Spriteset_Map
  329.   attr_reader :minimap
  330.   alias wora_minimap_sprsetmap_ini initialize
  331.   alias wora_minimap_sprsetmap_dis dispose
  332.   alias wora_minimap_sprsetmap_upd update
  333.   
  334.   def initialize
  335.     wora_minimap_sprsetmap_ini
  336.     if $game_map.show_minimap?
  337.       @minimap = Game_MiniMap.new(@tilemap)
  338.       $game_system.show_minimap = true if $game_system.show_minimap.nil?
  339.       @minimap.visible = $game_system.show_minimap
  340.     end
  341.   end
  342.   
  343.   def dispose
  344.     @minimap.dispose if [email protected]?
  345.     wora_minimap_sprsetmap_dis
  346.   end

  347.   def update
  348.     if [email protected]?
  349.       if $game_system.show_minimap
  350.         @minimap.visible = true
  351.         @minimap.update_object_list
  352.         @minimap.update
  353.       else
  354.         @minimap.visible = false
  355.       end
  356.     end
  357.     wora_minimap_sprsetmap_upd
  358.   end
  359. end
  360. #==============================================================================
  361. # ■ Scene_Map
  362. #------------------------------------------------------------------------------
  363. class Scene_Map < Scene_Base
  364.   attr_reader :spriteset
  365. end
复制代码


黑之翅膀于2011-8-25 01:43补充以下内容:
抱歉抱歉抱歉抱歉抱歉抱歉抱歉抱歉

点评

原帖地址呢……如果不记得了也要标个来自网络吧^  发表于 2011-9-4 14:48
黑之结界勇士

Lv1.梦旅人

梦石
0
星屑
72
在线时间
15 小时
注册时间
2011-8-12
帖子
10
2
发表于 2011-8-25 09:14:58 | 只看该作者
谢啦楼主,很实用的脚本呢
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
51 小时
注册时间
2010-9-20
帖子
106
3
发表于 2011-8-25 09:47:33 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

音速君

梦石
0
星屑
161
在线时间
1623 小时
注册时间
2011-6-9
帖子
3393

开拓者贵宾

4
发表于 2011-8-25 11:10:52 | 只看该作者
很好,就是位置移动的等候时间较长
Deartime
RMVA从零学起
【RMVA从零学起】【基础27课】数据库-系统
#2013年11月24日更新
偷懒了好久呢. .
于是最终还是决定暂时不写进阶教程了
先把这些基础的东西仔细说一下.w.
回复 支持 反对

使用道具 举报

Lv2.观梦者

傻♂逼

梦石
0
星屑
369
在线时间
1605 小时
注册时间
2007-3-13
帖子
6562

烫烫烫开拓者

5
发表于 2011-8-25 15:36:01 | 只看该作者
不错不错很优秀的地图显示,最喜欢了
哎呀,蛋疼什么的最有爱了
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1697
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

6
发表于 2011-8-25 23:18:16 | 只看该作者
看到了我的更新标记了……莫非是我以前更新过的喵?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 05:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表