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

Project1

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

[已经解决] 怎么让这个地图显示脚本的位置固定

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
24 小时
注册时间
2013-8-13
帖子
21
跳转到指定楼层
1
发表于 2013-9-20 01:37:11 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
怎么让这个地图显示脚本的位置固定??
一般那些小地图都是随着角色的移动小地图就会移动。。
我想要把小地图设置改为无法移动怎么改?
[
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4. #==============================================================================
  5. # ■ 縮小地图的表示+地图显示地图名和坐标 (ver 1.19)
  6. # by ピニョン clum-sea
  7. # 修改by精灵使者
  8. #
  9. #修正了在某些模版下读档产生的Window_base中x和y为nil的错误。
  10. #修正了大地图下的can't create bitmap的错误
  11. #修改了事件静止状态的时候事件图形发生的BUG和色调出现的严重错误。
  12. #修正了色调同步的时候viewport黑块的BUG。
  13. #增加了小地图和大地图的色调同步(感谢orzfly的viewport脚本)
  14. #增加了刷新速度,解决了从菜单返回地图的卡bug(地图重新生成的时候引起的)
  15. #解决了F12引起的dispose error错误(真累死我了……)
  16. #继续添加了变量的入口,改进了地图的事件效果和事件算法。
  17. #增加了小地图不显示主角的开关,防止某些特殊场合显示主角
  18. #增添了雾图形的描绘,完善了自动元件的算法。调整了地图的z坐标。
  19. #继续增添一些变量的入口,减少了XY坐标的刷新量,优化了BLUR的效果。
  20. #增加了小地图模糊效果,感谢忧雪の伤
  21. #添加了一些变量入口,增加了坐标背景图等
  22. #整合了小地图和坐标两个脚本,请去掉显示地图名的原始脚本(可以退休了)
  23. #去掉了一些老版本使用的旧常量,修正了窗口皮肤和初始可见变量,增添了
  24. #手动刷新开关。
  25. #增添了事件图等,完善了一些开关和变量
  26. #修正了场所移动的时候远景图变黑的问题,感谢忧雪の伤
  27. #精灵再度更新:支持地图的远景图显示(如果有的话)
  28. #冬夜更新说明
  29. #更改了小地图的位置,Q是开启小地图跟随开关
  30. #更新了场所移动时地图的不同步,更新了战斗后的地图不同步
  31. #小地图默认成为false,只在第一次登入时是,以后跟随开关的指示
  32. #修正了由于小地图变化引起的不能转换问题,修整了房间内的地图原先的那个羁押功能
  33. #==============================================================================
  34. #==============================================================================
  35. # □ 前期定义
  36. #==============================================================================
  37. module PLAN_Map_Window
  38.   WIN_WIDTH   = 250               # 地图的宽度
  39.   WIN_HEIGHT  = 200               # 地图的高度
  40.   ZOOM        = 7.0             # 地图的放缩比例
  41.   WINDOWSKIN  = ""                # 自定义地图窗口素材,如果留空则是默认的
  42.   ON_OFF_KEY  = Input::A          # 打开地图的按钮,A就是键盘的Z键
  43.   SWITCH      = 490                 # 禁用地图功能的开关,默认这个就是打开100号
  44.                                   # 开关则禁止使用地图功能,关闭则可以使用地图功能
  45.   WINDOW_MOVE = true              # 窗口中的地图跟随移动,(true:跟随, false:固定)
  46.   OPACITY     = 255               # 窗口的透明度
  47.   C_OPACITY   = 255               # 地图的透明度
  48.   VISIBLE     = false             # 最初是否可见(如果是事件标题请置false)
  49.   SWITCH_KEY  = Input::L          # Q键锁定/解锁小地图(可以用上下左右切换小地图的位置)
  50.   MAP_VISIBLE = 491                 # 地图/地图名显示开关状态
  51.   MAP_SWITCH = 492                  # 地图锁定开关状态
  52.   MAP_DIRECTION = 11               # 地图方向变量
  53.   MINI_MAP = [30,30]              # 小地图和中地图范围
  54.   LARGE_MAP = [70,70]             # 中地图和大地图范围
  55.   EXTRA_MAP = [800,800]           # 超过地图所能显示范围的上限
  56.   MINIMAP_ZOOM = 0.5              # 小地图相对于放缩比的比率
  57.   LARGEMAP_ZOOM = 1.5             # 大地图相对于放所比的比率
  58.   COVER_SWITCH = true             # 是否图块遮掩的时候不显示主角
  59.   MANUAL_REFRESH = 12              # 手动刷新事件开关号
  60.                                   # ,打开即刷新一次,无需手动关闭
  61.   MOVE_REFRESH = 493                # 事件移动时刷新小地图事件开关号
  62.                                   #(效果较好,但耗费内存,请谨慎开启!)
  63.                                   # 可以和手动刷新事件开关配合使用
  64.   AUTO_REFRESH = 494                # 所有小地图事件强制刷新开关号
  65.                                   #(效果最好,严重耗费内存,请谨慎开启!)
  66.   WINDOW_XY = MAP_VISIBLE         # XY坐标窗口开关(和默认地图开关相同,如果不需要
  67.                                   # 相同请单独设置开关号
  68.   MAPNAME_COLOR =
  69.   Color.new(255, 255, 255)        # 地图名颜色,如果是其他颜色请指定
  70.   XYNAME_COLOR =
  71.   Color.new(192, 224, 255)        # XY名字的颜色,如果是其他颜色请指定
  72.   XYNUMBER_COLOR =
  73.   Color.new(255, 255, 255)        # XY数字的颜色,如果是其他颜色请指定
  74.   XY_OPACITY = 0                  # XY窗口的透明度,默认完全透明
  75.   XY_B_OPACITY = 0                # XY窗口背景的透明度,默认完全透明
  76.   XY_C_OPACITY = 255              # XY窗口内容的透明度,默认完全不透明
  77.   XYBACK_PNG = ""                 # XY背景图片文件名(注:背景图片会遮挡小地图)
  78.   XYBACK_OPATITY = 192            # XY背景透明度(建议透明,否则会完全盖住)
  79.   XY_WORD_X = "X:"                # 表示X坐标的用语
  80.   XY_WORD_Y = "Y:"                # 表示Y坐标的用语
  81.   BLUR = true                     # 柔化开关,对地图统一柔化
  82.   NO_ACTOR_SWITCH = 495             # 不显示主角的开关
  83.   ACTOR_MOVE = false              # 主角走路开关(会占用些许内存,请谨慎开启)
  84. end
  85.  
  86. #=============================================================================
  87. # ■ Bitmap重定义
  88. #=============================================================================
  89.  
  90. class Bitmap
  91.   def blur(strength = 1, opacity = 10)
  92.    (-strength).upto(strength) do |x|
  93.      (-strength).upto(strength) do |y|
  94.       next if x.zero? and y.zero?
  95.       src_rect = Rect.new(0, 0, width - x, height - y)
  96.       blt(x, y, self, src_rect, opacity)
  97.      end
  98.     end
  99.   end
  100. end
  101.  
  102. #==============================================================================
  103. # ■ Game_Temp
  104. #==============================================================================
  105. class Game_Temp
  106.   attr_accessor  :map_visible     # 地图的表示状态
  107.   attr_accessor  :xy_visible      # XY地图的表示状态
  108.   attr_accessor  :back_visible    # 背景图表示状态
  109. end
  110.  
  111. #==============================================================================
  112. # ■ Window_XY
  113. #------------------------------------------------------------------------------
  114. #  显示坐标的窗口。
  115. #==============================================================================
  116. class Window_xy < Window_Base
  117. #--------------------------------------------------------------------------
  118. # ● 初始化窗口
  119. #--------------------------------------------------------------------------
  120. def initialize
  121.    super(0, 0, 280, 96)
  122.    @mapnames = load_data("Data/MapInfos.rxdata")
  123.    self.contents = Bitmap.new(width - 32, height - 32)
  124.    self.back_opacity = PLAN_Map_Window::XY_B_OPACITY
  125.    self.opacity = PLAN_Map_Window::XY_OPACITY
  126.    self.contents.font.bold = true
  127.    self.contents_opacity = PLAN_Map_Window::XY_C_OPACITY
  128.    self.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  129.    refresh if self.visible
  130.    @x = $game_player.x
  131.    @y = $game_player.y
  132.    @id = $game_map.map_id
  133. end
  134.  
  135. #--------------------------------------------------------------------------
  136. # ● 刷新
  137. #--------------------------------------------------------------------------
  138. def refresh
  139.     if $game_switches[PLAN_Map_Window::WINDOW_XY]
  140.      @x = $game_player.x
  141.      @y = $game_player.y
  142.      @id = $game_map.map_id
  143.     self.contents.clear
  144.     map_name = @mapnames[@id].name
  145.     self.contents.font.color = PLAN_Map_Window::MAPNAME_COLOR
  146.     self.contents.draw_text(0, 0, 175, 32, map_name,1)
  147.     self.contents.font.color = PLAN_Map_Window::XYNAME_COLOR
  148.     self.contents.draw_text(0, 32, 175, 32, PLAN_Map_Window::XY_WORD_X)
  149.     self.contents.font.color = PLAN_Map_Window::XYNUMBER_COLOR
  150.     self.contents.draw_text(0, 32, 80, 32, @x.to_s,2)
  151.     self.contents.font.color = PLAN_Map_Window::XYNAME_COLOR
  152.     self.contents.draw_text(95, 32, 175, 32, PLAN_Map_Window::XY_WORD_Y)
  153.     self.contents.font.color = PLAN_Map_Window::XYNUMBER_COLOR
  154.     self.contents.draw_text(0, 32, 175, 32, @y.to_s,2)
  155.    end
  156. end
  157.  
  158. #--------------------------------------------------------------------------
  159. # ● 判断文字刷新。节约内存用
  160. #--------------------------------------------------------------------------
  161. def judge
  162.    return true if @x != $game_player.x
  163.    return true if @y != $game_player.y
  164.    return true if @id != $game_map.map_id
  165.    return false
  166. end
  167. end
  168.  
  169. #==============================================================================
  170. # ■ Scene_Map
  171. #==============================================================================
  172. class Scene_Map
  173.   #--------------------------------------------------------------------------
  174.   # ● 主处理
  175.   #--------------------------------------------------------------------------
  176.   alias plan_map_window_main main unless $@
  177.   def main
  178.   $minimap = false
  179.   @map_window = Window_Map.new
  180.   @xy_window = Window_xy.new
  181.   @xy_window.x = 640 - 230
  182.   @xy_window.y = 480 - 101
  183.   @xy_window.z = 1500
  184.   @map_window.z = 1000
  185.   vx = @map_window.x + 16
  186.   vy = @map_window.y + 16
  187.   vw = @map_window.contents.width
  188.   vh = @map_window.contents.height
  189.   @viewport = Viewport.new(vx,vy,vw,vh)
  190.   @sprite = Sprite.new(@viewport)
  191.   @sprite.bitmap = $sprite_bitmap.clone
  192.   @sprite.tone = $game_screen.tone.clone
  193.   @sprite.opacity = PLAN_Map_Window::C_OPACITY
  194.   @viewport.z = @map_window.z
  195.   @viewport.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  196.   @xy_window.opacity = PLAN_Map_Window::XY_OPACITY
  197.   @xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  198.   @xy_window.refresh if @xy_window.visible
  199.   @map_window.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  200.   @back = Sprite.new
  201.   unless PLAN_Map_Window::XYBACK_PNG.empty?
  202.   @back.bitmap = Bitmap.new("Graphics/Pictures/"+PLAN_Map_Window::XYBACK_PNG)
  203.   @back.x = 640 - 16 - @back.bitmap.width
  204.   @back.y = 480 - 16 - @back.bitmap.height
  205.   @back.z = 1250
  206.   end
  207.   @back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  208.   @back.opacity = PLAN_Map_Window::XYBACK_OPATITY
  209.   plan_map_window_main
  210.   @map_window.dispose
  211.   @xy_window.dispose
  212.   @back.dispose
  213.   @sprite.dispose
  214.   @viewport.dispose
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● 更新
  218.   #--------------------------------------------------------------------------
  219.   alias plan_map_window_update update unless $@
  220.   def update
  221.     $game_temp.map_visible = @map_window.visible
  222.     $game_temp.xy_visible = @xy_window.visible
  223.     $game_temp.back_visible = @back.visible
  224.     @xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  225.     @xy_window.refresh if (@xy_window.judge and @xy_window.visible)
  226.     @back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  227.     plan_map_window_update
  228.      if PLAN_Map_Window::VISIBLE and !@first_open
  229.       @map_window.visible = true
  230.       $game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
  231.       @xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  232.       @xy_window.refresh if @xy_window.visible
  233.       @back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  234.       $map_close = false
  235.       @first_open = true
  236.      end
  237.     if $game_switches[PLAN_Map_Window::SWITCH]
  238.       if @map_window.visible
  239.       @map_window.visible = false
  240.       $game_switches[PLAN_Map_Window::MAP_VISIBLE]= false
  241.       $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  242.       $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  243.       $map_close = true
  244.       end  
  245.     else
  246.       if $map_close
  247.          @map_window.visible = true
  248.          $game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
  249.          @xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  250.          @xy_window.refresh if @xy_window.visible
  251.          @back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  252.          $map_close = false
  253.       end
  254.     if !$game_temp.in_battle
  255.       if Input.trigger?(PLAN_Map_Window::ON_OFF_KEY)
  256.         if @map_window.visible
  257.           $game_system.se_play($data_system.cancel_se)
  258.           @map_window.visible = false
  259.           $game_switches[PLAN_Map_Window::MAP_VISIBLE]= false
  260.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  261.           $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  262.         else
  263.           $game_system.se_play($data_system.decision_se)
  264.           @map_window.visible = true
  265.           $game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
  266.           @xy_window.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  267.           @xy_window.refresh if @xy_window.visible
  268.           @back.visible = $game_switches[PLAN_Map_Window::WINDOW_XY]
  269.         end
  270.       end
  271.       if Input.trigger?(PLAN_Map_Window::SWITCH_KEY)
  272.         if @map_window.visible
  273.         if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  274.           $game_system.se_play($data_system.cancel_se)
  275.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  276.           $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  277.          else
  278.           $game_system.se_play($data_system.decision_se)
  279.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = true
  280.          end
  281.        end
  282.      end
  283.    end
  284.     end
  285.       @map_window.update if @map_window.visible
  286.      vx = @map_window.x + 16
  287.      vy = @map_window.y + 16
  288.      vw = @map_window.contents.width
  289.      vh = @map_window.contents.height
  290.     @viewport.rect = Rect.new(vx,vy,vw,vh)
  291.     @sprite.bitmap = $sprite_bitmap.clone
  292.     @sprite.tone = $game_screen.tone.clone
  293.     @viewport.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  294.     @sprite.update if @viewport.visible
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 场所移动的变化
  298.   #--------------------------------------------------------------------------
  299. alias plan_map_window_transfer_player transfer_player unless $@
  300.   def transfer_player
  301.     old_map_id = $game_map.map_id
  302.     plan_map_window_transfer_player
  303.     if old_map_id != $game_map.map_id
  304.     GC.start
  305.     @map_window.visible = false
  306.     @viewport.visible = false
  307.     @map_window.dispose
  308.     @sprite.dispose
  309.     @viewport.dispose
  310.     @map_window = Window_Map.new
  311.     vx = @map_window.x + 16
  312.     vy = @map_window.y + 16
  313.     vw = @map_window.contents.width
  314.     vh = @map_window.contents.height
  315.     @viewport = Viewport.new(vx,vy,vw,vh)
  316.     @sprite = Sprite.new(@viewport)
  317.     @sprite.bitmap = $sprite_bitmap.clone
  318.     @sprite.tone = $game_screen.tone.clone
  319.     @sprite.opacity = PLAN_Map_Window::C_OPACITY
  320.     @viewport.z = @map_window.z
  321.     @viewport.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  322.     end
  323.   end
  324. end
  325. #==============================================================================
  326. # ■ Window_Map
  327. #==============================================================================
  328. class Window_Map < Window_Base
  329.   #--------------------------------------------------------------------------
  330.   # ● 初始化
  331.   #--------------------------------------------------------------------------
  332.   def initialize
  333.    $direction = $game_variables[PLAN_Map_Window::MAP_DIRECTION]
  334.    if $win_x != nil
  335.       x = $win_x
  336.       y = $win_y
  337.    else
  338.    case $direction
  339.      when 0
  340.      x = 8
  341.      y = 8
  342.      $win_x = x
  343.      $win_y = y
  344.      when 1
  345.      x = 382
  346.      y = 8
  347.      $win_x = x
  348.      $win_y = y
  349.      when 2
  350.      x = 8
  351.      y = 280 - 8
  352.      $win_x = x
  353.      $win_y = y
  354.      when 3
  355.      x = 382
  356.      y = 280 - 8
  357.      $win_x = x
  358.      $win_y = y
  359.      end
  360.    end
  361.     w = PLAN_Map_Window::WIN_WIDTH
  362.     h = PLAN_Map_Window::WIN_HEIGHT
  363.   $minimap = true
  364.    super(x, y, w, h)
  365.   $minimap = false
  366.     self.contents = Bitmap.new(width - 32, height - 32)
  367.     $sprite_bitmap = Bitmap.new(width - 32, height - 32)
  368.     self.opacity = PLAN_Map_Window::OPACITY
  369.     self.contents_opacity = 0
  370.     self.z = 1000
  371.     @map_data = $game_map.data
  372.     @tileset = RPG::Cache.tileset($game_map.tileset_name)
  373.     @autotiles = []
  374.     for i in 0..6
  375.       autotile_name = $game_map.autotile_names[i]
  376.       @autotiles[i] = RPG::Cache.autotile(autotile_name)
  377.     end
  378.     @old_event = $game_map.events
  379.     @old_real_x = $game_player.real_x
  380.     @old_real_y = $game_player.real_y
  381.     @old_char_name = $game_party.actors[0].character_name if $game_party.actors.size > 0
  382.     @old_pattern = $game_player.pattern if $game_party.actors.size > 0
  383.     @old_panorama = $game_map.panorama_name
  384.     @old_fog = $game_map.fog_name
  385.   if $game_map.width > PLAN_Map_Window::LARGE_MAP[0] or $game_map.height > PLAN_Map_Window::LARGE_MAP[1]
  386.       $ZOOM = PLAN_Map_Window::LARGEMAP_ZOOM * PLAN_Map_Window::ZOOM
  387.   else   
  388.     if $game_map.width < PLAN_Map_Window::MINI_MAP[0] or $game_map.height < PLAN_Map_Window::MINI_MAP[1]
  389.       $ZOOM = PLAN_Map_Window::MINIMAP_ZOOM * PLAN_Map_Window::ZOOM
  390.     else
  391.       $ZOOM = PLAN_Map_Window::ZOOM
  392.     end
  393.   end
  394.     @panorama = make_panorama
  395.     @all_map = make_all_map
  396.     @make_event = make_event
  397.     @all_fog = make_fog
  398.     self.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  399.      unless PLAN_Map_Window::WINDOWSKIN.empty?
  400.        self.windowskin = RPG::Cache.windowskin(PLAN_Map_Window::WINDOWSKIN)
  401.      end
  402.     refresh
  403.   end
  404. #--------------------------------------------------------------------------
  405. # ● 自动元件相关
  406. #--------------------------------------------------------------------------
  407.  
  408. def make_one_autotile(id)
  409. one_autotile = Bitmap.new(32,32)
  410. case id
  411. # 中间的空白部分
  412.    when 0 : w = 2 ; h = 4 ; #中间空白
  413. # 四周的方框
  414.    when 1 : w = 0 ; h = 0 ; #左上
  415.    when 2 : w = 1 ; h = 0 ; #右上
  416.    when 3 : w = 0 ; h = 1 ; #左下
  417.    when 4 : w = 1 ; h = 1 ; #右下
  418. # 四周的边角
  419.    when 5 : w = 4 ; h = 0 ; #左上
  420.    when 6 : w = 5 ; h = 0 ; #右上
  421.    when 7 : w = 4 ; h = 1 ; #左下
  422.    when 8 : w = 5 ; h = 1 ; #右下
  423. # 四周的直线
  424.    when 9 : w = 0 ; h = 4 ; #左边
  425.    when 10 : w = 5 ; h = 4 ; #右边
  426.    when 11 : w = 2 ; h = 2 ; #上边
  427.    when 12 : w = 2 ; h = 7 ; #下边
  428.   end
  429.   src_rect = Rect.new(w * 16, h * 16, 16, 16)
  430.   one_autotile.blt(0,0,@autotiles[@tile_num / 48],src_rect)
  431.   return one_autotile
  432. end
  433. def make_autotile(id)
  434.   full_autotile = Bitmap.new(32,32)
  435.   autotile_table = [0,0,0,0]
  436.   case id
  437.   # 左上右上左下右下
  438.   when 0 : autotile_table = [ 0, 0, 0, 0 ]
  439.   when 1 : autotile_table = [ 5, 0, 0, 0 ]
  440.   when 2 : autotile_table = [ 0, 6, 0, 0 ]
  441.   when 3 : autotile_table = [ 5, 6, 0, 0 ]
  442.   when 4 : autotile_table = [ 0, 0, 0, 8 ]
  443.   when 5 : autotile_table = [ 5, 0, 0, 8 ]
  444.   when 6 : autotile_table = [ 0, 6, 0, 8 ]
  445.   when 7 : autotile_table = [ 5, 6, 0, 8 ]
  446.  
  447.   when 8 : autotile_table = [ 0, 0, 7, 0 ]
  448.   when 9 : autotile_table = [ 5, 0, 7, 0 ]
  449.   when 10 : autotile_table = [ 0, 6, 7, 0 ]
  450.   when 11 : autotile_table = [ 5, 6, 7, 0 ]
  451.   when 12 : autotile_table = [ 0, 0, 7, 8 ]
  452.   when 13 : autotile_table = [ 5, 0, 7, 8 ]
  453.   when 14 : autotile_table = [ 0, 6, 7, 8 ]
  454.   when 15 : autotile_table = [ 5, 6, 7, 8 ]
  455.  
  456.   when 16 : autotile_table = [ 9, 0, 9, 0 ]
  457.   when 17 : autotile_table = [ 9, 6, 9, 0 ]
  458.   when 18 : autotile_table = [ 9, 0, 9, 8 ]
  459.   when 19 : autotile_table = [ 9, 6, 9, 8 ]
  460.   when 20 : autotile_table = [ 11, 11, 0, 0 ]
  461.   when 21 : autotile_table = [ 11, 11, 0, 8 ]
  462.   when 22 : autotile_table = [ 11, 11, 7, 0 ]
  463.   when 23 : autotile_table = [ 11, 11, 7, 8 ]
  464.  
  465.   when 24 : autotile_table = [ 0, 10, 0, 10 ]
  466.   when 25 : autotile_table = [ 0, 10, 7, 10 ]
  467.   when 26 : autotile_table = [ 5, 10, 0, 10 ]
  468.   when 27 : autotile_table = [ 5, 10, 7, 10 ]
  469.   when 28 : autotile_table = [ 0, 0, 12, 12 ]
  470.   when 29 : autotile_table = [ 5, 0, 12, 12 ]
  471.   when 30 : autotile_table = [ 0, 6, 12, 12 ]
  472.   when 31 : autotile_table = [ 5, 6, 12, 12 ]
  473.  
  474.   when 32 : autotile_table = [ 9, 10, 9, 10 ]
  475.   when 33 : autotile_table = [ 11, 11, 12, 12 ]
  476.   when 34 : autotile_table = [ 1, 11, 9, 0 ]
  477.   when 35 : autotile_table = [ 1, 11, 9, 8 ]
  478.   when 36 : autotile_table = [ 11, 2, 0, 10 ]
  479.   when 37 : autotile_table = [ 11, 2, 7, 10 ]
  480.   when 38 : autotile_table = [ 0, 10, 12, 4 ]
  481.   when 39 : autotile_table = [ 5, 10, 12, 4 ]
  482.  
  483.   when 40 : autotile_table = [ 9, 0, 3, 12 ]
  484.   when 41 : autotile_table = [ 9, 6, 3, 12 ]
  485.   when 42 : autotile_table = [ 1, 2, 9, 10 ]
  486.   when 43 : autotile_table = [ 1, 11, 3, 12 ]
  487.   when 44 : autotile_table = [ 9, 10, 3, 4 ]
  488.   when 45 : autotile_table = [ 11, 2, 12, 4 ]
  489.   when 46 : autotile_table = [ 1, 2, 3, 4 ]
  490.   when 47 : autotile_table = [ 1, 2, 3, 4 ]
  491. end
  492.   one_autotile1 = make_one_autotile(autotile_table[0])
  493.   one_autotile2 = make_one_autotile(autotile_table[1])
  494.   one_autotile3 = make_one_autotile(autotile_table[2])
  495.   one_autotile4 = make_one_autotile(autotile_table[3])
  496.   src_rect = Rect.new( 0, 0,16,16)
  497.   full_autotile.blt( 0, 0,one_autotile1,src_rect)
  498.   full_autotile.blt(16, 0,one_autotile2,src_rect)
  499.   full_autotile.blt( 0,16,one_autotile3,src_rect)
  500.   full_autotile.blt(16,16,one_autotile4,src_rect)
  501.   return full_autotile
  502.   end
  503.  
  504.   #--------------------------------------------------------------------------
  505.   # ● 缩小图做成
  506.   #--------------------------------------------------------------------------
  507.   def make_all_map
  508.     load_backup = $ret_bitmap.nil? ? false : !$ret_bitmap.disposed?
  509.     if ($game_map.map_id == $old_map_id) and load_backup
  510.       ret_bitmap = $ret_bitmap.clone
  511.   else
  512.     all_map = Bitmap.new($game_map.width * 32, $game_map.height * 32)
  513.     for y in 0...$game_map.height
  514.       for x in 0...$game_map.width
  515.         for z in 0...3
  516.           @tile_num = @map_data[x, y, z]
  517.           next if @tile_num == nil
  518.           if @tile_num < 384
  519.             if @tile_num >= 48
  520.               @tile_num -= 48
  521.               tile_id = @tile_num % 48
  522.               src_rect = Rect.new(0,0,32,32)
  523.               autotile = make_autotile(tile_id)
  524.               all_map.blt(x * 32, y * 32, autotile , src_rect)
  525.             end
  526.           else
  527.             @tile_num -= 384
  528.             src_rect = Rect.new(@tile_num % 8 * 32, @tile_num / 8 * 32, 32, 32)
  529.             all_map.blt(x * 32, y * 32, @tileset, src_rect)
  530.           end
  531.         end
  532.       end
  533.     end
  534.     w = ($game_map.width / $ZOOM) * 32
  535.     h = ($game_map.height / $ZOOM) * 32
  536.     ret_bitmap = Bitmap.new(w, h)
  537.     src_rect = Rect.new(0, 0, all_map.width, all_map.height)
  538.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  539.     ret_bitmap.stretch_blt(dest_rect, all_map, src_rect)
  540.     $ret_bitmap = ret_bitmap.clone
  541.     $old_map_id = $game_map.map_id
  542.     end
  543.     all_map.dispose unless all_map.nil?
  544.     autotile.dispose unless autotile.nil?
  545.     return ret_bitmap
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # ● 远景图做成
  549.   #--------------------------------------------------------------------------
  550.   def make_panorama
  551.     all_panorama = RPG::Cache.panorama($game_map.panorama_name,$game_map.panorama_hue).clone
  552.     w = ($game_map.width / $ZOOM) * 32
  553.     h = ($game_map.height / $ZOOM) * 32
  554.     ret_bitmap = Bitmap.new(w, h)
  555.     src_rect = Rect.new(0, 0, all_panorama.width, all_panorama.height)
  556.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  557.     ret_bitmap.stretch_blt(dest_rect, all_panorama, src_rect)
  558.     all_panorama.dispose
  559.     return ret_bitmap
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # ● 缩小事件做成
  563.   #--------------------------------------------------------------------------
  564.   def make_event
  565.     all_event = Bitmap.new($game_map.width * 32, $game_map.height * 32)
  566.     for event in $game_map.events.values
  567.      x = event.x
  568.      y = event.y
  569.      @tile_id = event.tile_id
  570.      @character_name = event.character_name
  571.      @character_hue = event.character_hue
  572.      @direction = event.direction
  573.      @pattern = event.pattern
  574.      [url=home.php?mod=space&uid=316553]@opacity[/url] = event.opacity
  575.      if @character_name != ""
  576.        temp_b = RPG::Cache.character(@character_name,@character_hue).clone
  577.        @cw = temp_b.width / 4
  578.        @ch = temp_b.height / 4
  579.        sx = @pattern * @cw
  580.        sy = (@direction - 2) / 2 * @ch
  581.        src_rect = Rect.new(sx,sy,@cw,@ch)
  582.        all_event.blt(((x * 32)-((@cw-32)/2)), ((y * 32) - (@ch-32)), temp_b, src_rect ,@opacity)
  583.        temp_b.dispose
  584.      elsif @tile_id != 0
  585.        @tile_id -= 384
  586.        src_rect = Rect.new(@tile_id % 8 * 32, @tile_id / 8 * 32, 32, 32)
  587.        all_event.blt(x * 32, y * 32, @tileset, src_rect)
  588.      end
  589.     end
  590.     w = ($game_map.width / $ZOOM) * 32
  591.     h = ($game_map.height / $ZOOM) * 32
  592.     ret_bitmap = Bitmap.new(w, h)
  593.     src_rect = Rect.new(0, 0, all_event.width, all_event.height)
  594.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  595.     ret_bitmap.stretch_blt(dest_rect, all_event, src_rect)
  596.     all_event.dispose
  597.     return ret_bitmap
  598.   end
  599.   #--------------------------------------------------------------------------
  600.   # ● 移动事件判断
  601.   #--------------------------------------------------------------------------
  602.   def event_move_judge
  603.     moving = false
  604.     if $game_switches[PLAN_Map_Window::MOVE_REFRESH]
  605.      for event in $game_map.events.values
  606.        event_old = @old_event[event.id]
  607.        moving = true if event.moving? or event.jumping?
  608.        moving = true if event.character_name != event_old.character_name
  609.        moving = true if event.character_hue != event_old.character_hue
  610.        moving = true if event.tile_id != event_old.tile_id
  611.        moving = true if event.direction != event_old.direction
  612.        moving = true if event.pattern != event_old.pattern
  613.        moving = true if event.opacity != event_old.opacity
  614.      end
  615.     end
  616.     moving = true if $game_switches[PLAN_Map_Window::AUTO_REFRESH]
  617.     if $game_switches[PLAN_Map_Window::MANUAL_REFRESH]
  618.       moving = true
  619.       $game_switches[PLAN_Map_Window::MANUAL_REFRESH] = false
  620.     end
  621.       @old_event = $game_map.events
  622.     return moving
  623.   end
  624.  
  625.   #--------------------------------------------------------------------------
  626.   # ● 雾图形做成
  627.   #--------------------------------------------------------------------------
  628.   def make_fog
  629.     all_fog = Bitmap.new($game_map.width * 32, $game_map.height * 32)
  630.     fog_name = $game_map.fog_name
  631.     fog_hue = $game_map.fog_hue
  632.     fog_bitmap = RPG::Cache.fog(fog_name, fog_hue).clone
  633.     num_x = $game_map.width * 32 / fog_bitmap.width
  634.     num_y = $game_map.height * 32 / fog_bitmap.height
  635.     for x in 0..num_x
  636.      for y in 0..num_y
  637.       src_rect = Rect.new(0, 0, fog_bitmap.width, fog_bitmap.height)
  638.       all_fog.blt((x * fog_bitmap.width),(y * fog_bitmap.height),
  639.       fog_bitmap,src_rect)
  640.      end
  641.     end
  642.     w = ($game_map.width / $ZOOM) * 32
  643.     h = ($game_map.height / $ZOOM) * 32
  644.     ret_bitmap = Bitmap.new(w, h)
  645.     src_rect = Rect.new(0, 0, all_fog.width, all_fog.height)
  646.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  647.     ret_bitmap.stretch_blt(dest_rect, all_fog, src_rect,50)
  648.     return ret_bitmap
  649.   end
  650.   #--------------------------------------------------------------------------
  651.   # ● 刷新
  652.   #--------------------------------------------------------------------------
  653.   def refresh
  654.     self.contents.clear
  655.     self.x = $win_x.nil? ? 0 : $win_x
  656.     self.y = $win_y.nil? ? 0 : $win_y
  657.     self.z = 1000
  658.   @small_map = false
  659.   if $game_map.width < PLAN_Map_Window::LARGE_MAP[0] or $game_map.height < PLAN_Map_Window::LARGE_MAP[1]
  660.     #这个是当地图大小宽和高小于指定大小时才改变大小,限制小地图窗口大小
  661.     if $game_map.width < PLAN_Map_Window::MINI_MAP[0] or $game_map.height < PLAN_Map_Window::MINI_MAP[1]
  662.       #这同时限制了变换小地图的大小,防止因为地图宽长无法切换
  663.       self.width = [@all_map.width,PLAN_Map_Window::WIN_WIDTH].min
  664.       self.height = [@all_map.height,PLAN_Map_Window::WIN_HEIGHT].min
  665.       self.contents = Bitmap.new(width-32, height-32)
  666.      #让改变的小地图X坐标紧贴边缘
  667.     if self.x + self.width > 250
  668.       self.x = 625 - self.width
  669.     end
  670.       #让改变的小地图Y左边紧贴边缘
  671.     if self.y + self.height > 380
  672.       self.y = 470 - self.height
  673.     end
  674.      @small_map = true
  675.   end
  676. end
  677.    if self.windowskin == nil
  678.    @windowskin_name = $game_system.windowskin_name
  679.    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  680.    end
  681.     one_tile_size = 32 / $ZOOM
  682.     x = $game_player.real_x - 64 * (self.contents.width / one_tile_size)
  683.     y = $game_player.real_y - 64 * (self.contents.height / one_tile_size)
  684.     x = x * one_tile_size / 128
  685.     y = y * one_tile_size / 128
  686.     px = 0
  687.     py = 0
  688.     half_width = self.contents.width * 128 / 2
  689.     rest_width = ($game_map.width * 128 - $game_player.real_x) * one_tile_size
  690.     rev_x = 0
  691.     if @all_map.width < self.contents.width
  692.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  693.       rev_x -= (self.contents.width - @all_map.width) / 2
  694.       x += rev_x
  695.     elsif half_width > $game_player.real_x * one_tile_size
  696.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  697.       x += rev_x
  698.     elsif half_width > rest_width
  699.       rev_x = -((half_width - rest_width) / 128)
  700.       x += rev_x
  701.     end
  702.     half_height = self.contents.height * 128 / 2
  703.     rest_height = ($game_map.height * 128 - $game_player.real_y) * one_tile_size
  704.     rev_y = 0
  705.     if @all_map.height < self.contents.height
  706.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  707.       rev_y -= (self.contents.height - @all_map.height) / 2
  708.       y += rev_y
  709.     elsif half_height > $game_player.real_y * one_tile_size
  710.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  711.       y += rev_y
  712.     elsif half_height > rest_height
  713.       rev_y = -((half_height - rest_height) / 128)
  714.       y += rev_y
  715.     end
  716.     src_rect = Rect.new(x, y, self.contents.width, self.contents.height)
  717.     $sprite_bitmap.blt(0, 0, @panorama, src_rect)
  718.     $sprite_bitmap.blt(0, 0, @all_map, src_rect)
  719.     $sprite_bitmap.blt(0, 0, @make_event, src_rect)
  720.     $sprite_bitmap.blt(0, 0, @all_fog, src_rect)
  721.      if PLAN_Map_Window::WINDOW_MOVE
  722.       w = self.x - 32 .. self.x + self.width + 32
  723.       h = self.y - 64 .. self.y + self.height + 64
  724.       if w === $game_player.screen_x and h === $game_player.screen_y
  725.         if !@small_map
  726.       case self.x
  727.        when 8; self.x = 382
  728.        when 382; self.x = 8
  729.       end
  730.       case self.y
  731.        when 272; self.y = 8
  732.        when 8; self.y = 272
  733.       end
  734.       else
  735.        case self.x
  736.        when  625 - self.width ;self.x = 8
  737.        when 8; self.x = 625 - self.width
  738.        end
  739.        case self.y
  740.        when 470 - self.height; self.y = 8
  741.        when 8; self.y = 470 - self.height
  742.        end
  743.       end
  744.     end
  745.    end
  746.      #主角位置
  747.     if $game_party.actors.size > 0
  748.       if $game_switches[PLAN_Map_Window::NO_ACTOR_SWITCH]
  749.         $sprite_bitmap.blur if PLAN_Map_Window::BLUR
  750.         return
  751.       end
  752.       if PLAN_Map_Window::COVER_SWITCH
  753.       for i in [2, 1, 0]
  754.         tile = @map_data[$game_player.x, $game_player.y, i]
  755.         next if tile == 0
  756.         if $game_map.priorities[tile] > 0
  757.         $sprite_bitmap.blur if PLAN_Map_Window::BLUR
  758.         return
  759.         end
  760.       end
  761.       end
  762.       actor = $game_party.actors[0]
  763.       if actor.character_name == "" or $game_player.opacity == 0
  764.       $sprite_bitmap.blur if PLAN_Map_Window::BLUR  
  765.       return
  766.       end
  767.       bitmap = RPG::Cache.character(actor.character_name, actor.character_hue).clone
  768.       width = bitmap.width/ 4
  769.       height = bitmap.height / 4
  770.       pattern = $game_player.pattern
  771.       sx = PLAN_Map_Window::ACTOR_MOVE ? pattern * width : 0
  772.       sy = ($game_player.direction - 2) / 2 * height
  773.       #原始行走图大小矩形
  774.       src_rect = Rect.new(sx, sy, width, height)
  775.       if $ZOOM > 7
  776.       w = width / 5
  777.       h = height / 5
  778.       else  
  779.       w = width / $ZOOM
  780.       h = height / $ZOOM
  781.       end
  782.       x = self.contents.width / 2 - w / 2 + one_tile_size / 2 - rev_x
  783.       y = self.contents.height / 2 - h / 2 - rev_y
  784.       #小地图上的行走图大小
  785.       dest_rect = Rect.new(x, y, w, h)
  786.       $sprite_bitmap.stretch_blt(dest_rect, bitmap, src_rect, $game_player.opacity)
  787.       bitmap.dispose
  788.     end
  789.     $sprite_bitmap.blur if PLAN_Map_Window::BLUR
  790.     end
  791.   #--------------------------------------------------------------------------
  792.   # ● 更新
  793.   #--------------------------------------------------------------------------
  794.   def update
  795.     super
  796.     if @old_real_x != $game_player.real_x or @old_real_y != $game_player.real_y or
  797.      @old_real_direction != $game_player.direction
  798.       refresh
  799.       @old_real_x = $game_player.real_x
  800.       @old_real_y = $game_player.real_y
  801.       @old_real_direction = $game_player.direction
  802.     end
  803.     if $game_party.actors.size > 0
  804.       if @old_char_name != $game_party.actors[0].character_name
  805.        refresh
  806.        @old_char_name = $game_party.actors[0].character_name
  807.       end
  808.     end
  809.     if PLAN_Map_Window::ACTOR_MOVE and @old_pattern != $game_player.pattern
  810.       refresh
  811.       @old_pattern = $game_player.pattern
  812.     end
  813.     if event_move_judge
  814.       @make_event = make_event
  815.       refresh
  816.     end
  817.     if @old_panorama != $game_map.panorama_name
  818.       @panorama = make_panorama
  819.       refresh
  820.       @old_panorama = $game_map.panorama_name
  821.     end
  822.     if @old_fog != $game_map.fog_name
  823.        @all_fog = make_fog
  824.        refresh
  825.        @old_fog = $game_map.fog_name
  826.      end
  827.   end
  828.   #--------------------------------------------------------------------------
  829.   # ● 解放
  830.   #--------------------------------------------------------------------------
  831.   def dispose
  832.     super
  833.     @panorama.dispose unless @panorama.disposed?
  834.     @all_map.dispose unless @all_map.disposed?
  835.     @make_event.dispose unless @make_event.disposed?
  836.     @all_fog.dispose unless @all_fog.disposed?
  837.   end
  838. end
  839.  
  840. #==============================================================================
  841. # ■ Game_Player
  842. #------------------------------------------------------------------------------
  843. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  844. # 本类的实例请参考 $game_player。
  845. #==============================================================================
  846.  
  847. class Game_Player < Game_Character
  848.   alias plan_map_window_update update
  849.   def update
  850.     plan_map_window_update
  851.     unless moving? or $game_system.map_interpreter.running? or
  852.            @move_route_forcing or $game_temp.message_window_showing
  853.       # 如果方向键被按下、主角就朝那个方向移动
  854.      case Input.dir4
  855.       when 2
  856.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  857.        $win_x = 8
  858.        $win_y = 8
  859.        $direction = 0
  860.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  861.       end
  862.       when 4
  863.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  864.        $win_x = 382
  865.        $win_y = 8
  866.        $direction = 1
  867.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  868.       end
  869.       when 6
  870.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  871.        $win_x = 8
  872.        $win_y = 280 - 8
  873.        $direction = 2
  874.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  875.       end
  876.       when 8
  877.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  878.        $win_x = 382
  879.        $win_y = 280 - 8
  880.        $direction = 3
  881.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  882.       end
  883.      end
  884.     end
  885.   end
  886. end
  887. #==============================================================================
  888. # ■ Window_Base
  889. #------------------------------------------------------------------------------
  890. #  游戏中全部窗口的超级类。
  891. #==============================================================================
  892.  
  893. class Window_Base < Window
  894.   #--------------------------------------------------------------------------
  895.   # ● 初始化对像
  896.   #     x      : 窗口的 X 坐标
  897.   #     y      : 窗口的 Y 坐标
  898.   #     width  : 窗口的宽
  899.   #     height : 窗口的宽
  900.   #--------------------------------------------------------------------------
  901.   def initialize(x, y, width, height)
  902.     super()
  903.     @windowskin_name = $game_system.windowskin_name
  904.     if !$minimap
  905.       self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  906.     end
  907.     self.x = x.nil? ? 0 : x
  908.     self.y = y.nil? ? 0 : y
  909.     self.width = width
  910.     self.height = height
  911.     self.z = 100
  912.   end
  913.  
  914. end
  915. #==============================================================================
  916. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  917. #==============================================================================

Lv5.捕梦者

梦石
0
星屑
33125
在线时间
5104 小时
注册时间
2012-11-19
帖子
4878

开拓者

2
发表于 2013-9-20 01:50:07 | 只看该作者
脚本第 45 行。

评分

参与人数 1星屑 +50 收起 理由
myownroc + 50 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 03:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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