设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 738|回复: 0
打印 上一主题 下一主题

存放腳本

[复制链接]

梦石
0
星屑
382
在线时间
1291 小时
注册时间
2013-1-12
帖子
3590

贵宾

跳转到指定楼层
1
发表于 2013-8-29 09:01:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    9 V1 J  P2 K$ p+ }* {" o

  2. 5 K/ P. U& F9 p2 d: I
  3.   Sion Mouse System v1.3e, {, g- Y& b3 N+ J: @2 j) L
  4.   
    " B; `6 L% g  u2 Z
  5.   Changlog
    1 ?# v" K) V+ Y1 v8 H
  6.   
    . y, G/ x+ ?6 _( E9 I
  7.   2013.4.21 v1.3f
    , z% O) r9 F' [, D# Y4 g
  8.    
    2 c% o* Q; D/ x/ R& X
  9.     1.3f 卷动地图 bug 修正3 c2 [  Y  V4 w" W/ S- x$ f4 v# X# k4 E
  10.     " p: l) u7 c* v' \- U
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    $ \5 j1 A  F- X2 Y$ J" B
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内) j. Y- m( m' o" e( N8 ]5 S
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    9 x. u. U* }$ Z! k

  14. - k" I! C( }/ |# P& J# q3 c1 j" o
  15.     1.3f bug修正1 d- D' C, D, L2 o; D) q
  16.   : K7 o! v  @$ r2 f
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    2 D6 `9 `3 u' l% A9 ?3 O, w* Q/ o* h1 c
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    % q% N6 A5 D& L( o- i, E: [, X

  19. / O: `3 P$ j1 |- c, K6 e
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    5 ~5 @& _8 E) I% h
  21. $ S3 {8 o% k- \# I4 {
  22.     1.3b 修正一些罕见的bug;
    * o& s& L; f! y9 Q

  23. ; Q9 I( @. a7 T  P/ @3 O! d
  24.     1.3a 代码小修改;
    1 i( }; e' ]& ^$ I
  25.           加入了鼠标点击启动事件的功能,  b" C/ ^$ q) \/ m8 z( Q$ z/ P: I  R
  26.           在事件中加入“注释”: 鼠标启动  ,, s+ O7 ^# a. V& n' D/ N
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    4 N' ^* _$ Q) U) g9 |1 H; F
  28.   
    1 N/ p" C& f  Z) K' h- V; q6 P& K
  29.   2013.2.12 v1.2
    6 ^( U* c& M  H2 U4 y) Z  j
  30. & t  U& B# t6 q2 u, G
  31.     寻路逻辑优化;" \" ~* B+ a; k& E  k" \, k
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;0 O# N5 J! T* _9 o" u
  33.     现在支持用鼠标来操作载具了。- m0 s9 {3 E3 c- p  W+ y, q
  34. ' J) T+ Z/ A( t+ N. C% O' A0 f3 y9 _
  35.   2013.2.8 v1.17 v: J4 X& G. d  U
  36. # H2 j7 z/ U. |4 A4 n6 H
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;) Y& f; T1 N* U
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    ( V! k, g9 x# b! q7 C7 T
  39.     移动时,路径指示点的绘制更加稳定;
    1 T" A+ f1 V9 \3 k5 I
  40.     现在支持默认存档画面的鼠标操作了。
    * D/ h' @! V# U( }; Z! r

  41. - c4 ?; B6 u  E' ^; b( {9 g
  42. 3 @8 ^5 j) a5 l6 H5 B
  43.   OrigenVersion
    0 g! a" C0 n1 k' V! _
  44.   
    5 Z. V  ~$ W* X5 R6 W- M0 p  W
  45.     2013.2.7 v1.0 + X$ e) F" \& t+ ^- w- i9 O
  46. & ?, s1 g/ A4 {' L
  47.   主要功能& Z# a+ c* A2 P( y1 Q
  48. 8 _3 ~; D; R3 R
  49.       使用鼠标进行各种操作...
    9 m5 m& g$ Y  k$ E$ E% r
  50.       将鼠标锁定在游戏窗口内$ ~' D% }/ v# R4 w7 d) O! V) G) ~
  51.       自动寻路,按住 D 键可以扩大寻路的范围" W  i0 m- p/ n& l9 J
  52.       双击鼠标进行冲刺- L: C) C. Q9 ~( m
  53.       更改地图卷动方式以适应鼠标移动' s" B; u) U1 ?) J8 Q' p) H3 A) r
  54.       变量输入框改良0 C1 x% N4 k2 K. Z& j- Z4 E$ p1 x- g
  55. : N# z2 ^6 U% ?$ R" j
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹0 n3 H: Z* I* q7 X
  57. 0 r1 f6 i2 O! o8 h$ y+ b. i+ R
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    : X$ G1 ^7 V' R% G

  59. & x! A- B* M6 d4 ]4 ?# s7 a
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭8 E0 Y4 }! @, Z
  61. % C& n6 g; b0 [3 ?
  62. 6 e% L0 W; _4 S% g4 R  d
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★5 }/ F+ j, S6 r6 g8 m' C
  64. # M0 S# Y/ ^& u$ w/ D
  65. & s) H$ e8 {( k+ m
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    ; y. D  a+ W" B2 T+ c% ^

  67. ) e3 t. U- h' j& O, C2 ?) f
  68. #==============================================================================5 a! S. P5 m4 _
  69. # ■ 常数设置
    ; m% _, ]" R' d) S+ k
  70. #==============================================================================
    ! {, k( l" ^2 c
  71. module KsOfSion
    ! z& i; T/ T) ]0 S& z* `1 x
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false7 i2 `! n! s. Q: G
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    7 D6 h5 l1 n# G& f" X; h% P
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false! H2 G. Z# S: y4 w; {
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    $ s1 B3 H6 r  ?) q9 |) F& b
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处  G6 N* p/ T/ L' }. D2 o9 i3 G0 \8 m
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    % \7 w* m( B; o; I5 c8 W  V
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    & a2 i6 t; |% I( l) p" b8 p
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    5 F" ?! Q  G3 `
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    - t: b, P4 ?" T$ p' q1 P
  81. end2 z' l4 E3 s2 c4 d6 C/ c
  82. 0 ~8 }' b4 V, Q  K2 @; S
  83. #==============================================================================
    9 c1 m3 J6 j6 w: D
  84. # ■ 用来显示路径点的类4 N4 \! d$ l$ S! j1 k, B2 h
  85. #==============================================================================3 `  j# ~6 _! `. b
  86. class Move_Sign  Game_Character) h$ Y: M& P; A2 a% `' y* j
  87.   #--------------------------------------------------------------------------0 a. O7 a3 {3 b
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图0 ]4 p8 T% v3 s* {1 r
  89.   #--------------------------------------------------------------------------: z9 @6 D* |0 L3 E0 |
  90.   def init_public_members
    , m0 _# R( g# |5 f1 N0 o- o) F. {
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹) s8 a* _4 z7 E4 M
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    7 c% q/ {/ R9 T: Q5 q9 I+ X: P6 W% h
  93.     @move_speed      = 5        # ★ 踏步速度* ~1 @" C0 F$ i. s" X' a
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    1 k$ c$ D( `8 M
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    + Q; p  T, Y4 r3 J/ n$ ]  W' A# e
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)5 O; a2 q5 y0 k4 X5 N' h4 ~# c
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列0 \/ O- t( ^! l+ L) W
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)' j* W5 t- c" Y- S2 p: {& K

  99. 6 {1 H2 e) I; `3 W

  100. 5 g0 [1 r" T$ I+ M* g/ o: x9 a
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    ) ^/ F% [8 x4 Z* A# o( |

  102. 3 g" {# j3 x0 {% y, @8 G" Z
  103. ; V; W9 p1 K7 S" v$ Q& x
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    0 m2 F$ [% z- g0 r6 q
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    8 Q+ u. O1 c& b% t: x

  106. 4 M* `- k# Q1 e# h
  107.       if $no_arrowpic_warn
    # x+ V4 b; |8 w; h) h) K
  108.         MouseShow_Cursor.call(1)
    5 h4 s- g" [$ L' P' g& C
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    7 K7 m7 d8 S, b7 d

  110. 7 {! T+ [, K4 W9 Z2 i! h1 U" F
  111. “路径指示点”将使用游戏自带图片
    5 i8 c; }4 X* E

  112. 8 C# T* o) v+ T
  113. 该提示可以在脚本内关闭')
    3 d( Q2 z! d0 ]' `  v
  114.         MouseShow_Cursor.call(0)
    ! q( ]5 q1 J9 ~7 B
  115.         $no_arrowpic_warn = false, g# d4 c& C) V# m- p% `
  116.       end
    1 H9 u4 t8 F+ R0 P2 b+ g
  117.       @character_name  = '!Flame'
    9 j" b8 t( R, A/ a9 T5 \
  118.       @character_index = 6
    , u! @. [% A+ T* c

  119. 1 L! C) ?7 i7 Z' W: d
  120.     end
    ; J. p4 Q  _  [: ^$ |" e
  121.     @direction_fix = false  # 固定朝向, J1 R6 B) u/ v3 q( [7 A/ u
  122.     @move_frequency = 6     # 移动频率: w9 {+ P; [1 D8 G" f# {, b' N, y: w
  123.     @walk_anime = true      # 步行动画4 e4 v2 g  g6 p
  124.     @pattern = 1            # 图案' l' a3 P; {* }# L2 u1 q0 E
  125.     @through = true         # 穿透
    1 t* G0 [& l' s7 q$ Z: L
  126.     @bush_depth = 0         # 草木深度
    6 b) x3 k0 p; d1 {9 Q- g
  127.     @animation_id = 0       # 动画 ID3 o- B: M1 Q& Q4 ^7 o
  128.     @balloon_id = 0         # 心情 ID0 }) `5 @% z1 x
  129.     @transparent = true     # 透明8 d/ G% k7 X2 a
  130.     @id = 0
      @) T7 V& {6 T
  131.     @x = 0
    . d2 V; s4 s8 j! }
  132.     @y = 0
    . q2 m9 ~" k6 ~7 {
  133.     @real_x = 08 _4 B2 Q8 w" X( i9 C' H& ~* K
  134.     @real_y = 0
    / {# Y8 N" }  J6 }# n/ i# _: i4 e/ P
  135.     @tile_id = 0
    8 T& O3 w/ B; y# }4 O
  136.   end
    ) h/ U. I& [2 u
  137.   #--------------------------------------------------------------------------' ?) m! v5 E. ]& ]: w6 d
  138.   # ● 定义实例变量
      e  ]) x4 h/ N4 Z
  139.   #--------------------------------------------------------------------------
    + Z% D% C" C* q# Y
  140.   attr_accessor direction
    ) a9 F1 T1 |- t# B6 p( r- S
  141. end. n5 g2 Y6 M6 N3 z5 x6 y4 E7 E

  142. * {0 R) l. x+ Y* p3 L
  143. #==============================================================================# P& Q# d, k, {- H, d) y! R
  144. # ■ Module Mouse% Q/ {4 k4 |4 ^( Y! G/ [* B
  145. #==============================================================================* M2 B  r5 ]8 p
  146. module Mouse
    # \; W3 k" c2 u/ K# N
  147.   #--------------------------------------------------------------------------( k& L9 l: Q. ]5 G' M( D4 ^
  148.   # ● API
    & A7 q, C% `8 r" `+ n
  149.   #--------------------------------------------------------------------------3 `8 U+ s8 Q% _5 S5 m& E3 l0 x) \
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l'): g$ l, @& V' o' W8 D! b$ k
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')' ?; c" @# Z" U. c# c  j6 j+ e9 J' K
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
      c* [/ K  {) t4 J6 @6 E/ ~; P
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    ) z! k" E$ Q" E* Q1 o% G. f7 [
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    0 n% d9 j3 O4 ?% Q! z
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')- G$ H: I: V& z$ f- g. c
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    5 ?2 l8 o4 f8 v0 ?
  157.   Window_Hwnd       = Get_Active_Window.call
    / u9 R" A/ o( c$ _3 W' K+ e. i

  158. 9 i' T' s  [- F" ^0 l& U
  159. class  self
    5 Y9 [* v8 G, U5 x" k
  160.   #--------------------------------------------------------------------------  @4 y- [! U; X" ]4 r' m8 Q
  161.   # ● 初始化
    - q9 t9 N- }7 G' r6 h
  162.   #--------------------------------------------------------------------------( H9 u( {$ w2 T+ Z( A
  163.   def init- T  R- C: v) z+ p8 z+ i1 t7 D
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    " s! m/ j% b; s6 j" {
  165.     @left_state = 0) m8 G/ Z/ T& u
  166.     @right_state = 0% {2 I) Y# q1 `7 R
  167.     @ck_count = 0 # 帧数计,单击以后从0开始' X, }( g* s# C7 ~+ W$ M
  168.     @dk_count = 0 # 用于双击的判定
      Z  O* q$ ?2 N3 C. b1 G, S
  169.     @clicked = false
    5 u* }1 M6 Z# j  Y4 m+ p# o
  170.     creat_mouse_sprite. _( Y3 N" d" x) d! @: g2 {
  171.     update
    % U6 T$ N1 v$ B7 z$ f
  172.   end
    9 {6 G+ ~( Z7 d9 a
  173.   #--------------------------------------------------------------------------4 S. J' \. U$ \3 X3 g
  174.   # ● 鼠标指针精灵' ]8 a3 {4 O, f9 P
  175.   #--------------------------------------------------------------------------
    9 S5 J5 K4 y+ p9 }3 M4 {! X+ B
  176. #~   def creat_mouse_sprite
    & m$ Z2 F/ _0 m. F# n
  177. #~     
    & i+ C# g# a$ e
  178. #~       @mouse_sprite = Sprite.new
    2 r; u  Q$ M  J' c9 e, V3 W) g# h7 k9 }
  179. #~       panda = 2#rand(2)+1
    & ^) K7 r2 c& U! x3 v$ u& U
  180. * z/ I: d! \3 [  R$ b
  181. #~      if panda = 1
    ; J7 s2 `5 h  T6 N! |; n5 @, m$ B
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    1 p' I6 e! N1 B% D( I  S
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    # x$ y4 U/ w  P0 R8 ^/ d
  184. #~        end#with if File.exist
    : ?  C, A. H, j; q
  185. #~   
    6 k7 n! C9 I" n% a- N3 w
  186. #~     else if panda = 2 #with if panda=1) e  a- L/ M+ @2 l: |
  187. #~      
    ! R3 p$ L! N$ N
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    4 O% k1 O( T" E& H/ W
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    ( A/ G* u& P" a( m& _
  190. #~      end#with if File.exist
    / |( Q' ]4 ~2 C' t/ ^! X
  191. #~       1 s0 ~0 |$ ^+ b. T& E$ d+ j5 E
  192. #~     else #with if panda=1
    ' u  d& }+ |8 p  S
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    6 O- T) m$ [  n* J$ \1 {. J
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    ( e$ Q0 l  u5 `2 v3 S
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    1 b( @7 B$ H0 P7 W
  196. #~     end#with if panda=1
    7 W5 d1 w; W) y& u
  197. #~     
    8 m1 I% }, M2 v% `6 n% x1 L5 k
  198. #~     #with def0 C' V! m' q; E# u0 X1 I5 O) P
  199. #~   end" X# P2 r( |& ?, ^7 j
  200. def creat_mouse_sprite+ u+ a* I6 Q2 `+ |$ {  A
  201.     @mouse_sprite = Sprite.new
    : `5 N. z4 s) I7 g
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    : F0 p1 N8 g& o$ v5 d
  203.     @mouse_sprite.z = 9999
    - Q. Y( c6 F" p! s7 U) a
  204.     Show_Cursor.call(0)7 L) n  I9 }$ }1 M
  205. end
    0 G) L$ I. o5 @$ v, T' V

  206. ! m# o! X* ~2 E* F8 O
  207.   #--------------------------------------------------------------------------' |; R/ v, ]7 W
  208.   # ● 更新" e  b. }: g6 {# ^5 ]$ r3 x( S
  209.   #--------------------------------------------------------------------------
    & x1 c3 x" m$ V9 `" P
  210.   def update
    6 ?/ p5 Q8 e; ?8 {/ d/ X
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos1 ]- ~" f$ u0 w0 w$ y
  212.     left_state  = Get_Key_State.call(0x01)
    + o; Y6 Z5 e* V+ ~, K
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    7 `1 [; X! \  Y  M6 c: W
  214.     right_state = Get_Key_State.call(0x02)1 ]9 S$ M8 k: L2 u6 o1 W, T
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    4 U0 R4 u- w+ N! C; s
  216.     update_double_click9 l3 |9 t( H3 V
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    ' t* a% M! j8 i7 H2 m( C3 E0 m
  218.   end
    ; j, x6 {) r! c! U- j. ^
  219.   #--------------------------------------------------------------------------, A/ S- i+ Y2 q3 J/ I
  220.   # ● 获取鼠标坐标9 x& T" O3 w& ?# G$ ]
  221.   #--------------------------------------------------------------------------5 G3 e6 y( d3 h! ?" S7 Q
  222.   def get_mouse_pos
    " j7 H6 ]" ?, R6 P9 [
  223.     arg = [0, 0].pack('ll')$ c; z: c1 O  \% F
  224.     Get_Cursor_Pos.call(arg)
    ( |" t0 U! n: Q& \$ y) R7 y
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    6 W# _! J1 }3 |8 T5 R  \, `2 [  q
  226.     x, y = arg.unpack('ll')% p, \# D9 {. T+ k
  227.     return x, y
    % c* I" O8 [9 `; J$ ^4 {  T' j; l5 }
  228.   end+ Q1 c, H. j4 a$ S
  229.   #--------------------------------------------------------------------------7 {* j! `$ z  q7 n) p, [! U& ~
  230.   # ● 将鼠标固定在屏幕内) [- ^5 P& ~9 j' O
  231.   #--------------------------------------------------------------------------% b/ U  f. e1 k) \2 E2 ^- ~
  232.   def lock_mouse_in_screen2 ]- L) {; K5 C3 ]0 s1 A5 u* g$ v' |
  233.     arg = [0, 0].pack('ll')
    & C( @5 w1 t; N# z" }8 S
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    7 U! n8 Q8 S0 N7 @
  235.     x, y  = arg.unpack('ll')" D* m' w! N0 v# v3 a9 y6 C/ l5 ^
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))0 U0 r% F4 |0 M) Z1 X# m/ c
  237.   end1 E. E, G' ^: w( {2 X
  238.   #--------------------------------------------------------------------------  t! F0 P$ _7 I$ r, V! Q
  239.   # ● 解除鼠标固定
    . q" t( K! q. b1 {8 T
  240.   #--------------------------------------------------------------------------) A  Y7 R) l$ A- _7 o3 Q  {
  241.   def unlock_mouse_in_screen9 T; M9 ?4 S/ U5 T& ]; ^! i
  242.     Clip_Cursor.call(0)% A  Z) A7 Y) R* e7 ?1 W& I( H
  243.   end( m; I+ W) L5 u
  244.   #--------------------------------------------------------------------------
    9 m4 ?5 ~- v: B( L
  245.   # ● 鼠标双击判定+ _) _# N) R) e
  246.   #--------------------------------------------------------------------------
    + x2 r: a/ h3 S1 H% w8 u7 u
  247.   def update_double_click
    5 R  I+ f# W- o  \. M
  248.     @clicked = true if @left_state == 1; E- _& |- m1 M! m
  249.     if @dk_count  0 && @left_state == 1
    ( P# Z$ X$ l" Z) @/ Y
  250.       @dk_count = 0; @clicked = false; |& B9 L8 u) s
  251.       return @double_click = true0 R2 n8 p5 f* B. y, W
  252.     elsif @clicked
    5 \4 `% x% _2 |" f2 [- s1 Q! R
  253.       if @dk_count  KsOfSionDbclick_Frame: C# C! o) w7 k& x0 @0 x* i7 s
  254.         @dk_count += 1
    ; g) b$ N1 ]& u) q! X4 ?
  255.       else; b! ^4 |" Q& J  c0 F+ Z# ?
  256.         @dk_count = 0; @clicked = false7 m/ k( \1 E# @6 M$ |; ?
  257.       end
    * [0 o( W1 O: k8 m: v; V
  258.     end
    $ K9 P$ o4 F  v0 k( a) Y  `
  259.     @double_click = false
    $ B2 @4 y8 F" O7 S8 d2 q
  260.   end
    1 G7 N) r4 I5 p5 x: x
  261.   #--------------------------------------------------------------------------4 \2 ^2 D+ ^2 u) Q; @
  262.   # ● 按键被按下就返回true5 e$ R5 x8 ~, V1 j1 I6 ^/ I) Y
  263.   #--------------------------------------------------------------------------' W8 E9 a' w. X; n+ i
  264.   def press(button)( O7 j# M- N4 {, s9 u8 Y) d
  265.     case button
    / f" O: A2 ^- I3 f
  266.       when 0x01; return !@left_state.zero1 w4 M; q! J- M
  267.       when 0x02; return !@right_state.zero
    + S0 v1 u( {& A. v0 L
  268.     end  G. m3 r0 c0 a1 B9 R2 a
  269.     return false: l. x( A" J( w! i3 W4 M- s6 e% C, ?6 `
  270.   end
    ' C: B+ _# y8 ]  C
  271.   #--------------------------------------------------------------------------" V5 d9 ?& s- W8 {1 {* M
  272.   # ● 按键刚被按下则返回true$ O7 d3 f$ d' Y/ b
  273.   #--------------------------------------------------------------------------
    6 }* i% h) u; z/ |
  274.   def trigger(button). c9 T7 K2 B) Z7 p, M' s8 x: G
  275.     case button
    + t! C1 r4 _2 ?; \0 Y
  276.       when 0x01; return @left_state == 1& ]. g+ S( L3 {+ c: P
  277.       when 0x02; return @right_state == 1
    # v6 i8 \0 x. o- N' h  e
  278.     end9 [& y9 S% K6 h' S2 t/ u. F
  279.     return false3 ~( z) w$ }3 w' e+ j
  280.   end+ j, S$ [+ M! }  @& z# h1 W9 m
  281.   #--------------------------------------------------------------------------& j- m; o, R' T4 }
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    + \4 j; [" J0 @5 N7 H% ~1 T
  283.   #--------------------------------------------------------------------------
    7 T  D' B; n' H; \' q
  284.   def repeat(button)
    . y) c  r7 L- v* D1 g# o
  285.     case button
    / U0 f8 Y' p! g5 Y/ G* R
  286.       when 0x01; return @left_state == 1
    6 d. Q& z! |0 \! m) Q. r$ N" a! E
  287.         (@left_state  22 && (@left_state % 6).zero)# x8 G# B' V9 w% a/ }
  288.       when 0x02; return @right_state == 1
    / r. u& h9 b/ X
  289.         (@right_state  22 && (@right_state % 6).zero)% F5 l" v3 \4 h+ {& ~9 D/ F
  290.     end
    1 c% D& x$ ~& v
  291.     return false
    3 V) f( c; @+ p* e
  292.   end6 x& z4 r& x" W/ B8 n- z% G
  293.   #--------------------------------------------------------------------------, o; D7 J9 q# m4 S
  294.   # ● 判断是否双击鼠标
    7 ?0 m, @& x# N6 n
  295.   #--------------------------------------------------------------------------; ~; I0 ?0 ]! ?/ D, F8 q6 v
  296.   def double_click3 v- z0 p5 o$ a1 G, b, J: x, h1 W
  297.     @double_click
    " N) U' L/ @  K( a* O
  298.   end( E, U' i& e& @
  299.   #--------------------------------------------------------------------------5 i; {2 \) ~9 H" x, q
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)+ D% ]: i( i# K1 [  C7 S% l
  301.   #--------------------------------------------------------------------------
    2 A4 w% C5 r# G6 o: a
  302.   def click_count+ D$ `8 y& Q) j, H2 \
  303.     @ck_count
    8 Y7 D& K2 c5 V
  304.   end; {" H- P7 z6 G' e9 z) S& k
  305.   #--------------------------------------------------------------------------
    4 ?; g7 u9 T& _5 v; d8 O3 @
  306.   # ● 获取@left_state(按住左键每一帧+=1)0 Y7 J+ B# _+ h* I8 Q
  307.   #--------------------------------------------------------------------------" f3 `+ B- Q5 R) i" z* d
  308.   def left_state
    : M0 w( i7 ?0 u  p: }4 O) d, n( e. ~
  309.     @left_state
    : S. v* T* Q/ l4 c7 f
  310.   end
    / U8 I0 T2 H& J
  311.   #--------------------------------------------------------------------------
    8 X" F! v! A5 J1 K8 K4 O+ C! r
  312.   # ● 获取鼠标的x坐标& w: y7 m3 h% x$ u, |/ i# v; T
  313.   #--------------------------------------------------------------------------
    ; V2 w- y8 C8 [. x1 f& x
  314.   def mouse_x
    * a4 z; \, M. C& I- m* \  F7 Z
  315.     @mouse_sprite.x
    ! J3 n0 Z/ {/ {+ M& G
  316.   end. U, s0 ^9 s: K4 d
  317.   #--------------------------------------------------------------------------
    8 `3 O$ R* g2 _* k* C! }- r' y
  318.   # ● 获取鼠标的y坐标8 x/ b. v+ f( C8 C4 j
  319.   #--------------------------------------------------------------------------
    ( P5 Z1 n9 d% N3 l- K
  320.   def mouse_y
    + q- F" ~! a; X$ D6 K4 R- s4 M: r
  321.     @mouse_sprite.y5 [) u4 w# f0 k% Z5 T) R2 Q
  322.   end
    ( H2 {& ~: G. a7 F9 h
  323.   #--------------------------------------------------------------------------; q, y$ N% \- d/ w) {* J
  324.   # ● 设置鼠标坐标4 J, z- W3 N5 B8 {  A3 H, ^
  325.   #--------------------------------------------------------------------------
    & a) f0 ~! {. T2 v
  326.   def set_mouse_pos(new_x, new_y)* `  \& Q" H+ K  ^3 r, H
  327.     arg = [0, 0].pack('ll'). k) T! [% Y/ S* g
  328.     Screen_To_Client.call(Window_Hwnd, arg)' f; t7 j2 O7 `
  329.     x, y  = arg.unpack('ll')* h# H7 {" O- P2 J& O8 I1 f; g6 W
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    ' V1 v9 M; L1 p
  331.   end
    ' g6 P8 }: R" \& i
  332. end #end of class  self
    7 I6 G- U7 P0 T0 V: |. N* i" Q
  333. " j  F- L1 Y% u! h- ]
  334. end
    . |6 \' b6 p! f8 y$ A# N% ~4 a* R% h
  335. : e: V; \- ~, |- {) T* m6 L
  336. #==============================================================================' R: W1 S! b7 t  y  A0 e
  337. # ■ SceneManager
    1 y( G% C- ]7 B
  338. #==============================================================================7 x" z  o9 k9 r. o. t
  339. class  SceneManager" a% `5 \; H- P' E
  340.   #--------------------------------------------------------------------------
    1 b9 @* d/ z7 A) {9 y
  341.   # ● alias6 M- k6 u. D+ x3 l# R/ b
  342.   #--------------------------------------------------------------------------
    5 r/ K" t  {! N; h+ i! B! k
  343.   unless self.method_defined(sion_mouse_run)
    & L6 D) L+ W" I7 \) Y8 {
  344.     alias_method sion_mouse_run, run7 s( j7 H0 \# \3 g3 _( M
  345.     alias_method sion_mouse_call, call
    4 _6 y. K6 i+ O5 K
  346.     alias_method sion_mouse_return, return
    2 ~: S+ `4 Z% a! _0 W5 ?1 H- _
  347.   end3 j# B4 T) S- d6 ]& d
  348.   #--------------------------------------------------------------------------
    " ?8 `' p7 C- C# r" t& d
  349.   # ● 运行6 u# B7 L/ I7 n
  350.   #--------------------------------------------------------------------------
    3 q" e2 p1 N+ A
  351.   def run
    $ M6 u( F  i, x2 M! J7 n' V. t
  352.     Mouse.init; [/ l9 H/ ~8 x  ~3 W  K6 X0 p
  353.     sion_mouse_run
    4 y; X( Z/ O+ r" g( U
  354.   end
    3 V7 S% q$ T) q$ V! q1 y) f
  355.   #--------------------------------------------------------------------------5 n4 a, c: r+ g0 G1 ^- L1 ^
  356.   # ● 切换2 P2 T. ^7 k: f. w. B: ]/ ~+ \* f
  357.   #--------------------------------------------------------------------------
    6 d' |4 `( Y5 K( m
  358.   def call(scene_class)
    * K$ a% Q  ]6 L, n: O1 R  p7 q
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    4 X6 i" Z- s/ ?$ G
  360.     sion_mouse_call(scene_class)5 L& z3 V+ a% h6 {
  361.   end
    9 r: w, {8 W5 X# i7 Z
  362.   #--------------------------------------------------------------------------3 h% {. \' a# Q3 u4 z* J6 C/ ^2 D
  363.   # ● 返回到上一个场景
    1 s- F, ~; p/ [9 V+ t1 }8 I5 @1 U
  364.   #--------------------------------------------------------------------------1 X# k+ j& m* X3 U8 A" D
  365.   def return
    + r$ P1 b0 m0 n8 _( y6 A
  366.     sion_mouse_return
    2 K/ t# U0 K6 {" i$ h
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&' T" E* r1 {, [8 O3 d; F' T- z
  368.       @scene.instance_of(Scene_Map)
    5 @. {& c% L4 _2 ?$ ?
  369.   end
    % K! @0 H1 l% Z- h4 e$ h
  370. end' _0 e9 {0 R2 E7 f. p6 X; R- J1 s

  371. & T; d- a0 r' g/ h- o" N
  372. #==============================================================================$ D" y' @4 {3 D0 @7 H: l
  373. # ■ Module Input
    , k. v$ f( ]2 p8 B9 D2 U. _
  374. #==============================================================================
    0 S4 G( ]  W$ W/ @( x/ }
  375. class  Input
    0 }( w  H( {7 E* ?! _/ i! g
  376.   #--------------------------------------------------------------------------! s8 @( ~9 l- }1 H* z! r8 \
  377.   # ● alias0 k: m5 c9 E, f0 Y0 E/ n
  378.   #--------------------------------------------------------------------------
    ; S1 n; w/ M+ G1 L) @1 n
  379.   unless self.method_defined(sion_mouse_update)
    * l5 B- ^0 u+ p1 C0 P3 K! K
  380.     alias_method sion_mouse_update,   update5 Q4 U: o' b' f% ~; a& m6 r
  381.     alias_method sion_mouse_press,   press
    + O( l% D" c8 F9 o0 b- r
  382.     alias_method sion_mouse_trigger, trigger- N& G! ^8 Z/ U
  383.     alias_method sion_mouse_repeat,  repeat
    4 S7 j9 H; o6 y
  384.   end0 Y; V! s, ?2 |- d) V) x
  385.   #--------------------------------------------------------------------------
    - G* _6 }3 Y7 u. ]' q
  386.   # ● 更新鼠标
    5 |1 W) Z3 J# j1 G& ^1 q1 t% X
  387.   #--------------------------------------------------------------------------
    * G# d6 _( p  A6 C9 t: z9 Y
  388.   def update6 s' m3 O6 H% h, B( ~
  389.     Mouse.update% t# H9 o5 G4 Q% m6 U* l1 [
  390.     sion_mouse_update
    % J0 Q. d) o4 D- H
  391.   end
    / _/ v: `+ ]7 |0 P2 e" o2 N
  392.   #--------------------------------------------------------------------------
    " m6 h1 p) j$ g8 v
  393.   # ● 按键被按下就返回true
    3 d# ~7 Q- o- S. a. \
  394.   #--------------------------------------------------------------------------
    & p- U3 H% h" R9 z" C
  395.   def press(key)
    * [' ]: M2 I5 }0 f. T0 c
  396.     return true if sion_mouse_press(key)
    4 E, z) {( P: L5 u
  397.     return Mouse.press(0x01) if key == C4 K6 d# y5 V  d3 h5 H
  398.     return Mouse.press(0x02) if key == B: s2 t, }4 W) W' [. m+ G
  399.     return false
    6 z/ Z; u) V$ l/ F& x( }: A+ u5 ?
  400.   end5 X5 x) L- |; s& l* b' ^* Q8 o
  401.   #--------------------------------------------------------------------------6 Y: r8 X/ {% @: u
  402.   # ● 按键刚被按下则返回true
    3 V$ Y5 l* v: j( [; i3 L6 o3 u- I  Z
  403.   #--------------------------------------------------------------------------
    + h4 P/ R8 s# J, P
  404.   def trigger(key)
    5 M# _# y- J8 _+ r1 i2 w: @7 m
  405.     return true if sion_mouse_trigger(key)
    ( i- [$ n2 m* T# |+ I/ B
  406.     return Mouse.trigger(0x01) if key == C- F$ D! l3 U+ t+ n8 m) b
  407.     return Mouse.trigger(0x02) if key == B) z9 r$ l  R1 Z/ B" r
  408.     return false
    5 m8 ?5 S. m9 z+ F4 t
  409.   end1 k6 O$ V# ?3 g( R( [
  410.   #--------------------------------------------------------------------------: i2 ^; H$ `' z/ Q6 p
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    3 N- ~, T/ U$ i% C/ u! `
  412.   #--------------------------------------------------------------------------. g- d0 G& Y1 u: W6 y# Q4 P6 Y
  413.   def repeat(key)
    9 ]4 B& s) }2 B
  414.     return true if sion_mouse_repeat(key)
    + `# {+ @! V& \! s: u) d7 M. W
  415.     return Mouse.repeat(0x01) if key == C
    " w- t! J/ f. R7 u
  416.     return Mouse.repeat(0x02) if key == B) d6 Q. t( T) J0 C' E) I
  417.     return false+ r2 {8 F  a' ^* ^: h4 l
  418.   end
    6 e# J+ n5 e$ `0 V* _, l
  419. end
    8 R/ Q$ f/ ~+ c1 D: f
  420. & m! h: K' m8 M# w( [: q6 H: ?

  421. 4 \8 H( U" C( }  r7 ]
  422. #==============================================================================
    ; G+ H0 L% H  j: l3 M# m" P4 `
  423. # ■ Window_Selectable  F! u6 H1 g# Y& v/ H
  424. #------------------------------------------------------------------------------
      A) w+ f- x1 L
  425. #  拥有光标移动、滚动功能的窗口
    * r& y6 Y. V7 K# u
  426. #==============================================================================
    - @( p9 M, B7 o( h7 a7 M
  427. class Window_Selectable5 R; q+ x6 g  r1 G; _( z
  428.   #--------------------------------------------------------------------------! ?6 M; k3 N4 p! o- T
  429.   # ● 初始化
    : J9 H1 q. W' R; ?# j. \' E4 q
  430.   #--------------------------------------------------------------------------# _- e! g( x8 P
  431.   alias sion_mouse_initialize initialize
    2 f1 Z0 o( [) n+ ^
  432.   def initialize(x, y, width, height)7 _* m* S5 m" X& r6 `* P
  433.     sion_mouse_initialize(x, y, width, height)+ W8 Q: H2 D* J  S' _, W" q% Y/ f
  434.     @move_state = 0
    ! g- u; v7 w9 z0 R9 k- R
  435.   end- y3 t. L, E" r! w" O
  436.   #--------------------------------------------------------------------------# L9 ]( ?' h$ m+ v, ^
  437.   # ● 更新; q3 s% k, e$ T' U. X
  438.   #--------------------------------------------------------------------------
    5 j! }+ }5 S# c, K3 Y/ H' x4 v
  439.   alias sion_mouse_update update+ P5 J8 S) O7 I1 L! u4 V* y
  440.   def update
    1 }  K; b- Q$ q# h
  441.     sion_mouse_update
    3 |1 O4 T! h2 O: R. h
  442.     update_mouse_cursor2 B5 u. R3 ~5 Q& T
  443.   end% H" B  D+ F3 E. v
  444.   #--------------------------------------------------------------------------* B8 |5 G3 C# @
  445.   # ● 启动后设置鼠标到index位置
    2 w  |+ q0 W5 f6 C' J- |
  446.   #--------------------------------------------------------------------------
    0 T- n2 ?. C' @( ]8 ~+ r. u( Z
  447.   def activate# @4 i6 u; u, s) q
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos5 y4 v3 o: L; _* ]) Q* L6 A7 ^) ?& f
  449.     super5 x6 x9 z' \7 b0 J3 I
  450.   end' b3 V# P2 D/ t" l
  451.   #--------------------------------------------------------------------------
    8 q) s, U+ v& T- j0 R3 e
  452.   # ● 更新鼠标和光标的位置
    ) s' z$ J" ?' m% J( Y
  453.   #--------------------------------------------------------------------------
    7 F3 a3 f: _: {6 P; x$ t
  454.   def update_mouse_cursor' G+ e1 `) `1 k! f+ H
  455.     if active4 o4 x) @& E5 _9 [7 Y3 E
  456.       if @need_set_pos
    2 w* _4 A3 [0 M$ ~; H! `
  457.         @need_set_pos = nil4 u) Q9 i- M$ P4 t/ B8 B
  458.         set_mouse_pos' a6 @% j/ k$ u: G3 ?5 t7 U0 V
  459.       elsif cursor_movable
    # p) n/ `+ ^) D. {, t" k; x
  460.         Input.dir4.zero  set_cursor  set_mouse_pos' D, m9 f& z  v) V0 W4 J6 o9 k% |
  461.       end
    ; {8 ?5 {. o# ?, n7 H) [* h7 K) T+ u' ^
  462.     end% B2 Z* s8 H. e% f2 g5 j% G+ ?6 T$ p
  463.   end
    5 y* A& O7 o' `9 a: A
  464.   #--------------------------------------------------------------------------0 x# v8 n: u/ n
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能( G: m1 _$ Q* ?
  466.   #--------------------------------------------------------------------------
    # J, g; F# a0 G" ^
  467.   def set_cursor
    6 t0 D/ S' }4 o" T
  468.     mouse_row, mouse_col = mouse_window_area( M, ], E4 @- K& D
  469.     if    mouse_row == -10 ]/ s6 ]  o2 m
  470.       @move_state += 1 if need_scroll, q2 l) o, d7 H4 F  i- O/ C
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ; ]  ~% q+ U8 F: `) `1 r: ], C9 h
  472.     elsif mouse_row == -2
    ) F3 M2 S" L3 y  F- \! ~9 W( @
  473.       @move_state += 1 if need_scroll
    5 K' K' Y3 _9 {2 I% P
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    0 `  v8 P% m+ Z# c$ I
  475.     elsif mouse_col == -1
    5 B% j& A2 B" F2 i
  476.       @move_state += 1 if need_scroll+ m- Z2 n9 _9 I4 Q
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand1 T/ e* i. y5 Z# u) N& Z! @
  478.     elsif mouse_col == -2
    7 k* h$ S( P0 C0 g' a% x$ o
  479.       @move_state += 1 if need_scroll
    : y5 |; {" v1 C" Y; F1 b; u
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    2 P  x, I4 d2 v4 p5 w/ K+ z
  481.     else9 ~7 d$ \  G. `' G* o1 |; q
  482.       @move_state = 0
    ; S* n& c* ?& M0 e* E+ Z8 Q% v
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col% ?% ?+ i* a6 W
  484.       select(new_index) if new_index  item_max && new_index != @index
    / {' B3 @$ c2 Z. ?1 s0 L
  485.     end2 d2 q5 }) N4 [# B. V3 [& w
  486.   end3 ^2 e, J! R: ^3 s
  487.   #--------------------------------------------------------------------------
    8 I+ r# U4 D! W
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    5 T! ^! {- V2 P( H2 ~- M3 Q8 L
  489.   #--------------------------------------------------------------------------4 `. C; c  z/ F( ^" C
  490.   def mouse_window_area: P4 Y+ r" _! z9 C8 b
  491.     if viewport.nil # necessary!. w5 [( V( }% f7 _9 K
  492.       vp_x, vp_y = 0, 0
    ) _4 C) K( U; p2 g
  493.     else
    ( ?7 p0 u) U3 T8 Y7 H( G1 e, C
  494.       vp_x = viewport.rect.x - viewport.ox) g5 l; g$ ~9 _7 k- A; C
  495.       vp_y = viewport.rect.y - viewport.oy+ q4 {, d6 M& V; }9 ?+ J- F
  496.     end
    % C. D  h2 Q- r9 \& f3 q, K: z
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y6 P1 d" W' L0 `
  498.     item_x1 = vp_x + x + standard_padding & d* m* B1 c7 ]3 l& @+ |. c5 T6 W
  499.     item_y1 = vp_y + y + standard_padding
    - Y# i; f: i6 E) `- {
  500.     item_x2 = vp_x + x - standard_padding + width
    0 D" l( P# l! f/ q
  501.     item_y2 = vp_y + y - standard_padding + height6 b! u8 t. G0 B' w% v; y+ @6 I. X
  502.     if mouse_x  item_x1( U+ u2 ~9 g. X* D3 j
  503.       mouse_col = -1! F- m1 b$ E7 A4 G) n" d/ O* J/ ~
  504.     elsif mouse_x  item_x29 f+ Q8 D! q" T# {% s% P
  505.       mouse_col = -22 h3 q$ e0 E& j. j( e1 \7 n
  506.     else
    7 _1 U* ^8 a) Y/ Y+ a- N
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1). ?! @7 \" q8 P- |* J# L& J
  508.     end1 }+ a3 U& q  m& {+ R
  509.     if mouse_y  item_y1
      l0 W1 v+ Z% w  N4 f
  510.       mouse_row = -1
    2 ?& @: C0 P$ x8 i
  511.     elsif mouse_y  item_y2
    ; l- j$ @) H" W0 K/ @9 K; A
  512.       mouse_row = -2
    , Z" D3 W6 E, }; u( w
  513.     else
    , V  S! r* h9 i2 j6 x
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)' t& p0 n5 p- g3 w0 ~1 ^
  515.     end
    : D: ]) I4 P0 h7 T- A, I
  516.     return mouse_row, mouse_col9 ?. R: N& T8 F6 z$ b) N1 Q
  517.   end2 [& b2 q1 ^) j, E9 M4 Q9 ?
  518.   #--------------------------------------------------------------------------
    : J- G' s1 y( \
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置+ O' E6 I4 R; {3 H& n
  520.   #--------------------------------------------------------------------------1 c1 g: X- B: N! M) c
  521.   def set_mouse_pos1 R4 F5 v3 R4 K4 C0 S' n
  522.     if viewport.nil # necessary!
    ; W; m4 `  O+ W3 l9 U; L
  523.       vp_x, vp_y = 0, 0; |' g0 j6 j0 k
  524.     else
    ' D3 x& z" f, N& W, q
  525.       vp_x = viewport.rect.x - viewport.ox# i8 n2 ?# z0 }0 H& b- y
  526.       vp_y = viewport.rect.y - viewport.oy1 E, z. c% A9 A0 I2 |
  527.     end
    # c0 P; B( x7 B- k: s' y+ {' Z
  528.     item_x1 = vp_x + x + standard_padding
    7 y0 e; u6 U* w5 L* x0 ?+ m
  529.     item_y1 = vp_y + y + standard_padding- r* T2 n2 B- B0 j
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index + e" d6 [, T! [3 u! M* D* s9 a$ t/ q( ?
  531.     row = get_index  col_max - top_row: A( r- f" L) d$ c( E  }
  532.     col = get_index % col_max
      I. `  T0 [# y& q- |% C! T# O
  533.     new_x = item_x1 + item_width  (col + 0.5)' H7 {9 b+ X6 ?/ a. p. G( O
  534.     new_y = item_y1 + item_height  (row + 0.5)7 _, a8 {" c5 z, F
  535.     Mouse.set_mouse_pos(new_x, new_y)0 f% |, H9 R& K" z* C: d1 i
  536.   end3 y  w9 y3 {6 Q5 ?7 _; W3 c
  537.   #--------------------------------------------------------------------------
    / g# T8 _; Q: J! w+ N# C: G' ^3 n
  538.   # ● 判断菜单是否需要卷动  s: a3 [  d* D6 M1 K* `7 j; B7 Q
  539.   #--------------------------------------------------------------------------8 L3 A) z+ U1 Y5 ~2 _% O1 H6 E
  540.   def need_scroll& v( Q# y6 Z5 _* O0 L/ @
  541.     item_max  col_max  page_row_max
    ( g+ ^  ~$ i- \* [2 S
  542.   end/ |7 H  K3 M, ^% h" U1 y3 `
  543.   #--------------------------------------------------------------------------/ s/ `" ?# I( z" B
  544.   # ● 判断是否为水平卷动菜单
    , \) B! B0 H' I& J' u
  545.   #--------------------------------------------------------------------------
    ' o8 \. |3 V( ^0 k- T( D
  546.   def is_horzcommand- x$ e( f/ _! l. a+ {; C; f9 P
  547.     return false! V5 p% r9 k/ G5 h5 c
  548.   end5 U+ h! H! s& n$ q7 s  a
  549. end
    ( H& [/ e# d' k8 l
  550. . [% v) ]% l( l1 H1 K* R
  551. class Window_HorzCommand# N! w% u5 A. G; K* |9 I
  552.   #--------------------------------------------------------------------------' _6 z, ]5 v5 P
  553.   # ● 判断是否为水平卷动菜单' x5 q; _3 ^; G9 i; @% Q0 f9 C
  554.   #--------------------------------------------------------------------------, D8 a9 o, ^7 _$ t" q) A
  555.   def is_horzcommand% o8 d6 v8 J6 [; M9 Y2 d
  556.     return true6 C9 u. S1 P* e. e. o6 M5 [- |
  557.   end0 j0 g; C+ Z; l& H" O0 D; {9 C
  558. end0 p4 k, `5 C2 f) N* D  V2 k8 ~
  559. + H% k: U2 V" P9 {
  560. #==============================================================================5 W. p) ]+ Z! o8 x) L
  561. # ■ Window_NameInput
    / h" h8 U, m( ~
  562. #------------------------------------------------------------------------------7 a" t3 }+ O- X  f9 [. v  @
  563. #  名字输入画面中,选择文字的窗口。& E; j- ^" M, O, _9 x3 i1 A& f
  564. #==============================================================================! ?+ g2 G; ]0 W
  565. class Window_NameInput+ ^4 f5 v2 n) T$ N* K
  566.   #--------------------------------------------------------------------------) l; z' I1 E! W9 p7 I0 R
  567.   # ● 设置列数
    3 o! M& \) C4 L3 p& I+ N$ x
  568.   #--------------------------------------------------------------------------
    * T+ ~  c( r" x0 C- Z' o  L* `
  569.   def col_max
    9 n0 |( o) B9 s& C
  570.     return 10
    " ?4 F* Y" H6 J* F2 z/ Y) [$ T
  571.   end# ~' ]1 Z" E3 Y0 D) i9 H$ c' Y
  572.   #--------------------------------------------------------------------------* @. A+ K( V% u8 G) \0 z) \% p
  573.   # ● 设置填充的Item个数3 d$ e3 w( l' ]% M" `
  574.   #--------------------------------------------------------------------------3 W$ h; c8 j9 h& A1 \
  575.   def item_max
    6 g8 h- x; `2 R
  576.     return 90
    ) @+ w+ l$ I( b4 ~# H5 W9 }5 |6 ]
  577.   end
    / L2 c: C9 `* X+ o. G! S
  578.   #--------------------------------------------------------------------------
    : x# q7 K6 g0 e( P
  579.   # ● 设置填充的Item个数
    2 C2 {0 p6 Y3 ?! |  z# [1 j( V
  580.   #--------------------------------------------------------------------------% m% B+ H0 Z  i  N: t
  581.   def item_width% Q( u7 _) X) `# y) m5 e( J$ c- q
  582.     return 32
    . ~0 p1 @. c! |# Z# L# `0 s* V
  583.   end
    0 J$ A& M- w5 t
  584.   #--------------------------------------------------------------------------% A8 j. Y8 V! f, u6 U5 m* v, c
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    + B* j& P: p& s9 @' J, [
  586.   #--------------------------------------------------------------------------* J& X8 l& A* u9 I+ X  z, g6 B
  587.   def mouse_window_area$ i; K6 i/ L; ^# A; k
  588.     if viewport.nil/ H: w: D; v6 p* u! ?, q
  589.       vp_x, vp_y = 0, 0
    ' C$ L1 ?: x+ T7 L. H1 E* Y3 ]1 s
  590.     else
    , `  G! n- }; Y* B2 d" R6 A
  591.       vp_x = viewport.rect.x - viewport.ox# \, _% h- p) i/ `5 Z0 q( O; R/ u
  592.       vp_y = viewport.rect.y - viewport.oy
    % @$ ~) A" T- m" m
  593.     end
    + Q* j$ Q( t8 W6 [) V2 Z
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y6 ?* a3 @) s8 W: l3 z
  595.     item_x1 = vp_x + x + standard_padding ! v! W# |( E) i; t
  596.     item_y1 = vp_y + y + standard_padding# o; v& P* j2 U6 m, Z; Y$ D$ w
  597.     item_x2 = vp_x + x - standard_padding + width
    6 a8 @& d: ]7 L; l
  598.     item_y2 = vp_y + y - standard_padding + height
    0 W5 X6 h% |9 G+ n" b
  599.     if mouse_x  item_x1
    - m' _% j9 ~# ~/ b
  600.       mouse_col = -1
    ; D# v7 z& I5 Q% ^
  601.     elsif mouse_x  item_x2, |' k9 ~8 `1 f- A
  602.       mouse_col = -2
    / C2 k  G9 I& P+ P, v, w
  603.     elsif mouse_x  item_x1 + 160
    . k/ ~, D) f2 ^4 f& W3 d
  604.       mouse_col = (mouse_x - item_x1)32
    / M  v7 c1 ~2 M( p
  605.     elsif mouse_x  item_x2 - 160
    ) L& M; ~% Z! A& A
  606.       mouse_col = 9 - (item_x2 - mouse_x)327 x% x$ w% y7 R' x! l! n' l
  607.     else. t# O" c5 F/ o9 P
  608.       mouse_col = mouse_x  x + width2  5  44 `  [* h9 h0 x
  609.     end0 v3 A) w3 p/ _6 f8 N
  610.     if mouse_y  item_y1  i$ }7 m1 G5 i5 |- J! ?' r. N
  611.       mouse_row = -1
    & ?$ H. {  l9 w
  612.     elsif mouse_y  item_y20 B0 w1 U5 z8 \0 }* @
  613.       mouse_row = -2* {% V; N" H7 S9 u% L' u  I
  614.     else4 C7 W/ }9 U' T" c7 Y! t$ O
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)6 a3 ]2 a$ b& {5 @" `
  616.     end
    & T0 ~  p1 ]0 o, i
  617.     return mouse_row, mouse_col
    9 X$ i8 }. D6 X5 O) t" q1 V
  618.   end
    ; e6 m# v! r* d3 X( }
  619.   #--------------------------------------------------------------------------
    " ?$ I& Z5 c& F% {
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置4 x# _& {  K* b" B5 w" I
  621.   #--------------------------------------------------------------------------, T- h! S* V: C: _: w# ^9 g3 F
  622.   def set_mouse_pos
    + b/ d3 @& S* u; L0 n3 J( }
  623.     if viewport.nil # necessary!
    ! S4 X: L: O+ G  i' P3 G8 S
  624.       vp_x, vp_y = 0, 0
    6 r1 K& m! F9 f3 ^, H5 u
  625.     else
    : g3 ]1 [: i  F' e2 b
  626.       vp_x = viewport.rect.x - viewport.ox
      ~4 E6 S2 w8 m; M9 ]( M5 i
  627.       vp_y = viewport.rect.y - viewport.oy4 Z( Y$ O- S) p) _
  628.     end
    # `* R5 P. q; c: p" L% N8 R$ E: n
  629.     item_x1 = vp_x + x + standard_padding 4 H- Q1 a4 w& v1 }
  630.     item_y1 = vp_y + y + standard_padding
    2 ?2 C; O( P3 s6 F- s
  631.     get_index = @index  0  0  @index ) [+ v8 E8 Y. @9 f2 u1 E1 L
  632.     row = get_index  col_max - top_row* a$ p; f! M( a
  633.     col = get_index % col_max+ e+ T4 G" h3 u0 Y+ Y
  634.     new_x = item_x1 + item_width  (col + 0.5)9 ^) D5 ~' F, ^9 v/ ]* E2 u5 g
  635.     new_y = item_y1 + item_height  (row + 0.5)0 y4 h; w& X$ b" \( z8 e5 `
  636.     new_x += 14 if col  43 I7 b8 D: m' u" h" p
  637.     Mouse.set_mouse_pos(new_x, new_y), B3 c1 I4 U( f, z% V8 l4 V* A0 ?
  638.   end9 W- {8 e" R' t: L& i# |
  639. end
    4 t( V% C8 [  N( a7 Y5 e% d# U# p
  640. - }3 {! I' d! t2 J( i7 Z
  641. #==============================================================================: O* E+ ]* U; Y
  642. # ■ Window_NumberInput
    ' x# L0 D1 X4 S, e2 W
  643. #------------------------------------------------------------------------------
    - M, ?8 O. p( q2 D
  644. #  重写了数值输入的方法以适应鼠标
    & |* v" I0 z+ G
  645. #==============================================================================; x3 [' |$ [9 r. t- V
  646. class Window_NumberInput  Window_Base
    $ s1 I* v6 ~! u6 P+ e. M, A  {
  647.   #--------------------------------------------------------------------------
    ' ?! E: e# Q- ]
  648.   # ● 定义实例变量
    1 s7 W& W2 U$ p4 W
  649.   #--------------------------------------------------------------------------! r1 x, g- _; v( T3 A' A
  650.   attr_reader extra_window
    ; U1 ]. o. r/ D' e9 n' o9 c# n
  651.   #--------------------------------------------------------------------------8 ?8 u) U; `- ]9 S
  652.   # ● 初始化0 g0 n, |" }/ {8 P& k& s
  653.   #--------------------------------------------------------------------------% i9 D& u" F9 e
  654.   alias sion_mouse_initialize initialize
    3 s8 Y; N' V6 f- y$ A9 T, y
  655.   def initialize(arg)
    ; z1 r. n0 t$ q2 y: j! E: x
  656.     sion_mouse_initialize(arg)7 C) |) d4 `  B2 O" a
  657.     create_extra_window
    ) ^2 a7 w. ], o9 Q- d8 W
  658.   end
    5 g/ X9 ~+ T. i+ a
  659.   #--------------------------------------------------------------------------) k- B2 a/ P; V2 u9 P; X5 L
  660.   # ● 启动9 Q' c; F! s; ^% M: \
  661.   #--------------------------------------------------------------------------. R( y* G# {# D6 i/ y
  662.   alias sion_mouse_start start
    * \5 L5 i' ]2 s0 B8 j: ]
  663.   def start  v! ?1 R  C+ T/ L9 h- v
  664.     sion_mouse_start3 c2 o2 `- q9 Y
  665.     deactivate  x. f4 a( @1 \9 u
  666.     extra_start
    * y/ v- E) z5 ], ^
  667.   end+ a' g3 G2 o7 V1 {' g9 ]
  668.   #--------------------------------------------------------------------------
    0 L) c2 }$ ^) \4 F: P, W
  669.   # ● 创建新的数值输入窗口4 S6 o; J1 f. G+ i$ ]7 `" ~2 \
  670.   #--------------------------------------------------------------------------
    ! w4 T- Z) d& i; e2 I" A: I1 O
  671.   def create_extra_window- H( Z* r! w! o. \3 w
  672.     @extra_window = Window_NumberInput_Ex.new
    9 N* V9 [" x5 ^0 f/ x* P
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2; L" n4 i/ k& d. F; w3 N
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    9 H9 D3 F- u& {
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    ( e0 G( j4 K' q+ j2 u) t! c( m
  676.     @extra_window.close_proc   = Proc.new { close }
    4 X# z' i# I' _: ?: X
  677.     @extra_window.refresh_proc = Proc.new { refresh }% @% k2 y' X' g/ Z; _! X
  678.   end' r3 ?: N+ Y! e" B* Z( Q5 ~
  679.   #--------------------------------------------------------------------------- h! K+ {# f: \2 z1 G
  680.   # ● 激活新窗口
    ! [5 J/ F+ ]* {; _& H7 s
  681.   #--------------------------------------------------------------------------. _/ h  l3 [/ B: T
  682.   def extra_start
    7 ]5 F0 p% h7 r* w
  683.     case $game_message.position0 N) X2 u& D' A! A
  684.       when 0; @extra_window.y = y + height + 4
    3 e1 Y/ u- j0 T7 |
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8) n& k$ `" Q# M, y, Q, n! }$ ?8 I
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    - s( X- Y- |, m; p
  687.       else  ; @extra_window.y = 8
    4 x; G; f( s+ l! T, E
  688.     end
    4 v3 a, f6 C& J1 j
  689.     @extra_window.variable_id = $game_message.num_input_variable_id# g& z: H. w: m) m, v) ~! Z2 K- @
  690.     @extra_window.digits_max  = @digits_max
    $ k, K; L$ e+ F
  691.     @extra_window.number      = @number2 d. [! G  {+ ?
  692.     @extra_window.open8 z1 |* `$ d+ \
  693.     @extra_window.activate
    9 `. |* g0 }, a
  694.   end4 g6 R. w7 h2 V. N
  695.   #--------------------------------------------------------------------------7 H- R! v4 J; K4 j& Y) ~# u
  696.   # ● 更新4 E% K0 T5 H. H# b! \% Z1 @
  697.   #--------------------------------------------------------------------------
    * I* q" M3 F( _( ]
  698.   def update
    ' A7 Y  D0 s( E; J
  699.     super
    1 J( E- N! J  q! T  A
  700.     @extra_window.update$ N: s% G0 c; E" f0 v
  701.     update_cursor
    - I! C/ M. d0 l- E4 r3 ]* D3 {
  702.   end
    , U$ I% G( Q- o2 s$ `1 X: o, I8 k
  703.   #--------------------------------------------------------------------------
    ( W7 n- c+ X  i( C% q
  704.   # ● 关闭窗口" g0 v) s2 Q. O% }; i
  705.   #--------------------------------------------------------------------------2 h3 W- f" _; @( i
  706.   def close9 D5 G/ Q9 W" E) P9 X2 A! B; s
  707.     super
    2 G9 Q  M4 _+ {; |0 z/ p
  708.     @extra_window.close( ^6 C) \0 z3 y' [+ ]: J
  709.     @extra_window.deactivate5 c2 _5 v- A5 W( y$ H$ M( d$ u7 p1 Y
  710.   end
    ) W- e7 r7 J) H) s
  711. end
    " b2 F8 S- c. V/ o

  712. $ V  W, m* ^5 ?4 V. y
  713. #==============================================================================! [0 B# Z6 Y) M
  714. # ■ Window_NumberInput_Ex6 I2 }2 f2 k: X! [0 s
  715. #------------------------------------------------------------------------------$ o& E. O  ~0 B% H5 V, x& |& d6 P
  716. #  新的数值输入窗口(NewClass)
    + ?% o2 X) L! }+ h4 _( |- S
  717. #==============================================================================
    2 y" U0 n! q5 c5 s
  718. class Window_NumberInput_Ex  Window_Selectable2 X' Z3 f+ D4 q/ K9 E* b+ A
  719.   #--------------------------------------------------------------------------
    & o+ N) v% h: g. |9 ^( N1 j
  720.   # ● 定义实例变量: _" J* J, q; h' S' j, d
  721.   #--------------------------------------------------------------------------! M) w" U! H  J# Z
  722.   attr_accessor number_proc
    + @4 J. z7 ?& J- ], k
  723.   attr_accessor index_proc
    / B! R6 J  i* e; j
  724.   attr_accessor close_proc
    / J  ]+ c3 h" f3 o8 s9 V
  725.   attr_accessor refresh_proc
    " U2 U1 x) D% L
  726.   attr_accessor number& k8 Z! e1 k( ]9 d+ I( w
  727.   attr_accessor digits_max1 }. e; i! L1 Z' G% n; [1 E
  728.   attr_accessor variable_id  }! T, H$ j2 Y! [2 N6 y9 p
  729.   #--------------------------------------------------------------------------
    0 j( ], U% V! T1 \0 ?1 q0 ^
  730.   # ● 数字表$ Q7 k4 J2 ^" @! ?3 k* e
  731.   #--------------------------------------------------------------------------
    5 i/ b2 V# j3 ~
  732.   TABLE = [  7,  8,  9,
    - L3 g- q2 S: W% }8 p5 b3 h
  733.              4,  5,  6,
    7 l: P) A* H# Q) e% H* }
  734.              1,  2,  3,+ k5 D  s% R# i+ C# b/ j7 y* [
  735.             '←',0,'确定',]
    . o, H$ E/ p& _- v8 }( e- X0 [
  736.   #--------------------------------------------------------------------------
    1 T. Z! u; N1 q7 L# U* A2 f5 N: q( ?
  737.   # ● 初始化对象
    ( ?  r1 S& Z. Q. Q
  738.   #--------------------------------------------------------------------------) U! V) @2 Y  Y# Y% F* ?
  739.   def initialize- {! {# t  b) G
  740.     super(0, 0, 120, fitting_height(4))
    - r, m# g4 m: V7 [
  741.     self.openness = 0
    . O, Y$ C! a% F* m
  742.     @index = 0
    0 T6 j. k2 M8 ?2 ?& `: y) \* l
  743.     @number = 0
    6 ?6 \+ k! Y  y0 b& M8 @2 X
  744.     @old_window_index = 0) e( R) M( R& u+ R1 x, L7 `: |' U
  745.     @digits_max = 03 X- D; P) I  n( Y% r0 p4 Z
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    ) Z  |5 Z, ^: S) l' f
  747.   end
    % n  Y* c2 {& n$ ?) |4 J
  748.   #--------------------------------------------------------------------------1 j" [" U& M1 a  u- H/ F/ K$ j
  749.   # ● 获取项目的绘制矩形
    1 o8 `& c* f9 ~: e6 b
  750.   #--------------------------------------------------------------------------$ C6 v6 _3 k- j" f- Q
  751.   def item_rect(index)
    * j" K* I3 g8 S4 C- f+ B6 a
  752.     rect = Rect.new7 n/ b, A% P2 ]  {# o- r
  753.     rect.x = index % 3  32
    9 X. t8 {& r1 m% ]; I
  754.     rect.y = index  3  line_height. Q# P' N7 [- L" A" P7 \  w
  755.     rect.width = 32
    $ C) \" C" N& j; N1 W: C$ q: C% ]  H
  756.     rect.height = line_height) }5 e' p) f9 {( b8 b/ E
  757.     return rect8 r( q9 x$ @$ N2 X" y8 J/ G- d
  758.   end
    7 K* r- k/ Y1 J6 P0 a% U
  759.   #--------------------------------------------------------------------------! m, i% a* U+ ^/ {$ d/ \* ]8 Q3 g: c
  760.   # ● 将光标设置到鼠标所在的位置3 Y3 s8 V9 Y, C5 e2 s
  761.   #--------------------------------------------------------------------------
    ; t8 |8 Z9 S! I; F8 p
  762.   def set_cursor
    8 e0 t5 q; o( y; Q0 y- Y
  763.     mouse_row, mouse_col = mouse_window_area
    7 g5 g7 d6 C/ s0 m) ]6 l. F
  764.     if mouse_row = 0 && mouse_col = 04 `( A* ?% C! j0 E7 i" s* _( T3 p3 G
  765.       new_index = mouse_row  3 + mouse_col
    2 \0 D2 k- @2 m% J. ?, P" r! j& C
  766.       select(new_index) if new_index = 11: z3 {5 r0 H' a6 F8 D+ `3 s3 _6 I! ^
  767.     end
    & @' d: P3 |5 o- z
  768.   end9 d' `5 n( U/ s7 w
  769.   #--------------------------------------------------------------------------
    . M' [" T$ r$ ]# z
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    % v- i' [" c0 C& v0 r
  771.   #--------------------------------------------------------------------------* b# N6 j- R0 b
  772.   def mouse_window_area) V* {- r9 X( a. C
  773.     if viewport.nil
    5 K! \6 E* W3 M+ h4 v
  774.       vp_x, vp_y = 0, 0
    2 J% i  [- @0 F& E
  775.     else% O/ Q3 m( D' c5 m4 u
  776.       vp_x = viewport.rect.x - viewport.ox# x$ S, a: o6 x9 V& b- G, q- l
  777.       vp_y = viewport.rect.y - viewport.oy# m1 U; f( k9 M" o  u9 l; Y- Q
  778.     end
    0 k! W) ~: u" s9 I6 O9 A8 k
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ) z* o% t' q* }5 v
  780.     item_x1 = vp_x + x + standard_padding
    , E) \% h6 ]7 [% ~3 x9 k
  781.     item_y1 = vp_y + y + standard_padding
    & B( o+ ]- ]3 ]2 {' s
  782.     item_x2 = vp_x + x - standard_padding + width
    ; g7 `6 X; R$ G7 B* O
  783.     item_y2 = vp_y + y - standard_padding + height/ L1 {4 E6 r# h% c1 c
  784.     if mouse_x  item_x1
    : X7 @3 {7 K! p, i9 f' |
  785.       mouse_col = -1
    $ O" w3 o( `) o: o7 o9 d
  786.     elsif mouse_x  item_x2
    2 f* @/ K. @" @2 v
  787.       mouse_col = -2! \! K1 s. a; s: q3 v) h
  788.     else
    2 t/ J$ I0 M- H5 J6 O
  789.       mouse_col = (mouse_x - item_x1)  32
    4 X1 w4 t4 ]( j, G5 P
  790.     end( I' M  ]) k8 {2 H5 _. U8 j
  791.     if mouse_y  item_y1
    9 t5 g* T; [( j
  792.       mouse_row = -1
    $ S+ ~# A  D8 s- Y' o% M
  793.     elsif mouse_y  item_y2. t/ z* ^& t* i  T1 D
  794.       mouse_row = -25 n6 T/ ^' i) l. U# a8 c7 I
  795.     else/ S$ m& l3 A" `! e
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)/ o& }& y3 M0 }8 [/ E; Z; s
  797.     end; q3 c& z% g- e" @( [7 v+ E& L
  798.     return mouse_row, mouse_col
    " d. q7 b$ X9 f5 m
  799.   end
    9 |1 p0 H3 R; }5 n$ B
  800.   #--------------------------------------------------------------------------
    " _* \0 T7 J. k) A- i* e+ X) h
  801.   # ● 获取文字
    4 C( L) W9 _/ f9 S; L
  802.   #--------------------------------------------------------------------------
    3 R; Z6 n) @1 F
  803.   def get_number
    ' J* I3 n0 `; U& u1 l
  804.     return false if @index == 9  @index == 11
    : o6 |. s' |: p$ g' v' n$ x
  805.     return TABLE[@index]# m" f6 q7 a) r  K! g) N
  806.   end. q) T$ v9 n4 p
  807.   #--------------------------------------------------------------------------2 L8 n: ^7 @1 k% Z% N' X" s3 d8 L5 V
  808.   # ● 判定光标位置是否在“退格”上
    1 ]- J. Q' ]4 L- S
  809.   #--------------------------------------------------------------------------! t- w! Y4 T1 k. q* o5 r6 i
  810.   def is_delete
    ( n" D/ w4 p3 h6 U# Y, m3 n: D
  811.     @index == 9* C4 Q/ n. n% \! Y6 f
  812.   end
      N/ ?. d" @& h2 I$ r. H8 [' T9 l) k
  813.   #--------------------------------------------------------------------------
    : `% N! c0 J7 W6 c- r
  814.   # ● 判定光标位置是否在“确定”上
    % L2 O# f& d& X
  815.   #--------------------------------------------------------------------------; k9 P0 z. e" O( q' ]/ H
  816.   def is_ok
    & a) n+ y) X8 `4 b! ?
  817.     @index == 11
      g4 m: c; h3 t( k
  818.   end; P. @  n3 x5 f- S
  819.   #--------------------------------------------------------------------------+ z7 j! E/ x3 E+ h$ B1 f2 X9 \
  820.   # ● 更新光标. \- q. W& n5 V
  821.   #--------------------------------------------------------------------------5 k# p2 v: h0 `. Q) X4 T
  822.   def update_cursor7 l) N/ r( S' W
  823.     cursor_rect.set(item_rect(@index))5 m1 w1 x5 E; C9 R1 z8 j' C- \* j
  824.   end
    - `$ \% m# b' U* A8 r
  825.   #--------------------------------------------------------------------------
    7 y; I0 l5 A  t" R% B3 M
  826.   # ● 判定光标是否可以移动0 Q0 F1 A( J/ _7 u$ a
  827.   #--------------------------------------------------------------------------* J4 p6 Z3 e7 T! H
  828.   def cursor_movable- W9 Q8 Q# w: b6 W/ E% T' X. i
  829.     active2 P' |! V( v- \, I* {( U4 x. g
  830.   end
    + ?, v+ o8 [0 C# ]! J, C# a
  831.   #--------------------------------------------------------------------------' f+ C7 e) I" e( u5 y% R
  832.   # ● 光标向下移动
    + S. E  f: ?; g0 o+ a; I$ B4 Y0 t
  833.   #     wrap  允许循环) K0 E. z: T6 e% F1 E4 `( D
  834.   #--------------------------------------------------------------------------
    , r0 I$ e" u$ f+ I" S
  835.   def cursor_down(wrap)
    & B" n: g& F8 N2 O9 _& z) e
  836.     if @index  9 or wrap
    3 e0 n) u  x* G) x
  837.       @index = (index + 3) % 12, n  y! \9 c8 X& P- `6 _
  838.     end4 N3 O) \" \9 Z; g7 u
  839.   end! f, ~$ J. v* b* s+ b
  840.   #--------------------------------------------------------------------------( K5 b0 m  o  n4 H$ w/ A% Y9 k" A1 r% a
  841.   # ● 光标向上移动
    . O- l  c1 N) D9 k- k
  842.   #     wrap  允许循环( D$ |# x" B9 T* p1 \9 F6 K" X
  843.   #--------------------------------------------------------------------------( T, X) f1 X% {) V6 q, x  J/ W
  844.   def cursor_up(wrap)- ?- r4 R! b( q9 D2 R# g2 a
  845.     if @index = 3 or wrap5 f$ L0 n4 K/ a* P4 f
  846.       @index = (index + 9) % 12+ K# G3 H4 g) Q) }! n6 o
  847.     end
    1 d9 I. q/ L" c& s" F) w9 k/ \4 o
  848.   end2 C1 {6 c3 T/ `
  849.   #--------------------------------------------------------------------------  h* _' A# B) \$ i' M. q$ F
  850.   # ● 光标向右移动
    ) e' C9 D( z. Y. R
  851.   #     wrap  允许循环$ y& W9 p) O. Q  s/ ^9 g
  852.   #--------------------------------------------------------------------------- u; W! r" `; \8 e4 z6 [4 v3 I
  853.   def cursor_right(wrap)7 h5 ~; K2 [0 R, u$ `# q
  854.     if @index % 3  2
    % n& D, X2 w& t) z5 t
  855.       @index += 1
    . D- Y) h+ I" u3 `
  856.     elsif wrap3 E* m3 K; [3 u/ \0 @% L  d
  857.       @index -= 2) }: {7 f0 U$ N  T  k, z
  858.     end
    & e3 L+ K2 _5 y) \0 H- F2 _
  859.   end) x/ r% |, ]7 h  d3 F  W
  860.   #--------------------------------------------------------------------------+ L. w0 E7 b: e4 M' X& v- T
  861.   # ● 光标向左移动
    % ~, ]" R( A" E
  862.   #     wrap  允许循环
    # x4 @/ F5 D1 K, }
  863.   #--------------------------------------------------------------------------
    / r# L. W) u. t* p6 T
  864.   def cursor_left(wrap)
      m9 U9 m, Q8 e
  865.     if @index % 3  0/ `8 I" b* {% a' s1 z4 W! x' W
  866.       @index -= 1
    # v' F' V! H$ s. K9 L* A. o
  867.     elsif wrap- [. u' P# d7 T! r
  868.       @index += 2
    6 i5 I+ ?9 y& O0 t3 M
  869.     end
    8 i9 t+ G9 v5 _  L
  870.   end! _7 o; S3 B! E; S; i
  871.   #--------------------------------------------------------------------------5 h5 S1 P8 P. B
  872.   # ● 处理光标的移动
    # L7 t. }1 i8 A* f; Z' Y$ g
  873.   #--------------------------------------------------------------------------9 B, m9 C1 ~) E2 c2 `0 S# I* c( l
  874.   def process_cursor_move9 A" n' M% q$ R+ O0 F
  875.     super- i: r+ Q$ y1 a. e, |' q; E
  876.     update_cursor
      |" f$ p  _# Y8 \5 E
  877.   end  \5 _& Q  q: G9 X% |
  878.   #--------------------------------------------------------------------------
    / n0 \" `' x; E; k5 H7 `- r' E6 s
  879.   # ● “确定”、“删除字符”和“取消输入”的处理! ]* r0 g, i$ n, `
  880.   #--------------------------------------------------------------------------  b" J: Y4 W: d3 o# G
  881.   def process_handling, k6 e  ], ~5 w( B
  882.     return unless open && active/ Y8 j; U! p. `) O  i
  883.     process_jump if Input.trigger(A)% S, c8 D9 K8 i3 f1 L
  884.     process_back if Input.repeat(B)& y# G5 @8 b6 r7 P3 q: E2 T
  885.     process_ok   if Input.trigger(C)& v% t$ C$ E2 X0 _$ |
  886.   end# E  p% [8 S( p
  887.   #--------------------------------------------------------------------------
    . M' x3 V, r/ L% L% N/ N# V
  888.   # ● 跳转“确定”& O* n8 ~# C! N+ o8 P
  889.   #--------------------------------------------------------------------------/ d# b9 \/ {" m) a. |( c6 ?
  890.   def process_jump
    1 y7 c- n1 R4 u% g, ^+ w; J
  891.     if @index != 11
    2 n8 [& b/ g* g
  892.       @index = 11
    * B, c5 ?8 m) V, x1 e
  893.       Sound.play_cursor
    2 J- V$ w$ ]+ s/ ~
  894.     end7 y' `% B. e  y& \( M, i- Z, k
  895.   end
    3 e) \0 a8 _4 O$ m6 N  [" x
  896.   #--------------------------------------------------------------------------" W& K. J9 P8 v8 d8 {) V
  897.   # ● 后退一个字符' e5 J2 X( m9 @. s# {6 h
  898.   #--------------------------------------------------------------------------
    , _6 I  w$ l+ x" H
  899.   def process_back7 \9 z% c) q9 _) I1 k) Q
  900.     Sound.play_cancel& j. S. K6 x$ D0 K  p- {
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    2 o; p+ `( ?6 W& O: P
  902.     n = (@number  place) % 106 k( }# k8 @. {4 Q* e/ Q1 ^
  903.     @number -= n  place
    ' S' O3 }4 g5 {
  904.     @number_proc.call(@number)4 ?$ q5 f) G: c" T* l1 i( }
  905.     @old_window_index -= 1 if @old_window_index  0
    ) m' d+ }3 w/ _* ?6 z
  906.     @index_proc.call(@old_window_index), P' `3 e" `: E5 T( F, S, X. P7 E
  907.     @refresh_proc.call
      P" E: X( B, J
  908.   end# ?2 _4 r/ n+ Y
  909.   #--------------------------------------------------------------------------; W/ j. o; v. O  z3 z
  910.   # ● 按下确定键时的处理
    $ Z# S$ W; k1 l$ V
  911.   #--------------------------------------------------------------------------
    5 n! q  y1 ]# r/ C& P
  912.   def process_ok
    4 F2 i- @( X# O9 h2 r
  913.     if get_number
    2 R3 U& m: L/ E
  914.       Sound.play_cursor6 X- E: L( Q$ v' `+ i
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    % [* J/ W( B, F+ h
  916.       n = get_number - (@number  place) % 10+ m; b# E4 |; a5 l1 c! e
  917.       @number += n  place" g4 T( A4 ]/ g$ f) }1 X/ |, h- q* E
  918.       @number_proc.call(@number)! a- Z* C% _, L
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1/ E$ y4 v2 V( Y( e9 s5 o. O
  920.       @index_proc.call(@old_window_index)
    $ b+ G7 Z& h4 m
  921.       @refresh_proc.call
    % k* i+ d- p1 X9 g/ N
  922.     elsif is_delete2 B6 Z1 z/ K" I+ z7 c
  923.       process_back3 n; z- Z$ t# B  l7 s% U8 B1 n8 x
  924.     elsif is_ok- [1 B" w5 c% q4 L; O
  925.       on_input_ok* T% u! c% z! k
  926.     end
    # Y3 y& i( G0 A6 e
  927.   end
    ( r  k2 \2 {3 B3 ?% s% b
  928.   #--------------------------------------------------------------------------& ~" X7 ?1 i2 d# o( f4 [' T
  929.   # ● 确定
    ( Z, k2 H, h2 B& ?
  930.   #--------------------------------------------------------------------------
    3 c' w5 t4 d2 ^- A' v. n+ F
  931.   def on_input_ok
    : x8 z" I' l3 y- D1 C7 D/ l
  932.     @index = 0# |9 k  e1 U3 M: }( R* `  r
  933.     @old_window_index = 0
    4 T# h4 h9 [5 O$ R# v; w+ ]
  934.     $game_variables[@variable_id] = @number: Q0 P9 m1 d' Y
  935.     Sound.play_ok0 n' v* j! P! a* f+ U
  936.     @close_proc.call6 ~* N3 V' R2 y- U  U2 j
  937.   end# I2 A1 p3 D2 O" C9 p
  938.   #--------------------------------------------------------------------------5 X- j# @4 c, G$ b0 p8 r% l
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置: Y) E( \4 C" v
  940.   #--------------------------------------------------------------------------4 }7 {1 T" L+ d' o  E
  941.   def set_mouse_pos
    5 G2 {! M* @- |
  942.     if viewport.nil # necessary!. A  _- T' B  L4 o
  943.       vp_x, vp_y = 0, 0% _' k& _: n+ V4 n! `
  944.     else) R5 U/ z+ V7 k/ I1 p
  945.       vp_x = viewport.rect.x - viewport.ox) Q. f9 x, ^, v' f( y% U/ C- W$ ~
  946.       vp_y = viewport.rect.y - viewport.oy
    ( F9 E; \" p" ?6 |
  947.     end
    9 m' c" ~& Z- k+ Y6 W/ @: }- y0 E
  948.     item_x1 = vp_x + x + standard_padding
    / `' L* h" E7 }8 r9 q3 Z
  949.     item_y1 = vp_y + y + standard_padding
    , e+ y6 v( t; H2 S/ R* ~
  950.     get_index = @index  0  0  @index
    2 i& l" T8 B0 I4 N+ B0 f/ r7 F$ K+ Z2 y: p
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)) f: R- e# X$ @7 V- K% K4 ?
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)4 N6 p( ^& q, ?# e- X7 c
  953.     Mouse.set_mouse_pos(new_x, new_y): i  r' j2 ^  z% D: J
  954.   end
    & z" }3 ?6 T/ r, x: n$ |
  955. end
    ! M5 h# V. o& f- u+ f) O

  956. # B  D% |7 ^$ v
  957. #==============================================================================
    7 ^2 f* ]) z9 p7 D) R% X
  958. # ■ Window_Message. T5 R9 J9 g+ c; Y2 C; Q+ C
  959. #------------------------------------------------------------------------------" Y8 V* r# P7 q6 ?( y. \" y
  960. #  显示文字信息的窗口。  }; M" d( n3 S3 T9 ]
  961. #==============================================================================4 K% b1 s6 D6 x+ I
  962. class Window_Message  Window_Base
    $ c: U# x' A. @) e: x2 _
  963.   #--------------------------------------------------------------------------4 w6 D7 Z+ s* Y! q8 B
  964.   # ● 处理数值的输入(覆盖原方法)
    % o1 i) D7 @% `5 w; D: p4 {8 L
  965.   #--------------------------------------------------------------------------# a/ I7 q/ C$ I, S, i3 @' T
  966.   def input_number0 m% @3 Z  w/ U2 P# l3 D# o
  967.     @number_window.start
    + h$ b% U2 E) x
  968.     Fiber.yield while @number_window.extra_window.active
    9 ~7 @+ i) B  l7 {$ u& M
  969.   end
    6 p$ d+ V2 k. V) X
  970. end8 m! V! o* G5 M- z. {

  971. + X* d/ I+ ^# z4 r0 y: M
  972. #==============================================================================
    2 G! Y; G# _1 O7 D: ]
  973. # ■ Window_PartyCommand
    , A3 }7 f% d$ Z4 ]* E
  974. #------------------------------------------------------------------------------0 z! \4 j% ]( k/ ~
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
      h/ ]! g& |# ]
  976. #==============================================================================0 Z& P6 V8 p6 i$ F
  977. class Window_PartyCommand  Window_Command0 @* {5 n+ b: Y/ q8 F: n
  978.   #--------------------------------------------------------------------------( u) @# W  c5 l
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    7 G1 m3 p. U/ {& \& S5 [
  980.   #--------------------------------------------------------------------------" n" P/ {' t/ ]
  981.   def set_mouse_pos6 Y- f# e. R4 C/ X+ k5 V$ L
  982.     if viewport.nil( D" i6 O7 o4 J& y0 h1 W, S
  983.       vp_x, vp_y = 0, 0  M2 K% s1 G- K+ |/ Y
  984.     else: w; f4 C4 F& {/ m8 x7 \$ m* s
  985.       #vp_x = viewport.rect.x - viewport.ox
    + a' N9 f$ ^6 e  G7 H
  986.       vp_y = viewport.rect.y - viewport.oy0 ?# F; N6 _4 A: e0 ]
  987.     end
    : x" t2 H. d3 ?) N/ m0 O
  988.     item_x1 = x + standard_padding
    . Y$ h# [$ O3 Z$ b( ]+ C- ]
  989.     item_y1 = vp_y + y + standard_padding
    3 r8 A  E6 f3 h, Z8 V0 c" A" M
  990.     get_index = @index  0  0  @index " `0 D! U" X# r6 K; p
  991.     row = get_index  col_max - top_row
    - K/ M1 i8 j7 l( ]8 P0 O. r- h
  992.     col = get_index % col_max* H( r7 h! O/ U4 @: `% f2 l
  993.     new_x = item_x1 + item_width  (col + 0.5)
    ' A% l' w! o) M( b
  994.     new_y = item_y1 + item_height  (row + 0.5)
    8 w6 P$ Z$ K( N& ]- P: Y
  995.     Mouse.set_mouse_pos(new_x, new_y)/ O) x. M2 p1 @* {! a. e+ O! e
  996.   end! q% F. W, ~0 ]0 T* P$ i+ R
  997. end% v: s: T: _& z5 B, Q
  998. # n4 Q% I0 G; |: Q
  999. #==============================================================================
    7 i5 I0 }! Y( n/ M& ~
  1000. # ■ Window_ActorCommand
      z: a: F3 H% w& @" S/ ^  v: O( P
  1001. #------------------------------------------------------------------------------2 J: J! _+ r& l' l
  1002. #  战斗画面中,选择角色行动的窗口。6 o) x7 f( `9 H, u
  1003. #==============================================================================# S) I. \; h* V) w9 G% J+ ]
  1004. class Window_ActorCommand  Window_Command
    ; }% r- b) n- ^- {6 `
  1005.   #--------------------------------------------------------------------------2 s' n2 x" ]+ n# u
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ! M5 `. n% n! a8 K( h9 l- w
  1007.   #--------------------------------------------------------------------------5 R& G/ K7 q) n4 p
  1008.   def set_mouse_pos3 E+ U& C  N$ X- V
  1009.     if viewport.nil
    & ^! R0 U2 M7 a0 D1 Q& d. F) x& A2 ~
  1010.       vp_x, vp_y = 0, 0
    * j7 }" x. |9 H: t
  1011.     else; _5 c% `( j$ N8 _0 w' Z: @
  1012.       #vp_x = viewport.rect.x - viewport.ox
    ( \/ B- c2 g5 P& \& {2 w
  1013.       vp_y = viewport.rect.y - viewport.oy9 M& r) x4 r! J
  1014.     end
    ; @1 c0 F* h0 N/ E) j
  1015.     item_x1 = Graphics.width - width + standard_padding
    - z  P( j  t% L
  1016.     item_y1 = vp_y + y + standard_padding
    $ H! u. ?% a% A- J
  1017.     get_index = @index  0  0  @index % K+ }& |1 h1 d1 x; `2 m
  1018.     row = get_index  col_max - top_row. F8 C5 K2 [7 o9 l: r
  1019.     col = get_index % col_max
    0 S# `* E! A: t9 c# E5 H! J+ |
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    ' ]7 {: A; Z3 w- \
  1021.     new_y = item_y1 + item_height  (row + 0.5). A( J" ?) m1 u( y# P
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    4 x5 B/ S8 K" V& a' g5 `/ a
  1023.   end* ?" E0 f1 }, @' m# c7 S
  1024. end
    2 K2 U4 o) O9 ?

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

  2145. % K3 D) l- Z$ O% |
  2146. #==============================================================================
    ' Y* a, f, y1 u: O. [3 W% G* v1 s- T
  2147. # ■ Game_Map2 W9 O6 @  y$ U1 _( y
  2148. #------------------------------------------------------------------------------# |& B3 c; m( o; u. D3 E8 d
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。: a3 d/ {1 @3 u& @$ }: W0 u
  2150. #   本类的实例请参考 $game_map 。
    ! T1 P& E. y# T, h; p# Q
  2151. #==============================================================================. {; \, K4 m( y) c, i
  2152. class Game_Map
    1 z) t, N* a4 \/ O5 s: D8 E
  2153.   #--------------------------------------------------------------------------. v) U, \. C  A2 V6 N  c+ }1 ]
  2154.   # ● 定义实例变量5 h: V5 u' a& T2 O! G
  2155.   #--------------------------------------------------------------------------
    7 V) _/ S4 i3 D# P
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
    7 f; X/ f7 H- q0 G/ g7 C
  2157.   attr_reader mouse_map_y # 同上
    4 c1 a, r2 W, X# W, ]
  2158.   #--------------------------------------------------------------------------
    5 d) T, A' B; C8 A% @: ^, q3 _
  2159.   # ● 初始化对象% J7 b, Y8 Z7 P
  2160.   #--------------------------------------------------------------------------
    ; |1 Y! {' N6 |
  2161.   alias sion_mouse_initialize initialize
    % `5 B! R+ A! n
  2162.   def initialize
    : p( D, t) k" \4 ^
  2163.     sion_mouse_initialize
    , e1 C. j9 U# T' P3 A, C$ A  x
  2164.     creat_move_sign  #### W! L+ g4 X' X6 }- f$ N
  2165.     set_constants
    ' v% N+ ^  F3 `- k
  2166.   end& R) y" }% @- b& K
  2167.   #--------------------------------------------------------------------------+ R" `4 o3 `5 H/ F) @. P8 h. W
  2168.   # ● 更新画面
    ! T( t$ h! r/ S% z9 ]& v- `8 {
  2169.   #     main  事件解释器更新的标志
    2 ~1 D9 \/ ~; [% \6 x  Z
  2170.   #--------------------------------------------------------------------------2 u6 |1 h% Z( }+ m
  2171.   alias sion_mouse_update update  L: ^' {' U! x: j- d
  2172.   def update(main = false)# a  f% k! `& i7 K9 D. O- O
  2173.     sion_mouse_update(main)% o' b& L1 a& X; t6 z2 ^/ ~
  2174.     update_move_sign
    " \' Y9 i, O" M, v; L
  2175.   end
    7 j! I$ R  V! l0 M3 k. i* s
  2176.   #--------------------------------------------------------------------------1 C$ `; d' k9 f8 M! e3 @/ R
  2177.   # ● 创建显示路径点的事件4 `, t  A8 |  A6 B3 p
  2178.   #--------------------------------------------------------------------------* B; s# F" O+ z6 ~; Z& y% {7 S
  2179.   def creat_move_sign
    ) J: f0 e2 A* }) N- t: K" |; ~1 _
  2180.     $mouse_move_sign = Move_Sign.new& q$ T' M+ x0 D' }3 _  v
  2181.   end( E* t7 }( z: E7 d5 G; Z* T
  2182.   #--------------------------------------------------------------------------
    ! d' q& A4 x+ _1 ^" ~
  2183.   # ● 更新显示路径点的事件
    0 q1 E# x$ u. X8 G7 ?  p# Y+ r9 o
  2184.   #--------------------------------------------------------------------------
    * f% O& o  S, H  O( X# H' Z+ ]# [
  2185.   def set_constants# V5 C7 @, ^5 N
  2186.     @mouse_pos_setted = true
    0 j. V$ r, {, n+ Y. X& G% o
  2187.     @set_pos_prepared = false
    0 s$ n% s' ^; R& H, Y; k" R4 Q- v
  2188.     @mouse_old_x = 0; G: j' k9 p2 Y
  2189.     @mouse_old_y = 0
    8 ~$ w$ M. m/ {) o0 O
  2190.   end+ L2 T/ q2 u6 V% Z; a
  2191.   #--------------------------------------------------------------------------
    ' X8 k" G) f: v" i3 q7 E
  2192.   # ● 更新显示路径点的事件
    ! ~) Z. F  E9 I& A* y0 ~3 _
  2193.   #--------------------------------------------------------------------------$ i/ o" p8 l8 p9 O6 l+ _
  2194.   def update_move_sign0 F( \. i; s/ q1 c( A  D
  2195.     $mouse_move_sign.update
      B! C9 p, Q5 G- {# h" v7 @
  2196.   end
    ; M$ Y# o' T1 t9 P- I
  2197.   #--------------------------------------------------------------------------
    3 G) E# O6 F: D. `( _" @! j0 |
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    : i: d/ _; ^7 h' ?$ D/ o
  2199.   #--------------------------------------------------------------------------: c' Y+ \7 Q/ ^6 E8 F2 T9 y6 T
  2200.   def get_mouse_map_xy* ]- h8 {3 Z1 {  ^! t4 P4 @: h
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y& u/ t* c1 v( K
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    ) o+ M$ r5 G: L# z% a
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    9 P. J9 ~- Y) L6 X( N1 h
  2204.   end7 B- @3 ^3 d; j% g& n
  2205.   #--------------------------------------------------------------------------) h0 m9 P& L+ h3 u! ~0 ^$ x9 ?) m
  2206.   # ● 返回地图画面时重设鼠标坐标
    ) E5 U# g( d9 \6 ^  _+ H
  2207.   #--------------------------------------------------------------------------
    3 ]3 q8 B- B; l5 K
  2208.   def reset_mouse_pos6 V& ]2 ?) P  c# |& x* u1 N
  2209.     return if @mouse_pos_setted2 Z2 b" ^7 g$ D; E+ I9 r' Q7 q
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
    . o& D' d8 z  Y' L3 S5 l
  2211.     @mouse_pos_setted = true
    , r) [8 Q1 i% ?( c0 @  o
  2212.     @set_pos_prepared = false, ^  S( B$ a9 {
  2213.   end
    7 l, T9 D0 ]# O( ^; J
  2214.   #--------------------------------------------------------------------------$ x$ ^) R& c# b' ?' Z
  2215.   # ● 重设鼠标的坐标
    3 J! T2 X7 A* H. {# O
  2216.   #--------------------------------------------------------------------------$ F4 a0 D( P8 w& Y; n
  2217.   def prepare_reset_mouse_pos
    $ t4 `+ l9 h$ c
  2218.     return if @set_pos_prepared5 Y! ~! ?5 t! e2 b
  2219.     @mouse_pos_setted = false/ H' a2 z) o  d
  2220.     @mouse_old_x = Mouse.mouse_x3 m. M: s; L$ v
  2221.     @mouse_old_y = Mouse.mouse_y
    ' R* ]) F/ a+ W) Q6 K9 ?- i5 n
  2222.     @set_pos_prepared = true: j  G. ?4 x% p. M
  2223.   end
    # l* `8 S7 y3 ^: {% G9 p; E
  2224. end
    # m* ]' d2 h# k  i

  2225.   j& L' Z0 C/ Y" Q4 a/ ?
  2226. #==============================================================================0 r% B/ S0 ~8 q" x
  2227. # ■ Spriteset_Map' q# ^. d  f1 r/ F7 V  S
  2228. #------------------------------------------------------------------------------
    7 m; f' \5 W; H# b  c
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    3 W8 d9 B7 X* V/ G
  2230. #==============================================================================
    5 ~" h$ R* o" C0 D9 o
  2231. class Spriteset_Map, m& f- l+ E( \# F3 A/ y
  2232.   #--------------------------------------------------------------------------
    : [& B3 d; N( H# |
  2233.   # ● 生成路径点精灵" u- [  b( S" m  X, S" |
  2234.   #--------------------------------------------------------------------------
    * D; T9 r8 ~+ N. t- H
  2235.   alias sion_mouse_create_characters create_characters& P1 [( K2 ?) o
  2236.   def create_characters
    1 h, Z% t. V9 w$ T
  2237.     sion_mouse_create_characters
      q/ H- r; o' o" w* T. F' U
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    6 `+ {# y, p+ i! ^1 g
  2239.   end
    : u5 B8 b+ X# c8 z: H
  2240. end
    $ t( Z& U, ^& L- l3 ?1 p
  2241. 9 i  W! O" Y1 C2 C& ^
  2242. #==============================================================================. M' T7 W' R. h' j
  2243. # ■ Scene_Map1 ^* ~. G) F% w4 |" [  }
  2244. #------------------------------------------------------------------------------2 [. \4 ^) U8 M
  2245. #  地图画面, g" V# I& W0 i4 I5 K0 l, c# o! Z/ A
  2246. #==============================================================================6 P+ f8 u  U% w  q1 |, T" c4 K
  2247. class Scene_Map  Scene_Base; z0 c0 Z$ c$ P* C- {, k! w
  2248.   #--------------------------------------------------------------------------
    4 {! {0 p4 R% e& Q0 Q; F
  2249.   # ● 画面更新
    . i% ]# I! e/ }  L$ X
  2250.   #--------------------------------------------------------------------------
    % `( o( K: x9 R
  2251.   alias sion_mouse_update_scene update_scene$ U9 ^+ w& e5 l9 w# }) f9 U) l
  2252.   def update_scene
    ( b/ U$ B+ x7 U) J# w
  2253.     sion_mouse_update_scene
    7 w6 ~& y  Z% d" J; F2 r8 Z
  2254.     update_mouse_action unless scene_changing& T7 p& P7 Y  k% r
  2255.   end
    ' K  u# d3 [& L' Q/ p! l
  2256.   #--------------------------------------------------------------------------) m% _' z9 x9 O: C  n3 H' Q. m
  2257.   # ● 场所移动前的处理4 h; K- f% e1 ^6 h
  2258.   #--------------------------------------------------------------------------5 }9 j  v- b( {* M7 G& A! {
  2259.   alias sion_mouse_pre_transfer pre_transfer) W! n2 Z. A. K) y4 j8 u) q# a
  2260.   def pre_transfer5 u/ Y  I6 r/ J6 r
  2261.     $game_player.reset_move_path( ~7 n9 ]$ Q( q& E7 V: [1 A
  2262.     sion_mouse_pre_transfer
    6 `0 F$ R+ o; J' ?  P$ n" Z) n
  2263.   end: S; Y8 B* G, p3 z: u
  2264.   #--------------------------------------------------------------------------
    0 R5 E1 P1 p( w+ Y; P# u$ V
  2265.   # ● 监听鼠标左键的按下
    + Y$ d; f0 u3 R0 x) a
  2266.   #--------------------------------------------------------------------------
    4 q/ i; L  j2 x, j$ v  f) y
  2267.   def update_mouse_action0 g! r% [$ }, b2 [% j
  2268.     $game_player.left_button_action if Mouse.press(0x01), ^6 O. S- @( _1 ~, \9 U
  2269.   end" @" A9 P8 p, |( ~# C) y
  2270. end
      C" m. _' g6 |5 Z  e

  2271. " l+ J2 ^$ s# u; r. L
  2272. #==============================================================================
    " |+ b3 J7 I4 o/ C
  2273. # ■ Scene_File
    9 o. @* t6 K8 D; P2 C9 ^! j- j0 e
  2274. #------------------------------------------------------------------------------/ m0 h" v- U, `, c" h
  2275. #  存档画面和读档画面共同的父类5 P$ [5 @) t6 Z8 `8 g
  2276. #==============================================================================/ s- c4 @! B9 m
  2277. class Scene_File  Scene_MenuBase6 }6 ~$ R/ g9 p$ C
  2278.   #--------------------------------------------------------------------------; k3 ~! T/ T  g9 Z, `
  2279.   # ● 开始处理4 `6 T  M6 B# W1 ~$ z+ n1 ]7 N
  2280.   #--------------------------------------------------------------------------
    . d! t) n' C' _. q' L
  2281.   alias sion_mouse_start start: f  T8 X; `. y
  2282.   def start
    $ r2 Q* w3 e, Z% [5 J1 w# N4 p7 F7 G8 @
  2283.     sion_mouse_start
    - l2 y, u: W+ t' q% y/ h
  2284.     @move_state = 04 S- Z" G) \! M$ N% |
  2285.     set_mouse_pos
    7 o* W0 A5 d* A& E% J1 Y' d% g
  2286.   end
    0 v; B$ @' e0 p( B& U
  2287.   #--------------------------------------------------------------------------2 A5 Z$ M! D1 \" C% S, x+ Y+ P
  2288.   # ● 更新画面, b2 j7 U6 {: ]4 i3 d, S
  2289.   #--------------------------------------------------------------------------
    2 n# w6 x5 R3 n9 h! K* R/ I
  2290.   alias sion_mouse_update update
    ; b1 ~: y# ~4 ?+ W
  2291.   def update
    % r2 D% {! c- R. d% y" f% Z$ N
  2292.     sion_mouse_update
    / `/ L. J2 X! ^8 `3 p
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos. Q* E: ?: ~. G% I8 L0 z  v5 N8 v, }- v) k
  2294.   end6 K( \$ x0 @  `* C5 j
  2295.   #--------------------------------------------------------------------------
    6 ]7 s& M* V+ g3 J
  2296.   # ● 更新光标
    , r; o/ s, f9 L1 g: {+ c; t  T+ O
  2297.   #--------------------------------------------------------------------------  j( N: I) r  n8 ?( _" Y1 ]# T
  2298.   def set_cursor
    ' {3 h) q8 o! C" w) @$ V! Z
  2299.     @move_state += 1
    3 |" b) t+ z% H9 L" g
  2300.     last_index = @index1 C1 d1 R+ F+ b/ T( L
  2301.     if mouse_which_window == -2
    # _7 v' D6 X( I! l+ S, Y8 Y
  2302.       if (@move_state - 1) % 6 == 0! ~. \8 e8 t, A+ S* F
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    - m7 O$ h/ T. h' f) _4 H
  2304.       end
    ( V: G" G9 h/ z: n3 g- {8 f
  2305.     elsif mouse_which_window == -1
    6 `! t8 i" T; u% F
  2306.       if (@move_state - 1) % 6 == 0
    * V# {2 P3 \3 G. t+ G: a" u
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0' |+ u( C4 v$ D
  2308.       end
    8 w* I( B, P* @0 A6 ]( o( r
  2309.     else5 @" I6 p! m* Z+ v, p5 T) W7 _
  2310.       @move_state = 0
    # r  ~$ h/ m' Y. L+ ?
  2311.       @index = top_index + mouse_which_window5 v/ R4 b/ U+ }( C
  2312.     end2 s; T# h( h( Z. [
  2313.     ensure_cursor_visible
    : H2 o; ~/ W: ]8 t
  2314.     if @index != last_index
    7 }7 y4 o: f# U% h
  2315.       @savefile_windows[last_index].selected = false
    . \/ T( {. T( n  P: D' B- k! t
  2316.       @savefile_windows[@index].selected = true
    * j/ ~$ g* ?1 R; P; \- U
  2317.     end% X6 R! Z6 \6 n" W$ A% {/ ?
  2318.   end$ c( _$ h  @, K# M/ l* X
  2319.   #--------------------------------------------------------------------------
    & ]% O" A1 V0 F* q* Q" P0 Q
  2320.   # ● 判断鼠标位于哪个窗口+ N% `* {; z4 F% [1 m
  2321.   #--------------------------------------------------------------------------  s" U+ m( }' f* H/ q$ D6 x
  2322.   def mouse_which_window
    2 i& @' D/ z' ^2 M2 p
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y5 C2 ]7 V4 L) [; x0 n! m" T& j
  2324.     if mouse_y  @help_window.height + 14
      E. @( A2 G4 I! U) A2 x/ ~, X! R
  2325.       mouse_row = -1: g* R8 l& h" D
  2326.     elsif mouse_y  Graphics.height - 149 h* H" ^9 s6 N$ x1 V0 s6 i* e
  2327.       mouse_row = -2. Z: D* ^) y0 ~
  2328.     else# c# Q' T- N3 X! t* m4 L7 x3 {
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    ' H- Z4 b! f& F) m. a
  2330.         (Graphics.height - @help_window.height)
    ' o4 S7 W% }/ K
  2331.     end3 K* ]6 d. {1 }
  2332.     return mouse_row" x3 }  F: L) d
  2333.   end7 F$ H3 g/ @; {
  2334.   #--------------------------------------------------------------------------
    : C5 j  |9 Z; l: a
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置' i, o' i# D% |* W6 r
  2336.   #--------------------------------------------------------------------------4 A# y* A! r( R2 b
  2337.   def set_mouse_pos
    ; `# n2 F8 e- I+ F* N
  2338.     new_x = 40
    ! O( u6 B8 m0 g4 U6 X4 y6 u
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24: [5 k! W3 h4 }! A5 [, G, c
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    ; d9 V$ T+ M" u% r
  2341.   end2 L! m( v  B. E: G( a
  2342. end- O1 ?' q/ G: ]: N& \
  2343. * j7 ~; g1 [/ x  v: r
  2344. #==============================================================================: u" S! V, i( z# \! ?* |5 e$ o# l
  2345. # ■ Game_Event  T' y* K* E4 j! T7 Q$ C
  2346. #------------------------------------------------------------------------------+ G# L! u; `) E( }
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。2 A: ?6 Z0 H" P7 \
  2348. #   在 Game_Map 类的内部使用。
    * T0 @$ z. x7 z' v: h/ U
  2349. #==============================================================================
    ; Y- F" o& o; C; k' `
  2350. class Game_Event  Game_Character! }) o* Q9 y) p, \& \; q; H6 h
  2351.   #--------------------------------------------------------------------------% E# ]1 i0 V! E2 v6 u/ ]
  2352.   # ● 事件启动
    - m0 r0 I% L! d( b3 g. d
  2353.   #--------------------------------------------------------------------------0 f, t8 H! H+ j% |6 h
  2354.   alias sion_mouse_start start
    / p7 x& m1 ]4 F" Y" s! w
  2355.   def start
    8 N! k0 w" w0 O! }) c
  2356.     return if mouse_start && !Mouse.press(0x01)1 p2 j% T& K: V( w' T0 S6 R
  2357.     sion_mouse_start
    % ]. U* L! Y- S) J" w
  2358.   end
    ( @, s* o1 U1 O2 {
  2359.   #--------------------------------------------------------------------------% l- |- e  y% R+ Q7 u
  2360.   # ● 判断事件是否由鼠标启动
    5 Z* M, n& i/ x/ U& T; f  j9 J2 D' M7 G
  2361.   #--------------------------------------------------------------------------
    # q$ q" m5 G& @( X
  2362.   def mouse_start
    / M/ J4 \/ S) n8 M% ]9 C2 R
  2363.     return false if empty
    $ X% y, O! J; {2 n
  2364.     @list.each do index
    1 B: q: h) |& l
  2365.       return true if (index.code == 108  index.code == 408) &&' X" q) }, r; E. m) Y
  2366.         index.parameters[0].include('鼠标启动')3 r0 w0 |( w4 P
  2367.     end: N& R9 g# B  P* u. E4 b
  2368.     return false
    4 L. g6 V7 g, V# o$ V0 ]
  2369.   end; H! M+ o+ _, X1 ]+ a0 C
  2370. end( b/ O/ L( o1 h& D

  2371. , ]+ N  d( G2 z
  2372. ####泥煤的height- U2 z) B7 e" T* c2 b" H% M* J
  2373. # @height = height! u9 O7 h  C  _* W2 r, q) i

  2374. 7 c( ?. X4 g! r0 K* z9 S
  2375. class Area_Response+ J6 s( f( w+ R7 ~+ n
  2376.   attr_accessor type
    9 w3 ~9 G$ n* x: u2 T: L! p
  2377.   attr_reader ox
    * N) M2 t9 q, A: j" V! j4 X
  2378.   attr_reader oy% }! T; a/ j% g
  2379.   attr_reader width% i* g$ l$ L; G+ [' e, y7 ^
  2380.   attr_reader height
    % W; m7 A! M4 v% d
  2381.   attr_reader switch_id
    , E9 F( J, w% o2 P" P7 A6 Z- P  N
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    ( ]: p7 Y' ~7 F9 [
  2383.     @type = type
    3 |. s- d6 o+ R
  2384.     @ox = ox1 b" }4 |; j  N/ p5 g
  2385.     @oy = oy! ^7 G3 y+ E" M( V2 C! n
  2386.     @width = width/ T; i9 \: W) j' x5 z
  2387.     @height = height
    + Y" P7 U: e$ i. E, m/ T
  2388.     @switch_id = switch_id4 ~1 ]# c: ?* `" o
  2389.   end8 U! {9 C5 j) S# b- I* l
  2390. end  o& M7 p6 W& a5 N5 G  k" |
  2391. ( G9 o( `( o. d6 m2 i
  2392. $area_responses = []0 c% W- n6 u1 c# h
  2393. 9 s& Q5 M- g3 ?7 o! A
  2394. class Scene_Map$ m; H/ z/ ?( W) m! A' _" B
  2395.   alias update_mouse_2013421 update_mouse_action& I# i9 B1 C, x0 m6 Y( I6 N
  2396.   def update_mouse_action. `" y( F+ ]  L/ j
  2397.     update_area_response
      P+ O% O6 p4 A- N, r; G. V& g
  2398.     update_mouse_2013421+ U2 u1 Y2 U  Q' s$ Y, R$ E
  2399.   end: I4 R7 f, f- T8 T% P! X4 S2 W, s: F
  2400.   def update_area_response' @2 `4 ~, Z  N  n: B5 v  U, w, I
  2401.     responses = $area_responses3 I8 a4 {; F, Y
  2402.     responses.each {response% m% z& @2 u* u- }- J- E: }
  2403.       ox = response.ox3 y) g0 \* c! K; Z4 Q4 M% Y+ r* V5 G
  2404.       oy = response.oy
    7 ]/ I6 ^( A& l$ A9 v
  2405.       width = response.width8 F! I7 L# ^' S: L$ M! B$ L
  2406.       height = response.height
    ( a' x( e7 s5 z: w/ @' [) U5 D
  2407.       switch_id = response.switch_id
    ( W; d  E- _, H  ~' B. M9 n1 y
  2408.       case response.type9 K9 N1 V  g* K& b# l! _: B
  2409.       when 0
    $ N& u8 D* r& A! x
  2410.         if mouse_in_area(ox, oy, width, height): G; w' `! h8 B) D! y
  2411.           $game_switches[switch_id] = true
    9 M& C/ z1 g# {8 z% ?
  2412.           $area_responses.delete(response)1 Q' F2 ~9 X% ]9 O0 L- M5 G
  2413.         end
    / {" ^, i" |6 L% E. m+ D1 Q
  2414.       when 1# ^- {; n  o$ W3 I4 g- Q. h/ A
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)" O, T/ f2 X: t8 I6 v
  2416.           $game_switches[switch_id] = true& e7 {( n3 f6 `, w4 h. R9 \
  2417.           $area_responses.delete(response)
    3 Q6 o. Q4 f, ~
  2418.         end
    0 O/ p2 f; S3 ^' x( a2 H' c
  2419.       when 2( k! [" c  u9 h, i
  2420.         if mouse_in_area(ox, oy, width, height)& G3 K+ o# ?, v8 q5 I" |
  2421.           $game_switches[switch_id] = true( Q+ r- Z8 k* V% ~
  2422.         else, J- b* @+ j  W7 Q5 ]5 [
  2423.           $game_switches[switch_id] = false  v* U; s; m. B1 M
  2424.         end
    5 P# X0 A5 D" x8 o' ~
  2425.       when 3
    / n! V0 F. r" a
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,$ T/ A$ Z; l) M0 n8 m- m$ _+ k& e
  2427.             (oy - $game_map.display_y)  32, width, height)
    5 ~0 B* w6 O) Z. N, Z  m  [/ T* M6 U8 L
  2428.           $game_map.events_xy(ox, oy).each {event: n/ }4 j; ^5 c
  2429.           event.start9 P) R% x; b& w! D8 M3 ~2 b
  2430.           $area_responses.delete(response)
    . z+ P6 S/ G9 Q( o" N
  2431.           return* ]$ s, m$ _7 f$ B& {0 P* l  ?% H
  2432.           } 7 Q. \3 I& J7 j" Q" Y" F+ j: n* V' X
  2433.         end
    : {) R6 u$ d. J, h
  2434.       when 49 C3 B- w- V* J) a
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,9 O* R4 z9 C" U( F0 p
  2436.             (oy - $game_map.display_y)  32, width, height)
    * i( P6 F/ c. [, ^* y3 r& J: W
  2437.           $game_map.events_xy(ox, oy).each {event
    ; L) _  V. \: z& q
  2438.             event.start
    ' i0 D# W5 t. c( o; q
  2439.             return+ D9 N& r9 U1 l6 o& A4 y* {
  2440.           }
    6 Z& U- Z+ O. v3 O+ s
  2441.         end3 Q) C: ]/ M# _+ D8 N3 y
  2442.       end0 z/ v# T- ^8 Q! L
  2443.     }
    ' O  N8 C; R, c0 Y" {- c2 z7 l- T; N( M
  2444.   end$ S# Z3 Y% ?7 F  @1 E6 \
  2445.   def mouse_in_area(ox, oy, width, height): {$ n: I- a  v  \1 Q
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    0 P* E# q( o$ C" j
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    . k! O" b: }2 G' J' m# t4 ^
  2448.   end
    : D+ z+ D6 ~3 A$ E: n/ N
  2449. end
    1 j2 y3 U2 w' f0 t% d8 ~0 I
  2450. class Game_Interpreter6 N8 w2 I8 \6 C: a  X
  2451.   def area_response(arg)
      G" ~& b9 s8 q! q! A! L2 ~; h
  2452.     $area_responses.push(Area_Response.new(arg))
    5 U  T6 S- S/ D, @/ [" R
  2453.   end/ t0 I8 H  ]$ q& m9 x
  2454. end& D7 W5 H' c* x0 ~: T  G
复制代码

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2026-6-7 20:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表