查看: 810|回复: 0

存放腳本

[复制链接]

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

贵宾

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

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

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

×
純屬給LBQ腳本:
  1. =begin #=======================================================================
    0 N% J( {4 H  s; f7 ?( l

  2. % D( f( Y. w; e6 `# S- r
  3.   Sion Mouse System v1.3e7 X' l( O3 y; e' T. x0 S- ^
  4.   - o: b* L/ u3 t% ~$ [2 r
  5.   Changlog2 K( g0 O6 z/ n( \# H7 a
  6.   & `2 y6 z/ S  u4 e+ Z" A
  7.   2013.4.21 v1.3f3 H$ |/ [$ o( M- O5 I
  8.    
    ! X& E' C/ `7 O- @& x
  9.     1.3f 卷动地图 bug 修正" [  j( \% _+ y- K& C! X
  10.     1 o* ?; w' B6 y1 ^& Z
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    ; L" e9 v- j' ~3 V& f3 {4 [; u
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内+ {, L  O1 O2 z* V4 S8 @
  13.                               Mouse.unlock_mouse_in_screen 解除锁定! u/ d2 j. O$ }4 e0 R( A2 F6 S$ W
  14. 5 u# z9 k8 i0 R6 S9 D5 x$ I3 i2 A
  15.     1.3f bug修正
    + c' R2 I$ o6 ~5 @; y  {: V0 v
  16.   % S- p( E- @; E8 q( U' u4 }1 b* ?
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及$ [" z& `' h9 O* |
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    ( d& u& m. c* l3 D% ]3 A7 m
  19. 0 L7 `0 r5 N' J. U
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    % z; ]  l2 c7 L/ G) d3 {
  21. + K% r* \( C1 G' M: B5 g+ f
  22.     1.3b 修正一些罕见的bug;+ R6 G, ^1 S. i

  23. 1 R* S; j9 A$ g) `, m
  24.     1.3a 代码小修改;
    " c! m% C+ m/ ^/ O4 }
  25.           加入了鼠标点击启动事件的功能,1 D4 n/ t& p/ V
  26.           在事件中加入“注释”: 鼠标启动  ,: N: p' ^: k- N2 N
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。& C4 q$ l( M' X7 ~) b  N4 C$ a7 F0 E* @
  28.   
    ; N3 A  |( M1 i2 w0 G  ^. U, r
  29.   2013.2.12 v1.2/ L7 R# L, X5 z$ F

  30. ) t9 o$ U5 v+ r- ]2 T. }
  31.     寻路逻辑优化;6 C) {2 A5 A5 g
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;: A+ T  _+ J) m. z9 Y1 K6 r
  33.     现在支持用鼠标来操作载具了。1 G: |# `: x7 Y; w  u3 V

  34. # H' n2 U& `1 ]% @/ U9 k
  35.   2013.2.8 v1.1
    ; t2 q0 E3 q$ x7 C2 u0 p/ A
  36. % \' d, ~' ~6 z# A" \/ i) [6 t  Q
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    9 _7 L( M+ B' c4 ^9 T
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    " q1 }- Z$ l( L" S, V
  39.     移动时,路径指示点的绘制更加稳定;  T, w+ z  T/ M6 L. F7 A& ~/ W
  40.     现在支持默认存档画面的鼠标操作了。
    * P5 x0 m4 f3 P5 e* b1 z1 s

  41. , `" t9 Y2 _  J, n& @' O/ c
  42. 7 P6 o, H5 {: a: s) r8 P, V) m
  43.   OrigenVersion
    + U: A6 g+ z3 K: E
  44.   
    ' u; I4 M  b% r6 G4 `& r
  45.     2013.2.7 v1.0 ! o& M9 {2 c( n& i0 ]

  46. 6 m, L* v6 r6 a! M1 w7 ~2 ]2 U
  47.   主要功能0 z0 ]  x! ?) P* [

  48. - t2 w# e* S: G; O
  49.       使用鼠标进行各种操作...0 D. I  f, z4 ^: X
  50.       将鼠标锁定在游戏窗口内
    9 n+ u7 n' Z! z3 M# {- K
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    6 ?( ?" F% p) A0 w) G' `
  52.       双击鼠标进行冲刺
    0 i/ u- C) K- c( o
  53.       更改地图卷动方式以适应鼠标移动" p% H8 U  A# K: X1 J
  54.       变量输入框改良
    0 j( A! f0 n  i! f# Q
  55. 8 d8 k8 O% q8 u5 X2 V
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    + t8 _  q2 v/ q  s4 }

  57. % y* M' @0 c7 r7 l
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹- Y7 w' N; F, ^, V
  59. & R; h5 B8 I2 _; B* T* q
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭! `* x2 E- w9 ]/ e0 z! x
  61.   {( X0 l- N  {) }; D
  62. & X, Z7 R0 U( ?4 j) o8 U' |
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★, j" r7 A" u% @3 V% d
  64. ! g% J! J. |8 A/ k! ?2 j
  65. 2 R: m8 _+ ]& T
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示, z1 J3 T! n0 M8 |1 J

  67. 5 [: o9 f* K' h, B! m
  68. #==============================================================================
    , [; M8 ^7 z9 r
  69. # ■ 常数设置 8 ?( P7 O" r4 v: \4 }; |0 ]5 k
  70. #==============================================================================! c' c" v: K5 `" T
  71. module KsOfSion
    % A% q0 R- J$ Z- @$ E
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    * O  t. a; _% X! \
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑, \/ g5 d8 c8 p
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    1 c. b% g8 j- f
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    " D% h( s: W4 R5 I" [. L+ Q
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    ' x: i$ P1 x  J8 }
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    + s/ V# X$ {" N/ Z
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)7 y9 D8 d1 }/ _0 Y. G$ z2 [
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    & v+ q3 v% E& a1 q5 K+ K( n" q/ T9 s
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)3 h3 `  n3 H( }# o5 @
  81. end3 A, {: D" `2 D) _9 _
  82. 5 Z4 `; T4 e# a- c
  83. #==============================================================================) M" W7 ^7 o* @, F, M
  84. # ■ 用来显示路径点的类8 j2 n6 d: T4 ~. `0 ?' T9 b0 U
  85. #==============================================================================
    , k, f% f4 z: I
  86. class Move_Sign  Game_Character
    . S' J3 U5 k6 T2 B" S1 N' J
  87.   #--------------------------------------------------------------------------
    " h: L0 v0 ?7 h$ \3 r% Y
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    & i0 H# G% S: f+ Z% F; n/ z
  89.   #--------------------------------------------------------------------------
    & Z. e$ E) g$ r8 U9 H
  90.   def init_public_members
    2 p1 v' H1 ~/ N7 l1 m
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹# K+ B8 a' l( n* H/ ^  I  G
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    / v6 ^+ K+ K4 S# \# K$ v
  93.     @move_speed      = 5        # ★ 踏步速度  r$ t# A( ^( K
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    6 q* \+ N) ?" K. S3 x5 j+ a
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度9 M) _1 m9 t* r( Y
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    : L6 K; P* L$ k. ~
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    + s, N8 G( M- u( @
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    : L( g2 l4 W7 `* ?6 F7 m% w

  99. / J! |9 Y, x" A: B' u% t2 S
  100. 1 K) D  o. {+ J& y. M
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★; B/ S; i. p% |' I' {
  102. 9 X" m$ m5 k$ G6 I
  103. 1 N6 ]5 S; c; U; U
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    % F1 L: B2 K- Q3 f3 ], R
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')+ h: }$ E* [7 B# w* D) }
  106. $ l' I% k5 K; C+ i. `8 ^
  107.       if $no_arrowpic_warn: J) z! s6 V# ]6 m. `
  108.         MouseShow_Cursor.call(1), [9 y, n% j% u3 {" ~9 G
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    $ Z% ]+ o! ~% y" @4 e8 \
  110. . \+ q0 n8 U4 e4 o
  111. “路径指示点”将使用游戏自带图片
    / l5 Q, U# g4 s3 w0 |, s$ O8 H
  112. + [8 _, K1 c1 v
  113. 该提示可以在脚本内关闭')
    2 }- I  s8 b9 S0 m
  114.         MouseShow_Cursor.call(0)7 h6 _4 A+ W! z( ~+ @% e8 `( k# T
  115.         $no_arrowpic_warn = false
    $ |  d7 {4 ~8 C7 S/ \( g/ |9 u
  116.       end- P: ]4 J' r( X5 c! Z6 \) Y4 O
  117.       @character_name  = '!Flame'8 f* l' ?9 ]' c" }, q( r
  118.       @character_index = 63 Z6 Y8 M0 I' ?0 f) i0 |1 H2 w
  119. + ]6 }6 f3 k8 F, Z" o( J
  120.     end: z8 j7 l, N' p; u7 l3 k) Z
  121.     @direction_fix = false  # 固定朝向& n. c% g, ]0 l6 W8 f7 e
  122.     @move_frequency = 6     # 移动频率. H0 V% Y* U2 X9 P5 M
  123.     @walk_anime = true      # 步行动画
    ; H2 m* o- O$ P# f& h
  124.     @pattern = 1            # 图案
    7 Z* B8 @3 R) N" }# V; B
  125.     @through = true         # 穿透
    0 W  k& N: @; B9 h  u
  126.     @bush_depth = 0         # 草木深度; U8 u3 A* u- K9 m8 D; N$ t$ u7 }
  127.     @animation_id = 0       # 动画 ID2 f0 x1 r: O4 k: K( x! _2 O! j4 }. w
  128.     @balloon_id = 0         # 心情 ID
    + w4 _; ~+ w/ `4 ~7 q9 ~" Z
  129.     @transparent = true     # 透明( ?6 J* ~. s+ U
  130.     @id = 0
    + `6 Y1 t  v1 B8 o  R9 O
  131.     @x = 0
    " e% M9 Q7 i, M  J; c
  132.     @y = 0( \0 M* t% R- D) }. F8 a) d4 \" K, o
  133.     @real_x = 0
    . A5 @/ c; j$ R2 y* G# W
  134.     @real_y = 0" I' n% Y7 N! u6 q- l8 N9 b
  135.     @tile_id = 0
      k  u' y9 T  m+ R3 v. q
  136.   end4 K, m' ]: |0 X( p: X
  137.   #--------------------------------------------------------------------------
    6 Z- M- @% B* ^$ _
  138.   # ● 定义实例变量
    2 k1 V( X. ?: B2 u3 D
  139.   #--------------------------------------------------------------------------
    . v  _$ }" E3 L
  140.   attr_accessor direction8 Q* j9 x1 b3 {0 E) |& R: l
  141. end
    ! I9 ^& f$ g5 G- }  B$ V0 _& s' X- y- h

  142. 0 e, ^* o, j' c( E8 A
  143. #==============================================================================
    ) F  F% W, x( x9 Z5 p( @
  144. # ■ Module Mouse: h4 y% b& u1 |
  145. #==============================================================================' N! W* n8 [3 x3 d  r$ b3 s! f# A
  146. module Mouse' D4 d4 ~: h6 O1 B) ?
  147.   #--------------------------------------------------------------------------
    9 a% P  m3 r8 q1 ]3 l' H. T7 n
  148.   # ● API
    - f. j8 M( W, c4 d
  149.   #--------------------------------------------------------------------------' U; C4 {- [8 ~, |/ e; R3 b! S
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    3 r. f9 `  I: k1 ~! A$ q
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    , Y6 I, `7 m/ z$ X% E3 A
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    5 c/ l: \" N$ c+ x3 |; l3 j6 j8 ]' w
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')5 ]) y, B  V5 w
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    " M; P. ^- S% e9 g
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')! N$ q9 }; R1 q  U
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    ) Z- Q  `. I  N% P
  157.   Window_Hwnd       = Get_Active_Window.call
    ) @* H" J% n6 d( T* J# o( e
  158. 5 q0 P* ]) i9 x+ h& p+ M
  159. class  self+ U# h' \/ C# Z$ x: r; @' `4 x2 O
  160.   #--------------------------------------------------------------------------/ V8 ^) e( l% o( m4 d& [# X; }
  161.   # ● 初始化
    ( l$ ^/ \1 s1 m# ?
  162.   #--------------------------------------------------------------------------
    0 q& t" D+ Q7 h' I# c' v. s4 ^7 n
  163.   def init) y$ r3 L1 G+ w. w; m) d
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor, P; @! _8 f% U( O- O0 H
  165.     @left_state = 08 f/ K! e6 n6 r" D$ I. i
  166.     @right_state = 04 r5 a% l; G& `+ l* o, ]
  167.     @ck_count = 0 # 帧数计,单击以后从0开始$ v5 J; r: R/ n
  168.     @dk_count = 0 # 用于双击的判定
    ) w- p. i5 y7 F5 L/ g
  169.     @clicked = false
    8 j$ U% O3 L* C$ t: {
  170.     creat_mouse_sprite% Z: m! [" f- X( D5 |% j3 d  \5 `$ d) g4 k
  171.     update
    9 R* |; @% D- i
  172.   end1 Z6 p- `: D' X5 a" N4 {
  173.   #--------------------------------------------------------------------------
    + r  [2 P( E' L- [) B$ @3 H; t' S
  174.   # ● 鼠标指针精灵3 E9 h" k$ E" T: P
  175.   #--------------------------------------------------------------------------- Z. W, F8 {: L0 B3 k8 e0 T4 S
  176. #~   def creat_mouse_sprite' r+ W( }: U! i: `* i' `+ o
  177. #~     
    / D6 z% [5 `" R2 _: v5 ?; [
  178. #~       @mouse_sprite = Sprite.new
    7 O! t* Z3 v( n! g0 b( @; U
  179. #~       panda = 2#rand(2)+1$ w" W# M* h5 }1 P' y, I

  180. ! p3 D8 e, a7 e/ G
  181. #~      if panda = 1" }7 O5 z( z$ v) \  e6 R) X
  182. #~        if File.exist('GraphicsSystemCursor2.png'): @7 }8 z  h  Y8 o
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')* ^% e$ d9 Y+ E, G0 x7 e
  184. #~        end#with if File.exist* Q' t  w' @; u* x* J1 M, |: j$ W
  185. #~   
      z, ?/ p, e9 x  @- s
  186. #~     else if panda = 2 #with if panda=1+ n# d4 f% ^+ J% A0 G/ @: h
  187. #~      
    + {2 o! x8 N+ T5 ]* p% h4 ?
  188. #~      if File.exist('GraphicsSystemCursor2.png')) E2 h7 X8 @7 v9 H
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    / O" F/ Z2 m5 p& _7 C4 a
  190. #~      end#with if File.exist
    - F8 o- G7 c; @: Z2 K3 `: {  C
  191. #~       * ^: k% h2 U: D8 V5 r0 n
  192. #~     else #with if panda=1
    & U. ]; d" e6 n- F, ^6 T$ |
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    7 g5 n0 z+ L# U2 F
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),+ t+ T  r: I3 M- t  o) ^  _
  195. #~       Rect.new(5  24, 24  24, 24, 24))" j! V; r$ U; W" s/ @0 \, _
  196. #~     end#with if panda=1
    ; ]" K( i6 D8 u( |) f; Q7 R
  197. #~     4 L9 b) R& M8 i3 u0 P
  198. #~     #with def
    " r! M! Y, |  N/ e; W9 @
  199. #~   end
      k& w1 i+ {$ W% Z8 h% M- v, M
  200. def creat_mouse_sprite
    4 C# E6 b5 F# B
  201.     @mouse_sprite = Sprite.new0 P- G: E4 m. Z. v% F6 i
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    0 C* Q# r4 t/ Y* x, o( \0 O( H# k
  203.     @mouse_sprite.z = 9999- B. S% F$ Q+ W) P) Q
  204.     Show_Cursor.call(0)% X5 d3 t2 d( N/ j5 g4 C: q
  205. end
    + F1 D& E4 D" \0 P7 K
  206. 7 N( A9 r0 L* k" U) W
  207.   #--------------------------------------------------------------------------
    7 F' s7 q2 W9 d. J( D! ~
  208.   # ● 更新
    : d$ g/ o: m- A% z( n5 O& W
  209.   #--------------------------------------------------------------------------# R5 W; _' i1 L7 n3 ]
  210.   def update
    5 _$ f) E1 Y9 w. H4 ~2 p; V
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos6 ^4 ^1 `. C+ |) s5 I4 x
  212.     left_state  = Get_Key_State.call(0x01)# G7 K# _( W% c5 a
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0' ~9 l7 e* F' _- ]- {
  214.     right_state = Get_Key_State.call(0x02)" q% n- t# P% c9 j; n
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0! L; f8 ~+ h! P7 _
  216.     update_double_click
    + P3 C- M2 ?4 A0 g
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    + V0 P  K+ Z/ M9 j* f
  218.   end' R2 V( \% m% Y% @3 X) P
  219.   #--------------------------------------------------------------------------' S' A# P& S& O% p3 I$ U& [
  220.   # ● 获取鼠标坐标
    9 u- r) k/ H8 q: |
  221.   #--------------------------------------------------------------------------
    $ Q6 J* n( W$ U$ [
  222.   def get_mouse_pos9 I# G5 l& V3 u0 R* b1 P) j6 N
  223.     arg = [0, 0].pack('ll')9 U: _' `6 z: a' O
  224.     Get_Cursor_Pos.call(arg)* M0 ~# k. @5 A
  225.     Screen_To_Client.call(Window_Hwnd, arg)2 {: m7 C5 C0 {# H
  226.     x, y = arg.unpack('ll')
    4 ]+ w* e, o: E! \3 l! ]/ c& E
  227.     return x, y
    ' w/ D$ _4 \7 q, `
  228.   end; r2 P( |/ ^1 {3 j6 _" c
  229.   #--------------------------------------------------------------------------( e3 c* o) T3 w4 }  m. v- Y
  230.   # ● 将鼠标固定在屏幕内
    + [7 q9 A# M! w- F  a7 [
  231.   #--------------------------------------------------------------------------
    $ e2 x8 S* M, R7 P8 w9 A7 k1 C0 e
  232.   def lock_mouse_in_screen
    " {7 w' K  l. L1 P4 r$ I. Q- F
  233.     arg = [0, 0].pack('ll')+ J1 q+ K' P) d8 J. m) g
  234.     Screen_To_Client.call(Window_Hwnd, arg)/ l9 Z* s$ w7 p& [( [# ^
  235.     x, y  = arg.unpack('ll')5 q, W7 @- \/ N) K, k# Z$ {
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    ) `% b% C# l" J* }/ ?
  237.   end
    ) ]  ~2 x; x( o8 Q( O
  238.   #--------------------------------------------------------------------------- X& N' y( S6 G; J
  239.   # ● 解除鼠标固定
    # q+ y8 k7 q. M
  240.   #--------------------------------------------------------------------------5 w2 W5 P" a! R! {
  241.   def unlock_mouse_in_screen9 F# O: w. ]5 N
  242.     Clip_Cursor.call(0)! `7 }4 P6 f" W
  243.   end8 g% l& |$ X6 H* u
  244.   #--------------------------------------------------------------------------; e- @; P& h& a( y" R
  245.   # ● 鼠标双击判定# }8 H0 R8 @! Y9 t5 a
  246.   #--------------------------------------------------------------------------
    / w+ ]  p! N5 p7 z# O! M
  247.   def update_double_click0 P5 T' P: g6 K4 W0 ^
  248.     @clicked = true if @left_state == 1
    / }' F, h1 k  W# g
  249.     if @dk_count  0 && @left_state == 1
    . Q% L% o- X1 P% h9 ]0 o; {
  250.       @dk_count = 0; @clicked = false
    - h' q' h, M" V2 |" c5 l
  251.       return @double_click = true
    4 ?' l' Q3 V4 |. ~
  252.     elsif @clicked
    4 j, ^8 C0 y/ G3 f+ N3 _. o% t
  253.       if @dk_count  KsOfSionDbclick_Frame
    8 }/ H9 U0 h! m# Y2 w! n
  254.         @dk_count += 1
    6 q( h; D$ p6 ~5 c% J& g
  255.       else1 j# a# t, f2 E
  256.         @dk_count = 0; @clicked = false* n. Q- \' g, ?8 |! A) K, {) l
  257.       end
    ' d2 v( f3 N% C1 Z4 K# h
  258.     end
    ' ?2 E8 |% r9 m8 `3 n0 |4 ^7 d
  259.     @double_click = false3 \* F( v' R9 d" t
  260.   end
    # X7 ~* Y2 x4 m; R# m* l
  261.   #--------------------------------------------------------------------------
    : y4 f+ f; D* `  D7 y
  262.   # ● 按键被按下就返回true
    5 t5 u4 E" S! T
  263.   #--------------------------------------------------------------------------/ u7 m1 q, u- i# F
  264.   def press(button)
    " Y( L" a% _. E& M, [1 U' s
  265.     case button- s. n: d  G2 a; G- s) U' ]" L
  266.       when 0x01; return !@left_state.zero
    4 G5 }, E& w) ]/ e
  267.       when 0x02; return !@right_state.zero
    % j# P" y7 Y% ?$ Z4 P
  268.     end
    0 Z# b" @. G! K4 p( X
  269.     return false/ Q, w- k" t( Y5 p. E7 ~
  270.   end& c0 b0 l+ z9 w! I) D' O
  271.   #--------------------------------------------------------------------------/ n& A: }& V% D% E9 X6 v! @
  272.   # ● 按键刚被按下则返回true! s9 l9 F# S+ q9 f
  273.   #--------------------------------------------------------------------------
    ' M+ A! N0 l7 ]3 V1 y
  274.   def trigger(button)
    ; N6 L2 X+ E: g( W1 q
  275.     case button
    / {( a9 h+ [! Z9 Q" U$ X9 _$ K5 B
  276.       when 0x01; return @left_state == 13 Y1 W3 O+ q8 I/ T
  277.       when 0x02; return @right_state == 15 `" m$ u* T) A
  278.     end
    , {( g' ]3 Z; T2 q- `3 C3 m
  279.     return false
    / l) a) @" E. }( d6 W
  280.   end% `" l& |' ]2 `3 V; ~  z# z- B
  281.   #--------------------------------------------------------------------------
    2 p* \2 o# |6 R' z4 k7 I
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true( N4 ^' J' L7 K, R$ e# F
  283.   #--------------------------------------------------------------------------
    $ z0 v+ h9 p& y! `: X1 r" }
  284.   def repeat(button)- B1 l5 Y0 ~+ L9 V7 ^) d9 \3 ~
  285.     case button) n: n& D6 y: g; I- h* k
  286.       when 0x01; return @left_state == 1
    ) C# n7 A, D" c' G$ x
  287.         (@left_state  22 && (@left_state % 6).zero). C# |, B) [9 g3 q; v( p$ c: U/ o
  288.       when 0x02; return @right_state == 1 + f* Y; ]" c& X8 l  M1 R% D
  289.         (@right_state  22 && (@right_state % 6).zero)
    ! x3 f$ {; G1 ~- i% z
  290.     end
    1 A$ V9 ?$ t# z
  291.     return false* s( }& `; C9 `" X% Z2 ^7 ^
  292.   end
    . i8 @9 r& f6 z; s" J- W* y0 N) a
  293.   #--------------------------------------------------------------------------. l3 x5 x. W* Y) x5 U
  294.   # ● 判断是否双击鼠标
    3 B# R5 p* j' X' L
  295.   #--------------------------------------------------------------------------' u! _) J# ~  a* \( E7 Z
  296.   def double_click3 @% y# G( L. q' \1 ~
  297.     @double_click
    * E& V5 B. N+ J1 T6 h
  298.   end
    9 B  Y& N+ ?* @7 S- x
  299.   #--------------------------------------------------------------------------
    ( o: m' f# `$ k8 j; H. M5 w) D
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)6 c0 F7 E' ^0 K4 \7 k
  301.   #--------------------------------------------------------------------------
    : p# u9 t( @% u2 U
  302.   def click_count
    6 }& ~, O4 X, n& T
  303.     @ck_count
    # u0 x0 u* i& y( V
  304.   end
    * R$ J0 I3 R- r
  305.   #--------------------------------------------------------------------------& e1 V; \6 H. G4 z7 O1 T
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    ! h3 b7 U& T+ L2 \* g
  307.   #--------------------------------------------------------------------------
    / ~; _/ h  K3 q  H( a/ v. u
  308.   def left_state
    . O+ v$ _1 `4 l1 ]
  309.     @left_state
    , v5 l- U9 D" ^2 Y* Y& l; G
  310.   end
    ) u5 m' p# N1 k7 @' z+ x! _
  311.   #--------------------------------------------------------------------------
    6 I$ C, l" {$ G( R+ @
  312.   # ● 获取鼠标的x坐标8 _# l, Y$ p/ b0 b3 f7 ]
  313.   #--------------------------------------------------------------------------
    2 p" j! y  w+ l- [
  314.   def mouse_x; M  X7 Y+ B2 J; F( U0 K# q# G
  315.     @mouse_sprite.x( Z7 y' R/ `5 N- R
  316.   end
    ' Z: e* Y& R  A5 l* {& Y
  317.   #--------------------------------------------------------------------------
    8 R/ v9 N/ M& _2 t8 p
  318.   # ● 获取鼠标的y坐标- u5 i" e* j7 W8 T' w. x
  319.   #--------------------------------------------------------------------------+ t) C, i0 V8 N. q5 ^
  320.   def mouse_y" m4 e5 o! w" |( V' U1 i( K
  321.     @mouse_sprite.y
      B' K  v9 w- S3 z
  322.   end+ Q/ o6 h) R& g7 k
  323.   #--------------------------------------------------------------------------
    : T0 w5 C! ]( ~7 _
  324.   # ● 设置鼠标坐标$ z  f  y9 ?  v* x* j" M0 \
  325.   #--------------------------------------------------------------------------3 j. O4 y) p( V/ u9 q1 [) K  \/ U, X
  326.   def set_mouse_pos(new_x, new_y); j$ t+ ~' a/ f4 k  ^
  327.     arg = [0, 0].pack('ll')
    1 n4 c6 U( s  a- _+ A& n
  328.     Screen_To_Client.call(Window_Hwnd, arg): ^! l% {4 ~0 ]
  329.     x, y  = arg.unpack('ll')9 K' g7 _1 E4 n6 P0 k
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)8 L/ r0 U' B% `8 \  l6 j0 E
  331.   end
    / |. H8 Z6 @! i; z1 q2 ~% E
  332. end #end of class  self
    * K$ e* i! T4 }4 h: D  y
  333. 9 w" v8 Y. {7 y, n, b3 R& C. L
  334. end# l6 m2 x; E  I

  335. ) ^  x3 z8 M* w; Z  _
  336. #==============================================================================4 ^0 o9 V3 W! [8 ^9 J5 r1 |
  337. # ■ SceneManager+ e1 M! B# F" a3 N  F( J3 w" Y7 e$ x
  338. #==============================================================================
    4 o- B: v" S! m2 ?$ t) I8 Q
  339. class  SceneManager2 z! W, Z4 j+ p0 x, S: f0 n
  340.   #--------------------------------------------------------------------------
    , k9 M( e% t/ U6 Q
  341.   # ● alias" r- L/ g& x0 S" y: E( |6 \* ]" b
  342.   #--------------------------------------------------------------------------
    4 J; G7 |& [8 i' N7 A
  343.   unless self.method_defined(sion_mouse_run)9 e8 |, t" v7 x& D2 c- S  ~0 @
  344.     alias_method sion_mouse_run, run9 @! S! ~' u3 `  N
  345.     alias_method sion_mouse_call, call/ W7 w0 X8 ?/ W( j! X2 t0 s
  346.     alias_method sion_mouse_return, return
    1 \3 `2 }+ x$ N; D! a; Z
  347.   end& E* L, Y2 m0 A8 A, M* g0 r
  348.   #--------------------------------------------------------------------------* V* [4 w5 O( [" A6 W
  349.   # ● 运行
    : T8 o5 L9 ^4 w6 \  S. v( l
  350.   #--------------------------------------------------------------------------" \* h* R! O, B- c
  351.   def run% X9 e0 r+ x/ ]* m; ~7 i3 m
  352.     Mouse.init
    ! {7 u' p! O4 q* W! \- C
  353.     sion_mouse_run
    " k% A$ F; G- [+ z. V- k* D8 {
  354.   end0 `, _' P+ k4 z
  355.   #--------------------------------------------------------------------------
    5 ~# S9 Y4 `: s, P* T* F+ l( f3 h
  356.   # ● 切换1 j7 I' o. x) M* |( H1 Y! e
  357.   #--------------------------------------------------------------------------
    3 h0 Q' c4 d( a' O+ t
  358.   def call(scene_class)8 n5 e- S: J2 g% V  g& V
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    & Q' R5 D" `& F% v" M
  360.     sion_mouse_call(scene_class)
    ( G+ t; U& Z5 P  t2 c4 b
  361.   end
    3 A: G$ A3 o3 e4 y9 N+ p% I
  362.   #--------------------------------------------------------------------------
    5 u' ?" @9 B. ?( V1 k
  363.   # ● 返回到上一个场景
    3 Y: G& K- D. O; z  ]
  364.   #--------------------------------------------------------------------------
    ; B4 n6 S+ f: P" s
  365.   def return
    / ?2 `- @; \6 Y# j4 u2 h" M3 H+ v
  366.     sion_mouse_return
    ; O5 ?8 i! z# o- `4 L9 K9 C
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    ; W% {5 Z8 n% M  n7 L
  368.       @scene.instance_of(Scene_Map)
      n8 L+ [3 Y3 k1 {$ V. a' D0 i1 z
  369.   end& l/ N) E4 L) m/ s6 i: d  k3 C
  370. end; k% g: V# `- @8 V  M  |

  371. ; U" \* ]& ^: @" b1 o. b0 c
  372. #==============================================================================; [2 |" m" \: p& J* B- g. P
  373. # ■ Module Input
    % Q3 n9 V8 x, {0 \3 W2 C1 r% n) o
  374. #==============================================================================% k& Y1 u" C/ k1 F" D
  375. class  Input
      ?& n( n$ \* I2 e6 F
  376.   #--------------------------------------------------------------------------
    ' m  b9 [% B- F" B* d
  377.   # ● alias
    ) I( R* q/ F1 k5 w( S- R$ B$ O# K* l" [
  378.   #--------------------------------------------------------------------------
    3 t3 F8 e& H& ^* r. h/ b
  379.   unless self.method_defined(sion_mouse_update)
      i* ~, p: G# \
  380.     alias_method sion_mouse_update,   update
    4 [3 G' Q+ z  s0 `  n& M
  381.     alias_method sion_mouse_press,   press
    * z! p, a- M+ X5 o- K0 U, X/ I
  382.     alias_method sion_mouse_trigger, trigger1 i2 v4 x: t3 o) Y1 w. @
  383.     alias_method sion_mouse_repeat,  repeat
    - G+ y1 ^9 {* ?6 q0 q
  384.   end
    " A; c0 f+ k$ ^6 K
  385.   #--------------------------------------------------------------------------! `' U3 F- e9 o: q( B5 T+ j. t
  386.   # ● 更新鼠标7 w# [* D9 ?. t7 D- E. a
  387.   #--------------------------------------------------------------------------
    4 Z# P, ~  s6 u
  388.   def update
    7 K4 i: M, Z2 V
  389.     Mouse.update
    , g1 z/ x; Z6 C4 ^+ N
  390.     sion_mouse_update
      M0 h# Q  z9 H
  391.   end; Q: u0 M% K, g9 t
  392.   #--------------------------------------------------------------------------
    . W. d; s/ y& s, B7 ^4 E
  393.   # ● 按键被按下就返回true! G2 M, N, i9 l
  394.   #--------------------------------------------------------------------------  `# Q& J9 B, M5 v! T
  395.   def press(key)- u) \  ?" e% e5 t4 r7 b
  396.     return true if sion_mouse_press(key)9 A7 n5 S2 _: X  Z0 w! T
  397.     return Mouse.press(0x01) if key == C
    * C- C! |) P/ B; Q) \, w% o5 \" d! M
  398.     return Mouse.press(0x02) if key == B
    9 Z6 C- w# B8 A" {% @+ x
  399.     return false9 l/ g0 ^* @4 e, S  d0 @6 S6 \
  400.   end1 _+ }! q, }; ]# t7 X& y' B3 c
  401.   #--------------------------------------------------------------------------
    ' G  r9 c0 e/ f7 y7 m; D
  402.   # ● 按键刚被按下则返回true8 o! S: r! W* U( R8 }7 z7 W' Y
  403.   #--------------------------------------------------------------------------- _) M7 h4 [; o, S
  404.   def trigger(key)
    - n! W5 R7 @* j8 p
  405.     return true if sion_mouse_trigger(key)
      n  A! p& s6 ?% Z% `
  406.     return Mouse.trigger(0x01) if key == C
    1 I/ n0 ]- F' F) M, g0 C) I
  407.     return Mouse.trigger(0x02) if key == B: m2 N# `: h5 T& m% s
  408.     return false( S1 M& g2 I, ]7 l
  409.   end9 s, d. i! M6 i8 A7 o
  410.   #--------------------------------------------------------------------------
    ) y1 ?! {  N; ~
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    , j! H9 K1 L* d, T
  412.   #--------------------------------------------------------------------------2 f* Z8 _2 W6 w  M# S1 l- ~* Y# _
  413.   def repeat(key)
    6 C/ h  [6 j2 i" d' |
  414.     return true if sion_mouse_repeat(key)8 U% n9 i; m& |
  415.     return Mouse.repeat(0x01) if key == C
    6 \4 Y/ o9 {' A" m3 `$ q$ |0 v
  416.     return Mouse.repeat(0x02) if key == B3 o6 g+ |: Z" ~6 C1 F5 h$ \8 Z- F# C! c
  417.     return false& C+ n( @) B& t4 ?
  418.   end+ ?3 [  n: o( x5 d9 U
  419. end7 }, C4 P  a3 f9 j6 b% ]0 e5 M
  420. & U$ l3 ~7 y+ z7 W4 W

  421. 4 x2 l4 [$ r9 ~
  422. #==============================================================================5 K% ]2 w% x# L5 h- H. Z; S
  423. # ■ Window_Selectable
    8 b7 }" l/ c2 f3 j! U& {. R
  424. #------------------------------------------------------------------------------
    " y+ C4 Z+ ]" v( d+ P$ t8 y
  425. #  拥有光标移动、滚动功能的窗口
    8 l* l# {, K. E7 x: m2 A4 k
  426. #==============================================================================
    : O8 v* L6 x/ j( l% S% k& v9 k5 Y
  427. class Window_Selectable9 g0 `7 c# f" K' r
  428.   #--------------------------------------------------------------------------$ }- s1 `# A  j; S; v
  429.   # ● 初始化5 p+ u: X8 \2 f2 V2 w) y8 a, m
  430.   #--------------------------------------------------------------------------
    # ^) m' @2 E- Z& J1 {! F) Q9 n
  431.   alias sion_mouse_initialize initialize1 R. f% J9 n# o/ E
  432.   def initialize(x, y, width, height)6 |, N/ \$ |! p
  433.     sion_mouse_initialize(x, y, width, height)
      f/ ?* ]  W0 P" [
  434.     @move_state = 0
    ) e$ V: _/ [! j8 e% z: P0 [; h( @
  435.   end
    0 x# I+ p2 F' k, r4 ^( _0 D
  436.   #--------------------------------------------------------------------------& H! k* }# Q& U2 j4 Z- C0 U
  437.   # ● 更新
    4 x8 L( ~9 g7 d3 b7 h- m0 ^. T) X" G
  438.   #--------------------------------------------------------------------------
    , `3 F/ |3 H4 i/ ]; s$ u
  439.   alias sion_mouse_update update
    " H8 x( |+ h' v8 G' w' o6 o
  440.   def update
    1 g3 n% V2 a0 g: Y4 m
  441.     sion_mouse_update+ V2 N- A9 o/ R* [) X
  442.     update_mouse_cursor
    8 O! m/ I( C# Q! V9 R& s# h7 x- |& _
  443.   end' n$ j& ]' x+ J# H5 ]( K+ m& h# O
  444.   #--------------------------------------------------------------------------
    3 g9 s- h! Q" ^" ]2 n0 J' c
  445.   # ● 启动后设置鼠标到index位置2 _: s$ G1 H7 n0 S5 K  g' d! C
  446.   #--------------------------------------------------------------------------* z1 Z: O% t$ H$ |" x% C1 _
  447.   def activate# {7 {$ F* W( g( J# `' l" @" E$ d5 R
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos. ?1 t+ u: q4 i0 E0 B
  449.     super
    8 Y5 D# @% v2 e, i
  450.   end
    ! B* k" ~; Q4 I9 E- h) m5 W4 L
  451.   #--------------------------------------------------------------------------) {' y) O5 U6 e! X
  452.   # ● 更新鼠标和光标的位置: Q# A/ D/ d5 ]  D6 x7 H+ k1 e: v
  453.   #--------------------------------------------------------------------------3 c0 F2 R, C) H% A% D2 ~$ P/ [0 c1 o
  454.   def update_mouse_cursor
    $ ^4 J! w2 b  q( ~3 ?
  455.     if active# V3 O+ U" N1 ^% ?0 Z
  456.       if @need_set_pos
    3 W! j3 G- F) N2 y& L, ]& ?# r- W
  457.         @need_set_pos = nil
    ! i2 O) S" ]% p9 z! u0 A/ r
  458.         set_mouse_pos
    1 t8 d, Q/ A) X- ^* \. c. S
  459.       elsif cursor_movable
    % d0 J( F% C* V" \* g
  460.         Input.dir4.zero  set_cursor  set_mouse_pos" i) \5 X3 A5 @3 f, W5 _
  461.       end
    - _$ D( T* x" i; i& R' Q
  462.     end. D: U: P" C3 `. v) d
  463.   end+ F$ ^6 F3 Y/ X. d
  464.   #--------------------------------------------------------------------------
    4 @. y: H1 I' `& s7 X
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    ( P8 i1 F/ l/ \3 u$ {
  466.   #--------------------------------------------------------------------------
    8 t( @$ @7 n3 K( {
  467.   def set_cursor
      n) `8 s! f+ A+ K
  468.     mouse_row, mouse_col = mouse_window_area: Y9 c2 y6 X% O. r) d7 m' M# v
  469.     if    mouse_row == -1
    2 u# _$ M8 h8 Z8 z
  470.       @move_state += 1 if need_scroll
    2 ^$ I7 H! u: Y/ z: W+ y' A
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ! u+ U' D/ f4 F, ~  B4 y# m7 P
  472.     elsif mouse_row == -28 e% B6 l  n: Q# l- E; B2 P
  473.       @move_state += 1 if need_scroll1 E, N/ t, _# Y; K
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    1 |5 f; s7 R6 \2 d& {
  475.     elsif mouse_col == -1. r4 X) v6 C! p2 m
  476.       @move_state += 1 if need_scroll. j! U# b' m3 t/ f+ @6 N( X
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand2 ^# W8 b+ Y; x3 b* e% {
  478.     elsif mouse_col == -2
    1 z1 D7 A9 h" H" o
  479.       @move_state += 1 if need_scroll
    . Q# G( s" Y/ a' y
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    3 B0 ~8 Q7 K; x. B7 x9 |+ M
  481.     else& s; h6 d' H8 ~; ?% m0 x
  482.       @move_state = 02 C# K  {# r! K+ V6 \  [' d
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    , E+ U$ f1 r" s9 Q
  484.       select(new_index) if new_index  item_max && new_index != @index5 _. H1 s0 e/ w  A
  485.     end9 W, `5 @8 p+ s1 E9 h4 v) P
  486.   end
    ! b- a, [9 [, s
  487.   #--------------------------------------------------------------------------
    # e9 s% P) l1 M. a5 x
  488.   # ● 判断鼠标位于菜单的第几行、第几列  b4 O% C7 a/ F7 \2 }5 n6 m0 z+ U
  489.   #--------------------------------------------------------------------------' @" Q7 w' ^: m' U
  490.   def mouse_window_area
    ; X% R; N' D* O( M. P( U; [
  491.     if viewport.nil # necessary!/ Z$ n* C( `5 Z' E# Z
  492.       vp_x, vp_y = 0, 0
    - b: G# t9 w, M2 v* C& w
  493.     else
    7 G+ N5 `  O7 t3 a' D7 X3 V
  494.       vp_x = viewport.rect.x - viewport.ox
    & a; p& A5 N/ H* ^6 s5 e/ e0 _
  495.       vp_y = viewport.rect.y - viewport.oy, L1 L- q* F$ Z5 V& J
  496.     end" M; R6 |2 u( g1 }! B% n
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y, P# v; R4 r  k% i4 s- e1 j. [7 q4 J/ m
  498.     item_x1 = vp_x + x + standard_padding ; w, O" O9 N) f# q, x+ v$ _
  499.     item_y1 = vp_y + y + standard_padding
    3 I, W3 g* j/ u1 s
  500.     item_x2 = vp_x + x - standard_padding + width
    ! B( y6 Q' g: h' z8 B
  501.     item_y2 = vp_y + y - standard_padding + height. G' u; v) M9 |
  502.     if mouse_x  item_x1
      O' W1 a% x( H& v1 ]( F1 ]
  503.       mouse_col = -12 x2 h; j6 {5 I2 w. m0 k% n- @( F
  504.     elsif mouse_x  item_x25 A3 I6 i# S& k8 x: n/ U
  505.       mouse_col = -2& a2 t; m. e5 a/ ?8 L* T
  506.     else/ ~+ m7 G1 j  F0 \6 l8 x
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)6 I7 Q1 w: U& X& c& p) r) }
  508.     end3 m  c4 k7 W/ S( w
  509.     if mouse_y  item_y1) }) ?! B+ |- W! t" e
  510.       mouse_row = -1  p5 G+ h/ T9 u4 D
  511.     elsif mouse_y  item_y2% M. z8 J, T: @7 o( ~) T
  512.       mouse_row = -2
    ( X/ y0 t2 E2 ]! a2 s+ w' J1 s% w
  513.     else
    ! W3 S* R& t" L' Q9 l% a( H
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    * C7 N7 W1 l; B9 J! j
  515.     end
    7 |, v! D' {* k  T1 F. r
  516.     return mouse_row, mouse_col
    3 T. S2 i0 l+ ^3 Y! c" F
  517.   end
    9 Y, ^+ `2 U" G- L: _( g
  518.   #--------------------------------------------------------------------------* ^( P0 F/ E" F& E3 S  j
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ' b- L" n6 q- c7 [( [
  520.   #--------------------------------------------------------------------------+ _- U4 G: s0 _( w0 B, j
  521.   def set_mouse_pos
    7 S# x( B  E( V' o' s; e0 N
  522.     if viewport.nil # necessary!; a7 x' d! |' w2 ~" ^
  523.       vp_x, vp_y = 0, 0
    5 t0 U. l/ B" C6 o0 j
  524.     else
    $ e  s; L* f6 H7 O; e
  525.       vp_x = viewport.rect.x - viewport.ox& n7 S: s8 v1 c& h: S) U0 _3 v) N
  526.       vp_y = viewport.rect.y - viewport.oy
    $ ]& p" z0 ~  x6 _+ n4 e* ^& T
  527.     end3 z* W9 J4 s% [6 `
  528.     item_x1 = vp_x + x + standard_padding ! `5 h% D/ ^6 H# q, U
  529.     item_y1 = vp_y + y + standard_padding
    ) Z8 ^# U  I' U0 `! f
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
      T" ~6 Q. d# B' r, B  n1 Z
  531.     row = get_index  col_max - top_row
    * k8 @( j$ Y4 R& r
  532.     col = get_index % col_max+ C- w: U/ A' p
  533.     new_x = item_x1 + item_width  (col + 0.5)
    7 z8 Y$ e" d2 D- `9 b$ I
  534.     new_y = item_y1 + item_height  (row + 0.5)
    * t# \5 }8 W  q# o6 L/ ]& d" `+ B" Y
  535.     Mouse.set_mouse_pos(new_x, new_y)
    1 o4 F9 N: C/ j0 c3 L3 z2 r: c3 k
  536.   end7 N8 R, M* w7 G. n4 X$ q/ B7 J
  537.   #--------------------------------------------------------------------------
    4 B0 P5 r: i1 q3 d: J1 I
  538.   # ● 判断菜单是否需要卷动
    2 V# |9 H+ ?. j2 e
  539.   #--------------------------------------------------------------------------, q. c( S, C9 Z
  540.   def need_scroll7 I) u  t# z0 C& v) j: }0 u* U
  541.     item_max  col_max  page_row_max+ _& ]3 n+ w- [; `
  542.   end
    4 B6 @! w% H" {) |$ N; @- O0 L
  543.   #--------------------------------------------------------------------------
    7 r) z4 \! Q, Z# W% G
  544.   # ● 判断是否为水平卷动菜单# t  Q* F5 |) P* v& D& a
  545.   #--------------------------------------------------------------------------
    & a! B$ H: m  a2 Y- }) R/ M! D
  546.   def is_horzcommand6 Q1 c4 x4 i( Z, u/ @9 w6 o+ o# I+ w5 K
  547.     return false: d; C- _+ s5 l0 v5 Y
  548.   end9 }8 e1 i" {! y! K3 h9 ~# N
  549. end8 q0 H. ~) S4 i

  550. / I* \9 O4 G0 Z' n
  551. class Window_HorzCommand# j0 v+ R$ e$ l. P/ T, o' Z  Y
  552.   #--------------------------------------------------------------------------
    ) @- p& B8 V& B6 B
  553.   # ● 判断是否为水平卷动菜单( p5 N& ]  A/ p, m0 V! g
  554.   #--------------------------------------------------------------------------( V, E! M0 d& q6 Y6 H5 Y& \* T
  555.   def is_horzcommand. F6 A6 C2 V) r- l) _; g
  556.     return true# |3 f- t2 M" z4 k/ y
  557.   end
    5 F1 w0 ?* d* }* L1 c( _
  558. end" Z! q# O: s+ h/ f) a
  559. / f' L0 U8 R9 }- Y! k% Z
  560. #==============================================================================
    5 z( A" t7 p8 ?7 }; T# n+ e
  561. # ■ Window_NameInput
    6 w6 B; I( L' \
  562. #------------------------------------------------------------------------------
    ' c9 b7 ]# n; P4 j
  563. #  名字输入画面中,选择文字的窗口。
    : J, o  `  ]' I/ K3 _0 `
  564. #==============================================================================
    . b8 p9 I) F# \5 x
  565. class Window_NameInput' }" S5 E( P, O+ t$ Q& q
  566.   #--------------------------------------------------------------------------
    ) Y! t0 N+ k) a. `4 X
  567.   # ● 设置列数0 m3 c1 E: ]( ]
  568.   #--------------------------------------------------------------------------, \! g1 m5 D8 p
  569.   def col_max
    + W, S5 I. W# ^5 y! i$ D/ G
  570.     return 10
    " ]& P" z/ M4 ]% G+ R+ l
  571.   end/ d1 Q# a8 j8 C% J) v6 r; G
  572.   #--------------------------------------------------------------------------" T5 j' U$ t3 [* a4 ^& E1 f* E
  573.   # ● 设置填充的Item个数
    $ r0 j' e5 i0 [  t  Z& h% @
  574.   #--------------------------------------------------------------------------& @  m& p6 c3 k3 _! {# ~
  575.   def item_max
    7 F& m$ y, p0 m" |- F( i
  576.     return 90, H2 g3 p  c9 X' M. N; A7 p2 g
  577.   end
    1 T0 O, W. V$ `! m. A9 ?
  578.   #--------------------------------------------------------------------------
    ; c- n0 w0 o2 W
  579.   # ● 设置填充的Item个数+ [" i& E+ @+ {: X' H
  580.   #--------------------------------------------------------------------------* b9 L8 y; |( `
  581.   def item_width
    % V5 k# R( w4 {% l7 U. X; ]$ U
  582.     return 32
    + g! V& t+ z( c3 ], z
  583.   end
    & ~* _0 E$ q% F% s
  584.   #--------------------------------------------------------------------------0 x7 H/ _% `- Q& w* P
  585.   # ● 判断鼠标位于菜单的第几行、第几列& h' I' z" i- o
  586.   #--------------------------------------------------------------------------5 |7 C; i; }8 F7 t
  587.   def mouse_window_area
    8 M: f# x' V( c! Q
  588.     if viewport.nil' z1 f$ B+ N& q1 f# z& _3 M
  589.       vp_x, vp_y = 0, 0
    * m5 ~7 |" }; Y2 S
  590.     else, M; ]  K" a+ {  U
  591.       vp_x = viewport.rect.x - viewport.ox
    4 E& a* M& t) [" n* s9 R
  592.       vp_y = viewport.rect.y - viewport.oy
    6 f4 z7 R- g$ [
  593.     end+ `' H* o: y  A2 }/ E( s
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y2 b) x' r, w8 }5 k% F9 l
  595.     item_x1 = vp_x + x + standard_padding , |( j7 `) r! G2 x9 G! ^* D
  596.     item_y1 = vp_y + y + standard_padding2 O( {! h# _! Q  l
  597.     item_x2 = vp_x + x - standard_padding + width
    6 z  J* s( u0 d( k( @6 t; q9 X. _
  598.     item_y2 = vp_y + y - standard_padding + height- j% U5 }  c6 Q5 F
  599.     if mouse_x  item_x1
    % o8 G8 a/ W- V8 u
  600.       mouse_col = -13 V( H$ b) M/ x4 h; b& O  m8 e' @
  601.     elsif mouse_x  item_x2: L% ]7 P8 N, V
  602.       mouse_col = -2( N" S1 O9 k7 M" H, A) s! P- I
  603.     elsif mouse_x  item_x1 + 160
    ; k6 t2 e' ]& u5 j4 `0 R
  604.       mouse_col = (mouse_x - item_x1)329 _2 d& k& W( W- u
  605.     elsif mouse_x  item_x2 - 160
    2 R% ~% l$ a5 j" ^; Y% c
  606.       mouse_col = 9 - (item_x2 - mouse_x)32/ C  s' E, S5 u
  607.     else2 U4 ?8 y# P" m! m# G
  608.       mouse_col = mouse_x  x + width2  5  4
    3 z: g* {) d  L6 v; [3 d- n
  609.     end
    4 r8 f4 N! W8 |6 o8 G" L1 o; t  [
  610.     if mouse_y  item_y1
    9 b" n' T0 v, B3 z3 a3 [
  611.       mouse_row = -1+ ~/ s; ~1 t- J1 E/ [; W, c9 F
  612.     elsif mouse_y  item_y2
    / \; v# ^3 B% r6 O+ e6 {. ], B; ^
  613.       mouse_row = -2  }# Q/ A/ s  g- X8 c9 A
  614.     else
    * R" x% j, v# Q0 F4 b
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    # w2 j( T! V$ G( ~8 n
  616.     end5 q# b( k7 E( y
  617.     return mouse_row, mouse_col
    6 \& \/ V  C4 P* }7 i
  618.   end$ \1 h. e1 O) J
  619.   #--------------------------------------------------------------------------
    8 V3 K# ], c: C& W
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    . Z& t: x% K/ g+ s8 e
  621.   #--------------------------------------------------------------------------
    7 O1 G+ w! ^0 |# u
  622.   def set_mouse_pos* t+ q! ^9 @& c: o! [' M/ x
  623.     if viewport.nil # necessary!
    , [2 S; V0 R. \! |" Y# ?) o" U
  624.       vp_x, vp_y = 0, 0
    4 l" k/ ^/ f9 o7 D/ C) n
  625.     else( z" y+ K, ?; G! q% E
  626.       vp_x = viewport.rect.x - viewport.ox
    - l, Q" N- z. ]) V8 P
  627.       vp_y = viewport.rect.y - viewport.oy6 y+ E  W5 F/ S! }
  628.     end* j! z7 A8 K. k0 B& O0 M- U
  629.     item_x1 = vp_x + x + standard_padding
    * C- ?0 |' ?8 x! K/ d. p
  630.     item_y1 = vp_y + y + standard_padding
    8 E, ?; }! R2 `: a6 G
  631.     get_index = @index  0  0  @index 3 l! Z+ _) Q4 c5 X4 N7 _
  632.     row = get_index  col_max - top_row) H$ e/ ]8 B2 I* r/ i% q/ u
  633.     col = get_index % col_max1 r" |* A9 h1 K" f- j+ G
  634.     new_x = item_x1 + item_width  (col + 0.5)! J- u4 ^) P" r. L" i% L
  635.     new_y = item_y1 + item_height  (row + 0.5). u5 b1 }7 |& r' r" Q0 _2 {
  636.     new_x += 14 if col  45 r- M: D2 X1 Z/ c2 u. Y; z
  637.     Mouse.set_mouse_pos(new_x, new_y)  l+ k' j( h( l. j  G4 V
  638.   end  |* f- O' ?% k9 s6 K; ^$ [2 n
  639. end
    ) d# A4 z' x9 w+ J
  640. 6 s! [$ k- p, [1 _8 c' j, j
  641. #==============================================================================7 `( b. I. G' ?1 L9 @
  642. # ■ Window_NumberInput
    $ D7 h3 i+ z; v: b: Q) b, T9 a
  643. #------------------------------------------------------------------------------
    3 n! q9 s% L5 z( `% R7 a
  644. #  重写了数值输入的方法以适应鼠标
      H% L0 J; e( |& m: q& }
  645. #==============================================================================
    ' T+ S: ?' u/ G1 |' `0 ?( ?2 G
  646. class Window_NumberInput  Window_Base
    ' Z: s% X' U9 I* A; E( ^
  647.   #--------------------------------------------------------------------------
    7 ^( r6 v  k% M+ F$ a
  648.   # ● 定义实例变量
    5 X4 q7 |$ J% ^- e
  649.   #--------------------------------------------------------------------------- l1 ~; b% W/ B
  650.   attr_reader extra_window
    $ D) K' V8 A: u8 [' Z
  651.   #--------------------------------------------------------------------------
    ) W2 Z" k) X1 `
  652.   # ● 初始化& v6 n: |2 U9 u  [- L) a
  653.   #--------------------------------------------------------------------------
    # V' s: j9 u) B% a- ^; p
  654.   alias sion_mouse_initialize initialize3 m1 a# ^9 n/ i( A# A7 `
  655.   def initialize(arg)
    % ?9 V' B! h; h
  656.     sion_mouse_initialize(arg)
    * G+ W5 t0 x" [" C
  657.     create_extra_window7 J5 ^6 M9 f& I5 ~; s' P& p
  658.   end  w# m! o9 c3 U, O: E5 d
  659.   #--------------------------------------------------------------------------: g8 F. g. H, y" |  I
  660.   # ● 启动
    1 o& @& U$ x" o. p: {
  661.   #--------------------------------------------------------------------------
    / r! h- a! {$ D% V; ?
  662.   alias sion_mouse_start start# U+ Z( E) a7 _- w. ~- h; F
  663.   def start' V) c# b' N6 Z' @
  664.     sion_mouse_start4 B% P) Q' h; @+ y; S5 U' s0 ?
  665.     deactivate, u$ b9 {. I8 E8 y) i
  666.     extra_start0 S% X4 Q# x2 P9 P1 u, y
  667.   end* S/ k) z: [; e  r9 O7 c3 s
  668.   #--------------------------------------------------------------------------
    2 ?, c6 ^9 i6 I, O5 [. @6 e
  669.   # ● 创建新的数值输入窗口& I* W5 o" c! L- M
  670.   #--------------------------------------------------------------------------
    " w) U; _  P7 O8 X$ v* I) m  Q
  671.   def create_extra_window) r/ H1 ~6 ]  M* u6 ]& X
  672.     @extra_window = Window_NumberInput_Ex.new
    8 K7 q, c9 @$ r: {
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2: {0 Q- I' N9 q
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    ! }8 |6 n0 p  O5 [3 Z4 R
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    $ s+ ?/ G. X) C; Y) C$ W
  676.     @extra_window.close_proc   = Proc.new { close }8 Y. R  o1 G$ n
  677.     @extra_window.refresh_proc = Proc.new { refresh }1 ^; z( B$ _8 G! J9 y0 `. V
  678.   end0 \6 S: Z- h: y9 w% a
  679.   #--------------------------------------------------------------------------
    7 S$ H/ V- I) G- F" w" T9 K/ R
  680.   # ● 激活新窗口' [6 v4 f6 s1 }  j
  681.   #--------------------------------------------------------------------------3 R# [/ A  D) S1 }
  682.   def extra_start
    - u8 q" v, o5 E5 M  q1 h3 w# f
  683.     case $game_message.position( |+ G7 }8 z/ P4 @9 g/ g" l* D4 p
  684.       when 0; @extra_window.y = y + height + 4- z) t6 A2 D, u+ j' z
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8& p" ]: w* ]9 s3 P7 L! Z0 G
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    : q7 k6 W, g' h# y. J
  687.       else  ; @extra_window.y = 8, Y4 {  Q, M$ w9 S4 e" a8 t
  688.     end
    . m. J2 I1 ]9 e8 q2 y& W/ h6 Y
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    * Y9 n& b4 p3 V4 M, z
  690.     @extra_window.digits_max  = @digits_max
      h2 ?: t7 v. l  d2 {: C& M
  691.     @extra_window.number      = @number
    - s  }) C7 N: m4 K0 d; M* l& S- I; e
  692.     @extra_window.open; _; J' o6 {- G0 Z0 g8 E& }
  693.     @extra_window.activate1 E  h9 O0 @9 }$ n" D
  694.   end* P+ y1 _5 ~9 h
  695.   #--------------------------------------------------------------------------
    % J! O! U( i. i/ h, P4 U4 Z( e7 C
  696.   # ● 更新
    : V+ G3 }% m  ^, z3 i
  697.   #--------------------------------------------------------------------------
    # U  I- k  ^9 P( O# ^
  698.   def update. L! o3 I5 G) L" u6 L3 G& V
  699.     super
    % s3 o2 r. l9 E& K; @5 ~/ ~
  700.     @extra_window.update
    + n; Q- v4 z+ X$ l+ R  ?
  701.     update_cursor" W. U9 Y" t- x6 ?
  702.   end9 G. B, I3 H) c7 h8 z6 V9 W  ~% |" Z
  703.   #--------------------------------------------------------------------------5 J. {% C7 E( n1 b) D9 j$ F
  704.   # ● 关闭窗口
    8 O6 W- H/ v2 x! g
  705.   #--------------------------------------------------------------------------
    , o/ X- t( Q) l5 w( [9 \5 |
  706.   def close" c) _( [' y* j4 n$ n, k4 w) U
  707.     super: U8 ^2 c9 A6 @" E4 g
  708.     @extra_window.close1 }0 t; ~. L8 ~" I0 @
  709.     @extra_window.deactivate
    3 I0 R: p" @9 }  J
  710.   end
    . j: T! Z+ V% ~7 y; a$ G. _
  711. end! X& }0 m2 D( b6 H+ a$ Z

  712. 0 ]: q) ?5 M' z/ f8 _( J- d9 ]1 B
  713. #==============================================================================# h( j, C% b7 t# e* q$ M/ k
  714. # ■ Window_NumberInput_Ex' Q% \1 I) o2 @  S( v
  715. #------------------------------------------------------------------------------7 ~7 Z1 w. L1 [; i8 \' T7 v
  716. #  新的数值输入窗口(NewClass)+ W! F1 v9 q" @5 F) U2 c: Z
  717. #==============================================================================2 i  p; ^; b, }1 t' p1 d
  718. class Window_NumberInput_Ex  Window_Selectable: t- W/ c5 g, Q; ?9 G
  719.   #--------------------------------------------------------------------------' u0 K2 V' U2 b# M3 N, s0 f
  720.   # ● 定义实例变量" I' N! F7 M, |/ @; _8 U
  721.   #--------------------------------------------------------------------------
    2 q4 P5 M( O3 E9 W; @
  722.   attr_accessor number_proc
    & O+ e* J9 f  [' n/ v
  723.   attr_accessor index_proc
    8 ~* r3 K% ~7 M9 u
  724.   attr_accessor close_proc
    . d! A2 A6 D; _* ]1 M4 u- i# {
  725.   attr_accessor refresh_proc
    : a: e. [( w8 C/ p1 q. {
  726.   attr_accessor number, ^2 r! r3 ^( n  c4 n5 X: X
  727.   attr_accessor digits_max. R% H( M9 Y" l& t/ Q9 i0 {: C
  728.   attr_accessor variable_id# j$ S8 @% x3 y* }( k
  729.   #--------------------------------------------------------------------------
    . n, H0 z" ?2 l/ \
  730.   # ● 数字表
    7 W# q) m  E" D/ \$ _% x) d
  731.   #--------------------------------------------------------------------------
    : ~6 g. W, C7 b# G, h3 y6 r
  732.   TABLE = [  7,  8,  9,
    . u2 ?6 B6 r7 Y7 X
  733.              4,  5,  6,* a- @9 M. E' X! K
  734.              1,  2,  3,
    " |( o0 N6 O; x
  735.             '←',0,'确定',], m3 q8 f( u* o( A, q
  736.   #--------------------------------------------------------------------------
    / p+ C" M! O+ E$ i3 [
  737.   # ● 初始化对象
    ! {! A& e+ z9 g
  738.   #--------------------------------------------------------------------------- ~) _" j6 V' @+ r( k( B
  739.   def initialize/ q$ ]8 T) ^/ m4 @: j8 J" @( H
  740.     super(0, 0, 120, fitting_height(4))
    3 e5 p& O- q1 `3 \
  741.     self.openness = 02 v* r, c% b/ }+ O. E- t$ k  b
  742.     @index = 07 N% X* @) T! e: H5 ?( e* q) {
  743.     @number = 0
    ; e" k. V- z. b8 J  ]& p  i3 m4 I, O
  744.     @old_window_index = 0
    # @7 K- ?8 \" P6 i( @' U0 s' E
  745.     @digits_max = 0
    2 K. C0 c/ {: ?2 Q
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    1 F' x' ?/ d, B: L) }
  747.   end
    " I  J* a4 L  }5 N+ N2 {8 ^
  748.   #--------------------------------------------------------------------------
    4 @' y4 R& O+ n' o9 m/ @1 t7 V; a
  749.   # ● 获取项目的绘制矩形9 H, n' g8 q; N
  750.   #--------------------------------------------------------------------------" I6 b- }' k/ f3 ^! R3 Q# [
  751.   def item_rect(index)
    1 G1 d- K% l4 E' q
  752.     rect = Rect.new. G9 U. o! }# |( Q' l4 Q
  753.     rect.x = index % 3  327 ~; n/ [7 M$ ~) g) D' s2 L
  754.     rect.y = index  3  line_height7 Q& ]% B" ^! n) y; y) j: w5 M3 E
  755.     rect.width = 32
    5 h+ O6 M& v2 K( C
  756.     rect.height = line_height* b; g! h0 T! O
  757.     return rect
    7 w! y& B! s2 o7 ^
  758.   end
    8 c, ^- W; V0 V7 j* Y( Z
  759.   #--------------------------------------------------------------------------
    8 a4 m9 i% i! ~+ L: q& b
  760.   # ● 将光标设置到鼠标所在的位置
    4 |; @% }0 I# ^5 M
  761.   #--------------------------------------------------------------------------
    ; F* F2 |5 M) Q% z/ i: L
  762.   def set_cursor! u" I9 J: R- I! ]
  763.     mouse_row, mouse_col = mouse_window_area
    $ n% ~& @/ e% T: v1 ]% B4 D
  764.     if mouse_row = 0 && mouse_col = 0
    6 Z+ u' B6 ^: P" K7 H
  765.       new_index = mouse_row  3 + mouse_col
    + s+ Y: x' z4 E% |0 z$ x
  766.       select(new_index) if new_index = 11- i7 n0 T) d. {# ?9 o2 @' b+ u
  767.     end3 c% L) y) u2 g# R/ q1 c
  768.   end
    8 r  U+ T' J9 _0 W5 n
  769.   #--------------------------------------------------------------------------7 E1 j+ I4 |$ Q4 m4 T, W
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列' Q( @/ G( P$ Y( `" x
  771.   #--------------------------------------------------------------------------
    # `% {. y0 ~1 J0 K
  772.   def mouse_window_area& e8 h; B9 E3 b/ Y' N1 O$ {# \* o( B
  773.     if viewport.nil
    + L  x+ G1 e1 y9 f5 Q. ~" x( w; K1 U
  774.       vp_x, vp_y = 0, 0* X5 i8 b. G; F' p1 l
  775.     else7 W4 U  R2 N; A
  776.       vp_x = viewport.rect.x - viewport.ox
    * L( W& a" P- [' S! g0 A7 Z
  777.       vp_y = viewport.rect.y - viewport.oy
    & S# J: @0 E0 Y) L# c- g% U& M6 z
  778.     end
    % a8 I; E. M0 j
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y# t# y( y6 W6 A% G6 @. P* O$ [
  780.     item_x1 = vp_x + x + standard_padding & B7 W4 `; W- w! P3 m& Y
  781.     item_y1 = vp_y + y + standard_padding+ s# q% O9 S6 }) e; B) `/ P# r+ c
  782.     item_x2 = vp_x + x - standard_padding + width
    + Z& f# l8 ^' M2 T1 `5 S
  783.     item_y2 = vp_y + y - standard_padding + height, U2 F! j, k! I+ n
  784.     if mouse_x  item_x13 I0 \1 w- V4 s' Q
  785.       mouse_col = -1: A$ T$ y6 A2 U7 M8 N" f  p
  786.     elsif mouse_x  item_x2
    4 ]# H8 k; `4 T9 d$ G; m! f
  787.       mouse_col = -2
    ( W5 L, d5 B  x* o9 K
  788.     else" ^7 t, {5 M2 `: v6 \
  789.       mouse_col = (mouse_x - item_x1)  32- ^( V, n. c( a& d! s- Q2 f6 m( M
  790.     end
    , e' b5 t- r& t$ o6 K& f& f  s0 Z
  791.     if mouse_y  item_y1: `& i. u% m2 k# j6 Y7 h
  792.       mouse_row = -1
    4 ?" ?9 z( Q2 x- o6 z- L. ]
  793.     elsif mouse_y  item_y2
      [$ \$ L' U" T. `/ N
  794.       mouse_row = -2
    3 ~# C& F/ t. X3 b& V8 n1 [
  795.     else/ e: a# N* t' H9 j+ J% H/ g; Q* t
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    6 n1 k/ g  k# W" o) c! `
  797.     end
    % {' k, v0 u) p
  798.     return mouse_row, mouse_col6 D4 c& K( d1 I1 L
  799.   end
    - G/ b/ r' ^0 h7 U
  800.   #--------------------------------------------------------------------------
    : ]- G& d- Q) I
  801.   # ● 获取文字: i; X0 ^0 g4 b) \" Q
  802.   #--------------------------------------------------------------------------
    2 {- F0 Y( y+ v1 e+ D7 t( o
  803.   def get_number
    ' B% ]9 {- f. a% L6 J; U
  804.     return false if @index == 9  @index == 11# w  `6 V0 _$ s# w: f7 ^
  805.     return TABLE[@index]
    ! y: y- ?( y+ |' X6 L; Z
  806.   end# A) g0 S) @5 h! n% w6 g# D
  807.   #--------------------------------------------------------------------------
    9 y% ^* ]! b& y. Q- X
  808.   # ● 判定光标位置是否在“退格”上
    ; d" |9 t6 B/ {- s6 o( X, `: G! y! ~6 x2 @
  809.   #--------------------------------------------------------------------------
    ! v* ]. P! s5 X) @2 ~: e: q
  810.   def is_delete' h4 K: `  H8 k2 D: k7 U& v* m
  811.     @index == 9
    + [2 b1 L$ x* d# {3 e# W5 m2 g% O
  812.   end
    4 J8 Y2 P8 k1 N- [. O3 n' F- _
  813.   #--------------------------------------------------------------------------- F( z' |( w  L  M; `4 L% ~: F. _
  814.   # ● 判定光标位置是否在“确定”上6 P/ ^- c, K- D! F+ @- U
  815.   #--------------------------------------------------------------------------
      z0 D- O1 G- ^* Y4 G
  816.   def is_ok  P, V& a& u5 f
  817.     @index == 115 G" H4 _+ m% Y1 c! q5 w
  818.   end
    7 u* h! e8 Q/ \7 _, C9 }7 U
  819.   #--------------------------------------------------------------------------
    9 c( X4 [* u) @) A' b5 ]' I) T
  820.   # ● 更新光标
    9 `6 @$ h& X# n6 _
  821.   #--------------------------------------------------------------------------
    6 y/ ~' K: B. f5 A
  822.   def update_cursor" F5 b9 {7 @0 d# m9 o9 }* w
  823.     cursor_rect.set(item_rect(@index))* |# L; q" W  F: t: ?) G
  824.   end- T+ ?/ o" {% i4 w0 e
  825.   #--------------------------------------------------------------------------. s  h6 ~- w0 b( C0 m" |- R- \
  826.   # ● 判定光标是否可以移动7 a- T' a( W& [* o
  827.   #--------------------------------------------------------------------------
    + @$ o% I" N" @8 e9 X; c8 O
  828.   def cursor_movable" n8 i$ @! `8 m- G8 y) J
  829.     active
    * `3 Y1 ~0 Q1 p2 \* D. I2 z
  830.   end
    2 Q2 l/ [4 X" e, f, w
  831.   #--------------------------------------------------------------------------3 g+ ^& x/ _! Z2 a& r
  832.   # ● 光标向下移动
    2 [; i# b- }% N, h- d+ q
  833.   #     wrap  允许循环
    7 j. v& Q9 Y) @" v8 k7 ?
  834.   #--------------------------------------------------------------------------
    1 z' n, w( X& b9 P
  835.   def cursor_down(wrap): L% u. \; H5 }9 u( ]
  836.     if @index  9 or wrap; G& |& s" X" O( W8 P: T( t
  837.       @index = (index + 3) % 12
    ; _2 T5 g1 s; \- G
  838.     end8 o4 l! Q$ {7 \% h- C
  839.   end# z7 [& ]# g' I# @9 ]6 X
  840.   #--------------------------------------------------------------------------, g6 V) N) }  a0 ]: m0 k
  841.   # ● 光标向上移动
    # a6 t% }$ E8 i/ {( K
  842.   #     wrap  允许循环
    , {2 k- q( A0 o
  843.   #--------------------------------------------------------------------------, {- H' @3 w, ~# P! A7 o7 }
  844.   def cursor_up(wrap)
    , h5 e% Y. ~# K
  845.     if @index = 3 or wrap5 \$ S4 T- l3 a' a4 T0 T
  846.       @index = (index + 9) % 120 ?: n3 R4 i6 b) {' g/ }
  847.     end% ~# _% M" M, J% u
  848.   end
    ! f) S, z! g9 A; S" B
  849.   #--------------------------------------------------------------------------: j2 h8 F( X  P- O
  850.   # ● 光标向右移动7 N8 Q5 m' s" Z0 ]" }
  851.   #     wrap  允许循环! P" _6 x# V# n7 Q7 U+ O( ?3 j0 l
  852.   #--------------------------------------------------------------------------$ [; J" x3 L/ y' h; w6 E
  853.   def cursor_right(wrap)
    1 v& c. ]6 c, t, P
  854.     if @index % 3  2$ h- s) ~3 z& a6 t  F
  855.       @index += 10 @6 W( t+ {$ U2 j3 F
  856.     elsif wrap+ [: y7 r! I/ R- h
  857.       @index -= 27 z: M8 l! E4 B; c5 U; f2 U6 A7 J  K
  858.     end
    ( _; j- Y& D6 q, D
  859.   end# l- |6 @4 T/ M2 Z$ B1 N- z
  860.   #--------------------------------------------------------------------------- P4 V. J. I5 d0 {3 W. t, k1 G
  861.   # ● 光标向左移动5 X; W' j$ i0 [# f4 |9 b2 k
  862.   #     wrap  允许循环
    0 C1 D  v; M7 ~: ^9 e0 ^2 p7 W5 ?
  863.   #--------------------------------------------------------------------------
      u% J! [6 b6 w5 J6 B! l" q0 V
  864.   def cursor_left(wrap)' i) @% i# l' t
  865.     if @index % 3  0
    , n8 ^: M  z6 Z+ Y( z' F6 A- o1 s
  866.       @index -= 1
    / ^' U) ~% b0 s
  867.     elsif wrap
    6 u! S3 i: b- F' n1 n; @) h
  868.       @index += 2
    8 L" c7 v. U2 V2 [! d
  869.     end
    " ]# l: p& O0 w( u$ m
  870.   end7 Q. F, ~0 \" _& D/ J' z7 r
  871.   #--------------------------------------------------------------------------/ X/ d1 e; F% R( y3 n* c% Z
  872.   # ● 处理光标的移动6 u" F4 w8 o% M
  873.   #--------------------------------------------------------------------------
      e$ p0 s% G; p' h
  874.   def process_cursor_move% ~4 \  a. p9 b! `0 v/ l! ^& U1 N
  875.     super* W) _; j7 G, u- ]
  876.     update_cursor9 ?2 P& R! k/ C5 i" k# @. Q
  877.   end0 Z: B. }( p+ A3 q$ y6 o
  878.   #--------------------------------------------------------------------------' [+ W. O8 W4 S: X
  879.   # ● “确定”、“删除字符”和“取消输入”的处理& O  H% i$ v1 l( m
  880.   #--------------------------------------------------------------------------
    3 T2 U: k8 J5 J" P: L9 A- g  P
  881.   def process_handling
    ' k2 E4 ^  v! N6 {  ]2 b/ `
  882.     return unless open && active+ c0 g; S1 m: [/ {4 r
  883.     process_jump if Input.trigger(A)
    7 o- b4 z. [, R% W" U
  884.     process_back if Input.repeat(B)
    2 v) A. D7 p3 q
  885.     process_ok   if Input.trigger(C)
    1 q4 r  L% W- ^% m  ?
  886.   end+ s* ^- a8 [& L- H
  887.   #--------------------------------------------------------------------------
    : v( {5 ]. q& i1 H6 v& F
  888.   # ● 跳转“确定”7 `3 X8 I. ]3 v- `7 W! E( G& b$ d& ?
  889.   #--------------------------------------------------------------------------
    ( D7 V; [; y/ {" O5 B7 r2 H
  890.   def process_jump! ~. P$ c. v1 [
  891.     if @index != 11: C' Y: L4 ^2 q3 O$ y
  892.       @index = 11$ K6 g" a  f$ h8 M
  893.       Sound.play_cursor
    5 Y4 G8 }) [6 x0 M' M  ^
  894.     end
    ! R9 e( j; b# t
  895.   end
    3 v* n* H5 `/ D+ ^+ V' f6 u; K
  896.   #--------------------------------------------------------------------------
    3 |+ ]% F" \6 ~1 y$ C
  897.   # ● 后退一个字符
    7 m1 G) ^7 L' f
  898.   #--------------------------------------------------------------------------. G/ [) f$ ?# c9 ^+ [: w. k
  899.   def process_back. V4 s, ~+ r" X  ~
  900.     Sound.play_cancel
    $ K) G  a& s( w# W4 m
  901.     place = 10  (@digits_max - 1 - @old_window_index)0 V# {* b  g3 X( s( V8 b! ^
  902.     n = (@number  place) % 10
    0 y* e& J* }$ g( ^( y
  903.     @number -= n  place5 L1 S* _+ N. E
  904.     @number_proc.call(@number)
    $ C! f, b+ w' Y' H1 Q
  905.     @old_window_index -= 1 if @old_window_index  0# F$ G1 a* X' Q/ Q( Y  g  r, p7 O
  906.     @index_proc.call(@old_window_index)* m, s$ a( g/ t* N. K& H; r
  907.     @refresh_proc.call: }" j/ `- Q  {3 e. d0 z
  908.   end* E! L- B, a  W6 g6 L* k
  909.   #--------------------------------------------------------------------------
    : r0 ?9 R. @) ?8 G( }
  910.   # ● 按下确定键时的处理
    ! k$ T8 x5 v' y1 \# Z! K/ a9 d: x
  911.   #--------------------------------------------------------------------------
    % O8 ?/ O3 B  R) t
  912.   def process_ok
    3 s9 ]. @  p( C/ F# t1 x# j
  913.     if get_number( }) i1 h+ Y# t+ e9 \+ z
  914.       Sound.play_cursor* i: T# t; t* l
  915.       place = 10  (@digits_max - 1 - @old_window_index)  N0 G5 b, @4 F3 c0 C" M5 h
  916.       n = get_number - (@number  place) % 103 N  Y- f. g2 g# m2 A/ i$ [
  917.       @number += n  place7 J1 a% W6 ?+ U
  918.       @number_proc.call(@number)
      G, x" C8 j" c6 O' B
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    9 T, {3 W, E' }
  920.       @index_proc.call(@old_window_index)6 k! M9 }. @5 x
  921.       @refresh_proc.call
    4 ?& d4 a8 U4 w( m5 v2 J; u3 H! C3 `
  922.     elsif is_delete
    ! [4 n/ j  q& p6 Z$ `+ T
  923.       process_back
    ; a, n6 ~' U3 A& k8 h1 t2 U
  924.     elsif is_ok
      l& [5 I3 ~" C2 u: j4 L
  925.       on_input_ok( s) x' f- M: K2 E( t# ~2 E
  926.     end- O4 q: V% w; e8 D, T' b
  927.   end
    4 B/ q+ p; n  ^
  928.   #--------------------------------------------------------------------------
    / i8 d4 y; X% s1 a' r
  929.   # ● 确定$ ]8 {) B' k' h& R4 n& P
  930.   #--------------------------------------------------------------------------, `: `4 e9 h" c/ r4 A6 b+ ]! |
  931.   def on_input_ok2 z" p0 C; F7 |
  932.     @index = 0: K/ J5 H! [) u; U
  933.     @old_window_index = 0
    : F) I9 R2 e1 T- a" K% _) B! w
  934.     $game_variables[@variable_id] = @number
      i* V; x2 M8 t4 [9 ^
  935.     Sound.play_ok* n4 Z* B' y1 S/ g2 a- u! E& j8 D
  936.     @close_proc.call
    0 p1 W, ?; v2 |; q. K9 n0 N
  937.   end
    8 ^4 P6 F4 U0 k+ C& R2 K
  938.   #--------------------------------------------------------------------------% X" Q5 x+ l9 W  B9 H
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置$ Y' D# _$ A0 f4 t
  940.   #--------------------------------------------------------------------------
    + @# R) Z0 l! U& e4 n  f
  941.   def set_mouse_pos
    ! R9 x% |& H- w0 @* }& k
  942.     if viewport.nil # necessary!0 r- s0 ?# \% p5 U
  943.       vp_x, vp_y = 0, 0
    1 `! `3 A- J2 Z5 [
  944.     else
    / h9 \( e# P. x4 g$ Y
  945.       vp_x = viewport.rect.x - viewport.ox
    1 M$ O9 Z( C' G7 \: m+ T
  946.       vp_y = viewport.rect.y - viewport.oy
    , R% U! ^+ B, r% A6 u( _2 A
  947.     end. ?/ E! e! j- N1 S" [# p7 ~* G
  948.     item_x1 = vp_x + x + standard_padding
    ( u. w" }8 Q3 R: t
  949.     item_y1 = vp_y + y + standard_padding6 i2 m8 S, h0 o
  950.     get_index = @index  0  0  @index 8 I: E% T6 q% d. n3 B3 g
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)4 f; p7 C0 k/ R) y- W
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    3 A/ z+ m3 @6 f9 [* a; [- P
  953.     Mouse.set_mouse_pos(new_x, new_y)
    ( U: ~! G! V4 N* Y8 M! r& p. a
  954.   end8 T2 w" V$ \' Y4 j9 M1 h
  955. end
    $ e) A' ?' X6 n! L' n1 N2 c: |
  956. & C1 U) v" m; i" {% }5 d
  957. #==============================================================================  r# j1 O% r, R: _; l& H8 S! r
  958. # ■ Window_Message
    ( N! A6 {1 r  t9 ^# a1 G3 s+ q
  959. #------------------------------------------------------------------------------- t% _+ u0 Q* H9 Y8 k8 F" R
  960. #  显示文字信息的窗口。
    6 @# Y. v2 @3 ~" {/ m9 Q8 i( d( l
  961. #==============================================================================! w# Y% N9 p; p, ^! `
  962. class Window_Message  Window_Base
    6 \# S6 X. c/ ?3 G* L$ T2 q
  963.   #--------------------------------------------------------------------------
    7 w: K0 }* O% b! \1 i
  964.   # ● 处理数值的输入(覆盖原方法)% p1 J9 L$ Q; W& ]$ x: a
  965.   #--------------------------------------------------------------------------: f9 D# b. C/ L8 A
  966.   def input_number% S6 B# |( }" S  c1 D
  967.     @number_window.start
      v( p' L/ R7 C9 u0 `
  968.     Fiber.yield while @number_window.extra_window.active
    3 ^( G( L3 c# D9 ~' R
  969.   end
    5 v' S8 Y! s' ~9 M2 i/ c* T
  970. end5 p6 L- e# ]% }0 ^
  971.   O: \: H: Y$ T4 t) y
  972. #==============================================================================
    : b; t& q/ c# I: P( Y& ?$ z: r1 C
  973. # ■ Window_PartyCommand
    # D. B7 y0 y8 i0 Y
  974. #------------------------------------------------------------------------------2 \1 B& |. t- d. `
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    / o  i+ z( B5 P* g
  976. #==============================================================================
    ' q# H7 }! {& Y5 E) Y
  977. class Window_PartyCommand  Window_Command
    + S' T. E* c1 K% ?
  978.   #--------------------------------------------------------------------------6 E+ G5 Q8 p/ _$ A
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    $ Z$ _' O) S: J" r5 s
  980.   #--------------------------------------------------------------------------: C' H9 [3 J, k: {4 X. f; y+ x1 D
  981.   def set_mouse_pos
    ; W5 @$ t$ t6 Q2 H
  982.     if viewport.nil
    0 x% C2 N; a- Q) v- k8 b5 F5 [
  983.       vp_x, vp_y = 0, 0
    3 T6 T4 {5 R2 J& R* x
  984.     else
    9 v( Z, b- d) q  y- e
  985.       #vp_x = viewport.rect.x - viewport.ox
    7 }5 T6 C# @1 z( I* t7 y
  986.       vp_y = viewport.rect.y - viewport.oy0 E* D0 x* G7 t) z3 C
  987.     end
    $ R9 u/ d, o7 O; b  @& q8 N; j
  988.     item_x1 = x + standard_padding 2 ?# R) e7 l# X
  989.     item_y1 = vp_y + y + standard_padding
    * i; e# i4 y2 v5 V
  990.     get_index = @index  0  0  @index ( U, }5 b$ L- t) p2 J* B
  991.     row = get_index  col_max - top_row
    : y% _$ Y: Z" Y! Z
  992.     col = get_index % col_max' H$ _* M$ }  p" r& X5 i
  993.     new_x = item_x1 + item_width  (col + 0.5)
    8 K  i' z- w; a; a4 ~$ M
  994.     new_y = item_y1 + item_height  (row + 0.5): x  Q) E9 b" A) V7 E# k; R& N
  995.     Mouse.set_mouse_pos(new_x, new_y)5 y' u/ B+ [' Q: S' v2 d
  996.   end
    7 \4 q% D/ k2 R& ?9 q. t
  997. end0 h' U6 \7 R. W1 ?7 Y: X
  998. # D, `  ?2 r2 O8 e- d
  999. #==============================================================================( ~/ k; I( w* Z5 t+ n
  1000. # ■ Window_ActorCommand8 _, F1 ^2 _, V) _
  1001. #------------------------------------------------------------------------------
    ; z1 o% i( r4 A4 D# w
  1002. #  战斗画面中,选择角色行动的窗口。* J$ C$ p7 I  g# S% a
  1003. #==============================================================================! p& |, \) r4 ?! m$ ]- h1 ^1 G
  1004. class Window_ActorCommand  Window_Command
    * r4 i5 S# R7 U/ J
  1005.   #--------------------------------------------------------------------------. f$ b7 s& y4 J8 Y
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置: K+ G: R  B+ A% l
  1007.   #--------------------------------------------------------------------------% t/ T" v( y) N1 X5 u- H
  1008.   def set_mouse_pos
    " D& Y. G6 ?( W+ ?* r1 W, T
  1009.     if viewport.nil: z+ m6 e* N# ~$ ?$ p, h8 k3 e
  1010.       vp_x, vp_y = 0, 0$ |5 n+ m/ T+ |) w. T3 D0 H5 n
  1011.     else7 r, t% X$ r  _: `) Z
  1012.       #vp_x = viewport.rect.x - viewport.ox! u  k- |6 y- ?
  1013.       vp_y = viewport.rect.y - viewport.oy. W: f  D# v' _% r: }. |* t( k
  1014.     end
    * E) F) R: M) B, y3 t* N
  1015.     item_x1 = Graphics.width - width + standard_padding
    9 K* P% `2 q7 J- G1 z7 P; a" Y
  1016.     item_y1 = vp_y + y + standard_padding0 x$ t" z8 @; a- V
  1017.     get_index = @index  0  0  @index
    1 r  w' _2 Y+ ^' ^; R( s! K0 i4 M& P3 `
  1018.     row = get_index  col_max - top_row
    / L: V, U- P& a) e( X
  1019.     col = get_index % col_max4 {3 e& e, k4 Y( i
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    5 q1 F7 Z& }; }0 y8 B
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    8 N# y0 }2 ]. K8 l" Q7 ]* r, x. G
  1022.     Mouse.set_mouse_pos(new_x, new_y)  M' l) E* ~3 g% o
  1023.   end
    4 N; s* M& `3 `0 g1 }2 W& X( j" w
  1024. end! U& \0 f, ?. M8 {. \0 }

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

  2145. ; k5 F, `0 q2 Z. ]. j' G& N. q5 k
  2146. #==============================================================================; f; k* W( L8 H. f; T7 `4 W, D7 K- D
  2147. # ■ Game_Map% T4 A# w% k6 ^5 @6 x
  2148. #------------------------------------------------------------------------------
    ' W$ X  |+ w/ S+ P; C9 u
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    4 d' [$ |6 @" u& u$ k. z$ ^
  2150. #   本类的实例请参考 $game_map 。
    ; V4 q. {; @# i2 L& e! F4 S
  2151. #==============================================================================
    6 n, W8 M. z; T6 z* ~- |$ [
  2152. class Game_Map- ?- L# M3 o! q5 f; S
  2153.   #--------------------------------------------------------------------------
    6 D' ?. A3 w- G! r' [
  2154.   # ● 定义实例变量
    4 A/ R9 O! S" k* ~# R+ w2 {- [
  2155.   #--------------------------------------------------------------------------5 f( Q. [' r. G7 `6 o
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据% S* k$ E5 {( E* @/ e2 G+ \  d8 H
  2157.   attr_reader mouse_map_y # 同上
    & C, E2 K% L" D+ R& l6 x
  2158.   #--------------------------------------------------------------------------2 g2 G2 k+ O# V( C( r2 j
  2159.   # ● 初始化对象
    9 d9 E: j8 w) ?) v7 l# l8 S& _
  2160.   #--------------------------------------------------------------------------; Y' Q( P6 J" i1 d
  2161.   alias sion_mouse_initialize initialize4 h8 {3 E. E& o$ w
  2162.   def initialize( v: W! m' T+ r; g3 _9 U
  2163.     sion_mouse_initialize' x- C( F. w% J' }2 e0 `
  2164.     creat_move_sign  ###6 E5 m' m' m* ?
  2165.     set_constants) ~) j2 Y+ K. ~8 r
  2166.   end9 Q, \. J+ J5 b
  2167.   #--------------------------------------------------------------------------
    0 d7 f# u5 }3 w" Z  ]
  2168.   # ● 更新画面/ e( u' D$ B+ p! l$ Q
  2169.   #     main  事件解释器更新的标志
    5 J$ w6 t) @+ ^
  2170.   #--------------------------------------------------------------------------
      e' d0 J1 z- N% R9 i7 F7 @9 ~
  2171.   alias sion_mouse_update update# X* ~7 ~8 N# V( s2 M( K
  2172.   def update(main = false)' }* z& q8 r9 O- K) P7 y9 i
  2173.     sion_mouse_update(main)
    % l2 S7 J8 l7 C5 S1 H& q# L
  2174.     update_move_sign$ }( a: x; R4 U+ C4 L) E
  2175.   end8 W" U4 M3 w% m( l% T; l
  2176.   #--------------------------------------------------------------------------
    2 m) v/ d! F1 v2 ~3 ~
  2177.   # ● 创建显示路径点的事件3 K/ [9 w/ o# k+ a0 C
  2178.   #--------------------------------------------------------------------------7 Y# [  b' ~* O, ~; b
  2179.   def creat_move_sign2 l4 A* Q, z, [/ }2 h# k" R, I
  2180.     $mouse_move_sign = Move_Sign.new; A* C+ J$ C$ q9 J/ `- V
  2181.   end
    ( s0 K; C! H6 S% S, ?) l, i
  2182.   #--------------------------------------------------------------------------
    ; B: B2 A$ g" R, ?3 l2 d, Y& _
  2183.   # ● 更新显示路径点的事件
    * R. w6 H" k: W& ~$ y1 P/ ?
  2184.   #--------------------------------------------------------------------------/ l( X5 K2 J- Q# c
  2185.   def set_constants
    ' ]- ~7 a6 a; |( a" B
  2186.     @mouse_pos_setted = true( |( X$ m1 @/ G7 V- n3 \1 v5 M
  2187.     @set_pos_prepared = false" i4 x" g) R5 F, D( T9 J0 o  |6 m
  2188.     @mouse_old_x = 0
    + a. S. i* n  B$ T* J6 r/ u* ]/ {
  2189.     @mouse_old_y = 0* Q* ?. N* h+ B/ c- @
  2190.   end
    , s, n. d! O% A2 A
  2191.   #--------------------------------------------------------------------------. D, S! O" B& ^; g3 P
  2192.   # ● 更新显示路径点的事件( q" F& J  F0 I! Q" h
  2193.   #--------------------------------------------------------------------------
    5 D8 P8 e( C# H5 }
  2194.   def update_move_sign
    6 i: J' U& u; T9 r9 q
  2195.     $mouse_move_sign.update0 |) f! h: \; T5 c; z
  2196.   end2 ^& n4 p2 L3 H# e
  2197.   #--------------------------------------------------------------------------3 a) ^/ ^' C# W7 o3 v
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    $ x- \* {- M9 L& G. T
  2199.   #--------------------------------------------------------------------------
    ; W1 F3 H$ E1 ^  Y5 n0 P" e
  2200.   def get_mouse_map_xy
    3 S) n/ J! I  @$ ?3 u
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    8 L6 s9 H  f; ^: _
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    , j1 Y( c' e7 F4 Q1 v, n
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)  m2 A! a) q* b! Q
  2204.   end
    . o$ h4 W6 y, V
  2205.   #--------------------------------------------------------------------------
    ; M8 I8 ?& Y9 {* O0 C" V) k
  2206.   # ● 返回地图画面时重设鼠标坐标/ A# q! l1 e' @  C1 F1 M
  2207.   #--------------------------------------------------------------------------
    : j3 a7 f- F7 T2 S( W+ ?% Z
  2208.   def reset_mouse_pos
    7 J% b* Q% ]2 \3 t
  2209.     return if @mouse_pos_setted! a0 v( p% D/ x
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
    + `4 Z- [' r+ O6 B! n7 U% C
  2211.     @mouse_pos_setted = true
    7 ^% z  N0 m) n. X7 T6 B+ G# b- `
  2212.     @set_pos_prepared = false. O$ b  n; S1 o7 ]: I+ g" p
  2213.   end
    1 a# Q/ }. {) L. p; w' M
  2214.   #--------------------------------------------------------------------------
    4 k4 b, g- ]& q- X$ ~& {
  2215.   # ● 重设鼠标的坐标2 D% \9 _. r% C( V* a. s" N, C
  2216.   #--------------------------------------------------------------------------/ s; ]6 w6 o) o; t: q! `
  2217.   def prepare_reset_mouse_pos
    1 c% v  |9 O/ X8 ~  R
  2218.     return if @set_pos_prepared- R9 x6 [: t8 j( e6 v2 p
  2219.     @mouse_pos_setted = false
    " W4 [( W( R7 J7 G* f; J! z8 F
  2220.     @mouse_old_x = Mouse.mouse_x1 P* j0 a- K/ ^5 g
  2221.     @mouse_old_y = Mouse.mouse_y
    ! z% @6 \! u9 c0 K7 c6 V/ g
  2222.     @set_pos_prepared = true
    1 R4 `/ _5 l$ L, e3 c, X
  2223.   end) H2 g* X6 j. H, X- J$ ^6 Y
  2224. end) p3 l2 p: s8 @

  2225. - Y, q7 `4 N! Y
  2226. #==============================================================================
    + |. q7 L3 `0 ?0 {8 i9 }! {9 R& @
  2227. # ■ Spriteset_Map
    4 K9 H& @0 v3 ]
  2228. #------------------------------------------------------------------------------0 W! q; ?4 X3 c3 T/ s8 @8 g
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    9 Q; k% s0 O' E3 V; O. L
  2230. #==============================================================================/ {* h5 W) ]  }5 A# n
  2231. class Spriteset_Map, a. P) U( }" }% r
  2232.   #--------------------------------------------------------------------------
    ! M5 a( H$ ]- Q& d2 O2 F6 d' X0 C
  2233.   # ● 生成路径点精灵# C4 P/ ^# \% m
  2234.   #--------------------------------------------------------------------------
    , ~* a- ]: k' v: m, y
  2235.   alias sion_mouse_create_characters create_characters
    4 r9 f+ \, P: m  g2 V9 A' N3 o: q
  2236.   def create_characters
    0 L/ X, V' d. T7 q' P  N8 s
  2237.     sion_mouse_create_characters
    - Z4 M* V8 x' B2 ?- d7 C; o8 {& ]
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))! D, F% w$ T( _$ {* S4 }' {! L
  2239.   end6 p: i- c/ M& }8 Z' ~; q4 i3 g* E# Z
  2240. end. S9 h. i4 P9 G9 T
  2241. 0 S1 S# X# v" H6 \' n2 v
  2242. #==============================================================================
    ) `& N+ f9 }( a
  2243. # ■ Scene_Map
    ) W4 L% M# J( m1 @0 r
  2244. #------------------------------------------------------------------------------
    1 M" U: l9 V6 T5 u2 }& l. ^" X$ A
  2245. #  地图画面
    " g+ J/ F( `) k3 I: p' D5 F
  2246. #==============================================================================% _/ U. P* l% G# R
  2247. class Scene_Map  Scene_Base- h. C, I- Q6 q# H( w9 ~) r4 i0 |
  2248.   #--------------------------------------------------------------------------8 j; a) O/ C8 x1 k# f' t9 U
  2249.   # ● 画面更新
    + p7 L! U3 q0 E0 l: n' u
  2250.   #--------------------------------------------------------------------------9 g+ v3 ^6 s' `, J, A3 K
  2251.   alias sion_mouse_update_scene update_scene
    9 I9 q2 C& ]5 E& Q5 j( y+ [- ]
  2252.   def update_scene7 x3 y6 X2 S* Y/ R
  2253.     sion_mouse_update_scene
    ; J& r- W& [( z5 I
  2254.     update_mouse_action unless scene_changing5 V# }. x6 G& v5 E9 w. E
  2255.   end
    . E/ t1 k; A& c3 a
  2256.   #--------------------------------------------------------------------------
    7 ]6 y6 P! T1 d6 _6 E
  2257.   # ● 场所移动前的处理- ]" o# ]' q4 p% ]2 j$ b: `
  2258.   #--------------------------------------------------------------------------# I( M; l" \1 q3 ~; b# ]6 f+ {
  2259.   alias sion_mouse_pre_transfer pre_transfer
    8 k2 N6 n: k2 N
  2260.   def pre_transfer% P& k% j" C( _. \0 i  k6 u
  2261.     $game_player.reset_move_path
    : o6 M2 D8 g% g
  2262.     sion_mouse_pre_transfer5 B4 X# V8 T% f2 B; Z; P& Q
  2263.   end9 s7 C2 k+ d0 b5 K0 F) B$ x
  2264.   #--------------------------------------------------------------------------
    5 Q0 A6 d, @6 w% |4 D1 m
  2265.   # ● 监听鼠标左键的按下
    + ~% r" M7 }6 W# {( N4 F
  2266.   #--------------------------------------------------------------------------* K! f$ H& n$ x- o' \8 t5 e
  2267.   def update_mouse_action3 f' ]" p5 Y  f2 m$ j2 l# P* i  T7 ~
  2268.     $game_player.left_button_action if Mouse.press(0x01), C+ h" y2 \: m9 W3 l. t
  2269.   end( E4 f3 a( @6 u6 U+ o* o  g
  2270. end- u! l; \2 F5 U+ l. z( F( C: N

  2271. 8 `. U: V# F2 W: A, `1 z: j2 E
  2272. #==============================================================================
    5 M  o8 S8 x4 G& X' `
  2273. # ■ Scene_File* x6 A! n/ D5 Q# w
  2274. #------------------------------------------------------------------------------. D; u& _1 S  |3 l* E- t5 E8 h2 E
  2275. #  存档画面和读档画面共同的父类% R  {7 E* {) J) S  v; ^2 x2 _
  2276. #==============================================================================
    " s+ P* ?+ |$ m' K" ~7 T9 @* _
  2277. class Scene_File  Scene_MenuBase
    0 T( n! D+ q: P: m; Z( Y6 R! s- \
  2278.   #--------------------------------------------------------------------------0 h1 P( t, I9 [; i
  2279.   # ● 开始处理
    5 r  |1 T7 z5 S# o' h- y$ ]* ]" I
  2280.   #--------------------------------------------------------------------------
    - i& R2 A  Y  f& [' y
  2281.   alias sion_mouse_start start' Q! m' p" \6 W+ P5 ~: z
  2282.   def start& u+ S* {( F1 n4 \) X9 r# r
  2283.     sion_mouse_start, m2 d: k% A8 i8 ^3 M) t
  2284.     @move_state = 02 |/ b! m9 W) c  L
  2285.     set_mouse_pos
    1 k  y% Q: c" Q( f6 U
  2286.   end8 K0 |7 U- H( {( r
  2287.   #--------------------------------------------------------------------------* {2 a/ L* Z8 K& ~0 Q5 [
  2288.   # ● 更新画面
    ' X) q7 z/ }+ D
  2289.   #--------------------------------------------------------------------------0 o1 \' R6 r! w$ }* j
  2290.   alias sion_mouse_update update
    ' I: m% P4 C! Y: b" E' G
  2291.   def update
    . c. G" @, u9 {3 v! X
  2292.     sion_mouse_update
    ; K  C2 M& P' S
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos- W1 z  v7 N6 S& T' ~) W
  2294.   end
    4 c. y% i3 _" }6 D2 @
  2295.   #--------------------------------------------------------------------------
    + a. E* B& l8 W% o( y8 s0 G& w
  2296.   # ● 更新光标
    ) B$ D  F- Q  r$ e. }3 U- o
  2297.   #--------------------------------------------------------------------------
    4 q0 a0 u/ ?2 z' e& h
  2298.   def set_cursor" T; [  Z3 u3 `
  2299.     @move_state += 1
    ! N- M) K- k  d& A; j  R
  2300.     last_index = @index
    ; G/ P- u  s) e/ {
  2301.     if mouse_which_window == -2
    * }; _7 D# ]" g6 G' P
  2302.       if (@move_state - 1) % 6 == 05 H3 S. I( ^) i7 S7 l
  2303.         @index = (@index + 1) % item_max if @index  item_max - 18 x5 ?& V5 |$ {2 u+ o+ L2 w- R
  2304.       end
    3 @( r5 W& o' Y# z- r
  2305.     elsif mouse_which_window == -1
    5 Q* L! D% P8 q/ X; j( U! \1 n# [: T$ z
  2306.       if (@move_state - 1) % 6 == 0% b: f/ D$ y7 b% j" |
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    : E% t& J0 A1 y$ F, [$ A0 a* N! _
  2308.       end5 ~8 l: D: h: _1 K
  2309.     else
    9 k, q2 I/ s; c" O. f' j
  2310.       @move_state = 0
    . a5 M- x1 f9 g9 N  X
  2311.       @index = top_index + mouse_which_window
    , ~/ K4 H, `7 ^* A& B8 K+ B
  2312.     end' `  d# m4 [3 _8 r
  2313.     ensure_cursor_visible/ V8 `! P: |" X  q; g2 L! b2 f) G% O
  2314.     if @index != last_index
    2 H: j' t+ a9 R/ U1 b
  2315.       @savefile_windows[last_index].selected = false
      \5 J5 i$ _0 f! D1 O; n
  2316.       @savefile_windows[@index].selected = true+ C- H( h& M. E/ A- w
  2317.     end
    3 E: |  o3 S/ b. i* n& ?
  2318.   end% A# M8 x$ ^9 E
  2319.   #--------------------------------------------------------------------------+ [2 a9 Q: E3 t- @2 I
  2320.   # ● 判断鼠标位于哪个窗口2 }# A5 i4 W+ i) M( Z
  2321.   #--------------------------------------------------------------------------
    * D* B7 E) l- o& J: G; x( A
  2322.   def mouse_which_window3 X/ A) G7 N3 E, [1 x- i
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y' }+ q- r2 s& p7 u
  2324.     if mouse_y  @help_window.height + 14
    3 u! A6 @! F! n7 M6 O$ q7 s
  2325.       mouse_row = -1
    5 ?( ~0 X; Q- R
  2326.     elsif mouse_y  Graphics.height - 14. U2 t3 @( U( v% ?+ m6 ]) ~6 Z
  2327.       mouse_row = -22 C/ T; k0 W1 }' K  l
  2328.     else* H% R" u' k8 X+ y" X5 Y# B* f
  2329.       mouse_row = 4  (mouse_y - @help_window.height) 5 d5 K: T! {0 L' W. d) ~
  2330.         (Graphics.height - @help_window.height)# A7 }. C9 H! _
  2331.     end
    8 e: G! T7 I# e, J7 @; m$ L1 w' W
  2332.     return mouse_row
    ; [: y- G& E5 N- c, w" b1 t& g
  2333.   end# a& d3 e1 z, B/ y# A4 p: J4 M6 W
  2334.   #--------------------------------------------------------------------------: }/ |6 o7 ]! \" \( k
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置! a% k6 G: B$ @& g
  2336.   #--------------------------------------------------------------------------
    ) p& F% Z+ F7 B* v7 i( Q' w" `! {( O
  2337.   def set_mouse_pos+ t" \8 c: j: |- X
  2338.     new_x = 40
    4 R! k4 V' U  o7 ]/ v- b
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    1 R6 z' O! L. e8 E
  2340.     Mouse.set_mouse_pos(new_x, new_y)# t, v( [: O+ N( _, o
  2341.   end
    " _4 J0 L' E: M- Y! y
  2342. end
    # {  A( g4 \6 g, X; Q. H

  2343. 0 ^/ ~1 C, [' W- S! E: i
  2344. #==============================================================================1 `3 X* I4 n- }: o& U0 J, J" W8 V* Y
  2345. # ■ Game_Event
    / o+ n" [; J, A( A5 G1 h
  2346. #------------------------------------------------------------------------------
    # T1 o/ h) r4 p% t6 z( i
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。3 K. I7 _) E% D: }
  2348. #   在 Game_Map 类的内部使用。" k: R7 d7 n5 o/ l* u- K
  2349. #==============================================================================. s. T+ g9 R. k1 T' ^
  2350. class Game_Event  Game_Character
    8 O2 m% y2 T: Z: n6 t' A) F
  2351.   #--------------------------------------------------------------------------
    + a# q. \) L$ C$ q0 B- L
  2352.   # ● 事件启动2 W/ M& w) o0 }# Y8 c! ?; R# n; Q
  2353.   #--------------------------------------------------------------------------6 c  w) O5 U- T4 h& j, o
  2354.   alias sion_mouse_start start
    8 c  k. O; [7 e  K5 }3 W- X" t
  2355.   def start
    3 f9 v2 \3 S. G+ U1 _- L
  2356.     return if mouse_start && !Mouse.press(0x01)
    ! D! |' f/ w) K) `2 B& ~
  2357.     sion_mouse_start
    - V- h( E3 N; }  |% |  H# [
  2358.   end
    $ T( \: l% W$ n1 o6 i4 d: g
  2359.   #--------------------------------------------------------------------------. v, [1 e5 G0 Y* g! q
  2360.   # ● 判断事件是否由鼠标启动
    * w8 ?& `1 U! O
  2361.   #--------------------------------------------------------------------------
    % L* ]1 l1 Q. C' ]: y  ~
  2362.   def mouse_start! U: \. s5 y! E2 A
  2363.     return false if empty$ X0 ^- p2 v+ _8 K
  2364.     @list.each do index
    ; o. `* y* W& B1 p$ c/ @  e% ^
  2365.       return true if (index.code == 108  index.code == 408) &&0 ]5 @5 X  F9 ?
  2366.         index.parameters[0].include('鼠标启动')( @; c6 i% b0 W: E1 A, B
  2367.     end) L  d' H5 Z* }' g, n% @, s5 S
  2368.     return false$ Y" v9 p2 D; X' ~5 f
  2369.   end: G& A* c, ]' x8 Q5 |. j, p% s
  2370. end9 c) k# _3 o8 c# a9 h
  2371. . X) D+ l- {) D* M0 t' w
  2372. ####泥煤的height7 e! H* {7 B7 ^+ v/ O3 @7 T
  2373. # @height = height0 x  R6 S& h* f

  2374. + s  _6 v6 I: X! u2 W/ m' P
  2375. class Area_Response
    4 e! {: I5 A9 J2 j
  2376.   attr_accessor type
    ! |6 {* g3 D$ d7 I
  2377.   attr_reader ox4 V; g, x9 b( v: u( ]8 w
  2378.   attr_reader oy
    5 Q+ A. j* Y9 j9 p5 P/ |
  2379.   attr_reader width. |0 N' ^+ w$ |: y9 [0 c4 f
  2380.   attr_reader height8 i6 S: Z, ?" H1 o: v9 a
  2381.   attr_reader switch_id
    : H  a* i" W  f$ B( ?/ z
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)1 x5 O" e: T8 t& V; R
  2383.     @type = type
    : a' H! ^6 c) a5 a! u
  2384.     @ox = ox
    , t/ P8 f3 v, N! T
  2385.     @oy = oy
    * P1 ]3 i6 k% O- h8 e/ Z4 [# z
  2386.     @width = width
    ' Y) N' k3 j# p; \
  2387.     @height = height
    " c" `% ^. g" |+ h0 Y1 o: X& z
  2388.     @switch_id = switch_id6 Z3 L3 R3 R* o; }4 V) s: s4 ?' p  t
  2389.   end" p) S6 K( W3 a) P* M1 _
  2390. end
    5 e; V1 ?( n9 z- L! G& G

  2391. 0 C8 D/ a) k. G) K
  2392. $area_responses = []
    3 z% T7 M6 z9 w3 n9 f3 d/ B$ |
  2393. / }2 {/ j1 a2 h* S1 E
  2394. class Scene_Map; ^5 J9 }5 H- e0 w9 C7 _
  2395.   alias update_mouse_2013421 update_mouse_action& f; o3 O' V) m, l" |( A8 \
  2396.   def update_mouse_action: l, r* ]/ P# ~. N
  2397.     update_area_response
    ; r: X. z/ V) a: I8 Q$ |+ U
  2398.     update_mouse_2013421
    ( t+ e  h; F/ s# }( }2 B, @5 y
  2399.   end
    1 m) d" k& a4 |4 K( o/ u9 A4 P
  2400.   def update_area_response
    ! r* x, _, ^# ]0 g/ i" J
  2401.     responses = $area_responses3 J! p# d- `% }# P! H2 W
  2402.     responses.each {response, I! L4 W8 }4 ]! C
  2403.       ox = response.ox. G# c7 v; h& C& T/ C( x
  2404.       oy = response.oy
    4 d2 C0 g! o) }7 r, b4 C
  2405.       width = response.width3 U/ a! e  c* E6 d2 D  n% w- ^2 {
  2406.       height = response.height1 v( a& w3 v! K" w6 F+ e
  2407.       switch_id = response.switch_id
    , k- e! ~" y9 |% D& ?) B
  2408.       case response.type
    & v+ A- [( Z' z  [
  2409.       when 0
    1 q" @0 o# Y2 `6 M6 _
  2410.         if mouse_in_area(ox, oy, width, height)
    ! I# o: B$ @' X  x
  2411.           $game_switches[switch_id] = true
    $ @+ u6 p: {: Q- l$ B' e3 d7 Y
  2412.           $area_responses.delete(response)4 V( X2 B9 |# F3 ]9 J) B$ M$ d; W& C4 t
  2413.         end! w$ e; Q: ~8 {) L  S) f( e& j3 J
  2414.       when 10 D) }2 J; D7 V& P
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    * q5 o. R  ]0 h  W
  2416.           $game_switches[switch_id] = true- b+ Z! s9 a4 Y' O
  2417.           $area_responses.delete(response)
    + i3 ~! v3 E8 G8 F, f1 e
  2418.         end
    / U3 F+ C4 @3 S8 r5 u
  2419.       when 2
    & e' ^) ^* D% H' H
  2420.         if mouse_in_area(ox, oy, width, height)
    & L2 M' O1 j/ j0 X" F$ v
  2421.           $game_switches[switch_id] = true
    ' n5 j! R0 w3 h- ?
  2422.         else
    6 y  @6 y' r$ F
  2423.           $game_switches[switch_id] = false
    * L$ x6 A9 T& F. {
  2424.         end% \/ J& ~, ?" r
  2425.       when 3
      i# v5 ?. J- G  Y, |/ b: p
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,' M5 e/ G* X. _/ _
  2427.             (oy - $game_map.display_y)  32, width, height)
    1 M* Q. \4 ~2 i4 B
  2428.           $game_map.events_xy(ox, oy).each {event$ I$ \& H* k+ t6 G3 L% K8 ^; N9 [
  2429.           event.start1 u! r8 C- _5 a' u  U/ N9 P
  2430.           $area_responses.delete(response)& k) Q( O8 o! d, K
  2431.           return
    " ~5 w5 ]9 X9 I6 z
  2432.           }
    1 g0 b2 _+ N, f# w
  2433.         end  `/ [$ W) }& U! t  w# P
  2434.       when 4
    . l: _4 x, Y1 z2 s# H
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,0 L8 C% Q6 l9 h3 z/ {
  2436.             (oy - $game_map.display_y)  32, width, height)3 L& P  A; a: A& h
  2437.           $game_map.events_xy(ox, oy).each {event# @9 m* Z1 S; J1 }- f1 q
  2438.             event.start/ |2 I. N8 P8 U9 L: f
  2439.             return
    - j3 Z% \; _# V% [; g; x) G7 K" @$ y
  2440.           } 5 o2 N0 L+ Y& \1 J, N, N% U6 n
  2441.         end
    # h, w, i  A8 \6 Q8 z
  2442.       end' t4 \3 N- @( u5 `, R! L
  2443.     }9 d2 o7 \; u* |6 Q/ r
  2444.   end$ q5 e* ^4 r- Z% i( L: {0 }) G
  2445.   def mouse_in_area(ox, oy, width, height)+ _1 L/ Q1 q9 s, N  E( `7 d6 C
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&; u8 T: l' v" E8 _: }# l' L; x, ]
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height; U. h% E* V( ~
  2448.   end0 l6 y7 [+ i4 T' Q5 S* Z
  2449. end
    / J1 X: R. Q! r+ {8 m7 C
  2450. class Game_Interpreter
    ' q0 d- X! v. q. E, D8 y  T! j/ d
  2451.   def area_response(arg)
    $ v7 q  J( W" N  G% p
  2452.     $area_responses.push(Area_Response.new(arg))7 l6 W% x% f( i! g8 c5 K
  2453.   end" @. j3 C; n% Y4 S( j! p
  2454. end
    ! w2 I! h( o+ o- H- \6 }
复制代码

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

在本发帖返回顶部