查看: 851|回复: 0

存放腳本

[复制链接]

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

发表于 2013-8-29 09:01:09 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
純屬給LBQ腳本:
  1. =begin #=======================================================================
    " Y- S, g$ f( k: \6 {+ I! E

  2. 6 e1 P% D0 z0 ^8 h6 F
  3.   Sion Mouse System v1.3e# z9 U9 C; @0 m" z7 O9 Z
  4.   ' I3 Y' [- m6 {1 c8 A
  5.   Changlog
    $ i8 W: P$ s) M) d- x* f
  6.   
    7 }3 a  O5 L/ R, q7 }6 y+ f
  7.   2013.4.21 v1.3f0 k. C* M2 p9 b( {  ~) s
  8.    
    ; b" w3 b! Q9 T. |
  9.     1.3f 卷动地图 bug 修正3 ]  V3 ~0 G* P2 h% d
  10.    
      g0 _, @/ {( O) y
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    8 h" _; Y9 y5 G. F
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    4 m7 S8 o, ~- y% ~: ^8 |  z) a
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    * w) {1 O9 p3 S/ e( L; |
  14. 3 I) ]+ q: U# p5 E/ I% N
  15.     1.3f bug修正3 i9 C; K: w" Z) P
  16.   ! U! V- n0 W" R/ T3 r' f4 q  z- A
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及' z9 g6 W. f0 [: F
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    + M9 @9 m; j3 _* J
  19. 5 G" C6 F& E  ]; D1 u: ]& h
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处0 `4 X7 G: p7 Z' Q) x2 @* A, q

  21.   D( Y# q0 F8 }  D& |5 q
  22.     1.3b 修正一些罕见的bug;$ S6 |5 {& J+ s8 S7 }- Q9 o( K
  23. 0 k) i' z( D1 a* f4 \+ [
  24.     1.3a 代码小修改;
    9 `7 O2 p! y3 r1 e9 @
  25.           加入了鼠标点击启动事件的功能,
    1 W8 W( U" `( I- n( p2 E& x1 R  u
  26.           在事件中加入“注释”: 鼠标启动  ,
      M+ Y5 K, O4 g6 K: F& t
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。6 s7 c$ |. @* E
  28.   
    3 ?+ W. `. b( S2 M  B, X5 Q6 s
  29.   2013.2.12 v1.2, t; j) j! O+ a! f& W$ P
  30. 0 `7 d) ]8 N/ o$ R' q4 A) Q" E
  31.     寻路逻辑优化;
    % c5 v+ \' `3 M4 `7 f4 P+ ]
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;0 E6 g! x# j) f" Z# z
  33.     现在支持用鼠标来操作载具了。
    0 L6 _3 K7 h" [  j8 ]: n. O) ~: ^% J
  34. ! H/ [- \# r/ |- e+ u6 M  g* A! F
  35.   2013.2.8 v1.1- L# Q8 n  C- s2 S8 f% ~$ \
  36. ( T  D& z, F9 o/ A! E  X( m
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    6 R" z! n2 a+ o6 W. y) T
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;8 z5 F: F1 V/ a5 R
  39.     移动时,路径指示点的绘制更加稳定;
    1 K5 U/ b0 L8 H- W4 R+ _; j, e
  40.     现在支持默认存档画面的鼠标操作了。7 _0 O7 t# G) J; ]0 E7 z% d
  41. & x: ~% H6 V& }1 o
  42. ! A! y# U& m8 l4 |4 R. v5 W
  43.   OrigenVersion
    # @1 y; W# g4 x
  44.   4 S9 J# q6 x: v8 {5 M
  45.     2013.2.7 v1.0
    9 R4 A# m. i+ y4 D8 q& B
  46. 4 |$ h! P* g. d+ F/ B7 g* e2 |
  47.   主要功能
    2 C# D4 N8 u# s* `" z* d
  48. ) u, T) v. D) Y2 _
  49.       使用鼠标进行各种操作...
    7 W) Y+ |; [/ E# H
  50.       将鼠标锁定在游戏窗口内0 \8 P5 c/ y, E& ^0 u
  51.       自动寻路,按住 D 键可以扩大寻路的范围# }9 D# p+ d) z- g1 G/ w
  52.       双击鼠标进行冲刺7 O: i( O- e9 k' Y3 s/ f
  53.       更改地图卷动方式以适应鼠标移动( V( f, r/ a+ X( z% R
  54.       变量输入框改良& T$ f& m1 ~4 P' t2 Q
  55.   {% B: ~$ b8 m! b& t: P. t
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    ' T+ E1 m. [9 E/ ]' z
  57.   X0 Z8 y/ d7 M9 Z7 l, ~
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    % B* U* R% L7 Q1 L5 e( N

  59. 8 S# Y" b/ T# ~( w9 X1 u: F
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    ! ]; @- E9 W+ S' D
  61. # n' d3 G& k4 W2 d/ Z
  62. ; l8 h( ~. X2 C5 c( _
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    : B8 \5 f+ _8 Y. P$ n- @

  64. 1 Y! J* c0 r: U. _' S
  65. 6 ]) N3 ^6 D: E9 ]; e" A3 t8 m/ y
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示$ V) [; {5 h2 {! S) h

  67. 4 R( B$ c3 Y; v' n% v0 y- J. d
  68. #==============================================================================
    & `3 ~3 g1 V# N4 n
  69. # ■ 常数设置
    + E+ N8 O" N- Y0 ]% P4 `% V
  70. #==============================================================================
    7 V2 ]& N+ x: o9 y! M/ X" R
  71. module KsOfSion( M" A$ _* U8 r6 X: G3 [
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false" j( L3 [" p, Y! e& a  p
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑, Z% z# w* X! q* x
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false0 o* o( y% U2 L8 h: G9 |4 R1 j3 c' j
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量4 I- n% \7 b0 H
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处. W/ K4 R' D8 J  N" d. G
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧0 x2 }6 ]$ i& t6 y
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)" I! j. A3 U" x( u$ L
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    : Q. H' a  u7 Y) g( P+ M
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)+ R. Z$ ]/ ~$ g2 v
  81. end
    9 A5 h$ ?( u+ n, U, R# S

  82. 5 X, |9 j4 S4 t7 H0 u/ K+ G& m. [
  83. #==============================================================================
    # R1 A" k9 |! A) j1 i$ X
  84. # ■ 用来显示路径点的类' J% J: M, p, f% R
  85. #==============================================================================
    # Y$ X% q; ?# ?6 \6 d% B
  86. class Move_Sign  Game_Character# d2 O- ^2 U' b: W
  87.   #--------------------------------------------------------------------------* B0 t9 L4 E! m* p( x- A8 B% e
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图' k# k* K6 S+ Q" H8 k1 N3 D
  89.   #--------------------------------------------------------------------------
    5 k; C. V7 b' V, T7 n
  90.   def init_public_members- V8 ?2 a2 W$ H. ?! m& ]1 A6 f
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    3 T1 D8 N- m. s
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    / V0 K) ?" v2 S# ~/ s9 l' m' i
  93.     @move_speed      = 5        # ★ 踏步速度
    8 M' A1 t4 J- f2 A. P
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    6 w6 D" F8 i) L
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度1 J! @- ^: x. L
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    1 s* q& w$ G6 }6 ~% f- E& F1 ?9 W2 p
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列% y! O& W$ u$ t. C) ]
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    & u. ~" M# b# A2 q: W" I
  99. , Y$ Y2 v' K/ m; W8 ^3 Z

  100. ( l* B6 c3 K5 _& K- K
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★' X/ {3 y2 A, @4 G7 B! J$ o' v. P

  102. $ m" \1 D( h) C; w8 j; _
  103. * g2 ~4 B+ I6 V% o2 [
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图7 S1 I! Z. e/ W
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')* L9 ^' B( L( r

  106. / l! s/ N& z6 M9 u9 `' t
  107.       if $no_arrowpic_warn. E: ?* e* ]8 O6 r
  108.         MouseShow_Cursor.call(1): w, s5 s' X* p2 E- `
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png+ q" W) C  ~: h% a/ }- t& H2 ~; x

  110. . s  i. X! i5 Y$ ]
  111. “路径指示点”将使用游戏自带图片# ?! q; O1 k' @+ \6 m6 w( @; Q0 c

  112. 3 G' z7 X) e# P1 E/ `" D
  113. 该提示可以在脚本内关闭')6 D3 L! _6 S: J1 y. d
  114.         MouseShow_Cursor.call(0)
    7 y1 S( R4 F+ d% T
  115.         $no_arrowpic_warn = false. Z0 P/ l; K' R- A; b. }: d) u9 w
  116.       end
    * d, \3 z1 V1 K+ J
  117.       @character_name  = '!Flame'
    1 p- E8 T6 [6 C, c2 G  [
  118.       @character_index = 6, b- @* K1 _; A& V" b/ j- {

  119. . ?6 D4 |  y) Z6 ]6 l
  120.     end  T* k$ f1 e& T( ?/ L+ o) {
  121.     @direction_fix = false  # 固定朝向) h) @9 {: p9 b: ?# {) [
  122.     @move_frequency = 6     # 移动频率
    $ r* m8 L1 \/ m5 H
  123.     @walk_anime = true      # 步行动画* b8 S6 Q6 c  r: _
  124.     @pattern = 1            # 图案
    * ]: [* S2 d, ^- u; N. X0 b, m
  125.     @through = true         # 穿透7 v' n( D# ~, G
  126.     @bush_depth = 0         # 草木深度5 X, l. b, [' y$ Z" c" R
  127.     @animation_id = 0       # 动画 ID" j! d; q4 L- x! s4 X' V. g
  128.     @balloon_id = 0         # 心情 ID
    - k3 ]+ ]* F5 V- H8 P# t; p
  129.     @transparent = true     # 透明
    7 ?( ^( m- ^: g5 l# c- ^
  130.     @id = 0  h) R7 Z' }* K& _9 |4 I
  131.     @x = 0& [* d. z1 R; Z: ~, g9 |4 y. i
  132.     @y = 0+ c; Z* t% A; m% P$ c* ]# E
  133.     @real_x = 05 q) a: t* d3 I! a' o
  134.     @real_y = 0
    7 m" e) o- C5 h# `0 e$ F
  135.     @tile_id = 0
    / ?% q- [/ o' x# Z
  136.   end3 G! c- H7 t& z8 f& H- y$ @
  137.   #--------------------------------------------------------------------------
    3 F$ S' `' N8 h: B7 K3 I
  138.   # ● 定义实例变量8 [. f! z; d! T. h4 D0 w  c6 x
  139.   #--------------------------------------------------------------------------
      A! s1 \# J' E& S9 V
  140.   attr_accessor direction) }  ?6 \3 o6 q5 O, [! O
  141. end% J" u9 N( m. C' _8 Y  }- t$ Y

  142. / {7 i# s# L. l. e" ?! W
  143. #==============================================================================
    . ^8 `7 ~( u1 ]) ^
  144. # ■ Module Mouse( K) j/ L( o4 b0 z: Y0 n
  145. #==============================================================================
    9 _% j# N& U0 {
  146. module Mouse
    . e) a* Q6 Q3 H4 s. l% R9 z4 A' |  S
  147.   #--------------------------------------------------------------------------
    % L9 Q9 h# |. V1 m0 a& a; l
  148.   # ● API% t& r8 T/ i6 f( G) f" c) v/ }
  149.   #--------------------------------------------------------------------------
    6 {/ j; k3 t$ U- s. i
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    7 ~. H8 ^% A) P  P; e9 a
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i'): X2 h) Z) E; V, h- m2 S
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')2 `* w: }3 X+ ~  n3 H4 M
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')0 |; F; n. A5 R* c$ ]: i
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')( C; ]3 f  q  |0 g) J* Y
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')8 M) s: M+ q* V. r9 U, G. @* V
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    ) b: _$ i8 p1 m( m; R* }' Y% R
  157.   Window_Hwnd       = Get_Active_Window.call; T& C$ i2 D7 i8 |2 x) B# [  Z8 h! j

  158. 5 P9 ?2 J- b' p# n' J& r- F
  159. class  self
    + m: o8 H9 H1 D# X$ ^
  160.   #--------------------------------------------------------------------------9 [# C3 m5 ]; a/ y
  161.   # ● 初始化
    8 q; t8 {. X1 \" Q$ i: Z
  162.   #--------------------------------------------------------------------------3 Y1 V. i) o; w; n! ]
  163.   def init
    : j$ |7 G' t! v) v- Z) ]) w9 V
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    2 N% q* W4 I$ o/ u6 C
  165.     @left_state = 04 E; x$ S; {* @* H6 D
  166.     @right_state = 00 T( B& N; w( q2 S! v  @# F
  167.     @ck_count = 0 # 帧数计,单击以后从0开始2 v" r' v7 P  o% {% {2 j0 Y' g
  168.     @dk_count = 0 # 用于双击的判定1 F1 f& ~# w6 ~
  169.     @clicked = false9 b) y7 \& z) o/ \
  170.     creat_mouse_sprite5 v9 N+ U% j9 J1 S9 `% O1 w
  171.     update0 J% ]  d9 L; K0 U1 a" W; R5 l
  172.   end
    1 a& d8 D' d. o# L, V" G1 d
  173.   #--------------------------------------------------------------------------0 C. S( ?" Y5 k- g/ b5 O, L
  174.   # ● 鼠标指针精灵
    % a6 G( I/ O4 g
  175.   #--------------------------------------------------------------------------
    5 k4 f0 c  u2 J' @- ?2 n" |
  176. #~   def creat_mouse_sprite
    3 e2 b5 [7 u( h; W
  177. #~     
    1 l' l* \+ c; w; S' [+ N+ d
  178. #~       @mouse_sprite = Sprite.new& k7 k4 K3 `. n
  179. #~       panda = 2#rand(2)+1
    " S$ S3 h1 b% I, ~7 F
  180. ' u6 L: j4 ?4 t. u' R8 y) L
  181. #~      if panda = 1
    7 t( Y7 k& K: P, ~. l
  182. #~        if File.exist('GraphicsSystemCursor2.png'): i; M" I- m8 d6 Z4 k4 d3 n! @3 S
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    , x. `0 `8 H8 F0 ^! B- z
  184. #~        end#with if File.exist' ^  }! Y1 \8 S% i- |
  185. #~    0 Q2 i. e' M% ?1 u
  186. #~     else if panda = 2 #with if panda=1
    * B$ d8 F% z2 w! N
  187. #~      . a* _+ M+ e# ]; C
  188. #~      if File.exist('GraphicsSystemCursor2.png')7 b6 p  B0 a9 ~( N) s9 v$ `  f
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    8 A* G- ~* r% s, t3 g$ V
  190. #~      end#with if File.exist
    + h$ \6 r, K2 c; X! h9 k
  191. #~       7 R% E6 @% d( u. h8 c. P1 i  Z- W2 {3 R
  192. #~     else #with if panda=1! O  F! ~" X3 q* R5 B3 J" \, a
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)7 `6 F  L7 x3 T% `' U/ j
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    5 w& ~# y' a9 R: f
  195. #~       Rect.new(5  24, 24  24, 24, 24))) b& b8 ~5 u* v# `
  196. #~     end#with if panda=1
    " ?! L$ v# c4 `7 f1 O; }+ m9 i
  197. #~     ' {. I' Q1 s% N- |& x3 x" p5 F' r
  198. #~     #with def
    % q8 z) g; A( L# [( `0 E2 f
  199. #~   end
    7 _4 E5 P  T9 v$ u
  200. def creat_mouse_sprite
    : F& o0 Y7 ^0 Y( L% o9 P: F
  201.     @mouse_sprite = Sprite.new3 u+ g- O  q: I7 u5 S7 ]
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})% n9 {6 n" s6 d
  203.     @mouse_sprite.z = 9999
    & [" \  Q) d" E
  204.     Show_Cursor.call(0)/ ~* y0 A  ~* w' V4 z3 x5 J
  205. end
    4 Q* o+ l2 B* D4 V) c$ H
  206. + u+ |5 N# @8 M4 j6 u+ E7 l
  207.   #--------------------------------------------------------------------------+ {: M8 x1 Z- d) m3 z8 e% `1 D
  208.   # ● 更新
    8 j0 g( q" j5 f0 D% M
  209.   #--------------------------------------------------------------------------
    . b, x, X* K+ p. H5 _- R7 P0 s
  210.   def update9 r5 N+ h( z' i5 J( o" C9 T
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos- g% n7 p* `! W/ Z8 ?9 n! D$ M" O* S* y
  212.     left_state  = Get_Key_State.call(0x01)( h2 S$ q6 U7 }7 t) V. ]! p
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0! [6 G3 T' M( U3 p
  214.     right_state = Get_Key_State.call(0x02)2 D1 R8 P4 |3 d
  215.     right_state[7] == 1  @right_state +=1  @right_state = 03 N8 w. b  m/ w; i, L- g
  216.     update_double_click
    % }! W( G; [7 N' \
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    $ j  G; Z/ l( `. ~" P, p2 [5 g
  218.   end* n* G7 ]' {; U, N5 r3 A! j1 o
  219.   #--------------------------------------------------------------------------
    8 w: r# G' f5 D
  220.   # ● 获取鼠标坐标9 c  r# r# |3 ?" X* |" \* n, A' y
  221.   #--------------------------------------------------------------------------) [. z' o9 e* _& Z0 [
  222.   def get_mouse_pos3 f( s- r* _2 M8 R
  223.     arg = [0, 0].pack('ll')
      u1 p+ H- m7 I
  224.     Get_Cursor_Pos.call(arg)
    . g/ r1 y: ^& F% X2 o* l
  225.     Screen_To_Client.call(Window_Hwnd, arg)6 m0 }! ?% Y) d7 |, C4 l
  226.     x, y = arg.unpack('ll')
    2 [; Y- n: e0 E* C( G
  227.     return x, y
    " V9 h) ?# {( V5 |9 U( i6 p1 ]
  228.   end; v- O2 H' y% ]
  229.   #--------------------------------------------------------------------------
      p2 [4 q4 a1 R/ y7 y& n. ?
  230.   # ● 将鼠标固定在屏幕内
    3 M' N' E  ?+ g9 `1 L8 a2 c
  231.   #--------------------------------------------------------------------------
    7 W  ~2 e) |% w2 t: O9 c! V0 _1 A4 h
  232.   def lock_mouse_in_screen
    & t2 F& S4 H4 ^
  233.     arg = [0, 0].pack('ll')1 w2 T# @0 s7 K6 Q/ n
  234.     Screen_To_Client.call(Window_Hwnd, arg)# T+ ~  R$ _: ~( b* n! r
  235.     x, y  = arg.unpack('ll')
    3 E3 V$ j' y5 F" G, ], j/ h
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    + f1 S6 j* J( j5 ]
  237.   end
    2 g$ f* Z+ e/ N, ?; n, p
  238.   #--------------------------------------------------------------------------
    5 l. c& F8 B2 I! b) Q6 I2 B
  239.   # ● 解除鼠标固定7 A7 d4 [4 m' W: f7 {
  240.   #--------------------------------------------------------------------------
    * X2 S  k$ m# Y" z5 K1 V
  241.   def unlock_mouse_in_screen* }) o* K; x% W; `
  242.     Clip_Cursor.call(0)! b' `3 [9 s$ r: p1 U) C
  243.   end& E+ C$ J; i% `6 i+ v2 f' {# y* @
  244.   #--------------------------------------------------------------------------: p8 K! z  a; C& y% ?7 @' S; j; X
  245.   # ● 鼠标双击判定# k# k6 p! [- j: g5 w2 Y7 j
  246.   #--------------------------------------------------------------------------
    ( C' ?  m- m+ k( U
  247.   def update_double_click/ i% @& r1 ^8 T  a& a6 ?, a4 G8 e9 e
  248.     @clicked = true if @left_state == 1; [' X" q% s  c6 V0 G/ \2 w
  249.     if @dk_count  0 && @left_state == 1
    ; P) Y7 c, g1 u
  250.       @dk_count = 0; @clicked = false
    9 i+ X* U# Z" {7 q1 x. i
  251.       return @double_click = true8 Q% [5 S6 _$ ^
  252.     elsif @clicked
    1 F- ~- W9 v, l& J; M+ j* U
  253.       if @dk_count  KsOfSionDbclick_Frame5 w9 m% [7 g+ ]0 @* @+ c3 Y
  254.         @dk_count += 1
    % f8 t: b8 E2 g7 z8 C3 J
  255.       else
    & R/ C3 g' h2 }
  256.         @dk_count = 0; @clicked = false
      I! X- F$ f$ s7 S- `6 G4 [( s; l
  257.       end+ @/ k. D7 y2 F. }/ Z" \/ z
  258.     end
    1 z8 R* J. _2 T: z3 x1 Y
  259.     @double_click = false6 L+ Z3 r: J: m% H  p6 n7 Y
  260.   end
    # O# F% u3 Q' ~$ \: v
  261.   #--------------------------------------------------------------------------/ f) Z$ l/ P/ A: ^9 i
  262.   # ● 按键被按下就返回true
    . s2 t2 g  \" n9 c; e2 O
  263.   #--------------------------------------------------------------------------
    - e4 a8 m- q# _- }. o9 {3 p
  264.   def press(button)
    ! w1 j5 |: w1 D3 t$ n
  265.     case button5 n$ m5 Y7 i/ p% p7 t
  266.       when 0x01; return !@left_state.zero
    1 u+ ]# A2 }8 _5 s) H% k
  267.       when 0x02; return !@right_state.zero
    ' X8 |- }% N: Y5 q
  268.     end# V: [; `* U( M8 I7 d# P9 n; ^# d
  269.     return false
    % s9 }6 K. E9 i( E6 V- s  t
  270.   end/ d8 \4 @  \/ h1 j+ A- W, M) j
  271.   #--------------------------------------------------------------------------
    3 |, `9 e* L: `$ b# I; L
  272.   # ● 按键刚被按下则返回true7 k" u( N, w9 H/ t  u
  273.   #--------------------------------------------------------------------------' i# [: S2 j! \$ Z' g
  274.   def trigger(button)
    & }% k+ E, ?) p$ K) F7 e
  275.     case button
    ) Q1 j: R. {7 T
  276.       when 0x01; return @left_state == 1
    9 Q) ~' w* W5 E3 C1 w- z; O! v! Y7 J
  277.       when 0x02; return @right_state == 1  ?; Q) E( f: u/ ~" M
  278.     end
    : G* x" \3 q/ U6 w5 F& P
  279.     return false
    " o# Z# Z* M# C& Q6 M
  280.   end
    2 u) r- g6 d1 W( T3 Q5 u
  281.   #--------------------------------------------------------------------------& l2 f, b" P1 P8 }- ]4 t9 X* \
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    ! [* c4 N4 r: Q2 X' I7 V! {  q$ T
  283.   #--------------------------------------------------------------------------" X7 r; n  R. o/ B! \* |& H  b
  284.   def repeat(button)
    , `6 S% g% U) `* z3 p% G" f
  285.     case button6 A% q, O* F* f( l0 n2 L% x9 O* ~' ?( I
  286.       when 0x01; return @left_state == 1 " g& C/ D' z; E
  287.         (@left_state  22 && (@left_state % 6).zero)
    ' @1 ?7 V& Y, C1 R* n( `/ o" r
  288.       when 0x02; return @right_state == 1
    6 P/ j  K3 b+ c8 H+ \2 N
  289.         (@right_state  22 && (@right_state % 6).zero)
    " w! Y1 S  ~3 j% v6 U% Q: D
  290.     end
    0 ]; p+ y5 q* ?* @
  291.     return false* E9 f7 Y  _9 }; Y& l
  292.   end6 K+ c0 F8 ~# Z2 A7 O3 g9 I
  293.   #--------------------------------------------------------------------------
    " J& s, \" V' f; V
  294.   # ● 判断是否双击鼠标
    ' S" F+ [+ o* ^* O. o! K
  295.   #--------------------------------------------------------------------------
    1 ]5 j( n" G' K8 b, D5 \
  296.   def double_click
    1 |: {. J" q/ A& p
  297.     @double_click
    0 P: M- {9 a: W
  298.   end- M+ k( E. H% ]8 ]5 K4 _* G+ [
  299.   #--------------------------------------------------------------------------
    8 {1 s5 ~* e9 y  f3 I$ A
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    8 d" ]" `/ h6 I) d- u
  301.   #--------------------------------------------------------------------------2 ^+ n8 ~3 S+ v
  302.   def click_count
    1 h& g  D$ v& |* Z3 M
  303.     @ck_count
    0 ?# Y1 f( N8 y9 m
  304.   end8 b; E0 A2 Z/ r- b5 \; X
  305.   #--------------------------------------------------------------------------( m) b( q- @! t0 c
  306.   # ● 获取@left_state(按住左键每一帧+=1)% z' {  w" C6 `& R
  307.   #--------------------------------------------------------------------------
    9 H/ l$ \6 y) ?' Y1 C- i: Z
  308.   def left_state" k, K: P! J) `
  309.     @left_state
    ) M0 J! W& g4 T  C5 v2 o
  310.   end5 L  |( g0 ?6 d: W
  311.   #--------------------------------------------------------------------------$ P3 I3 d7 z4 m
  312.   # ● 获取鼠标的x坐标
    , _. d! ~  a6 Z/ R/ k$ C; \
  313.   #--------------------------------------------------------------------------
    ; H0 x" p6 x4 ]
  314.   def mouse_x
    ) v* `3 L& a8 }6 B. u
  315.     @mouse_sprite.x
    3 u. v% d! O! D6 Q9 ^) X
  316.   end/ }0 {6 V) [! ?1 c( o* M* a$ E. ~. J
  317.   #--------------------------------------------------------------------------
    , x  ]; m, k! [+ J: U, `6 X" s
  318.   # ● 获取鼠标的y坐标6 L/ S5 B/ T; P3 H* W8 y# C. {
  319.   #--------------------------------------------------------------------------
    / _' N$ J! [" R- r& {
  320.   def mouse_y
    6 i. L' j* v' S. k5 q2 \
  321.     @mouse_sprite.y9 |; |% ?, I! e' d, b$ x$ u
  322.   end
    + ?) [0 Q6 U2 B' s7 F4 N/ n9 ]
  323.   #--------------------------------------------------------------------------( `6 y0 W% y4 U( |
  324.   # ● 设置鼠标坐标2 A8 k# i, m6 Y3 S( o
  325.   #--------------------------------------------------------------------------4 _- F/ U8 y+ ^% r
  326.   def set_mouse_pos(new_x, new_y)
    # \2 {- }$ v- M$ L& a
  327.     arg = [0, 0].pack('ll')
      C* ?9 Q* z7 h5 B' B
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    4 e" F& G  q; ]
  329.     x, y  = arg.unpack('ll'). ?2 r! O* G- \7 G% k
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    + h6 b# H! a* n2 ~+ F; r5 |
  331.   end  Q  M) v/ }- v4 z$ W, R
  332. end #end of class  self ) l% _2 S# K: S
  333.   ]0 M+ e. R( {5 b; E: b
  334. end6 p  N; Z" s2 ~$ J3 @7 K- {( E
  335. 7 F$ P- T0 {0 `+ U
  336. #==============================================================================  m7 |8 `! R- |. w
  337. # ■ SceneManager
    5 Y7 y, G7 z5 k/ J: b; W3 J- P$ b
  338. #==============================================================================
    : v; S$ r$ L' n0 M9 @
  339. class  SceneManager
    - Y/ t! R8 i2 e& ]
  340.   #--------------------------------------------------------------------------" U* @6 D( V3 s  }0 i: A
  341.   # ● alias; ]; @0 @  C, \3 P
  342.   #--------------------------------------------------------------------------
    8 m* M1 ^$ a/ t3 ]+ }6 ]( f/ `
  343.   unless self.method_defined(sion_mouse_run)/ c5 G7 \8 W) G6 |
  344.     alias_method sion_mouse_run, run
    / ~9 ?2 E! a" v1 Y% ?
  345.     alias_method sion_mouse_call, call7 Q# ], F% Y* F$ P  O4 Z9 T
  346.     alias_method sion_mouse_return, return
    3 \$ ]# d0 g" N' o2 `8 S
  347.   end! M, u8 a( v- m1 s6 R
  348.   #--------------------------------------------------------------------------
    / Q4 k  s6 V: t) W8 i; ]
  349.   # ● 运行
    ( A# D' O4 r! q4 |& L  j) E, d( W
  350.   #--------------------------------------------------------------------------
    . h. `, e' }) A# }$ t8 n4 `9 {# n
  351.   def run
    $ g" y7 M% w+ I! G
  352.     Mouse.init5 X& x# }' G, z; e
  353.     sion_mouse_run0 ~# E+ D! F: ^9 X+ I
  354.   end
    7 z1 C) D4 c1 q
  355.   #--------------------------------------------------------------------------
    , f# @. M7 t0 G2 @$ P; L
  356.   # ● 切换+ a$ _- @$ N$ k# h% o) E% R5 d* @
  357.   #--------------------------------------------------------------------------
    ( g9 A8 s! h/ s" Y$ u" Q4 u# r
  358.   def call(scene_class)2 Z$ E7 _# L; X, M) ?; n
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    4 Q# E" y. k8 t4 R
  360.     sion_mouse_call(scene_class)6 K6 h1 M' J: ^
  361.   end
    3 S3 l8 P3 s3 H$ S8 O; [
  362.   #--------------------------------------------------------------------------
    2 M4 g& q: J% p" ?- [+ z
  363.   # ● 返回到上一个场景6 T4 l0 J* Z: Q" e% h6 Y. X
  364.   #--------------------------------------------------------------------------
    # U' o# ?. N% f, J7 k9 I
  365.   def return
    2 z5 `" z' x0 x
  366.     sion_mouse_return' D! Y) A) S* h, A
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    ' ]2 l' d* Z. o6 B
  368.       @scene.instance_of(Scene_Map): j$ \+ b  h6 @9 f" n: n/ P
  369.   end
    ) o, o2 p$ \1 r7 ]
  370. end
    . ^: ?4 o: M/ f: O0 b
  371. % |$ u5 |$ @6 \9 \: o9 e
  372. #==============================================================================) S8 J# s9 V3 Y
  373. # ■ Module Input
    . ]) Q4 k5 J0 ~) ?( Y1 i
  374. #==============================================================================+ n. C! M+ i) u0 X9 `$ N6 Z4 R
  375. class  Input
    . c% a  y! ?2 J1 ?# a& @+ G
  376.   #--------------------------------------------------------------------------
    5 j5 k) p! D% T* \7 \. p
  377.   # ● alias6 b! M% d& h7 A) u6 j8 T
  378.   #--------------------------------------------------------------------------6 A% O/ D8 m+ D) p' q" u
  379.   unless self.method_defined(sion_mouse_update). c, q. Y/ U' z8 F1 a  R
  380.     alias_method sion_mouse_update,   update* P* z! X( E$ A, m- {
  381.     alias_method sion_mouse_press,   press# M. r/ D% f9 f& w: h
  382.     alias_method sion_mouse_trigger, trigger- U! A- O2 G) G
  383.     alias_method sion_mouse_repeat,  repeat2 H- }) b- n( Z" v2 F1 ~/ l
  384.   end
    - O: _( y) w; d
  385.   #--------------------------------------------------------------------------
    $ P' ^5 |. x' p3 z* t
  386.   # ● 更新鼠标+ q% t" _0 `; P  c) R& x* z
  387.   #--------------------------------------------------------------------------0 i* F! C& M! l& W9 `% H  D9 _  M- G( [
  388.   def update
    . J+ j  I+ p4 p7 N. F9 ^# V) f! `
  389.     Mouse.update3 a. M' }3 \% g  o4 C
  390.     sion_mouse_update2 \; \; D7 E) k
  391.   end: _, U4 @3 x. Z
  392.   #--------------------------------------------------------------------------
    0 w2 C' I: ]5 i; ]! C3 @
  393.   # ● 按键被按下就返回true
    8 R  u+ }; {8 O6 s  O, x' Z
  394.   #--------------------------------------------------------------------------
    : L1 ?# A& i+ v. c  X- }
  395.   def press(key)
    * @- [' u8 V: g
  396.     return true if sion_mouse_press(key)
    + }8 |9 R: M1 `8 @: }$ L' L: i
  397.     return Mouse.press(0x01) if key == C' i9 l, ^4 Y6 C( g
  398.     return Mouse.press(0x02) if key == B
    ! O2 ]% k8 g# s' t& F, Z' n; e
  399.     return false
    , x  P& n" u% o% Z7 e
  400.   end8 ^0 ~: i0 u- N6 \" M, U
  401.   #--------------------------------------------------------------------------
      j1 v8 @0 g2 U" E) g
  402.   # ● 按键刚被按下则返回true
    % `5 G2 s+ j6 ~0 ^% o/ C3 @
  403.   #--------------------------------------------------------------------------
    3 S) L; P% g+ l& ]: V7 E- Z! d9 @
  404.   def trigger(key)
    5 B- y1 |7 X( _) G; @4 ^0 [
  405.     return true if sion_mouse_trigger(key)$ J. x' z0 X1 s6 _/ V
  406.     return Mouse.trigger(0x01) if key == C2 k1 ]3 j( K/ ~
  407.     return Mouse.trigger(0x02) if key == B
    * o" f6 `( D# ~+ z% a
  408.     return false7 B& k* g# |  A) d+ h% [* {
  409.   end" v7 W2 D$ Z* U7 w/ C5 W/ N
  410.   #--------------------------------------------------------------------------3 F. k- f- J) }1 B' G2 i# n
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true2 \) t+ C8 c' J/ V5 z' b! @
  412.   #--------------------------------------------------------------------------
    5 u" Z5 u* a" `/ f
  413.   def repeat(key)
    9 m, ]( q! T" N$ ^" X
  414.     return true if sion_mouse_repeat(key)( I3 |1 ^. e6 a2 n& R& Z5 x2 k. k
  415.     return Mouse.repeat(0x01) if key == C: A$ P7 M& i) \- T& A
  416.     return Mouse.repeat(0x02) if key == B0 d6 b! l( S4 O# y2 }
  417.     return false+ f1 G, [4 p( u3 \( S# ^7 B
  418.   end
    , T) |' g0 C  a: C" E! y1 M$ b+ e
  419. end( t( K8 n9 b7 {$ K3 S, J# p
  420. ( L& g. {, ]0 T5 I2 |7 I

  421. + W+ D- y" J4 [" K! N( @
  422. #==============================================================================
    . a  `8 e# \; x7 M- i1 p
  423. # ■ Window_Selectable
      m' b% [  [' c9 d1 u# S) A
  424. #------------------------------------------------------------------------------
    9 j, y9 I+ U! H7 M9 l. o3 h2 G3 V" x
  425. #  拥有光标移动、滚动功能的窗口
    - R* |3 P; [5 J' T, u$ t
  426. #==============================================================================
    , z/ R7 X* |' v% d6 l
  427. class Window_Selectable
      p- y4 B& {& ]* ?5 Y
  428.   #--------------------------------------------------------------------------# L. i2 [2 t. Z9 N0 \
  429.   # ● 初始化
    - L$ c1 v2 u  v4 D5 a/ O
  430.   #--------------------------------------------------------------------------
    , v; O' R3 R5 f$ W* t' x
  431.   alias sion_mouse_initialize initialize3 H% i0 C' u/ c9 W: E
  432.   def initialize(x, y, width, height)
    % I0 _) ^7 Z) D: q7 F3 |
  433.     sion_mouse_initialize(x, y, width, height)
    * d- d: ~) Y; C! b* Z
  434.     @move_state = 0
    " l+ u7 {: h6 A( \/ V9 Q
  435.   end
    + e- H. x8 |' V6 m, R6 t
  436.   #--------------------------------------------------------------------------4 B: C, L1 z0 O* f) m# x' I6 H1 C
  437.   # ● 更新! N5 q# f0 a% B5 ?- F
  438.   #--------------------------------------------------------------------------
    , X8 [7 m  n: }3 a9 |1 [( N
  439.   alias sion_mouse_update update4 ^* x7 a- ?: M1 a% a
  440.   def update
    & _! |: U3 Q2 X, b) _, C
  441.     sion_mouse_update6 S3 J' P- i- t. @+ l; r
  442.     update_mouse_cursor8 R1 R# [2 i2 |- u9 P# W8 u# ?/ O
  443.   end
      d( Y9 A# F0 I) B) n
  444.   #--------------------------------------------------------------------------
    8 ~4 }0 Z$ s) a4 X. ~  m
  445.   # ● 启动后设置鼠标到index位置$ m" ]3 V0 O1 M! E$ U
  446.   #--------------------------------------------------------------------------
    0 T: I7 ?" R6 g/ _# |
  447.   def activate( i3 T% A; d- t! K4 f! B$ ]4 _; H- ^
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos. D: j1 \% e3 b" B: p6 u( E" g4 v
  449.     super
    ! d/ I0 L; e, F; v* L
  450.   end8 B* W0 ^9 g2 q/ H* R/ E# X' b4 m8 a
  451.   #--------------------------------------------------------------------------0 j- i& T2 h+ h0 |) x6 A$ G( F
  452.   # ● 更新鼠标和光标的位置% U/ h# [/ |( L2 h; c1 P
  453.   #--------------------------------------------------------------------------6 ]' d. R' e2 D+ V
  454.   def update_mouse_cursor7 l8 ~' _; x3 _" i
  455.     if active8 F, L9 [# e: u$ \# t0 Q
  456.       if @need_set_pos
    - ]& C3 U0 A3 \# n2 Z1 \
  457.         @need_set_pos = nil
    + |0 o/ s$ J* v3 `! g
  458.         set_mouse_pos
    $ d9 W3 k* K& T& T* n# Q! v
  459.       elsif cursor_movable5 o2 U9 c7 K. R" g+ k' C9 D
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    . l2 X2 J4 m5 }% O5 C2 P( n5 I; C
  461.       end
    ( u" X* Z" x8 c4 H; g! B
  462.     end
    2 [- x$ o$ V4 Z! s9 l
  463.   end
    , T$ h7 I7 d; [5 ?6 D: x- |3 B
  464.   #--------------------------------------------------------------------------
    * ^. @& d2 }/ x: B  A
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    1 S; n3 v1 s/ d
  466.   #--------------------------------------------------------------------------
    6 q! {! G$ {9 `2 t
  467.   def set_cursor6 b; f, \+ L' ?* L) y9 A
  468.     mouse_row, mouse_col = mouse_window_area
    , J/ m& V$ t- [+ t$ b. g
  469.     if    mouse_row == -1$ w7 h& \) z: {& S, Y
  470.       @move_state += 1 if need_scroll: T6 K+ Q4 Y+ A% u
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    $ I* W+ K; d% l7 C; z& Z5 q4 c
  472.     elsif mouse_row == -2
    8 O7 {- ]9 n- p5 Z4 `
  473.       @move_state += 1 if need_scroll
    ! Q; A* X8 t- r- \
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand. c2 K* j4 x2 U. k
  475.     elsif mouse_col == -1( z) `  |7 d% V6 T8 O5 u
  476.       @move_state += 1 if need_scroll% e* [& y. }$ i3 B, ^* g
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    4 H' \% _1 L4 N+ K0 j+ P; [
  478.     elsif mouse_col == -2
    7 v5 T' O3 K( L
  479.       @move_state += 1 if need_scroll$ w8 j, T/ n% ~
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand3 D: b" n- A4 A0 \; E, x: E
  481.     else
    + t' a4 y4 O4 r( ]# N
  482.       @move_state = 07 m, Y& ]# z) d; P6 g% U
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    ! \/ }* x- z4 _3 W. ~
  484.       select(new_index) if new_index  item_max && new_index != @index0 C& P0 a$ O5 @9 H: [+ k/ D' s
  485.     end
    " V9 ]7 N+ b5 D$ x; j
  486.   end7 L: f9 [, j7 l4 z' e7 l9 \; X
  487.   #--------------------------------------------------------------------------( J$ i1 {: z( F" B! w" F8 {
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    9 q# i5 L9 P* u) r' }: ?. \9 D
  489.   #--------------------------------------------------------------------------
    ) {+ U! M: \) I1 k; O
  490.   def mouse_window_area
    " U3 t, k) X1 d) ~4 X3 _
  491.     if viewport.nil # necessary!. ?7 Q' |& ]- H. H$ w
  492.       vp_x, vp_y = 0, 0$ J# G- a3 M9 Q/ ~
  493.     else% _. |$ i; j0 p$ q- K
  494.       vp_x = viewport.rect.x - viewport.ox. V5 }. u3 ?: @' q9 o
  495.       vp_y = viewport.rect.y - viewport.oy
    " g# \& y  G* }7 }& h! h0 o* q
  496.     end4 R& R$ G6 D* r
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y* U/ T  C; k: @) r4 D
  498.     item_x1 = vp_x + x + standard_padding
    % L, N; q- @. U1 b+ s4 j
  499.     item_y1 = vp_y + y + standard_padding, y) k7 h' S: h, Q: z
  500.     item_x2 = vp_x + x - standard_padding + width
    6 d8 A/ H! V1 V7 g* }1 n
  501.     item_y2 = vp_y + y - standard_padding + height* m5 j) u3 A3 S: g) T; W
  502.     if mouse_x  item_x11 v6 w: m# e) j7 F# X5 g
  503.       mouse_col = -1& s0 _$ C" p, I$ |* f" N6 W
  504.     elsif mouse_x  item_x2% R5 [: S4 b7 \- i- n" J
  505.       mouse_col = -23 j* X/ ]) A- _- k% ?4 |* x  J, G% ]
  506.     else
    " K3 g$ f6 @9 S  T( b+ s& ~! H) b
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    . V! v* q3 A. @$ E
  508.     end
    " ~- U+ _# w. O# C" M) l/ W
  509.     if mouse_y  item_y1
    5 r; V9 L% c6 K2 [  n
  510.       mouse_row = -1( L7 m% `2 u4 E1 y  @: a4 s
  511.     elsif mouse_y  item_y2& O. f5 r( K! L5 E7 L: _+ g
  512.       mouse_row = -2  Z* @& K% U/ b" t( b; j5 R4 C% W0 i
  513.     else
    6 }& o# N  \: s
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)+ D5 H4 {7 l( K1 s2 Z- Y
  515.     end! `) e8 m9 ^0 ?# M9 y$ Y
  516.     return mouse_row, mouse_col
    7 w& N3 v: I* \2 M
  517.   end5 I9 X: Q; @% K
  518.   #--------------------------------------------------------------------------
    7 s1 f' V5 }, }* C
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置9 X' V1 ?- z+ H
  520.   #--------------------------------------------------------------------------3 k9 _9 V2 g# w: G7 |( \, D4 n, t, r4 K
  521.   def set_mouse_pos
    $ Y: ~/ ^- ~9 X7 c6 y5 H/ k
  522.     if viewport.nil # necessary!
    ' s, [/ o7 j2 X& `  s! L& d
  523.       vp_x, vp_y = 0, 0
    4 I* R0 I  m/ ?3 H
  524.     else
    6 [! r3 t, P$ W
  525.       vp_x = viewport.rect.x - viewport.ox$ L) ^0 W" P0 f! \, Q
  526.       vp_y = viewport.rect.y - viewport.oy
    5 d$ R7 Z% j* _* o# f
  527.     end7 Q1 `% t( U, U3 b, v  t5 l
  528.     item_x1 = vp_x + x + standard_padding
    - Z& S3 ]/ G1 q) h
  529.     item_y1 = vp_y + y + standard_padding. d, ^3 z* x3 d* _  ]+ Y
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index - L/ b' f2 Z* Y& C" O
  531.     row = get_index  col_max - top_row
    + J) |8 e# v. Q" N& y2 a
  532.     col = get_index % col_max' I4 U* R; y' e! p7 h- d" ?
  533.     new_x = item_x1 + item_width  (col + 0.5)
      Q0 v' u' f' d; K6 M! ]# z9 b7 C
  534.     new_y = item_y1 + item_height  (row + 0.5)
    & {0 v) ]& b9 e6 P$ Y
  535.     Mouse.set_mouse_pos(new_x, new_y)
    6 i$ ~! M) a0 G( [/ _* O3 ~" ~
  536.   end
    / C" [: ~0 x' _2 m+ C' B
  537.   #--------------------------------------------------------------------------
    5 g9 r/ ?  H2 w; F
  538.   # ● 判断菜单是否需要卷动9 Y- B: ~# }, B: K; U8 W
  539.   #--------------------------------------------------------------------------
    " W" f  j# M8 W
  540.   def need_scroll5 H+ t3 @: Q( l7 H( I- @5 q- ^
  541.     item_max  col_max  page_row_max+ b5 x4 l  v6 |- L8 c* o
  542.   end
    0 w! f9 A9 {  Y+ a0 G; E' A; i% h
  543.   #--------------------------------------------------------------------------0 p+ F1 l. ]$ Q1 G0 V( g
  544.   # ● 判断是否为水平卷动菜单, Q3 A% b$ b7 Y1 H) o& Q- z: a1 i3 u
  545.   #--------------------------------------------------------------------------
      k2 n) \8 n: J) o0 t3 c; s
  546.   def is_horzcommand
    & h1 J  d0 d: G) l/ O
  547.     return false9 V8 x/ D) B" {6 ~- {; T5 o/ O
  548.   end5 R  t+ U  f/ I- M. l$ p
  549. end
    7 C) Z# \- W- g8 t6 g
  550. & M( z1 y. A/ }) `: X, @4 K
  551. class Window_HorzCommand; X1 U. b/ ^2 P8 N: o! {
  552.   #--------------------------------------------------------------------------
    / B* S$ b8 B' W  ^4 E. F0 h$ b1 n3 S
  553.   # ● 判断是否为水平卷动菜单
    + x4 p7 i: j$ X, W* x, G; K
  554.   #--------------------------------------------------------------------------4 [) p* H& I' w; K" M, K
  555.   def is_horzcommand" k" A! T- H. Q1 N
  556.     return true6 B$ x/ ]7 K; \- e; D+ ]4 P
  557.   end4 G  t6 O( Z' ]
  558. end
    7 X2 W3 X) r5 [! ?; ?2 C0 s1 g

  559. & l9 y) B' d* a0 O
  560. #==============================================================================, s8 h: g) m2 Q* M5 A, a5 }; V
  561. # ■ Window_NameInput& v% c; Y0 y5 f
  562. #------------------------------------------------------------------------------
    : c% |7 Y+ l) F* E- a1 a
  563. #  名字输入画面中,选择文字的窗口。
    & k+ @  g9 w7 O4 ?9 J; Y
  564. #==============================================================================
    % X  \4 Y. o" m% W# P4 V
  565. class Window_NameInput
    6 ]. O: M. a  {  c
  566.   #--------------------------------------------------------------------------- m9 M0 k; ?! L$ `  _6 d* }8 g
  567.   # ● 设置列数
      u, b1 f: c( I* P& C* [( _1 ^( ~
  568.   #--------------------------------------------------------------------------1 _( Z% p0 q; v% N& [7 x+ }
  569.   def col_max& K% o4 L, b* }2 o: d. A# g% R
  570.     return 10" L( L: F$ D. ]. W
  571.   end( U1 L. E3 R$ D6 h& m
  572.   #--------------------------------------------------------------------------0 V( P: W# I7 y; l/ \& n
  573.   # ● 设置填充的Item个数
    8 i4 S: D% o/ B8 b  p: r5 m
  574.   #--------------------------------------------------------------------------4 m) h# ?, A5 u& p; }8 i
  575.   def item_max
    , y! A1 D; Z* p( W3 U4 S
  576.     return 90
    - I$ d1 S2 _# W" }  ^8 U& m3 J
  577.   end
      |$ d+ y% ~2 v! \: W
  578.   #--------------------------------------------------------------------------
    # e( ^+ M% w8 h. q, O4 Q" z
  579.   # ● 设置填充的Item个数
    ) e" C4 K# Q. X2 R2 l0 @8 H+ J
  580.   #--------------------------------------------------------------------------
    6 s; L( C. J1 c0 Z2 R7 z, H
  581.   def item_width8 ~8 v8 }0 q7 G8 `) }
  582.     return 32
    : I/ |5 r7 S! r3 C; g
  583.   end
    / ?9 ~" M  u6 {$ l1 N0 E
  584.   #--------------------------------------------------------------------------" p& }* U* @. B( Y" X0 e" P( }2 u
  585.   # ● 判断鼠标位于菜单的第几行、第几列  Z( x$ B: ?. T) h# g1 P& s8 t9 [
  586.   #--------------------------------------------------------------------------
    , _7 n- v2 h) a6 ~: k7 y
  587.   def mouse_window_area
    # V( j* b- U1 I* s( G% K
  588.     if viewport.nil$ T3 J3 g$ B' u( V7 `5 c% u" F  N
  589.       vp_x, vp_y = 0, 0; G; l- Y! R0 k
  590.     else
    ' Z$ l0 O4 Z  F" H+ v
  591.       vp_x = viewport.rect.x - viewport.ox9 J) w- m4 s7 s2 m& |7 z
  592.       vp_y = viewport.rect.y - viewport.oy/ t" n3 \- G2 u; Z; F! d
  593.     end7 @0 _* n9 j" a/ x5 v; X3 c5 p+ `& ~, y
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y) p/ D+ u7 m( c1 f
  595.     item_x1 = vp_x + x + standard_padding % T& k; P5 H- v/ F. I+ N. R1 v- ^
  596.     item_y1 = vp_y + y + standard_padding
    / K5 X4 m7 e/ [2 I3 R/ m: Q, L
  597.     item_x2 = vp_x + x - standard_padding + width* R& O: J1 m: l3 Q+ L
  598.     item_y2 = vp_y + y - standard_padding + height# ]; E' t- E! h! ~# [0 V
  599.     if mouse_x  item_x1
    $ d/ k% U& N" j; A. }6 x- F) D
  600.       mouse_col = -1
    0 h7 m. q; Q. O9 x) d8 f; C0 ~
  601.     elsif mouse_x  item_x2
    3 A* h) o  B) W7 N# ^: k7 b7 J$ {
  602.       mouse_col = -2
    2 i8 u* \+ d( \- u; p: U6 K% G
  603.     elsif mouse_x  item_x1 + 160
    ( h5 ?4 s6 ?, }9 w
  604.       mouse_col = (mouse_x - item_x1)32) {7 D. C- y, L
  605.     elsif mouse_x  item_x2 - 160# u3 F3 \  J# h. t; E3 @
  606.       mouse_col = 9 - (item_x2 - mouse_x)32& X* T8 q- I) U7 N
  607.     else+ N5 A9 e# O9 i7 K
  608.       mouse_col = mouse_x  x + width2  5  4
    $ @! p, u( ~% G6 s" f8 [6 ]5 U
  609.     end# u3 C. N' e9 x
  610.     if mouse_y  item_y1
    + n% X* k7 \4 q7 a  S
  611.       mouse_row = -1$ ^% V9 `9 x& w8 N- D) ~
  612.     elsif mouse_y  item_y2( [8 p/ Z( R8 _! z
  613.       mouse_row = -2
    ( {* Z& O. i: Q7 b& J) g! M
  614.     else  i  |0 a4 w5 B3 H: W! ~& D
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)( J; j0 j5 u$ B
  616.     end! f, x3 R& \& a
  617.     return mouse_row, mouse_col
    ( h& O2 U1 _% q# @% g9 q7 U# e
  618.   end
    + o9 N# S2 z6 h( j( ^( P) ^
  619.   #--------------------------------------------------------------------------4 s1 A$ U- f8 ]
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    " h0 }$ C- O, @' _8 |  o3 a
  621.   #--------------------------------------------------------------------------
    9 E$ Y" {! u: _" p! h
  622.   def set_mouse_pos/ f3 H) w7 q& b9 w" I: W% [  Y
  623.     if viewport.nil # necessary!% P: a5 W3 N6 x* t
  624.       vp_x, vp_y = 0, 0! M# e- q6 |% J7 s$ V: `& @
  625.     else
    + I7 j* D5 X1 x6 z" K
  626.       vp_x = viewport.rect.x - viewport.ox; i! O  w. x7 n5 Q+ D
  627.       vp_y = viewport.rect.y - viewport.oy: h" v9 I9 Z3 j8 ^& X
  628.     end; s. l: k& T! c  J7 K1 p* A
  629.     item_x1 = vp_x + x + standard_padding
    / g1 W( r+ n" B, F$ j: M
  630.     item_y1 = vp_y + y + standard_padding7 o9 |1 g% F7 U
  631.     get_index = @index  0  0  @index # L1 D" q1 `7 H! _5 W7 L: l9 y
  632.     row = get_index  col_max - top_row
    - @: s1 c# }1 ^/ O3 C$ `$ ]1 C
  633.     col = get_index % col_max* ], g# s5 u1 P  d
  634.     new_x = item_x1 + item_width  (col + 0.5)5 _) ]  ^- m. }' `( K$ d6 a, R
  635.     new_y = item_y1 + item_height  (row + 0.5)! Z, M( U5 A) j7 d9 N) K
  636.     new_x += 14 if col  4+ T0 |- t4 W4 r$ ~
  637.     Mouse.set_mouse_pos(new_x, new_y)
    & L; k7 Y- l% H( ^
  638.   end
    0 ~. `6 Z8 |6 l
  639. end
    # G0 g+ ]$ `4 Q0 }; u; t+ ~: @

  640. , \4 m4 u. ~' ?' s5 @- O, ^
  641. #==============================================================================1 M4 L, s* W2 D  |% a( V
  642. # ■ Window_NumberInput, Q& j6 w9 V' g* M6 b+ e. Y5 P1 q
  643. #------------------------------------------------------------------------------7 s) v7 ]' _9 U0 u1 g1 C5 p
  644. #  重写了数值输入的方法以适应鼠标
    0 o" X# x$ A* w9 n7 W3 W- o
  645. #==============================================================================
    0 M/ f  u/ G% B4 y
  646. class Window_NumberInput  Window_Base
    . E& t* \2 G0 x1 ~, Q: u# z
  647.   #--------------------------------------------------------------------------
    * y1 s8 d4 k- O& h  |
  648.   # ● 定义实例变量' H/ a$ k5 X" V* h; X! I- ]
  649.   #--------------------------------------------------------------------------
    ' D, C, P' \) \0 ?  }' e
  650.   attr_reader extra_window9 O% b6 J* Q: H. E
  651.   #--------------------------------------------------------------------------4 G" `- p7 T. ]* I  c) M( ?, o. u
  652.   # ● 初始化) Q) o3 D' O8 ]: U& _# Z2 S
  653.   #--------------------------------------------------------------------------
    8 R5 ^! f4 J) S" Y4 }( [
  654.   alias sion_mouse_initialize initialize) O- U  D/ z4 k- k3 P% u! s$ B: [
  655.   def initialize(arg)
    & [0 a( k, n# a# D/ F! ~! O
  656.     sion_mouse_initialize(arg)
    9 s( k  {' A! X) b, G3 v
  657.     create_extra_window  I+ s4 a  o1 B7 s6 D
  658.   end
    ( _% G5 V  o2 n) o. h0 N, M
  659.   #--------------------------------------------------------------------------
    8 n8 ~2 I3 D4 r: P( x
  660.   # ● 启动7 {- W5 e% y9 e+ }1 q' }
  661.   #--------------------------------------------------------------------------
    6 I, n* `2 s3 l/ C6 g# O+ O/ T
  662.   alias sion_mouse_start start
    ( c% L" h3 Z9 e+ |' e3 y4 V* a
  663.   def start* y% s* D: z& k  L
  664.     sion_mouse_start
    6 l  `; h3 o+ n% K5 B
  665.     deactivate; @. [+ }, Z$ o( t# c
  666.     extra_start! H6 D% L, ?2 b
  667.   end' p* ]$ q' O& P" E3 d
  668.   #--------------------------------------------------------------------------) W& W9 |+ Q3 }
  669.   # ● 创建新的数值输入窗口
    " h- t; p7 Z5 r2 L9 B
  670.   #--------------------------------------------------------------------------
    ) h& ?+ G- T& a3 y) g% L
  671.   def create_extra_window  A7 V5 `9 L! T5 o6 a4 [8 z8 `
  672.     @extra_window = Window_NumberInput_Ex.new" |* U0 i5 y( {7 y
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2% {/ ]9 Z$ w4 l) w9 o
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    . j& P: u. G9 v4 D- b# w
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    , q) `. @7 N. w3 X: b; M4 r: ]
  676.     @extra_window.close_proc   = Proc.new { close }& I! `/ _  b5 `! P5 @( X
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    & w% I) W) g3 w
  678.   end
    4 E- t. C1 J$ K& m( {) Q
  679.   #--------------------------------------------------------------------------
    5 K/ n8 R- a$ T
  680.   # ● 激活新窗口
    . s" h1 P% Y$ [. b  S8 s
  681.   #--------------------------------------------------------------------------! b6 d3 r; X* Q- I* e3 Q
  682.   def extra_start
    " M1 S+ P  c' f2 h4 N& R9 o. u
  683.     case $game_message.position
    0 y, v0 [! M5 X! Y0 D
  684.       when 0; @extra_window.y = y + height + 4
    7 @" D  F( J1 O; ]1 H+ b
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8) _( ^/ h8 q9 G
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    8 S/ c9 ?  s* h* D* p; M( a$ h
  687.       else  ; @extra_window.y = 89 @! c/ \- {( l5 \% z+ H
  688.     end
    3 Y. M# m) o; k, M8 v4 m3 A
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    2 B# |5 G* q7 q; y
  690.     @extra_window.digits_max  = @digits_max3 k  Y$ J) @! X! Q+ b% _- k
  691.     @extra_window.number      = @number
    1 J; p; `+ N+ a% C5 P0 y1 {
  692.     @extra_window.open% x4 F! S4 q7 m) |2 |
  693.     @extra_window.activate2 i6 b6 v( K: L; I
  694.   end6 ?! ]9 q, L- H! R$ N; v' i6 y
  695.   #--------------------------------------------------------------------------+ V+ G; L3 s1 l! s
  696.   # ● 更新; ^, F. U6 E# {4 T" a* Z9 V
  697.   #--------------------------------------------------------------------------: Q5 \8 f" w: m+ L" f7 W
  698.   def update3 V9 R$ n9 w6 [" x: b
  699.     super
    1 G/ u: E7 I) ?8 i4 e  w/ r: }. M2 x: r
  700.     @extra_window.update
    $ l& Q# {+ R9 U# H6 d0 e7 Q- K( |
  701.     update_cursor* ^0 g6 D; y5 D, E5 e2 U" L6 i; `% Z
  702.   end
    6 i- C) Z$ u2 _8 h7 g
  703.   #--------------------------------------------------------------------------
    ! [, T2 i) d; R; b: c2 q, B, |$ O6 z7 y
  704.   # ● 关闭窗口
    - Z9 y) P3 Y* I& z+ }2 J
  705.   #--------------------------------------------------------------------------
    - a1 W4 j# _, W! S
  706.   def close- N' \/ i% ~5 L9 S1 D' u
  707.     super( k' [0 E3 _4 I  k' u
  708.     @extra_window.close' H4 K: I% a* g; x. w
  709.     @extra_window.deactivate2 A  l3 T! ?% f; S, @( M
  710.   end
    ( n; r( b( I8 _6 T5 ]3 u8 A
  711. end& T+ Z# S' t- {1 Q3 A

  712. 0 _. }6 t0 m6 z6 v  m& _
  713. #==============================================================================: e1 f$ _' ]& Z
  714. # ■ Window_NumberInput_Ex% x- ^+ c/ G3 i% y3 G
  715. #------------------------------------------------------------------------------
    ! p' w0 }6 Q$ g$ y- s8 f' X! t
  716. #  新的数值输入窗口(NewClass)
    4 H2 A$ q, C7 T: u5 n! w1 C/ b' L5 C
  717. #==============================================================================
    * l* b% I8 e# @: b
  718. class Window_NumberInput_Ex  Window_Selectable
    5 x' J, Q# S& ^6 O; }9 Y
  719.   #--------------------------------------------------------------------------
    & _+ [3 a" y$ s( Y. `- |" ]
  720.   # ● 定义实例变量* ^! L$ s# ~+ i9 O
  721.   #--------------------------------------------------------------------------) o: v) a" F/ z; _0 R
  722.   attr_accessor number_proc6 b! L5 u5 u7 T' |4 u
  723.   attr_accessor index_proc
    % M9 Q9 x+ Y) `) _9 s
  724.   attr_accessor close_proc
    / B! ]0 P4 |% d1 O! H6 _9 {
  725.   attr_accessor refresh_proc# f9 C1 N/ w5 E$ q9 y
  726.   attr_accessor number; d) y2 T% r. p- k; A! `' m
  727.   attr_accessor digits_max
    / w2 d. K4 J  f* Z$ s
  728.   attr_accessor variable_id' [" k0 |0 P& U* [; s
  729.   #--------------------------------------------------------------------------. w- F9 K/ B% y% a1 ~
  730.   # ● 数字表
    7 f! i% t# x( U  l* H- o  C
  731.   #--------------------------------------------------------------------------9 B% f; S& e' M* m! N# Z$ c
  732.   TABLE = [  7,  8,  9,
    ( B) G$ L4 t8 n  p% X! q* Q
  733.              4,  5,  6,# m, N0 _* c. X' \# _, f* Q7 p
  734.              1,  2,  3,
    / h* ~! k2 O+ S
  735.             '←',0,'确定',]7 L& S( z2 x( g& o# V% ]) A
  736.   #--------------------------------------------------------------------------1 j/ A" w6 j& s: }- ~: x5 Z
  737.   # ● 初始化对象2 s& b/ M, P. p: t1 @
  738.   #--------------------------------------------------------------------------
    ; J$ k2 D* V9 b. M
  739.   def initialize5 F- T( d4 E1 ~, Z4 ]: K0 f
  740.     super(0, 0, 120, fitting_height(4))9 b+ E9 G% q- f1 M
  741.     self.openness = 00 r7 O# H) r$ @8 \( l( J9 F- S" F7 p
  742.     @index = 02 S, t  F$ L7 B, s! [; @( W
  743.     @number = 0( O: H. M1 R: ]- F2 x3 x  u
  744.     @old_window_index = 0
    8 `, U/ w9 J! t0 v4 @
  745.     @digits_max = 0
      v6 \( C% X/ C3 r* g8 B) v0 T: H
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
      j( M3 v/ i5 [# O5 `
  747.   end7 f5 S, @2 N: U' G
  748.   #--------------------------------------------------------------------------) N; {7 X" n0 D7 E, m
  749.   # ● 获取项目的绘制矩形
    0 p$ H, h/ W) l9 B0 s+ l
  750.   #--------------------------------------------------------------------------
    ( x8 u# g. t( R) _5 _. X$ w; l
  751.   def item_rect(index)
    1 c) T; y2 f! `5 x/ }2 i+ ]* g
  752.     rect = Rect.new
      [" h$ E) q* F6 ?5 j
  753.     rect.x = index % 3  32
    8 ~/ Q* Z$ V% i
  754.     rect.y = index  3  line_height  O2 U. g2 ?1 m. O
  755.     rect.width = 32
    ; A" _0 u7 m  P3 g9 C. }: c
  756.     rect.height = line_height
    2 O9 M& c9 M; O5 f
  757.     return rect
    ( E" Q0 K9 ?  ~3 z" M3 m8 b; ~
  758.   end# A/ `) V" y* t& c- x$ o8 I
  759.   #--------------------------------------------------------------------------2 }7 F* `! P; {% l! g; ^' b! r
  760.   # ● 将光标设置到鼠标所在的位置7 i9 |3 s5 U$ Y% @$ F
  761.   #--------------------------------------------------------------------------' N& ]  v% w# Z5 Y
  762.   def set_cursor  ], C* _1 h' T  R% n5 Y- g( V3 l: ~
  763.     mouse_row, mouse_col = mouse_window_area
    " V, q' E  ~/ X8 O
  764.     if mouse_row = 0 && mouse_col = 0
    % b+ r* P! v8 o
  765.       new_index = mouse_row  3 + mouse_col9 l5 V2 q1 I" a
  766.       select(new_index) if new_index = 11$ u9 ~0 Y: X% d( N
  767.     end
    8 M" C# P: l+ v2 _
  768.   end7 D4 q" `" L; F$ c3 z
  769.   #--------------------------------------------------------------------------1 c( w5 f- x4 |5 ?
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    % }: N: @: ?( F4 _9 Y/ t& T* h
  771.   #--------------------------------------------------------------------------
    " J& h* u6 M# J9 w& {
  772.   def mouse_window_area0 H& P& U5 D' `) v9 L1 \
  773.     if viewport.nil; b5 u" P4 P! m( C/ m
  774.       vp_x, vp_y = 0, 0. P1 t0 `! R" r- d( Y0 P
  775.     else, p8 a5 r* [( t2 |  x- D: r* x" r
  776.       vp_x = viewport.rect.x - viewport.ox& d3 U. e! ?" B& ?' Q6 [! Q; W
  777.       vp_y = viewport.rect.y - viewport.oy
    * @; ?0 W% m: u8 D2 D
  778.     end) {( y6 [% d7 c; Y: k" n
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    1 _- B, v7 Q- L5 ?
  780.     item_x1 = vp_x + x + standard_padding 9 V1 i. p: H* ~" ?
  781.     item_y1 = vp_y + y + standard_padding) G" \+ d6 f& J7 _5 V3 ?
  782.     item_x2 = vp_x + x - standard_padding + width& F7 H4 _$ f) m8 r) M6 m, j2 P
  783.     item_y2 = vp_y + y - standard_padding + height
    ( {4 q$ S7 f" E) M
  784.     if mouse_x  item_x1, |( _  O) E" y1 m1 x& l2 @/ C
  785.       mouse_col = -16 a# W0 Y" Z, z# Z$ z. O
  786.     elsif mouse_x  item_x2
    3 K7 n7 a4 h( ]. {6 y/ c
  787.       mouse_col = -2( Y  r& v) f2 {+ p
  788.     else. U7 I( g% f" s9 G
  789.       mouse_col = (mouse_x - item_x1)  320 g4 @- M4 g" Z9 Q3 e
  790.     end* t. j# ]9 `: O2 i
  791.     if mouse_y  item_y18 i# z$ O- t- E. f; \
  792.       mouse_row = -1
    $ A. C4 ^5 Y, D
  793.     elsif mouse_y  item_y2# K4 _; F+ v$ W+ ?
  794.       mouse_row = -2
    8 ]0 V8 _$ G: N& g1 i. r
  795.     else
    / p4 {2 s' P: u
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    1 Z# T. ]- e4 o! |5 K! \4 L' n$ h
  797.     end
    " q0 ~" J$ ]' j: M/ t, k
  798.     return mouse_row, mouse_col% _6 K+ c0 v$ u/ u1 P
  799.   end
    ' V) K+ T$ }4 ^0 G9 o
  800.   #--------------------------------------------------------------------------
    8 @" Y, J) \' M% E
  801.   # ● 获取文字
    : Y; Q  q; ^+ ?( H. z. O
  802.   #--------------------------------------------------------------------------0 x, f& ~2 Z; `( c
  803.   def get_number, N6 ?( B" |/ d, p
  804.     return false if @index == 9  @index == 11
    7 @+ [1 T$ V/ I
  805.     return TABLE[@index]
    % h8 g* z6 i( K7 B; f7 f
  806.   end* M# \. c! t1 J' J' [) j
  807.   #--------------------------------------------------------------------------
    1 t2 T8 k; j& p, E+ a* w
  808.   # ● 判定光标位置是否在“退格”上
    7 I" N5 l3 Q2 x' r
  809.   #--------------------------------------------------------------------------
    " X" ]3 a0 ~( M& x
  810.   def is_delete. K) d# z6 m4 `; k% A" \3 P
  811.     @index == 9
    7 T' h0 j" b( C1 U) h
  812.   end1 y# L2 A3 j) c- {, t& b, Q; W& a  G
  813.   #--------------------------------------------------------------------------* N* _0 \* G% F9 K
  814.   # ● 判定光标位置是否在“确定”上9 Z: n. W4 H) H1 E6 h
  815.   #--------------------------------------------------------------------------
    + `& H  b6 k+ e) u# e/ {" B& P
  816.   def is_ok! S) f3 e% B; x. g( O) `1 |  A
  817.     @index == 115 D! F& @1 H# p
  818.   end/ H5 E! p/ {5 u( b( b
  819.   #--------------------------------------------------------------------------# [9 I3 L/ [1 y# O0 \" i
  820.   # ● 更新光标/ j5 X) W3 a0 t! N
  821.   #--------------------------------------------------------------------------4 n' n( a5 X4 z2 X( g
  822.   def update_cursor
    7 a$ y( X! {* l! u' b
  823.     cursor_rect.set(item_rect(@index))
    / G, s$ R4 c, P# d% v* C% O
  824.   end) M4 h! ?" v6 e% C
  825.   #--------------------------------------------------------------------------
    7 Z- m6 e( Z0 H8 R
  826.   # ● 判定光标是否可以移动- [6 n7 {9 {+ m0 A" w$ g
  827.   #--------------------------------------------------------------------------
    . |/ O# R% {8 ?
  828.   def cursor_movable
    ( }, N+ x# L4 e. D) t' \; G
  829.     active8 Z% B7 x' G) \/ w$ i
  830.   end6 D+ E0 ~8 Q3 ]8 L1 Y. F4 O0 s
  831.   #--------------------------------------------------------------------------! u  z/ r& r+ l6 z0 ]% n* f
  832.   # ● 光标向下移动0 V1 p# ~1 I+ V: e- v6 S6 F, n" w
  833.   #     wrap  允许循环
    , N( J9 f- B1 n
  834.   #--------------------------------------------------------------------------5 O/ Z9 G$ L' x1 d; n5 T, J
  835.   def cursor_down(wrap)5 s/ q- _7 i! A
  836.     if @index  9 or wrap6 A5 C# @5 v& Y) l$ T0 |
  837.       @index = (index + 3) % 12/ I" n/ g$ p6 |6 n2 H
  838.     end# r. s1 Q$ H  z" j5 o9 w
  839.   end, Q0 y# _+ P6 Q5 Z9 v9 t, J  C
  840.   #--------------------------------------------------------------------------  ~+ @  W+ H% r7 U  g
  841.   # ● 光标向上移动5 v) z% T  k; x9 k0 a" ?$ y
  842.   #     wrap  允许循环+ n3 `/ p7 H; A. P, x3 t4 H) e
  843.   #--------------------------------------------------------------------------1 ^. g, B$ |' e4 Y( {' {
  844.   def cursor_up(wrap)
    " y  H5 ?' p& ]* U) X6 e8 w
  845.     if @index = 3 or wrap. [+ |0 M$ p: c& U; J
  846.       @index = (index + 9) % 120 C; }' e0 E, w  q0 H6 Y% W- F
  847.     end
    & }) Y& b, D1 p* J$ x/ Y
  848.   end3 b3 N; F" ]7 y9 V0 p3 E" l" o
  849.   #--------------------------------------------------------------------------. m$ [8 z, n( T
  850.   # ● 光标向右移动0 i) i. Q8 z) Z) G- o
  851.   #     wrap  允许循环9 e/ {! U7 o1 y1 l2 `/ c
  852.   #--------------------------------------------------------------------------
      T* Y- z6 \/ l; y& X+ G
  853.   def cursor_right(wrap)
    , \/ n+ q, f# Z% E$ e8 B4 J
  854.     if @index % 3  2. Y$ c( Q& B4 A# G& V
  855.       @index += 1
    + _  K3 C6 y3 H& W3 I5 K# k
  856.     elsif wrap
    ! Y! e) p) T3 B  E; \' a* q2 k& ]6 K
  857.       @index -= 2
    ) }6 ]8 l  s8 A# M" L, V
  858.     end5 z) U2 q  N( M5 L. a( l* G* H2 _6 q
  859.   end
    ) |5 m+ W8 h5 c. d! H' f2 J
  860.   #--------------------------------------------------------------------------
    ) r! n" R" Y1 ^" ~$ N3 O
  861.   # ● 光标向左移动9 y- w" s2 _6 {% y1 p" [
  862.   #     wrap  允许循环; Z6 [5 z1 V% p- g. m
  863.   #--------------------------------------------------------------------------
    1 q5 c/ W$ H1 b' e
  864.   def cursor_left(wrap)( X- K' [7 p: Z* L2 d
  865.     if @index % 3  0
      p& U2 `( D7 w3 |3 Z6 C) @
  866.       @index -= 15 I! L$ Q" g! Z( ]0 P8 N( K
  867.     elsif wrap
    4 d# B4 m& v3 C: ~
  868.       @index += 23 [5 c6 u9 K' p
  869.     end* g; o4 k" [' m, p0 n& R
  870.   end
    ; M! H% a& f; c: U/ p
  871.   #--------------------------------------------------------------------------
    8 e$ o; ?+ c; j& Q' o* f* _; a
  872.   # ● 处理光标的移动1 b; A( ]3 T, G% D% y% _
  873.   #--------------------------------------------------------------------------1 A2 D# Q1 R* f3 ~, p: I; v6 P4 h- [
  874.   def process_cursor_move
    2 n* d  t7 A( |: k  }
  875.     super
    0 P! P+ e! w/ a$ r
  876.     update_cursor
    0 n# X# V  c+ i# ~3 E
  877.   end, |* ?  Z9 g: v+ b4 b& \* _
  878.   #--------------------------------------------------------------------------
    3 B( c) m4 f9 k6 K1 _) P2 k
  879.   # ● “确定”、“删除字符”和“取消输入”的处理8 M* z5 J6 Q. J9 p7 V3 H! X
  880.   #--------------------------------------------------------------------------
    * ?7 }4 Q5 [' N7 k7 C
  881.   def process_handling* V3 w2 U1 g$ z! R: e: L9 V
  882.     return unless open && active. Q5 Z, q, i. V$ S# ?1 ~0 r
  883.     process_jump if Input.trigger(A)1 _. w3 w: h9 C) o
  884.     process_back if Input.repeat(B)5 T" n2 X, e( m. d
  885.     process_ok   if Input.trigger(C)$ N3 D2 ~; f6 l
  886.   end9 v& z0 w! g2 e* |: h
  887.   #--------------------------------------------------------------------------
    0 `/ W% i# q. [: \: G* Y
  888.   # ● 跳转“确定”( U. Z5 ~$ R) z& W* [/ I7 W
  889.   #--------------------------------------------------------------------------
    4 g: Q: ~5 v6 w5 W
  890.   def process_jump# D, A' A8 {2 {+ Y. V. u
  891.     if @index != 11+ j8 z/ P" ~; E8 D. o
  892.       @index = 11
    3 D& p0 Y; P+ L% d9 A" {  {3 C) c
  893.       Sound.play_cursor
    1 u- J. E0 ?( x1 F) ^4 ?  n% D9 j
  894.     end
    & a' ^3 }) \+ \+ \* \/ k
  895.   end( ?$ v- x8 M( V5 \
  896.   #--------------------------------------------------------------------------3 s7 x1 D, E5 \* g' R- V& g
  897.   # ● 后退一个字符
    . p* p2 P- }+ j
  898.   #--------------------------------------------------------------------------
    2 H# D5 o' c9 S7 i8 c1 j
  899.   def process_back( v& U, n( J) L( _% L; ~
  900.     Sound.play_cancel6 Z4 m! e: q' ]+ W! x; I- m) J
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    6 p4 h) L% |2 v% \% m6 N: ~- v. L
  902.     n = (@number  place) % 10
    2 p, Y& V! [/ j
  903.     @number -= n  place% a  @1 ~1 h6 a. q2 A
  904.     @number_proc.call(@number)+ S/ u+ M' |7 R, @: X8 V# i
  905.     @old_window_index -= 1 if @old_window_index  0
    / [& {( S( V# |+ I
  906.     @index_proc.call(@old_window_index)7 R  |% o3 ]* u9 Z3 E* q% \
  907.     @refresh_proc.call
      x% s. l3 i2 S
  908.   end9 O2 `$ u* [7 M  _0 q( g. S
  909.   #--------------------------------------------------------------------------
    ) x6 V9 ^  A+ ?. d  _" t; V
  910.   # ● 按下确定键时的处理
    8 K6 T+ w1 ?+ X/ |
  911.   #--------------------------------------------------------------------------$ `) d: j4 w+ U4 A
  912.   def process_ok
    3 B& Z% y- m/ ]* E/ F! }
  913.     if get_number- u* e; A) W# T  C
  914.       Sound.play_cursor; W) N0 a( d/ Y  [' k
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    " V1 P. W# D  S( Q3 N
  916.       n = get_number - (@number  place) % 10
    3 [: Y3 h( [' c4 b- z# J+ ]$ t
  917.       @number += n  place
    6 |+ ?6 {  f- o' r) c6 ^" ^1 l! @
  918.       @number_proc.call(@number)
    , Q  G4 F- O% p. ?/ ?: u. Z
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1$ o5 L: S9 y' d/ ~, l8 m4 T8 ]! k) G
  920.       @index_proc.call(@old_window_index)/ s$ r4 p. `& D# B1 X: o
  921.       @refresh_proc.call
    $ ~% w. Q. X9 O0 v* f- T& x
  922.     elsif is_delete
    ; I* y4 Y+ w# u- t1 u
  923.       process_back
    6 y! K' n( j! |! [4 U# J
  924.     elsif is_ok
    , v  N" z0 O2 w2 G& u: x
  925.       on_input_ok1 B/ J8 p' w! f, {% n
  926.     end
    ' x* t# w" A- g% C& ?5 D3 w( s
  927.   end
    8 ]4 M$ |, Y* \& P
  928.   #--------------------------------------------------------------------------
    % x: t( \7 C' }+ U' L
  929.   # ● 确定1 t" M7 p2 }! Z# M; t% v$ p
  930.   #--------------------------------------------------------------------------* o: z* ?4 Z6 K- W8 I+ P
  931.   def on_input_ok4 A* U" P7 u- b+ a; N( L
  932.     @index = 0
    5 X: T+ j- {9 Q
  933.     @old_window_index = 0+ C. }0 ~5 G; k: F: T9 x
  934.     $game_variables[@variable_id] = @number
    + w7 Q3 {( b. ^6 R, B
  935.     Sound.play_ok
    7 I: G% \! v/ C  e& w/ \! n
  936.     @close_proc.call4 d5 l" e/ E2 u2 G, y% P  d
  937.   end
    2 C) g* t+ f/ \, Q6 _
  938.   #--------------------------------------------------------------------------0 P! G/ K( v9 d+ T- J- G( H
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置- p& L3 ~; w$ {, l2 ]2 P
  940.   #--------------------------------------------------------------------------5 A4 W& _" C4 b2 r' F
  941.   def set_mouse_pos
    . R" a7 V( r9 W: D# M8 {8 ^  D
  942.     if viewport.nil # necessary!, M+ h% D& y, [
  943.       vp_x, vp_y = 0, 0# E& M) T* L$ N! g3 E) }: y) a. e
  944.     else1 a. G% n- N9 L3 Q6 n2 L) [, Q
  945.       vp_x = viewport.rect.x - viewport.ox
    9 T) A, n' A, F, d$ Z8 @# j3 H
  946.       vp_y = viewport.rect.y - viewport.oy
    # g' s: x7 W8 f, }2 }: F! |
  947.     end/ n! ~8 S5 r, ~, I, ~3 e
  948.     item_x1 = vp_x + x + standard_padding 3 J2 x  v3 P4 r7 T7 K+ F3 F; k
  949.     item_y1 = vp_y + y + standard_padding
    * q) C+ T  {" J: R4 q9 a
  950.     get_index = @index  0  0  @index ' {5 x" @2 O$ @6 \, N- ?
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    6 {* ^' A1 L& _+ O6 m/ O: I
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)! u, t6 i9 J0 [
  953.     Mouse.set_mouse_pos(new_x, new_y)% l& ?( [$ y2 O
  954.   end5 [8 M# k1 V' r+ C5 L& l
  955. end) x" h& V& S: U& z

  956. 6 j% W, v' b" c8 H6 _5 N
  957. #==============================================================================# c6 Y% [" }/ h9 u# I, F* M
  958. # ■ Window_Message
    ' U$ I4 }4 i; N+ z% w* [
  959. #------------------------------------------------------------------------------1 r- |/ B  v! {! v5 E  G& ~1 O
  960. #  显示文字信息的窗口。
    ) z& m4 u2 s2 V( w; c1 i# R
  961. #==============================================================================$ K% r1 B% v: _' C
  962. class Window_Message  Window_Base  @* E+ T8 L" K4 {8 p5 e, t
  963.   #--------------------------------------------------------------------------/ f5 z7 s8 q! ^+ Z  l
  964.   # ● 处理数值的输入(覆盖原方法)
    8 }, v& V! w7 c6 E0 j
  965.   #--------------------------------------------------------------------------
    4 D' F+ F/ ~% O0 f, X- _
  966.   def input_number6 Q0 ~" ]$ U+ [
  967.     @number_window.start2 b! w% r1 K- F( Z2 z7 e
  968.     Fiber.yield while @number_window.extra_window.active0 Y7 ]  ^9 X* w+ ~' ~
  969.   end
    2 N3 k4 k4 T& l8 `' B+ G
  970. end
    6 w0 r. L: P& G5 k1 ^
  971. * h# g& u  d. s4 \7 s
  972. #==============================================================================# Q) \4 c' q3 `3 R" O- A7 x
  973. # ■ Window_PartyCommand1 m0 s$ F. l, V
  974. #------------------------------------------------------------------------------
    3 S4 i  \% s/ L8 f
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    $ i: m2 C. r' X) `+ E
  976. #==============================================================================
    9 }- s/ I8 s2 f
  977. class Window_PartyCommand  Window_Command7 {" v  f) S, h' ~7 ?% t- o. E# W
  978.   #--------------------------------------------------------------------------
    ; x8 h, z* ^9 C( M
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置# y5 v  c& q+ L% E
  980.   #--------------------------------------------------------------------------# |5 {( g5 J: b. A" A( A7 V  Z% L
  981.   def set_mouse_pos
    7 |( [; o3 Q3 v9 Z& G& H4 c, s& w
  982.     if viewport.nil* k$ s  P, s& B
  983.       vp_x, vp_y = 0, 08 p: C: m; u  V
  984.     else
    , }/ U* H* ?; t1 C; \
  985.       #vp_x = viewport.rect.x - viewport.ox( a' B* z4 q  o; D% _
  986.       vp_y = viewport.rect.y - viewport.oy
    * Q; ?2 y! K. t
  987.     end* j" z0 N3 [& m) d
  988.     item_x1 = x + standard_padding . n8 X/ G' \6 [, J: W7 h  T, H7 N' t
  989.     item_y1 = vp_y + y + standard_padding7 F4 b' r8 j! e; r
  990.     get_index = @index  0  0  @index . `1 y4 p6 L  O1 r" \( d% h: g
  991.     row = get_index  col_max - top_row7 G/ E* H/ J" |  }$ \; f
  992.     col = get_index % col_max
    $ X& Z4 i, Z& U0 R2 B
  993.     new_x = item_x1 + item_width  (col + 0.5)# S7 _% w3 y- z
  994.     new_y = item_y1 + item_height  (row + 0.5)
    # N; f* v. d# y8 U/ p& x# R6 ~
  995.     Mouse.set_mouse_pos(new_x, new_y)- u" O, y; r: e; Y
  996.   end
    - W" Z3 v9 x9 v- F& u
  997. end
    : v8 y/ J' C! h* t

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

  2225. + D. D. n' t( o: X$ ?
  2226. #==============================================================================
      z- K# Z, _0 h2 @
  2227. # ■ Spriteset_Map8 {$ q- K+ P) A& a
  2228. #------------------------------------------------------------------------------5 Q/ f* f3 C* @8 Y+ ~7 c; m3 [
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。/ _- d% ~. r' q2 x0 s# |1 Q1 z
  2230. #==============================================================================0 g% K  r# f9 w5 t
  2231. class Spriteset_Map
    ) _7 N% s9 w: B  p7 j1 [' Y
  2232.   #--------------------------------------------------------------------------
    5 [6 g1 }( k' |# S1 m, ]3 e
  2233.   # ● 生成路径点精灵
    ' P7 @5 i- Z. M8 N2 C( N6 Q" ]3 A
  2234.   #--------------------------------------------------------------------------
    3 F8 e. G, _  u& y
  2235.   alias sion_mouse_create_characters create_characters$ m8 Y% N4 G' a  o1 h; y$ t
  2236.   def create_characters
    3 E5 M# w) i( Y; l/ H
  2237.     sion_mouse_create_characters
    $ d# U' \3 H* Y' v) f. U
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))0 M/ D: B1 B/ }0 K" Z& u
  2239.   end! ?. j! [; ?0 u9 v& b. h( ~4 v
  2240. end
    : h  Y% G6 `: E9 {, T
  2241. 6 ^, i1 ^0 t# j# `# f& t6 ]6 k
  2242. #==============================================================================5 q& }* F7 g9 v$ m1 t
  2243. # ■ Scene_Map
    7 h( E  x4 _" M5 @2 v; q
  2244. #------------------------------------------------------------------------------
    2 j: \6 M% O$ a5 Q3 w! y' `
  2245. #  地图画面
    : P* \; v# c: t$ I7 q- i, d
  2246. #==============================================================================
    3 S+ i: U9 |; U5 j- F, {
  2247. class Scene_Map  Scene_Base9 P: N/ z. R9 N2 T2 J7 ]
  2248.   #--------------------------------------------------------------------------
    & r5 _: p9 y! x' @% h" R8 ^2 m
  2249.   # ● 画面更新
    ) s, l5 d' c3 i5 G( f- G$ _# F
  2250.   #--------------------------------------------------------------------------
    3 U* u9 ~$ V! g$ r) d6 y5 N
  2251.   alias sion_mouse_update_scene update_scene% C( p% ~2 Q; a' j+ x- C( n, ^3 x9 F) n
  2252.   def update_scene, ~. ]+ i, }7 E% x( x  z# Y: |* c
  2253.     sion_mouse_update_scene
    ; P8 H5 W9 ^- D6 Z3 T
  2254.     update_mouse_action unless scene_changing* V/ u7 q* h, c) u2 o) {9 p+ x
  2255.   end( M: E5 u) Q/ I& X+ A
  2256.   #--------------------------------------------------------------------------
    ) N( \1 S+ x, m: O# G9 z
  2257.   # ● 场所移动前的处理! L1 N7 S' J# V, F3 m: f, P
  2258.   #--------------------------------------------------------------------------9 }# q( r- G& @& p5 E+ L6 D
  2259.   alias sion_mouse_pre_transfer pre_transfer. e& l3 @) Z  o6 u" \+ r5 W
  2260.   def pre_transfer
    . |; h# m( c5 a$ w, H1 o
  2261.     $game_player.reset_move_path; ?: H7 m% _! `7 A" y
  2262.     sion_mouse_pre_transfer" t0 z6 B. x! n. v( d- U! z, e
  2263.   end+ {3 [+ E* p3 s$ I
  2264.   #--------------------------------------------------------------------------7 o+ A6 s5 g% @
  2265.   # ● 监听鼠标左键的按下
    / Q* i  x8 B4 M/ [
  2266.   #--------------------------------------------------------------------------* k1 H8 @! l2 b
  2267.   def update_mouse_action0 V8 W! F( o% _0 \, C; @+ W
  2268.     $game_player.left_button_action if Mouse.press(0x01)' q/ Q/ t* `7 R/ a% d
  2269.   end6 b7 G6 {+ R# n0 j) Q5 Y
  2270. end3 Y3 E3 J: @6 L- B) g3 W
  2271. 4 o! j9 t( Z! d9 E7 N
  2272. #==============================================================================
    & r- E2 W9 B7 X
  2273. # ■ Scene_File: i' [9 R+ x7 n/ B% Z8 w- M; E- Q
  2274. #------------------------------------------------------------------------------4 @( d' O2 d2 Z8 m! ^. _/ i( j
  2275. #  存档画面和读档画面共同的父类
    6 b8 [  U/ U2 A$ H: i
  2276. #==============================================================================
    % k1 z+ Y8 ?! }+ L
  2277. class Scene_File  Scene_MenuBase$ M4 t5 L3 G6 s$ {
  2278.   #--------------------------------------------------------------------------9 A, N9 J: ~/ k. {  l" t
  2279.   # ● 开始处理, Q$ g6 C. d1 s% x0 L' {
  2280.   #--------------------------------------------------------------------------, B5 ~$ o. X- h* _  B! r. J% h
  2281.   alias sion_mouse_start start
    5 w' z0 R. |8 c% F3 d' m
  2282.   def start
    " b4 `6 }; D$ n! `  ^- V# d( \
  2283.     sion_mouse_start* v3 w# v0 N# J4 T1 i
  2284.     @move_state = 01 }" A& X! m, `6 A; m# f
  2285.     set_mouse_pos
    5 C9 w; }# M! P+ h$ ]/ \; Q1 `1 Z3 ^( t
  2286.   end% p7 E2 O: o4 T0 m# D2 k0 [" W2 m
  2287.   #--------------------------------------------------------------------------
    % X( g# D6 q% K5 M/ r- j
  2288.   # ● 更新画面8 F. ~  e  C3 ^4 Q8 W. T0 k7 e
  2289.   #--------------------------------------------------------------------------# a7 ~( W6 [5 J
  2290.   alias sion_mouse_update update% B6 S) i& q0 p( Z( |
  2291.   def update' E7 F" a9 I2 ?1 O' y
  2292.     sion_mouse_update* L1 \5 @* d" i" }/ {$ C- i
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos+ L6 D% l5 U) u' x  N
  2294.   end
    % `% h  a9 [  c" }
  2295.   #--------------------------------------------------------------------------
    4 E% H( k) l* g  b) _* E! ?
  2296.   # ● 更新光标! m& x/ u  p! t% l6 I
  2297.   #--------------------------------------------------------------------------
    0 _, w& i& Y1 ?
  2298.   def set_cursor4 {- S3 Z$ _* _3 P
  2299.     @move_state += 1, d0 c: |" P% t8 Z( R1 J
  2300.     last_index = @index
    / n) q4 }" B' F8 h- a2 A$ Y/ w- O
  2301.     if mouse_which_window == -2& H& c; s+ q) q2 t
  2302.       if (@move_state - 1) % 6 == 0
    & J' h3 x  H, H' N) S
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1) v2 b, q0 u- H2 G
  2304.       end
    . p) `0 C5 T% @  _9 z
  2305.     elsif mouse_which_window == -19 k# `3 k; |9 x! w1 T3 x
  2306.       if (@move_state - 1) % 6 == 0
    5 A5 h3 {  \9 x% S
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    ( Z' @, H+ z7 R4 U4 J* T0 G- s3 H
  2308.       end* u$ T) l, ?* l# _% S
  2309.     else
    % Y+ X6 _- `/ I! E
  2310.       @move_state = 0  G5 q+ P$ G( B
  2311.       @index = top_index + mouse_which_window
    % E% [* K" k7 `
  2312.     end9 ]% b5 y  k* M& h6 _
  2313.     ensure_cursor_visible
      u6 M4 A, Y6 o6 g0 T4 V& F& X
  2314.     if @index != last_index3 Y6 G) Y& R1 `6 o/ p
  2315.       @savefile_windows[last_index].selected = false' P8 x9 `2 o2 r4 B2 q( N; m- Y  _
  2316.       @savefile_windows[@index].selected = true* T) _5 H+ b3 \  S
  2317.     end
    4 _$ K+ v1 N5 j3 {* T8 ~
  2318.   end" h  z) z/ X. P, v) ?/ U0 z
  2319.   #--------------------------------------------------------------------------
    8 [1 l1 B/ y4 O/ ^8 Y
  2320.   # ● 判断鼠标位于哪个窗口; g9 W- M4 G2 S/ @" H+ ]
  2321.   #--------------------------------------------------------------------------
    + w2 ?( n7 v, S3 a; K8 Z
  2322.   def mouse_which_window
    : i* P& z3 t: _4 b# |
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    * C/ f' U% m# R! x
  2324.     if mouse_y  @help_window.height + 145 d9 |; U. b4 E6 X: v. Q! N" F
  2325.       mouse_row = -1
    3 c$ N/ s+ N0 }4 b1 W4 l# V
  2326.     elsif mouse_y  Graphics.height - 14
    " M% e8 C( W5 w
  2327.       mouse_row = -2) ]" f/ ^" n6 a/ q5 z! H- E" e- \" o9 P
  2328.     else
    , f) T3 N6 `6 k+ O; B
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    0 ?4 g5 z9 f9 ~0 T8 f! x* t
  2330.         (Graphics.height - @help_window.height)
    % @7 N/ r! |  n5 i' {( U) X
  2331.     end
    , |; X; r0 N( d! e: a, A* H7 f
  2332.     return mouse_row1 t+ j+ X' o# I8 d& `0 L
  2333.   end
    : X3 f$ F) `  U. r8 p/ T
  2334.   #--------------------------------------------------------------------------4 h% S% b* A2 p% q' h
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置$ l3 ?" a. y$ R) Q! W2 c! o( r
  2336.   #--------------------------------------------------------------------------
    ' O, F( ^% B9 g! Z
  2337.   def set_mouse_pos* b, R$ a9 f0 T, n. Z9 Y, B9 w) `
  2338.     new_x = 40
    & P( x8 T8 a, o
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
      e1 y, L5 e3 _8 g. K& I: W+ n0 q
  2340.     Mouse.set_mouse_pos(new_x, new_y)/ L+ l9 z5 @. q5 o: V  o1 e
  2341.   end7 u' o* @6 o9 ^0 N% a' @
  2342. end- K( i3 d; v; h- K  A6 `* l
  2343. ! R; t6 c9 g$ `, b7 g' t/ e; |
  2344. #==============================================================================
    . Q! ~5 I* i9 T% o) I2 U5 S
  2345. # ■ Game_Event; S  l- K* O/ ^: q0 O
  2346. #------------------------------------------------------------------------------6 ]" w, ]! y3 s
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。! J( ]: W& A& D5 Z  L4 j) Y
  2348. #   在 Game_Map 类的内部使用。! z2 T  ?/ R1 J. r/ f( Y0 ]
  2349. #==============================================================================
    3 S5 A+ u- U5 h3 `- b" D- S
  2350. class Game_Event  Game_Character9 i6 _! y% A9 }% e
  2351.   #--------------------------------------------------------------------------
    8 g4 j, M2 D# r3 D6 `6 ]
  2352.   # ● 事件启动0 B. x- G7 {$ y6 ?5 f, l8 d
  2353.   #--------------------------------------------------------------------------
    7 C2 l1 g, \; e; |2 {
  2354.   alias sion_mouse_start start0 v# Z3 e) S; p/ |2 e* q. x' ~
  2355.   def start
    5 x# B2 R/ s$ S: _
  2356.     return if mouse_start && !Mouse.press(0x01)
    + B) q) X* C" Q; E$ C7 v- B% F
  2357.     sion_mouse_start) k/ r' N4 V! D
  2358.   end
    5 I* H6 C9 X% }7 p, Z
  2359.   #--------------------------------------------------------------------------$ V& X* R8 G( g. C, A3 U( I
  2360.   # ● 判断事件是否由鼠标启动& L9 s$ Q2 H2 q, G8 m; _: m
  2361.   #--------------------------------------------------------------------------" L* \: f; ]8 N# u8 `$ m2 x2 ~. s
  2362.   def mouse_start
    - q4 F. L/ p- j
  2363.     return false if empty
    . J5 h0 {5 Y1 y
  2364.     @list.each do index3 @" }1 `" ^7 u+ W# [. [5 E; r, b
  2365.       return true if (index.code == 108  index.code == 408) &&
    # c! r5 k. U9 D& X
  2366.         index.parameters[0].include('鼠标启动')$ ~3 r  G# k* D% S- l* E. k
  2367.     end7 c  y7 w4 b" ]8 j! @9 j; m
  2368.     return false5 @& I5 ^" ?) i& M
  2369.   end- V0 j* Y  {4 X
  2370. end) ^$ m' k1 }4 i* v3 v
  2371. ; H# W* u- p2 Z
  2372. ####泥煤的height
    7 I, n9 M0 I- o7 r  V
  2373. # @height = height1 v' n. L# }+ Y9 u8 ~/ J
  2374. 5 [, E! r, y* O) e! O0 ]- f1 F# E0 l
  2375. class Area_Response
    5 l- @# h( E  _0 U' R0 E, B! G
  2376.   attr_accessor type! o9 q* \5 }8 [3 r# q! u- V0 S+ p
  2377.   attr_reader ox& ]% x9 \  n; N( `  m
  2378.   attr_reader oy6 b$ U9 F! L, ~1 c% T, a
  2379.   attr_reader width+ q7 |1 q) P3 p; N6 g$ D7 o
  2380.   attr_reader height
    # b; W2 [* j% Q5 x% M. k
  2381.   attr_reader switch_id
    # i5 m' |2 m1 L3 E. J
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)# Q/ L+ P/ v; Q# z2 q% y
  2383.     @type = type
    2 h7 F* \/ S2 O2 {
  2384.     @ox = ox& }; f( Y* b/ W$ a
  2385.     @oy = oy
    % e2 V3 @- s5 n, ^- O
  2386.     @width = width
    5 i- l+ _6 N% P0 E3 E! g
  2387.     @height = height& ?9 H8 g0 l% T+ h1 z4 ^
  2388.     @switch_id = switch_id# j  v' T8 ^! h: J& R/ `
  2389.   end( u. J. N) P# [) l) U
  2390. end# f/ E6 M* _5 _; p% U  k' Q1 Q
  2391. ) J  A4 g& w. Z: z: s' z( p
  2392. $area_responses = []& T9 r. s3 {! t( z; L0 C
  2393. $ `; W! {3 c- K6 a4 j* A. _; `( z
  2394. class Scene_Map( a' h& p# D7 B( w7 S" J
  2395.   alias update_mouse_2013421 update_mouse_action& |, _) Y( S8 v" m/ I
  2396.   def update_mouse_action* R* l2 p. h2 w" S/ f! Y0 {
  2397.     update_area_response3 T/ P" {/ T- M" B3 N4 }" w* [
  2398.     update_mouse_2013421
    / R/ v9 s% w; j
  2399.   end
    8 G0 ^; \) P% e+ I" t( i- m3 ~
  2400.   def update_area_response
    ; v# z: m: a) ]" w
  2401.     responses = $area_responses
    . L' C& G) B5 m3 c, e
  2402.     responses.each {response
    8 }) R1 j" }. ^
  2403.       ox = response.ox1 o* U' F" t8 {! R& R7 v" w& h
  2404.       oy = response.oy
    ' F6 R. N& @) O. t) Y* t. {1 ]4 l
  2405.       width = response.width
    5 f+ g, [( w2 `) g
  2406.       height = response.height% L* d4 o3 U& ?; J; D$ v
  2407.       switch_id = response.switch_id- ^$ X6 b1 M4 n1 C
  2408.       case response.type
    ! S* M3 I$ c, B5 @+ ?2 }9 P
  2409.       when 02 W$ n, I9 q  c: A; I
  2410.         if mouse_in_area(ox, oy, width, height)
    % K9 y, r9 y( M7 n- X
  2411.           $game_switches[switch_id] = true# V: p; U$ l8 t) r  `
  2412.           $area_responses.delete(response)
      n4 k2 k6 |$ x; i
  2413.         end
    . U/ Q/ P7 e/ E& y2 \0 c, [
  2414.       when 1
    ! T7 v3 _- g1 r9 i9 I) B. u
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    . a2 Q  P$ `8 I9 @' u
  2416.           $game_switches[switch_id] = true
    ' t6 g2 t% o3 a3 ~6 {5 L
  2417.           $area_responses.delete(response)
    - o3 J, {/ ?' w# R  M0 N
  2418.         end) X1 T7 v' H5 O( U7 K# d
  2419.       when 2; w2 s. J) y. f5 W# f
  2420.         if mouse_in_area(ox, oy, width, height)
    * H( v" W) y  Q  j! b/ I
  2421.           $game_switches[switch_id] = true0 [3 d1 p! E% U& |  u# m6 d
  2422.         else4 s) w, q& v& e) j3 \( x: T
  2423.           $game_switches[switch_id] = false: x+ G4 ~6 F  @7 k
  2424.         end9 L/ W: s# p" |6 @! x* a; j
  2425.       when 3
    9 i  i4 I( X6 Q% M* ^$ K! v3 p+ b
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,/ Z. f( ?( c' N3 G5 t  k
  2427.             (oy - $game_map.display_y)  32, width, height)
    + |8 I9 W4 R& a2 P1 [. l5 g
  2428.           $game_map.events_xy(ox, oy).each {event: _$ c  W/ S- n8 n6 ~
  2429.           event.start
    - w) w5 x8 a: }* z
  2430.           $area_responses.delete(response)
    * u. V! e7 f) T( v7 e' _
  2431.           return! m6 c. A- S/ a) g. l+ _
  2432.           }
    " B/ z. J* a3 u7 D8 P; j
  2433.         end
    , `6 R0 M7 Z5 @9 |
  2434.       when 4
    7 G3 V- D( U+ u% K; X* e% y$ G0 K
  2435.         if mouse_in_area((ox - $game_map.display_x)  32," s: `7 s( }. _& ]" g+ u
  2436.             (oy - $game_map.display_y)  32, width, height)
    : ^6 M( V3 E" Z* _0 Q; G- U4 ?% g6 d
  2437.           $game_map.events_xy(ox, oy).each {event+ F6 T  X: O# G$ F( X' H0 h! h
  2438.             event.start
    % H% U, N$ e4 z. S. |
  2439.             return
    . L' e6 N( r1 P+ v
  2440.           } 7 O4 w1 f  ^- V: B+ x* L) }
  2441.         end# W* w* l$ x3 g5 j. o! l  Z
  2442.       end8 W- u# ~' ~- p0 I# A+ ~2 m  H
  2443.     }
    1 x7 P- a/ H& Z
  2444.   end9 T" D4 C2 z, e
  2445.   def mouse_in_area(ox, oy, width, height)
    0 n3 U+ ?/ [" s- {: U
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    & O3 I( }4 `) p; U9 _
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    1 {6 m: }9 L; L8 a- t1 S
  2448.   end" ~% \. C  i5 |) ^7 q
  2449. end
      Z/ f! E+ ~; ?0 U
  2450. class Game_Interpreter
    % G" |0 M7 z. B5 W0 s' ]
  2451.   def area_response(arg)
    2 s- ~$ r* c+ X4 U4 j1 C  X. h
  2452.     $area_responses.push(Area_Response.new(arg))
    & H# K: Y7 r& V( l& `8 d
  2453.   end
    9 z) s( u, L, T( ?7 O
  2454. end  p" [% _  Z3 ]4 t+ S
复制代码

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本发帖返回顶部