查看: 811|回复: 0

存放腳本

[复制链接]

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

贵宾

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

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

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

×
純屬給LBQ腳本:
  1. =begin #=======================================================================7 t+ M) x& z$ |$ E; C

  2. 7 b! q4 g0 G1 T, ~" p6 K
  3.   Sion Mouse System v1.3e3 [7 |6 P/ X3 }0 s  u2 [/ O" M
  4.   
    + f$ A; v$ V2 I* W/ i
  5.   Changlog
    ; y7 L; O" \% L5 x1 t: B$ Z# Q
  6.   
    ; S4 [1 a1 E* u. `  c
  7.   2013.4.21 v1.3f; y, `! s$ ]3 D4 c2 `, z1 }
  8.    
    $ Z; G) S4 Y- L" @/ z( J( s
  9.     1.3f 卷动地图 bug 修正
    : k( b5 ^; E- E; g2 ~( f! b2 `
  10.     6 R. b1 S4 P- n. ]  W& U7 {, z
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口. z6 [! x) q! h0 g) D
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    / F6 X4 Z! _2 _0 {
  13.                               Mouse.unlock_mouse_in_screen 解除锁定# r  d( N' J9 t) k9 ?; n0 M) ]1 l
  14. & T: P, b* M# I7 M4 V/ _3 L
  15.     1.3f bug修正
    3 P( Z7 W# C; w" q
  16.     a( b/ X& A) ~0 f. F! q8 E0 \
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    4 x' P! }0 w% R. ~( U1 \
  18.           关闭菜单时,鼠标是否移动到原来的位置。: c1 J& ?) }7 b
  19. , z) l; l# J; S' g
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处% N6 D' {9 j8 }* W, W( u7 a

  21. / c# [, n3 n" a4 X  z% e" t
  22.     1.3b 修正一些罕见的bug;1 J6 E6 T( c: L+ Q$ ~; g1 M+ w
  23. ' i9 g; }; R% ]; L' F
  24.     1.3a 代码小修改;
    + w5 ^; Y" H& I3 J% {/ r
  25.           加入了鼠标点击启动事件的功能,
      i% ]  q; O, c2 \
  26.           在事件中加入“注释”: 鼠标启动  ,
    * Y) g% [( @% k5 l' `# y, }+ f
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。! {; d! f  i$ b3 c
  28.   
    - [6 }8 C3 i' O3 X; x
  29.   2013.2.12 v1.2
    4 I' u8 P2 O; }; x2 M6 e
  30.   r+ ~5 }' b/ c0 a% @1 c: z
  31.     寻路逻辑优化;
    9 n3 P- l  c+ @5 C% X" p& [1 H! _
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;" ^3 d8 j. q# M4 `% j& V
  33.     现在支持用鼠标来操作载具了。+ K; X" `: L: _" Y

  34. 3 N$ F0 f& t: b2 U* z
  35.   2013.2.8 v1.12 C/ ~( t, ~* b7 n3 B

  36. $ n) K$ `, ?3 f# y( _# t& g
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;& n  z, N+ C% K( Y0 x4 N$ Z
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    , R7 N, E) w* }% C' F/ r! o) L
  39.     移动时,路径指示点的绘制更加稳定;
    2 u0 ^: `: A* [$ V7 x  r) J
  40.     现在支持默认存档画面的鼠标操作了。
    ! V5 A5 q8 w2 k* P) a% I+ W
  41. 3 V3 y% b0 {+ U4 M, z- ~

  42. . Q% q% u  y* I
  43.   OrigenVersion' o9 O: J& B, k2 M7 X3 T* W' ]
  44.   / B& [, V% o3 b
  45.     2013.2.7 v1.0 ) @' j  m8 D0 U; ]) D& ~
  46. 8 ]0 x4 @' y( _% y6 {) o
  47.   主要功能  p) D; S9 Q" F% L3 p! O( [
  48. 6 L$ }8 l: r7 c" {4 H+ C+ ?
  49.       使用鼠标进行各种操作...' z; S9 R& T% F$ Q; r
  50.       将鼠标锁定在游戏窗口内9 H2 |9 {4 G  ^7 t& K) N1 c! E
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    9 H7 b$ V; v2 a( l- C% e5 L4 \  z' G1 ~
  52.       双击鼠标进行冲刺
    - P% `9 w) K* @' s, a
  53.       更改地图卷动方式以适应鼠标移动2 g2 V* G3 _/ w! a' G$ H( s
  54.       变量输入框改良  @5 z' i0 Y) S! |! @5 ]* U

  55. # I: g. T# C& N: X1 ?
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    4 N! J6 q- f) d  B# ]3 V4 }

  57. % A5 _/ }5 I/ W1 \' `, R3 |2 _
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    8 I% l6 A) C! p( O6 K9 |8 U
  59. 3 n+ u. ?* Z/ m  _+ X% o# S5 R3 U
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    . Y# f) s& R- A" J  x" d# g, J( h
  61. # Z; Y' u: \  W# I2 j
  62. : P2 O$ |, v7 R6 d3 B! g
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
      `& L+ k6 E1 p. \

  64. ! `# x1 a% u/ t1 t: C
  65. ( m0 J( T% n3 F8 D1 U( V
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    & u2 K' I! M; V" R( Q1 H5 f. k: {
  67. $ q# j' P0 Q. S) J" E3 I
  68. #==============================================================================! [$ a, d. x! F6 O9 p
  69. # ■ 常数设置 0 I( D4 U& a  D* W6 w( N5 j1 p* x8 k
  70. #==============================================================================
    . }$ k# K8 W6 ^' p" T8 o$ {
  71. module KsOfSion" `/ b! V% H( z6 ]
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    4 H. Q; n- \0 M' }" A
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑* `! m/ p* r; [- N. c1 U
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false: M( c$ U0 g$ Y' Q0 w7 L
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量4 m( g" t/ n  |
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    0 D5 q) u; Z+ t# g  i0 _" s$ ]
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧, I" o) G' j- B! K! [* M7 r( \" ]
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    5 k% [! a6 v# x) ]9 Z
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键& |% i; s  l" f4 _
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    % \, g1 D* a3 k' P. M2 v% h
  81. end
    / ^+ m1 V- T  C5 m$ m% [
  82. ; J' @8 |% s' [% W: d+ y; B& r/ [
  83. #==============================================================================4 A' c* G6 b7 O8 j0 o# _0 }
  84. # ■ 用来显示路径点的类
    ' `6 e# i8 _0 H( V
  85. #==============================================================================
    $ I3 a- V1 K; O0 Z+ j; j8 o
  86. class Move_Sign  Game_Character
    ! |! f( o# x6 F3 [
  87.   #--------------------------------------------------------------------------  }) Q* S2 ?& Y5 W+ h
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
      s6 c. {6 D3 B' |2 `8 u0 C
  89.   #--------------------------------------------------------------------------6 m* N7 d* }$ e* _4 @4 n
  90.   def init_public_members& u$ d# @) J) m
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    9 B! y% R4 u4 B  [. C1 d' d% S
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0% L7 ^7 z" Z- l: q- t! e- J; v
  93.     @move_speed      = 5        # ★ 踏步速度
    3 C+ K" P0 d" F8 U+ C1 N
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    3 N( n1 ~( ]8 O1 Y
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度# T' C/ L; }$ e* f, |; Q- {, ]; c6 y
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    2 K1 s/ K  x  A- M$ T
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列/ M* S! b8 B9 \, R5 T
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    ' c  k( T! W4 z- O$ d6 @! Q

  99. . g/ D1 P/ o2 ^5 e5 Q; E0 l" o
  100. 8 q8 @7 L. ?! B* Q1 c/ @
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★; p' k7 L! S7 f2 n: a; L

  102. 4 \, i$ j1 @" o  a$ A

  103. ) @" a0 z+ k  L+ M. \5 v: q
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    ' e) r0 g4 L" j# q
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')7 f  ]5 @. q7 Y" U

  106. 3 [0 a) J0 O2 p' W1 n# ]' S6 L
  107.       if $no_arrowpic_warn$ n* h- d0 w6 u
  108.         MouseShow_Cursor.call(1)
    3 K0 x& f8 J3 P& T! P  T
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png0 k- _! S$ _- E0 B, b* l& C

  110. 3 \5 P+ ?7 q. n# s; R) |3 \+ P6 l1 D
  111. “路径指示点”将使用游戏自带图片
    ' I9 f* Y8 A' E  `) @" h
  112. 6 @' E2 r' z! R4 ?/ k9 F3 H
  113. 该提示可以在脚本内关闭')
    6 C* q, j) Y- W
  114.         MouseShow_Cursor.call(0)
    # e0 @0 N$ ~6 _$ |- |  u. }
  115.         $no_arrowpic_warn = false- j4 G9 H+ v7 M' W3 X
  116.       end
    ; n) [9 H' z7 I5 F/ p" b
  117.       @character_name  = '!Flame'# [9 @: d0 }+ D! ]
  118.       @character_index = 6
    9 `1 D8 Z2 D! @4 C6 V% A7 ~
  119.   M9 Y9 |2 i# i& \7 r
  120.     end
      A3 j7 u0 v; J) L, n
  121.     @direction_fix = false  # 固定朝向
    % A' {9 p1 B$ ]- ~
  122.     @move_frequency = 6     # 移动频率
    6 y% ?. p$ J6 l6 B
  123.     @walk_anime = true      # 步行动画
    - R8 o) D3 V/ v2 ~& U
  124.     @pattern = 1            # 图案
    ' o1 Z. Q# }# {8 d: j, f2 e0 H
  125.     @through = true         # 穿透  ^+ J* n( Z2 U
  126.     @bush_depth = 0         # 草木深度, j" L: t1 ?- \0 B
  127.     @animation_id = 0       # 动画 ID
    : [5 z' S, W. B9 c# A4 p1 V; v& V
  128.     @balloon_id = 0         # 心情 ID
    & f) J' o2 \* z; ?( u
  129.     @transparent = true     # 透明5 @" t6 f1 c* |
  130.     @id = 0
    % t6 _* n& B" e6 ~! d, o7 u2 ]
  131.     @x = 0, q* `. r* _7 \3 k
  132.     @y = 0
    ( A* z* n4 H% l3 n% t9 G8 X
  133.     @real_x = 0" H) U; i, b/ r3 F. j& `! k
  134.     @real_y = 0
    " S3 N2 b+ S. f* O
  135.     @tile_id = 0
    7 G& n& L+ g( b0 |1 J0 J" k, J
  136.   end
    ; z9 g1 c3 e* U4 R
  137.   #--------------------------------------------------------------------------9 S( h! [! G& ]' s3 N. [
  138.   # ● 定义实例变量
    8 r! z& T7 D. x* g% d/ ?$ @: O1 N
  139.   #--------------------------------------------------------------------------
    9 E) y2 R) U+ n4 b- w
  140.   attr_accessor direction
    , p5 |8 t5 D: G' l2 F* K( Y, H4 c
  141. end) N1 E. U- x# }! u
  142. 3 [2 k% @1 d8 R7 v7 y% Q
  143. #==============================================================================3 \0 O" q8 G; [0 i$ x8 s
  144. # ■ Module Mouse9 n2 O8 ?% o: ]
  145. #==============================================================================
    9 v9 ~: p0 ?; N4 h: [8 F6 r
  146. module Mouse
    + s7 [' j% `' h/ c
  147.   #--------------------------------------------------------------------------. ^: F, B5 D; c8 T# q$ k, R% Z
  148.   # ● API* h8 i8 W, i/ t% q
  149.   #--------------------------------------------------------------------------6 S5 f/ m4 {; S; X
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    ! g$ @: b  e) \8 V
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')8 N! Q: ?0 `) l( i2 L1 s
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    . ]2 G0 w4 K4 [5 a; a3 W6 D  Y
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    , v4 g( r& c2 l! [- O/ X0 [
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')1 }$ i6 h$ Y# x
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    ) n7 T- a1 _# @4 x' `% a, \
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')4 t( R* N* t. \* \$ l: r" I7 @
  157.   Window_Hwnd       = Get_Active_Window.call; D. P; z3 d4 `( O# z# g$ y  U6 b; q

  158. . h! v& y& s- l" W* E" [; V
  159. class  self
    * {$ n/ Q3 T0 Q
  160.   #--------------------------------------------------------------------------
    6 g! }8 r% h/ f
  161.   # ● 初始化; x' E, m$ e2 _" G# u
  162.   #--------------------------------------------------------------------------
    3 M" s* l( I  u0 }6 a' ^, l
  163.   def init
    - V4 W4 p$ {" t
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    ! e4 U3 `. p! r: S4 ^$ r% `6 x
  165.     @left_state = 0
    1 B) o  F' m9 N7 R' j1 X* D& C
  166.     @right_state = 0- A8 A4 K) Y+ |
  167.     @ck_count = 0 # 帧数计,单击以后从0开始  M: j. B' [) s8 S' a5 K* A
  168.     @dk_count = 0 # 用于双击的判定5 u, f* r) a) C% v2 Y
  169.     @clicked = false" [; h# u$ [. g5 R0 Q6 P$ v7 g
  170.     creat_mouse_sprite! N1 `% l; w  r0 O" i! u$ {
  171.     update! E0 q7 I  L7 E. M: F  B
  172.   end  b& o4 d+ h8 Y% C: a- D1 k
  173.   #--------------------------------------------------------------------------
    - J6 w& W& B7 T
  174.   # ● 鼠标指针精灵
    ! U& }( T/ T0 t4 p0 W' `: ^0 v* p
  175.   #--------------------------------------------------------------------------0 ~! p! ~' J3 W- Z' Y* V9 h* @
  176. #~   def creat_mouse_sprite
    2 ?7 G  n3 r* v6 z4 i+ g
  177. #~     $ }  i7 i  Z' b8 Y1 d
  178. #~       @mouse_sprite = Sprite.new0 s& F/ _1 c8 R6 z
  179. #~       panda = 2#rand(2)+1
    7 G1 l$ A  b) @. h' \% H6 Q
  180. 4 Y) Z, L1 K' T6 @2 v- a+ l( K/ R
  181. #~      if panda = 1
    " v! J. K4 }/ P  {6 A
  182. #~        if File.exist('GraphicsSystemCursor2.png'), H+ H# V2 o3 d' W& |2 I/ S
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
      t" t# X( n. c8 M
  184. #~        end#with if File.exist) g& p3 Y: E: H& w0 @& l
  185. #~    0 }: n. m" e- n
  186. #~     else if panda = 2 #with if panda=1
    " y0 }  @4 W3 p0 {8 x5 J& T
  187. #~      ( I  k% v! @4 T5 Y
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    " M  g0 T1 o/ c3 Y
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    2 {. b% \4 }7 f. @
  190. #~      end#with if File.exist
    . b2 i, u) Y# }# r! q
  191. #~       5 n. g3 u& y* g0 }$ }2 ^
  192. #~     else #with if panda=1
    / y& c7 x6 G7 z0 I0 q2 c/ Y2 \1 s, G
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    & @; I) _( D( }, f+ y- c" ~. v
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    0 n- J3 @& I  b9 Z
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    ( ~8 m( g# h+ s$ }# N0 y
  196. #~     end#with if panda=1
    8 o7 i! K8 h- e+ Q% R: Q" E+ l. {
  197. #~     
    8 S* [( b" Q; {+ Z, T: i
  198. #~     #with def4 P9 G$ _! s' p8 l( ^. H
  199. #~   end1 S; w. e3 F0 |9 M
  200. def creat_mouse_sprite
    6 w- W( A# V% w6 A% I  w
  201.     @mouse_sprite = Sprite.new' |; v4 d. s. {2 ^& \1 _8 j4 F
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})# q  k3 W% Z; e
  203.     @mouse_sprite.z = 9999( [% D9 p: I. x
  204.     Show_Cursor.call(0)
    2 @( g) X# F) `; ?$ Q# ~9 n- G
  205. end7 }0 b( a% N  W! o; |& F
  206. 0 z) P. l# J; t& T/ i4 B
  207.   #--------------------------------------------------------------------------7 }8 V. Q: }7 c% g
  208.   # ● 更新
    4 Y' a* n, a+ S+ t3 ]* m1 _" [( a
  209.   #--------------------------------------------------------------------------( m' v9 ^- a0 c2 j0 Z- I
  210.   def update
    3 \7 s# \4 t: g
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    & L7 d% ]) I* K; d; {3 {6 Y
  212.     left_state  = Get_Key_State.call(0x01)0 W/ ]7 S6 E, ~) N5 X5 ~- T0 u
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    8 ]! c; F, m( h2 {7 D) B: n4 X
  214.     right_state = Get_Key_State.call(0x02)" {' H0 h$ x: I
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    % f. a, L: Q% [5 ]( \8 {: S
  216.     update_double_click
    5 K8 T/ H6 c# O/ G
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    % b$ M) W1 Q6 ~
  218.   end/ l; z: u4 P$ Z+ A; {" T1 z
  219.   #--------------------------------------------------------------------------: _! S5 Y/ |6 }, }" ]0 l' b
  220.   # ● 获取鼠标坐标
    ( B+ G, y. M/ b
  221.   #--------------------------------------------------------------------------
    % t6 Z9 W4 q! e# G9 ~
  222.   def get_mouse_pos+ l# h4 C+ Q' U2 c
  223.     arg = [0, 0].pack('ll')
    0 G" U' b! E# m0 U
  224.     Get_Cursor_Pos.call(arg)
    $ q; c0 |. v& w/ X
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    6 u. V7 E7 h2 G2 d' U- A+ R
  226.     x, y = arg.unpack('ll')
    ( R# s) q, a& B( t
  227.     return x, y: S3 W! ~8 f. D2 g& B
  228.   end
    & d# m* v% U+ U9 t
  229.   #--------------------------------------------------------------------------8 H. T6 J& e/ p5 j3 Z# r" ]
  230.   # ● 将鼠标固定在屏幕内7 S8 H8 |/ j. O& I2 l
  231.   #--------------------------------------------------------------------------
    9 D$ W9 ?8 a  `# A* ]! D
  232.   def lock_mouse_in_screen
    + r8 U8 N% S0 E
  233.     arg = [0, 0].pack('ll')
    ! u! x5 t  c/ Q# U+ I
  234.     Screen_To_Client.call(Window_Hwnd, arg), y/ }; y% H: z7 J* C% [# C
  235.     x, y  = arg.unpack('ll')- s; h5 ^3 L( B1 B) h' S
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    & {% P6 c4 z0 J& S" ?
  237.   end8 [  `/ {  o8 a" M8 K0 v) w% I
  238.   #--------------------------------------------------------------------------
    3 c- g8 W: }% O& G8 ]4 F
  239.   # ● 解除鼠标固定
    / |& C" x- y& S8 t7 |& T; C
  240.   #--------------------------------------------------------------------------
    " g; J" R/ Y* w" h( [* @6 [
  241.   def unlock_mouse_in_screen& a8 t( x8 g* X0 }. ]
  242.     Clip_Cursor.call(0)
    0 Q8 k3 a, t5 N8 l* v6 R
  243.   end
      r$ u! h2 P' h
  244.   #--------------------------------------------------------------------------
      D. `5 @9 R5 `2 {. v3 G5 {
  245.   # ● 鼠标双击判定
    $ |/ z. E7 g$ v% M
  246.   #--------------------------------------------------------------------------
    - [! O, F$ V8 S" C
  247.   def update_double_click7 a- `* r* E( J3 K
  248.     @clicked = true if @left_state == 1% U9 A4 p$ n0 {1 Z# }* w0 x4 n
  249.     if @dk_count  0 && @left_state == 17 ]- `* C9 ~+ c+ L/ d+ X6 W' p
  250.       @dk_count = 0; @clicked = false# I. [3 s! B1 Q( ]/ Y2 B$ G& f# n
  251.       return @double_click = true
    5 x# H# D: `6 S6 b$ A: ?# Z6 q
  252.     elsif @clicked. B5 r- t4 p) V! P& h6 }6 X
  253.       if @dk_count  KsOfSionDbclick_Frame+ o9 [% I3 A0 K: Z- y$ L4 C
  254.         @dk_count += 13 X. }- z1 i+ w; Z- K3 L6 u# ]
  255.       else3 S# U/ I  f2 |4 j& A+ {
  256.         @dk_count = 0; @clicked = false- Z' e2 @; _) w0 o7 }
  257.       end
    5 G0 v9 s% I- ~
  258.     end
    & n3 @/ h# }: a! x; w2 M
  259.     @double_click = false1 ]1 T( E  M( `: b0 e
  260.   end
    0 l0 f4 Y  }* f, ~8 l9 i% ~
  261.   #--------------------------------------------------------------------------- ]: ]; ~" o" x
  262.   # ● 按键被按下就返回true
    ' r9 d9 p6 {  ?
  263.   #--------------------------------------------------------------------------
    ) a: n" d3 }" `& p7 ~/ P& H
  264.   def press(button)
    / \& O( m0 W0 }# a# X
  265.     case button
    3 S5 U" x- x$ r6 t% Z
  266.       when 0x01; return !@left_state.zero; v- M' _/ |/ t% D0 e
  267.       when 0x02; return !@right_state.zero
    , O, p( {4 J6 V! C
  268.     end" Z: j* U! G/ A; x7 @4 H
  269.     return false3 C4 |+ J" f% q' u" v4 D0 M
  270.   end& [- r# o$ m, q2 j, k
  271.   #--------------------------------------------------------------------------, c5 n" x8 A  B' R% r7 H) x
  272.   # ● 按键刚被按下则返回true
      x; D4 v& d5 [* t; b2 K2 U2 j
  273.   #--------------------------------------------------------------------------, J3 Q9 w' }& J. d2 H, {! S' B9 [' }
  274.   def trigger(button)( }  e! ^/ S0 a2 Z/ Y
  275.     case button" D+ }9 v2 J4 G% G5 C1 r
  276.       when 0x01; return @left_state == 1
    * E& |" L( c6 G5 D$ g! [
  277.       when 0x02; return @right_state == 1
    : A/ ~. \9 M7 J0 E5 q4 C
  278.     end) W1 ?( V. o* O- s0 e! A  k
  279.     return false4 @! B) E+ E* ~( K$ W" H& x+ t
  280.   end% J  V* ?  e8 K4 s4 M9 q& y2 x# V
  281.   #--------------------------------------------------------------------------  @, m. x( h, k( w
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    # R; d. d+ j' D2 e
  283.   #--------------------------------------------------------------------------
    0 |- k! v0 K9 I3 S$ R$ b
  284.   def repeat(button)
    8 \3 R* w& E" G( E. f; y# j
  285.     case button7 L' c- V2 g. ?6 e  L& y& c
  286.       when 0x01; return @left_state == 1 : i, M$ w, N& K0 A
  287.         (@left_state  22 && (@left_state % 6).zero)# Z" j$ b: r1 y' X* s7 s
  288.       when 0x02; return @right_state == 1 % ^6 x" Q/ i' t0 R. V
  289.         (@right_state  22 && (@right_state % 6).zero)$ k9 T) O6 n5 j3 z4 S
  290.     end
    $ R7 }! s7 `+ a# W7 `3 @, a
  291.     return false& r4 O3 k) {. A: C. E( R
  292.   end
    * S0 y8 O& A, P; i
  293.   #--------------------------------------------------------------------------9 I; Z! D- w4 R
  294.   # ● 判断是否双击鼠标1 g) V: \3 r5 s- ]( H5 K
  295.   #--------------------------------------------------------------------------: S  B  a- i3 A1 q' J3 c
  296.   def double_click
    ( ]7 \8 N3 D8 n5 z, L  {
  297.     @double_click5 u6 O- A: }  ]; }* h
  298.   end- D$ ~, |, A7 {  n$ _7 U, x% ^
  299.   #--------------------------------------------------------------------------: z# F, y5 y0 Y0 Q8 f, v% I# U
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)1 m8 v7 g3 O' ]8 G% V* b
  301.   #--------------------------------------------------------------------------
    6 K+ @% v. _1 m- i$ i
  302.   def click_count+ ~  i+ y6 W$ {
  303.     @ck_count& L. ~" v  w$ H' D; j7 D8 `
  304.   end! u, I$ G. O* N& Z; y- m9 l* \
  305.   #--------------------------------------------------------------------------# b% p* \* G: n% p' P# q
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    $ }2 u9 L4 p, K2 N9 |/ _- G
  307.   #--------------------------------------------------------------------------
      }3 h& T9 |4 h# `8 D
  308.   def left_state
    % n, g' ?( p0 b$ O
  309.     @left_state% B* p- R' l% V
  310.   end
    & O) o8 i) @% H9 j2 B& I
  311.   #--------------------------------------------------------------------------
    % s3 x1 X- l+ ^5 I: t" j$ T4 ^
  312.   # ● 获取鼠标的x坐标
    * m1 ]1 x% w! s
  313.   #--------------------------------------------------------------------------
    ( w% O8 {2 _1 U+ |& i& M, H" [
  314.   def mouse_x
    . |5 R+ K( f; a; Q
  315.     @mouse_sprite.x
    6 Q% g! u! A* e/ i- f: f7 v( n5 b
  316.   end( p& T1 ?/ Y& V
  317.   #--------------------------------------------------------------------------+ u9 U  H3 R; L5 @8 L5 P$ J2 A
  318.   # ● 获取鼠标的y坐标+ I$ f4 S3 Z5 }4 e
  319.   #--------------------------------------------------------------------------
    ) e. q, c& [7 A  K1 X& }& O
  320.   def mouse_y
    * H* k" A9 E0 ^; v
  321.     @mouse_sprite.y
    $ d, `% }: ~+ B4 |$ u$ J& j/ a1 C
  322.   end- B, u3 m+ h: A
  323.   #--------------------------------------------------------------------------
    7 o8 i. X7 m1 V; R
  324.   # ● 设置鼠标坐标
    - F4 @2 B+ m- ]
  325.   #--------------------------------------------------------------------------2 e9 C( U4 K' ^  o$ N9 X  ~; B' ?
  326.   def set_mouse_pos(new_x, new_y)# b/ i6 L0 {  a$ `5 c
  327.     arg = [0, 0].pack('ll'). r3 v1 v" ]  k$ u
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    7 h0 q: @  J: k
  329.     x, y  = arg.unpack('ll')3 ]8 }) l7 B% S) h9 l& e" j- M
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)3 U0 Q) T& \( E8 ~! }/ ~* [5 t
  331.   end
    / B# s' y! E7 e' s; Q7 V& k
  332. end #end of class  self
      d4 U& w+ h9 u9 n+ l% N$ B0 u

  333. : X2 M, G" h. Z2 p9 C; `2 v. B
  334. end
    . {4 i- s0 }4 Y+ z& C/ v
  335. / T" H4 l/ _, Q2 P0 z3 G: k
  336. #==============================================================================
    ; R4 k6 c# q/ R( ^& b* c
  337. # ■ SceneManager' h) y* q4 ]7 P3 I/ P
  338. #==============================================================================& W2 L$ [6 ?2 g  d4 e' L3 C
  339. class  SceneManager
    ' S0 ~9 Y, N+ `" D" n
  340.   #--------------------------------------------------------------------------
    & o6 S$ }  C& \) F$ B* w0 W
  341.   # ● alias1 i6 [1 ?- |3 b
  342.   #--------------------------------------------------------------------------/ U# Q/ G/ X/ ^0 \
  343.   unless self.method_defined(sion_mouse_run)% W3 |, N0 d9 o1 k7 ?
  344.     alias_method sion_mouse_run, run
    3 }( @. S& Y2 H7 d4 U. j
  345.     alias_method sion_mouse_call, call. w  n5 v5 i0 @* f. t3 D7 Y. x
  346.     alias_method sion_mouse_return, return
    / P$ Q2 e6 w% O" {8 c& ~! Q6 Z- c/ F
  347.   end
    9 l- y: f" |5 }- X# H3 h
  348.   #--------------------------------------------------------------------------
    & f. p6 i/ ^7 u# J4 F1 k
  349.   # ● 运行
    6 P$ E9 \* _  m/ ]) ]
  350.   #--------------------------------------------------------------------------$ J2 U3 ^, o* d9 K+ [
  351.   def run
    % z% J) y! V( u' y
  352.     Mouse.init" @) {1 u& V9 p0 h
  353.     sion_mouse_run
    . O. b9 `/ z+ n% B" D; p
  354.   end
    . h/ J8 I. D0 V' b. S. }* x! d4 K- K
  355.   #--------------------------------------------------------------------------/ D9 o9 U" r; M5 s; k
  356.   # ● 切换
    - S/ I, V( Z( A' O- o3 P; n" Z7 \
  357.   #--------------------------------------------------------------------------- Z. B* D% e( y+ l7 ?. o
  358.   def call(scene_class)+ f( w6 \2 D6 d7 E9 F) @
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)* C& e" O6 p1 W7 ~
  360.     sion_mouse_call(scene_class)
    4 v# k( f- U" ]5 \- ~, m
  361.   end
    0 Z6 p- P8 c/ O" s
  362.   #--------------------------------------------------------------------------1 p$ j# B9 \( T( p8 h' o8 `0 B% U
  363.   # ● 返回到上一个场景
    + c& X9 {- Q7 o3 z
  364.   #--------------------------------------------------------------------------" Z" u4 \) N% R' |
  365.   def return6 u& \5 v, Y$ r9 v, a& ?& F
  366.     sion_mouse_return
    5 Q/ u0 p4 m# @" d; x/ C; n
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    * b, I& d6 D/ _4 y& M
  368.       @scene.instance_of(Scene_Map)
    9 I/ _5 [) @3 _, X2 s
  369.   end& `0 Z7 y" B* g: [7 ^5 I2 I8 ~5 m
  370. end
    5 b* E7 O; d) \0 l; ~7 J

  371. 2 `4 ]$ W1 a* p, L3 o
  372. #==============================================================================
    : }! }% H3 C) v+ R) Z
  373. # ■ Module Input4 g8 J7 R- {- b% R  {4 h4 I2 {7 j
  374. #==============================================================================7 K5 h. ~( H3 f) R' n& u' D
  375. class  Input
    " M: D5 h$ p, x" T! z
  376.   #--------------------------------------------------------------------------6 b/ d7 F" D( @  D1 i. k" C" x
  377.   # ● alias
    : r3 }  A' C4 q3 @+ m; A
  378.   #--------------------------------------------------------------------------
    : t) [% U5 `" V
  379.   unless self.method_defined(sion_mouse_update)
    1 o9 [6 X( [) X2 ?. V
  380.     alias_method sion_mouse_update,   update- i; M4 E- I6 U  s6 h
  381.     alias_method sion_mouse_press,   press9 a, w/ x1 T4 I9 W- U, b2 o& n
  382.     alias_method sion_mouse_trigger, trigger  I8 z$ W) L) B1 V
  383.     alias_method sion_mouse_repeat,  repeat( d" x+ ]! \0 f
  384.   end
    " E9 C6 i' q, I: M
  385.   #--------------------------------------------------------------------------# T! V3 K. c$ z7 q' c" d: S0 V
  386.   # ● 更新鼠标
    , V# B7 n4 s! e; u  `, ~
  387.   #--------------------------------------------------------------------------! x2 ~$ A" k  w* @: V& |# L
  388.   def update
    ' n  J1 ?) w" l+ V4 l+ ?1 N1 |
  389.     Mouse.update
    ' _4 ]( ^2 U; g% S* ]
  390.     sion_mouse_update1 e, H7 i, B) g9 {. h
  391.   end' A/ c  n- D8 L/ }$ t8 J
  392.   #--------------------------------------------------------------------------  q% @) P! _3 s
  393.   # ● 按键被按下就返回true
    & I: L1 S6 ~" Z0 i" L
  394.   #--------------------------------------------------------------------------7 \3 o; }, T- J7 i# f7 b4 v1 K) J
  395.   def press(key)
    8 |8 W1 Q" d2 z! v+ `- z
  396.     return true if sion_mouse_press(key)" d" G8 s6 q$ G
  397.     return Mouse.press(0x01) if key == C
    - S  u3 x. h: N! L: g
  398.     return Mouse.press(0x02) if key == B7 s& |4 b- v5 d% R0 C
  399.     return false
    - B; G  U- v+ X) Q  B
  400.   end7 {# b. F. Y' E
  401.   #--------------------------------------------------------------------------( M: w% B3 X& p& `/ m
  402.   # ● 按键刚被按下则返回true
    & S' m* e$ c/ C! d
  403.   #--------------------------------------------------------------------------3 d/ |% X, \+ Q3 n# G9 r6 t7 z
  404.   def trigger(key)( P/ t& }! {9 H7 K0 n
  405.     return true if sion_mouse_trigger(key)# [% }7 Q. l2 O$ w/ [
  406.     return Mouse.trigger(0x01) if key == C
    0 d: J, L& v: Z2 F
  407.     return Mouse.trigger(0x02) if key == B
    8 g6 g* \5 q& T! w
  408.     return false
    . R0 |, v0 U0 g
  409.   end" ~& ?$ u/ n7 K& o
  410.   #--------------------------------------------------------------------------
    " o! o) F" u- q
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    : L8 O. p, N/ H2 R, `$ M2 [
  412.   #--------------------------------------------------------------------------
    ; n  e6 n& [# f: z7 ]9 A
  413.   def repeat(key)+ m& f4 o( {& q- c: a& v, h
  414.     return true if sion_mouse_repeat(key); @, z1 F7 \" z. H5 q$ P, r
  415.     return Mouse.repeat(0x01) if key == C
    : G6 R) |4 ?! d  r$ n' j8 Y
  416.     return Mouse.repeat(0x02) if key == B5 H2 h) D, R, _7 c5 c
  417.     return false( R& P9 q5 |8 Q2 g' T$ `6 A
  418.   end# ]- Y1 y) @1 N; k1 e7 a
  419. end" }0 G# {2 o" N

  420. * a( x$ k. k, E4 i: |5 a! m

  421. : |" n$ M" f) W
  422. #==============================================================================! w& a) ^$ M- {8 w* |0 b
  423. # ■ Window_Selectable" Q7 ~; z: q* v3 K) k
  424. #------------------------------------------------------------------------------
    * s3 h* p6 O* Y# g: F
  425. #  拥有光标移动、滚动功能的窗口
    3 s6 H* l, g, S: c& \9 `
  426. #==============================================================================
    0 h- k! |8 D  _" B# r6 g7 ?6 ]. O
  427. class Window_Selectable7 {# S  Q% `; ^
  428.   #--------------------------------------------------------------------------2 q$ J8 e$ u7 Y" ?7 q
  429.   # ● 初始化8 Z8 N2 s5 l3 l: S7 l
  430.   #--------------------------------------------------------------------------/ y$ R0 {3 l+ }* w! q% X
  431.   alias sion_mouse_initialize initialize
    # A6 _5 l# v) |8 U( I
  432.   def initialize(x, y, width, height)
    ; H8 U) }/ M$ X2 W# o0 m" Z1 j
  433.     sion_mouse_initialize(x, y, width, height)
    . V( v7 t( C* j+ E
  434.     @move_state = 0# D5 R1 p9 j4 f! s: D4 H
  435.   end' T+ T3 g# @3 J" x! p* f( n
  436.   #--------------------------------------------------------------------------$ P% @: y. X) Z, x/ F- B
  437.   # ● 更新2 i/ T, g  S/ h: I/ K
  438.   #--------------------------------------------------------------------------0 ?3 S: ^' r! D- h
  439.   alias sion_mouse_update update
    4 C9 ^0 C' {8 K1 v* S' q/ r# m4 E6 b
  440.   def update' B8 N9 J/ z6 T" I
  441.     sion_mouse_update
    1 D: \: ^0 v  m6 _0 N
  442.     update_mouse_cursor
    9 c9 [" O$ o" ^. N. `
  443.   end. X3 H9 w" D. s6 H  E; Z
  444.   #--------------------------------------------------------------------------$ P' G9 |0 t! J7 }& m) l+ K5 w8 N3 ]
  445.   # ● 启动后设置鼠标到index位置; d/ F: R1 j$ ^& ^5 ~) D0 E2 \2 k
  446.   #--------------------------------------------------------------------------* K" @$ i& F( f
  447.   def activate
    3 ]0 Y) ?8 z& W- N2 v
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    , B0 L$ o4 L5 J2 P& W; r9 l
  449.     super& B' W% g$ M9 y0 L+ z; i
  450.   end- ~/ Z' U2 i7 o, {( x# u: ]0 o! ]5 \
  451.   #--------------------------------------------------------------------------
    6 X2 C+ ~- `+ A. T
  452.   # ● 更新鼠标和光标的位置1 {! p# d! j' j1 L, i# I
  453.   #--------------------------------------------------------------------------2 \" E7 n% f4 w
  454.   def update_mouse_cursor
    6 e5 G7 s  ]0 [/ m& \% O. ~4 O, N
  455.     if active# _. l; A: q) W
  456.       if @need_set_pos0 N. B4 d* j( |# k7 E
  457.         @need_set_pos = nil6 a" ?) T4 Z$ g' W" D
  458.         set_mouse_pos6 d) ]5 I/ ?# \: W
  459.       elsif cursor_movable$ `6 o8 ]$ m2 c& ?+ N
  460.         Input.dir4.zero  set_cursor  set_mouse_pos' G' m6 a- L. V+ R/ A# `
  461.       end% y. \$ a# ^$ S( J9 _, x6 S
  462.     end( q# d% }* ^* Z5 Y& e; h2 Y# d6 ]
  463.   end
    4 I, v8 S( v0 I
  464.   #--------------------------------------------------------------------------
    7 a1 {& X6 A! N6 m" i
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    # L4 U+ {2 S7 Q* X( g
  466.   #--------------------------------------------------------------------------$ e5 n* m- Z* x' s  B0 ^
  467.   def set_cursor
    9 K. B, y5 z2 i8 `0 s4 M- h# y' _
  468.     mouse_row, mouse_col = mouse_window_area
    3 k6 w+ a& c3 p: i; O
  469.     if    mouse_row == -1
    . E3 h% s3 W# V# p' d+ h/ i
  470.       @move_state += 1 if need_scroll5 U3 K5 A5 |: [: Y1 z: I8 e! r
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand9 `; P4 h6 Z- l; j0 |" ]; M
  472.     elsif mouse_row == -2, O0 @, b+ L  f
  473.       @move_state += 1 if need_scroll, e8 j/ I$ o, y; N3 a5 E
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand2 o' m7 b8 s9 p; |7 ]8 a; L4 K
  475.     elsif mouse_col == -1
    5 u5 s3 I& \1 L! [( q& i; F
  476.       @move_state += 1 if need_scroll
    + S- r* S, o% g
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    3 @% y2 n) w$ q9 Z2 x# W
  478.     elsif mouse_col == -25 z# S! M3 I: c' E! j
  479.       @move_state += 1 if need_scroll( S/ W0 H( d6 r' t
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand/ f2 T( j/ p! ~1 s# ~+ h
  481.     else
    6 Y, V! z* i0 g. i9 C6 g6 f
  482.       @move_state = 0
    ; W" T' c- n$ Y3 a( Q, h+ G2 A& q
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col5 c* [9 G: y# J
  484.       select(new_index) if new_index  item_max && new_index != @index  A( g4 v4 `0 D1 {! J) _/ j
  485.     end& p3 ]7 ]1 M! X  X& o
  486.   end
    9 F2 D, q! A2 L  o% C# P
  487.   #--------------------------------------------------------------------------
    / f* \5 p+ Z4 q7 m
  488.   # ● 判断鼠标位于菜单的第几行、第几列. x9 I  l* c& U: \5 e, {
  489.   #--------------------------------------------------------------------------7 F. o$ Z, g. j; u
  490.   def mouse_window_area
    : G+ c" Z: }* m8 m; J
  491.     if viewport.nil # necessary!& R- X9 y. A) c8 Y
  492.       vp_x, vp_y = 0, 0
    ! J7 G! @/ h4 z$ _6 A/ s# `8 u
  493.     else
    3 }3 D! L/ o6 z, y- q% o# N
  494.       vp_x = viewport.rect.x - viewport.ox3 X, I  n/ W, I* g4 p: |" q
  495.       vp_y = viewport.rect.y - viewport.oy$ R; ~0 v" P& C' \: j' K
  496.     end- [* D) }* ^; F: {
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    4 z) e/ I( m; i; i8 \
  498.     item_x1 = vp_x + x + standard_padding
    2 R5 ?" s% c' q8 q
  499.     item_y1 = vp_y + y + standard_padding9 T: K/ ?! U6 X
  500.     item_x2 = vp_x + x - standard_padding + width
    , `; w/ [" w, B+ x4 [
  501.     item_y2 = vp_y + y - standard_padding + height8 |( m& }2 i4 W9 |6 Q8 I+ \
  502.     if mouse_x  item_x1( _! W, z* M2 L
  503.       mouse_col = -1& t  C' u( ?  V. Z- M' e& }! h2 ?
  504.     elsif mouse_x  item_x2' K5 {8 u9 G! `  Y/ n  _
  505.       mouse_col = -2
    , ?  H/ M1 M* T5 N# D" `
  506.     else6 x, G% a  |- g9 j( o: c+ t
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    $ M% ]2 \: M9 J: B8 e" @
  508.     end
    $ N' k, |. [8 w- n
  509.     if mouse_y  item_y12 G5 ?$ [! u* j6 h) C& l* a3 Z
  510.       mouse_row = -17 Q5 P9 o$ b' T. M3 ~- \* t
  511.     elsif mouse_y  item_y25 i% v: R& j. o
  512.       mouse_row = -2; M4 G7 p& l& @0 @
  513.     else6 ^6 f/ ~3 `1 x( G# w
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    3 ]! }: R; l* h
  515.     end8 Y) t7 Y8 u  ^# ~$ z- `! d  m
  516.     return mouse_row, mouse_col1 U' B7 u+ a9 C8 ?( I; o" |
  517.   end
    3 {! _7 U9 j% w' S
  518.   #--------------------------------------------------------------------------
    . |$ k* t3 \8 Y& M; G, T2 ]
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    * m, l. l! m4 B; [5 W) Y
  520.   #--------------------------------------------------------------------------9 {8 J' m' l" W( p; |+ W
  521.   def set_mouse_pos
    ; M) a4 w8 k( U* F: }
  522.     if viewport.nil # necessary!
    5 P1 j, ?. m/ e/ f# H+ B6 s8 q
  523.       vp_x, vp_y = 0, 0! y8 P% ~' b5 c/ G4 X' j( E
  524.     else
    . T% k3 g% D# N; D% {; r. W& U
  525.       vp_x = viewport.rect.x - viewport.ox
    % N4 x' O& i' \) b! T
  526.       vp_y = viewport.rect.y - viewport.oy
    ! H$ e- U, T# D; J: D# X0 |
  527.     end6 C* o$ ?. Y. L' t1 P
  528.     item_x1 = vp_x + x + standard_padding 5 L: _" e) c1 f  u0 }" x( Q) Z+ g
  529.     item_y1 = vp_y + y + standard_padding
    3 ~$ \4 y. D: m  h. V! C+ W+ [4 G
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index 6 X, M; u: M9 z1 l6 Q
  531.     row = get_index  col_max - top_row+ C' r" A( u& K8 J$ `
  532.     col = get_index % col_max
    + M: A9 k/ h# Q; c  s
  533.     new_x = item_x1 + item_width  (col + 0.5)+ k5 l2 W6 X9 f- A' P5 u
  534.     new_y = item_y1 + item_height  (row + 0.5)+ e0 |, P  H9 i1 j+ C: G. A) j
  535.     Mouse.set_mouse_pos(new_x, new_y)' ~3 H4 _8 z. s3 t4 [6 m# }
  536.   end" y7 p. m0 |- U1 C$ l) o0 i1 I+ x
  537.   #--------------------------------------------------------------------------# l( q9 j" W  r; S4 a
  538.   # ● 判断菜单是否需要卷动
    ! R/ Z: T# h6 c
  539.   #--------------------------------------------------------------------------
    7 z3 G: y0 A+ L( H" {, U
  540.   def need_scroll% D& }; T0 f, j) u+ e
  541.     item_max  col_max  page_row_max
    % b. P, ]; U. z8 |7 i5 i) D3 x2 S
  542.   end
      s1 u' J' M* H
  543.   #--------------------------------------------------------------------------
    * Q; U1 g- O4 g- \0 W+ O
  544.   # ● 判断是否为水平卷动菜单+ s' ~+ m* ^2 v* @. D
  545.   #--------------------------------------------------------------------------
    * l* Q$ a* ]$ Z0 q9 K2 X
  546.   def is_horzcommand# _  ?3 ^9 b7 |  z! E! }
  547.     return false) ]5 |+ F8 b' `# q
  548.   end
    & R6 K2 X+ a* X5 Q4 ]& j
  549. end! X$ g" c# F4 O. ^) d7 s& p

  550. " u+ C) [% G9 r" U: ^& D* F
  551. class Window_HorzCommand" n8 h) H' `% `/ B4 Y
  552.   #--------------------------------------------------------------------------3 \! b" M0 A4 b; t
  553.   # ● 判断是否为水平卷动菜单
    2 ~% w0 b3 R, V$ n. T. C& a6 R6 b" s
  554.   #--------------------------------------------------------------------------* A; T+ Y- [% u6 E( {
  555.   def is_horzcommand! R" D: B5 s3 x$ ?
  556.     return true  i9 r: u. ?; c$ L  T
  557.   end
    5 M( U, z7 S( ]. i8 d4 ?
  558. end- V, ]5 C) ~3 C. f  {! S8 n  d
  559. ' S. z! n( P0 |$ a$ ^
  560. #==============================================================================
    9 w8 f! M3 x( U$ C; a
  561. # ■ Window_NameInput
    . s4 P$ O3 u5 m; }3 O' J/ Z3 y
  562. #------------------------------------------------------------------------------# y( X8 A3 B" F& A( g2 U
  563. #  名字输入画面中,选择文字的窗口。
    " _+ L& B2 N! h4 z! }" Z0 M4 P
  564. #==============================================================================
    ! M; Y' X* K# A. z6 h1 d
  565. class Window_NameInput  ~) q% J4 g9 y4 Z" S
  566.   #--------------------------------------------------------------------------
    ! I2 c: m2 [) Y1 ~2 D
  567.   # ● 设置列数
    7 T; f+ |5 u- q( w4 p* k) X
  568.   #--------------------------------------------------------------------------% |1 H2 @8 I) o7 r5 O3 W$ A8 V# t% S
  569.   def col_max. |5 c: x2 a: N# s! w( `
  570.     return 10
    $ x$ Q" ~1 M2 y6 ^6 C2 \
  571.   end
    / J8 H& Z- a8 b
  572.   #--------------------------------------------------------------------------3 r* q8 ~6 T8 C8 B
  573.   # ● 设置填充的Item个数
    . B% m  S2 H% _- e+ f- S0 d: V( H
  574.   #--------------------------------------------------------------------------/ @( e0 q8 g4 o! f
  575.   def item_max9 Y6 c1 R/ `# C2 v
  576.     return 906 n7 V$ Z+ g  z2 w6 I0 Q
  577.   end
    8 s7 m! v, {' I. h9 S# q" O
  578.   #--------------------------------------------------------------------------
    / M4 c, T6 L* Z- a4 M$ o2 P
  579.   # ● 设置填充的Item个数
    : e! T( u* J9 y6 Q: l
  580.   #--------------------------------------------------------------------------% i8 d5 K* K; g9 ?  h' z
  581.   def item_width* ~8 B/ O6 ?6 S! b
  582.     return 32& ?4 O$ H, e! @$ j
  583.   end5 A5 q" x/ ^# o6 N; Y. S, d
  584.   #--------------------------------------------------------------------------
      }4 d( u- p; N5 C
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    * U9 b6 A1 s# ~) F$ h: G7 i, O
  586.   #--------------------------------------------------------------------------
    % G$ l) t2 K% G9 S# A3 d2 ?
  587.   def mouse_window_area5 R: E7 x7 N, P: x
  588.     if viewport.nil7 u# R& n7 r' Z1 m9 M0 P. |9 W- R
  589.       vp_x, vp_y = 0, 0  C9 m, r  b; F/ y4 D4 {
  590.     else8 L+ f% i# K8 V
  591.       vp_x = viewport.rect.x - viewport.ox
    4 b0 k2 l0 b& Q  e. F) h. y' F
  592.       vp_y = viewport.rect.y - viewport.oy5 j" B) G. |' d( u1 t4 I
  593.     end" Z5 `. T: d( X. Q/ U, i2 e
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    2 d& q& k$ @% y# a5 _( @- N
  595.     item_x1 = vp_x + x + standard_padding 0 m# i. e3 E, ^( _: a  Z. e
  596.     item_y1 = vp_y + y + standard_padding4 X0 B4 B) c% B
  597.     item_x2 = vp_x + x - standard_padding + width
    : a) Z; X" I  g( P
  598.     item_y2 = vp_y + y - standard_padding + height  z. F: C% Y+ v& P3 c
  599.     if mouse_x  item_x1
    - ?+ \3 X& ~' V) j; j! H" @
  600.       mouse_col = -1
    0 W$ I! r6 M" T) _0 w  I& z
  601.     elsif mouse_x  item_x2
    . L5 B+ u/ d& n* s7 A
  602.       mouse_col = -2
    4 R7 H2 J6 c8 T7 w7 x3 s' A3 J. O
  603.     elsif mouse_x  item_x1 + 160
    6 x' Z/ `6 ~: N5 i- [$ |$ L4 h
  604.       mouse_col = (mouse_x - item_x1)328 ~0 p; {- U1 B5 q! `8 _, `
  605.     elsif mouse_x  item_x2 - 160) d1 D3 G& x3 m- ~0 q
  606.       mouse_col = 9 - (item_x2 - mouse_x)329 ^2 }, P5 D0 S, ^" z: ?, ^) W& t
  607.     else+ H, H5 r$ O: o2 G% r- _4 @
  608.       mouse_col = mouse_x  x + width2  5  4
    0 i- [. s- Q$ S4 g, v  S
  609.     end0 U7 l+ a0 n  C7 Q1 o  f) g1 l8 h
  610.     if mouse_y  item_y12 ]  V6 C9 Y; n7 g4 r, t5 _
  611.       mouse_row = -13 Z' F+ `, A" j, U" v& N
  612.     elsif mouse_y  item_y2
    / I) r0 w1 h9 s2 H% P
  613.       mouse_row = -2
    , R/ D. N3 N* X! r" Z4 N1 T
  614.     else
    " t4 j. b$ k: n9 l- @
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1): J. m9 r% e2 v* u/ E
  616.     end) `2 J# F& [& P: ~+ z5 P0 i3 Q
  617.     return mouse_row, mouse_col
    3 |$ L% {- H) {7 S& C1 R! A4 q; h1 @
  618.   end
    % D- j, x( P8 Z1 g1 ~- J7 {
  619.   #--------------------------------------------------------------------------
    ( E% Z8 q1 n% m0 ^6 h! ~# s
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    6 F/ g" e3 C: c9 E+ C
  621.   #--------------------------------------------------------------------------
    ( [: L1 d# B0 b, r. J% E% i! M3 ?' Z
  622.   def set_mouse_pos
    - P, g' J- o3 d3 d
  623.     if viewport.nil # necessary!
    ; C  @! B9 K) I# W( B
  624.       vp_x, vp_y = 0, 0  R# c, r) l$ V5 O7 G5 \
  625.     else
    ! V* G( C. h2 z7 ^4 b2 \
  626.       vp_x = viewport.rect.x - viewport.ox: O' Z/ j' |1 R1 J; r2 t/ ^6 r
  627.       vp_y = viewport.rect.y - viewport.oy
      h0 A5 E8 I. K' }% ?; d
  628.     end
    ; Z0 v$ X3 i1 O
  629.     item_x1 = vp_x + x + standard_padding 1 Q4 i- X8 e0 x: d
  630.     item_y1 = vp_y + y + standard_padding4 y4 s1 z/ F7 c  S7 W
  631.     get_index = @index  0  0  @index
    3 b# ?- n9 ?0 _  k- S0 L
  632.     row = get_index  col_max - top_row
    6 b# N4 n7 O; T+ O; w1 T
  633.     col = get_index % col_max. l: p- j  ?" T4 B3 r1 _- @7 J
  634.     new_x = item_x1 + item_width  (col + 0.5)
    ( R7 y& X9 J1 x
  635.     new_y = item_y1 + item_height  (row + 0.5)9 n+ }  E; o: |
  636.     new_x += 14 if col  4
    ( z: P- y: P4 o  d/ N2 X# d
  637.     Mouse.set_mouse_pos(new_x, new_y)
      B, o: G1 B) j( w3 R
  638.   end% v  u7 }! J9 K# F0 _1 V: c
  639. end4 c! A1 ^+ e6 |* d

  640. 2 t# i  r( `2 @( k# J* D
  641. #==============================================================================
    ) X# C9 u# |( B+ w7 C& q% {1 U" \
  642. # ■ Window_NumberInput, }) I5 I" }& _! V9 K
  643. #------------------------------------------------------------------------------
    9 V/ D$ y0 j! O! k8 ]9 o# v5 p- s
  644. #  重写了数值输入的方法以适应鼠标
    : ~0 U% y3 R! ?. h* s* g
  645. #==============================================================================
    ' t& {) i( N8 ]
  646. class Window_NumberInput  Window_Base
    4 E+ F" l! L9 F# N
  647.   #--------------------------------------------------------------------------$ H4 M- G/ G7 [
  648.   # ● 定义实例变量# K5 I& y  [7 b) ~
  649.   #--------------------------------------------------------------------------
    $ i/ T% j+ l, n$ b* v3 T
  650.   attr_reader extra_window
      ]# y! d$ n- x& f6 l' ~
  651.   #--------------------------------------------------------------------------: U1 N9 u3 K; D5 S
  652.   # ● 初始化
    ! j6 z* S; c5 |' y, b
  653.   #--------------------------------------------------------------------------
    ; Z4 h2 _5 I# k+ M( ]
  654.   alias sion_mouse_initialize initialize8 V# k9 P& _! e  \7 f
  655.   def initialize(arg)
    : K; ?. i1 D& W9 ~
  656.     sion_mouse_initialize(arg)
    ! j5 J$ Q% v: Z9 A1 h" V
  657.     create_extra_window
    ; h3 f9 ~8 W7 z1 ~: C: I# E
  658.   end
    ( s8 H8 z$ n7 b
  659.   #--------------------------------------------------------------------------
    # |6 T( ^* ]3 b1 L* F
  660.   # ● 启动
    , D8 @% k$ P, y7 \. Z9 n; Z" j* S) m
  661.   #--------------------------------------------------------------------------
    " ^8 b) t- K. d% Z( [. b6 P9 j
  662.   alias sion_mouse_start start
    7 V9 M1 p1 |, D. f
  663.   def start+ H1 ~& |8 l7 a; p: T
  664.     sion_mouse_start8 H' C9 l8 j, D8 ]3 h
  665.     deactivate! W$ Z0 t8 r+ L6 Q1 K
  666.     extra_start- q0 v; o# {) w& |9 \
  667.   end
    ) p5 h: w! |/ E. k  Q
  668.   #--------------------------------------------------------------------------2 j- y" ?( d2 [+ z+ {
  669.   # ● 创建新的数值输入窗口
    : `8 k. ^# B: Y& H0 E( A! d
  670.   #--------------------------------------------------------------------------& ?! v4 j% I  Z  Z( Q. q
  671.   def create_extra_window" d/ U0 g6 T- D4 B
  672.     @extra_window = Window_NumberInput_Ex.new% w& i7 l+ ]' {. [+ U
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  20 d# i2 t9 k' K3 e
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }6 T+ i; D3 K+ }+ p2 c
  675.     @extra_window.index_proc   = Proc.new {n @index = n }8 m% V+ ]7 p9 |- d
  676.     @extra_window.close_proc   = Proc.new { close }# K1 Y0 ~# l) }" a; ?2 u7 W
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    ! {' U5 J0 [" W1 R& f
  678.   end$ i# }" M8 E4 B
  679.   #--------------------------------------------------------------------------
    * M4 D' J0 X/ K1 W$ ?( }
  680.   # ● 激活新窗口  Z2 [2 S$ ]: M+ H/ s
  681.   #--------------------------------------------------------------------------
    4 S+ E  ?" G1 Y
  682.   def extra_start, e2 K, d+ h+ R# A# S. ^
  683.     case $game_message.position
    ) p. T+ m0 `; q
  684.       when 0; @extra_window.y = y + height + 4
    / z" v9 o! ?1 l: c& \2 X
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    ( u9 g; i7 R& V$ a3 k4 l
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    : @* I5 `$ N4 G: I! t8 ?
  687.       else  ; @extra_window.y = 8
    : n% H* t; X* f- k) K/ T
  688.     end
    1 q  y1 ^" v" |2 k! I1 A6 ^' u
  689.     @extra_window.variable_id = $game_message.num_input_variable_id' E/ Y! P" d9 f# Y* Z0 }
  690.     @extra_window.digits_max  = @digits_max
    / K# Q0 ]9 c. S" k* z4 z
  691.     @extra_window.number      = @number* P* u' M# G! Y+ {- \  Q" s
  692.     @extra_window.open
    9 a8 @' v* H; R. t2 z1 Z
  693.     @extra_window.activate% [0 w  a& @. T
  694.   end. T" k6 s2 V) F4 R0 ^3 X
  695.   #--------------------------------------------------------------------------' }  N. _9 `$ A# x1 ?6 p. B5 j
  696.   # ● 更新" H3 A  y5 E, j  h# i
  697.   #--------------------------------------------------------------------------
    % r8 G& V' u  |7 X5 M0 |$ i
  698.   def update1 A( D. t0 F1 h  R1 b2 n; c
  699.     super
    5 u" k1 l) C3 B& z: j0 ]  X5 I
  700.     @extra_window.update: M! W) }1 ^0 t  ^( G
  701.     update_cursor
    ( Y6 c2 g  U- x
  702.   end
    ! a7 o0 h9 s; M& t
  703.   #--------------------------------------------------------------------------
    ! j7 @0 u( i4 s
  704.   # ● 关闭窗口
    " f7 j2 s+ E" k# c& O
  705.   #--------------------------------------------------------------------------
    & [6 c+ R& Y9 P' L; V  {2 |2 ^
  706.   def close: u3 N  c4 F/ z. ]1 B- m7 Y
  707.     super* C$ q( I/ X7 p! w
  708.     @extra_window.close6 }* i8 P) q* t$ g
  709.     @extra_window.deactivate
    $ \; h6 R+ y$ W# D( k
  710.   end
    8 X, q( C) q2 `& {  F  q
  711. end' d8 F+ ^. \  `& C' a- @
  712. % a& d" Z- c! W. S
  713. #==============================================================================
    0 S7 A4 b0 W  {% h6 _
  714. # ■ Window_NumberInput_Ex; [# ?  H8 V+ S0 x7 c
  715. #------------------------------------------------------------------------------
    / E2 R6 V5 b1 r( V8 T2 F
  716. #  新的数值输入窗口(NewClass): t- m6 u( ~# [1 C6 [
  717. #==============================================================================
    5 ~' V* V, o5 z: }% ], c
  718. class Window_NumberInput_Ex  Window_Selectable1 c1 ~9 H/ j7 o
  719.   #--------------------------------------------------------------------------2 z5 n+ l1 j( H3 e
  720.   # ● 定义实例变量
    + Q! @, h( q0 i- e1 X$ B; Z
  721.   #--------------------------------------------------------------------------1 r; Z% |$ i* }/ Y
  722.   attr_accessor number_proc3 c6 y+ V7 \, Y/ D
  723.   attr_accessor index_proc% i/ z& z2 P. O+ m: B6 y  p
  724.   attr_accessor close_proc8 |" k% g! p* O" f
  725.   attr_accessor refresh_proc
    . R, Z9 \4 M1 T) S6 q. ^
  726.   attr_accessor number6 ^* L6 d8 H; r( [
  727.   attr_accessor digits_max
    " T' t# B7 e6 w6 [8 F$ I
  728.   attr_accessor variable_id5 F9 J! g; l* a. y% M
  729.   #--------------------------------------------------------------------------
    ' s" p8 C4 s6 M- y- e1 }
  730.   # ● 数字表( t8 i: N  E; c4 N7 ^3 j
  731.   #--------------------------------------------------------------------------
    " D2 N0 j% ?9 F- Z' C( g& _: P
  732.   TABLE = [  7,  8,  9,
    ' h5 J- d9 M* A0 I4 l* l! u% I
  733.              4,  5,  6,' S, e' ~8 f7 k4 B, z
  734.              1,  2,  3,- V" _  _& V3 j) `0 [% p
  735.             '←',0,'确定',]  ]& W- N& ^. D9 Y. q
  736.   #--------------------------------------------------------------------------
    $ w0 M0 z" z6 v4 U* i
  737.   # ● 初始化对象
    ; j  o* Y* V7 m- U
  738.   #--------------------------------------------------------------------------$ w' ?# V2 I$ b8 a5 Z8 c
  739.   def initialize
    . s1 b5 u) @% t4 L9 O
  740.     super(0, 0, 120, fitting_height(4))
    - b2 w3 l2 @% |& K
  741.     self.openness = 0
    8 [. q/ v( t+ `, u
  742.     @index = 0( k& S2 T1 E& N
  743.     @number = 03 ]6 F0 Q$ x8 [* j& ?
  744.     @old_window_index = 08 q9 C2 S, d7 k) n5 S% i+ {2 X
  745.     @digits_max = 08 B8 a8 w* x( a- p& r
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    " W% t/ ?8 h5 J, g7 e% O0 [
  747.   end1 V& x/ T8 Y  Z0 Y/ o, W
  748.   #--------------------------------------------------------------------------# [! z8 \1 Q' ^9 s/ B  f
  749.   # ● 获取项目的绘制矩形
    6 p7 l; o' w! G7 G
  750.   #--------------------------------------------------------------------------
    : s1 b2 U/ o6 h( Z! j% _
  751.   def item_rect(index)
    " s) o4 [+ p6 i- k
  752.     rect = Rect.new
    ! I" V" F, }- A* w
  753.     rect.x = index % 3  32
    7 u/ E3 D/ `' T: ~0 U
  754.     rect.y = index  3  line_height7 l! N% p  `' X7 m1 V4 g; M7 O! t6 n2 T
  755.     rect.width = 32
    . g, h6 `( O- U" J/ u
  756.     rect.height = line_height% F1 R1 {9 S, \0 W1 \9 A# J
  757.     return rect4 j0 q, [& _* S5 Y6 D6 y0 s
  758.   end
    ! y( [4 q/ F0 h( l
  759.   #--------------------------------------------------------------------------* ]- p  i1 m# R1 h- g, n
  760.   # ● 将光标设置到鼠标所在的位置
    , z3 U4 G" c: S: M
  761.   #--------------------------------------------------------------------------
    1 g. d6 W6 b- _% t
  762.   def set_cursor
    / w* d1 B& X) @/ D8 j# x
  763.     mouse_row, mouse_col = mouse_window_area- d- c/ ^. u5 _
  764.     if mouse_row = 0 && mouse_col = 07 ~9 H$ v9 k- ~1 B) t
  765.       new_index = mouse_row  3 + mouse_col
    5 `# M! E+ w1 g1 k4 a8 H5 G
  766.       select(new_index) if new_index = 114 x) D  N) B* a: M9 v1 R3 w
  767.     end
    ; l, g7 @0 b  i; d, p# f
  768.   end, X7 Z$ f7 q  ~
  769.   #--------------------------------------------------------------------------/ o: D, Z+ ^' H4 ]7 @8 q
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    6 |$ }3 b' o& s
  771.   #--------------------------------------------------------------------------
    : u9 ^2 y* |& ^( C
  772.   def mouse_window_area
    4 H; I# t4 i7 q# m  v+ C, N- Z
  773.     if viewport.nil2 R) G( L9 f3 d) V; K
  774.       vp_x, vp_y = 0, 0
    ) \' [+ j& ^& c9 [* x9 K4 I( N
  775.     else) O% l8 x; Y; W% M0 ^; N
  776.       vp_x = viewport.rect.x - viewport.ox
    + j1 d8 X0 Q$ W! T- d* J7 N
  777.       vp_y = viewport.rect.y - viewport.oy, u9 n: ?* D$ l, u2 k8 b1 A
  778.     end
    ' z" E- Z1 \3 ^- f) t. D* Y$ R
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y0 P2 F* {- K; l* H
  780.     item_x1 = vp_x + x + standard_padding
    8 R5 Y4 ]' ]# }; y; C: P% ]
  781.     item_y1 = vp_y + y + standard_padding
    ' }% G8 {: L  U  K3 \
  782.     item_x2 = vp_x + x - standard_padding + width
    7 n- i# }* k  ]7 v, ]2 j3 U+ z
  783.     item_y2 = vp_y + y - standard_padding + height
    . b6 F( w8 M/ G6 M) S/ R" `
  784.     if mouse_x  item_x1* f0 I  I7 {" @& `
  785.       mouse_col = -1" ?. L3 @* o. C, J- G
  786.     elsif mouse_x  item_x25 c9 j5 N: k4 V" P: D- O
  787.       mouse_col = -2
    - ?7 E; x7 |4 {& L0 |
  788.     else
    : t' H- p$ _2 Y/ S& G/ p
  789.       mouse_col = (mouse_x - item_x1)  320 h9 j$ |" p  |) a6 s
  790.     end
    : {; g8 ~& m9 C( h
  791.     if mouse_y  item_y1: H+ n  V* @3 F1 R+ T, h
  792.       mouse_row = -1
    " I" O! B1 ]. A3 b% A
  793.     elsif mouse_y  item_y2: J2 w$ O- y" _% y
  794.       mouse_row = -22 r$ {7 D3 P) E
  795.     else# Q+ i* Y0 n: S) ^0 F" l
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    3 B% J1 i1 w  f8 [& ^
  797.     end7 I  N$ F6 z! L" G' e
  798.     return mouse_row, mouse_col1 k) ^! w# D& ?- t. J- K. D
  799.   end
    5 N5 e% D& g. M: n6 U! D
  800.   #--------------------------------------------------------------------------% V) N1 I( B. w% V3 [. N1 H
  801.   # ● 获取文字
    + b! }2 ~: k, @* o5 a
  802.   #--------------------------------------------------------------------------  F; B8 O0 Z( ?, |% g6 d8 G
  803.   def get_number
    ) I2 K1 f" Z$ @
  804.     return false if @index == 9  @index == 11
    9 e- M* Z4 N4 k9 r8 ~  h  ^7 v
  805.     return TABLE[@index]
      U3 f: W" t/ z
  806.   end
    / a$ l* a: k% s5 P) W  {( q! W) [
  807.   #--------------------------------------------------------------------------
    9 V: Z% ?- G' r) ~5 p1 e- Y
  808.   # ● 判定光标位置是否在“退格”上
    ( u1 p& I& D' [8 Y
  809.   #--------------------------------------------------------------------------
    & ]& x. L8 L5 m5 }
  810.   def is_delete
    1 D: H) {0 t# l) a; O" g0 d/ ?" Z
  811.     @index == 9) o6 l8 D+ q( P& o/ I$ h- z, @
  812.   end
    ) {' g* q: d. L
  813.   #--------------------------------------------------------------------------
    # f$ {1 |% `6 T/ q2 z* @2 g
  814.   # ● 判定光标位置是否在“确定”上
    " v& Y4 T. P1 z8 q1 G- H! z# I
  815.   #--------------------------------------------------------------------------
    + E8 d; L! f9 v6 V
  816.   def is_ok
    6 r2 N# a  D7 W, ~9 A; C
  817.     @index == 11
    5 g6 }: R; E1 l2 P! P* }# R
  818.   end
    % Y1 L/ ^  w7 @" p2 W5 s; O: `
  819.   #--------------------------------------------------------------------------
    / u: \: ]) L' c# X
  820.   # ● 更新光标
    & \% Q  u( E1 N1 p6 C
  821.   #--------------------------------------------------------------------------
    # S4 ]2 J) |! w, ^, p: ?8 Z+ C( u
  822.   def update_cursor( e' K! |# b- o0 v4 q- o3 l; x
  823.     cursor_rect.set(item_rect(@index))9 y7 n- H2 W/ E! h0 W
  824.   end0 @- m" |) |$ {
  825.   #--------------------------------------------------------------------------
    $ G5 o; M2 F2 U' p
  826.   # ● 判定光标是否可以移动
    / K7 n  `. g( X) j; Q
  827.   #--------------------------------------------------------------------------# R& @3 o: p% r& g; {, ?# _
  828.   def cursor_movable
    # S$ d" @9 h. V
  829.     active% D6 a8 a7 f! e1 t3 ^8 L
  830.   end$ ?5 P5 V& L8 A' _: f
  831.   #--------------------------------------------------------------------------+ z% q' U  T& j
  832.   # ● 光标向下移动
    8 ~( H- u* i* _
  833.   #     wrap  允许循环4 a% u/ C7 p- P! g
  834.   #--------------------------------------------------------------------------
    ' l4 b. G  L; n0 s4 ^$ K
  835.   def cursor_down(wrap)3 n7 k/ [- n" _! L0 |
  836.     if @index  9 or wrap8 y; w: e8 Z' g. P" f
  837.       @index = (index + 3) % 12& F9 O+ I; F8 E! D9 j- N# M
  838.     end
    / a9 ?: H$ J1 m3 T
  839.   end
    % \, h. E, f/ ^' f) @3 k* |$ R
  840.   #--------------------------------------------------------------------------4 j$ L& W6 R* ]( }; N- S) U: j: B
  841.   # ● 光标向上移动/ M& I& y8 L- {! b# \6 A, D/ ^
  842.   #     wrap  允许循环5 K. @, [4 Z. R& X" }8 u& A
  843.   #--------------------------------------------------------------------------* l* B3 U% {+ B' B4 Y& }' Y! w, V
  844.   def cursor_up(wrap)
    - J8 v, r( n* H4 b. N5 M$ I7 f) k
  845.     if @index = 3 or wrap
    6 y; E$ o" O. n+ `# y
  846.       @index = (index + 9) % 123 s5 p9 O" @+ |7 z0 f
  847.     end; Q! M% |$ {  P+ o
  848.   end
    * x3 S4 x. q+ Q' H) X
  849.   #--------------------------------------------------------------------------6 R0 g, I4 j4 T2 y2 v% ^
  850.   # ● 光标向右移动
    ) t8 v1 _, m0 q; d7 x. R
  851.   #     wrap  允许循环
    : E7 i# T1 M1 R7 [3 _
  852.   #--------------------------------------------------------------------------& C! m0 C# n; ^0 _& e
  853.   def cursor_right(wrap)0 d. O+ c/ g* K1 h
  854.     if @index % 3  2
    " C4 P9 Q# f% @5 N6 L
  855.       @index += 1
    ; O$ x% D7 s, P0 e
  856.     elsif wrap+ A7 K0 a" J# u" G6 E
  857.       @index -= 2
    0 q2 |0 ^: m$ {+ H) j
  858.     end
    7 r" J( [! k: K% [& ~' Y% @( z
  859.   end& |0 c9 e/ M# q: K9 x
  860.   #--------------------------------------------------------------------------
    0 p- P' O7 L  @, K6 ]$ s) k
  861.   # ● 光标向左移动
    , N; R& K  t7 t7 R" E1 E0 n( j
  862.   #     wrap  允许循环$ T' L; l9 n2 Z" P/ m% S
  863.   #--------------------------------------------------------------------------, v& N8 o3 T* b5 N6 q# N
  864.   def cursor_left(wrap)
    + O5 c: Z, r1 `. s2 Z0 X
  865.     if @index % 3  01 y0 u, L7 I" C  U! o* q
  866.       @index -= 1- n5 |, _9 y4 c/ A2 O! P* q) Q1 [$ n
  867.     elsif wrap
    6 A! }+ T7 L3 W- m
  868.       @index += 2
    ' c% H( E+ n' J2 U
  869.     end
    . F7 J( J, b+ R* b1 z" b1 i
  870.   end
    " j) p; O2 H. E% N3 r
  871.   #--------------------------------------------------------------------------& _( N: f. ?. k1 s; e
  872.   # ● 处理光标的移动6 Y. A: L) Y6 ~6 X) B  u
  873.   #--------------------------------------------------------------------------
    " J. I9 ?, ?" p" m8 Z' _
  874.   def process_cursor_move$ h8 G+ R. |! B
  875.     super
      H5 M$ F9 o2 |/ @2 d5 z) j2 ~
  876.     update_cursor0 ?( v& v- E* G; D9 ~7 D) \
  877.   end# N, E5 f) _- h" s) e  {/ L
  878.   #--------------------------------------------------------------------------+ O$ K6 B7 B  }7 W8 }
  879.   # ● “确定”、“删除字符”和“取消输入”的处理+ x" \: L, H& U6 h& u
  880.   #--------------------------------------------------------------------------
    9 J# s4 q: b0 ~! h5 `! `, [
  881.   def process_handling+ O( w  w/ i8 A+ E
  882.     return unless open && active* d* |4 h* |% f( Q
  883.     process_jump if Input.trigger(A)6 {9 ~! j) f( d
  884.     process_back if Input.repeat(B)6 s9 l* q5 f( L+ ?& N5 ^
  885.     process_ok   if Input.trigger(C)
    ' C# b) v1 `3 B8 A. G
  886.   end" p8 v& |9 s! u' t" ?/ J4 p
  887.   #--------------------------------------------------------------------------
    % g" x; @* e, S9 o! {2 J% r+ w
  888.   # ● 跳转“确定”
    2 a% T8 G2 [0 i  _
  889.   #--------------------------------------------------------------------------/ s: p/ f7 W% x% [  R9 h5 q2 Q
  890.   def process_jump$ m; l" I2 ?7 s0 Z* \! @
  891.     if @index != 11. t: |/ y4 k( O; b1 {8 N0 U0 \
  892.       @index = 11
    , Y3 H4 D$ q8 h, O: y: E( ^3 c( @$ l. ?
  893.       Sound.play_cursor: R2 T% ]! M8 g% j4 U5 W' O
  894.     end3 Y- }1 e8 e9 F' g4 O
  895.   end. w, Q; H1 z1 U' @% ]4 q
  896.   #--------------------------------------------------------------------------7 e+ V  f$ R- k0 z
  897.   # ● 后退一个字符
    % c- x9 j3 G7 o, A5 h( A# f
  898.   #--------------------------------------------------------------------------
    & c; F5 ~, V. W% V7 u9 c
  899.   def process_back
    $ h3 n' u8 i8 R4 X* s; U
  900.     Sound.play_cancel  f8 A+ K) ~5 E( I! s
  901.     place = 10  (@digits_max - 1 - @old_window_index), Q+ }: ]4 H" C+ v( J
  902.     n = (@number  place) % 10+ a, f  s: c: y/ K- s1 u1 c0 Z/ q' k
  903.     @number -= n  place2 N0 ]' o/ k5 l" K+ l
  904.     @number_proc.call(@number)1 R8 t* F3 v8 K0 p
  905.     @old_window_index -= 1 if @old_window_index  0# {2 ^0 T/ T# m/ O
  906.     @index_proc.call(@old_window_index): U! D* E, E. F$ Z3 E5 z* f$ t
  907.     @refresh_proc.call
    % Z/ v, @: y) s% p
  908.   end
    0 P1 p2 t8 C* c9 x; D2 S# W
  909.   #--------------------------------------------------------------------------! w5 S* m7 k2 y+ n, E3 P
  910.   # ● 按下确定键时的处理( T: ~( r- m. m* m& l5 C
  911.   #--------------------------------------------------------------------------
    9 h& R! @; H: Z/ d; H4 P
  912.   def process_ok" w9 k" a5 W1 o8 b/ k
  913.     if get_number
    / M' K* S6 c) S
  914.       Sound.play_cursor
    % R" k# q1 J2 O+ u! P2 k
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    & T( c5 Y+ u; }% E0 E* \
  916.       n = get_number - (@number  place) % 105 n2 u1 x1 s7 H/ `& y- \
  917.       @number += n  place
    4 P  Z; p& u! i9 c6 x/ H
  918.       @number_proc.call(@number)
    3 Q1 ]# M3 a2 O6 n( \4 U
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1% }2 {  W# N( q: l! R. }9 C
  920.       @index_proc.call(@old_window_index)2 _8 v) e) F+ ?4 j8 j8 G. j3 ^
  921.       @refresh_proc.call
    $ o& v* Y/ F: Q' ], k9 u6 M; U
  922.     elsif is_delete. D+ s* y7 |8 ]% K  g# q  [
  923.       process_back) l; M, O% y; Q! e" c) S  ]
  924.     elsif is_ok5 t3 t0 n8 p5 M$ N' x, F% C
  925.       on_input_ok
    2 p8 \3 L. _* O6 j
  926.     end
    " ^% x! u& O: g, X5 T3 q
  927.   end# h9 b* }1 I. f. M
  928.   #--------------------------------------------------------------------------
    6 H- k/ {& |) q
  929.   # ● 确定
    3 @! B$ U: x$ H( @5 ]! k: c& A
  930.   #--------------------------------------------------------------------------: [: _" F8 m0 j: U% ~2 i" }
  931.   def on_input_ok
    . M. J: |0 J: e5 P
  932.     @index = 0) R6 o- x: e- n3 I2 ]/ e: z
  933.     @old_window_index = 0
    5 {2 i. l" }, a1 S
  934.     $game_variables[@variable_id] = @number! k! ^" _: s7 ^' D' E7 ^+ X. P
  935.     Sound.play_ok9 E+ m) i1 k# X3 o; H. Z
  936.     @close_proc.call
    % d0 R! s0 j! j, ?' S2 ^% l& c, [- |+ V
  937.   end
    8 a, d. n; y1 d) A7 G9 t. R
  938.   #--------------------------------------------------------------------------
    : T3 U2 b  m7 A. _
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    2 |; u" W+ C' ^1 K: G: q
  940.   #--------------------------------------------------------------------------
    ( Q; \! t  B. t5 [4 P1 W
  941.   def set_mouse_pos! ?8 d& O/ M! z& }
  942.     if viewport.nil # necessary!
    + C( O" {# o5 \
  943.       vp_x, vp_y = 0, 0% c) R; U( w# a' M7 @) l! n6 V
  944.     else
    , b. A6 s- C* o" v3 D9 I0 l
  945.       vp_x = viewport.rect.x - viewport.ox# ^, J( K& [. u" X% e1 {: p
  946.       vp_y = viewport.rect.y - viewport.oy
    3 ^! \- e/ \% V/ O' ~* J. g
  947.     end' G0 S: x) |' e$ N
  948.     item_x1 = vp_x + x + standard_padding . s) a9 x- d1 T5 k
  949.     item_y1 = vp_y + y + standard_padding3 d+ A) b7 l4 `9 I" h9 w" r9 H
  950.     get_index = @index  0  0  @index
    7 S6 Y, V9 h. ?) M, P3 o- g4 D
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    1 d! f4 d9 T4 I2 ^
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)3 _6 P4 D% C& `2 l5 M/ s8 W
  953.     Mouse.set_mouse_pos(new_x, new_y), M% r& p6 }3 p8 f8 K# J$ a1 F
  954.   end' i8 h8 K) \' E% ?) c4 r
  955. end
    ( w! w2 z- e* s# x" J

  956. $ N$ ^6 [" v, l# U4 p
  957. #==============================================================================7 Q7 o; E5 B/ v
  958. # ■ Window_Message
    5 A% w- C; h! W; `. K) S
  959. #------------------------------------------------------------------------------
    ; k9 F8 |# g/ I: c8 Q
  960. #  显示文字信息的窗口。
    : t* j6 C. S9 j4 m/ E
  961. #==============================================================================
    ) a/ I+ g1 y( A9 m' J
  962. class Window_Message  Window_Base
    - e" Z! T9 f: O& z
  963.   #--------------------------------------------------------------------------
    0 U2 u7 q  y1 I9 G! r2 V; [2 R
  964.   # ● 处理数值的输入(覆盖原方法), P( S, g7 u% N1 Z' V
  965.   #--------------------------------------------------------------------------
    % Z; i: u% U6 A, F
  966.   def input_number1 Z+ T$ ?2 N, r3 ]: i  Q1 {
  967.     @number_window.start
    3 [% ]3 B6 a. U- O- w* `7 y
  968.     Fiber.yield while @number_window.extra_window.active
    / E8 U- W2 g1 Q+ p
  969.   end
    & j; O9 x% V  Y4 A
  970. end
    % \+ T7 b2 c* g

  971. . x) U3 z, v* D+ Z6 |
  972. #==============================================================================
    7 q3 t* a+ t% d9 G0 ^
  973. # ■ Window_PartyCommand0 l. y  |) m% R: a1 U
  974. #------------------------------------------------------------------------------& K+ T* H* O2 `) O
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    # D) A2 e/ j8 R/ R9 ^9 \' j3 H# z
  976. #==============================================================================
    ; U- R5 }- D1 @; b! _8 h& e
  977. class Window_PartyCommand  Window_Command
    , W9 y* Y7 p  x) F
  978.   #--------------------------------------------------------------------------
    # X+ d/ F% ~$ @% y
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    + C% ?2 l3 i1 p" |4 e/ ~2 v
  980.   #--------------------------------------------------------------------------
    6 W) p3 ^, Y, @9 c2 m( N" i; l5 ~
  981.   def set_mouse_pos
    ) X8 ^/ v. F: e) R% ~& b, v
  982.     if viewport.nil
    # D3 i% Q/ a, u  m4 @% \( F! w( }
  983.       vp_x, vp_y = 0, 07 y  |2 p9 G: O6 I( z4 J$ O
  984.     else* i% C  H6 ]# Q. r
  985.       #vp_x = viewport.rect.x - viewport.ox( p* U  `+ u' Y! `
  986.       vp_y = viewport.rect.y - viewport.oy
    / j' r% V. x  V' @
  987.     end- D/ E0 v% Z7 Q2 {" v
  988.     item_x1 = x + standard_padding , {9 |* t0 H3 x
  989.     item_y1 = vp_y + y + standard_padding
    ) g9 Y; v; E" X- z: c
  990.     get_index = @index  0  0  @index 5 D+ h3 e# X" W& E7 k
  991.     row = get_index  col_max - top_row$ N2 A% k) D7 \0 |$ j
  992.     col = get_index % col_max5 Z- p+ p  {. [0 r, ?5 Q/ g3 `8 r
  993.     new_x = item_x1 + item_width  (col + 0.5)
    . \5 g- I2 t$ N; b) T3 l+ e
  994.     new_y = item_y1 + item_height  (row + 0.5)
    " Y( F. x5 h8 a" B( X
  995.     Mouse.set_mouse_pos(new_x, new_y)
    # V6 e+ a+ H7 \7 Q; ~  H0 G
  996.   end
    : k' ]/ t- W2 w; g+ l
  997. end$ b& ]8 ]0 T2 G; d- t

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

  2225. 4 w( r; h: `+ z
  2226. #==============================================================================
    1 f- S0 x1 R' Q4 l; R/ h7 }/ x
  2227. # ■ Spriteset_Map
    , k- b% F( I7 @) h9 R+ n- c* E* H4 w
  2228. #------------------------------------------------------------------------------: A" H3 S, Y) |2 {6 r
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    $ i5 t6 \0 t. [7 k' U
  2230. #==============================================================================2 L6 P6 T' b7 Z* z/ J6 K6 J
  2231. class Spriteset_Map/ g7 i0 K  d5 x+ {$ q- Z3 p
  2232.   #--------------------------------------------------------------------------
    ( Y* ~: m  G$ [+ l& H2 h
  2233.   # ● 生成路径点精灵
    : c2 o; W& d8 K5 _
  2234.   #--------------------------------------------------------------------------- j/ H& T! C- H1 H2 d* w* _; s
  2235.   alias sion_mouse_create_characters create_characters
    + h$ o4 j; {9 u( o# Z" [
  2236.   def create_characters
    3 s5 C+ e4 b0 ~3 _
  2237.     sion_mouse_create_characters4 I( w% c* `' C% K' b$ \
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    ( h' L* I, i* c, N$ E' v
  2239.   end
    9 `0 T0 W: u* B' z
  2240. end
    ) {- h& Z' C8 k  B) X

  2241. ( w" t" p# _" H5 g$ {
  2242. #==============================================================================
    : c/ }% O( j/ s+ s8 n, R
  2243. # ■ Scene_Map1 s3 H$ A! @. _% A1 R6 U5 T
  2244. #------------------------------------------------------------------------------
    5 C3 M7 {. h, o5 j& w
  2245. #  地图画面5 i+ r+ s; x; d" Y8 ]4 `, E
  2246. #==============================================================================, ?8 \% l  S" n% w
  2247. class Scene_Map  Scene_Base
    ; n; Y7 t. R' o# @# ]: f0 X
  2248.   #--------------------------------------------------------------------------. S% l  W1 h) W& J0 S
  2249.   # ● 画面更新
    ! @# }" C0 [5 k3 O) P% J
  2250.   #--------------------------------------------------------------------------
    & p' w  f, O; q3 W. O
  2251.   alias sion_mouse_update_scene update_scene- i" l# \! l6 l7 A
  2252.   def update_scene
    ; }1 n& f) a3 m- M& c
  2253.     sion_mouse_update_scene, f8 v8 [6 i+ {4 @/ g* Y
  2254.     update_mouse_action unless scene_changing* k0 M# Q1 P) {8 u% F5 E
  2255.   end
    9 `4 r$ R$ [0 r6 |
  2256.   #--------------------------------------------------------------------------
      G9 }- G; F1 L. B3 n
  2257.   # ● 场所移动前的处理& J- S: R; F' x3 H
  2258.   #--------------------------------------------------------------------------2 d+ p( E% _! D) {% R6 S
  2259.   alias sion_mouse_pre_transfer pre_transfer# m% t  C& O. P" b
  2260.   def pre_transfer& }1 f. H/ {- `( D5 H
  2261.     $game_player.reset_move_path
    ( \2 H- |4 c* d+ P6 ]; P! V/ ?
  2262.     sion_mouse_pre_transfer  I0 a3 A" w1 q( u
  2263.   end4 J8 l, M3 {$ R% ?4 G3 X0 v
  2264.   #--------------------------------------------------------------------------  O0 H/ s' B2 D% P* a) U  j
  2265.   # ● 监听鼠标左键的按下6 N# u7 s$ v7 j" z: x
  2266.   #--------------------------------------------------------------------------: N6 @/ R4 S  c" T; B
  2267.   def update_mouse_action
    7 e/ s7 S$ |. K: L  W0 Z6 s% K
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    ; W( I4 Q: S1 D3 t) t  ^& W
  2269.   end- d) F+ ?- I  l9 F- n
  2270. end
    : A- _  O1 L" S

  2271. " O6 a0 e$ T: @  S
  2272. #==============================================================================  s0 t6 ?+ d8 l9 \0 |' o
  2273. # ■ Scene_File- T; n- ]2 U/ \; f
  2274. #------------------------------------------------------------------------------/ C1 i+ L( \; R
  2275. #  存档画面和读档画面共同的父类7 S7 N& _" D0 \6 p( ]2 `0 K$ a; Y2 `
  2276. #==============================================================================4 v% s+ p1 ~" g" B* e4 T0 }' ~: P
  2277. class Scene_File  Scene_MenuBase: O# B/ L1 e3 g, J9 E* x% P
  2278.   #--------------------------------------------------------------------------. @2 }, Z: L9 r1 _# w' h
  2279.   # ● 开始处理
    % `+ k9 z# i& y1 y  v+ @2 K5 s1 x
  2280.   #--------------------------------------------------------------------------6 i) Z$ n8 t. h
  2281.   alias sion_mouse_start start1 L0 o( @0 x$ K  g7 k
  2282.   def start
    # D# i- N2 y6 Q; n8 D! l! P4 K
  2283.     sion_mouse_start' a- J" v5 d) U3 C+ B6 E
  2284.     @move_state = 0
    6 j/ F# k! s$ z$ o$ K
  2285.     set_mouse_pos
    ) e8 F: x5 A! E+ F- B3 {
  2286.   end
    3 a' t! ]9 K7 C6 D' _1 f
  2287.   #--------------------------------------------------------------------------6 \3 x- s2 A& _7 x0 B2 Y
  2288.   # ● 更新画面
    & K, }: X# K- d2 Z4 G+ g) L
  2289.   #--------------------------------------------------------------------------
    8 [  h/ M# O' ~* b$ d3 |4 z
  2290.   alias sion_mouse_update update0 N, @& |) {! y  d/ u' N
  2291.   def update' ]/ y/ p$ b7 ~5 N; r. v
  2292.     sion_mouse_update
    4 R3 y6 m0 f- J. Y7 k+ ?
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    % T5 E0 r! E' |1 e3 n9 j
  2294.   end
    : |: ]- B: }" C9 D7 J: D
  2295.   #--------------------------------------------------------------------------
    ' i4 \0 @. K' A
  2296.   # ● 更新光标
    ' b2 T2 K! F# c  }+ F. f: `
  2297.   #--------------------------------------------------------------------------; [* ]4 l: }; f. d9 W
  2298.   def set_cursor, k, t8 E" Y1 d
  2299.     @move_state += 16 a3 A% R, O7 g& y0 x4 t
  2300.     last_index = @index" w: h' u+ ^5 Z: \7 I
  2301.     if mouse_which_window == -2: V- E1 h/ B4 b' m" }  R% ~' B- m
  2302.       if (@move_state - 1) % 6 == 0# {- g! U0 E/ d. u" |0 k+ u
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    " a) W2 i0 X6 \8 g+ p( [) U: C
  2304.       end% k% h, w7 V% K* L
  2305.     elsif mouse_which_window == -1! T# ?8 I% Q% A8 W1 @
  2306.       if (@move_state - 1) % 6 == 0% f/ x' x0 J3 W. ?2 f2 U/ e
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    6 e! B3 M2 Z$ m5 v% r' Z
  2308.       end
    : P+ k1 K, _0 V% z$ P
  2309.     else
    / _! A# b( h4 @) ]2 W6 f4 m
  2310.       @move_state = 0' t) T. {# g6 @+ U" N
  2311.       @index = top_index + mouse_which_window7 I  {. E! n6 A2 W* P/ c
  2312.     end& X0 Z1 b- X" d/ b6 c
  2313.     ensure_cursor_visible- {0 c' A; y. Z7 E  E5 s0 q' p
  2314.     if @index != last_index
    ; k; b  h, W0 I4 [
  2315.       @savefile_windows[last_index].selected = false
    / n+ X( e& ]! G9 ~
  2316.       @savefile_windows[@index].selected = true
    ( c7 x* H8 }  B8 J2 k' y" w
  2317.     end: H' q' G+ A! d6 e2 l! `0 j" U9 k
  2318.   end
    * v* g& C. X: b! Q
  2319.   #--------------------------------------------------------------------------$ h+ N" O- x4 Z7 p+ |* I
  2320.   # ● 判断鼠标位于哪个窗口& y6 p8 x) i) A* Y! x% y- C, l
  2321.   #--------------------------------------------------------------------------* M% O" c& w' Q
  2322.   def mouse_which_window
    ' |) R+ g/ d- L
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y* I& ^5 ^; ?9 z3 g* C2 W
  2324.     if mouse_y  @help_window.height + 14
    - ~* f8 Y* ~4 c7 J" @  z
  2325.       mouse_row = -1
    ) }5 z! L* ^, l# B/ \) Y* H2 E
  2326.     elsif mouse_y  Graphics.height - 14
    ' s; x: f9 I& p/ V
  2327.       mouse_row = -2* }5 n# Y- c0 `( |
  2328.     else0 E. D& ?* x/ k2 Z  T$ t6 G
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    0 }2 W7 j; C, M& ?8 [( M3 |1 U& p
  2330.         (Graphics.height - @help_window.height)9 n0 f& R/ e; Z7 a' D( z
  2331.     end
    # T# w$ s) R( @& z; y% d
  2332.     return mouse_row, l4 I+ N+ l0 h- c
  2333.   end
    . `. G1 @# u, v4 N7 O3 T
  2334.   #--------------------------------------------------------------------------. _5 Z2 y+ e# g, P: [
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置& W( G; m" G& o  y# _% a( r- D: h
  2336.   #--------------------------------------------------------------------------
    ; D$ N1 X8 `4 d+ i
  2337.   def set_mouse_pos
    ! u5 q0 A  |( z. O) e
  2338.     new_x = 40- z: m  C0 d8 I2 N6 A
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    * d3 W4 C6 E; L, j/ ^( P6 N( [
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    # z0 q4 [4 ~" b
  2341.   end; n0 k+ X& d7 I! x6 P) Q( L/ C
  2342. end
    7 E: }7 X$ z! D( J5 B% P

  2343. 2 T, g" ]" ]% J" w9 f/ s5 Z* [4 y7 h
  2344. #==============================================================================/ D2 _' u! X6 U0 h8 T2 B( Q
  2345. # ■ Game_Event
      ?) A6 y6 c5 J  v! _0 J7 K
  2346. #------------------------------------------------------------------------------
    - V- V1 m7 l$ b' L
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。: \/ U" N$ T" H; ?- k7 l
  2348. #   在 Game_Map 类的内部使用。
    9 D9 B* [4 L% v- y8 Z
  2349. #==============================================================================
    7 s+ ^) p8 d" B, d
  2350. class Game_Event  Game_Character$ _6 ^- @1 ?0 g  t/ S' C
  2351.   #--------------------------------------------------------------------------  t, o& N+ z3 Z1 i7 L& p3 G
  2352.   # ● 事件启动4 a9 f6 k# B6 p: z% U) A- D
  2353.   #--------------------------------------------------------------------------6 a- P0 V' |- m3 q
  2354.   alias sion_mouse_start start: G3 n% w% @/ t% c' z
  2355.   def start  V/ L& s) x* _& e" \% Z! Y- t* t
  2356.     return if mouse_start && !Mouse.press(0x01)
    1 k5 a& |8 U! P
  2357.     sion_mouse_start. b8 X& i4 R# D+ F9 Q
  2358.   end
    - h6 P8 Q7 u* k7 ^( M- _+ g2 U
  2359.   #--------------------------------------------------------------------------
    # |+ P) V# H( G/ J
  2360.   # ● 判断事件是否由鼠标启动
    9 K/ R0 }5 S. S# C% @
  2361.   #--------------------------------------------------------------------------
    5 {/ a' Q5 Q, r4 |
  2362.   def mouse_start
    / M. P4 N) R: q$ U0 {
  2363.     return false if empty" g; s' Z# I  x3 }6 S
  2364.     @list.each do index) u6 @+ i* x% g3 w
  2365.       return true if (index.code == 108  index.code == 408) &&
    & Q0 n1 I% f" u; p
  2366.         index.parameters[0].include('鼠标启动')7 q7 E3 @; p0 D8 \# s3 V' C  n
  2367.     end  i3 A# d( i6 J" ?7 d8 `% B
  2368.     return false/ B8 u3 b3 \. C6 O& S8 O" d8 i+ D
  2369.   end) r; N: E7 V$ [; l& q$ P
  2370. end; g" e1 H( `, M! D( Y# U3 V! @
  2371. " I" g# ]- b$ j0 I: `5 |3 I; P  y
  2372. ####泥煤的height
    " E) g& Q0 Q" R
  2373. # @height = height
    5 T( ^& B  x9 }$ P- {: b' u

  2374. " z- x: {- ~8 L3 ]6 j  f# U
  2375. class Area_Response
    . a7 {+ E: n7 i* d
  2376.   attr_accessor type0 v% [, `1 P8 o+ {9 U8 C$ V
  2377.   attr_reader ox
    3 Y4 U4 v# I: K0 D# L
  2378.   attr_reader oy
    4 C5 Y& L5 `6 K& l1 m
  2379.   attr_reader width
    6 w7 g0 F' n9 U& r# `
  2380.   attr_reader height
    6 s$ m; X  i) F0 k
  2381.   attr_reader switch_id
    ; P8 a. ]% ?% z1 f
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)7 C& n9 c) b+ x- H
  2383.     @type = type$ X. o0 t  A. C# L. }; R
  2384.     @ox = ox" r. z* K! ]4 ?& l
  2385.     @oy = oy& f3 b2 ]8 I. ?5 U8 m7 C% V& A- ?/ [  U
  2386.     @width = width
      Q$ d! A) a. B( C1 ?
  2387.     @height = height
    $ @7 @9 V6 ?+ O" j3 y' Y
  2388.     @switch_id = switch_id; w1 \6 l( o1 C% K+ I) q) ]8 B
  2389.   end! S6 J2 y) x4 o7 I
  2390. end
    . R" h9 e! w) z
  2391. ( P& Z+ j( Y0 A( K- S0 i9 ?& z2 b( B, H, ?
  2392. $area_responses = []  y/ ^, s+ C# o4 q
  2393. 9 l% K' ?. K& t
  2394. class Scene_Map
    . r# F3 F9 k& R* U
  2395.   alias update_mouse_2013421 update_mouse_action
    . j# B& }& z+ O# P- j" f
  2396.   def update_mouse_action
    ! R. Z  T+ _4 S4 _+ O- J0 A9 D3 P" A2 w
  2397.     update_area_response( x: x) |2 R& p. Q4 m! I
  2398.     update_mouse_2013421! b) D9 t' z0 _3 [5 @4 \
  2399.   end$ N- j: O( d  \; {6 H
  2400.   def update_area_response( b) h) v3 J5 A& F6 g7 {! h% Q
  2401.     responses = $area_responses
    / L7 p. Z6 M8 m* k& @, w6 r
  2402.     responses.each {response
    " ]8 w6 P; d& N" b
  2403.       ox = response.ox
    * A, {% j5 {! D  ?, [! U
  2404.       oy = response.oy
    * I. z; ^+ |# i$ {8 v
  2405.       width = response.width
    4 v* p4 W/ R) g) ^) r
  2406.       height = response.height: w. _# X1 K6 S( O, T
  2407.       switch_id = response.switch_id
    2 N. f1 d/ {9 B5 N: [3 C
  2408.       case response.type
    " K9 I6 o. J: N  W( Q! v  o3 L
  2409.       when 0
      h7 A2 |4 Q/ x
  2410.         if mouse_in_area(ox, oy, width, height)# {: j& z" F' M6 Y6 h
  2411.           $game_switches[switch_id] = true
    . ~% ~0 S% m* X4 X# G
  2412.           $area_responses.delete(response): A$ g0 _+ z& @$ _9 z9 a
  2413.         end
      f6 x- {5 M3 r0 n  O
  2414.       when 1
    - ?# w2 K7 n5 u" }
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    * z( H& d7 ~0 G! H
  2416.           $game_switches[switch_id] = true
      _2 V0 t8 n6 L7 _+ J3 `! P) Q
  2417.           $area_responses.delete(response)0 ?0 W2 e! ]- F7 v, L) S
  2418.         end
    5 G( @# g/ {4 B/ l2 c+ x9 d
  2419.       when 2
    7 I$ y2 j1 W# e6 C* K) T5 ^# B( L
  2420.         if mouse_in_area(ox, oy, width, height): t2 P# z- i6 U
  2421.           $game_switches[switch_id] = true
    * I9 [9 J$ ^8 t6 E
  2422.         else
    0 V+ o9 c1 v/ S9 V7 @
  2423.           $game_switches[switch_id] = false
    ; L: {% k+ d' j& ~* T' @1 {7 R
  2424.         end, a. Q* P4 a5 v+ R( R" o" b
  2425.       when 39 h9 I" O$ h1 J3 P
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    6 K$ j4 ^6 e* [4 H" k7 q# C
  2427.             (oy - $game_map.display_y)  32, width, height)" j. p- J9 {2 \) D* U. V* j
  2428.           $game_map.events_xy(ox, oy).each {event' S" G/ ^( R, p/ I- U7 C
  2429.           event.start
    8 j/ O+ N& ~7 ]
  2430.           $area_responses.delete(response)
    2 m' G1 N8 f( }' ~8 S7 P# u
  2431.           return
    . @2 l! Y2 z$ C: ^0 F! Q! x  Y: j
  2432.           }
    ) A1 [  k/ Z' K, o4 Q
  2433.         end" b+ y1 e" M5 W1 C
  2434.       when 4# D! X, Z/ o5 L3 u: G4 P9 p
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,& I/ L3 D6 V# A& D7 L
  2436.             (oy - $game_map.display_y)  32, width, height). N1 D; P( I% W& C
  2437.           $game_map.events_xy(ox, oy).each {event: Z5 Q0 ~; s1 @
  2438.             event.start) U3 G9 _9 T" x5 K2 ?2 U
  2439.             return* s; |* a5 K, k6 a$ t: H% a
  2440.           } 3 W6 `. m. _/ t+ n
  2441.         end# L7 t% q: e. A; q% G- A
  2442.       end( M( m# Z- I& o  `! X
  2443.     }
    ) |7 b' }& _9 R) i
  2444.   end
    , l# A. U8 u/ b  V- n
  2445.   def mouse_in_area(ox, oy, width, height)! c% @# `& o6 F+ F, L: a& u3 D, m
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    # L: H( }& P' V8 d6 f$ M$ {" F1 f
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height( a2 p, D& j. Y/ X6 a1 h
  2448.   end
    8 R+ l6 r% ~" J" c9 _( H+ }
  2449. end
      k# Q, ^3 d+ ?# [. D0 O4 n  C4 Y
  2450. class Game_Interpreter' i- Z2 ^$ k0 V
  2451.   def area_response(arg)
    4 G6 Q) M, o" c1 \2 P: Z& L1 o$ H$ d
  2452.     $area_responses.push(Area_Response.new(arg))' l" e  k% B. I  v
  2453.   end1 v- M# n0 L1 R( p: u+ E+ g! |
  2454. end
    , Q) |/ p( V/ L' B! X; g$ }! g
复制代码

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

在本发帖返回顶部