Project1

标题: 存放腳本 [打印本页]

作者: 熊喵酱    时间: 2013-8-29 09:01
标题: 存放腳本
純屬給LBQ腳本:
  1. =begin #=======================================================================% n  v- C3 k$ I  y$ c6 q! ?

  2. # a; q" d% S% M9 i2 V
  3.   Sion Mouse System v1.3e! \* E; K; v5 S  p% e0 J4 m
  4.   
    , |/ g& {5 Z2 w7 h( C# f
  5.   Changlog
    2 x' U/ F, e2 R/ J4 k$ y  B
  6.   
    9 m% \* z7 N4 Q4 F
  7.   2013.4.21 v1.3f
    ) |' z2 W# g+ L% X3 c0 w1 B
  8.    
    & T$ I5 {' X4 ]6 `0 B; d
  9.     1.3f 卷动地图 bug 修正6 u( K$ q: u6 r4 D& e2 K
  10.    
    * ?8 Q0 e/ n# T! W& S
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口! t( U) F4 s. ?
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内( C% r) z0 n: \1 V0 J6 [
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    ! c# E. d3 f1 H- z
  14. 4 i% b7 b, A' z1 R, b
  15.     1.3f bug修正2 @( {$ v' j5 u) k1 Q' `6 c9 z
  16.   
      p7 U2 a. P# q* t5 {! l
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及: N. d& d7 B( f, ^0 ^8 |
  18.           关闭菜单时,鼠标是否移动到原来的位置。$ p, W3 q. {6 ~# P6 i3 b+ p

  19. ! W7 q4 I8 p! A6 x' w
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    1 [# c0 e( h; P/ J7 N
  21. 1 w9 V2 x4 d$ s: a! E
  22.     1.3b 修正一些罕见的bug;
    ! B. ~& h, z* c. i

  23. & G2 ~, l/ }# r5 {
  24.     1.3a 代码小修改;/ F9 t8 L4 Y1 i) P
  25.           加入了鼠标点击启动事件的功能,9 w; d; B- A3 C  `
  26.           在事件中加入“注释”: 鼠标启动  ,
    . C  \$ v, L2 E
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    % {  ~5 x8 M( N/ H" _; x! x
  28.   % Y& t7 }6 S, P. f
  29.   2013.2.12 v1.2
    ) ?; Y5 t2 y; P8 r7 [  ~5 ~& E; t
  30. 0 d4 T) m* k/ h2 b! d/ _4 Q2 h
  31.     寻路逻辑优化;
    & e1 z" V2 }* `* M+ T5 {$ c
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    4 F; t+ f2 H0 D6 V' P& n4 F
  33.     现在支持用鼠标来操作载具了。
    , F- m# R  m/ e( F$ T: \

  34. + ?; X1 F: z2 w6 J) }  A
  35.   2013.2.8 v1.16 m- R& I- q! i* ?- E

  36. % V5 H$ U3 T% m0 {$ V
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;% D3 l3 w2 J# Y5 d3 K" P6 b+ h
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    4 U" k9 q- U0 s( u  c5 ~
  39.     移动时,路径指示点的绘制更加稳定;" ]) o9 a- Q$ R
  40.     现在支持默认存档画面的鼠标操作了。( ]6 Q7 g; F4 W5 H! M& T
  41. / z3 h1 X+ k7 g, h
  42. : S& w( Y3 r! d" U# P2 ~4 W& q
  43.   OrigenVersion
    * E" M' t( @* B+ a/ g% f
  44.   
    - U- A3 P) O$ @4 y1 {
  45.     2013.2.7 v1.0 5 T6 l- g9 ^/ v" t( c

  46. 6 a3 p! F& J% l! L3 M; k( a) e
  47.   主要功能  z4 M2 v: H; a3 W/ h8 Y

  48. 4 r! I9 r5 Y& {8 C  ~) C
  49.       使用鼠标进行各种操作...
    1 F1 I+ D, Y; Y
  50.       将鼠标锁定在游戏窗口内
    - k. n/ z4 D: v, a5 }7 o; R
  51.       自动寻路,按住 D 键可以扩大寻路的范围8 Z& s0 i, E" c  @
  52.       双击鼠标进行冲刺4 T2 B( I* t7 W  y6 M
  53.       更改地图卷动方式以适应鼠标移动
    , L: `9 _) A4 Y) _
  54.       变量输入框改良
    ' @: j' F7 e0 ~0 r9 ~5 s$ z

  55. ! U, W' \; X& ]$ c3 H$ |
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹1 i$ l* y' }' O+ u; \1 M
  57. 3 \* ]) P1 T. H+ J
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    + A7 j8 {) U! ^! X

  59. 1 `0 J* {; B' O+ s3 ^+ x- }  G6 E9 _
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭: I! k! d7 x( |! X7 n7 M0 j! b3 y

  61. , B( M# u; ?/ G* l; g6 j

  62. 7 o8 P4 y% z9 ?# T5 U, I3 e
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★4 J0 j% e4 t* }  i  F" d+ R. }5 g' o
  64. 7 _2 A! j5 ~2 B' g+ m2 x: F. W: k

  65.   N6 u* H7 _' k3 }! e" t  f0 I# j
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    ) m9 E" q3 V$ Y# p; A3 A9 G

  67. ' m: v- Y! `/ D$ d
  68. #==============================================================================
    ! ?7 C3 }# y: [( N1 q
  69. # ■ 常数设置   W( B$ V5 p- L% j3 k
  70. #==============================================================================
    1 S. D4 i6 R8 D0 ^- z/ o/ G
  71. module KsOfSion
    9 P! E6 I8 H- \" ?" l( D; q
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false( D* X, y: x- d
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑7 |, Z$ V% c2 |' @! J
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false: h. K8 J$ k" \3 o; b3 ]
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量" {( ]7 m& n6 a6 |$ W, m  ~8 h
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处8 J7 v( s& Z) r) U6 M/ X+ Z, g  Q
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧' u/ }% G1 p$ K2 k4 @, B: h' n
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)6 Y& v0 Y' E8 }$ R
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键% Z, D( o/ q3 ?8 n
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    9 K+ n7 B- k& m# N
  81. end
    * ~) ~3 {/ z, ?' n9 m4 }  s

  82. 3 G) D3 ?" ?9 E9 a6 \
  83. #==============================================================================
    * Y8 T$ f2 k8 ?1 v  _' k. u
  84. # ■ 用来显示路径点的类
    9 M/ H: @3 R6 `7 m* G+ H9 i3 e
  85. #==============================================================================
    1 N$ t/ U; t. P6 Y' a: l: N' A2 b4 o
  86. class Move_Sign  Game_Character6 K' ^" T7 x( ]6 C2 ]" e3 g
  87.   #--------------------------------------------------------------------------
    7 f# Y& I; Y$ |0 K" P7 U, g
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    $ q7 L" l( h4 j8 o+ D$ p) A6 I
  89.   #--------------------------------------------------------------------------( a5 C' o1 v" H9 p
  90.   def init_public_members  i# f% a- s2 {1 F: k0 {
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    ' \4 N0 ?9 j. W$ G" W" A( h
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为05 H2 c9 E" g* r0 @
  93.     @move_speed      = 5        # ★ 踏步速度+ t1 o; V. w5 h( H7 c% u7 ]
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)/ g0 \6 A/ R) G. Y
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度  w" L/ ^- L  g' w/ E0 i3 T
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)# U+ G0 ~3 _4 Z7 r9 R5 [
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    2 e# {, U7 G! M- @
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    ; h) D6 C) w3 X+ w
  99. 1 O1 |. F, w2 w
  100. 5 s+ R# |+ p( a  F/ |9 [
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    8 Q! `$ q& S0 i, [5 l$ E, ?
  102. ) S+ a: a4 V, {* ~7 ?6 @* `
  103. 7 K2 c+ R1 }* P) l
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图7 X( \8 L* O* P$ M' B
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    ; b0 T- y5 L- R- h5 D4 c

  106. 6 h& A3 t: y$ u
  107.       if $no_arrowpic_warn
    4 k5 a$ K7 ?+ d5 p* R
  108.         MouseShow_Cursor.call(1)4 Z: F# Z5 z& t0 P# f! z& v
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    6 q+ T2 N1 I3 a% A. X3 i5 s
  110. ( |8 K; {' m1 }6 B+ e: d7 d
  111. “路径指示点”将使用游戏自带图片
    5 D1 ?* U7 e9 x! W+ ~7 F( B- M

  112. $ _6 R% t# M- w6 [1 Y3 b
  113. 该提示可以在脚本内关闭')( Y/ U, D7 |/ i/ R! m
  114.         MouseShow_Cursor.call(0)
    0 t! t6 U9 \; b4 b/ w, q
  115.         $no_arrowpic_warn = false
    ' T6 S( B2 |7 F# F0 d2 ?
  116.       end
    * l3 [- a6 c$ e1 K( r* ?6 a
  117.       @character_name  = '!Flame'" G- Y+ _) q  Z+ O5 j
  118.       @character_index = 6$ H! v$ Q4 T* @2 \# t' p
  119. . G' i* D& _! c& }; ]
  120.     end+ l( c" N# s( i5 ?: e
  121.     @direction_fix = false  # 固定朝向' l/ R2 J2 `/ I
  122.     @move_frequency = 6     # 移动频率
    ' u# U/ k2 d) Z% ^3 d& s
  123.     @walk_anime = true      # 步行动画
    7 u( ]+ W4 D% l& _; g2 P
  124.     @pattern = 1            # 图案
    * l5 c1 i) e6 A- `2 |+ s
  125.     @through = true         # 穿透" d) }1 ^. v2 A+ C
  126.     @bush_depth = 0         # 草木深度
    $ X8 s0 u" \+ p
  127.     @animation_id = 0       # 动画 ID
    6 S% s$ @8 W, j+ b% b0 ^
  128.     @balloon_id = 0         # 心情 ID* E& t2 T" _) s8 C" r1 Q
  129.     @transparent = true     # 透明) o6 _/ r& @) u& ~' k
  130.     @id = 0+ q0 O5 y1 t6 Y3 ^7 p  ?4 E, B
  131.     @x = 0
    2 ^# `4 |' Q6 W5 M3 ]: g! H
  132.     @y = 0
    3 ?( @1 `5 i! f# Q
  133.     @real_x = 0: D! F( a& D! T! w) c" M* T% i
  134.     @real_y = 0
    3 B5 x! b/ y5 d$ `! S: s7 }% W% ~
  135.     @tile_id = 0/ ?1 S* i/ {1 W: ]
  136.   end
    / h, c$ t2 P4 t
  137.   #--------------------------------------------------------------------------
    ; `7 n8 w( J) g, x$ }  O
  138.   # ● 定义实例变量* Q' _! F' w- P( J% O( }
  139.   #--------------------------------------------------------------------------
    * P  s# p. H: D9 h
  140.   attr_accessor direction
    , M1 \- A3 ]* a3 e5 K/ \& X, j- o8 Y
  141. end
    2 x, \8 H0 r0 G/ g8 a
  142. & j" _. H; @6 J  v. L8 `
  143. #==============================================================================  ^5 N9 ~! y! n  ?- _1 p& Y
  144. # ■ Module Mouse
    ( M% g# ^0 q6 W7 T- ^$ ~
  145. #==============================================================================0 X/ z* Z* V; i$ X) R/ T7 h& K$ `
  146. module Mouse
    8 W) A) N4 X  S! M* L6 ~! a
  147.   #--------------------------------------------------------------------------% X+ r/ y+ ]& i
  148.   # ● API# b9 C" }- v' n2 F- u% V' j% q
  149.   #--------------------------------------------------------------------------
    * S2 c4 O: W8 J' v0 U
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')3 \) Q/ O8 g3 @5 q  {
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    6 a; t/ `; \9 \5 f, I
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    " ?) f- k, V8 ~' ~2 v
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')3 x/ u7 X# ]# l' q+ I% Q9 Q
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    . k" m0 Z/ u, K% t1 K; j
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    6 E8 |' T- b# k6 H7 ?- e8 N6 m
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    . G5 j% J! h! ~, r9 U* f& q7 F2 l
  157.   Window_Hwnd       = Get_Active_Window.call
    $ Y+ Y& R3 k6 {6 C3 V8 e% u

  158. : h( T" L3 k2 ?
  159. class  self1 H. v% f6 c0 l! L/ \' o8 ]* d
  160.   #--------------------------------------------------------------------------
    & j! p8 j' |0 @  Y
  161.   # ● 初始化
    3 P1 Y$ B4 j9 z; x4 J8 T# l
  162.   #--------------------------------------------------------------------------1 O- V# p8 d) q, l0 x6 Y
  163.   def init: ~* {3 `) \1 K) B
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor6 _& @# P+ O. N% L
  165.     @left_state = 03 I; b. `4 E, p9 W
  166.     @right_state = 0
    1 G* z- [  v9 _! F! N* s( {4 \
  167.     @ck_count = 0 # 帧数计,单击以后从0开始* {/ ^/ Y7 T+ w- y
  168.     @dk_count = 0 # 用于双击的判定
    7 T# R! Y5 b' e6 [- b
  169.     @clicked = false6 Q) L2 D( `7 [0 I" H3 w& [$ ~! a
  170.     creat_mouse_sprite4 z. i# H  h9 C* Q" \& m' G
  171.     update* v- o2 R, ?  I
  172.   end
    * H- H; B: Y  f
  173.   #--------------------------------------------------------------------------. t0 b. j8 a7 ]* R+ N7 u% h1 q
  174.   # ● 鼠标指针精灵# x% M1 G- E4 D
  175.   #--------------------------------------------------------------------------9 Z' p3 h$ L! I, X8 k" {9 ?
  176. #~   def creat_mouse_sprite
    # |# ]& Q' Q/ w" v( W3 q. m- l
  177. #~     * p' J) l, Q4 j* b( X9 _
  178. #~       @mouse_sprite = Sprite.new# D  u! l2 y2 O* U& M
  179. #~       panda = 2#rand(2)+14 e6 u: U9 q% j4 Q# d; |

  180. " F+ R$ }0 e" }1 H6 Z, }6 u4 v
  181. #~      if panda = 1
    2 t( B. Z, B# s" O& S
  182. #~        if File.exist('GraphicsSystemCursor2.png')# ?2 |5 `7 Y  f  [8 s. o
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    3 F+ f9 H' C# @
  184. #~        end#with if File.exist
    9 O% y5 ]! X8 K8 w# {
  185. #~    ! P$ x% N% a* s: I5 L2 _' v
  186. #~     else if panda = 2 #with if panda=1
    , [8 q7 D; @4 H) j
  187. #~      % _+ D: w- K. B$ I9 V
  188. #~      if File.exist('GraphicsSystemCursor2.png')% M8 p% \6 t' p3 f
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    : C: j) X$ ^6 C7 t3 k2 }  h
  190. #~      end#with if File.exist; ?3 c5 K1 A, Y0 g9 Y
  191. #~       * j. G* ]* [6 Q; ]
  192. #~     else #with if panda=1, L) y. G, k# t+ k  B, A2 g( J
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    5 V* p1 F3 N- D
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    ' \" `) y: R: \) u  g) L# O
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    ( h  R4 B: P" W# v8 U7 O
  196. #~     end#with if panda=1
    0 N5 H; h; q# b
  197. #~     
      O# x3 P( a# }% H1 q; e. o8 l
  198. #~     #with def4 X3 f$ M" U1 ~# t4 |8 r3 i
  199. #~   end6 y6 y" A9 G7 D, l9 ?- G# E
  200. def creat_mouse_sprite$ c* |+ {; t! _/ C, D
  201.     @mouse_sprite = Sprite.new
    2 t0 J- |: T5 Y. _0 r
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    4 v4 ^% k" R8 }5 |
  203.     @mouse_sprite.z = 9999  ?9 R0 G/ a5 \8 C
  204.     Show_Cursor.call(0)
    1 s( O  q, z1 O5 V- e0 U- r
  205. end+ r' W* c: D. u2 h1 _6 s& o

  206. & d# O! x( f% v: j
  207.   #--------------------------------------------------------------------------
    8 t2 Z6 w7 P' B$ ^: x7 ]" s# k' ~
  208.   # ● 更新0 z; q) g5 h1 J4 E$ e' ]) R
  209.   #--------------------------------------------------------------------------
      c+ D) h3 P5 _3 |4 v
  210.   def update
    % W- Y8 F) H6 L' R) u4 V# L1 w
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    + i- {/ {) k' L4 K
  212.     left_state  = Get_Key_State.call(0x01)$ j$ G) b: u5 N' A
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    8 s3 }% H6 G: O; S: e% D
  214.     right_state = Get_Key_State.call(0x02)( `* W% ?+ \7 r
  215.     right_state[7] == 1  @right_state +=1  @right_state = 01 y5 v* n$ z, f
  216.     update_double_click
    ) O# a1 w! V$ R7 _* i
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1; E( a, z5 Y- S
  218.   end. K7 l" v7 y/ {6 G
  219.   #--------------------------------------------------------------------------# i- g9 z3 @7 H; i4 t5 c
  220.   # ● 获取鼠标坐标
    , R$ C: _8 ]% g% A
  221.   #--------------------------------------------------------------------------# K; ?: A& }! c9 X9 I, w; E: O% T
  222.   def get_mouse_pos3 y/ v8 C( [3 F2 h: e, Y
  223.     arg = [0, 0].pack('ll')
    7 w6 D7 K, d2 k3 Q( h8 u  d
  224.     Get_Cursor_Pos.call(arg)6 t( H( j' b6 O* P: U9 U& |, r
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    * Y" V( T" I: C. q
  226.     x, y = arg.unpack('ll')* ]; U$ I" W: `. Q
  227.     return x, y
    ; K3 {& W8 V/ H0 R" d
  228.   end! m0 A( |. k3 V: y1 g3 ~- F7 W
  229.   #--------------------------------------------------------------------------9 |1 }$ U5 }7 U/ ^. B9 e3 H' v
  230.   # ● 将鼠标固定在屏幕内
    / w, j% w3 L1 ^; J) L" f1 F
  231.   #--------------------------------------------------------------------------: S5 @$ ?1 O% Y. r! L
  232.   def lock_mouse_in_screen. u" x* _: O  T% }' c. M9 g8 W
  233.     arg = [0, 0].pack('ll')
    6 q8 M. l, X4 s9 i# T
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    3 Y7 E2 X0 d6 s$ @4 u, U
  235.     x, y  = arg.unpack('ll')$ r8 }; d$ c5 n( }3 _
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
      o  |; W6 T8 r2 c! ^9 ^
  237.   end% `, X1 B4 L) N
  238.   #--------------------------------------------------------------------------
    2 w- n$ Q: s( s
  239.   # ● 解除鼠标固定
    9 W6 _! Y- r* U, e
  240.   #--------------------------------------------------------------------------
    - _0 B+ D# b8 q* ~' `
  241.   def unlock_mouse_in_screen  D' i+ z8 v, b- `/ N0 O
  242.     Clip_Cursor.call(0)
    ; \% k  Y+ |6 I: v& Y
  243.   end
    & d* }" B5 C- t4 y
  244.   #--------------------------------------------------------------------------
    ) R$ A6 w( j: J8 N# Z
  245.   # ● 鼠标双击判定
    ) d: Z/ T/ c9 l
  246.   #--------------------------------------------------------------------------$ @6 X, K9 O  S& ]
  247.   def update_double_click1 ?5 @# i  f/ D, R; S% a: K. ?
  248.     @clicked = true if @left_state == 1* j; _- G& k( S5 |& @# _# i; L: z
  249.     if @dk_count  0 && @left_state == 1
    4 P' f9 Z  S/ S, a& j3 z! n
  250.       @dk_count = 0; @clicked = false
    # |4 u5 i  A# R/ Y$ p" h. n8 E( D
  251.       return @double_click = true
    , Y/ I& j, ~0 S$ J! s: F$ M
  252.     elsif @clicked1 C# |' R! A8 a/ w/ H" }, a( D
  253.       if @dk_count  KsOfSionDbclick_Frame
    : m: B- d9 w  k5 f. g
  254.         @dk_count += 1
    & p( X9 F. b9 P& ~0 f* ^
  255.       else( [$ ]: Q/ R7 w& O, p
  256.         @dk_count = 0; @clicked = false, j9 l0 h: Z/ _" w) h9 W
  257.       end
    0 C9 T6 i2 M8 {8 i) x/ m
  258.     end2 b3 l$ n3 `7 l  W, E+ \- S, e
  259.     @double_click = false
    " `+ h1 f7 u" E% r
  260.   end7 P  N' i% {2 ~0 S& n2 l
  261.   #--------------------------------------------------------------------------
    8 \" }. H7 n/ z& o
  262.   # ● 按键被按下就返回true
    7 I: i4 T3 Y2 _- R
  263.   #--------------------------------------------------------------------------
    , B6 c2 ^# P* ~& E! Y
  264.   def press(button)  u; w8 K. ?+ O
  265.     case button5 L+ U8 v$ u8 ^) `
  266.       when 0x01; return !@left_state.zero$ ~$ w& |7 Y! Q9 Z8 f4 @
  267.       when 0x02; return !@right_state.zero' v; G2 @( i$ R( Y1 W- F
  268.     end
    2 u; A# v- |4 B6 {
  269.     return false5 m9 b; x% U9 G9 e! y
  270.   end
    & L. r$ O  T- h
  271.   #--------------------------------------------------------------------------1 N! [1 K1 l+ }
  272.   # ● 按键刚被按下则返回true
    , X& Q" u( }: w3 U3 q
  273.   #--------------------------------------------------------------------------
    ; I; x' M# G) i7 I9 ^! y
  274.   def trigger(button)
    # X% E( J; _: @: p' @0 d' v
  275.     case button
    + T" w* y9 S5 u7 w+ N9 n- `
  276.       when 0x01; return @left_state == 1( q0 o+ i- q1 @! T
  277.       when 0x02; return @right_state == 1
    - H; a; K8 g! k. F2 E: B" Z
  278.     end- ?' l) k& q4 A$ Q
  279.     return false5 G; I. R" k9 g8 L! z5 ]2 D
  280.   end- C; o- {3 C; t, N! d
  281.   #--------------------------------------------------------------------------9 A  v; I- E/ ~( o' e! Q  R, \( Z* E
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true$ t  s6 w* N5 L) ?3 E; P
  283.   #--------------------------------------------------------------------------
    $ D6 r% @# t' V; z! \
  284.   def repeat(button)" h6 v: Q6 x/ W
  285.     case button2 ]9 H, O8 q. [! D8 \5 e* s
  286.       when 0x01; return @left_state == 1
    $ e/ ?) [- y  d: T, H2 \
  287.         (@left_state  22 && (@left_state % 6).zero). r( ~) Z$ I5 Y; h6 J, H" R- q/ ^
  288.       when 0x02; return @right_state == 1
    , i, ]- h3 _% Y7 @& k, F
  289.         (@right_state  22 && (@right_state % 6).zero)" T+ U& I& V% v3 E( W, B7 _$ a9 `$ m
  290.     end; M: ~& {/ R: l( A- Y( D1 b
  291.     return false; N" |0 ^" W' a/ S6 V3 ?2 ?6 {- g$ l" B
  292.   end; f$ \! K3 A5 f8 e8 ]0 c( N
  293.   #--------------------------------------------------------------------------
    1 G" h1 z5 S6 q- V7 T' L
  294.   # ● 判断是否双击鼠标
    ! n' w3 v3 r0 w0 b; h
  295.   #--------------------------------------------------------------------------
    * ?# z- o+ X0 |  m
  296.   def double_click
    / X9 M4 ]0 }9 f* u8 d2 o/ v8 R, n( e
  297.     @double_click- k- S1 y8 u+ s* ~7 S. U6 L  e
  298.   end+ A& l1 z; J; `) J! J
  299.   #--------------------------------------------------------------------------0 v+ g* r! {. r) ~
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    - n4 ?2 ^; r7 M. S( g
  301.   #--------------------------------------------------------------------------6 _- @# N- D; v8 V
  302.   def click_count. B4 l- `& s! D0 K- H' ^3 w9 u
  303.     @ck_count
    % R1 t( ~6 S. H! t0 B
  304.   end
    1 {5 B" ?! V0 |( t! i3 v
  305.   #--------------------------------------------------------------------------
    3 Z, v! _2 C' X1 L, ]( O
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    , t3 x5 K% v2 F
  307.   #--------------------------------------------------------------------------! O# f- E9 }: ~' l* K. r9 [5 o
  308.   def left_state
    ; S* u) b3 s1 Y7 t8 k5 i
  309.     @left_state
    5 ]( u+ V9 N9 _  v) [, N! [& v
  310.   end
    ' h# R6 e: h0 i; q
  311.   #--------------------------------------------------------------------------
    9 v9 W- G: p$ ?5 E- Q( I. e/ k2 H4 ~
  312.   # ● 获取鼠标的x坐标
    / U0 f. ]+ \; b7 L. Y
  313.   #--------------------------------------------------------------------------4 e# O7 _  o+ F1 O: Q: A, W3 m
  314.   def mouse_x: @( ~5 y! J3 S# W' q
  315.     @mouse_sprite.x
    * ^* ~8 k1 Z1 A
  316.   end
    , f% |4 \# A7 @& Q" }3 }9 M
  317.   #--------------------------------------------------------------------------
    - p5 w: t% J9 a# S; q/ t+ X$ e
  318.   # ● 获取鼠标的y坐标7 u) m; f% G/ v$ f7 P0 C) h. x
  319.   #--------------------------------------------------------------------------; ?, |$ R# I3 i
  320.   def mouse_y
    9 S7 t# v4 ~; Y" s
  321.     @mouse_sprite.y
    / n+ f6 Y9 ~8 \' l2 y
  322.   end
    % @% ]! X9 J3 K6 G' b
  323.   #--------------------------------------------------------------------------
    ! V+ L6 R1 ?/ ~, g' z& `  ~
  324.   # ● 设置鼠标坐标
    9 I) f! ]; u& ]) A
  325.   #--------------------------------------------------------------------------
    . g1 T5 h4 K& l% U4 \7 b; U) R6 i
  326.   def set_mouse_pos(new_x, new_y)
    ( J- G4 @2 O4 K4 z6 d0 l
  327.     arg = [0, 0].pack('ll')' h- y/ g3 I! j
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    - F( y8 s' a* A' [' t
  329.     x, y  = arg.unpack('ll')
    9 p# N4 v! `) b3 v
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)2 c0 v2 P( C; \2 C5 h
  331.   end& {$ {# T$ K: z9 w! m1 l6 G* W( E# H" M
  332. end #end of class  self
    % J8 H% {7 z; z' {" |
  333. ! q# L& }. \' q2 r% ?1 g
  334. end$ @2 M) a8 S* N& {% `( E
  335. * S7 P- C. f% V9 y1 h! l7 J' F
  336. #==============================================================================
    / B' W' l% V- R: w/ I- M- ^0 ^
  337. # ■ SceneManager8 ]# Y* U$ y8 m5 x7 y4 ]
  338. #==============================================================================; N% `- E/ X* Y  t% L
  339. class  SceneManager  y1 H6 V3 O7 L. z
  340.   #--------------------------------------------------------------------------9 T4 i4 r$ p5 @' e# F' H
  341.   # ● alias" o7 E- Y: Z: S5 j
  342.   #--------------------------------------------------------------------------
      J: M8 ^8 N4 K# q2 l$ s% j$ X
  343.   unless self.method_defined(sion_mouse_run)
    + z* O) v' J& Y: ?  z; q& E
  344.     alias_method sion_mouse_run, run
    % A/ t! a2 V; J6 P/ u
  345.     alias_method sion_mouse_call, call
    + ~8 y! B! W; F! ?" g
  346.     alias_method sion_mouse_return, return
    9 F0 U1 H4 u9 j0 A: Q
  347.   end6 T$ P- q% C5 U: I, K
  348.   #--------------------------------------------------------------------------/ [+ b4 S: X8 k3 f" K$ i
  349.   # ● 运行: @7 U; g! R3 @- M0 ^
  350.   #--------------------------------------------------------------------------
    % F0 y, d& y# ]% a8 g
  351.   def run
    " x1 R( w# o2 x# y) e+ C! G0 e' d
  352.     Mouse.init
    4 B- B1 E! y- b! Y
  353.     sion_mouse_run8 K  [3 T+ K1 ~( F# }3 A2 i
  354.   end
    , k% z% }, l9 h" c/ s2 b4 f& w' d
  355.   #--------------------------------------------------------------------------
    ( M7 _5 b; E8 C2 S$ c
  356.   # ● 切换
    & v4 u! g- L- m% j8 q% k- Z- ^2 l8 _
  357.   #--------------------------------------------------------------------------
    , E' @6 G7 B, N
  358.   def call(scene_class)" ~. p- l2 i4 t& a4 z
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)( V) w) J* R3 b$ z/ F/ i9 [, E+ p
  360.     sion_mouse_call(scene_class)+ M* E( `) ^3 w2 D4 e6 Y
  361.   end& x7 I. @9 l* m, m2 {
  362.   #--------------------------------------------------------------------------. o' s# d, A6 ]% b; B7 z
  363.   # ● 返回到上一个场景- X+ V) f! r+ n; b. g5 \; |
  364.   #--------------------------------------------------------------------------+ }6 x8 f9 N: B  k( ?* L4 \
  365.   def return5 i# X" K4 N+ G- Q; C: `1 h, O
  366.     sion_mouse_return
    ) _# `9 J2 r2 ]; D( |! w
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    0 H& C" c$ |/ n; R0 Z
  368.       @scene.instance_of(Scene_Map)2 i# v/ d/ L) v) V
  369.   end' u! U: V; l8 `& i
  370. end1 s2 F( E! M, a- w  h

  371. - C) C2 w, F0 V% F" l
  372. #==============================================================================
    ; B/ Q3 V: e4 j
  373. # ■ Module Input, I/ T# N& j& \8 l$ d
  374. #==============================================================================
    - ^* V# F3 L# P5 n0 o+ h" B; A
  375. class  Input
    & i+ q8 R: h3 D* r% A
  376.   #--------------------------------------------------------------------------$ Y, T) N- H/ W5 G: W" T
  377.   # ● alias
      Z3 h9 q$ U$ Q8 c9 h5 ~
  378.   #--------------------------------------------------------------------------0 r8 w( V7 j! o! [% J' `0 z
  379.   unless self.method_defined(sion_mouse_update)
    5 s5 \4 V; y# h! g- z2 Z
  380.     alias_method sion_mouse_update,   update
    0 |) Y4 Q8 D) `0 b0 ]
  381.     alias_method sion_mouse_press,   press# e9 ?2 l( B8 \
  382.     alias_method sion_mouse_trigger, trigger# a+ B+ j: Z' @; |7 ^3 D! a
  383.     alias_method sion_mouse_repeat,  repeat4 D3 Z1 l& J' _, W" g
  384.   end
    5 w; R& N& F1 t( B8 h; w' Z- ^9 S( q
  385.   #--------------------------------------------------------------------------
    # w) V8 L' V5 f; S9 X5 E& r& Z
  386.   # ● 更新鼠标7 [2 j5 Q' m0 S
  387.   #--------------------------------------------------------------------------' W6 I5 f& J6 u" U& M
  388.   def update! F# \7 v$ Y( P; h3 v( r0 s
  389.     Mouse.update: ^/ Y  T$ N) `' o' O5 I: P
  390.     sion_mouse_update
    ; V5 g8 e% M: i$ K/ C4 k5 O5 u
  391.   end
    2 v7 E  h9 l* C! I+ U0 f; J
  392.   #--------------------------------------------------------------------------3 Z: a% Z- {( s& z" t/ e+ Z
  393.   # ● 按键被按下就返回true  r# x5 Z# A' W: ]8 b
  394.   #--------------------------------------------------------------------------1 e" R# P, f3 z$ m8 B; x
  395.   def press(key)2 M  s" E0 @: h9 X
  396.     return true if sion_mouse_press(key)( a8 p1 p: T, j  d- L4 L
  397.     return Mouse.press(0x01) if key == C4 z# i3 |" N; P( X! i
  398.     return Mouse.press(0x02) if key == B7 H* o+ R4 s4 p. ]( V, x; G
  399.     return false
    - n  J7 m& h  ?% {' c5 `" j! p  f
  400.   end
    $ Y- d, T% G  Q2 {% s# t7 V+ [
  401.   #--------------------------------------------------------------------------
    - F$ n5 X' R/ X, |+ Y" J
  402.   # ● 按键刚被按下则返回true. s" ?) P. |4 [$ F$ w
  403.   #--------------------------------------------------------------------------! J' n. x+ s3 U" X2 {* [% N! v* U
  404.   def trigger(key)
    ) ?0 O5 G* {) o0 {4 z; K
  405.     return true if sion_mouse_trigger(key)
    ! r& b) _5 L$ T  I( e! J
  406.     return Mouse.trigger(0x01) if key == C; J6 p; |. {! @: B! T) B2 n
  407.     return Mouse.trigger(0x02) if key == B0 I  e3 q0 z8 \
  408.     return false& p3 a0 Y; D% F- r/ \; S( f9 O
  409.   end# J4 f# n: O% P9 S7 B4 |0 f8 o- Q
  410.   #--------------------------------------------------------------------------
    3 K$ b; Q( c4 V% {, c7 V  V
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    1 N+ c; S! H$ h: X6 N2 z
  412.   #--------------------------------------------------------------------------
    . y8 v9 j1 Z: t) A
  413.   def repeat(key)
    4 f- P7 t3 @& d# f% ?
  414.     return true if sion_mouse_repeat(key)
    # r9 _) n* y; [) e/ Y4 i. ]  M
  415.     return Mouse.repeat(0x01) if key == C7 d: t1 Z4 o4 X, v( T& Y
  416.     return Mouse.repeat(0x02) if key == B1 r' _6 k" _8 t8 U2 e
  417.     return false) {2 M+ S- C! ]8 M0 l9 R
  418.   end
    $ L; P1 ]2 Q$ d1 e
  419. end, t) R+ I( `2 w4 C  k  |
  420. % i+ w. L0 L' R1 h4 C  X

  421. , q9 @7 j$ q$ }4 Y: {8 }+ J
  422. #==============================================================================8 C  Q9 I( k' f; i" Q! x* G
  423. # ■ Window_Selectable
      B7 f9 H( k* Y9 A; A7 l+ W1 T
  424. #------------------------------------------------------------------------------
    & w1 B2 z1 I# B1 J; P3 H3 |$ {
  425. #  拥有光标移动、滚动功能的窗口
    $ i6 G# Z; o. v  b! Q/ Y. J5 C
  426. #==============================================================================% E2 q# A* x( j( _6 B
  427. class Window_Selectable
    ( J2 J3 Y0 {3 l- r
  428.   #--------------------------------------------------------------------------* P2 P- x4 k% t4 p1 h4 m
  429.   # ● 初始化
    - n+ v* j, L- T) B3 M: i' Y
  430.   #--------------------------------------------------------------------------$ k6 i' @; b' @( `9 z1 G- y$ a; E8 h
  431.   alias sion_mouse_initialize initialize
    4 @, b* A7 u' }- }! {0 v
  432.   def initialize(x, y, width, height)
    ! M6 d+ y" h9 U4 ?4 E5 R! l6 D
  433.     sion_mouse_initialize(x, y, width, height)9 o  Y1 o1 w% c9 G$ L' b- V! c3 x8 D' I
  434.     @move_state = 0
    5 v; I8 W, b8 D! `  H9 O1 d7 q
  435.   end) F/ H  Y. M3 X5 J
  436.   #--------------------------------------------------------------------------
    8 u" k. I( W0 ^  x3 z) d
  437.   # ● 更新. X. t' p- M9 E6 a
  438.   #--------------------------------------------------------------------------
    % _& ~2 Q7 [# f8 x. c! p
  439.   alias sion_mouse_update update
    ( t' _" N& t$ I
  440.   def update: h- N: w' k3 K! ?/ p4 l. c
  441.     sion_mouse_update
    * `$ r' {% }4 u2 j& q) j
  442.     update_mouse_cursor
    4 j7 c4 @8 ?, w6 J! q0 m
  443.   end
    . s) m2 V3 x/ \3 m) O( j& b
  444.   #--------------------------------------------------------------------------
    - p, Z  d$ D- Z* o6 j) K) I
  445.   # ● 启动后设置鼠标到index位置
    5 z7 z1 Y! d3 y) g5 J! V
  446.   #--------------------------------------------------------------------------
    + q) T- `4 }1 H$ A2 W* a
  447.   def activate& h' s, R4 C7 ~5 \- V$ k
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    % h, N! o) a; O5 i! ?
  449.     super
    1 w! g& x) w% o+ u; S- T# I4 h
  450.   end' v5 N3 O1 D0 C: t6 e
  451.   #--------------------------------------------------------------------------) d5 N  K' F4 x: i1 N
  452.   # ● 更新鼠标和光标的位置
    ( P8 i4 A9 W0 C# @
  453.   #--------------------------------------------------------------------------
    2 [3 l! h# |' \, G5 [2 H' T
  454.   def update_mouse_cursor5 U* r. [& l8 a- O; ]  ?* D. V
  455.     if active: [4 c9 v4 H( ^
  456.       if @need_set_pos
    . X1 M3 F* A' H) z/ B# v! V+ R
  457.         @need_set_pos = nil
    + x1 m( G. f  n
  458.         set_mouse_pos  E# c! L3 x. O9 i7 g& t  S
  459.       elsif cursor_movable
      V8 t* a* }$ `" r( w& N
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    ! J  d: F! _. v+ w6 G  y
  461.       end) b7 O- ~5 r5 K6 q; `# E
  462.     end/ Y: E" N4 d* b; ]+ C' c
  463.   end
    6 L/ x( p- U3 z
  464.   #--------------------------------------------------------------------------
    4 E3 z" O' x' U9 L2 r
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能1 a/ K+ a3 F( ?  j0 K. }: e9 _) }
  466.   #--------------------------------------------------------------------------
    ; I' V# \: {+ i5 r- K$ u
  467.   def set_cursor
    . y' o3 L* x4 _9 F
  468.     mouse_row, mouse_col = mouse_window_area0 U. R9 p5 D. K; a
  469.     if    mouse_row == -1$ r- m8 h* A1 _/ f6 {) [) X  L
  470.       @move_state += 1 if need_scroll
      J2 p9 x! D- X: r2 `5 ~
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ' V; s( ^  M' M& U
  472.     elsif mouse_row == -2. j  O( w( {5 `: f5 Q% b8 {
  473.       @move_state += 1 if need_scroll
    0 E: m! x5 E( J; A2 i
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    % [; X7 \# ?; [7 M; V# A) [$ v- }
  475.     elsif mouse_col == -1! y& G1 G' o( R- F* T0 z  S
  476.       @move_state += 1 if need_scroll
    * z7 E' G9 A* Q0 O0 K
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
      ?! K7 T4 J, J$ Y0 q) V
  478.     elsif mouse_col == -2- `( U% S3 \  }! i5 G
  479.       @move_state += 1 if need_scroll
    . E! v: k' ~. A" Y3 ?" `& \4 t1 z4 C
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand  D" T8 n4 e9 e+ m
  481.     else
    % m) l0 l" p2 b* m$ i. x
  482.       @move_state = 01 t) [1 o6 b4 j$ q+ a. h3 }
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col" y+ p, E* ?. d" e9 H$ g/ K. C
  484.       select(new_index) if new_index  item_max && new_index != @index
    . \( Q+ g8 z! l0 o! T, @
  485.     end
    # m9 h+ C/ \: b3 k- S% v& g& _
  486.   end# A) w+ E  Z5 [" O3 t; I, x
  487.   #--------------------------------------------------------------------------
    % R1 R# n% a) Z) y. e: N: ~" {5 ]
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    1 @8 y+ ~$ ^6 I: g  Q5 D- v
  489.   #--------------------------------------------------------------------------: W9 A# X/ H& q3 v+ Y
  490.   def mouse_window_area: G7 E' n) v$ Q0 \$ `6 P9 N
  491.     if viewport.nil # necessary!! E, n- }" B0 _4 H
  492.       vp_x, vp_y = 0, 0, ]$ e3 ?8 O2 w) `; O5 g0 ^8 C& u
  493.     else) ^2 l2 ]; A# ]; Q: p/ d
  494.       vp_x = viewport.rect.x - viewport.ox6 P! k" U7 }! u& ~8 H3 x. D: s
  495.       vp_y = viewport.rect.y - viewport.oy
    ; f0 D0 H, N% `7 K- {
  496.     end
    + P% L' M  k/ k: w
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y0 x2 c9 ?/ Y" W0 D: u+ e! o+ p
  498.     item_x1 = vp_x + x + standard_padding # }4 v! C3 W+ N& p+ s
  499.     item_y1 = vp_y + y + standard_padding
    ' f' h, F& M3 d" W
  500.     item_x2 = vp_x + x - standard_padding + width
    3 N; ?& i9 A6 K' z, y3 R( }9 ?
  501.     item_y2 = vp_y + y - standard_padding + height/ C3 N3 b/ N: I* S. G6 A
  502.     if mouse_x  item_x1
    4 T* B( y2 H, m5 o. ~  _0 m
  503.       mouse_col = -1% n9 m; m1 d* M& F2 i
  504.     elsif mouse_x  item_x2! l* k8 x" t. f- a  Y/ y, o
  505.       mouse_col = -2
    & d% |! g. L- u5 P( v% G/ {8 A8 P! F) r
  506.     else
    % s1 r5 D% L; L- ^. ]
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)+ B' g7 D- \: Q9 y/ X; D7 l
  508.     end4 t0 z% O* w1 `- W/ K' X( t
  509.     if mouse_y  item_y1
    8 Z% ]9 P; }6 g6 d- l" f7 K* \
  510.       mouse_row = -1" `4 h, f" O; f* X' H6 F
  511.     elsif mouse_y  item_y2
    & V- m% b& Y9 h; K" S& X! W
  512.       mouse_row = -2# d) D" @- X# P; m, z% {0 c# J
  513.     else2 w2 O* c! q- ^+ F+ [
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)8 y5 M: s, ]: L) r. Y" R2 z8 }% v
  515.     end. M  j1 ^( ]9 i1 P
  516.     return mouse_row, mouse_col
    % |, \1 k  f, W, U
  517.   end
    8 _' s5 g) i* l1 x
  518.   #--------------------------------------------------------------------------
    + N0 e1 m# J4 f
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置7 r% {" w8 [# v$ L
  520.   #--------------------------------------------------------------------------
    7 B7 Q1 E) Y& Y- q* w  k/ Q) D+ H
  521.   def set_mouse_pos
    3 e$ p, k3 H2 Y0 l
  522.     if viewport.nil # necessary!
    " e& i* p4 w- ]+ a4 L/ `
  523.       vp_x, vp_y = 0, 0
    2 o* ]& X7 O& c8 j) I+ s) f
  524.     else
    ' A* T* {# ^3 F8 Y
  525.       vp_x = viewport.rect.x - viewport.ox
    8 G2 G& H/ K2 n1 L) A
  526.       vp_y = viewport.rect.y - viewport.oy4 v. X9 M, Q. s0 \6 T) t
  527.     end0 }( P% l0 ?" _
  528.     item_x1 = vp_x + x + standard_padding 0 R0 q7 w9 B% z9 [7 r7 k
  529.     item_y1 = vp_y + y + standard_padding
    4 i' n, n. y3 V0 N3 k' Z7 x
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index $ x3 A/ [1 \; q6 ?6 f; b% B2 z
  531.     row = get_index  col_max - top_row# A0 L' h4 ^) i. f( \9 l& J1 g+ W
  532.     col = get_index % col_max7 U. R5 r, Z, v" y
  533.     new_x = item_x1 + item_width  (col + 0.5)
    2 v/ D+ a; n3 B- U
  534.     new_y = item_y1 + item_height  (row + 0.5)
    5 k* X) G2 p! `) Y2 d: P2 n: a4 N
  535.     Mouse.set_mouse_pos(new_x, new_y)
    - Y( j% ^  F* t
  536.   end
    # J  \- S- F/ b" X- [  X8 b
  537.   #--------------------------------------------------------------------------
    " N1 h& x  h3 d+ e; ]$ |6 q/ V) d
  538.   # ● 判断菜单是否需要卷动
    0 w1 W( `5 ?3 k3 d
  539.   #--------------------------------------------------------------------------9 d9 H, S( ^0 K
  540.   def need_scroll
    3 N1 D6 R/ m: j5 K# S1 X7 E
  541.     item_max  col_max  page_row_max2 y! O& s) Z( a1 v# R, H! R& ]% C
  542.   end( L+ _; w# ?* F9 Z  Y
  543.   #--------------------------------------------------------------------------
    ( n( L8 R2 Q, G- K* P, ?7 l3 L
  544.   # ● 判断是否为水平卷动菜单
    4 X4 T# h- ^0 w! V
  545.   #--------------------------------------------------------------------------" g* U; Y4 D& {1 J9 v- G
  546.   def is_horzcommand: Y1 A5 E5 N: Z/ Y; Y" s
  547.     return false- X4 K' e% z4 |: G) X, W5 E$ @( U/ ]
  548.   end
    ' D5 d. P% r, n4 W! L, _" l4 t
  549. end/ h& o6 i9 |, F2 i

  550. & ^; @+ L( J# o8 h# Y7 T0 N7 G2 B5 i
  551. class Window_HorzCommand# @$ |: D3 M! O) V
  552.   #--------------------------------------------------------------------------
    0 `: x- Q2 k# W. u1 I/ n
  553.   # ● 判断是否为水平卷动菜单
    # P7 R% ^; ~; V% F& R
  554.   #--------------------------------------------------------------------------
    " @& A0 ?. Y( ^; S& y# L
  555.   def is_horzcommand& B. @8 C3 l2 ?2 ^1 r9 M; x8 N3 ?$ S
  556.     return true
    3 K+ q5 F  u* F
  557.   end1 P2 Q0 t. ]  Z: \# ~  W9 v% H) p" E
  558. end5 f: M. J$ I5 B! f# R% L
  559. , |$ n) t# Z  ~6 |( m3 |. X
  560. #==============================================================================/ O# R$ o+ m& \/ d- c- ?  p' A
  561. # ■ Window_NameInput  c- S& F7 h- A/ m$ T
  562. #------------------------------------------------------------------------------: R* m9 _4 u" P! b
  563. #  名字输入画面中,选择文字的窗口。0 l: E4 P/ P/ {5 f# A* J" q
  564. #==============================================================================0 z* B' `8 T6 t! b) E" d6 l0 [
  565. class Window_NameInput. e* h4 U. `% ~2 \
  566.   #--------------------------------------------------------------------------
    ) `* Y' q# Q& [' b
  567.   # ● 设置列数
    & I  ?5 A* M) I7 W& I! m
  568.   #--------------------------------------------------------------------------
    2 e' }- Z6 o) s" D
  569.   def col_max0 z1 n9 h5 R! z% r  z2 k1 p
  570.     return 10
    : t9 V! V' Z0 _+ k
  571.   end
    7 N8 S/ ?  p4 W" }" Q( n( m
  572.   #--------------------------------------------------------------------------
    $ Y; s" @6 A% R$ O  ^
  573.   # ● 设置填充的Item个数
    ( M+ K. E1 c5 I# @8 s
  574.   #--------------------------------------------------------------------------$ X) i6 v$ x, b
  575.   def item_max9 s/ a. v9 u+ B% a
  576.     return 90" l. @2 _7 E+ J  |6 e
  577.   end& M/ [+ }7 x" ~5 r( d6 {  r* d# i
  578.   #--------------------------------------------------------------------------1 q& y/ m) Q. j  _9 c
  579.   # ● 设置填充的Item个数
    2 M8 N( u. K8 j, w/ h; |! a
  580.   #--------------------------------------------------------------------------2 j' E& I' f# l. J! Z
  581.   def item_width3 e+ w8 s/ b; C4 }! n* C
  582.     return 32
    9 \: X7 v6 l6 {" a  p7 y1 h
  583.   end, j4 R; g2 w6 M/ [8 l) r4 j. w
  584.   #--------------------------------------------------------------------------4 E% a* g9 ~# z1 h; D" X- r3 R
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    1 V3 y: {$ R! e7 Z1 Q0 G
  586.   #--------------------------------------------------------------------------0 B8 H* M: C5 W" l
  587.   def mouse_window_area3 P; E) P* e& L6 P2 _
  588.     if viewport.nil
      A# U$ q$ \0 a
  589.       vp_x, vp_y = 0, 0- ^/ p5 j5 ?3 z+ i5 l; Y5 X
  590.     else
    3 L; ]- x7 Z$ `" d* w
  591.       vp_x = viewport.rect.x - viewport.ox6 ~8 Z* r9 z6 ?  ^/ ]+ @
  592.       vp_y = viewport.rect.y - viewport.oy% E+ p- h& s* l* T
  593.     end/ V8 ?9 ^+ g6 n, ]4 Z( z; t4 R
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y* j5 o  Y# N& Z1 a  w6 s
  595.     item_x1 = vp_x + x + standard_padding 4 Z& |$ q% M2 l9 G
  596.     item_y1 = vp_y + y + standard_padding
    ( w; O" k( {8 m7 O/ {
  597.     item_x2 = vp_x + x - standard_padding + width' V7 ^6 C' a! p, Q
  598.     item_y2 = vp_y + y - standard_padding + height* i" g, n$ |& Y5 G
  599.     if mouse_x  item_x1! \  d5 R8 J" R0 J
  600.       mouse_col = -1; x8 Y: X: C& {7 t8 G+ y$ ]  w
  601.     elsif mouse_x  item_x2
    % `& {# r( C1 L
  602.       mouse_col = -2
    $ J7 h5 p! ^8 ?6 I, I! D
  603.     elsif mouse_x  item_x1 + 160
    # _# ~( j/ o; O
  604.       mouse_col = (mouse_x - item_x1)32) ]' k8 r" o% M! Q* n
  605.     elsif mouse_x  item_x2 - 160
    ! B% i3 ~% o  Z8 |' \) ?
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    4 R: x9 s" n1 [* x, `" M5 J5 P
  607.     else
    ) u2 V; s5 w7 P; |
  608.       mouse_col = mouse_x  x + width2  5  4
    . v' ~+ {, G/ H; A3 q5 |& v1 @) F
  609.     end
      f9 j! l/ W8 a
  610.     if mouse_y  item_y1
    ; S0 |& v# ^, E+ G' u  l
  611.       mouse_row = -1  M7 O# L- c- @% M& t
  612.     elsif mouse_y  item_y2
    1 d! b. l0 V( y: W$ t& r
  613.       mouse_row = -2
    * {+ t. j& ]; ]) E8 H
  614.     else
    ; M/ a  d; ^, {' U
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)7 [- j; j$ ^! Z7 v5 S* }
  616.     end
    8 {( o# C% N& W* O  g* }. d
  617.     return mouse_row, mouse_col  y9 V3 o9 q3 F/ k# H4 Y
  618.   end; x& c: _5 D4 U: m
  619.   #--------------------------------------------------------------------------
    + ]4 M7 ?- \: y- K2 C( ^3 g1 S, s3 A' P
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    $ a) A; R* d# k6 H& h. U) N
  621.   #--------------------------------------------------------------------------
    & P6 K  x! v& y
  622.   def set_mouse_pos7 @3 W$ D5 v2 s$ ~
  623.     if viewport.nil # necessary!6 [9 B2 k4 E3 r) G+ {! n0 J
  624.       vp_x, vp_y = 0, 0
    8 h. j- c# M$ H8 e6 q) e
  625.     else
    4 v. ]) m# C2 o# V: Q) R
  626.       vp_x = viewport.rect.x - viewport.ox
    / z9 H2 _) Y9 L/ T- _( K$ Y2 x' Z
  627.       vp_y = viewport.rect.y - viewport.oy: v2 o9 [; p2 H3 s( b
  628.     end
    $ d# f- X' z1 K+ P3 N% T8 a
  629.     item_x1 = vp_x + x + standard_padding " T, H7 Q# |: _0 Y0 U9 J! Y/ C, Z
  630.     item_y1 = vp_y + y + standard_padding! x" g# F6 `) ?. p
  631.     get_index = @index  0  0  @index
    : H+ D* b* d8 x1 x" R8 E
  632.     row = get_index  col_max - top_row! }- X. Q) \- m) R  [6 M) q
  633.     col = get_index % col_max4 r) ^$ w1 d" y# G& K0 E! l
  634.     new_x = item_x1 + item_width  (col + 0.5)
    ' g5 C; t, q, ?; z" }
  635.     new_y = item_y1 + item_height  (row + 0.5)
    + j+ R$ J+ ~. |; b
  636.     new_x += 14 if col  4& ?# I! H) g3 J! V5 F# v
  637.     Mouse.set_mouse_pos(new_x, new_y)( f& i: V2 `, X+ ?4 A
  638.   end
    # }& |1 i3 M, I$ m6 ~; L2 [2 y
  639. end5 z% a. Q: s  `3 W8 D" u

  640. / q! x! i4 B# o0 Z
  641. #==============================================================================
    $ n6 |2 D& R5 K- y+ q# R1 ?4 i0 `" ~
  642. # ■ Window_NumberInput
    1 l- W' g" n7 \  ]) H5 o5 O" X
  643. #------------------------------------------------------------------------------$ {  Q# e2 Q' [1 V; E5 c2 g0 D+ ^
  644. #  重写了数值输入的方法以适应鼠标/ l) y. a2 U* l/ e; H
  645. #==============================================================================
    ) y1 \# o9 F) `$ B% i, U! T
  646. class Window_NumberInput  Window_Base
    . v$ X! f5 l+ a; X3 _* o2 p
  647.   #--------------------------------------------------------------------------9 z/ ]: w& M0 m
  648.   # ● 定义实例变量
    % I7 I; P+ x! p7 i8 m; x* Z3 B
  649.   #--------------------------------------------------------------------------1 O- W+ X6 G( |/ @3 F
  650.   attr_reader extra_window
    * z+ |. d/ m' \. }
  651.   #--------------------------------------------------------------------------1 a+ p$ W/ {. T7 A1 P" x
  652.   # ● 初始化
    5 D# V6 e; B' M! c
  653.   #--------------------------------------------------------------------------
    : E4 H5 a9 N" }* ?
  654.   alias sion_mouse_initialize initialize+ s* z) N/ [4 m: K( u
  655.   def initialize(arg)2 a/ b' K1 ]: G  P; }$ ?
  656.     sion_mouse_initialize(arg)
    $ k" E( L# f% B0 R2 P. P$ Q+ l1 p
  657.     create_extra_window! J& X1 F6 Q8 |% _& ^$ k1 e
  658.   end
    9 h. q) Y/ A: ]/ R0 G# q& T% w
  659.   #--------------------------------------------------------------------------2 {: n( O: O! \% O/ j0 R
  660.   # ● 启动
    7 M4 b  Y% g9 \* M& N6 f
  661.   #--------------------------------------------------------------------------
    0 P0 \$ A8 ]: ?  F; y
  662.   alias sion_mouse_start start
    , W* [/ C0 z6 ^  i
  663.   def start: A2 @  ^  ^0 W4 B# ^3 U; t1 V
  664.     sion_mouse_start  t4 j) o# W' y' N: G
  665.     deactivate+ C, }1 H% G+ Y. `
  666.     extra_start
    8 `+ O5 ?- G) }0 V' b- _! x; z
  667.   end
    ) f9 F3 Y0 E- X+ X$ y$ }3 P: G
  668.   #--------------------------------------------------------------------------2 h! K* j  e5 t- z+ n. u
  669.   # ● 创建新的数值输入窗口& H* |7 i7 d/ A1 Y' a
  670.   #--------------------------------------------------------------------------
    3 K6 p! W1 Z- p- s
  671.   def create_extra_window% f4 W# j: h( f% j  R
  672.     @extra_window = Window_NumberInput_Ex.new/ v; i) {: L* Q' C
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    " G1 Z, x5 `% u' _* s$ T" ]( b
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }2 Y; F' z( d7 [' P
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    ) G0 k8 C! \8 d* U, i
  676.     @extra_window.close_proc   = Proc.new { close }! y8 L; z( u$ k+ L
  677.     @extra_window.refresh_proc = Proc.new { refresh }- U7 v& c2 ~1 f; z
  678.   end
    * d6 z% z; k' w8 E$ g
  679.   #--------------------------------------------------------------------------/ u3 F, F2 o8 C6 p! b
  680.   # ● 激活新窗口3 j5 ~( U$ Y. v7 `7 `7 ?% ?% S9 y
  681.   #--------------------------------------------------------------------------0 B  ]8 V3 t8 w) G! ]" R
  682.   def extra_start' N$ v" w, Y+ U  p0 J0 l5 H
  683.     case $game_message.position8 o- k2 [/ h. z; D9 i3 b
  684.       when 0; @extra_window.y = y + height + 4- c" o8 L2 H8 h$ k" D6 P" h. P$ h
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    3 l. S5 M, V% o. N+ t* x  ^6 _
  686.       when 2; @extra_window.y = y - @extra_window.height - 4# ]8 {' c# n# Z1 c5 y$ }* R
  687.       else  ; @extra_window.y = 81 e1 m* P1 E0 A# c: }
  688.     end# N# `) z9 v. a! W, v9 K
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    " s, V; s& o, A
  690.     @extra_window.digits_max  = @digits_max
    ) A9 t- f8 _$ D
  691.     @extra_window.number      = @number0 J9 Q. t% _4 z9 T: {  g8 c4 ?
  692.     @extra_window.open
    " ^" z+ G$ N6 r2 H4 Q, x
  693.     @extra_window.activate! R6 b6 l8 a1 W9 n+ x3 d1 e
  694.   end6 }) v7 |# Z, i) b1 h3 Z# H
  695.   #--------------------------------------------------------------------------
    ; N5 P0 k: S$ v' G9 I, }
  696.   # ● 更新
    4 ^* O+ C  T$ @; V0 y8 {0 ~
  697.   #--------------------------------------------------------------------------: {3 Y) L5 \0 z/ Q
  698.   def update
    - f) w! F# J2 z4 q1 G; }  H7 k0 a5 ?
  699.     super
    2 d0 k5 |5 t6 c3 }9 T$ d, J1 @9 O
  700.     @extra_window.update% \% X+ E- k9 B1 G0 p
  701.     update_cursor
      ?: V. L/ E. R8 _5 r! A% T- v5 N. k* n
  702.   end) U. @, T) S% _) Z$ o- Q" g0 q; r
  703.   #--------------------------------------------------------------------------8 b; U; [2 X$ F
  704.   # ● 关闭窗口7 \2 n* f. P6 \0 Y, L3 \3 G
  705.   #--------------------------------------------------------------------------/ T2 R$ t+ R; C
  706.   def close
    8 F& z: Z1 ^% T) c. `
  707.     super$ x5 y) @5 W1 ~" d) z) W) O3 q
  708.     @extra_window.close
    . h( D; ]% ~7 ~, K/ s6 B9 |6 {
  709.     @extra_window.deactivate9 X2 R. Y, y' T  p& [
  710.   end
    , t4 |3 D6 H  J2 o; z5 q3 s
  711. end0 G/ w& @; E. I" i

  712. 6 G9 I& n- V$ m
  713. #==============================================================================
    / o: t: f, Z- D+ h: I1 n) _) J' r" |
  714. # ■ Window_NumberInput_Ex& P0 d, a' L& F% t0 o
  715. #------------------------------------------------------------------------------
    7 T! \- f& N, E/ z, d4 F
  716. #  新的数值输入窗口(NewClass)
    8 L# g* k- @9 A8 s- b- G& ]# K
  717. #==============================================================================6 i: A% C" A" h) H3 H
  718. class Window_NumberInput_Ex  Window_Selectable9 J) E' [1 j2 P& ~7 }  A
  719.   #--------------------------------------------------------------------------( w- C/ Y: g: t! `5 \; g
  720.   # ● 定义实例变量
    ) Y! \4 D; B+ a+ v5 f6 u. j* Y  x
  721.   #--------------------------------------------------------------------------& I: H) ~( P# g6 Z# m7 ?
  722.   attr_accessor number_proc' t& T" W8 E( H" a# Z/ b( n
  723.   attr_accessor index_proc, ]9 ^) Y6 Y* ]' D: z
  724.   attr_accessor close_proc2 l/ Y+ `5 Z3 y; k
  725.   attr_accessor refresh_proc
    1 Y! V- C! d+ o
  726.   attr_accessor number# g. j. W4 j9 D: y$ I
  727.   attr_accessor digits_max% o: L5 v# Q6 {7 ]
  728.   attr_accessor variable_id- i  F. Q+ x3 M4 }3 n
  729.   #--------------------------------------------------------------------------
    / j' V8 @# L- R
  730.   # ● 数字表
    ! y4 I! T( L3 J% Z: E4 K4 T+ ~
  731.   #--------------------------------------------------------------------------
    8 h1 x2 r2 ^& u( L
  732.   TABLE = [  7,  8,  9,
    . Z5 o% R6 h  i: ~
  733.              4,  5,  6,
    $ i" l; y5 i- f( B
  734.              1,  2,  3,
    & w. M! Z2 e& \' P* L- _
  735.             '←',0,'确定',]1 @4 K$ t9 Z( O1 c( n
  736.   #--------------------------------------------------------------------------
    # W2 T& k+ V9 }; p  {' \1 g
  737.   # ● 初始化对象
    - l5 V6 M/ @! N$ w9 r5 x
  738.   #--------------------------------------------------------------------------
    % j6 k8 ?  F5 `* s- g+ C* V; z$ R
  739.   def initialize% H9 `% ^& h% t! v2 ?
  740.     super(0, 0, 120, fitting_height(4))
    3 I! F: e8 B; Q; x# g) M( Y
  741.     self.openness = 06 v4 E7 L* J1 s* c, O0 {
  742.     @index = 0: `$ j4 l+ R, g' Z% ~9 D  v
  743.     @number = 0
    7 L! {/ p/ G- `2 ]7 n
  744.     @old_window_index = 0
    5 J/ }- I/ g- Y# Z
  745.     @digits_max = 0
    6 Q& O: o6 S2 H1 d
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }9 f' D" v# [( b) n( ^8 V4 t' F
  747.   end
      n$ B) E. J, c1 W1 B) j; D# g& a
  748.   #--------------------------------------------------------------------------
    1 y# H' g- T1 ^& n, s: \
  749.   # ● 获取项目的绘制矩形! h( g) a2 O- M2 Q
  750.   #--------------------------------------------------------------------------8 a& s6 y/ S3 ~3 ]( s+ Q
  751.   def item_rect(index)
    * f0 s9 r' y) e7 O
  752.     rect = Rect.new
    $ I" T# g; y, m* l6 Z4 a4 [* p, G
  753.     rect.x = index % 3  32
    ) T0 {  X, X8 U9 }# H/ e
  754.     rect.y = index  3  line_height
    : A5 `( b% u0 X) I9 X
  755.     rect.width = 32
    , q& [) ]- s6 }. W; A( p  }& Q; F
  756.     rect.height = line_height! d3 l! G9 j" c3 @/ r
  757.     return rect
    : M: L% z1 f4 y  I8 G
  758.   end
    8 f5 ?7 h, j& N
  759.   #--------------------------------------------------------------------------
    5 z( \/ U: v2 r# a( i2 T
  760.   # ● 将光标设置到鼠标所在的位置0 \: Q; Q8 M: A$ H  V& G# P* O
  761.   #--------------------------------------------------------------------------( z5 P8 w" U4 @2 C4 K
  762.   def set_cursor6 i! F/ S- B# D) S6 Y. B; g/ `
  763.     mouse_row, mouse_col = mouse_window_area* c8 R$ F6 o$ p0 k) Q' L
  764.     if mouse_row = 0 && mouse_col = 0
    : S. p( p6 d: O) V; Z) ?* s5 a
  765.       new_index = mouse_row  3 + mouse_col; u/ B. W# R, E/ \
  766.       select(new_index) if new_index = 11
    - T; r% ?" H$ w
  767.     end
    1 K3 P# ]7 u- @2 Z5 S
  768.   end
    . U  c7 _4 {2 C! ?  I% i, |
  769.   #--------------------------------------------------------------------------7 l* ]/ F' |. Q% `# o3 k' Y
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    & d! ~1 i- \! a! I' S- M
  771.   #--------------------------------------------------------------------------. B5 U$ b6 z! n+ r4 ?0 s
  772.   def mouse_window_area
    ; R( }+ [, R- x9 s' y$ X# V
  773.     if viewport.nil9 z& Z* d8 r2 k9 M7 b
  774.       vp_x, vp_y = 0, 0) z1 q# g5 n0 B% y5 s
  775.     else
    9 O: _( r; I( n) y( z5 d
  776.       vp_x = viewport.rect.x - viewport.ox
    4 a8 e0 q( E2 e6 T  y) k. q# A1 [
  777.       vp_y = viewport.rect.y - viewport.oy4 S$ H" R$ ^) ^9 @, |
  778.     end9 `' q# ]" q! w- U
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    0 U6 `, d8 l0 z) V( f# c
  780.     item_x1 = vp_x + x + standard_padding
    * G2 |' H& [+ x+ l* e. h8 x
  781.     item_y1 = vp_y + y + standard_padding
    ! d: q) ]5 d1 m: ^/ Y. s% d
  782.     item_x2 = vp_x + x - standard_padding + width
    & a! X+ s3 w; c! \' k
  783.     item_y2 = vp_y + y - standard_padding + height
    3 d; {; @" |) T/ \  J3 B; j
  784.     if mouse_x  item_x1
    : ^# m2 r+ K/ K2 {7 V) E
  785.       mouse_col = -1
    3 D7 Y' t* S7 @. i; [; s
  786.     elsif mouse_x  item_x2
    - S/ u% g# ^" i) U" `' J
  787.       mouse_col = -2
    7 R6 O& U1 n3 ^$ _/ u. f. F9 I% V
  788.     else
    4 S0 _+ m+ i- ^" X
  789.       mouse_col = (mouse_x - item_x1)  32
    1 {! _  H- _' l& D
  790.     end
    : X0 x% }6 }9 h& s- w
  791.     if mouse_y  item_y1
    / `! m' `$ x# W0 p7 L, V
  792.       mouse_row = -1) k/ G5 ]/ G0 X* F$ ~# u
  793.     elsif mouse_y  item_y23 D# [* }: p8 r: Q& U
  794.       mouse_row = -2
    ! {% G( D1 @7 M& a5 l9 ^( M
  795.     else
    5 J* T7 |3 g7 w  \4 }, x
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)( Q! N- a8 z+ g6 I4 I& V% _  t6 T8 `+ q
  797.     end
    " z1 V4 U& l2 G' U6 S1 K/ p
  798.     return mouse_row, mouse_col
    5 \! {0 e- ~9 Z! v* o! ^
  799.   end5 A, q/ R* C0 [: |  u- B/ R
  800.   #--------------------------------------------------------------------------' }& \: a0 |# u( j6 x9 n- z
  801.   # ● 获取文字
    / Q8 J: Y& g; X( X
  802.   #--------------------------------------------------------------------------
    $ N) k, h; N$ P) e5 @# G5 I
  803.   def get_number9 p' m2 ^  k6 w3 I0 `$ x3 V
  804.     return false if @index == 9  @index == 11
    5 h' G$ [2 ?( j, [* \& a+ x
  805.     return TABLE[@index]
    ; m( @# N3 E4 p* e! v
  806.   end
    " v7 L0 i- k2 p1 L. W. r( ?3 O
  807.   #--------------------------------------------------------------------------
    9 f# T1 G, V* z8 Y$ A
  808.   # ● 判定光标位置是否在“退格”上
    & Z) d  s8 W' K; h
  809.   #--------------------------------------------------------------------------
    $ q6 q" h/ k. w) Q
  810.   def is_delete/ _7 r! u9 a* J% r: \3 s% d0 R
  811.     @index == 9
    " A& t1 f8 z9 M5 ~' d5 E8 p
  812.   end( f; b8 J8 ^" J4 N
  813.   #--------------------------------------------------------------------------
    ! d3 `1 G! K5 ~) ^# U- o2 |- p4 `
  814.   # ● 判定光标位置是否在“确定”上
    * {6 h; E6 j/ @% w. a4 |  R* G
  815.   #--------------------------------------------------------------------------
    ! e' m# C) B5 t8 b9 f
  816.   def is_ok
    8 k; {# T4 L& ^) E# I
  817.     @index == 11
    . |7 ~. }" F* H% e5 B
  818.   end4 @- k* q# l3 k: e4 B* [5 _1 I
  819.   #--------------------------------------------------------------------------9 K. L* M  L* o( o; t0 V! T
  820.   # ● 更新光标
    ! G0 i, i, D1 W) I% p8 |
  821.   #--------------------------------------------------------------------------
    - E* ~% l1 V! w0 W# c: p
  822.   def update_cursor
    $ T8 Y! [% n5 i. k! @! n6 O& F
  823.     cursor_rect.set(item_rect(@index))" m; ^6 C- i; ]  T' g5 F9 i+ b
  824.   end9 {+ V; H" x" l' x, Z, T
  825.   #--------------------------------------------------------------------------% F* `# I: O2 |/ Y9 b% e. f
  826.   # ● 判定光标是否可以移动
    2 w9 T9 J% r4 h2 X: A5 m4 B
  827.   #--------------------------------------------------------------------------4 ^! @1 J) a2 z9 ~: S! Z$ k
  828.   def cursor_movable
    8 h: D' T: I2 t* S0 Z- }+ u
  829.     active* w5 ^" G7 W5 j
  830.   end
    - l4 E! s6 E/ R" t/ M
  831.   #--------------------------------------------------------------------------4 J# u7 M/ G, x" ]. P# v. \
  832.   # ● 光标向下移动# s' \7 W9 q) }
  833.   #     wrap  允许循环
    + O$ h; l# P$ l0 o
  834.   #--------------------------------------------------------------------------" ^# ?2 p# n& x, @5 X! h4 T
  835.   def cursor_down(wrap)
    " R" n) b$ A! y6 T, a' g; H  }, P
  836.     if @index  9 or wrap
    $ A% U5 d8 J; l! C& N* L
  837.       @index = (index + 3) % 12
    - _$ Y/ Y" B2 }8 ]" o1 X7 C
  838.     end2 M( m6 B5 S# A! `
  839.   end
    0 r* x# s; z$ P- J) a! \1 p
  840.   #--------------------------------------------------------------------------
    6 Q+ C* k9 z( X! `3 C2 X; Q
  841.   # ● 光标向上移动6 ~1 N) [' d0 v0 z$ M2 n" i! ~$ c
  842.   #     wrap  允许循环
    1 [7 Q* {1 X. e" u
  843.   #--------------------------------------------------------------------------% n$ w- t8 M8 ^$ C8 o! v! X; K) h
  844.   def cursor_up(wrap)
    / W' O( S6 q% E3 Q/ y
  845.     if @index = 3 or wrap) ^3 M1 O3 ?# t! j1 y7 J4 B
  846.       @index = (index + 9) % 12
    & J  M- x) x3 Y) C3 w2 G8 }
  847.     end4 c' ^# D9 x8 `  f, P, i
  848.   end- T" V# K( {# N8 [+ Y( X, u  r+ i
  849.   #--------------------------------------------------------------------------( E. o! m# V" E( g9 k( g( i6 C3 s8 `! I
  850.   # ● 光标向右移动  x& O% R& P) }2 M
  851.   #     wrap  允许循环
    1 E+ \* W( F9 q. i- ?
  852.   #--------------------------------------------------------------------------* ^1 K) E6 ^$ g8 Y
  853.   def cursor_right(wrap)7 b! f2 g7 i2 `$ N) G6 z7 n( i
  854.     if @index % 3  2" a+ \3 z; a; t
  855.       @index += 1
    8 J& V+ A. S: z# C& h2 s( X
  856.     elsif wrap
    , p7 [5 f- p8 l. `* }+ T" J: }
  857.       @index -= 2
    , ~6 l- y) k$ d/ n! m
  858.     end
    # A8 j+ W# X4 l6 E9 S% t
  859.   end9 U& A1 m4 j6 Z2 P3 h3 c! O' \
  860.   #--------------------------------------------------------------------------
      v) f: L- b4 K) w0 U2 o
  861.   # ● 光标向左移动
    9 w$ g& N# C$ W- S1 _# @
  862.   #     wrap  允许循环$ _& z1 L# I6 b
  863.   #--------------------------------------------------------------------------. c/ q8 Q0 R0 r4 W. w8 Q( n# M
  864.   def cursor_left(wrap)6 e5 ~3 Y# {9 }3 O
  865.     if @index % 3  00 A# c# G1 D* f8 {  R* j) J$ d
  866.       @index -= 1& K6 C! v7 b3 J
  867.     elsif wrap
    3 m0 b* k2 H+ J; F0 O! a
  868.       @index += 2
    6 v1 I3 g* V9 w* ]( X8 U
  869.     end, r' p1 W( W7 p* A" e
  870.   end
    5 f. B0 o. t' [7 F( R+ `. G- X2 s
  871.   #--------------------------------------------------------------------------
    5 i3 Z8 R) k/ f, h3 z- w( L/ r, }
  872.   # ● 处理光标的移动; z5 t, C; m: s, Q  g
  873.   #--------------------------------------------------------------------------
    6 W' d9 m; o) E* G- T
  874.   def process_cursor_move! N9 n2 `# K7 k' [. B" c
  875.     super
    ; H, w" A% r- c. H. i3 T  j. Q
  876.     update_cursor
    8 {8 q" r( S" ?: F2 u1 R& G
  877.   end- d6 B# N* e- g3 g( t0 s/ ?% ^4 k
  878.   #--------------------------------------------------------------------------; x& z& C* _4 o' [/ a
  879.   # ● “确定”、“删除字符”和“取消输入”的处理8 y+ G* o" O; [* L
  880.   #--------------------------------------------------------------------------: g# G; E; o3 w: t' _
  881.   def process_handling
    * Q: ^2 W% E4 ^, N
  882.     return unless open && active
    * S& E' O5 Y5 \/ t% H" y
  883.     process_jump if Input.trigger(A)
    " o3 c" e7 W8 d6 I
  884.     process_back if Input.repeat(B)# {4 b- `; [# G& q5 L8 ]. |
  885.     process_ok   if Input.trigger(C)& @+ @7 P6 X. V, I" f$ b# P; L- H
  886.   end& l% w* h; k! o; j3 K! o
  887.   #--------------------------------------------------------------------------
    0 `. I! h4 _  v, f' |# X+ q; G' |
  888.   # ● 跳转“确定”
    6 @+ c* [* o4 U' S( @
  889.   #--------------------------------------------------------------------------
    ' \; \) `: y+ ?& F- @9 Z8 S0 R! e
  890.   def process_jump) @, L% v' C  _8 V5 E/ Y
  891.     if @index != 11$ k6 q# [& l5 f- D9 n
  892.       @index = 11& E; }3 A. P& h; X
  893.       Sound.play_cursor
    ; ?! o' i& e) Z) u. O/ `: y
  894.     end) y, {$ A$ ^. G$ U
  895.   end
    3 _" z2 |! J# l  c% V  R+ P) V$ i
  896.   #--------------------------------------------------------------------------
    8 g: X: j7 X1 J, T
  897.   # ● 后退一个字符! o( w9 e- I9 u% A' E: g5 i7 C
  898.   #--------------------------------------------------------------------------
    / I2 @4 K2 {, M# @# B
  899.   def process_back
    : H  ?5 f3 G" ~0 l. K+ X: f2 Q# \
  900.     Sound.play_cancel! y6 z. n5 |+ J4 @# P5 ^
  901.     place = 10  (@digits_max - 1 - @old_window_index)& F! a1 Y2 Q7 E2 C# U. Z; {8 Y  s
  902.     n = (@number  place) % 10# X. m/ r3 g" H, l% ~, m. f
  903.     @number -= n  place
    ( ]0 f$ f2 `7 N* {5 L( W8 ?% B3 v, ]
  904.     @number_proc.call(@number)
    # d0 b1 ]+ s; U- V0 s5 ^; G* b: |6 {
  905.     @old_window_index -= 1 if @old_window_index  01 S0 H5 F" s+ I6 L- i: t% O
  906.     @index_proc.call(@old_window_index)
    * C  X8 m1 q9 N7 |2 h+ ~
  907.     @refresh_proc.call
    ) `5 y- C% u( v. H, I+ D( ?
  908.   end
    , S* d7 {4 J' N  k, B6 N, e
  909.   #--------------------------------------------------------------------------- ~9 i: y7 g. q/ A) \- P
  910.   # ● 按下确定键时的处理; K0 \* |9 M. \$ [4 {: h
  911.   #--------------------------------------------------------------------------
    % {0 m; K' M- f( N& ]( j
  912.   def process_ok9 r% k3 i4 v4 p" O! V0 m: o
  913.     if get_number4 G& x! m3 m5 K) h7 n* j
  914.       Sound.play_cursor
    0 q4 `# a* ]( R  G( V! C6 X
  915.       place = 10  (@digits_max - 1 - @old_window_index); |* T& U+ S6 P
  916.       n = get_number - (@number  place) % 10
    ; X$ J/ |4 A% l5 r* y) @
  917.       @number += n  place( I1 K/ i) E* v/ M
  918.       @number_proc.call(@number)8 n4 y& N; u/ L$ B4 P- F
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 17 T- `" H$ e+ ?: `
  920.       @index_proc.call(@old_window_index)# u  X# a( b3 f8 ]- R# {( v) B% r
  921.       @refresh_proc.call
    & M0 V& A0 j2 F9 O
  922.     elsif is_delete
    ' l5 [( _' K9 Q. b/ F
  923.       process_back% }' L+ y, @1 {: H' `6 q2 Y
  924.     elsif is_ok- I' C" X( F* b- S+ V0 i
  925.       on_input_ok
    0 {4 x, a! ^6 }2 b; d7 W
  926.     end
    1 ^0 U. e4 H; Y1 h" y- M
  927.   end( Y6 W. u; o! F/ ]
  928.   #--------------------------------------------------------------------------0 v0 P. b6 I1 {
  929.   # ● 确定
    . }& b" B: x- U! d
  930.   #--------------------------------------------------------------------------
    & Z% Q, C& o: h9 E9 `4 T
  931.   def on_input_ok
    $ U! R) Y- q+ t$ G5 l/ |( t
  932.     @index = 07 z8 u+ o2 K8 p$ j7 n
  933.     @old_window_index = 0+ X+ x+ z) {8 h  Y2 z
  934.     $game_variables[@variable_id] = @number0 a  ?# n7 {6 y0 i2 a# {% V
  935.     Sound.play_ok) q7 F" e1 M. J; W9 d0 G
  936.     @close_proc.call/ p( ^; k$ `+ C- v6 T% `( e# H
  937.   end% g# ~3 ?1 J4 U- k4 O
  938.   #--------------------------------------------------------------------------
    ' l- d( T# h$ U
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    * x6 G/ J& o! c  t# g% T
  940.   #--------------------------------------------------------------------------  u$ I. ~$ `. i7 b
  941.   def set_mouse_pos
    - R" K( v9 w. s* v
  942.     if viewport.nil # necessary!6 e& J) j3 l" m; Y
  943.       vp_x, vp_y = 0, 0
    $ U! {- d$ W# j) N' l9 }3 K8 q
  944.     else6 l# L( w8 ~1 m
  945.       vp_x = viewport.rect.x - viewport.ox# f( A, E  j' j4 |+ Y  N
  946.       vp_y = viewport.rect.y - viewport.oy
    2 |, B+ ^- G6 G
  947.     end1 V2 e' r3 F, e3 x' u8 F) ~- P
  948.     item_x1 = vp_x + x + standard_padding 3 z  H2 ]: p: ^; q: B
  949.     item_y1 = vp_y + y + standard_padding
    8 a& d$ p+ g. f1 S) E3 P7 j/ S
  950.     get_index = @index  0  0  @index
    " D0 O$ b2 S) ~' u9 [1 A
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    1 H* _8 i" W6 T# L
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)& L5 z! [" c  v( l
  953.     Mouse.set_mouse_pos(new_x, new_y)+ F  j( c/ X% |( I% k
  954.   end# C; Z9 j- F& q+ w
  955. end
    ) R  h5 x( \4 W/ i# T6 T* d+ p
  956. ! c: h$ r1 x9 J. e7 l/ d' a
  957. #==============================================================================
    : r" x1 H- `) Y; j
  958. # ■ Window_Message
    7 j& b( g( j% J& L" k, y0 H
  959. #------------------------------------------------------------------------------9 i) f7 u& R6 O: y4 l
  960. #  显示文字信息的窗口。- Z5 T% k1 z! ?. a
  961. #==============================================================================
    " r* L) f+ w' N6 Y' k) q+ f3 M: q; z
  962. class Window_Message  Window_Base, A; G* A7 t  y
  963.   #--------------------------------------------------------------------------3 J) v5 g6 D, S+ d! B  s
  964.   # ● 处理数值的输入(覆盖原方法)( b4 |* T8 Z/ K8 X6 |' K
  965.   #--------------------------------------------------------------------------
    ; U( S1 d* b+ W
  966.   def input_number# i4 X! e, @- K0 A0 ^' R: U
  967.     @number_window.start* a# B8 R; u% v) k
  968.     Fiber.yield while @number_window.extra_window.active
    + \6 @" y: D. V" }' }
  969.   end
    ' _" y9 }8 [1 v. ~. i
  970. end
    & h1 F4 \& v" z1 a1 R) E/ g- w
  971. ( f& m  L: N2 \% }# Y0 n& d
  972. #==============================================================================1 V$ V0 ?9 I& u6 Y4 ]
  973. # ■ Window_PartyCommand. s) P9 I* W3 [: j/ o6 c2 E) K
  974. #------------------------------------------------------------------------------
    2 A, ]4 @9 H6 C( f
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    8 d" e. H8 e; E: e) C0 d
  976. #==============================================================================9 R. T0 G& i5 e. p/ |) i" W
  977. class Window_PartyCommand  Window_Command
    ) `2 j( D8 ^! v$ S* `, A& Y  ]' t$ f
  978.   #--------------------------------------------------------------------------
    4 A$ I8 k- `+ v& K: V2 ~5 v
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置' F9 z0 @5 [$ ?) l3 s$ ^* A
  980.   #--------------------------------------------------------------------------
      M$ K# j7 o( j0 y3 m6 U0 g
  981.   def set_mouse_pos
    . v/ ]% R7 \3 Y- g4 U) T
  982.     if viewport.nil; O2 z) ~, I* q9 ~. |
  983.       vp_x, vp_y = 0, 01 z9 v$ y+ C( R0 j& f5 q
  984.     else3 W! y, H0 c7 w/ B, A( n4 K
  985.       #vp_x = viewport.rect.x - viewport.ox3 y. Q- @5 v9 K" r/ B5 m5 v" C
  986.       vp_y = viewport.rect.y - viewport.oy+ ^# N: S7 Y+ X& ^8 Q8 ?+ }
  987.     end5 e0 a. h! B8 H  U5 X+ O$ `! F
  988.     item_x1 = x + standard_padding 7 l0 q7 T4 n# n7 U( [% x
  989.     item_y1 = vp_y + y + standard_padding
    8 }" l1 H: |1 m/ t, A! g' h; z# s, ]
  990.     get_index = @index  0  0  @index 3 U% d* r0 c8 [& t
  991.     row = get_index  col_max - top_row  A( Y( c/ c1 p7 G* S) l! K% a4 Z
  992.     col = get_index % col_max# a1 x* J5 O" h6 d
  993.     new_x = item_x1 + item_width  (col + 0.5)9 ~+ Y5 Q$ F# g) ^0 }! F1 G
  994.     new_y = item_y1 + item_height  (row + 0.5)  K: _. t( }+ N8 _" A* z& E
  995.     Mouse.set_mouse_pos(new_x, new_y)4 j5 m4 l' V! k
  996.   end
    ) _- _: t6 ^4 p" c+ E- k* E" `# X& ]
  997. end
    . K( A7 ~0 ~$ a1 f6 K: P! s

  998. + p5 Q' U$ z$ y4 y
  999. #==============================================================================
    - M3 U# [7 Y# S
  1000. # ■ Window_ActorCommand
    4 G# q% U7 Z! L  }+ b
  1001. #------------------------------------------------------------------------------3 e# N8 F! {7 z* k- }* X
  1002. #  战斗画面中,选择角色行动的窗口。
    4 h5 i2 X+ b8 ]4 @; ]% m
  1003. #==============================================================================
    ' y2 Q6 b% U( u/ C* m$ b5 v
  1004. class Window_ActorCommand  Window_Command3 d! ?1 Z: V9 {# [
  1005.   #--------------------------------------------------------------------------  \  d: x0 P, ^3 N# a- l
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ! q; B2 g" R+ A) g5 t5 n* N
  1007.   #--------------------------------------------------------------------------
    ; k) r6 w. u1 {) I/ F7 Q6 F
  1008.   def set_mouse_pos
    % c6 V( t( O. M( Z# ~. `3 N
  1009.     if viewport.nil- V- j: ]% n0 r) m  U8 q' j
  1010.       vp_x, vp_y = 0, 0
    ; Q5 w, F/ Z  `7 R1 h8 a3 p
  1011.     else( t/ s) b+ z, ~
  1012.       #vp_x = viewport.rect.x - viewport.ox
    & M: r3 s$ n3 O( M/ M* Q6 k
  1013.       vp_y = viewport.rect.y - viewport.oy
    & }/ S  `1 a9 c( x5 _; D
  1014.     end
    4 w  q* y. c( v0 r
  1015.     item_x1 = Graphics.width - width + standard_padding
    " V5 Z3 H# z% }8 \) @& d
  1016.     item_y1 = vp_y + y + standard_padding/ C3 ]3 Q& g- C0 k$ J6 \6 \
  1017.     get_index = @index  0  0  @index 3 ~% R9 R4 T* V. S5 y% H3 b
  1018.     row = get_index  col_max - top_row
    ( G. W& b- H5 P7 @  y) j0 b, Z
  1019.     col = get_index % col_max5 Z9 a% _, j8 K  x) H
  1020.     new_x = item_x1 + item_width  (col + 0.5)- J  m! W6 t" R, G
  1021.     new_y = item_y1 + item_height  (row + 0.5), K  Y( G9 q6 V& H/ P: s. t1 _
  1022.     Mouse.set_mouse_pos(new_x, new_y)* ]3 Z0 Q+ B1 |3 F: l4 Q
  1023.   end: C# Y" l; I3 T+ }8 e3 |
  1024. end
    : k- |- X4 r  W; ]

  1025. ( b1 O: _8 ?5 @# b
  1026. #==============================================================================
    " }, s+ B& Z5 g
  1027. # ■ Game_Player: ]0 l, [+ m9 A3 f
  1028. #------------------------------------------------------------------------------
    1 i9 ~. ~1 s7 O
  1029. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
    8 z; a# g9 ^, j, p* C% l! p# M4 F
  1030. #   本类的实例请参考 $game_player 。
    * D+ Z1 ]7 C0 W
  1031. #==============================================================================6 ?/ t' O( ~- |2 r% ?8 ~
  1032. class Game_Player  Game_Character
    9 a& p2 o& M; h  x
  1033.   #--------------------------------------------------------------------------" X6 w0 F. g& w5 D  v( O* x
  1034.   # ● 由方向移动(覆盖原方法), j& M! E8 @) c3 O1 ~$ M( ]
  1035.   #--------------------------------------------------------------------------  U( S4 K5 b4 d6 C2 l" _5 x: ?3 k
  1036.   def move_by_input
    5 H8 L* D/ o) Z$ v% C; e) S/ o
  1037.     return if !movable  $game_map.interpreter.running
    + [# a5 e2 P* e/ B" X0 o
  1038.     if Input.dir4  0
    # Q; x* Y& Y, G
  1039.       move_straight(Input.dir4)   S/ s2 s4 k6 d# F+ G
  1040.       reset_move_path1 h7 @4 q; C* Z7 [
  1041.     else
    # }5 J8 t7 I& \- s$ D3 d
  1042.       move_by_mouse" `4 @% ?$ h$ T+ J- C* F
  1043.     end/ R7 u, `& G# G% H
  1044.   end( _* I4 U  |5 w& F  K- u
  1045.   #--------------------------------------------------------------------------
    " J4 J5 ]. W: D, ?9 b# Q, u  |
  1046.   # ● 非移动中的处理(覆盖原方法)
    ) S- k' x4 U4 w( |* O2 Z
  1047.   #     last_moving  此前是否正在移动
    ! R' u( C9 ?; o2 `9 g
  1048.   #--------------------------------------------------------------------------
    1 p: e8 }/ l7 c" Q2 v5 [
  1049.   def update_nonmoving(last_moving)% x/ n6 Q2 \) L! ?: ]7 [* L
  1050.     return if $game_map.interpreter.running% N: i7 S/ D2 P' O. f4 B, |
  1051.     if last_moving" ]* ?1 F% H. G7 t6 \
  1052.       $game_party.on_player_walk$ Q8 b  I2 ]7 n0 B& [- d5 q
  1053.       return if check_touch_event
    & l  H) R% y4 ~5 W
  1054.     end
    : d& O+ n$ f; i# s& P; n6 E/ Q" h8 {
  1055.     if movable && Input.trigger(C)5 U7 k  m% E: u6 v' N5 j4 L
  1056.       return if Mouse.press(0x01) # 防止按下鼠标左键绘制路径时触发事件或载具切换
    ( n0 E9 Q5 ^/ {* u9 [/ [
  1057.       return if get_on_off_vehicle! U1 s+ a# G) X: |$ j0 {1 \
  1058.       return if check_action_event
    - e) G6 n( z2 F' M) U
  1059.     end
    9 L9 w" ~! \) Q4 O
  1060.     update_encounter if last_moving
    7 W9 m8 o6 u: k& H
  1061.   end
    0 Y5 B, u% S% K3 i/ F" v& Q7 S
  1062.   #--------------------------------------------------------------------------
    2 ]: P3 H9 @' L% s
  1063.   # ● 判定是否跑步状态(覆盖原方法)
    9 m8 g( W% O, D- _' R. p% X
  1064.   #--------------------------------------------------------------------------  Z, h+ `! V- v1 x
  1065.   def dash
    6 B5 o3 r7 r: h0 `. J: ]5 g
  1066.     return false if @move_route_forcing
    6 |5 u: b2 }% `4 O2 u0 w5 Q
  1067.     return false if $game_map.disable_dash6 g! Z* K' h4 q0 |4 B: x
  1068.     return false if vehicle
    4 s( j+ N$ o8 U; x9 {
  1069.     return Input.press(A)  @mouse_dash! p) d4 A) d% F6 x% n
  1070.   end+ m! f! \6 v( r8 K- c* @
  1071.   #--------------------------------------------------------------------------
    3 x  g$ u* }0 M* r
  1072.   # ● 初始化! s$ V) u4 w7 z/ n; O
  1073.   #--------------------------------------------------------------------------
    / ~8 l  d; T* F, f$ Y; J
  1074.   alias sion_mouse_initialize initialize0 l; N0 c1 U+ Z4 b- @4 V8 o
  1075.   def initialize: ]" P( x, q6 }/ o/ _) m
  1076.     sion_mouse_initialize
    5 f( y# p9 |4 p* R# g- a- w
  1077.     reset_move_path
    6 H: Q; g" W& O, T
  1078.     @moveto_x = 0" _6 {" O$ P% I! g
  1079.     @moveto_y = 01 W' x+ ]' R! h. Z
  1080.   end
    4 R3 f; `' E# h" D0 ~# J& ^: Z
  1081.   #--------------------------------------------------------------------------& v: `* e8 ]5 r- C8 i: ]9 @
  1082.   # ● 更新% P/ F0 J; D2 }  ^' n; x0 _- @
  1083.   #--------------------------------------------------------------------------
    4 }0 K$ G. i; q8 b. R
  1084.   alias sion_mouse_update update% J( [, _  O7 u) F' ]/ j5 A: r# D- D
  1085.   def update1 ]) r+ Z9 m% C5 l3 f. c
  1086.     sion_mouse_update
    ( L: }4 O5 C( J% ~0 u# m
  1087.     clear_unreachable_sign
    7 c7 F: M2 X: r$ Z# J
  1088.   end  o$ N/ ~$ l+ p. E7 g
  1089.   #--------------------------------------------------------------------------# R6 d3 f6 ^6 b, L
  1090.   # ● 处理卷动4 S4 I) i; [/ g8 Q- g4 ~/ E
  1091.   #--------------------------------------------------------------------------* T5 V% w1 M$ [2 \- J7 |" W5 P  g
  1092.   alias sion_mouse_update_scroll update_scroll
    4 U5 j& J% n1 e/ V
  1093.   def update_scroll(last_real_x, last_real_y)' i3 U7 z7 m3 [% u4 O  _
  1094.     return if $game_map.scrolling
    % e& N0 a5 p7 X) ^
  1095.     KsOfSionNew_Scroll  new_update_scroll
    & d; n: E: n8 U/ x) C
  1096.       sion_mouse_update_scroll(last_real_x, last_real_y)
    % }+ Y$ J2 i; X
  1097.   end
    . r% Y) e- g8 {8 L) a
  1098.   #--------------------------------------------------------------------------
    # V1 V* i# W& [" Y+ ?& V
  1099.   # ● 重置移动路径相关信息
    6 b# @) Z* K2 U  B3 z
  1100.   #--------------------------------------------------------------------------7 u& S+ I; t# m  R
  1101.   def reset_move_path
    5 f* ?5 n7 M1 }$ q4 B! Q' d- ?
  1102.     @mouse_dash = false
    : v/ M( U2 p  z: j9 R
  1103.     @mouse_move_path = []+ v& s) D: j- A$ B" I+ m
  1104.     $mouse_move_sign.transparent = true
    - r# l+ J, G" L" y9 U) W
  1105.   end
    2 z  N9 c, C: I& l) Z
  1106.   #--------------------------------------------------------------------------
    ( y  v: [% x* N, N) C7 c! K
  1107.   # ● 新的卷动地图方法
    8 r5 P6 f- O" P. _
  1108.   #--------------------------------------------------------------------------
    + {5 Z- E% E/ C) S. I9 G+ f& k
  1109.   def new_update_scroll) t" |9 {. y9 g0 J$ o! |
  1110.     horz_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.width
    : W8 O& e' e+ \2 Y% A
  1111.     vert_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.height
    3 G" Z& D9 p' g5 R- p, D$ {
  1112.     ax = $game_map.adjust_x(@real_x); `7 h( d- c" J# ~  V3 Q' C
  1113.     ay = $game_map.adjust_y(@real_y)5 p: l) R/ h0 A  F  T2 I
  1114.     $game_map.scroll_down (vert_speed  (ay - center_y)) if ay  center_y, Q4 @6 P6 b* N- |2 l' z( l
  1115.     $game_map.scroll_left (horz_speed  (center_x - ax)) if ax  center_x6 |5 U/ [' |2 P  G: W& v
  1116.     $game_map.scroll_right(horz_speed  (ax - center_x)) if ax  center_x& [$ _* q* D& \% _2 {' N- F
  1117.     $game_map.scroll_up   (vert_speed  (center_y - ay)) if ay  center_y
    / E$ c# y; A( Q' B6 Q- @
  1118.   end# N0 b( n  \8 d2 e; O
  1119.   #--------------------------------------------------------------------------
    9 x8 E- ?% P6 }
  1120.   # ● 消除不能抵达图标
    6 U, g: C/ I9 U' Z8 P8 J8 O3 n+ l/ V/ ^
  1121.   #--------------------------------------------------------------------------2 i: V8 W2 M9 k$ V6 m) i
  1122.   def clear_unreachable_sign# [# V- c, ^: s! v& `- D) N: a4 t
  1123.     return if Mouse.press(0x01)
    % v+ B( }7 C$ B+ u9 O. q  v
  1124.     if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 03 z: O0 G9 v: W6 Q. F9 _
  1125.       $mouse_move_sign.transparent = true
    ' _7 h% m5 _, `
  1126.       $mouse_move_sign.direction = 2/ b8 k1 r" q0 A$ E) n# n
  1127.     end% M8 e8 ~7 r" A- {9 r, i9 ~4 Y" }% K
  1128.   end" A( D( j& w* ]2 c: V( V7 M
  1129.   #--------------------------------------------------------------------------
    6 T+ s; v2 D" F& s5 k
  1130.   # ● 由鼠标移动
    * G0 ^4 A# t  o+ ~+ _, ]8 f
  1131.   #--------------------------------------------------------------------------5 S, L: e9 {* D8 {
  1132.   def move_by_mouse1 G. Q7 O3 t! a9 X% o2 u* F
  1133.     unless @mouse_move_path.empty # 移动路线数组不为空则执行移动
    * q9 |" r) N( v# w
  1134.       dir = @mouse_move_path.shift
    $ J3 `0 E  a2 D& T& z& r% y
  1135.       if passable(x, y, dir) && !@mouse_move_path.empty
    1 e4 N+ U. P# {
  1136.         move_straight(dir)
    * s* `  E! e% i- A' b
  1137.       elsif @mouse_move_path.empty # 判断是否是最后一步
    0 s' B& V% _: d5 }5 d- [
  1138.         x2 = $game_map.round_x_with_direction(x, dir)& H4 a; d; X7 F0 K7 p" ]
  1139.         y2 = $game_map.round_y_with_direction(y, dir)& r. z2 M0 C1 B$ ^- V( f
  1140.         move_straight(dir) unless dir.zero
    ' |: l$ J2 K! x0 f; p
  1141.         unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具
    4 F4 E" V/ e/ g8 |
  1142.           check_event_trigger_there([0,1,2])% l( G4 k; x0 k9 z! h
  1143.           get_on_off_vehicle unless $game_map.setup_starting_event4 U4 ?6 |, P* [" E0 k, V4 ^
  1144.         end
    $ Z, O7 [4 w& e2 R
  1145.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2/ R8 a/ d" T7 P9 J
  1146.         @mouse_dash = false. N/ y) w% i8 L4 ?$ |
  1147.       elsif @mouse_move_path[0].zero # 目标点无法抵达,调整朝向→目标点
    , V) `6 q7 y; g5 L! r1 K$ @
  1148.         @mouse_move_path.shift& C5 [8 H+ |, d1 i
  1149.         @direction = dir4 r* W- G6 {- m$ c3 y8 D
  1150.         @mouse_dash = false2 s9 }3 u+ p3 h; v' g9 }
  1151.       else
    : }+ e3 n6 a6 P8 I8 m) Q1 I7 _
  1152.         draw_move_path2 t+ p$ D# @' ]6 z# Y: T% Q% O; ~, Z' E
  1153.       end, B8 o: U0 q. p2 x. L2 B6 T/ U% U
  1154.     end- R: i6 S- Y. |
  1155.   end3 @8 Q) Q- d5 A: O2 O& l# I
  1156.   #--------------------------------------------------------------------------  W+ m0 V0 H9 C7 z- Q7 a
  1157.   # ● 地图界面按下鼠标左键的处理
    0 ^, a! z) {$ X5 S
  1158.   #--------------------------------------------------------------------------+ G1 o$ G. R) G
  1159.   def left_button_action5 Y! H6 E: H8 K/ C4 x: J3 k3 D
  1160.     return if !drawable  $game_map.interpreter.running: H8 |& D  ]$ D$ h7 a
  1161.     get_mouse_pos/ ]  N6 U. m" n9 G3 {! N0 C
  1162.     $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图3 `, [6 R! m) C2 X" ^% o" ]* j
  1163.     if @shift_event
    ; l% V7 D! G+ V4 L% L
  1164.       if Mouse.trigger(0x01)9 `: t; S9 k& m! P3 p% G
  1165.         @shift_event.jump(@moveto_x - @shift_event.x,) c4 R; ~9 }  u$ z% a- q7 q
  1166.           @moveto_y - @shift_event.y). y* o, Q& \# `, d% k, u$ a  g
  1167.         @shift_event = nil  u* h0 ~( B; W. F- [4 N* G, H" R7 P  R, I
  1168.       end' m7 S" A1 d$ D0 Z
  1169.       return' S! g% `* f% f0 R- `# N& c& b
  1170.     end
    # z& g; o' K4 Q4 n) R
  1171.     if @moveto_x == x && @moveto_y == y # 判断目标点是否与角色重合
    ( ^  Z$ T; m' k8 t3 T" B
  1172.       return if moving  (vehicle && !vehicle.movable)  r9 m4 a- @# ^' b$ m( ^5 Y
  1173.       check_event_trigger_here([0]) # 判断是否触发重合点事件4 l! P- E4 `, |5 b2 j! V$ O
  1174.       get_on_off_vehicle if !$game_map.setup_starting_event && 6 k5 ?; U! G/ ]
  1175.         $game_map.airship.pos(x, y)  # 判断是否要上、下飞艇( @% S: P! o/ f; T+ Z" R; n
  1176.       return' t' W  u% F% Q/ u
  1177.     end
    - P" m3 d4 C+ j4 E) n
  1178.     # 判断是否用鼠标启动事件
    6 Y; D7 q9 \5 B2 S' ^3 F3 m' F
  1179.     $game_map.events_xy(@moveto_x, @moveto_y).each do event
    5 U, a- C! `1 k$ W  F7 q' U
  1180.       if event.mouse_start
    / V: J8 z& L5 t- G
  1181.         reset_move_path! e& |& r/ J; q* f& R
  1182.         event.start if Mouse.trigger(0x01)
    9 D* O8 m! w, W& B
  1183.         return/ @" Y  R8 e, Q. o7 H( n. f- k* M
  1184.       end) `3 ~# i2 R4 _1 s8 h: f" h- a
  1185.     end
    2 @0 ?# }" N. U) Z9 j
  1186.     @mouse_dash = true if Mouse.double_click # 双击冲刺
    ( c+ {6 |  }& T
  1187.     return if Mouse.left_state % 10 != 1 # 按住鼠标左键10帧绘制1次路径- X+ s: J  W; ~1 o; p" l
  1188.     for i in 1..4 # 判断目标点是否为角色周围四点' A8 Z! x% e  r$ Y) ~6 W
  1189.       if x == $game_map.round_x_with_direction(@moveto_x, i  2) &&; o: O3 D; y- c" M* z
  1190.          y == $game_map.round_y_with_direction(@moveto_y, i  2)+ c& b: }1 q1 G" i% k& U
  1191.       $mouse_move_sign.transparent = true( g8 d0 l0 s- t0 ~
  1192.       @mouse_move_path = [10 - i  2] if Mouse.trigger(0x01)
    3 g% j' s1 Z" e" l
  1193.       return; end
    9 k( p7 x7 i2 Z+ r! J9 y2 z5 m4 g
  1194.     end# _% @& J9 i2 I3 l3 J  E: M
  1195.     draw_move_path- K) u! J' H; m6 m) {
  1196.   end
    ! F! T8 D% k3 ?: B
  1197.   #--------------------------------------------------------------------------
    ; k3 V8 l" f" i9 f; k' j5 M
  1198.   # ● 取得鼠标处对应地图坐标点, H0 I" L" w' g. x# {8 F/ q
  1199.   #--------------------------------------------------------------------------0 Y& e% k2 R3 a  W/ l/ o
  1200.   def get_mouse_pos+ u' {! J0 I  l, U0 z& G
  1201.     $game_map.get_mouse_map_xy6 Z8 o$ ]* O! s% @
  1202.     @moveto_x = $game_map.mouse_map_x/ C1 ~' B% o2 s! g
  1203.     @moveto_y = $game_map.mouse_map_y
    / H" n8 A7 m3 ]+ k8 Q  @& e1 |8 @8 U
  1204.     #mouse_x, mouse_y = Mouse.get_mouse_pos- @9 k' P5 a, {. v) z
  1205.     #@moveto_x = $game_map.round_x(x + (mouse_x -   `6 R! H* W" O5 q
  1206.     #  ($game_map.adjust_x(x)  32 + 16).to_i + 16)  32)+ j8 n; D: C  B2 T3 F9 `
  1207.     #@moveto_y = $game_map.round_y(y + 1 + (mouse_y -6 u9 O3 D' O- K0 X9 I
  1208.     #  ($game_map.adjust_y(y)  32 + 16).to_i - 16)  32). W) k! k0 z. A7 T
  1209.   end- e* y1 p: |0 ~& @& S/ a
  1210.   #--------------------------------------------------------------------------
    4 B% n8 N$ A! K2 E
  1211.   # ● 绘制移动路径 @array[move_directions...]9 p# l; ^$ U$ m
  1212.   #--------------------------------------------------------------------------: n$ Y1 v' M$ X& s+ `: ^6 N$ M6 G
  1213.   def draw_move_path
    7 u7 b" k& ^8 J' x& Q2 K
  1214.     #temp = Time.now
    9 _+ R' w1 a* s' Z" G1 x
  1215.     case @vehicle_type, d& o6 B: I1 R, N% o
  1216.     when walk$ Q/ v3 J0 G/ d
  1217.       draw_walk_path
    % m4 b9 P0 \2 I3 s4 z; F4 {$ O
  1218.     when boat  Q9 e% [) q" y* K! l$ Z+ v8 X
  1219.       draw_boat_path) A. M( ~7 o# `  H. Z8 C
  1220.     when ship( \( \; ^( |8 D& P! h
  1221.       draw_ship_path5 A, d2 n! T/ A$ z, C  _
  1222.     when airship
    ' o. D1 p7 W5 ?+ {2 Y/ v
  1223.       draw_air_path
    & O% U4 \- l+ z5 T5 r
  1224.     end0 `# W: z8 \0 L
  1225.     #p (Time.now.to_f - temp.to_f) # 测试效率
    9 ?6 y; _" ]. i0 x
  1226.   end
    9 J; K( z" b2 D7 q: x
  1227.   #--------------------------------------------------------------------------% t3 @' p6 i! ~' d, M
  1228.   # ● 判定是否可以绘制移动路径& E" q# j3 R0 Q- l% L6 K
  1229.   #--------------------------------------------------------------------------. f. Y) {9 ~& z/ j/ O/ b
  1230.   def drawable) Q; h* j+ M3 K' k; E) M; Z
  1231.     return false if @move_route_forcing  @followers.gathering) \8 L3 f: }( X( C9 H* I
  1232.     return false if @vehicle_getting_on  @vehicle_getting_off* \1 L. R! T! u. T
  1233.     return false if $game_message.busy  $game_message.visible; _% `( B. ]7 P: V3 C) x
  1234.     return true3 |9 [6 a( ~* `: u
  1235.   end
    ' a* U, Q, V) c) l
  1236.   #--------------------------------------------------------------------------
    1 b5 j, K$ L) _, e% a* T( y
  1237.   # ● 绘制walk移动路径 @array[move_directions...], s" q( ~0 C% }
  1238.   #--------------------------------------------------------------------------& @" G* u/ G, T2 ^
  1239.   def draw_walk_path
    - M9 T& Y5 f8 P7 A& [% y
  1240.     # 准备绘制路径表格9 r/ N" b% `' x7 w$ d% P! ]
  1241.     sheet = Table.new($game_map.width, $game_map.height)
    ) |7 l* w- ?1 S% s# n- S
  1242.     reversed_chase_path  = []; chase_path  = []
    3 n5 L, t$ Y- g) [: B3 t; [
  1243.     reversed_chase_point = []; chase_point = []% M/ u% y# Y' j: G
  1244.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]8 R$ o8 _: d8 ]2 h$ _: R
  1245.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
    ) I0 ]* |" a8 p: M" K3 C
  1246.     reach_point = false
    % n9 y/ z: l. P. Y* ^% [
  1247.     step = 39 l6 n$ j8 S! O9 P  L( e' P
  1248.     loop do #loop1 开始填充表格* |. B7 }1 Y# w+ I0 i
  1249.      draw_path = false
    , I- w7 j$ r( p3 z+ g1 K* L
  1250.      check_points = new_start_points
    4 ]3 o- a; G( h' f, r6 c+ K6 {
  1251.      new_start_points = []# F& Y4 J9 w8 b7 v4 m- o
  1252.       loop do #loop2 从起点开始正向填充
    * K0 h: j  e. W: F# J, F
  1253.         point_x = check_points.shift
    $ v" I4 a; I7 w3 a
  1254.         break if point_x == nil; g4 W2 L) d+ c! v% L# z) _
  1255.         point_y = check_points.shift# c0 X/ r- ?; G; W( q
  1256.         left_x  = $game_map.round_x(point_x - 1)# v7 J' y: C( s
  1257.         right_x = $game_map.round_x(point_x + 1)) U# s: b; Y8 ~
  1258.         up_y    = $game_map.round_y(point_y - 1)( F& E, B6 \+ r
  1259.         down_y  = $game_map.round_y(point_y + 1); F; V6 f" F3 a
  1260.                     # 判断路径是否连通
    ) {+ X, y, @4 K; a( N! j5 W
  1261.         path_step = step - 1
    * M- R6 e7 s& |3 M2 w# o
  1262.         if sheet[left_x, point_y] == path_step     &&
    - P8 w- K* @% K2 w
  1263.            $game_map.passable(left_x, point_y, 6) &&2 d# g. Y5 D  o  f7 i5 \6 w
  1264.            $game_map.passable(point_x, point_y, 4)2 g1 E- n8 A& a. Q/ B; ~: U
  1265.           chase_path.push(4)% a$ w5 J- v0 n  y, w2 k1 [# ^# W
  1266.           chase_point = [left_x, point_y]
    1 D( g( a' J% Y6 c& b' \& s: W# s
  1267.           reversed_chase_point = [point_x, point_y]. B( {7 Z3 a, V; T
  1268.           reach_point = true; break
    * }: x; S& Y6 V" V6 y- E- C! [0 m
  1269.         elsif sheet[right_x, point_y] == path_step     &&
    7 T, A' G, g% H" z# |; b
  1270.               $game_map.passable(right_x, point_y, 4) &&( f* c% x* ~" H; v0 P$ Z
  1271.               $game_map.passable(point_x, point_y, 6)7 H  s  ^1 e! l/ v4 w
  1272.             chase_path.push(6)7 Q& w# H* Y0 y* J: @/ Q8 i' X
  1273.             chase_point = [right_x, point_y]* b6 u7 T2 R4 f
  1274.             reversed_chase_point = [point_x, point_y]
    9 X- N  o% p; x' [5 s
  1275.             reach_point = true; break1 c* ^- r8 |- d/ x6 `9 J9 r0 d$ T
  1276.         elsif sheet[point_x, up_y] == path_step     &&. ~0 r) c( P' w7 X# I& G6 E
  1277.               $game_map.passable(point_x, up_y, 2) &&
    1 Q6 \2 ^5 a6 i; s
  1278.               $game_map.passable(point_x, point_y, 8)+ q! K# m$ h$ V& U6 J
  1279.             chase_path.push(8)
    ( ~' e9 {3 W( S, X% I
  1280.             chase_point = [point_x, up_y]
    7 k. Q( g- B$ Z3 h+ x8 g7 s
  1281.             reversed_chase_point = [point_x, point_y]
    ) V' X& i0 X# r/ K6 m) a0 b
  1282.             reach_point = true; break8 D) A, @5 u& J2 F1 I# r
  1283.         elsif sheet[point_x, down_y] == path_step     &&: u- J: |7 ^: ]7 f( p7 t# J: w
  1284.               $game_map.passable(point_x, down_y, 8) &&
    % h/ F# _' n. a
  1285.               $game_map.passable(point_x, point_y, 2)! H; ^9 F7 n, _4 h. A+ k
  1286.             chase_path.push(2)$ \& k* a& d) [) k. n
  1287.             chase_point = [point_x, down_y]
    3 v7 b3 S/ K/ X; ?& w1 ?2 ^
  1288.             reversed_chase_point = [point_x, point_y]
    6 a- x5 `% j) E
  1289.             reach_point = true; break
    ) L' F* e+ h, q- Z; m+ o
  1290.         end( i! C6 w$ p3 P8 ]9 I/ ^
  1291.         # 以需要抵达该点的步数填充路径表格 #
    ! U; |# R, i: R! o! X4 z1 l
  1292.         if sheet[left_x, point_y] == 0              &&
    ) P6 }+ P4 _8 N  x3 h# @
  1293.            $game_map.passable(left_x, point_y, 6)  &&/ Z( I; p7 u; v! o' {7 M& S
  1294.            !collide_with_events(left_x, point_y)   &&5 W" t7 f: N2 x) I5 h
  1295.            $game_map.passable(point_x, point_y, 4) &&& c/ J" W' {+ l3 I* J! c. ^& P( v
  1296.            !collide_with_vehicles(left_x, point_y) #judge_end$ r4 v% f8 Z1 L+ s5 x) @; |
  1297.           sheet[left_x, point_y] = step  E) l# I+ z; J- K* A3 d! `
  1298.           draw_path = true
    * A8 w, R4 x9 P# |
  1299.           new_start_points.push(left_x, point_y)7 k# k( w, v/ W9 ~: V: L; Q
  1300.         end
    " |: J) G: |8 Q
  1301.         if sheet[right_x, point_y] == 0             &&
    5 j6 C' R0 Y0 M
  1302.            $game_map.passable(right_x, point_y, 4) &&) m# Z/ ?; f& R, x% Y8 u& B
  1303.            !collide_with_events(right_x, point_y)  &&! M9 Q1 J- w% `; T7 o
  1304.            $game_map.passable(point_x, point_y, 6) &&
    * m+ p' a2 h( n# ]# y) W) a: f
  1305.            !collide_with_vehicles(right_x, point_y)#judge_end9 o, D5 S/ q1 D0 z" }/ W
  1306.           sheet[right_x, point_y] = step
    & Z6 @6 R) r2 H. e  g
  1307.           draw_path = true
    6 b& Y" m$ w6 W/ Z1 d$ w. X
  1308.           new_start_points.push(right_x, point_y)
    ( S. B# g7 X9 W9 o- U. [& W
  1309.         end1 }- U) m1 @7 L
  1310.         if sheet[point_x, up_y] == 0                &&
    * R6 P2 v! Z3 {# `
  1311.            $game_map.passable(point_x, up_y, 2)    &&
    . w8 @7 x5 L& s3 W; t
  1312.            !collide_with_events(point_x, up_y)     &&. U7 E4 R7 Y$ c4 ~6 D& J
  1313.            $game_map.passable(point_x, point_y, 8) &&
    / R7 I3 B. U$ ]+ u/ T/ ~* [# W6 \
  1314.            !collide_with_vehicles(point_x, up_y)   #judge_end3 B. ]- K. V0 |* ~
  1315.           sheet[point_x, up_y] = step( L4 b, Z! f, R: |2 z: J6 K* j
  1316.           draw_path = true
    5 I! c2 N& D& o
  1317.           new_start_points.push(point_x, up_y)
    8 b; O3 s& d, B  c+ X7 w9 \6 y7 E
  1318.         end9 H: k7 }7 l. r6 F! w" `8 c1 S- u) a
  1319.         if sheet[point_x, down_y] == 0              &&  q& \' F6 @& g0 t6 {
  1320.            $game_map.passable(point_x, down_y, 8)  &&
    ! o0 j+ @2 F6 N, W, g  ?
  1321.            !collide_with_events(point_x, down_y)   &&( k* Q- o- N( V$ `9 g
  1322.            $game_map.passable(point_x, point_y, 2) &&9 h+ U: c4 ]& `7 K( ?' m
  1323.            !collide_with_vehicles(point_x, down_y) #judge_end% ?7 v$ X; [' V" D* ~; X9 Q
  1324.           sheet[point_x, down_y] = step
    - h/ W  A7 p' g. p& q8 i
  1325.           draw_path = true- p9 A0 m0 b! [- v: D& W
  1326.           new_start_points.push(point_x, down_y)
    ) C6 @8 a8 ~4 F
  1327.         end
      T7 D0 d( Q) S1 d% ~* e% v- r" }- Q
  1328.       end#endOfLoop2
    - v7 A; p. U# E' P  P
  1329.       break if !draw_path  reach_point
    3 n! \% s- I7 s  `9 W
  1330.       draw_path = false& C, r3 z- T8 G- e( \+ i" ^: b
  1331.       check_points = new_end_points, v: }- K, _- b7 C/ B$ D
  1332.       new_end_points = []
    8 N; E3 L9 O6 \4 E
  1333.       step += 1
    ( X. b1 t. s' i' v1 |# z3 _
  1334.       break if step  KsOfSionBreak_Steps &&8 U# Z5 A" s; e+ K% o' F
  1335.                !Input.press(KsOfSionFind_Path_Key)
    , P, ~7 b, M$ e/ V! ]6 r  i6 K( M
  1336.       loop do #loop3 从终点开始反向填充) x+ i+ t, T6 l4 ~8 L  U1 T
  1337.         point_x = check_points.shift* W# H3 f' u' L
  1338.         break if point_x == nil
    ; k! U% ]' e; Q/ C
  1339.         point_y = check_points.shift
    2 Z7 i  y  o' B# O- e6 {+ ~7 G
  1340.         left_x  = $game_map.round_x(point_x - 1)
    6 r/ d5 H3 V; j. _4 }1 A. p/ `9 ?
  1341.         right_x = $game_map.round_x(point_x + 1)
    ' y' a3 s4 A0 J, [! B
  1342.         up_y    = $game_map.round_y(point_y - 1)5 ~9 `& T' u/ M0 s3 U
  1343.         down_y  = $game_map.round_y(point_y + 1)2 l0 D( M; k1 x& O. r3 x
  1344.         # 判断路径是否连通* g2 m% O* m6 p, f
  1345.         path_step = step - 1
    ; H4 g/ p# c& _7 `! T
  1346.         if sheet[left_x, point_y] == path_step     &&2 c0 {$ i* m9 u3 Q& G9 e- I% ^8 K
  1347.            $game_map.passable(left_x, point_y, 6) &&% \. s; M7 N3 _4 p1 h4 U, z
  1348.            $game_map.passable(point_x, point_y, 4)2 A# w8 E% c2 {& s* d, [8 p7 V
  1349.           chase_path.push(6)( s% r% w$ r" W0 v1 |
  1350.           chase_point = [point_x, point_y]
    8 U- I9 F' g  x
  1351.           reversed_chase_point = [left_x, point_y]
    8 E8 g$ v+ d. Y  S1 p) i
  1352.           reach_point = true; break0 q  f+ g/ L, k' ?2 m
  1353.         elsif sheet[right_x, point_y] == path_step     &&* v( u( V5 Y1 l  ?7 z3 e! H( o
  1354.               $game_map.passable(right_x, point_y, 4) &&
    : J- q8 ?  D4 G. B  @. {: C
  1355.               $game_map.passable(point_x, point_y, 6)
    1 v5 u7 c9 O( `& e
  1356.             chase_path.push(4)
    " H! x" x6 f, c7 o$ R- g7 D! J
  1357.             chase_point = [point_x, point_y]/ W6 p* A/ A4 j  z- k
  1358.             reversed_chase_point = [right_x, point_y]" t" c3 q5 B: T+ N
  1359.             reach_point = true; break
    & [* a( I% m/ B" w/ K; R# ^( h4 `
  1360.         elsif sheet[point_x, up_y] == path_step     &&
    $ r% g+ N8 B/ X7 D) Y
  1361.               $game_map.passable(point_x, up_y, 2) &&
    3 h" h9 v7 o  F
  1362.               $game_map.passable(point_x, point_y, 8)
    ) |& V7 Q, s6 {7 _$ Z2 T
  1363.             chase_path.push(2)
    / ^3 X- h# H% R' h' ~- y4 Z; ~1 w
  1364.             chase_point = [point_x, point_y]
    0 b- s& c% `0 {; z! T; Z
  1365.             reversed_chase_point = [point_x, up_y]
    6 e  K5 \# C/ t: }
  1366.             reach_point = true; break
    2 |1 o0 M7 e4 Z1 D" C
  1367.         elsif sheet[point_x, down_y] == path_step     &&5 d" D. A* Y$ X* l% w9 e
  1368.               $game_map.passable(point_x, down_y, 8) &&' m5 O4 M  `3 f& Z2 r! B6 {
  1369.               $game_map.passable(point_x, point_y, 2)
    8 P  ~, N/ k9 J- S, p
  1370.             chase_path.push(8)' D/ c7 T! Z) Y  y
  1371.             chase_point = [point_x, point_y]
    ( R" G4 \" F! w& _% Q  n
  1372.             reversed_chase_point = [point_x, down_y]
    - I! J8 k  g4 C, B
  1373.             reach_point = true; break. J9 I' |- Q; b. d. I( ~. y9 ^
  1374.         end& @6 ^0 |6 T1 x" D3 D
  1375.         # 以需要抵达该点的步数填充路径表格 ## w5 |+ Z: h* |4 |1 v
  1376.         if sheet[left_x, point_y] == 0              &&5 b* z* L1 W( J) e$ t  U
  1377.            $game_map.passable(left_x, point_y, 6)  &&6 P$ Q0 Q6 J/ O' m0 \' f) W) J6 C/ _8 }
  1378.            !collide_with_events(left_x, point_y)   &&
    7 R0 P! d$ l6 I  N. X4 I/ d
  1379.            $game_map.passable(point_x, point_y, 4) &&" F9 M: |3 E. n' P! L
  1380.            !collide_with_vehicles(left_x, point_y) #judge_end0 J2 f- J4 A7 o' ]5 k3 F
  1381.           sheet[left_x, point_y] = step
    4 G& s; d1 D! W, {
  1382.           draw_path = true
    # H" L3 u: h3 E8 F. q
  1383.           new_end_points.push(left_x, point_y)0 x+ H3 [; c9 B* V& U+ ^0 a
  1384.         end
    # ^6 O' x0 N( S
  1385.         if sheet[right_x, point_y] == 0             &&6 l; ~% l7 G! h5 R$ w% g4 Q
  1386.            $game_map.passable(right_x, point_y, 4) &&
    & K3 f& |: V$ C& V8 @, V! G
  1387.            !collide_with_events(right_x, point_y)  &&
    1 Y1 e: y  h6 F6 `2 e
  1388.            $game_map.passable(point_x, point_y, 6) &&  s  g! Q; j, a& ]) L# a/ F
  1389.            !collide_with_vehicles(right_x, point_y)#judge_end
    ; [* L1 a9 N8 R, p' P  \7 x
  1390.           sheet[right_x, point_y] = step
    + W  v% `6 P) g& {
  1391.           draw_path = true
    1 A/ w% W* d. m0 v( X- q
  1392.           new_end_points.push(right_x, point_y)
    7 S" g7 U: u5 R  a
  1393.         end& J) h2 y% p( d+ M8 Z  E
  1394.         if sheet[point_x, up_y] == 0                &&  k) p3 `2 z( ^
  1395.            $game_map.passable(point_x, up_y, 2)    &&8 G# A3 c6 }8 c. y1 v2 H4 K: u  X9 \
  1396.            !collide_with_events(point_x, up_y)     &&
      T5 g1 P* |$ x( Q: E
  1397.            $game_map.passable(point_x, point_y, 8) &&9 x' y0 f/ k6 Q" y3 h8 F
  1398.            !collide_with_vehicles(point_x, up_y)   #judge_end
    - j( k- [! a( L  b; n
  1399.           sheet[point_x, up_y] = step
    4 {& k/ @# X0 {& F. y
  1400.           draw_path = true( e1 C2 N0 {+ l7 w' N
  1401.           new_end_points.push(point_x, up_y)
    - u; ]0 b* U% {
  1402.         end
    " m6 d5 \7 U% o; z, a
  1403.         if sheet[point_x, down_y] == 0              &&
    1 q* G% E  I/ a/ F2 P: d
  1404.            $game_map.passable(point_x, down_y, 8)  &&, d6 O6 v3 m) e0 N6 y
  1405.            !collide_with_events(point_x, down_y)   &&$ a3 X; j5 O/ l5 ?
  1406.            $game_map.passable(point_x, point_y, 2) &&
    ; @8 W+ o& ?0 C8 P' ~
  1407.            !collide_with_vehicles(point_x, down_y) #judge_end0 f: @$ B1 E+ |" ]2 p1 g
  1408.           sheet[point_x, down_y] = step  T( u% Z+ Q( l4 P/ z: o% {
  1409.           draw_path = true$ C5 R- D8 h- L. R3 h# Y7 v8 B+ y
  1410.           new_end_points.push(point_x, down_y), V9 q0 d8 D* h4 T+ f# f
  1411.         end
    ! g- @% y" d8 q( i( T
  1412.       end#endOfLoop3; x" y- S' {( s, F) g4 {* Q  @) Q5 G1 n
  1413.       break if !draw_path  reach_point, Z" ~: K- G  ~
  1414.       step += 1
    $ j. M: \' F# t6 w  n0 z8 X$ W2 \! O
  1415.     end #endOfLoop1 路径表格填充完毕
    0 K) ~! y0 M! q! O
  1416.     $mouse_move_sign.transparent = false
    7 @' x1 i4 k4 j( y+ ]5 d5 l; x  ~, \
  1417.     # 判断指定地点能否抵达
    4 W3 a. K7 [8 X1 C* T3 O% e9 v6 w# f
  1418.     if reach_point. ]" @7 _( W+ C" X* y
  1419.       $mouse_move_sign.direction = 2' L( P* r5 v4 H/ _, Q4 Z. _
  1420.     else. l0 B9 J* t8 }5 s( i* z
  1421.       not_reach_point" c  d; y4 `# y" u6 L0 Z  u3 _
  1422.       return
    , Z- x' _1 I; V- c
  1423.     end; F3 {3 s: [: N! F( {
  1424.     # 根据路径表格绘制最短移动路径(反向)
    + w5 U6 _. G$ ~3 s% ?7 |
  1425.     steps = step  2  2 + 1
    ( d7 m' y* h6 H0 M
  1426.     loop_times = step  22 X* Z/ w3 b/ O
  1427.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
    2 `: R* |  @4 Z8 g  a# z
  1428.     for i in 1..loop_times # forLoop( V, {. y: |) h) y
  1429.     steps -= 2
    1 @& N/ T; M( M% u
  1430.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs #反过来?蛋疼了……
    3 j7 ?' b2 g" A
  1431.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&/ W6 A3 E" |: K3 V$ l9 U* g
  1432.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
    + S% ]/ ~) x1 B
  1433.             $game_map.passable(point_x, point_y, 4)                #judge_end: C6 N( ^+ b' ?+ @! H
  1434.         reversed_chase_path.push(6)5 W$ p  i5 A/ V4 f0 u! L7 b7 U
  1435.         point_x = $game_map.round_x(point_x - 1)
    + \/ |: j: }' k9 k/ i- j8 H/ _
  1436.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&% g' @; z+ \6 g- F
  1437.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    5 |' Z6 [0 n) m" H
  1438.             $game_map.passable(point_x, point_y, 6)                #judge_end
    . o% @. Q9 h5 [
  1439.         reversed_chase_path.push(4)
      l0 r' y6 R/ ~* X; @
  1440.         point_x = $game_map.round_x(point_x + 1)
      h% l' o5 B# j3 f
  1441.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&& d# n6 H" M1 ~; H+ ?, c1 C
  1442.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    . A5 C" H5 H3 ~
  1443.             $game_map.passable(point_x, point_y, 2)                #judge_end
    7 A. ~) F3 K. x$ q9 N$ i
  1444.         reversed_chase_path.push(8)
    : K5 N( _' |  n/ A* ]0 }! h
  1445.         point_y = $game_map.round_y(point_y + 1)
    : o1 F" \( k  j# `$ E! ?* d' P+ ]
  1446.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    " r: R2 i' a) X5 {4 H9 j; ~
  1447.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    8 j/ G3 e4 G; ?3 _
  1448.             $game_map.passable(point_x, point_y, 8)                #judge_end+ Q- o. [4 Y! U' h' l
  1449.         reversed_chase_path.push(2)
    , O# }$ [! h8 w1 \
  1450.         point_y = $game_map.round_y(point_y - 1)$ R# ]8 N5 v; W' M% N
  1451.       end% u. k7 {, A6 d/ Y
  1452.     else
    8 v( X' \' b9 E$ Z1 j6 K& u3 a
  1453.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&0 i& U( D( w. Y2 k$ ?
  1454.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&) L' k' v# B  z; n, {
  1455.             $game_map.passable(point_x, point_y, 2)                #judge_end+ z% g; G4 y# ?6 p$ Q" w* \+ N* h
  1456.         reversed_chase_path.push(8)
    . H5 X) E8 w0 x8 @; @4 o
  1457.         point_y = $game_map.round_y(point_y + 1)' k7 ]4 V- O2 p: e
  1458.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    / e8 r  Q; I- r
  1459.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    % j  K# n$ x5 A6 v0 Y3 n8 `5 x
  1460.             $game_map.passable(point_x, point_y, 8)                #judge_end4 K1 r  W) H/ f: k6 Z( Y
  1461.         reversed_chase_path.push(2). I- F" P7 d6 p. J- C  k0 S& v3 i
  1462.         point_y = $game_map.round_y(point_y - 1)( t4 K, u8 k# k7 M1 Q, l7 ?
  1463.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&7 L& i# R# B$ |( _
  1464.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&/ A- F1 S9 E# D6 S9 E! U
  1465.             $game_map.passable(point_x, point_y, 4)                #judge_end
    * b. O( _, U$ {' m- f* |
  1466.         reversed_chase_path.push(6)# W/ I$ o- J& z2 H7 i. e- R
  1467.         point_x = $game_map.round_x(point_x - 1)
    2 J" g. f, _8 ]* P8 k* b; g' U
  1468.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    ) \1 `6 N: h: t1 ^' r
  1469.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    - f& T2 D5 A$ r. u: o
  1470.             $game_map.passable(point_x, point_y, 6)                #judge_end
    + c) n5 h7 b% h
  1471.         reversed_chase_path.push(4)
    + g  j7 i& O7 O0 G; y- w
  1472.         point_x = $game_map.round_x(point_x + 1)
    & B+ L. m' G+ ]
  1473.       end, U9 [! _( ~8 }2 \
  1474.     end
    8 f5 P+ k1 W% w  Q
  1475.     end #endOfForLoop
    6 O& k3 @4 a8 q- y, X0 s
  1476.     # 根据路径表格绘制最短移动路径(正向)) b  A4 i0 t0 F4 F/ ?! ~' F
  1477.     steps = step  2  2
    " ~9 a% o. Y2 d
  1478.     loop_times = step  28 z% d* z% m9 [2 ]" t' [+ o
  1479.     point_x, point_y = chase_point[0], chase_point[1]4 w& L- v; x4 L/ \3 G
  1480.     for i in 2..loop_times # forLoop! O' [& f& ?8 e6 K) m& G' ~
  1481.     steps -= 26 x) r& x2 \; R! ]; `. T6 H
  1482.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs3 K" w9 D" v& U8 J, ~7 k
  1483.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
    8 I; `5 j# `$ G0 I4 {8 c
  1484.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    7 d9 V1 H5 P8 k2 d) g# b7 w2 N% r% f
  1485.             $game_map.passable(point_x, point_y, 2)                #judge_end
    5 S" z5 O- J: ^- H8 s. L; ~. i
  1486.         chase_path.push(2)/ Q. p6 u8 ~9 A& b6 B: v/ J: J4 c5 @
  1487.         point_y = $game_map.round_y(point_y + 1)
    8 l2 X! ]! Y- Z; S" @
  1488.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&9 g% c  ^% ]8 q2 ]5 W* }
  1489.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&3 S: W% e7 R8 k8 |6 L
  1490.             $game_map.passable(point_x, point_y, 8)                #judge_end
    * }, X" P" Y5 ]( ~+ F0 {; x
  1491.         chase_path.push(8); ~6 S1 q1 @  t# ?/ S: W
  1492.         point_y = $game_map.round_y(point_y - 1)1 l6 n3 ~1 T- j0 H7 Z, i" T$ p
  1493.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    ' h, k9 U& J" c
  1494.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&, H" V2 x& I  e8 l
  1495.             $game_map.passable(point_x, point_y, 4)                #judge_end
    , @& b- [4 T' ?$ E0 P6 Q9 ~
  1496.         chase_path.push(4)
    . s6 F$ d9 b/ W9 D
  1497.         point_x = $game_map.round_x(point_x - 1)
    % ?$ u' q7 `5 J, P. P+ c
  1498.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&1 k. G7 j  ]" {2 Z1 Q2 `( ]; |7 C
  1499.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&# O* H4 ~8 x! Y! O0 W; c& |- A: L* ^
  1500.             $game_map.passable(point_x, point_y, 6)                #judge_end6 f! A1 |! ^3 u* r* D/ @+ k( r
  1501.         chase_path.push(6)# K" H4 N/ Y' ?* S
  1502.         point_x = $game_map.round_x(point_x + 1)2 G1 H7 J& q' M  |  B  u0 ^3 u9 \
  1503.       end
      y# E: \5 V. x3 ^4 Q+ y$ H: z
  1504.     else
    6 Q; I' J; Y# y& D* t0 x( ~' |
  1505.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&7 O# s- D" Q1 u8 Q. `( @& q4 i
  1506.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&& {: f8 l9 q* V$ S0 C
  1507.             $game_map.passable(point_x, point_y, 4)                #judge_end
    + d4 D) v; k, a) ^) ?1 W7 x9 R
  1508.         chase_path.push(4)
    ; f5 @2 O' y. i, @' |; U
  1509.         point_x = $game_map.round_x(point_x - 1); S  ^8 y3 _7 `4 E5 u0 _( F
  1510.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    3 T: p2 _& I; L& n# E2 r1 G. a6 H
  1511.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&0 i) l5 C0 V1 v7 J' c
  1512.             $game_map.passable(point_x, point_y, 6)                #judge_end* j. [4 r6 S2 F- j" P1 n
  1513.         chase_path.push(6)3 j/ ]. l) |6 j9 [: d8 U9 M
  1514.         point_x = $game_map.round_x(point_x + 1)+ i+ k2 y3 ?" i; C% n
  1515.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
    , V' q) N3 ~& Z  t
  1516.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&7 W. f% |6 p7 S) `9 D+ ~' G
  1517.             $game_map.passable(point_x, point_y, 2)                #judge_end
      F3 r* c6 a5 g/ ^- v- ^! f
  1518.         chase_path.push(2)
    8 _+ g7 S% [8 i; J+ `4 Z
  1519.         point_y = $game_map.round_y(point_y + 1)8 T' Q9 d; V4 H4 ~/ R% u
  1520.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&+ D/ d. ~; }- {2 |, a* H
  1521.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&8 \  u+ D; K8 Z& t" D/ U
  1522.             $game_map.passable(point_x, point_y, 8)                #judge_end$ \- Y9 y: X2 C, Q) |0 x$ q3 ~
  1523.         chase_path.push(8)5 \; S: o# V, @2 L- W8 D
  1524.         point_y = $game_map.round_y(point_y - 1)! V% [4 f5 v9 g/ p3 s: D5 v* ^3 i9 M
  1525.       end
    0 x/ \1 ^' K/ P% y8 Z1 @
  1526.     end
    $ c9 r9 i* w  J5 Z
  1527.     end #endOfForLoop6 d; Q- s1 z4 G: }8 P, ?4 K" P2 V
  1528.     @mouse_move_path = reversed_chase_path.reverse + chase_path
    , r- d" p/ J: [. _! i- E% _
  1529.   end#walk
    , G3 `7 M4 i$ p
  1530.   #--------------------------------------------------------------------------
    9 c. M$ p; \* M8 c' \/ p
  1531.   # ● 绘制boat的移动路径 @array[move_directions...]
    0 ?9 }8 l* B3 }% F& i2 Z/ N
  1532.   #--------------------------------------------------------------------------' T4 T( x3 \( f( q' ]0 C
  1533.   def draw_boat_path! Z2 Y2 \4 ]; D+ y' {5 N3 O7 n
  1534.     # 准备绘制路径表格
    7 H6 b$ }: o+ _6 o
  1535.     sheet = Table.new($game_map.width, $game_map.height)* V# y/ v9 R& h$ W
  1536.     reversed_chase_path  = []; chase_path  = []7 \* ?* X  p  k2 `
  1537.     reversed_chase_point = []; chase_point = []
    8 G/ _8 k- [2 I& J( Z
  1538.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
    ( ?0 @6 \" q1 V9 Q" i: x
  1539.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
    - t$ v4 s" \: w4 g; F
  1540.     reach_point = false  ^  h9 ^2 n! A. k
  1541.     step = 3
    ! e( z4 |& W1 \& `2 @8 a2 P: ]
  1542.     loop do #loop1 开始填充表格% I' n; Z  y8 J( ~  o9 v! v& s
  1543.      draw_path = false) f4 j, ~  v, ?# I* H
  1544.      check_points = new_start_points; F6 C. Z3 o3 L/ f
  1545.      new_start_points = []& z4 |0 f% f6 y1 {+ B- g8 S$ }# r
  1546.       loop do #loop2 从起点开始正向填充
    : Q; X7 D) x9 E
  1547.         point_x = check_points.shift, l& Q- ~* Y6 f% V  i- {( z( _! M3 J
  1548.         break if point_x == nil7 I1 e! `2 O+ ]! x% g
  1549.         point_y = check_points.shift
    / i/ Q: @4 s7 d( p! [3 l  D
  1550.         left_x  = $game_map.round_x(point_x - 1)& h; C* l( X; S% e7 B& H
  1551.         right_x = $game_map.round_x(point_x + 1)# r# ?3 w# [2 I) I# c$ i# G2 A
  1552.         up_y    = $game_map.round_y(point_y - 1)3 X( J  K0 U  _) p, K/ Z, s
  1553.         down_y  = $game_map.round_y(point_y + 1)
    ' L* b3 u/ l, S! Q! P$ X/ D; ~
  1554.                     # 判断路径是否连通1 y% u; X6 f* U8 r' B
  1555.         path_step = step - 1
    " c1 h* e& o4 V, {+ r( @6 m
  1556.         if sheet[left_x, point_y] == path_step
    , n' S$ c+ d2 q9 K, F( A, A" z% `
  1557.           chase_path.push(4)
    4 K7 u; F( w) J( T$ w' \
  1558.           chase_point = [left_x, point_y]
    5 _0 C% c# N/ R! u2 \
  1559.           reversed_chase_point = [point_x, point_y]
    - ^9 I. }0 o, M
  1560.           reach_point = true; break
    ; y( e. \0 |2 X# i* e6 G
  1561.         elsif sheet[right_x, point_y] == path_step- d4 `' L# P8 q5 U1 j# [5 l( w
  1562.             chase_path.push(6)% g& ?' B1 b4 }
  1563.             chase_point = [right_x, point_y]3 [- y# B+ b" ^2 g
  1564.             reversed_chase_point = [point_x, point_y]
    " u) H) X* e/ }1 i$ c6 Z1 b
  1565.             reach_point = true; break$ i! n4 O- Q6 ~& F5 f
  1566.         elsif sheet[point_x, up_y] == path_step
    5 ?; ^; D2 K- B: ^, m; N
  1567.             chase_path.push(8)8 a2 w" K$ U. U7 C" |4 e$ W
  1568.             chase_point = [point_x, up_y]
    ( e, Z" a' |$ C2 d6 w+ l, Q# e" c
  1569.             reversed_chase_point = [point_x, point_y]; f. P5 C$ |8 ?4 S
  1570.             reach_point = true; break  l: V8 r' S5 M6 E, o$ ~, B
  1571.         elsif sheet[point_x, down_y] == path_step6 A3 E& W5 V( _0 V, B- j
  1572.             chase_path.push(2)
    ; `7 }4 S2 ?, p0 v* M/ u# z+ r9 L
  1573.             chase_point = [point_x, down_y]
    - r2 t  f+ |& n" U& d7 p( x0 [
  1574.             reversed_chase_point = [point_x, point_y]
    ) a4 A0 o1 ?) {. ?0 Q" q/ n
  1575.             reach_point = true; break! U# M4 V& d( j7 n, i
  1576.         end' o7 N/ E. D& q0 J+ b; U
  1577.         # 以需要抵达该点的步数填充路径表格 #* H7 E8 K% [+ x" k' U& U8 |
  1578.         if sheet[left_x, point_y] == 0                &&/ J3 v/ }4 U- X& t7 i% q
  1579.            $game_map.boat_passable(left_x, point_y)  &&
    ( R0 b% T8 v  Z; w4 K9 G$ k% w
  1580.            !collide_with_events(left_x, point_y)     &&
    0 Q& j% d  P$ d; N$ ^
  1581.            !collide_with_vehicles(left_x, point_y)   #judge_end
    " i" y" [: {& t/ R/ j  Q+ q
  1582.           sheet[left_x, point_y] = step' H3 p( U& U7 [3 ?" ^% W9 L
  1583.           draw_path = true% _4 p( U8 c  v8 ^6 X- ^4 j& }
  1584.           new_start_points.push(left_x, point_y)5 o4 |8 `0 [( r: ^, @% K& S% L, j& v# @
  1585.         end
    5 n6 |. W0 e, j$ @- m
  1586.         if sheet[right_x, point_y] == 0               &&" B; g5 z- J) b; u
  1587.            $game_map.boat_passable(right_x, point_y) &&& |  J: O0 ~. L' c! q
  1588.            !collide_with_events(right_x, point_y)    &&
    ! [! M/ j: j3 ^% K  [! O( J
  1589.            !collide_with_vehicles(right_x, point_y)  #judge_end
    % A4 n- [% j" q5 I; @% a6 n3 c, b+ a
  1590.           sheet[right_x, point_y] = step
    2 S  i4 Z; Q" ?( h1 H) R$ r
  1591.           draw_path = true
    . C; ^) _" E' O6 R  E7 ?
  1592.           new_start_points.push(right_x, point_y)
    , Y: l8 ]: M3 a. I0 y2 e7 L( s
  1593.         end
    . N& z' v. V6 m
  1594.         if sheet[point_x, up_y] == 0                  &&
    2 `  ^2 O0 q& d) b4 N9 u4 Z
  1595.            $game_map.boat_passable(point_x, up_y)    &&  [* D. p+ |& X( Z
  1596.            !collide_with_events(point_x, up_y)       &&
    / n# r, \) K, m$ ?
  1597.            !collide_with_vehicles(point_x, up_y)     #judge_end5 P# w6 @- ~, q# e% Y
  1598.           sheet[point_x, up_y] = step5 B  q4 G) t' b5 R4 X" N
  1599.           draw_path = true3 M; o6 Z+ A9 H) ^$ r/ \. x
  1600.           new_start_points.push(point_x, up_y)
    - V9 z1 P; x( C9 z% M
  1601.         end* I. B; N* ]% ]) D0 Y, h
  1602.         if sheet[point_x, down_y] == 0                &&
    + @- `. }% Y! `4 y* }; s1 X
  1603.            $game_map.boat_passable(point_x, down_y)  &&# n; E& U9 _8 g0 R- Z& j5 m
  1604.            !collide_with_events(point_x, down_y)     &&& ~+ X0 ~2 @( T, b: o' D5 r# F
  1605.            !collide_with_vehicles(point_x, down_y)   #judge_end
    1 L/ E, H7 h  n9 Q( k( P2 \+ v
  1606.           sheet[point_x, down_y] = step
    ' r' c& W3 t+ r6 l( l5 \  P" {
  1607.           draw_path = true
    4 k0 x! @7 V$ J5 m7 k: c& c
  1608.           new_start_points.push(point_x, down_y)1 @6 N. t- L7 k) m5 V5 n2 w3 ?
  1609.         end
    6 J+ a2 n4 b; x3 k: j
  1610.       end#endOfLoop27 g3 Y2 p; ]4 k6 z6 T" Y
  1611.       break if !draw_path  reach_point- J0 `7 A! Z% q
  1612.       draw_path = false5 F3 z  p+ ^, \# ?5 g
  1613.       check_points = new_end_points. f/ y% N7 W; n$ B. V8 _$ D* `
  1614.       new_end_points = []
    6 k3 O9 w; J  ~: H! E
  1615.       step += 1( G1 S; f* i5 N) u9 g+ r
  1616.       break if step  KsOfSionBreak_Steps &&7 B! K' x; n* R  [/ d% p' ^8 }
  1617.                !Input.press(KsOfSionFind_Path_Key)$ c  i4 M$ K! u  X% B; J# v: f
  1618.       loop do #loop3 从终点开始反向填充
    & @* g, Y! k9 D" d0 G; [: R
  1619.         point_x = check_points.shift( X6 @$ o8 z& F" E; r* \  v5 W
  1620.         break if point_x == nil
    " m" g1 X5 e, M' y& ~! g% p
  1621.         point_y = check_points.shift
    7 Z$ ?' q4 ]0 q! v: z
  1622.         left_x  = $game_map.round_x(point_x - 1)
    8 ?9 g! I, ~. v8 s% N7 g
  1623.         right_x = $game_map.round_x(point_x + 1)7 ?9 D3 }0 b& N! b, D" @- ~0 l
  1624.         up_y    = $game_map.round_y(point_y - 1)
    1 J, o/ y* `" @+ h( ]# C0 D
  1625.         down_y  = $game_map.round_y(point_y + 1)
    1 y: t0 Q" q5 W  S4 _2 W) J- u
  1626.         # 判断路径是否连通
    & L: t6 \0 j; k) P7 E
  1627.         path_step = step - 1
    , H% w9 r) }: v( J+ W& M
  1628.         if sheet[left_x, point_y] == path_step- @! q: |* H% v0 i1 b5 ?9 w7 e. L
  1629.           chase_path.push(6)
    + i6 Q3 M; \2 Z+ \6 u
  1630.           chase_point = [point_x, point_y]
    6 }; q; h9 U1 v) |" F0 m* D* ]7 C
  1631.           reversed_chase_point = [left_x, point_y]) G9 m9 ]# D5 l- H, |
  1632.           reach_point = true; break2 N6 S& U- p' z" J/ Z$ ?/ y
  1633.         elsif sheet[right_x, point_y] == path_step# z% }' Q( x! o/ F6 V
  1634.             chase_path.push(4)# P6 W( }2 K# _, h, d( g. R7 K/ k
  1635.             chase_point = [point_x, point_y]
    7 w2 Z+ Z9 J; L5 T/ Z( a
  1636.             reversed_chase_point = [right_x, point_y]: U5 I+ i" H& y- A
  1637.             reach_point = true; break' l# x6 S) x- W% U
  1638.         elsif sheet[point_x, up_y] == path_step
    8 T% n- E! |) w' D+ V& I' z" R
  1639.             chase_path.push(2)5 w- g9 l4 G: _+ ~5 r" h1 o
  1640.             chase_point = [point_x, point_y]
    9 s  R& F2 u, w5 v- `4 |3 ?1 [
  1641.             reversed_chase_point = [point_x, up_y]
    3 ?- D. T: E  M
  1642.             reach_point = true; break
    1 v) G. t5 q8 e4 t3 I
  1643.         elsif sheet[point_x, down_y] == path_step* ~+ m: k1 x$ _' w- }" u' Z, ?$ ?7 V
  1644.             chase_path.push(8)* R3 s, o6 P1 J* v' |
  1645.             chase_point = [point_x, point_y]9 s* z( s0 s0 t6 J& O9 L
  1646.             reversed_chase_point = [point_x, down_y]
    - f8 |( y5 t7 [9 H
  1647.             reach_point = true; break" K! x0 Q( e! }) p
  1648.         end
    - ?, }; ?% ?( `. [3 |% K. K% G  z
  1649.         # 以需要抵达该点的步数填充路径表格 #
    2 `4 ^; f/ u" ]9 W" w9 \5 ~3 ~
  1650.         if sheet[left_x, point_y] == 0                &&+ ~$ k0 m4 w' Y6 n2 D& D* Z$ N
  1651.            $game_map.boat_passable(left_x, point_y)  &&. u  i) G* ~- ?) P
  1652.            !collide_with_events(left_x, point_y)     &&% C6 \$ U. _5 Y8 [5 Y$ V9 I
  1653.            !collide_with_vehicles(left_x, point_y)   #judge_end
    0 g% G6 R7 [' _7 b
  1654.           sheet[left_x, point_y] = step
    . ]4 O8 a% r# d9 I) M
  1655.           draw_path = true: C6 w) A5 j! z  P
  1656.           new_end_points.push(left_x, point_y)/ l# w4 X  F# c1 J6 T
  1657.         end
    1 ]$ @0 h3 ^  Q7 @: v7 d: v: u! ]$ k
  1658.         if sheet[right_x, point_y] == 0               &&8 _" n+ l4 [4 i, U
  1659.            $game_map.boat_passable(right_x, point_y) &&) D( z: o/ p6 [; j9 e# z
  1660.            !collide_with_events(right_x, point_y)    &&3 \$ K9 e( h' q6 z0 k
  1661.            !collide_with_vehicles(right_x, point_y)  #judge_end
    1 \5 a$ s- ^8 c7 m& }4 z' m( `
  1662.           sheet[right_x, point_y] = step+ v& Q6 y1 c8 a3 ?& T
  1663.           draw_path = true
    ' B; r0 U4 r  W) W6 L
  1664.           new_end_points.push(right_x, point_y)
    ) I  |" K* _7 C8 u( `% l7 D2 I/ k
  1665.         end
    0 a& ?( G1 O0 X; \; ~
  1666.         if sheet[point_x, up_y] == 0                  &&( m/ S) c8 S* Q3 T( J3 S0 b! _
  1667.            $game_map.boat_passable(point_x, up_y)    &&- t0 l% d: R4 }1 J
  1668.            !collide_with_events(point_x, up_y)       &&
    5 W; a' s1 p$ F2 K9 D
  1669.            !collide_with_vehicles(point_x, up_y)     #judge_end
    $ z6 `% k8 d; Y5 {
  1670.           sheet[point_x, up_y] = step
    3 B. o- {- n+ O5 X! z- _+ e
  1671.           draw_path = true
    1 _% c; E& `6 ]% I& S( J
  1672.           new_end_points.push(point_x, up_y)6 G) v. K$ ^8 U* o0 h/ O, V+ q
  1673.         end: Z7 v9 P1 v, P
  1674.         if sheet[point_x, down_y] == 0                &&% M- z/ w5 G8 p# h1 F8 P
  1675.            $game_map.boat_passable(point_x, down_y)  &&! W: i4 A0 i- o! ]
  1676.            !collide_with_events(point_x, down_y)     &&# M/ x1 T4 `6 g8 j+ V: {2 F
  1677.            !collide_with_vehicles(point_x, down_y)   #judge_end
    & I& Q  @) [3 n; [, k! K
  1678.           sheet[point_x, down_y] = step
    * _' D" R. T: n# t7 F- c
  1679.           draw_path = true1 c; }/ C, c* u) [' I- [: e
  1680.           new_end_points.push(point_x, down_y)
    8 B$ I) i2 {  q# N/ t2 `- T* d7 W
  1681.         end
    / n; Z% T" D' e" ?: h4 T8 k$ O
  1682.       end#endOfLoop3
    4 j5 r1 F  p, u4 y. j" V  z! d( B1 d
  1683.       break if !draw_path  reach_point
    3 M9 f1 f- }' S8 `' P
  1684.       step += 1
    - y2 S/ D+ o# @/ m
  1685.     end #endOfLoop1 路径表格填充完毕
    # F" |+ D7 q0 q! |0 x7 |
  1686.     $mouse_move_sign.transparent = false6 E: V3 l3 N" q0 U( F  U3 ?5 c9 B+ f
  1687.     # 判断指定地点能否抵达
    7 m  Z0 ]/ s9 p
  1688.     if reach_point
    $ V9 z8 K# W8 D" d  H( g% U: ^% ^  |" [* ?
  1689.       $mouse_move_sign.direction = 2
    0 U% ?) _% b' z$ |$ C
  1690.     else) F8 P- A, J- G9 e6 j- C9 Q
  1691.       not_reach_point
    + M, s3 q4 g) J, l3 A2 L
  1692.       return, u  Z5 s9 U; S- C) U/ Q
  1693.     end7 N: a2 O$ ^; U1 j# O0 C
  1694.     # 根据路径表格绘制最短移动路径(正向)7 Z8 {1 @1 S. ]# T( s
  1695.     steps = step  2  2
    + O% c* {1 Y; y& s' C  B! c
  1696.     loop_times = step  2
    # T, a: R8 j( Q/ O
  1697.     point_x, point_y = chase_point[0], chase_point[1]
    * p) A, ^% k  x5 C& Y" t: ]
  1698.     for i in 2..loop_times # forLoop
    6 U$ v% W8 z7 b
  1699.     steps -= 2' r" i; A0 u& C  i! k
  1700.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs. u# n% K# D: F, V5 J+ X$ n
  1701.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    ) r, q# `1 k/ a: C
  1702.         chase_path.push(2)
    # ~% s% S+ X, }( i6 w5 U
  1703.         point_y = $game_map.round_y(point_y + 1)" m! e. ~: N6 `' D/ X
  1704.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    + m3 ]& W/ A' U, \0 i/ w$ p
  1705.         chase_path.push(8)
    6 r5 P5 z# `7 L4 A3 A0 H! g8 U9 E
  1706.         point_y = $game_map.round_y(point_y - 1)  p# R2 m- r, u; v* z. o
  1707.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    - P& D6 n7 P/ @& ]
  1708.         chase_path.push(4)
    4 E# F. d3 X7 e- W) g$ |
  1709.         point_x = $game_map.round_x(point_x - 1)
    $ B0 n6 q4 Q; O* W% k) I* p9 C
  1710.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    ; i. V$ Q6 R$ B, I. m. V0 h7 g
  1711.         chase_path.push(6)0 F( `4 w" _8 O# w% H4 w
  1712.         point_x = $game_map.round_x(point_x + 1)
    / R! }# H5 T* t* A0 ^% n
  1713.       end2 y% r1 s! r/ B! B) B
  1714.     else/ ~' ]" D2 Z; k4 Z# b; y2 m
  1715.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps; S8 u1 Y, B4 O+ `% J
  1716.         chase_path.push(4)# ]( _# T' S9 [
  1717.         point_x = $game_map.round_x(point_x - 1)) N' f/ }* l( W" r& V
  1718.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps" z$ Z8 X, I4 m$ F. W) s
  1719.         chase_path.push(6)
    " h' e  U- R% X
  1720.         point_x = $game_map.round_x(point_x + 1)
    : H9 p8 I. @  ?: u4 Z( _+ O7 k
  1721.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    2 B- Z  K8 P, P  F3 E. ~
  1722.         chase_path.push(2)4 i8 F) M9 r! Z. [2 X4 x
  1723.         point_y = $game_map.round_y(point_y + 1)
    / m$ z2 S) H9 ]# J/ w( I/ P
  1724.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps/ b9 h9 l: O. N  I7 |: d- A% X
  1725.         chase_path.push(8), A/ l4 x* t: ~% V8 v/ E" o$ R
  1726.         point_y = $game_map.round_y(point_y - 1)
    3 w9 T* G7 m+ d& k
  1727.       end
    ' ?7 s9 @! K# S. u% @$ t
  1728.     end) Z5 }! U& ?! `  w6 M2 L: h
  1729.     end #endOfForLoop# [& H! h! e& w$ j  @
  1730.     # 如果指定点无法抵达或者登陆
    ( S' Z+ X9 {) h: o. n
  1731.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)
    # P6 U) U( [5 [+ W1 J! O
  1732.     # 根据路径表格绘制最短移动路径(反向)
    & @( D9 A: f: ]" |- D$ @
  1733.     steps = step  2  2 + 1
    2 O; o5 m3 O/ M3 Q6 n, y+ Q
  1734.     loop_times = step  2
    8 E& B# u" |7 X
  1735.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]1 Q- ~4 C% R" e! n9 g: c
  1736.     for i in 1..loop_times # forLoop
    0 r; P- Y4 n! H" q% `; k
  1737.     steps -= 2( C; n! o4 C! S6 \, d7 G2 \
  1738.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    * l( D6 v+ a0 U
  1739.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    8 \  X  v8 N- y/ F/ ?( l) L* r
  1740.         reversed_chase_path.push(6)
    - i2 q& y$ L1 \7 j- a6 Y
  1741.         point_x = $game_map.round_x(point_x - 1)
    1 q, a) `) a3 C* P0 X
  1742.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    5 Y6 Q' X* {' A+ O
  1743.         reversed_chase_path.push(4)
    : ~$ @) ?/ [; V8 u3 Q+ I, a6 x
  1744.         point_x = $game_map.round_x(point_x + 1)- S4 E1 N! L3 f! I  f
  1745.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps) _* B0 E, d' E  V" t, B: i& _9 d
  1746.         reversed_chase_path.push(8)
    1 @) F& D; i0 S. u) s: k# c
  1747.         point_y = $game_map.round_y(point_y + 1)) N7 r" d- c* t& T
  1748.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps/ n; `2 E: Y$ w- J
  1749.         reversed_chase_path.push(2)
    . B# E  _& b( U" Y5 G) n* H6 c, k& A' O2 ~
  1750.         point_y = $game_map.round_y(point_y - 1)* \. O) {% K1 U% J
  1751.       end
    : s! J/ s& y: z9 t
  1752.     else
    ; Y7 r+ o: L+ U+ C: _5 O
  1753.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    1 }' e% I7 p8 ~2 ?/ I) }
  1754.         reversed_chase_path.push(8)
    ) F0 M3 k! x1 H" _" X
  1755.         point_y = $game_map.round_y(point_y + 1)/ D( h6 g+ @6 w
  1756.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps* i% Y: Y" I, H  K3 l& _" G& x
  1757.         reversed_chase_path.push(2)( J' R- C4 w: n# A8 I
  1758.         point_y = $game_map.round_y(point_y - 1)
    " v+ B6 L5 U0 V2 ^
  1759.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps9 z" ^: S, r5 [- n& h8 X( A5 j
  1760.         reversed_chase_path.push(6)/ N. h1 r% O- }4 B# }3 }: d' f/ _) f
  1761.         point_x = $game_map.round_x(point_x - 1)
    ! f; X4 h6 v/ ~7 ]1 r) g% ^
  1762.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps9 I, l% B2 j2 R2 z6 Y" p) U( t! g$ @
  1763.         reversed_chase_path.push(4)) {& Q  x+ r' d' u6 {5 H
  1764.         point_x = $game_map.round_x(point_x + 1)
    0 {& S5 s$ C$ F7 l; w9 @5 t7 e- R
  1765.       end
    7 |* L5 f! d2 z: M, x& x% U5 m
  1766.     end& ~/ D. E, ^) n- {
  1767.     end #endOfForLoop
    9 b, s# p4 o+ `; l* O
  1768.     @mouse_move_path = reversed_chase_path.reverse + chase_path9 u! N9 _3 d% U6 z! E1 ^7 i5 I& S
  1769.   end#boat4 z8 C/ f, J3 O
  1770.   #--------------------------------------------------------------------------
    # O, V3 A, _4 W0 Q
  1771.   # ● 绘制ship的移动路径 @array[move_directions...]
    ( X! }1 c' t! ]8 W0 C
  1772.   #--------------------------------------------------------------------------1 k4 K/ `( o" b# m( S& v$ t
  1773.   def draw_ship_path, c& H# r2 s; t1 G. `7 W# o* }7 h. O- n
  1774.     # 准备绘制路径表格
    & s4 C( K) X2 Z) g; d) G! P
  1775.     sheet = Table.new($game_map.width, $game_map.height)9 ~' e" O& R2 H+ H
  1776.     reversed_chase_path  = []; chase_path  = []- b- W6 c4 @0 q3 u6 Y
  1777.     reversed_chase_point = []; chase_point = []
    % o& F; T" `  U/ O/ {
  1778.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]  n! ~1 k0 @  S. X6 V  P7 t/ s
  1779.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
    ) X6 ]: v, ]. m7 s5 l
  1780.     reach_point = false0 E1 t) K* }$ H( @6 A* k
  1781.     step = 3
    5 Z* P2 r( r' s% s( I
  1782.     loop do #loop1 开始填充表格. G4 }0 V8 X: @  D
  1783.      draw_path = false2 {; z* U( u% s% M! c6 [
  1784.      check_points = new_start_points0 y% H0 X8 _8 w/ `  G7 n
  1785.      new_start_points = []* N; |" k- ~1 Y# ~0 S; `
  1786.       loop do #loop2 从起点开始正向填充
    3 i4 q+ i7 n' J( h# o
  1787.         point_x = check_points.shift2 a3 m$ k( A+ `1 u" l7 ~
  1788.         break if point_x == nil
    * r8 G7 C" o  c% K
  1789.         point_y = check_points.shift
    5 D+ `- [: l2 x+ s8 t- ]+ b, ~5 F8 Q
  1790.         left_x  = $game_map.round_x(point_x - 1)! C6 _* L1 Q, t# p7 a. d" ~# c  n, [
  1791.         right_x = $game_map.round_x(point_x + 1)
    0 o4 K- A; }/ O& D7 j6 B
  1792.         up_y    = $game_map.round_y(point_y - 1)
    : J# D2 W: H' @+ r  X- P
  1793.         down_y  = $game_map.round_y(point_y + 1)
      ~1 Q; R  R+ o( b6 p6 [$ h
  1794.                     # 判断路径是否连通
    ) [1 ?3 b/ t+ E
  1795.         path_step = step - 1
    ) _. d/ }: L- v% c+ e
  1796.         if sheet[left_x, point_y] == path_step& T( @" j1 p8 Z: E
  1797.           chase_path.push(4)1 X+ p9 y- O3 }$ B" v" B3 x
  1798.           chase_point = [left_x, point_y]
    7 F: h, C7 e+ u6 e
  1799.           reversed_chase_point = [point_x, point_y]
    8 p8 s6 d/ U5 P* ?/ t/ ~7 j' S; G) C
  1800.           reach_point = true; break
    . R, e# o0 k, _  a# ]4 u
  1801.         elsif sheet[right_x, point_y] == path_step
    $ g% E, m+ l% p: O: d; E' s$ W1 @
  1802.             chase_path.push(6)9 g* N2 ]5 V1 _" _/ [! a
  1803.             chase_point = [right_x, point_y]# P8 z0 @1 b& e- W
  1804.             reversed_chase_point = [point_x, point_y]
    4 E7 S1 v% G2 Q, `4 }1 h$ T  Y' E
  1805.             reach_point = true; break
    0 c  i' |1 Q7 e4 m1 v/ w2 F5 A. U
  1806.         elsif sheet[point_x, up_y] == path_step
    + o# u: t. l5 |1 X6 R& R
  1807.             chase_path.push(8)1 t1 M+ C2 Q( G$ e
  1808.             chase_point = [point_x, up_y]
    8 ]% C! n  j# m7 F8 M/ ^3 n
  1809.             reversed_chase_point = [point_x, point_y]
    2 v: P& }4 V5 R4 N% i: J( g9 N5 u9 I
  1810.             reach_point = true; break7 _  P: y) w- z3 ^
  1811.         elsif sheet[point_x, down_y] == path_step. I- Z  w) L; z& U
  1812.             chase_path.push(2)
    . w6 V  @3 N3 n( D  o
  1813.             chase_point = [point_x, down_y]4 q$ O8 a; b9 H& O0 U
  1814.             reversed_chase_point = [point_x, point_y]$ `0 ]! x5 }3 g
  1815.             reach_point = true; break8 ~8 t% x! X2 G4 V& t, Y
  1816.         end
    % f8 C1 S4 A* o8 Q8 E5 h/ q: T& l
  1817.         # 以需要抵达该点的步数填充路径表格 #/ W# z2 P4 J' K( I
  1818.         if sheet[left_x, point_y] == 0                &&. U" e( j" [. x  U. t( o; m
  1819.            $game_map.ship_passable(left_x, point_y)  &&" d* k% I9 D& w2 k. I1 z
  1820.            !collide_with_events(left_x, point_y)     &&
    1 N' G2 v7 ~) h  `3 F4 e+ r
  1821.            !collide_with_vehicles(left_x, point_y)   #judge_end9 G1 V. Q4 z! l
  1822.           sheet[left_x, point_y] = step6 ^( _! r( n8 J. _! g9 W1 q1 q
  1823.           draw_path = true
    ' p6 `/ p0 q% s; a. @
  1824.           new_start_points.push(left_x, point_y)4 a" m1 ?7 y% P7 p0 T7 ^5 K
  1825.         end# k) |4 Z2 p  C0 r4 x+ D* l, a
  1826.         if sheet[right_x, point_y] == 0               &&
    ! o2 S1 i, ^6 Q* Q3 j, p9 _' m+ O
  1827.            $game_map.ship_passable(right_x, point_y) &&5 w0 S/ n& ]8 g9 B9 E3 \
  1828.            !collide_with_events(right_x, point_y)    &&
    $ m8 ?" A1 m# v6 D
  1829.            !collide_with_vehicles(right_x, point_y)  #judge_end
    5 j* G5 l/ v" H' G* h( R
  1830.           sheet[right_x, point_y] = step
    * [* b: l; i& b% y
  1831.           draw_path = true3 N+ f& V; f1 q, ]
  1832.           new_start_points.push(right_x, point_y)  V2 _) z2 ^9 P& ~
  1833.         end, ~9 v# q) \/ Q
  1834.         if sheet[point_x, up_y] == 0                  &&
    / h* V1 I) m% T0 Y0 v4 U5 {- r6 j
  1835.            $game_map.ship_passable(point_x, up_y)    &&7 _* K: s' C7 l* m$ n
  1836.            !collide_with_events(point_x, up_y)       &&  M9 ~* q1 t% E$ K( r
  1837.            !collide_with_vehicles(point_x, up_y)     #judge_end! v! l0 p6 q4 v5 C6 ]* E/ B
  1838.           sheet[point_x, up_y] = step3 e& g0 ?2 t1 D5 k) |( v* c
  1839.           draw_path = true% S3 w/ T  }3 K
  1840.           new_start_points.push(point_x, up_y)
    6 s' k0 k! f8 ?" k& Z1 o
  1841.         end
    2 \/ U( H' _9 T( N: E2 u! p8 a
  1842.         if sheet[point_x, down_y] == 0                &&2 I+ Q0 t! {1 d1 _* W9 l
  1843.            $game_map.ship_passable(point_x, down_y)  &&
    # n2 c4 m0 u4 w) g6 m9 {/ b5 d1 W
  1844.            !collide_with_events(point_x, down_y)     &&! B8 _1 v) w2 R/ e
  1845.            !collide_with_vehicles(point_x, down_y)   #judge_end
    % x8 w  u) u5 R( h! [
  1846.           sheet[point_x, down_y] = step$ W- T6 a! z* L- N
  1847.           draw_path = true2 R/ d" a/ n  F& U. h. y( u0 f6 M: X
  1848.           new_start_points.push(point_x, down_y). \! ]9 ~* Z5 H/ [
  1849.         end
    3 G- X" J! j& F" a. Q
  1850.       end#endOfLoop2" e% @7 \/ \! {, v+ L5 V
  1851.       break if !draw_path  reach_point
    ! m& n: Q+ e0 O! w# D4 ^% ?4 N3 a
  1852.       draw_path = false
    * T: |5 k2 Z! ^5 ~
  1853.       check_points = new_end_points! d. N4 i3 L3 `8 k6 h
  1854.       new_end_points = []0 u9 e0 n7 @2 E5 r1 C) G
  1855.       step += 1
    ' H3 d6 f. }8 s- \: z6 W
  1856.       break if step  KsOfSionBreak_Steps &&* b6 T4 G5 U: |* P; X
  1857.                !Input.press(KsOfSionFind_Path_Key)6 Y7 d( B; ]0 T& {8 R4 z0 o5 C: c
  1858.       loop do #loop3 从终点开始反向填充, W$ t( e: T' Y+ d. Y. O
  1859.         point_x = check_points.shift
    4 e- B: p  A  c: y9 y4 ]- h, P4 q  I
  1860.         break if point_x == nil
    8 a8 f5 P+ N6 _7 m) g1 H
  1861.         point_y = check_points.shift- E! e- z1 B6 x
  1862.         left_x  = $game_map.round_x(point_x - 1)9 f% g; |- v0 x. T( A! f9 N
  1863.         right_x = $game_map.round_x(point_x + 1)
    0 i3 P8 i% i3 F( P4 p: T
  1864.         up_y    = $game_map.round_y(point_y - 1)
    * Q9 r3 Y+ g; U  e/ h
  1865.         down_y  = $game_map.round_y(point_y + 1)* l7 T. K) r2 \9 |5 D* b
  1866.         # 判断路径是否连通
    ) n* |2 S9 f# a  }
  1867.         path_step = step - 10 V- j6 B6 t$ q6 ?
  1868.         if sheet[left_x, point_y] == path_step* f3 x9 h$ z9 V2 i+ m
  1869.           chase_path.push(6)
    - N4 C- P1 o5 B6 @- _
  1870.           chase_point = [point_x, point_y]
    ( J8 D$ g' \2 v: b7 O3 f" i2 H
  1871.           reversed_chase_point = [left_x, point_y]
    & e- s% q: e4 b; m
  1872.           reach_point = true; break
    # W, u4 C/ j/ |
  1873.         elsif sheet[right_x, point_y] == path_step
    ' {% Y2 d7 u, }; c: P  L
  1874.             chase_path.push(4)
    3 T2 c6 L, Y2 k8 ?$ I( c- ~
  1875.             chase_point = [point_x, point_y], k  \& y* Z1 C) H* v
  1876.             reversed_chase_point = [right_x, point_y]; L9 `% }9 A; T8 {2 X, C
  1877.             reach_point = true; break
    8 W7 }8 \& P% |5 g
  1878.         elsif sheet[point_x, up_y] == path_step4 E) X5 B- [# E6 z- F
  1879.             chase_path.push(2)* f, w6 ?9 R/ p
  1880.             chase_point = [point_x, point_y]
    # }* }6 W5 W8 b; v+ E) n8 \
  1881.             reversed_chase_point = [point_x, up_y]2 j+ e* u+ ~$ ~
  1882.             reach_point = true; break
    1 O% H% W/ i" f. k4 `6 f" H
  1883.         elsif sheet[point_x, down_y] == path_step
    % p9 p" x. K) ^  C& Y6 s
  1884.             chase_path.push(8)9 h% f4 [. n5 H: |" O% U& ^
  1885.             chase_point = [point_x, point_y]
    8 p) C8 q( |3 U7 K2 d$ U
  1886.             reversed_chase_point = [point_x, down_y]4 \- }( E1 ?  p7 `! n
  1887.             reach_point = true; break
    , f, d& V" b/ Q7 m! y
  1888.         end
    7 |; t2 g  C$ c5 i. z/ e; g
  1889.         # 以需要抵达该点的步数填充路径表格 #9 S# r  I9 G' k6 X1 m+ B
  1890.         if sheet[left_x, point_y] == 0                &&
    " H1 T  Z8 j6 g
  1891.            $game_map.ship_passable(left_x, point_y)  &&
    0 B5 I1 T$ K" s  |3 O% J7 U& t
  1892.            !collide_with_events(left_x, point_y)     &&
    $ {* e5 h" x3 s6 e9 Y
  1893.            !collide_with_vehicles(left_x, point_y)   #judge_end+ G1 x; `4 c4 Q7 I* R, |& H+ X
  1894.           sheet[left_x, point_y] = step+ _' w: Q! ]( d) y* s9 T0 d3 V
  1895.           draw_path = true1 G. ?7 \* X7 y: ?
  1896.           new_end_points.push(left_x, point_y)
    8 a! E, R' u& ?1 {! Z
  1897.         end
    $ o3 y' Y. [' M
  1898.         if sheet[right_x, point_y] == 0               &&
    7 c5 x7 u. r+ Z
  1899.            $game_map.ship_passable(right_x, point_y) &&
    0 q' v1 d2 A! m( n; ^7 n. @
  1900.            !collide_with_events(right_x, point_y)    &&
    0 n' {7 P# k" m' P  f
  1901.            !collide_with_vehicles(right_x, point_y)  #judge_end  A3 ?( @% J8 Q1 O# c
  1902.           sheet[right_x, point_y] = step$ L! ~9 m) r1 Z/ b) x5 s
  1903.           draw_path = true5 _# ^# L, `) p
  1904.           new_end_points.push(right_x, point_y)
    ) z# J- V" J1 k$ X2 u) z$ e
  1905.         end/ D* ?  z2 y7 p; x
  1906.         if sheet[point_x, up_y] == 0                  &&; }4 B) `- z# h+ o  \8 o
  1907.            $game_map.ship_passable(point_x, up_y)    &&
    ; E3 g& B) g5 a$ U* ?0 r, H9 m! {
  1908.            !collide_with_events(point_x, up_y)       &&
    7 ]% U  I9 i* }& w  Z! ]
  1909.            !collide_with_vehicles(point_x, up_y)     #judge_end/ n9 u$ K' S# T& U/ e4 ]: l
  1910.           sheet[point_x, up_y] = step, {* S, m5 M  ^
  1911.           draw_path = true" X4 D0 W+ E5 s+ k; Y- Q
  1912.           new_end_points.push(point_x, up_y)
    . F. \( Z3 m1 M  V
  1913.         end
    6 l/ g6 o3 {6 p1 P" K
  1914.         if sheet[point_x, down_y] == 0                &&
    ; o; E2 P% h3 M7 U( l7 z, x: e+ y
  1915.            $game_map.ship_passable(point_x, down_y)  &&
    ' w# b# \* |5 j1 H5 d- H  ?
  1916.            !collide_with_events(point_x, down_y)     &&) n$ Z! N# M" [7 y0 v4 `: y6 h
  1917.            !collide_with_vehicles(point_x, down_y)   #judge_end
    3 Q6 I9 Z3 b& o* j- m- G2 c- V- R0 v7 q
  1918.           sheet[point_x, down_y] = step
    / {9 g  Y. ?  c- X
  1919.           draw_path = true
    $ |3 `- G! v" @. p! e
  1920.           new_end_points.push(point_x, down_y)
    1 \( T6 I1 d0 `7 U% X
  1921.         end
    4 |3 I' Z& u. H6 n* R% r
  1922.       end#endOfLoop3* b$ A% v4 k" Z) S
  1923.       break if !draw_path  reach_point9 D$ @% Z5 w6 _
  1924.       step += 1
    - U/ B" w$ o* Q  Q' }) n
  1925.     end #endOfLoop1 路径表格填充完毕2 T! G: m9 |4 N5 ~5 v& v
  1926.     $mouse_move_sign.transparent = false
    2 y2 ^/ g8 r6 T; L
  1927.     # 判断指定地点能否抵达
      u' i" R3 V  ^8 N2 N( b
  1928.     if reach_point3 z1 ^; U# l( u# k  E
  1929.       $mouse_move_sign.direction = 2
    5 p/ T, p- K" Z0 _0 t0 K
  1930.     else* t+ H3 @2 O6 K1 s  f' @4 ~% K* f
  1931.       not_reach_point
    0 z' K* B7 Z+ o2 I9 M/ F
  1932.       return: m" y* h5 @# o* k- S7 X4 u' A
  1933.     end
      W- G/ H4 w% r
  1934.     # 根据路径表格绘制最短移动路径(正向); p% e+ f+ [8 o4 I. ?* z
  1935.     steps = step  2  28 ~# i! d( d/ V
  1936.     loop_times = step  2
    : F5 k: U9 C& A* d$ ?/ I  f
  1937.     point_x, point_y = chase_point[0], chase_point[1]
    9 _0 a, G$ Q  c  a
  1938.     for i in 2..loop_times # forLoop) u+ P! |) V1 a6 D/ v' y
  1939.     steps -= 2! g; t" h2 Y- u: m6 a4 G% L7 N
  1940.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs) l7 r( \, t# e, `
  1941.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps, Y8 p* {0 p4 q
  1942.         chase_path.push(2)
    / C* y& H& y+ o& ^& \! B  \1 @
  1943.         point_y = $game_map.round_y(point_y + 1). _# x7 |% g/ l: |# G6 b1 G
  1944.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps) ?' W6 F' ]- e4 K
  1945.         chase_path.push(8)2 r+ k! a2 Z' x; |% Q7 s. J
  1946.         point_y = $game_map.round_y(point_y - 1)  |( G9 L' R# `5 H) j
  1947.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps% q% T9 p" Z, N* b
  1948.         chase_path.push(4)) C  @" h4 X4 K) I. z
  1949.         point_x = $game_map.round_x(point_x - 1)
    - r! x3 s& n4 H
  1950.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    . r, U+ g9 k! |7 T
  1951.         chase_path.push(6)) ~# g" Z' d7 c
  1952.         point_x = $game_map.round_x(point_x + 1)& Q( Z0 R0 J7 u% t8 I
  1953.       end
      h2 K! ~+ ?1 O" A7 F! w
  1954.     else& W9 u- b& Y7 E4 F
  1955.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps* r7 S& b- k' ~3 p/ L- w
  1956.         chase_path.push(4)
    7 U, r6 g, I, Z
  1957.         point_x = $game_map.round_x(point_x - 1)! h5 j/ K, D$ q3 N9 H7 H
  1958.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    : i0 u# V  i7 ^( t2 x6 U
  1959.         chase_path.push(6)
    1 R( ?' _* {" u: Q
  1960.         point_x = $game_map.round_x(point_x + 1)
    7 E+ S# h3 `9 i0 `# A
  1961.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    8 F" {/ Q" X& w8 {: h5 C8 ?
  1962.         chase_path.push(2)  C% Y, U8 c/ N7 ?
  1963.         point_y = $game_map.round_y(point_y + 1)0 D$ J) y! b" ~, c
  1964.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps- }: o/ P4 x! q1 S) Z, V' l
  1965.         chase_path.push(8)
    - i, u! \/ j0 o5 m5 T' Y8 ?) h
  1966.         point_y = $game_map.round_y(point_y - 1)
    / G; C4 ^* J0 I1 k9 N; A
  1967.       end& g0 T  I$ h4 b/ ?7 q
  1968.     end
    ( b1 n7 n9 g7 k" N; U7 [
  1969.     end #endOfForLoop
    5 l8 S1 k, A' E1 \) e/ y4 ?% y) q) o
  1970.     # 如果指定点无法抵达或者登陆
    2 g1 R% X8 X) s5 u
  1971.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)/ X8 U8 D) t3 G- K
  1972.     # 根据路径表格绘制最短移动路径(反向)
    9 W  S; E: N, ^# [9 ]$ r  i
  1973.     steps = step  2  2 + 1
    0 e) s* s2 }% g7 V' v. `1 }# `) N
  1974.     loop_times = step  2
    9 C2 }% [" B1 v% `# L9 A1 `8 x
  1975.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
    ! f) X  ~  K7 @- y: y
  1976.     for i in 1..loop_times # forLoop1 E" \2 }7 @2 W( l* W( r) L, }! l  H6 b
  1977.     steps -= 2
    3 _5 p- O* [# [& {
  1978.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs; _$ ^0 U' i) ^. b2 E
  1979.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps7 L' W2 f# s. z+ u
  1980.         reversed_chase_path.push(6). t% s: [9 z; P, v* s0 ]0 R
  1981.         point_x = $game_map.round_x(point_x - 1)8 L  O0 L  j$ I- E
  1982.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps/ ~) F" |6 ^- |+ b: D4 ?* z: b  T( [
  1983.         reversed_chase_path.push(4)
    0 R8 D' _; g3 y! S7 ]1 v0 o& v
  1984.         point_x = $game_map.round_x(point_x + 1)' h5 t! m5 X; n8 j' o4 I0 k( a$ Z
  1985.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps) c5 V  {# Y, ~: Y8 o
  1986.         reversed_chase_path.push(8)
    ; I! F7 @$ @( @# G7 ]3 a; h+ b, S
  1987.         point_y = $game_map.round_y(point_y + 1)$ m6 f- Q) k- Y$ a. H. r7 R( G7 \
  1988.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
      u. [' j9 d4 G# S- s
  1989.         reversed_chase_path.push(2)
    1 k- ~8 [' Y% j3 F  ^
  1990.         point_y = $game_map.round_y(point_y - 1)
    & X: J+ e' ~5 x2 Z
  1991.       end  N# o) K* c8 [; d& u
  1992.     else4 R) V( @3 r$ V& c
  1993.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps4 k) E4 b. H0 r( C7 Q( ]% `
  1994.         reversed_chase_path.push(8)# u% @- _) N& q7 J" m0 O
  1995.         point_y = $game_map.round_y(point_y + 1)! y9 {$ F: n1 [& P  {9 S
  1996.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps; y! i6 k7 [5 p5 i3 k8 }2 h
  1997.         reversed_chase_path.push(2)  t$ w3 A& m) }4 `7 Q
  1998.         point_y = $game_map.round_y(point_y - 1)% K& ^7 `0 F& P$ J% V, b, B  y
  1999.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps: w0 X& I! H9 a( D  o9 b, T+ y
  2000.         reversed_chase_path.push(6)2 h1 f2 X3 b, ]$ t$ x" P
  2001.         point_x = $game_map.round_x(point_x - 1)
    . m. W" {. k& S' l0 B8 x
  2002.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    - _# {5 l8 ^4 ^  b/ ~8 {
  2003.         reversed_chase_path.push(4)
    0 f$ c) G9 Q0 ]2 B
  2004.         point_x = $game_map.round_x(point_x + 1)
    , @9 a% a- f: b+ x7 V6 y
  2005.       end
      D! S' H9 {  I8 {' F" s4 k- d
  2006.     end4 Y0 @/ T. ^4 o( X( |9 D
  2007.     end #endOfForLoop
    7 y4 ^) T6 g$ L
  2008.     @mouse_move_path = reversed_chase_path.reverse + chase_path
    6 o. U: }3 L$ M1 w  ?6 b
  2009.   end#ship
    + `: ~* z6 w7 i3 F. W# X; x) s# Q
  2010.   #--------------------------------------------------------------------------% H& l. j; z4 x% B* B  N
  2011.   # ● 绘制airship的移动路径 @array[move_directions...]$ V% d! q( i& i; J, v% x/ ^
  2012.   #--------------------------------------------------------------------------
    ( s" x; c$ z) R& F  N/ H! @4 T
  2013.   def draw_air_path
    8 r) k6 i6 M& c# U# k
  2014.     $mouse_move_sign.transparent = false- y, i! l$ G  u1 M5 n, J, {/ ]
  2015.     # 准备绘制路径表格, I5 \' f1 ^1 H: H7 t2 t; i& v1 F
  2016.     sheet = Table.new($game_map.width, $game_map.height)
    1 _$ l# A: S4 {
  2017.     new_check_point = [x, y]; sheet[x, y] = 1! W: Z$ _* ~5 N, F; x; P" O( K  h$ l
  2018.     reach_point = false;      step = 2/ [' |1 Y: R* }  b2 l' M9 @, |
  2019.     loop do #loop13 O% G5 s& n+ }& R% Q0 G
  2020.      check_point = new_check_point  O5 W7 E8 h( ^. M3 k+ w# O/ [- P
  2021.      new_check_point = []+ r+ a$ z7 x) t: W. b, j& w
  2022.       loop do #loop2
    8 f0 f7 l- r3 v. l' l
  2023.         point_x = check_point.shift
    % g0 t! f& j4 g8 o7 W  }
  2024.         break if point_x == nil$ R' W" M; n* D* z
  2025.         point_y = check_point.shift
    : K4 |  `/ g- P5 Q. A* m
  2026.         if point_x == @moveto_x && point_y == @moveto_y5 P. H) G) r2 u9 @; l
  2027.           reach_point = true; break
      n, M- S1 a4 O! q! k7 t
  2028.         end
    ! B# ~8 Z( _( x/ E( g
  2029.         left_x  = $game_map.round_x(point_x - 1)6 y1 g3 D2 c$ m; r" M
  2030.         right_x = $game_map.round_x(point_x + 1)3 c1 t4 k3 l! `* |7 f6 `# \
  2031.         up_y    = $game_map.round_y(point_y - 1)* B8 h# r1 E, ^0 \) e: R% B
  2032.         down_y  = $game_map.round_y(point_y + 1)
    ; V) D8 e1 V+ M! Q' `& P
  2033.         # 以需要抵达该点的步数填充路径表格 #
    9 V! o7 L0 x/ T6 C2 E! k  h  V# h. p9 V
  2034.         if sheet[left_x, point_y] == 0+ [, F$ v" a2 q& i6 \
  2035.           sheet[left_x, point_y] = step
    , G  u& }) R/ ~9 G0 ]
  2036.           new_check_point.push(left_x, point_y)
    5 B3 @* o" x6 T+ c! q7 C
  2037.         end
    + L$ l. j* ^: C! B
  2038.         if sheet[right_x, point_y] == 0" D/ t# C& q0 C, H( i
  2039.           sheet[right_x, point_y] = step
    5 \$ [  J, u9 h8 N5 I  R
  2040.           new_check_point.push(right_x, point_y)3 q& j6 w+ D; q. g' N) o
  2041.         end
    0 p$ D& D( e& R4 J. K  U+ V
  2042.         if sheet[point_x, up_y] == 0: c, a8 C0 G6 I3 L
  2043.           sheet[point_x, up_y] = step9 u9 t; Q, v; u, e. F  `
  2044.           new_check_point.push(point_x, up_y)' D. k. C0 n* a& M8 ^
  2045.         end
    : J, n' r, ?+ f. [. g& t1 O0 b
  2046.         if sheet[point_x, down_y] == 0
    ) p: b' @$ I/ e' D
  2047.           sheet[point_x, down_y] = step
    + N" d1 K- s4 @6 e, |
  2048.           new_check_point.push(point_x, down_y)# P! N# ?  w  L8 M; F
  2049.         end8 `; c9 m$ _8 a2 c+ G
  2050.       end#endOfLoop2, \+ i, E" f" J* H/ a' V3 p: X
  2051.       break if reach_point
    5 H, R7 X: l4 S/ r- Q
  2052.       step += 1. E/ W1 _1 J0 m6 L0 K8 k
  2053.     end #endOfLoop1
    . n5 c! B  U+ B  h- M& J
  2054.     # 根据路径表格绘制最短移动路径 #: X8 f: r, h/ a' u, Y
  2055.     reversed_chase_path = []; step -= 1
    * e# ], p! h# S8 ^0 n% A$ k
  2056.     point_x, point_y = @moveto_x, @moveto_y& f& G+ E! j4 ]+ ^. i% S" p
  2057.     for i in 2..step
    4 G# {) {  M8 y, \
  2058.     step -= 1
    ) ]" g5 p! I! v0 A4 B
  2059.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    ) h; R$ X5 [1 K" T
  2060.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
    + q; s6 q9 W- X; Q: D/ N0 T6 Y
  2061.         reversed_chase_path.push(6)6 H5 \  i. B& d
  2062.         point_x = $game_map.round_x(point_x - 1)- Z, ?1 v6 z- e7 U, E
  2063.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step4 [- n+ h8 J. Q" C6 t7 d# e
  2064.         reversed_chase_path.push(4)
    ; H- C" K- ?! m6 M$ Q
  2065.         point_x = $game_map.round_x(point_x + 1)7 f. e5 K0 J' I/ ~! W4 f0 R
  2066.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step; }  J$ |! s  n& B3 m9 K/ y
  2067.         reversed_chase_path.push(8)
    7 X- T$ ^8 D$ Z: q- W
  2068.         point_y = $game_map.round_y(point_y + 1)' k$ N* Z$ M3 O, Q" x; ?
  2069.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step/ `7 O# A% L, ?
  2070.         reversed_chase_path.push(2)( E# J: S2 w( M
  2071.         point_y = $game_map.round_y(point_y - 1)
    1 c. @1 L; P3 Y) ?
  2072.       end
    2 T# {5 o, w$ ?, _1 S6 _1 }' ?
  2073.     else5 H  T$ ?3 |1 ?0 ~7 ~# w0 r# L8 @
  2074.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step1 v, [( a) b$ m" E# M& _' Z
  2075.         reversed_chase_path.push(8)
    6 \3 Y* f& \5 x/ O: O* i, r
  2076.         point_y = $game_map.round_y(point_y + 1)! J+ l+ Y- t4 H$ f; \
  2077.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
    ! R* ?4 i0 F7 H  x& _4 Q) c0 |
  2078.         reversed_chase_path.push(2)
    ( g, G4 M+ k; K# \9 w/ _
  2079.         point_y = $game_map.round_y(point_y - 1)" y, p7 L. R* q* M# X$ Z* v
  2080.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step
    . H' u9 r* M' A
  2081.         reversed_chase_path.push(6)
    , ]! v0 M$ y- q9 N1 C. s
  2082.         point_x = $game_map.round_x(point_x - 1)
    - o( \( n. I  z
  2083.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
    ; O4 t' c; v2 R* V" C% B
  2084.         reversed_chase_path.push(4)
    , ?& L2 L% Q& m
  2085.         point_x = $game_map.round_x(point_x + 1)+ F# W7 Y0 s+ C, z; x/ o0 E( [* u
  2086.       end
    - z1 y2 Z4 O7 p- Q
  2087.     end9 Q2 n4 a" _5 Q( A1 A8 R+ e% r
  2088.     end #endOfForLoop
    1 c# v6 z! P* _- }9 E* Y
  2089.     @mouse_move_path = reversed_chase_path.reverse
    / D6 j9 z, z5 D% t
  2090.   end#airship% o8 a2 s4 [. T- m4 |8 [7 H9 t
  2091.   #--------------------------------------------------------------------------- T  [/ X: F. ^% U
  2092.   # ● 目标点无法抵达时的处理,用于各路径绘制方法内部
    5 {/ t. J: v" D  t& Z2 N
  2093.   #--------------------------------------------------------------------------
    $ Y+ |' M! r- h: U5 r
  2094.   def not_reach_point
    1 s- L% U- a8 ~5 T+ ?( c/ l& o
  2095.     $mouse_move_sign.direction = 4
    7 Z/ ~1 [; a& \; X9 U- f9 C1 B
  2096.     dx = 0; dy = 0; dir = 0
    ( r8 i5 L! [9 @' W- ^  R9 e+ H
  2097.     if @moveto_x - x  0* |' g5 q: x  F0 J; ^# L1 F
  2098.       if @moveto_x - x  $game_map.width - @moveto_x + x &&' N& G5 n) Y9 |; ^) |$ `1 J
  2099.           $game_map.loop_vertical
    & h; A" K+ P  U0 v5 R5 _' _
  2100.         dx = $game_map.width - @moveto_x + x; dir = 4
    0 T: C2 x$ x8 G& Z
  2101.       else
    0 D3 _" P4 }- [: }% ]
  2102.         dx = @moveto_x - x; dir = 6
    % Z! W4 h+ @; w1 T
  2103.       end2 W: j! n% W! U  C
  2104.     else3 i( \( q' [& J- P) z
  2105.       if x - @moveto_x  $game_map.width - x + @moveto_x &&
    4 R4 W3 Q2 e4 `, z
  2106.           $game_map.loop_vertical
    % l$ ?. s* f' i6 ]8 v$ N9 A* }+ U
  2107.         dx = $game_map.width - x + @moveto_x; dir = 6* N, d( F5 `8 i7 f+ p
  2108.       else/ b. h! v5 ^8 o5 F# }9 ]
  2109.         dx = x - @moveto_x; dir = 49 p' C2 K. K, B
  2110.       end5 e2 `  G) S' c: r
  2111.     end8 }& e; A! Q1 d) r, K: y( F4 V: D
  2112.     if @moveto_y - y  00 s1 t' F% u2 k# r: R% A
  2113.       if @moveto_y - y  $game_map.height - @moveto_y + y &&: A. }% f: Y0 x" s1 O
  2114.           $game_map.loop_horizontal
    . ~3 O% A* a/ P1 }; r6 O) Q
  2115.         dy = $game_map.height - @moveto_y + y
    + E( X. c6 v6 R) e1 [2 b
  2116.         dir = 8 if dy  dx
    4 |4 v& L9 v' @: n; R( |- I. L
  2117.       else  a: g7 Y8 j; C4 B  |4 _" d( v$ u/ H
  2118.         dy = @moveto_y - y( e$ L- s( I) h- M# y& H6 Q
  2119.         dir = 2 if dy  dx
    ) n8 H* X$ L  ?* J/ A
  2120.       end
    5 ]! M' z: I# g" j. F- `% U3 I
  2121.     else
    $ @3 C2 `  q; S( Y
  2122.       if y - @moveto_y  $game_map.height - y + @moveto_y &&% ?! w3 }2 m% E. _) M3 }& \% V
  2123.           $game_map.loop_horizontal
    . ]0 y! E: R; W( \% z9 i
  2124.         dy = $game_map.height - y + @moveto_y
    : X+ w) K9 p" s' |
  2125.         dir = 2 if dy  dx
    . H5 ~: H4 w+ G5 j* ?+ z3 K
  2126.       else
    5 g% s$ [0 c4 Q
  2127.         dy = y - @moveto_y
    , b! y- U5 f6 a
  2128.         dir = 8 if dy  dx
    . p/ ^. V, s" z* b
  2129.       end
    2 D# |" ^- T' R; |, F5 x6 P/ F
  2130.     end
    ; ^+ b* w; r* d- Z9 i% ?: s6 x
  2131.     @mouse_move_path = [dir, 0] # 0方向用于防止移动过程中触发事件
    % ]; s& ?8 h/ b" x* [; J1 Q
  2132.   end( J6 S$ N/ G3 y1 f$ R! p
  2133.   #--------------------------------------------------------------------------5 ^6 |& t7 a; C6 Z$ _/ c3 r
  2134.   # ● 判断目标点是否能抵达、登陆,用于船只路径绘制
    % S' }* Y; k; u$ |2 n0 e: ?$ V
  2135.   #--------------------------------------------------------------------------" z( d3 u: M, i$ a5 X0 B
  2136.   def landable(x, y, path)
    ! D6 M- v1 }( F; H* o8 q2 ~4 O' Z' l
  2137.     case @vehicle_type
    * Y, t" H. O/ j1 x, V' C3 I3 D( P. C: ^
  2138.       when ship; return $game_map.ship_passable(x, y)
    3 s# r, [+ J, G+ k" w
  2139.         $game_map.passable(x, y, 10 - path[-1])
    ( o  G% z& U+ G2 F8 n- j1 ^+ R
  2140.       when boat; return $game_map.boat_passable(x, y)
    " D0 r! F0 Q" R% s. }, N
  2141.         $game_map.passable(x, y, 10 - path[-1]); \: `+ s& G# y8 _4 o$ v/ K
  2142.     end
      q0 ]! ]/ x# \6 s
  2143.   end
      @; b+ E# ]% f. e
  2144. end
    2 o+ H' G0 C  V/ b, ~

  2145. 6 ]. M+ _$ j+ q  q. Q" R4 i: d
  2146. #==============================================================================$ o; }) X4 Z6 s! x
  2147. # ■ Game_Map) b; Y. @' S( |5 E! A! K9 h
  2148. #------------------------------------------------------------------------------: m: o  `2 G. \1 F$ \
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    : L9 Y  U; e! L  E4 D, o
  2150. #   本类的实例请参考 $game_map 。
    3 ?$ D6 h. N) {2 t
  2151. #==============================================================================" D2 K8 }, l+ Y. y
  2152. class Game_Map
    & j, t# I6 j* z5 M/ q0 q
  2153.   #--------------------------------------------------------------------------& N8 P* \3 e& U* [1 i
  2154.   # ● 定义实例变量# T: d0 w8 {  `3 V% v1 ?
  2155.   #--------------------------------------------------------------------------
    ! o. c/ g+ w5 O8 C* q+ B
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
      q, A1 L8 L; x( `
  2157.   attr_reader mouse_map_y # 同上
    4 N8 `3 u9 ^5 ]5 L$ X$ I
  2158.   #--------------------------------------------------------------------------
      ^' f0 n: w3 M1 q6 F9 i
  2159.   # ● 初始化对象4 r9 h2 g# A" q- O+ c2 H" R
  2160.   #--------------------------------------------------------------------------7 V& G6 \/ F( D. S, S4 y! G
  2161.   alias sion_mouse_initialize initialize
    # V, g8 @8 _1 B; C4 ^) `
  2162.   def initialize
    ( _. E# X0 t$ b
  2163.     sion_mouse_initialize
    , z) @: L$ Z+ [9 d& }
  2164.     creat_move_sign  ###
    5 b+ z5 t* h% B; b
  2165.     set_constants4 r1 A6 E) B; S) g3 R  \/ q* e
  2166.   end
    1 Q0 P) q/ J; m7 W9 u
  2167.   #--------------------------------------------------------------------------" Q5 c  t9 z2 @  Z" R6 r% T
  2168.   # ● 更新画面5 }/ a1 K0 g+ @# B
  2169.   #     main  事件解释器更新的标志- n3 p. B) E$ R2 r3 ~5 U( K) d
  2170.   #--------------------------------------------------------------------------
    / A, m+ k4 _/ c1 a0 h
  2171.   alias sion_mouse_update update
    7 d/ e6 X& I& H; H1 d# u3 x
  2172.   def update(main = false)
    " O4 m  X5 g: @
  2173.     sion_mouse_update(main)/ b/ r5 o+ o$ }9 K  Z2 G
  2174.     update_move_sign% j2 t: q* Y) J' d, W( ?/ H
  2175.   end
    " M1 L9 [3 T8 x; N6 `' ~
  2176.   #--------------------------------------------------------------------------
    ; Y3 V; w7 ]5 p& x3 j
  2177.   # ● 创建显示路径点的事件
    : c( l7 N# m; Y! \* A( j8 f8 D
  2178.   #--------------------------------------------------------------------------
    3 T% M& L8 j- X0 s8 u0 }, @
  2179.   def creat_move_sign
    " _: q: ?0 y* Q' f: y
  2180.     $mouse_move_sign = Move_Sign.new2 |" D& y* u8 }* K8 N9 j! P0 j
  2181.   end3 z3 r' x- W& ^+ F0 _
  2182.   #--------------------------------------------------------------------------" [  g; H. F( Q+ i) h) B, j
  2183.   # ● 更新显示路径点的事件
    + N: M1 \/ Z% A+ T
  2184.   #--------------------------------------------------------------------------1 D- q" O8 _) X; U. _
  2185.   def set_constants3 A" Z7 |: |$ j' u; m" g* J
  2186.     @mouse_pos_setted = true
    5 ^7 @9 d( K9 g* y, O5 ^$ k3 s1 v/ [# |! n
  2187.     @set_pos_prepared = false+ s. f% N$ p1 \
  2188.     @mouse_old_x = 0: k9 K. i, H& s: I: B
  2189.     @mouse_old_y = 0, }6 G" ~; K1 {1 E  K1 e; @
  2190.   end
    ! d2 f( b5 `* v5 k6 P
  2191.   #--------------------------------------------------------------------------  k+ W) A9 e! e- E
  2192.   # ● 更新显示路径点的事件
    % Q# D' y: W5 m
  2193.   #--------------------------------------------------------------------------
    + g& R9 x" g  d3 `
  2194.   def update_move_sign0 q4 N8 c/ m6 D* w# [
  2195.     $mouse_move_sign.update' A5 X5 }+ v$ S1 Z- v  ]# O/ s" ^+ M( x
  2196.   end) u! i  N4 _7 m+ g' R
  2197.   #--------------------------------------------------------------------------+ c& D. l/ d6 \) r
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    / b9 V8 H+ N0 A$ M) _7 k
  2199.   #--------------------------------------------------------------------------# l! ]* _6 h8 n/ J; z' N2 _" ~3 A
  2200.   def get_mouse_map_xy0 D) }1 q3 z6 Y
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    6 S+ R* O  p& i. d( H- W
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    " T9 D1 |& Q: q0 B+ e4 M% L& t4 l
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)) x: m4 S" p. d% E& W% n
  2204.   end- x" }. t! f5 h1 _1 Z5 Q
  2205.   #--------------------------------------------------------------------------
    ' o; I1 G7 h) H/ x2 R4 a
  2206.   # ● 返回地图画面时重设鼠标坐标
    4 A  U" d8 p- }+ Y7 I
  2207.   #--------------------------------------------------------------------------, @" E! f0 u- i! G
  2208.   def reset_mouse_pos
    , l- T: ?+ V$ f, @! w0 H
  2209.     return if @mouse_pos_setted( Z* s+ b, m  F& a6 H- Z
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)' B  d& t9 ^+ M" e+ u& U6 n2 m! c
  2211.     @mouse_pos_setted = true
    3 {9 B9 z& _0 L2 m' L
  2212.     @set_pos_prepared = false% Q/ Z& I5 R% K! Y! `8 Z$ l
  2213.   end* Q8 p% B8 M1 V7 o$ b/ k, u
  2214.   #--------------------------------------------------------------------------
    & K2 ~+ \3 }4 |& p1 A2 ]+ x' C! S' o/ h
  2215.   # ● 重设鼠标的坐标2 e0 k( F$ ]/ R: {
  2216.   #--------------------------------------------------------------------------
    ) U/ a4 \; \1 r# x8 U
  2217.   def prepare_reset_mouse_pos- V6 v! |; J1 v3 P# r9 m3 T! h
  2218.     return if @set_pos_prepared3 M; }! [/ D& n6 `
  2219.     @mouse_pos_setted = false
    ) o. r) S& d8 K
  2220.     @mouse_old_x = Mouse.mouse_x5 a( z1 C! X3 |9 `! Z
  2221.     @mouse_old_y = Mouse.mouse_y
    5 A0 r. S* x3 C# _9 _
  2222.     @set_pos_prepared = true
    - M" @4 C. o8 }0 t" Q8 _
  2223.   end" m# p9 V% ]9 Z6 i
  2224. end4 }( r* R! @  p1 ?4 A: d

  2225.   p! [) v2 X7 f9 f
  2226. #==============================================================================
    0 z% C/ x7 x; K- X
  2227. # ■ Spriteset_Map6 h# X4 e1 S; }" `( g; E# [! ~
  2228. #------------------------------------------------------------------------------, _5 \( E$ R& }9 [. Z4 q
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    + v2 ~9 V! C5 ]3 @" L2 b* k. H
  2230. #==============================================================================, m2 i/ c& H+ o3 q+ v6 m6 B, r) w
  2231. class Spriteset_Map
    9 T1 _8 H/ U: Y
  2232.   #--------------------------------------------------------------------------
    ' U! b* E6 ^+ h) }9 e8 V
  2233.   # ● 生成路径点精灵
    : _1 y) v( m3 R/ K! r1 o
  2234.   #--------------------------------------------------------------------------( @" ?2 l4 ^! j1 ~5 {- s* o
  2235.   alias sion_mouse_create_characters create_characters5 N- o7 L6 @, R9 {
  2236.   def create_characters
    - \7 R4 q3 B) R* p
  2237.     sion_mouse_create_characters3 r- R9 c7 B5 P! `/ B/ x0 \3 x
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    , z! D  A7 b+ p3 x7 T8 M1 ]6 x& K
  2239.   end
    ! R; ?4 \/ F) {- C$ W
  2240. end5 u# _0 d" K3 K. ]2 k. c* S
  2241. 4 E1 i3 P% e) ]$ |  m
  2242. #==============================================================================+ `1 w% ^" ~: Y; }* L* z, n2 }' P
  2243. # ■ Scene_Map
    9 G+ z3 a* j$ P* D: M* {) o
  2244. #------------------------------------------------------------------------------
    ( Z' t: K: `8 \( R! t/ c
  2245. #  地图画面
    5 \2 W9 D6 r5 ]+ ^, Y7 c( o  l
  2246. #==============================================================================
    : l2 e6 ^: h$ X; Y8 |% }
  2247. class Scene_Map  Scene_Base
    6 ~2 E1 Q$ A0 d* B* d
  2248.   #--------------------------------------------------------------------------3 ^+ C7 E1 F6 |/ q
  2249.   # ● 画面更新
    4 h) L, G1 i8 N7 A
  2250.   #--------------------------------------------------------------------------6 G6 `/ f0 o' F8 z1 u! u
  2251.   alias sion_mouse_update_scene update_scene
    9 N7 v" L5 w" t9 G9 G
  2252.   def update_scene
    ) m, B( d% `; L
  2253.     sion_mouse_update_scene( |. f6 X( {  D5 a
  2254.     update_mouse_action unless scene_changing
    3 C! K) r5 B, f+ U' x8 ?4 o
  2255.   end
    ; I7 Y  w# g9 v5 x
  2256.   #--------------------------------------------------------------------------
    # G. d3 X/ x! t4 e$ i# q( T
  2257.   # ● 场所移动前的处理
    9 \/ O$ D7 T7 l# y% [4 x$ K
  2258.   #--------------------------------------------------------------------------
    ; l* W6 g1 Z6 V, t5 C$ y
  2259.   alias sion_mouse_pre_transfer pre_transfer1 a6 v1 |0 B3 M9 z* T
  2260.   def pre_transfer
    6 s$ ^, l' W) a: K0 G
  2261.     $game_player.reset_move_path$ D& X3 `  ~/ z3 A; {4 y2 y
  2262.     sion_mouse_pre_transfer3 G9 z1 V! f4 G, X/ g
  2263.   end
    + Z1 n* ~6 f, h5 Q
  2264.   #--------------------------------------------------------------------------
    5 a# T+ l9 e0 A5 r! {% }2 G8 v
  2265.   # ● 监听鼠标左键的按下7 z7 U7 J! @! k! n5 U$ L5 N
  2266.   #--------------------------------------------------------------------------
    8 r7 P' _& r1 x# G
  2267.   def update_mouse_action
    3 h4 G- v6 h6 ~# @" h$ ^( D
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    9 B1 l( Q" T" r9 N9 c. q
  2269.   end
    ; R3 Y9 S  O, E3 f4 B, ^) j
  2270. end: _' S9 O4 }: b4 ]3 k8 T% m8 s
  2271. 4 v- \& \/ M7 Y- {9 T
  2272. #==============================================================================% R, Y/ b  b7 W! \) N% B( p: \
  2273. # ■ Scene_File, ~! a! g7 e0 S. d) n
  2274. #------------------------------------------------------------------------------
    , e( Y) c$ f- g' N% e/ ~# b
  2275. #  存档画面和读档画面共同的父类* w! _! M) @+ E& z  b' h: B! ]
  2276. #==============================================================================: _6 D& k% \0 V. b' B% H* F
  2277. class Scene_File  Scene_MenuBase
    " L8 o9 \5 z/ ^; |
  2278.   #--------------------------------------------------------------------------
    ) a0 N5 c& ?' O. |! x% v! D
  2279.   # ● 开始处理
    ' ?' T4 i! ~5 f' S5 R/ D. A6 B
  2280.   #--------------------------------------------------------------------------2 {) L# |; @$ s) u' ~# d" Y
  2281.   alias sion_mouse_start start. Q: [+ ?4 u9 @2 `2 _+ r
  2282.   def start8 K+ G! C% w9 \  w; v  T* Z
  2283.     sion_mouse_start
    # Y" k4 ^; @' z' Z) |, b' a) J
  2284.     @move_state = 0( i! S( s2 x, |( ?, Y, y) h
  2285.     set_mouse_pos- }7 ]$ `" S) {3 d; V: I
  2286.   end! A: n% {6 n) D$ W+ |/ g
  2287.   #--------------------------------------------------------------------------
    . X: U- ~; O* d
  2288.   # ● 更新画面) @* u9 [; K3 k
  2289.   #--------------------------------------------------------------------------
    , b9 E. p1 E2 C; j% C9 \
  2290.   alias sion_mouse_update update6 S! H  h4 c4 w
  2291.   def update/ ^  }' J  ]( p3 O5 R3 P% V1 ~
  2292.     sion_mouse_update" G8 R2 Q. I( ]$ W
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    " T3 Q* K8 x8 j2 q
  2294.   end3 f# T% w/ @. D2 `$ F/ O7 C
  2295.   #--------------------------------------------------------------------------6 i/ `  G" W2 B4 Z4 p- Y
  2296.   # ● 更新光标
    # G$ n7 ^7 |3 b$ P
  2297.   #--------------------------------------------------------------------------+ M" V8 H0 g& ~5 ?: O
  2298.   def set_cursor4 K* }' y  _% g
  2299.     @move_state += 19 W6 @8 ]' m1 |/ o, O/ ~0 _5 {# x
  2300.     last_index = @index
    9 I8 H! Z* g0 J* [, e" S
  2301.     if mouse_which_window == -2
    5 K4 c5 [5 M3 V' m  _
  2302.       if (@move_state - 1) % 6 == 0
    - d) `8 l9 Z6 N5 k: x5 ~6 J
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1) t- y% @/ N, B8 U2 q9 ?
  2304.       end
    7 g% j: P) _2 g0 F. P
  2305.     elsif mouse_which_window == -1- x0 P0 W. `, q
  2306.       if (@move_state - 1) % 6 == 0+ d7 G0 S( _) x: @  B7 l9 C
  2307.         @index = (@index - 1 + item_max) % item_max if @index  08 A% t- Y$ H1 o' |+ K3 L7 q" Y1 b
  2308.       end6 w8 r. V  J' R# G3 ]
  2309.     else
    2 M+ {& \" \3 s$ L9 M
  2310.       @move_state = 0
    ! ?, {; e" ^. s3 \, X2 E
  2311.       @index = top_index + mouse_which_window
    8 \- F4 o, w# ^  j( X9 R
  2312.     end
    ) L, ~. o  r0 c9 F
  2313.     ensure_cursor_visible' M7 y4 p* B: d* j
  2314.     if @index != last_index4 u0 o8 U" H- |; d. h: v4 Q
  2315.       @savefile_windows[last_index].selected = false3 g# v/ e# m1 k8 S. \4 v
  2316.       @savefile_windows[@index].selected = true/ H7 D/ X% w% Q
  2317.     end8 G: ?& M4 }# G. i4 F2 {3 B
  2318.   end1 K8 L* z# G( W8 W# x! M: H7 j
  2319.   #--------------------------------------------------------------------------
    / x" b# t3 H5 g# |) r
  2320.   # ● 判断鼠标位于哪个窗口
    6 \2 H8 o' h6 d  W# ]+ O/ u
  2321.   #--------------------------------------------------------------------------" g5 r- J6 z3 d4 x
  2322.   def mouse_which_window
    ! e. b( C! i, T; K2 ^, `
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y# }6 p, \- |4 J
  2324.     if mouse_y  @help_window.height + 148 Q3 E, m* _: a$ L3 O& n. c: ?
  2325.       mouse_row = -11 o/ H' d" s" m8 m
  2326.     elsif mouse_y  Graphics.height - 14" c/ J* b& R: j1 N; Y8 \
  2327.       mouse_row = -2, i! @$ m- a% ~: r' O& p5 d, A9 g: O+ e
  2328.     else
    6 J9 F7 G2 E* w5 b+ g
  2329.       mouse_row = 4  (mouse_y - @help_window.height) $ E( Y+ ]. A" r& P( E; K
  2330.         (Graphics.height - @help_window.height)
    7 e/ ?" G9 z+ H! ]' l) ~
  2331.     end1 M5 G- l2 k% |  N1 z( F. d7 j& e
  2332.     return mouse_row
      \% o+ O5 A4 Q/ m2 i
  2333.   end
    8 D7 F! G/ r7 S9 i; q: o% ]
  2334.   #--------------------------------------------------------------------------
    2 n; z2 h: _/ d. B) D0 b/ f' j
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置4 M4 U; U" z/ g3 S5 l6 h
  2336.   #--------------------------------------------------------------------------( I$ S4 n/ p1 e  M( s; M' o
  2337.   def set_mouse_pos" X+ U6 |, D6 l' d5 l( k$ X, r( u
  2338.     new_x = 40
    # e! R* `3 D' w8 K# q: H( {% g# T
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 245 L: X9 c" i$ D. R! Q  I0 i" r
  2340.     Mouse.set_mouse_pos(new_x, new_y)) u  J5 C: z" p/ D. z+ d
  2341.   end& `" ?) t+ {; }& O) E
  2342. end
    ' _7 s1 ^. D" n

  2343. - A: V/ j2 o2 `; {
  2344. #==============================================================================
    % {) d& z% m# r0 B, a/ ~
  2345. # ■ Game_Event# g9 b7 a& {) ^+ K  j4 c; }
  2346. #------------------------------------------------------------------------------
    9 o+ c) Q1 [& L# {
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    $ c5 Q! n% x2 E1 A0 k5 L$ Q
  2348. #   在 Game_Map 类的内部使用。
    ! w% o+ D- Y9 k+ {& j& V& V
  2349. #==============================================================================1 T; ~. T) f) q5 @% z
  2350. class Game_Event  Game_Character
    0 V9 P/ Q( }6 x. {$ a5 t! o
  2351.   #--------------------------------------------------------------------------( w) R1 R( T# k
  2352.   # ● 事件启动
    1 k8 \3 i* n: _1 L
  2353.   #--------------------------------------------------------------------------) H7 ^7 _( y0 n. {
  2354.   alias sion_mouse_start start  s  b2 N0 P/ V1 S! M' \
  2355.   def start' o& e7 G/ @& {
  2356.     return if mouse_start && !Mouse.press(0x01)! ?7 |# `; j, s
  2357.     sion_mouse_start9 d: Q0 }& n  O4 {4 ~
  2358.   end# N+ R  W4 E, z9 h* p  A" n
  2359.   #--------------------------------------------------------------------------
    $ N; ?- n) B6 u8 |. d  D
  2360.   # ● 判断事件是否由鼠标启动
    7 @) [+ L7 c4 E5 U9 }% n4 j  W& Q4 w: w
  2361.   #--------------------------------------------------------------------------( S5 y$ H) p2 f5 {9 c3 G
  2362.   def mouse_start4 j6 U: ?; S2 q  c5 C2 `; z
  2363.     return false if empty
    7 K# F9 Y7 P+ [$ L0 B! M) v4 B
  2364.     @list.each do index0 L+ r: J" V3 H1 m- I# k
  2365.       return true if (index.code == 108  index.code == 408) &&
    ! ]# [5 P6 R$ I. V6 H$ x/ M" T7 e; k
  2366.         index.parameters[0].include('鼠标启动')  F, H, u3 L5 m# P
  2367.     end, `) W1 @: s. [" Y5 o. w
  2368.     return false) p7 i; Q' y% o" O7 K
  2369.   end5 Z" x* @6 G* \" J$ j1 z; b
  2370. end. l2 W# }2 r) q1 v4 e9 l

  2371. ( u1 u' z' [& f) E$ k
  2372. ####泥煤的height; T9 V2 @/ _5 g7 @1 r
  2373. # @height = height
    + l# i$ q# j% z" B6 K5 K% ^  U2 q; \
  2374. ; B3 C+ b0 {6 ^0 o7 K
  2375. class Area_Response# f! G% k# X+ Q8 P: t; z6 y8 U! j
  2376.   attr_accessor type3 X" ^3 }# w: g; [
  2377.   attr_reader ox
    # M* `% `. p2 Z1 n: B. f3 k
  2378.   attr_reader oy
      u8 s) t! ~9 @
  2379.   attr_reader width
      _9 t$ S+ N1 D2 O3 y
  2380.   attr_reader height) X- w3 ?- A5 O" d( S+ d
  2381.   attr_reader switch_id. b2 l. u" k  |0 r
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    # Q; {, @$ Z9 b  q
  2383.     @type = type1 Q, p- I' @" V6 h4 N4 P1 S
  2384.     @ox = ox
    6 D* F2 @# f2 I) c, J
  2385.     @oy = oy
    , w2 ]+ ~2 H! V2 S  w9 O
  2386.     @width = width
    7 ]/ L" D- S" O  R. V# O
  2387.     @height = height
    4 v- c+ M. ~! Z# ]9 \$ K
  2388.     @switch_id = switch_id
    % V7 N; a+ q; ^) h1 r
  2389.   end9 f6 _8 w1 ~5 F; r- g, O
  2390. end, c( \2 x* c) U# f
  2391. , n- E& [; z+ t# G; k2 B
  2392. $area_responses = []% R4 x" c( n! _2 ]: O

  2393. 4 I* T9 D1 z+ l9 H$ b
  2394. class Scene_Map5 @  V9 A2 h$ V4 F2 j% P3 k
  2395.   alias update_mouse_2013421 update_mouse_action; Z* [% F0 l$ ^7 l5 M) d( _
  2396.   def update_mouse_action- T5 g' J1 ^. s: `+ `3 i
  2397.     update_area_response
    ) ]+ J9 W4 \' P, s, m+ \  Q
  2398.     update_mouse_2013421. n, |- s( Q$ d8 {5 X7 w9 F
  2399.   end2 f9 k* d1 Z  J+ L' D
  2400.   def update_area_response
    / w: g+ O) p( h6 n" V1 X! c
  2401.     responses = $area_responses* n2 S/ K5 ^- U* i6 K0 y) t
  2402.     responses.each {response
    3 u) M7 I9 M4 g+ {8 A2 J9 _) \0 r
  2403.       ox = response.ox
    / f4 J! y6 x& ~) x3 q! G
  2404.       oy = response.oy
    0 E  \) F; Q2 g0 E; S
  2405.       width = response.width
    4 q9 ?4 {% s9 Q% P; b7 c, S& R
  2406.       height = response.height
    ! o- x# g% x0 ?- d3 i/ k( D
  2407.       switch_id = response.switch_id  W( c& a9 b) r3 q# ^6 x
  2408.       case response.type
    0 x" f* S: Z- i  v7 Q9 }8 ^
  2409.       when 0
      s2 T  T7 ~$ m
  2410.         if mouse_in_area(ox, oy, width, height)
    1 `. |5 v" F* D# h
  2411.           $game_switches[switch_id] = true! Z+ B) X8 P& G6 ~  Q# c5 y9 Z
  2412.           $area_responses.delete(response)
    1 d! j4 ?+ X+ S  C
  2413.         end8 O/ }0 D6 Q0 W) H" B
  2414.       when 14 X+ ?3 E0 c  J; d) e' h+ m" M
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
      C8 H1 B" N" y/ w  N; z; l
  2416.           $game_switches[switch_id] = true
    ) o$ V. N: t. d( w* C5 s! S" Q
  2417.           $area_responses.delete(response)
    6 U2 U9 S' N. l* ^  u0 v! p
  2418.         end8 U/ q! i  }# v: n  ?6 h
  2419.       when 2
    9 \% I1 Y( ^9 r0 u  o
  2420.         if mouse_in_area(ox, oy, width, height)5 v$ x3 X( w! E2 q  M5 p* t* Z
  2421.           $game_switches[switch_id] = true
    $ Y+ Q, m4 _& `
  2422.         else! l" [3 w* S2 ^% p
  2423.           $game_switches[switch_id] = false
    % `' O# {- Y# P
  2424.         end$ V  A7 c/ W( n5 h( d6 ~& U
  2425.       when 3
    5 _0 p3 b( D: Q' E8 s
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,* x$ g) {) }$ e
  2427.             (oy - $game_map.display_y)  32, width, height)
    ) X9 p; ^& J% B5 |% j2 k- C6 D2 A
  2428.           $game_map.events_xy(ox, oy).each {event
    * `' v- W4 C' b. F" K. m
  2429.           event.start
    ( ^0 J+ E7 t! f" x) E4 E2 O
  2430.           $area_responses.delete(response)
    4 }- w, Q$ m: W
  2431.           return8 g9 }; U! h3 O5 b8 m
  2432.           } : D9 v# P4 M8 W2 Y; W- y
  2433.         end( {. N0 A, u5 w8 H) F
  2434.       when 4( u5 {' u; |- u* b7 x
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    ) _4 v- T$ C2 ^0 C+ v2 F9 n
  2436.             (oy - $game_map.display_y)  32, width, height)
    - |9 S% o% }% u- X( Z& e' w
  2437.           $game_map.events_xy(ox, oy).each {event
    ( p* a+ }' K; k, v! `% d: j7 Y
  2438.             event.start  a+ \' H0 _/ A; |" ?
  2439.             return
    # D9 o7 `3 s. Y5 w
  2440.           } 7 n9 o# V7 \, w# ]$ D8 i- b1 K
  2441.         end
    3 Y) u* G/ t- G# I$ h% `
  2442.       end
      K; b5 z" A4 F5 m* T1 R8 G! A5 @
  2443.     }8 E) y9 Y  v, w6 h6 A, N
  2444.   end
    . d3 @9 q2 r/ v. m) v8 c
  2445.   def mouse_in_area(ox, oy, width, height)- c8 ?$ C: i: Y& R6 c
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&& {7 S* B" Y3 K4 u
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    ) W% I: r# i  g, k' g
  2448.   end6 F1 T, X9 l0 a( a' O3 G
  2449. end2 G0 B6 l1 I  K4 V5 D
  2450. class Game_Interpreter
    ( h$ P  f/ k9 _
  2451.   def area_response(arg); H* B: [6 H6 ~% o) f
  2452.     $area_responses.push(Area_Response.new(arg))
    % o& i5 R6 X) @. k/ E
  2453.   end
    8 {6 `# r+ o* c& I; ~1 A
  2454. end
    4 X% u* H. B5 `. F, {* [  ^( M) w
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1