Project1

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

作者: 熊喵酱    时间: 2013-8-29 09:01
标题: 存放腳本
純屬給LBQ腳本:
  1. =begin #=======================================================================+ Q4 L1 b; K+ g' t

  2. # a' `- _- y. \( h* \
  3.   Sion Mouse System v1.3e& Y1 R& |% a* _  x2 T: H# G7 \
  4.   
    , i- O& k$ g7 T# `
  5.   Changlog7 d  j6 X0 g# \/ `" x
  6.   + q0 p3 v4 l: T* h6 D( D! m; e
  7.   2013.4.21 v1.3f0 K; p0 L1 @0 X# |( S0 w
  8.     4 s3 w9 R9 V! ?$ }7 W& f  M
  9.     1.3f 卷动地图 bug 修正( M  e) k! ^" _) Z0 ?0 E3 N
  10.    
    ) n6 ~3 p2 B9 t# H" g: p
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    ) j8 \. |9 z2 U
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    2 m: m6 z; T# J  n) S( X
  13.                               Mouse.unlock_mouse_in_screen 解除锁定; Z9 F% j; q, u7 D4 h
  14.   y' a1 m* l! x, o$ L3 X
  15.     1.3f bug修正* h: R/ o5 |/ p) Z; D0 Y* T5 U4 |
  16.   6 O9 M% }1 M! \9 I
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    + h: F9 O3 Z. I. ]' V6 j' P
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    7 U: ^2 x7 ]) D/ e
  19. ) E% X( G" ?( w/ q3 W
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    3 h3 x" R$ P, ]% s; `  N
  21. $ _2 _$ {; X" `4 t
  22.     1.3b 修正一些罕见的bug;
    6 F5 r; P( ~' O( E6 g
  23. : O/ ?: L, y  v8 }3 [
  24.     1.3a 代码小修改;3 J) C. W) g( q) _- R. Q" D
  25.           加入了鼠标点击启动事件的功能,
    # a: m, Q; _* D7 {" n6 l
  26.           在事件中加入“注释”: 鼠标启动  ,) P# g$ C& k8 _  @3 }
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。8 b6 ]: E# z0 @
  28.   / l9 c% }1 ^1 ?- x& q9 U
  29.   2013.2.12 v1.28 W0 D0 \/ G6 l! n* w7 `! ]

  30.   c/ S0 _, v* m/ I, b/ P' D/ y
  31.     寻路逻辑优化;
    : W0 s' j' l9 v$ q- ^
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;5 B/ [* P6 X/ j. [& W6 K9 L+ f
  33.     现在支持用鼠标来操作载具了。
    $ h9 r: a( M1 G* c# h: V
  34.   K. f& M! N! m: x) \( i
  35.   2013.2.8 v1.1
    4 O; u0 u; l) t% t; ~" H0 k

  36. # g  ~0 i& u4 G0 X0 w% M
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;9 j6 A! ~7 Z; p0 U1 z0 A( D  I' g
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;0 i: }0 h7 c  |0 U
  39.     移动时,路径指示点的绘制更加稳定;) Z5 G# `8 w4 |0 }/ H  Z: G
  40.     现在支持默认存档画面的鼠标操作了。
    % Z) H) ^+ \: d' n& H
  41. & a8 r: q( f$ l: A4 k! p. t+ U9 x
  42. + @# ^- r4 ]7 n* ~6 `  \
  43.   OrigenVersion
    , n# {1 |6 l. n! K8 h! a# r
  44.   ( H* E6 z' }! E) i
  45.     2013.2.7 v1.0 - W- |$ k& w2 p
  46. 6 X* j; S. @& h$ [
  47.   主要功能
    - I0 \1 P/ C$ o! x; i
  48. $ s5 Y- L7 o; S1 B& t( V
  49.       使用鼠标进行各种操作...
    % s( D8 Q. }8 y' E3 d
  50.       将鼠标锁定在游戏窗口内' Y) y7 b, \5 T% [
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    8 l1 P7 A7 x( ^! a( _5 z
  52.       双击鼠标进行冲刺
    6 J. {% w* c( J) o
  53.       更改地图卷动方式以适应鼠标移动
    5 q" I" U' ^7 @2 l  G/ Y' |
  54.       变量输入框改良) p5 ?% Y8 N9 {, d$ ]6 e  p
  55. + H3 Z* f: {6 L/ E, `
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹6 S- w( i3 g9 z+ s

  57. , E3 b1 P: x9 U  W
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹: q: b5 P: K/ N! j8 J/ A! J8 ?
  59. % C( R5 A' L" q- m
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    % G& `6 q; _5 z$ `

  61. + C/ h$ z: {3 G/ T# P( y3 Q/ _; e
  62. & Q* z' ]/ Q) j# C  l
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★! B7 B. ~, k* h' c
  64. ) ^% s( v7 |7 b5 `# m

  65. $ U" z! w% ]7 Q- V+ u9 O: }
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    ) M. m3 W6 c! b2 j. a5 x8 b$ \

  67. $ G# s3 b$ _& @2 s
  68. #==============================================================================
    ' U0 h0 n- l5 U2 z7 [) s
  69. # ■ 常数设置 ! A6 V, U/ Y6 u5 ?8 E: d
  70. #==============================================================================
    : L* c: w' g( X; ^
  71. module KsOfSion' A3 Z( ?& g3 b
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    6 B; g2 H! Q7 z2 z! ]: a; P
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑6 i# ~# M+ U" t5 e4 j- R
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    1 }5 c; h: Z+ q; N5 z8 j
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    * {$ [' A" K6 Z7 z- L! J
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    , ?6 M' \, S9 [0 _) E& R5 Z; p  o$ I, w
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    , |* f" ^: R8 f% l. z4 T
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)) E8 W  P: I- V/ v& W
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    ( W, W% f+ k4 k; E  o  ~" `$ y
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    ) B* r3 I) U4 O1 m0 q0 b1 N
  81. end3 W2 o6 F9 Z. i" d. w: n
  82. - A8 I5 l. O4 v
  83. #==============================================================================# K/ B) G- ~& P
  84. # ■ 用来显示路径点的类3 O- E! K5 _7 V- X4 l7 Z$ v& D
  85. #==============================================================================
    + K" @% L, e# }4 L/ W, _' [
  86. class Move_Sign  Game_Character
    " E1 ^8 U5 ?4 t4 H6 L8 u
  87.   #--------------------------------------------------------------------------- ^& `7 i3 A  w/ Y! `. E% A
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    8 n3 C! t. i4 x" {0 R8 e
  89.   #--------------------------------------------------------------------------6 W2 q# k7 I3 ]
  90.   def init_public_members
    3 Z# A: q" ~+ A; u* \7 n
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    : I5 A/ e, }/ j0 |' N% s
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为01 X5 g6 l7 w2 q8 a* N
  93.     @move_speed      = 5        # ★ 踏步速度- Q$ Y& n/ Z" E" G! F: o9 T
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)1 A8 z% A) J( Z5 D5 z) r2 M  }( `
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度) q4 N5 g- Y8 s, q4 P1 O! G
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    " U9 j* J! B) I( y* J
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    7 O6 S2 P; T% W% B( x
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)" N$ c1 Z' q* k5 X9 C

  99. $ Q5 e7 X$ C  ~+ p) b* j5 X% r

  100. / k9 m+ |& K$ W" K2 U
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★5 R" \' J3 D1 U  p& X6 v
  102. , |: t; C7 ~2 @. }9 H* c1 D0 R
  103. " c9 P& i9 [: @* I) @6 |- m
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    1 P4 M7 `2 P) k2 L
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')6 m* _* u7 z% T# C5 b

  106.   U5 ]) y8 ?8 B* w
  107.       if $no_arrowpic_warn
    . e' {& Z" c+ n! u
  108.         MouseShow_Cursor.call(1): }* e  v0 b! B, A9 f
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png8 K6 E" b; Q2 @2 W
  110. ( ?' [3 R" P% F& @, q
  111. “路径指示点”将使用游戏自带图片* [; R* H, B+ a* m
  112. " @9 W9 r7 T- D5 I. q& c
  113. 该提示可以在脚本内关闭'), \' Y+ Y# i* W9 U) p
  114.         MouseShow_Cursor.call(0)$ ^" g/ T2 A5 L. m
  115.         $no_arrowpic_warn = false
    , n9 U- H3 \8 b
  116.       end2 N+ ^7 D$ h0 X+ L; u9 b8 O7 v
  117.       @character_name  = '!Flame'
    0 W# J9 V* [4 Q8 D$ J0 a0 J
  118.       @character_index = 68 j2 l  f; D7 t8 ?

  119. ! N5 C4 u$ q, _% U
  120.     end4 [  w: p0 z, p/ ]% T
  121.     @direction_fix = false  # 固定朝向5 L* X) K' h+ H) Z8 e' D1 g
  122.     @move_frequency = 6     # 移动频率
    5 Q( a: {. o: ^4 m: J5 \' ^% k
  123.     @walk_anime = true      # 步行动画/ k3 P$ m" E, H7 _+ Y9 E9 f  ~
  124.     @pattern = 1            # 图案  Y0 K2 r, I2 ~" Z- O5 Y
  125.     @through = true         # 穿透: f/ \7 U+ e, p' t% s" W
  126.     @bush_depth = 0         # 草木深度
    1 c7 t: J1 ^7 z& ]# G& [! r' [
  127.     @animation_id = 0       # 动画 ID
    7 j" n* [0 Y' P7 t# O
  128.     @balloon_id = 0         # 心情 ID
    2 G/ c9 a4 D: c% p' d
  129.     @transparent = true     # 透明
    " l) _0 r6 {% |5 E6 w' p
  130.     @id = 0
    9 e- [5 d4 e7 H  g
  131.     @x = 0
      R; m0 w, z3 X, \! P
  132.     @y = 06 l0 N" D0 U9 v! Q+ b/ i, w
  133.     @real_x = 0+ n6 @7 p4 [. G' e3 N. Y
  134.     @real_y = 0
    + B1 K- H" }2 T  m' n: Q3 h+ y" c
  135.     @tile_id = 0
    , s, C2 g7 J% @, r7 z
  136.   end7 o: E6 q$ r( `2 B8 Z
  137.   #--------------------------------------------------------------------------( d1 d# a, @4 {+ E4 {) M
  138.   # ● 定义实例变量; L1 \- B5 S# V( }% W
  139.   #--------------------------------------------------------------------------. V8 \7 W8 j3 y
  140.   attr_accessor direction
    + S7 e1 x3 `5 h# b
  141. end8 \/ W" r+ v, E9 f

  142. ; S) _" M6 l( d
  143. #==============================================================================- Y5 ^$ M# F7 l2 {
  144. # ■ Module Mouse
    3 A( Z) q  v# ~1 a* ?) v* L
  145. #==============================================================================5 F  ^4 g; z" _, J+ [4 w8 c
  146. module Mouse9 e2 k+ [! U: s- Q9 U9 I) b
  147.   #--------------------------------------------------------------------------
    , i9 P; K$ H! _! D* I6 @# L3 @
  148.   # ● API: t( t) \5 [3 B
  149.   #--------------------------------------------------------------------------0 r% P( r. H* c0 {, c
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')6 }5 n2 S1 T8 w1 G5 R% z, i
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    6 z0 T; N+ V7 C5 h
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')" E5 v2 l/ j# ?* P! x
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')& P2 B6 S/ v0 B# g: Q: C: V3 k# ]7 z
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')4 K2 C9 N' ~  h& c8 A  J
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')6 D$ w. r- p+ y* J- j( W
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    7 _. W6 y" \6 O7 ~2 A! v7 w/ C: C5 {
  157.   Window_Hwnd       = Get_Active_Window.call
    % \& M4 H; j  @7 w! p8 t% J

  158. - x8 ^& o6 L( y
  159. class  self* t$ N, b/ z" J! {+ b
  160.   #--------------------------------------------------------------------------
    0 C  C% `6 p8 m6 |  _& |, c- V# k
  161.   # ● 初始化% K; ?2 S4 k; O# E# N
  162.   #--------------------------------------------------------------------------
    / }  K" N" ]5 N& R
  163.   def init) J+ I/ o' S8 f
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    2 X; w% \- U" u
  165.     @left_state = 0
      d9 i9 B* P* t7 V( Y9 s
  166.     @right_state = 0
    , H, y# }. l; T% w/ \
  167.     @ck_count = 0 # 帧数计,单击以后从0开始/ |: Q( e& o7 M, U. d$ _
  168.     @dk_count = 0 # 用于双击的判定
    4 k1 p# _4 n3 Z: M
  169.     @clicked = false
    ' c" {' q/ @* f# S, [; j7 e
  170.     creat_mouse_sprite
    6 S3 T9 i/ H7 n
  171.     update
    . D$ S5 P, W- @3 v6 w0 G3 U
  172.   end) M  i' g8 b# ?8 z9 w$ L& ~: r
  173.   #--------------------------------------------------------------------------; y+ ^( X; K9 D+ ^. [! }7 M( n" I
  174.   # ● 鼠标指针精灵
    # d5 ]9 u1 u* ]; W% e
  175.   #--------------------------------------------------------------------------
    8 g! o, [5 F# s' h: d6 {
  176. #~   def creat_mouse_sprite- ]; e2 n4 p( V, h( H1 Z
  177. #~     
    7 L$ m$ L5 \# f) X
  178. #~       @mouse_sprite = Sprite.new
    5 e, N# v$ d! A7 N; t1 e
  179. #~       panda = 2#rand(2)+1# m, f5 h9 T* ^$ T& o

  180. * Q% N, s  \$ W$ Z* ^3 q
  181. #~      if panda = 1# X3 L# S, I2 |% u# z& E. q
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    " Q2 c/ ~9 [" u* Z! {" X' q
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    # @$ V8 e) G8 \8 |* m! t. u2 {) m
  184. #~        end#with if File.exist
    " m; \, T2 H2 W8 M& w" H8 I
  185. #~   
    " J3 b' ?9 l2 f, _" ]6 F
  186. #~     else if panda = 2 #with if panda=19 t' F' l6 V  F& T
  187. #~      
    3 L& B$ Q, Y1 D9 j
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    9 ?3 E$ }" c& y9 f7 Y4 M. _
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')6 P& b) Q; f. A3 g$ ~( h+ ]; D$ A
  190. #~      end#with if File.exist
    * O9 Z+ L/ e! W/ T9 W
  191. #~       1 e/ P. m7 o9 z  c
  192. #~     else #with if panda=1
    4 b) V9 _" r/ c/ V# I' z3 q/ G
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)5 s  H0 I5 I% P6 t# `, D2 v
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    / {! @& U" y5 x( g& y
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    " }/ @: h$ n: @& W
  196. #~     end#with if panda=1
    9 r" m" n8 e' b* S6 Q  Z
  197. #~     + }4 J: H9 V" F4 M) D0 y
  198. #~     #with def
    " {! l+ `; j' I" U) ^+ K& J
  199. #~   end' N) y2 O4 m0 k- b% m
  200. def creat_mouse_sprite! I5 H; U. w0 L
  201.     @mouse_sprite = Sprite.new
    ! D* j" @2 w! F  R( W* @7 y+ v! l& A
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})1 U8 A1 V# @! Z1 G' F( x
  203.     @mouse_sprite.z = 9999
    6 u9 ~7 g# ?/ t$ [9 B7 X$ \+ p. |
  204.     Show_Cursor.call(0)
    6 K% |5 A$ B0 o$ s7 l+ f" e
  205. end
    % z4 K' J( U" P0 l

  206. $ ~+ z/ |" Q8 A/ [' L: G
  207.   #--------------------------------------------------------------------------" m0 K$ Y6 ?8 ]3 _7 H' Z4 n
  208.   # ● 更新
    + P. g& O! o$ n& N, M& x# M
  209.   #--------------------------------------------------------------------------" m$ j- t+ e) d. w" K1 J$ ~
  210.   def update
    $ ~0 S. K' j/ J7 z; {; [! Y
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos- Z$ ~, ?* W  @, R4 Q; g' J) Q4 o9 p
  212.     left_state  = Get_Key_State.call(0x01)
    * |! B/ j% o- h" L9 k1 X
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    # Y( E5 L+ y9 y  V4 v
  214.     right_state = Get_Key_State.call(0x02)
    2 g* w7 z7 I/ N
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    . L' m0 b9 b2 e, `9 R
  216.     update_double_click' ~# K' a4 \1 c! H3 u' b( i
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    / F( c/ ], _) `
  218.   end
    7 J1 C# z" Q9 E7 `( f; W7 S
  219.   #--------------------------------------------------------------------------
    9 L" `2 o8 z7 z) `
  220.   # ● 获取鼠标坐标7 Z" x! M) d  ~) |! s
  221.   #--------------------------------------------------------------------------8 n( b( L( [( r, n: u: H4 [6 M
  222.   def get_mouse_pos# v) }# }2 b6 ?9 T4 g/ C
  223.     arg = [0, 0].pack('ll')
    - D' Y" v) c  o7 i) ~. C
  224.     Get_Cursor_Pos.call(arg)
    ) B5 g: Q. s. \1 w
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    6 m. E9 r% o3 H$ d) d! n/ a' z
  226.     x, y = arg.unpack('ll')
    % i4 Q- T9 j3 ~' b
  227.     return x, y
    " K6 |2 {1 d% A% j) P" g( Z  D
  228.   end; j( J2 `, n. k4 ^& n0 s( j
  229.   #--------------------------------------------------------------------------. H) t/ _3 B2 v2 a, Y3 w2 Y4 ~
  230.   # ● 将鼠标固定在屏幕内* z" v) B" L; U! e1 ~
  231.   #--------------------------------------------------------------------------
    + `# t9 i' O. B9 y+ z( B
  232.   def lock_mouse_in_screen
    , r. M- q" h  H# P# m0 a7 O
  233.     arg = [0, 0].pack('ll')
    * h( }% f1 V* |4 j
  234.     Screen_To_Client.call(Window_Hwnd, arg)$ D5 I& [9 K9 ]7 I
  235.     x, y  = arg.unpack('ll')
    : N  H$ }" y" t1 v8 e
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))5 A0 V" S) L/ Q5 Z: }1 l( `- g. ^
  237.   end
    3 C" d  u* g( k: c
  238.   #--------------------------------------------------------------------------/ |' a8 {: A1 e7 h) j
  239.   # ● 解除鼠标固定$ B7 Q# u; Y4 B6 D$ M% r$ x0 q$ X
  240.   #--------------------------------------------------------------------------
    , n6 L2 \7 h; I
  241.   def unlock_mouse_in_screen+ q! e. e( J2 b$ `1 V
  242.     Clip_Cursor.call(0)- ~; T6 @5 V* \  N8 M8 C6 Q8 v( i/ S- B
  243.   end
    ! U" n7 @# s1 L+ z$ t/ B' r
  244.   #--------------------------------------------------------------------------
    ; H+ ?! N2 M0 L
  245.   # ● 鼠标双击判定  n; z  O5 f4 |6 `* o
  246.   #--------------------------------------------------------------------------0 Z( G. v9 Q; j' p7 g
  247.   def update_double_click5 n: n/ G: F0 [6 G% j# @2 s& p
  248.     @clicked = true if @left_state == 1
    6 F/ o" r6 S4 \8 j( {& u; j
  249.     if @dk_count  0 && @left_state == 17 R3 W2 Z: O+ ?/ f9 ]
  250.       @dk_count = 0; @clicked = false
    , [% ]7 p" v3 _' ?
  251.       return @double_click = true
    8 q0 ~! P" |3 R' W+ H* j2 s
  252.     elsif @clicked6 h! I" j+ w5 a& o" Y7 P
  253.       if @dk_count  KsOfSionDbclick_Frame
    / r% [" J9 ?& ^- j
  254.         @dk_count += 1
    $ d5 J& y5 b. K: P# x4 |( d
  255.       else
    , J2 P' \$ N; W  j7 ]9 D7 I
  256.         @dk_count = 0; @clicked = false7 d# m! M6 L; J/ V% \, Q% A' }0 B6 F/ n
  257.       end# i8 S) o8 O( }. H1 t. _
  258.     end
    : n# V2 R% Y' X/ ]' T+ D
  259.     @double_click = false* r9 E' P+ V& t3 g& a
  260.   end4 |& v. R5 I( s
  261.   #--------------------------------------------------------------------------& \; ]! X9 B5 A  ?
  262.   # ● 按键被按下就返回true
    ; e( }0 ^" p/ Z) F; n: L
  263.   #--------------------------------------------------------------------------
    # v% `0 ~; a2 r/ j
  264.   def press(button)9 |" {6 K1 d, r8 Q/ x2 B
  265.     case button5 |1 B2 g- i+ t2 r. j# q& l8 L
  266.       when 0x01; return !@left_state.zero# d0 S. e7 p- y/ f8 B6 X$ Z
  267.       when 0x02; return !@right_state.zero
    1 o$ u- V. h( E8 I6 L2 C
  268.     end* v  D% v+ d! W
  269.     return false
    $ f% }3 I" d2 K. |9 x
  270.   end8 |- C* i9 a! o6 @9 y# A" r$ Z
  271.   #--------------------------------------------------------------------------
    $ f! [3 }( v  Z. m1 H  p/ H
  272.   # ● 按键刚被按下则返回true
      V+ F5 Y8 H1 @5 D3 |* b. V- `  |
  273.   #--------------------------------------------------------------------------
    3 M- E7 e; N# E, F' b! C
  274.   def trigger(button)+ E2 h" J% v$ r) L
  275.     case button
    ( J9 T+ x; |# ?; ~2 G) B2 l
  276.       when 0x01; return @left_state == 1
    ! I# C9 z! b- ~5 I( O! L; \* M
  277.       when 0x02; return @right_state == 1
    9 U; o, y& ~5 f8 P/ c; G
  278.     end
    + M! l& o$ c9 \' d  n5 l- y1 Q
  279.     return false1 ?9 Y+ f1 \$ x8 ?- I1 O
  280.   end
    * {, g* `2 u* i" I/ i
  281.   #--------------------------------------------------------------------------: z$ k' N8 E4 n1 y3 b  G' E) l$ S0 j
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true7 q3 V# ?+ }$ R$ s
  283.   #--------------------------------------------------------------------------9 P3 B) g3 ^! _! O+ G7 r# c$ S& B
  284.   def repeat(button)
    + w1 e( g7 L0 ^/ n4 r6 p+ K; T
  285.     case button; ^) _5 R0 }/ @' I
  286.       when 0x01; return @left_state == 1 * d- m: y, T% i( w9 h$ o1 w! c
  287.         (@left_state  22 && (@left_state % 6).zero). w8 o" |* v) c4 e, U
  288.       when 0x02; return @right_state == 1
    4 G! X, R5 N4 R$ {8 |; x3 m
  289.         (@right_state  22 && (@right_state % 6).zero); U& ^$ b) ]3 |$ ]' P) ]( w
  290.     end
    . \0 p* f* d3 K1 g$ h4 X/ ]
  291.     return false
    / n3 O  H7 Q0 u( s. T& [
  292.   end
    ) m- q# P  [: ~$ n& q. W0 ?
  293.   #--------------------------------------------------------------------------
    * s6 [& H7 Q8 J2 ?- ?1 Q
  294.   # ● 判断是否双击鼠标+ h" m/ l. }3 s
  295.   #--------------------------------------------------------------------------
    6 H! C# ~/ X* \# D# k
  296.   def double_click" a3 [' E% M4 `, g
  297.     @double_click
    4 f1 g6 S' n* v" }
  298.   end, v6 l, z7 \+ ^! T# G8 e
  299.   #--------------------------------------------------------------------------) c& k; [2 }3 J) n* ^
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    ( B5 ~4 H7 N2 ]4 S/ c9 Y
  301.   #--------------------------------------------------------------------------
    1 Q; x4 t9 w& f9 R5 z9 B
  302.   def click_count
    ( }( s0 j6 V" Z$ g5 U9 s
  303.     @ck_count
      }& O( U# C9 N9 T
  304.   end
    : q0 a) w4 l. c1 A
  305.   #--------------------------------------------------------------------------) p( E; q8 \2 D$ W
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    8 v1 ~; Z6 k; D. C7 o
  307.   #--------------------------------------------------------------------------
    5 t( y$ a4 b0 @. ^& S2 P4 p
  308.   def left_state. x- G$ p( d# S1 f- I6 r# a
  309.     @left_state8 z# M2 Q0 L) n! i6 L0 B
  310.   end$ |" @+ G2 g; o3 v7 m
  311.   #--------------------------------------------------------------------------4 n/ ]' t2 }2 a& }' J: e
  312.   # ● 获取鼠标的x坐标" z3 ^2 ]9 a0 _. h* Q  ]
  313.   #--------------------------------------------------------------------------: r% U3 Z! G! i6 }" [+ A; b1 e
  314.   def mouse_x
    3 X3 _8 @& E  j! f& g7 h
  315.     @mouse_sprite.x
    + R( L2 w+ d+ g: o. }
  316.   end
    2 d8 ^: R4 g; c
  317.   #--------------------------------------------------------------------------
    0 D! n2 ~; r$ M/ z9 z
  318.   # ● 获取鼠标的y坐标
    ( O. S( f) S* r* S1 V" {6 ?
  319.   #--------------------------------------------------------------------------. k  P3 I. ~& b
  320.   def mouse_y
    " w3 E8 o& G: C. k# r4 c& D
  321.     @mouse_sprite.y
    - l- _. s: I% q. \  H! U2 @
  322.   end2 H$ b. [5 ?; S& V) Q( O  P
  323.   #--------------------------------------------------------------------------& p7 N9 I2 j* t- U9 U) Z2 o
  324.   # ● 设置鼠标坐标
    6 @* o0 s$ ~' D0 c; w
  325.   #--------------------------------------------------------------------------
    ; u2 `& D, E) q' Y3 {2 n
  326.   def set_mouse_pos(new_x, new_y)8 `; i. R4 \# v+ Q4 @+ o. e
  327.     arg = [0, 0].pack('ll')/ h3 `8 Z1 m* ^# A, M* O# f& `
  328.     Screen_To_Client.call(Window_Hwnd, arg)7 v; ^3 Z$ B; {% F: d1 d' b
  329.     x, y  = arg.unpack('ll')
    - t+ E8 v$ s) f4 p8 s6 O
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    * c# B5 k8 R$ Y" L+ D; ?- G- s& e
  331.   end4 x0 i0 g1 N7 p& K# g, F# k; E3 K
  332. end #end of class  self
    ! J" e7 V7 `1 Q$ W5 q1 ?3 t4 v# A
  333. & M  \7 U# g* a8 Q
  334. end( C- R. U& A( I& o5 o

  335. 1 e* A$ P* |' o8 R2 v2 R
  336. #==============================================================================7 E" w8 d5 q/ @+ A
  337. # ■ SceneManager8 [3 k+ S) k5 A& x& `
  338. #==============================================================================0 P. C6 a  I8 ?9 g* Z5 t
  339. class  SceneManager! B/ \7 p1 ~1 X' q
  340.   #--------------------------------------------------------------------------
    * d$ b* V0 `  a# Y- S
  341.   # ● alias, `8 J3 O6 e  s
  342.   #--------------------------------------------------------------------------
    & D  _3 {' E0 x5 A4 b: `& u) ?
  343.   unless self.method_defined(sion_mouse_run): ~8 X" Y" y8 T, X$ A9 _2 h
  344.     alias_method sion_mouse_run, run
    8 M4 m# e. m1 L/ ?2 S! P
  345.     alias_method sion_mouse_call, call: x; m+ @- V4 p# A) {
  346.     alias_method sion_mouse_return, return" D; l  u. C% i1 m
  347.   end6 z$ B$ {7 Z  |* s; @
  348.   #--------------------------------------------------------------------------
    1 R1 Z; N; I/ n8 G8 s
  349.   # ● 运行
    ! @; X! \0 P( z$ H1 \% C
  350.   #--------------------------------------------------------------------------
    $ S0 D- `. A, k: O. `5 o
  351.   def run
    ) C$ r+ }$ G3 m$ n
  352.     Mouse.init, O. }) S1 D; t1 n9 r
  353.     sion_mouse_run' t( f; u* O/ t  f3 ^" Q) o, D# i* M
  354.   end
    - o' L- ]7 q5 O+ v" |
  355.   #--------------------------------------------------------------------------" d& R- z- b2 [7 l; s, A( T
  356.   # ● 切换- \# u( r  d) o
  357.   #--------------------------------------------------------------------------3 Q5 s/ m2 ]. o" L! r2 t
  358.   def call(scene_class)
    ; e- V/ @$ l+ Z' m- D
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)5 L. Q2 C* S$ k, Y
  360.     sion_mouse_call(scene_class)7 o  X7 y' {- p+ {; g/ {3 o; r
  361.   end
    - t& ^5 S; w1 l) b6 A; I5 `
  362.   #--------------------------------------------------------------------------
    0 k3 H+ l$ k9 D$ c7 u
  363.   # ● 返回到上一个场景
    % j) \$ q1 E% D: u) }
  364.   #--------------------------------------------------------------------------
    , a' r9 Y' j3 J
  365.   def return
    ' f" ]) `7 d" F! j* E' C$ ~5 f
  366.     sion_mouse_return, Z$ {7 b  R% z: n7 q0 q
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    ' Z, [$ Z" ]1 T& D+ Q* b1 H5 ?
  368.       @scene.instance_of(Scene_Map)
    7 A+ p1 z) Z/ b) L
  369.   end. X$ s( M  C1 y
  370. end
    3 H7 x2 c2 M2 Q# g5 `; J
  371. . W) u3 N' k9 d2 K
  372. #==============================================================================
    4 z6 G3 D7 G1 j
  373. # ■ Module Input
    . \) d( j8 u9 J8 U7 T" a
  374. #==============================================================================
    ' j- ?* k% l1 U& |6 `+ M) @
  375. class  Input
    1 e& V( T& E# J+ Y
  376.   #--------------------------------------------------------------------------% F) J) T7 T- U
  377.   # ● alias0 T6 s  ]' K$ u  t+ }
  378.   #--------------------------------------------------------------------------4 r2 Y8 ?. D, i: i
  379.   unless self.method_defined(sion_mouse_update); b7 H, `+ Y  ?/ k3 X
  380.     alias_method sion_mouse_update,   update
    2 ^2 S0 @% |6 K4 t
  381.     alias_method sion_mouse_press,   press* j( u/ S: r1 |* A
  382.     alias_method sion_mouse_trigger, trigger
    8 G' _8 y  A% i# i
  383.     alias_method sion_mouse_repeat,  repeat9 t  D; j8 X2 |' V& }1 S
  384.   end& @  G9 y5 Z- H
  385.   #--------------------------------------------------------------------------7 N# y: _% U( T. u( y" R' @
  386.   # ● 更新鼠标* T) \. J( g6 U+ [. y" E8 _) c
  387.   #--------------------------------------------------------------------------
    5 h# U- N2 t( ~) J/ ?5 T
  388.   def update' K+ q3 @8 i* y# p7 m: q7 y
  389.     Mouse.update# \% k. t6 D+ M3 v, L8 a
  390.     sion_mouse_update* V2 y$ m3 S& l3 V  m  d
  391.   end
    & ?. E0 w5 V  ~  j
  392.   #--------------------------------------------------------------------------, g( @- T  U, J/ ^" }. b2 h4 I
  393.   # ● 按键被按下就返回true
    ; S& k) B$ V7 s. Z8 ^# n; e" U# E7 _1 y& ?
  394.   #--------------------------------------------------------------------------
    , z, i7 [6 o+ v7 b9 x
  395.   def press(key)$ G/ H" n; t1 x2 @, o0 p% r2 z
  396.     return true if sion_mouse_press(key)
    : C( K+ [: A: ~) _7 K# A
  397.     return Mouse.press(0x01) if key == C2 p/ {; ^) F" h1 X
  398.     return Mouse.press(0x02) if key == B
    ) W1 P. A* x/ H* X$ _
  399.     return false
    + O+ ?9 V/ N1 [% S
  400.   end
    8 m3 \/ h7 S" m6 I6 U
  401.   #--------------------------------------------------------------------------
    + w6 @. V" ?) i
  402.   # ● 按键刚被按下则返回true
    % h; [$ r2 Z  P" j3 @/ `0 k
  403.   #--------------------------------------------------------------------------
    4 r# T: d' Z5 N0 h
  404.   def trigger(key), K; p4 j8 q6 W8 _: x
  405.     return true if sion_mouse_trigger(key)8 Y" [$ p6 A% K, Q8 |6 d$ m3 R
  406.     return Mouse.trigger(0x01) if key == C8 z/ Z& a1 R9 c+ f5 B  }) c5 E4 W* g
  407.     return Mouse.trigger(0x02) if key == B1 R  q8 W( l# V7 q
  408.     return false! \8 E3 v( S) a2 B% d4 o
  409.   end) h' W" i+ m! n+ a
  410.   #--------------------------------------------------------------------------
    8 a4 q" g* o) U0 ]1 J# w, A
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    ) j7 Z0 A1 P( P$ h# M; q
  412.   #--------------------------------------------------------------------------
    ( Y9 E& N! D0 y% g+ L
  413.   def repeat(key)
    5 e; x; u* ?) `3 _4 g$ @
  414.     return true if sion_mouse_repeat(key)4 C) ~! r" K& a0 ]6 N4 d
  415.     return Mouse.repeat(0x01) if key == C3 {9 K: l- T) K% _$ w) e2 P6 ?
  416.     return Mouse.repeat(0x02) if key == B
    : U4 c  A; e/ v) X
  417.     return false  o+ g( J( N( E7 e8 A9 J  ]( W
  418.   end  d5 P& T! x/ s" H
  419. end
    ' m4 ^# F- `" Y; y0 Q" f. o
  420. " Y4 A' U: D$ N6 @$ s2 w

  421. : o# |: v, ~9 F5 [
  422. #==============================================================================
    3 Z- ^) P& Q! \9 Y0 i( c
  423. # ■ Window_Selectable
    4 A7 B+ g5 \6 o- o6 k% Z
  424. #------------------------------------------------------------------------------7 u' Q/ z  w, q% `$ D
  425. #  拥有光标移动、滚动功能的窗口" e" d) U$ A1 r! V! X+ Q- ]; @" s
  426. #==============================================================================# r- B3 O7 W! w* ?# a! t: Y$ L# y
  427. class Window_Selectable
    1 T% X/ {: \2 V, a3 I
  428.   #--------------------------------------------------------------------------0 c- D" \7 |" B8 }, k' I
  429.   # ● 初始化& l! D5 u4 h1 j- N2 q; v' e
  430.   #--------------------------------------------------------------------------
    , `) n) K0 P4 N% q1 V; A/ s+ q
  431.   alias sion_mouse_initialize initialize- y- S0 h6 l! A# ?
  432.   def initialize(x, y, width, height)
    ! d: [, V4 ~$ w, D& U
  433.     sion_mouse_initialize(x, y, width, height): x) I4 _3 [! z/ V
  434.     @move_state = 0
    ( _' O1 |$ F! S" _- B
  435.   end2 c" y9 i* u% }- m; Q2 W' w+ V$ m
  436.   #--------------------------------------------------------------------------
    - x! {& ]7 |' N) x9 R" G
  437.   # ● 更新2 [: `& n3 }  d' d& r8 V2 B* B5 I
  438.   #--------------------------------------------------------------------------
    9 R5 K& L6 o# s5 Q
  439.   alias sion_mouse_update update/ b  b$ K( Z: Z* F
  440.   def update
    3 n* X) N6 p  H9 N) N2 w' E4 Q
  441.     sion_mouse_update
    9 R  f& _; n$ m8 ~2 Z# M. c) O; T9 C+ a
  442.     update_mouse_cursor) z. M  p3 v1 w
  443.   end
    , a, @  W6 y/ d2 q4 E$ v2 m! ^
  444.   #--------------------------------------------------------------------------
    ' z+ U( }2 i9 W+ N. T9 r
  445.   # ● 启动后设置鼠标到index位置
    3 @" Z: u8 b" g, E( B
  446.   #--------------------------------------------------------------------------/ j2 K! N& Z5 ~
  447.   def activate
    , V# F& ^/ m/ g6 F6 D" @) K
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    9 E: k& f8 k0 h0 v: w
  449.     super
    , m8 e: t8 i! B: y& t6 J! T( B6 m
  450.   end: w' n; a$ o: d5 [+ U- G! p
  451.   #--------------------------------------------------------------------------
      ]  v) d3 _( r1 H! J7 Z7 k2 }
  452.   # ● 更新鼠标和光标的位置$ t3 O) l& t* _; Z
  453.   #--------------------------------------------------------------------------
    % J) A' A, k+ a
  454.   def update_mouse_cursor
    ! I# A2 x6 ?  L
  455.     if active
    6 P" _; f! l1 M. B
  456.       if @need_set_pos1 S7 T, W8 q- V, N' N, j% S6 T) g
  457.         @need_set_pos = nil( C# W8 \5 s+ u, p
  458.         set_mouse_pos3 L0 I! z4 x( @) v! Y; }% J
  459.       elsif cursor_movable
    % Y6 y0 {) B  L
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    1 B; ~3 M+ M, I; G
  461.       end! D! z( B* Y5 ~+ B. y( T
  462.     end
    ! F% K  ~; m8 Q, |
  463.   end
    3 e  G& u; p7 d3 |! _* D
  464.   #--------------------------------------------------------------------------3 G7 E0 n. f# g+ a$ F7 @
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    $ R3 f& p* ?8 e$ z, [; w& m
  466.   #--------------------------------------------------------------------------
    9 V% i; v+ _: j7 H: |2 F: k
  467.   def set_cursor
    * K' M6 T. D2 z' j! l! E- r
  468.     mouse_row, mouse_col = mouse_window_area- a/ Y5 r3 R% d4 p7 Y! _$ l8 ], T
  469.     if    mouse_row == -1
    ) s+ e+ V: B! t6 f& ]
  470.       @move_state += 1 if need_scroll
    0 c% ?- Y% g: i9 y) k
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand. n. p+ f+ Q4 `2 _# g, t
  472.     elsif mouse_row == -2
    9 {; Z% a: B! a) {7 P9 h
  473.       @move_state += 1 if need_scroll
    ) e/ Y. A0 ]4 r$ A4 ]. a, H4 J! {
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand3 o% x7 d5 [0 {. L3 r( K
  475.     elsif mouse_col == -1  P8 A/ K2 x' h) D0 Y/ H
  476.       @move_state += 1 if need_scroll
    9 [6 ^2 M# h' Z  E# z) }4 W
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand' ^, q: C' ^* N$ d
  478.     elsif mouse_col == -2
    6 k/ n- d% }- V" @( R/ @& P
  479.       @move_state += 1 if need_scroll6 q, \  z% C6 ^3 k" |, E
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand: \2 c" l! k7 ~- _
  481.     else: _+ l8 n0 u' k' H
  482.       @move_state = 0+ N# G% E( ^7 g( m
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    9 r) @, J- M% |$ L! |$ e& K8 f
  484.       select(new_index) if new_index  item_max && new_index != @index
    8 y, _& p# U5 X- f/ {
  485.     end# m- l# `$ T9 f3 N/ T
  486.   end
    $ p; {$ i3 n7 I( G
  487.   #--------------------------------------------------------------------------: {  e0 A- }; E! k6 n
  488.   # ● 判断鼠标位于菜单的第几行、第几列/ N" o* f3 u1 G- K6 F( M
  489.   #--------------------------------------------------------------------------
      s. q. o4 g/ A  B. k- A
  490.   def mouse_window_area
    ! ^- |% v, o7 j5 c& D
  491.     if viewport.nil # necessary!8 `4 e' {" W6 h" c5 K3 }5 C
  492.       vp_x, vp_y = 0, 0
    0 K' P8 F7 y& N& O3 G: `
  493.     else
    8 R, \* L" k/ }# n% s$ B, P; U
  494.       vp_x = viewport.rect.x - viewport.ox& |* g1 b$ p! P. U; ?1 w; J* S1 I
  495.       vp_y = viewport.rect.y - viewport.oy' ?- y% O9 x: F, K
  496.     end4 _7 P" X- ~4 `
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    + h% ?  T: x; @& b" x3 X+ @
  498.     item_x1 = vp_x + x + standard_padding
    3 w9 k9 _: I# }) c) m# ^9 G0 o
  499.     item_y1 = vp_y + y + standard_padding* z7 l: W# D6 A1 K% A4 ?
  500.     item_x2 = vp_x + x - standard_padding + width; o! Y7 i8 r# O& o. o% A$ N+ Y
  501.     item_y2 = vp_y + y - standard_padding + height/ N- n- k3 E# J$ n- }( ?3 S+ t% B) M
  502.     if mouse_x  item_x1
    6 K* r3 D$ ~  N. B9 m  L( g, r. Y
  503.       mouse_col = -15 v. o' f2 s; h$ \: Q
  504.     elsif mouse_x  item_x2, a+ i9 G7 W: I& B# p6 T  @  v
  505.       mouse_col = -29 l2 j" G, T! E1 ^$ Y& d
  506.     else
    4 ?, m0 Q" G8 v; E, u/ G
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    9 o& w4 r7 ]/ _, j
  508.     end* z; X; m$ T: @: x% l9 G" {
  509.     if mouse_y  item_y1; ?' f! u, c; @$ a
  510.       mouse_row = -15 X# L. `! _2 ?& j
  511.     elsif mouse_y  item_y2
    4 M+ {/ C. {% J+ [5 q3 D/ d
  512.       mouse_row = -2: L; v/ m3 G5 k- ^0 E
  513.     else9 y0 g- ?0 T" H; ?- B; M7 K
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)4 `6 [1 D: K6 q
  515.     end
    9 h0 _+ b, t+ z! a" {
  516.     return mouse_row, mouse_col
    9 j" H+ f# n$ _) Q( c2 G
  517.   end
    2 C! ?& ^6 O" ]. j2 M# I1 K& B
  518.   #--------------------------------------------------------------------------
    4 k; g) }; H4 S# R' @  f0 }
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置: m( m9 e# o$ |2 M8 `2 k
  520.   #--------------------------------------------------------------------------
    , X$ S+ N' v% i' Y9 v! d; j! E6 D
  521.   def set_mouse_pos) O4 H8 ?1 }/ S2 x$ u" z3 T% B7 g. @
  522.     if viewport.nil # necessary!* C- G3 `) n3 R4 c" {6 ~; Q1 Z
  523.       vp_x, vp_y = 0, 0
    5 {; e" W# f( \1 {4 }5 `/ ]( J
  524.     else& d1 r; e( b& s# I0 s
  525.       vp_x = viewport.rect.x - viewport.ox* T1 J! W3 _& P, ~. E! i* r% ~7 ?# k
  526.       vp_y = viewport.rect.y - viewport.oy7 X; e7 A  T& X4 [
  527.     end
    , K, ^  ~* U2 C" D- l
  528.     item_x1 = vp_x + x + standard_padding ) T" X! A5 C" \9 S, p3 G4 s  ?
  529.     item_y1 = vp_y + y + standard_padding1 U. l4 G0 p/ @) F% I+ t
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index : @1 a6 h. n# Y5 }" N
  531.     row = get_index  col_max - top_row! ]; w; E5 L# B9 j( _4 {/ K
  532.     col = get_index % col_max
    ' H9 l2 w6 z9 M( p( y- d
  533.     new_x = item_x1 + item_width  (col + 0.5)
    / m) x+ \; C3 @* T  j
  534.     new_y = item_y1 + item_height  (row + 0.5)
    $ l1 w( e9 V5 G% v5 c4 f+ @3 b
  535.     Mouse.set_mouse_pos(new_x, new_y)' f& b) x/ s1 A0 D2 S2 }+ i
  536.   end! z" b1 G/ ]! e( Q! d
  537.   #--------------------------------------------------------------------------0 T8 T4 o9 t4 v. p5 V6 e
  538.   # ● 判断菜单是否需要卷动
    , j; d: P1 q% N/ ^+ R- ~- T; w: ]0 L
  539.   #--------------------------------------------------------------------------$ ~4 r) n. M6 a6 n' N! l" L5 r: O
  540.   def need_scroll
    ! k. o& M) \, V* N
  541.     item_max  col_max  page_row_max3 D( b. l5 A2 f+ J
  542.   end# {1 C+ E- C  ?& Z' S
  543.   #--------------------------------------------------------------------------
    : T: }: [8 F$ s; U5 K
  544.   # ● 判断是否为水平卷动菜单' X/ o6 x! w* i. i
  545.   #--------------------------------------------------------------------------
    . t4 i+ G4 J: T4 |& x* Z
  546.   def is_horzcommand
    8 C: J% a$ P! \4 c, n; e, V
  547.     return false
    ( o9 g& d/ E- j; t9 z% b7 _
  548.   end/ ]  R0 ]1 O+ X  J( Q. f* b8 [1 p
  549. end' a. t) t0 x# O. l3 U( s& b0 }

  550. ) |; I9 Y! |* J) F
  551. class Window_HorzCommand7 ~2 i0 `# D5 Y5 i8 {
  552.   #--------------------------------------------------------------------------! x- v- @% h+ }( |
  553.   # ● 判断是否为水平卷动菜单
    0 t. o1 d4 n" N
  554.   #--------------------------------------------------------------------------
    + [7 u9 h* W; J% A; j/ D% o  v
  555.   def is_horzcommand
    ( q5 d" Y4 c9 B* z* d- m
  556.     return true9 x/ a9 W' J* b, w. Q
  557.   end
    ! O; f, ~( }3 _* U4 A1 ?2 ~5 L
  558. end
    * `" \3 A4 Z; D0 N0 j4 P2 O
  559. " L9 g3 k5 w3 N7 E) H  Y
  560. #==============================================================================
    , {$ S  l2 ?# x8 F& `
  561. # ■ Window_NameInput
    & i2 S. x) U! H
  562. #------------------------------------------------------------------------------
    6 q* r2 U8 d5 X( I5 U
  563. #  名字输入画面中,选择文字的窗口。6 Q! x2 J8 z! j& }2 ]3 A
  564. #==============================================================================
    ) y5 w$ E# d  k
  565. class Window_NameInput+ I1 V& Y! U' ~$ r+ D
  566.   #--------------------------------------------------------------------------
    ' i3 K' ^: O( @
  567.   # ● 设置列数
    8 j0 z5 g7 [' `. m) i$ L
  568.   #--------------------------------------------------------------------------
    " r# ^" u% @/ T
  569.   def col_max
    / i* w; J( S3 r, {8 K( M7 W4 i
  570.     return 10  [* c& c7 u6 P- \5 ]
  571.   end" ^/ B4 b- z" D4 B) @; T: A" H( u
  572.   #--------------------------------------------------------------------------8 p) n8 v# C" C, j
  573.   # ● 设置填充的Item个数
    & b- [; c! e5 U$ Q& p
  574.   #--------------------------------------------------------------------------
    " D3 c" w; @. _: A& [7 W3 [
  575.   def item_max9 q9 `6 p* D- ~" |2 Q$ V
  576.     return 904 X0 I$ C' p( n$ H5 h
  577.   end& b/ r) T' {  {; B. \) G" v. ?. d- w4 H
  578.   #--------------------------------------------------------------------------
    4 _& G; \$ V# R; Y# F, V% v  r0 K4 o
  579.   # ● 设置填充的Item个数
      J4 W- e0 ~9 m5 v0 k
  580.   #--------------------------------------------------------------------------7 ^9 _6 X  U7 U9 z, ]* [
  581.   def item_width
    . t" x, L  V0 e: Q1 V- Q
  582.     return 324 G9 D9 F; h1 E  F. Y
  583.   end
    6 N: G+ b. m6 w3 A: \: ^
  584.   #--------------------------------------------------------------------------
    & J) {- c0 ~! `! ]
  585.   # ● 判断鼠标位于菜单的第几行、第几列
      `3 S, K2 D7 y& w) L
  586.   #--------------------------------------------------------------------------
    ! N  @8 m3 A1 ]2 ?. z
  587.   def mouse_window_area' D: d7 E2 s4 T& Z
  588.     if viewport.nil
    ) I* j# ?0 \2 v/ U2 k
  589.       vp_x, vp_y = 0, 0
    + V+ P) s8 {' c$ T
  590.     else9 |8 E( R9 @0 p* j: |
  591.       vp_x = viewport.rect.x - viewport.ox2 Z4 w& A7 f9 u" j7 D
  592.       vp_y = viewport.rect.y - viewport.oy1 ]1 l# u1 H+ D1 d5 i  @4 ?# |4 {
  593.     end
    + q* [6 s& a% d1 j: {$ F/ u
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y" q! ?1 a0 A# r! `6 p0 `  w
  595.     item_x1 = vp_x + x + standard_padding
    1 A7 d' _# w# z# D  _
  596.     item_y1 = vp_y + y + standard_padding
    ( X' H0 h% ?* K3 m# r, R
  597.     item_x2 = vp_x + x - standard_padding + width2 K4 K% \- @0 B2 |; w, J
  598.     item_y2 = vp_y + y - standard_padding + height  ?% E8 j: y( O0 V- s
  599.     if mouse_x  item_x1
    ; I+ [& p( g, x
  600.       mouse_col = -1
      |2 u9 A; q( B- `2 i4 Y
  601.     elsif mouse_x  item_x2
    - Q/ o& ]# @8 k! d: r, v
  602.       mouse_col = -2# L6 P7 F+ Q, ]* Z3 p1 M+ Q8 y
  603.     elsif mouse_x  item_x1 + 160: k0 X. x! F* `" C. B' P; N4 l9 q/ [
  604.       mouse_col = (mouse_x - item_x1)32$ k8 n% t8 ^- q5 v' P- v
  605.     elsif mouse_x  item_x2 - 160$ K3 n  S, U$ C
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    3 C' _' B6 w1 U* ~
  607.     else# I0 |4 h2 `$ C' x& J1 r! k
  608.       mouse_col = mouse_x  x + width2  5  42 H: e: p0 r( [% n0 y/ i2 b
  609.     end5 s: L# n1 b2 ?7 {* p( t
  610.     if mouse_y  item_y1
    & v% O1 z  V; H: n, K
  611.       mouse_row = -1
    : ^7 f: S( Y/ n" }) f- N
  612.     elsif mouse_y  item_y2- |# |  W- g; H
  613.       mouse_row = -27 h* p7 A, h5 }6 b/ Z! {2 C
  614.     else
    + b, I' ~. b$ \3 c* P- t
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)  r1 D2 @4 i" T$ g( y
  616.     end9 f& T! I5 E' T+ B3 h9 I- E
  617.     return mouse_row, mouse_col  ]9 \/ R- S. I: \0 s
  618.   end
    ( U4 t9 A& l* `8 Q
  619.   #--------------------------------------------------------------------------
    2 ?& x& X* F+ t% h8 @
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    3 \; l1 L0 k+ }* i3 O5 A
  621.   #--------------------------------------------------------------------------4 c# Z8 [9 Q- H% u+ q6 p- G$ z
  622.   def set_mouse_pos
    / |5 Y: p/ T, D: H5 d8 ~) d- j: Z
  623.     if viewport.nil # necessary!9 n. ~) N; Z; F& O; z2 X
  624.       vp_x, vp_y = 0, 0
    4 b! [) |# n0 W- T! f9 O
  625.     else
    ! e  f! T2 X3 S4 v! e+ U% x1 D3 U
  626.       vp_x = viewport.rect.x - viewport.ox
    2 H6 x* Z+ ]: x) u8 ?
  627.       vp_y = viewport.rect.y - viewport.oy. D/ ~, k, F1 C3 O2 }, X  p9 ?. \
  628.     end
    $ D4 w- D6 _( h3 ~/ q
  629.     item_x1 = vp_x + x + standard_padding   Q9 s2 k8 s5 B: ?
  630.     item_y1 = vp_y + y + standard_padding' [- l+ l+ P/ q! Q! P
  631.     get_index = @index  0  0  @index
    1 g& [" u" w, l! M+ U/ d
  632.     row = get_index  col_max - top_row) h3 B) ~0 J3 D1 c
  633.     col = get_index % col_max
    ) T) G2 f* I2 w  a5 e+ I
  634.     new_x = item_x1 + item_width  (col + 0.5)" Q: T: ^8 j6 V0 `: I
  635.     new_y = item_y1 + item_height  (row + 0.5); O7 ]/ n: O+ ^' O9 l  r2 X
  636.     new_x += 14 if col  4: N0 d9 i8 Q. p
  637.     Mouse.set_mouse_pos(new_x, new_y)" W: E% Y2 O1 z  p  \
  638.   end
    7 d% w) C( F' R3 {
  639. end- @  w# m' f* F, ]

  640. 1 `5 M$ Z: X: O1 K% ?" k0 [
  641. #==============================================================================) a  ?/ \6 G$ u" C9 F/ I: K
  642. # ■ Window_NumberInput
    ! E* E4 y5 ?; T3 w' E6 A% h
  643. #------------------------------------------------------------------------------
    & j2 }. L3 X& D8 T, R8 w, T  s
  644. #  重写了数值输入的方法以适应鼠标
    ! \0 n, a4 H6 i1 f3 u' q
  645. #==============================================================================( {( N& v& _/ c# I1 I" y  u* w& y
  646. class Window_NumberInput  Window_Base
    . K% f8 A2 u( [2 x- R2 X
  647.   #--------------------------------------------------------------------------+ B( [5 N0 z2 M, D) c, S: \0 K
  648.   # ● 定义实例变量6 Y) B: X5 y2 b5 Y5 I0 d6 d- E, H
  649.   #--------------------------------------------------------------------------
    ) P& O7 t! A1 K
  650.   attr_reader extra_window6 s7 ]0 A+ d. S$ _8 i
  651.   #--------------------------------------------------------------------------' c/ v9 ?) w* q
  652.   # ● 初始化
    3 }7 k3 w9 p# h) s
  653.   #--------------------------------------------------------------------------; r7 w3 ]' T1 D$ y
  654.   alias sion_mouse_initialize initialize
    4 u  |: ^5 f1 U6 x3 q
  655.   def initialize(arg): Z+ l5 d; M/ `8 J6 D1 M
  656.     sion_mouse_initialize(arg)1 M, \* D+ Z/ Q; e$ P2 V
  657.     create_extra_window
    7 w2 J8 G/ n5 u  z
  658.   end6 D* W( ?, k: j7 ]+ ~
  659.   #--------------------------------------------------------------------------3 n& T/ z8 j8 v1 k
  660.   # ● 启动
    3 l  ~1 M4 t, ?' N2 K
  661.   #--------------------------------------------------------------------------  \3 Y0 K0 _0 n5 S! D8 X
  662.   alias sion_mouse_start start
    : C/ d" a' w( e4 Z9 |: p
  663.   def start
    8 y" `5 F) a" s( J5 T5 u
  664.     sion_mouse_start
    ' H2 ?0 r% S2 Q# m# o
  665.     deactivate9 ]1 N5 H& h7 i$ m
  666.     extra_start  [8 F5 n) V5 |& l; Y0 o
  667.   end
    : {. E1 H* k- p5 J0 H6 Y% B$ R, P! C
  668.   #--------------------------------------------------------------------------. u) G) }; y$ ~0 I( U. Q
  669.   # ● 创建新的数值输入窗口1 S; S! ^, y% l) x* r$ _1 C
  670.   #--------------------------------------------------------------------------; z  d0 z! }; @# x  H& y% H! C
  671.   def create_extra_window
    % @4 B5 X1 S, l0 D; h
  672.     @extra_window = Window_NumberInput_Ex.new
    / P2 P$ i; [5 D! p7 X
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    6 _/ V5 p) ]" m9 K- g8 |: w
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }+ L; r/ l+ K5 \" e3 y2 p( `
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    3 n- B/ g5 U8 ?* r" }
  676.     @extra_window.close_proc   = Proc.new { close }
    1 r5 d9 {; O! V3 I
  677.     @extra_window.refresh_proc = Proc.new { refresh }% `1 ?8 K4 B, w1 A- o% j
  678.   end
    - Z( E" g% H8 l9 Y* q. D
  679.   #--------------------------------------------------------------------------
    5 K8 [; b* P2 j6 f( [- s
  680.   # ● 激活新窗口$ {3 }+ J% A( e. e& y
  681.   #--------------------------------------------------------------------------
    - _5 ~. n7 V% [( a! j5 p
  682.   def extra_start8 y9 ?: d5 W4 A+ e( }3 o) x. ?
  683.     case $game_message.position. q5 v3 Q; K! O& ~8 I
  684.       when 0; @extra_window.y = y + height + 4
    ) @4 w; n6 r9 L$ ]" W; z1 |/ `
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    ( E5 Y3 p' S3 m" w# \
  686.       when 2; @extra_window.y = y - @extra_window.height - 44 B' X  ]: Z" w0 U  h6 M9 Z1 d6 U. c
  687.       else  ; @extra_window.y = 8+ P, ]- c$ {3 F4 a( P$ e. s
  688.     end* H* P; S* g, p3 Y9 G% K
  689.     @extra_window.variable_id = $game_message.num_input_variable_id6 m4 I* ^+ [( L/ k
  690.     @extra_window.digits_max  = @digits_max& J: m7 c9 y$ T3 U$ ]; v9 ?& A( S
  691.     @extra_window.number      = @number! h4 q5 h6 i2 p! b$ _/ q# U+ r! r1 J
  692.     @extra_window.open
    9 \+ l5 i/ [0 Q2 Y  i7 V" K
  693.     @extra_window.activate
    2 ?- G$ f) G% L% g  _
  694.   end
    $ o# t& H9 @6 ^) |
  695.   #--------------------------------------------------------------------------
    / k2 k) V3 P! n( Q! c: Y4 R
  696.   # ● 更新2 _" n3 C- H4 n2 M& o9 Z3 U8 v* `
  697.   #--------------------------------------------------------------------------1 C/ e. `" b/ i* t- g; m0 j
  698.   def update9 a, [2 L" k. p
  699.     super
    ( \/ p* R% A0 F4 ?7 ^# c2 b/ W
  700.     @extra_window.update% u' Q% T- W3 Z+ }8 K9 O8 @
  701.     update_cursor
    $ N+ O  x6 `- {; j" ^  x
  702.   end! \8 P! s9 p/ G5 @
  703.   #--------------------------------------------------------------------------, \" A9 ~' v. M: `3 @9 G9 o
  704.   # ● 关闭窗口5 U3 o5 g1 V5 v' ?: ]. N2 g' J
  705.   #--------------------------------------------------------------------------( O* U  d7 N9 Z$ f0 u
  706.   def close' f  R- v' I' a2 U( f, g- }
  707.     super9 T+ v& [0 i% H5 k
  708.     @extra_window.close1 I9 z1 }0 S& u' e6 S' V
  709.     @extra_window.deactivate5 L) P& _% E' N1 W
  710.   end
    , ]& d8 b/ t+ B
  711. end
    ; Y# O8 m8 ]! G
  712. ! U; A# |0 @+ l
  713. #==============================================================================" W$ K) Z# N( V& `( x" r2 `+ E5 \5 ^
  714. # ■ Window_NumberInput_Ex! U& ?6 c8 G! @' B4 w4 ~4 r! w
  715. #------------------------------------------------------------------------------7 ?7 V) `+ c* _- e
  716. #  新的数值输入窗口(NewClass). ^6 Z) C1 l8 ]! [. V, W2 b$ x
  717. #==============================================================================
    6 L% g( |3 T- ~2 j
  718. class Window_NumberInput_Ex  Window_Selectable
    ' N: o: h0 T) j. O" F$ {$ J- `8 r
  719.   #--------------------------------------------------------------------------
    ( w( U; _9 C! k# f
  720.   # ● 定义实例变量+ C1 w, t  L  I# j$ Y2 g" y
  721.   #--------------------------------------------------------------------------( \- x' ~1 m; Y8 s( H3 \
  722.   attr_accessor number_proc
    ( A) b" I# O( o! y4 K
  723.   attr_accessor index_proc; `7 n& \! }# Y( z
  724.   attr_accessor close_proc
    4 `# ]2 [8 p! `$ C
  725.   attr_accessor refresh_proc( k3 ^. v( P# W8 ~' r" X
  726.   attr_accessor number
    6 ?$ O8 u2 X0 h8 M8 T/ X  L
  727.   attr_accessor digits_max
    4 ?' s! u% w! p/ c, `- L
  728.   attr_accessor variable_id
    1 B! i+ T* h9 A6 |6 C' e9 v
  729.   #--------------------------------------------------------------------------
    . I( `5 K' V# l. P
  730.   # ● 数字表
    7 @; _, ]1 ?  K" K
  731.   #--------------------------------------------------------------------------- g" B, ?' V1 j' A" o" O1 [
  732.   TABLE = [  7,  8,  9,
    ; a8 N) q0 ?6 R6 q8 ?2 q7 b
  733.              4,  5,  6,
    9 G- {2 G# I# B+ u- w
  734.              1,  2,  3,
    6 m& v# F7 P8 @
  735.             '←',0,'确定',]/ W# k# X) G. b* C/ W# {. R+ ~
  736.   #--------------------------------------------------------------------------
    8 I, G# ?% ?7 H: E
  737.   # ● 初始化对象
      n* ^6 J& |# T1 L
  738.   #--------------------------------------------------------------------------( F: H6 L9 }( Y: P) M( q1 f
  739.   def initialize) O/ a: |, \* ^# |
  740.     super(0, 0, 120, fitting_height(4))$ Q7 Z! E( N- o) G
  741.     self.openness = 0
    ) x) M; G4 k6 \4 b" ?( G5 f; O
  742.     @index = 0
    % H* e% ~# j4 K$ r/ G
  743.     @number = 0
    ) @) C% M6 B3 M: R; g- i
  744.     @old_window_index = 0
    ' K% c; K4 l0 x+ R
  745.     @digits_max = 0
    - D: p; y0 g& v7 ~# l) N: W
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    ' k% z" K5 l3 E; D* O8 _
  747.   end
    3 e4 U9 D3 f/ z9 r5 @7 l3 u/ t
  748.   #--------------------------------------------------------------------------
    . J: m0 X* i0 }/ Y9 {
  749.   # ● 获取项目的绘制矩形  |/ P7 i% ^0 k6 f" o, p
  750.   #--------------------------------------------------------------------------' [' Q5 \1 Q6 a6 @
  751.   def item_rect(index)3 o3 d9 M' N: ]0 O7 b" Z$ N
  752.     rect = Rect.new
    % q6 N2 ~. S6 O$ G+ G
  753.     rect.x = index % 3  321 M* r6 N1 t" i* d: s; d$ `! M
  754.     rect.y = index  3  line_height
    % _0 M% x0 d' S/ M
  755.     rect.width = 32( ~# l- o7 H3 N9 q9 g
  756.     rect.height = line_height) ?! K; I+ I4 s+ H2 \
  757.     return rect
    ( W! F. p: z7 C/ c
  758.   end
    5 X; m# c) j: B; W
  759.   #--------------------------------------------------------------------------1 ~5 ?; l$ n9 i& [$ J$ R' ^
  760.   # ● 将光标设置到鼠标所在的位置" M$ q" Y! e3 h' U% J9 j2 ~& T
  761.   #--------------------------------------------------------------------------
    , c- k7 D" b9 A2 V+ n% c3 r
  762.   def set_cursor
    . w1 T% ^$ @, p: k9 u1 S* Y5 |# O' k
  763.     mouse_row, mouse_col = mouse_window_area
    ' R# H3 L0 B! s( Z: B- x
  764.     if mouse_row = 0 && mouse_col = 0) y; p, M: V* f% C4 a# z6 |
  765.       new_index = mouse_row  3 + mouse_col' d. i4 W4 D5 H  ?
  766.       select(new_index) if new_index = 11! s8 s) x" l: H. M
  767.     end
    3 @4 N; @* K. i8 b  `0 y
  768.   end
    9 |  g! ?0 x1 B* y
  769.   #--------------------------------------------------------------------------2 g& [# m& t: G, F* p/ b
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列5 T7 R/ I! l8 t5 Q: e
  771.   #--------------------------------------------------------------------------
    8 D8 W7 I, V8 R/ d3 X/ I
  772.   def mouse_window_area
    0 ]7 G6 T/ O4 W$ n; X
  773.     if viewport.nil' }  K4 M' |! q$ _6 o! c0 T: W/ a. x
  774.       vp_x, vp_y = 0, 0$ L9 i3 O) a, l$ q6 P8 O: E
  775.     else
    3 q$ v2 {; F8 H  z3 Y# d- h: N
  776.       vp_x = viewport.rect.x - viewport.ox& }; l' [4 O! _: \
  777.       vp_y = viewport.rect.y - viewport.oy
    ) B! m" Y4 C$ u) e
  778.     end9 x9 }) H# p# x$ l$ X& j5 w
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y5 n# {& b5 D( r+ C- s' L
  780.     item_x1 = vp_x + x + standard_padding 8 y+ N+ s! v1 H* ]
  781.     item_y1 = vp_y + y + standard_padding
    ' Z0 p- t+ ?; h4 u( B2 s+ e
  782.     item_x2 = vp_x + x - standard_padding + width" e, T# L% \, g" a8 f0 t
  783.     item_y2 = vp_y + y - standard_padding + height8 |% ?# n  }) ^4 Z
  784.     if mouse_x  item_x1! e+ G% |' C  B% m/ d) E
  785.       mouse_col = -1
    6 D) A5 |1 i) T: X# A, l
  786.     elsif mouse_x  item_x2$ M% s: x0 {2 m5 L% v; e
  787.       mouse_col = -2
    9 i8 {& r9 x# @5 [+ [
  788.     else" S4 }  ^3 F: c3 S! @6 u
  789.       mouse_col = (mouse_x - item_x1)  32
    3 P8 V* E; Y5 O1 X7 T; S8 t
  790.     end
    ! Y! E% O& ~- J% u& j2 t# ?
  791.     if mouse_y  item_y1# q8 X- t0 H: Z* a: O' t
  792.       mouse_row = -1
    ( y* ^% d' E/ J$ m
  793.     elsif mouse_y  item_y2% K" `  e4 v) Z2 }* P! x$ D2 d1 X
  794.       mouse_row = -2/ P9 y; B- n- A9 S3 z! i" F
  795.     else0 n- a; T2 C) q' G1 s/ v
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    ' u2 _, k' q* B! u/ C" g
  797.     end: p5 [2 ?; s; V1 \* {
  798.     return mouse_row, mouse_col
    / X- b2 L' S' [$ W( X
  799.   end
    9 Q  o( W4 `4 r7 X: |1 q
  800.   #--------------------------------------------------------------------------$ v& \3 M+ T% R' X5 k
  801.   # ● 获取文字
    $ A3 X" s5 Q& [* |6 O0 [* j
  802.   #--------------------------------------------------------------------------
    7 x0 @, G4 W. B9 Y1 T1 F
  803.   def get_number
    5 B( W0 V) S* o3 I: C4 j
  804.     return false if @index == 9  @index == 11
    & @7 o" ^5 o  V( J! y! P
  805.     return TABLE[@index]
    & m4 z% j0 y3 k) o% I
  806.   end
    7 Q2 |& {+ a+ B6 f" C/ ~: `% Q
  807.   #--------------------------------------------------------------------------$ h. @+ [* G4 s! D0 v  b% [* @
  808.   # ● 判定光标位置是否在“退格”上
    4 X4 E0 [" Y) b1 b+ C" `7 m: M
  809.   #--------------------------------------------------------------------------# c4 q. w# _! [0 [/ I2 r" V6 w2 u
  810.   def is_delete
    9 M. J8 l/ C4 g& C8 l. n  K# t
  811.     @index == 9# p0 S8 U# R+ K; e/ |
  812.   end
    0 P. y: X6 e% |! p# l! B& U
  813.   #--------------------------------------------------------------------------
      P1 N$ B4 R. q% A3 h
  814.   # ● 判定光标位置是否在“确定”上
    6 M; [6 m5 J' r/ g# a
  815.   #--------------------------------------------------------------------------
    0 H: _) l( h5 @8 S) x7 P
  816.   def is_ok
    % L  A& {  U% t
  817.     @index == 117 y/ A6 l1 @& |( Z) c, |2 C
  818.   end
    6 h  y- t8 C5 l( N4 G
  819.   #--------------------------------------------------------------------------# x, x# T  j: ?
  820.   # ● 更新光标+ P& s1 o- X  R6 f" r% I+ ?
  821.   #--------------------------------------------------------------------------
    5 Z: l9 H. [# m+ W* W$ _
  822.   def update_cursor
    & V  V  ?+ V6 J7 D6 c' t
  823.     cursor_rect.set(item_rect(@index))! U1 I. B: E& K$ O+ M) j- f6 E7 E+ ?
  824.   end" L* g1 Y: g' x* {
  825.   #--------------------------------------------------------------------------
    2 w2 [0 I$ Q9 H- q
  826.   # ● 判定光标是否可以移动* R$ S$ q8 k1 }: ~8 r0 C0 |
  827.   #--------------------------------------------------------------------------
    ( F6 L3 K/ n3 ^& i
  828.   def cursor_movable
    ( d0 H7 _0 ~& t* n! x' }
  829.     active
    # ?8 v* e4 M* E0 Y. |7 x
  830.   end$ v4 R- Y% k6 X
  831.   #--------------------------------------------------------------------------
    6 X# I' g  D/ b3 U7 d
  832.   # ● 光标向下移动8 T# l4 w& l0 i1 x: W
  833.   #     wrap  允许循环7 ?4 t# E) ~; ~7 [* O, O+ N9 Q- ]
  834.   #--------------------------------------------------------------------------
    0 {/ s- y$ ]" j, y
  835.   def cursor_down(wrap)
    & F4 E, b: c2 Q
  836.     if @index  9 or wrap1 m) X9 ^2 f. w* O3 [
  837.       @index = (index + 3) % 12
    / t8 o, W( F) _
  838.     end
      Q0 z5 X, q0 `# F/ ~/ G& e5 `
  839.   end
    * h8 E9 X' i! m2 s0 {$ v) ]; B: U
  840.   #--------------------------------------------------------------------------
    7 x4 l- X% M, `
  841.   # ● 光标向上移动
    , t) `( f$ V  d! i- A8 F* k& L
  842.   #     wrap  允许循环
    # B5 {+ q. M, `2 Y! Y8 a
  843.   #--------------------------------------------------------------------------
    ; U% n3 |) G$ c6 d9 o# f5 \- Q8 a
  844.   def cursor_up(wrap)
    , e& z/ l" I% s
  845.     if @index = 3 or wrap
    3 t3 M2 t9 s+ {& E
  846.       @index = (index + 9) % 128 L) Q# U9 J8 M$ R) z4 H$ P
  847.     end! f% U% |) g2 q1 {5 V
  848.   end1 B$ `# P7 B* x
  849.   #--------------------------------------------------------------------------
    7 s4 r2 T2 B8 U5 F+ f  Z0 {6 Z
  850.   # ● 光标向右移动
    - \2 {' Y$ p- B  }2 h3 |- f9 g& P# f
  851.   #     wrap  允许循环9 z1 j1 X0 F6 F, N- u+ B
  852.   #--------------------------------------------------------------------------
    ' f4 n$ f6 u. V8 P4 h5 B
  853.   def cursor_right(wrap)
    $ ~# Z2 I; H/ D; u& }8 O
  854.     if @index % 3  2
    ! X$ G, v( s# a8 n% x, L
  855.       @index += 1- F+ o( M: P' Y
  856.     elsif wrap
    " t+ ^* m" n+ L# q  P; H" ^! f
  857.       @index -= 2
    " _3 o/ _0 C+ F; L+ }
  858.     end
    # l2 ]9 V! ^: i: S  t2 q
  859.   end7 G' o- ?$ e% L; E* Y; L* ^
  860.   #--------------------------------------------------------------------------
    % f1 S2 I7 F# r5 y
  861.   # ● 光标向左移动
    * F* H7 A, F3 U6 r5 E
  862.   #     wrap  允许循环; Q' _+ \1 ]) l# ~  [& u# y
  863.   #--------------------------------------------------------------------------
    1 p; v$ e1 v& v, i
  864.   def cursor_left(wrap)  H& a& v, n  D& C  O! O! ~
  865.     if @index % 3  0
    2 x7 K5 m/ D/ P& Y2 l8 W) W
  866.       @index -= 1
    ; d/ m! i+ \" T# g5 v: n
  867.     elsif wrap- I1 P. ?7 s- |$ R3 }7 \& w
  868.       @index += 25 T! m$ {% O) ?) y3 [
  869.     end0 l5 x+ j' E! \1 n/ `
  870.   end
    + t) |1 d& i/ O6 J3 j& T! W1 _
  871.   #--------------------------------------------------------------------------
    ' h" ]* N" S; g/ {9 e
  872.   # ● 处理光标的移动: g+ g$ J2 `( c7 @, ]  {
  873.   #--------------------------------------------------------------------------
    . I) h1 A( V. F- M
  874.   def process_cursor_move* U( e+ S) W: G9 W, W" ~9 G7 i
  875.     super% m" ?7 m: ?0 ^) p
  876.     update_cursor
    2 c0 c0 Y  s2 ^1 o
  877.   end
    4 ?: @/ \4 C1 T
  878.   #--------------------------------------------------------------------------
      `1 b: ?! R9 J, p( m3 Q3 U
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    3 T/ _( v; k$ }
  880.   #--------------------------------------------------------------------------. D8 D4 {& f$ J: S
  881.   def process_handling) [1 E, l' D* E' a# H8 M# A6 N
  882.     return unless open && active
    / j$ s$ z. V' V2 M8 I
  883.     process_jump if Input.trigger(A)
    % q% ~6 N9 M, @$ l' O- d
  884.     process_back if Input.repeat(B)0 Q* u. U, M/ u; l
  885.     process_ok   if Input.trigger(C)
    ; Y1 D9 G. B) p* P1 s% {
  886.   end
    ) k, n. C! `( G  p) e* t, S
  887.   #--------------------------------------------------------------------------
    5 i" n# U+ \; ?( A9 n
  888.   # ● 跳转“确定”  G1 X7 @2 W- ?) L. _
  889.   #--------------------------------------------------------------------------# ]0 ^  H& L  x: \( i+ T6 ?
  890.   def process_jump) N0 F$ v6 W1 J! B
  891.     if @index != 11
    9 I1 C! ~' q1 q# a4 C1 g
  892.       @index = 11( H4 w& H7 P8 I  b' z& _
  893.       Sound.play_cursor
    ) M! W" y# o9 u( f$ S$ {
  894.     end+ A5 S7 U4 N+ C- \. _8 q! R
  895.   end
    5 d! ~% u' o& w4 S; h2 r
  896.   #--------------------------------------------------------------------------3 ]3 k( m! q3 Z* [0 k# r) Q
  897.   # ● 后退一个字符
    / g+ q3 q2 N; j  L+ X$ X
  898.   #--------------------------------------------------------------------------1 Z% _) n2 x+ V1 @; F4 u
  899.   def process_back
    $ \8 [6 l1 k, t8 e' P! ^8 J* G6 {
  900.     Sound.play_cancel
    : n5 j# r1 V& e# P8 z
  901.     place = 10  (@digits_max - 1 - @old_window_index)+ e1 q. p6 a" O! u8 z6 x
  902.     n = (@number  place) % 10% F* [. R3 @9 Q
  903.     @number -= n  place7 z- v/ x6 i+ p2 \9 f8 J9 B! a
  904.     @number_proc.call(@number)
    9 d0 Y8 \1 K* f) t2 b2 e5 g- t
  905.     @old_window_index -= 1 if @old_window_index  01 c0 U; l$ z5 O, M* l" b; U
  906.     @index_proc.call(@old_window_index)  ~6 ]1 K& u; D5 \
  907.     @refresh_proc.call4 T8 b6 x0 ^  }) m& y4 o/ Q5 J
  908.   end
      S1 N, i7 k, {3 T  ?
  909.   #--------------------------------------------------------------------------: K  \  H4 L5 B# a5 S4 \" V
  910.   # ● 按下确定键时的处理! Q' D" K9 J3 T4 j* y0 t! D9 C
  911.   #--------------------------------------------------------------------------
    $ P/ Z' Z5 X' E3 \" ]" _0 O4 W& u
  912.   def process_ok
    $ S0 a: _- n: O4 O; t) Q6 U
  913.     if get_number( K* S5 Q$ M8 y* ?3 @
  914.       Sound.play_cursor  w$ E3 N& U9 M5 P; \4 I% V* [. j, d
  915.       place = 10  (@digits_max - 1 - @old_window_index)0 A2 X" X; W8 H8 c$ t0 V2 y1 q
  916.       n = get_number - (@number  place) % 10
    $ P6 O4 ^7 u# A& s. M8 `2 ~
  917.       @number += n  place
    ) T8 V% w/ U% m, p1 G
  918.       @number_proc.call(@number)
    - L& O$ ?8 n/ A. n9 X8 B  L
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    ' t2 x) l$ N( I4 `. e, n  S
  920.       @index_proc.call(@old_window_index)
    ! O4 d0 m! w# }* l) I5 \7 O
  921.       @refresh_proc.call
    $ ^, e3 S* G$ G# F5 ~; K( v+ V
  922.     elsif is_delete
    - M" Q7 W+ a0 h# V) q' g
  923.       process_back
    ! e& g$ _# K% e0 ?8 f3 h
  924.     elsif is_ok6 |9 t& X  q7 v1 Z
  925.       on_input_ok
    6 p$ {) x) X$ V2 D
  926.     end
    9 r' P5 L1 P- t- ^9 V2 r
  927.   end1 \0 @' h: B" T* i. s; T3 T, ^
  928.   #--------------------------------------------------------------------------* `$ p3 B& D1 P+ B5 p2 T1 h* R
  929.   # ● 确定5 z1 v: u2 o; R
  930.   #--------------------------------------------------------------------------  q8 |! h3 D0 h3 u6 O4 Z0 e$ U9 t" O! _, Z
  931.   def on_input_ok  C" z1 p/ c2 j% e, k- W$ k
  932.     @index = 0+ P1 e5 I3 j( D$ {  H: O7 [
  933.     @old_window_index = 0  W: J, ?; T) p* w' O- T
  934.     $game_variables[@variable_id] = @number
    2 P7 D: o2 w; K! j' s' H
  935.     Sound.play_ok
    4 b7 A5 m: a& P+ i2 `9 \
  936.     @close_proc.call& ?5 y$ C( Q- j( M# c0 e1 C
  937.   end0 t& S# T- S7 x! E# U, d' k
  938.   #--------------------------------------------------------------------------6 ^$ D; a, V: n. e5 ~% m1 x1 E
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    " D3 i( U% Z& P" j$ r
  940.   #--------------------------------------------------------------------------
    " |* d! S! D2 y& V  Q/ u! R7 Q( O* Z
  941.   def set_mouse_pos, C+ [, r) i1 _& B; U
  942.     if viewport.nil # necessary!
    8 [* V  }& ~$ Y: [; W) j. o. N
  943.       vp_x, vp_y = 0, 0
    ( D  j* ~8 V; K6 k, K2 H+ s
  944.     else% `& Q0 i9 z: }8 Y  o+ ]' ^, U
  945.       vp_x = viewport.rect.x - viewport.ox1 g( f$ q' v+ d9 P
  946.       vp_y = viewport.rect.y - viewport.oy
    4 d" P5 ~8 A2 x1 C) Z; s$ k
  947.     end
    0 z4 e" V" s+ i5 x; {9 }0 ^! _
  948.     item_x1 = vp_x + x + standard_padding
    9 A0 ^( Z- C0 ]+ A; a
  949.     item_y1 = vp_y + y + standard_padding
    ) [$ r; N5 a+ v7 E8 S% H
  950.     get_index = @index  0  0  @index 3 u0 y  ?3 k4 [" ^9 c
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)1 h" H# g2 L& _& l
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)( P! A  w, C# w* j. d
  953.     Mouse.set_mouse_pos(new_x, new_y)
    4 \" v( T. c/ U+ s! T7 M
  954.   end- {* ?6 G  u. T" \4 ~4 b
  955. end
      h& ]$ ?4 I: z, c

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

  2145. $ `( y/ Z: q+ Q6 m6 ~; ^' p
  2146. #==============================================================================
    - V' @" ~% t3 G4 N/ e$ I
  2147. # ■ Game_Map
    ; b$ a0 e8 P( ~9 t; x
  2148. #------------------------------------------------------------------------------
    3 K( K! h/ i% s$ j/ F
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    , _3 Y0 @" r  g( ]) W
  2150. #   本类的实例请参考 $game_map 。
    $ b* A' o! v  _- r* a' }
  2151. #==============================================================================
    6 f0 c1 I: A1 s5 Q
  2152. class Game_Map
    + s+ Q, ]1 b$ A  H' B, G) s
  2153.   #--------------------------------------------------------------------------4 p% W8 s0 _. c+ n, y! b
  2154.   # ● 定义实例变量$ F+ B+ V! }9 R! |4 c7 Z) m/ c
  2155.   #--------------------------------------------------------------------------
    + s' U  P( [& J0 q; X  o
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据6 i  i. {8 R8 S
  2157.   attr_reader mouse_map_y # 同上( a; X# ]  T' f) T% o
  2158.   #--------------------------------------------------------------------------9 d* @& V3 a' a
  2159.   # ● 初始化对象
    ' ^2 t% r( c" F/ E" l! E
  2160.   #--------------------------------------------------------------------------$ {% E$ b  t' S+ _6 d
  2161.   alias sion_mouse_initialize initialize
    2 m5 R. x2 u  J3 p( B: S
  2162.   def initialize
    3 `$ L; s2 Q3 {  I# h9 ~, }" z- X
  2163.     sion_mouse_initialize
    ; C  r$ i; h& G1 }. x9 V
  2164.     creat_move_sign  ###% S2 Q/ Y( ^  j  O  S/ p' n& i
  2165.     set_constants9 x9 w6 E" f- _0 _( `+ _
  2166.   end
    9 E0 M- `; D$ g7 P/ U' }, W
  2167.   #--------------------------------------------------------------------------
    6 l9 o) j) A8 K! |( \
  2168.   # ● 更新画面- j, l  A+ n7 D( d; R' u3 x
  2169.   #     main  事件解释器更新的标志; ~! p+ n) o. U
  2170.   #--------------------------------------------------------------------------
    3 H7 N5 _; N# U- P) m' V
  2171.   alias sion_mouse_update update
    " X) ]1 |3 [8 |; O1 Z/ @
  2172.   def update(main = false); W5 L/ Z: v* w; u7 h
  2173.     sion_mouse_update(main)
    ) P; R1 c5 V, o; E, a! s: H. [
  2174.     update_move_sign
      W* M0 d/ L. ^5 E  Q
  2175.   end
    7 T& z  p' D; \6 J
  2176.   #--------------------------------------------------------------------------
    ' m7 i" ~# v/ ^3 _
  2177.   # ● 创建显示路径点的事件
    2 ]$ |/ [. d- g6 y) J
  2178.   #--------------------------------------------------------------------------, d; q& }5 R' R5 v8 N; M5 u, ~
  2179.   def creat_move_sign
    + d1 l3 F& D# r) S: s& E# {
  2180.     $mouse_move_sign = Move_Sign.new
    ' s2 [! I2 f$ B9 T
  2181.   end' I5 ^) B; X9 E2 ]7 t
  2182.   #--------------------------------------------------------------------------
    " k. S$ _$ }+ e7 ?  ?/ a( j- O: K7 e
  2183.   # ● 更新显示路径点的事件
    ! m8 K" B; l* h6 t* m. n' _! O) E
  2184.   #--------------------------------------------------------------------------
    - u& I0 g- Y% F) a7 q) m
  2185.   def set_constants
    5 `1 X$ Y6 m9 f) o
  2186.     @mouse_pos_setted = true7 x1 p- W9 \2 L5 @$ j" ?7 h6 h# {
  2187.     @set_pos_prepared = false
    & {& w( ?/ s0 G# T; A' o. @* |& y
  2188.     @mouse_old_x = 0$ M& ]" j* f6 Y4 K3 M! l. f9 b/ T
  2189.     @mouse_old_y = 0
    ; x$ j* Y8 n. c) \- h8 h' s5 `
  2190.   end
    8 @& s: G( i% e( c+ c+ o0 A
  2191.   #--------------------------------------------------------------------------
    # j7 F; r  ^1 S# N3 w( P' }
  2192.   # ● 更新显示路径点的事件
    ; e  J: Y- L! A- ?5 f0 m
  2193.   #--------------------------------------------------------------------------
    ( w) }2 u5 t2 b; G: x8 E5 m' d" l
  2194.   def update_move_sign
    5 y) r* e7 Q( n6 Y% E; G1 R  a
  2195.     $mouse_move_sign.update
    : P/ f! d: \3 x% W3 v  o
  2196.   end
    : c( x0 k0 I6 x" W! X- B
  2197.   #--------------------------------------------------------------------------( t6 G2 C4 P! k$ N/ `
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    2 N/ V8 A! Z9 f: h4 Q/ U) q6 A. M7 [  K
  2199.   #--------------------------------------------------------------------------
    + ~# o+ ?( [  V. V. z, T3 S$ G
  2200.   def get_mouse_map_xy
    5 P$ O' V3 n* J4 [# K  a
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    " r3 Y* X; N! G. i9 s3 M& l" g  H
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    + J) g5 z) l9 U2 e
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)5 o9 p+ C: S! t: ~4 E, f2 h
  2204.   end% `5 x( N, p2 ?1 @7 ^
  2205.   #--------------------------------------------------------------------------, y1 T5 X9 Z/ {3 Q- B- U4 A  T' g0 W( c
  2206.   # ● 返回地图画面时重设鼠标坐标6 k* S- j, j% U) M
  2207.   #--------------------------------------------------------------------------
    $ Y8 Z$ a) B. z- p9 M  w; [
  2208.   def reset_mouse_pos
    4 B2 \( _* G3 u8 [' f9 G
  2209.     return if @mouse_pos_setted
      @7 h4 X" m1 S
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
    / @( S8 P* d+ |3 B2 \
  2211.     @mouse_pos_setted = true
    5 h2 }& m. \- g+ H
  2212.     @set_pos_prepared = false6 ~' P; W4 {' c" W' c
  2213.   end
    ' F  U( O* L9 u# r
  2214.   #--------------------------------------------------------------------------% r) i/ |) L, N6 y$ J, l' }
  2215.   # ● 重设鼠标的坐标
    : V# k, @- c2 N7 Y
  2216.   #--------------------------------------------------------------------------
    ' h! x4 E6 A8 R5 V
  2217.   def prepare_reset_mouse_pos/ I" C3 ]  h* x' |% p9 [
  2218.     return if @set_pos_prepared
    1 `4 i& A; m" Y1 [) h" Y5 @6 F
  2219.     @mouse_pos_setted = false
    . f5 a2 h! P1 G  _1 N  g& d4 x. l
  2220.     @mouse_old_x = Mouse.mouse_x
    & N  v4 S  E9 K9 W: W
  2221.     @mouse_old_y = Mouse.mouse_y
    4 q6 {% d* d3 f5 V) O
  2222.     @set_pos_prepared = true
    / d  N# W! w7 ]# p- r" z
  2223.   end
    0 e7 S& {0 l1 d( Y) x* {
  2224. end. L7 s6 O% n/ x8 C0 B

  2225. # L# b: J- b" J
  2226. #==============================================================================0 y2 {! I* C; G3 I9 k
  2227. # ■ Spriteset_Map
    9 W/ c! |1 q, [1 C: W* N, s6 E( ]
  2228. #------------------------------------------------------------------------------( v8 N$ P  L/ F  \1 k/ c; w
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    . `/ o& k1 b! M- R
  2230. #==============================================================================* E7 F% c/ L$ ]+ R) t: k
  2231. class Spriteset_Map
    4 X+ ]* K" e  b; \) M" n
  2232.   #--------------------------------------------------------------------------
    & q2 n  B2 q& x; \
  2233.   # ● 生成路径点精灵
    9 R5 l, u( R$ }$ j6 Q
  2234.   #--------------------------------------------------------------------------8 k# _. ]. D# a- r3 b" o
  2235.   alias sion_mouse_create_characters create_characters
    ) s$ s5 `  M& e( a0 @3 ~- i4 [
  2236.   def create_characters$ W2 f  c1 l" X
  2237.     sion_mouse_create_characters! Q" j" f4 Y4 K: k+ d! F
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign)). j* i1 @1 n4 f6 m1 K- q
  2239.   end+ ~5 |% q6 _" [& Q  A4 @# P( o/ ?1 j
  2240. end9 ]" z6 C1 c9 }$ d3 I
  2241. ( |* H% j4 h6 d* p6 w0 [
  2242. #==============================================================================
    ' [: w% E" d# e' V
  2243. # ■ Scene_Map, i* X. w3 N2 V. n
  2244. #------------------------------------------------------------------------------
    ; a; F9 k9 k  J8 O6 o
  2245. #  地图画面
    9 p8 H# `" `6 x: x) ]" z
  2246. #==============================================================================& s/ r+ V0 S  O( Q
  2247. class Scene_Map  Scene_Base
    ) K2 F/ H3 ^! o/ z  {
  2248.   #--------------------------------------------------------------------------2 E* [# ]; _2 N5 ^
  2249.   # ● 画面更新
    - P$ B5 ^2 ^8 D
  2250.   #--------------------------------------------------------------------------% M1 k" B1 C2 s+ `3 I5 f7 s. `* {
  2251.   alias sion_mouse_update_scene update_scene& v9 Q1 w" v2 E6 M+ N( K
  2252.   def update_scene
    . B" @( H+ x9 t5 E/ w! \' j6 E
  2253.     sion_mouse_update_scene
    0 D% C# ]5 K8 T( Q% R7 C, b! u) [
  2254.     update_mouse_action unless scene_changing
    2 ^3 c$ \2 C9 b! K+ j+ y7 }
  2255.   end; A% E" y: R4 h
  2256.   #--------------------------------------------------------------------------) [6 w8 d( i% ?: L- G
  2257.   # ● 场所移动前的处理1 `# C* L$ P" v' B( M
  2258.   #--------------------------------------------------------------------------1 j+ P& }: j4 b8 s+ h
  2259.   alias sion_mouse_pre_transfer pre_transfer/ u$ m. x, p! y3 |" C
  2260.   def pre_transfer7 T3 c  t! z' G& |. t' L6 |
  2261.     $game_player.reset_move_path
    : ^! h$ E6 e/ k$ k, ^. y
  2262.     sion_mouse_pre_transfer7 ^; D3 h, h& q) `' s9 ]" o
  2263.   end2 P  k5 z' l! B. T- U/ ^
  2264.   #--------------------------------------------------------------------------# S; P2 R- |: C4 E% E* q
  2265.   # ● 监听鼠标左键的按下
      s6 ~* u8 T" m1 {- j1 j
  2266.   #--------------------------------------------------------------------------, z, r2 X) x$ C$ T4 Z0 e
  2267.   def update_mouse_action. ~; A1 }" K$ L1 j
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    - H* |* X/ T: Q# t4 a8 t8 n
  2269.   end
    * v/ F& |& I+ i/ p
  2270. end
    2 X% b+ u9 _5 O9 v# s& Y- ~; U3 t
  2271. " `1 U/ p" T- j- u6 l
  2272. #==============================================================================
    6 Q, f- M$ q% c2 U1 z
  2273. # ■ Scene_File
    & s3 B, D% y1 K* C. C
  2274. #------------------------------------------------------------------------------
    2 V" q6 R' `' k# r- N
  2275. #  存档画面和读档画面共同的父类
    2 u. N( L  Q" W' h5 X0 C& Y# g4 v
  2276. #==============================================================================
    & u2 @1 R. i3 |1 q! X- W$ Z2 A! @
  2277. class Scene_File  Scene_MenuBase
    . Y/ N" [, j3 ?/ i, S8 i5 w3 t! D
  2278.   #--------------------------------------------------------------------------
    / o7 k! J/ t) A) z& U1 N( u0 k
  2279.   # ● 开始处理& B( _: H  E) p' E
  2280.   #--------------------------------------------------------------------------
    ( s, d: Z* e8 g, @6 ]
  2281.   alias sion_mouse_start start
    3 r! D- \, p; k2 |; T& q
  2282.   def start
    1 g; K, D6 h5 j4 j7 |
  2283.     sion_mouse_start6 z8 h4 @3 D+ q% ^) u3 B
  2284.     @move_state = 0
    " ^9 Y$ W! O' q  C
  2285.     set_mouse_pos
    1 ]* L, `! S' L- N1 V; b. X
  2286.   end: B# U1 A' @, E5 p
  2287.   #--------------------------------------------------------------------------$ |$ ]! U+ d) c3 h  _
  2288.   # ● 更新画面
    ' G, r, A2 I: ~& e- n
  2289.   #--------------------------------------------------------------------------
      H6 u2 g* Y7 l+ L' z5 {- H
  2290.   alias sion_mouse_update update8 r+ Q# y+ H5 y. b! W2 ^% z
  2291.   def update
    3 l2 O2 A2 X* K6 X- t8 z" Z
  2292.     sion_mouse_update
    6 p7 B' v, _. u4 T; D% L$ z& }1 a
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    . F2 x8 b8 }5 v7 g
  2294.   end
    ! c; r/ P; d) N
  2295.   #--------------------------------------------------------------------------* b3 {6 N" ^7 x/ i
  2296.   # ● 更新光标" S: p) Q( M9 r& y7 u
  2297.   #--------------------------------------------------------------------------
    * X# Z! }3 G8 H( Y$ X" u1 x
  2298.   def set_cursor
    ' V8 n& i! `8 C5 k5 Z. y: \
  2299.     @move_state += 1
    3 p" T2 s! o: h2 T8 O6 b% r
  2300.     last_index = @index) p6 u# i/ S3 [5 R; s
  2301.     if mouse_which_window == -2* m! h% c0 b, K5 _* B9 d$ w- V
  2302.       if (@move_state - 1) % 6 == 0$ d; L7 B' }: i9 v  ]/ E% @
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    8 |/ N& q- |% C3 a1 g/ K
  2304.       end0 t( K) @) q3 C
  2305.     elsif mouse_which_window == -1
    % g! ^9 @$ h! E, |# \1 s  H
  2306.       if (@move_state - 1) % 6 == 06 C7 \. u4 d, _& U6 [
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    $ C. m$ b5 ^- l  o% s# `& ]" @
  2308.       end$ }, [/ b6 g! K3 ^9 b
  2309.     else, S1 P# R% r" B# \7 c
  2310.       @move_state = 0. q% S1 o# l0 f& L/ V0 f+ T
  2311.       @index = top_index + mouse_which_window
    & z8 O& {) u; k, ]+ A* I5 {( [
  2312.     end7 d6 v0 m7 E$ _3 P
  2313.     ensure_cursor_visible
    ) y! C) h) K# ]7 s8 i/ b
  2314.     if @index != last_index8 K, F0 o: H) e* _4 `5 a: {1 C
  2315.       @savefile_windows[last_index].selected = false
    7 Q; r$ J5 ]. K; m9 _- D% C
  2316.       @savefile_windows[@index].selected = true$ i4 G/ [# _* ^* p! w/ r7 ^
  2317.     end# ^* d$ E0 i, ]5 n% s( P
  2318.   end8 _/ A5 v6 U7 [- w
  2319.   #--------------------------------------------------------------------------
      H2 V7 @( C) Z$ b" p8 W2 f
  2320.   # ● 判断鼠标位于哪个窗口# C# g1 C6 }9 \, p- m/ A
  2321.   #--------------------------------------------------------------------------5 L4 o- r/ q/ w" f$ z- J8 c" m
  2322.   def mouse_which_window
    2 g5 [" b+ v- c- \7 [. _& A" z
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    5 I1 b) x: d- E0 z4 l- C+ N% _
  2324.     if mouse_y  @help_window.height + 148 B9 l" ^4 l, f2 |* {7 ~) P
  2325.       mouse_row = -1
    2 u) S  [& {, ?
  2326.     elsif mouse_y  Graphics.height - 14
    " I: M8 i0 z. K8 q) _- j4 s
  2327.       mouse_row = -2  x) Q1 K" ]/ L" b: }# h0 f
  2328.     else# \; a' Z- [/ {) w, \/ Z
  2329.       mouse_row = 4  (mouse_y - @help_window.height) ! s* i0 {6 C) Q# i: v: M
  2330.         (Graphics.height - @help_window.height): s( ]0 r3 w# u3 u1 `
  2331.     end
    ! J/ a& h% A% D( L' {, I9 _
  2332.     return mouse_row3 {& e6 B' l2 d0 v- D1 q- E  N
  2333.   end
    * ]) }' b3 V+ J3 C+ S
  2334.   #--------------------------------------------------------------------------
    - d3 U3 |+ a3 P- S6 t# p& x* f
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    / M0 Y- ^1 D8 j* W
  2336.   #--------------------------------------------------------------------------
    # [6 P0 [2 U. s8 q& Y* [. h% Q3 r5 i
  2337.   def set_mouse_pos6 m) {6 C3 |, R8 U) l. H, U/ Y3 f4 }
  2338.     new_x = 40; {! f; m' q5 k- W; j0 |
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    7 {% `6 F5 U  c6 Q
  2340.     Mouse.set_mouse_pos(new_x, new_y)9 P' d9 v3 M8 K& z) _$ x
  2341.   end0 t7 G8 ~* h+ b/ c2 J
  2342. end. ?* t- \/ ~$ ^9 N! C. {1 z
  2343. $ L# e! q- v+ K3 |6 D  n1 d
  2344. #==============================================================================
    * i* P/ c" j8 q; z9 n
  2345. # ■ Game_Event: k6 S5 }( j  c, B+ ^# @
  2346. #------------------------------------------------------------------------------+ s  c6 F( I( H. Z
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。" X; u% V' t' Z3 T/ l0 _
  2348. #   在 Game_Map 类的内部使用。
    ) e! r3 ^/ l) M, T* Z, g$ o+ w  |
  2349. #==============================================================================& c& M, _, E) S( t; J4 R$ @- T
  2350. class Game_Event  Game_Character
    7 X5 c- I  s! E, x8 a
  2351.   #--------------------------------------------------------------------------
    $ {4 N" P: k! d
  2352.   # ● 事件启动
    , O5 d. ?2 d6 n* J6 P) e) x1 f: C0 F
  2353.   #--------------------------------------------------------------------------
    - U; Z8 d) u7 z5 V- W: \6 `/ q
  2354.   alias sion_mouse_start start) C3 A* U5 \; V5 d2 K3 p
  2355.   def start
    ! D: T/ G' x" H1 R! c! p
  2356.     return if mouse_start && !Mouse.press(0x01)
    # O, i3 ~) `( o" t
  2357.     sion_mouse_start
    4 m! H% y- X1 V$ s& X, A
  2358.   end; z  Q  H$ u- ?9 i: N, @
  2359.   #--------------------------------------------------------------------------2 j1 U0 s! T# c- Y2 _; c8 {( _
  2360.   # ● 判断事件是否由鼠标启动" M1 X7 d( _- [% f
  2361.   #--------------------------------------------------------------------------* C2 Q* [2 E; d# z9 R1 Q
  2362.   def mouse_start. ?! I8 e1 i$ W* |
  2363.     return false if empty
    # D  Q) z$ \7 D$ E* q8 i7 d: ~
  2364.     @list.each do index
    - T# l  k* G2 V& o1 P+ Q, Z4 l
  2365.       return true if (index.code == 108  index.code == 408) &&7 _$ P8 m5 E" m& F' f! ~% a8 Z9 `
  2366.         index.parameters[0].include('鼠标启动')
    ( }+ ]1 \% w% x4 U! x1 f
  2367.     end/ O- {& H& H: {
  2368.     return false0 u" b' z+ x  e% M/ a6 \. ~; r& Z
  2369.   end7 {: n+ C9 {% _! Q
  2370. end" @' T1 m3 s$ L$ F) S

  2371. ; I6 Q  _7 t+ l; p
  2372. ####泥煤的height
    # o+ a2 G0 e: c6 O
  2373. # @height = height
    8 u# \; \) {  \  j
  2374. ; Z4 |, s$ _# a2 n+ [; R; ^2 q
  2375. class Area_Response% O1 n% D! p/ E) t6 o+ r7 R
  2376.   attr_accessor type% r, z6 C; y$ e) G2 S
  2377.   attr_reader ox
      n. l1 @# S! m# O7 r  c. ~3 T0 N
  2378.   attr_reader oy/ a. _3 t8 }2 L, i2 {
  2379.   attr_reader width
    8 X+ \9 ~! F+ @: u% h9 Z. b
  2380.   attr_reader height1 ~1 {! Y0 l! N5 Z$ q! U; e
  2381.   attr_reader switch_id
    ! x' u/ h2 h7 y9 x# s3 {
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    6 Z8 d9 a7 s% R4 O) n% H
  2383.     @type = type
    . @5 y7 r: {" G8 w$ _. s4 ?
  2384.     @ox = ox
    & O) f# p/ Q  j9 ~' b
  2385.     @oy = oy; L) T0 r& D/ e0 z8 n
  2386.     @width = width
    ! g) d! Y1 z8 a8 B# a8 {4 W1 q; `+ Q
  2387.     @height = height
      J; a8 }% e( b, v$ B
  2388.     @switch_id = switch_id
    5 l  j4 U; b; x9 W* B+ n8 g9 D
  2389.   end. c- V/ \, K6 y! g! T. W' q1 p
  2390. end: e4 C% s$ m7 Q  a9 o6 ^' t
  2391. 4 s/ i$ q- K9 p" V& V& [
  2392. $area_responses = []
    0 C. R( A9 x. n, d, l0 X

  2393. # e/ S& n9 f. |% V4 m! M  t
  2394. class Scene_Map# `8 w3 x: S/ |2 }4 F* O
  2395.   alias update_mouse_2013421 update_mouse_action* b% W8 ~& N$ i" X
  2396.   def update_mouse_action
    ( o, Q- ^! o5 B
  2397.     update_area_response
    / G- F; K$ }( _, p+ Y  Z4 p% X
  2398.     update_mouse_2013421
    - W0 }! p* _/ s9 Z
  2399.   end
    6 I! k; V! Q* d5 U& z9 t& C0 n) c
  2400.   def update_area_response
    4 i/ K7 X3 F- T+ `8 J( D
  2401.     responses = $area_responses
    , g) P  _. N$ l) Q9 b3 {' S
  2402.     responses.each {response, P# x% j; b* G  m' A. p
  2403.       ox = response.ox9 A0 g! H# @- r
  2404.       oy = response.oy8 Q0 D0 l% s! m8 @: V$ g5 N" i
  2405.       width = response.width
    ! m3 V4 G) p" A8 W% A
  2406.       height = response.height1 l! o/ ]! t1 W  T
  2407.       switch_id = response.switch_id: G+ L) ]5 P1 a1 V& J2 K) N7 Y) N: v
  2408.       case response.type
    . e! H5 P1 j$ c& b' h7 c
  2409.       when 0
    % Z4 s. ^+ C& P
  2410.         if mouse_in_area(ox, oy, width, height)2 m- C/ h5 ?" L/ r
  2411.           $game_switches[switch_id] = true/ {' A5 M( I% B% {
  2412.           $area_responses.delete(response)- j% h2 U  R, g/ X! l/ Y
  2413.         end
    % ]0 R' T5 I8 [5 z; W% X" x
  2414.       when 13 q" h8 k. z* f* m9 t; s7 S' v7 @
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    : T& J# x5 l) M( J
  2416.           $game_switches[switch_id] = true
      E% m5 [4 Z' U8 N( X
  2417.           $area_responses.delete(response)
    0 A" f. m" f# {0 Q0 E
  2418.         end9 R+ T/ s8 N3 H" l$ R
  2419.       when 29 z% Z1 {- z7 f) |1 H5 v/ T. ~& K
  2420.         if mouse_in_area(ox, oy, width, height)
    " n! B3 x) B7 P! l, Z+ X' k
  2421.           $game_switches[switch_id] = true
    & O3 g$ t/ E! R7 j3 S
  2422.         else, e% G1 y  V  v0 \9 V
  2423.           $game_switches[switch_id] = false6 n& D, j* R7 D3 R
  2424.         end# `' `  w4 w. u2 I4 o8 o4 v
  2425.       when 3
    + S: V4 a" M5 H  R+ e
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,+ E7 R/ H+ ^+ l% T9 J
  2427.             (oy - $game_map.display_y)  32, width, height)
    + [/ Z. z$ W# T, |! a
  2428.           $game_map.events_xy(ox, oy).each {event) H8 A7 t3 R/ L) [  q  ~; ?" o2 }3 u
  2429.           event.start
    ( r& J4 ]# m- x
  2430.           $area_responses.delete(response)
    - K! [2 ^  x$ \+ O9 T
  2431.           return
    # ~) @5 q; N- K  f
  2432.           } , ]6 g9 Q1 W0 d+ l! O' R
  2433.         end
    & p) [- h. O% L* T/ L2 n
  2434.       when 4, \* H/ R  _% y
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    & B! Y, z3 D. ]8 s
  2436.             (oy - $game_map.display_y)  32, width, height); Q* L  j' g/ e
  2437.           $game_map.events_xy(ox, oy).each {event9 [0 i* X; D5 E, f6 ?0 `
  2438.             event.start* X4 i: ]) a: _! w8 N
  2439.             return
    ' g' S% P3 N1 x" ]; a8 C8 s& d3 f0 C
  2440.           }
    7 d6 f. t: r4 G3 a' m7 E
  2441.         end5 Y/ B8 _/ ~; p* F. C
  2442.       end' n: L$ j# y, N0 ^
  2443.     }) N' r9 U1 {! g6 F8 O9 u
  2444.   end9 a8 Q" L) ]* [
  2445.   def mouse_in_area(ox, oy, width, height)2 ^5 d9 h2 e5 u1 \
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    - Q& F8 `; K0 `/ v) F9 m
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height0 k' h! G9 l5 c. S$ b
  2448.   end6 I( J6 P$ M" Y3 S6 I/ I
  2449. end
    # C/ ^# ]$ E. {! t) m2 L
  2450. class Game_Interpreter
    6 b  G1 T2 e* L: y" X) `
  2451.   def area_response(arg)
    # I: k& z6 ]  M, D# U" ~- B
  2452.     $area_responses.push(Area_Response.new(arg)), a7 w. w7 Z0 H7 Q5 p, n) Q. h, B
  2453.   end, P7 ?9 k9 n" |! f
  2454. end
    ' y2 y0 s4 F: A8 n' d
复制代码





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