Project1

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

作者: 熊喵酱    时间: 2013-8-29 09:01
标题: 存放腳本
純屬給LBQ腳本:
  1. =begin #=======================================================================4 I+ f9 M; p% P) a7 J4 K5 A" v1 i
  2. ; W  y; d; O3 C. L; L
  3.   Sion Mouse System v1.3e
    : }' {8 }4 ~! }8 {9 o
  4.   / `7 d8 _  d4 J/ V+ {% R
  5.   Changlog
    9 p4 G1 t# ^+ x* P9 i
  6.   7 ?- ]+ Y* M* X9 i, C& r
  7.   2013.4.21 v1.3f7 ?4 n" e& w- b5 \. m( r7 w5 p* n1 P
  8.     $ X! H$ a+ R2 B3 V. M2 r# }
  9.     1.3f 卷动地图 bug 修正- Q" r3 H; j2 r
  10.    
    * ~1 g( I7 V, ~  j
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口" N% ~# _5 g; }8 S4 B* E8 s; V* T! N& Y
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内0 o: Q& _7 Y3 G2 I" {/ q( Q6 I3 r
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    + {( W4 C/ \" \; V
  14. " Y' B/ A- Z! Y% D
  15.     1.3f bug修正
      }0 i0 R/ M. ]  \, v
  16.   
    ! o1 I2 ~! T+ Q' z) U$ L2 P: r
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    ; B, ~! q3 ~' |+ |
  18.           关闭菜单时,鼠标是否移动到原来的位置。, x2 q6 h* m! T& E
  19. 2 j0 y1 b7 f$ `8 I2 k7 F  x% |
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    + H: V9 X9 q( _( _
  21. / D9 b7 L+ O; q& N$ h  v
  22.     1.3b 修正一些罕见的bug;: \6 O1 v) N* F7 S% S; x. {

  23. 0 i! _( M; L! J/ a/ q) l3 N
  24.     1.3a 代码小修改;
    - ?" O! p! X" m2 J# z( ?6 n
  25.           加入了鼠标点击启动事件的功能,4 c+ A8 X+ j3 L9 |' W6 ]( O
  26.           在事件中加入“注释”: 鼠标启动  ,7 K3 f$ R, ^) K" D+ M% t* k
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。# q+ r+ I4 E: }1 r" v1 e
  28.   
    # a: ?" r5 z& h6 t4 d2 F7 {
  29.   2013.2.12 v1.2
    % a! I: D( Y7 W& Z0 c
  30. * k( b$ h9 e1 V% W% I- `3 h, o
  31.     寻路逻辑优化;* _8 n0 g& X- f4 B; @% u" O
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    8 t( D, v5 F9 J8 @! K9 J. F! E
  33.     现在支持用鼠标来操作载具了。
    9 b8 Y+ w5 M4 i% j, m: [0 T
  34. ; u: L+ \+ M: u6 {# J/ ^0 y
  35.   2013.2.8 v1.17 S( H% ~0 h9 [: H# f& b

  36. 8 `- o- A! l8 X$ E, m
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    9 H/ f3 j3 T' h5 E
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;* V0 T5 S4 e* p0 v4 j% m
  39.     移动时,路径指示点的绘制更加稳定;) c+ b$ r" t/ o' P* E
  40.     现在支持默认存档画面的鼠标操作了。
    + E& O# h1 q) E  @2 m

  41. 5 h+ B2 y& J! v$ F
  42. + U0 {, t3 ]) M7 P" R" m
  43.   OrigenVersion; ?) `. k6 z' {6 z
  44.   ! u' K1 g! \6 B/ |! T3 y8 t2 k
  45.     2013.2.7 v1.0 / b3 ?% ~" E+ }9 |6 ~4 j2 N) W
  46. 7 o$ |* o# u9 p3 |
  47.   主要功能
    * K' _1 }  j; B8 v7 o: a
  48. 3 F: I' w' L: j: [, H, c: @+ r
  49.       使用鼠标进行各种操作...$ w9 H/ u7 z0 \$ F( q. J
  50.       将鼠标锁定在游戏窗口内
      w9 J4 O6 V9 G+ z% \; H4 @! M
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    9 b. W" ^0 Z+ G
  52.       双击鼠标进行冲刺/ Y3 E1 U( m. J8 u7 w
  53.       更改地图卷动方式以适应鼠标移动
    + l! }0 b6 j* U
  54.       变量输入框改良
    8 w# d; m- M; C, ?8 j$ v+ ?2 A
  55. " }5 f. F, J$ X6 r" C& Q4 @1 m
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹# q1 j8 d2 q  K1 O

  57. ( l5 X8 N! y1 H5 g- M5 |3 j
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹1 h6 A' }: d) m; B! ?

  59. ! X, i( l) h" }; z
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭) ^% S9 m) i/ R2 O2 ~" J, B- x* ?

  61. 7 v, _& [0 y6 T0 \9 D

  62. . S% x" v6 E9 G$ o4 s
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    0 t4 h2 r" T/ l- D7 O; d& l
  64. 8 L4 R3 W* d' o+ }
  65. 4 @6 k' c2 i$ w. C* a
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示' N5 d1 r2 Z- J2 Z

  67. 2 W; D( I. U/ g9 Q9 ]0 e9 k
  68. #==============================================================================% g+ S$ A& [& i3 U
  69. # ■ 常数设置 8 p' l9 _. N9 r& `0 Y8 s$ t
  70. #==============================================================================
    2 |$ m, ?8 ?: w; f+ |1 k
  71. module KsOfSion. }5 [3 q- s' E7 ]8 k1 I* e& x. J6 Y
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    6 J/ D& i) {9 f
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑! b1 @& s+ _: U% A& Y. ^
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    ! O" X' f/ p, ~* l% `$ X9 R# j
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量3 F1 P+ u  e# Z6 Z( ?# J
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    + h# L! ]7 k5 ^9 ^# k, q8 I2 A+ z
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧# q+ ~1 C' \/ }0 e7 G2 N# b$ z
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13), ?  `) S7 E9 q- Y
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键* Q0 {* o4 `7 l( {* H
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)" o) R6 e. S' P; F9 z% R
  81. end; r3 ~4 Q( ^7 r

  82. & s# Y3 a! ?: }# f/ H; l
  83. #==============================================================================
    ) ^% \, _! ]7 ^" ?: r( ^/ f5 ?
  84. # ■ 用来显示路径点的类
    / q: T3 T8 A4 a7 g: I/ h
  85. #==============================================================================: I# {0 ]& X- o5 \
  86. class Move_Sign  Game_Character5 D: q: ?! [1 O/ G4 E3 S
  87.   #--------------------------------------------------------------------------5 w# ?4 h4 l& k; [1 R3 u
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    : C7 R8 |' D1 @. m
  89.   #--------------------------------------------------------------------------
    # W4 ]& z- Z+ Q3 t
  90.   def init_public_members8 U/ G0 a- v* }) D2 \8 S: S5 Y# {6 E
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹1 ?2 M+ Q3 y, S
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为00 G$ Z* q# E4 J' |( V0 r
  93.     @move_speed      = 5        # ★ 踏步速度6 p3 u( N1 J4 g: h% g
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    4 X2 ]% d: }- C) Z5 D" x, p
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    8 v8 f! f6 h8 W+ U- U) G
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    . j  w, v! }2 e6 ~' V% R
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列; u! X* W/ v& N/ O& }
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    ; M  V$ O9 K" ]
  99. ; S  y) R4 c6 n' {1 H8 W

  100. / c1 K5 E" l3 J$ G- U9 M9 X( p1 K# w# ^
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
      V3 A( w( D# e# A8 ?

  102. : V  L, F& ?; y  x+ m

  103. ( u; f) ?7 J% G2 ~# C& k
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图* c/ p4 W7 e* T, l1 w
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png'), L7 `( x. m% u6 l
  106.   I. Z6 H' j( }- ?* _! I) c( I
  107.       if $no_arrowpic_warn
    ' T3 g" B/ {# I
  108.         MouseShow_Cursor.call(1)) [0 ^$ P$ n: t1 B* c
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png9 K9 U" g, E7 q) ]: U
  110. : D8 t$ f% F5 F# W/ ?
  111. “路径指示点”将使用游戏自带图片2 a& v# B4 J3 [9 b
  112. 4 P/ D4 T9 w( M
  113. 该提示可以在脚本内关闭')
    & ]* `: k/ K9 o* k) s9 B: g. p9 [
  114.         MouseShow_Cursor.call(0)( v6 E& z! M( y6 E
  115.         $no_arrowpic_warn = false  M% F# M" m) G4 y& Z
  116.       end( A7 e# K" C3 _$ T2 e5 J0 Q
  117.       @character_name  = '!Flame'
    5 G; t" R1 `( I' V7 V- i; M
  118.       @character_index = 63 F3 n& _3 x- j# u

  119. 6 C5 b+ t& X7 g$ s  ^& e0 R( Q% E
  120.     end
    ( _* g& c- e" h+ g9 ~; R
  121.     @direction_fix = false  # 固定朝向
    ( ]( [! E: w- Z1 a" a* [
  122.     @move_frequency = 6     # 移动频率
    : u( d: X2 X3 _
  123.     @walk_anime = true      # 步行动画
    ) v; L: N' [' {, v& Z* |8 d% S: O
  124.     @pattern = 1            # 图案
    " S. |1 x6 z5 Y$ h% f; }/ q
  125.     @through = true         # 穿透
    5 G" @. ]2 e) g7 I( R) H
  126.     @bush_depth = 0         # 草木深度$ E# p# d7 N( z" g3 L- j4 I
  127.     @animation_id = 0       # 动画 ID
    , \& E( c9 h: U$ K$ V8 W& H
  128.     @balloon_id = 0         # 心情 ID8 {7 _: p9 y5 r& |
  129.     @transparent = true     # 透明9 x/ o+ F+ p; n) ]. X
  130.     @id = 0
    : P: l0 N2 b5 E' H$ n, D
  131.     @x = 0
    * M: A$ E) t/ g7 J. N. O
  132.     @y = 0
    3 f$ A' e/ a7 @! _6 S9 W
  133.     @real_x = 0
    3 I+ I; ~4 r6 \& E' s
  134.     @real_y = 0
    ( w( e3 |( H' ~. J* w2 }: c
  135.     @tile_id = 0
    8 M7 Z' ~9 [+ D4 e
  136.   end7 f+ F6 }) J2 `4 J, c" t
  137.   #--------------------------------------------------------------------------
    . W8 z, U! j1 d# L+ R' B! ^
  138.   # ● 定义实例变量9 H% y; w/ R2 g; E: r5 s0 y! o
  139.   #--------------------------------------------------------------------------2 p/ f. Y" k+ ?2 ~# W0 {# w
  140.   attr_accessor direction
    9 S3 i6 d% d9 u! w0 ^# {! G
  141. end
    2 t  o2 E" U# z, ?1 R% I) ~' k! r

  142. : k0 ^$ c( e, x2 j/ I; }
  143. #==============================================================================5 f1 m% I; X& T* }# m7 M. v! D) y
  144. # ■ Module Mouse
    8 v2 Y1 ]) ]; Y
  145. #==============================================================================
    ' x% ]8 i$ C  Y/ r2 {8 E
  146. module Mouse
    8 x3 w6 w) T- z
  147.   #--------------------------------------------------------------------------
    3 J: i, Q- ~: H9 W- p7 V
  148.   # ● API$ `8 P% w$ L' s& v9 P* \
  149.   #--------------------------------------------------------------------------( Y# _2 }1 k( n; ^4 \7 Q4 A" {
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')& ~1 ]8 S# x+ x; G2 m, v* Z
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    8 S9 q# Q3 U. ]# Y# a2 _/ M6 N
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    # v0 C0 {9 G8 U, L; h5 a
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')8 X4 ]- G! ?0 h7 w1 }& n
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    0 x" S  K: G) m  E, A& A
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')( J% ~% [- F$ P  V0 `6 L& b
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    5 a  a- z) Q) m/ k% t% e
  157.   Window_Hwnd       = Get_Active_Window.call( j# m. R0 H& I* ^1 b
  158. & [  j6 _' b. ^+ G6 y5 ?
  159. class  self8 P4 W5 P- C3 G' ]; u+ q- J
  160.   #--------------------------------------------------------------------------
    2 {0 Q- h: w8 y6 K* q' E5 o8 \8 b
  161.   # ● 初始化
    + S; _: c7 [. p' Y: s: U
  162.   #--------------------------------------------------------------------------* o( e! X, F$ r! u& E: ]1 E$ B8 Q
  163.   def init' g- c5 v4 q3 F- q/ x
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor' e1 m/ ^* n$ s) V3 h
  165.     @left_state = 0
    ; ]) {3 D6 x, p) {
  166.     @right_state = 0
    ) M8 ~* h$ i( J& ]! p
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    4 k  h, h; y3 A+ h9 C
  168.     @dk_count = 0 # 用于双击的判定1 T5 T. E8 Q& \8 q
  169.     @clicked = false9 W7 \7 \& L% K( j/ ?- D* |- z* ^
  170.     creat_mouse_sprite( K3 U( L8 P- l7 x3 w
  171.     update
    0 `: W( W" x; M  o" H
  172.   end, |$ i' ]6 j7 U9 C
  173.   #--------------------------------------------------------------------------
    7 q- _7 H/ X, Q4 |
  174.   # ● 鼠标指针精灵) Z/ W: ?7 \' r' H: p6 B
  175.   #--------------------------------------------------------------------------
    ; \& A, Q5 y5 R
  176. #~   def creat_mouse_sprite
    6 x" p9 B$ {( c0 U+ O: j9 Q
  177. #~     # ]0 U2 S' [- l  |3 b7 u
  178. #~       @mouse_sprite = Sprite.new7 {; o' M, ~# ~7 ?* ]6 a
  179. #~       panda = 2#rand(2)+10 l, _9 M# t8 O6 s( D

  180. & M& e8 N& b; g- _8 K, }1 H7 l3 d( T
  181. #~      if panda = 1: I5 K' k2 ]! f* e
  182. #~        if File.exist('GraphicsSystemCursor2.png')* d. c3 j* N8 n( @6 t
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')& P' X8 c# H% Z8 o
  184. #~        end#with if File.exist
    ( e! q2 T+ q% o2 x; N. c
  185. #~   
    $ [2 |% g$ P$ r( Z4 t) x
  186. #~     else if panda = 2 #with if panda=1
    4 U* M( R) y# l
  187. #~      0 L& S: I! C3 ]8 H6 l
  188. #~      if File.exist('GraphicsSystemCursor2.png')4 k. A. l% u/ W
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    - ~" }# Q7 Z, O
  190. #~      end#with if File.exist
      K9 t6 v* W  @& ?
  191. #~       / ?1 v4 g8 R0 \# C2 X3 _
  192. #~     else #with if panda=16 o- v3 y% D' a0 ~
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)" h3 ^7 t  Q  W3 k( `. Y
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    , [) H* }; F6 `1 ]
  195. #~       Rect.new(5  24, 24  24, 24, 24)). w. g5 O" D! L  F/ z
  196. #~     end#with if panda=1- P/ R' u, T, m* w3 g: [, Z
  197. #~     
    7 t6 D& L6 T/ c+ Z7 e, @1 V
  198. #~     #with def
    . k( Y2 A( w2 t: h) w: }
  199. #~   end
      h+ r+ p& T4 j4 a! _. E* H
  200. def creat_mouse_sprite8 t6 y7 g* ^) Z
  201.     @mouse_sprite = Sprite.new0 e7 Z5 w( d& |7 J9 d
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    ! V6 s9 b" R1 n' M$ K3 S2 C  _
  203.     @mouse_sprite.z = 9999
    6 V/ y, b3 `  o9 `4 A6 T
  204.     Show_Cursor.call(0)
    3 r  R/ i4 G& x$ |" Q
  205. end
    " e1 ?; T- v# z) }. ]

  206. 8 m$ [; L- S1 J6 j, m
  207.   #--------------------------------------------------------------------------
    3 T' G5 q, o6 u, R2 d- w
  208.   # ● 更新
    1 B# x7 p6 S" V) w; d* X2 B: J% H
  209.   #--------------------------------------------------------------------------* p8 y: {7 B2 M! k3 i3 X  \2 h& b
  210.   def update6 @9 a2 d; g/ P9 |) c3 ]: C2 N
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    8 B% ]$ D8 e- K  }9 x; F" z5 V
  212.     left_state  = Get_Key_State.call(0x01)) C& y- K6 X* `) q/ t' q' L
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    6 \1 f! B1 s& [: ~" u
  214.     right_state = Get_Key_State.call(0x02)  P0 Z  l* ?9 W! C' m$ h
  215.     right_state[7] == 1  @right_state +=1  @right_state = 01 T9 V# ], v+ D( i
  216.     update_double_click- b7 f- }7 C1 I) U$ @- ^' J
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1! L# u) y2 n& H. n( G
  218.   end6 a8 y: `; J  u' Q' Q" \
  219.   #--------------------------------------------------------------------------  Z. O6 p" ~4 _8 P0 f2 b  b
  220.   # ● 获取鼠标坐标
    1 O& M, i4 M, z5 J- Y) x5 Q" F
  221.   #--------------------------------------------------------------------------3 f! q: d: j! A2 K) c+ U
  222.   def get_mouse_pos; E+ O8 v) _, Z7 f
  223.     arg = [0, 0].pack('ll')
    % B! q  ^9 }0 d% @/ R3 Z
  224.     Get_Cursor_Pos.call(arg)
    4 X2 h% U* u( X  h4 c
  225.     Screen_To_Client.call(Window_Hwnd, arg)  |: O# @0 j  Q  t" v5 @* j
  226.     x, y = arg.unpack('ll')
    ) E9 s2 T6 N0 B- g9 g( n# q$ v: G6 B& @  w
  227.     return x, y
    % z9 d& f% U, O' W: D  A5 x
  228.   end
    * u4 Q" W$ U* l
  229.   #--------------------------------------------------------------------------
    4 e/ G+ m1 ]+ G1 V8 F
  230.   # ● 将鼠标固定在屏幕内+ a8 \4 o3 G, L, E, [# x, K
  231.   #--------------------------------------------------------------------------  Y( j. C) E& X  P
  232.   def lock_mouse_in_screen
    & }9 ^$ q# X" {4 }# _9 @0 O/ [
  233.     arg = [0, 0].pack('ll')8 ], f: f' @* R: }* f
  234.     Screen_To_Client.call(Window_Hwnd, arg)
      z8 O( a2 L( u4 Q; I; h
  235.     x, y  = arg.unpack('ll'). F8 e3 r6 s' _- b3 ]) _
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))# @5 c" M, ~$ y8 ^
  237.   end" Q8 Q) L' }  H' R0 C" B
  238.   #--------------------------------------------------------------------------
    ) H4 v" {) Z8 I$ h& n. |' A1 R
  239.   # ● 解除鼠标固定, _' B' i6 s3 L0 i
  240.   #--------------------------------------------------------------------------
      f. X  u& }9 Q
  241.   def unlock_mouse_in_screen
    . U; A* P, p2 `2 d
  242.     Clip_Cursor.call(0)% ^7 O  x# h0 O# @5 z# L2 U4 P
  243.   end1 |! D+ }2 Z/ L" ~, j
  244.   #--------------------------------------------------------------------------1 G1 o% R! T; y$ E! a- F2 T
  245.   # ● 鼠标双击判定
    % y8 x6 W8 {1 S. n  ]8 G2 {5 S
  246.   #--------------------------------------------------------------------------
    4 H9 o# q' T$ c. P) X+ {
  247.   def update_double_click( @. o7 C. m7 Q' v1 m. q
  248.     @clicked = true if @left_state == 1
      g. F. x: P7 w! n" Q( U0 W
  249.     if @dk_count  0 && @left_state == 1
    1 C( q/ F+ C+ e, G8 |) O
  250.       @dk_count = 0; @clicked = false8 V1 |6 A9 K' z$ P) I6 s0 T7 ]1 a
  251.       return @double_click = true8 s$ O# M6 [9 q; s  }/ h' d
  252.     elsif @clicked
    & g4 b; e& ]! \% b
  253.       if @dk_count  KsOfSionDbclick_Frame' Z2 w& E  _$ Z+ a0 R: F
  254.         @dk_count += 16 i5 u; A, j& u, t, y
  255.       else
    . l( n/ `5 X4 l, X* W
  256.         @dk_count = 0; @clicked = false
      o* j" R5 t6 H5 E" v" g
  257.       end
    2 M/ W% z; W4 c2 i1 a* I
  258.     end
    7 X7 [! h: [: e3 h. m3 y( J2 B  K& A
  259.     @double_click = false# C! }: {3 Y* ~; j
  260.   end" @. n- V% g6 V( R6 H' r$ T
  261.   #--------------------------------------------------------------------------
    " X  s" c: a9 I% i9 A
  262.   # ● 按键被按下就返回true0 ^" A2 h" k) m  x* |+ c9 t4 I8 ?
  263.   #--------------------------------------------------------------------------
    4 E% X4 U0 `7 B
  264.   def press(button)/ e% l9 W# e+ I! j8 B: [
  265.     case button
    3 w6 ?5 e8 O. m; l  ?
  266.       when 0x01; return !@left_state.zero
    , w: B0 W* `" s# f( I, v$ A
  267.       when 0x02; return !@right_state.zero3 p" m5 _$ x2 X. n! t
  268.     end
    / p5 ~8 C9 [8 \$ @$ T2 Q
  269.     return false
    9 ^; ?$ Z& `5 E, N
  270.   end; f( c" ]* t& B& h
  271.   #--------------------------------------------------------------------------
    3 K+ }+ }; Z/ V5 ?& ]! c% I2 M
  272.   # ● 按键刚被按下则返回true
    8 i% e' l+ Q6 d+ b
  273.   #--------------------------------------------------------------------------
    0 ?) l9 c  _  x- w3 U2 m, o' c8 \1 |
  274.   def trigger(button)
    5 E8 t6 r& U, v
  275.     case button
    5 X/ i3 |. k& f4 r6 Q6 Z
  276.       when 0x01; return @left_state == 1* b1 m* N9 |  s5 k% z6 X
  277.       when 0x02; return @right_state == 1; W4 Y: r7 B' _: Z1 \, W) }
  278.     end2 T/ k1 }  d/ C
  279.     return false
    - o8 @3 R" y4 x  p
  280.   end
    6 {' y" @9 [* U/ T
  281.   #--------------------------------------------------------------------------+ X, y% S, Q" |* J& q
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
      F, q  o$ N5 E, l1 j6 K
  283.   #--------------------------------------------------------------------------
    ; i5 l2 P- P$ n; \
  284.   def repeat(button)
    & Y" @! [; Y) s( S
  285.     case button) q: ~. q" H/ L
  286.       when 0x01; return @left_state == 1
    % X. b! C( C  X" q
  287.         (@left_state  22 && (@left_state % 6).zero)
    ( u5 v* c* e9 K
  288.       when 0x02; return @right_state == 1 ' g6 Y$ M5 r$ _% V
  289.         (@right_state  22 && (@right_state % 6).zero)* d% Y- Q' m$ Z( R" r
  290.     end, F) u+ N5 {2 z9 c0 w
  291.     return false
    . h3 r) ?7 Q1 y7 F( K/ f7 C+ l
  292.   end4 a1 }$ t/ f! `" {
  293.   #--------------------------------------------------------------------------; l* \3 c: Q' j1 m! C4 |5 u' _, T
  294.   # ● 判断是否双击鼠标
    - L: w/ d" E. I! V6 b" ]/ _: b( H
  295.   #--------------------------------------------------------------------------
    3 s) u* p. Y: U# u: n
  296.   def double_click
    ) `  Z/ b1 g, t9 J6 |. H
  297.     @double_click6 ^- ]" l& s* ?) u) z" Z
  298.   end- W' e( r, i; n) p$ l
  299.   #--------------------------------------------------------------------------7 n7 R" _( R9 M% F( g* e
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)/ U" ?2 g; w" K8 T. x! `1 W
  301.   #--------------------------------------------------------------------------( z! @! o4 k8 D; V8 S
  302.   def click_count
    ( B+ y: q2 z" I5 n
  303.     @ck_count. K: S( v/ N1 d
  304.   end7 B2 J# \  D9 O, @2 N. D$ Q
  305.   #--------------------------------------------------------------------------  z! R/ F. W2 T; n6 Z  e* T, k6 u  R
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    1 l0 d) U$ t: J
  307.   #--------------------------------------------------------------------------  c: |4 }, w4 f- K7 q
  308.   def left_state
    - A1 ~: T& F: I. a
  309.     @left_state
    : e! V# M# M. E1 K
  310.   end
    & M+ V" U% V$ @, r# u& ^/ m
  311.   #--------------------------------------------------------------------------
    4 Y4 q. x: Q: a! U6 L! h: K
  312.   # ● 获取鼠标的x坐标- ^! s# |- w6 o! }3 _. Q% w3 n8 \9 ]
  313.   #--------------------------------------------------------------------------
    # }  ]- X0 x5 `% B& O. s5 B
  314.   def mouse_x
    " p6 z  J0 ^- x* K
  315.     @mouse_sprite.x
    0 k: V* x" ?) R2 f
  316.   end% I/ L( F! `0 O$ U$ G& ~) N
  317.   #--------------------------------------------------------------------------
    . e8 b/ y: ^; H& H6 z
  318.   # ● 获取鼠标的y坐标
    * l4 v$ W: H8 u% q9 `# U
  319.   #--------------------------------------------------------------------------$ N2 Z$ r( a4 w/ `
  320.   def mouse_y
    4 _' F0 B! g. k
  321.     @mouse_sprite.y
    " B3 }6 e9 m2 Z- g3 P$ ]2 M
  322.   end
    - F% o2 @1 y+ ~* g% U
  323.   #--------------------------------------------------------------------------4 k1 o3 v7 c& F$ N
  324.   # ● 设置鼠标坐标
    5 i- v5 o* r5 a' f0 S! r4 q) A
  325.   #--------------------------------------------------------------------------, t& S, c2 z: ~% H( x3 V( `4 r" S
  326.   def set_mouse_pos(new_x, new_y)
    : `8 O* f3 o2 k0 `* |4 E
  327.     arg = [0, 0].pack('ll')
    - _$ @9 ?" [) T& s6 r
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    ! r' O0 i+ @( B+ G( ]1 @
  329.     x, y  = arg.unpack('ll')
    ! A# L7 M5 i/ G/ C! |
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    & Q9 k/ i5 Z* A$ _$ e1 X
  331.   end0 T& i$ I% L; q% |' d
  332. end #end of class  self
    4 t2 q/ j3 m4 _, s% F% E* s
  333. 7 z6 P& s' H# k, n3 ?
  334. end$ W* b, c& Q# R* A9 O+ {1 Z

  335. ) \. [5 V2 Z. d
  336. #==============================================================================$ B0 N0 G3 y7 L$ ^0 Y& h* E
  337. # ■ SceneManager
    ) ~, }2 W8 W6 Z1 w
  338. #==============================================================================5 v5 |. L6 n7 s7 R+ ~$ `: ^+ H
  339. class  SceneManager" K: q8 H; Z  n% G0 D
  340.   #--------------------------------------------------------------------------
    # `; ^9 {/ c3 }: E! ^' ], |8 G. V
  341.   # ● alias
    ) P% q1 f$ |$ f
  342.   #--------------------------------------------------------------------------% }/ q- Z3 V0 n& X
  343.   unless self.method_defined(sion_mouse_run)
      C' I* @* C" ]5 v/ P
  344.     alias_method sion_mouse_run, run
    ) h0 x. y4 k' q& G
  345.     alias_method sion_mouse_call, call
    2 u; r( W% d2 w
  346.     alias_method sion_mouse_return, return& H0 g6 q! e& t2 ?+ }5 y0 F8 n* g
  347.   end, l/ _8 \) @1 f: d* c, w' x
  348.   #--------------------------------------------------------------------------0 c/ T6 ?: s( q7 z/ p# A
  349.   # ● 运行% j; \$ l( ]/ ?. G
  350.   #--------------------------------------------------------------------------/ [( x2 m5 A9 k) y
  351.   def run
    * |% d. q' |) M+ x0 M
  352.     Mouse.init/ c1 b% d0 U0 f6 F% g. }4 m, M
  353.     sion_mouse_run
    $ g& J5 ^7 g; F9 v1 y2 F/ C# c. D
  354.   end
    $ E3 F1 |: ~* y3 H& g, K
  355.   #--------------------------------------------------------------------------
    1 C1 r6 m; c4 |% U+ ]/ e
  356.   # ● 切换' i) v& M' B0 r# m7 i# k
  357.   #--------------------------------------------------------------------------; D" i9 D  l; {' K$ @
  358.   def call(scene_class)
    ) d3 g* S6 B5 S2 M3 f% e/ H
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    % [/ J+ t& X4 W; o% S" A
  360.     sion_mouse_call(scene_class), k& H  B2 G2 V) e% ]  r8 ?, d# E
  361.   end
    2 N* L- v2 J4 ^! P* J
  362.   #--------------------------------------------------------------------------6 c3 v1 g) a# q% S4 i( p! _) Z
  363.   # ● 返回到上一个场景
    0 A% w  \" _; P9 n
  364.   #--------------------------------------------------------------------------
    - M4 T. C) \# c3 n% w! C% F  y6 X9 m
  365.   def return! E# L9 u* J9 E! O, r2 B
  366.     sion_mouse_return. x. W# J$ J% r3 a0 n
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    " J( e$ f7 f$ j
  368.       @scene.instance_of(Scene_Map); a, K# g1 ]! k/ M! F8 i. ~0 |
  369.   end
    5 a" L* F. v; J$ k
  370. end
    % ^# G8 R7 ?9 s5 S9 y

  371. + ^2 e# m  Z" s' e. Q
  372. #==============================================================================, y1 O" f3 i# O
  373. # ■ Module Input8 v* V' Q  R: v- G! l: d; g
  374. #==============================================================================
    : Q/ U. e9 P9 w; Y) |
  375. class  Input- a. o* V3 ^% i$ N+ z' K& E3 _
  376.   #--------------------------------------------------------------------------( c  o/ l0 v% C+ V0 i
  377.   # ● alias
    8 f' D1 r7 h' }) p# v
  378.   #--------------------------------------------------------------------------, i. o4 _( g$ X1 s9 A" w) \
  379.   unless self.method_defined(sion_mouse_update)' R( S8 @& j6 U5 u% L6 Q
  380.     alias_method sion_mouse_update,   update$ U4 S3 {) {  {. L2 `
  381.     alias_method sion_mouse_press,   press
    $ {% i8 K& L: f
  382.     alias_method sion_mouse_trigger, trigger
    ) u3 p- {- f% r- R
  383.     alias_method sion_mouse_repeat,  repeat& {- m3 U; R- D' h$ Y
  384.   end4 A: ?0 p$ ]  o3 a1 b2 y
  385.   #--------------------------------------------------------------------------
    7 m3 C4 O/ M' i6 [5 ~+ k. m
  386.   # ● 更新鼠标
    ' \+ g' E6 j. E0 e: j
  387.   #--------------------------------------------------------------------------4 J, P6 h* x: ]' C7 v* d1 o( ]' w  Y
  388.   def update
    ' R8 p6 p0 q# B7 @- u3 Y
  389.     Mouse.update1 g, o; {4 j3 j5 [0 S
  390.     sion_mouse_update
    / ]- _/ V2 ~& G" X
  391.   end, q9 ?: ]  L- ^: Q
  392.   #--------------------------------------------------------------------------
    ; j4 ~% p0 z  [. E+ B' s
  393.   # ● 按键被按下就返回true
    3 z) {4 X3 G/ _" k5 F
  394.   #--------------------------------------------------------------------------# {- g) Z1 S! U- y+ E
  395.   def press(key)
    7 E3 }" C5 z9 g
  396.     return true if sion_mouse_press(key)! F( B  x3 E1 i! }, z1 p" |
  397.     return Mouse.press(0x01) if key == C1 t  r& v" _6 _& `9 j
  398.     return Mouse.press(0x02) if key == B  t/ G5 ?; L: a! O4 i$ W" ]
  399.     return false( }0 |8 \" B# h9 V: B6 ]
  400.   end
    ; a0 j; R5 l( V
  401.   #--------------------------------------------------------------------------. [+ `8 g1 Z' B$ k5 |: r
  402.   # ● 按键刚被按下则返回true1 w  j! Q0 _$ o( B( x
  403.   #--------------------------------------------------------------------------
    / {( i4 A, I5 K$ T
  404.   def trigger(key)) _. N( w+ f" G, R% ^& J5 X
  405.     return true if sion_mouse_trigger(key)3 G6 n0 m. |$ h
  406.     return Mouse.trigger(0x01) if key == C
    # e& R; S* g/ }
  407.     return Mouse.trigger(0x02) if key == B
    $ J- w) P* n1 n  k
  408.     return false
    + |& w7 G3 J! z4 d# f4 o
  409.   end
    2 Z  r  L1 o1 e2 t3 |! q
  410.   #--------------------------------------------------------------------------
    ( f3 Y1 L+ W; w* n, P6 P3 ~' I
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true6 ?+ C. U: l6 d7 `8 E
  412.   #--------------------------------------------------------------------------* d0 e) n5 z" T3 ^: h9 R& a4 ^
  413.   def repeat(key)
    8 T, |, G# n5 P2 h# A) s9 N
  414.     return true if sion_mouse_repeat(key)
    3 s) W* g" S  A2 m- [
  415.     return Mouse.repeat(0x01) if key == C
    $ x) S  i' r9 I# e) R# `
  416.     return Mouse.repeat(0x02) if key == B
    1 p8 x) T. ^, j6 }- \6 \; L- T; _
  417.     return false4 c# U. e0 P; U5 T- t, `
  418.   end* h# }7 Y  z& n
  419. end: K- r2 U; l2 h: {# o6 r1 W% T. M
  420. ( k' J% `) K" i) [* ^

  421. 3 N4 q% e* U6 K3 d3 A9 |
  422. #==============================================================================* b# N- O" J8 Q  k- f( f
  423. # ■ Window_Selectable
    * X9 A& X  T) P
  424. #------------------------------------------------------------------------------
    4 P8 o: |8 Q/ }3 Q
  425. #  拥有光标移动、滚动功能的窗口
    ) C* g" k5 ]+ h9 E3 q
  426. #==============================================================================! ?+ N6 c  x+ }! N( Q, K
  427. class Window_Selectable
    7 X( ]. j5 ^( k- j
  428.   #--------------------------------------------------------------------------) M' V9 y$ k2 L, T8 D" Q
  429.   # ● 初始化" H3 n4 m. @. b8 X4 X# Y
  430.   #--------------------------------------------------------------------------
    * r& L% T0 }. L( T7 n3 L; L* S
  431.   alias sion_mouse_initialize initialize
    4 b  a' _9 m; n$ u" [+ n
  432.   def initialize(x, y, width, height)
    : ?& A3 [0 s1 [/ S6 Q2 B' o# ~7 c
  433.     sion_mouse_initialize(x, y, width, height). d5 E! y1 K/ v$ C6 p+ s/ e7 ?
  434.     @move_state = 0
    0 A2 Y* r: ~3 t* ?* K) E
  435.   end
    6 k! F3 m  M$ k. H/ U) h- V
  436.   #--------------------------------------------------------------------------
    0 r  f, U* G" d
  437.   # ● 更新5 S* Y& H  w7 i
  438.   #--------------------------------------------------------------------------
      i6 R1 J( v: K
  439.   alias sion_mouse_update update
    7 M2 q7 p+ O; {3 Q5 n
  440.   def update
    4 W/ |3 ^" h% q# }6 k
  441.     sion_mouse_update
    - \* g. h- ]$ b; L' H* ?0 D0 D
  442.     update_mouse_cursor' z) d2 K) J! l
  443.   end
    , I0 e5 V. i1 h
  444.   #--------------------------------------------------------------------------4 `% r9 @/ v6 k" H
  445.   # ● 启动后设置鼠标到index位置( ?8 ~( Y" m; J6 i
  446.   #--------------------------------------------------------------------------) D8 P4 {) @% `8 D8 Y0 W2 Q
  447.   def activate
    7 b& E4 C' @9 |2 l; j. h/ r* Z
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos$ p/ z6 K8 G' X( z0 E; g
  449.     super2 L# x9 y# f7 t. ^
  450.   end; f8 r0 ~. _0 q) ^7 d
  451.   #--------------------------------------------------------------------------3 D8 K+ W" @$ M) o+ i9 I/ M6 f
  452.   # ● 更新鼠标和光标的位置
    & u: f2 d( d3 Z+ s$ g" P
  453.   #--------------------------------------------------------------------------
    8 b5 [/ {9 [# e$ o& h) f; p) D
  454.   def update_mouse_cursor! G# H3 F; |- F8 |% I' y9 E
  455.     if active% a- i" j2 K8 P' X, q
  456.       if @need_set_pos( {. P" w8 N1 J7 q& D4 e( g# m7 [
  457.         @need_set_pos = nil
    : D- f; p; B- ]+ u; X" u* J
  458.         set_mouse_pos
    - B* o4 [1 w" D5 ]! Q
  459.       elsif cursor_movable
    , H; `+ W' t2 A7 Q9 E/ |
  460.         Input.dir4.zero  set_cursor  set_mouse_pos- c1 Q( i, X" M/ e, ^6 x
  461.       end8 v2 F  d$ M- Y5 }2 C
  462.     end
    6 i1 g% l$ o3 E5 J. u
  463.   end- w9 z2 C/ {# J& J/ V3 C# M
  464.   #--------------------------------------------------------------------------. a6 n2 H$ f+ U* R! T
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    % f% Y  D$ v7 w3 @
  466.   #--------------------------------------------------------------------------
    6 E0 Y  A) O6 |
  467.   def set_cursor' r0 {, k) j3 ^5 w9 n
  468.     mouse_row, mouse_col = mouse_window_area& Z0 F* M- I$ n9 G: D4 D4 e
  469.     if    mouse_row == -1
    3 J: o6 ~" ~, }: A3 j. d
  470.       @move_state += 1 if need_scroll1 g+ t6 N% F: j+ R' }- M. ~. Z
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand; ]# M& C" {5 I; B1 a
  472.     elsif mouse_row == -2
    3 }" B" e/ R- b) L5 f& p, w
  473.       @move_state += 1 if need_scroll, i1 A4 v$ g1 m5 @
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand; c* \* a3 c' q; d6 t- j
  475.     elsif mouse_col == -1
    4 c" l5 ]0 H( D/ d! m( _4 a
  476.       @move_state += 1 if need_scroll
    % D) b% J0 J1 z9 W0 w! H
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand0 h# N2 E7 d0 F  n
  478.     elsif mouse_col == -2
    9 c! I$ W: y" P1 w
  479.       @move_state += 1 if need_scroll- C; t8 ?' K" U( D' o3 f: V$ H! h
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand# \$ p9 G. A9 ~9 g
  481.     else
    ; b2 B& w7 g! C8 k5 F, ?! ?3 V7 d
  482.       @move_state = 0
    ) @% R. o& u4 J* g0 ?
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    * m) Z5 u  J1 U( K6 t
  484.       select(new_index) if new_index  item_max && new_index != @index
    0 _; L) h( ^9 R0 A# z! q( l
  485.     end
    # V  q& g4 \! Y# W. [# o
  486.   end
    5 O0 @  _/ w) R
  487.   #--------------------------------------------------------------------------
    0 `* b+ V; c; _
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    $ _5 `& G: {. p" e) k/ r
  489.   #--------------------------------------------------------------------------
    + t6 i2 T/ s' D' }7 L
  490.   def mouse_window_area: S9 @$ X2 a. r, I% M8 e7 @
  491.     if viewport.nil # necessary!% N5 L" b+ \8 o' x; O; S
  492.       vp_x, vp_y = 0, 09 K2 @: G/ Y2 ~
  493.     else
    # B. a+ _6 \0 T! x
  494.       vp_x = viewport.rect.x - viewport.ox
    2 \1 `- v$ X1 }, E  v
  495.       vp_y = viewport.rect.y - viewport.oy9 v$ x5 v9 s: l2 q
  496.     end: c5 |0 n/ l% c% I
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    7 d  V( {, K. C6 A/ o
  498.     item_x1 = vp_x + x + standard_padding
    5 }, ?8 R% A6 V7 B' \
  499.     item_y1 = vp_y + y + standard_padding
    , t- |7 c. {- D$ f
  500.     item_x2 = vp_x + x - standard_padding + width
    ) S3 \1 i/ N- [& t# N; Q2 g# X
  501.     item_y2 = vp_y + y - standard_padding + height
    & |$ [; F& F( q5 A3 j" v' ?7 `0 `
  502.     if mouse_x  item_x11 F" u$ K, I/ c9 c
  503.       mouse_col = -1
      h# L; T( Q* C3 P7 v1 x& W  Z) W
  504.     elsif mouse_x  item_x2$ x+ ^0 g; _" Y' R  o, e2 a
  505.       mouse_col = -2$ k& l7 P& v* i; U  f* R
  506.     else5 F3 b" `. X* r9 |( [
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    , S: Y. R8 ^$ B6 l1 A1 ?
  508.     end9 x3 D, Q  D  }0 ]" I
  509.     if mouse_y  item_y15 G* U! m: o7 B
  510.       mouse_row = -1
    7 h: Y; k6 C. S
  511.     elsif mouse_y  item_y2% O% x9 A: ^* G) L
  512.       mouse_row = -2
    2 \1 x* G$ @) v3 a3 Y7 g: K- V  y9 }
  513.     else
    % U3 A. o+ Q' x+ v  g9 [) Z. C
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    7 W7 o& _9 }. T+ f) m
  515.     end
    ! b# c/ O6 }4 ~& y) e
  516.     return mouse_row, mouse_col
    / s4 K; Y% n# V8 q" _7 O- N
  517.   end
    4 `+ Y/ a+ q# Q
  518.   #--------------------------------------------------------------------------' |( F- B( M: G, d" }4 f* w
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    3 Z$ h! D3 \: `3 L# k
  520.   #--------------------------------------------------------------------------3 \  k+ D- D  x  P, Q. a' \/ l/ `0 ]
  521.   def set_mouse_pos* A' j7 N  j* W* n( e! p! F
  522.     if viewport.nil # necessary!3 |6 V0 b3 E* p' y" }$ }
  523.       vp_x, vp_y = 0, 0
    4 f+ `9 ~  o- Y& y; V" ^# O$ r4 y
  524.     else
    7 J2 h( B8 v* P  m8 r1 J
  525.       vp_x = viewport.rect.x - viewport.ox) Z4 M- g$ K, P$ ?7 D. r
  526.       vp_y = viewport.rect.y - viewport.oy. M1 m* ]% O) J
  527.     end
    # u; W# U) @0 U  K$ C' l
  528.     item_x1 = vp_x + x + standard_padding & O. a" ^" [# s2 [
  529.     item_y1 = vp_y + y + standard_padding; g4 \9 d1 _8 D  |" G1 D; A  F% E/ B
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    + I; C5 K' c" _9 f2 V0 h6 F( F
  531.     row = get_index  col_max - top_row
    ' f- ^5 n+ Q9 M+ D" B8 \% `
  532.     col = get_index % col_max7 R) N6 j# \6 [4 m
  533.     new_x = item_x1 + item_width  (col + 0.5)" K+ ]7 E+ I' i0 ]. H4 o
  534.     new_y = item_y1 + item_height  (row + 0.5)
    0 j* x8 }( }  u6 P' e/ i9 Q3 s
  535.     Mouse.set_mouse_pos(new_x, new_y)
    # w* c. I1 O" k
  536.   end6 r8 F( [& B  j2 X; u
  537.   #--------------------------------------------------------------------------" ^% `" q* X' T. N8 [& }* t6 H( {$ m! \8 y
  538.   # ● 判断菜单是否需要卷动
    9 y; X0 a$ m- F, k/ v2 b6 ?& G# s; U
  539.   #--------------------------------------------------------------------------/ t: k5 {! h8 c% O7 R3 s5 j2 t
  540.   def need_scroll  S4 J, {" A* a0 r. q
  541.     item_max  col_max  page_row_max
    1 T8 O6 q; d& V1 m' d- I# }6 ~' C
  542.   end
    6 ^. D1 ?5 n/ X# y: Z3 l
  543.   #--------------------------------------------------------------------------/ `  b0 s/ {# g. j" c% A
  544.   # ● 判断是否为水平卷动菜单
    1 l# W; b# F% b: E
  545.   #--------------------------------------------------------------------------& V7 z8 ?" U4 {$ c
  546.   def is_horzcommand$ B7 P  T+ i' O
  547.     return false( }7 `) C, G3 V( w8 i, Y! l" N
  548.   end
    ' }0 O, S2 B& k5 j, ?6 E% |
  549. end
    0 R- T8 V& k1 d' V. ^
  550. , o# D% s" l5 T' R" Y7 x
  551. class Window_HorzCommand& S9 N; R& b" J6 [3 l
  552.   #--------------------------------------------------------------------------& `/ o) `. y9 g/ C+ e* |6 B
  553.   # ● 判断是否为水平卷动菜单2 l0 @9 S2 a7 p* T3 k5 H3 v! U+ m4 x
  554.   #--------------------------------------------------------------------------' I" k. x; A# c  N9 X* j6 l* q
  555.   def is_horzcommand
    - D8 Q- y  d, B/ V. F7 e5 l
  556.     return true
    ( S( d3 U& j3 U
  557.   end
    * b9 g/ G: h( ~1 w, |, a6 N! Z
  558. end
    3 q" I- y) y, [3 C
  559. , T$ X3 D; }  }+ R: _
  560. #==============================================================================4 e$ u/ s1 B$ P$ M) L, T& J% X
  561. # ■ Window_NameInput
    5 D6 B6 f7 T5 _. [& m' m
  562. #------------------------------------------------------------------------------
    " J) P5 W# i% ~1 h8 \, o( s
  563. #  名字输入画面中,选择文字的窗口。1 g0 ^/ }& I* [! u- X& l
  564. #==============================================================================
    $ p; o3 S" a$ T1 N' @
  565. class Window_NameInput
      B; U" r3 c5 K; Q& C7 O
  566.   #--------------------------------------------------------------------------3 N2 H1 d' I, r3 |* X( A
  567.   # ● 设置列数! K. O7 E, K% F  V4 Y5 u
  568.   #--------------------------------------------------------------------------
    $ q& M. K) o' m. l, ]9 R! Q( n) ?0 M
  569.   def col_max& q, M7 a6 s3 i# e" H
  570.     return 10
    0 Q; I; e9 Z# z  T
  571.   end& [3 Y" ]! ^/ p7 a- I
  572.   #--------------------------------------------------------------------------
    $ F* Y; N* V+ B0 {) W' @
  573.   # ● 设置填充的Item个数' v6 a' E- ]; H  ~) h
  574.   #--------------------------------------------------------------------------
      J* l  ]6 Y: l5 m5 Y9 ^
  575.   def item_max4 M/ `! V" N3 t
  576.     return 901 f& p/ O3 K# Z! |% W
  577.   end$ Q4 z0 t" \/ c; p0 X% A
  578.   #--------------------------------------------------------------------------: m4 f$ ?6 x* U  }
  579.   # ● 设置填充的Item个数
    $ k! {( B' a6 Y! a) c- H
  580.   #--------------------------------------------------------------------------
    0 q; R  o% x- U+ U3 n3 W
  581.   def item_width
    # ]  {5 q$ l. ]: \2 z! E
  582.     return 32/ I8 ~$ i7 ^7 O0 E# n7 E# @, K* f
  583.   end7 i  W" L, ]  E0 l' V. Z
  584.   #--------------------------------------------------------------------------
    ' H, q, U# G; `- j4 y% [
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    ' k1 h' e5 T9 _& e" X, q$ v; E
  586.   #--------------------------------------------------------------------------* h* ^3 o% |" ^% j% M$ M( l
  587.   def mouse_window_area
    1 |, a" H* W, W( j# l1 l& O
  588.     if viewport.nil; ^  k! Q$ X& ]% W- i  |
  589.       vp_x, vp_y = 0, 0
    / ~/ y" }1 o4 N* R* ~0 V& @
  590.     else1 r/ Z  A' N6 x) s- j" q
  591.       vp_x = viewport.rect.x - viewport.ox
    0 N9 @) g. `, L- {! y: x1 l4 H+ j
  592.       vp_y = viewport.rect.y - viewport.oy7 d" p1 X# H  O! F
  593.     end
    0 J( q2 s6 P/ M  o  A" T/ N
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y0 Z' S4 \* w3 h" Q4 ]' A  G1 ?
  595.     item_x1 = vp_x + x + standard_padding / Y3 V4 r+ y+ W2 x" h0 j* ~
  596.     item_y1 = vp_y + y + standard_padding
    ' q+ n/ ~( s0 H3 ^3 d" C$ A7 q/ j3 q# u
  597.     item_x2 = vp_x + x - standard_padding + width
    , H, K! G' P) D8 _" a: j
  598.     item_y2 = vp_y + y - standard_padding + height5 g1 |) g  r! H9 o
  599.     if mouse_x  item_x1
    ' L& I1 X. o+ I- s% j1 L. x3 O
  600.       mouse_col = -1
    + C, K2 z. m) l
  601.     elsif mouse_x  item_x2
    , _: I' g- t) z+ B
  602.       mouse_col = -2! _; X- M9 K8 ^6 z+ d  S1 b7 b
  603.     elsif mouse_x  item_x1 + 160
    % E" T& l, @/ c0 a) }2 v8 n/ F! c
  604.       mouse_col = (mouse_x - item_x1)32% _6 v# A/ O, Y3 n  D) Y; p3 `
  605.     elsif mouse_x  item_x2 - 160
    7 s$ P- b9 a! W  w* [* z% P% U
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    # v, @( @& U" t' u- k
  607.     else) r, j0 r, m: W7 |/ H. l0 g
  608.       mouse_col = mouse_x  x + width2  5  4
    2 Z8 |2 l  l* Q
  609.     end) s% |5 p) H/ \' y2 s$ `
  610.     if mouse_y  item_y1
    ( o3 N1 E5 v) w. ?- i
  611.       mouse_row = -1. R; l: \- w+ @0 I
  612.     elsif mouse_y  item_y24 ~9 w: N* ~' O" a0 {1 @3 O! g8 n- o' F
  613.       mouse_row = -29 F, a6 Q9 `; z1 C; H+ w, N
  614.     else
    ) w5 }# U2 u7 c5 R1 w
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    : X; K# U; R4 Q/ D
  616.     end
    . R2 f8 L# {4 w
  617.     return mouse_row, mouse_col
    5 T( G0 T0 O6 [* y
  618.   end- z4 L1 y: i7 y+ d- i% O( F
  619.   #--------------------------------------------------------------------------
    $ o4 t6 ~4 x. Y: K" W
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置9 J6 Z2 _3 O" q9 l! ^
  621.   #--------------------------------------------------------------------------& R- M: E& D" V
  622.   def set_mouse_pos
    6 x4 y3 t3 U& O) [: w0 |+ d( M- j
  623.     if viewport.nil # necessary!
    1 N4 F9 S1 T: ]
  624.       vp_x, vp_y = 0, 0
    : w. O; ?3 Z  l" u9 T
  625.     else9 x: f5 @/ v& T* Y
  626.       vp_x = viewport.rect.x - viewport.ox9 R- s; T; G( Q2 D  F
  627.       vp_y = viewport.rect.y - viewport.oy& I0 U. @  n& M, @. i2 [$ J
  628.     end
    & S" g1 G8 y$ {9 ?! H1 d- p1 l' l) _
  629.     item_x1 = vp_x + x + standard_padding
    ) s5 j5 ^0 ?0 l4 s) S& O+ @
  630.     item_y1 = vp_y + y + standard_padding' W5 V+ Y1 ^3 J: D$ P
  631.     get_index = @index  0  0  @index
    ' E5 o. l% l) v* K$ J
  632.     row = get_index  col_max - top_row! D# T; J7 l3 Y' F5 u- F1 Z
  633.     col = get_index % col_max
    / h- y$ R4 V; i) S$ l. b$ E* ?
  634.     new_x = item_x1 + item_width  (col + 0.5)
    6 a1 e* q: d9 A
  635.     new_y = item_y1 + item_height  (row + 0.5)
    ( ^) D( g( D3 d$ M: M& ^4 V
  636.     new_x += 14 if col  4
      U0 F( W" f) e' E% \& B
  637.     Mouse.set_mouse_pos(new_x, new_y)
    8 z. K" R) K1 r$ B6 y7 x
  638.   end
    - x! J. Y2 W) V- I3 }; W" Q1 P! c
  639. end
    3 v/ e  l# L8 Y" l
  640. 2 F  o) |; Y4 r3 w
  641. #==============================================================================7 M* L  H0 @! x
  642. # ■ Window_NumberInput0 q) S' S' G; _4 ?8 r3 r
  643. #------------------------------------------------------------------------------
    + A1 ?5 T. G3 d2 M) v' s% @
  644. #  重写了数值输入的方法以适应鼠标8 l6 N  O! W0 ?, f. \+ b
  645. #==============================================================================
    * G* u+ |% @8 |, _
  646. class Window_NumberInput  Window_Base
    2 {7 F) Y. O- R+ g. v, L  y
  647.   #--------------------------------------------------------------------------
    $ \$ M% K+ m& ?& {4 v# L( V
  648.   # ● 定义实例变量
    1 N; k& r  Y" g* f8 i' \) g5 I
  649.   #--------------------------------------------------------------------------
    # `+ F, c9 [: \- N( _5 s. ?8 D
  650.   attr_reader extra_window
    1 o7 k% X& v& n
  651.   #--------------------------------------------------------------------------
    $ r5 W4 I$ t. z  L  L/ u0 t# b
  652.   # ● 初始化
    4 l6 |4 }( x6 X$ h* l3 i
  653.   #--------------------------------------------------------------------------. T. T0 {+ ?* }" Q1 b
  654.   alias sion_mouse_initialize initialize
    " i# h; _( f- s
  655.   def initialize(arg)" [0 e' j7 v1 f# {( f
  656.     sion_mouse_initialize(arg)
    - ^( f% |: F& w8 W. \' ], P
  657.     create_extra_window9 v4 X" c# p4 R/ v6 M& t9 Q1 C
  658.   end+ U5 c6 w% S; @6 x4 F1 r6 Z
  659.   #--------------------------------------------------------------------------( \) }) S2 _9 A* j2 w, i) Z4 A
  660.   # ● 启动! b2 m. Z# ?# G; P7 H
  661.   #--------------------------------------------------------------------------+ ]( S7 c5 X) |3 J0 Z: [. [
  662.   alias sion_mouse_start start; J! |) N1 v; V5 b
  663.   def start/ l4 f; p' U. S+ J8 i% k3 ?7 S
  664.     sion_mouse_start
    & v0 l4 Y) V+ L
  665.     deactivate
    . {! L5 p; R. C3 |  S
  666.     extra_start
    4 l7 w# x/ {+ D* B4 R8 P) W; l- m: ]$ y
  667.   end+ M; m" m5 l, [* S! r7 c8 I6 A* A' p
  668.   #--------------------------------------------------------------------------
    & y1 }/ l: x) v# D: I# f
  669.   # ● 创建新的数值输入窗口
    ( A: d# I& A/ D* ?. _  f
  670.   #--------------------------------------------------------------------------9 y5 ?3 |. P3 |5 O3 l# V5 V
  671.   def create_extra_window, C# T4 S$ @+ F
  672.     @extra_window = Window_NumberInput_Ex.new. h6 [7 h" u2 N$ [) R
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  27 m3 E2 j8 Q4 v; \) S
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }( a/ A: r4 A% d! G* y9 s. C/ n
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    9 l4 Z9 z% |: x( b7 U, f
  676.     @extra_window.close_proc   = Proc.new { close }
    3 ?$ u7 a0 j7 N. ?8 |! g
  677.     @extra_window.refresh_proc = Proc.new { refresh }8 R% }; W4 t* w9 p& E
  678.   end0 ~6 Q- v6 x! g+ f# _( K
  679.   #--------------------------------------------------------------------------2 ]. I; x  c6 @2 q% B+ q. l8 N
  680.   # ● 激活新窗口
    0 {2 C0 j5 M/ W2 D( c; A" {7 n
  681.   #--------------------------------------------------------------------------1 Z6 J- O0 O2 K' f: C/ R5 m2 n
  682.   def extra_start
    4 P9 R+ [3 x! e* v
  683.     case $game_message.position: x3 H0 v8 I8 V4 x
  684.       when 0; @extra_window.y = y + height + 4
      u, i) `0 _3 d7 n! {/ o- z8 y
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    / `8 c1 O" ]; ~$ g6 E' |
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    ! I5 d% m6 m/ K/ Q* O
  687.       else  ; @extra_window.y = 8
    + ?* p7 k6 j% n( y- Q
  688.     end
    # E% w' u0 ?; J# J, q- S8 v- i6 Y
  689.     @extra_window.variable_id = $game_message.num_input_variable_id3 T7 W, C$ }- P" K
  690.     @extra_window.digits_max  = @digits_max
    3 d% M' ~9 e# x; O
  691.     @extra_window.number      = @number
    # h6 s4 `6 d5 i/ P% G0 R
  692.     @extra_window.open
    8 H2 r9 {" m8 L( N( n& Q
  693.     @extra_window.activate
    * b, W* A7 T- m$ z
  694.   end
    / h# b3 y9 k# L6 W, X0 i! @
  695.   #--------------------------------------------------------------------------" c8 R. t  p* ]' ^4 q  h
  696.   # ● 更新" A* e' D9 q+ \7 W( y' y
  697.   #--------------------------------------------------------------------------& b4 M' b9 P( r
  698.   def update
    8 B3 H6 i$ u" o
  699.     super2 Z# H% p& f8 a
  700.     @extra_window.update
    7 {6 s; J9 [5 b. q
  701.     update_cursor
    ! @4 Y, }. }. [$ X+ H1 Z
  702.   end+ m" C  d% I) X% @" v  _
  703.   #--------------------------------------------------------------------------
    ; m9 d9 @; J5 t( k
  704.   # ● 关闭窗口
    / a2 ?+ i, G# V/ l+ F# W5 U
  705.   #--------------------------------------------------------------------------
    ; K5 L' ]' z* ~# ~+ p1 L& k
  706.   def close
    # T" {. W+ T- h3 p* F. A  t
  707.     super4 ^- c5 E+ m! O" U
  708.     @extra_window.close
    & h9 R+ m( P) E5 J) l
  709.     @extra_window.deactivate
    " I2 t) B  l) m2 i  U0 M+ N8 |% u* Y
  710.   end% g, `7 {9 F7 I. v$ z# @
  711. end
    7 U. G* _  H! A, B0 U" M  [* x( l

  712. - Z* T  V4 \/ f% }# H, y: C
  713. #==============================================================================
    ; G  A# o' R  J4 e7 [) B6 S
  714. # ■ Window_NumberInput_Ex
    ) Y% M" W$ t2 J- k: U/ [0 U
  715. #------------------------------------------------------------------------------7 I3 c' d& C2 q! Y0 z5 a& S
  716. #  新的数值输入窗口(NewClass)# l( d- c7 o4 r2 F, ~6 ?2 z& i
  717. #==============================================================================2 X5 M0 m9 l& \0 L6 l$ B0 ~* L( E
  718. class Window_NumberInput_Ex  Window_Selectable8 Y5 i3 k8 q& n& o! y" V7 p; I
  719.   #--------------------------------------------------------------------------! Q; g* F2 B, p4 p7 ^
  720.   # ● 定义实例变量
    7 `. j: W+ q( i9 q" w0 p
  721.   #--------------------------------------------------------------------------
    5 Y5 K( q) f/ j# h
  722.   attr_accessor number_proc
    3 b5 |3 H9 D* {$ B6 |5 t5 R, v
  723.   attr_accessor index_proc  l& _2 N; N  v4 l8 }
  724.   attr_accessor close_proc7 X) m  v) {# `7 h7 D
  725.   attr_accessor refresh_proc
    % D2 r( G7 ]& U8 P5 K& ^0 u4 }
  726.   attr_accessor number
    4 P* z$ |# Z( R$ k
  727.   attr_accessor digits_max
    7 c- V- E* q! L  R; d! I
  728.   attr_accessor variable_id
    $ Q0 n, @! M) g* v
  729.   #--------------------------------------------------------------------------
    % t5 g, W9 V9 r! i" D
  730.   # ● 数字表
    0 y' `3 Y' V" q/ V; I$ m. M
  731.   #--------------------------------------------------------------------------$ e+ k9 _. u3 A: o4 V) ^! o. C
  732.   TABLE = [  7,  8,  9,5 b0 l1 e+ c* F7 ?& L4 P( D* V6 z1 X
  733.              4,  5,  6,% |3 }0 S" b: r  Y
  734.              1,  2,  3,9 N8 p* p2 G$ E, S
  735.             '←',0,'确定',]1 A2 \/ s8 N% ]
  736.   #--------------------------------------------------------------------------! y/ X: X1 [% q' ?* {3 \1 A
  737.   # ● 初始化对象1 R9 O/ _5 p/ Y8 `" p  b; W
  738.   #--------------------------------------------------------------------------$ v& Z; N4 |$ a4 ]
  739.   def initialize# m1 q6 j. T& B- c2 {* Q9 Q
  740.     super(0, 0, 120, fitting_height(4))
    6 U0 S* @/ m0 X5 n! ^' Y3 q& H
  741.     self.openness = 0
    2 a( b' _& @( @1 f  D' ^3 w
  742.     @index = 0/ h1 X, g2 G5 M2 G
  743.     @number = 0
    9 E/ K  v2 `2 o* @
  744.     @old_window_index = 0
    * J; _% K7 a3 _
  745.     @digits_max = 0
    - T1 U1 B0 l, j, v
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }/ w5 T1 w  G: y" a" ^0 q6 b, ^$ W
  747.   end
    8 ~! g1 K2 E5 O* L/ J1 i. _
  748.   #--------------------------------------------------------------------------" z" ~) c7 Y/ C
  749.   # ● 获取项目的绘制矩形% j* n- g' e  U- I  j# s* s
  750.   #--------------------------------------------------------------------------
    1 C# R% A+ x0 p" n- @/ W
  751.   def item_rect(index)
    $ M( [  t# k; ]* d
  752.     rect = Rect.new+ p' l& T) u( ]- S( j7 B
  753.     rect.x = index % 3  32
    & B& H! G' t9 Y! P1 j
  754.     rect.y = index  3  line_height+ |, t+ R5 U" [- l9 C' E
  755.     rect.width = 32
    & }7 S0 a' i  x( I5 R5 |! t9 Q( P1 l3 |
  756.     rect.height = line_height
    ( I0 X& y' H' u
  757.     return rect& i% j4 f0 w+ O. v. \
  758.   end4 E: ?( D5 m: K' k
  759.   #--------------------------------------------------------------------------
    $ N5 P! j8 Q) {5 `' C% n
  760.   # ● 将光标设置到鼠标所在的位置- N. d7 j6 p# I! T
  761.   #--------------------------------------------------------------------------
    . Q* j6 I9 U9 k, `3 d  u5 p
  762.   def set_cursor
    " H4 m* a% ~$ S; u% X
  763.     mouse_row, mouse_col = mouse_window_area7 e: c: t: v3 g2 w5 }) _/ g; h
  764.     if mouse_row = 0 && mouse_col = 0
    " I+ @+ B& W  U: {& s8 O2 M  O& L  j
  765.       new_index = mouse_row  3 + mouse_col
      Y* n" _9 b( d& C+ Z
  766.       select(new_index) if new_index = 11% d. ^4 M) n- F, Z4 f* S3 o) r. I9 N( e
  767.     end
    * w9 z5 M" {' ?
  768.   end
    0 S) G. m. v# d& M2 e' I" v
  769.   #--------------------------------------------------------------------------
    * Z+ E! p; S4 `
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    $ W  q5 w: c, A! z' @+ }
  771.   #--------------------------------------------------------------------------
    - `8 |4 f3 Y2 f0 J
  772.   def mouse_window_area
    * h, d4 _- B6 }2 _- [6 O
  773.     if viewport.nil9 w; [7 T& h; J
  774.       vp_x, vp_y = 0, 0
    1 h/ e+ t  `* Z8 X6 P4 _
  775.     else
    , s4 b) `# P2 F* S& w
  776.       vp_x = viewport.rect.x - viewport.ox
    " @; B  ~6 X, P+ m4 C! u2 h+ q6 ?; c
  777.       vp_y = viewport.rect.y - viewport.oy
    ) n: q# W( _, L
  778.     end2 v8 |: b& w! p5 `1 o- l+ m2 s
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    / X! g8 ?2 C$ i) |
  780.     item_x1 = vp_x + x + standard_padding
    - O5 B4 x) Y. Z% |, a3 g
  781.     item_y1 = vp_y + y + standard_padding; z  x8 u/ X7 J: f3 ]2 r8 X
  782.     item_x2 = vp_x + x - standard_padding + width
    6 n0 h+ P8 a6 D/ p9 j( x
  783.     item_y2 = vp_y + y - standard_padding + height
    6 ^$ E' `+ Z+ \! I) D
  784.     if mouse_x  item_x14 ]" H2 I8 R  B8 ?* ]0 c7 @7 d
  785.       mouse_col = -1
    & l0 j) v6 V6 {8 X; Z6 q
  786.     elsif mouse_x  item_x2; ]6 I2 z7 K+ ^  B/ H8 y( A5 x
  787.       mouse_col = -2
    * o' T& Q/ b% k  l. x# C
  788.     else
    & o' Q' R" x7 z. H
  789.       mouse_col = (mouse_x - item_x1)  32+ E- }- u4 ]9 f9 G( S) P
  790.     end: c: }' V( c* e; g( j) W% T* @+ X
  791.     if mouse_y  item_y16 i/ O2 [# t; X* a2 z6 @/ ~/ z
  792.       mouse_row = -1/ @9 d0 ^: `4 R# ~9 ]: Q) b2 ~
  793.     elsif mouse_y  item_y2
      C! E7 W5 b6 q5 @
  794.       mouse_row = -2( g0 r$ y( M8 H" C7 d
  795.     else
    " f5 w5 t/ ~; s# W6 ~. f% D' D
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)1 u' u, v+ T* A
  797.     end. T, Z1 l" k# [$ c
  798.     return mouse_row, mouse_col3 I% H( Q0 C/ p" U+ |8 i
  799.   end
    9 |/ d5 N' M& W' U
  800.   #--------------------------------------------------------------------------
    7 |, |5 [- r# S# s; D
  801.   # ● 获取文字, F- V0 ]% w! z, C0 z2 g9 O0 t
  802.   #--------------------------------------------------------------------------
    # S! M. y& r$ ^. c; L
  803.   def get_number4 x- G9 A: g5 k  j3 D
  804.     return false if @index == 9  @index == 110 j3 \0 F9 K8 }8 i
  805.     return TABLE[@index]" O8 `8 b( o+ x* O  X* f% o% Z4 Y
  806.   end0 ]; o( }" d9 w7 B
  807.   #--------------------------------------------------------------------------* E. `8 I& o2 \; Q; G6 c1 O% z1 S3 O
  808.   # ● 判定光标位置是否在“退格”上" I; z  v, N3 H: a: a. t+ a1 s! c! J% ^
  809.   #--------------------------------------------------------------------------
    ) S$ }4 k9 u; H2 [8 ~; M
  810.   def is_delete* c6 J- d* P$ z: x5 l
  811.     @index == 9
    & M5 n# B3 W* a4 ~* y; L
  812.   end6 @! s. s. p5 }# U6 P' E, B& X
  813.   #--------------------------------------------------------------------------
    3 g+ S2 u) W8 \/ [' I$ A
  814.   # ● 判定光标位置是否在“确定”上4 D, ?6 ?2 X# `" O# ?- Q* g, s
  815.   #--------------------------------------------------------------------------2 |# `6 i2 b9 i4 I1 R% i
  816.   def is_ok
    $ ]2 }1 B0 b; }# B2 g, U# P: G
  817.     @index == 112 @# x' j! d9 m! B
  818.   end
    7 i- a+ E: C  ?$ i* e3 S6 R
  819.   #--------------------------------------------------------------------------7 f, O5 r  T  v  C8 [+ R3 O
  820.   # ● 更新光标9 B9 ?; }- |. D
  821.   #--------------------------------------------------------------------------6 U% a( O7 i- Z; F
  822.   def update_cursor, H1 Q( w1 h7 X+ e
  823.     cursor_rect.set(item_rect(@index))
    ; C- ?/ z# i5 g1 W
  824.   end
    ! `  j1 K$ z- w' h+ y. q$ M
  825.   #--------------------------------------------------------------------------
    " t, z; [- B+ r5 i
  826.   # ● 判定光标是否可以移动
    * f8 \1 q( ]! _6 u
  827.   #--------------------------------------------------------------------------
    " f; Q1 M9 H/ L1 b2 `8 ?
  828.   def cursor_movable
    $ ]/ W# {) }' H. u8 M
  829.     active
    - O. Z1 K/ ~8 c1 B6 c. J/ W
  830.   end
    4 G; a0 o: g( J$ n! j
  831.   #--------------------------------------------------------------------------
    8 H: \+ Y! f+ ]0 k
  832.   # ● 光标向下移动
    1 Q0 n& L' s* ~! f, Z, S
  833.   #     wrap  允许循环
    9 g0 i$ }5 G6 C( X' S# b  X" J
  834.   #--------------------------------------------------------------------------
    6 a$ Y. [9 s4 g  U1 H2 P
  835.   def cursor_down(wrap)
    / Q( J' R; B! T2 R6 V# y: P4 M
  836.     if @index  9 or wrap
    3 y8 `. s; `' ~6 H
  837.       @index = (index + 3) % 12
    ( h5 V) V; s7 l! E/ I' t( _
  838.     end
    5 }% @  ?* _- m# W
  839.   end
    9 T- u5 D' S+ a) ~. \! W2 ]1 @
  840.   #--------------------------------------------------------------------------* R# D) K! E9 I- U! s
  841.   # ● 光标向上移动1 A8 N+ ]- M" G. ~6 ^
  842.   #     wrap  允许循环
    # y$ c% X! Z1 o/ j+ K9 l1 h1 z% V
  843.   #--------------------------------------------------------------------------3 h/ o2 h! Q$ o# ?# [
  844.   def cursor_up(wrap)
    0 I, o3 F! v1 |6 _6 c
  845.     if @index = 3 or wrap
    9 a2 ?  j; }( N. r- a
  846.       @index = (index + 9) % 12
    ) _1 D7 K  y. {( K) E
  847.     end
    0 p9 |  F$ F% r* P1 o
  848.   end( c( l: Z' _+ T: x# J" b; s
  849.   #--------------------------------------------------------------------------) Q; ]- J  ]5 ~1 A- S) Y/ E7 M& V; N
  850.   # ● 光标向右移动1 J( z( \( ^! J5 c7 W
  851.   #     wrap  允许循环
    + I9 y8 l+ P) n- F* u7 h7 B+ b. x
  852.   #--------------------------------------------------------------------------
    . @+ M* {+ m- w% m7 Y2 a
  853.   def cursor_right(wrap)4 q+ e6 P& v3 h
  854.     if @index % 3  2+ B3 q/ l: B1 K$ X2 u
  855.       @index += 1
    5 M" R8 g8 i, S& u
  856.     elsif wrap
    " V+ S- @, A" |) ]( }' p  r
  857.       @index -= 2
    4 A6 G! E7 r( E4 R- A
  858.     end
    4 d2 e/ D7 L& [7 a2 j# F
  859.   end
    $ G+ x# D+ r  m* m  s( h
  860.   #--------------------------------------------------------------------------
    : w! V9 @. O% d  V
  861.   # ● 光标向左移动
    : M( P2 U+ Z; P* x" m
  862.   #     wrap  允许循环
    ' e; b) Y4 n6 X
  863.   #--------------------------------------------------------------------------4 J  @3 z7 z; ?" ~: q- I% M
  864.   def cursor_left(wrap)# L, o" u1 b2 I2 ?
  865.     if @index % 3  0
    9 G8 F* Q9 L/ _1 u( ]+ {, B
  866.       @index -= 15 W; d3 ~, l7 l! v7 z$ n* J
  867.     elsif wrap
    4 V1 E5 T6 g, o& V, t
  868.       @index += 25 V5 K2 K+ v0 `" {" a
  869.     end
    0 ?# t' C" |. e# u" `& u4 q
  870.   end8 S& Y( N2 X. q
  871.   #--------------------------------------------------------------------------% a/ T4 S+ y2 j4 F, J' n
  872.   # ● 处理光标的移动
    ! \3 Y. a' [2 b  |
  873.   #--------------------------------------------------------------------------
    9 w1 Y" E: d" o; L) f* P) @
  874.   def process_cursor_move3 X1 y6 E5 Z3 b! a
  875.     super
    # G9 @# }9 ~0 q+ M1 h8 G0 j
  876.     update_cursor; g' i8 {+ ~  ?3 A$ w, P
  877.   end9 b  p0 S5 {& H) j9 c* @
  878.   #--------------------------------------------------------------------------
    . }" \/ O* _! Y& V; n! \& y
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    - L$ L9 u+ L0 ~# U# t6 J' S
  880.   #--------------------------------------------------------------------------: L, t0 D% R' D
  881.   def process_handling
    0 y# O- w9 M7 A( E# l# j
  882.     return unless open && active
    3 }! J& w& `) _
  883.     process_jump if Input.trigger(A)
    4 n6 W* C7 x& B4 ?
  884.     process_back if Input.repeat(B)6 c) h5 H. x  ]& a9 S! m4 O* [! [
  885.     process_ok   if Input.trigger(C)
      q0 A; V' e7 r' ?' C2 A5 s0 j
  886.   end
    * `$ _  e, ?  r4 k6 R
  887.   #--------------------------------------------------------------------------
    " l2 G; [7 K, S, i- M$ A4 N
  888.   # ● 跳转“确定”
    " {$ j6 H. ~2 v  I. `- f5 u2 ~- z
  889.   #--------------------------------------------------------------------------
    2 m4 {4 D- [0 q& I5 q2 }
  890.   def process_jump
    5 P# g; I* W7 q9 \1 K6 E
  891.     if @index != 11
    & L/ p5 W- D; S% N- U/ Z
  892.       @index = 11' s/ v  R4 g4 V; H3 p! b8 z
  893.       Sound.play_cursor
    . c1 [' {3 Q$ C5 A# [( S: W! U( p
  894.     end
    - J0 a7 J, \. q  W# v
  895.   end8 c6 [( o7 [& f
  896.   #--------------------------------------------------------------------------. i5 R+ I& V0 M: G# p
  897.   # ● 后退一个字符
    8 _0 x+ b6 E6 Y9 T! ~
  898.   #--------------------------------------------------------------------------
    3 w* H/ r* D+ r) I0 A+ c
  899.   def process_back
    % S1 t. O# c* P' {
  900.     Sound.play_cancel
    ( b4 |/ {3 m- f$ ~: E. \3 p
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    9 V+ Q5 P  y* N4 T8 W( B9 e, j. I
  902.     n = (@number  place) % 10
    / p5 y5 Z) p$ {# Z7 _0 Z* t) b
  903.     @number -= n  place
    1 t% }+ A- T( F4 L" n6 v& B9 Q
  904.     @number_proc.call(@number)7 ^& n& o* ~& R& Z' d# H
  905.     @old_window_index -= 1 if @old_window_index  0! q0 s, H  J( k( `% T, a: }# u
  906.     @index_proc.call(@old_window_index)1 G& a! E: l: s: I0 Q& [# w+ w7 }
  907.     @refresh_proc.call
    6 Z- e  l  i7 Y# l, Z7 P  m
  908.   end
    * e9 G( M2 ^0 Q) `3 D7 y
  909.   #--------------------------------------------------------------------------
    3 @- S. L- X( z- Y9 U' o
  910.   # ● 按下确定键时的处理
    3 C, N1 R4 z; }9 C* J6 \9 b
  911.   #--------------------------------------------------------------------------
    - F, [% i( H7 }/ g9 d
  912.   def process_ok0 @3 L+ `6 r6 W  w; E8 [
  913.     if get_number+ k' v- j! b8 a5 Q' l
  914.       Sound.play_cursor# I' ~5 Q- ^% E! d% b1 |
  915.       place = 10  (@digits_max - 1 - @old_window_index)& D5 g. x/ {4 {4 k5 e9 c* [# B& E5 U
  916.       n = get_number - (@number  place) % 107 b3 x7 W# V! v# C. e4 X6 d
  917.       @number += n  place
    ( Q6 ?2 L& t3 M5 N# \4 Z  {# L
  918.       @number_proc.call(@number)
    ( u' q' M% y  U$ L/ ]; K
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 11 U3 ?9 Q. @2 h1 |4 e2 Z
  920.       @index_proc.call(@old_window_index)+ w4 ^* c% N. M% n% k
  921.       @refresh_proc.call
    2 g7 L# X4 Z. N- _! O! S- d$ ^
  922.     elsif is_delete
      d! B0 F  ~, w
  923.       process_back; M! ?; l1 p1 q& u7 X" n/ g
  924.     elsif is_ok
    # A, R9 F' e' @+ H" \
  925.       on_input_ok
    # B5 B6 B: b- g) s7 B+ s
  926.     end
    + Q8 r- b# e- u8 j+ @! f
  927.   end) l) n4 W$ M! E& x& _# j) g  ~
  928.   #--------------------------------------------------------------------------8 ~. ~0 n) p  `. U% t
  929.   # ● 确定
    # f1 t! ~3 H# `$ f
  930.   #--------------------------------------------------------------------------
    5 q: J* f, [9 ^6 w1 x2 w* N- |0 B
  931.   def on_input_ok
    $ \" W) a) t8 P1 W' K
  932.     @index = 05 p; e, _# v. S5 ?0 K  ]6 C" v
  933.     @old_window_index = 0' q3 k; J/ @0 i0 a8 ~
  934.     $game_variables[@variable_id] = @number8 u: n! F7 {5 V+ \/ M5 G
  935.     Sound.play_ok
    & N7 V8 }/ f: R2 W
  936.     @close_proc.call3 z! ^  O& |8 r- r& {! [
  937.   end
    + k! P3 E5 b1 [5 G/ H
  938.   #--------------------------------------------------------------------------
    2 g: B/ n; h- D( x  x
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    9 H& w+ Q( j/ h% H
  940.   #--------------------------------------------------------------------------, P2 U+ Y# y- V8 y2 S1 O5 W0 U
  941.   def set_mouse_pos! A, k: g+ S/ Z& |: F
  942.     if viewport.nil # necessary!8 a( }0 U" N$ q
  943.       vp_x, vp_y = 0, 0
    ( X1 M0 u' o# u) _" Z* B
  944.     else
    7 Z; z; e' P. D
  945.       vp_x = viewport.rect.x - viewport.ox1 n( I$ d6 B- g
  946.       vp_y = viewport.rect.y - viewport.oy
    ' d5 \- Q8 n+ e4 `$ L
  947.     end5 c0 o. O2 t! M  {( a
  948.     item_x1 = vp_x + x + standard_padding , n- T; n/ C! o2 ~
  949.     item_y1 = vp_y + y + standard_padding
      [* x' f8 V  A6 V7 R" m; i
  950.     get_index = @index  0  0  @index   ?* ]8 z* {7 x
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5); y! _2 _4 \2 U4 |0 M& S" z
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    8 q, |. D+ g  t8 ^/ t. N& z' H
  953.     Mouse.set_mouse_pos(new_x, new_y)/ E; C9 e5 `2 V" T
  954.   end7 B& M+ `! A$ D" t$ e" n
  955. end5 K5 @! j3 y2 {2 e9 W9 W7 z
  956. # N  X5 t6 P5 Z# {/ J1 {
  957. #==============================================================================8 f7 ~- b0 i# y! f  w; x2 g
  958. # ■ Window_Message
    9 u) _- E7 j+ G' ]) H0 k
  959. #------------------------------------------------------------------------------
    5 B# H3 R7 ^; _1 Q  x
  960. #  显示文字信息的窗口。; M* ?: ~7 C9 t7 \0 Z4 J* M& p5 s
  961. #==============================================================================
    3 e( R' g1 j  C# O8 ]) c
  962. class Window_Message  Window_Base" H. \1 K3 ~- t, l* n: `* s
  963.   #--------------------------------------------------------------------------  z" f6 n8 H' \1 H( E
  964.   # ● 处理数值的输入(覆盖原方法)/ P& ]$ W1 e4 r: f  v1 T* I' T
  965.   #--------------------------------------------------------------------------
    $ p2 x6 J* |% b8 N
  966.   def input_number& D, l, V5 s% M3 P8 V. z: e, v
  967.     @number_window.start
    7 O% @2 {, {; m$ d8 A
  968.     Fiber.yield while @number_window.extra_window.active; D5 e7 A/ ?/ b; k
  969.   end9 w4 t/ R8 `! K0 @
  970. end
    : u+ a) h# Z' L0 @7 j6 t$ y

  971. 0 x  ]6 E$ y7 t% Y. o
  972. #==============================================================================
    ( |9 m( |. f# f, Y/ y
  973. # ■ Window_PartyCommand: N/ Q9 K0 ~9 d# \+ Y4 [& D- g6 {1 I
  974. #------------------------------------------------------------------------------
    - y9 {! T1 E" w  `* ~# D! z
  975. #  战斗画面中,选择“战斗/撤退”的窗口。2 \1 y& q: L$ P
  976. #==============================================================================  d$ R  e' [; _4 Y3 ^8 A
  977. class Window_PartyCommand  Window_Command
    $ f4 P& C' w& y# t  ?4 T2 x
  978.   #--------------------------------------------------------------------------  u7 g+ }" `9 P9 ^( p/ C7 E/ v
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置; w, D/ G5 [* v1 _( x/ x! t
  980.   #--------------------------------------------------------------------------4 i5 y* }! n+ _* q" D  ~
  981.   def set_mouse_pos
    * t( X/ m5 z9 Y# g0 U4 p
  982.     if viewport.nil/ A* ?' X) d3 W6 g+ V. F0 ]1 u0 r
  983.       vp_x, vp_y = 0, 0( e/ u' g/ i) ^( _
  984.     else
    # o4 b! ]' u1 F/ G
  985.       #vp_x = viewport.rect.x - viewport.ox
    ' p% E8 ~$ ~: U& I0 W
  986.       vp_y = viewport.rect.y - viewport.oy% L( Z1 g- O  d
  987.     end
    5 g3 }! o2 |  C9 Q  Q
  988.     item_x1 = x + standard_padding ; M' j+ {+ d$ P# n: m! O
  989.     item_y1 = vp_y + y + standard_padding( W# `# z  [" _
  990.     get_index = @index  0  0  @index % k( ~  ?  R/ m- ^; x% q
  991.     row = get_index  col_max - top_row* ?* f$ e; ~$ N* O
  992.     col = get_index % col_max  A6 A/ ]9 J  v1 Y. h
  993.     new_x = item_x1 + item_width  (col + 0.5)
    * \5 a1 I& ^6 g
  994.     new_y = item_y1 + item_height  (row + 0.5)
    / g/ H* y: w: B" I6 q. ~
  995.     Mouse.set_mouse_pos(new_x, new_y)
    $ T) M9 C$ A6 M( A
  996.   end/ R. |' L% t) [6 q& N+ C
  997. end1 ?% h6 r; ?1 N

  998. 9 V( W; c, i8 G( b/ U/ Q
  999. #==============================================================================7 x8 k! v3 h4 k" |" W8 ]
  1000. # ■ Window_ActorCommand) ^5 u: _  V& Z: F
  1001. #------------------------------------------------------------------------------
    + W8 c* r2 k5 O" F2 _4 ^3 @7 L
  1002. #  战斗画面中,选择角色行动的窗口。
    5 T- N+ s6 Q9 o
  1003. #==============================================================================- j: A4 P* b0 G+ N7 X. m
  1004. class Window_ActorCommand  Window_Command
    2 \; S( z% D3 c( \3 ^4 f. y2 O* `
  1005.   #--------------------------------------------------------------------------
    5 e9 p6 }6 Y- K4 g7 I
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    1 {6 d0 Z. E+ u( c
  1007.   #--------------------------------------------------------------------------
    : J! T5 d2 f* {
  1008.   def set_mouse_pos
    1 J5 `+ [) A% l7 J
  1009.     if viewport.nil7 {* S# J- _. Y! m6 F3 [
  1010.       vp_x, vp_y = 0, 0
    0 O) d; `8 k9 c1 x
  1011.     else" v& z. @; G! f! q$ w. f# C
  1012.       #vp_x = viewport.rect.x - viewport.ox* ^  Q; m/ }" F
  1013.       vp_y = viewport.rect.y - viewport.oy
    ; w0 K+ T) B% A3 `9 [
  1014.     end
    ' B* Y5 V7 L) N8 }6 H# a! N5 \
  1015.     item_x1 = Graphics.width - width + standard_padding5 F: g3 A' p( A7 Q" y8 k; x# M
  1016.     item_y1 = vp_y + y + standard_padding1 L" V( x8 b) R
  1017.     get_index = @index  0  0  @index , N9 |7 q, l7 {# ~4 m( T: u
  1018.     row = get_index  col_max - top_row) r' G7 P% J/ V& a; V
  1019.     col = get_index % col_max
    $ W4 E+ h/ T$ ]
  1020.     new_x = item_x1 + item_width  (col + 0.5)1 d- Q" n( N, U' ]8 ~6 m! r
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    8 k2 c3 x$ f- P5 {' P) k
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    4 F1 ]& l% R4 f& E7 }6 ?
  1023.   end
    8 R: Z7 G  e: y$ \. _
  1024. end$ ]7 w& @1 D* b

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

  2241. 9 g# E# h. H# q( L/ K/ Z# f% i" E
  2242. #==============================================================================
    % ]4 r. k1 U, K+ f
  2243. # ■ Scene_Map
    + y7 S* N( O' o6 ^! e3 ^
  2244. #------------------------------------------------------------------------------
    2 p! N* s; b, f
  2245. #  地图画面7 Q$ r9 e+ A; [/ L0 |
  2246. #==============================================================================1 {: k1 N- Q. V, R  y
  2247. class Scene_Map  Scene_Base
    ; n# F; |6 U! Q, h2 |7 }
  2248.   #--------------------------------------------------------------------------3 @' N% X* W8 _' b  }- {
  2249.   # ● 画面更新
    $ ~: z, ]$ N* X8 J0 l+ @
  2250.   #--------------------------------------------------------------------------
    3 f: R( a3 U7 e% i: v, j
  2251.   alias sion_mouse_update_scene update_scene! r" I- {6 ]! ^
  2252.   def update_scene
    - l1 U3 C: a. s
  2253.     sion_mouse_update_scene8 t  D' B& ?) ]: T$ y( Q( Z
  2254.     update_mouse_action unless scene_changing' d. q7 m$ Y% t5 J# |- ]: O
  2255.   end) v( a( s, b: {) u0 V
  2256.   #--------------------------------------------------------------------------
    + s' x) P3 T# M& h9 f. t
  2257.   # ● 场所移动前的处理
    5 U- e  x* n+ s' L; w. O
  2258.   #--------------------------------------------------------------------------
    ) P9 j2 P; o+ |7 F% u: v& B
  2259.   alias sion_mouse_pre_transfer pre_transfer! N0 Q: e  o% m# t2 i+ m
  2260.   def pre_transfer9 q6 N9 M* a5 \! s, Q( I& r0 q; H
  2261.     $game_player.reset_move_path5 u( \& {! ^* _4 j
  2262.     sion_mouse_pre_transfer4 {9 M, y9 b4 v2 ~
  2263.   end: B$ d6 n  K6 m8 p
  2264.   #--------------------------------------------------------------------------- p( N. B1 f' r; I9 O
  2265.   # ● 监听鼠标左键的按下
    7 A$ v* C9 A1 j/ U
  2266.   #--------------------------------------------------------------------------' k: f. O( v: E1 q
  2267.   def update_mouse_action
    % Y+ G5 e6 L9 h! \, f
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    ! {4 Q- L" W# G. @# B! Q
  2269.   end
    * G% o, S) v2 V& N3 f4 `
  2270. end
    6 `' Z% I5 D5 a6 T

  2271. 4 o9 i5 Q# P3 Z2 h/ @+ k$ E
  2272. #==============================================================================
    ) Y1 q* [8 c, T6 E- s! {* b0 F
  2273. # ■ Scene_File0 H4 z7 y4 e+ E7 [1 p, D* n/ c3 C* P* n3 x
  2274. #------------------------------------------------------------------------------5 w$ n. V5 q; n5 [4 o3 }- R% k
  2275. #  存档画面和读档画面共同的父类8 x1 |/ ~" w; R  u) U- y
  2276. #==============================================================================4 Q( }4 ]6 I  N4 {
  2277. class Scene_File  Scene_MenuBase
    $ i: ~$ f8 [/ B6 t9 Q+ W
  2278.   #--------------------------------------------------------------------------8 y. A' T- Y  \, V8 {3 A+ _6 Q- @+ ]+ T
  2279.   # ● 开始处理
    6 L" s7 u( w. B
  2280.   #--------------------------------------------------------------------------
    6 n$ a' o3 S' I  m! u  c
  2281.   alias sion_mouse_start start5 R8 q6 \! u  r, R* q, m
  2282.   def start, S7 E5 k3 V! h# s
  2283.     sion_mouse_start) _! g2 T3 S. M+ s* U6 y0 \
  2284.     @move_state = 0
    * H1 S* ~- o' M/ n9 `& o) O2 m( s
  2285.     set_mouse_pos" z; ^  ^6 C  t0 w  V0 f* S
  2286.   end3 g8 w& M+ I  @
  2287.   #--------------------------------------------------------------------------2 V8 x; o) ?! v+ Y- v2 e; b# r
  2288.   # ● 更新画面
    2 }' u8 Q0 h0 c) L2 x3 B: \6 |3 ~
  2289.   #--------------------------------------------------------------------------9 }1 R6 w1 F9 `6 z9 h% O
  2290.   alias sion_mouse_update update9 N3 n7 y. G, g- d: `8 S. z( }5 x
  2291.   def update0 _6 Q# U, y( d. r" ]" i
  2292.     sion_mouse_update
    , m! X9 s0 x0 l" @' G. c8 L$ h! ~
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos9 n7 ]  `5 }3 W2 ^* L
  2294.   end
    9 G) v0 U0 G! S4 H
  2295.   #--------------------------------------------------------------------------
    # y& n! E4 L" l( \; _9 R
  2296.   # ● 更新光标& p5 f( o( c  u4 ?$ _
  2297.   #--------------------------------------------------------------------------' W: N4 y; X! a, D2 v: F
  2298.   def set_cursor
    . Z& T9 b. d0 t5 N4 _7 T
  2299.     @move_state += 1
    9 |0 c! w* v& V
  2300.     last_index = @index) \' _* D0 \% Q0 b
  2301.     if mouse_which_window == -2
    ' N8 j4 I# i/ j
  2302.       if (@move_state - 1) % 6 == 08 R; }8 `. \# ^0 b) U/ _) |
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    ; C) O4 r( j6 n- \( I
  2304.       end) b2 T) \/ a3 d$ ]
  2305.     elsif mouse_which_window == -1
    / I/ I9 h/ A- l/ e! x
  2306.       if (@move_state - 1) % 6 == 0+ J& ^6 v+ I# Q+ U# h: ^
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0! _! o3 x" o8 C+ @' v) w  C5 m
  2308.       end
    6 [! b- r, d, X( w! ?) S& i8 H) C8 w
  2309.     else4 ]4 P6 w" ^0 C3 p. T3 n) r
  2310.       @move_state = 0. [  B% p# R: ]1 }8 O# V& D
  2311.       @index = top_index + mouse_which_window8 C8 w7 Q0 ~" U5 C: }* z2 V3 _( \( Q" J2 ?
  2312.     end4 C6 y2 ~8 e5 d: A3 w) M
  2313.     ensure_cursor_visible! ~3 h8 k( `1 D8 @+ H. Z
  2314.     if @index != last_index# [1 G" T7 F- H4 e* k
  2315.       @savefile_windows[last_index].selected = false3 h" A' a8 {1 S/ A2 h8 W
  2316.       @savefile_windows[@index].selected = true0 \( }0 c4 ?' g8 Q( Y6 W" Q8 K
  2317.     end3 b4 P0 P0 Z" O2 _# D9 u
  2318.   end
    , I% [2 Y* c) r
  2319.   #--------------------------------------------------------------------------2 L: ^( G1 X% c! J% I3 b5 J+ S
  2320.   # ● 判断鼠标位于哪个窗口; a$ e" M9 d' f
  2321.   #--------------------------------------------------------------------------
    9 F  Q' s4 d, t
  2322.   def mouse_which_window
    ; b  f4 W, d: h& w% _  c" A% Q9 ]
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y) D% w8 C9 U+ A$ Q- r$ Q
  2324.     if mouse_y  @help_window.height + 14
    ( B) U) S1 G: U6 I- ]
  2325.       mouse_row = -1; x1 r6 @1 T* A  o# b
  2326.     elsif mouse_y  Graphics.height - 14. s) U) T1 k1 o$ t+ U
  2327.       mouse_row = -2
    8 v% R3 }6 w  i: F' n: W( n5 d
  2328.     else4 T( D2 Z! \: R" e
  2329.       mouse_row = 4  (mouse_y - @help_window.height) 2 l( N0 B: _# w4 t, H4 w
  2330.         (Graphics.height - @help_window.height)
    4 e% K. N; e# a( p7 m. [
  2331.     end) t. [: j# `, X+ F8 M
  2332.     return mouse_row1 i  p% N0 u9 x+ ]1 n6 H
  2333.   end* b% u5 M  E% W. M, o7 X6 c: R
  2334.   #--------------------------------------------------------------------------5 i: _5 y4 B7 Y5 ?% s
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置! c8 [2 G( ]" i4 `
  2336.   #--------------------------------------------------------------------------6 R% d* U, _" E- P6 I4 }
  2337.   def set_mouse_pos4 [4 M8 _3 {* h' }0 |  F" N2 [
  2338.     new_x = 40
    " a/ H9 |$ `' _' Z
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24+ U7 J) ^3 c! Q+ }& _
  2340.     Mouse.set_mouse_pos(new_x, new_y)9 Y$ Q8 ]. ?1 c% Q
  2341.   end" P  U+ @( S: u$ Z
  2342. end  z: Y7 K% \6 W# ]1 J
  2343. 9 D  i$ B  o) ^& Z+ F/ d
  2344. #==============================================================================* z' ]' h2 j' k+ E: n
  2345. # ■ Game_Event
    + k" n9 o1 S0 _; w
  2346. #------------------------------------------------------------------------------
    3 H# X- t6 `# L9 d
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    1 A* B  \% r: G" a" j6 M4 d
  2348. #   在 Game_Map 类的内部使用。) R: Y' n" x; p9 i$ t- G+ J
  2349. #==============================================================================1 ?  j, z' B% V9 o
  2350. class Game_Event  Game_Character
    7 Y3 X* w8 H( j! F) w
  2351.   #--------------------------------------------------------------------------) g  T1 _7 ^/ t9 x' n/ [0 E& |! x
  2352.   # ● 事件启动# ~  a; `3 e6 b$ b% }
  2353.   #--------------------------------------------------------------------------) E% \) J: o/ t, V! A
  2354.   alias sion_mouse_start start
    5 ~  o2 @! `# F- K8 ]  J+ }
  2355.   def start4 j4 d, m' T3 Z' z9 H
  2356.     return if mouse_start && !Mouse.press(0x01)
    % T8 V2 P$ C1 G8 [3 `4 v
  2357.     sion_mouse_start
    + d) X; \; z2 j  ^
  2358.   end: c* s, z, z4 N' N  E
  2359.   #--------------------------------------------------------------------------
    0 `# f2 o/ _3 Q4 f5 L! C
  2360.   # ● 判断事件是否由鼠标启动
    ! K. o8 v5 p0 u* }' t! I
  2361.   #--------------------------------------------------------------------------6 c" |2 j6 c) H7 V; e3 R; o
  2362.   def mouse_start
    # s$ R: o& g% S' Z& n6 F
  2363.     return false if empty8 f7 p6 `9 L" m. z$ `) I' `4 v
  2364.     @list.each do index% f+ W% i( |/ p
  2365.       return true if (index.code == 108  index.code == 408) &&* T& [& p( |, T6 Y7 L, B
  2366.         index.parameters[0].include('鼠标启动')
    9 G, G* V, R! \) [7 Y' E
  2367.     end
    4 r" J2 [& T7 |# V
  2368.     return false
      a3 x  x% e2 j$ ?2 |
  2369.   end" W% v- _: t8 Y6 ]1 A
  2370. end2 o( l. E2 h! a, n3 f! K
  2371. 7 Z+ j9 i' N' Y( O2 W' K8 u
  2372. ####泥煤的height$ |3 _. d" S/ |- u% w; t5 ~
  2373. # @height = height5 e2 I+ Y. u0 G
  2374. 9 `# m" p5 N+ ^3 u
  2375. class Area_Response
    ( @: P1 c3 g5 ?
  2376.   attr_accessor type
    ' ?# N, a3 K' R+ Z
  2377.   attr_reader ox
    . _0 e" q! T4 |
  2378.   attr_reader oy7 ^/ j, ]$ I9 K- r  D$ m
  2379.   attr_reader width; \" d, K& i& U8 T* l1 k5 y
  2380.   attr_reader height7 t& t8 L/ F( p9 }
  2381.   attr_reader switch_id5 w6 O6 c. e0 u; n5 P
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)6 q- ~3 _, y+ _/ @6 I: E. Z' ^! \* {, X
  2383.     @type = type
    ( A, i* n6 s; @" C, w1 K, r. h
  2384.     @ox = ox
    1 L& u! `2 i; R+ @& U6 ^
  2385.     @oy = oy
    ' Y2 |. l% x. p  U' J
  2386.     @width = width- M2 z1 [! C3 {  k; B
  2387.     @height = height
    % U+ U8 i* G/ x: }2 s% u
  2388.     @switch_id = switch_id! o) \3 t- Y* K
  2389.   end# i: p+ ~$ A& U8 z# N' D. R
  2390. end
    % p- z" K" G, |! s
  2391. ( [- j, H. G& y
  2392. $area_responses = [], C: P* R6 }4 A7 P. {" G" ~
  2393. : z* g" z8 @! \% I1 L. M/ R) y
  2394. class Scene_Map8 c% }, G% l- z8 v' K5 I
  2395.   alias update_mouse_2013421 update_mouse_action- k* D* _  m0 V7 c# S( j
  2396.   def update_mouse_action
    ; K* T* S# _0 I4 z4 L+ ~
  2397.     update_area_response
    . J& ]7 A1 l  D+ [$ ?2 \
  2398.     update_mouse_2013421
    - {0 D' L9 u0 j  {$ ^0 {
  2399.   end
    # O1 O$ m# R, C5 M) W
  2400.   def update_area_response
    0 t- l2 o2 f  L( B. l1 S8 [% B
  2401.     responses = $area_responses' b$ F; U- P! n# F) b9 g% Y
  2402.     responses.each {response
    4 l' L7 w( ~# H4 J
  2403.       ox = response.ox
    6 j6 E3 i4 V5 W- U: @" ~1 E7 ]
  2404.       oy = response.oy6 ?  x" ]. W# F0 H9 c) h
  2405.       width = response.width
    ) y7 W' Q0 G9 W
  2406.       height = response.height  T+ O& `2 N% `+ P7 n& z, s
  2407.       switch_id = response.switch_id3 V: I5 a  G9 d: F' l8 Y6 y
  2408.       case response.type
    ! a+ P; y. A1 z  G3 v# D
  2409.       when 0
    7 W6 ]1 f  I# L! w3 w  }8 q: n
  2410.         if mouse_in_area(ox, oy, width, height)  M/ o0 r0 M& o
  2411.           $game_switches[switch_id] = true7 m, v& Z6 y, S+ K" o: B
  2412.           $area_responses.delete(response)6 |& ^+ C- l, j" u1 A, X5 X
  2413.         end
    % ~* n, u$ v7 Q* [
  2414.       when 1
    % o% e( J. a6 Q7 x9 k. {
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    + S+ W( O5 d) E) {
  2416.           $game_switches[switch_id] = true& `, A3 K* A: W% R# y  K/ X0 e
  2417.           $area_responses.delete(response)" a( o, i) G  A; `4 Q" e
  2418.         end
    # _- z% C  j& w, Y4 O5 X; s& U
  2419.       when 2
    4 M! y4 a' L1 K) M0 S6 G
  2420.         if mouse_in_area(ox, oy, width, height)% R3 b' @" o. j% N! W( M* N! P: B
  2421.           $game_switches[switch_id] = true
    8 g; J9 B& r2 @. c! k9 e1 e
  2422.         else, c" X- Q9 X+ M8 H8 U+ [, w
  2423.           $game_switches[switch_id] = false( B# G  F2 C9 U4 m, Q' J2 T& w
  2424.         end) c$ ]# D9 [2 k1 d" X5 v
  2425.       when 3( f" q1 P: v+ D$ x# w
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    % |. k- o) c4 j& h7 F5 @- E1 I. u4 t
  2427.             (oy - $game_map.display_y)  32, width, height)
    * X9 `7 r* R. `0 `% t. _/ d
  2428.           $game_map.events_xy(ox, oy).each {event
    5 f* @# a0 G5 A7 M
  2429.           event.start0 Y5 E* J) {( q- \
  2430.           $area_responses.delete(response)* c9 D5 |- g! e7 W0 i) A
  2431.           return  u/ b1 S& N/ U6 Z
  2432.           }
    0 R8 J; H. ]- M0 H. a, K8 T* w
  2433.         end
    & @  }3 Z% K$ x" s
  2434.       when 4, U( @, h' n3 G" s; |( K' U
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,' Y7 K  Y$ s1 v5 E8 z" P/ H
  2436.             (oy - $game_map.display_y)  32, width, height)
    $ C6 u* ~7 Z' Q! c& e
  2437.           $game_map.events_xy(ox, oy).each {event
    . N8 G6 v6 }2 Z+ [. W  g$ ^
  2438.             event.start
    8 H; H8 l% G/ W
  2439.             return
    ; s- t. S. j+ s; }6 P/ [
  2440.           } 2 r  m! Q7 u4 F/ V
  2441.         end
    # G0 n# ]" r- w; ]2 v9 J
  2442.       end
    & k+ e! _7 [. y. d
  2443.     }; r, O* E) n! g( S' X/ A
  2444.   end9 Q6 D" _0 B% m1 g  D
  2445.   def mouse_in_area(ox, oy, width, height)0 x# e- r& ^4 Q/ R3 E1 B$ ~
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&) t- m6 K7 s& B6 k1 D: f% b0 U
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height1 B+ I. J0 K% U+ h' }
  2448.   end* [6 T+ l7 [2 |
  2449. end
    & O" y/ G" a* \' j0 R3 ~- P
  2450. class Game_Interpreter
    4 ], I) \3 \: ^6 V0 e- S- p& M3 v
  2451.   def area_response(arg)
    6 n( a. ~0 ]9 t& E5 i0 V) ^
  2452.     $area_responses.push(Area_Response.new(arg))* e7 W$ V% ~5 H1 c  g5 ^
  2453.   end
    7 `2 E: Y) s3 c
  2454. end% e' {) v! }: L
复制代码





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