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

Project1

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

[已经过期] 小地图脚本怎么修改可以用31号开关显示和关闭呢?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
105
在线时间
393 小时
注册时间
2008-11-7
帖子
353
跳转到指定楼层
1
发表于 2011-7-31 20:06:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. #第四重更新:修正了场所移动的时候远景图变黑的问题,感谢忧雪の伤
  5. #第三重更新:紧急修正了某个错误(书写所致)
  6. #初步修复远景同步问题
  7. #精灵再度更新:支持地图的远景图显示(如果有的话)

  8. #冬夜更新说明
  9. #更改了小地图的位置,Q是开启小地图跟随开关

  10. #更新了场所移动时地图的不同步,更新了战斗后的地图不同步
  11. #小地图默认成为false,只在第一次登入时是,以后跟随开关的指示
  12. #恩恩  
  13. #最后更新,测试过


  14. #修正了由于小地图变化引起的不能转换问题,修整了房间内的地图原先的那个羁押功能




  15. #==============================================================================
  16. # ■ 縮小地图的表示(ver 1.04)
  17. # by ピニョン clum-sea
  18. #==============================================================================
  19. #==============================================================================
  20. # □ 前期定义
  21. #==============================================================================
  22. module PLAN_Map_Window
  23.   WIN_X       = 8         # 地图的 X 座標
  24.   WIN_Y       = 8         # 地图的 Y 座標
  25.   WIN_WIDTH   = 250     # 地图的宽度
  26.   WIN_HEIGHT  = 200     # 地图的高度
  27.   ZOOM        = 4.0     # 地图的放缩比例
  28.   WINDOWSKIN  = ""        # 自定义地图窗口素材,如果留空则是默认的

  29.   ON_OFF_KEY  = Input::A  # 打开地图的按钮,A就是键盘的Z键

  30.   SWITCH      = 6       # 禁用地图功能的开关,默认这个就是打开100号开关则禁止
  31.                           # 使用地图功能,关闭则可以使用地图功能

  32.   WINDOW_MOVE = true   # 窗口中的地图跟随移动,(true:跟随, false:固定)
  33.   
  34.   OVER_X      = 632 - WIN_WIDTH   # 移動后的 X 座標(初期位置と往復します)
  35.   OVER_Y      = 8         # 移動后的 Y 座標(初期位置と往復します)

  36.   OPACITY     = 0  # 窗口的透明度
  37.   C_OPACITY   = 255   # 地图的透明度
  38.   
  39.   VISIBLE     = false      # 最初是否可见
  40.   SWITCH_KEY  = Input::L  # Q键锁定/解锁小地图
  41.   MAP_VISIBLE = 7         #地图显示开关状态
  42.   MAP_SWITCH = 8          #地图锁定开关状态
  43.   MAP_DIRECTION = 10       #地图方向变量
  44. end
  45. #==============================================================================
  46. # ■ Game_Temp
  47. #==============================================================================
  48. class Game_Temp
  49.   attr_accessor  :map_visible     # 地图的表示状態
  50. end
  51. #==============================================================================
  52. # ■ Scene_Map
  53. #==============================================================================
  54. class Scene_Map
  55.   #--------------------------------------------------------------------------
  56.   # ● 主处理
  57.   #--------------------------------------------------------------------------
  58.   alias plan_map_window_main main
  59.   def main
  60.   $minimap = false
  61.   @map_window         = Window_Map.new
  62.     @map_window.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  63.     plan_map_window_main
  64.     @map_window.dispose
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 更新
  68.   #--------------------------------------------------------------------------
  69.   alias plan_map_window_update update
  70.   def update
  71.     $game_temp.map_visible = @map_window.visible
  72.     plan_map_window_update
  73.     if $game_switches[PLAN_Map_Window::SWITCH]      
  74.       if @map_window.visible
  75.       @map_window.visible = false
  76.       $game_switches[PLAN_Map_Window::MAP_VISIBLE]= false
  77.       $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  78.       $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  79.       $map_close = true
  80.       end  
  81.     else
  82.       if $map_close         
  83.          @map_window.visible = true
  84.          $game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
  85.          $map_close = false
  86.       end
  87.     if !$game_temp.in_battle
  88.       if Input.trigger?(PLAN_Map_Window::ON_OFF_KEY)
  89.         if @map_window.visible
  90.           $game_system.se_play($data_system.cancel_se)
  91.           @map_window.visible = false
  92.           $game_switches[PLAN_Map_Window::MAP_VISIBLE]= false
  93.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  94.           $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  95.         else
  96.           $game_system.se_play($data_system.decision_se)
  97.           @map_window.visible = true
  98.           $game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
  99.         end
  100.       end
  101.       if Input.trigger?(PLAN_Map_Window::SWITCH_KEY)
  102.         if @map_window.visible
  103.         if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  104.           $game_system.se_play($data_system.cancel_se)
  105.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  106.           $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  107.          else
  108.           $game_system.se_play($data_system.decision_se)
  109.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = true
  110.          end
  111.        end
  112.      end
  113.    end
  114.     end
  115.       @map_window.update if @map_window.visible
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 场所移动的变化
  119.   #--------------------------------------------------------------------------
  120.   alias plan_map_window_transfer_player transfer_player
  121.   def transfer_player
  122.     @map_window.visible = false
  123.     plan_map_window_transfer_player
  124.     @map_window.dispose
  125.     @map_window = Window_Map.new
  126.   end
  127. end
  128. #==============================================================================
  129. # ■ Window_Map
  130. #==============================================================================
  131. class Window_Map < Window_Base
  132.   #--------------------------------------------------------------------------
  133.   # ● 初始化
  134.   #--------------------------------------------------------------------------
  135.   def initialize
  136.    $direction = $game_variables[PLAN_Map_Window::MAP_DIRECTION]
  137.    if $win_x != nil
  138.       x = $win_x
  139.       y = $win_y
  140.    else
  141.    case $direction
  142.      when 0
  143.      x = 8
  144.      y = 8
  145.      $win_x = x
  146.      $win_y = y
  147.      when 1
  148.      x = 382
  149.      y = 8
  150.      $win_x = x
  151.      $win_y = y
  152.      when 2
  153.      x = 8
  154.      y = 280 - 8
  155.      $win_x = x
  156.      $win_y = y
  157.      when 3
  158.      x = 382
  159.      y = 280 - 8
  160.      $win_x = x
  161.      $win_y = y
  162.      end
  163.    end
  164.     w = PLAN_Map_Window::WIN_WIDTH
  165.     h = PLAN_Map_Window::WIN_HEIGHT
  166.   $minimap = true
  167.    super(x, y, w, h)
  168.   $minimap = false
  169.     self.contents = Bitmap.new(width - 32, height - 32)
  170.     self.opacity = PLAN_Map_Window::OPACITY
  171.     self.contents_opacity = PLAN_Map_Window::C_OPACITY
  172.     self.z = 100
  173.     @map_data = $game_map.data
  174.     @tileset = RPG::Cache.tileset($game_map.tileset_name)
  175.     @autotiles = []
  176.     for i in 0..6
  177.       autotile_name = $game_map.autotile_names[i]
  178.       @autotiles[i] = RPG::Cache.autotile(autotile_name)
  179.     end
  180.     @old_real_x = $game_player.real_x
  181.     @old_real_y = $game_player.real_y
  182.   if $game_map.width > 70 or $game_map.height > 70
  183.       $ZOOM = 2 * PLAN_Map_Window::ZOOM
  184.   else
  185.    
  186.      if $game_map.width < 40 or $game_map.height < 40
  187.       $ZOOM = PLAN_Map_Window::ZOOM / 2
  188.     else
  189.       $ZOOM = PLAN_Map_Window::ZOOM
  190.       end
  191.   end
  192.     @panorama = make_panorama
  193.     @all_map = make_all_map
  194.     self.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  195.      unless PLAN_Map_Window::WINDOWSKIN.empty?
  196.       self.windowskin = RPG::Cache.windowskin("")
  197.     end
  198.     refresh
  199.   end

  200.   #--------------------------------------------------------------------------
  201.   # ● 缩小图做成
  202.   #--------------------------------------------------------------------------
  203.   def make_all_map
  204.     all_map = Bitmap.new($game_map.width * 32, $game_map.height * 32)
  205.     for y in 0...$game_map.height
  206.       for x in 0...$game_map.width
  207.         for z in 0...3
  208.           tile_num = @map_data[x, y, z]
  209.           next if tile_num == nil
  210.           if tile_num < 384
  211.             if tile_num >= 48
  212.               tile_num -= 48
  213.               src_rect = Rect.new(32, 2 * 32, 32, 32)
  214.               all_map.blt(x * 32, y * 32, @autotiles[tile_num / 48], src_rect)
  215.             end
  216.           else
  217.             tile_num -= 384
  218.             src_rect = Rect.new(tile_num % 8 * 32, tile_num / 8 * 32, 32, 32)
  219.             all_map.blt(x * 32, y * 32, @tileset, src_rect)
  220.           end
  221.         end
  222.       end
  223.     end
  224.     w = ($game_map.width / $ZOOM) * 32
  225.     h = ($game_map.height / $ZOOM) * 32
  226.     ret_bitmap = Bitmap.new(w, h)
  227.     src_rect = Rect.new(0, 0, all_map.width, all_map.height)
  228.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  229.     ret_bitmap.stretch_blt(dest_rect, all_map, src_rect)
  230.     all_map.dispose
  231.     return ret_bitmap
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   # ● 远景图做成
  235.   #--------------------------------------------------------------------------
  236.   def make_panorama
  237.     all_panorama = RPG::Cache.panorama($game_map.panorama_name,$game_map.panorama_hue)
  238.     cw = $game_map.width * 32
  239.     ch = $game_map.height * 32
  240.     src_rect = Rect.new(0, 0, cw, ch)
  241.     self.contents.blt(0 , 0, all_panorama, src_rect)
  242.     w = ($game_map.width / $ZOOM) * 32
  243.     h = ($game_map.height / $ZOOM) * 32
  244.     ret_bitmap = Bitmap.new(w, h)
  245.     src_rect = Rect.new(0, 0, all_panorama.width, all_panorama.height)
  246.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  247.     ret_bitmap.stretch_blt(dest_rect, all_panorama, src_rect)
  248.     return ret_bitmap
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 刷新
  252.   #--------------------------------------------------------------------------
  253.   def refresh
  254.     self.contents.clear
  255.     self.x = $win_x
  256.     self.y = $win_y
  257.     self.z = 100
  258.   @small_map = false
  259.   if $game_map.width < 80 or $game_map.height < 80
  260.     #这个是当地图大小宽和高小于指定大小时才改变大小,限制小地图窗口大小
  261.     if $game_map.width < 40 or $game_map.height < 40
  262.       #这同时限制了变换小地图的大小,防止关卡和队长办公室因为地图宽长无法切换
  263.       self.width = [@all_map.width,200].min
  264.       self.height = [@all_map.height,200].min
  265.       self.contents = Bitmap.new(width-32, height-32)
  266.      #让改变的小地图X坐标紧贴边缘
  267.     if self.x + self.width > 250
  268.       self.x = 625 - self.width
  269.     end
  270.       #让改变的小地图Y左边紧贴边缘
  271.     if self.y + self.height > 380
  272.       self.y = 470 - self.height
  273.     end
  274.      @small_map = true
  275.   end
  276. end
  277.    if self.windowskin == nil
  278.    @windowskin_name = $game_system.windowskin_name
  279.    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  280.    end
  281.     one_tile_size = 32 / $ZOOM
  282.     x = $game_player.real_x - 128 * (self.contents.width / one_tile_size) / 2
  283.     y = $game_player.real_y - 128 * (self.contents.height / one_tile_size) / 2
  284.     x = x * one_tile_size / 128
  285.     y = y * one_tile_size / 128
  286.     half_width = self.contents.width * 128 / 2
  287.     rest_width = ($game_map.width * 128 - $game_player.real_x) * one_tile_size
  288.     px = x
  289.     py = y
  290.     rev_x = 0
  291.     if @all_map.width < self.contents.width
  292.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  293.       rev_x -= (self.contents.width - @all_map.width) / 2
  294.       x += rev_x
  295.     elsif half_width > $game_player.real_x * one_tile_size
  296.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  297.       x += rev_x
  298.     elsif half_width > rest_width
  299.       rev_x = -((half_width - rest_width) / 128)
  300.       x += rev_x
  301.     end
  302.     rev_px = 0
  303.     if @panorama.width < self.contents.width
  304.       rev_px = (half_width - $game_player.real_x * one_tile_size) / 128
  305.       rev_px -= (self.contents.width - @all_map.width) / 2
  306.       px += rev_px
  307.     elsif half_width > $game_player.real_x * one_tile_size
  308.       rev_px = (half_width - $game_player.real_x * one_tile_size) / 128
  309.       px += rev_px
  310.     elsif half_width > rest_width
  311.       rev_px = -((half_width - rest_width) / 128)
  312.       px += rev_px
  313.     end
  314.     half_height = self.contents.height * 128 / 2
  315.     rest_height = ($game_map.height * 128 - $game_player.real_y) * one_tile_size
  316.     rev_y = 0
  317.     if @all_map.height < self.contents.height
  318.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  319.       rev_y -= (self.contents.height - @all_map.height) / 2
  320.       y += rev_y
  321.     elsif half_height > $game_player.real_y * one_tile_size
  322.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  323.       y += rev_y
  324.     elsif half_height > rest_height
  325.       rev_y = -((half_height - rest_height) / 128)
  326.       y += rev_y
  327.     end
  328.     rev_py = 0
  329.     if @panorama.height < self.contents.height
  330.       rev_py = (half_height - $game_player.real_y * one_tile_size) / 128
  331.       rev_py -= (self.contents.height - @all_map.height) / 2
  332.       py += rev_py
  333.     elsif half_height > $game_player.real_y * one_tile_size
  334.       rev_py = (half_height - $game_player.real_y * one_tile_size) / 128
  335.       py += rev_py
  336.     elsif half_height > rest_height
  337.       rev_py = -((half_height - rest_height) / 128)
  338.       py += rev_py
  339.     end
  340.     px /= 2
  341.     py /= 2
  342.     src_rect1 = Rect.new(px, py, self.contents.width, self.contents.height)
  343.     src_rect2 = Rect.new(x, y, self.contents.width, self.contents.height)
  344.     self.contents.blt(0, 0, @panorama, src_rect1)
  345.     self.contents.blt(0, 0, @all_map, src_rect2)
  346.      if PLAN_Map_Window::WINDOW_MOVE == true
  347.       w = self.x - 32 .. self.x + self.width + 32
  348.       h = self.y - 64 .. self.y + self.height + 64
  349.       if w === $game_player.screen_x and h === $game_player.screen_y
  350.      if !@small_map
  351.      case self.x
  352.       when 8
  353.          self.x = 382
  354.       when 382
  355.         self.x = 8
  356.       end
  357.      case self.y
  358.     when 272
  359.       self.y = 8
  360.     when 8
  361.       self.y = 272
  362.     end
  363.   else
  364.     case self.x
  365.     when  625 - self.width
  366.       self.x = 8
  367.     when 8
  368.       self.x = 625 - self.width
  369.     end
  370.     case self.y
  371.     when 470 - self.height
  372.       self.y = 8
  373.     when 8
  374.       self.y = 470 - self.height
  375.     end
  376.     end
  377. end
  378. end
  379.      #主角位置
  380.     if $game_party.actors.size > 0
  381.       actor = $game_party.actors[0]
  382.       bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  383.       width = bitmap.width/ 4
  384.       height = bitmap.height / 4
  385.       sy = ($game_player.direction - 2) / 2 * height
  386.       #原始行走图大小矩形
  387.       src_rect = Rect.new(0, sy, width, height)
  388.       if $ZOOM > 7
  389.       w = width / 5
  390.       h = height / 5
  391.       else  
  392.       w = width / $ZOOM
  393.       h = height / $ZOOM
  394.       end
  395.       x = self.contents.width / 2 - w / 2 + one_tile_size / 2 - rev_x
  396.       y = self.contents.height / 2 - h / 2 - rev_y
  397.       #小地图上的行走图大小
  398.       dest_rect = Rect.new(x, y, w, h)
  399.       self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ● 更新
  404.   #--------------------------------------------------------------------------
  405.   def update
  406.     super
  407.     if @old_real_x != $game_player.real_x or @old_real_y != $game_player.real_y
  408.       @old_real_x = $game_player.real_x
  409.       @old_real_y = $game_player.real_y
  410.       refresh
  411.     end
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # ● 解放
  415.   #--------------------------------------------------------------------------
  416.   def dispose
  417.     super
  418.     @panorama.dispose
  419.     @all_map.dispose
  420.   end
  421. end

  422. #==============================================================================
  423. # ■ Game_Player
  424. #------------------------------------------------------------------------------
  425. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  426. # 本类的实例请参考 $game_player。
  427. #==============================================================================

  428. class Game_Player < Game_Character
  429.   alias old_update update
  430.   def update
  431.     old_update
  432.     unless moving? or $game_system.map_interpreter.running? or
  433.            @move_route_forcing or $game_temp.message_window_showing
  434.       # 如果方向键被按下、主角就朝那个方向移动
  435.      case Input.dir4
  436.       when 2
  437.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  438.        $win_x = 8
  439.        $win_y = 8
  440.        $direction = 0
  441.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  442.       end
  443.       when 4
  444.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  445.        $win_x = 382
  446.        $win_y = 8
  447.        $direction = 1
  448.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  449.       end
  450.       when 6
  451.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  452.        $win_x = 8
  453.        $win_y = 280 - 8
  454.        $direction = 2
  455.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  456.       end
  457.       when 8
  458.        if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  459.        $win_x = 382
  460.        $win_y = 280 - 8
  461.        $direction = 3
  462.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  463.       end
  464.      end
  465.     end
  466.   end
  467. end
  468. #==============================================================================
  469. # ■ Window_Base
  470. #------------------------------------------------------------------------------
  471. #  游戏中全部窗口的超级类。
  472. #==============================================================================

  473. class Window_Base < Window
  474.   #--------------------------------------------------------------------------
  475.   # ● 初始化对像
  476.   #     x      : 窗口的 X 坐标
  477.   #     y      : 窗口的 Y 坐标
  478.   #     width  : 窗口的宽
  479.   #     height : 窗口的宽
  480.   #--------------------------------------------------------------------------
  481.   def initialize(x, y, width, height)
  482.     super()
  483.     @windowskin_name = $game_system.windowskin_name
  484.     if !$minimap
  485.     self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  486.     end
  487.     self.x = x
  488.     self.y = y
  489.     self.width = width
  490.     self.height = height
  491.     self.z = 100
  492.   end
  493. end
  494. #==============================================================================
  495. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  496. #==============================================================================
