查看: 2308|回复: 0

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

[复制链接]
梦石
0
星屑
55
在线时间
87 小时
注册时间
2013-7-11
回帖
75
发表于 2014-1-28 10:54:56 | 显示全部楼层 |阅读模式

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

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

×
我加入了鼠标脚本之后,用鼠标点“开始游戏”就会这样是怎么回事呢?求助,谢谢。阿里嘎多狗杂一马斯!
鼠标脚本为:
  1. =begin #=======================================================================

  2.   Sion Mouse System v1.3
  3.   
  4.   Changlog
  5.   
  6.   2013.6.15 v1.3f
  7.    
  8.     1.3f 卷动地图 bug 修正
  9.    
  10.     1.3e: 逻辑优化;提供解除鼠标固定的接口
  11.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
  12.                               Mouse.unlock_mouse_in_screen 解除锁定

  13.     1.3f: bug修正
  14.   
  15.     1.3d: 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
  16.           关闭菜单时,鼠标是否移动到原来的位置。

  17.     1.3c: 打开菜单、光标移动时鼠标会移动到光标位置处

  18.     1.3b: 修正一些罕见的bug;

  19.     1.3a: 代码小修改;
  20.           加入了鼠标点击启动事件的功能,
  21.           在事件中加入“注释”: 鼠标启动  ,
  22.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
  23.   
  24.   2013.2.12 v1.2

  25.     寻路逻辑优化;
  26.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
  27.     现在支持用鼠标来操作载具了。

  28.   2013.2.8 v1.1

  29.     优化了事件判断,现在可以方便地启动柜台后面的事件;
  30.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
  31.     移动时,路径指示点的绘制更加稳定;
  32.     现在支持默认存档画面的鼠标操作了。


  33.   OrigenVersion
  34.   
  35.     2013.2.7 v1.0

  36.   主要功能

  37.       使用鼠标进行各种操作...
  38.       将鼠标锁定在游戏窗口内
  39.       自动寻路,按住 D 键可以扩大寻路的范围
  40.       双击鼠标进行冲刺
  41.       更改地图卷动方式以适应鼠标移动
  42.       变量输入框改良

  43.   ★ 鼠标指针图片 Cursor.png 放入 Graphics\System 文件夹

  44.   ★ 路径点指示图片 $Arrow.png 放入 Graphics\Characters 文件夹

  45.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭


  46. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★


  47. $no_arrowpic_warn = false   # ★ 设置为false不弹出图片缺失提示

  48. #==============================================================================
  49. # ■ 常数设置
  50. #==============================================================================
  51. module KsOfSion
  52.   Clip_Cursor    = false   # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
  53.   Dbclick_Frame  = 15      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
  54.   New_Scroll     = true    # ★ 更改地图卷动方式,需要关闭设置为false
  55.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
  56.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
  57.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
  58. #                             “30” 是默认显示格子数 长(17) + 宽(13)
  59.   Find_Path_Key  = :Z      # ★ 扩大寻路范围至全地图按键 :Z 对应 D键
  60. #                               RM几个内置的空键位 (:X = A)(:Y = S)(:Z = D)
  61. end

  62. #==============================================================================
  63. # ■ 用来显示路径点的类
  64. #==============================================================================
  65. class Move_Sign < Game_Character
  66.   #--------------------------------------------------------------------------
  67.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
  68.   #--------------------------------------------------------------------------
  69.   def init_public_members
  70.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.\Graphics\Characters文件夹
  71.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
  72.     @move_speed      = 5        # ★ 踏步速度
  73.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
  74.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
  75.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
  76.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
  77.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)


  78. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★


  79.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
  80.     unless File.exist?('Graphics/Characters/' + @character_name + '.png')

  81.       if $no_arrowpic_warn
  82.         Mouse::Show_Cursor.call(1)
  83.         msgbox('未找到文件:Graphics\Characters\\' + @character_name + '.png

  84. “路径指示点”将使用游戏自带图片

  85. 该提示可以在脚本内关闭')
  86.         Mouse::Show_Cursor.call(0)
  87.         $no_arrowpic_warn = false
  88.       end
  89.       @character_name  = '!Flame'
  90.       @character_index = 6

  91.     end
  92.     @direction_fix = false  # 固定朝向
  93.     @move_frequency = 6     # 移动频率
  94.     @walk_anime = true      # 步行动画
  95.     @pattern = 1            # 图案
  96.     @through = true         # 穿透
  97.     @bush_depth = 0         # 草木深度
  98.     @animation_id = 0       # 动画 ID
  99.     @balloon_id = 0         # 心情 ID
  100.     @transparent = true     # 透明
  101.     @id = 0
  102.     @x = 0
  103.     @y = 0
  104.     @real_x = 0
  105.     @real_y = 0
  106.     @tile_id = 0
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● 定义实例变量
  110.   #--------------------------------------------------------------------------
  111.   attr_accessor :direction
  112. end

  113. #==============================================================================
  114. # ■ Module Mouse
  115. #==============================================================================
  116. module Mouse
  117.   #--------------------------------------------------------------------------
  118.   # ● API
  119.   #--------------------------------------------------------------------------
  120.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
  121.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  122.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
  123.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
  124.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
  125.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
  126.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
  127.   Window_Hwnd       = Get_Active_Window.call

  128. class << self
  129.   #--------------------------------------------------------------------------
  130.   # ● 初始化
  131.   #--------------------------------------------------------------------------
  132.   def init
  133.     lock_mouse_in_screen if KsOfSion::Clip_Cursor
  134.     @left_state = 0
  135.     @right_state = 0
  136.     @ck_count = 0 # 帧数计,单击以后从0开始
  137.     @dk_count = 0 # 用于双击的判定
  138.     @clicked = false
  139.     creat_mouse_sprite
  140.     update
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 鼠标指针精灵
  144.   #--------------------------------------------------------------------------
  145.   def creat_mouse_sprite
  146.     @mouse_sprite = Sprite.new
  147.     if File.exist?('Graphics/System/Cursor.png')
  148.       @mouse_sprite.bitmap = Bitmap.new('Graphics/System/Cursor')
  149.     else

  150.       if $no_arrowpic_warn
  151.         msgbox('未找到文件:Graphics\System\Cursor.png

  152. “鼠标指针”将使用游戏自带图片

  153. 该提示可以在脚本内关闭')
  154.       end

  155.       @mouse_sprite.bitmap = Bitmap.new(24, 24)
  156.       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
  157.         Rect.new(5 * 24, 24 * 24, 24, 24))
  158.     end
  159.     @mouse_sprite.z = 9999
  160.     Show_Cursor.call(0)
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● 更新
  164.   #--------------------------------------------------------------------------
  165.   def update
  166.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
  167.     left_state  = Get_Key_State.call(0x01)
  168.     left_state[7] == 1 ? @left_state +=1 : @left_state = 0
  169.     right_state = Get_Key_State.call(0x02)
  170.     right_state[7] == 1 ? @right_state +=1 : @right_state = 0
  171.     update_double_click
  172.     @left_state == 1 ? @ck_count = 0 : @ck_count += 1
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ● 获取鼠标坐标
  176.   #--------------------------------------------------------------------------
  177.   def get_mouse_pos
  178.     arg = [0, 0].pack('ll')
  179.     Get_Cursor_Pos.call(arg)
  180.     Screen_To_Client.call(Window_Hwnd, arg)
  181.     x, y = arg.unpack('ll')
  182.     return x, y
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 将鼠标固定在屏幕内
  186.   #--------------------------------------------------------------------------
  187.   def lock_mouse_in_screen
  188.     arg = [0, 0].pack('ll')
  189.     Screen_To_Client.call(Window_Hwnd, arg)
  190.     x, y  = arg.unpack('ll')
  191.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 解除鼠标固定
  195.   #--------------------------------------------------------------------------
  196.   def unlock_mouse_in_screen
  197.     Clip_Cursor.call(0)
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ● 鼠标双击判定
  201.   #--------------------------------------------------------------------------
  202.   def update_double_click
  203.     @clicked = true if @left_state == 1
  204.     if @dk_count > 0 && @left_state == 1
  205.       @dk_count = 0; @clicked = false
  206.       return @double_click = true
  207.     elsif @clicked
  208.       if @dk_count < KsOfSion::Dbclick_Frame
  209.         @dk_count += 1
  210.       else
  211.         @dk_count = 0; @clicked = false
  212.       end
  213.     end
  214.     @double_click = false
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● 按键被按下就返回true
  218.   #--------------------------------------------------------------------------
  219.   def press?(button)
  220.     case button
  221.       when 0x01; return !@left_state.zero?
  222.       when 0x02; return !@right_state.zero?
  223.     end
  224.     return false
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ● 按键刚被按下则返回true
  228.   #--------------------------------------------------------------------------
  229.   def trigger?(button)
  230.     case button
  231.       when 0x01; return @left_state == 1
  232.       when 0x02; return @right_state == 1
  233.     end
  234.     return false
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
  238.   #--------------------------------------------------------------------------
  239.   def repeat?(button)
  240.     case button
  241.       when 0x01; return @left_state == 1 ||
  242.         (@left_state > 22 && (@left_state % 6).zero?)
  243.       when 0x02; return @right_state == 1 ||
  244.         (@right_state > 22 && (@right_state % 6).zero?)
  245.     end
  246.     return false
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● 判断是否双击鼠标
  250.   #--------------------------------------------------------------------------
  251.   def double_click?
  252.     @double_click
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
  256.   #--------------------------------------------------------------------------
  257.   def click_count
  258.     @ck_count
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ● 获取@left_state(按住左键每一帧+=1)
  262.   #--------------------------------------------------------------------------
  263.   def left_state
  264.     @left_state
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● 获取鼠标的x坐标
  268.   #--------------------------------------------------------------------------
  269.   def mouse_x
  270.     @mouse_sprite.x
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ● 获取鼠标的y坐标
  274.   #--------------------------------------------------------------------------
  275.   def mouse_y
  276.     @mouse_sprite.y
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● 设置鼠标坐标
  280.   #--------------------------------------------------------------------------
  281.   def set_mouse_pos(new_x, new_y)
  282.     arg = [0, 0].pack('ll')
  283.     Screen_To_Client.call(Window_Hwnd, arg)
  284.     x, y  = arg.unpack('ll')
  285.     Set_Cursor_Pos.call(new_x - x, new_y - y)
  286.   end
  287. end #end of: class << self

  288. end

  289. #==============================================================================
  290. # ■ SceneManager
  291. #==============================================================================
  292. class << SceneManager
  293.   #--------------------------------------------------------------------------
  294.   # ● alias
  295.   #--------------------------------------------------------------------------
  296.   unless self.method_defined?(:sion_mouse_run)
  297.     alias_method :sion_mouse_run, :run
  298.     alias_method :sion_mouse_call, :call
  299.     alias_method :sion_mouse_return, :return
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● 运行
  303.   #--------------------------------------------------------------------------
  304.   def run
  305.     Mouse.init
  306.     sion_mouse_run
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   # ● 切换
  310.   #--------------------------------------------------------------------------
  311.   def call(scene_class)
  312.     $game_map.prepare_reset_mouse_pos if @scene.instance_of?(Scene_Map)
  313.     sion_mouse_call(scene_class)
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 返回到上一个场景
  317.   #--------------------------------------------------------------------------
  318.   def return
  319.     sion_mouse_return
  320.     $game_map.reset_mouse_pos if KsOfSion::Menu_Set_Pos &&
  321.       @scene.instance_of?(Scene_Map)
  322.   end
  323. end

  324. #==============================================================================
  325. # ■ Module Input
  326. #==============================================================================
  327. class << Input
  328.   #--------------------------------------------------------------------------
  329.   # ● alias
  330.   #--------------------------------------------------------------------------
  331.   unless self.method_defined?(:sion_mouse_update)
  332.     alias_method :sion_mouse_update,   :update
  333.     alias_method :sion_mouse_press?,   :press?
  334.     alias_method :sion_mouse_trigger?, :trigger?
  335.     alias_method :sion_mouse_repeat?,  :repeat?
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 更新鼠标
  339.   #--------------------------------------------------------------------------
  340.   def update
  341.     Mouse.update
  342.     sion_mouse_update
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # ● 按键被按下就返回true
  346.   #--------------------------------------------------------------------------
  347.   def press?(key)
  348.     return true if sion_mouse_press?(key)
  349.     return Mouse.press?(0x01) if key == :C
  350.     return Mouse.press?(0x02) if key == :B
  351.     return false
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ● 按键刚被按下则返回true
  355.   #--------------------------------------------------------------------------
  356.   def trigger?(key)
  357.     return true if sion_mouse_trigger?(key)
  358.     return Mouse.trigger?(0x01) if key == :C
  359.     return Mouse.trigger?(0x02) if key == :B
  360.     return false
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
  364.   #--------------------------------------------------------------------------
  365.   def repeat?(key)
  366.     return true if sion_mouse_repeat?(key)
  367.     return Mouse.repeat?(0x01) if key == :C
  368.     return Mouse.repeat?(0x02) if key == :B
  369.     return false
  370.   end
  371. end


  372. #==============================================================================
  373. # ■ Window_Selectable
  374. #------------------------------------------------------------------------------
  375. #  拥有光标移动、滚动功能的窗口
  376. #==============================================================================
  377. class Window_Selectable
  378.   #--------------------------------------------------------------------------
  379.   # ● 初始化
  380.   #--------------------------------------------------------------------------
  381.   alias sion_mouse_initialize initialize
  382.   def initialize(x, y, width, height)
  383.     sion_mouse_initialize(x, y, width, height)
  384.     @move_state = 0
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 更新
  388.   #--------------------------------------------------------------------------
  389.   alias sion_mouse_update update
  390.   def update
  391.     sion_mouse_update
  392.     update_mouse_cursor
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # ● 启动后设置鼠标到index位置
  396.   #--------------------------------------------------------------------------
  397.   def activate
  398.     @need_set_pos = true if KsOfSion::Menu_Set_Pos
  399.     super
  400.   end
  401.   #--------------------------------------------------------------------------
  402.   # ● 更新鼠标和光标的位置
  403.   #--------------------------------------------------------------------------
  404.   def update_mouse_cursor
  405.     if active
  406.       if @need_set_pos
  407.         @need_set_pos = nil
  408.         set_mouse_pos
  409.       elsif cursor_movable?
  410.         Input.dir4.zero? ? set_cursor : set_mouse_pos
  411.       end
  412.     end
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
  416.   #--------------------------------------------------------------------------
  417.   def set_cursor
  418.     mouse_row, mouse_col = mouse_window_area
  419.     if    mouse_row == -1
  420.       @move_state += 1 if need_scroll?
  421.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand?
  422.     elsif mouse_row == -2
  423.       @move_state += 1 if need_scroll?
  424.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand?
  425.     elsif mouse_col == -1
  426.       @move_state += 1 if need_scroll?
  427.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand?
  428.     elsif mouse_col == -2
  429.       @move_state += 1 if need_scroll?
  430.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand?
  431.     else
  432.       @move_state = 0
  433.       new_index = (top_row + mouse_row) * col_max + mouse_col
  434.       select(new_index) if new_index < item_max && new_index != @index
  435.     end
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● 判断鼠标位于菜单的第几行、第几列
  439.   #--------------------------------------------------------------------------
  440.   def mouse_window_area
  441.     if viewport.nil? # necessary!
  442.       vp_x, vp_y = 0, 0
  443.     else
  444.       vp_x = viewport.rect.x - viewport.ox
  445.       vp_y = viewport.rect.y - viewport.oy
  446.     end
  447.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  448.     item_x1 = vp_x + x + standard_padding
  449.     item_y1 = vp_y + y + standard_padding
  450.     item_x2 = vp_x + x - standard_padding + width
  451.     item_y2 = vp_y + y - standard_padding + height
  452.     if mouse_x < item_x1
  453.       mouse_col = -1
  454.     elsif mouse_x > item_x2
  455.       mouse_col = -2
  456.     else
  457.       mouse_col = col_max * (mouse_x - item_x1) / (item_x2 - item_x1)
  458.     end
  459.     if mouse_y < item_y1
  460.       mouse_row = -1
  461.     elsif mouse_y > item_y2
  462.       mouse_row = -2
  463.     else
  464.       mouse_row = page_row_max * (mouse_y - item_y1 - 1) / (item_y2 - item_y1)
  465.     end
  466.     return mouse_row, mouse_col
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  470.   #--------------------------------------------------------------------------
  471.   def set_mouse_pos
  472.     if viewport.nil? # necessary!
  473.       vp_x, vp_y = 0, 0
  474.     else
  475.       vp_x = viewport.rect.x - viewport.ox
  476.       vp_y = viewport.rect.y - viewport.oy
  477.     end
  478.     item_x1 = vp_x + x + standard_padding
  479.     item_y1 = vp_y + y + standard_padding
  480.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url] < 0 ? 0 : @index
  481.     row = get_index / col_max - top_row
  482.     col = get_index % col_max
  483.     new_x = item_x1 + item_width * (col + 0.5)
  484.     new_y = item_y1 + item_height * (row + 0.5)
  485.     Mouse.set_mouse_pos(new_x, new_y)
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # ● 判断菜单是否需要卷动
  489.   #--------------------------------------------------------------------------
  490.   def need_scroll?
  491.     item_max > col_max * page_row_max
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 判断是否为水平卷动菜单
  495.   #--------------------------------------------------------------------------
  496.   def is_horzcommand?
  497.     return false
  498.   end
  499. end

  500. class Window_HorzCommand
  501.   #--------------------------------------------------------------------------
  502.   # ● 判断是否为水平卷动菜单
  503.   #--------------------------------------------------------------------------
  504.   def is_horzcommand?
  505.     return true
  506.   end
  507. end

  508. #==============================================================================
  509. # ■ Window_NameInput
  510. #------------------------------------------------------------------------------
  511. #  名字输入画面中,选择文字的窗口。
  512. #==============================================================================
  513. class Window_NameInput
  514.   #--------------------------------------------------------------------------
  515.   # ● 设置列数
  516.   #--------------------------------------------------------------------------
  517.   def col_max
  518.     return 10
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ● 设置填充的Item个数
  522.   #--------------------------------------------------------------------------
  523.   def item_max
  524.     return 90
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 设置填充的Item个数
  528.   #--------------------------------------------------------------------------
  529.   def item_width
  530.     return 32
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ● 判断鼠标位于菜单的第几行、第几列
  534.   #--------------------------------------------------------------------------
  535.   def mouse_window_area
  536.     if viewport.nil?
  537.       vp_x, vp_y = 0, 0
  538.     else
  539.       vp_x = viewport.rect.x - viewport.ox
  540.       vp_y = viewport.rect.y - viewport.oy
  541.     end
  542.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  543.     item_x1 = vp_x + x + standard_padding
  544.     item_y1 = vp_y + y + standard_padding
  545.     item_x2 = vp_x + x - standard_padding + width
  546.     item_y2 = vp_y + y - standard_padding + height
  547.     if mouse_x < item_x1
  548.       mouse_col = -1
  549.     elsif mouse_x > item_x2
  550.       mouse_col = -2
  551.     elsif mouse_x < item_x1 + 160
  552.       mouse_col = (mouse_x - item_x1)/32
  553.     elsif mouse_x > item_x2 - 160
  554.       mouse_col = 9 - (item_x2 - mouse_x)/32
  555.     else
  556.       mouse_col = mouse_x > x + width/2 ? 5 : 4
  557.     end
  558.     if mouse_y < item_y1
  559.       mouse_row = -1
  560.     elsif mouse_y > item_y2
  561.       mouse_row = -2
  562.     else
  563.       mouse_row = page_row_max * (mouse_y - item_y1 - 1)/(item_y2 - item_y1)
  564.     end
  565.     return mouse_row, mouse_col
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  569.   #--------------------------------------------------------------------------
  570.   def set_mouse_pos
  571.     if viewport.nil? # necessary!
  572.       vp_x, vp_y = 0, 0
  573.     else
  574.       vp_x = viewport.rect.x - viewport.ox
  575.       vp_y = viewport.rect.y - viewport.oy
  576.     end
  577.     item_x1 = vp_x + x + standard_padding
  578.     item_y1 = vp_y + y + standard_padding
  579.     get_index = @index < 0 ? 0 : @index
  580.     row = get_index / col_max - top_row
  581.     col = get_index % col_max
  582.     new_x = item_x1 + item_width * (col + 0.5)
  583.     new_y = item_y1 + item_height * (row + 0.5)
  584.     new_x += 14 if col > 4
  585.     Mouse.set_mouse_pos(new_x, new_y)
  586.   end
  587. end

  588. #==============================================================================
  589. # ■ Window_NumberInput
  590. #------------------------------------------------------------------------------
  591. #  重写了数值输入的方法以适应鼠标
  592. #==============================================================================
  593. class Window_NumberInput < Window_Base
  594.   #--------------------------------------------------------------------------
  595.   # ● 定义实例变量
  596.   #--------------------------------------------------------------------------
  597.   attr_reader :extra_window
  598.   #--------------------------------------------------------------------------
  599.   # ● 初始化
  600.   #--------------------------------------------------------------------------
  601.   alias sion_mouse_initialize initialize
  602.   def initialize(arg)
  603.     sion_mouse_initialize(arg)
  604.     create_extra_window
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ● 启动
  608.   #--------------------------------------------------------------------------
  609.   alias sion_mouse_start start
  610.   def start
  611.     sion_mouse_start
  612.     deactivate
  613.     extra_start
  614.   end
  615.   #--------------------------------------------------------------------------
  616.   # ● 创建新的数值输入窗口
  617.   #--------------------------------------------------------------------------
  618.   def create_extra_window
  619.     @extra_window = Window_NumberInput_Ex.new
  620.     @extra_window.x = (Graphics.width - @extra_window.width) / 2
  621.     @extra_window.number_proc  = Proc.new {|n| [url=home.php?mod=space&uid=27178]@Number[/url] = n }
  622.     @extra_window.index_proc   = Proc.new {|n| @index = n }
  623.     @extra_window.close_proc   = Proc.new { close }
  624.     @extra_window.refresh_proc = Proc.new { refresh }
  625.   end
  626.   #--------------------------------------------------------------------------
  627.   # ● 激活新窗口
  628.   #--------------------------------------------------------------------------
  629.   def extra_start
  630.     case $game_message.position
  631.       when 0; @extra_window.y = y + height + 4
  632.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
  633.       when 2; @extra_window.y = y - @extra_window.height - 4
  634.       else  ; @extra_window.y = 8
  635.     end
  636.     @extra_window.variable_id = $game_message.num_input_variable_id
  637.     @extra_window.digits_max  = @digits_max
  638.     @extra_window.number      = @number
  639.     @extra_window.open
  640.     @extra_window.activate
  641.   end
  642.   #--------------------------------------------------------------------------
  643.   # ● 更新
  644.   #--------------------------------------------------------------------------
  645.   def update
  646.     super
  647.     @extra_window.update
  648.     update_cursor
  649.   end
  650.   #--------------------------------------------------------------------------
  651.   # ● 关闭窗口
  652.   #--------------------------------------------------------------------------
  653.   def close
  654.     super
  655.     @extra_window.close
  656.     @extra_window.deactivate
  657.   end
  658. end

  659. #==============================================================================
  660. # ■ Window_NumberInput_Ex
  661. #------------------------------------------------------------------------------
  662. #  新的数值输入窗口(NewClass)
  663. #==============================================================================
  664. class Window_NumberInput_Ex < Window_Selectable
  665.   #--------------------------------------------------------------------------
  666.   # ● 定义实例变量
  667.   #--------------------------------------------------------------------------
  668.   attr_accessor :number_proc
  669.   attr_accessor :index_proc
  670.   attr_accessor :close_proc
  671.   attr_accessor :refresh_proc
  672.   attr_accessor :number
  673.   attr_accessor :digits_max
  674.   attr_accessor :variable_id
  675.   #--------------------------------------------------------------------------
  676.   # ● 数字表
  677.   #--------------------------------------------------------------------------
  678.   TABLE = [  7,  8,  9,
  679.              4,  5,  6,
  680.              1,  2,  3,
  681.             '←',0,'确定',]
  682.   #--------------------------------------------------------------------------
  683.   # ● 初始化对象
  684.   #--------------------------------------------------------------------------
  685.   def initialize
  686.     super(0, 0, 120, fitting_height(4))
  687.     self.openness = 0
  688.     @index = 0
  689.     @number = 0
  690.     @old_window_index = 0
  691.     @digits_max = 0
  692.     12.times {|i| draw_text(item_rect(i), TABLE[i], 1) }
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # ● 获取项目的绘制矩形
  696.   #--------------------------------------------------------------------------
  697.   def item_rect(index)
  698.     rect = Rect.new
  699.     rect.x = index % 3 * 32
  700.     rect.y = index / 3 * line_height
  701.     rect.width = 32
  702.     rect.height = line_height
  703.     return rect
  704.   end
  705.   #--------------------------------------------------------------------------
  706.   # ● 将光标设置到鼠标所在的位置
  707.   #--------------------------------------------------------------------------
  708.   def set_cursor
  709.     mouse_row, mouse_col = mouse_window_area
  710.     if mouse_row >= 0 && mouse_col >= 0
  711.       new_index = mouse_row * 3 + mouse_col
  712.       select(new_index) if new_index <= 11
  713.     end
  714.   end
  715.   #--------------------------------------------------------------------------
  716.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
  717.   #--------------------------------------------------------------------------
  718.   def mouse_window_area
  719.     if viewport.nil?
  720.       vp_x, vp_y = 0, 0
  721.     else
  722.       vp_x = viewport.rect.x - viewport.ox
  723.       vp_y = viewport.rect.y - viewport.oy
  724.     end
  725.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  726.     item_x1 = vp_x + x + standard_padding
  727.     item_y1 = vp_y + y + standard_padding
  728.     item_x2 = vp_x + x - standard_padding + width
  729.     item_y2 = vp_y + y - standard_padding + height
  730.     if mouse_x < item_x1
  731.       mouse_col = -1
  732.     elsif mouse_x > item_x2
  733.       mouse_col = -2
  734.     else
  735.       mouse_col = (mouse_x - item_x1) / 32
  736.     end
  737.     if mouse_y < item_y1
  738.       mouse_row = -1
  739.     elsif mouse_y > item_y2
  740.       mouse_row = -2
  741.     else
  742.       mouse_row = 4 * (mouse_y - item_y1 - 1) / (item_y2 - item_y1)
  743.     end
  744.     return mouse_row, mouse_col
  745.   end
  746.   #--------------------------------------------------------------------------
  747.   # ● 获取文字
  748.   #--------------------------------------------------------------------------
  749.   def get_number
  750.     return false if @index == 9 || @index == 11
  751.     return TABLE[@index]
  752.   end
  753.   #--------------------------------------------------------------------------
  754.   # ● 判定光标位置是否在“退格”上
  755.   #--------------------------------------------------------------------------
  756.   def is_delete?
  757.     @index == 9
  758.   end
  759.   #--------------------------------------------------------------------------
  760.   # ● 判定光标位置是否在“确定”上
  761.   #--------------------------------------------------------------------------
  762.   def is_ok?
  763.     @index == 11
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● 更新光标
  767.   #--------------------------------------------------------------------------
  768.   def update_cursor
  769.     cursor_rect.set(item_rect(@index))
  770.   end
  771.   #--------------------------------------------------------------------------
  772.   # ● 判定光标是否可以移动
  773.   #--------------------------------------------------------------------------
  774.   def cursor_movable?
  775.     active
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # ● 光标向下移动
  779.   #     wrap : 允许循环
  780.   #--------------------------------------------------------------------------
  781.   def cursor_down(wrap)
  782.     if @index < 9 or wrap
  783.       @index = (index + 3) % 12
  784.     end
  785.   end
  786.   #--------------------------------------------------------------------------
  787.   # ● 光标向上移动
  788.   #     wrap : 允许循环
  789.   #--------------------------------------------------------------------------
  790.   def cursor_up(wrap)
  791.     if @index >= 3 or wrap
  792.       @index = (index + 9) % 12
  793.     end
  794.   end
  795.   #--------------------------------------------------------------------------
  796.   # ● 光标向右移动
  797.   #     wrap : 允许循环
  798.   #--------------------------------------------------------------------------
  799.   def cursor_right(wrap)
  800.     if @index % 3 < 2
  801.       @index += 1
  802.     elsif wrap
  803.       @index -= 2
  804.     end
  805.   end
  806.   #--------------------------------------------------------------------------
  807.   # ● 光标向左移动
  808.   #     wrap : 允许循环
  809.   #--------------------------------------------------------------------------
  810.   def cursor_left(wrap)
  811.     if @index % 3 > 0
  812.       @index -= 1
  813.     elsif wrap
  814.       @index += 2
  815.     end
  816.   end
  817.   #--------------------------------------------------------------------------
  818.   # ● 处理光标的移动
  819.   #--------------------------------------------------------------------------
  820.   def process_cursor_move
  821.     super
  822.     update_cursor
  823.   end
  824.   #--------------------------------------------------------------------------
  825.   # ● “确定”、“删除字符”和“取消输入”的处理
  826.   #--------------------------------------------------------------------------
  827.   def process_handling
  828.     return unless open? && active
  829.     process_jump if Input.trigger?(:A)
  830.     process_back if Input.repeat?(:B)
  831.     process_ok   if Input.trigger?(:C)
  832.   end
  833.   #--------------------------------------------------------------------------
  834.   # ● 跳转“确定”
  835.   #--------------------------------------------------------------------------
  836.   def process_jump
  837.     if @index != 11
  838.       @index = 11
  839.       Sound.play_cursor
  840.     end
  841.   end
  842.   #--------------------------------------------------------------------------
  843.   # ● 后退一个字符
  844.   #--------------------------------------------------------------------------
  845.   def process_back
  846.     Sound.play_cancel
  847.     place = 10 ** (@digits_max - 1 - @old_window_index)
  848.     n = (@number / place) % 10
  849.     @number -= n * place
  850.     @number_proc.call(@number)
  851.     @old_window_index -= 1 if @old_window_index > 0
  852.     @index_proc.call(@old_window_index)
  853.     @refresh_proc.call
  854.   end
  855.   #--------------------------------------------------------------------------
  856.   # ● 按下确定键时的处理
  857.   #--------------------------------------------------------------------------
  858.   def process_ok
  859.     if get_number
  860.       Sound.play_cursor
  861.       place = 10 ** (@digits_max - 1 - @old_window_index)
  862.       n = get_number - (@number / place) % 10
  863.       @number += n * place
  864.       @number_proc.call(@number)
  865.       @old_window_index += 1 if @old_window_index < @digits_max - 1
  866.       @index_proc.call(@old_window_index)
  867.       @refresh_proc.call
  868.     elsif is_delete?
  869.       process_back
  870.     elsif is_ok?
  871.       on_input_ok
  872.     end
  873.   end
  874.   #--------------------------------------------------------------------------
  875.   # ● 确定
  876.   #--------------------------------------------------------------------------
  877.   def on_input_ok
  878.     @index = 0
  879.     @old_window_index = 0
  880.     $game_variables[@variable_id] = @number
  881.     Sound.play_ok
  882.     @close_proc.call
  883.   end
  884.   #--------------------------------------------------------------------------
  885.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  886.   #--------------------------------------------------------------------------
  887.   def set_mouse_pos
  888.     if viewport.nil? # necessary!
  889.       vp_x, vp_y = 0, 0
  890.     else
  891.       vp_x = viewport.rect.x - viewport.ox
  892.       vp_y = viewport.rect.y - viewport.oy
  893.     end
  894.     item_x1 = vp_x + x + standard_padding
  895.     item_y1 = vp_y + y + standard_padding
  896.     get_index = @index < 0 ? 0 : @index
  897.     new_x = item_x1 + 32 * (get_index % 3 + 0.5)
  898.     new_y = item_y1 + 24 * (get_index / 3 + 0.5)
  899.     Mouse.set_mouse_pos(new_x, new_y)
  900.   end
  901. end

  902. #==============================================================================
  903. # ■ Window_Message
  904. #------------------------------------------------------------------------------
  905. #  显示文字信息的窗口。
  906. #==============================================================================
  907. class Window_Message < Window_Base
  908.   #--------------------------------------------------------------------------
  909.   # ● 处理数值的输入(覆盖原方法)
  910.   #--------------------------------------------------------------------------
  911.   def input_number
  912.     @number_window.start
  913.     Fiber.yield while @number_window.extra_window.active
  914.   end
  915. end

  916. #==============================================================================
  917. # ■ Window_PartyCommand
  918. #------------------------------------------------------------------------------
  919. #  战斗画面中,选择“战斗/撤退”的窗口。
  920. #==============================================================================
  921. class Window_PartyCommand < Window_Command
  922.   #--------------------------------------------------------------------------
  923.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  924.   #--------------------------------------------------------------------------
  925.   def set_mouse_pos
  926.     if viewport.nil?
  927.       vp_x, vp_y = 0, 0
  928.     else
  929.       #vp_x = viewport.rect.x - viewport.ox
  930.       vp_y = viewport.rect.y - viewport.oy
  931.     end
  932.     item_x1 = x + standard_padding
  933.     item_y1 = vp_y + y + standard_padding
  934.     get_index = @index < 0 ? 0 : @index
  935.     row = get_index / col_max - top_row
  936.     col = get_index % col_max
  937.     new_x = item_x1 + item_width * (col + 0.5)
  938.     new_y = item_y1 + item_height * (row + 0.5)
  939.     Mouse.set_mouse_pos(new_x, new_y)
  940.   end
  941. end

  942. #==============================================================================
  943. # ■ Window_ActorCommand
  944. #------------------------------------------------------------------------------
  945. #  战斗画面中,选择角色行动的窗口。
  946. #==============================================================================
  947. class Window_ActorCommand < Window_Command
  948.   #--------------------------------------------------------------------------
  949.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  950.   #--------------------------------------------------------------------------
  951.   def set_mouse_pos
  952.     if viewport.nil?
  953.       vp_x, vp_y = 0, 0
  954.     else
  955.       #vp_x = viewport.rect.x - viewport.ox
  956.       vp_y = viewport.rect.y - viewport.oy
  957.     end
  958.     item_x1 = Graphics.width - width + standard_padding
  959.     item_y1 = vp_y + y + standard_padding
  960.     get_index = @index < 0 ? 0 : @index
  961.     row = get_index / col_max - top_row
  962.     col = get_index % col_max
  963.     new_x = item_x1 + item_width * (col + 0.5)
  964.     new_y = item_y1 + item_height * (row + 0.5)
  965.     Mouse.set_mouse_pos(new_x, new_y)
  966.   end
  967. end

  968. #==============================================================================
  969. # ■ Game_Player
  970. #------------------------------------------------------------------------------
  971. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
  972. #   本类的实例请参考 $game_player 。
  973. #==============================================================================
  974. class Game_Player < Game_Character
  975.   #--------------------------------------------------------------------------
  976.   # ● 由方向移动(覆盖原方法)
  977.   #--------------------------------------------------------------------------
  978.   def move_by_input
  979.     return if !movable? || $game_map.interpreter.running?
  980.     if Input.dir4 > 0
  981.       move_straight(Input.dir4)
  982.       reset_move_path
  983.     else
  984.       move_by_mouse
  985.     end
  986.   end
  987.   #--------------------------------------------------------------------------
  988.   # ● 非移动中的处理(覆盖原方法)
  989.   #     last_moving : 此前是否正在移动
  990.   #--------------------------------------------------------------------------
  991.   def update_nonmoving(last_moving)
  992.     return if $game_map.interpreter.running?
  993.     if last_moving
  994.       $game_party.on_player_walk
  995.       return if check_touch_event
  996.     end
  997.     if movable? && Input.trigger?(:C)
  998.       return if Mouse.press?(0x01) # 防止按下鼠标左键绘制路径时触发事件或载具切换
  999.       return if get_on_off_vehicle
  1000.       return if check_action_event
  1001.     end
  1002.     update_encounter if last_moving
  1003.   end
  1004.   #--------------------------------------------------------------------------
  1005.   # ● 判定是否跑步状态(覆盖原方法)
  1006.   #--------------------------------------------------------------------------
  1007.   def dash?
  1008.     return false if @move_route_forcing
  1009.     return false if $game_map.disable_dash?
  1010.     return false if vehicle
  1011.     return Input.press?(:A) || @mouse_dash
  1012.   end
  1013.   #--------------------------------------------------------------------------
  1014.   # ● 初始化
  1015.   #--------------------------------------------------------------------------
  1016.   alias sion_mouse_initialize initialize
  1017.   def initialize
  1018.     sion_mouse_initialize
  1019.     reset_move_path
  1020.     @moveto_x = 0
  1021.     @moveto_y = 0
  1022.   end
  1023.   #--------------------------------------------------------------------------
  1024.   # ● 更新
  1025.   #--------------------------------------------------------------------------
  1026.   alias sion_mouse_update update
  1027.   def update
  1028.     sion_mouse_update
  1029.     clear_unreachable_sign
  1030.   end
  1031.   #--------------------------------------------------------------------------
  1032.   # ● 处理卷动
  1033.   #--------------------------------------------------------------------------
  1034.   alias sion_mouse_update_scroll update_scroll
  1035.   def update_scroll(last_real_x, last_real_y)
  1036.     return if $game_map.scrolling?
  1037.     KsOfSion::New_Scroll ? new_update_scroll :
  1038.       sion_mouse_update_scroll(last_real_x, last_real_y)
  1039.   end
  1040.   #--------------------------------------------------------------------------
  1041.   # ● 重置移动路径相关信息
  1042.   #--------------------------------------------------------------------------
  1043.   def reset_move_path
  1044.     @mouse_dash = false
  1045.     @mouse_move_path = []
  1046.     $mouse_move_sign.transparent = true
  1047.   end
  1048.   #--------------------------------------------------------------------------
  1049.   # ● 新的卷动地图方法
  1050.   #--------------------------------------------------------------------------
  1051.   def new_update_scroll
  1052.     horz_speed = 2 ** @move_speed * KsOfSion::Map_Scroll_Spd / Graphics.width
  1053.     vert_speed = 2 ** @move_speed * KsOfSion::Map_Scroll_Spd / Graphics.height
  1054.     ax = $game_map.adjust_x(@real_x)
  1055.     ay = $game_map.adjust_y(@real_y)
  1056.     $game_map.scroll_down (vert_speed * (ay - center_y)) if ay > center_y
  1057.     $game_map.scroll_left (horz_speed * (center_x - ax)) if ax < center_x
  1058.     $game_map.scroll_right(horz_speed * (ax - center_x)) if ax > center_x
  1059.     $game_map.scroll_up   (vert_speed * (center_y - ay)) if ay < center_y
  1060.   end
  1061.   #--------------------------------------------------------------------------
  1062.   # ● 消除不能抵达图标
  1063.   #--------------------------------------------------------------------------
  1064.   def clear_unreachable_sign
  1065.     return if Mouse.press?(0x01)
  1066.     if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 0
  1067.       $mouse_move_sign.transparent = true
  1068.       $mouse_move_sign.direction = 2
  1069.     end
  1070.   end
  1071.   #--------------------------------------------------------------------------
  1072.   # ● 由鼠标移动
  1073.   #--------------------------------------------------------------------------
  1074.   def move_by_mouse
  1075.     unless @mouse_move_path.empty? # 移动路线数组不为空则执行移动
  1076.       dir = @mouse_move_path.shift
  1077.       if passable?(x, y, dir) && !@mouse_move_path.empty?
  1078.         move_straight(dir)
  1079.       elsif @mouse_move_path.empty? # 判断是否是最后一步
  1080.         x2 = $game_map.round_x_with_direction(x, dir)
  1081.         y2 = $game_map.round_y_with_direction(y, dir)
  1082.         move_straight(dir) unless dir.zero?
  1083.         unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具
  1084.           check_event_trigger_there([0,1,2])
  1085.           get_on_off_vehicle unless $game_map.setup_starting_event
  1086.         end
  1087.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2
  1088.         @mouse_dash = false
  1089.       elsif @mouse_move_path[0].zero? # 目标点无法抵达,调整朝向→目标点
  1090.         @mouse_move_path.shift
  1091.         @direction = dir
  1092.         @mouse_dash = false
  1093.       else
  1094.         draw_move_path
  1095.       end
  1096.     end
  1097.   end
  1098.   #--------------------------------------------------------------------------
  1099.   # ● 地图界面按下鼠标左键的处理
  1100.   #--------------------------------------------------------------------------
  1101.   def left_button_action
  1102.     return if !drawable? || $game_map.interpreter.running?
  1103.     get_mouse_pos
  1104.     $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图
  1105.     if @shift_event
  1106.       if Mouse.trigger?(0x01)
  1107.         @shift_event.jump(@moveto_x - @shift_event.x,
  1108.           @moveto_y - @shift_event.y)
  1109.         @shift_event = nil
  1110.       end
  1111.       return
  1112.     end
  1113.     if @moveto_x == x && @moveto_y == y # 判断目标点是否与角色重合
  1114.       return if moving? || (vehicle && !vehicle.movable?)
  1115.       check_event_trigger_here([0]) # 判断是否触发重合点事件
  1116.       get_on_off_vehicle if !$game_map.setup_starting_event &&
  1117.         $game_map.airship.pos?(x, y)  # 判断是否要上、下飞艇
  1118.       return
  1119.     end
  1120.     # 判断是否用鼠标启动事件
  1121.     $game_map.events_xy(@moveto_x, @moveto_y).each do |event|
  1122.       if event.mouse_start?
  1123.         reset_move_path
  1124.         event.start if Mouse.trigger?(0x01)
  1125.         return
  1126.       end
  1127.     end
  1128.     @mouse_dash = true if Mouse.double_click? # 双击冲刺
  1129.     return if Mouse.left_state % 10 != 1 # 按住鼠标左键10帧绘制1次路径
  1130.     for i in 1..4 # 判断目标点是否为角色周围四点
  1131.       if x == $game_map.round_x_with_direction(@moveto_x, i * 2) &&
  1132.          y == $game_map.round_y_with_direction(@moveto_y, i * 2)
  1133.       $mouse_move_sign.transparent = true
  1134.       @mouse_move_path = [10 - i * 2] if Mouse.trigger?(0x01)
  1135.       return; end
  1136.     end
  1137.     draw_move_path
  1138.   end
  1139.   #--------------------------------------------------------------------------
  1140.   # ● 取得鼠标处对应地图坐标点
  1141.   #--------------------------------------------------------------------------
  1142.   def get_mouse_pos
  1143.     $game_map.get_mouse_map_xy
  1144.     @moveto_x = $game_map.mouse_map_x
  1145.     @moveto_y = $game_map.mouse_map_y
  1146.     #mouse_x, mouse_y = Mouse.get_mouse_pos
  1147.     #@moveto_x = $game_map.round_x(x + (mouse_x -
  1148.     #  ($game_map.adjust_x(x) * 32 + 16).to_i + 16) / 32)
  1149.     #@moveto_y = $game_map.round_y(y + 1 + (mouse_y -
  1150.     #  ($game_map.adjust_y(y) * 32 + 16).to_i - 16) / 32)
  1151.   end
  1152.   #--------------------------------------------------------------------------
  1153.   # ● 绘制移动路径 @array[move_directions...]
  1154.   #--------------------------------------------------------------------------
  1155.   def draw_move_path
  1156.     #temp = Time.now
  1157.     case @vehicle_type
  1158.     when :walk
  1159.       draw_walk_path
  1160.     when :boat
  1161.       draw_boat_path
  1162.     when :ship
  1163.       draw_ship_path
  1164.     when :airship
  1165.       draw_air_path
  1166.     end
  1167.     #p (Time.now.to_f - temp.to_f) # 测试效率
  1168.   end
  1169.   #--------------------------------------------------------------------------
  1170.   # ● 判定是否可以绘制移动路径
  1171.   #--------------------------------------------------------------------------
  1172.   def drawable?
  1173.     return false if @move_route_forcing || @followers.gathering?
  1174.     return false if @vehicle_getting_on || @vehicle_getting_off
  1175.     return false if $game_message.busy? || $game_message.visible
  1176.     return true
  1177.   end
  1178.   #--------------------------------------------------------------------------
  1179.   # ● 绘制walk移动路径 @array[move_directions...]
  1180.   #--------------------------------------------------------------------------
  1181.   def draw_walk_path
  1182.     # 准备绘制路径表格
  1183.     sheet = Table.new($game_map.width, $game_map.height)
  1184.     reversed_chase_path  = []; chase_path  = []
  1185.     reversed_chase_point = []; chase_point = []
  1186.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1187.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1188.     reach_point = false
  1189.     step = 3
  1190.     loop do #loop1 开始填充表格
  1191.      draw_path = false
  1192.      check_points = new_start_points
  1193.      new_start_points = []
  1194.       loop do #loop2 从起点开始正向填充
  1195.         point_x = check_points.shift
  1196.         break if point_x == nil
  1197.         point_y = check_points.shift
  1198.         left_x  = $game_map.round_x(point_x - 1)
  1199.         right_x = $game_map.round_x(point_x + 1)
  1200.         up_y    = $game_map.round_y(point_y - 1)
  1201.         down_y  = $game_map.round_y(point_y + 1)
  1202.                     # 判断路径是否连通
  1203.         path_step = step - 1
  1204.         if sheet[left_x, point_y] == path_step     &&
  1205.            $game_map.passable?(left_x, point_y, 6) &&
  1206.            $game_map.passable?(point_x, point_y, 4)
  1207.           chase_path.push(4)
  1208.           chase_point = [left_x, point_y]
  1209.           reversed_chase_point = [point_x, point_y]
  1210.           reach_point = true; break
  1211.         elsif sheet[right_x, point_y] == path_step     &&
  1212.               $game_map.passable?(right_x, point_y, 4) &&
  1213.               $game_map.passable?(point_x, point_y, 6)
  1214.             chase_path.push(6)
  1215.             chase_point = [right_x, point_y]
  1216.             reversed_chase_point = [point_x, point_y]
  1217.             reach_point = true; break
  1218.         elsif sheet[point_x, up_y] == path_step     &&
  1219.               $game_map.passable?(point_x, up_y, 2) &&
  1220.               $game_map.passable?(point_x, point_y, 8)
  1221.             chase_path.push(8)
  1222.             chase_point = [point_x, up_y]
  1223.             reversed_chase_point = [point_x, point_y]
  1224.             reach_point = true; break
  1225.         elsif sheet[point_x, down_y] == path_step     &&
  1226.               $game_map.passable?(point_x, down_y, 8) &&
  1227.               $game_map.passable?(point_x, point_y, 2)
  1228.             chase_path.push(2)
  1229.             chase_point = [point_x, down_y]
  1230.             reversed_chase_point = [point_x, point_y]
  1231.             reach_point = true; break
  1232.         end
  1233.         # 以需要抵达该点的步数填充路径表格 #
  1234.         if sheet[left_x, point_y] == 0              &&
  1235.            $game_map.passable?(left_x, point_y, 6)  &&
  1236.            !collide_with_events?(left_x, point_y)   &&
  1237.            $game_map.passable?(point_x, point_y, 4) &&
  1238.            !collide_with_vehicles?(left_x, point_y) #judge_end
  1239.           sheet[left_x, point_y] = step
  1240.           draw_path = true
  1241.           new_start_points.push(left_x, point_y)
  1242.         end
  1243.         if sheet[right_x, point_y] == 0             &&
  1244.            $game_map.passable?(right_x, point_y, 4) &&
  1245.            !collide_with_events?(right_x, point_y)  &&
  1246.            $game_map.passable?(point_x, point_y, 6) &&
  1247.            !collide_with_vehicles?(right_x, point_y)#judge_end
  1248.           sheet[right_x, point_y] = step
  1249.           draw_path = true
  1250.           new_start_points.push(right_x, point_y)
  1251.         end
  1252.         if sheet[point_x, up_y] == 0                &&
  1253.            $game_map.passable?(point_x, up_y, 2)    &&
  1254.            !collide_with_events?(point_x, up_y)     &&
  1255.            $game_map.passable?(point_x, point_y, 8) &&
  1256.            !collide_with_vehicles?(point_x, up_y)   #judge_end
  1257.           sheet[point_x, up_y] = step
  1258.           draw_path = true
  1259.           new_start_points.push(point_x, up_y)
  1260.         end
  1261.         if sheet[point_x, down_y] == 0              &&
  1262.            $game_map.passable?(point_x, down_y, 8)  &&
  1263.            !collide_with_events?(point_x, down_y)   &&
  1264.            $game_map.passable?(point_x, point_y, 2) &&
  1265.            !collide_with_vehicles?(point_x, down_y) #judge_end
  1266.           sheet[point_x, down_y] = step
  1267.           draw_path = true
  1268.           new_start_points.push(point_x, down_y)
  1269.         end
  1270.       end#endOfLoop2
  1271.       break if !draw_path || reach_point
  1272.       draw_path = false
  1273.       check_points = new_end_points
  1274.       new_end_points = []
  1275.       step += 1
  1276.       break if step > KsOfSion::Break_Steps &&
  1277.                !Input.press?(KsOfSion::Find_Path_Key)
  1278.       loop do #loop3 从终点开始反向填充
  1279.         point_x = check_points.shift
  1280.         break if point_x == nil
  1281.         point_y = check_points.shift
  1282.         left_x  = $game_map.round_x(point_x - 1)
  1283.         right_x = $game_map.round_x(point_x + 1)
  1284.         up_y    = $game_map.round_y(point_y - 1)
  1285.         down_y  = $game_map.round_y(point_y + 1)
  1286.         # 判断路径是否连通
  1287.         path_step = step - 1
  1288.         if sheet[left_x, point_y] == path_step     &&
  1289.            $game_map.passable?(left_x, point_y, 6) &&
  1290.            $game_map.passable?(point_x, point_y, 4)
  1291.           chase_path.push(6)
  1292.           chase_point = [point_x, point_y]
  1293.           reversed_chase_point = [left_x, point_y]
  1294.           reach_point = true; break
  1295.         elsif sheet[right_x, point_y] == path_step     &&
  1296.               $game_map.passable?(right_x, point_y, 4) &&
  1297.               $game_map.passable?(point_x, point_y, 6)
  1298.             chase_path.push(4)
  1299.             chase_point = [point_x, point_y]
  1300.             reversed_chase_point = [right_x, point_y]
  1301.             reach_point = true; break
  1302.         elsif sheet[point_x, up_y] == path_step     &&
  1303.               $game_map.passable?(point_x, up_y, 2) &&
  1304.               $game_map.passable?(point_x, point_y, 8)
  1305.             chase_path.push(2)
  1306.             chase_point = [point_x, point_y]
  1307.             reversed_chase_point = [point_x, up_y]
  1308.             reach_point = true; break
  1309.         elsif sheet[point_x, down_y] == path_step     &&
  1310.               $game_map.passable?(point_x, down_y, 8) &&
  1311.               $game_map.passable?(point_x, point_y, 2)
  1312.             chase_path.push(8)
  1313.             chase_point = [point_x, point_y]
  1314.             reversed_chase_point = [point_x, down_y]
  1315.             reach_point = true; break
  1316.         end
  1317.         # 以需要抵达该点的步数填充路径表格 #
  1318.         if sheet[left_x, point_y] == 0              &&
  1319.            $game_map.passable?(left_x, point_y, 6)  &&
  1320.            !collide_with_events?(left_x, point_y)   &&
  1321.            $game_map.passable?(point_x, point_y, 4) &&
  1322.            !collide_with_vehicles?(left_x, point_y) #judge_end
  1323.           sheet[left_x, point_y] = step
  1324.           draw_path = true
  1325.           new_end_points.push(left_x, point_y)
  1326.         end
  1327.         if sheet[right_x, point_y] == 0             &&
  1328.            $game_map.passable?(right_x, point_y, 4) &&
  1329.            !collide_with_events?(right_x, point_y)  &&
  1330.            $game_map.passable?(point_x, point_y, 6) &&
  1331.            !collide_with_vehicles?(right_x, point_y)#judge_end
  1332.           sheet[right_x, point_y] = step
  1333.           draw_path = true
  1334.           new_end_points.push(right_x, point_y)
  1335.         end
  1336.         if sheet[point_x, up_y] == 0                &&
  1337.            $game_map.passable?(point_x, up_y, 2)    &&
  1338.            !collide_with_events?(point_x, up_y)     &&
  1339.            $game_map.passable?(point_x, point_y, 8) &&
  1340.            !collide_with_vehicles?(point_x, up_y)   #judge_end
  1341.           sheet[point_x, up_y] = step
  1342.           draw_path = true
  1343.           new_end_points.push(point_x, up_y)
  1344.         end
  1345.         if sheet[point_x, down_y] == 0              &&
  1346.            $game_map.passable?(point_x, down_y, 8)  &&
  1347.            !collide_with_events?(point_x, down_y)   &&
  1348.            $game_map.passable?(point_x, point_y, 2) &&
  1349.            !collide_with_vehicles?(point_x, down_y) #judge_end
  1350.           sheet[point_x, down_y] = step
  1351.           draw_path = true
  1352.           new_end_points.push(point_x, down_y)
  1353.         end
  1354.       end#endOfLoop3
  1355.       break if !draw_path || reach_point
  1356.       step += 1
  1357.     end #endOfLoop1 路径表格填充完毕
  1358.     $mouse_move_sign.transparent = false
  1359.     # 判断指定地点能否抵达
  1360.     if reach_point
  1361.       $mouse_move_sign.direction = 2
  1362.     else
  1363.       not_reach_point
  1364.       return
  1365.     end
  1366.     # 根据路径表格绘制最短移动路径(反向)
  1367.     steps = step / 2 * 2 + 1
  1368.     loop_times = step / 2
  1369.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1370.     for i in 1..loop_times # forLoop
  1371.     steps -= 2
  1372.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs #反过来?蛋疼了……
  1373.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1374.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1375.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1376.         reversed_chase_path.push(6)
  1377.         point_x = $game_map.round_x(point_x - 1)
  1378.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1379.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1380.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1381.         reversed_chase_path.push(4)
  1382.         point_x = $game_map.round_x(point_x + 1)
  1383.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1384.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1385.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1386.         reversed_chase_path.push(8)
  1387.         point_y = $game_map.round_y(point_y + 1)
  1388.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1389.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1390.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1391.         reversed_chase_path.push(2)
  1392.         point_y = $game_map.round_y(point_y - 1)
  1393.       end
  1394.     else
  1395.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1396.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1397.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1398.         reversed_chase_path.push(8)
  1399.         point_y = $game_map.round_y(point_y + 1)
  1400.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1401.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1402.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1403.         reversed_chase_path.push(2)
  1404.         point_y = $game_map.round_y(point_y - 1)
  1405.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1406.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1407.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1408.         reversed_chase_path.push(6)
  1409.         point_x = $game_map.round_x(point_x - 1)
  1410.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1411.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1412.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1413.         reversed_chase_path.push(4)
  1414.         point_x = $game_map.round_x(point_x + 1)
  1415.       end
  1416.     end
  1417.     end #endOfForLoop
  1418.     # 根据路径表格绘制最短移动路径(正向)
  1419.     steps = step / 2 * 2
  1420.     loop_times = step / 2
  1421.     point_x, point_y = chase_point[0], chase_point[1]
  1422.     for i in 2..loop_times # forLoop
  1423.     steps -= 2
  1424.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1425.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1426.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1427.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1428.         chase_path.push(2)
  1429.         point_y = $game_map.round_y(point_y + 1)
  1430.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1431.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1432.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1433.         chase_path.push(8)
  1434.         point_y = $game_map.round_y(point_y - 1)
  1435.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1436.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1437.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1438.         chase_path.push(4)
  1439.         point_x = $game_map.round_x(point_x - 1)
  1440.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1441.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1442.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1443.         chase_path.push(6)
  1444.         point_x = $game_map.round_x(point_x + 1)
  1445.       end
  1446.     else
  1447.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1448.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1449.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1450.         chase_path.push(4)
  1451.         point_x = $game_map.round_x(point_x - 1)
  1452.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1453.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1454.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1455.         chase_path.push(6)
  1456.         point_x = $game_map.round_x(point_x + 1)
  1457.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1458.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1459.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1460.         chase_path.push(2)
  1461.         point_y = $game_map.round_y(point_y + 1)
  1462.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1463.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1464.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1465.         chase_path.push(8)
  1466.         point_y = $game_map.round_y(point_y - 1)
  1467.       end
  1468.     end
  1469.     end #endOfForLoop
  1470.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1471.   end#walk
  1472.   #--------------------------------------------------------------------------
  1473.   # ● 绘制boat的移动路径 @array[move_directions...]
  1474.   #--------------------------------------------------------------------------
  1475.   def draw_boat_path
  1476.     # 准备绘制路径表格
  1477.     sheet = Table.new($game_map.width, $game_map.height)
  1478.     reversed_chase_path  = []; chase_path  = []
  1479.     reversed_chase_point = []; chase_point = []
  1480.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1481.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1482.     reach_point = false
  1483.     step = 3
  1484.     loop do #loop1 开始填充表格
  1485.      draw_path = false
  1486.      check_points = new_start_points
  1487.      new_start_points = []
  1488.       loop do #loop2 从起点开始正向填充
  1489.         point_x = check_points.shift
  1490.         break if point_x == nil
  1491.         point_y = check_points.shift
  1492.         left_x  = $game_map.round_x(point_x - 1)
  1493.         right_x = $game_map.round_x(point_x + 1)
  1494.         up_y    = $game_map.round_y(point_y - 1)
  1495.         down_y  = $game_map.round_y(point_y + 1)
  1496.                     # 判断路径是否连通
  1497.         path_step = step - 1
  1498.         if sheet[left_x, point_y] == path_step
  1499.           chase_path.push(4)
  1500.           chase_point = [left_x, point_y]
  1501.           reversed_chase_point = [point_x, point_y]
  1502.           reach_point = true; break
  1503.         elsif sheet[right_x, point_y] == path_step
  1504.             chase_path.push(6)
  1505.             chase_point = [right_x, point_y]
  1506.             reversed_chase_point = [point_x, point_y]
  1507.             reach_point = true; break
  1508.         elsif sheet[point_x, up_y] == path_step
  1509.             chase_path.push(8)
  1510.             chase_point = [point_x, up_y]
  1511.             reversed_chase_point = [point_x, point_y]
  1512.             reach_point = true; break
  1513.         elsif sheet[point_x, down_y] == path_step
  1514.             chase_path.push(2)
  1515.             chase_point = [point_x, down_y]
  1516.             reversed_chase_point = [point_x, point_y]
  1517.             reach_point = true; break
  1518.         end
  1519.         # 以需要抵达该点的步数填充路径表格 #
  1520.         if sheet[left_x, point_y] == 0                &&
  1521.            $game_map.boat_passable?(left_x, point_y)  &&
  1522.            !collide_with_events?(left_x, point_y)     &&
  1523.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1524.           sheet[left_x, point_y] = step
  1525.           draw_path = true
  1526.           new_start_points.push(left_x, point_y)
  1527.         end
  1528.         if sheet[right_x, point_y] == 0               &&
  1529.            $game_map.boat_passable?(right_x, point_y) &&
  1530.            !collide_with_events?(right_x, point_y)    &&
  1531.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1532.           sheet[right_x, point_y] = step
  1533.           draw_path = true
  1534.           new_start_points.push(right_x, point_y)
  1535.         end
  1536.         if sheet[point_x, up_y] == 0                  &&
  1537.            $game_map.boat_passable?(point_x, up_y)    &&
  1538.            !collide_with_events?(point_x, up_y)       &&
  1539.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1540.           sheet[point_x, up_y] = step
  1541.           draw_path = true
  1542.           new_start_points.push(point_x, up_y)
  1543.         end
  1544.         if sheet[point_x, down_y] == 0                &&
  1545.            $game_map.boat_passable?(point_x, down_y)  &&
  1546.            !collide_with_events?(point_x, down_y)     &&
  1547.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1548.           sheet[point_x, down_y] = step
  1549.           draw_path = true
  1550.           new_start_points.push(point_x, down_y)
  1551.         end
  1552.       end#endOfLoop2
  1553.       break if !draw_path || reach_point
  1554.       draw_path = false
  1555.       check_points = new_end_points
  1556.       new_end_points = []
  1557.       step += 1
  1558.       break if step > KsOfSion::Break_Steps &&
  1559.                !Input.press?(KsOfSion::Find_Path_Key)
  1560.       loop do #loop3 从终点开始反向填充
  1561.         point_x = check_points.shift
  1562.         break if point_x == nil
  1563.         point_y = check_points.shift
  1564.         left_x  = $game_map.round_x(point_x - 1)
  1565.         right_x = $game_map.round_x(point_x + 1)
  1566.         up_y    = $game_map.round_y(point_y - 1)
  1567.         down_y  = $game_map.round_y(point_y + 1)
  1568.         # 判断路径是否连通
  1569.         path_step = step - 1
  1570.         if sheet[left_x, point_y] == path_step
  1571.           chase_path.push(6)
  1572.           chase_point = [point_x, point_y]
  1573.           reversed_chase_point = [left_x, point_y]
  1574.           reach_point = true; break
  1575.         elsif sheet[right_x, point_y] == path_step
  1576.             chase_path.push(4)
  1577.             chase_point = [point_x, point_y]
  1578.             reversed_chase_point = [right_x, point_y]
  1579.             reach_point = true; break
  1580.         elsif sheet[point_x, up_y] == path_step
  1581.             chase_path.push(2)
  1582.             chase_point = [point_x, point_y]
  1583.             reversed_chase_point = [point_x, up_y]
  1584.             reach_point = true; break
  1585.         elsif sheet[point_x, down_y] == path_step
  1586.             chase_path.push(8)
  1587.             chase_point = [point_x, point_y]
  1588.             reversed_chase_point = [point_x, down_y]
  1589.             reach_point = true; break
  1590.         end
  1591.         # 以需要抵达该点的步数填充路径表格 #
  1592.         if sheet[left_x, point_y] == 0                &&
  1593.            $game_map.boat_passable?(left_x, point_y)  &&
  1594.            !collide_with_events?(left_x, point_y)     &&
  1595.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1596.           sheet[left_x, point_y] = step
  1597.           draw_path = true
  1598.           new_end_points.push(left_x, point_y)
  1599.         end
  1600.         if sheet[right_x, point_y] == 0               &&
  1601.            $game_map.boat_passable?(right_x, point_y) &&
  1602.            !collide_with_events?(right_x, point_y)    &&
  1603.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1604.           sheet[right_x, point_y] = step
  1605.           draw_path = true
  1606.           new_end_points.push(right_x, point_y)
  1607.         end
  1608.         if sheet[point_x, up_y] == 0                  &&
  1609.            $game_map.boat_passable?(point_x, up_y)    &&
  1610.            !collide_with_events?(point_x, up_y)       &&
  1611.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1612.           sheet[point_x, up_y] = step
  1613.           draw_path = true
  1614.           new_end_points.push(point_x, up_y)
  1615.         end
  1616.         if sheet[point_x, down_y] == 0                &&
  1617.            $game_map.boat_passable?(point_x, down_y)  &&
  1618.            !collide_with_events?(point_x, down_y)     &&
  1619.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1620.           sheet[point_x, down_y] = step
  1621.           draw_path = true
  1622.           new_end_points.push(point_x, down_y)
  1623.         end
  1624.       end#endOfLoop3
  1625.       break if !draw_path || reach_point
  1626.       step += 1
  1627.     end #endOfLoop1 路径表格填充完毕
  1628.     $mouse_move_sign.transparent = false
  1629.     # 判断指定地点能否抵达
  1630.     if reach_point
  1631.       $mouse_move_sign.direction = 2
  1632.     else
  1633.       not_reach_point
  1634.       return
  1635.     end
  1636.     # 根据路径表格绘制最短移动路径(正向)
  1637.     steps = step / 2 * 2
  1638.     loop_times = step / 2
  1639.     point_x, point_y = chase_point[0], chase_point[1]
  1640.     for i in 2..loop_times # forLoop
  1641.     steps -= 2
  1642.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1643.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1644.         chase_path.push(2)
  1645.         point_y = $game_map.round_y(point_y + 1)
  1646.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1647.         chase_path.push(8)
  1648.         point_y = $game_map.round_y(point_y - 1)
  1649.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1650.         chase_path.push(4)
  1651.         point_x = $game_map.round_x(point_x - 1)
  1652.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1653.         chase_path.push(6)
  1654.         point_x = $game_map.round_x(point_x + 1)
  1655.       end
  1656.     else
  1657.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1658.         chase_path.push(4)
  1659.         point_x = $game_map.round_x(point_x - 1)
  1660.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1661.         chase_path.push(6)
  1662.         point_x = $game_map.round_x(point_x + 1)
  1663.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1664.         chase_path.push(2)
  1665.         point_y = $game_map.round_y(point_y + 1)
  1666.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1667.         chase_path.push(8)
  1668.         point_y = $game_map.round_y(point_y - 1)
  1669.       end
  1670.     end
  1671.     end #endOfForLoop
  1672.     # 如果指定点无法抵达或者登陆
  1673.     return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path)
  1674.     # 根据路径表格绘制最短移动路径(反向)
  1675.     steps = step / 2 * 2 + 1
  1676.     loop_times = step / 2
  1677.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1678.     for i in 1..loop_times # forLoop
  1679.     steps -= 2
  1680.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1681.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1682.         reversed_chase_path.push(6)
  1683.         point_x = $game_map.round_x(point_x - 1)
  1684.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1685.         reversed_chase_path.push(4)
  1686.         point_x = $game_map.round_x(point_x + 1)
  1687.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1688.         reversed_chase_path.push(8)
  1689.         point_y = $game_map.round_y(point_y + 1)
  1690.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1691.         reversed_chase_path.push(2)
  1692.         point_y = $game_map.round_y(point_y - 1)
  1693.       end
  1694.     else
  1695.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1696.         reversed_chase_path.push(8)
  1697.         point_y = $game_map.round_y(point_y + 1)
  1698.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1699.         reversed_chase_path.push(2)
  1700.         point_y = $game_map.round_y(point_y - 1)
  1701.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1702.         reversed_chase_path.push(6)
  1703.         point_x = $game_map.round_x(point_x - 1)
  1704.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1705.         reversed_chase_path.push(4)
  1706.         point_x = $game_map.round_x(point_x + 1)
  1707.       end
  1708.     end
  1709.     end #endOfForLoop
  1710.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1711.   end#boat
  1712.   #--------------------------------------------------------------------------
  1713.   # ● 绘制ship的移动路径 @array[move_directions...]
  1714.   #--------------------------------------------------------------------------
  1715.   def draw_ship_path
  1716.     # 准备绘制路径表格
  1717.     sheet = Table.new($game_map.width, $game_map.height)
  1718.     reversed_chase_path  = []; chase_path  = []
  1719.     reversed_chase_point = []; chase_point = []
  1720.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1721.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1722.     reach_point = false
  1723.     step = 3
  1724.     loop do #loop1 开始填充表格
  1725.      draw_path = false
  1726.      check_points = new_start_points
  1727.      new_start_points = []
  1728.       loop do #loop2 从起点开始正向填充
  1729.         point_x = check_points.shift
  1730.         break if point_x == nil
  1731.         point_y = check_points.shift
  1732.         left_x  = $game_map.round_x(point_x - 1)
  1733.         right_x = $game_map.round_x(point_x + 1)
  1734.         up_y    = $game_map.round_y(point_y - 1)
  1735.         down_y  = $game_map.round_y(point_y + 1)
  1736.                     # 判断路径是否连通
  1737.         path_step = step - 1
  1738.         if sheet[left_x, point_y] == path_step
  1739.           chase_path.push(4)
  1740.           chase_point = [left_x, point_y]
  1741.           reversed_chase_point = [point_x, point_y]
  1742.           reach_point = true; break
  1743.         elsif sheet[right_x, point_y] == path_step
  1744.             chase_path.push(6)
  1745.             chase_point = [right_x, point_y]
  1746.             reversed_chase_point = [point_x, point_y]
  1747.             reach_point = true; break
  1748.         elsif sheet[point_x, up_y] == path_step
  1749.             chase_path.push(8)
  1750.             chase_point = [point_x, up_y]
  1751.             reversed_chase_point = [point_x, point_y]
  1752.             reach_point = true; break
  1753.         elsif sheet[point_x, down_y] == path_step
  1754.             chase_path.push(2)
  1755.             chase_point = [point_x, down_y]
  1756.             reversed_chase_point = [point_x, point_y]
  1757.             reach_point = true; break
  1758.         end
  1759.         # 以需要抵达该点的步数填充路径表格 #
  1760.         if sheet[left_x, point_y] == 0                &&
  1761.            $game_map.ship_passable?(left_x, point_y)  &&
  1762.            !collide_with_events?(left_x, point_y)     &&
  1763.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1764.           sheet[left_x, point_y] = step
  1765.           draw_path = true
  1766.           new_start_points.push(left_x, point_y)
  1767.         end
  1768.         if sheet[right_x, point_y] == 0               &&
  1769.            $game_map.ship_passable?(right_x, point_y) &&
  1770.            !collide_with_events?(right_x, point_y)    &&
  1771.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1772.           sheet[right_x, point_y] = step
  1773.           draw_path = true
  1774.           new_start_points.push(right_x, point_y)
  1775.         end
  1776.         if sheet[point_x, up_y] == 0                  &&
  1777.            $game_map.ship_passable?(point_x, up_y)    &&
  1778.            !collide_with_events?(point_x, up_y)       &&
  1779.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1780.           sheet[point_x, up_y] = step
  1781.           draw_path = true
  1782.           new_start_points.push(point_x, up_y)
  1783.         end
  1784.         if sheet[point_x, down_y] == 0                &&
  1785.            $game_map.ship_passable?(point_x, down_y)  &&
  1786.            !collide_with_events?(point_x, down_y)     &&
  1787.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1788.           sheet[point_x, down_y] = step
  1789.           draw_path = true
  1790.           new_start_points.push(point_x, down_y)
  1791.         end
  1792.       end#endOfLoop2
  1793.       break if !draw_path || reach_point
  1794.       draw_path = false
  1795.       check_points = new_end_points
  1796.       new_end_points = []
  1797.       step += 1
  1798.       break if step > KsOfSion::Break_Steps &&
  1799.                !Input.press?(KsOfSion::Find_Path_Key)
  1800.       loop do #loop3 从终点开始反向填充
  1801.         point_x = check_points.shift
  1802.         break if point_x == nil
  1803.         point_y = check_points.shift
  1804.         left_x  = $game_map.round_x(point_x - 1)
  1805.         right_x = $game_map.round_x(point_x + 1)
  1806.         up_y    = $game_map.round_y(point_y - 1)
  1807.         down_y  = $game_map.round_y(point_y + 1)
  1808.         # 判断路径是否连通
  1809.         path_step = step - 1
  1810.         if sheet[left_x, point_y] == path_step
  1811.           chase_path.push(6)
  1812.           chase_point = [point_x, point_y]
  1813.           reversed_chase_point = [left_x, point_y]
  1814.           reach_point = true; break
  1815.         elsif sheet[right_x, point_y] == path_step
  1816.             chase_path.push(4)
  1817.             chase_point = [point_x, point_y]
  1818.             reversed_chase_point = [right_x, point_y]
  1819.             reach_point = true; break
  1820.         elsif sheet[point_x, up_y] == path_step
  1821.             chase_path.push(2)
  1822.             chase_point = [point_x, point_y]
  1823.             reversed_chase_point = [point_x, up_y]
  1824.             reach_point = true; break
  1825.         elsif sheet[point_x, down_y] == path_step
  1826.             chase_path.push(8)
  1827.             chase_point = [point_x, point_y]
  1828.             reversed_chase_point = [point_x, down_y]
  1829.             reach_point = true; break
  1830.         end
  1831.         # 以需要抵达该点的步数填充路径表格 #
  1832.         if sheet[left_x, point_y] == 0                &&
  1833.            $game_map.ship_passable?(left_x, point_y)  &&
  1834.            !collide_with_events?(left_x, point_y)     &&
  1835.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1836.           sheet[left_x, point_y] = step
  1837.           draw_path = true
  1838.           new_end_points.push(left_x, point_y)
  1839.         end
  1840.         if sheet[right_x, point_y] == 0               &&
  1841.            $game_map.ship_passable?(right_x, point_y) &&
  1842.            !collide_with_events?(right_x, point_y)    &&
  1843.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1844.           sheet[right_x, point_y] = step
  1845.           draw_path = true
  1846.           new_end_points.push(right_x, point_y)
  1847.         end
  1848.         if sheet[point_x, up_y] == 0                  &&
  1849.            $game_map.ship_passable?(point_x, up_y)    &&
  1850.            !collide_with_events?(point_x, up_y)       &&
  1851.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1852.           sheet[point_x, up_y] = step
  1853.           draw_path = true
  1854.           new_end_points.push(point_x, up_y)
  1855.         end
  1856.         if sheet[point_x, down_y] == 0                &&
  1857.            $game_map.ship_passable?(point_x, down_y)  &&
  1858.            !collide_with_events?(point_x, down_y)     &&
  1859.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1860.           sheet[point_x, down_y] = step
  1861.           draw_path = true
  1862.           new_end_points.push(point_x, down_y)
  1863.         end
  1864.       end#endOfLoop3
  1865.       break if !draw_path || reach_point
  1866.       step += 1
  1867.     end #endOfLoop1 路径表格填充完毕
  1868.     $mouse_move_sign.transparent = false
  1869.     # 判断指定地点能否抵达
  1870.     if reach_point
  1871.       $mouse_move_sign.direction = 2
  1872.     else
  1873.       not_reach_point
  1874.       return
  1875.     end
  1876.     # 根据路径表格绘制最短移动路径(正向)
  1877.     steps = step / 2 * 2
  1878.     loop_times = step / 2
  1879.     point_x, point_y = chase_point[0], chase_point[1]
  1880.     for i in 2..loop_times # forLoop
  1881.     steps -= 2
  1882.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1883.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1884.         chase_path.push(2)
  1885.         point_y = $game_map.round_y(point_y + 1)
  1886.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1887.         chase_path.push(8)
  1888.         point_y = $game_map.round_y(point_y - 1)
  1889.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1890.         chase_path.push(4)
  1891.         point_x = $game_map.round_x(point_x - 1)
  1892.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1893.         chase_path.push(6)
  1894.         point_x = $game_map.round_x(point_x + 1)
  1895.       end
  1896.     else
  1897.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1898.         chase_path.push(4)
  1899.         point_x = $game_map.round_x(point_x - 1)
  1900.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1901.         chase_path.push(6)
  1902.         point_x = $game_map.round_x(point_x + 1)
  1903.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1904.         chase_path.push(2)
  1905.         point_y = $game_map.round_y(point_y + 1)
  1906.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1907.         chase_path.push(8)
  1908.         point_y = $game_map.round_y(point_y - 1)
  1909.       end
  1910.     end
  1911.     end #endOfForLoop
  1912.     # 如果指定点无法抵达或者登陆
  1913.     return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path)
  1914.     # 根据路径表格绘制最短移动路径(反向)
  1915.     steps = step / 2 * 2 + 1
  1916.     loop_times = step / 2
  1917.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1918.     for i in 1..loop_times # forLoop
  1919.     steps -= 2
  1920.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1921.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1922.         reversed_chase_path.push(6)
  1923.         point_x = $game_map.round_x(point_x - 1)
  1924.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1925.         reversed_chase_path.push(4)
  1926.         point_x = $game_map.round_x(point_x + 1)
  1927.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1928.         reversed_chase_path.push(8)
  1929.         point_y = $game_map.round_y(point_y + 1)
  1930.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1931.         reversed_chase_path.push(2)
  1932.         point_y = $game_map.round_y(point_y - 1)
  1933.       end
  1934.     else
  1935.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1936.         reversed_chase_path.push(8)
  1937.         point_y = $game_map.round_y(point_y + 1)
  1938.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1939.         reversed_chase_path.push(2)
  1940.         point_y = $game_map.round_y(point_y - 1)
  1941.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1942.         reversed_chase_path.push(6)
  1943.         point_x = $game_map.round_x(point_x - 1)
  1944.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1945.         reversed_chase_path.push(4)
  1946.         point_x = $game_map.round_x(point_x + 1)
  1947.       end
  1948.     end
  1949.     end #endOfForLoop
  1950.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1951.   end#ship
  1952.   #--------------------------------------------------------------------------
  1953.   # ● 绘制airship的移动路径 @array[move_directions...]
  1954.   #--------------------------------------------------------------------------
  1955.   def draw_air_path
  1956.     $mouse_move_sign.transparent = false
  1957.     # 准备绘制路径表格
  1958.     sheet = Table.new($game_map.width, $game_map.height)
  1959.     new_check_point = [x, y]; sheet[x, y] = 1
  1960.     reach_point = false;      step = 2
  1961.     loop do #loop1
  1962.      check_point = new_check_point
  1963.      new_check_point = []
  1964.       loop do #loop2
  1965.         point_x = check_point.shift
  1966.         break if point_x == nil
  1967.         point_y = check_point.shift
  1968.         if point_x == @moveto_x && point_y == @moveto_y
  1969.           reach_point = true; break
  1970.         end
  1971.         left_x  = $game_map.round_x(point_x - 1)
  1972.         right_x = $game_map.round_x(point_x + 1)
  1973.         up_y    = $game_map.round_y(point_y - 1)
  1974.         down_y  = $game_map.round_y(point_y + 1)
  1975.         # 以需要抵达该点的步数填充路径表格 #
  1976.         if sheet[left_x, point_y] == 0
  1977.           sheet[left_x, point_y] = step
  1978.           new_check_point.push(left_x, point_y)
  1979.         end
  1980.         if sheet[right_x, point_y] == 0
  1981.           sheet[right_x, point_y] = step
  1982.           new_check_point.push(right_x, point_y)
  1983.         end
  1984.         if sheet[point_x, up_y] == 0
  1985.           sheet[point_x, up_y] = step
  1986.           new_check_point.push(point_x, up_y)
  1987.         end
  1988.         if sheet[point_x, down_y] == 0
  1989.           sheet[point_x, down_y] = step
  1990.           new_check_point.push(point_x, down_y)
  1991.         end
  1992.       end#endOfLoop2
  1993.       break if reach_point
  1994.       step += 1
  1995.     end #endOfLoop1
  1996.     # 根据路径表格绘制最短移动路径 #
  1997.     reversed_chase_path = []; step -= 1
  1998.     point_x, point_y = @moveto_x, @moveto_y
  1999.     for i in 2..step
  2000.     step -= 1
  2001.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  2002.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
  2003.         reversed_chase_path.push(6)
  2004.         point_x = $game_map.round_x(point_x - 1)
  2005.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  2006.         reversed_chase_path.push(4)
  2007.         point_x = $game_map.round_x(point_x + 1)
  2008.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
  2009.         reversed_chase_path.push(8)
  2010.         point_y = $game_map.round_y(point_y + 1)
  2011.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  2012.         reversed_chase_path.push(2)
  2013.         point_y = $game_map.round_y(point_y - 1)
  2014.       end
  2015.     else
  2016.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step
  2017.         reversed_chase_path.push(8)
  2018.         point_y = $game_map.round_y(point_y + 1)
  2019.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  2020.         reversed_chase_path.push(2)
  2021.         point_y = $game_map.round_y(point_y - 1)
  2022.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step
  2023.         reversed_chase_path.push(6)
  2024.         point_x = $game_map.round_x(point_x - 1)
  2025.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  2026.         reversed_chase_path.push(4)
  2027.         point_x = $game_map.round_x(point_x + 1)
  2028.       end
  2029.     end
  2030.     end #endOfForLoop
  2031.     @mouse_move_path = reversed_chase_path.reverse
  2032.   end#airship
  2033.   #--------------------------------------------------------------------------
  2034.   # ● 目标点无法抵达时的处理,用于各路径绘制方法内部
  2035.   #--------------------------------------------------------------------------
  2036.   def not_reach_point
  2037.     $mouse_move_sign.direction = 4
  2038.     dx = 0; dy = 0; dir = 0
  2039.     if @moveto_x - x > 0
  2040.       if @moveto_x - x > $game_map.width - @moveto_x + x &&
  2041.           $game_map.loop_vertical?
  2042.         dx = $game_map.width - @moveto_x + x; dir = 4
  2043.       else
  2044.         dx = @moveto_x - x; dir = 6
  2045.       end
  2046.     else
  2047.       if x - @moveto_x > $game_map.width - x + @moveto_x &&
  2048.           $game_map.loop_vertical?
  2049.         dx = $game_map.width - x + @moveto_x; dir = 6
  2050.       else
  2051.         dx = x - @moveto_x; dir = 4
  2052.       end
  2053.     end
  2054.     if @moveto_y - y > 0
  2055.       if @moveto_y - y > $game_map.height - @moveto_y + y &&
  2056.           $game_map.loop_horizontal?
  2057.         dy = $game_map.height - @moveto_y + y
  2058.         dir = 8 if dy > dx
  2059.       else
  2060.         dy = @moveto_y - y
  2061.         dir = 2 if dy > dx
  2062.       end
  2063.     else
  2064.       if y - @moveto_y > $game_map.height - y + @moveto_y &&
  2065.           $game_map.loop_horizontal?
  2066.         dy = $game_map.height - y + @moveto_y
  2067.         dir = 2 if dy > dx
  2068.       else
  2069.         dy = y - @moveto_y
  2070.         dir = 8 if dy > dx
  2071.       end
  2072.     end
  2073.     @mouse_move_path = [dir, 0] # 0方向用于防止移动过程中触发事件
  2074.   end
  2075.   #--------------------------------------------------------------------------
  2076.   # ● 判断目标点是否能抵达、登陆,用于船只路径绘制
  2077.   #--------------------------------------------------------------------------
  2078.   def landable?(x, y, path)
  2079.     case @vehicle_type
  2080.       when :ship; return $game_map.ship_passable?(x, y) ||
  2081.         $game_map.passable?(x, y, 10 - path[-1])
  2082.       when :boat; return $game_map.boat_passable?(x, y) ||
  2083.         $game_map.passable?(x, y, 10 - path[-1])
  2084.     end
  2085.   end
  2086. end

  2087. #==============================================================================
  2088. # ■ Game_Map
  2089. #------------------------------------------------------------------------------
  2090. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
  2091. #   本类的实例请参考 $game_map 。
  2092. #==============================================================================
  2093. class Game_Map
  2094.   #--------------------------------------------------------------------------
  2095.   # ● 定义实例变量
  2096.   #--------------------------------------------------------------------------
  2097.   attr_reader :mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
  2098.   attr_reader :mouse_map_y # 同上
  2099.   #--------------------------------------------------------------------------
  2100.   # ● 初始化对象
  2101.   #--------------------------------------------------------------------------
  2102.   alias sion_mouse_initialize initialize
  2103.   def initialize
  2104.     sion_mouse_initialize
  2105.     creat_move_sign  ###
  2106.     set_constants
  2107.   end
  2108.   #--------------------------------------------------------------------------
  2109.   # ● 更新画面
  2110.   #     main : 事件解释器更新的标志
  2111.   #--------------------------------------------------------------------------
  2112.   alias sion_mouse_update update
  2113.   def update(main = false)
  2114.     sion_mouse_update(main)
  2115.     update_move_sign
  2116.   end
  2117.   #--------------------------------------------------------------------------
  2118.   # ● 创建显示路径点的事件
  2119.   #--------------------------------------------------------------------------
  2120.   def creat_move_sign
  2121.     $mouse_move_sign = Move_Sign.new
  2122.   end
  2123.   #--------------------------------------------------------------------------
  2124.   # ● 更新显示路径点的事件
  2125.   #--------------------------------------------------------------------------
  2126.   def set_constants
  2127.     @mouse_pos_setted = true
  2128.     @set_pos_prepared = false
  2129.     @mouse_old_x = 0
  2130.     @mouse_old_y = 0
  2131.   end
  2132.   #--------------------------------------------------------------------------
  2133.   # ● 更新显示路径点的事件
  2134.   #--------------------------------------------------------------------------
  2135.   def update_move_sign
  2136.     $mouse_move_sign.update
  2137.   end
  2138.   #--------------------------------------------------------------------------
  2139.   # ● 获取鼠标位于的地图块的x、y坐标
  2140.   #--------------------------------------------------------------------------
  2141.   def get_mouse_map_xy
  2142.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  2143.     @mouse_map_x = round_x((@display_x + mouse_x / 32.0).to_i)
  2144.     @mouse_map_y = round_y((@display_y + mouse_y / 32.0).to_i)
  2145.   end
  2146.   #--------------------------------------------------------------------------
  2147.   # ● 返回地图画面时重设鼠标坐标
  2148.   #--------------------------------------------------------------------------
  2149.   def reset_mouse_pos
  2150.     return if @mouse_pos_setted
  2151.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
  2152.     @mouse_pos_setted = true
  2153.     @set_pos_prepared = false
  2154.   end
  2155.   #--------------------------------------------------------------------------
  2156.   # ● 重设鼠标的坐标
  2157.   #--------------------------------------------------------------------------
  2158.   def prepare_reset_mouse_pos
  2159.     return if @set_pos_prepared
  2160.     @mouse_pos_setted = false
  2161.     @mouse_old_x = Mouse.mouse_x
  2162.     @mouse_old_y = Mouse.mouse_y
  2163.     @set_pos_prepared = true
  2164.   end
  2165. end

  2166. #==============================================================================
  2167. # ■ Spriteset_Map
  2168. #------------------------------------------------------------------------------
  2169. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
  2170. #==============================================================================
  2171. class Spriteset_Map
  2172.   #--------------------------------------------------------------------------
  2173.   # ● 生成路径点精灵
  2174.   #--------------------------------------------------------------------------
  2175.   alias sion_mouse_create_characters create_characters
  2176.   def create_characters
  2177.     sion_mouse_create_characters
  2178.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
  2179.   end
  2180. end

  2181. #==============================================================================
  2182. # ■ Scene_Map
  2183. #------------------------------------------------------------------------------
  2184. #  地图画面
  2185. #==============================================================================
  2186. class Scene_Map < Scene_Base
  2187.   #--------------------------------------------------------------------------
  2188.   # ● 画面更新
  2189.   #--------------------------------------------------------------------------
  2190.   alias sion_mouse_update_scene update_scene
  2191.   def update_scene
  2192.     sion_mouse_update_scene
  2193.     update_mouse_action unless scene_changing?
  2194.   end
  2195.   #--------------------------------------------------------------------------
  2196.   # ● 场所移动前的处理
  2197.   #--------------------------------------------------------------------------
  2198.   alias sion_mouse_pre_transfer pre_transfer
  2199.   def pre_transfer
  2200.     $game_player.reset_move_path
  2201.     sion_mouse_pre_transfer
  2202.   end
  2203.   #--------------------------------------------------------------------------
  2204.   # ● 监听鼠标左键的按下
  2205.   #--------------------------------------------------------------------------
  2206.   def update_mouse_action
  2207.     $game_player.left_button_action if Mouse.press?(0x01)
  2208.   end
  2209. end

  2210. #==============================================================================
  2211. # ■ Scene_File
  2212. #------------------------------------------------------------------------------
  2213. #  存档画面和读档画面共同的父类
  2214. #==============================================================================
  2215. class Scene_File < Scene_MenuBase
  2216.   #--------------------------------------------------------------------------
  2217.   # ● 开始处理
  2218.   #--------------------------------------------------------------------------
  2219.   alias sion_mouse_start start
  2220.   def start
  2221.     sion_mouse_start
  2222.     @move_state = 0
  2223.     set_mouse_pos
  2224.   end
  2225.   #--------------------------------------------------------------------------
  2226.   # ● 更新画面
  2227.   #--------------------------------------------------------------------------
  2228.   alias sion_mouse_update update
  2229.   def update
  2230.     sion_mouse_update
  2231.     Input.dir4.zero? ? set_cursor : set_mouse_pos
  2232.   end
  2233.   #--------------------------------------------------------------------------
  2234.   # ● 更新光标
  2235.   #--------------------------------------------------------------------------
  2236.   def set_cursor
  2237.     @move_state += 1
  2238.     last_index = @index
  2239.     if mouse_which_window == -2
  2240.       if (@move_state - 1) % 6 == 0
  2241.         @index = (@index + 1) % item_max if @index < item_max - 1
  2242.       end
  2243.     elsif mouse_which_window == -1
  2244.       if (@move_state - 1) % 6 == 0
  2245.         @index = (@index - 1 + item_max) % item_max if @index > 0
  2246.       end
  2247.     else
  2248.       @move_state = 0
  2249.       @index = top_index + mouse_which_window
  2250.     end
  2251.     ensure_cursor_visible
  2252.     if @index != last_index
  2253.       @savefile_windows[last_index].selected = false
  2254.       @savefile_windows[@index].selected = true
  2255.     end
  2256.   end
  2257.   #--------------------------------------------------------------------------
  2258.   # ● 判断鼠标位于哪个窗口
  2259.   #--------------------------------------------------------------------------
  2260.   def mouse_which_window
  2261.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  2262.     if mouse_y < @help_window.height + 14
  2263.       mouse_row = -1
  2264.     elsif mouse_y > Graphics.height - 14
  2265.       mouse_row = -2
  2266.     else
  2267.       mouse_row = 4 * (mouse_y - @help_window.height) /
  2268.         (Graphics.height - @help_window.height)
  2269.     end
  2270.     return mouse_row
  2271.   end
  2272.   #--------------------------------------------------------------------------
  2273.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
  2274.   #--------------------------------------------------------------------------
  2275.   def set_mouse_pos
  2276.     new_x = 40
  2277.     new_y = @help_window.height + savefile_height * (@index - top_index) + 24
  2278.     Mouse.set_mouse_pos(new_x, new_y)
  2279.   end
  2280. end

  2281. #==============================================================================
  2282. # ■ Game_Event
  2283. #------------------------------------------------------------------------------
  2284. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
  2285. #   在 Game_Map 类的内部使用。
  2286. #==============================================================================
  2287. class Game_Event < Game_Character
  2288.   #--------------------------------------------------------------------------
  2289.   # ● 事件启动
  2290.   #--------------------------------------------------------------------------
  2291.   alias sion_mouse_start start
  2292.   def start
  2293.     return if mouse_start? && !Mouse.press?(0x01)
  2294.     sion_mouse_start
  2295.   end
  2296.   #--------------------------------------------------------------------------
  2297.   # ● 判断事件是否由鼠标启动
  2298.   #--------------------------------------------------------------------------
  2299.   def mouse_start?
  2300.     return false if empty?
  2301.     @list.each do |index|
  2302.       return true if (index.code == 108 || index.code == 408) &&
  2303.         index.parameters[0].include?('鼠标启动')
  2304.     end
  2305.     return false
  2306.   end
  2307. end

  2308. ####泥煤的height
  2309. # @height = height

  2310. class Area_Response
  2311.   attr_accessor :type
  2312.   attr_reader :ox
  2313.   attr_reader :oy
  2314.   attr_reader :width
  2315.   attr_reader :height
  2316.   attr_reader :switch_id
  2317.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
  2318.     @type = type
  2319.     @ox = ox
  2320.     @oy = oy
  2321.     @width = width
  2322.     @height = height
  2323.     @switch_id = switch_id
  2324.   end
  2325. end

  2326. $area_responses = []

  2327. class Scene_Map
  2328.   alias update_mouse_2013421 update_mouse_action
  2329.   def update_mouse_action
  2330.     update_area_response
  2331.     update_mouse_2013421
  2332.   end
  2333.   def update_area_response
  2334.     responses = $area_responses
  2335.     responses.each {|response|
  2336.       ox = response.ox
  2337.       oy = response.oy
  2338.       width = response.width
  2339.       height = response.height
  2340.       switch_id = response.switch_id
  2341.       case response.type
  2342.       when 0
  2343.         if mouse_in_area?(ox, oy, width, height)
  2344.           $game_switches[switch_id] = true
  2345.           $area_responses.delete(response)
  2346.         end
  2347.       when 1
  2348.         if mouse_in_area?(ox, oy, width, height) && Mouse.trigger?(0x01)
  2349.           $game_switches[switch_id] = true
  2350.           $area_responses.delete(response)
  2351.         end
  2352.       when 2
  2353.         if mouse_in_area?(ox, oy, width, height)
  2354.           $game_switches[switch_id] = true
  2355.         else
  2356.           $game_switches[switch_id] = false
  2357.         end
  2358.       when 3
  2359.         if mouse_in_area?((ox - $game_map.display_x) * 32 ,
  2360.             (oy - $game_map.display_y) * 32, width, height)
  2361.           $game_map.events_xy(ox, oy).each {|event|
  2362.           event.start
  2363.           $area_responses.delete(response)
  2364.           return
  2365.           }
  2366.         end
  2367.       when 4
  2368.         if mouse_in_area?((ox - $game_map.display_x) * 32,
  2369.             (oy - $game_map.display_y) * 32, width, height)
  2370.           $game_map.events_xy(ox, oy).each {|event|
  2371.             event.start
  2372.             return
  2373.           }
  2374.         end
  2375.       end
  2376.     }
  2377.   end
  2378.   def mouse_in_area?(ox, oy, width, height)
  2379.     Mouse.mouse_x >= ox && Mouse.mouse_x <= ox + width &&
  2380.     Mouse.mouse_y >= oy && Mouse.mouse_y <= oy + height
  2381.   end
  2382. end
  2383. class Game_Interpreter
  2384.   def area_response(*arg)
  2385.     $area_responses.push(Area_Response.new(*arg))
  2386.   end
  2387. end
