Project1

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

作者: 熊喵酱    时间: 2013-8-29 09:01
标题: 存放腳本
純屬給LBQ腳本:
  1. =begin #=======================================================================
    2 ]  S. d2 W+ g! h: J
  2. , P4 U- K! E& q5 j6 `2 i
  3.   Sion Mouse System v1.3e7 @7 i7 a1 ~% t. R  F, g
  4.   
    $ q0 i3 {  p9 E+ u* o
  5.   Changlog0 m& @( J  y' ]% o* v2 K" h
  6.   7 o5 _. H! t( a
  7.   2013.4.21 v1.3f
    * z* w3 M: G- O2 S' U- y& S
  8.     + \/ q1 i% U' v: G; P
  9.     1.3f 卷动地图 bug 修正
    ! K0 b+ t' `) ]9 b/ d
  10.    
    5 q1 t; ]% e2 ?/ q& r$ a* v
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口5 P3 d# ^8 A! G; q5 E2 Y
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内" @8 Q. A7 ]( f6 u9 B; `
  13.                               Mouse.unlock_mouse_in_screen 解除锁定/ J3 `( G9 v+ u  Z0 M

  14. 4 @1 u3 n* t7 Z; M4 ^7 E* ]
  15.     1.3f bug修正
    ' g# E8 H5 a( c: u
  16.   & r# j! F, u' A+ v. C; p7 D( H1 J
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及8 M+ E5 k- J' R( ^
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    # }9 Y& ~) c' M7 T: O' t
  19. . E# ~  x% q( N: X, _  @  M; e# f
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处7 B( W' R( S& [' H2 P$ f8 O" p

  21. ! |" J! P2 \9 p) h
  22.     1.3b 修正一些罕见的bug;
    3 [- `( r. J' K* O0 U

  23. ' f1 m$ W3 [. N: K
  24.     1.3a 代码小修改;
    7 f) m0 V2 O: V, a3 l
  25.           加入了鼠标点击启动事件的功能,1 I4 Z" u2 q0 x/ V( K2 h; v
  26.           在事件中加入“注释”: 鼠标启动  ,; ^2 {5 T- c- l4 ^. U# t9 J  f
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。0 u% u. \: ~. K. e& c/ }/ ~5 }
  28.   
    * I! u! K) p- q" [% M
  29.   2013.2.12 v1.2
    5 t7 ~* ^3 G/ b9 J/ @5 K+ V; ~

  30. 9 P- x% Y- v8 U/ J2 |* ^' |2 M$ G) [
  31.     寻路逻辑优化;6 v$ A$ U8 L, t7 @
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    4 m7 y& a( ^% [4 d/ p1 y/ k1 q; F
  33.     现在支持用鼠标来操作载具了。' p4 T/ }4 R" \  s
  34. 2 Y- I7 _  V; H- G
  35.   2013.2.8 v1.12 F, x: b0 Y8 `1 M9 w0 g! D- h+ W

  36. 3 o) D0 ?- _0 [% S
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;* g2 J: b9 t) G8 @" b- _) f; G7 g
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    * F5 C6 F1 J+ J% I1 @! G( o
  39.     移动时,路径指示点的绘制更加稳定;
    . ~" M0 p* p1 j$ X2 f8 `& r& c: g
  40.     现在支持默认存档画面的鼠标操作了。! y/ @( ?* P" w  ~# E+ I% P9 T
  41. 6 \) [4 ^5 H% ^- S6 f) f* w
  42. , r4 v, X! [5 Q: Y2 O4 _
  43.   OrigenVersion
    6 U' Q4 `$ r6 b, E9 a
  44.   
    % |# ]; N) s( m
  45.     2013.2.7 v1.0 / y* c  e4 y2 |2 Y

  46. 4 A2 d% J* s9 d- @9 D8 e
  47.   主要功能" j8 ?( }, A6 W$ q. @

  48. ( u% H# W. Y7 Y7 ^
  49.       使用鼠标进行各种操作...7 Z( x- o/ d; U
  50.       将鼠标锁定在游戏窗口内
    / _  H6 r- A" J* t, u
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    ) ^1 m( P( A, a* k! ]4 r
  52.       双击鼠标进行冲刺( b1 I  O; E8 n; I/ h
  53.       更改地图卷动方式以适应鼠标移动
    % y, Q9 n; q& x/ o& b
  54.       变量输入框改良
    $ K6 @- \' o; l- P+ D
  55. 5 n8 X- I# ^, W0 ~" t* }9 R: a
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹  [. A8 K: K7 \/ {

  57. ; y8 b4 u5 H( \) J+ v2 g, A9 @6 t" ^! g
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    9 e9 J6 _0 t) Q% R( N

  59. ( p. g4 i$ S4 h; t
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭) V: z9 K3 Z' D5 z) I

  61. 8 \4 d5 o: i2 i4 o8 {

  62. ; ]! W8 ]2 u) m5 J
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    ; z; U$ N$ m4 c& s. r# X

  64. , L3 ~6 y- Y, Y. S$ G

  65. * Y. S/ n7 Q! u% m
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示! a0 h) {9 a5 f4 b" S4 ^2 e

  67. 3 e. @) @6 ?/ N2 _. @
  68. #==============================================================================' @! I" f9 t$ K8 {- \5 b
  69. # ■ 常数设置
    : R2 A" z- h" @! e$ N6 l. E
  70. #==============================================================================
    + V* B2 a$ U+ Q3 G  c) S. {+ X2 j" I
  71. module KsOfSion
    " F: O& @; J, g! C: I
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false; ]6 C; @4 f! v" a
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    4 Y* _/ {! c2 z* x. O5 G7 o/ m; P
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    + V. F8 D# f1 u- q+ x0 L
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量5 i2 c* X. s; [/ s  C  d6 a
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处1 b( p( ?9 _4 E3 l/ x$ V- U! J2 a' P
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧% |- j9 |$ u7 i6 J* q: Q" B# j& b  O
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    . ~9 l; z; N" H/ j- h
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    / w6 T4 U- p9 E. v% B1 s
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    , W2 i: g( h5 [7 O
  81. end
    3 r. k- g) a& {, l$ E8 r/ g

  82. ' o$ n5 b8 J/ O
  83. #==============================================================================: j' h' T% Y2 y" h# c/ \2 M* @
  84. # ■ 用来显示路径点的类1 o) ^% m9 i3 W9 g; d
  85. #==============================================================================9 a9 w; c7 t+ r) h
  86. class Move_Sign  Game_Character
    ; S1 j6 z0 E7 X; x
  87.   #--------------------------------------------------------------------------
    & J. X" @6 p. z4 T( \5 I3 U
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    7 C+ L5 Y3 H0 e
  89.   #--------------------------------------------------------------------------
    5 _( b) \( @) m* b) @; l6 o2 e0 v- ?4 }
  90.   def init_public_members
    2 Z% _5 t, I' n9 j" x$ e
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    5 j" _* d8 P: u9 U7 W
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为00 |7 ~+ ?* A4 E% B7 T- q2 c; M5 M& u
  93.     @move_speed      = 5        # ★ 踏步速度, Z, ^! c  c6 L4 [
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    4 r/ K2 n% I0 R$ g1 m' c& J
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度( H8 a# `0 S8 ~4 G9 e/ Y
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常). J8 Z3 n# D$ n+ ]9 B
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
      }9 [/ g' {" f
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    7 j& }, a7 ^- V2 m9 g$ ]
  99. ; ~% q. ^3 K& [/ f9 W1 X! t1 \% ?
  100. ; d, P* d" n# H; h, ~  D: |( P
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★$ _& a& K: ]9 h9 v' a+ n) f! X
  102.   V* i) [' h9 `0 C3 B5 _3 ~; P! f5 }' b

  103. " e0 p. Y+ ?7 J% E7 y
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图' t. r/ ~3 J8 J# q% h& i
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')- m& J( A6 X) k2 Q0 b- v5 D

  106. 0 @+ e0 G' O1 n2 m/ \
  107.       if $no_arrowpic_warn
    ! E) ^: n% H3 a' Y
  108.         MouseShow_Cursor.call(1)
    4 e( U5 v$ J4 E; p5 |
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    " ^/ C0 D9 o0 d4 V0 G: p

  110. ' {. j4 _2 w0 E2 e  V
  111. “路径指示点”将使用游戏自带图片
    1 t$ r+ n& f( N/ G  O
  112. 0 h  @, c2 x, n, n2 z% i! z9 y
  113. 该提示可以在脚本内关闭')7 ^; n, v: ]; ]) Q
  114.         MouseShow_Cursor.call(0)
    1 w- |; o) Z( s3 D! I5 X3 ^
  115.         $no_arrowpic_warn = false
    % \8 h" Q8 n0 J9 z" j9 C  w2 t( T2 ^
  116.       end
    2 c% D! ?0 a2 F3 E7 }* i& p/ Q
  117.       @character_name  = '!Flame'
    ' R9 c6 P! s+ T; F  w
  118.       @character_index = 6
    ; d% x: U; a4 T& w
  119. 8 e6 ]" e) S# b. t5 A
  120.     end, t8 |/ B0 m; N) n# M9 l( J
  121.     @direction_fix = false  # 固定朝向
    $ o2 Z" c1 ~* O* ]' s( n1 ~4 `
  122.     @move_frequency = 6     # 移动频率# u# p; u6 O) k" d+ v
  123.     @walk_anime = true      # 步行动画! w& e& A" K, N7 W" q
  124.     @pattern = 1            # 图案
    2 Z/ @4 \  f' z; `( a8 Y( w& ~
  125.     @through = true         # 穿透
    5 @0 s( m' }4 Z2 Y" f5 }
  126.     @bush_depth = 0         # 草木深度! R7 n, d4 j: v6 e8 H7 t% z, z
  127.     @animation_id = 0       # 动画 ID
    % j+ I5 r3 k$ X3 ]
  128.     @balloon_id = 0         # 心情 ID
    7 ?9 I( S/ \! s4 U
  129.     @transparent = true     # 透明
    ; k, [/ ~0 Q+ @
  130.     @id = 0% z% |# r2 N/ o$ Y( b, l$ K! Q
  131.     @x = 0
    ) G# h# `' }/ \5 k5 ?
  132.     @y = 0
    ; Q3 b& w/ R. \, [; F
  133.     @real_x = 0
      r" j) x/ {' s5 _# F% l* T
  134.     @real_y = 06 R: r* x% x4 B$ n4 G- o
  135.     @tile_id = 0
    % }$ ?- H5 f/ e( t/ v& [0 z
  136.   end
    / B2 z' _3 G1 X, @
  137.   #--------------------------------------------------------------------------
    3 Q: {; W  h, z! o2 p% Y
  138.   # ● 定义实例变量: V3 a/ S2 {7 K  |) `
  139.   #--------------------------------------------------------------------------
    / e2 |5 y3 J) F! Q
  140.   attr_accessor direction
    ' n6 t0 X4 n, U: e7 F: ]
  141. end
    2 r6 `$ u2 ^0 g- n0 i4 C1 t; `
  142. 4 i0 o8 o3 x4 k7 ]
  143. #==============================================================================
    $ c$ e' x* [( i# W& I
  144. # ■ Module Mouse
    / K. l& @# G- l. ^% U2 Z8 p: ~
  145. #==============================================================================$ z. x/ X/ n9 ]
  146. module Mouse9 f( T5 B0 p8 @& Z  @% Z0 r
  147.   #--------------------------------------------------------------------------
    ) g! `3 F( _1 {
  148.   # ● API
    ) P2 {$ [; x, v: J1 s  L3 J5 H
  149.   #--------------------------------------------------------------------------
    ; v! ?4 }3 T$ ~: G! s, l. y/ h" g
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    * ]) e. Q" |! P
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    * T2 h0 ^6 [. c, }! n
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    7 x: f( z3 J+ H
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')) a8 ]5 ~: b2 s* s# A0 D4 _3 `
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')0 e" X/ s- ?: @6 y
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    2 }/ S+ E5 D6 Z+ ]2 V/ n/ Z3 Z
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    & {6 {5 U+ k+ j: s+ s* y# Z# I
  157.   Window_Hwnd       = Get_Active_Window.call" f. S( T' n. O! V! T
  158. , h) i5 }1 H4 ?+ Y( d( o" }6 E
  159. class  self
    $ z8 P# M. d3 m/ P6 ~  e
  160.   #--------------------------------------------------------------------------8 S" X0 H1 E( ]' U' u0 B2 R  h! ^. b
  161.   # ● 初始化
    8 a- _8 y% H" _1 k+ W/ D
  162.   #--------------------------------------------------------------------------2 k, v# C$ Y6 n4 F" L
  163.   def init. J$ S4 y  `5 ?( G% [; x
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    ; \" |0 b6 I6 X5 R' x9 Z) [
  165.     @left_state = 0
    7 P& ?; V0 G/ u0 l9 y' k) o# t1 P
  166.     @right_state = 0/ I) v  h6 F6 F/ z9 z
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    - q6 E9 w/ F% T- r
  168.     @dk_count = 0 # 用于双击的判定
    9 q  ?& t. u3 l
  169.     @clicked = false% C. g; w1 v- Z/ f* S' t3 C* R
  170.     creat_mouse_sprite
    . `" Q) q6 n# ^4 a/ e8 B" a$ o
  171.     update7 ]; l- ?. b2 i" d6 z
  172.   end
    4 W( e" ^" M: `3 q7 F4 X
  173.   #--------------------------------------------------------------------------% c1 Y8 s' \: f
  174.   # ● 鼠标指针精灵
    2 v* t+ [& B7 v, {
  175.   #--------------------------------------------------------------------------: l& V5 i/ V2 B1 x1 D+ m" n
  176. #~   def creat_mouse_sprite
    ! r$ M! A/ \) O% p: B) L* h1 D
  177. #~     
    4 S* D9 N, }4 Q- i7 Y- Y0 R
  178. #~       @mouse_sprite = Sprite.new8 G0 H' W' P# N( m7 J
  179. #~       panda = 2#rand(2)+1
    ! T  H. U# f' h0 g7 H) r

  180. 1 _9 T& J+ e: Q5 A; p
  181. #~      if panda = 1; |3 l+ ?" E" t6 F6 Z: r8 b8 a
  182. #~        if File.exist('GraphicsSystemCursor2.png')) y" z+ x- [7 [/ K: p
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    ( e* d5 F* w; P! T+ V) Q) M! m" S
  184. #~        end#with if File.exist, r; H9 c$ U$ y5 g
  185. #~   
    3 ^+ G& Z+ m. \/ N
  186. #~     else if panda = 2 #with if panda=1
    . P( Q, O/ W: c9 a3 C) t) H6 k
  187. #~      
    / }! V: i1 [* c  D5 Y
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    5 n  O* h  [' o; G
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')9 W2 x) {7 M  i7 g
  190. #~      end#with if File.exist
    : f; a' j8 a3 R( \# H9 |
  191. #~       : ?& G3 m+ g! i" a
  192. #~     else #with if panda=1" F; V& p  f" |7 B
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    + R5 m- V; K; t+ r9 J+ W" O) g( E
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    6 ]& J- |: ?! o* F4 n% [
  195. #~       Rect.new(5  24, 24  24, 24, 24))' E* w$ g8 S4 E+ i
  196. #~     end#with if panda=1
    * |1 q3 i& [7 H) G
  197. #~     6 @, I! X. b# e3 d( V: |
  198. #~     #with def. j+ l" A: U! G& R  l, M! I
  199. #~   end$ s7 E: \5 _; N/ J* ~- q
  200. def creat_mouse_sprite% X- H1 z6 b7 J
  201.     @mouse_sprite = Sprite.new
    ' M+ Z9 F7 w. X1 t! R
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    % E& [- \9 F- g
  203.     @mouse_sprite.z = 9999/ Z. D% v+ D* y. F( v
  204.     Show_Cursor.call(0)  x5 }0 |( E7 z+ g
  205. end. g- U% r2 f/ e0 L- R$ W5 F  i
  206. 3 @/ @% k- F! J$ L
  207.   #--------------------------------------------------------------------------
    " ~1 I& ]5 a- R. Y7 d
  208.   # ● 更新4 l* s8 [$ X" i$ Q6 s: s- V
  209.   #--------------------------------------------------------------------------
    0 t: u3 ^. W( _2 ]5 V' v& K
  210.   def update) d' |6 {2 v/ D/ h# X) C
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos+ _" R. f" g9 ~. ]
  212.     left_state  = Get_Key_State.call(0x01)+ r' z8 h8 V: B
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0: |4 j9 A/ b9 [3 t7 w- O  J# a* c
  214.     right_state = Get_Key_State.call(0x02)
    : s$ d6 C7 X  E# M  y
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    " g' b! M9 [& W7 l* g
  216.     update_double_click
    : t- R) i& {, p/ r3 {( Y( ?- ~3 v2 T
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1# S4 ]5 E3 w9 E& Q, o- q' J
  218.   end6 J& j! K+ \2 P
  219.   #--------------------------------------------------------------------------- V: k! d5 n% X) _# c
  220.   # ● 获取鼠标坐标
    0 k# \6 ^* z* A: U7 a( l
  221.   #--------------------------------------------------------------------------
    8 z( i8 [% b2 A$ j
  222.   def get_mouse_pos
    6 b# X. Q) [; P- R0 v
  223.     arg = [0, 0].pack('ll')
    ! M) b* e$ g, I5 ]
  224.     Get_Cursor_Pos.call(arg)( \) x0 A' y$ A* p0 X) f
  225.     Screen_To_Client.call(Window_Hwnd, arg)
      I- }7 S5 `3 |: G
  226.     x, y = arg.unpack('ll')
    ) I$ Q& `! J/ D
  227.     return x, y3 b* b" C6 D1 d- ^- n# h
  228.   end
    ; `# ^7 a) p5 |: L! H" M: ?3 h
  229.   #--------------------------------------------------------------------------7 _" l8 y8 y+ J" R% I, M% H2 i
  230.   # ● 将鼠标固定在屏幕内: w, h* _/ [) |/ z
  231.   #--------------------------------------------------------------------------
    7 g/ B& n/ X) d% l  V* E, h0 Q6 _
  232.   def lock_mouse_in_screen
    # ^# h& m) q! j$ J& w7 Q# u3 ?
  233.     arg = [0, 0].pack('ll')
    / o/ ]8 I2 A% q% D5 S! I9 v4 p
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    + e6 [, `- h. G$ m  f6 K
  235.     x, y  = arg.unpack('ll')8 _6 }- U' L8 m
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))1 U/ Q/ q* H( T  L1 o
  237.   end9 b& ]( F3 z- M% h
  238.   #--------------------------------------------------------------------------
    % [  K8 p, r$ C
  239.   # ● 解除鼠标固定; }- x2 ^, t, J
  240.   #--------------------------------------------------------------------------) A. y$ x% l; n9 k
  241.   def unlock_mouse_in_screen
    9 l; \5 E6 {' y* F2 \# k* E
  242.     Clip_Cursor.call(0)- o: G( a, x1 j$ e
  243.   end" l7 p) S+ }4 A4 ^2 h5 Y
  244.   #--------------------------------------------------------------------------
    + w" I) E+ X. H2 I2 k8 @
  245.   # ● 鼠标双击判定
    + }: w. V/ `- L. i8 y
  246.   #--------------------------------------------------------------------------
    - v3 q" ?8 Q9 @
  247.   def update_double_click  W# C+ S8 T& K- |/ ]9 i) D" R+ [
  248.     @clicked = true if @left_state == 1" F: n5 ?  Y% Z* J/ m1 K
  249.     if @dk_count  0 && @left_state == 1
    $ m9 v, d4 y- {6 d+ V
  250.       @dk_count = 0; @clicked = false+ B$ v5 |+ s; ]5 a: O
  251.       return @double_click = true
    5 i' T1 [% O; ^: E; j5 ]
  252.     elsif @clicked
    3 j2 J+ [! I, |
  253.       if @dk_count  KsOfSionDbclick_Frame
    # A* d& |4 ^1 s2 l5 `7 U
  254.         @dk_count += 1
    " Q; [5 M' y5 `) @
  255.       else! F3 G! B! ]$ N  A7 X, ?$ m+ D6 N% h
  256.         @dk_count = 0; @clicked = false
    7 w9 w! T2 d! b1 H& a
  257.       end  o0 }  Q1 c& W4 \/ u
  258.     end
    # J1 `+ G6 f) |, {
  259.     @double_click = false' H6 f2 Q9 [* x6 Q% x$ K% T
  260.   end
    $ x; z: \( E% I! S# s8 {5 w- P
  261.   #--------------------------------------------------------------------------  ^1 A& P2 C/ D. |5 }4 S. |
  262.   # ● 按键被按下就返回true% c- L$ Z  u0 ]2 e; \
  263.   #--------------------------------------------------------------------------2 l2 `! F  k! u% m5 \
  264.   def press(button)
    , F# A) x  l6 a( `
  265.     case button
    ) _' I4 n- q$ T/ X6 J
  266.       when 0x01; return !@left_state.zero' x; Y5 g: }$ M  H; p* X+ a
  267.       when 0x02; return !@right_state.zero
    & x- U5 x( [! t8 p" y/ U( ]6 U
  268.     end
    , ^0 b* _  m' {) Z, H: n
  269.     return false
    . _! m7 w5 ]1 z! ]2 ]/ f7 D
  270.   end) L& _5 G, H' ~4 ?. j0 G( I
  271.   #--------------------------------------------------------------------------$ q+ K( k5 c4 M1 m
  272.   # ● 按键刚被按下则返回true5 E" x& t) G! q
  273.   #--------------------------------------------------------------------------
    # M4 u1 I' }7 B  X) d+ ]
  274.   def trigger(button)
    , X+ g4 O3 A; M) H3 \5 W
  275.     case button% C9 b9 P# _9 q$ \; j: T
  276.       when 0x01; return @left_state == 1. b6 @! a( y, Y) c2 d/ I
  277.       when 0x02; return @right_state == 11 I, [& C* a+ w5 F8 v. [3 N% @
  278.     end
    ( L4 z3 Y% N/ D3 B$ k; G
  279.     return false
    . d2 Y3 O. L2 d* f
  280.   end5 m, T7 f1 E1 P, h5 |/ q" |
  281.   #--------------------------------------------------------------------------
    7 V3 M' B7 R- c5 J% D0 ^
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    6 f) j& w3 Q. a. ]
  283.   #--------------------------------------------------------------------------
    / e3 f2 _  {8 ^8 P
  284.   def repeat(button)
    + |/ [- q$ _, x3 O9 L: j; a8 l
  285.     case button% ~0 n! h- R; v
  286.       when 0x01; return @left_state == 1 # R+ o: O+ b0 t( [+ n5 R2 q
  287.         (@left_state  22 && (@left_state % 6).zero)
    7 s' u& u) d3 g: K( _# _
  288.       when 0x02; return @right_state == 1 1 v4 c. ~' s& X5 O
  289.         (@right_state  22 && (@right_state % 6).zero), V5 k/ p1 u+ e& y+ h5 n
  290.     end
    - c1 U- ^* r4 s& R
  291.     return false2 O% d' u+ a+ Z$ j7 H
  292.   end
    6 l5 W& g& Z# Z0 j9 N
  293.   #--------------------------------------------------------------------------
    5 {& Z& }0 R) g1 \% _
  294.   # ● 判断是否双击鼠标2 {/ M. z- q  D) S, C
  295.   #--------------------------------------------------------------------------' [/ B! ~# O" X  `) g
  296.   def double_click
    % t, j: V) d/ K  _0 k9 D
  297.     @double_click
    $ j2 u0 s. t: C% W! O
  298.   end/ ?3 Q4 b/ u) W
  299.   #--------------------------------------------------------------------------4 A- d$ q; c/ `4 D% C+ ^! v! o
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    ( W% c6 U) o) Q9 s' O) T
  301.   #--------------------------------------------------------------------------
    3 ^5 V6 s: H+ t, L
  302.   def click_count& K4 g8 Y7 q9 F5 y7 Y( G& b
  303.     @ck_count: N* e  i( @7 |0 |# ~7 G
  304.   end
    + t  X* o% R7 B) h. P" h$ _+ t
  305.   #--------------------------------------------------------------------------  n7 _8 Y0 G  h/ @% ^0 {
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    . o+ A% ~) T: P! d3 r9 y/ {4 M; z9 J
  307.   #--------------------------------------------------------------------------
    , b6 ]! `! Z3 A. h8 o
  308.   def left_state7 F* ~6 d* Q: t- ^3 |9 u& w  a
  309.     @left_state
    + v* [7 h- n% C2 z) J
  310.   end$ ~* I, ?& r4 g% s7 V  D: ]
  311.   #--------------------------------------------------------------------------
    6 H' m3 o5 J) J  B
  312.   # ● 获取鼠标的x坐标: b( U$ @) J* ?* `4 C* h
  313.   #--------------------------------------------------------------------------$ E7 C- t7 W  F2 k. z$ M
  314.   def mouse_x
    * {" e& k& l9 r; x; C+ Y
  315.     @mouse_sprite.x
    * [0 i% C8 Y) R
  316.   end
    $ N; r/ q1 }! q. G6 T
  317.   #--------------------------------------------------------------------------( b% y/ E% j: E5 {; A# C% G3 }+ Z
  318.   # ● 获取鼠标的y坐标" M+ ]; Y) S+ u: K: R+ L
  319.   #--------------------------------------------------------------------------
    % _2 R0 l, z3 b5 \8 w( V
  320.   def mouse_y/ d1 Q6 F- R* _. s, b/ S
  321.     @mouse_sprite.y
    ' U, h! U- g8 _- g- i" Y' h
  322.   end
    0 V' N3 I7 K/ i7 Y" R
  323.   #--------------------------------------------------------------------------
    3 y* F$ s) l- i8 T, A; s/ O2 e2 l
  324.   # ● 设置鼠标坐标2 @6 g0 ~) H; @4 {
  325.   #--------------------------------------------------------------------------
    1 |0 m# }' [- O- b1 \, N% R% Y
  326.   def set_mouse_pos(new_x, new_y)) L- w1 R% r' O" b$ ^
  327.     arg = [0, 0].pack('ll')
    + z& F+ M* s2 u7 j2 j7 K0 t7 [
  328.     Screen_To_Client.call(Window_Hwnd, arg)# a8 f6 t7 m5 C* v- k
  329.     x, y  = arg.unpack('ll')" o0 H5 a2 H" Y2 N
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    . r1 v2 w2 n, c5 p9 d/ }
  331.   end( G$ c+ Q: A8 z+ q6 J5 D6 s% G; V
  332. end #end of class  self ' R' u, Y1 ?- O  F+ x* M- z! `! ?4 t

  333. " z0 c% \! @( o3 m
  334. end
    7 J/ g, v8 O" _3 }2 j, C: ]
  335. & F7 ^. m: t# n' m- o7 K! h5 o
  336. #==============================================================================' x  {* ]5 K" T6 l6 l
  337. # ■ SceneManager8 b3 d2 [6 V9 {# f. {8 u& h
  338. #==============================================================================) j6 ?7 j( y: Y/ ~. e
  339. class  SceneManager
    & I# w) p( u: T$ h
  340.   #--------------------------------------------------------------------------
    / S+ a' K  a: K1 b6 L
  341.   # ● alias- L8 `4 {2 m5 `; K# v
  342.   #--------------------------------------------------------------------------* B) d& z/ U$ b( Y4 v2 b$ }
  343.   unless self.method_defined(sion_mouse_run)1 i  Y5 Q* `9 Z$ r3 K  X  J# \2 w9 s
  344.     alias_method sion_mouse_run, run
    - P' v7 H; E( o. l+ U
  345.     alias_method sion_mouse_call, call
    5 a. q" M# J' D% g* j1 o' t+ h
  346.     alias_method sion_mouse_return, return
    + b4 s5 N/ {2 L' g* t! ^4 d4 Q
  347.   end) P6 v: M1 M5 u# ~0 B: f! V. J& p
  348.   #--------------------------------------------------------------------------  c% p1 r, w8 n8 e
  349.   # ● 运行# H6 T0 E0 {' D
  350.   #--------------------------------------------------------------------------
    . {5 j  s5 z/ ~0 n( u
  351.   def run
    % s3 C3 k/ t( v2 t
  352.     Mouse.init
    / q- H5 k) {0 e( ~: \, n
  353.     sion_mouse_run
    ) l" \6 [' \0 L7 V: F: X1 ~
  354.   end
      ]: |% i; S9 R2 b) m# F8 f
  355.   #--------------------------------------------------------------------------3 z) ]7 f$ N' D% ]" v
  356.   # ● 切换
    : \1 T* M: z0 H( C0 x# C/ @0 k
  357.   #--------------------------------------------------------------------------& |  L7 o8 w: F1 i! a; Z- ~/ @4 d- ]
  358.   def call(scene_class), O# ]" }6 S: ^
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    + a, z. j5 l3 |* ^9 g5 w; ?
  360.     sion_mouse_call(scene_class)
    : {) u- t5 Y6 n
  361.   end
    8 F" o, G1 x; K
  362.   #--------------------------------------------------------------------------
    7 j/ t7 o+ X9 Q# ?
  363.   # ● 返回到上一个场景* u# T0 t/ ?6 C, {
  364.   #--------------------------------------------------------------------------
    9 H, k2 E4 Q3 X0 V
  365.   def return# k: d( c& e7 d1 b' i4 U3 m7 d2 Q7 {
  366.     sion_mouse_return
    1 x- J6 Z) G6 k
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    4 i1 g0 S; V. ^( C
  368.       @scene.instance_of(Scene_Map)
    7 G( N  J0 J' Z! Q
  369.   end
    9 B) P7 U' a7 E
  370. end) D5 P2 K. l4 r
  371. , s5 ]0 c* f; {$ ^" F. t
  372. #==============================================================================
    ) ^5 e0 k0 N& ]9 Q
  373. # ■ Module Input4 a( T- \" h7 k5 n; g
  374. #==============================================================================
    & N8 l( ]0 Y4 R0 }8 X) o6 G0 ?
  375. class  Input
    * w3 o( Z, t1 A& `( ~
  376.   #--------------------------------------------------------------------------
    6 F6 `$ z+ D  S8 K, C3 u; N
  377.   # ● alias
    * S1 e9 T0 `% Y6 h/ P1 R
  378.   #--------------------------------------------------------------------------5 @$ D# Z4 o- f; o' q0 \& i
  379.   unless self.method_defined(sion_mouse_update)6 ~$ R6 r2 ~( P; g, u) Z' _% O
  380.     alias_method sion_mouse_update,   update
    1 F9 c* @5 a2 O, T. t8 g% D
  381.     alias_method sion_mouse_press,   press3 H/ r2 k8 U( K7 }
  382.     alias_method sion_mouse_trigger, trigger
    5 X1 V% v7 h: G, c; W! g+ x
  383.     alias_method sion_mouse_repeat,  repeat
    # r- h1 D$ M8 _! U& v% m' {7 D
  384.   end* ]( t0 E1 m8 M& b+ p' R0 G7 L- d3 C
  385.   #--------------------------------------------------------------------------
    $ Z+ y/ [9 b7 f) y# N3 {
  386.   # ● 更新鼠标; W( H& M1 p9 T
  387.   #--------------------------------------------------------------------------4 a8 Y5 c0 J8 B9 t
  388.   def update$ [# C, R( r7 f2 g
  389.     Mouse.update
    $ M5 C/ Y4 Z. G
  390.     sion_mouse_update
    # r) p$ d  M: K- U8 P' E
  391.   end+ ]' p6 }# Z  }
  392.   #--------------------------------------------------------------------------
    % r" |! |9 Q, Q, }% L! k8 G
  393.   # ● 按键被按下就返回true2 x* X" @3 [6 l& j. l2 ~
  394.   #--------------------------------------------------------------------------& x, g7 r; B$ }4 E  `  s# |  N/ [
  395.   def press(key)# S1 C* `! {9 u0 |9 J
  396.     return true if sion_mouse_press(key)
    / _/ C& M7 h6 g4 r0 ?; h
  397.     return Mouse.press(0x01) if key == C/ A3 F( R2 K& I. @7 ~  r+ r
  398.     return Mouse.press(0x02) if key == B
    % {) g- l: D/ Z0 \
  399.     return false. R# V, q/ ?# q- G5 H# T9 \- z
  400.   end
    ( {0 }" e- B* |3 g( L  o6 z: }( Y
  401.   #--------------------------------------------------------------------------5 S$ g4 E1 X9 U2 L
  402.   # ● 按键刚被按下则返回true1 z  b, P5 z/ V" W" M- E# h3 M
  403.   #--------------------------------------------------------------------------
    # p: k, p4 e; s9 r& Q
  404.   def trigger(key)
    7 E# O! f+ `9 ^; I( W2 ~2 M, _, `
  405.     return true if sion_mouse_trigger(key)- E6 L, |( E% `  f5 Y+ _) q* C
  406.     return Mouse.trigger(0x01) if key == C4 C; ?* c8 W$ H
  407.     return Mouse.trigger(0x02) if key == B5 q9 d8 u& R  e* X+ t; W& S
  408.     return false1 _+ \1 k6 ]6 r( _" i2 U
  409.   end
    ) Q  S" `7 s3 @  a
  410.   #--------------------------------------------------------------------------) _. e2 t+ {4 g( l) D
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true) l) k/ t6 }$ e5 f: |! X6 [. `' ^/ M; q
  412.   #--------------------------------------------------------------------------# \7 b6 z0 R# g/ y3 v( {: v& K
  413.   def repeat(key)" E& a: s  g2 y9 t# ^
  414.     return true if sion_mouse_repeat(key)
    ) v* n: S+ y1 m4 l% j1 i0 e
  415.     return Mouse.repeat(0x01) if key == C
    / o% H) [+ V/ _3 j# Z$ P. M
  416.     return Mouse.repeat(0x02) if key == B
    ; b# A! H/ c& [9 t
  417.     return false
    ! t; J, ?4 W$ W- c# X% ^& \+ n
  418.   end' S" `) w) W% [  g, ?! N! k  z
  419. end: ?" J& }& C  |

  420. ; ~7 h9 G+ @2 P9 Z5 T& `7 \
  421. - F. V& j2 {( `( t+ b+ `
  422. #==============================================================================
    6 M! w# f" Z% a
  423. # ■ Window_Selectable* Q4 a" w9 u% r
  424. #------------------------------------------------------------------------------& G+ W# r$ b$ x2 A3 {/ v
  425. #  拥有光标移动、滚动功能的窗口2 T3 r& M' G! V/ y8 }
  426. #==============================================================================
    ) a  Q+ I4 E3 E  Y. [
  427. class Window_Selectable
    6 a( r% e' Q6 b6 n) b+ W5 B
  428.   #--------------------------------------------------------------------------
    2 s, t, e$ X! [4 E9 ~
  429.   # ● 初始化
    4 Q0 i- s8 @" s, ?& [
  430.   #--------------------------------------------------------------------------% x+ c% j$ z% p
  431.   alias sion_mouse_initialize initialize# r$ ^2 `7 j! M* [8 D+ M( _  a
  432.   def initialize(x, y, width, height)' U5 D! c3 j1 W! D, F
  433.     sion_mouse_initialize(x, y, width, height)# y' k, ]$ q- u0 r, ?; J% W; F6 U) M
  434.     @move_state = 07 C* v* \  }0 l1 P( U# j8 [1 S
  435.   end
    : Y4 S, L9 F# z8 F; \% E* g
  436.   #--------------------------------------------------------------------------
    / N$ _- H* \; J1 f( g
  437.   # ● 更新
    ' v2 S, `3 p2 a9 y' Y0 q! v
  438.   #--------------------------------------------------------------------------; R- O6 U+ s4 _' W
  439.   alias sion_mouse_update update
    7 v; e9 @1 q3 k9 N
  440.   def update
    7 z# x) K/ y4 I( s* S
  441.     sion_mouse_update
    0 P' [( i$ s% y9 V( R% U/ u
  442.     update_mouse_cursor
    + h$ Y2 H3 u! i4 p
  443.   end
    ) W! t+ V" W9 R6 ~8 Z- r& n; Z
  444.   #--------------------------------------------------------------------------  ]* J( D$ w3 n& v
  445.   # ● 启动后设置鼠标到index位置8 x/ ^$ J/ C% ^- [
  446.   #--------------------------------------------------------------------------: f7 n( P  ~8 e: D( ~" b) p% f
  447.   def activate
    ( X4 X; w& B" |* g1 B# v
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos$ ?+ r, R* W, t$ J4 d$ b
  449.     super
    6 O+ g& A6 I9 r" J8 T6 m
  450.   end
    ; t# q, X+ d2 w
  451.   #--------------------------------------------------------------------------( N5 w' z8 x. c3 H
  452.   # ● 更新鼠标和光标的位置
      O; H# ~! F9 U: k6 @
  453.   #--------------------------------------------------------------------------
    . G( A; Z/ l( n  K, ~0 E* G
  454.   def update_mouse_cursor
    $ E  D2 {5 Z: U9 [% T/ K
  455.     if active4 _0 n+ L  E/ x" }" Z( Y7 k" m# S( X
  456.       if @need_set_pos# k7 z- I6 u4 I2 L9 U
  457.         @need_set_pos = nil- ]( ]0 n; ~# A% L3 Z
  458.         set_mouse_pos
    ) @; g8 q  h' o: I' {
  459.       elsif cursor_movable
    + `6 P9 @1 P  h  k
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    8 J; u7 @" ]$ L: C4 X. e$ N: W) J
  461.       end- o2 M  z8 v! x1 R$ m/ x2 k9 W
  462.     end9 j! a- r% Q+ X
  463.   end* n/ Z# w" O  ]* U+ ?
  464.   #--------------------------------------------------------------------------: J. W7 W: R9 e# |+ y% V2 S
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    ; O+ W- s' X, W1 x. \, K7 z& g
  466.   #--------------------------------------------------------------------------  {. s$ q6 A3 \( T
  467.   def set_cursor  T# X; M  [1 b& m4 j# q
  468.     mouse_row, mouse_col = mouse_window_area
    2 x8 m4 U# b# L, ~: w
  469.     if    mouse_row == -11 x, j8 ?6 z0 r' Z, U& t# W
  470.       @move_state += 1 if need_scroll
    ( C9 {& {% N, M/ [
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    4 l, k' @* F' L5 e+ i" H
  472.     elsif mouse_row == -2
    + @$ u, f3 Q1 f8 X7 {6 u% P
  473.       @move_state += 1 if need_scroll
    , T( J' I( z) t% ^/ }1 R5 t4 W
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand6 e4 o% d# P! _2 f8 N
  475.     elsif mouse_col == -1+ a: H" R+ n! g$ W" |6 E
  476.       @move_state += 1 if need_scroll* O) }5 i+ _1 j3 u% u1 Q. G9 I
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand* J3 M) h3 k4 S  q. ]  W7 m4 l' b. {
  478.     elsif mouse_col == -2
    , i% r- z7 P. ~) g+ [" o
  479.       @move_state += 1 if need_scroll; C3 l0 U' t) I% K( ?
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    6 Y, Z/ [% m! S, ?. r$ B: Y/ v! c
  481.     else+ J7 l  L: U, S6 L
  482.       @move_state = 0
    6 r0 e: M- [, G+ |+ B8 E& {
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col7 W5 |/ [7 X' `$ k# U9 p* p+ S
  484.       select(new_index) if new_index  item_max && new_index != @index
    ) S3 F/ P* ?$ _6 q9 T4 a( m
  485.     end
    2 _0 N0 r, }& p$ v
  486.   end
    ! x) \: t. f" v; E
  487.   #--------------------------------------------------------------------------
    & F* ^2 S3 O) u: b0 y: H
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    / t  Z5 L2 m7 z) g4 c! N
  489.   #--------------------------------------------------------------------------" y0 }6 b0 @* M8 A2 l8 W
  490.   def mouse_window_area8 U: b3 w9 f( @: w) O0 f
  491.     if viewport.nil # necessary!
    / v5 H! L: k6 B2 ]
  492.       vp_x, vp_y = 0, 0: a- w( [( t7 k6 s/ J
  493.     else1 I4 R5 Q# P2 N9 s1 }, Y  @7 J
  494.       vp_x = viewport.rect.x - viewport.ox
    7 t* A5 w) N5 J
  495.       vp_y = viewport.rect.y - viewport.oy
    4 W/ }9 R" E7 N( f, G1 k
  496.     end; T3 T" C! m- R* k; _
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    9 y1 ?" s$ x2 A# v9 J5 Z+ t( s9 C
  498.     item_x1 = vp_x + x + standard_padding * ?% O2 R5 A; ~9 o
  499.     item_y1 = vp_y + y + standard_padding
    ! V+ o5 |; d; f: e# u9 n6 _
  500.     item_x2 = vp_x + x - standard_padding + width
    8 }5 u* y  u8 a7 `
  501.     item_y2 = vp_y + y - standard_padding + height
    3 D; B* T$ E, T2 C" f; n% _
  502.     if mouse_x  item_x16 u- k/ f" S( c" \7 p: H
  503.       mouse_col = -1* O, z. m/ v% L9 `: g
  504.     elsif mouse_x  item_x2
    ) S! t1 h9 P' N
  505.       mouse_col = -2* Q: c0 |4 L4 ]/ t3 _; @
  506.     else
    5 b& g" p- p; Y: o" Z* t! |4 q. D
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    ( R" i5 R: M, a
  508.     end0 ]2 l5 E% f1 Z3 T  D
  509.     if mouse_y  item_y1
    + }; g+ j3 w7 v) B
  510.       mouse_row = -1) ?0 M5 \9 Y! \
  511.     elsif mouse_y  item_y2
    - M- \% g6 f$ w: B+ b5 v0 I
  512.       mouse_row = -2
    & N# ]$ ?" y4 [0 x; `4 j- w, S
  513.     else
    8 [' a, t7 h  u+ h& N! h, {
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    & ], E# r' {  J( m  |% A9 _
  515.     end
    1 b) D+ O; V0 E
  516.     return mouse_row, mouse_col
    * s& u; a8 G9 w3 u1 M4 ~, n
  517.   end
    & w$ m0 a* J* f- \' L4 Z
  518.   #--------------------------------------------------------------------------0 X2 h" f. {  O5 `1 k3 t9 y
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    5 w2 a, A+ P% v4 _
  520.   #--------------------------------------------------------------------------
    3 `+ u# ~+ t+ |, ?6 H- C
  521.   def set_mouse_pos
    " i6 i/ |0 A9 N" @/ C
  522.     if viewport.nil # necessary!- m. _+ W! u$ U, d4 |, J! I2 s
  523.       vp_x, vp_y = 0, 0
    1 h! E7 v( ?( i5 C5 V5 q, @
  524.     else
    , Q/ w5 U0 p1 F% \# J) y! \
  525.       vp_x = viewport.rect.x - viewport.ox5 \$ _( W( t. T7 i  A' I
  526.       vp_y = viewport.rect.y - viewport.oy3 K9 H& d/ x2 ]- ]6 w
  527.     end
    " i% U8 n; U! m9 W. w" f
  528.     item_x1 = vp_x + x + standard_padding
    " O: x" ~5 J- i) H& g! g7 _. a
  529.     item_y1 = vp_y + y + standard_padding% [, _& X9 X5 Z2 _9 r- i3 t4 [
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    $ H' Q( h* z# c. E6 h
  531.     row = get_index  col_max - top_row3 y9 R" I6 V" _" O# u! C
  532.     col = get_index % col_max
    9 [0 h# `/ h/ q5 }7 i1 `' y
  533.     new_x = item_x1 + item_width  (col + 0.5)
    " d" ]4 F0 I& A, @3 m
  534.     new_y = item_y1 + item_height  (row + 0.5)
    ; S0 U  {  ?9 s4 _
  535.     Mouse.set_mouse_pos(new_x, new_y)
    ) g& n5 Y% T+ \4 _6 y3 x( K
  536.   end' r1 E: p4 }' r4 }
  537.   #--------------------------------------------------------------------------
    ) l4 k# N  F9 Y( O& c' u# _
  538.   # ● 判断菜单是否需要卷动
    ' W1 h( S. b5 H" @1 x$ j9 Z" `
  539.   #--------------------------------------------------------------------------/ E  g3 h* `  S2 O$ s% q/ u
  540.   def need_scroll0 ~# L( B& H( }8 a
  541.     item_max  col_max  page_row_max
    ! Y9 t& _# F6 V2 }
  542.   end
    * \8 K" P9 S; c: u0 {; ]
  543.   #--------------------------------------------------------------------------5 E/ k2 f5 P; }. |9 F2 g  x. A/ A
  544.   # ● 判断是否为水平卷动菜单) }, _" B% G5 ~* E) Y
  545.   #--------------------------------------------------------------------------
    9 L/ q# ~1 u2 c8 R7 @4 z; j" [4 `6 X
  546.   def is_horzcommand
    5 E# t* m& O( K6 L; l7 ^& y
  547.     return false
    + S; `) S, m) c/ c9 b
  548.   end
    . f- p3 X0 Z, @1 v
  549. end
    ; A( y- k% p6 r0 g2 {/ ]3 A, K& U$ `

  550. ) A. n8 [+ M" t0 Z: T/ A, ^
  551. class Window_HorzCommand% V, O9 B$ U7 t" U" b' _* \
  552.   #--------------------------------------------------------------------------, b8 t1 A4 x6 F2 s+ N+ k. R
  553.   # ● 判断是否为水平卷动菜单% j' n4 l" W3 C# S/ T: m# o$ e. O
  554.   #--------------------------------------------------------------------------# X; D* `/ l$ m/ G, R+ v! `
  555.   def is_horzcommand
    1 Y2 F6 i! W; r. T" a5 j
  556.     return true
    ! M+ w) W( u( W  L/ I9 O$ \6 X
  557.   end2 t6 d* j3 K1 s3 \
  558. end( Z9 x& H- T( n$ b; U  A) E. A5 V8 k

  559. ' d, g  i: Y; d: F
  560. #==============================================================================6 e! x2 f! }0 t, r
  561. # ■ Window_NameInput1 z. C8 i+ |7 v4 X5 g8 F$ z
  562. #------------------------------------------------------------------------------. |- A# v+ S/ p$ Q( |) t9 }9 R" e2 z
  563. #  名字输入画面中,选择文字的窗口。8 U4 l. Z1 l) s
  564. #==============================================================================
    2 f  q# U- G' l7 o% U# K
  565. class Window_NameInput! N8 b1 D+ [% [6 R* z8 N
  566.   #--------------------------------------------------------------------------' Z3 ~9 b+ z* e' r6 C7 n
  567.   # ● 设置列数
    6 _! g+ F% ^3 u/ g2 C
  568.   #--------------------------------------------------------------------------$ q: u8 b) r! R( _* d8 l
  569.   def col_max$ R0 B5 e& y4 t9 ~6 T! y
  570.     return 10
    & z6 s7 P  Q4 j# \! _1 n3 g4 Z7 _. G/ t
  571.   end
    : H% s0 ?, Q& h1 U  C6 J
  572.   #--------------------------------------------------------------------------
    # [4 p* d' A% A; x
  573.   # ● 设置填充的Item个数% S: r0 W  R7 a( u1 g# N6 z
  574.   #--------------------------------------------------------------------------
    6 c( w% z2 Z/ s/ f1 O
  575.   def item_max
    + l% s" o4 J: ~
  576.     return 90
    , Y1 O8 z, q. y+ D' R; \
  577.   end: y6 `  G% `4 |8 \
  578.   #--------------------------------------------------------------------------/ a# }; n( n3 v/ h
  579.   # ● 设置填充的Item个数/ z. v0 a2 @2 H0 `7 s6 y! r  h
  580.   #--------------------------------------------------------------------------: q) ^5 e: n. ?
  581.   def item_width$ t1 C$ B+ s1 Q5 v
  582.     return 32' M3 R1 h8 d& M' H
  583.   end
    / e! c/ P7 b$ \& u3 M1 f+ _
  584.   #--------------------------------------------------------------------------* [4 A) A: c% y: m$ e4 X1 e
  585.   # ● 判断鼠标位于菜单的第几行、第几列# @8 N4 G( i4 o3 F) }" }: v
  586.   #--------------------------------------------------------------------------
    / i% i2 U/ Y' L( O# f( h* C+ H
  587.   def mouse_window_area
    8 ~( F* M3 E: Q$ ]; f% s
  588.     if viewport.nil5 |: y) b/ Z! G. e8 Q. k
  589.       vp_x, vp_y = 0, 00 U: N; P& t' w5 g* U
  590.     else
    0 J% G2 B9 t* a( q
  591.       vp_x = viewport.rect.x - viewport.ox
    # P& ~  ?" [8 {1 ~6 ?) Q4 [3 ]$ |; L3 p
  592.       vp_y = viewport.rect.y - viewport.oy& P, V% P7 Z- Y, j: ?
  593.     end
    8 V( z# K, i2 T6 @
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    & {/ U/ ~4 q. B6 O) t5 i
  595.     item_x1 = vp_x + x + standard_padding : E; w% r/ r) O
  596.     item_y1 = vp_y + y + standard_padding
    0 o: `! Q; D: x; N& Z% a& I: e
  597.     item_x2 = vp_x + x - standard_padding + width/ W8 N. B3 o& }
  598.     item_y2 = vp_y + y - standard_padding + height: K' K* I7 L. T8 x- t+ G9 i
  599.     if mouse_x  item_x1( m* F, P: P4 m6 Q) b
  600.       mouse_col = -1
    " e+ p: u" a( H9 Y" _
  601.     elsif mouse_x  item_x2
      \( V. q7 B" ^2 i
  602.       mouse_col = -28 E9 J, w  `% a. a+ o
  603.     elsif mouse_x  item_x1 + 160* y% I+ m% j2 l
  604.       mouse_col = (mouse_x - item_x1)32
    # H$ ~+ I0 T, p6 k# i
  605.     elsif mouse_x  item_x2 - 160( n4 @2 V0 V0 }; K! _
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    ) z3 V# j; a2 n( X; x7 T, I2 M
  607.     else6 B5 m/ d9 D. x1 Y, R: b
  608.       mouse_col = mouse_x  x + width2  5  4, q0 ]1 c' @7 K% {8 R9 A
  609.     end: X2 p3 T4 e9 Q5 X
  610.     if mouse_y  item_y1; H5 @6 O9 e6 }, |, ~- G# |. ?
  611.       mouse_row = -1
    ) _% i1 V3 p$ u0 a$ X+ o
  612.     elsif mouse_y  item_y2, n( T6 \: U! m) g& I, r" O5 R8 {
  613.       mouse_row = -26 E! Y. n) b) f& D) T8 E: w
  614.     else
    - Y6 o9 P2 C" D1 T1 i1 K
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)0 c2 Q' T; B: s2 ?1 A7 l  V
  616.     end
    ; x3 u7 [+ d0 F" Z6 \
  617.     return mouse_row, mouse_col
    7 o" P) i  t. E6 u$ }+ E; ]6 Q7 v
  618.   end
    , Z0 Y% E$ P& `  S5 ]2 M! L9 ~
  619.   #--------------------------------------------------------------------------/ f# Q, U! v- l( P! a
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    0 r% E# D9 u2 C" O+ L
  621.   #--------------------------------------------------------------------------/ O- ]6 s3 A7 Y- ^
  622.   def set_mouse_pos! d2 z$ e3 E- E0 a
  623.     if viewport.nil # necessary!
    . U3 Z6 A- t# j5 E
  624.       vp_x, vp_y = 0, 06 p* [  L0 p9 b9 F
  625.     else) ^/ W: E( T  f
  626.       vp_x = viewport.rect.x - viewport.ox0 T* F  l% X' |( {; ?  T# C& g
  627.       vp_y = viewport.rect.y - viewport.oy' L/ }/ R) f! q
  628.     end
    - y* P9 Y" V% s  _6 [) H( B' L
  629.     item_x1 = vp_x + x + standard_padding
    4 g3 v$ \# b- d6 \! ~5 l
  630.     item_y1 = vp_y + y + standard_padding
    7 m6 I1 g+ _5 t8 P
  631.     get_index = @index  0  0  @index
    ; x5 [9 N' o* ^; I, T* {: _
  632.     row = get_index  col_max - top_row
      ]3 s# ~3 F! L5 r# g8 a3 Y( x6 k
  633.     col = get_index % col_max
    0 Y+ t; Z1 T* T2 A- @3 C+ b
  634.     new_x = item_x1 + item_width  (col + 0.5)( y1 d4 y0 l5 w
  635.     new_y = item_y1 + item_height  (row + 0.5)
    ! g4 K. Q7 e  k' u: e" p8 E' F/ G
  636.     new_x += 14 if col  4. m% I# Q0 B. H2 w8 D* o+ Z) X
  637.     Mouse.set_mouse_pos(new_x, new_y): V; |+ [. L2 j6 o
  638.   end
    2 e$ v$ n) _) Y4 E4 t
  639. end) H+ c6 q3 r' b+ ]5 K1 N2 m' c
  640. 3 r  p, s% H7 o; z
  641. #==============================================================================8 J8 m: K' i4 p% ~; Q% Z
  642. # ■ Window_NumberInput
    3 v* L# O( t% e4 r# N
  643. #------------------------------------------------------------------------------. X  a) z2 A  ?) k0 g) |# `
  644. #  重写了数值输入的方法以适应鼠标1 y- ]" b) P6 @! `$ R, Y! h
  645. #==============================================================================
    " d4 ]! B; z0 w6 ~  E& K
  646. class Window_NumberInput  Window_Base
    / v  t- e9 S+ h
  647.   #--------------------------------------------------------------------------
    # M: e1 z! T! h/ e! H
  648.   # ● 定义实例变量
    ) a" j, p2 {0 Q3 b* A
  649.   #--------------------------------------------------------------------------4 `  s1 D8 r7 S; M4 w# w
  650.   attr_reader extra_window* G; T% B! c1 i9 R
  651.   #--------------------------------------------------------------------------
    , Y! k' W3 `: m! b+ i
  652.   # ● 初始化
    1 R/ M) B) D6 O3 e! H% B, R1 n6 ?
  653.   #--------------------------------------------------------------------------
    " k7 h4 U/ I2 c7 ?8 w
  654.   alias sion_mouse_initialize initialize0 H1 [8 K/ p0 u( {
  655.   def initialize(arg)
    6 x$ d6 f4 K6 S2 R2 @' ?
  656.     sion_mouse_initialize(arg)
    # m) t5 G: W; i% t$ U
  657.     create_extra_window, G% l8 l4 w6 ]2 G+ O, n1 c
  658.   end5 ]" y1 H' y6 \, w; F  @/ K
  659.   #--------------------------------------------------------------------------
    ) j0 {. B; z- E' f) e6 D  a& z
  660.   # ● 启动
    " X3 N% B8 }6 v' E; p
  661.   #--------------------------------------------------------------------------
    0 W3 p, V' h5 ]+ n' M( N$ o: u0 @! C
  662.   alias sion_mouse_start start" d" p5 q3 c3 S- _
  663.   def start+ a" i9 ]1 z! [  o% [) m3 v
  664.     sion_mouse_start
    3 E5 l/ Q: g- R. ~1 d
  665.     deactivate# R: x  W& t' |. M  @; b+ y0 W
  666.     extra_start
    7 e- ^0 @6 y* S: u& {/ s1 `
  667.   end5 p' O, y: C/ `1 `$ W! z. |. |
  668.   #--------------------------------------------------------------------------7 |5 j, o' [7 c. d/ p
  669.   # ● 创建新的数值输入窗口
    + U' f- z9 K% ]! G  W
  670.   #--------------------------------------------------------------------------
    ; T$ J: c: v5 k4 ]& u5 G$ i3 a
  671.   def create_extra_window
    - k  k# F9 V* d0 Z% ?- {" G6 |
  672.     @extra_window = Window_NumberInput_Ex.new1 V9 T2 C0 c( q- |; p" T
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    6 P' e' M, T# a4 d2 w2 P
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }9 x) h4 p, T( Z5 F. F3 c" F
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    5 W3 q3 }& r. L
  676.     @extra_window.close_proc   = Proc.new { close }
    " t' ]% E9 I" P  ^* |/ H/ Z
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    $ g6 k+ y7 i  Z6 I! w
  678.   end7 Z! a5 _5 R8 m* L
  679.   #--------------------------------------------------------------------------4 {: o1 a8 B: }  D# Q3 u& V& |% S8 S
  680.   # ● 激活新窗口
    & _( q9 _; P1 J
  681.   #--------------------------------------------------------------------------; ^7 ^! M) A# `: ^
  682.   def extra_start. ], q/ l; g) z9 u. Q1 c6 N: k
  683.     case $game_message.position
    2 w2 D2 X% w& T* J, |; p) c
  684.       when 0; @extra_window.y = y + height + 4
    3 ?* W( ^% g" ^# ^
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    + t0 b4 c$ `& W( c& N2 o
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    # F, E8 f$ N5 R1 Y; g8 D
  687.       else  ; @extra_window.y = 8/ D, r: R. C2 \7 A
  688.     end9 X* }" D2 c! q: w0 q8 j- D& @
  689.     @extra_window.variable_id = $game_message.num_input_variable_id9 V, S6 k/ U3 ~: J2 D
  690.     @extra_window.digits_max  = @digits_max
    3 p2 Q; |# N: ]
  691.     @extra_window.number      = @number+ o& r2 G* a- Z* p5 K. v
  692.     @extra_window.open
    1 L7 u, M+ N9 c7 N* ^" c/ g
  693.     @extra_window.activate
    1 l7 x! C8 `# }% m1 ]
  694.   end4 I# Z+ D: R9 B' t% I
  695.   #--------------------------------------------------------------------------
    - \" s( b6 ~# O6 i
  696.   # ● 更新7 w2 K& ]' K, N* J- r' h) V
  697.   #--------------------------------------------------------------------------
    , i& u( h  R& d1 O7 Z! I8 C- }' Q& {
  698.   def update7 w' D- X* A/ O0 D6 l0 q
  699.     super
    ! A6 |8 G; o+ ?% `
  700.     @extra_window.update7 H9 c# m+ l5 O; ]' p+ [
  701.     update_cursor
      N  o' v" u/ _/ q: l! Q
  702.   end
    6 ~9 p% q/ Q3 v" \
  703.   #--------------------------------------------------------------------------  H; m  ^7 e9 o# \% A2 n
  704.   # ● 关闭窗口# x3 O; {1 B0 N, y: w4 U* j
  705.   #--------------------------------------------------------------------------
    ; v4 r$ v, d6 t6 D* u
  706.   def close
    % y! K) O" E5 A9 J
  707.     super
    - t$ x* L3 j. G' u$ m! T' B0 C$ ]
  708.     @extra_window.close
    $ Y% S" p+ p- W7 Z% T3 q6 R# i
  709.     @extra_window.deactivate% O) g- S0 C/ I5 X
  710.   end
    / R: V* v! m- ?/ V/ I8 h& {
  711. end4 g1 l. P! V& A" }
  712. 5 K# o8 V% M6 `& y6 U) q
  713. #==============================================================================
    ) V; j" a( r) D  k4 F. }
  714. # ■ Window_NumberInput_Ex. m2 ^1 v9 S/ ?- i
  715. #------------------------------------------------------------------------------
    6 e, G9 q  K# N; H
  716. #  新的数值输入窗口(NewClass)
    * I4 L0 L6 t4 D9 @( M/ T
  717. #==============================================================================
    . Q$ C# P& e7 z1 p! u* M* R0 G8 O6 {
  718. class Window_NumberInput_Ex  Window_Selectable
    8 x% U* a, V8 ~5 g  t" U
  719.   #--------------------------------------------------------------------------
    ( e% Q  H- @$ ]
  720.   # ● 定义实例变量! o- }, V) N+ u- j4 k" O
  721.   #--------------------------------------------------------------------------9 E3 @) E( y9 N' q* Q, \
  722.   attr_accessor number_proc
    . i% H- x5 L2 c1 }% ]
  723.   attr_accessor index_proc- I8 v) j; ~+ o2 q/ D
  724.   attr_accessor close_proc, I! E( T3 _  E3 l7 }4 }) q
  725.   attr_accessor refresh_proc
    / O( `* u7 L) m7 g4 c
  726.   attr_accessor number# h0 o1 _3 ]  I3 h4 s$ R
  727.   attr_accessor digits_max
    ( _: F, x0 o. P2 ?3 y
  728.   attr_accessor variable_id, W9 v, u% `  _1 I6 t. E
  729.   #--------------------------------------------------------------------------
    ! j* ~, o( G6 ]1 _* P3 u
  730.   # ● 数字表7 L; H( c. a4 Z4 g! P# `
  731.   #--------------------------------------------------------------------------/ I8 l( j+ [" ]- Q
  732.   TABLE = [  7,  8,  9,
    % |" j5 x/ d' ?0 D
  733.              4,  5,  6,
    * o; v1 N+ [& ~0 k3 ^+ Y
  734.              1,  2,  3,$ m, ^. O4 g1 M( B2 b0 U8 j" E0 t& [9 A
  735.             '←',0,'确定',]4 l" k' T. ^) ~( ]( ~. n7 s
  736.   #--------------------------------------------------------------------------; h, N6 Z& q3 @$ J
  737.   # ● 初始化对象% I/ m. M2 i. `8 _# E
  738.   #--------------------------------------------------------------------------
    1 u/ @/ y* I; m  `7 }) R3 k
  739.   def initialize( Y+ V- Q8 l8 s: s$ J; o
  740.     super(0, 0, 120, fitting_height(4))& U% Y; f5 ~5 f" J7 o8 X
  741.     self.openness = 06 Y3 ?/ W3 c4 \$ O# _8 O1 R1 I: R2 P
  742.     @index = 0$ Y: ^, W0 W- j. q: Z
  743.     @number = 0. ~+ X" v7 }2 C- T9 v
  744.     @old_window_index = 0
    / J7 X" o7 G- X# u( T
  745.     @digits_max = 0
    3 i, M* L3 E: ~- W( u" R+ S
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    ) w# O" X3 `2 g6 x% `
  747.   end- G. K, E0 k. e* e5 ^: I5 _2 k$ G
  748.   #--------------------------------------------------------------------------8 _, n- ]3 Q/ M" e; r
  749.   # ● 获取项目的绘制矩形
    ; A  ?8 J# Y& O$ _4 P8 \
  750.   #--------------------------------------------------------------------------
    5 I; {# i( d1 h: ?3 v
  751.   def item_rect(index)
    3 j) t* g  Z6 g9 ~9 ~7 p( C
  752.     rect = Rect.new
    ) v" G/ D! L4 p% S
  753.     rect.x = index % 3  32
    9 f3 ]3 {8 V3 |" }4 K# x1 {
  754.     rect.y = index  3  line_height
    , P; _' X: j! a( l
  755.     rect.width = 32
    9 d. U/ G( ?3 Q) K
  756.     rect.height = line_height
    , O8 l* a3 ^2 E1 v3 ]- B
  757.     return rect& \  Q9 L7 R) M
  758.   end5 I% _) k) h/ o- [0 f9 g6 T6 q5 l1 o1 [& R
  759.   #--------------------------------------------------------------------------0 o+ ?# m) t* t  B6 C
  760.   # ● 将光标设置到鼠标所在的位置
    / e  {$ _  y2 L- A3 A
  761.   #--------------------------------------------------------------------------( G3 h& b  C; q- v( |
  762.   def set_cursor
    # L5 h$ b9 ?7 }, Q
  763.     mouse_row, mouse_col = mouse_window_area( z/ f5 @# U, e1 N4 N9 n
  764.     if mouse_row = 0 && mouse_col = 0# H4 g+ `4 h: r5 ?$ A
  765.       new_index = mouse_row  3 + mouse_col
    5 Q& J7 z" {! ~7 ^( ^8 ^) m. B
  766.       select(new_index) if new_index = 11$ E" ^1 p6 `0 V% P  s
  767.     end7 {! Z. p) t# e9 E; Y
  768.   end
    ; y' W! D, T" K$ L) j
  769.   #--------------------------------------------------------------------------
    8 ?. Y+ L* z7 ^2 `3 {, ?
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    ( X- b( f$ @7 Z. D8 X
  771.   #--------------------------------------------------------------------------
    ; N: H: z8 K1 F! e) \! E
  772.   def mouse_window_area
    % B  \) w3 A4 X, Y
  773.     if viewport.nil9 i/ y" w9 @( @7 c; v; D! v' s$ e
  774.       vp_x, vp_y = 0, 0% U4 k. P/ E) t1 _3 k5 l5 H
  775.     else% v0 y/ x7 p8 `9 U3 y
  776.       vp_x = viewport.rect.x - viewport.ox
    # I' l' d0 s: v/ q) O1 f9 Z
  777.       vp_y = viewport.rect.y - viewport.oy
    + R( z; P6 b7 h3 J, A* u9 q" K2 x" ^) y
  778.     end
    + N; V7 ]2 O% W
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y8 v2 s3 P+ [9 v0 N4 q) v7 y
  780.     item_x1 = vp_x + x + standard_padding
    ' }% ~4 x$ U1 C4 I5 Q+ z! _# K
  781.     item_y1 = vp_y + y + standard_padding
    9 P  z; a  q6 M/ a0 m
  782.     item_x2 = vp_x + x - standard_padding + width
    : f! b$ d$ M, `8 O
  783.     item_y2 = vp_y + y - standard_padding + height2 q: u' j- e) y: h' B
  784.     if mouse_x  item_x10 B0 B5 w' {* j) R2 n- r) r3 {( s
  785.       mouse_col = -1
      m( \. m4 a; D$ M/ I2 g6 q. l
  786.     elsif mouse_x  item_x2# Y! o& I7 D) S+ b. M! W& B
  787.       mouse_col = -2) L! |1 r+ p2 m7 ~2 E# M3 X0 k
  788.     else4 g# d6 x' p7 Z
  789.       mouse_col = (mouse_x - item_x1)  32  f4 c' m* {! g. X; ?1 O
  790.     end3 y8 C, @8 _' w% ~- s3 `
  791.     if mouse_y  item_y17 I" }8 U% J2 u8 @
  792.       mouse_row = -1
    ) u" r) R# q( M8 u3 `, M4 ?
  793.     elsif mouse_y  item_y2. p7 G  e9 _& \7 h( L
  794.       mouse_row = -2' F* _6 ?  p& Y
  795.     else9 `9 H/ k$ o- K
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    * W" W- ^5 L6 M" c  C
  797.     end
    ) v6 a$ L0 {& f2 d1 o7 x/ O' O2 t
  798.     return mouse_row, mouse_col
    & N0 N% @% \2 E. B
  799.   end
    * V, W1 f# d  B' f9 r
  800.   #--------------------------------------------------------------------------% L; y+ K9 S% ?
  801.   # ● 获取文字
    ) B2 \) T( Q6 |& \3 n( _
  802.   #--------------------------------------------------------------------------
      S9 U/ Q5 y' M4 w& t* |$ ?
  803.   def get_number
    2 h- B8 {  D% d" c
  804.     return false if @index == 9  @index == 11, C" J" u. R8 J3 k& y  P
  805.     return TABLE[@index]% S. e1 T$ F% J5 [
  806.   end
    6 a# @+ H5 @! [+ A2 c. p
  807.   #--------------------------------------------------------------------------
    5 v. D& l9 m: J5 A5 h: _9 ?2 E
  808.   # ● 判定光标位置是否在“退格”上
    - u$ o1 B% H; ]& @6 R" M; H6 G/ M
  809.   #--------------------------------------------------------------------------" K2 _3 o, t2 \+ R- p9 A/ V4 t
  810.   def is_delete$ g1 F) z% l0 ^) j$ Y, O0 T
  811.     @index == 9! c" p  |) _' J3 }
  812.   end/ d2 _( y9 ^8 ^4 t0 F
  813.   #--------------------------------------------------------------------------! S3 c* c' ?9 Y6 w( w
  814.   # ● 判定光标位置是否在“确定”上
    + _5 \( K9 t- h# z* x5 P( o) O
  815.   #--------------------------------------------------------------------------
    * m5 L6 {1 w& |* b6 ~
  816.   def is_ok" L# G) e# V+ s5 S" o, r
  817.     @index == 116 m9 n' d. z! p$ q# K1 s
  818.   end/ Q+ b" P" g. H0 A. n6 X% U3 j
  819.   #--------------------------------------------------------------------------
    0 Z$ h6 b1 E7 V; s
  820.   # ● 更新光标% b$ f) j0 Q' w" D6 m2 ~
  821.   #--------------------------------------------------------------------------- c: x2 y; U7 l
  822.   def update_cursor
    - U7 X" G6 F; E7 A* `
  823.     cursor_rect.set(item_rect(@index))4 z1 O, M# w9 r' R& x6 K0 m
  824.   end
    " }. J, N2 ^1 }) M
  825.   #--------------------------------------------------------------------------
    ! o/ L6 l  `# Z: P1 S3 `6 @8 j, |9 d3 J
  826.   # ● 判定光标是否可以移动
    # P) k7 ?& o& O1 u
  827.   #--------------------------------------------------------------------------
    % z! D0 w0 D1 L$ ^1 k8 n
  828.   def cursor_movable/ P: W; ~2 d7 u" f8 s' h% \
  829.     active8 {: ?% T4 ~4 J1 H& S
  830.   end
    8 J, v: [2 A1 A) c+ Q
  831.   #--------------------------------------------------------------------------1 y: x/ i  e  v, A
  832.   # ● 光标向下移动
    ; v( E  D& P: K& K
  833.   #     wrap  允许循环  j! U: z8 O3 A4 W! W$ [$ A
  834.   #--------------------------------------------------------------------------; E: r" y( |- J* X. U' Q& r; s* s
  835.   def cursor_down(wrap)0 \/ ^% I3 T1 u1 P$ [
  836.     if @index  9 or wrap
    0 o# Q# ]4 [" G# k$ i
  837.       @index = (index + 3) % 12; d# i, |" J6 s' {. i# d- U2 U
  838.     end8 Y1 {. L  a- f. S7 a
  839.   end8 R4 n8 w/ G' X6 O" ]" j
  840.   #--------------------------------------------------------------------------* B. F* [0 m7 [1 ]' k8 m
  841.   # ● 光标向上移动
    - N( W$ J4 B, C4 r7 U
  842.   #     wrap  允许循环' [* K( j/ h4 B( C. D2 ?
  843.   #--------------------------------------------------------------------------
    3 W8 i  w+ Z, A( r* y. I/ g
  844.   def cursor_up(wrap)1 G* a! Q1 K! K- @
  845.     if @index = 3 or wrap
    " Y; z4 T: s2 s* L! n3 b! e; `1 j
  846.       @index = (index + 9) % 128 C0 R# p+ N' Q; X, Y- E! L6 }/ I
  847.     end2 T; g1 b( J9 V+ v" D' y
  848.   end
    * B* G* k+ a9 y2 W: [8 [6 b
  849.   #--------------------------------------------------------------------------1 ^( K. m. ?- j, b' P& K
  850.   # ● 光标向右移动3 h# Z' N) j+ h$ [; c  ^
  851.   #     wrap  允许循环
    2 |" d% f* T0 d
  852.   #--------------------------------------------------------------------------  k2 O+ w" M2 h9 M) j
  853.   def cursor_right(wrap)
    " x, `2 c3 ]( Q' G4 d) `, u
  854.     if @index % 3  2
    - Q8 C& |7 c; B+ m: n
  855.       @index += 1
    $ I. }6 Y5 N7 ~
  856.     elsif wrap
    - O6 d; O# m, J9 d# J+ k$ I  e
  857.       @index -= 2
    ' y* [+ R1 y( b% r" p" \3 Y" |
  858.     end$ T5 V5 G+ f8 s2 Q0 e
  859.   end1 l; z- c, g9 Y6 w0 U  A
  860.   #--------------------------------------------------------------------------
    . N% v- W1 E$ \% X+ f0 e0 _
  861.   # ● 光标向左移动
    - M4 z  {% _% B! a9 @5 a7 k, H
  862.   #     wrap  允许循环8 ?5 c2 n9 K2 \& X$ `! J3 G
  863.   #--------------------------------------------------------------------------
    5 ]/ S: n& q! h7 u2 j
  864.   def cursor_left(wrap)
    & G- q* ]( A. t: C+ e4 L" A/ u$ e' k
  865.     if @index % 3  0
    - e6 U; U% H; W( _
  866.       @index -= 1$ W% @( c0 C' g  U
  867.     elsif wrap  ]; @0 a+ f& a2 D& z  Z
  868.       @index += 2
    ) ]7 X+ Z3 B6 h; e9 ]1 [5 D! w! u
  869.     end; _/ o  O' g- e1 S; J9 l- T
  870.   end2 x4 v. V2 @; y! @9 I
  871.   #--------------------------------------------------------------------------
    ! n7 J4 L7 o2 A6 ?5 Y4 P# D+ _
  872.   # ● 处理光标的移动
    ( \; u" l  W. G  ^! C
  873.   #--------------------------------------------------------------------------
      Z  H* V! L3 i* k4 A. _8 h
  874.   def process_cursor_move
    / z; r2 A9 \' F& M
  875.     super
    2 L) U" ]: e1 y* ~! o
  876.     update_cursor  ~$ R$ i* ^( O5 |' g: g
  877.   end
    ' j' C' T! \& j6 J: B/ h, u3 W
  878.   #--------------------------------------------------------------------------
    1 d) ?8 Z5 m% f$ V6 S: s
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    / N/ Z) l/ t1 K5 z+ k
  880.   #--------------------------------------------------------------------------" d- x+ G* m. C3 l7 S' i; P2 X
  881.   def process_handling
    - o. l7 s. d: g' J, m/ _
  882.     return unless open && active+ O; I# ?0 Q7 ?8 A
  883.     process_jump if Input.trigger(A)8 a$ q/ O/ c* @% H. {
  884.     process_back if Input.repeat(B)' b8 ]- \, D3 i' I9 X1 s2 ~% c2 W
  885.     process_ok   if Input.trigger(C)
    8 X+ }$ M! L4 S
  886.   end
    " Z  N$ l) i$ e6 b4 u& n
  887.   #--------------------------------------------------------------------------
      o, _7 c, _+ `8 E1 a
  888.   # ● 跳转“确定”( i2 t0 [- G2 f; ^
  889.   #--------------------------------------------------------------------------
    : l% f6 _( O; }, O1 f- b$ |
  890.   def process_jump
    , p& m. w$ b7 K% k/ T# F. V* P
  891.     if @index != 11' l% z: Y% p# I: {% h, `
  892.       @index = 11
    4 R1 k: W& r9 p# \* o4 E4 Q
  893.       Sound.play_cursor
    4 \" p, g6 m9 J; ~: Y8 z
  894.     end
    0 k4 V; E6 V" j9 l
  895.   end) g; [" F; {% B) m5 ^, L
  896.   #--------------------------------------------------------------------------4 C$ v% z- a6 l+ k4 S* @  t
  897.   # ● 后退一个字符' f$ _1 q9 P% g' Y  \; t5 h
  898.   #--------------------------------------------------------------------------  B  e( b0 ~  Q
  899.   def process_back& {/ u/ u- g9 a: S3 T0 r
  900.     Sound.play_cancel* m4 O* e( H/ k- l1 g
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    : [2 Y% b$ J7 h" R/ m+ b! Q) k
  902.     n = (@number  place) % 10
    ) J& h' K% x3 O) a' v1 n8 J
  903.     @number -= n  place; v: j  U6 x5 ?" l. U/ J
  904.     @number_proc.call(@number)
    , i; _+ T0 H- b* I
  905.     @old_window_index -= 1 if @old_window_index  0
    3 @. e  S7 X+ I+ e4 F5 L# L
  906.     @index_proc.call(@old_window_index): u$ V2 l' f& ~  g& h
  907.     @refresh_proc.call
    * s9 y9 E7 z( N
  908.   end8 a6 R! Y' A7 o( s7 C8 M2 g( G
  909.   #--------------------------------------------------------------------------* F& n/ v( S& _/ B* E. S$ n
  910.   # ● 按下确定键时的处理/ s# T( m+ K' r: h* o0 r) s0 e: e5 P  ~
  911.   #--------------------------------------------------------------------------
    / s- I) _- B1 h$ s6 S- y7 ]
  912.   def process_ok+ m+ }& W  ]1 F1 Q
  913.     if get_number; d6 Y# D* ]0 D) Y
  914.       Sound.play_cursor
    7 ?/ n8 N0 U% e( {, {7 ~
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    0 L  [* R- h/ v! p: F! y
  916.       n = get_number - (@number  place) % 10+ j. @1 u- |6 R7 p3 y/ M! K; O" x! }
  917.       @number += n  place! D: H. |! z0 {! a7 f& v: n4 s
  918.       @number_proc.call(@number). H' R9 X1 m8 e7 m
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    9 F8 T- n9 c/ ~% n
  920.       @index_proc.call(@old_window_index)2 j: w! q# U3 @; V% g4 _
  921.       @refresh_proc.call! k& L, y) @- g4 G) c1 E& p& d* f
  922.     elsif is_delete7 R4 i' f. N+ P: ]
  923.       process_back
    2 d- K, j4 r8 U+ \6 r' D: L
  924.     elsif is_ok% x$ U! }% B. T2 D
  925.       on_input_ok
    % d! o. I& g: j6 c2 m: Z; L
  926.     end1 h4 X, }' d0 |
  927.   end
    & X! u5 m: t5 X' H
  928.   #--------------------------------------------------------------------------
    4 l" R5 H* h, D9 G3 {( t) r0 L
  929.   # ● 确定
    # K" Y5 h& L" ^1 M0 |. ], S( `+ }( c
  930.   #--------------------------------------------------------------------------* \5 r+ T, w" a- O- a& m2 m
  931.   def on_input_ok
    6 X* h+ q& W3 J8 X+ h  M
  932.     @index = 0; o0 p* i0 |7 y2 N; Z
  933.     @old_window_index = 07 b* {, ^% s7 h" @6 i  k
  934.     $game_variables[@variable_id] = @number0 y* y" Y: V% s- w( R- `) k' U
  935.     Sound.play_ok
    # R' O2 m. J/ _- {& e" s$ v# u
  936.     @close_proc.call
    / u6 i( h4 Y7 T+ \8 e
  937.   end
    3 O; i/ j2 S  I" v' O9 A2 ?  D) _  y
  938.   #--------------------------------------------------------------------------7 V: b/ m: y- e+ V) y1 D
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    9 A! `; _4 C5 L" H
  940.   #--------------------------------------------------------------------------
    : q% r7 a$ W, b
  941.   def set_mouse_pos! h- Y7 e2 V/ R/ `0 K) {: p
  942.     if viewport.nil # necessary!
    , w4 k5 p, W- j7 C/ S9 B
  943.       vp_x, vp_y = 0, 0- P% R9 y0 Z' D  n* B7 I$ t$ \; S
  944.     else, E/ _* Q( d1 d- D
  945.       vp_x = viewport.rect.x - viewport.ox) N) _. |: ^7 `: u
  946.       vp_y = viewport.rect.y - viewport.oy
    - K, D2 |2 G" S2 o
  947.     end% V: G8 M1 y8 K
  948.     item_x1 = vp_x + x + standard_padding : P2 {- ?+ r" P* y& f( |/ c
  949.     item_y1 = vp_y + y + standard_padding2 C+ c* ~3 k# K% f+ L8 t* y
  950.     get_index = @index  0  0  @index
    , p! c- o0 \8 a; i/ a, E  N
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5): I8 o, l/ [# b
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)) [  L! Z. v' D$ t) q4 f
  953.     Mouse.set_mouse_pos(new_x, new_y)
    5 t% o& A+ w9 c, ~
  954.   end. w9 W, v$ X. b6 {! n* x3 E
  955. end5 j) Q6 @4 C3 e* N  l

  956. 3 k( Q' n6 |0 h& p- K
  957. #==============================================================================' H; E/ A3 B9 k: r8 y& _! d& N
  958. # ■ Window_Message
    $ H- h$ {6 ^3 t8 ~7 d# J
  959. #------------------------------------------------------------------------------. Z9 ]5 h5 o4 `- C8 f
  960. #  显示文字信息的窗口。3 s, I% Y" Y4 ~0 k' x6 k
  961. #==============================================================================, J4 O! O$ S3 v( o3 R
  962. class Window_Message  Window_Base! V' [) T6 O( y$ Q* u2 L
  963.   #--------------------------------------------------------------------------: F1 Z7 y: I! E) A
  964.   # ● 处理数值的输入(覆盖原方法)
    9 x& `) @2 i! Q. e) d
  965.   #--------------------------------------------------------------------------; F9 F6 e- Q2 z  o# K! x4 I4 R
  966.   def input_number# j1 e; K% K( N# e
  967.     @number_window.start1 ~/ W( V2 n5 y: V
  968.     Fiber.yield while @number_window.extra_window.active& E, O# h! P- M) g) K6 L
  969.   end) c2 d6 o! k  N) _. q
  970. end( a5 m9 c+ ~5 s( h% W' T

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

  2271. 4 G0 a3 ?$ G4 _# U0 a
  2272. #==============================================================================
      S& F: s* Z* Z' Z4 A( L
  2273. # ■ Scene_File* j4 \0 [) k  Y1 O
  2274. #------------------------------------------------------------------------------
    ! Y/ \8 z0 L- t) t/ o5 Z
  2275. #  存档画面和读档画面共同的父类
    ( h8 O* E  d$ s5 k! A* M: [
  2276. #==============================================================================# P; u# X6 i# i& h& r0 g6 B, p0 u
  2277. class Scene_File  Scene_MenuBase# z) p! W: {1 C6 q5 ^0 j
  2278.   #--------------------------------------------------------------------------5 M2 g9 s+ F7 h. q% z4 z
  2279.   # ● 开始处理
    $ ?! A& D! [3 h' q! T& e) ]: J/ |1 A
  2280.   #--------------------------------------------------------------------------  S. T8 y9 j0 ?+ X4 `/ \0 b* ?- G
  2281.   alias sion_mouse_start start& T+ K- D' V" R+ q' q- x
  2282.   def start% e" _1 M- q: m2 ]2 E
  2283.     sion_mouse_start
    % `) c  P9 S# E9 ~; j: k
  2284.     @move_state = 0( T+ ^( x- P% G9 H: g- z5 v
  2285.     set_mouse_pos% q+ Z; b# M1 }/ s
  2286.   end
    6 }1 G0 O5 p& F- ^4 p7 r1 H0 ^
  2287.   #--------------------------------------------------------------------------' L/ W1 L2 C+ u7 f8 v# P6 `
  2288.   # ● 更新画面- s+ z8 f5 f, Z
  2289.   #--------------------------------------------------------------------------
    / ~/ W$ |& \; B: h9 F4 G
  2290.   alias sion_mouse_update update
    5 m( G: B4 H0 Q" ?9 ~
  2291.   def update
    # U" R8 o3 X, n: Y' _7 `5 t5 _
  2292.     sion_mouse_update. ~+ G2 x8 K( L1 d
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    9 z5 @" Q5 {  y$ H  N& }% Y
  2294.   end
    & j5 A, J) |) Q; b) O3 C
  2295.   #--------------------------------------------------------------------------
    3 Y4 a. ]+ L- o) [  ~# L, l
  2296.   # ● 更新光标/ ~6 \; B& \  c1 V! m
  2297.   #--------------------------------------------------------------------------# z- F& X* b. {5 D1 s
  2298.   def set_cursor
    1 ~; h: J: N; j% o  F& J4 ]
  2299.     @move_state += 1
    6 d! @9 R# n$ w2 R& l. G
  2300.     last_index = @index
    ! c0 w0 O, f. U' w
  2301.     if mouse_which_window == -2
    5 W% B& u5 o6 i* O
  2302.       if (@move_state - 1) % 6 == 04 m& q) P9 Y/ A4 L& d. M
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1! K* m, R8 Q3 i  A; U; f  C7 @
  2304.       end3 \* h+ k  P) h' p* x) E
  2305.     elsif mouse_which_window == -1) x9 W  |$ g# P1 M5 s9 }+ N
  2306.       if (@move_state - 1) % 6 == 06 D4 U0 K0 s9 t, t0 n+ E" b' C. J  y+ v
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0* k4 y1 x' ~. Q7 Q6 k" R1 ^0 C$ l
  2308.       end' }' p( g" U( U. u3 q: H/ {) U
  2309.     else
    $ E6 {$ \) S% X9 A: d6 Q6 W. C+ Q0 f
  2310.       @move_state = 0
    9 `( @/ Z" e& p, n/ @
  2311.       @index = top_index + mouse_which_window
      A1 \' P5 j8 G: K% e3 f
  2312.     end7 W! V8 }2 h$ E% |+ l
  2313.     ensure_cursor_visible- T/ j, D; P8 W  f
  2314.     if @index != last_index
    8 {3 Z$ s; w- c
  2315.       @savefile_windows[last_index].selected = false
    : i$ Z* U0 W) f# D* T/ [
  2316.       @savefile_windows[@index].selected = true/ Z/ I/ {5 T2 q
  2317.     end, ?" [& }- Y% J* B% o+ T* x5 H
  2318.   end# Y! K- a- L: o  V( q# D
  2319.   #--------------------------------------------------------------------------
    . g; v9 F- x  p" j5 {9 v
  2320.   # ● 判断鼠标位于哪个窗口
    , U4 n. E4 E. V2 u
  2321.   #--------------------------------------------------------------------------- R. p, {# o, d9 W% q- |3 ~
  2322.   def mouse_which_window9 H, A- l8 N: V/ i# b7 V0 I
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    , `3 G  }, Y  r3 e% z! `! H
  2324.     if mouse_y  @help_window.height + 14  M3 q9 F5 i9 T3 Y
  2325.       mouse_row = -11 B9 u+ J; a' S- X
  2326.     elsif mouse_y  Graphics.height - 144 Y' |) N% ]2 e, r4 G& r$ k
  2327.       mouse_row = -2
    7 L% c  ?: K$ m
  2328.     else
    / M7 c$ B+ f! V! N" o8 v
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    - S1 X4 x9 U" h! ~0 s9 B
  2330.         (Graphics.height - @help_window.height)# H8 T" I9 y* \$ N% t8 y
  2331.     end& D8 w0 f9 S3 ?# a8 I
  2332.     return mouse_row
    ! y/ W) L( B7 V* o9 I
  2333.   end
    " h8 g! c4 Y9 ~3 y) @
  2334.   #--------------------------------------------------------------------------2 s% S6 l3 K  a$ q  q- n
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置; m2 e3 n; v  X9 m7 ?
  2336.   #--------------------------------------------------------------------------
    + y' H1 Y+ e: V
  2337.   def set_mouse_pos+ c7 t- f& O$ @; v9 b7 I
  2338.     new_x = 40
    ' n# Q( w( |: j" k
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 249 p4 d! N# B0 p- z4 _1 e7 ?
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    . b1 e0 ^: o9 u8 Z: [# z: @
  2341.   end
    ( R& M( n6 X9 z& Z6 y
  2342. end* E; Z  p7 I- x9 f9 {: B0 \

  2343. # o) F/ H4 I; O3 W% i* W& R
  2344. #==============================================================================& V* W$ U! g# C: x1 p! Z$ O
  2345. # ■ Game_Event0 a  f( g4 V* p1 D" k
  2346. #------------------------------------------------------------------------------( b% m% b; J2 j$ v8 }5 B
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    % H, I* G1 M! I1 @9 Z3 W* ]
  2348. #   在 Game_Map 类的内部使用。6 m" M6 C) o+ i+ V
  2349. #==============================================================================
      n, {3 g. ]+ F7 h2 |
  2350. class Game_Event  Game_Character8 @; g% H. `8 b6 j8 O0 e
  2351.   #--------------------------------------------------------------------------
    * N8 k3 x: X; p& K+ M- B
  2352.   # ● 事件启动: M! D  x7 ~1 c# |: M$ A' a
  2353.   #--------------------------------------------------------------------------- D" Z  k* n5 M0 A$ `% F$ K
  2354.   alias sion_mouse_start start
    . Z; N7 }0 O0 M* ^
  2355.   def start
    , a/ i0 V0 A6 z  V, P
  2356.     return if mouse_start && !Mouse.press(0x01)
    9 k) V4 p! M& b  g8 R
  2357.     sion_mouse_start
    ( f* b' K1 {+ w9 r. J8 P+ \
  2358.   end
    # ]/ t' O8 ]# I7 \; j, Z
  2359.   #--------------------------------------------------------------------------( m7 \- r  a- Y* i$ \+ \
  2360.   # ● 判断事件是否由鼠标启动: ~! R' Z- c2 `6 ~+ H
  2361.   #--------------------------------------------------------------------------& i% Y" k' `: b0 C
  2362.   def mouse_start3 h. u7 {5 `7 [
  2363.     return false if empty. }' y& @$ f6 T1 N: _, ?
  2364.     @list.each do index
    " [1 Z  M; t6 J: J" X
  2365.       return true if (index.code == 108  index.code == 408) &&
    6 G2 X2 j3 i* u$ @9 }- u* e
  2366.         index.parameters[0].include('鼠标启动')( d! x' r9 C: r+ f
  2367.     end0 V! g# E2 q' d3 {- V  k' o
  2368.     return false
    + r  I' `4 n2 t$ Z7 m8 U# ]
  2369.   end
    - C7 z; _& k/ c! ]# x
  2370. end7 x& d- u  ~2 x$ b7 k
  2371. ; d& i4 d; c2 a' p
  2372. ####泥煤的height, ?4 [7 q, x+ S, Z3 U, |
  2373. # @height = height
    % e* H7 w' [* p# c

  2374. 0 x2 L7 ~' m* i0 v7 S! ?
  2375. class Area_Response
    6 q+ W: e. X/ c# m) a9 @/ m' n
  2376.   attr_accessor type! R4 E( u+ J# x
  2377.   attr_reader ox
    4 s3 s. Y) E. l  N
  2378.   attr_reader oy/ T, c  \& J" F/ e$ h0 S: ^. A3 g
  2379.   attr_reader width* o. T2 I9 n* ?5 o& n( _! b1 m' r
  2380.   attr_reader height( Q7 N" o2 o2 u5 [
  2381.   attr_reader switch_id, o" g. v/ \& W5 n, }- [$ s" C
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)& c+ Y5 i# b$ \2 a- w
  2383.     @type = type
    7 l+ t% C+ D0 ?* x
  2384.     @ox = ox
    0 h( {% o" E1 U; A# S: R- k
  2385.     @oy = oy
    ( t, t$ m$ u$ ~2 z& ]' d
  2386.     @width = width; b, V8 w2 P3 X; i" X
  2387.     @height = height
    5 V% a  @$ t' `  [
  2388.     @switch_id = switch_id2 N( p. V$ a, v) V% W5 P
  2389.   end
    6 T2 ^& Q6 a: d5 J% I+ e" {
  2390. end( U2 h4 u7 }4 E+ X
  2391. " z5 D/ g5 t' F& i* e1 e7 r
  2392. $area_responses = []% z. U0 g7 X4 D! E+ v+ ^

  2393. ; c# C4 R& K: B2 A- b5 U
  2394. class Scene_Map
    2 P; @% k( f# k9 Z# X+ W
  2395.   alias update_mouse_2013421 update_mouse_action
    : `% A) |. s+ z& M
  2396.   def update_mouse_action  h( }$ N# f8 y  G# u
  2397.     update_area_response7 z  r: V- I% f# a/ H( d0 Z/ F7 O
  2398.     update_mouse_2013421- K( J& D% J4 ~
  2399.   end
    1 z5 I! y4 l4 @; \- d
  2400.   def update_area_response4 x8 g! }4 n; }. h4 k- z
  2401.     responses = $area_responses) S7 c) d% G( V% M
  2402.     responses.each {response
    6 ?: K; N0 Q, Y: g
  2403.       ox = response.ox, e. w. k6 _! w, P: L4 [% @
  2404.       oy = response.oy
    ; k8 Z' i+ D' T, N
  2405.       width = response.width
    * s! C( n2 Y/ j( p0 ~0 @$ P# a
  2406.       height = response.height, x7 h& ~: l8 q" ~$ \" d' {
  2407.       switch_id = response.switch_id
    7 t/ i0 {  Y; C
  2408.       case response.type. {& }" G1 l9 A9 E) b' A
  2409.       when 0
    7 D' c4 C) d) t( ~2 ~5 U: M
  2410.         if mouse_in_area(ox, oy, width, height)
    , s5 R9 [& t+ O& f. F9 A/ G9 z
  2411.           $game_switches[switch_id] = true4 m: i! i; c; Y, e- P* I
  2412.           $area_responses.delete(response): }9 B4 [+ }. q4 l; W" B
  2413.         end7 f- }5 d2 U: l% J% y2 C/ T
  2414.       when 1# ~3 Q+ e8 O$ z' X9 L' }$ r/ Y
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    ! ^5 G; H" E7 G% s; Z
  2416.           $game_switches[switch_id] = true
    # x+ G7 b3 B7 S1 k8 `6 ]4 [/ R9 e
  2417.           $area_responses.delete(response)7 w3 e6 b, O1 y
  2418.         end
    ) a3 ]' w  i4 _) W
  2419.       when 21 \1 t0 q. K! ~% }7 e! L0 j4 M
  2420.         if mouse_in_area(ox, oy, width, height)
    ( `; ~- w7 N& a8 s0 o
  2421.           $game_switches[switch_id] = true
    , ?$ T7 m1 V, n
  2422.         else
    1 s: E8 x' X8 ~% n' S) B
  2423.           $game_switches[switch_id] = false
    & g- H! T7 R. T- \% R* i1 a
  2424.         end
    . Z2 q" V- q  [; Q1 D
  2425.       when 3# @$ E2 {$ A; ]3 V% l+ \& t; K1 F
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,/ m0 W! m) \9 K: M! ~7 f
  2427.             (oy - $game_map.display_y)  32, width, height)
    5 Q7 x( y6 i" @( k8 @. ?5 F  x
  2428.           $game_map.events_xy(ox, oy).each {event
    ! G' w- S3 J' u/ C' x
  2429.           event.start2 c$ l- |2 p6 X- O
  2430.           $area_responses.delete(response)
    ; G' \: H; ^3 Z. H4 e% j/ r+ h
  2431.           return
    1 n% I5 M3 A0 [, A6 X( I* U9 @
  2432.           }   C. A- g) B1 r' `% c
  2433.         end
    " N, h3 c- J/ v
  2434.       when 4
    7 v; `+ \0 u* t* J7 l/ y8 B5 N
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    0 X& W- Q% _& W) R! X) d
  2436.             (oy - $game_map.display_y)  32, width, height)
    9 G  x" q2 e" _6 u$ B# J
  2437.           $game_map.events_xy(ox, oy).each {event
    $ }  V  }$ F) G" A  n7 x
  2438.             event.start
    1 b% [% q/ f9 U/ N
  2439.             return
    . c1 r! H" L8 W& u3 `
  2440.           } 4 L; h* E; l) T- d, p
  2441.         end
    . Q) g: K1 m  O8 D  p
  2442.       end+ A3 E" I9 u$ P6 ?1 P6 t9 {
  2443.     }
    " ?0 K* z' Z2 v2 ^) v8 b7 t3 d
  2444.   end- W. a9 K7 t6 C- ]
  2445.   def mouse_in_area(ox, oy, width, height)
    4 ^& W7 A2 b+ o+ t' U3 y
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&3 S. S) O$ H5 R7 K' s, P5 @/ O
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height; O' I1 ^1 s% L
  2448.   end/ f! P, x8 D' M6 f5 |# k
  2449. end/ B' [' Q& K! `  J! r& R
  2450. class Game_Interpreter! S6 R- t# a6 t! q, u4 F
  2451.   def area_response(arg)
    ( h0 k* B+ r6 H
  2452.     $area_responses.push(Area_Response.new(arg))
    1 }* M- g8 Y; H# V, R# D+ A7 q
  2453.   end
    7 _- C. K- V' h8 D' Z3 }2 q
  2454. end
    % C( ]" I- O2 _' p4 X7 k
复制代码





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