复制代码

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
2
发表于 2011-7-31 20:16:55 | 只看该作者
第41行XD
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
192
在线时间
166 小时
注册时间
2009-5-2
帖子
300

开拓者

3
发表于 2011-8-1 07:26:48 | 只看该作者
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. #第四重更新:修正了场所移动的时候远景图变黑的问题,感谢忧雪の伤
  5. #第三重更新:紧急修正了某个错误(书写所致)
  6. #初步修复远景同步问题
  7. #精灵再度更新:支持地图的远景图显示(如果有的话)

  8. #冬夜更新说明
  9. #更改了小地图的位置,Q是开启小地图跟随开关

  10. #更新了场所移动时地图的不同步,更新了战斗后的地图不同步
  11. #小地图默认成为false,只在第一次登入时是,以后跟随开关的指示
  12. #恩恩  
  13. #最后更新,测试过


  14. #修正了由于小地图变化引起的不能转换问题,修整了房间内的地图原先的那个羁押功能




  15. #==============================================================================
  16. # ■ 縮小地图的表示(ver 1.04)
  17. # by ピニョン clum-sea
  18. #==============================================================================
  19. #==============================================================================
  20. # □ 前期定义
  21. #==============================================================================
  22. module PLAN_Map_Window
  23.   WIN_X       = 8         # 地图的 X 座標
  24.   WIN_Y       = 8         # 地图的 Y 座標
  25.   WIN_WIDTH   = 250     # 地图的宽度
  26.   WIN_HEIGHT  = 200     # 地图的高度
  27.   ZOOM        = 4.0     # 地图的放缩比例
  28.   WINDOWSKIN  = ""        # 自定义地图窗口素材,如果留空则是默认的

  29.   ON_OFF_KEY  = Input::A  # 打开地图的按钮,A就是键盘的Z键

  30.   SWITCH      = 31      # 禁用地图功能的开关,默认这个就是打开100号开关则禁止
  31.                           # 使用地图功能,关闭则可以使用地图功能

  32.   WINDOW_MOVE = true   # 窗口中的地图跟随移动,(true:跟随, false:固定)
  33.   
  34.   OVER_X      = 632 - WIN_WIDTH   # 移動后的 X 座標(初期位置と往復します)
  35.   OVER_Y      = 8         # 移動后的 Y 座標(初期位置と往復します)

  36.   OPACITY     = 0  # 窗口的透明度
  37.   C_OPACITY   = 255   # 地图的透明度
  38.   
  39.   VISIBLE     = false      # 最初是否可见
  40.   SWITCH_KEY  = Input::L  # Q键锁定/解锁小地图
  41.   MAP_VISIBLE = 7         #地图显示开关状态
  42.   MAP_SWITCH = 8          #地图锁定开关状态
  43.   MAP_DIRECTION = 10       #地图方向变量
  44. end
  45. #==============================================================================
  46. # ■ Game_Temp
  47. #==============================================================================
  48. class Game_Temp
  49.   attr_accessor  :map_visible     # 地图的表示状態
  50. end
  51. #==============================================================================
  52. # ■ Scene_Map
  53. #==============================================================================
  54. class Scene_Map
  55.   #--------------------------------------------------------------------------
  56.   # ● 主处理
  57.   #--------------------------------------------------------------------------
  58.   alias plan_map_window_main main
  59.   def main
  60.   $minimap = false
  61.   @map_window         = Window_Map.new
  62.     @map_window.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  63.     plan_map_window_main
  64.     @map_window.dispose
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 更新
  68.   #--------------------------------------------------------------------------
  69.   alias plan_map_window_update update
  70.   def update
  71.     $game_temp.map_visible = @map_window.visible
  72.     plan_map_window_update
  73.     if $game_switches[PLAN_Map_Window::SWITCH]      
  74.       if @map_window.visible
  75.       @map_window.visible = false
  76.       $game_switches[PLAN_Map_Window::MAP_VISIBLE]= false
  77.       $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  78.       $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  79.       $map_close = true
  80.       end  
  81.     else
  82.       if $map_close         
  83.          @map_window.visible = true
  84.          $game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
  85.          $map_close = false
  86.       end
  87.     if !$game_temp.in_battle
  88.       if Input.trigger?(PLAN_Map_Window::ON_OFF_KEY)
  89.         if @map_window.visible
  90.           $game_system.se_play($data_system.cancel_se)
  91.           @map_window.visible = false
  92.           $game_switches[PLAN_Map_Window::MAP_VISIBLE]= false
  93.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  94.           $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  95.         else
  96.           $game_system.se_play($data_system.decision_se)
  97.           @map_window.visible = true
  98.           $game_switches[PLAN_Map_Window::MAP_VISIBLE]= true
  99.         end
  100.       end
  101.       if Input.trigger?(PLAN_Map_Window::SWITCH_KEY)
  102.         if @map_window.visible
  103.         if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  104.           $game_system.se_play($data_system.cancel_se)
  105.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = false
  106.           $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  107.          else
  108.           $game_system.se_play($data_system.decision_se)
  109.           $game_switches[PLAN_Map_Window::MAP_SWITCH] = true
  110.          end
  111.        end
  112.      end
  113.    end
  114.     end
  115.       @map_window.update if @map_window.visible
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 场所移动的变化
  119.   #--------------------------------------------------------------------------
  120.   alias plan_map_window_transfer_player transfer_player
  121.   def transfer_player
  122.     @map_window.visible = false
  123.     plan_map_window_transfer_player
  124.     @map_window.dispose
  125.     @map_window = Window_Map.new
  126.   end
  127. end
  128. #==============================================================================
  129. # ■ Window_Map
  130. #==============================================================================
  131. class Window_Map < Window_Base
  132.   #--------------------------------------------------------------------------
  133.   # ● 初始化
  134.   #--------------------------------------------------------------------------
  135.   def initialize
  136.    $direction = $game_variables[PLAN_Map_Window::MAP_DIRECTION]
  137.    if $win_x != nil
  138.       x = $win_x
  139.       y = $win_y
  140.    else
  141.    case $direction
  142.      when 0
  143.      x = 8
  144.      y = 8
  145.      $win_x = x
  146.      $win_y = y
  147.      when 1
  148.      x = 382
  149.      y = 8
  150.      $win_x = x
  151.      $win_y = y
  152.      when 2
  153.      x = 8
  154.      y = 280 - 8
  155.      $win_x = x
  156.      $win_y = y
  157.      when 3
  158.      x = 382
  159.      y = 280 - 8
  160.      $win_x = x
  161.      $win_y = y
  162.      end
  163.    end
  164.     w = PLAN_Map_Window::WIN_WIDTH
  165.     h = PLAN_Map_Window::WIN_HEIGHT
  166.   $minimap = true
  167.    super(x, y, w, h)
  168.   $minimap = false
  169.     self.contents = Bitmap.new(width - 32, height - 32)
  170.     self.opacity = PLAN_Map_Window::OPACITY
  171.     self.contents_opacity = PLAN_Map_Window::C_OPACITY
  172.     self.z = 100
  173.     @map_data = $game_map.data
  174.     @tileset = RPG::Cache.tileset($game_map.tileset_name)
  175.     @autotiles = []
  176.     for i in 0..6
  177.       autotile_name = $game_map.autotile_names[i]
  178.       @autotiles[i] = RPG::Cache.autotile(autotile_name)
  179.     end
  180.     @old_real_x = $game_player.real_x
  181.     @old_real_y = $game_player.real_y
  182.   if $game_map.width > 70 or $game_map.height > 70
  183.       $ZOOM = 2 * PLAN_Map_Window::ZOOM
  184.   else
  185.    
  186.      if $game_map.width < 40 or $game_map.height < 40
  187.       $ZOOM = PLAN_Map_Window::ZOOM / 2
  188.     else
  189.       $ZOOM = PLAN_Map_Window::ZOOM
  190.       end
  191.   end
  192.     @panorama = make_panorama
  193.     @all_map = make_all_map
  194.     self.visible = $game_switches[PLAN_Map_Window::MAP_VISIBLE]
  195.      unless PLAN_Map_Window::WINDOWSKIN.empty?
  196.       self.windowskin = RPG::Cache.windowskin("")
  197.     end
  198.     refresh
  199.   end

  200.   #--------------------------------------------------------------------------
  201.   # ● 缩小图做成
  202.   #--------------------------------------------------------------------------
  203.   def make_all_map
  204.     all_map = Bitmap.new($game_map.width * 32, $game_map.height * 32)
  205.     for y in 0...$game_map.height
  206.       for x in 0...$game_map.width
  207.         for z in 0...3
  208.           tile_num = @map_data[x, y, z]
  209.           next if tile_num == nil
  210.           if tile_num < 384
  211.             if tile_num >= 48
  212.               tile_num -= 48
  213.               src_rect = Rect.new(32, 2 * 32, 32, 32)
  214.               all_map.blt(x * 32, y * 32, @autotiles[tile_num / 48], src_rect)
  215.             end
  216.           else
  217.             tile_num -= 384
  218.             src_rect = Rect.new(tile_num % 8 * 32, tile_num / 8 * 32, 32, 32)
  219.             all_map.blt(x * 32, y * 32, @tileset, src_rect)
  220.           end
  221.         end
  222.       end
  223.     end
  224.     w = ($game_map.width / $ZOOM) * 32
  225.     h = ($game_map.height / $ZOOM) * 32
  226.     ret_bitmap = Bitmap.new(w, h)
  227.     src_rect = Rect.new(0, 0, all_map.width, all_map.height)
  228.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  229.     ret_bitmap.stretch_blt(dest_rect, all_map, src_rect)
  230.     all_map.dispose
  231.     return ret_bitmap
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   # ● 远景图做成
  235.   #--------------------------------------------------------------------------
  236.   def make_panorama
  237.     all_panorama = RPG::Cache.panorama($game_map.panorama_name,$game_map.panorama_hue)
  238.     cw = $game_map.width * 32
  239.     ch = $game_map.height * 32
  240.     src_rect = Rect.new(0, 0, cw, ch)
  241.     self.contents.blt(0 , 0, all_panorama, src_rect)
  242.     w = ($game_map.width / $ZOOM) * 32
  243.     h = ($game_map.height / $ZOOM) * 32
  244.     ret_bitmap = Bitmap.new(w, h)
  245.     src_rect = Rect.new(0, 0, all_panorama.width, all_panorama.height)
  246.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  247.     ret_bitmap.stretch_blt(dest_rect, all_panorama, src_rect)
  248.     return ret_bitmap
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 刷新
  252.   #--------------------------------------------------------------------------
  253.   def refresh
  254.     self.contents.clear
  255.     self.x = $win_x
  256.     self.y = $win_y
  257.     self.z = 100
  258.   @small_map = false
  259.   if $game_map.width < 80 or $game_map.height < 80
  260.     #这个是当地图大小宽和高小于指定大小时才改变大小,限制小地图窗口大小
  261.     if $game_map.width < 40 or $game_map.height < 40
  262.       #这同时限制了变换小地图的大小,防止关卡和队长办公室因为地图宽长无法切换
  263.       self.width = [@all_map.width,200].min
  264.       self.height = [@all_map.height,200].min
  265.       self.contents = Bitmap.new(width-32, height-32)
  266.      #让改变的小地图X坐标紧贴边缘
  267.     if self.x + self.width > 250
  268.       self.x = 625 - self.width
  269.     end
  270.       #让改变的小地图Y左边紧贴边缘
  271.     if self.y + self.height > 380
  272.       self.y = 470 - self.height
  273.     end
  274.      @small_map = true
  275.   end
  276. end
  277.    if self.windowskin == nil
  278.    @windowskin_name = $game_system.windowskin_name
  279.    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  280.    end
  281.     one_tile_size = 32 / $ZOOM
  282.     x = $game_player.real_x - 128 * (self.contents.width / one_tile_size) / 2
  283.     y = $game_player.real_y - 128 * (self.contents.height / one_tile_size) / 2
  284.     x = x * one_tile_size / 128
  285.     y = y * one_tile_size / 128
  286.     half_width = self.contents.width * 128 / 2
  287.     rest_width = ($game_map.width * 128 - $game_player.real_x) * one_tile_size
  288.     px = x
  289.     py = y
  290.     rev_x = 0
  291.     if @all_map.width < self.contents.width
  292.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  293.       rev_x -= (self.contents.width - @all_map.width) / 2
  294.       x += rev_x
  295.     elsif half_width > $game_player.real_x * one_tile_size
  296.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  297.       x += rev_x
  298.     elsif half_width > rest_width
  299.       rev_x = -((half_width - rest_width) / 128)
  300.       x += rev_x
  301.     end
  302.     rev_px = 0
  303.     if @panorama.width < self.contents.width
  304.       rev_px = (half_width - $game_player.real_x * one_tile_size) / 128
  305.       rev_px -= (self.contents.width - @all_map.width) / 2
  306.       px += rev_px
  307.     elsif half_width > $game_player.real_x * one_tile_size
  308.       rev_px = (half_width - $game_player.real_x * one_tile_size) / 128
  309.       px += rev_px
  310.     elsif half_width > rest_width
  311.       rev_px = -((half_width - rest_width) / 128)
  312.       px += rev_px
  313.     end
  314.     half_height = self.contents.height * 128 / 2
  315.     rest_height = ($game_map.height * 128 - $game_player.real_y) * one_tile_size
  316.     rev_y = 0
  317.     if @all_map.height < self.contents.height
  318.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  319.       rev_y -= (self.contents.height - @all_map.height) / 2
  320.       y += rev_y
  321.     elsif half_height > $game_player.real_y * one_tile_size
  322.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  323.       y += rev_y
  324.     elsif half_height > rest_height
  325.       rev_y = -((half_height - rest_height) / 128)
  326.       y += rev_y
  327.     end
  328.     rev_py = 0
  329.     if @panorama.height < self.contents.height
  330.       rev_py = (half_height - $game_player.real_y * one_tile_size) / 128
  331.       rev_py -= (self.contents.height - @all_map.height) / 2
  332.       py += rev_py
  333.     elsif half_height > $game_player.real_y * one_tile_size
  334.       rev_py = (half_height - $game_player.real_y * one_tile_size) / 128
  335.       py += rev_py
  336.     elsif half_height > rest_height
  337.       rev_py = -((half_height - rest_height) / 128)
  338.       py += rev_py
  339.     end
  340.     px /= 2
  341.     py /= 2
  342.     src_rect1 = Rect.new(px, py, self.contents.width, self.contents.height)
  343.     src_rect2 = Rect.new(x, y, self.contents.width, self.contents.height)
  344.     self.contents.blt(0, 0, @panorama, src_rect1)
  345.     self.contents.blt(0, 0, @all_map, src_rect2)
  346.      if PLAN_Map_Window::WINDOW_MOVE == true
  347.       w = self.x - 32 .. self.x + self.width + 32
  348.       h = self.y - 64 .. self.y + self.height + 64
  349.       if w === $game_player.screen_x and h === $game_player.screen_y
  350.      if !@small_map
  351.      case self.x
  352.       when 8
  353.          self.x = 382
  354.       when 382
  355.         self.x = 8
  356.       end
  357.      case self.y
  358.     when 272
  359.       self.y = 8
  360.     when 8
  361.       self.y = 272
  362.     end
  363.   else
  364.     case self.x
  365.     when  625 - self.width
  366.       self.x = 8
  367.     when 8
  368.       self.x = 625 - self.width
  369.     end
  370.     case self.y
  371.     when 470 - self.height
  372.       self.y = 8
  373.     when 8
  374.       self.y = 470 - self.height
  375.     end
  376.     end
  377. end
  378. end
  379.      #主角位置
  380.     if $game_party.actors.size > 0
  381.       actor = $game_party.actors[0]
  382.       bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  383.       width = bitmap.width/ 4
  384.       height = bitmap.height / 4
  385.       sy = ($game_player.direction - 2) / 2 * height
  386.       #原始行走图大小矩形
  387.       src_rect = Rect.new(0, sy, width, height)
  388.       if $ZOOM > 7
  389.       w = width / 5
  390.       h = height / 5
  391.       else  
  392.       w = width / $ZOOM
  393.       h = height / $ZOOM
  394.       end
  395.       x = self.contents.width / 2 - w / 2 + one_tile_size / 2 - rev_x
  396.       y = self.contents.height / 2 - h / 2 - rev_y
  397.       #小地图上的行走图大小
  398.       dest_rect = Rect.new(x, y, w, h)
  399.       self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ● 更新
  404.   #--------------------------------------------------------------------------
  405.   def update
  406.     super
  407.     if @old_real_x != $game_player.real_x or @old_real_y != $game_player.real_y
  408.       @old_real_x = $game_player.real_x
  409.       @old_real_y = $game_player.real_y
  410.       refresh
  411.     end
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # ● 解放
  415.   #--------------------------------------------------------------------------
  416.   def dispose
  417.     super
  418.     @panorama.dispose
  419.     @all_map.dispose
  420.   end
  421. end

  422. #==============================================================================
  423. # ■ Game_Player
  424. #------------------------------------------------------------------------------
  425. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  426. # 本类的实例请参考 $game_player。
  427. #==============================================================================

  428. class Game_Player < Game_Character
  429.   alias old_update update
  430.   def update
  431.     old_update
  432.     unless moving? or $game_system.map_interpreter.running? or
  433.            @move_route_forcing or $game_temp.message_window_showing
  434.       # 如果方向键被按下、主角就朝那个方向移动
  435.      case Input.dir4
  436.       when 2
  437.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  438.        $win_x = 8
  439.        $win_y = 8
  440.        $direction = 0
  441.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  442.       end
  443.       when 4
  444.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  445.        $win_x = 382
  446.        $win_y = 8
  447.        $direction = 1
  448.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  449.       end
  450.       when 6
  451.       if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  452.        $win_x = 8
  453.        $win_y = 280 - 8
  454.        $direction = 2
  455.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  456.       end
  457.       when 8
  458.        if $game_switches[PLAN_Map_Window::MAP_SWITCH]
  459.        $win_x = 382
  460.        $win_y = 280 - 8
  461.        $direction = 3
  462.        $game_variables[PLAN_Map_Window::MAP_DIRECTION] = $direction
  463.       end
  464.      end
  465.     end
  466.   end
  467. end
  468. #==============================================================================
  469. # ■ Window_Base
  470. #------------------------------------------------------------------------------
  471. #  游戏中全部窗口的超级类。
  472. #==============================================================================

  473. class Window_Base < Window
  474.   #--------------------------------------------------------------------------
  475.   # ● 初始化对像
  476.   #     x      : 窗口的 X 坐标
  477.   #     y      : 窗口的 Y 坐标
  478.   #     width  : 窗口的宽
  479.   #     height : 窗口的宽
  480.   #--------------------------------------------------------------------------
  481.   def initialize(x, y, width, height)
  482.     super()
  483.     @windowskin_name = $game_system.windowskin_name
  484.     if !$minimap
  485.     self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  486.     end
  487.     self.x = x
  488.     self.y = y
  489.     self.width = width
  490.     self.height = height
  491.     self.z = 100
  492.   end
  493. end
  494. #==============================================================================
  495. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  496. #==============================================================================
复制代码
OK了,打开31号开关就不能用了,关闭则可以用
同一片蓝天下,你可曾记起那几年
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-22 01:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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