复制代码
  1. =begin ========================================================================

  2.   路径可视化补丁,原作者oott123

  3.   Require : Sion Mouse System

  4.     * *  [url]http://rpg.blue/forum.php?mod=viewthread&tid=284480[/url]  * *


  5.    

  6.   使用方法:置于 Sion Mouse System 脚本下方
  7.             $PSign.png 路径图片行走图,置于.\Graphics\Characters文件夹
  8.   
  9. =end #=========================================================================

  10. $path_sign_amount = 15 #路径最大长度,觉得卡的话就调低一些

  11. class Move_Path < Game_Character
  12.   #--------------------------------------------------------------------------
  13.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
  14.   #--------------------------------------------------------------------------
  15.   def init_public_members
  16.     @character_name  = '1' # ★ 路径箭头,置于.\Graphics\Characters文件夹
  17.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
  18.     @move_speed      = 1        # ★ 踏步速度
  19.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
  20.     @opacity         = 120      # ★ 不透明度
  21.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
  22.     @direction       = 4        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
  23.     @priority_type   = 0        # ★ 优先级(与人物同级为:1)
  24.     @direction_fix = true   # 固定朝向
  25.     @move_frequency = 6     # 移动频率
  26.     @walk_anime = true      # 步行动画
  27.     @pattern = 1            # 图案
  28.     @through = true         # 穿透
  29.     @bush_depth = 0         # 草木深度
  30.     @animation_id = 0       # 动画 ID
  31.     @balloon_id = 0         # 心情 ID
  32.     @transparent = true     # 透明
  33.     @id = 0
  34.     @x = 0
  35.     @y = 0
  36.     @real_x = 0
  37.     @real_y = 0
  38.     @tile_id = 0
  39.     unless File.exist?('Graphics/Characters/' + @character_name + '.png')
  40.       @character_name  = 'Actor1' #......
  41.       @character_index = 1
  42.     end
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 定义XXX
  46.   #--------------------------------------------------------------------------
  47.   attr_accessor :transparent
  48.   attr_accessor :direction
  49. end

  50. class Game_Player < Game_Character
  51.   #--------------------------------------------------------------------------
  52.   # ● 绘制移动路径 @array[move_directions...]
  53.   #--------------------------------------------------------------------------
  54.   alias path_visualization_draw_move_path draw_move_path
  55.   def draw_move_path
  56.     path_visualization_draw_move_path
  57.     draw_path_on_map
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # ● 由鼠标移动
  61.   #--------------------------------------------------------------------------
  62.   alias path_visualization_move_by_mouse move_by_mouse
  63.   def move_by_mouse
  64.     path_visualization_move_by_mouse
  65.     path_fix_with_move
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 重置移动路径相关信息
  69.   #--------------------------------------------------------------------------
  70.   alias path_visualization_reset_move_path reset_move_path
  71.   def reset_move_path
  72.     path_visualization_reset_move_path
  73.     reset_path_signs
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 把移动路径绘制到地图上
  77.   #--------------------------------------------------------------------------
  78.   def draw_path_on_map
  79.     reset_path_signs
  80.     return if @mouse_move_path[1].zero? # 目标点无法抵达时不绘制
  81.     dirs = @mouse_move_path[0, $path_sign_amount]
  82.     $mouse_move_path[0].moveto(x, y)
  83.     $mouse_move_path[0].direction = dirs[0]
  84.     $mouse_move_path[0].transparent = false
  85.     for index in 1..dirs.size - 1
  86.       $mouse_move_path[index].moveto(      #移动到
  87.         $game_map.round_x_with_direction(  # x坐标
  88.           $mouse_move_path[index - 1].x, dirs[index - 1]),
  89.         $game_map.round_y_with_direction(  # y坐标
  90.           $mouse_move_path[index - 1].y, dirs[index - 1])
  91.         )
  92.       $mouse_move_path[index].direction = dirs[index]
  93.       $mouse_move_path[index].transparent = false
  94.     end
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 移动后更新移动路径
  98.   #--------------------------------------------------------------------------
  99.   def path_fix_with_move
  100.     if $path_sign_amount > @mouse_move_path.size
  101.       $mouse_move_path[@sign_index].transparent = true
  102.     else
  103.       index = (@sign_index - 1) % ($path_sign_amount)
  104.       $mouse_move_path[@sign_index].moveto(                         # 移动到
  105.         $game_map.round_x_with_direction($mouse_move_path[index].x, # x坐标
  106.           @mouse_move_path[$path_sign_amount - 2]),
  107.         $game_map.round_y_with_direction($mouse_move_path[index].y, # y坐标
  108.           @mouse_move_path[$path_sign_amount - 2])
  109.         )
  110.       $mouse_move_path[@sign_index].direction =
  111.         @mouse_move_path[$path_sign_amount - 1]
  112.     end
  113.     @sign_index = (@sign_index + 1) % ($path_sign_amount)
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 消除地图上的移动路线
  117.   #--------------------------------------------------------------------------
  118.   def reset_path_signs
  119.     @sign_index = 0
  120.     $mouse_move_path.each {|sign| sign.transparent = true }
  121.   end
  122. end

  123. class Game_Map
  124.   #--------------------------------------------------------------------------
  125.   # ● 初始化对象
  126.   #--------------------------------------------------------------------------
  127.   alias path_visualization_initialize initialize
  128.   def initialize
  129.     path_visualization_initialize
  130.     creat_move_path
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 更新画面
  134.   #     main : 事件解释器更新的标志
  135.   #--------------------------------------------------------------------------
  136.   alias path_visualization_update update
  137.   def update(main = false)
  138.     path_visualization_update(main)
  139.     update_move_path
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 创建显示路径点的事件
  143.   #--------------------------------------------------------------------------
  144.   def creat_move_path
  145.     $mouse_move_path = []
  146.     $path_sign_amount.times { $mouse_move_path.push(Move_Path.new) }
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 更新显示路径点的事件
  150.   #--------------------------------------------------------------------------
  151.   def update_move_path
  152.     $mouse_move_path.each{|sign| sign.update}
  153.   end
  154. end

  155. class Spriteset_Map
  156.   #--------------------------------------------------------------------------
  157.   # ● 生成人物精灵
  158.   #--------------------------------------------------------------------------
  159.   alias path_visualization_create_characters create_characters
  160.   def create_characters
  161.     path_visualization_create_characters
  162.     $mouse_move_path.each do |sign|
  163.       @character_sprites.push(Sprite_Character.new(@viewport1, sign))
  164.     end
  165.   end
  166. end
复制代码

咋回事嘞

咋回事嘞

点评

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部