Project1

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

作者: 熊喵酱    时间: 2013-8-29 09:01
标题: 存放腳本
純屬給LBQ腳本:
  1. =begin #=======================================================================
    " A9 K5 i; y# E$ u

  2. 3 _- }$ M8 x" ?$ ^% ]( S
  3.   Sion Mouse System v1.3e
    - }2 ]; g% W. ?7 y  r! O0 t& \' D
  4.     [9 S% |4 j( Q# v7 c$ q
  5.   Changlog4 K8 p( Y4 E. G3 r. U2 u
  6.   
    ( x9 m1 k8 J9 H" n7 i0 c2 y) K
  7.   2013.4.21 v1.3f
      T! ]5 p3 s; O" K1 k" V! b
  8.    
    " ~; `# D4 W4 w3 V" R7 G  |. x. Z! T+ ], B
  9.     1.3f 卷动地图 bug 修正  T3 c* n, O: {5 {5 ]) ~
  10.    
    & D, Q2 c4 F, [' h* g0 ~* K# x' k
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口( n  o- J/ o4 X3 Q
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    6 U3 o  ~2 B- x
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    ; o  Y5 r5 i0 A. O' d" j

  14. ) A  k  e: S: n3 o
  15.     1.3f bug修正
    3 o: G  }; ~9 x" f( a1 l3 }7 S
  16.   ' G- P' A. x5 [
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    ; g) P' L$ K2 o; g2 {
  18.           关闭菜单时,鼠标是否移动到原来的位置。% z7 ^# d4 J7 m; S; E: A  I0 ?

  19. / q4 H: \  z* d2 y$ q4 X
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    ) b% I6 f( p/ t' d  @
  21. / I: O* N, u& C7 G. e$ o8 Q
  22.     1.3b 修正一些罕见的bug;
    # W# }8 n# B, i( h$ I% {

  23. , W$ }# }. b' V8 ?9 s2 @4 P
  24.     1.3a 代码小修改;5 z+ u) X( b% [2 @! u. m
  25.           加入了鼠标点击启动事件的功能,! G$ O9 {/ y9 G, J2 w! h
  26.           在事件中加入“注释”: 鼠标启动  ,$ \5 [! u0 m) Z* B
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    : k3 s  l/ ~# q; q- e
  28.   * p2 d$ @8 C, B% r" H9 O8 Z9 O; o- z& o
  29.   2013.2.12 v1.23 X+ Z5 m) ^# z5 o

  30. . `# h  I( I; o% U: E; z+ S
  31.     寻路逻辑优化;2 a, H+ a# e; ~7 r/ m; h3 J3 j% `
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    4 `5 @: |9 u4 K0 a9 D
  33.     现在支持用鼠标来操作载具了。* F: i7 D- [( i  l

  34. , G& A- x2 h. u: u( G0 M0 l
  35.   2013.2.8 v1.16 K+ h7 D  r% H, N2 v

  36. 3 z7 U. L3 ]- o7 }9 Y% w6 F4 w5 I
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;3 a6 f6 m& B0 L! F
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    4 D0 G& p2 R6 [; x8 s
  39.     移动时,路径指示点的绘制更加稳定;& Z$ k% K: A0 l7 a% H  R1 [* r
  40.     现在支持默认存档画面的鼠标操作了。) |; L6 Y. j/ q# q

  41. ) S1 s! P( ^( \$ \) n5 ~

  42. * c6 W' ~0 E+ G2 N- E2 P; v9 `- ~
  43.   OrigenVersion/ F4 L: G& c3 h! Y* c" N9 S1 m$ U  H- M
  44.   7 Q  v: B' z* n3 C. T% A5 S  T
  45.     2013.2.7 v1.0
    , c' R" v2 G- h  s

  46. " y2 b& I3 j/ t: ]$ F4 t
  47.   主要功能" [. c0 V3 o" E+ y3 U$ ^% ?
  48. : n* f: K1 p1 u# G) \# ?
  49.       使用鼠标进行各种操作...6 m& M5 ?4 E* ^, [2 P+ A
  50.       将鼠标锁定在游戏窗口内* \1 j# s; Q: G) Z
  51.       自动寻路,按住 D 键可以扩大寻路的范围- p! M( J5 y# m
  52.       双击鼠标进行冲刺' z* {, k4 u9 k, F
  53.       更改地图卷动方式以适应鼠标移动
    0 o; H4 t: w5 l9 _# y1 @
  54.       变量输入框改良# A) i! D) K9 `. K7 C  P. K

  55. , R8 F8 n! Y1 H
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    9 M/ E! {- s7 y& i
  57. 5 t; x- y$ Z% E( Q
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    1 `% s, @) j, `- q
  59. + K: j( r$ F1 I; u8 |: W0 L) ]
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    ! ~4 F- \: V1 j/ E  e7 i7 L/ C

  61. ( a% R+ q- ^6 V

  62. 6 o" H& N/ D* D, X5 ~
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    % V' h: R) m% B+ M5 h
  64.   f# U# _7 l/ r  O: c
  65. 5 F. t! ?! `" P: V7 E
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
      f' K' O: n3 P" b3 O3 T

  67. & \5 b" D7 c4 c) H5 e2 k/ w5 B# R
  68. #==============================================================================
    ( U. ^4 j& C( X; ]( o
  69. # ■ 常数设置 + v' v8 B: P- K$ v- C# c2 a! a
  70. #==============================================================================1 v- U( s% t+ O$ F$ [7 `
  71. module KsOfSion
      C$ p$ Z6 S7 ]
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false9 q% [# x8 M7 L7 h+ G* x3 \! {! A
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    , }+ _6 `+ \* I" ?- d
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false2 J. V& K# x0 x1 X
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    + d% f/ }8 R1 i4 Q
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处" \4 S$ r8 I4 l. H, E
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    1 J8 y2 N( w4 G& K$ N; S4 o/ C
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    0 W8 A: [2 D8 l/ ^% b% c; f7 r
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键  z! _8 h+ g$ D& H2 T2 j$ `6 m
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    " D8 E% J  U: d: ]2 N1 t; C3 k6 n2 s
  81. end
    % v! h* _: w# j) J6 e& |- l
  82. & Y" Z% a* G- R8 w7 o5 a, [
  83. #==============================================================================* X7 k2 ?5 D/ k- B) u1 v  k
  84. # ■ 用来显示路径点的类
    ; ?) R( c- R# A+ ?8 H
  85. #==============================================================================
    & F: ?4 G: ^0 M' f
  86. class Move_Sign  Game_Character* T' |7 I9 A5 |
  87.   #--------------------------------------------------------------------------" G4 l4 J) V1 s4 C/ D1 _2 d
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图5 j9 o( Z) p: E4 t5 \1 w
  89.   #--------------------------------------------------------------------------
    0 V( `8 A6 x) t9 X% r) J
  90.   def init_public_members
    6 Y* \0 Q1 R5 g3 G& O# y
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹7 F2 f& L: M- L( w1 H- b( C( D
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为09 B4 Y- b5 t/ H( q% k( P2 x
  93.     @move_speed      = 5        # ★ 踏步速度
    . ?' e. u8 j' {+ k8 @
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)& X+ j8 O/ H: z% P+ W' s
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度7 ~' n8 H- ~6 G) ?) G
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    & ?$ i! G1 T- b9 }, Y. [5 q
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    2 v* [( T7 ~. R( q+ J5 R  M1 y% c
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)4 ?# T/ O8 a: K$ |8 W4 M
  99. " x3 n! [) p+ q9 i6 T
  100. ! C$ @& o/ i6 n+ U5 D
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★! p& a+ s9 F! O3 J8 z
  102. 9 W! B: q) s' g* m6 c
  103. ' ]; b7 M/ A- @0 l4 w. A, F
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图- C. ~7 t$ z- ?, T. n
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    6 R7 {& i) s& h; S3 w5 e
  106. ) A% r; O$ B: A: U$ K
  107.       if $no_arrowpic_warn4 f" S  e( k, |6 N. N$ @
  108.         MouseShow_Cursor.call(1)
    * O7 e; H! h. J: _* G* w
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    % e4 z# P# h" J% L5 x" C
  110.   n) Q9 Q" f2 o$ l; y' c' U$ {+ b, a
  111. “路径指示点”将使用游戏自带图片
    - s: k5 L' x9 n- f9 i, p6 D
  112. 8 `9 Z  W; ~4 W& }$ n0 F
  113. 该提示可以在脚本内关闭'): L  @1 d! q" f  b' T2 Q, n) w' u
  114.         MouseShow_Cursor.call(0)4 e( z, c# Y) N
  115.         $no_arrowpic_warn = false3 H( t) J  X; R
  116.       end
    / a$ ]! Z* t+ }" G
  117.       @character_name  = '!Flame'8 ~$ y5 L) c, K8 |+ I9 Z5 v0 [. W: h
  118.       @character_index = 65 o. r, G" \( W' R! I8 g$ |
  119. ; w7 {6 w$ n7 B
  120.     end
    ' c, `: ~8 W; v" V# A+ m
  121.     @direction_fix = false  # 固定朝向% q9 u* R4 D8 H' [/ i0 E
  122.     @move_frequency = 6     # 移动频率
    : e; B. ]& y$ l2 [2 S  |& c
  123.     @walk_anime = true      # 步行动画
    3 y* ~7 ?5 N) G% e; S
  124.     @pattern = 1            # 图案5 O( V0 Z' B8 k' H$ [; t" d( d
  125.     @through = true         # 穿透7 r$ N9 H2 \; a0 \$ m- j
  126.     @bush_depth = 0         # 草木深度
    : X3 S/ F+ B* e. I1 I7 K
  127.     @animation_id = 0       # 动画 ID' n. o% m) T0 q$ n- R( }2 I
  128.     @balloon_id = 0         # 心情 ID
    . Q2 X7 ]8 i9 L5 N
  129.     @transparent = true     # 透明1 q7 I0 G9 o+ Q  D
  130.     @id = 0
    7 N* e4 W1 C( G4 W7 f9 P: a! E8 i
  131.     @x = 0
    ( \0 v; `$ z8 ?
  132.     @y = 0; u0 t- g$ ?* q7 M. D! _4 B/ n
  133.     @real_x = 08 n6 K3 [; G5 B* B  ?
  134.     @real_y = 04 E0 E+ z7 I7 T8 f+ q7 _' M
  135.     @tile_id = 0! ~' h. H7 q! v9 ]8 y4 m
  136.   end. q  Z0 S! H, X5 u: [6 c' ?* O& G1 Y" E
  137.   #--------------------------------------------------------------------------" J3 m% r6 j- j% g) u" y
  138.   # ● 定义实例变量# ]/ n7 W8 }* S0 d
  139.   #--------------------------------------------------------------------------
    , M9 m8 v! I( E4 w2 v3 d9 g
  140.   attr_accessor direction
    1 \5 R" N6 b2 f0 Y8 h
  141. end
    # G+ o& E2 \- V& \* f: ^
  142. ; D. w) }% _' h9 L* I
  143. #==============================================================================
    $ V" w' S. _2 X& c
  144. # ■ Module Mouse
    % f" |/ n$ N6 W( r6 s
  145. #==============================================================================
    * w5 A7 N/ _$ E3 d3 O7 c
  146. module Mouse
    " [/ J2 g3 a0 z9 J/ C! r
  147.   #--------------------------------------------------------------------------; J/ K" g, W! P( Q
  148.   # ● API: x- l" q; D( ^4 c
  149.   #--------------------------------------------------------------------------3 \# c, o( T, x( P, S
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l'), `0 G  s( I7 R8 f: k( a  |
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    ) ?; w- x+ C' J7 H1 P5 {9 Y
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    9 t# D& n6 R$ I4 V
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')  d. b$ x/ b3 I
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    2 H8 c) v$ X) c, \6 x
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')+ c8 Z8 s8 ^3 H# P( P% e0 l
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')# ?2 D4 U7 V0 D) {: V, K3 ~) Y4 ?- d
  157.   Window_Hwnd       = Get_Active_Window.call
    * Q6 _5 P6 B- Z+ s% Q$ ?
  158. % Y5 \  ^6 i' n" b9 U
  159. class  self8 H! a% l' p, e  H
  160.   #--------------------------------------------------------------------------* R" F7 }( H8 W$ q6 B3 q/ H' J
  161.   # ● 初始化
    # m' P+ ]& Q/ W6 x* M( @" p# L
  162.   #--------------------------------------------------------------------------
    / V" e) c5 t3 D5 z  {9 P7 y
  163.   def init
    8 f4 ~2 q* P! S+ \3 J: T* e- q
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    0 R& W$ q/ L$ u( Q3 e# T% h
  165.     @left_state = 07 }# W$ A) a$ T/ n: H
  166.     @right_state = 0
    : a! Q6 |  a/ T2 k; `% S/ P5 P4 D
  167.     @ck_count = 0 # 帧数计,单击以后从0开始' f  _' ?0 K6 [7 r# d( _. L' S
  168.     @dk_count = 0 # 用于双击的判定. d; ?8 C0 U) H- P9 `% |
  169.     @clicked = false
    ! z+ V$ E) h4 u1 b1 n
  170.     creat_mouse_sprite
    ) M8 q1 J' o6 O
  171.     update
    % ]/ G6 i. }* o
  172.   end& c+ ?! J: z2 D& M# c1 K
  173.   #--------------------------------------------------------------------------
    # s4 w0 q7 O4 B* R2 A
  174.   # ● 鼠标指针精灵
    . ]: F+ |* s" k8 A7 j/ s
  175.   #--------------------------------------------------------------------------
    * `6 n  U% O$ e7 n1 a* E
  176. #~   def creat_mouse_sprite4 l/ z8 j9 ]7 u% m7 ]
  177. #~     
    ( s5 Y, S- r0 |4 |
  178. #~       @mouse_sprite = Sprite.new" y! p9 C3 n7 i
  179. #~       panda = 2#rand(2)+1$ y$ Y; N5 R& m0 _" o( x

  180. ! m8 q7 u3 m8 D0 R& N5 ^& g
  181. #~      if panda = 1
      {$ ], w& q  Q+ {; F! ?) ~
  182. #~        if File.exist('GraphicsSystemCursor2.png')0 \1 p5 }  k0 S. {, O, v+ s. G
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    : T4 b5 R3 T( r8 c: d. c
  184. #~        end#with if File.exist
    4 F+ y! a. A+ W# }0 N
  185. #~   
    4 g& X. R9 ^, {8 H6 K* k
  186. #~     else if panda = 2 #with if panda=1
    " Q/ u- w! F6 D7 r) {
  187. #~      
    ! z3 ~. n4 y, T4 I8 b  a
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    / d: e7 Y& j* L! z: D2 m
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')4 Q& v. i$ I5 }' e5 r; K
  190. #~      end#with if File.exist
    5 A0 H( |  p" w/ x' E
  191. #~       / R8 ~8 I4 R( q8 R8 Q9 O
  192. #~     else #with if panda=1
    1 E" y% v7 J2 X) P  p' D
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24); @6 m: J: E5 U  [, {
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),! a5 U4 Q7 \6 u4 Z/ D
  195. #~       Rect.new(5  24, 24  24, 24, 24))4 W0 l4 J: K* w; v
  196. #~     end#with if panda=1
    4 w; ?, J" b) l0 E3 z6 K
  197. #~     " s/ c2 n0 g* q: i6 A2 ]
  198. #~     #with def
    ( q- ]9 h) r& @2 c
  199. #~   end
    * A% S, b1 S$ h8 R3 @" I
  200. def creat_mouse_sprite6 j+ x' i# G/ O' c% I5 c
  201.     @mouse_sprite = Sprite.new# f/ o' ^( j# ], s
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})3 Q6 N& E& A2 w7 T& E3 p0 G6 Q
  203.     @mouse_sprite.z = 9999- X2 }9 u1 X1 P$ W! R5 F0 S
  204.     Show_Cursor.call(0)# w' d9 [  w( H, W( e( P
  205. end
    . h" f/ f+ G: q- G

  206. 7 w1 g0 m0 Z3 p. x
  207.   #--------------------------------------------------------------------------5 p3 `" [% J1 A. _' L& _
  208.   # ● 更新# {2 M& O* _/ G- Z3 s. ?
  209.   #--------------------------------------------------------------------------
    4 _' a/ d" y+ w7 N) |
  210.   def update
    9 D% l) l5 U" V4 W
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
      j+ j9 O3 h1 J* |; J
  212.     left_state  = Get_Key_State.call(0x01)- B/ M4 z) S# N& N
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    # @" Q# ?6 W6 `) w# R
  214.     right_state = Get_Key_State.call(0x02)
    : ?4 i6 M. F6 z; T& N' @
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0' K: o8 U3 C0 J' J9 U' d! M
  216.     update_double_click
    : d) j/ q$ l  h1 z; [) a
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    . R7 V2 ?9 C) [1 W: s
  218.   end
    . [+ i* w  B3 D  Z( k
  219.   #--------------------------------------------------------------------------9 N! n% V! _# i4 h- l" u/ x
  220.   # ● 获取鼠标坐标
    0 \6 J5 Q6 E! B. g: Y4 r; Z
  221.   #--------------------------------------------------------------------------
      _* v7 P; H- m, J8 D' n( M, P
  222.   def get_mouse_pos
    & d, X9 J$ R6 t7 f4 P
  223.     arg = [0, 0].pack('ll')6 S# Q; m" K9 ^$ e1 R+ E: B
  224.     Get_Cursor_Pos.call(arg)+ N: y; M/ r) ^
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    % ]6 s7 p* O; r" O  }: F3 {; R
  226.     x, y = arg.unpack('ll')
    $ r* y3 s) ]0 Q2 ]
  227.     return x, y1 J, g" h$ o* d6 \8 L$ b" ~% N
  228.   end
    % H  e9 _: @$ R+ {, M
  229.   #--------------------------------------------------------------------------
    4 X& L& U7 a8 ~8 V
  230.   # ● 将鼠标固定在屏幕内
    ! ]- n3 S7 X# X" c% ~
  231.   #--------------------------------------------------------------------------
    6 t0 n6 {) x2 |9 K, [0 O2 K
  232.   def lock_mouse_in_screen5 y; U7 a7 K2 Q8 X5 S. T1 d9 k
  233.     arg = [0, 0].pack('ll')
    / y7 X2 C# s0 A3 A: a5 P" G  H
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    / I( V8 T9 F- b' v7 [/ e
  235.     x, y  = arg.unpack('ll')& [1 @2 B" u! U) c! f, l- a3 T
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    ' n3 i! e, Y0 g' @3 Z
  237.   end
    - a( r8 F$ r# w
  238.   #--------------------------------------------------------------------------. g) W1 n) L+ H  y  ~
  239.   # ● 解除鼠标固定
    0 \5 y2 z' U; F% N; w. n
  240.   #--------------------------------------------------------------------------9 F$ X# n3 r+ V4 }; e4 c$ ?
  241.   def unlock_mouse_in_screen0 r. ^! K5 Y2 z% S! d
  242.     Clip_Cursor.call(0)6 z. B  u% R. X" [5 u; P
  243.   end
    8 [2 Q3 u7 J* X& {2 A* q
  244.   #--------------------------------------------------------------------------7 F  ?5 _6 n/ L  T6 r! ~
  245.   # ● 鼠标双击判定
    ! L. r! e: V- W8 e" K$ J
  246.   #--------------------------------------------------------------------------, r, R1 J7 o/ P- G6 u/ {$ |# }% L
  247.   def update_double_click% Q  J6 z- H6 E3 z; o
  248.     @clicked = true if @left_state == 1
    / P5 u( N! X6 ]
  249.     if @dk_count  0 && @left_state == 1
    $ s& m  T3 y- t
  250.       @dk_count = 0; @clicked = false
    0 G9 |; }$ T8 X/ B
  251.       return @double_click = true
    ; T, X' @$ T% H5 R% t  {* A+ {# D
  252.     elsif @clicked; x+ Y/ R+ ~* H6 M" t5 \
  253.       if @dk_count  KsOfSionDbclick_Frame
    6 _( q6 |# M5 l9 A6 d' V
  254.         @dk_count += 1
    & @( h* D- ]  Z! @- s
  255.       else) j- L1 w' f& s) z1 j
  256.         @dk_count = 0; @clicked = false
    $ N3 k1 P; e9 d- A2 U: i
  257.       end% O, {4 [6 I* e3 y5 o
  258.     end* Z; B; X3 R1 x9 D. g# F
  259.     @double_click = false! f- X) f0 V8 H: q1 c; M& ~
  260.   end
    & }/ h( r" L* }* y" w' E! R
  261.   #--------------------------------------------------------------------------0 M7 g) ~5 {5 r; h  A8 `8 V
  262.   # ● 按键被按下就返回true! I7 B$ j! k' g5 j
  263.   #--------------------------------------------------------------------------
    ! e1 f6 ]8 d3 E0 i* K
  264.   def press(button)2 |. E8 }0 {- }6 H  p
  265.     case button. k9 A' I0 \! l( G1 G, S
  266.       when 0x01; return !@left_state.zero
    1 B4 U. }) @/ o5 }; A: M9 @6 l
  267.       when 0x02; return !@right_state.zero
    9 V5 o4 Q& _) f# i, d! T; x- |
  268.     end5 \, w! \+ U0 ~* f
  269.     return false
    ) F6 ~: y! {! E: R* s' N9 M
  270.   end
    + f, H; @! I9 B$ s# f* K5 q( b
  271.   #--------------------------------------------------------------------------# p6 u) b/ d' O( \
  272.   # ● 按键刚被按下则返回true
    : U- I4 G" D& U' m( a$ \, }7 r+ ^
  273.   #--------------------------------------------------------------------------
    1 H/ Z4 ]& k* o0 Z" m- X, ~
  274.   def trigger(button)7 \+ ]. R8 h" O9 l& |
  275.     case button
    # H! i# o1 C& M0 Z+ X) w
  276.       when 0x01; return @left_state == 1
    1 Z5 \$ h: h. Q: b
  277.       when 0x02; return @right_state == 1! |; p4 ~( \9 e; G
  278.     end
    ) W3 e5 Q5 D. j( S( b
  279.     return false
    2 t9 K! ~- \/ [
  280.   end, A/ ~  {3 q3 }8 n3 e+ q
  281.   #--------------------------------------------------------------------------) G. G% O2 E, q, W" N: p
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true' D3 |9 J/ B3 s* I: V0 p
  283.   #--------------------------------------------------------------------------
    . @" t7 }+ s/ h
  284.   def repeat(button)% J1 @$ l6 \! D1 b, _
  285.     case button
    / W% s4 A* m3 C# X4 U
  286.       when 0x01; return @left_state == 1
    % p( g. f, v# ^
  287.         (@left_state  22 && (@left_state % 6).zero)
    . q$ T7 n4 U: u: {
  288.       when 0x02; return @right_state == 1 + ?6 k  ~% l1 T  z) w* e6 Y
  289.         (@right_state  22 && (@right_state % 6).zero)
    2 l8 Z6 d- e: K/ W3 T# L. l
  290.     end3 G! X, l( H' \0 z
  291.     return false* C( w4 j4 Z* ]* @
  292.   end
    & X3 v  ?+ f( x; a! i6 O- U& O2 x
  293.   #--------------------------------------------------------------------------+ {( G/ Y' [- A+ b2 R
  294.   # ● 判断是否双击鼠标
    % V3 ~, }: _5 Z( Y+ u8 u
  295.   #--------------------------------------------------------------------------5 o  Z- C: Y& E" t1 J+ p" `
  296.   def double_click& D# n  Q+ y6 i: \+ x
  297.     @double_click
    3 u- ?& n, G  h0 m) X
  298.   end( K- E7 @! ?! `" V% _
  299.   #--------------------------------------------------------------------------
    ) e8 t+ {& y% m# M
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)  h5 F5 `) p% I! U" q, T9 ~! e& u
  301.   #--------------------------------------------------------------------------( g: {6 X, `+ S) w
  302.   def click_count
    2 a. \1 Q) F& |; v- \
  303.     @ck_count1 L. `1 \2 p8 K1 U0 W* t& M
  304.   end) p! Y' ?3 K6 H0 w( m6 ?3 y
  305.   #--------------------------------------------------------------------------* H9 ], a% ]* K/ R. M) O
  306.   # ● 获取@left_state(按住左键每一帧+=1), U, f6 R5 j: A3 V: n% b
  307.   #--------------------------------------------------------------------------" K; {0 }) D: F2 U7 g/ S) `
  308.   def left_state3 H- q% g/ H& O' Y& `$ ?+ P, L
  309.     @left_state
      b1 `# H# \. K! m  `/ y
  310.   end3 l# t# J& S! c5 F* ?6 \
  311.   #--------------------------------------------------------------------------* v2 O: t$ \5 R/ y" h9 i4 }1 Q
  312.   # ● 获取鼠标的x坐标% q6 q6 b2 ~- Z1 Y8 M" h, t6 e
  313.   #--------------------------------------------------------------------------5 O0 ?7 V5 l. D" G, Q
  314.   def mouse_x! r7 Z/ s7 r% O8 p* ~
  315.     @mouse_sprite.x* l' J6 d1 J- r4 u6 F/ \
  316.   end" |" g: `/ B- e. ^5 f! `
  317.   #--------------------------------------------------------------------------  Y/ g! F1 a$ l# u& f
  318.   # ● 获取鼠标的y坐标8 d" t9 o! _+ x& O* I5 u
  319.   #--------------------------------------------------------------------------
    ! R4 S9 b2 H% _2 H
  320.   def mouse_y( W2 N3 A$ W3 C% Y
  321.     @mouse_sprite.y
    " g4 f, J  o# ]) U) t# X
  322.   end
    - T- e& b2 q" @# L
  323.   #--------------------------------------------------------------------------
    9 j' ]3 l) \3 i. l! r5 A
  324.   # ● 设置鼠标坐标
    ' [( K# T& v/ D
  325.   #--------------------------------------------------------------------------
    0 C# s% s6 c! `- M5 K7 {1 A
  326.   def set_mouse_pos(new_x, new_y)% Y) c/ j8 D  G1 J8 ^+ m! r
  327.     arg = [0, 0].pack('ll')
    % W' |6 F- X0 K  p; e
  328.     Screen_To_Client.call(Window_Hwnd, arg)" z9 n+ B' R# @/ Q8 q
  329.     x, y  = arg.unpack('ll')
    ! r5 n1 ~! j* r" x* j: h  P
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)) T8 P9 ]" h  L5 ^
  331.   end" f' R2 u/ p- X+ H
  332. end #end of class  self
    9 V  p$ l3 Q, S7 w' B5 I0 J) x  [
  333. ' M7 V& K1 y" U0 k7 ?: N
  334. end
    : L# s, E) }4 p8 p$ i

  335. 9 V6 {1 r& s. m  V9 c4 I
  336. #==============================================================================) U5 |9 o3 \; m/ O0 C
  337. # ■ SceneManager
    ) v3 Y2 ^: c8 p! j1 D: e+ v7 F8 g
  338. #==============================================================================
    , G% Q8 S4 O' D% a; X. L
  339. class  SceneManager7 M, ~" ~# \7 I- D8 N
  340.   #--------------------------------------------------------------------------
    ( C9 ]. N' E! M- W' ]
  341.   # ● alias
    $ z- ~0 \  p0 j" U& K
  342.   #--------------------------------------------------------------------------& O$ X/ {) N- o
  343.   unless self.method_defined(sion_mouse_run)4 x% C6 |. W7 ?, i7 d/ R4 y- Z3 H
  344.     alias_method sion_mouse_run, run; \7 ]7 a) z  r# o
  345.     alias_method sion_mouse_call, call9 v- x+ z# j6 L0 g2 u" Z+ n
  346.     alias_method sion_mouse_return, return
    ' R. j; l3 V% B
  347.   end, {) h+ m  R4 D& z3 U! W
  348.   #--------------------------------------------------------------------------
    / \/ P: }$ n" T& z& O* j6 y
  349.   # ● 运行; e7 x: ^. N  l- o4 j+ c& a8 E. @
  350.   #--------------------------------------------------------------------------
    ( o4 n1 w; O$ M! s* K
  351.   def run
    0 a% n+ d: B6 l) J0 I2 ?
  352.     Mouse.init
    ( b% u, l  z$ R& u, ]5 `% |, I/ ?3 ?
  353.     sion_mouse_run
    1 v3 n6 R' `6 i3 }( `( X; I
  354.   end+ c( U+ K. l/ K$ d" S' s: F4 t
  355.   #--------------------------------------------------------------------------
    4 j$ R+ n5 h; F/ z' n5 j
  356.   # ● 切换
    5 P1 D8 L: Y( m
  357.   #--------------------------------------------------------------------------
    0 j/ [: ^8 p" _7 Y
  358.   def call(scene_class)
    % A8 Z$ D- V& K1 w( ~
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    ; \3 X0 b+ K/ o7 }& K
  360.     sion_mouse_call(scene_class)
    0 B3 w  E4 K" A; b& D
  361.   end
    . u( p8 ^6 P4 Y& W- J+ Q# Q
  362.   #--------------------------------------------------------------------------
    0 U; [2 U6 U5 I: j. E. u
  363.   # ● 返回到上一个场景1 k3 M1 Q1 [+ A/ ^9 |) N( D
  364.   #--------------------------------------------------------------------------+ D4 [/ I$ W& M1 f5 L
  365.   def return' w0 ?  F8 r2 ]: k( ~
  366.     sion_mouse_return: H# f) j& z. r  r4 ~8 Z
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    8 Z2 g: |1 O$ K2 @8 @
  368.       @scene.instance_of(Scene_Map)
    1 j  U3 X7 k" M0 U% i
  369.   end2 ~4 \3 S6 k) z/ U# V4 W/ |
  370. end( J7 x1 X+ S, [7 i* \0 b

  371. ( ^0 ?$ L0 C; w
  372. #==============================================================================) ^4 m7 [1 }5 ^# x9 D) p
  373. # ■ Module Input+ P2 s+ b4 [9 s
  374. #==============================================================================
    ) o/ ?: S; H3 M- P  w& z  `4 d
  375. class  Input. z& J7 M6 C: A& M0 ~. B; t
  376.   #--------------------------------------------------------------------------: a. E! G+ z# \( B& u3 d0 ?
  377.   # ● alias
    % @% A% n5 P$ i8 V& ^  K; m/ e
  378.   #--------------------------------------------------------------------------3 l# T2 V# z( ^2 _
  379.   unless self.method_defined(sion_mouse_update)/ M2 U+ B$ A# r, z" B2 t
  380.     alias_method sion_mouse_update,   update) Q9 l9 j" b$ J$ F
  381.     alias_method sion_mouse_press,   press- }6 p$ p% i8 ?& A3 \
  382.     alias_method sion_mouse_trigger, trigger
    + P+ [! B9 R( S' b- ?+ D
  383.     alias_method sion_mouse_repeat,  repeat3 [- V. |: {" y, p% M
  384.   end
    4 C+ a) j% T+ h# H8 s( C# O$ x
  385.   #--------------------------------------------------------------------------/ e- I( \7 Z5 y0 f' Q# O
  386.   # ● 更新鼠标
    8 i5 G/ {; x) O# B
  387.   #--------------------------------------------------------------------------
    & z2 b, ^8 S2 _& b7 K& l" i
  388.   def update  s! y. U8 O0 R  _
  389.     Mouse.update
    ' `# T# J* u  _! Z" u& y2 w
  390.     sion_mouse_update
    5 A: \' d3 h) d# D2 R
  391.   end! e5 |5 C0 O- L8 R; e' X
  392.   #--------------------------------------------------------------------------
    7 A% L5 C0 F" r
  393.   # ● 按键被按下就返回true" A& M. q1 x" T% N. z$ }2 v1 ~: e
  394.   #--------------------------------------------------------------------------
    8 n4 J: O# g% F% c7 Q3 a
  395.   def press(key)
    * L9 B# L# E# {: B5 T
  396.     return true if sion_mouse_press(key)
      c1 N; O5 x1 p. X4 f
  397.     return Mouse.press(0x01) if key == C
    7 W7 v4 B, T7 z6 e
  398.     return Mouse.press(0x02) if key == B7 Z8 s  S+ }1 E, o3 ~
  399.     return false
    ) L0 d" g' p9 D
  400.   end- M4 [: F" u# }' R, `( R9 z/ b
  401.   #--------------------------------------------------------------------------
    0 w& j% Y; n* N- i3 ?" o$ u6 r5 @' i
  402.   # ● 按键刚被按下则返回true3 |  @8 e+ ]% A8 `
  403.   #--------------------------------------------------------------------------, r- G  _1 }2 e! p5 l
  404.   def trigger(key)
    & e$ g  z9 e. `- ~: g
  405.     return true if sion_mouse_trigger(key)
    ' }) F. Z3 M4 ]& V; F
  406.     return Mouse.trigger(0x01) if key == C4 N' i7 [9 S6 \
  407.     return Mouse.trigger(0x02) if key == B* a  y9 ]! q/ C, u
  408.     return false
    , e# l" {* U% T1 _$ S. p
  409.   end% T, `" _1 @' t; n
  410.   #--------------------------------------------------------------------------
    7 `( f" u# k1 X
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true2 o: q% L  A* p2 D% _# K' X
  412.   #--------------------------------------------------------------------------
    ' j1 @( |; u, F# _& r  q
  413.   def repeat(key)9 f: E. b% C& F5 w9 F& D
  414.     return true if sion_mouse_repeat(key)& T+ @4 y# U3 e+ [' n) u9 D
  415.     return Mouse.repeat(0x01) if key == C
    4 K* {1 g2 R/ F; e+ {) I
  416.     return Mouse.repeat(0x02) if key == B
      Z% A7 x: O9 a3 i4 W
  417.     return false
    " Q& }! k; U; q9 P3 u# [4 @# v* w
  418.   end
    ( _" Q2 R" R2 F. h6 M& _
  419. end6 a  j% \; Q$ Q  \# h3 \

  420. * K4 ~  O4 |3 y& J. i6 D- z) {
  421. 3 ^& d' z  `$ A+ Q% Q! N
  422. #==============================================================================
    / l0 O" m$ D& [3 L* e' S
  423. # ■ Window_Selectable
    ) Y) C0 [% e# g, l3 W, J
  424. #------------------------------------------------------------------------------
    - S! W8 ^- j7 @. _
  425. #  拥有光标移动、滚动功能的窗口9 q. `) x' ?, `( a1 v" L
  426. #==============================================================================, N8 [3 O1 _! V0 M. V- c  y) ~
  427. class Window_Selectable  F3 q1 s6 {8 i. G
  428.   #--------------------------------------------------------------------------
    9 L# d8 W& Q- S4 G9 c3 k$ N8 f6 g
  429.   # ● 初始化
    9 g" Y# l) {, j( x
  430.   #--------------------------------------------------------------------------, s! S- ?, p0 H. _6 x
  431.   alias sion_mouse_initialize initialize
    $ _0 |- @8 ]2 B# n5 D
  432.   def initialize(x, y, width, height)' q9 j) W' c% a4 `
  433.     sion_mouse_initialize(x, y, width, height)$ ?" V/ o  {- M* k: e9 U
  434.     @move_state = 05 L# E3 i; a& \
  435.   end5 {) |' R9 k4 L: {3 A% m' o+ k
  436.   #--------------------------------------------------------------------------
    ) o3 W3 j) m3 G3 `) G
  437.   # ● 更新
    : t1 y1 z" v. g, P# R9 z
  438.   #--------------------------------------------------------------------------3 h, N' @- P" p2 z
  439.   alias sion_mouse_update update
    " y2 R/ `+ s7 w& H
  440.   def update* c/ u+ O3 }; [( L- D8 A
  441.     sion_mouse_update0 l( ?7 B  e7 e2 F
  442.     update_mouse_cursor3 p2 q2 U1 P3 W$ v6 ?' O* O
  443.   end& H1 E. A$ G, O8 G* M# J& m
  444.   #--------------------------------------------------------------------------# L  A& b% I  }) r8 P
  445.   # ● 启动后设置鼠标到index位置, Q& d. K- i  H' T3 ~# n: ?; f
  446.   #--------------------------------------------------------------------------% p& }2 V, q( S% W+ b8 ^3 F$ t
  447.   def activate: @9 L  D, ~5 a) b' T) b% |
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    5 ]8 i5 ?; |* F5 g7 N) q( v
  449.     super
    $ U7 q8 I1 I% h0 y, X/ e
  450.   end
    % _. g" t# G7 Z# J
  451.   #--------------------------------------------------------------------------' x/ i% v; ^- N% k) v
  452.   # ● 更新鼠标和光标的位置. @5 d# c9 c! Z! R( ^
  453.   #--------------------------------------------------------------------------3 t: ]9 n0 j1 \4 x8 ~0 ^4 a
  454.   def update_mouse_cursor
    7 k2 f: V9 q0 ^* I0 j
  455.     if active
    3 }5 y* {0 h2 W2 P
  456.       if @need_set_pos
    ! Z6 J& J+ N8 o, i/ ]3 H; u5 A* d
  457.         @need_set_pos = nil2 }, q; B; D  w& X% Y2 a$ i% G
  458.         set_mouse_pos
    ! w8 u4 P& ]# L, o
  459.       elsif cursor_movable" O/ M6 q# T1 K+ Q% f1 [
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    ! j* l  H0 o& V
  461.       end
    2 E5 u" J% W: U9 Q
  462.     end
    , p1 N8 V$ E' R6 t7 x9 i
  463.   end
    9 y! T5 d$ ]! h/ y
  464.   #--------------------------------------------------------------------------# w; b: M2 i; |' k; Z) p
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    ; U, |" e8 i6 ]. `& u; i/ J3 o) y
  466.   #--------------------------------------------------------------------------
    " i% V& X2 G8 {7 \' u& ]3 I+ I
  467.   def set_cursor. ]8 u" j. W. U
  468.     mouse_row, mouse_col = mouse_window_area
    ! H# g5 O4 A! O4 F$ x' y
  469.     if    mouse_row == -16 |( B" ^" |$ y' j. X9 k
  470.       @move_state += 1 if need_scroll; S# I' M) p' n. Q2 L3 n$ h
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand8 g3 u  A4 V2 G0 S4 {
  472.     elsif mouse_row == -2
    2 V; ]  Y8 ?5 W% L; C
  473.       @move_state += 1 if need_scroll
    * k2 _3 Y( N. N* o, h. ^: A
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ' y3 w; ~1 ?* k% q% V' @! I, Q5 w
  475.     elsif mouse_col == -1
    + L% G! ]8 l# a2 {. {
  476.       @move_state += 1 if need_scroll2 ?" B8 w( \4 O9 {
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    & l! ]6 Q/ b0 T- v  T9 n& v5 U( V" S; n4 p
  478.     elsif mouse_col == -2
    3 {9 n1 E3 G5 \5 _4 m
  479.       @move_state += 1 if need_scroll
    - x: \, n: B, F2 M' @
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    8 E! t/ K% D- o$ q  {$ a) |
  481.     else
    , ~- c% j8 ]6 i& Q
  482.       @move_state = 00 H% U9 f6 `: ?8 f9 C7 {
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col2 C2 b# A$ b; t2 W- K6 ]
  484.       select(new_index) if new_index  item_max && new_index != @index- U& `5 ^3 Z1 S+ P8 p5 M$ l7 z
  485.     end6 J0 F3 I1 [" g( p$ n& D7 n
  486.   end
    2 u! I' M3 e7 ^* O# u
  487.   #--------------------------------------------------------------------------
    6 \# P0 v- D$ a" v
  488.   # ● 判断鼠标位于菜单的第几行、第几列+ ?. q$ _4 ^6 _: t5 l+ j- {
  489.   #--------------------------------------------------------------------------
    ' M* [' ~* ^$ G7 n; a% }+ N
  490.   def mouse_window_area. j' w& X% c- k$ b, R) H
  491.     if viewport.nil # necessary!$ J/ Y8 H1 t, [# d# r8 U$ x' t' X% r
  492.       vp_x, vp_y = 0, 05 d1 C5 o; r* R$ t, w
  493.     else2 D# h% I5 z6 V& j" I9 E0 B
  494.       vp_x = viewport.rect.x - viewport.ox
    & _) d% U3 a; E* m* y! S
  495.       vp_y = viewport.rect.y - viewport.oy. G- J4 ]+ @/ z( _" G/ U$ ^
  496.     end0 l7 L+ }- n# b  V5 m, u& `
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y& i7 Q- L$ u3 j; x6 K& `
  498.     item_x1 = vp_x + x + standard_padding
    & W, g( M' P/ @/ W
  499.     item_y1 = vp_y + y + standard_padding# Y' r+ z! L( |$ h
  500.     item_x2 = vp_x + x - standard_padding + width2 o, d! S1 ^4 ?4 q% L$ ?  h
  501.     item_y2 = vp_y + y - standard_padding + height
    + O; |" L: ]! v7 a6 u/ p
  502.     if mouse_x  item_x1
    6 P1 a# ~5 \3 ^9 {1 p. R2 U
  503.       mouse_col = -19 u8 Y9 p6 b! X$ C( j& ^
  504.     elsif mouse_x  item_x2( h9 h1 q- L9 g! S
  505.       mouse_col = -2
    # y7 I& w0 r' U/ w/ r6 E! ?
  506.     else/ I' T# p3 G- n8 a) o4 ~) B
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    , A- j* m1 a5 U( ^. `7 h! n
  508.     end
    , N; ~$ X' c) ^5 p" i2 ?9 u& [9 q
  509.     if mouse_y  item_y18 P/ U4 g* u7 s9 |
  510.       mouse_row = -15 r" T4 f* a. Q, ?5 i. V+ Y
  511.     elsif mouse_y  item_y23 U$ i8 ^) a; P
  512.       mouse_row = -2; d. K: Z3 Z8 A8 \3 E
  513.     else
    1 P8 x4 t8 u& Y" n, ]
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    * {, m7 D; P; c
  515.     end4 g  D$ b7 v" ^! w
  516.     return mouse_row, mouse_col
    ' G1 y7 O7 M1 x8 a: t# g/ L& N
  517.   end
    - `& x- I& h% O' ^4 [  P7 h! c& E/ X, Y
  518.   #--------------------------------------------------------------------------
    0 p' v/ _- P- d2 T1 S
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    / }! Y1 h! l' I( A' y. m. T0 v
  520.   #--------------------------------------------------------------------------" x; d5 J) O6 p2 s2 k
  521.   def set_mouse_pos2 C# P* B5 t$ ?; r9 I/ w" |$ M
  522.     if viewport.nil # necessary!
    8 L& ?& X# `  N$ n3 E
  523.       vp_x, vp_y = 0, 0
      y* w, c6 O  `2 J! `  U0 Q
  524.     else
    / {7 C) n7 |0 U5 L+ }
  525.       vp_x = viewport.rect.x - viewport.ox/ W7 ]: a3 n# [  ?% g+ J
  526.       vp_y = viewport.rect.y - viewport.oy9 x" E! o% L  b8 ^& Q
  527.     end. Y- S2 X/ [' ^) g' y* f
  528.     item_x1 = vp_x + x + standard_padding
    . N  e$ ^+ `$ f$ H
  529.     item_y1 = vp_y + y + standard_padding, x! |" \- Y7 G' `5 H+ ^+ a
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    % `, \! ], o0 Y+ Y# s
  531.     row = get_index  col_max - top_row" N+ @8 t" B" n0 N. ]. K' o. j
  532.     col = get_index % col_max1 z9 {; M! H! ^! U7 P
  533.     new_x = item_x1 + item_width  (col + 0.5)
    3 w3 Q. k2 [! }' e1 [
  534.     new_y = item_y1 + item_height  (row + 0.5)
    ; Q, m5 N! E& }! ~
  535.     Mouse.set_mouse_pos(new_x, new_y)( A* s! l' {4 E8 c
  536.   end* n5 N' G" p0 z4 u! y; R
  537.   #--------------------------------------------------------------------------9 E# J5 E' s1 G3 q/ i" A
  538.   # ● 判断菜单是否需要卷动
    0 u4 ~, `* i/ p' q7 T1 o
  539.   #--------------------------------------------------------------------------
    6 m( N4 D% u) K) y/ I
  540.   def need_scroll
    ( N: J% t: I3 W
  541.     item_max  col_max  page_row_max# F, `2 X7 p. N0 E0 |  w  _, K' z7 N% q
  542.   end+ J- |2 F, B- A; n7 q6 e
  543.   #--------------------------------------------------------------------------
    2 i1 W$ a* ^+ J( O9 {: Z4 N) \
  544.   # ● 判断是否为水平卷动菜单
    / [) A; j' H6 k& b  l2 d/ g
  545.   #--------------------------------------------------------------------------
    & f& b0 `# \' x- B  w
  546.   def is_horzcommand
    . f7 _0 D9 I/ Q7 g* U8 c5 @: n
  547.     return false
    2 ^3 W0 l5 V3 D. @4 H" |: i; U
  548.   end
    0 \& ?7 c- R4 y6 g& e& R
  549. end4 k8 b, M9 s" N+ I( O0 ?
  550. 1 g% P0 X( A: l- P
  551. class Window_HorzCommand! `( @8 Z2 e+ R5 [$ \6 X
  552.   #--------------------------------------------------------------------------1 t# e6 \) g( O# @2 @9 L$ m- x
  553.   # ● 判断是否为水平卷动菜单
    4 M9 X% B) s% _
  554.   #--------------------------------------------------------------------------
    6 z6 ^7 V, X* v  I
  555.   def is_horzcommand8 x8 o! z. l8 S
  556.     return true
    ( j: A0 x3 ^, X0 N+ h  ^5 V
  557.   end8 w6 A4 c8 W* e
  558. end
    + F) }% u6 }$ {. ], {. a8 @
  559. 4 \& k+ L/ i1 g% n
  560. #==============================================================================
    6 i  z0 R/ D2 @( l/ E! r$ u
  561. # ■ Window_NameInput
    ) _4 G  l0 o! f7 n7 G; L7 P
  562. #------------------------------------------------------------------------------
      O2 \- w. w) x( R! s3 U& G
  563. #  名字输入画面中,选择文字的窗口。! B) u# O1 Z- Z. `( o
  564. #==============================================================================
    ( z: I) X; o. A) Z  T  X
  565. class Window_NameInput& L  g) W3 H; U. w& B0 L
  566.   #--------------------------------------------------------------------------# Q! d( N" _" b. |
  567.   # ● 设置列数
    1 T  h4 D: \9 T) R5 F" h
  568.   #--------------------------------------------------------------------------2 r( K  p" b: X
  569.   def col_max
    . Y: P( N: T7 y$ J* S: ]+ }* w8 u
  570.     return 10
    # v) o3 b: }/ _0 I
  571.   end
    ) U2 ^7 W/ G6 X# Y" N: O8 Z
  572.   #--------------------------------------------------------------------------2 x; l' _# ]+ ]3 c" {% A
  573.   # ● 设置填充的Item个数
    * v. [5 V/ k- f& u& k  i  x
  574.   #--------------------------------------------------------------------------" y- [' u& }4 t( i) j5 w7 n7 N
  575.   def item_max
    1 M0 _4 @1 M4 }- d4 O* Y8 x
  576.     return 90
    0 T6 K) T0 @' U1 v/ b0 X9 H
  577.   end
    6 w1 U$ y0 ]( c! a1 p
  578.   #--------------------------------------------------------------------------
    $ `% c  |) n$ J/ j4 F2 M
  579.   # ● 设置填充的Item个数6 g  x) H9 L+ w+ C1 T& K/ \* F, O
  580.   #--------------------------------------------------------------------------
    % z' w3 W( Q* ]! V; e1 v$ v
  581.   def item_width
    2 B: `" |& @$ m1 }- J" p) K
  582.     return 32" S5 @, b7 x- B, k
  583.   end& N" u7 x) o0 ?
  584.   #--------------------------------------------------------------------------; g* s- }9 T1 d# }: A& D( K6 }
  585.   # ● 判断鼠标位于菜单的第几行、第几列; j: O9 F. N" s  F" z" Q. o" L1 I
  586.   #--------------------------------------------------------------------------& n: }5 e# o+ V
  587.   def mouse_window_area8 d3 G" `2 h" x& y
  588.     if viewport.nil
    ! m! `1 i3 ^, n
  589.       vp_x, vp_y = 0, 0) O# m! C& D8 N
  590.     else+ j1 A* L  {. H' R
  591.       vp_x = viewport.rect.x - viewport.ox
    - V# m  Z% \: {& J, i
  592.       vp_y = viewport.rect.y - viewport.oy
    1 `* p; e- W9 U$ C
  593.     end
    5 s6 Z- O+ @  @+ x9 p7 Q
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    % V- n) t: W: b
  595.     item_x1 = vp_x + x + standard_padding
    3 m4 y4 p: ?" D" l3 R0 f& ?; @
  596.     item_y1 = vp_y + y + standard_padding7 w& _: F% C$ Q
  597.     item_x2 = vp_x + x - standard_padding + width
    ! Z7 o2 V, w8 L7 C* i" T
  598.     item_y2 = vp_y + y - standard_padding + height8 y3 _+ W2 c- R8 v
  599.     if mouse_x  item_x1" l0 L: z# h# q3 `& E( z* u( w
  600.       mouse_col = -1
    6 z) @) L$ R: J2 ^
  601.     elsif mouse_x  item_x2, N* i8 h* ~* e4 L
  602.       mouse_col = -2' C3 _) r8 p9 \' E# w4 `5 S* \
  603.     elsif mouse_x  item_x1 + 160; c9 }% x# h; x( `/ e) D( l
  604.       mouse_col = (mouse_x - item_x1)32
    , s: V8 Y3 T7 {8 z& B! V
  605.     elsif mouse_x  item_x2 - 160
    0 u: r: ^7 A4 t
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    ! C2 b% P6 M; S# _
  607.     else
      x4 P& ]+ x. t, ~" z; _; Q
  608.       mouse_col = mouse_x  x + width2  5  4; V+ Q9 [0 m, B* l9 x6 r
  609.     end
    4 j# f: M/ N1 O$ O! J8 a7 Q' G; O
  610.     if mouse_y  item_y1
    1 x* C  \* S7 B* Q. S8 h& `' J
  611.       mouse_row = -1
    7 u3 v( `4 B$ r% Z( L- ]
  612.     elsif mouse_y  item_y2
    & j0 c) ~; P/ d
  613.       mouse_row = -2
    2 e! }* f0 \7 N% o/ D& l8 n8 I
  614.     else
    1 \6 [4 ^* e4 R5 T/ F
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)6 J" E( S$ s; N, _' @# k: W
  616.     end5 ?; ^. B( D, K8 G0 ~1 ~9 ?
  617.     return mouse_row, mouse_col/ U+ {9 o5 ^9 A, R2 n
  618.   end) D8 i% w# g8 k- S
  619.   #--------------------------------------------------------------------------
    ) K4 a: _( c5 G; T8 m
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置4 l' s+ Z* W; s# e& k" b
  621.   #--------------------------------------------------------------------------
    4 o& W, h0 X1 X
  622.   def set_mouse_pos% s, _* H- b3 r0 Q" e7 c
  623.     if viewport.nil # necessary!
    $ @8 J/ S0 q9 G( _, c/ H
  624.       vp_x, vp_y = 0, 0
    6 `( W: Y7 ]3 h. U
  625.     else0 d1 Q# u9 C; X$ i  }
  626.       vp_x = viewport.rect.x - viewport.ox6 G4 G' k2 r) _3 _* `1 U7 d6 L
  627.       vp_y = viewport.rect.y - viewport.oy
    * W# {  \( U! ~7 _1 O% j
  628.     end7 x+ p/ u* f3 A  w$ F5 w
  629.     item_x1 = vp_x + x + standard_padding 8 S7 b$ m& D0 _0 C; u
  630.     item_y1 = vp_y + y + standard_padding
    0 _, z" c3 T3 n
  631.     get_index = @index  0  0  @index 7 {2 N/ K2 {; v0 V
  632.     row = get_index  col_max - top_row* e1 ^. b3 U; }0 C1 K; v2 o) F
  633.     col = get_index % col_max6 `5 `% t9 {7 R2 n  D7 y) F) a
  634.     new_x = item_x1 + item_width  (col + 0.5)
    & |6 g9 i# \/ y4 C' j7 G
  635.     new_y = item_y1 + item_height  (row + 0.5)( h1 b% f$ j) P' B  _6 |
  636.     new_x += 14 if col  4
    / @/ o1 {0 b! I0 y; o, u% p
  637.     Mouse.set_mouse_pos(new_x, new_y); O2 k3 i8 V7 ^& [, {
  638.   end
    8 E: Z0 e; `) Z- @
  639. end$ e$ K) D; Q* B- ^( \" x- j! u) ^. Z

  640. 2 H5 z$ b% i( B
  641. #==============================================================================
    1 l3 H" U3 b( U8 [* x6 K; z' x
  642. # ■ Window_NumberInput
    % b5 p* h6 M: o6 g. Y" q
  643. #------------------------------------------------------------------------------  E' ~' F9 [" s8 F
  644. #  重写了数值输入的方法以适应鼠标) e; v+ }3 f4 S5 R+ G. Q4 j1 t
  645. #==============================================================================# d$ g% n& f5 f4 F2 P4 n% B
  646. class Window_NumberInput  Window_Base
    . a8 Q; q  X4 c2 B: Q
  647.   #--------------------------------------------------------------------------! l9 K  {0 W& x/ @' w2 ?
  648.   # ● 定义实例变量
    7 L6 E7 B' M: z  u
  649.   #--------------------------------------------------------------------------- {- n! D5 B6 h" u
  650.   attr_reader extra_window
    7 V& z% Y! T: a: H
  651.   #--------------------------------------------------------------------------- e3 I5 n' v) b; I* j& W- `9 q1 g
  652.   # ● 初始化
    1 H! }: }% \" i0 Y/ o" F5 z/ k
  653.   #--------------------------------------------------------------------------
    " d0 n. u& e5 \8 I/ d1 p
  654.   alias sion_mouse_initialize initialize
    1 L0 q) S7 l0 q5 V! @% m8 C
  655.   def initialize(arg)
    + n1 F" u- {4 F8 L
  656.     sion_mouse_initialize(arg)) o* e; ^) h( Y' J7 Z  B/ c. y0 b
  657.     create_extra_window$ [; m( H9 g! _0 P5 [: c' Y; b/ Q
  658.   end
    / e0 E' k  B- M( Z
  659.   #--------------------------------------------------------------------------  @+ O! B- [$ d' Q) g, x
  660.   # ● 启动: b, S8 i$ u9 h1 F0 v0 v" P
  661.   #--------------------------------------------------------------------------' _9 ?( K+ h7 Q0 y8 B7 a
  662.   alias sion_mouse_start start
    1 x$ K+ i9 h" g( P, M/ Z
  663.   def start
    : u3 D/ J/ a8 z# t4 @
  664.     sion_mouse_start
    % @# T) @  V- o" o& d* N. u8 X+ l1 D
  665.     deactivate
    0 P4 ]. T9 S: s) N* w# g
  666.     extra_start
    % x5 P; a% d$ J
  667.   end- F: Y5 _; G8 `6 @* F+ x. [8 I5 G: z, w
  668.   #--------------------------------------------------------------------------0 L; v8 u. r& y  J
  669.   # ● 创建新的数值输入窗口
    1 G+ Y. q. p3 ]2 s) c
  670.   #--------------------------------------------------------------------------
    & J1 c6 L4 W6 U; `  Z. U* Q* A
  671.   def create_extra_window2 C) b( ?9 K2 A+ @9 Z2 |) M
  672.     @extra_window = Window_NumberInput_Ex.new0 \9 U* {: t5 `& C5 y* R
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2/ C' A7 s+ R% }; x2 S* r
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }* @' m  A+ B! R- ]! k7 f) H6 m0 z$ `
  675.     @extra_window.index_proc   = Proc.new {n @index = n }/ v4 y/ c# f4 P8 e+ H9 Q
  676.     @extra_window.close_proc   = Proc.new { close }
    $ P  `4 [6 ?$ ]8 C# D* y  w1 F+ p
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    1 i* O: l. ?5 `+ c) o9 x1 p
  678.   end
    , x6 N3 `  ^5 G' b
  679.   #--------------------------------------------------------------------------  Y6 e8 Y( }) z9 _1 J! i5 \
  680.   # ● 激活新窗口
    & I1 g6 q7 ]$ k/ h0 W& v% H; i. v6 G
  681.   #--------------------------------------------------------------------------
    & b* O& V2 A8 {) G; ^
  682.   def extra_start
    ( A& ~& ^$ Y& k! C' w+ d, F
  683.     case $game_message.position. _& _6 g* [4 `! r: e0 U
  684.       when 0; @extra_window.y = y + height + 4) r6 u6 a8 G' |5 B9 s+ C  U7 e3 [
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8+ c$ x- {/ f' @. B) N
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    , p+ _) s* x. s! w: H
  687.       else  ; @extra_window.y = 8
    6 V+ ~" C  A9 R8 Z
  688.     end2 X5 Z; i* r: `+ [, B
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    0 {) g0 v0 u$ D1 K! J6 u  O. Y& v
  690.     @extra_window.digits_max  = @digits_max
      p" v( G3 ?( Z4 Y% B! r
  691.     @extra_window.number      = @number
    & V6 A# z; O7 g9 J& G
  692.     @extra_window.open5 P8 E& O/ o' y% T) X
  693.     @extra_window.activate  ^+ U/ D) ~! y! j- R& K: c/ R
  694.   end
    ( ?8 m8 f! R" [  L/ H: y0 q
  695.   #--------------------------------------------------------------------------
    ( R, J$ v9 L! f) \8 T# H2 W! q
  696.   # ● 更新5 d; f% V0 _% j7 y1 R3 |5 B
  697.   #--------------------------------------------------------------------------
    3 L, ^( P( j- U: \# T
  698.   def update
    / R( I# b- h; O
  699.     super) N3 G3 E: K7 e  O0 w5 K' ~
  700.     @extra_window.update
    * n* F$ E3 W/ @' o
  701.     update_cursor7 V2 T" {& ^' z
  702.   end7 U4 ^2 W+ N; p  @9 f
  703.   #--------------------------------------------------------------------------! b8 I& _( c2 V
  704.   # ● 关闭窗口
    . W7 V' U+ Z( }
  705.   #--------------------------------------------------------------------------; n5 r8 B. m: D2 U3 }) x
  706.   def close$ \# B/ A5 b, U
  707.     super
    4 A' m& E2 c; M. G7 R9 z. f
  708.     @extra_window.close+ D6 y6 g3 a8 [* O
  709.     @extra_window.deactivate
    / v+ O6 U% l2 b8 ~0 S3 D* N
  710.   end% g3 u  r7 T3 D& g9 [8 w4 d. O
  711. end
    3 F- ^  l# ]. l9 |$ D
  712. 6 w2 `$ U6 @0 R& u
  713. #==============================================================================
    6 m; ?8 s- T% K, Q3 O) N4 u
  714. # ■ Window_NumberInput_Ex; V% N5 z3 D" C% Q! Q1 p
  715. #------------------------------------------------------------------------------$ G' O) L1 i1 ]$ {
  716. #  新的数值输入窗口(NewClass)
    7 @: ?- V, f; e5 u* l! ?0 k
  717. #==============================================================================
    % I$ L6 C+ L- k3 n! m$ o/ A. ]
  718. class Window_NumberInput_Ex  Window_Selectable
    0 X+ t, x  I4 J/ A7 ]
  719.   #--------------------------------------------------------------------------6 t& |; }( ^2 j  Z  U
  720.   # ● 定义实例变量6 f, H& F5 G: [; g/ n7 }) \: d
  721.   #--------------------------------------------------------------------------
    ) F+ ~4 {9 _1 q
  722.   attr_accessor number_proc
    ! r6 q- ?7 e2 q
  723.   attr_accessor index_proc
    ' t( r! Q! i1 c/ b1 n
  724.   attr_accessor close_proc8 U( s+ F) ^+ K* h5 }+ e' {/ J# e, z: p
  725.   attr_accessor refresh_proc# J6 h* ]& H6 ?0 k% t
  726.   attr_accessor number
    8 T  y% T$ Q; R0 Z% i
  727.   attr_accessor digits_max# V" y* W+ }. x1 _# m- V3 O
  728.   attr_accessor variable_id; f! Y; t$ x9 u0 x* `4 g& t; u* h( K
  729.   #--------------------------------------------------------------------------/ |0 `; t/ K. q: ]
  730.   # ● 数字表* a/ I( F9 d: w( [, H5 r
  731.   #--------------------------------------------------------------------------. V3 d( ~. Y  k& Z- a
  732.   TABLE = [  7,  8,  9,
    1 b2 H* I' S- f4 s
  733.              4,  5,  6,
    # z' \: G3 b) j1 e" ?% {0 a
  734.              1,  2,  3,
    : @% m$ Z6 K7 i' O  c2 v
  735.             '←',0,'确定',]
    $ p7 j; O9 c: t9 s) Y; Y  W" f
  736.   #--------------------------------------------------------------------------
    , V9 s; j. ?* l) y6 O
  737.   # ● 初始化对象. r5 t8 V$ b% y& P! f
  738.   #--------------------------------------------------------------------------7 u/ {8 H& N$ r5 {0 p
  739.   def initialize
    ! e# L  C: a4 g5 F
  740.     super(0, 0, 120, fitting_height(4))
    ) v' i+ x0 |0 V6 `7 t
  741.     self.openness = 0
    ; a$ {. r. A' K$ p$ T/ G7 [
  742.     @index = 0* b% f& w5 B" ]' G# q
  743.     @number = 08 k6 b+ ~+ n, ^' p
  744.     @old_window_index = 0
    ) R8 V* F' I6 i# W6 G
  745.     @digits_max = 0' @6 U  m3 G& ^# B$ Y8 o: U
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }4 _, e- D. E% Z4 d: D7 q6 K" m
  747.   end3 v% N3 q" t! u; q$ S
  748.   #--------------------------------------------------------------------------( c8 o8 }) }+ g- W; _
  749.   # ● 获取项目的绘制矩形
    % ?3 \; s! [( q4 x6 U- r( ]1 M: U
  750.   #--------------------------------------------------------------------------6 L( f2 X1 r; z* p8 X
  751.   def item_rect(index)4 J- l6 j$ ~+ D. `
  752.     rect = Rect.new9 ^% U$ N$ f2 H+ ~* X+ U
  753.     rect.x = index % 3  32/ I4 w' l% A3 E! h1 a" @) A
  754.     rect.y = index  3  line_height% j- w( |8 Y/ a/ I+ I! a  {2 f3 ]% r
  755.     rect.width = 326 k+ O0 Q$ i+ v! Y+ m+ m
  756.     rect.height = line_height
    , X3 h- B: g$ X& f7 T
  757.     return rect1 Q0 n/ R3 s" v; \- k
  758.   end
    7 ]- ]6 p) m0 i6 e9 D! y; T4 U, I
  759.   #--------------------------------------------------------------------------
    , X3 u# V1 p6 ]" s: C
  760.   # ● 将光标设置到鼠标所在的位置6 i0 G9 _! V6 a; _( p7 T2 O
  761.   #--------------------------------------------------------------------------0 O, J- ?+ k6 }. ~
  762.   def set_cursor6 m/ Q/ o! k' r& P9 H
  763.     mouse_row, mouse_col = mouse_window_area4 C% v  d0 ~' c
  764.     if mouse_row = 0 && mouse_col = 08 {0 v+ n% O" r4 H% T
  765.       new_index = mouse_row  3 + mouse_col8 p7 K$ {( ]9 a5 f+ X% `
  766.       select(new_index) if new_index = 111 ^, ?0 [; |1 u( c7 n
  767.     end) j+ \* U' n+ \3 [
  768.   end
    8 W0 M1 I/ t+ h3 X* q6 b
  769.   #--------------------------------------------------------------------------. j) r: h0 O0 D" L+ l' `
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    ; M& t4 q% L9 R7 L
  771.   #--------------------------------------------------------------------------
    3 Y: C3 \0 f6 a+ |4 u. P; Z2 y- W
  772.   def mouse_window_area/ x" y% Y) J7 S8 J7 y
  773.     if viewport.nil( p' j: F+ C8 x' i8 `6 Q  A( [
  774.       vp_x, vp_y = 0, 0
    $ E& S" U1 s8 f) g. [% C  x, H; F" d# O
  775.     else# D1 B% u* i% `* e8 F
  776.       vp_x = viewport.rect.x - viewport.ox
      h% L8 @5 q: v' n
  777.       vp_y = viewport.rect.y - viewport.oy
    9 ~; |9 H, Q9 P- x; A
  778.     end
    " h$ W9 x, L* j) ^! S/ U& V
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y$ q+ J/ C) f- L( s# w
  780.     item_x1 = vp_x + x + standard_padding 8 Z3 ~% u7 h/ g1 X% g! H
  781.     item_y1 = vp_y + y + standard_padding8 @2 r: V: B8 d9 A" ?$ }
  782.     item_x2 = vp_x + x - standard_padding + width
    , v$ I6 V/ g0 q# t9 M
  783.     item_y2 = vp_y + y - standard_padding + height/ Q& O% H# r0 D# x4 h
  784.     if mouse_x  item_x1& L8 y8 C8 H! V; e4 d/ V4 M4 i
  785.       mouse_col = -13 e5 @8 S5 O) J! g! w
  786.     elsif mouse_x  item_x2
    % V3 b4 d1 Q! q; Z; R, F7 }
  787.       mouse_col = -2
    ) }! B* X; O/ J. v
  788.     else
    & F, J+ N1 d, C* f
  789.       mouse_col = (mouse_x - item_x1)  32) {, D7 J# Q# Q8 r' G
  790.     end
    * s" P1 G# n' r: I7 ~! K
  791.     if mouse_y  item_y1- ^- G! p6 M$ a4 ?$ K3 N1 _5 J
  792.       mouse_row = -1
    + w6 d" H; V" x& s
  793.     elsif mouse_y  item_y2
    , H. F" J& j* g. A  Z! Z
  794.       mouse_row = -2
    1 G% R1 A3 ]) o  K
  795.     else9 U+ q1 o8 U3 N' [8 `2 a/ U
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    6 ~9 c: n- j. \9 W( F. i
  797.     end, F# I3 q% s, U0 k5 f3 Y
  798.     return mouse_row, mouse_col3 f- L' ?# A' a: C
  799.   end
    - }9 X; Q( b7 W, h, |$ f4 I5 i/ I
  800.   #--------------------------------------------------------------------------
    8 d# K3 N4 _" A( ^6 R5 o+ i
  801.   # ● 获取文字
      e8 q4 n& F' J& F
  802.   #--------------------------------------------------------------------------
    4 I% C9 z( X; i6 x5 i& Q
  803.   def get_number7 w3 W. `1 F$ t3 \  A
  804.     return false if @index == 9  @index == 115 `4 D. Q; n* S- P0 a0 v/ h4 a/ J
  805.     return TABLE[@index]9 ], n" H. `1 [  I( I4 Z9 I
  806.   end
    ! n  e( x( G% b- s+ h
  807.   #--------------------------------------------------------------------------: W2 R) h% `. r% s
  808.   # ● 判定光标位置是否在“退格”上
    & P; ?5 s* j4 `- [8 Q
  809.   #--------------------------------------------------------------------------
    ! t; Y( c: x1 H; m+ L
  810.   def is_delete
    - b; o- V" l3 l2 ~
  811.     @index == 9
    1 |* M. d/ k# s  h1 C
  812.   end
    " A6 w8 ^+ _7 p% n( x8 ]3 Y
  813.   #--------------------------------------------------------------------------, I$ J/ Y9 b1 |3 i6 Y
  814.   # ● 判定光标位置是否在“确定”上
    6 r% d0 i" P0 j' [8 n
  815.   #--------------------------------------------------------------------------- F, ~3 @0 Q8 s# m3 R  U) z
  816.   def is_ok
    6 w% d& G# q/ @# O
  817.     @index == 11
    & V4 @) x& r: Q/ G" f6 m
  818.   end
    # B7 P4 A9 a/ P9 a9 Y
  819.   #--------------------------------------------------------------------------' C- U  A5 ]* }2 k  M
  820.   # ● 更新光标# |+ H: t5 ?0 k1 b9 z7 Y
  821.   #--------------------------------------------------------------------------
    . D; b! P7 W/ ^
  822.   def update_cursor% S5 G" c/ \( d3 J
  823.     cursor_rect.set(item_rect(@index))
    ( y2 s) m& H) B
  824.   end) k( X) [$ |3 d& G0 h
  825.   #--------------------------------------------------------------------------
    " |* m6 J# Q. L1 g9 _! m: W5 b
  826.   # ● 判定光标是否可以移动
    $ I( ]$ a9 ?$ G2 H
  827.   #--------------------------------------------------------------------------
    ) i7 [  x! G/ d5 {
  828.   def cursor_movable
    # T' d4 j8 u* |& l2 b! r
  829.     active
    ! z/ ]/ L: K1 O# L
  830.   end
    $ y6 F) X% @& M9 U7 a3 g9 ~  R
  831.   #--------------------------------------------------------------------------( U0 s( A/ D/ B) w
  832.   # ● 光标向下移动7 [. y6 w' ]# o9 ~& G  F$ U, d
  833.   #     wrap  允许循环2 l. S/ P2 `$ e7 T/ O; ~( n+ l9 k  A5 `
  834.   #--------------------------------------------------------------------------
    8 K! @% u, w) g; S6 t
  835.   def cursor_down(wrap)
    ; X1 u6 t& V! [  a0 F
  836.     if @index  9 or wrap4 U3 p* |3 [2 \% X* r. Q* F$ Z
  837.       @index = (index + 3) % 128 }5 @( W5 t, ]# U* |& `' ^. h
  838.     end" e/ \' i: u0 B8 U
  839.   end% c, B4 C5 r6 `
  840.   #--------------------------------------------------------------------------  e" F) E5 U5 H3 u% n; h
  841.   # ● 光标向上移动
    $ w$ m6 N* |+ u( u. I* A$ Q
  842.   #     wrap  允许循环, n9 U% k0 u" |) S
  843.   #--------------------------------------------------------------------------6 N+ h" P* ?# K) R" S
  844.   def cursor_up(wrap)7 e+ T( Z5 r; g) M8 j
  845.     if @index = 3 or wrap
    9 a& r) y* d; |& j
  846.       @index = (index + 9) % 12
    5 [; r# ~1 H3 i/ a4 R5 p& L* W
  847.     end
    ; K# ^# Q% I! ~. O) A9 E9 j
  848.   end
    ; `7 N- o2 Y1 \  u0 e
  849.   #--------------------------------------------------------------------------
    7 A4 i1 I5 Q5 b% `4 @( x' h( n% u/ Q
  850.   # ● 光标向右移动
    0 q! r7 N( a3 H  c+ v5 A" p' I9 N
  851.   #     wrap  允许循环$ I' a7 ?9 K+ _( N: _/ W8 H' f! B
  852.   #--------------------------------------------------------------------------0 o- \' z  Z1 G! T0 S3 r* F$ b+ {
  853.   def cursor_right(wrap)
    , R; P3 U7 ^7 d, N- n1 O
  854.     if @index % 3  2
    ) M) d/ C; [( b7 D
  855.       @index += 1# w, j% V; e9 S6 E7 d
  856.     elsif wrap. e. g; }3 E  r/ S
  857.       @index -= 2
    ' w  |. {3 m. `$ q$ N4 ]  v" e9 S# x. ?
  858.     end9 L/ b& G+ o. [0 @
  859.   end) K' _! b1 M) S4 V3 K
  860.   #--------------------------------------------------------------------------
    - [$ @/ J6 X/ r
  861.   # ● 光标向左移动- F5 e$ f/ {0 _* d+ Z
  862.   #     wrap  允许循环8 I4 a5 Y- ~; X6 J) ~; T
  863.   #--------------------------------------------------------------------------
    * c. ^0 l  w3 a) D% }
  864.   def cursor_left(wrap)5 ?) ]8 g5 Y5 k6 \  B& ]
  865.     if @index % 3  0
    4 y- o; k4 |$ ~
  866.       @index -= 1! s5 u' V5 ]$ B9 D6 ]
  867.     elsif wrap
    ; `$ v4 X: |- X
  868.       @index += 2
    2 o# g. M" s  U; d
  869.     end! z3 c8 L, V1 n6 W3 W; f" c
  870.   end
    # X" j' o1 r' c8 |+ u7 R
  871.   #--------------------------------------------------------------------------2 u/ [- @6 z0 o- Z; X
  872.   # ● 处理光标的移动
    8 B) q1 g2 o1 Y' |! A5 a/ r
  873.   #--------------------------------------------------------------------------
    # H* b8 O# Z! g+ l9 w% h; j/ Z
  874.   def process_cursor_move
    # S( L8 j. {2 l( h. ^* W
  875.     super
    5 m( k  h' g! z9 h
  876.     update_cursor
    8 K% a; W3 `& t2 `8 N
  877.   end+ B7 F+ B5 ?2 o+ {+ Z
  878.   #--------------------------------------------------------------------------. b, ]8 B1 ?/ z
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    0 h# L" n) Y8 B
  880.   #--------------------------------------------------------------------------
    & h" `2 z' {% ^" x$ x
  881.   def process_handling3 l+ J* M+ I" n9 T6 l6 T7 H
  882.     return unless open && active+ a6 v6 Y/ }  e1 O
  883.     process_jump if Input.trigger(A)  Q, _+ l: T- W) M0 }& }! y- V4 r3 Z
  884.     process_back if Input.repeat(B)5 [$ K8 z' l. |7 U  P7 I( M: ~( i
  885.     process_ok   if Input.trigger(C). o. f* b6 }- ~9 y7 ]  X+ a' `. s
  886.   end! m. u% o1 f% b9 t
  887.   #--------------------------------------------------------------------------
    8 t  v6 v+ H- z( I. X( i
  888.   # ● 跳转“确定”
    # H. o. q# `5 k6 u3 T2 _1 n5 C
  889.   #--------------------------------------------------------------------------' j. {# ]- T" R! T
  890.   def process_jump1 j% `! K- O9 q, W6 \, |% P
  891.     if @index != 110 X. H( r$ K) H) G$ Q+ X
  892.       @index = 11
    + a% J+ r+ ?% b
  893.       Sound.play_cursor
    % v8 k. P" W1 z+ W" S- n
  894.     end
    , @9 I: A! W) j  p& V; d! M: A
  895.   end
    ! V5 a/ L; X1 v" a$ Q+ o
  896.   #--------------------------------------------------------------------------3 Q1 ?% ?( [. @
  897.   # ● 后退一个字符
    " K$ _; F6 A2 e, {: {/ j
  898.   #--------------------------------------------------------------------------
    4 X& P+ i& |7 }/ G. H& X; H- M( z
  899.   def process_back# t7 t9 Q* Q8 w! n; l
  900.     Sound.play_cancel9 R  l( I+ q, D
  901.     place = 10  (@digits_max - 1 - @old_window_index)- m* |7 F$ i1 n0 l+ R8 M% R
  902.     n = (@number  place) % 10
    # r: G  }8 Z0 _4 s$ `8 @7 E
  903.     @number -= n  place# l7 I, y. k' T( h* u
  904.     @number_proc.call(@number)0 Y  O! P5 S/ d7 k: Y3 j
  905.     @old_window_index -= 1 if @old_window_index  06 W: \! {6 p9 f. g
  906.     @index_proc.call(@old_window_index)1 n/ U/ H- K3 N- a2 Z
  907.     @refresh_proc.call
    # d9 e1 T$ R' G& J' t# k
  908.   end% r3 K( s3 W! l5 Z* `
  909.   #--------------------------------------------------------------------------
    9 R. Q8 P' {! }; g8 m
  910.   # ● 按下确定键时的处理
    $ l! C) y) D; C- `' k
  911.   #--------------------------------------------------------------------------% q" N& X! e$ V) T" H, v
  912.   def process_ok
    ! S, G: b9 U; y4 o4 V6 l
  913.     if get_number- I) U# \3 k9 w( z5 j* y
  914.       Sound.play_cursor
    - k, Q# w8 L, S7 q4 [: o4 s
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    " ?9 v- ~. _  _& K2 w
  916.       n = get_number - (@number  place) % 10
    ( w: f8 J) Z6 d% T- G8 q& V
  917.       @number += n  place2 @: ^8 Y) {3 R$ U, L% X
  918.       @number_proc.call(@number)# n/ |0 U/ v  Q3 f8 Y1 `+ K: ?, Z1 _
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1$ Q. w8 y# y( Y% @: w
  920.       @index_proc.call(@old_window_index)5 O  P+ X; C; |) x) R: L  X
  921.       @refresh_proc.call
    ; a" G7 U3 s# E4 R: [' f' I( e) x
  922.     elsif is_delete
    ' w5 @  v/ E  W& U: |/ j
  923.       process_back) o6 A8 c9 c. j2 e# w4 x
  924.     elsif is_ok# Q- A. n* j- Z* U( S3 J) C' u
  925.       on_input_ok2 j5 s2 J! v# P( M  A9 a
  926.     end8 M0 d6 a! c, R; J+ c
  927.   end
    - u: i1 R% Q3 v
  928.   #--------------------------------------------------------------------------
    0 G% q2 Z  ]1 |$ b3 |* e
  929.   # ● 确定& U0 L3 ?, |# L$ K" e) i7 z7 o
  930.   #--------------------------------------------------------------------------/ ]$ K" s. R# O' l. x8 q3 c; D
  931.   def on_input_ok
    ( p9 h' w; z# G( T
  932.     @index = 0
    ) r' S+ z& C; Z- c% f6 C/ K" p3 h
  933.     @old_window_index = 0
    + j: E! W  L  N" M; ~- o
  934.     $game_variables[@variable_id] = @number9 O3 ?0 [5 s7 p. p& S3 F; G
  935.     Sound.play_ok
    5 p: g, |6 f( @' d
  936.     @close_proc.call
    : O3 v( `0 t. v" }
  937.   end! o7 a4 ^1 i" v2 s7 Y
  938.   #--------------------------------------------------------------------------4 V0 L2 {; y5 V
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置) p% u( k9 M+ i. w0 C% b2 L# K% ?9 C
  940.   #--------------------------------------------------------------------------
    , `' w; u* l0 u4 Q
  941.   def set_mouse_pos
      X" ^. j  _( _0 B# R
  942.     if viewport.nil # necessary!2 Q4 ^5 z! x  ^1 c& ~5 J( B9 O
  943.       vp_x, vp_y = 0, 0
    ! x" }& j' g* |! G$ w
  944.     else/ l* u  J/ I+ ^" t; @& w
  945.       vp_x = viewport.rect.x - viewport.ox
    % P( @. x1 ^3 `# P. i
  946.       vp_y = viewport.rect.y - viewport.oy
    1 Y/ o/ S" Z5 |: Q- l4 K
  947.     end0 _3 h3 }& I8 f" E% Q( Q- o
  948.     item_x1 = vp_x + x + standard_padding   j+ L& C- q2 j5 l
  949.     item_y1 = vp_y + y + standard_padding$ x1 |0 H, ?- a% ]
  950.     get_index = @index  0  0  @index
    - G  ~1 G2 G) L' W0 S3 D
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)8 @9 X! ]6 w3 Y5 m/ }7 @  ]6 W9 i1 o
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    8 I. \2 X: \) d7 O
  953.     Mouse.set_mouse_pos(new_x, new_y)/ f9 m- W  D4 A+ r3 O
  954.   end
    3 t! D% `% A8 L- l
  955. end/ H( l7 F; u, R" Y" S/ \  Y: W
  956. 0 g  v- j% g( A  o
  957. #==============================================================================  P& I2 V% i. G+ O1 V' A7 t
  958. # ■ Window_Message
    2 W, T% V1 ?- k* z; u
  959. #------------------------------------------------------------------------------
    , a! c% g0 }- X2 ^9 \7 P
  960. #  显示文字信息的窗口。
    ( C3 ~& Q! L/ K0 o' D0 w5 D4 d" z0 g
  961. #==============================================================================
    . g+ c% ~: t: _) b% }
  962. class Window_Message  Window_Base9 R3 X" B5 N$ g+ F) W
  963.   #--------------------------------------------------------------------------
    ! _  o- b6 Q. ?9 Y, ~5 {
  964.   # ● 处理数值的输入(覆盖原方法)
    : A: p& X# M/ U' t  M- G  k
  965.   #--------------------------------------------------------------------------( n' i* |% ~) O
  966.   def input_number
    4 k4 ?& p8 u: l- e
  967.     @number_window.start
    7 y3 E2 x2 [) L( Z0 j- x0 ^. ]) b$ f
  968.     Fiber.yield while @number_window.extra_window.active7 O' T) E4 q9 C
  969.   end) l( f% }2 B6 [$ L2 h* _
  970. end
    2 ]2 }' [: w& F6 X) z2 j7 ^

  971. 4 q6 k7 R: F5 k
  972. #==============================================================================
    ( P# H' M2 j( J% C5 E2 T3 {
  973. # ■ Window_PartyCommand5 G  m/ b! X+ a( [
  974. #------------------------------------------------------------------------------
    ! o. X  ?! s4 r- r6 S4 B
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    7 `, d  j8 Q( |( Y  h6 ], A
  976. #==============================================================================
    8 h$ |# t( K4 S9 ~- i% b! w; r
  977. class Window_PartyCommand  Window_Command
    : D* d3 a" n2 U- |. P
  978.   #--------------------------------------------------------------------------
    4 h' v1 m* |+ ^6 u4 Y0 _/ ?; P. p2 E
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    : ?7 J# s6 v9 b+ u3 N
  980.   #--------------------------------------------------------------------------
    & M! b7 O- {; g
  981.   def set_mouse_pos9 Y0 r" P6 J" z  a3 u: K: D
  982.     if viewport.nil) i5 K# W, M- A1 k) L/ V  [
  983.       vp_x, vp_y = 0, 06 C7 |$ e  ]( \/ {. |
  984.     else
    3 C! R7 [, c- i, E- t
  985.       #vp_x = viewport.rect.x - viewport.ox# s2 S0 ^6 g6 q
  986.       vp_y = viewport.rect.y - viewport.oy& w+ y# S+ O) ^
  987.     end
    " a, h1 @# Q/ z: B
  988.     item_x1 = x + standard_padding . C, Z1 S! L. L8 M6 v  W
  989.     item_y1 = vp_y + y + standard_padding# x- M5 _' m9 z0 j, H  u
  990.     get_index = @index  0  0  @index + l1 E! }6 _5 \
  991.     row = get_index  col_max - top_row' z$ @, V0 ~8 u) o. \! o2 \6 d2 s
  992.     col = get_index % col_max
    ; G6 y* R# T; G2 p0 K
  993.     new_x = item_x1 + item_width  (col + 0.5)* O# g2 ^, i/ B& E  ^2 ^
  994.     new_y = item_y1 + item_height  (row + 0.5)4 G) x: T9 @" v; l# a' F
  995.     Mouse.set_mouse_pos(new_x, new_y)' @# u6 P: _" L/ \% j. D
  996.   end3 Y, f5 }( X$ T5 A. I  [
  997. end4 ]: o/ E" q; l& S0 I' l4 v# E
  998. % a  X* o4 u1 I. o) g
  999. #==============================================================================8 N' _8 u2 J' g1 r, C& E) [& O
  1000. # ■ Window_ActorCommand
    : j, ~9 I( ^7 r2 h! f* _- C2 k; E
  1001. #------------------------------------------------------------------------------( O1 Q) ]8 [  d9 }4 W
  1002. #  战斗画面中,选择角色行动的窗口。
    1 Q' v8 `  d& {/ S9 G: S+ h7 ]
  1003. #==============================================================================
    * Y7 j; |* @4 V' _% y% m% K8 n
  1004. class Window_ActorCommand  Window_Command4 h9 K, A' e8 X5 t4 N$ g- ?
  1005.   #--------------------------------------------------------------------------- U% c% ~: c& K5 s4 c2 O" {* E1 [3 R
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置9 [! B# v6 c6 i  G" H
  1007.   #--------------------------------------------------------------------------
    # s5 P# I0 I# \' W2 r$ j
  1008.   def set_mouse_pos
    ) o7 X9 @  \7 s9 ^
  1009.     if viewport.nil
    $ `" o! [. P# b2 _2 _+ \" K
  1010.       vp_x, vp_y = 0, 03 b$ Q3 |6 \5 }  T
  1011.     else
    * ^! y5 d: A. l' T& z( i0 _! q
  1012.       #vp_x = viewport.rect.x - viewport.ox
    7 G. ~/ |. l% l8 e3 |
  1013.       vp_y = viewport.rect.y - viewport.oy+ C6 C4 ~# N; \" P7 E9 h
  1014.     end
    * Z- k2 z( {# D6 S% M
  1015.     item_x1 = Graphics.width - width + standard_padding; c4 x! S5 c. g) p. V2 {8 ~
  1016.     item_y1 = vp_y + y + standard_padding! ?' F( S: L7 N5 c/ J% W* T
  1017.     get_index = @index  0  0  @index
      Y# _! P$ G2 `- ?( Z8 U2 r
  1018.     row = get_index  col_max - top_row
    : A( L8 ^4 D8 N% S% R
  1019.     col = get_index % col_max
    $ j. M& ?+ u% X$ c/ `. `" P
  1020.     new_x = item_x1 + item_width  (col + 0.5)2 Q$ |, o( k5 W8 @5 y6 A" F) L
  1021.     new_y = item_y1 + item_height  (row + 0.5)& u& Z8 j# q$ U3 C  }
  1022.     Mouse.set_mouse_pos(new_x, new_y)! H6 u4 [  Q% S* o
  1023.   end6 |) C, v# J  M7 _  Z
  1024. end( u7 {/ z: T1 h4 l% b

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

  2343. 2 s: g2 l. S3 M8 m6 _( l
  2344. #==============================================================================
    + _1 _! v# N* J. o7 N
  2345. # ■ Game_Event8 n+ H+ l# L& o+ s0 k
  2346. #------------------------------------------------------------------------------
    3 s; F* f! i" c- G+ x1 n
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。. ~8 u) }: n9 i# q4 t
  2348. #   在 Game_Map 类的内部使用。
    5 T- I! l( w% m* W: f( D3 k0 K! E
  2349. #==============================================================================
    0 j5 l1 K! o% T: H7 y
  2350. class Game_Event  Game_Character% _8 {$ i* J1 G- o+ a0 V- F
  2351.   #--------------------------------------------------------------------------* V. h: s) j7 k6 R: j0 x- m0 k
  2352.   # ● 事件启动0 f, |' ]# K/ p) A( D* _8 N
  2353.   #--------------------------------------------------------------------------0 g" h8 d1 S8 t" C, o; X0 n6 d! b
  2354.   alias sion_mouse_start start
    ! H9 [# u' S2 R' j) t7 M+ X: j
  2355.   def start
    " u  D( b7 V/ I5 Y/ Q; ~! S
  2356.     return if mouse_start && !Mouse.press(0x01)
    % \2 u" N# Q0 a; a& Q
  2357.     sion_mouse_start
    8 I  H& L7 X% p0 y9 H: a
  2358.   end
    " {, j# \' {' q1 ^$ F, p
  2359.   #--------------------------------------------------------------------------& \" ~5 S7 x7 k3 ?
  2360.   # ● 判断事件是否由鼠标启动
    * A  E0 @  ]" T% `" r
  2361.   #--------------------------------------------------------------------------( }; }# F' n$ t, i- C' P; s! V
  2362.   def mouse_start
    2 @/ w  `9 `5 v/ J, p2 x6 e
  2363.     return false if empty
    ! b* T$ ?5 ?! j0 P
  2364.     @list.each do index
    / k: Y4 Z* b5 f7 r/ b
  2365.       return true if (index.code == 108  index.code == 408) &&
    6 \' M+ |3 ?" R5 x- }! b
  2366.         index.parameters[0].include('鼠标启动')- _- R( @! j1 Z' m5 |
  2367.     end
    # O& K$ E7 X) }
  2368.     return false
    : e" v- ?. L2 Y
  2369.   end
    5 `2 `1 s7 k) V
  2370. end
    1 Y9 z# g6 ~) P4 |( \  \
  2371. 3 ^  [7 e$ @4 U% ]* C3 K
  2372. ####泥煤的height
    2 g& x  w! ^, Q# F2 R* B
  2373. # @height = height0 R5 i* C0 K: ^  J% f8 R

  2374. - k3 G4 q- z1 h. |' {4 `
  2375. class Area_Response- s3 j1 D. o( Z' g
  2376.   attr_accessor type
    ; ^! \) Q! f0 L0 \0 w# R  [% l
  2377.   attr_reader ox
    4 {. [8 Y8 ]: O+ @4 f: C
  2378.   attr_reader oy% |& h# ^8 C& F
  2379.   attr_reader width
    3 D) n0 y# G" _8 ^
  2380.   attr_reader height; K. @/ m& M5 q( S  T2 z& z
  2381.   attr_reader switch_id, t: c% G9 ]! Y$ Q) H
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil), L+ Y- W) r, z( e% l
  2383.     @type = type. R; R: x" R6 B0 [
  2384.     @ox = ox7 x$ u, q* ]$ D9 ^) Z: n
  2385.     @oy = oy8 }# |  Y2 K1 q- m5 l
  2386.     @width = width
    # C0 K2 d2 e1 z! r/ T/ J8 v6 ]
  2387.     @height = height
    , T; U$ i0 a0 E7 E5 e( v7 y
  2388.     @switch_id = switch_id
    3 g( H0 C9 s: D$ [
  2389.   end
    1 u% c$ B4 J1 k( w7 @2 X
  2390. end
    4 l& A' R3 E* @

  2391. ) ]* i+ x4 i& O2 R7 k
  2392. $area_responses = []
    4 G, ^6 ^% E$ i- o+ n

  2393. # Y! Z) Q  g6 N9 j% F
  2394. class Scene_Map0 f+ x. o1 B  y9 @: i4 m: q
  2395.   alias update_mouse_2013421 update_mouse_action  l( i# k  \2 {' v( `5 j+ F8 u, R
  2396.   def update_mouse_action
    8 ^8 Y5 A" u# f' N2 I$ R3 c
  2397.     update_area_response
    : t( m  [0 |& B0 x! }
  2398.     update_mouse_2013421
      Y2 v# a! j1 J. X
  2399.   end0 X2 B& c4 K* O; N. m
  2400.   def update_area_response
    4 R$ b0 U, ^2 X3 [5 j. R
  2401.     responses = $area_responses; n7 ^/ e. H' S1 r; A! K
  2402.     responses.each {response
    % N: N1 [2 i: E
  2403.       ox = response.ox* h) \+ D# N) r- u
  2404.       oy = response.oy. \! V- _$ E/ f4 k6 C
  2405.       width = response.width
    ! R1 Z( E# F9 n$ ]7 g# A
  2406.       height = response.height& k5 I1 w4 {  C" I3 [. ^
  2407.       switch_id = response.switch_id
    + m7 T5 }7 F/ |6 g
  2408.       case response.type
    ' B6 s! ^4 o8 [' T: t$ i
  2409.       when 01 X% \& p% I- ]6 c
  2410.         if mouse_in_area(ox, oy, width, height)5 |, J5 @/ Z' q; i+ @
  2411.           $game_switches[switch_id] = true
    ( i5 |7 m2 R2 P1 O. q  p7 q4 M
  2412.           $area_responses.delete(response)* Y$ w, `" {; L# W
  2413.         end
    " A9 S# t( _! m' U' w. E
  2414.       when 1( G  |- A! K( {
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01), a1 q# l& J/ `. y5 q0 [+ i- u0 S
  2416.           $game_switches[switch_id] = true( f8 u& R8 P3 ^+ F8 k
  2417.           $area_responses.delete(response)
    ( ]* M0 D9 p5 ]* x3 g, C. P
  2418.         end
    6 V! g3 r' J2 C
  2419.       when 22 j6 d7 P) k! @4 F' z+ m
  2420.         if mouse_in_area(ox, oy, width, height)
    + |3 I% A4 Q0 y( g# g) X9 h1 d: [
  2421.           $game_switches[switch_id] = true
    " ?" A! F/ _- i! }8 _  P
  2422.         else
    - E3 h1 J* {4 Y; k( Y- S
  2423.           $game_switches[switch_id] = false3 W! C3 J6 T# O5 H4 o. x2 Y
  2424.         end0 F  y  P+ L3 n) J$ M
  2425.       when 3: [" Y8 n* R' s
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    # O2 ]) \+ C8 e  s5 L. B; d3 Z6 Y
  2427.             (oy - $game_map.display_y)  32, width, height)
    + O  `3 f$ U% Y. U9 c
  2428.           $game_map.events_xy(ox, oy).each {event8 {, O6 N! D+ P8 O" _% h* M
  2429.           event.start3 p" x2 u  u! y  M3 R
  2430.           $area_responses.delete(response)  w; _$ D( a3 o0 C9 V. d+ t
  2431.           return
    ' o- [, h3 U8 |
  2432.           }
    4 E. i5 G2 N3 s! V5 v& q9 v* Z
  2433.         end
    8 D$ F, ~6 B' B' ^, f+ T" M2 i
  2434.       when 49 F6 S# ]5 B9 h) Y& U
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    1 D" \$ o8 o% ?
  2436.             (oy - $game_map.display_y)  32, width, height)
    6 y2 M  ]* M* c$ e+ P$ b& k  c
  2437.           $game_map.events_xy(ox, oy).each {event2 T6 x1 _1 |1 u5 A1 p9 [
  2438.             event.start4 P* M6 i/ C" ^/ {7 G- J! _' S
  2439.             return+ R$ ^" V& a* i; F/ `
  2440.           } 7 S% w( ]+ u' \) k. d3 x
  2441.         end# a# u1 `. p; O4 I" `) Y6 F1 u
  2442.       end# J4 J; x$ `; f# m
  2443.     }
    . l4 i" P3 o* H% q/ P
  2444.   end
    + w4 z2 [8 A# p  o
  2445.   def mouse_in_area(ox, oy, width, height)& t& O; F) h8 k% @3 M: R& |
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&5 P/ {0 o! h% z# m  h
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    8 |5 y( u* z, o; p2 G6 Q
  2448.   end
    4 k, ~, i, |; P
  2449. end
    . a. L3 [* E# I2 ~. Q3 A' n
  2450. class Game_Interpreter
    + m" }# O' s2 g, E0 k5 ~
  2451.   def area_response(arg)
    9 m2 i% P+ j& W, d$ e
  2452.     $area_responses.push(Area_Response.new(arg))! A- {# R. N" M# |0 v
  2453.   end
    2 t) l: c9 [4 J  i0 F6 {, w; r1 v) O
  2454. end
    9 e: P( J7 g0 t% w0 |/ H
复制代码





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