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

Project1

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

[已经过期] 鼠标脚本出错

[复制链接]

Lv1.梦旅人

梦石
0
星屑
55
在线时间
87 小时
注册时间
2013-7-11
帖子
100
跳转到指定楼层
1
发表于 2014-1-28 10:54:56 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我加入了鼠标脚本之后,用鼠标点“开始游戏”就会这样是怎么回事呢?求助,谢谢。阿里嘎多狗杂一马斯!
鼠标脚本为:
RUBY 代码复制
  1. =begin #=======================================================================
  2.  
  3.   Sion Mouse System v1.3
  4.  
  5.   Changlog
  6.  
  7.   2013.6.15 v1.3f
  8.     
  9.     1.3f 卷动地图 bug 修正
  10.     
  11.     1.3e: 逻辑优化;提供解除鼠标固定的接口
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
  14.  
  15.     1.3f: bug修正
  16.  
  17.     1.3d: 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
  18.           关闭菜单时,鼠标是否移动到原来的位置。
  19.  
  20.     1.3c: 打开菜单、光标移动时鼠标会移动到光标位置处
  21.  
  22.     1.3b: 修正一些罕见的bug;
  23.  
  24.     1.3a: 代码小修改;
  25.           加入了鼠标点击启动事件的功能,
  26.           在事件中加入“注释”: 鼠标启动  ,
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
  28.  
  29.   2013.2.12 v1.2
  30.  
  31.     寻路逻辑优化;
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
  33.     现在支持用鼠标来操作载具了。
  34.  
  35.   2013.2.8 v1.1
  36.  
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
  39.     移动时,路径指示点的绘制更加稳定;
  40.     现在支持默认存档画面的鼠标操作了。
  41.  
  42.  
  43.   OrigenVersion
  44.  
  45.     2013.2.7 v1.0
  46.  
  47.   主要功能
  48.  
  49.       使用鼠标进行各种操作...
  50.       将鼠标锁定在游戏窗口内
  51.       自动寻路,按住 D 键可以扩大寻路的范围
  52.       双击鼠标进行冲刺
  53.       更改地图卷动方式以适应鼠标移动
  54.       变量输入框改良
  55.  
  56.   ★ 鼠标指针图片 Cursor.png 放入 Graphics\System 文件夹
  57.  
  58.   ★ 路径点指示图片 $Arrow.png 放入 Graphics\Characters 文件夹
  59.  
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
  61.  
  62.  
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
  64.  
  65.  
  66. $no_arrowpic_warn = false   # ★ 设置为false不弹出图片缺失提示
  67.  
  68. #==============================================================================
  69. # ■ 常数设置
  70. #==============================================================================
  71. module KsOfSion
  72.   Clip_Cursor    = false   # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
  73.   Dbclick_Frame  = 15      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
  74.   New_Scroll     = true    # ★ 更改地图卷动方式,需要关闭设置为false
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
  79.   Find_Path_Key  = :Z      # ★ 扩大寻路范围至全地图按键 :Z 对应 D键
  80. #                               RM几个内置的空键位 (:X = A)(:Y = S)(:Z = D)
  81. end
  82.  
  83. #==============================================================================
  84. # ■ 用来显示路径点的类
  85. #==============================================================================
  86. class Move_Sign < Game_Character
  87.   #--------------------------------------------------------------------------
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
  89.   #--------------------------------------------------------------------------
  90.   def init_public_members
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.\Graphics\Characters文件夹
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
  93.     @move_speed      = 5        # ★ 踏步速度
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
  99.  
  100.  
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
  102.  
  103.  
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
  105.     unless File.exist?('Graphics/Characters/' + @character_name + '.png')
  106.  
  107.       if $no_arrowpic_warn
  108.         Mouse::Show_Cursor.call(1)
  109.         msgbox('未找到文件:Graphics\Characters\\' + @character_name + '.png
  110.  
  111. “路径指示点”将使用游戏自带图片
  112.  
  113. 该提示可以在脚本内关闭')
  114.         Mouse::Show_Cursor.call(0)
  115.         $no_arrowpic_warn = false
  116.       end
  117.       @character_name  = '!Flame'
  118.       @character_index = 6
  119.  
  120.     end
  121.     @direction_fix = false  # 固定朝向
  122.     @move_frequency = 6     # 移动频率
  123.     @walk_anime = true      # 步行动画
  124.     @pattern = 1            # 图案
  125.     @through = true         # 穿透
  126.     @bush_depth = 0         # 草木深度
  127.     @animation_id = 0       # 动画 ID
  128.     @balloon_id = 0         # 心情 ID
  129.     @transparent = true     # 透明
  130.     @id = 0
  131.     @x = 0
  132.     @y = 0
  133.     @real_x = 0
  134.     @real_y = 0
  135.     @tile_id = 0
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 定义实例变量
  139.   #--------------------------------------------------------------------------
  140.   attr_accessor :direction
  141. end
  142.  
  143. #==============================================================================
  144. # ■ Module Mouse
  145. #==============================================================================
  146. module Mouse
  147.   #--------------------------------------------------------------------------
  148.   # ● API
  149.   #--------------------------------------------------------------------------
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
  157.   Window_Hwnd       = Get_Active_Window.call
  158.  
  159. class << self
  160.   #--------------------------------------------------------------------------
  161.   # ● 初始化
  162.   #--------------------------------------------------------------------------
  163.   def init
  164.     lock_mouse_in_screen if KsOfSion::Clip_Cursor
  165.     @left_state = 0
  166.     @right_state = 0
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
  168.     @dk_count = 0 # 用于双击的判定
  169.     @clicked = false
  170.     creat_mouse_sprite
  171.     update
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ● 鼠标指针精灵
  175.   #--------------------------------------------------------------------------
  176.   def creat_mouse_sprite
  177.     @mouse_sprite = Sprite.new
  178.     if File.exist?('Graphics/System/Cursor.png')
  179.       @mouse_sprite.bitmap = Bitmap.new('Graphics/System/Cursor')
  180.     else
  181.  
  182.       if $no_arrowpic_warn
  183.         msgbox('未找到文件:Graphics\System\Cursor.png
  184.  
  185. “鼠标指针”将使用游戏自带图片
  186.  
  187. 该提示可以在脚本内关闭')
  188.       end
  189.  
  190.       @mouse_sprite.bitmap = Bitmap.new(24, 24)
  191.       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
  192.         Rect.new(5 * 24, 24 * 24, 24, 24))
  193.     end
  194.     @mouse_sprite.z = 9999
  195.     Show_Cursor.call(0)
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ● 更新
  199.   #--------------------------------------------------------------------------
  200.   def update
  201.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
  202.     left_state  = Get_Key_State.call(0x01)
  203.     left_state[7] == 1 ? @left_state +=1 : @left_state = 0
  204.     right_state = Get_Key_State.call(0x02)
  205.     right_state[7] == 1 ? @right_state +=1 : @right_state = 0
  206.     update_double_click
  207.     @left_state == 1 ? @ck_count = 0 : @ck_count += 1
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 获取鼠标坐标
  211.   #--------------------------------------------------------------------------
  212.   def get_mouse_pos
  213.     arg = [0, 0].pack('ll')
  214.     Get_Cursor_Pos.call(arg)
  215.     Screen_To_Client.call(Window_Hwnd, arg)
  216.     x, y = arg.unpack('ll')
  217.     return x, y
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● 将鼠标固定在屏幕内
  221.   #--------------------------------------------------------------------------
  222.   def lock_mouse_in_screen
  223.     arg = [0, 0].pack('ll')
  224.     Screen_To_Client.call(Window_Hwnd, arg)
  225.     x, y  = arg.unpack('ll')
  226.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # ● 解除鼠标固定
  230.   #--------------------------------------------------------------------------
  231.   def unlock_mouse_in_screen
  232.     Clip_Cursor.call(0)
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # ● 鼠标双击判定
  236.   #--------------------------------------------------------------------------
  237.   def update_double_click
  238.     @clicked = true if @left_state == 1
  239.     if @dk_count > 0 && @left_state == 1
  240.       @dk_count = 0; @clicked = false
  241.       return @double_click = true
  242.     elsif @clicked
  243.       if @dk_count < KsOfSion::Dbclick_Frame
  244.         @dk_count += 1
  245.       else
  246.         @dk_count = 0; @clicked = false
  247.       end
  248.     end
  249.     @double_click = false
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ● 按键被按下就返回true
  253.   #--------------------------------------------------------------------------
  254.   def press?(button)
  255.     case button
  256.       when 0x01; return !@left_state.zero?
  257.       when 0x02; return !@right_state.zero?
  258.     end
  259.     return false
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # ● 按键刚被按下则返回true
  263.   #--------------------------------------------------------------------------
  264.   def trigger?(button)
  265.     case button
  266.       when 0x01; return @left_state == 1
  267.       when 0x02; return @right_state == 1
  268.     end
  269.     return false
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
  273.   #--------------------------------------------------------------------------
  274.   def repeat?(button)
  275.     case button
  276.       when 0x01; return @left_state == 1 ||
  277.         (@left_state > 22 && (@left_state % 6).zero?)
  278.       when 0x02; return @right_state == 1 ||
  279.         (@right_state > 22 && (@right_state % 6).zero?)
  280.     end
  281.     return false
  282.   end
  283.   #--------------------------------------------------------------------------
  284.   # ● 判断是否双击鼠标
  285.   #--------------------------------------------------------------------------
  286.   def double_click?
  287.     @double_click
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
  291.   #--------------------------------------------------------------------------
  292.   def click_count
  293.     @ck_count
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 获取@left_state(按住左键每一帧+=1)
  297.   #--------------------------------------------------------------------------
  298.   def left_state
  299.     @left_state
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● 获取鼠标的x坐标
  303.   #--------------------------------------------------------------------------
  304.   def mouse_x
  305.     @mouse_sprite.x
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ● 获取鼠标的y坐标
  309.   #--------------------------------------------------------------------------
  310.   def mouse_y
  311.     @mouse_sprite.y
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   # ● 设置鼠标坐标
  315.   #--------------------------------------------------------------------------
  316.   def set_mouse_pos(new_x, new_y)
  317.     arg = [0, 0].pack('ll')
  318.     Screen_To_Client.call(Window_Hwnd, arg)
  319.     x, y  = arg.unpack('ll')
  320.     Set_Cursor_Pos.call(new_x - x, new_y - y)
  321.   end
  322. end #end of: class << self
  323.  
  324. end
  325.  
  326. #==============================================================================
  327. # ■ SceneManager
  328. #==============================================================================
  329. class << SceneManager
  330.   #--------------------------------------------------------------------------
  331.   # ● alias
  332.   #--------------------------------------------------------------------------
  333.   unless self.method_defined?(:sion_mouse_run)
  334.     alias_method :sion_mouse_run, :run
  335.     alias_method :sion_mouse_call, :call
  336.     alias_method :sion_mouse_return, :return
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ● 运行
  340.   #--------------------------------------------------------------------------
  341.   def run
  342.     Mouse.init
  343.     sion_mouse_run
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # ● 切换
  347.   #--------------------------------------------------------------------------
  348.   def call(scene_class)
  349.     $game_map.prepare_reset_mouse_pos if @scene.instance_of?(Scene_Map)
  350.     sion_mouse_call(scene_class)
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # ● 返回到上一个场景
  354.   #--------------------------------------------------------------------------
  355.   def return
  356.     sion_mouse_return
  357.     $game_map.reset_mouse_pos if KsOfSion::Menu_Set_Pos &&
  358.       @scene.instance_of?(Scene_Map)
  359.   end
  360. end
  361.  
  362. #==============================================================================
  363. # ■ Module Input
  364. #==============================================================================
  365. class << Input
  366.   #--------------------------------------------------------------------------
  367.   # ● alias
  368.   #--------------------------------------------------------------------------
  369.   unless self.method_defined?(:sion_mouse_update)
  370.     alias_method :sion_mouse_update,   :update
  371.     alias_method :sion_mouse_press?,   :press?
  372.     alias_method :sion_mouse_trigger?, :trigger?
  373.     alias_method :sion_mouse_repeat?,  :repeat?
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● 更新鼠标
  377.   #--------------------------------------------------------------------------
  378.   def update
  379.     Mouse.update
  380.     sion_mouse_update
  381.   end
  382.   #--------------------------------------------------------------------------
  383.   # ● 按键被按下就返回true
  384.   #--------------------------------------------------------------------------
  385.   def press?(key)
  386.     return true if sion_mouse_press?(key)
  387.     return Mouse.press?(0x01) if key == :C
  388.     return Mouse.press?(0x02) if key == :B
  389.     return false
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # ● 按键刚被按下则返回true
  393.   #--------------------------------------------------------------------------
  394.   def trigger?(key)
  395.     return true if sion_mouse_trigger?(key)
  396.     return Mouse.trigger?(0x01) if key == :C
  397.     return Mouse.trigger?(0x02) if key == :B
  398.     return false
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
  402.   #--------------------------------------------------------------------------
  403.   def repeat?(key)
  404.     return true if sion_mouse_repeat?(key)
  405.     return Mouse.repeat?(0x01) if key == :C
  406.     return Mouse.repeat?(0x02) if key == :B
  407.     return false
  408.   end
  409. end
  410.  
  411.  
  412. #==============================================================================
  413. # ■ Window_Selectable
  414. #------------------------------------------------------------------------------
  415. #  拥有光标移动、滚动功能的窗口
  416. #==============================================================================
  417. class Window_Selectable
  418.   #--------------------------------------------------------------------------
  419.   # ● 初始化
  420.   #--------------------------------------------------------------------------
  421.   alias sion_mouse_initialize initialize
  422.   def initialize(x, y, width, height)
  423.     sion_mouse_initialize(x, y, width, height)
  424.     @move_state = 0
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # ● 更新
  428.   #--------------------------------------------------------------------------
  429.   alias sion_mouse_update update
  430.   def update
  431.     sion_mouse_update
  432.     update_mouse_cursor
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # ● 启动后设置鼠标到index位置
  436.   #--------------------------------------------------------------------------
  437.   def activate
  438.     @need_set_pos = true if KsOfSion::Menu_Set_Pos
  439.     super
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # ● 更新鼠标和光标的位置
  443.   #--------------------------------------------------------------------------
  444.   def update_mouse_cursor
  445.     if active
  446.       if @need_set_pos
  447.         @need_set_pos = nil
  448.         set_mouse_pos
  449.       elsif cursor_movable?
  450.         Input.dir4.zero? ? set_cursor : set_mouse_pos
  451.       end
  452.     end
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
  456.   #--------------------------------------------------------------------------
  457.   def set_cursor
  458.     mouse_row, mouse_col = mouse_window_area
  459.     if    mouse_row == -1
  460.       @move_state += 1 if need_scroll?
  461.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand?
  462.     elsif mouse_row == -2
  463.       @move_state += 1 if need_scroll?
  464.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand?
  465.     elsif mouse_col == -1
  466.       @move_state += 1 if need_scroll?
  467.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand?
  468.     elsif mouse_col == -2
  469.       @move_state += 1 if need_scroll?
  470.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand?
  471.     else
  472.       @move_state = 0
  473.       new_index = (top_row + mouse_row) * col_max + mouse_col
  474.       select(new_index) if new_index < item_max && new_index != @index
  475.     end
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ● 判断鼠标位于菜单的第几行、第几列
  479.   #--------------------------------------------------------------------------
  480.   def mouse_window_area
  481.     if viewport.nil? # necessary!
  482.       vp_x, vp_y = 0, 0
  483.     else
  484.       vp_x = viewport.rect.x - viewport.ox
  485.       vp_y = viewport.rect.y - viewport.oy
  486.     end
  487.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  488.     item_x1 = vp_x + x + standard_padding
  489.     item_y1 = vp_y + y + standard_padding
  490.     item_x2 = vp_x + x - standard_padding + width
  491.     item_y2 = vp_y + y - standard_padding + height
  492.     if mouse_x < item_x1
  493.       mouse_col = -1
  494.     elsif mouse_x > item_x2
  495.       mouse_col = -2
  496.     else
  497.       mouse_col = col_max * (mouse_x - item_x1) / (item_x2 - item_x1)
  498.     end
  499.     if mouse_y < item_y1
  500.       mouse_row = -1
  501.     elsif mouse_y > item_y2
  502.       mouse_row = -2
  503.     else
  504.       mouse_row = page_row_max * (mouse_y - item_y1 - 1) / (item_y2 - item_y1)
  505.     end
  506.     return mouse_row, mouse_col
  507.   end
  508.   #--------------------------------------------------------------------------
  509.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  510.   #--------------------------------------------------------------------------
  511.   def set_mouse_pos
  512.     if viewport.nil? # necessary!
  513.       vp_x, vp_y = 0, 0
  514.     else
  515.       vp_x = viewport.rect.x - viewport.ox
  516.       vp_y = viewport.rect.y - viewport.oy
  517.     end
  518.     item_x1 = vp_x + x + standard_padding
  519.     item_y1 = vp_y + y + standard_padding
  520.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url] < 0 ? 0 : @index
  521.     row = get_index / col_max - top_row
  522.     col = get_index % col_max
  523.     new_x = item_x1 + item_width * (col + 0.5)
  524.     new_y = item_y1 + item_height * (row + 0.5)
  525.     Mouse.set_mouse_pos(new_x, new_y)
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # ● 判断菜单是否需要卷动
  529.   #--------------------------------------------------------------------------
  530.   def need_scroll?
  531.     item_max > col_max * page_row_max
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # ● 判断是否为水平卷动菜单
  535.   #--------------------------------------------------------------------------
  536.   def is_horzcommand?
  537.     return false
  538.   end
  539. end
  540.  
  541. class Window_HorzCommand
  542.   #--------------------------------------------------------------------------
  543.   # ● 判断是否为水平卷动菜单
  544.   #--------------------------------------------------------------------------
  545.   def is_horzcommand?
  546.     return true
  547.   end
  548. end
  549.  
  550. #==============================================================================
  551. # ■ Window_NameInput
  552. #------------------------------------------------------------------------------
  553. #  名字输入画面中,选择文字的窗口。
  554. #==============================================================================
  555. class Window_NameInput
  556.   #--------------------------------------------------------------------------
  557.   # ● 设置列数
  558.   #--------------------------------------------------------------------------
  559.   def col_max
  560.     return 10
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ● 设置填充的Item个数
  564.   #--------------------------------------------------------------------------
  565.   def item_max
  566.     return 90
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # ● 设置填充的Item个数
  570.   #--------------------------------------------------------------------------
  571.   def item_width
  572.     return 32
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ● 判断鼠标位于菜单的第几行、第几列
  576.   #--------------------------------------------------------------------------
  577.   def mouse_window_area
  578.     if viewport.nil?
  579.       vp_x, vp_y = 0, 0
  580.     else
  581.       vp_x = viewport.rect.x - viewport.ox
  582.       vp_y = viewport.rect.y - viewport.oy
  583.     end
  584.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  585.     item_x1 = vp_x + x + standard_padding
  586.     item_y1 = vp_y + y + standard_padding
  587.     item_x2 = vp_x + x - standard_padding + width
  588.     item_y2 = vp_y + y - standard_padding + height
  589.     if mouse_x < item_x1
  590.       mouse_col = -1
  591.     elsif mouse_x > item_x2
  592.       mouse_col = -2
  593.     elsif mouse_x < item_x1 + 160
  594.       mouse_col = (mouse_x - item_x1)/32
  595.     elsif mouse_x > item_x2 - 160
  596.       mouse_col = 9 - (item_x2 - mouse_x)/32
  597.     else
  598.       mouse_col = mouse_x > x + width/2 ? 5 : 4
  599.     end
  600.     if mouse_y < item_y1
  601.       mouse_row = -1
  602.     elsif mouse_y > item_y2
  603.       mouse_row = -2
  604.     else
  605.       mouse_row = page_row_max * (mouse_y - item_y1 - 1)/(item_y2 - item_y1)
  606.     end
  607.     return mouse_row, mouse_col
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  611.   #--------------------------------------------------------------------------
  612.   def set_mouse_pos
  613.     if viewport.nil? # necessary!
  614.       vp_x, vp_y = 0, 0
  615.     else
  616.       vp_x = viewport.rect.x - viewport.ox
  617.       vp_y = viewport.rect.y - viewport.oy
  618.     end
  619.     item_x1 = vp_x + x + standard_padding
  620.     item_y1 = vp_y + y + standard_padding
  621.     get_index = @index < 0 ? 0 : @index
  622.     row = get_index / col_max - top_row
  623.     col = get_index % col_max
  624.     new_x = item_x1 + item_width * (col + 0.5)
  625.     new_y = item_y1 + item_height * (row + 0.5)
  626.     new_x += 14 if col > 4
  627.     Mouse.set_mouse_pos(new_x, new_y)
  628.   end
  629. end
  630.  
  631. #==============================================================================
  632. # ■ Window_NumberInput
  633. #------------------------------------------------------------------------------
  634. #  重写了数值输入的方法以适应鼠标
  635. #==============================================================================
  636. class Window_NumberInput < Window_Base
  637.   #--------------------------------------------------------------------------
  638.   # ● 定义实例变量
  639.   #--------------------------------------------------------------------------
  640.   attr_reader :extra_window
  641.   #--------------------------------------------------------------------------
  642.   # ● 初始化
  643.   #--------------------------------------------------------------------------
  644.   alias sion_mouse_initialize initialize
  645.   def initialize(arg)
  646.     sion_mouse_initialize(arg)
  647.     create_extra_window
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ● 启动
  651.   #--------------------------------------------------------------------------
  652.   alias sion_mouse_start start
  653.   def start
  654.     sion_mouse_start
  655.     deactivate
  656.     extra_start
  657.   end
  658.   #--------------------------------------------------------------------------
  659.   # ● 创建新的数值输入窗口
  660.   #--------------------------------------------------------------------------
  661.   def create_extra_window
  662.     @extra_window = Window_NumberInput_Ex.new
  663.     @extra_window.x = (Graphics.width - @extra_window.width) / 2
  664.     @extra_window.number_proc  = Proc.new {|n| [url=home.php?mod=space&uid=27178]@Number[/url] = n }
  665.     @extra_window.index_proc   = Proc.new {|n| @index = n }
  666.     @extra_window.close_proc   = Proc.new { close }
  667.     @extra_window.refresh_proc = Proc.new { refresh }
  668.   end
  669.   #--------------------------------------------------------------------------
  670.   # ● 激活新窗口
  671.   #--------------------------------------------------------------------------
  672.   def extra_start
  673.     case $game_message.position
  674.       when 0; @extra_window.y = y + height + 4
  675.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
  676.       when 2; @extra_window.y = y - @extra_window.height - 4
  677.       else  ; @extra_window.y = 8
  678.     end
  679.     @extra_window.variable_id = $game_message.num_input_variable_id
  680.     @extra_window.digits_max  = @digits_max
  681.     @extra_window.number      = @number
  682.     @extra_window.open
  683.     @extra_window.activate
  684.   end
  685.   #--------------------------------------------------------------------------
  686.   # ● 更新
  687.   #--------------------------------------------------------------------------
  688.   def update
  689.     super
  690.     @extra_window.update
  691.     update_cursor
  692.   end
  693.   #--------------------------------------------------------------------------
  694.   # ● 关闭窗口
  695.   #--------------------------------------------------------------------------
  696.   def close
  697.     super
  698.     @extra_window.close
  699.     @extra_window.deactivate
  700.   end
  701. end
  702.  
  703. #==============================================================================
  704. # ■ Window_NumberInput_Ex
  705. #------------------------------------------------------------------------------
  706. #  新的数值输入窗口(NewClass)
  707. #==============================================================================
  708. class Window_NumberInput_Ex < Window_Selectable
  709.   #--------------------------------------------------------------------------
  710.   # ● 定义实例变量
  711.   #--------------------------------------------------------------------------
  712.   attr_accessor :number_proc
  713.   attr_accessor :index_proc
  714.   attr_accessor :close_proc
  715.   attr_accessor :refresh_proc
  716.   attr_accessor :number
  717.   attr_accessor :digits_max
  718.   attr_accessor :variable_id
  719.   #--------------------------------------------------------------------------
  720.   # ● 数字表
  721.   #--------------------------------------------------------------------------
  722.   TABLE = [  7,  8,  9,
  723.              4,  5,  6,
  724.              1,  2,  3,
  725.             '←',0,'确定',]
  726.   #--------------------------------------------------------------------------
  727.   # ● 初始化对象
  728.   #--------------------------------------------------------------------------
  729.   def initialize
  730.     super(0, 0, 120, fitting_height(4))
  731.     self.openness = 0
  732.     @index = 0
  733.     @number = 0
  734.     @old_window_index = 0
  735.     @digits_max = 0
  736.     12.times {|i| draw_text(item_rect(i), TABLE[i], 1) }
  737.   end
  738.   #--------------------------------------------------------------------------
  739.   # ● 获取项目的绘制矩形
  740.   #--------------------------------------------------------------------------
  741.   def item_rect(index)
  742.     rect = Rect.new
  743.     rect.x = index % 3 * 32
  744.     rect.y = index / 3 * line_height
  745.     rect.width = 32
  746.     rect.height = line_height
  747.     return rect
  748.   end
  749.   #--------------------------------------------------------------------------
  750.   # ● 将光标设置到鼠标所在的位置
  751.   #--------------------------------------------------------------------------
  752.   def set_cursor
  753.     mouse_row, mouse_col = mouse_window_area
  754.     if mouse_row >= 0 && mouse_col >= 0
  755.       new_index = mouse_row * 3 + mouse_col
  756.       select(new_index) if new_index <= 11
  757.     end
  758.   end
  759.   #--------------------------------------------------------------------------
  760.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
  761.   #--------------------------------------------------------------------------
  762.   def mouse_window_area
  763.     if viewport.nil?
  764.       vp_x, vp_y = 0, 0
  765.     else
  766.       vp_x = viewport.rect.x - viewport.ox
  767.       vp_y = viewport.rect.y - viewport.oy
  768.     end
  769.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  770.     item_x1 = vp_x + x + standard_padding
  771.     item_y1 = vp_y + y + standard_padding
  772.     item_x2 = vp_x + x - standard_padding + width
  773.     item_y2 = vp_y + y - standard_padding + height
  774.     if mouse_x < item_x1
  775.       mouse_col = -1
  776.     elsif mouse_x > item_x2
  777.       mouse_col = -2
  778.     else
  779.       mouse_col = (mouse_x - item_x1) / 32
  780.     end
  781.     if mouse_y < item_y1
  782.       mouse_row = -1
  783.     elsif mouse_y > item_y2
  784.       mouse_row = -2
  785.     else
  786.       mouse_row = 4 * (mouse_y - item_y1 - 1) / (item_y2 - item_y1)
  787.     end
  788.     return mouse_row, mouse_col
  789.   end
  790.   #--------------------------------------------------------------------------
  791.   # ● 获取文字
  792.   #--------------------------------------------------------------------------
  793.   def get_number
  794.     return false if @index == 9 || @index == 11
  795.     return TABLE[@index]
  796.   end
  797.   #--------------------------------------------------------------------------
  798.   # ● 判定光标位置是否在“退格”上
  799.   #--------------------------------------------------------------------------
  800.   def is_delete?
  801.     @index == 9
  802.   end
  803.   #--------------------------------------------------------------------------
  804.   # ● 判定光标位置是否在“确定”上
  805.   #--------------------------------------------------------------------------
  806.   def is_ok?
  807.     @index == 11
  808.   end
  809.   #--------------------------------------------------------------------------
  810.   # ● 更新光标
  811.   #--------------------------------------------------------------------------
  812.   def update_cursor
  813.     cursor_rect.set(item_rect(@index))
  814.   end
  815.   #--------------------------------------------------------------------------
  816.   # ● 判定光标是否可以移动
  817.   #--------------------------------------------------------------------------
  818.   def cursor_movable?
  819.     active
  820.   end
  821.   #--------------------------------------------------------------------------
  822.   # ● 光标向下移动
  823.   #     wrap : 允许循环
  824.   #--------------------------------------------------------------------------
  825.   def cursor_down(wrap)
  826.     if @index < 9 or wrap
  827.       @index = (index + 3) % 12
  828.     end
  829.   end
  830.   #--------------------------------------------------------------------------
  831.   # ● 光标向上移动
  832.   #     wrap : 允许循环
  833.   #--------------------------------------------------------------------------
  834.   def cursor_up(wrap)
  835.     if @index >= 3 or wrap
  836.       @index = (index + 9) % 12
  837.     end
  838.   end
  839.   #--------------------------------------------------------------------------
  840.   # ● 光标向右移动
  841.   #     wrap : 允许循环
  842.   #--------------------------------------------------------------------------
  843.   def cursor_right(wrap)
  844.     if @index % 3 < 2
  845.       @index += 1
  846.     elsif wrap
  847.       @index -= 2
  848.     end
  849.   end
  850.   #--------------------------------------------------------------------------
  851.   # ● 光标向左移动
  852.   #     wrap : 允许循环
  853.   #--------------------------------------------------------------------------
  854.   def cursor_left(wrap)
  855.     if @index % 3 > 0
  856.       @index -= 1
  857.     elsif wrap
  858.       @index += 2
  859.     end
  860.   end
  861.   #--------------------------------------------------------------------------
  862.   # ● 处理光标的移动
  863.   #--------------------------------------------------------------------------
  864.   def process_cursor_move
  865.     super
  866.     update_cursor
  867.   end
  868.   #--------------------------------------------------------------------------
  869.   # ● “确定”、“删除字符”和“取消输入”的处理
  870.   #--------------------------------------------------------------------------
  871.   def process_handling
  872.     return unless open? && active
  873.     process_jump if Input.trigger?(:A)
  874.     process_back if Input.repeat?(:B)
  875.     process_ok   if Input.trigger?(:C)
  876.   end
  877.   #--------------------------------------------------------------------------
  878.   # ● 跳转“确定”
  879.   #--------------------------------------------------------------------------
  880.   def process_jump
  881.     if @index != 11
  882.       @index = 11
  883.       Sound.play_cursor
  884.     end
  885.   end
  886.   #--------------------------------------------------------------------------
  887.   # ● 后退一个字符
  888.   #--------------------------------------------------------------------------
  889.   def process_back
  890.     Sound.play_cancel
  891.     place = 10 ** (@digits_max - 1 - @old_window_index)
  892.     n = (@number / place) % 10
  893.     @number -= n * place
  894.     @number_proc.call(@number)
  895.     @old_window_index -= 1 if @old_window_index > 0
  896.     @index_proc.call(@old_window_index)
  897.     @refresh_proc.call
  898.   end
  899.   #--------------------------------------------------------------------------
  900.   # ● 按下确定键时的处理
  901.   #--------------------------------------------------------------------------
  902.   def process_ok
  903.     if get_number
  904.       Sound.play_cursor
  905.       place = 10 ** (@digits_max - 1 - @old_window_index)
  906.       n = get_number - (@number / place) % 10
  907.       @number += n * place
  908.       @number_proc.call(@number)
  909.       @old_window_index += 1 if @old_window_index < @digits_max - 1
  910.       @index_proc.call(@old_window_index)
  911.       @refresh_proc.call
  912.     elsif is_delete?
  913.       process_back
  914.     elsif is_ok?
  915.       on_input_ok
  916.     end
  917.   end
  918.   #--------------------------------------------------------------------------
  919.   # ● 确定
  920.   #--------------------------------------------------------------------------
  921.   def on_input_ok
  922.     @index = 0
  923.     @old_window_index = 0
  924.     $game_variables[@variable_id] = @number
  925.     Sound.play_ok
  926.     @close_proc.call
  927.   end
  928.   #--------------------------------------------------------------------------
  929.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  930.   #--------------------------------------------------------------------------
  931.   def set_mouse_pos
  932.     if viewport.nil? # necessary!
  933.       vp_x, vp_y = 0, 0
  934.     else
  935.       vp_x = viewport.rect.x - viewport.ox
  936.       vp_y = viewport.rect.y - viewport.oy
  937.     end
  938.     item_x1 = vp_x + x + standard_padding
  939.     item_y1 = vp_y + y + standard_padding
  940.     get_index = @index < 0 ? 0 : @index
  941.     new_x = item_x1 + 32 * (get_index % 3 + 0.5)
  942.     new_y = item_y1 + 24 * (get_index / 3 + 0.5)
  943.     Mouse.set_mouse_pos(new_x, new_y)
  944.   end
  945. end
  946.  
  947. #==============================================================================
  948. # ■ Window_Message
  949. #------------------------------------------------------------------------------
  950. #  显示文字信息的窗口。
  951. #==============================================================================
  952. class Window_Message < Window_Base
  953.   #--------------------------------------------------------------------------
  954.   # ● 处理数值的输入(覆盖原方法)
  955.   #--------------------------------------------------------------------------
  956.   def input_number
  957.     @number_window.start
  958.     Fiber.yield while @number_window.extra_window.active
  959.   end
  960. end
  961.  
  962. #==============================================================================
  963. # ■ Window_PartyCommand
  964. #------------------------------------------------------------------------------
  965. #  战斗画面中,选择“战斗/撤退”的窗口。
  966. #==============================================================================
  967. class Window_PartyCommand < Window_Command
  968.   #--------------------------------------------------------------------------
  969.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  970.   #--------------------------------------------------------------------------
  971.   def set_mouse_pos
  972.     if viewport.nil?
  973.       vp_x, vp_y = 0, 0
  974.     else
  975.       #vp_x = viewport.rect.x - viewport.ox
  976.       vp_y = viewport.rect.y - viewport.oy
  977.     end
  978.     item_x1 = x + standard_padding
  979.     item_y1 = vp_y + y + standard_padding
  980.     get_index = @index < 0 ? 0 : @index
  981.     row = get_index / col_max - top_row
  982.     col = get_index % col_max
  983.     new_x = item_x1 + item_width * (col + 0.5)
  984.     new_y = item_y1 + item_height * (row + 0.5)
  985.     Mouse.set_mouse_pos(new_x, new_y)
  986.   end
  987. end
  988.  
  989. #==============================================================================
  990. # ■ Window_ActorCommand
  991. #------------------------------------------------------------------------------
  992. #  战斗画面中,选择角色行动的窗口。
  993. #==============================================================================
  994. class Window_ActorCommand < Window_Command
  995.   #--------------------------------------------------------------------------
  996.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  997.   #--------------------------------------------------------------------------
  998.   def set_mouse_pos
  999.     if viewport.nil?
  1000.       vp_x, vp_y = 0, 0
  1001.     else
  1002.       #vp_x = viewport.rect.x - viewport.ox
  1003.       vp_y = viewport.rect.y - viewport.oy
  1004.     end
  1005.     item_x1 = Graphics.width - width + standard_padding
  1006.     item_y1 = vp_y + y + standard_padding
  1007.     get_index = @index < 0 ? 0 : @index
  1008.     row = get_index / col_max - top_row
  1009.     col = get_index % col_max
  1010.     new_x = item_x1 + item_width * (col + 0.5)
  1011.     new_y = item_y1 + item_height * (row + 0.5)
  1012.     Mouse.set_mouse_pos(new_x, new_y)
  1013.   end
  1014. end
  1015.  
  1016. #==============================================================================
  1017. # ■ Game_Player
  1018. #------------------------------------------------------------------------------
  1019. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
  1020. #   本类的实例请参考 $game_player 。
  1021. #==============================================================================
  1022. class Game_Player < Game_Character
  1023.   #--------------------------------------------------------------------------
  1024.   # ● 由方向移动(覆盖原方法)
  1025.   #--------------------------------------------------------------------------
  1026.   def move_by_input
  1027.     return if !movable? || $game_map.interpreter.running?
  1028.     if Input.dir4 > 0
  1029.       move_straight(Input.dir4)
  1030.       reset_move_path
  1031.     else
  1032.       move_by_mouse
  1033.     end
  1034.   end
  1035.   #--------------------------------------------------------------------------
  1036.   # ● 非移动中的处理(覆盖原方法)
  1037.   #     last_moving : 此前是否正在移动
  1038.   #--------------------------------------------------------------------------
  1039.   def update_nonmoving(last_moving)
  1040.     return if $game_map.interpreter.running?
  1041.     if last_moving
  1042.       $game_party.on_player_walk
  1043.       return if check_touch_event
  1044.     end
  1045.     if movable? && Input.trigger?(:C)
  1046.       return if Mouse.press?(0x01) # 防止按下鼠标左键绘制路径时触发事件或载具切换
  1047.       return if get_on_off_vehicle
  1048.       return if check_action_event
  1049.     end
  1050.     update_encounter if last_moving
  1051.   end
  1052.   #--------------------------------------------------------------------------
  1053.   # ● 判定是否跑步状态(覆盖原方法)
  1054.   #--------------------------------------------------------------------------
  1055.   def dash?
  1056.     return false if @move_route_forcing
  1057.     return false if $game_map.disable_dash?
  1058.     return false if vehicle
  1059.     return Input.press?(:A) || @mouse_dash
  1060.   end
  1061.   #--------------------------------------------------------------------------
  1062.   # ● 初始化
  1063.   #--------------------------------------------------------------------------
  1064.   alias sion_mouse_initialize initialize
  1065.   def initialize
  1066.     sion_mouse_initialize
  1067.     reset_move_path
  1068.     @moveto_x = 0
  1069.     @moveto_y = 0
  1070.   end
  1071.   #--------------------------------------------------------------------------
  1072.   # ● 更新
  1073.   #--------------------------------------------------------------------------
  1074.   alias sion_mouse_update update
  1075.   def update
  1076.     sion_mouse_update
  1077.     clear_unreachable_sign
  1078.   end
  1079.   #--------------------------------------------------------------------------
  1080.   # ● 处理卷动
  1081.   #--------------------------------------------------------------------------
  1082.   alias sion_mouse_update_scroll update_scroll
  1083.   def update_scroll(last_real_x, last_real_y)
  1084.     return if $game_map.scrolling?
  1085.     KsOfSion::New_Scroll ? new_update_scroll :
  1086.       sion_mouse_update_scroll(last_real_x, last_real_y)
  1087.   end
  1088.   #--------------------------------------------------------------------------
  1089.   # ● 重置移动路径相关信息
  1090.   #--------------------------------------------------------------------------
  1091.   def reset_move_path
  1092.     @mouse_dash = false
  1093.     @mouse_move_path = []
  1094.     $mouse_move_sign.transparent = true
  1095.   end
  1096.   #--------------------------------------------------------------------------
  1097.   # ● 新的卷动地图方法
  1098.   #--------------------------------------------------------------------------
  1099.   def new_update_scroll
  1100.     horz_speed = 2 ** @move_speed * KsOfSion::Map_Scroll_Spd / Graphics.width
  1101.     vert_speed = 2 ** @move_speed * KsOfSion::Map_Scroll_Spd / Graphics.height
  1102.     ax = $game_map.adjust_x(@real_x)
  1103.     ay = $game_map.adjust_y(@real_y)
  1104.     $game_map.scroll_down (vert_speed * (ay - center_y)) if ay > center_y
  1105.     $game_map.scroll_left (horz_speed * (center_x - ax)) if ax < center_x
  1106.     $game_map.scroll_right(horz_speed * (ax - center_x)) if ax > center_x
  1107.     $game_map.scroll_up   (vert_speed * (center_y - ay)) if ay < center_y
  1108.   end
  1109.   #--------------------------------------------------------------------------
  1110.   # ● 消除不能抵达图标
  1111.   #--------------------------------------------------------------------------
  1112.   def clear_unreachable_sign
  1113.     return if Mouse.press?(0x01)
  1114.     if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 0
  1115.       $mouse_move_sign.transparent = true
  1116.       $mouse_move_sign.direction = 2
  1117.     end
  1118.   end
  1119.   #--------------------------------------------------------------------------
  1120.   # ● 由鼠标移动
  1121.   #--------------------------------------------------------------------------
  1122.   def move_by_mouse
  1123.     unless @mouse_move_path.empty? # 移动路线数组不为空则执行移动
  1124.       dir = @mouse_move_path.shift
  1125.       if passable?(x, y, dir) && !@mouse_move_path.empty?
  1126.         move_straight(dir)
  1127.       elsif @mouse_move_path.empty? # 判断是否是最后一步
  1128.         x2 = $game_map.round_x_with_direction(x, dir)
  1129.         y2 = $game_map.round_y_with_direction(y, dir)
  1130.         move_straight(dir) unless dir.zero?
  1131.         unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具
  1132.           check_event_trigger_there([0,1,2])
  1133.           get_on_off_vehicle unless $game_map.setup_starting_event
  1134.         end
  1135.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2
  1136.         @mouse_dash = false
  1137.       elsif @mouse_move_path[0].zero? # 目标点无法抵达,调整朝向→目标点
  1138.         @mouse_move_path.shift
  1139.         @direction = dir
  1140.         @mouse_dash = false
  1141.       else
  1142.         draw_move_path
  1143.       end
  1144.     end
  1145.   end
  1146.   #--------------------------------------------------------------------------
  1147.   # ● 地图界面按下鼠标左键的处理
  1148.   #--------------------------------------------------------------------------
  1149.   def left_button_action
  1150.     return if !drawable? || $game_map.interpreter.running?
  1151.     get_mouse_pos
  1152.     $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图
  1153.     if @shift_event
  1154.       if Mouse.trigger?(0x01)
  1155.         @shift_event.jump(@moveto_x - @shift_event.x,
  1156.           @moveto_y - @shift_event.y)
  1157.         @shift_event = nil
  1158.       end
  1159.       return
  1160.     end
  1161.     if @moveto_x == x && @moveto_y == y # 判断目标点是否与角色重合
  1162.       return if moving? || (vehicle && !vehicle.movable?)
  1163.       check_event_trigger_here([0]) # 判断是否触发重合点事件
  1164.       get_on_off_vehicle if !$game_map.setup_starting_event &&
  1165.         $game_map.airship.pos?(x, y)  # 判断是否要上、下飞艇
  1166.       return
  1167.     end
  1168.     # 判断是否用鼠标启动事件
  1169.     $game_map.events_xy(@moveto_x, @moveto_y).each do |event|
  1170.       if event.mouse_start?
  1171.         reset_move_path
  1172.         event.start if Mouse.trigger?(0x01)
  1173.         return
  1174.       end
  1175.     end
  1176.     @mouse_dash = true if Mouse.double_click? # 双击冲刺
  1177.     return if Mouse.left_state % 10 != 1 # 按住鼠标左键10帧绘制1次路径
  1178.     for i in 1..4 # 判断目标点是否为角色周围四点
  1179.       if x == $game_map.round_x_with_direction(@moveto_x, i * 2) &&
  1180.          y == $game_map.round_y_with_direction(@moveto_y, i * 2)
  1181.       $mouse_move_sign.transparent = true
  1182.       @mouse_move_path = [10 - i * 2] if Mouse.trigger?(0x01)
  1183.       return; end
  1184.     end
  1185.     draw_move_path
  1186.   end
  1187.   #--------------------------------------------------------------------------
  1188.   # ● 取得鼠标处对应地图坐标点
  1189.   #--------------------------------------------------------------------------
  1190.   def get_mouse_pos
  1191.     $game_map.get_mouse_map_xy
  1192.     @moveto_x = $game_map.mouse_map_x
  1193.     @moveto_y = $game_map.mouse_map_y
  1194.     #mouse_x, mouse_y = Mouse.get_mouse_pos
  1195.     #@moveto_x = $game_map.round_x(x + (mouse_x -
  1196.     #  ($game_map.adjust_x(x) * 32 + 16).to_i + 16) / 32)
  1197.     #@moveto_y = $game_map.round_y(y + 1 + (mouse_y -
  1198.     #  ($game_map.adjust_y(y) * 32 + 16).to_i - 16) / 32)
  1199.   end
  1200.   #--------------------------------------------------------------------------
  1201.   # ● 绘制移动路径 @array[move_directions...]
  1202.   #--------------------------------------------------------------------------
  1203.   def draw_move_path
  1204.     #temp = Time.now
  1205.     case @vehicle_type
  1206.     when :walk
  1207.       draw_walk_path
  1208.     when :boat
  1209.       draw_boat_path
  1210.     when :ship
  1211.       draw_ship_path
  1212.     when :airship
  1213.       draw_air_path
  1214.     end
  1215.     #p (Time.now.to_f - temp.to_f) # 测试效率
  1216.   end
  1217.   #--------------------------------------------------------------------------
  1218.   # ● 判定是否可以绘制移动路径
  1219.   #--------------------------------------------------------------------------
  1220.   def drawable?
  1221.     return false if @move_route_forcing || @followers.gathering?
  1222.     return false if @vehicle_getting_on || @vehicle_getting_off
  1223.     return false if $game_message.busy? || $game_message.visible
  1224.     return true
  1225.   end
  1226.   #--------------------------------------------------------------------------
  1227.   # ● 绘制walk移动路径 @array[move_directions...]
  1228.   #--------------------------------------------------------------------------
  1229.   def draw_walk_path
  1230.     # 准备绘制路径表格
  1231.     sheet = Table.new($game_map.width, $game_map.height)
  1232.     reversed_chase_path  = []; chase_path  = []
  1233.     reversed_chase_point = []; chase_point = []
  1234.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1235.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1236.     reach_point = false
  1237.     step = 3
  1238.     loop do #loop1 开始填充表格
  1239.      draw_path = false
  1240.      check_points = new_start_points
  1241.      new_start_points = []
  1242.       loop do #loop2 从起点开始正向填充
  1243.         point_x = check_points.shift
  1244.         break if point_x == nil
  1245.         point_y = check_points.shift
  1246.         left_x  = $game_map.round_x(point_x - 1)
  1247.         right_x = $game_map.round_x(point_x + 1)
  1248.         up_y    = $game_map.round_y(point_y - 1)
  1249.         down_y  = $game_map.round_y(point_y + 1)
  1250.                     # 判断路径是否连通
  1251.         path_step = step - 1
  1252.         if sheet[left_x, point_y] == path_step     &&
  1253.            $game_map.passable?(left_x, point_y, 6) &&
  1254.            $game_map.passable?(point_x, point_y, 4)
  1255.           chase_path.push(4)
  1256.           chase_point = [left_x, point_y]
  1257.           reversed_chase_point = [point_x, point_y]
  1258.           reach_point = true; break
  1259.         elsif sheet[right_x, point_y] == path_step     &&
  1260.               $game_map.passable?(right_x, point_y, 4) &&
  1261.               $game_map.passable?(point_x, point_y, 6)
  1262.             chase_path.push(6)
  1263.             chase_point = [right_x, point_y]
  1264.             reversed_chase_point = [point_x, point_y]
  1265.             reach_point = true; break
  1266.         elsif sheet[point_x, up_y] == path_step     &&
  1267.               $game_map.passable?(point_x, up_y, 2) &&
  1268.               $game_map.passable?(point_x, point_y, 8)
  1269.             chase_path.push(8)
  1270.             chase_point = [point_x, up_y]
  1271.             reversed_chase_point = [point_x, point_y]
  1272.             reach_point = true; break
  1273.         elsif sheet[point_x, down_y] == path_step     &&
  1274.               $game_map.passable?(point_x, down_y, 8) &&
  1275.               $game_map.passable?(point_x, point_y, 2)
  1276.             chase_path.push(2)
  1277.             chase_point = [point_x, down_y]
  1278.             reversed_chase_point = [point_x, point_y]
  1279.             reach_point = true; break
  1280.         end
  1281.         # 以需要抵达该点的步数填充路径表格 #
  1282.         if sheet[left_x, point_y] == 0              &&
  1283.            $game_map.passable?(left_x, point_y, 6)  &&
  1284.            !collide_with_events?(left_x, point_y)   &&
  1285.            $game_map.passable?(point_x, point_y, 4) &&
  1286.            !collide_with_vehicles?(left_x, point_y) #judge_end
  1287.           sheet[left_x, point_y] = step
  1288.           draw_path = true
  1289.           new_start_points.push(left_x, point_y)
  1290.         end
  1291.         if sheet[right_x, point_y] == 0             &&
  1292.            $game_map.passable?(right_x, point_y, 4) &&
  1293.            !collide_with_events?(right_x, point_y)  &&
  1294.            $game_map.passable?(point_x, point_y, 6) &&
  1295.            !collide_with_vehicles?(right_x, point_y)#judge_end
  1296.           sheet[right_x, point_y] = step
  1297.           draw_path = true
  1298.           new_start_points.push(right_x, point_y)
  1299.         end
  1300.         if sheet[point_x, up_y] == 0                &&
  1301.            $game_map.passable?(point_x, up_y, 2)    &&
  1302.            !collide_with_events?(point_x, up_y)     &&
  1303.            $game_map.passable?(point_x, point_y, 8) &&
  1304.            !collide_with_vehicles?(point_x, up_y)   #judge_end
  1305.           sheet[point_x, up_y] = step
  1306.           draw_path = true
  1307.           new_start_points.push(point_x, up_y)
  1308.         end
  1309.         if sheet[point_x, down_y] == 0              &&
  1310.            $game_map.passable?(point_x, down_y, 8)  &&
  1311.            !collide_with_events?(point_x, down_y)   &&
  1312.            $game_map.passable?(point_x, point_y, 2) &&
  1313.            !collide_with_vehicles?(point_x, down_y) #judge_end
  1314.           sheet[point_x, down_y] = step
  1315.           draw_path = true
  1316.           new_start_points.push(point_x, down_y)
  1317.         end
  1318.       end#endOfLoop2
  1319.       break if !draw_path || reach_point
  1320.       draw_path = false
  1321.       check_points = new_end_points
  1322.       new_end_points = []
  1323.       step += 1
  1324.       break if step > KsOfSion::Break_Steps &&
  1325.                !Input.press?(KsOfSion::Find_Path_Key)
  1326.       loop do #loop3 从终点开始反向填充
  1327.         point_x = check_points.shift
  1328.         break if point_x == nil
  1329.         point_y = check_points.shift
  1330.         left_x  = $game_map.round_x(point_x - 1)
  1331.         right_x = $game_map.round_x(point_x + 1)
  1332.         up_y    = $game_map.round_y(point_y - 1)
  1333.         down_y  = $game_map.round_y(point_y + 1)
  1334.         # 判断路径是否连通
  1335.         path_step = step - 1
  1336.         if sheet[left_x, point_y] == path_step     &&
  1337.            $game_map.passable?(left_x, point_y, 6) &&
  1338.            $game_map.passable?(point_x, point_y, 4)
  1339.           chase_path.push(6)
  1340.           chase_point = [point_x, point_y]
  1341.           reversed_chase_point = [left_x, point_y]
  1342.           reach_point = true; break
  1343.         elsif sheet[right_x, point_y] == path_step     &&
  1344.               $game_map.passable?(right_x, point_y, 4) &&
  1345.               $game_map.passable?(point_x, point_y, 6)
  1346.             chase_path.push(4)
  1347.             chase_point = [point_x, point_y]
  1348.             reversed_chase_point = [right_x, point_y]
  1349.             reach_point = true; break
  1350.         elsif sheet[point_x, up_y] == path_step     &&
  1351.               $game_map.passable?(point_x, up_y, 2) &&
  1352.               $game_map.passable?(point_x, point_y, 8)
  1353.             chase_path.push(2)
  1354.             chase_point = [point_x, point_y]
  1355.             reversed_chase_point = [point_x, up_y]
  1356.             reach_point = true; break
  1357.         elsif sheet[point_x, down_y] == path_step     &&
  1358.               $game_map.passable?(point_x, down_y, 8) &&
  1359.               $game_map.passable?(point_x, point_y, 2)
  1360.             chase_path.push(8)
  1361.             chase_point = [point_x, point_y]
  1362.             reversed_chase_point = [point_x, down_y]
  1363.             reach_point = true; break
  1364.         end
  1365.         # 以需要抵达该点的步数填充路径表格 #
  1366.         if sheet[left_x, point_y] == 0              &&
  1367.            $game_map.passable?(left_x, point_y, 6)  &&
  1368.            !collide_with_events?(left_x, point_y)   &&
  1369.            $game_map.passable?(point_x, point_y, 4) &&
  1370.            !collide_with_vehicles?(left_x, point_y) #judge_end
  1371.           sheet[left_x, point_y] = step
  1372.           draw_path = true
  1373.           new_end_points.push(left_x, point_y)
  1374.         end
  1375.         if sheet[right_x, point_y] == 0             &&
  1376.            $game_map.passable?(right_x, point_y, 4) &&
  1377.            !collide_with_events?(right_x, point_y)  &&
  1378.            $game_map.passable?(point_x, point_y, 6) &&
  1379.            !collide_with_vehicles?(right_x, point_y)#judge_end
  1380.           sheet[right_x, point_y] = step
  1381.           draw_path = true
  1382.           new_end_points.push(right_x, point_y)
  1383.         end
  1384.         if sheet[point_x, up_y] == 0                &&
  1385.            $game_map.passable?(point_x, up_y, 2)    &&
  1386.            !collide_with_events?(point_x, up_y)     &&
  1387.            $game_map.passable?(point_x, point_y, 8) &&
  1388.            !collide_with_vehicles?(point_x, up_y)   #judge_end
  1389.           sheet[point_x, up_y] = step
  1390.           draw_path = true
  1391.           new_end_points.push(point_x, up_y)
  1392.         end
  1393.         if sheet[point_x, down_y] == 0              &&
  1394.            $game_map.passable?(point_x, down_y, 8)  &&
  1395.            !collide_with_events?(point_x, down_y)   &&
  1396.            $game_map.passable?(point_x, point_y, 2) &&
  1397.            !collide_with_vehicles?(point_x, down_y) #judge_end
  1398.           sheet[point_x, down_y] = step
  1399.           draw_path = true
  1400.           new_end_points.push(point_x, down_y)
  1401.         end
  1402.       end#endOfLoop3
  1403.       break if !draw_path || reach_point
  1404.       step += 1
  1405.     end #endOfLoop1 路径表格填充完毕
  1406.     $mouse_move_sign.transparent = false
  1407.     # 判断指定地点能否抵达
  1408.     if reach_point
  1409.       $mouse_move_sign.direction = 2
  1410.     else
  1411.       not_reach_point
  1412.       return
  1413.     end
  1414.     # 根据路径表格绘制最短移动路径(反向)
  1415.     steps = step / 2 * 2 + 1
  1416.     loop_times = step / 2
  1417.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1418.     for i in 1..loop_times # forLoop
  1419.     steps -= 2
  1420.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs #反过来?蛋疼了……
  1421.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1422.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1423.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1424.         reversed_chase_path.push(6)
  1425.         point_x = $game_map.round_x(point_x - 1)
  1426.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1427.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1428.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1429.         reversed_chase_path.push(4)
  1430.         point_x = $game_map.round_x(point_x + 1)
  1431.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1432.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1433.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1434.         reversed_chase_path.push(8)
  1435.         point_y = $game_map.round_y(point_y + 1)
  1436.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1437.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1438.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1439.         reversed_chase_path.push(2)
  1440.         point_y = $game_map.round_y(point_y - 1)
  1441.       end
  1442.     else
  1443.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1444.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1445.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1446.         reversed_chase_path.push(8)
  1447.         point_y = $game_map.round_y(point_y + 1)
  1448.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1449.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1450.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1451.         reversed_chase_path.push(2)
  1452.         point_y = $game_map.round_y(point_y - 1)
  1453.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1454.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1455.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1456.         reversed_chase_path.push(6)
  1457.         point_x = $game_map.round_x(point_x - 1)
  1458.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1459.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1460.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1461.         reversed_chase_path.push(4)
  1462.         point_x = $game_map.round_x(point_x + 1)
  1463.       end
  1464.     end
  1465.     end #endOfForLoop
  1466.     # 根据路径表格绘制最短移动路径(正向)
  1467.     steps = step / 2 * 2
  1468.     loop_times = step / 2
  1469.     point_x, point_y = chase_point[0], chase_point[1]
  1470.     for i in 2..loop_times # forLoop
  1471.     steps -= 2
  1472.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1473.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1474.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1475.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1476.         chase_path.push(2)
  1477.         point_y = $game_map.round_y(point_y + 1)
  1478.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1479.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1480.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1481.         chase_path.push(8)
  1482.         point_y = $game_map.round_y(point_y - 1)
  1483.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1484.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1485.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1486.         chase_path.push(4)
  1487.         point_x = $game_map.round_x(point_x - 1)
  1488.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1489.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1490.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1491.         chase_path.push(6)
  1492.         point_x = $game_map.round_x(point_x + 1)
  1493.       end
  1494.     else
  1495.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1496.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1497.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1498.         chase_path.push(4)
  1499.         point_x = $game_map.round_x(point_x - 1)
  1500.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1501.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1502.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1503.         chase_path.push(6)
  1504.         point_x = $game_map.round_x(point_x + 1)
  1505.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1506.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1507.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1508.         chase_path.push(2)
  1509.         point_y = $game_map.round_y(point_y + 1)
  1510.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1511.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1512.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1513.         chase_path.push(8)
  1514.         point_y = $game_map.round_y(point_y - 1)
  1515.       end
  1516.     end
  1517.     end #endOfForLoop
  1518.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1519.   end#walk
  1520.   #--------------------------------------------------------------------------
  1521.   # ● 绘制boat的移动路径 @array[move_directions...]
  1522.   #--------------------------------------------------------------------------
  1523.   def draw_boat_path
  1524.     # 准备绘制路径表格
  1525.     sheet = Table.new($game_map.width, $game_map.height)
  1526.     reversed_chase_path  = []; chase_path  = []
  1527.     reversed_chase_point = []; chase_point = []
  1528.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1529.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1530.     reach_point = false
  1531.     step = 3
  1532.     loop do #loop1 开始填充表格
  1533.      draw_path = false
  1534.      check_points = new_start_points
  1535.      new_start_points = []
  1536.       loop do #loop2 从起点开始正向填充
  1537.         point_x = check_points.shift
  1538.         break if point_x == nil
  1539.         point_y = check_points.shift
  1540.         left_x  = $game_map.round_x(point_x - 1)
  1541.         right_x = $game_map.round_x(point_x + 1)
  1542.         up_y    = $game_map.round_y(point_y - 1)
  1543.         down_y  = $game_map.round_y(point_y + 1)
  1544.                     # 判断路径是否连通
  1545.         path_step = step - 1
  1546.         if sheet[left_x, point_y] == path_step
  1547.           chase_path.push(4)
  1548.           chase_point = [left_x, point_y]
  1549.           reversed_chase_point = [point_x, point_y]
  1550.           reach_point = true; break
  1551.         elsif sheet[right_x, point_y] == path_step
  1552.             chase_path.push(6)
  1553.             chase_point = [right_x, point_y]
  1554.             reversed_chase_point = [point_x, point_y]
  1555.             reach_point = true; break
  1556.         elsif sheet[point_x, up_y] == path_step
  1557.             chase_path.push(8)
  1558.             chase_point = [point_x, up_y]
  1559.             reversed_chase_point = [point_x, point_y]
  1560.             reach_point = true; break
  1561.         elsif sheet[point_x, down_y] == path_step
  1562.             chase_path.push(2)
  1563.             chase_point = [point_x, down_y]
  1564.             reversed_chase_point = [point_x, point_y]
  1565.             reach_point = true; break
  1566.         end
  1567.         # 以需要抵达该点的步数填充路径表格 #
  1568.         if sheet[left_x, point_y] == 0                &&
  1569.            $game_map.boat_passable?(left_x, point_y)  &&
  1570.            !collide_with_events?(left_x, point_y)     &&
  1571.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1572.           sheet[left_x, point_y] = step
  1573.           draw_path = true
  1574.           new_start_points.push(left_x, point_y)
  1575.         end
  1576.         if sheet[right_x, point_y] == 0               &&
  1577.            $game_map.boat_passable?(right_x, point_y) &&
  1578.            !collide_with_events?(right_x, point_y)    &&
  1579.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1580.           sheet[right_x, point_y] = step
  1581.           draw_path = true
  1582.           new_start_points.push(right_x, point_y)
  1583.         end
  1584.         if sheet[point_x, up_y] == 0                  &&
  1585.            $game_map.boat_passable?(point_x, up_y)    &&
  1586.            !collide_with_events?(point_x, up_y)       &&
  1587.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1588.           sheet[point_x, up_y] = step
  1589.           draw_path = true
  1590.           new_start_points.push(point_x, up_y)
  1591.         end
  1592.         if sheet[point_x, down_y] == 0                &&
  1593.            $game_map.boat_passable?(point_x, down_y)  &&
  1594.            !collide_with_events?(point_x, down_y)     &&
  1595.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1596.           sheet[point_x, down_y] = step
  1597.           draw_path = true
  1598.           new_start_points.push(point_x, down_y)
  1599.         end
  1600.       end#endOfLoop2
  1601.       break if !draw_path || reach_point
  1602.       draw_path = false
  1603.       check_points = new_end_points
  1604.       new_end_points = []
  1605.       step += 1
  1606.       break if step > KsOfSion::Break_Steps &&
  1607.                !Input.press?(KsOfSion::Find_Path_Key)
  1608.       loop do #loop3 从终点开始反向填充
  1609.         point_x = check_points.shift
  1610.         break if point_x == nil
  1611.         point_y = check_points.shift
  1612.         left_x  = $game_map.round_x(point_x - 1)
  1613.         right_x = $game_map.round_x(point_x + 1)
  1614.         up_y    = $game_map.round_y(point_y - 1)
  1615.         down_y  = $game_map.round_y(point_y + 1)
  1616.         # 判断路径是否连通
  1617.         path_step = step - 1
  1618.         if sheet[left_x, point_y] == path_step
  1619.           chase_path.push(6)
  1620.           chase_point = [point_x, point_y]
  1621.           reversed_chase_point = [left_x, point_y]
  1622.           reach_point = true; break
  1623.         elsif sheet[right_x, point_y] == path_step
  1624.             chase_path.push(4)
  1625.             chase_point = [point_x, point_y]
  1626.             reversed_chase_point = [right_x, point_y]
  1627.             reach_point = true; break
  1628.         elsif sheet[point_x, up_y] == path_step
  1629.             chase_path.push(2)
  1630.             chase_point = [point_x, point_y]
  1631.             reversed_chase_point = [point_x, up_y]
  1632.             reach_point = true; break
  1633.         elsif sheet[point_x, down_y] == path_step
  1634.             chase_path.push(8)
  1635.             chase_point = [point_x, point_y]
  1636.             reversed_chase_point = [point_x, down_y]
  1637.             reach_point = true; break
  1638.         end
  1639.         # 以需要抵达该点的步数填充路径表格 #
  1640.         if sheet[left_x, point_y] == 0                &&
  1641.            $game_map.boat_passable?(left_x, point_y)  &&
  1642.            !collide_with_events?(left_x, point_y)     &&
  1643.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1644.           sheet[left_x, point_y] = step
  1645.           draw_path = true
  1646.           new_end_points.push(left_x, point_y)
  1647.         end
  1648.         if sheet[right_x, point_y] == 0               &&
  1649.            $game_map.boat_passable?(right_x, point_y) &&
  1650.            !collide_with_events?(right_x, point_y)    &&
  1651.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1652.           sheet[right_x, point_y] = step
  1653.           draw_path = true
  1654.           new_end_points.push(right_x, point_y)
  1655.         end
  1656.         if sheet[point_x, up_y] == 0                  &&
  1657.            $game_map.boat_passable?(point_x, up_y)    &&
  1658.            !collide_with_events?(point_x, up_y)       &&
  1659.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1660.           sheet[point_x, up_y] = step
  1661.           draw_path = true
  1662.           new_end_points.push(point_x, up_y)
  1663.         end
  1664.         if sheet[point_x, down_y] == 0                &&
  1665.            $game_map.boat_passable?(point_x, down_y)  &&
  1666.            !collide_with_events?(point_x, down_y)     &&
  1667.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1668.           sheet[point_x, down_y] = step
  1669.           draw_path = true
  1670.           new_end_points.push(point_x, down_y)
  1671.         end
  1672.       end#endOfLoop3
  1673.       break if !draw_path || reach_point
  1674.       step += 1
  1675.     end #endOfLoop1 路径表格填充完毕
  1676.     $mouse_move_sign.transparent = false
  1677.     # 判断指定地点能否抵达
  1678.     if reach_point
  1679.       $mouse_move_sign.direction = 2
  1680.     else
  1681.       not_reach_point
  1682.       return
  1683.     end
  1684.     # 根据路径表格绘制最短移动路径(正向)
  1685.     steps = step / 2 * 2
  1686.     loop_times = step / 2
  1687.     point_x, point_y = chase_point[0], chase_point[1]
  1688.     for i in 2..loop_times # forLoop
  1689.     steps -= 2
  1690.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1691.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1692.         chase_path.push(2)
  1693.         point_y = $game_map.round_y(point_y + 1)
  1694.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1695.         chase_path.push(8)
  1696.         point_y = $game_map.round_y(point_y - 1)
  1697.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1698.         chase_path.push(4)
  1699.         point_x = $game_map.round_x(point_x - 1)
  1700.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1701.         chase_path.push(6)
  1702.         point_x = $game_map.round_x(point_x + 1)
  1703.       end
  1704.     else
  1705.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1706.         chase_path.push(4)
  1707.         point_x = $game_map.round_x(point_x - 1)
  1708.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1709.         chase_path.push(6)
  1710.         point_x = $game_map.round_x(point_x + 1)
  1711.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1712.         chase_path.push(2)
  1713.         point_y = $game_map.round_y(point_y + 1)
  1714.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1715.         chase_path.push(8)
  1716.         point_y = $game_map.round_y(point_y - 1)
  1717.       end
  1718.     end
  1719.     end #endOfForLoop
  1720.     # 如果指定点无法抵达或者登陆
  1721.     return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path)
  1722.     # 根据路径表格绘制最短移动路径(反向)
  1723.     steps = step / 2 * 2 + 1
  1724.     loop_times = step / 2
  1725.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1726.     for i in 1..loop_times # forLoop
  1727.     steps -= 2
  1728.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1729.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1730.         reversed_chase_path.push(6)
  1731.         point_x = $game_map.round_x(point_x - 1)
  1732.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1733.         reversed_chase_path.push(4)
  1734.         point_x = $game_map.round_x(point_x + 1)
  1735.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1736.         reversed_chase_path.push(8)
  1737.         point_y = $game_map.round_y(point_y + 1)
  1738.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1739.         reversed_chase_path.push(2)
  1740.         point_y = $game_map.round_y(point_y - 1)
  1741.       end
  1742.     else
  1743.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1744.         reversed_chase_path.push(8)
  1745.         point_y = $game_map.round_y(point_y + 1)
  1746.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1747.         reversed_chase_path.push(2)
  1748.         point_y = $game_map.round_y(point_y - 1)
  1749.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1750.         reversed_chase_path.push(6)
  1751.         point_x = $game_map.round_x(point_x - 1)
  1752.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1753.         reversed_chase_path.push(4)
  1754.         point_x = $game_map.round_x(point_x + 1)
  1755.       end
  1756.     end
  1757.     end #endOfForLoop
  1758.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1759.   end#boat
  1760.   #--------------------------------------------------------------------------
  1761.   # ● 绘制ship的移动路径 @array[move_directions...]
  1762.   #--------------------------------------------------------------------------
  1763.   def draw_ship_path
  1764.     # 准备绘制路径表格
  1765.     sheet = Table.new($game_map.width, $game_map.height)
  1766.     reversed_chase_path  = []; chase_path  = []
  1767.     reversed_chase_point = []; chase_point = []
  1768.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1769.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1770.     reach_point = false
  1771.     step = 3
  1772.     loop do #loop1 开始填充表格
  1773.      draw_path = false
  1774.      check_points = new_start_points
  1775.      new_start_points = []
  1776.       loop do #loop2 从起点开始正向填充
  1777.         point_x = check_points.shift
  1778.         break if point_x == nil
  1779.         point_y = check_points.shift
  1780.         left_x  = $game_map.round_x(point_x - 1)
  1781.         right_x = $game_map.round_x(point_x + 1)
  1782.         up_y    = $game_map.round_y(point_y - 1)
  1783.         down_y  = $game_map.round_y(point_y + 1)
  1784.                     # 判断路径是否连通
  1785.         path_step = step - 1
  1786.         if sheet[left_x, point_y] == path_step
  1787.           chase_path.push(4)
  1788.           chase_point = [left_x, point_y]
  1789.           reversed_chase_point = [point_x, point_y]
  1790.           reach_point = true; break
  1791.         elsif sheet[right_x, point_y] == path_step
  1792.             chase_path.push(6)
  1793.             chase_point = [right_x, point_y]
  1794.             reversed_chase_point = [point_x, point_y]
  1795.             reach_point = true; break
  1796.         elsif sheet[point_x, up_y] == path_step
  1797.             chase_path.push(8)
  1798.             chase_point = [point_x, up_y]
  1799.             reversed_chase_point = [point_x, point_y]
  1800.             reach_point = true; break
  1801.         elsif sheet[point_x, down_y] == path_step
  1802.             chase_path.push(2)
  1803.             chase_point = [point_x, down_y]
  1804.             reversed_chase_point = [point_x, point_y]
  1805.             reach_point = true; break
  1806.         end
  1807.         # 以需要抵达该点的步数填充路径表格 #
  1808.         if sheet[left_x, point_y] == 0                &&
  1809.            $game_map.ship_passable?(left_x, point_y)  &&
  1810.            !collide_with_events?(left_x, point_y)     &&
  1811.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1812.           sheet[left_x, point_y] = step
  1813.           draw_path = true
  1814.           new_start_points.push(left_x, point_y)
  1815.         end
  1816.         if sheet[right_x, point_y] == 0               &&
  1817.            $game_map.ship_passable?(right_x, point_y) &&
  1818.            !collide_with_events?(right_x, point_y)    &&
  1819.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1820.           sheet[right_x, point_y] = step
  1821.           draw_path = true
  1822.           new_start_points.push(right_x, point_y)
  1823.         end
  1824.         if sheet[point_x, up_y] == 0                  &&
  1825.            $game_map.ship_passable?(point_x, up_y)    &&
  1826.            !collide_with_events?(point_x, up_y)       &&
  1827.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1828.           sheet[point_x, up_y] = step
  1829.           draw_path = true
  1830.           new_start_points.push(point_x, up_y)
  1831.         end
  1832.         if sheet[point_x, down_y] == 0                &&
  1833.            $game_map.ship_passable?(point_x, down_y)  &&
  1834.            !collide_with_events?(point_x, down_y)     &&
  1835.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1836.           sheet[point_x, down_y] = step
  1837.           draw_path = true
  1838.           new_start_points.push(point_x, down_y)
  1839.         end
  1840.       end#endOfLoop2
  1841.       break if !draw_path || reach_point
  1842.       draw_path = false
  1843.       check_points = new_end_points
  1844.       new_end_points = []
  1845.       step += 1
  1846.       break if step > KsOfSion::Break_Steps &&
  1847.                !Input.press?(KsOfSion::Find_Path_Key)
  1848.       loop do #loop3 从终点开始反向填充
  1849.         point_x = check_points.shift
  1850.         break if point_x == nil
  1851.         point_y = check_points.shift
  1852.         left_x  = $game_map.round_x(point_x - 1)
  1853.         right_x = $game_map.round_x(point_x + 1)
  1854.         up_y    = $game_map.round_y(point_y - 1)
  1855.         down_y  = $game_map.round_y(point_y + 1)
  1856.         # 判断路径是否连通
  1857.         path_step = step - 1
  1858.         if sheet[left_x, point_y] == path_step
  1859.           chase_path.push(6)
  1860.           chase_point = [point_x, point_y]
  1861.           reversed_chase_point = [left_x, point_y]
  1862.           reach_point = true; break
  1863.         elsif sheet[right_x, point_y] == path_step
  1864.             chase_path.push(4)
  1865.             chase_point = [point_x, point_y]
  1866.             reversed_chase_point = [right_x, point_y]
  1867.             reach_point = true; break
  1868.         elsif sheet[point_x, up_y] == path_step
  1869.             chase_path.push(2)
  1870.             chase_point = [point_x, point_y]
  1871.             reversed_chase_point = [point_x, up_y]
  1872.             reach_point = true; break
  1873.         elsif sheet[point_x, down_y] == path_step
  1874.             chase_path.push(8)
  1875.             chase_point = [point_x, point_y]
  1876.             reversed_chase_point = [point_x, down_y]
  1877.             reach_point = true; break
  1878.         end
  1879.         # 以需要抵达该点的步数填充路径表格 #
  1880.         if sheet[left_x, point_y] == 0                &&
  1881.            $game_map.ship_passable?(left_x, point_y)  &&
  1882.            !collide_with_events?(left_x, point_y)     &&
  1883.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1884.           sheet[left_x, point_y] = step
  1885.           draw_path = true
  1886.           new_end_points.push(left_x, point_y)
  1887.         end
  1888.         if sheet[right_x, point_y] == 0               &&
  1889.            $game_map.ship_passable?(right_x, point_y) &&
  1890.            !collide_with_events?(right_x, point_y)    &&
  1891.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1892.           sheet[right_x, point_y] = step
  1893.           draw_path = true
  1894.           new_end_points.push(right_x, point_y)
  1895.         end
  1896.         if sheet[point_x, up_y] == 0                  &&
  1897.            $game_map.ship_passable?(point_x, up_y)    &&
  1898.            !collide_with_events?(point_x, up_y)       &&
  1899.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1900.           sheet[point_x, up_y] = step
  1901.           draw_path = true
  1902.           new_end_points.push(point_x, up_y)
  1903.         end
  1904.         if sheet[point_x, down_y] == 0                &&
  1905.            $game_map.ship_passable?(point_x, down_y)  &&
  1906.            !collide_with_events?(point_x, down_y)     &&
  1907.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1908.           sheet[point_x, down_y] = step
  1909.           draw_path = true
  1910.           new_end_points.push(point_x, down_y)
  1911.         end
  1912.       end#endOfLoop3
  1913.       break if !draw_path || reach_point
  1914.       step += 1
  1915.     end #endOfLoop1 路径表格填充完毕
  1916.     $mouse_move_sign.transparent = false
  1917.     # 判断指定地点能否抵达
  1918.     if reach_point
  1919.       $mouse_move_sign.direction = 2
  1920.     else
  1921.       not_reach_point
  1922.       return
  1923.     end
  1924.     # 根据路径表格绘制最短移动路径(正向)
  1925.     steps = step / 2 * 2
  1926.     loop_times = step / 2
  1927.     point_x, point_y = chase_point[0], chase_point[1]
  1928.     for i in 2..loop_times # forLoop
  1929.     steps -= 2
  1930.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1931.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1932.         chase_path.push(2)
  1933.         point_y = $game_map.round_y(point_y + 1)
  1934.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1935.         chase_path.push(8)
  1936.         point_y = $game_map.round_y(point_y - 1)
  1937.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1938.         chase_path.push(4)
  1939.         point_x = $game_map.round_x(point_x - 1)
  1940.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1941.         chase_path.push(6)
  1942.         point_x = $game_map.round_x(point_x + 1)
  1943.       end
  1944.     else
  1945.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1946.         chase_path.push(4)
  1947.         point_x = $game_map.round_x(point_x - 1)
  1948.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1949.         chase_path.push(6)
  1950.         point_x = $game_map.round_x(point_x + 1)
  1951.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1952.         chase_path.push(2)
  1953.         point_y = $game_map.round_y(point_y + 1)
  1954.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1955.         chase_path.push(8)
  1956.         point_y = $game_map.round_y(point_y - 1)
  1957.       end
  1958.     end
  1959.     end #endOfForLoop
  1960.     # 如果指定点无法抵达或者登陆
  1961.     return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path)
  1962.     # 根据路径表格绘制最短移动路径(反向)
  1963.     steps = step / 2 * 2 + 1
  1964.     loop_times = step / 2
  1965.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1966.     for i in 1..loop_times # forLoop
  1967.     steps -= 2
  1968.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1969.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1970.         reversed_chase_path.push(6)
  1971.         point_x = $game_map.round_x(point_x - 1)
  1972.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1973.         reversed_chase_path.push(4)
  1974.         point_x = $game_map.round_x(point_x + 1)
  1975.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1976.         reversed_chase_path.push(8)
  1977.         point_y = $game_map.round_y(point_y + 1)
  1978.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1979.         reversed_chase_path.push(2)
  1980.         point_y = $game_map.round_y(point_y - 1)
  1981.       end
  1982.     else
  1983.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1984.         reversed_chase_path.push(8)
  1985.         point_y = $game_map.round_y(point_y + 1)
  1986.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1987.         reversed_chase_path.push(2)
  1988.         point_y = $game_map.round_y(point_y - 1)
  1989.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1990.         reversed_chase_path.push(6)
  1991.         point_x = $game_map.round_x(point_x - 1)
  1992.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1993.         reversed_chase_path.push(4)
  1994.         point_x = $game_map.round_x(point_x + 1)
  1995.       end
  1996.     end
  1997.     end #endOfForLoop
  1998.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1999.   end#ship
  2000.   #--------------------------------------------------------------------------
  2001.   # ● 绘制airship的移动路径 @array[move_directions...]
  2002.   #--------------------------------------------------------------------------
  2003.   def draw_air_path
  2004.     $mouse_move_sign.transparent = false
  2005.     # 准备绘制路径表格
  2006.     sheet = Table.new($game_map.width, $game_map.height)
  2007.     new_check_point = [x, y]; sheet[x, y] = 1
  2008.     reach_point = false;      step = 2
  2009.     loop do #loop1
  2010.      check_point = new_check_point
  2011.      new_check_point = []
  2012.       loop do #loop2
  2013.         point_x = check_point.shift
  2014.         break if point_x == nil
  2015.         point_y = check_point.shift
  2016.         if point_x == @moveto_x && point_y == @moveto_y
  2017.           reach_point = true; break
  2018.         end
  2019.         left_x  = $game_map.round_x(point_x - 1)
  2020.         right_x = $game_map.round_x(point_x + 1)
  2021.         up_y    = $game_map.round_y(point_y - 1)
  2022.         down_y  = $game_map.round_y(point_y + 1)
  2023.         # 以需要抵达该点的步数填充路径表格 #
  2024.         if sheet[left_x, point_y] == 0
  2025.           sheet[left_x, point_y] = step
  2026.           new_check_point.push(left_x, point_y)
  2027.         end
  2028.         if sheet[right_x, point_y] == 0
  2029.           sheet[right_x, point_y] = step
  2030.           new_check_point.push(right_x, point_y)
  2031.         end
  2032.         if sheet[point_x, up_y] == 0
  2033.           sheet[point_x, up_y] = step
  2034.           new_check_point.push(point_x, up_y)
  2035.         end
  2036.         if sheet[point_x, down_y] == 0
  2037.           sheet[point_x, down_y] = step
  2038.           new_check_point.push(point_x, down_y)
  2039.         end
  2040.       end#endOfLoop2
  2041.       break if reach_point
  2042.       step += 1
  2043.     end #endOfLoop1
  2044.     # 根据路径表格绘制最短移动路径 #
  2045.     reversed_chase_path = []; step -= 1
  2046.     point_x, point_y = @moveto_x, @moveto_y
  2047.     for i in 2..step
  2048.     step -= 1
  2049.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  2050.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
  2051.         reversed_chase_path.push(6)
  2052.         point_x = $game_map.round_x(point_x - 1)
  2053.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  2054.         reversed_chase_path.push(4)
  2055.         point_x = $game_map.round_x(point_x + 1)
  2056.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
  2057.         reversed_chase_path.push(8)
  2058.         point_y = $game_map.round_y(point_y + 1)
  2059.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  2060.         reversed_chase_path.push(2)
  2061.         point_y = $game_map.round_y(point_y - 1)
  2062.       end
  2063.     else
  2064.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step
  2065.         reversed_chase_path.push(8)
  2066.         point_y = $game_map.round_y(point_y + 1)
  2067.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  2068.         reversed_chase_path.push(2)
  2069.         point_y = $game_map.round_y(point_y - 1)
  2070.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step
  2071.         reversed_chase_path.push(6)
  2072.         point_x = $game_map.round_x(point_x - 1)
  2073.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  2074.         reversed_chase_path.push(4)
  2075.         point_x = $game_map.round_x(point_x + 1)
  2076.       end
  2077.     end
  2078.     end #endOfForLoop
  2079.     @mouse_move_path = reversed_chase_path.reverse
  2080.   end#airship
  2081.   #--------------------------------------------------------------------------
  2082.   # ● 目标点无法抵达时的处理,用于各路径绘制方法内部
  2083.   #--------------------------------------------------------------------------
  2084.   def not_reach_point
  2085.     $mouse_move_sign.direction = 4
  2086.     dx = 0; dy = 0; dir = 0
  2087.     if @moveto_x - x > 0
  2088.       if @moveto_x - x > $game_map.width - @moveto_x + x &&
  2089.           $game_map.loop_vertical?
  2090.         dx = $game_map.width - @moveto_x + x; dir = 4
  2091.       else
  2092.         dx = @moveto_x - x; dir = 6
  2093.       end
  2094.     else
  2095.       if x - @moveto_x > $game_map.width - x + @moveto_x &&
  2096.           $game_map.loop_vertical?
  2097.         dx = $game_map.width - x + @moveto_x; dir = 6
  2098.       else
  2099.         dx = x - @moveto_x; dir = 4
  2100.       end
  2101.     end
  2102.     if @moveto_y - y > 0
  2103.       if @moveto_y - y > $game_map.height - @moveto_y + y &&
  2104.           $game_map.loop_horizontal?
  2105.         dy = $game_map.height - @moveto_y + y
  2106.         dir = 8 if dy > dx
  2107.       else
  2108.         dy = @moveto_y - y
  2109.         dir = 2 if dy > dx
  2110.       end
  2111.     else
  2112.       if y - @moveto_y > $game_map.height - y + @moveto_y &&
  2113.           $game_map.loop_horizontal?
  2114.         dy = $game_map.height - y + @moveto_y
  2115.         dir = 2 if dy > dx
  2116.       else
  2117.         dy = y - @moveto_y
  2118.         dir = 8 if dy > dx
  2119.       end
  2120.     end
  2121.     @mouse_move_path = [dir, 0] # 0方向用于防止移动过程中触发事件
  2122.   end
  2123.   #--------------------------------------------------------------------------
  2124.   # ● 判断目标点是否能抵达、登陆,用于船只路径绘制
  2125.   #--------------------------------------------------------------------------
  2126.   def landable?(x, y, path)
  2127.     case @vehicle_type
  2128.       when :ship; return $game_map.ship_passable?(x, y) ||
  2129.         $game_map.passable?(x, y, 10 - path[-1])
  2130.       when :boat; return $game_map.boat_passable?(x, y) ||
  2131.         $game_map.passable?(x, y, 10 - path[-1])
  2132.     end
  2133.   end
  2134. end
  2135.  
  2136. #==============================================================================
  2137. # ■ Game_Map
  2138. #------------------------------------------------------------------------------
  2139. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
  2140. #   本类的实例请参考 $game_map 。
  2141. #==============================================================================
  2142. class Game_Map
  2143.   #--------------------------------------------------------------------------
  2144.   # ● 定义实例变量
  2145.   #--------------------------------------------------------------------------
  2146.   attr_reader :mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
  2147.   attr_reader :mouse_map_y # 同上
  2148.   #--------------------------------------------------------------------------
  2149.   # ● 初始化对象
  2150.   #--------------------------------------------------------------------------
  2151.   alias sion_mouse_initialize initialize
  2152.   def initialize
  2153.     sion_mouse_initialize
  2154.     creat_move_sign  ###
  2155.     set_constants
  2156.   end
  2157.   #--------------------------------------------------------------------------
  2158.   # ● 更新画面
  2159.   #     main : 事件解释器更新的标志
  2160.   #--------------------------------------------------------------------------
  2161.   alias sion_mouse_update update
  2162.   def update(main = false)
  2163.     sion_mouse_update(main)
  2164.     update_move_sign
  2165.   end
  2166.   #--------------------------------------------------------------------------
  2167.   # ● 创建显示路径点的事件
  2168.   #--------------------------------------------------------------------------
  2169.   def creat_move_sign
  2170.     $mouse_move_sign = Move_Sign.new
  2171.   end
  2172.   #--------------------------------------------------------------------------
  2173.   # ● 更新显示路径点的事件
  2174.   #--------------------------------------------------------------------------
  2175.   def set_constants
  2176.     @mouse_pos_setted = true
  2177.     @set_pos_prepared = false
  2178.     @mouse_old_x = 0
  2179.     @mouse_old_y = 0
  2180.   end
  2181.   #--------------------------------------------------------------------------
  2182.   # ● 更新显示路径点的事件
  2183.   #--------------------------------------------------------------------------
  2184.   def update_move_sign
  2185.     $mouse_move_sign.update
  2186.   end
  2187.   #--------------------------------------------------------------------------
  2188.   # ● 获取鼠标位于的地图块的x、y坐标
  2189.   #--------------------------------------------------------------------------
  2190.   def get_mouse_map_xy
  2191.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  2192.     @mouse_map_x = round_x((@display_x + mouse_x / 32.0).to_i)
  2193.     @mouse_map_y = round_y((@display_y + mouse_y / 32.0).to_i)
  2194.   end
  2195.   #--------------------------------------------------------------------------
  2196.   # ● 返回地图画面时重设鼠标坐标
  2197.   #--------------------------------------------------------------------------
  2198.   def reset_mouse_pos
  2199.     return if @mouse_pos_setted
  2200.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
  2201.     @mouse_pos_setted = true
  2202.     @set_pos_prepared = false
  2203.   end
  2204.   #--------------------------------------------------------------------------
  2205.   # ● 重设鼠标的坐标
  2206.   #--------------------------------------------------------------------------
  2207.   def prepare_reset_mouse_pos
  2208.     return if @set_pos_prepared
  2209.     @mouse_pos_setted = false
  2210.     @mouse_old_x = Mouse.mouse_x
  2211.     @mouse_old_y = Mouse.mouse_y
  2212.     @set_pos_prepared = true
  2213.   end
  2214. end
  2215.  
  2216. #==============================================================================
  2217. # ■ Spriteset_Map
  2218. #------------------------------------------------------------------------------
  2219. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
  2220. #==============================================================================
  2221. class Spriteset_Map
  2222.   #--------------------------------------------------------------------------
  2223.   # ● 生成路径点精灵
  2224.   #--------------------------------------------------------------------------
  2225.   alias sion_mouse_create_characters create_characters
  2226.   def create_characters
  2227.     sion_mouse_create_characters
  2228.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
  2229.   end
  2230. end
  2231.  
  2232. #==============================================================================
  2233. # ■ Scene_Map
  2234. #------------------------------------------------------------------------------
  2235. #  地图画面
  2236. #==============================================================================
  2237. class Scene_Map < Scene_Base
  2238.   #--------------------------------------------------------------------------
  2239.   # ● 画面更新
  2240.   #--------------------------------------------------------------------------
  2241.   alias sion_mouse_update_scene update_scene
  2242.   def update_scene
  2243.     sion_mouse_update_scene
  2244.     update_mouse_action unless scene_changing?
  2245.   end
  2246.   #--------------------------------------------------------------------------
  2247.   # ● 场所移动前的处理
  2248.   #--------------------------------------------------------------------------
  2249.   alias sion_mouse_pre_transfer pre_transfer
  2250.   def pre_transfer
  2251.     $game_player.reset_move_path
  2252.     sion_mouse_pre_transfer
  2253.   end
  2254.   #--------------------------------------------------------------------------
  2255.   # ● 监听鼠标左键的按下
  2256.   #--------------------------------------------------------------------------
  2257.   def update_mouse_action
  2258.     $game_player.left_button_action if Mouse.press?(0x01)
  2259.   end
  2260. end
  2261.  
  2262. #==============================================================================
  2263. # ■ Scene_File
  2264. #------------------------------------------------------------------------------
  2265. #  存档画面和读档画面共同的父类
  2266. #==============================================================================
  2267. class Scene_File < Scene_MenuBase
  2268.   #--------------------------------------------------------------------------
  2269.   # ● 开始处理
  2270.   #--------------------------------------------------------------------------
  2271.   alias sion_mouse_start start
  2272.   def start
  2273.     sion_mouse_start
  2274.     @move_state = 0
  2275.     set_mouse_pos
  2276.   end
  2277.   #--------------------------------------------------------------------------
  2278.   # ● 更新画面
  2279.   #--------------------------------------------------------------------------
  2280.   alias sion_mouse_update update
  2281.   def update
  2282.     sion_mouse_update
  2283.     Input.dir4.zero? ? set_cursor : set_mouse_pos
  2284.   end
  2285.   #--------------------------------------------------------------------------
  2286.   # ● 更新光标
  2287.   #--------------------------------------------------------------------------
  2288.   def set_cursor
  2289.     @move_state += 1
  2290.     last_index = @index
  2291.     if mouse_which_window == -2
  2292.       if (@move_state - 1) % 6 == 0
  2293.         @index = (@index + 1) % item_max if @index < item_max - 1
  2294.       end
  2295.     elsif mouse_which_window == -1
  2296.       if (@move_state - 1) % 6 == 0
  2297.         @index = (@index - 1 + item_max) % item_max if @index > 0
  2298.       end
  2299.     else
  2300.       @move_state = 0
  2301.       @index = top_index + mouse_which_window
  2302.     end
  2303.     ensure_cursor_visible
  2304.     if @index != last_index
  2305.       @savefile_windows[last_index].selected = false
  2306.       @savefile_windows[@index].selected = true
  2307.     end
  2308.   end
  2309.   #--------------------------------------------------------------------------
  2310.   # ● 判断鼠标位于哪个窗口
  2311.   #--------------------------------------------------------------------------
  2312.   def mouse_which_window
  2313.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  2314.     if mouse_y < @help_window.height + 14
  2315.       mouse_row = -1
  2316.     elsif mouse_y > Graphics.height - 14
  2317.       mouse_row = -2
  2318.     else
  2319.       mouse_row = 4 * (mouse_y - @help_window.height) /
  2320.         (Graphics.height - @help_window.height)
  2321.     end
  2322.     return mouse_row
  2323.   end
  2324.   #--------------------------------------------------------------------------
  2325.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  2326.   #--------------------------------------------------------------------------
  2327.   def set_mouse_pos
  2328.     new_x = 40
  2329.     new_y = @help_window.height + savefile_height * (@index - top_index) + 24
  2330.     Mouse.set_mouse_pos(new_x, new_y)
  2331.   end
  2332. end
  2333.  
  2334. #==============================================================================
  2335. # ■ Game_Event
  2336. #------------------------------------------------------------------------------
  2337. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
  2338. #   在 Game_Map 类的内部使用。
  2339. #==============================================================================
  2340. class Game_Event < Game_Character
  2341.   #--------------------------------------------------------------------------
  2342.   # ● 事件启动
  2343.   #--------------------------------------------------------------------------
  2344.   alias sion_mouse_start start
  2345.   def start
  2346.     return if mouse_start? && !Mouse.press?(0x01)
  2347.     sion_mouse_start
  2348.   end
  2349.   #--------------------------------------------------------------------------
  2350.   # ● 判断事件是否由鼠标启动
  2351.   #--------------------------------------------------------------------------
  2352.   def mouse_start?
  2353.     return false if empty?
  2354.     @list.each do |index|
  2355.       return true if (index.code == 108 || index.code == 408) &&
  2356.         index.parameters[0].include?('鼠标启动')
  2357.     end
  2358.     return false
  2359.   end
  2360. end
  2361.  
  2362. ####泥煤的height
  2363. # @height = height
  2364.  
  2365. class Area_Response
  2366.   attr_accessor :type
  2367.   attr_reader :ox
  2368.   attr_reader :oy
  2369.   attr_reader :width
  2370.   attr_reader :height
  2371.   attr_reader :switch_id
  2372.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
  2373.     @type = type
  2374.     @ox = ox
  2375.     @oy = oy
  2376.     @width = width
  2377.     @height = height
  2378.     @switch_id = switch_id
  2379.   end
  2380. end
  2381.  
  2382. $area_responses = []
  2383.  
  2384. class Scene_Map
  2385.   alias update_mouse_2013421 update_mouse_action
  2386.   def update_mouse_action
  2387.     update_area_response
  2388.     update_mouse_2013421
  2389.   end
  2390.   def update_area_response
  2391.     responses = $area_responses
  2392.     responses.each {|response|
  2393.       ox = response.ox
  2394.       oy = response.oy
  2395.       width = response.width
  2396.       height = response.height
  2397.       switch_id = response.switch_id
  2398.       case response.type
  2399.       when 0
  2400.         if mouse_in_area?(ox, oy, width, height)
  2401.           $game_switches[switch_id] = true
  2402.           $area_responses.delete(response)
  2403.         end
  2404.       when 1
  2405.         if mouse_in_area?(ox, oy, width, height) && Mouse.trigger?(0x01)
  2406.           $game_switches[switch_id] = true
  2407.           $area_responses.delete(response)
  2408.         end
  2409.       when 2
  2410.         if mouse_in_area?(ox, oy, width, height)
  2411.           $game_switches[switch_id] = true
  2412.         else
  2413.           $game_switches[switch_id] = false
  2414.         end
  2415.       when 3
  2416.         if mouse_in_area?((ox - $game_map.display_x) * 32 ,
  2417.             (oy - $game_map.display_y) * 32, width, height)
  2418.           $game_map.events_xy(ox, oy).each {|event|
  2419.           event.start
  2420.           $area_responses.delete(response)
  2421.           return
  2422.           }
  2423.         end
  2424.       when 4
  2425.         if mouse_in_area?((ox - $game_map.display_x) * 32,
  2426.             (oy - $game_map.display_y) * 32, width, height)
  2427.           $game_map.events_xy(ox, oy).each {|event|
  2428.             event.start
  2429.             return
  2430.           }
  2431.         end
  2432.       end
  2433.     }
  2434.   end
  2435.   def mouse_in_area?(ox, oy, width, height)
  2436.     Mouse.mouse_x >= ox && Mouse.mouse_x <= ox + width &&
  2437.     Mouse.mouse_y >= oy && Mouse.mouse_y <= oy + height
  2438.   end
  2439. end
  2440. class Game_Interpreter
  2441.   def area_response(*arg)
  2442.     $area_responses.push(Area_Response.new(*arg))
  2443.   end
  2444. end
RUBY 代码复制
  1. =begin ========================================================================
  2.  
  3.   路径可视化补丁,原作者oott123
  4.  
  5.   Require : Sion Mouse System
  6.  
  7.     * *  [url]http://rpg.blue/forum.php?mod=viewthread&tid=284480[/url]  * *
  8.  
  9.  
  10.     
  11.  
  12.   使用方法:置于 Sion Mouse System 脚本下方
  13.             $PSign.png 路径图片行走图,置于.\Graphics\Characters文件夹
  14.  
  15. =end #=========================================================================
  16.  
  17. $path_sign_amount = 15 #路径最大长度,觉得卡的话就调低一些
  18.  
  19. class Move_Path < Game_Character
  20.   #--------------------------------------------------------------------------
  21.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
  22.   #--------------------------------------------------------------------------
  23.   def init_public_members
  24.     @character_name  = '1' # ★ 路径箭头,置于.\Graphics\Characters文件夹
  25.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
  26.     @move_speed      = 1        # ★ 踏步速度
  27.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
  28.     @opacity         = 120      # ★ 不透明度
  29.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
  30.     @direction       = 4        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
  31.     @priority_type   = 0        # ★ 优先级(与人物同级为:1)
  32.     @direction_fix = true   # 固定朝向
  33.     @move_frequency = 6     # 移动频率
  34.     @walk_anime = true      # 步行动画
  35.     @pattern = 1            # 图案
  36.     @through = true         # 穿透
  37.     @bush_depth = 0         # 草木深度
  38.     @animation_id = 0       # 动画 ID
  39.     @balloon_id = 0         # 心情 ID
  40.     @transparent = true     # 透明
  41.     @id = 0
  42.     @x = 0
  43.     @y = 0
  44.     @real_x = 0
  45.     @real_y = 0
  46.     @tile_id = 0
  47.     unless File.exist?('Graphics/Characters/' + @character_name + '.png')
  48.       @character_name  = 'Actor1' #......
  49.       @character_index = 1
  50.     end
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 定义XXX
  54.   #--------------------------------------------------------------------------
  55.   attr_accessor :transparent
  56.   attr_accessor :direction
  57. end
  58.  
  59. class Game_Player < Game_Character
  60.   #--------------------------------------------------------------------------
  61.   # ● 绘制移动路径 @array[move_directions...]
  62.   #--------------------------------------------------------------------------
  63.   alias path_visualization_draw_move_path draw_move_path
  64.   def draw_move_path
  65.     path_visualization_draw_move_path
  66.     draw_path_on_map
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 由鼠标移动
  70.   #--------------------------------------------------------------------------
  71.   alias path_visualization_move_by_mouse move_by_mouse
  72.   def move_by_mouse
  73.     path_visualization_move_by_mouse
  74.     path_fix_with_move
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 重置移动路径相关信息
  78.   #--------------------------------------------------------------------------
  79.   alias path_visualization_reset_move_path reset_move_path
  80.   def reset_move_path
  81.     path_visualization_reset_move_path
  82.     reset_path_signs
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 把移动路径绘制到地图上
  86.   #--------------------------------------------------------------------------
  87.   def draw_path_on_map
  88.     reset_path_signs
  89.     return if @mouse_move_path[1].zero? # 目标点无法抵达时不绘制
  90.     dirs = @mouse_move_path[0, $path_sign_amount]
  91.     $mouse_move_path[0].moveto(x, y)
  92.     $mouse_move_path[0].direction = dirs[0]
  93.     $mouse_move_path[0].transparent = false
  94.     for index in 1..dirs.size - 1
  95.       $mouse_move_path[index].moveto(      #移动到
  96.         $game_map.round_x_with_direction(  # x坐标
  97.           $mouse_move_path[index - 1].x, dirs[index - 1]),
  98.         $game_map.round_y_with_direction(  # y坐标
  99.           $mouse_move_path[index - 1].y, dirs[index - 1])
  100.         )
  101.       $mouse_move_path[index].direction = dirs[index]
  102.       $mouse_move_path[index].transparent = false
  103.     end
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 移动后更新移动路径
  107.   #--------------------------------------------------------------------------
  108.   def path_fix_with_move
  109.     if $path_sign_amount > @mouse_move_path.size
  110.       $mouse_move_path[@sign_index].transparent = true
  111.     else
  112.       index = (@sign_index - 1) % ($path_sign_amount)
  113.       $mouse_move_path[@sign_index].moveto(                         # 移动到
  114.         $game_map.round_x_with_direction($mouse_move_path[index].x, # x坐标
  115.           @mouse_move_path[$path_sign_amount - 2]),
  116.         $game_map.round_y_with_direction($mouse_move_path[index].y, # y坐标
  117.           @mouse_move_path[$path_sign_amount - 2])
  118.         )
  119.       $mouse_move_path[@sign_index].direction =
  120.         @mouse_move_path[$path_sign_amount - 1]
  121.     end
  122.     @sign_index = (@sign_index + 1) % ($path_sign_amount)
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 消除地图上的移动路线
  126.   #--------------------------------------------------------------------------
  127.   def reset_path_signs
  128.     @sign_index = 0
  129.     $mouse_move_path.each {|sign| sign.transparent = true }
  130.   end
  131. end
  132.  
  133. class Game_Map
  134.   #--------------------------------------------------------------------------
  135.   # ● 初始化对象
  136.   #--------------------------------------------------------------------------
  137.   alias path_visualization_initialize initialize
  138.   def initialize
  139.     path_visualization_initialize
  140.     creat_move_path
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 更新画面
  144.   #     main : 事件解释器更新的标志
  145.   #--------------------------------------------------------------------------
  146.   alias path_visualization_update update
  147.   def update(main = false)
  148.     path_visualization_update(main)
  149.     update_move_path
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 创建显示路径点的事件
  153.   #--------------------------------------------------------------------------
  154.   def creat_move_path
  155.     $mouse_move_path = []
  156.     $path_sign_amount.times { $mouse_move_path.push(Move_Path.new) }
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 更新显示路径点的事件
  160.   #--------------------------------------------------------------------------
  161.   def update_move_path
  162.     $mouse_move_path.each{|sign| sign.update}
  163.   end
  164. end
  165.  
  166. class Spriteset_Map
  167.   #--------------------------------------------------------------------------
  168.   # ● 生成人物精灵
  169.   #--------------------------------------------------------------------------
  170.   alias path_visualization_create_characters create_characters
  171.   def create_characters
  172.     path_visualization_create_characters
  173.     $mouse_move_path.each do |sign|
  174.       @character_sprites.push(Sprite_Character.new(@viewport1, sign))
  175.     end
  176.   end
  177. end

360截图20140128104226660.jpg (9.71 KB, 下载次数: 17)

咋回事嘞

咋回事嘞

点评

这个更新过了,你试试最新的。  发表于 2014-2-26 23:01
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-14 22:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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