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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================$ A# E7 r; u& N& S1 O2 @. ]3 U

  2. : @! H" U2 u2 b5 T0 q, i* x
  3.   Sion Mouse System v1.3e3 r6 D8 w1 ?7 \: Z3 H2 m
  4.   1 c9 X+ J# F. H
  5.   Changlog: j* c2 i- J. M3 L  [) I! i
  6.   / B7 I- F# z3 ]7 M/ Z
  7.   2013.4.21 v1.3f) E8 x! f2 V; ?# n% ]
  8.     / z/ u( e9 P) W" {! |% f8 Z7 R
  9.     1.3f 卷动地图 bug 修正5 P8 }; V( o) f' H
  10.     ; H' j, L. i) i. M8 Q4 C
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
      ?  K0 Z+ {8 d* `. m- K
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    6 V  U2 A1 I, |  ~3 Y4 x7 f
  13.                               Mouse.unlock_mouse_in_screen 解除锁定9 D, t  K) {5 H  y, }; H/ C9 |
  14. & }  E. w* Q6 ?# r
  15.     1.3f bug修正
    6 B. w1 F9 O9 B- m9 u5 A4 H
  16.   ) s: [: f. y( L3 {4 ~0 G, s
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    - S" A/ k" O& ?8 V+ v8 k
  18.           关闭菜单时,鼠标是否移动到原来的位置。* [& y2 |6 C; y
  19. 5 w- T+ Y& i' _8 _1 z+ _6 g
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    ' G' c$ Z" w, D1 X* `0 V/ W) L% g; l
  21. . _4 {" C) ]" K$ g! L! L
  22.     1.3b 修正一些罕见的bug;
    ; R1 \9 i# c' i! E

  23. % w" y, x2 |# y8 }* R
  24.     1.3a 代码小修改;
    - w) K9 @0 X$ _4 @' A( q; L
  25.           加入了鼠标点击启动事件的功能,
    5 G5 I, J% r$ \- u$ u
  26.           在事件中加入“注释”: 鼠标启动  ,5 k5 K' m5 a* h. E2 z1 d5 o
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    9 Q2 t+ o* n4 U6 w' ]
  28.   
    8 I! j% q2 F; I/ o' f! ?# I
  29.   2013.2.12 v1.2) Z" @" X1 ^6 j) m- X
  30. / m. @( j9 x0 S: I
  31.     寻路逻辑优化;
    2 e' L# N8 D; V% ^! T3 k8 e' n7 m" u
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;, p( ?: j9 j8 x1 {& L" b- a
  33.     现在支持用鼠标来操作载具了。
    ( W' u+ `/ H/ x* ?& d
  34. # q4 Z8 M9 D6 N9 Y) u; j7 N
  35.   2013.2.8 v1.13 h8 u! x( K: U6 r3 f

  36. . q! x6 a# U+ o& B) J
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    8 W5 S2 D5 d( p9 f% `, h
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    ! u7 M) B! v+ O6 E2 d$ P* B
  39.     移动时,路径指示点的绘制更加稳定;
    : s+ `8 k8 v; ?
  40.     现在支持默认存档画面的鼠标操作了。" y2 D5 E# J; r9 o* H
  41. 7 a( a. P6 G4 N- I2 e+ R- X

  42. ; f, q, I1 t4 C9 ^
  43.   OrigenVersion
    . t8 o+ ?' c8 d
  44.   * G% t) Y# Q, ?" Q$ m/ q
  45.     2013.2.7 v1.0 2 F0 q4 c/ a; i) g7 a) z. z- {; k
  46. # ^% ~" u! S, F7 p; R# Q0 j. Q
  47.   主要功能
    : [' {+ l1 b' a2 H+ G" s/ q

  48. 4 o2 T! a& }$ W$ W( j# r
  49.       使用鼠标进行各种操作...2 T3 l/ }) {5 k! ~9 H$ {' J1 T
  50.       将鼠标锁定在游戏窗口内: F( w2 ^# Y: S3 @. t5 T
  51.       自动寻路,按住 D 键可以扩大寻路的范围0 H7 V5 d/ d5 W! [' S3 g" Y( t
  52.       双击鼠标进行冲刺6 p+ j5 p4 I0 h
  53.       更改地图卷动方式以适应鼠标移动
    : j3 x0 b+ v% q
  54.       变量输入框改良& D) i& K& u6 `6 J7 A
  55. # M. j6 O+ |* L, O' v/ I, o  q" t* ]
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    9 P" L8 q, q: m0 b' W

  57. " K) `6 Q2 ?0 j, R3 n6 h
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    # G, e& |% z2 t: |  y; q$ `

  59. % H- c( j* W9 a; ^9 n. @
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭6 n- S. _3 ]1 Y9 a
  61. $ ~  ]6 ~. H3 h" r
  62.   ^* ^; A! w- J( Q- g
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★! d- h0 v0 O2 N, O/ f. F0 X+ ]

  64. & r& Q; S* S" Q5 P, x

  65. ! ]) x3 n* l/ J8 h3 M0 m- r7 i
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    5 _. @1 L0 e0 y- g

  67. . c4 Y! c1 d3 k7 v* |1 m9 C" }+ t
  68. #==============================================================================
    ! O, ]4 e7 r* [+ s) r/ R
  69. # ■ 常数设置
    ' _+ R, h/ V3 r$ g
  70. #==============================================================================
    . K$ @7 f6 }1 V$ P1 X! t; |
  71. module KsOfSion- z( v) p) a. M9 U7 x: M9 s
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    . f3 G* U3 B6 z& t) v9 t; q
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    1 w3 V" @  v4 ?2 I) W+ L5 q+ m) P
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false7 N, _0 D+ F4 D4 F  b" `. _- s
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    ( d8 L* o5 f- p2 v+ _
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处& F! y, n  s/ x
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    # i2 _' }1 `' g8 Q
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)- B1 o: {0 |- i2 G
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键+ Q/ H6 u5 _! b2 q+ K- G3 p1 ~2 L
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)9 Y! r; r% h* q1 y$ C2 i- b
  81. end+ |6 s! w1 l/ `9 ~6 W7 F6 u" _

  82. , n- ~  ]( n. V& l2 D9 H
  83. #==============================================================================. h6 n  o" S* i' d' D8 X
  84. # ■ 用来显示路径点的类
    9 ~5 r" k' b3 ~2 A( b7 P. q( V) A5 \
  85. #==============================================================================
    " t, ]6 @  S# I" A' ?) \9 F
  86. class Move_Sign  Game_Character% D0 a  x2 U, b. G3 k
  87.   #--------------------------------------------------------------------------
    ! |! B1 L. ~* i- x+ v$ i
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图$ |; A5 c7 l2 G- o
  89.   #--------------------------------------------------------------------------; _0 d% s1 f7 M! l* o& d0 x
  90.   def init_public_members3 `, T7 m( C9 q
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹* b2 A! Y* s. X+ `" [
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为02 y' ]6 \! z0 R( B( S5 I
  93.     @move_speed      = 5        # ★ 踏步速度7 Z1 ]; i3 q( k: ^4 R$ F; o5 T: q! r
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个), h. ^% Y$ ?- b* N' @
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度! R( Q& a! L3 v
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    " G' ]$ E% r0 i
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列1 X8 ^& q! F% Y
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    % b( j: T, F( R
  99. ; R$ ~# i. _# T, g# q6 @* F

  100. 9 D2 E1 a, ~  o/ P. M' l
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    3 m* E$ k0 S4 L& J8 k2 B! C

  102. * H2 P5 Y0 e. O! N! R4 j; m, W
  103. ) o$ ?3 E- L( B$ Z9 q
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图+ g2 X( G0 m& {6 ~* ?( G& Z  T" S( J
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    : {4 N' U: q' p% q" ]# z; }& o/ o
  106. 6 ^7 U+ {  Z+ h0 c  y0 R* S1 @- V
  107.       if $no_arrowpic_warn
    / r" }, S8 f6 v1 K9 k" D
  108.         MouseShow_Cursor.call(1)( W* W2 U/ J6 `) r- M0 g% P
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    ) {* y/ O1 z# s1 w' t% B% m

  110. 6 f; X+ R  P% j$ A; H
  111. “路径指示点”将使用游戏自带图片
    5 F! ^7 P) U* [! |
  112. 2 e9 [5 x% @) Z% G1 C( u
  113. 该提示可以在脚本内关闭')
    % `/ A. y2 J; R; u5 w- L6 r
  114.         MouseShow_Cursor.call(0), M* N. A1 t- I
  115.         $no_arrowpic_warn = false) D8 G$ G  ?: x% ?4 J
  116.       end  X: D! w( p1 I
  117.       @character_name  = '!Flame'5 g( U3 O1 y( ?: T
  118.       @character_index = 6
    0 s1 V& I/ C0 f) T% `
  119. , M/ I, j  q9 y# a# O6 @4 Z2 @8 H. W+ Y$ X
  120.     end
    ( y# @) R6 `& t3 e
  121.     @direction_fix = false  # 固定朝向5 f0 `8 D/ V; b" J1 q* O
  122.     @move_frequency = 6     # 移动频率. U& O& R5 P$ K, [( [* H5 p1 R6 b
  123.     @walk_anime = true      # 步行动画
    " I' J& _6 S) ~& ^$ _; H: ?( O
  124.     @pattern = 1            # 图案" i% a  _9 Q0 y7 z
  125.     @through = true         # 穿透1 A2 A$ N7 J- u6 [- L
  126.     @bush_depth = 0         # 草木深度- s0 P8 y& e* S
  127.     @animation_id = 0       # 动画 ID, e9 l* N) O4 W( M1 c0 I
  128.     @balloon_id = 0         # 心情 ID
    0 ~6 P  A  H* t
  129.     @transparent = true     # 透明
    7 @( F: A4 \! J+ U1 n5 K' [* o% n8 P+ _1 i
  130.     @id = 02 _) V/ ~4 Y4 n: }( l0 x- C1 f
  131.     @x = 0
    6 L6 l& e# l% q( }
  132.     @y = 0/ s  H% |7 L: S7 b9 |$ c9 a
  133.     @real_x = 0+ t" S7 r+ P) Q+ O
  134.     @real_y = 0
    2 P6 j, o  ^) k. e  ^
  135.     @tile_id = 0
    ( y3 c5 \" Y6 N- W
  136.   end
    1 ]5 l" ^. z' E, C( Y
  137.   #--------------------------------------------------------------------------1 h8 i* A, J" `/ j& T; i& W5 A' `
  138.   # ● 定义实例变量
    . G" N8 W& X+ H( D
  139.   #--------------------------------------------------------------------------
    0 e. ^" f* c2 L
  140.   attr_accessor direction
    5 P( H  F- ~5 i6 o9 S
  141. end2 A6 a, f, g/ J: [* Z4 _
  142. 1 d$ @  `8 x7 G& d! X* l
  143. #==============================================================================
    $ A! x% `; Z9 A5 W/ P8 C* o
  144. # ■ Module Mouse& [1 Z) x8 j( H! x. a
  145. #==============================================================================* [8 ]" U6 ^" M$ T' R
  146. module Mouse
    . s- E6 _% j; l$ O% d0 v- o
  147.   #--------------------------------------------------------------------------
    " O+ C# F4 u! A9 @! o) p( |* P7 {' Y
  148.   # ● API% Q9 i4 l  e) M  U4 b3 T  z( N
  149.   #--------------------------------------------------------------------------% ]1 T' @7 t/ y" A5 ?6 a. q
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')% ]  h' O) [( R7 x- @: H# N
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    - h; \( K0 z; E6 w; N
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')4 c* j( `: d& X/ c7 a7 k& V& d
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')" }. L6 i$ @, V
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l'), _4 v) b; w, a- B6 f, A
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')# w9 t2 \5 p9 J6 a" a
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')( d5 N- N: Q  ~$ t4 I) _
  157.   Window_Hwnd       = Get_Active_Window.call0 C* f* A- r  u* ^" i! q
  158. 1 r" V; z1 v* B$ @
  159. class  self
    3 K2 F3 R2 M. l6 w- |8 w3 ?$ C
  160.   #--------------------------------------------------------------------------0 |/ r8 R# B, l9 j. ?! w- b0 L3 T( k
  161.   # ● 初始化
    / q4 a4 o$ {1 r) W- j0 T
  162.   #--------------------------------------------------------------------------2 H. Q3 J3 `9 ?: Q( J
  163.   def init6 E7 k! f. K+ x! q# b- Z- R7 C
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    / T: ^. @6 Z3 J6 z% i7 p
  165.     @left_state = 0
    & F# U3 @/ i7 [3 k
  166.     @right_state = 0
    : D2 R3 N3 Z2 h3 ?* i5 c
  167.     @ck_count = 0 # 帧数计,单击以后从0开始, `. K  P# \; A
  168.     @dk_count = 0 # 用于双击的判定: \  r  _$ f4 W! d5 x* A
  169.     @clicked = false
    " U4 g6 g0 O% r7 n# o
  170.     creat_mouse_sprite+ F1 c) i7 ]- _9 `0 v7 n
  171.     update
    - M% s6 ^: x/ R1 T7 k' @) n
  172.   end
    ; [8 c5 m9 ?/ |
  173.   #--------------------------------------------------------------------------' z" R! l& x: U7 B, `" G$ l
  174.   # ● 鼠标指针精灵, G! r( U$ d+ o. l0 B
  175.   #--------------------------------------------------------------------------
    + c/ D8 p2 z& i" g3 d6 N
  176. #~   def creat_mouse_sprite- Q5 p- w$ P/ u1 }0 I) t
  177. #~     4 ^3 R/ ~/ M4 V
  178. #~       @mouse_sprite = Sprite.new
    : ~& k, r1 m% p, E$ m3 c
  179. #~       panda = 2#rand(2)+1
    6 a' K+ v' Y' {' M

  180. ! T& A% q; C5 o- L/ ?' J
  181. #~      if panda = 1+ g' x. C( K7 z
  182. #~        if File.exist('GraphicsSystemCursor2.png')8 N: e7 M3 m/ L5 H; |9 s" S
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')1 R0 B# C% R0 W9 i% v# A! p
  184. #~        end#with if File.exist
    9 m8 p- o) [* `2 m- y
  185. #~    8 Z6 Z" H: ]+ O
  186. #~     else if panda = 2 #with if panda=12 H0 R  X. x* E: ]
  187. #~      
    . |; R% d' W7 X2 [  z7 g
  188. #~      if File.exist('GraphicsSystemCursor2.png')& v# p$ A+ a5 I  f6 K. B2 W
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')7 W4 e  W4 D, @+ E6 G
  190. #~      end#with if File.exist
    ) ?' i% M" r: a8 u5 d
  191. #~      
    2 \: }' l* E8 g2 S" c
  192. #~     else #with if panda=1( t6 c; F( y- a) v0 N
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)  x) A6 M2 s, c( _
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),7 b/ X! H; n4 V/ S- e
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    * `4 U! a; b- k2 |! f! a
  196. #~     end#with if panda=1
    , Z+ T5 [' w% B% d; Z, K
  197. #~     * K! [' Q7 h' |* E( Y
  198. #~     #with def. W0 l: G! i8 o% L$ x' I
  199. #~   end- }/ x; [, l9 x6 V% F" K3 h4 Y
  200. def creat_mouse_sprite
    3 @3 w/ z* \6 A/ Z2 k# t/ r
  201.     @mouse_sprite = Sprite.new- L9 z& }& c4 a, h0 s- F
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    : d# Q/ C) W% E3 `* c
  203.     @mouse_sprite.z = 9999( O, m( v  J- Z. l  \
  204.     Show_Cursor.call(0)
    : Y  r0 l4 @: A+ f) k) E0 N
  205. end0 _. G4 l, S1 w7 f4 F9 M
  206. 1 l8 O* Y7 f( D
  207.   #--------------------------------------------------------------------------
    ; P$ [8 L+ n- J1 v# K( i3 Q1 f
  208.   # ● 更新
    4 f# ]% Z! u" K8 H4 P7 W
  209.   #--------------------------------------------------------------------------3 {3 j% c- `% q6 C6 j
  210.   def update
      n4 H# ?0 g/ G. l/ u
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos$ C, U0 F# i8 O! E& \. G8 h" f
  212.     left_state  = Get_Key_State.call(0x01)
    ( b9 u5 N2 Q3 {
  213.     left_state[7] == 1  @left_state +=1  @left_state = 06 J$ E$ ~9 q8 |1 a- x9 j
  214.     right_state = Get_Key_State.call(0x02)" X/ K6 l& S  t3 m8 x& e' j8 M& U" n/ ]
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    & a) v1 {% E% @3 }
  216.     update_double_click  t. q* P' t$ o. X! N: G
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1- O' O/ J& S' q0 D- M+ ]; B$ M
  218.   end
    $ u" ]; w: \. m& d$ c& G% C
  219.   #--------------------------------------------------------------------------
    * ~; U1 W- N( N5 a. P) k% D! \
  220.   # ● 获取鼠标坐标% Q0 u% p6 @" J# y  v
  221.   #--------------------------------------------------------------------------0 b0 ]/ r9 w! b, M& H
  222.   def get_mouse_pos
    * B1 Y, T' o% b6 ~9 h
  223.     arg = [0, 0].pack('ll')- r6 w" k9 Z, @' r; h
  224.     Get_Cursor_Pos.call(arg)* n1 [* K- U' ^$ ?' V
  225.     Screen_To_Client.call(Window_Hwnd, arg)/ i: Y. ~+ b2 p' T% N
  226.     x, y = arg.unpack('ll'). m1 R. o* a& ?# `6 p
  227.     return x, y( S: D  R- N* y3 Q' M2 h' L4 g
  228.   end  C) A5 ^" _( x; W
  229.   #--------------------------------------------------------------------------0 t& Y2 q! G, t
  230.   # ● 将鼠标固定在屏幕内
    ) y% w7 G' n3 k: n# }# R
  231.   #--------------------------------------------------------------------------
    4 [) m0 ?2 J8 g' n1 j
  232.   def lock_mouse_in_screen' E/ t7 X( Y9 H" u. ]! ?' b
  233.     arg = [0, 0].pack('ll')# d6 Y. g8 a, E% m) ~' j; G
  234.     Screen_To_Client.call(Window_Hwnd, arg)$ l% U5 o/ R5 }+ m
  235.     x, y  = arg.unpack('ll'); I( K0 Z- \/ r6 o$ u& b, X; S
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))2 G& k9 I+ B! i# h/ Q! k
  237.   end1 z9 E* ]+ P7 V
  238.   #--------------------------------------------------------------------------
    , f  |, [  @+ O. e$ T
  239.   # ● 解除鼠标固定6 p0 {  o/ R- D& B8 [: F
  240.   #--------------------------------------------------------------------------
    - Y8 Y9 L# z7 ]% q- a* k
  241.   def unlock_mouse_in_screen
    2 n0 e" y! c4 l& e  H) I4 a! R+ f( J
  242.     Clip_Cursor.call(0)
    9 w# t' ?- O% @' D! u
  243.   end
    2 m; z2 `* u+ q# q6 E* c! m
  244.   #--------------------------------------------------------------------------
    2 d& c# q1 @& X/ u
  245.   # ● 鼠标双击判定
    " v5 C% `4 Y) T& ~# K
  246.   #--------------------------------------------------------------------------
      m7 Y# v, }; ?0 ^/ f- Z, _
  247.   def update_double_click
    - x, w& L! L& o& }4 E, X+ G
  248.     @clicked = true if @left_state == 1
    ; f0 a0 Z) O7 [# j# g8 N. }
  249.     if @dk_count  0 && @left_state == 1& K# H+ p6 Y, Z! ^8 m* A
  250.       @dk_count = 0; @clicked = false
    / J" S- k! [& P7 {
  251.       return @double_click = true4 e6 O- q+ N/ d! }8 z
  252.     elsif @clicked
    $ L0 E7 B! v! N8 G/ \6 M- j; f
  253.       if @dk_count  KsOfSionDbclick_Frame  v0 z* [9 H1 A' b7 }
  254.         @dk_count += 11 _( [  l0 Y% S- N" @! H
  255.       else
    / a: c* M* o# w3 c; g2 m/ R
  256.         @dk_count = 0; @clicked = false3 i6 r0 ?+ @& J, f' S7 R
  257.       end7 n5 Z" V( W) @$ P
  258.     end
    ! u9 }& _: ?" }5 G/ P! B& o# T' t( l2 Q
  259.     @double_click = false7 W; c0 |/ F" S4 b2 m4 i
  260.   end
    % J5 B7 X- q( H8 y! [3 q: o! b
  261.   #--------------------------------------------------------------------------+ X0 i# C! h) N2 c
  262.   # ● 按键被按下就返回true- x# S( E$ z0 G$ _
  263.   #--------------------------------------------------------------------------/ U7 w+ B. n1 C: \& N
  264.   def press(button)
      g! F; B6 k# s, `) M( ?$ x# n: d* o- W0 N
  265.     case button/ k% V% a9 P& d& u0 r# \2 r
  266.       when 0x01; return !@left_state.zero" `8 L" w& ~* I# `* ^) P7 R
  267.       when 0x02; return !@right_state.zero
    " w5 ^+ R. q# N& C" m- @
  268.     end
    ) m1 _9 o2 M+ i6 R/ w6 k9 p1 t
  269.     return false
    2 w" v. C& P9 }& N
  270.   end- K% a, j2 u7 v# H
  271.   #--------------------------------------------------------------------------
    # L5 C$ V+ T, _, h- G. s
  272.   # ● 按键刚被按下则返回true
    / D' \+ p3 W: Q* c4 Q* q
  273.   #--------------------------------------------------------------------------, r- a& @/ M5 }2 a
  274.   def trigger(button)
    ( P# I7 o! x5 `
  275.     case button
    3 a/ |. u* s' ?2 [* |# p
  276.       when 0x01; return @left_state == 1- x$ |+ K- s! \  s8 a( g
  277.       when 0x02; return @right_state == 1
    7 [* g' K3 M& F6 f8 M  R: ]. a
  278.     end; `- m8 T$ B( ~7 ^% L# q
  279.     return false% o5 F7 z" B' O& a# S
  280.   end9 t7 R2 j5 D9 ?4 E. b4 v6 P: A
  281.   #--------------------------------------------------------------------------9 |" W: _, j  W& c0 P) b* Y
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true' u* B3 u7 O$ o4 G1 V2 z7 S
  283.   #--------------------------------------------------------------------------6 g6 i# Y8 ]4 K/ n# W
  284.   def repeat(button)
      A; m/ W1 T8 m( ?& j/ s: m
  285.     case button
    , \. z  n8 r4 _4 u# J" R
  286.       when 0x01; return @left_state == 1
    # B" e  z1 _8 ~+ N7 {* j7 [
  287.         (@left_state  22 && (@left_state % 6).zero)
    : x5 ~2 k1 I# p# m, G' l: O; D
  288.       when 0x02; return @right_state == 1 . L% E6 Q: i8 s, u) f! p. @
  289.         (@right_state  22 && (@right_state % 6).zero)
    5 f2 d; W! d3 ?# O0 \. G. H- u3 W
  290.     end2 _1 f2 Q0 {$ k
  291.     return false
    . k# j' a* N5 d; B* M! A
  292.   end) X; ]! o3 h' X2 h
  293.   #--------------------------------------------------------------------------
    ! [9 g6 w0 K5 `( Q( _- V
  294.   # ● 判断是否双击鼠标( L5 |. l9 M& T6 B
  295.   #--------------------------------------------------------------------------
    ) P1 h0 Y1 ]4 B2 @. i* W
  296.   def double_click5 }9 \/ y0 \" Z1 x! \( ?" d
  297.     @double_click
    % U% A* t$ f  X8 z7 ~. R
  298.   end
    6 ?2 h2 v  x% q& [* U& g
  299.   #--------------------------------------------------------------------------. t, o7 ~# c0 _$ x, f) z, X
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    ) M3 B$ Q3 Z' c6 x" W$ B- ~" O$ Y
  301.   #--------------------------------------------------------------------------4 i! J& O" F' k1 F  c
  302.   def click_count
    ; K: y# G, N/ e" S
  303.     @ck_count) y. _/ T5 W- B8 y% o$ ?
  304.   end9 d7 `8 n+ U$ ]" ]3 f
  305.   #--------------------------------------------------------------------------; W' W/ n- Z( J
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    + p' h2 k) ?8 O5 w3 v! G0 q/ o
  307.   #--------------------------------------------------------------------------
    5 S; u! \/ i1 W
  308.   def left_state
    1 Z- }: z; E, H/ v+ t) Z
  309.     @left_state
    / C/ Q; }2 _) L4 h# ^9 `, r
  310.   end
    ( ^7 J" d3 c" W6 M) a" ]; E
  311.   #--------------------------------------------------------------------------
    . f0 b' r$ [+ C  l$ y0 u
  312.   # ● 获取鼠标的x坐标
    $ Y- o) F' h+ L  \& z2 L
  313.   #--------------------------------------------------------------------------
      B# k& G7 ~: q# n# t
  314.   def mouse_x" D) b& H; x, u" I0 ^6 B
  315.     @mouse_sprite.x
    . `; @5 D/ C5 a/ \) b) A- n
  316.   end+ Y' M- D  v, a& G8 e0 w
  317.   #--------------------------------------------------------------------------
    " ?8 R3 i1 s6 k' ?
  318.   # ● 获取鼠标的y坐标
    ' N0 S; Y' X: P1 j/ R6 s$ F
  319.   #--------------------------------------------------------------------------3 R, M" J( _( x
  320.   def mouse_y' U7 b3 V- K2 W
  321.     @mouse_sprite.y5 Q+ s: j" ]+ D
  322.   end: @, Q) m1 Q1 F2 }" G5 r0 S
  323.   #--------------------------------------------------------------------------
    $ v2 N6 T0 I  V
  324.   # ● 设置鼠标坐标/ E9 m4 C6 I5 n4 }8 E; A
  325.   #--------------------------------------------------------------------------( \; ?% L/ x# I( _6 l, p
  326.   def set_mouse_pos(new_x, new_y)$ J0 U) i+ A3 j0 |" B2 D" ?
  327.     arg = [0, 0].pack('ll')7 S% A1 P# _$ ^. c6 n
  328.     Screen_To_Client.call(Window_Hwnd, arg)/ a3 T/ |# X& r' U/ A+ p
  329.     x, y  = arg.unpack('ll')0 y: a- C6 v- F) [- c
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)" o4 K6 h( y4 G
  331.   end0 q9 I! {+ }( i+ p3 ~
  332. end #end of class  self 6 ~$ m2 c8 i! Q; R: C5 g

  333. 8 s& B- \3 R3 i
  334. end
    # S/ r& \, W0 l5 U$ d
  335. 3 Z0 t# h! V8 a4 T' ?) |! a) N
  336. #==============================================================================
    : O) a' I& S  G% O2 M6 H
  337. # ■ SceneManager
    , P0 O) ]2 j, {/ z* m) _# h' s) G6 z2 ]
  338. #==============================================================================
    2 \- A) k6 U' {; r  ~- \! A/ _
  339. class  SceneManager' U2 K/ _  Y; r/ L; L
  340.   #--------------------------------------------------------------------------
      w$ E3 K7 W% v: R- g
  341.   # ● alias
    # }# {; W: s4 j' [5 ^6 ?" f
  342.   #--------------------------------------------------------------------------+ c8 _. p- D8 I  v. c
  343.   unless self.method_defined(sion_mouse_run)
    1 k6 }: f0 R9 J3 ?
  344.     alias_method sion_mouse_run, run9 ^2 v  m0 d  c0 y7 j5 J
  345.     alias_method sion_mouse_call, call1 ^* o' I/ X6 ~7 I. ~5 Q
  346.     alias_method sion_mouse_return, return5 `8 j/ E% y: I
  347.   end
    / _0 N: t/ p$ x3 F* f# W
  348.   #--------------------------------------------------------------------------
    . c0 b2 d" L- A( P
  349.   # ● 运行+ [( t& ^$ ]6 G" @; M1 Y4 \  [" ?
  350.   #--------------------------------------------------------------------------+ F/ P5 d5 Y9 C; Y( k; l3 P% }
  351.   def run' `1 C( A) ]5 p+ e, @3 S! ?! i) d# U
  352.     Mouse.init9 F$ E1 T  c4 q' F8 Z$ Y: }$ J+ a
  353.     sion_mouse_run
    7 r& y0 I: O5 X8 d* f
  354.   end
    7 D/ \) w* h; W/ _1 L$ f! M
  355.   #--------------------------------------------------------------------------
    , G- U9 x" t- X1 }7 \8 m# C0 v. m
  356.   # ● 切换+ W3 c) D" c) X7 v" ~4 @" ?. A; Z
  357.   #--------------------------------------------------------------------------
    # [' w4 n. H+ J" a$ K/ N% ^
  358.   def call(scene_class)
    ' i: k) T* H1 u/ x
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    3 f- d. d) H1 }  }1 t, }. Z
  360.     sion_mouse_call(scene_class): N% R+ X& J" |8 P& o9 {1 e
  361.   end
    & o# I' F) `) g! E/ m* V# L0 ?
  362.   #--------------------------------------------------------------------------6 d7 E2 q( @! `6 a
  363.   # ● 返回到上一个场景
      f% u: {0 B+ U1 Q
  364.   #--------------------------------------------------------------------------' Y' @4 {( X' p: Y0 o* P4 L
  365.   def return1 V6 [- h0 f/ G/ b, Z1 `
  366.     sion_mouse_return
    ! `% e4 X0 B; p( M  z
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    + ]8 s. B9 {% b$ n  ~
  368.       @scene.instance_of(Scene_Map). T3 j! D% P& o9 h: G. p( p6 n% N* O
  369.   end
    ' u8 J, b# @7 P( V( e9 X
  370. end1 C  J/ r1 W3 ?8 c
  371. 7 Y3 t9 O+ l6 Q: f5 ^0 {. K
  372. #==============================================================================
    ; o$ L9 W6 s# y7 B. r+ I
  373. # ■ Module Input" k5 J6 R& m/ ]' i" K( H/ K( F/ t
  374. #==============================================================================1 _1 t2 Q4 p6 [* C% }8 U4 b; \
  375. class  Input
    8 J: G/ Y5 G9 J0 U5 T5 D2 ~* N- ^
  376.   #--------------------------------------------------------------------------) r- m: n4 ~  X2 V
  377.   # ● alias, i" N$ |8 E% w" ?* q$ s
  378.   #--------------------------------------------------------------------------1 w' k9 U: {; W' B
  379.   unless self.method_defined(sion_mouse_update)
    $ Y+ x* e1 ]1 A- ~- k6 Y  w7 b! n
  380.     alias_method sion_mouse_update,   update* [8 \! k* N( d  |* a% N# t2 Y5 E
  381.     alias_method sion_mouse_press,   press
    & T- |1 f% P" O0 ~/ [, y: R
  382.     alias_method sion_mouse_trigger, trigger
    9 Q" u: t! ~0 g$ I8 G
  383.     alias_method sion_mouse_repeat,  repeat
    ( x- y# c: }  ?0 O. h2 E
  384.   end
    ! k% R9 ]8 e! x2 h" `; O
  385.   #--------------------------------------------------------------------------& z* m% B9 _, B5 o) }0 g& b
  386.   # ● 更新鼠标
    8 N" j4 \) P4 h6 N  E
  387.   #--------------------------------------------------------------------------
    8 V7 S+ R- R: v/ d* Y/ J5 Q
  388.   def update
    & @8 I) W* ~. J, F3 l: F+ ^1 v! c
  389.     Mouse.update
    : R4 Z! s, h: F
  390.     sion_mouse_update# b- k# H3 J0 p. Y
  391.   end0 j( X+ v# W* z  T& f: ]( O
  392.   #--------------------------------------------------------------------------
    1 i+ e4 T! h7 Y: c9 {& v
  393.   # ● 按键被按下就返回true
    - N. P# l9 A! @( o
  394.   #--------------------------------------------------------------------------
    : D( U; D, _; z' L
  395.   def press(key)+ A6 w+ A! W+ O/ t+ C0 i
  396.     return true if sion_mouse_press(key)3 v, C! _& m' g5 _8 W; ?
  397.     return Mouse.press(0x01) if key == C
    ' }& Z% d, j: S" T. M' L
  398.     return Mouse.press(0x02) if key == B! M6 D# f' L' }) n5 W* g& t
  399.     return false+ o# [- Q8 ]/ ^: d. w# l
  400.   end$ v. A( W2 ~( ]' F, b1 ?
  401.   #--------------------------------------------------------------------------" @* J6 t1 y% g4 r5 l' Q
  402.   # ● 按键刚被按下则返回true, B8 a& o( x3 O  E9 ~
  403.   #--------------------------------------------------------------------------
    # U7 M* I4 J: t8 O  l3 Z* x
  404.   def trigger(key)' J: X: Y) V  d4 ]' d, K4 {
  405.     return true if sion_mouse_trigger(key)
    ! \) A" P7 n8 a$ T9 U- B2 O3 X
  406.     return Mouse.trigger(0x01) if key == C5 ^+ E# w+ q+ Z; i
  407.     return Mouse.trigger(0x02) if key == B
    * }1 p  A4 }$ t1 |
  408.     return false, y% u; Y) i6 J8 Y9 v3 W$ E/ d
  409.   end$ Y9 J4 I& t7 c8 B! J9 |# K0 I- q
  410.   #--------------------------------------------------------------------------
    5 A. p+ `3 F9 j, X+ f
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    & d0 ?. O: u  B) f8 r
  412.   #--------------------------------------------------------------------------- a: c$ t  D2 @
  413.   def repeat(key)
    ; V; i: P4 o* U
  414.     return true if sion_mouse_repeat(key)
    . _0 V" a2 q: t# L0 ?3 T* L- D
  415.     return Mouse.repeat(0x01) if key == C
    ! P7 \+ D. w! |& `, j
  416.     return Mouse.repeat(0x02) if key == B  m; m5 ?9 u4 Z7 `7 Z
  417.     return false
    8 Y: g. e) n/ U5 d# t
  418.   end
    * {/ B: n) x; Y4 h6 k
  419. end
    ! \, z/ t0 k" r* h% H! e: S4 i

  420. 5 [' E: H; C* B! {$ G( V; ~
  421.   k5 ?! C; g3 c6 H
  422. #==============================================================================
      c1 i1 c+ q" r" b
  423. # ■ Window_Selectable; ?0 F- ~  J) M, A2 d' F
  424. #------------------------------------------------------------------------------
    . v1 @/ I" g" Y1 s0 I1 @7 N2 ^9 w+ n
  425. #  拥有光标移动、滚动功能的窗口% ^1 ^$ b+ _# }* H% N0 x0 c1 n
  426. #==============================================================================7 F7 M3 k( w! [) m+ A, b
  427. class Window_Selectable
    , i' n4 @3 M# g# n( L- {
  428.   #--------------------------------------------------------------------------
    ; P+ o+ N2 O3 j  n) ?# T3 Y+ ?% M
  429.   # ● 初始化
    ) _" \+ u  y) c
  430.   #--------------------------------------------------------------------------
    6 `( k3 a; l- B# S. t
  431.   alias sion_mouse_initialize initialize4 w7 l- ]4 ~8 ~; Y. K3 y1 Q3 j3 H
  432.   def initialize(x, y, width, height)+ |; k6 P2 E' I. v$ S' w
  433.     sion_mouse_initialize(x, y, width, height); F" s! h/ u: E9 B5 [
  434.     @move_state = 0
    ! M. v9 o% }( y% g; m1 e
  435.   end  g" Y2 s- i: T" a- o& w
  436.   #--------------------------------------------------------------------------- }) w7 o* s; U
  437.   # ● 更新8 R# L8 p$ B1 S/ [8 M
  438.   #--------------------------------------------------------------------------3 X" r" V9 P4 H; k& M+ v! R4 `9 L
  439.   alias sion_mouse_update update" {/ U! f& j6 e2 t; M
  440.   def update
    ) a" I) M0 Z0 s& I3 O/ d
  441.     sion_mouse_update4 |4 t9 d! q" ^, i. V8 @
  442.     update_mouse_cursor( y' T+ b3 i8 [# ?& P1 H" X; e
  443.   end2 S- ]7 ]& S4 |9 {; M
  444.   #--------------------------------------------------------------------------2 p* L& \; ]: ~( |
  445.   # ● 启动后设置鼠标到index位置: H4 L  R* M1 j) I, O8 L0 g
  446.   #--------------------------------------------------------------------------3 u% I- Q) ?! [! R9 H
  447.   def activate0 F6 z! P, x5 o
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    % g1 ~8 v2 ^1 }# g! {
  449.     super) r( N: _% B; C+ Y( q$ M
  450.   end
    7 e, o: X& {" r4 Y# F& w2 T0 A
  451.   #--------------------------------------------------------------------------
    # S# Y3 N! Z# o5 Y" F
  452.   # ● 更新鼠标和光标的位置2 x0 G' y5 n9 l
  453.   #--------------------------------------------------------------------------
    9 h; |, \5 ~3 y, U6 H7 F: }! P
  454.   def update_mouse_cursor. M- Q3 v2 Z2 s
  455.     if active4 i. M5 `: [0 d- [9 J
  456.       if @need_set_pos
    1 B1 O" N$ u' L# {, H
  457.         @need_set_pos = nil
    & W9 l, t8 H; B
  458.         set_mouse_pos9 t0 ?- D4 y$ S- w" Q5 r9 ^1 V
  459.       elsif cursor_movable
    ' Z. Q" P/ y% y( \. J+ b* n& y
  460.         Input.dir4.zero  set_cursor  set_mouse_pos% r0 U- k, c# P3 q! |
  461.       end! n1 v+ ?9 F! V/ _/ |
  462.     end5 v# Q0 H. I: J5 t6 ~1 C
  463.   end. `0 G9 f2 D- l2 g6 t- R
  464.   #--------------------------------------------------------------------------
    : a7 ^* j4 |7 O, _
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    . y4 ]* ^4 l3 e) E. v# H7 @
  466.   #--------------------------------------------------------------------------
    $ t1 f* x. S6 e8 p7 E. x
  467.   def set_cursor8 L& n: f( O3 c/ X$ k. Q/ @
  468.     mouse_row, mouse_col = mouse_window_area
      a* p$ O; U- h/ C. u* d: R
  469.     if    mouse_row == -1
    " \- l7 K  r  w9 A
  470.       @move_state += 1 if need_scroll
    5 O5 \( g! [/ j0 p& _1 b. \
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ! y- S# l3 K( h4 p4 k  K4 V
  472.     elsif mouse_row == -2) C+ {/ h% Q* k7 G. w
  473.       @move_state += 1 if need_scroll
    9 l. T% W: y1 @  |" z8 W  ^9 K
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ! Q. b! y0 H6 _3 a5 N+ @9 M/ f$ a
  475.     elsif mouse_col == -1; c- y5 \( m* n2 z
  476.       @move_state += 1 if need_scroll# \( G" g+ I$ B' Y" Z
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    2 t, J' h8 D$ B# N- p- F- x% f/ a  |
  478.     elsif mouse_col == -2* t( g4 X  t' t% A" \+ p
  479.       @move_state += 1 if need_scroll
    2 x8 c. H4 l, H4 B, B4 m* Z3 n- i
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand5 o3 m& q- |+ b0 @
  481.     else
      P: ^7 a3 c3 F1 S/ y+ X+ w
  482.       @move_state = 0( W3 I; L6 r6 Y+ _% k% ~
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col" \" }; W$ h( z3 w6 h- j
  484.       select(new_index) if new_index  item_max && new_index != @index  q, \6 ^* d# u# n# q8 F$ [
  485.     end. U1 _8 q1 U2 |: `1 t" |" x5 k
  486.   end! P+ z( n# s4 g$ p7 [1 }, z7 u  F
  487.   #--------------------------------------------------------------------------5 J0 w% d4 a: @8 S
  488.   # ● 判断鼠标位于菜单的第几行、第几列7 ]3 y  L8 V) u1 ^
  489.   #--------------------------------------------------------------------------0 |. p: r4 G( ]! D6 M: z* `( q9 K
  490.   def mouse_window_area
    0 b1 ]8 J2 |: v& P) R) D- G9 F" ^
  491.     if viewport.nil # necessary!  r8 |' k4 m/ f2 `; q9 v+ N6 C
  492.       vp_x, vp_y = 0, 0) E$ C3 }. j9 {; s
  493.     else6 Q: r' H) A1 C7 {6 M# S& ]' l
  494.       vp_x = viewport.rect.x - viewport.ox
    4 N4 Q: h' p9 v( {; d
  495.       vp_y = viewport.rect.y - viewport.oy
    0 `0 d- J7 L# i! z5 ?7 V
  496.     end1 a  ^3 d9 t9 T% C: f1 G/ S) I
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    8 u$ _9 k4 m7 p
  498.     item_x1 = vp_x + x + standard_padding
    4 H# v+ ?0 Z. f2 a+ a2 m# u2 s& {
  499.     item_y1 = vp_y + y + standard_padding
    , c+ H. l$ r# \. W" |! c
  500.     item_x2 = vp_x + x - standard_padding + width! n* ?3 Q* t+ C
  501.     item_y2 = vp_y + y - standard_padding + height+ ^! q( e' n! |( h! b8 r' R
  502.     if mouse_x  item_x1( }3 Y+ B) i  V1 G# d8 P% z9 z
  503.       mouse_col = -1
    + Q" j, o4 }8 V6 ^- y6 f8 Z% l
  504.     elsif mouse_x  item_x2. w1 e) s) `3 w: W  I
  505.       mouse_col = -22 q' V$ F8 T& a; Q
  506.     else# t% b5 X6 u- c; m. t/ g
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)4 D8 U/ R& \% a9 [, \
  508.     end, k6 J8 g* o7 a/ U/ E; Z3 V* d
  509.     if mouse_y  item_y1
      a( b( B1 @3 m4 e% z; ?: G# f
  510.       mouse_row = -1, {3 q0 e/ _, c1 N0 \+ }; |
  511.     elsif mouse_y  item_y2
    2 Q; e/ E" v" H: ^. K/ R' l
  512.       mouse_row = -2
    % \6 D7 F* p7 Y/ l, G
  513.     else3 T6 l6 t, z$ c
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    " i  l  [+ d% a" a4 C3 ]& s
  515.     end
    3 P$ d' M; Q+ L4 u& b
  516.     return mouse_row, mouse_col1 T& Q3 ~5 g: }* A' r
  517.   end
    ) M* `, }6 }7 z4 ^3 |: h* u
  518.   #--------------------------------------------------------------------------
    * y4 O5 I) r7 \% R1 T  r( a
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ) z% S9 R! F. K# r/ |
  520.   #--------------------------------------------------------------------------- m: `+ [( ~- ]% q9 y: h
  521.   def set_mouse_pos: ^* t0 [+ u' p0 ~; @4 L9 A8 A4 Z$ o
  522.     if viewport.nil # necessary!$ L% [2 q8 C, Q* A4 z, G( f8 x$ s
  523.       vp_x, vp_y = 0, 0
    9 k) c' b# [! v# A
  524.     else
    , o1 c1 f5 a8 L" V! V5 n6 j0 S
  525.       vp_x = viewport.rect.x - viewport.ox# b' P% P* f" C: g. C- c4 O, B
  526.       vp_y = viewport.rect.y - viewport.oy0 S. D6 b, k: h3 o! V1 S, H5 U
  527.     end
    + ?' ~! ~" D3 D
  528.     item_x1 = vp_x + x + standard_padding 0 V2 S& a9 R0 v- a/ a# k" C$ ?9 U
  529.     item_y1 = vp_y + y + standard_padding
    0 H0 W$ h) {  F' s* c
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index   d5 }: H/ Z5 ~% b
  531.     row = get_index  col_max - top_row! Q$ C# k: D8 X
  532.     col = get_index % col_max0 p( H7 c. S8 z& V% [0 ?; E
  533.     new_x = item_x1 + item_width  (col + 0.5): D2 B9 Z- Q( m7 C2 a
  534.     new_y = item_y1 + item_height  (row + 0.5)/ d% A/ _1 V6 b6 u
  535.     Mouse.set_mouse_pos(new_x, new_y)
    " ?- V; Y' R. ]0 [; r0 R
  536.   end
    " Q% U5 e8 Z; M5 `
  537.   #--------------------------------------------------------------------------% r! r$ X/ `, I& x2 D8 m
  538.   # ● 判断菜单是否需要卷动
    : l# ^' q" ^  S$ m$ B  t' Z' B- t, W* ^
  539.   #--------------------------------------------------------------------------0 r# s( Q& X! F% ]' m3 W5 g2 R* l
  540.   def need_scroll
    ; `) |# e0 W2 K7 a5 T
  541.     item_max  col_max  page_row_max. s- `( Q* x! h8 G
  542.   end
    + U6 Q7 d5 H- ~; R1 |2 o5 F2 _; Z
  543.   #--------------------------------------------------------------------------: I, k. ?8 L( j, u
  544.   # ● 判断是否为水平卷动菜单
    % b+ \$ C& x: z: M- ~0 f% i  D$ t
  545.   #--------------------------------------------------------------------------- i3 F0 a" o- H+ l& U7 [* p$ I
  546.   def is_horzcommand
    % K' F; Q- a; f# h5 F& w5 i
  547.     return false
    6 T0 b+ `  @+ h7 `  a. _
  548.   end
    . t+ n' C0 \  c2 Q. t
  549. end
    ) J- w8 i' ~" B# o! X! |

  550. 4 W" Y6 C, }! G
  551. class Window_HorzCommand( [2 q) \$ S, S& A- `9 s
  552.   #--------------------------------------------------------------------------
    2 T( ]% p/ T8 k9 V5 ]* n8 j
  553.   # ● 判断是否为水平卷动菜单0 @5 @4 b& w% i1 Z
  554.   #--------------------------------------------------------------------------
    : P' ~+ b9 B: |4 k$ [% r1 F
  555.   def is_horzcommand
    3 ^4 s" L) t; k: s
  556.     return true5 r3 b2 X; ^$ u& O* K' p" f) e5 D
  557.   end5 T. \- B) g! N7 R3 z. Y! v1 _8 Y
  558. end$ `) u/ B2 \( o8 W, a- _% ^
  559. ! z8 R4 x8 U" O/ F0 ]
  560. #==============================================================================
    & a9 z0 d7 R. y- F9 {) H
  561. # ■ Window_NameInput3 y$ f4 K  ^% a' H; k  @/ Z
  562. #------------------------------------------------------------------------------
    & [1 d# J, H" y, x+ A3 Z% T  e
  563. #  名字输入画面中,选择文字的窗口。3 L; t. ^2 ~. I0 b
  564. #==============================================================================
    8 _: G& }5 b( F  r1 S
  565. class Window_NameInput! h/ s4 b1 S- w, u: h- g
  566.   #--------------------------------------------------------------------------( E! z+ g" `4 G+ ]: f( f' G
  567.   # ● 设置列数
    4 i+ ]" y& }" W1 I. B) j
  568.   #--------------------------------------------------------------------------
    0 w- `* ?" C# V* R, q$ v, V
  569.   def col_max
    : I( ]  Q7 N" g! |' d9 q
  570.     return 10
    ) H6 [% R$ G/ R+ P( y& v
  571.   end; ?: z5 d$ f9 p/ D' b: |0 Y
  572.   #--------------------------------------------------------------------------
    8 Z7 Y+ i; l% A! b7 B9 `4 }
  573.   # ● 设置填充的Item个数
    5 J; j: G: Z3 r" _
  574.   #--------------------------------------------------------------------------
    3 Q0 }3 k7 s) ^2 R5 G
  575.   def item_max
    & e# R' `$ h+ c- `2 s+ n
  576.     return 90
    + L$ m* f3 a8 ?+ r' v0 ]+ k
  577.   end; ~1 V) l1 Q+ {
  578.   #--------------------------------------------------------------------------5 \; k/ _+ ~6 ?# A. \' s. W
  579.   # ● 设置填充的Item个数
    7 V0 X3 p) W+ m# Z. x
  580.   #--------------------------------------------------------------------------7 f! O: c) Q2 _4 I! z9 C3 [
  581.   def item_width4 c  k9 P3 m: ]" D% P
  582.     return 32
    1 d; {6 G6 H' g; T% Y% i
  583.   end+ t8 |5 q7 t/ P% @' k7 N# g, q8 H
  584.   #--------------------------------------------------------------------------
    4 z2 l3 S  g! H- N
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    4 ~0 D3 n0 d2 E) u+ x: s
  586.   #--------------------------------------------------------------------------
    : p3 P) v7 w  u3 i5 T) |
  587.   def mouse_window_area
    & ^+ i; A- D& s+ r9 ^  H/ _
  588.     if viewport.nil
    ! Z" |& {+ _+ `" z: z7 _5 U
  589.       vp_x, vp_y = 0, 0" u9 M' j0 g: j  l
  590.     else
    ' h7 W, t: I  J
  591.       vp_x = viewport.rect.x - viewport.ox
    ! n, q! b- ]1 \1 X4 _9 i
  592.       vp_y = viewport.rect.y - viewport.oy! y7 A6 I/ B, \! H
  593.     end
    $ j! Z; \( ]& ?
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    * P+ S5 k% ], `. M: ^/ P
  595.     item_x1 = vp_x + x + standard_padding 4 R9 x+ }, [; C6 w
  596.     item_y1 = vp_y + y + standard_padding
    & j0 o. R5 f, Y& \  S
  597.     item_x2 = vp_x + x - standard_padding + width# |7 F) y6 E  a
  598.     item_y2 = vp_y + y - standard_padding + height
      W  r% _5 X# ]- v5 g6 I' M* m
  599.     if mouse_x  item_x18 K- K2 X. m( r% F$ k
  600.       mouse_col = -1
    ) y! r2 U. O7 N* l# k
  601.     elsif mouse_x  item_x2
    7 x( q6 i0 C/ B: I/ t' k5 n( p0 w
  602.       mouse_col = -23 M; Q: V6 f1 ~; f* i; i
  603.     elsif mouse_x  item_x1 + 160
    & N3 v' H' f* `+ h2 G
  604.       mouse_col = (mouse_x - item_x1)320 z! Z) E* ^* G
  605.     elsif mouse_x  item_x2 - 160/ |! v1 y7 q, f
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    6 F+ C) Z3 y0 Z& h- y4 a
  607.     else; v  R3 e, S9 E8 z, I# e1 U
  608.       mouse_col = mouse_x  x + width2  5  42 ^& o$ x; A) ], y  D
  609.     end* o8 W. r0 R. u" U, V& c( r+ k! t# k
  610.     if mouse_y  item_y19 ^5 n5 |: Q* d4 ^7 K, V9 B
  611.       mouse_row = -18 ^3 m7 O% X8 j. P0 O
  612.     elsif mouse_y  item_y24 ]$ |1 c6 [1 T
  613.       mouse_row = -2
    ( h3 _0 r+ ^4 v3 B8 _2 l
  614.     else
    8 z) ^9 e* q' l
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)) [% n# o3 f4 u5 Y9 k2 \: z
  616.     end
    $ ], p' ~9 ~7 d& H5 ^
  617.     return mouse_row, mouse_col
    ! B9 _. e$ ]5 H% y; A
  618.   end
    : A0 H0 `4 c% ?
  619.   #--------------------------------------------------------------------------1 W! {$ t  r2 J  }  h
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ! o$ r' q$ c  o9 {& [2 q' K' U
  621.   #--------------------------------------------------------------------------  v/ |/ S( x, B9 J8 e
  622.   def set_mouse_pos7 w' |$ Q* C; W7 W1 n
  623.     if viewport.nil # necessary!& j0 T2 q* {7 J3 K: {
  624.       vp_x, vp_y = 0, 09 ^% D6 u% X' H# x# j
  625.     else
    9 V4 _2 V0 W! d9 O4 }0 x5 @
  626.       vp_x = viewport.rect.x - viewport.ox
      E/ w, u- I7 ~( N+ C
  627.       vp_y = viewport.rect.y - viewport.oy
    + j" ^3 L- s6 Z% k3 c
  628.     end
    4 C' J; h5 T- R: N5 f
  629.     item_x1 = vp_x + x + standard_padding " w. T# V- u  V$ w) V, V8 b" \; B
  630.     item_y1 = vp_y + y + standard_padding
    - c* e6 h# [& u" Q5 }9 u
  631.     get_index = @index  0  0  @index
    / N: q' I: x% j) M7 w  @- |, r
  632.     row = get_index  col_max - top_row; k& l3 T( W0 Y) n# q  S% k# {
  633.     col = get_index % col_max
    & `' o0 [9 \; u9 D5 T2 W0 E
  634.     new_x = item_x1 + item_width  (col + 0.5)
    + h) e* ?9 W* ~! _
  635.     new_y = item_y1 + item_height  (row + 0.5)
      R1 b2 L4 i1 C# o
  636.     new_x += 14 if col  4! B5 n6 T; s2 d0 }. e
  637.     Mouse.set_mouse_pos(new_x, new_y)& i& b& G5 A7 h( \7 T
  638.   end
      {1 e* H+ s( U! {, l* W2 r
  639. end
    ) U* H% Z2 v& i
  640. . b$ R. E3 r; a' j: i
  641. #==============================================================================) d0 H% P0 @! A6 Q* I4 P- T' D
  642. # ■ Window_NumberInput; _  d; F9 S0 c( u
  643. #------------------------------------------------------------------------------
    0 C1 u' V" Q( ]" m4 s' e, N
  644. #  重写了数值输入的方法以适应鼠标& y' X. c" u: M1 ^
  645. #==============================================================================; P# X# _* C+ ^+ T+ r! y3 E
  646. class Window_NumberInput  Window_Base8 ]. i3 k$ f. u3 n; b
  647.   #--------------------------------------------------------------------------
    6 A2 P; z) l5 P5 g/ S, ~
  648.   # ● 定义实例变量
    & y" E2 ^( w  f' N5 t
  649.   #--------------------------------------------------------------------------" c* c; C) t5 r/ f0 u/ F5 p$ w
  650.   attr_reader extra_window8 ~+ K5 ]2 j, P0 n
  651.   #--------------------------------------------------------------------------
    0 v6 w- `7 [5 ^( p# L! y. Y
  652.   # ● 初始化
    7 I3 u2 g+ ]6 R# B1 U
  653.   #--------------------------------------------------------------------------
    3 g' T. a; g/ n
  654.   alias sion_mouse_initialize initialize- i# b" _7 i( _4 ~$ K3 E, L
  655.   def initialize(arg)
    9 n5 p3 S. _: I( K7 x
  656.     sion_mouse_initialize(arg)
    & u7 j5 V7 W! k. `8 u. V
  657.     create_extra_window
    , j8 f  f  b" b% w  S. M3 p8 B8 ?' g4 i+ y
  658.   end
    5 V& [+ d* |- t8 b0 N4 c
  659.   #--------------------------------------------------------------------------' ]5 p  j8 S) F7 ]4 |
  660.   # ● 启动
    . a: G# R' v/ l7 }) p1 G" ^
  661.   #--------------------------------------------------------------------------
    ( a6 ^2 p. R8 w/ \3 |( e- K( R
  662.   alias sion_mouse_start start
    5 d$ D2 Q  }- a
  663.   def start* ]5 g+ e9 T7 R* R
  664.     sion_mouse_start
    / j3 |. @) E, Q' }; R& Q5 W: v
  665.     deactivate( S' m2 d& p" \
  666.     extra_start3 a$ n* V1 K- A9 m1 m, G: ]1 u6 ^
  667.   end
    - V& t/ O. s" i. K6 Y( }2 z2 h2 c
  668.   #--------------------------------------------------------------------------
    " `+ A( d. D' Z  w; h4 }
  669.   # ● 创建新的数值输入窗口4 Y8 j$ e9 E6 ^) P: O
  670.   #--------------------------------------------------------------------------
    8 E: z- m( n6 ?0 A
  671.   def create_extra_window
    ! Q9 h) \3 p% y6 m9 B3 M4 f
  672.     @extra_window = Window_NumberInput_Ex.new
    . c1 P! k3 `0 E4 O
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2! P5 @8 x0 {6 R. B/ `' u; W7 M
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    9 z: E  B0 [% E6 x& x) r3 F
  675.     @extra_window.index_proc   = Proc.new {n @index = n }6 M8 k; D# o! k- `7 ^
  676.     @extra_window.close_proc   = Proc.new { close }
    7 E7 F6 k( f7 ~! E) a  w4 a
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    3 Z. F' L& p7 q6 Z9 z' h, o
  678.   end
    ! J5 J+ u' z) }9 j! P% _0 l
  679.   #--------------------------------------------------------------------------
      n# c7 b% R5 J1 V- b
  680.   # ● 激活新窗口
    ; E8 x, G! c+ L9 t
  681.   #--------------------------------------------------------------------------
    : `- U+ T: @  b3 B; X; f
  682.   def extra_start
    2 [- C2 h4 L1 w+ B, _- K$ J
  683.     case $game_message.position
    9 c- B% G/ X# ^5 l
  684.       when 0; @extra_window.y = y + height + 4
    1 ^* F4 O( N+ x. ^7 T4 |7 z
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8& c; Y; c; i6 _/ B( D- I
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    ; l, k( _; c. I  ~1 e  ]9 ^# C
  687.       else  ; @extra_window.y = 8
    6 P( Q" ?4 Y7 f" V" j' c
  688.     end: S. m1 Y- I& _3 F2 m
  689.     @extra_window.variable_id = $game_message.num_input_variable_id2 ?- @6 i; q: A1 A" |
  690.     @extra_window.digits_max  = @digits_max
    - V1 E- u1 i! h; Y0 L% k
  691.     @extra_window.number      = @number3 N) h  Q/ v' @$ a( k/ n# L9 _7 ?
  692.     @extra_window.open7 G* V. `0 C7 m
  693.     @extra_window.activate
    $ a( ?5 D6 I- N1 b( L; \5 \- e
  694.   end+ T# ]9 `  R7 ^! @5 ~; l9 \) J
  695.   #--------------------------------------------------------------------------
    3 p0 Z& {- ~! N' v
  696.   # ● 更新0 G* ?, S. Z% {2 b
  697.   #--------------------------------------------------------------------------" B, A! b* u% Y% t9 r: U
  698.   def update
    , W+ T, C. b) z* r9 P( s) w
  699.     super" W% d) }+ [* d8 q
  700.     @extra_window.update3 g8 b) B* H; G1 i% m- W1 Q, K- N
  701.     update_cursor
    1 O) D# J( @4 Y3 P" `
  702.   end
    4 ]& W- J+ z2 }1 Q; f5 c
  703.   #--------------------------------------------------------------------------* x2 O4 p* f% R! O9 s( U- M
  704.   # ● 关闭窗口
    / L" V; z  m. Y: V
  705.   #--------------------------------------------------------------------------3 i: [4 f. V/ p
  706.   def close' D. M8 q, g: n- R  H, @6 n
  707.     super* o! a/ K' z* y8 [- T' M
  708.     @extra_window.close
    ( W1 `: r. x# A# t: Y8 w
  709.     @extra_window.deactivate
    6 n8 m8 ?, c( x' v0 I0 r
  710.   end; e& f7 q, I4 \$ X
  711. end1 Q$ X. v7 J" m% P
  712. 7 K6 Y9 ^, M2 @2 T0 q( I) X
  713. #==============================================================================
    # p2 E. m  I, q3 U+ P
  714. # ■ Window_NumberInput_Ex
    1 ~" C7 V- ?; k6 X" v. _+ d. K
  715. #------------------------------------------------------------------------------
    ! m. F% _: i2 J7 c9 {# b1 [
  716. #  新的数值输入窗口(NewClass)
    7 X; D3 ^% B- N) n9 y6 U
  717. #==============================================================================
    . Y* s, r7 l5 B: Q2 \7 A8 b" \* ~
  718. class Window_NumberInput_Ex  Window_Selectable
    4 w- N6 J" L# a# j8 S
  719.   #--------------------------------------------------------------------------& d% n: Y  T: Y' [2 c, u
  720.   # ● 定义实例变量
    ) Y$ `9 ?9 V/ W1 {! h
  721.   #--------------------------------------------------------------------------8 h5 U4 j6 |& E! Q" O: T0 N* G0 A
  722.   attr_accessor number_proc
      t8 c6 R' ~& Q* I; \
  723.   attr_accessor index_proc
    - X0 U  A, r# d+ x3 [* _, G
  724.   attr_accessor close_proc8 O3 o) P9 Y! k+ d$ f1 ~- _/ g
  725.   attr_accessor refresh_proc
    + C! C" m; B( V0 g3 }, o+ k' X! C* ?
  726.   attr_accessor number
    + l1 n5 [* Q" m4 e" ]5 r
  727.   attr_accessor digits_max
    ! g1 ~$ R2 ^1 q- _* T
  728.   attr_accessor variable_id4 b) _7 Z5 U; L+ A- I) ^6 O
  729.   #--------------------------------------------------------------------------: |2 C" t% g, D8 w
  730.   # ● 数字表) e& z+ t0 F$ P, n
  731.   #--------------------------------------------------------------------------6 p" r- p) J" G0 E: r
  732.   TABLE = [  7,  8,  9,
    * `0 ^5 F# O1 F
  733.              4,  5,  6,
    ( ^9 N( P& H6 O, w5 h
  734.              1,  2,  3,! ~. ]; o# T+ S
  735.             '←',0,'确定',]
    6 t5 Q, f: N% j: x! ]1 l6 j
  736.   #--------------------------------------------------------------------------
    - c/ i0 W" j0 V+ h6 q( y/ Q
  737.   # ● 初始化对象
    & u  Z5 t$ q6 _$ z3 Q( @' m: M
  738.   #--------------------------------------------------------------------------
    $ ?' D7 a0 P2 z5 ~; p, \' C) ^
  739.   def initialize
    - K  p& r* l* D: I4 R( a9 w4 c
  740.     super(0, 0, 120, fitting_height(4))3 B- e. w) s* f' Z# j3 P# H( l% R
  741.     self.openness = 0  ^; [+ m& k: Q* M) t3 F% p
  742.     @index = 0! N+ `& |/ C2 q7 w9 n# ~) R
  743.     @number = 0% Q+ i" C/ x9 S* P- b
  744.     @old_window_index = 0
    7 H/ X$ {3 w( x2 v
  745.     @digits_max = 0
    $ C4 |4 b6 I; F; P3 H
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }* e9 g- a' [1 P5 O
  747.   end
    8 A' f6 z0 D0 L8 {, N9 X& M) F
  748.   #--------------------------------------------------------------------------
    ; V4 a4 j4 f% k! d( [
  749.   # ● 获取项目的绘制矩形: n2 Y% K3 t* @( {3 c
  750.   #--------------------------------------------------------------------------
    . _4 c* a' o  {" _; v: n- a0 f
  751.   def item_rect(index)% S: m' u+ m. c- ~
  752.     rect = Rect.new
    * A9 E$ h2 x/ D4 ~  c* j/ Q: J
  753.     rect.x = index % 3  32
    5 r* n" m; W, v' R
  754.     rect.y = index  3  line_height
    0 }$ Z4 X! X2 r" X8 V
  755.     rect.width = 32
    , H: ?; y" p8 L& Z! k
  756.     rect.height = line_height
    ; W& |9 R9 C: U
  757.     return rect
    0 g: L5 v( P+ J! J
  758.   end3 U. E5 z. g6 R- v
  759.   #--------------------------------------------------------------------------, r# k$ c: ]1 D0 k& R3 Z) k
  760.   # ● 将光标设置到鼠标所在的位置% }% r% a% l: m3 t$ z8 e5 v
  761.   #--------------------------------------------------------------------------5 w% m7 ^+ e% n' @
  762.   def set_cursor
    5 @' F$ n- ?7 l3 C0 P9 F% l& }: p0 h. D
  763.     mouse_row, mouse_col = mouse_window_area- O! S# E, v5 Y' W6 ]" e
  764.     if mouse_row = 0 && mouse_col = 0' X! N3 V  M5 p$ |# x  N
  765.       new_index = mouse_row  3 + mouse_col
    4 p* w, M2 h6 x* Y
  766.       select(new_index) if new_index = 11
    6 q' [6 o* H5 m& y
  767.     end
    & K- ^, ^' B" V, I6 w4 f8 N0 K
  768.   end
      c3 C- i' ?% n
  769.   #--------------------------------------------------------------------------
    # [$ d' D/ O1 P4 I, A5 X. f' {
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    / ^9 N# t. h- r+ Q
  771.   #--------------------------------------------------------------------------
    8 z; w  G, r! t: J) q0 Y
  772.   def mouse_window_area- s; v. M: {; _& q
  773.     if viewport.nil
    5 N: G: j. U8 R. _% o0 Z
  774.       vp_x, vp_y = 0, 0
      Q- O# W% g- u- v4 T* H. y/ O
  775.     else8 J' D+ A$ h( a: k; x! l
  776.       vp_x = viewport.rect.x - viewport.ox
    7 y2 {- y$ U$ s: b" d) ^; {4 k! X
  777.       vp_y = viewport.rect.y - viewport.oy" g6 ^% M7 D1 D  X
  778.     end
    / I# t  J0 u# }. X7 _
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y/ ^( E# }  p. ~( f3 @% a
  780.     item_x1 = vp_x + x + standard_padding
    . \9 {$ C% Z2 l! s
  781.     item_y1 = vp_y + y + standard_padding5 N$ {4 O! x& i# U. W  D
  782.     item_x2 = vp_x + x - standard_padding + width
    ' P' N9 F! Z5 S
  783.     item_y2 = vp_y + y - standard_padding + height
    / \$ ]6 k8 b0 V. Z" [. s/ l, |5 {
  784.     if mouse_x  item_x1
    ( b; x0 }+ o3 u# I/ p. X9 p
  785.       mouse_col = -16 c2 O6 K; o1 a7 f  A
  786.     elsif mouse_x  item_x2' k" a% L8 t# u% X
  787.       mouse_col = -29 K  Y3 H8 R3 h0 p1 x
  788.     else
    - v0 q- m7 L. _  G- D
  789.       mouse_col = (mouse_x - item_x1)  32
    & H" f  g" @& V) z- t( `
  790.     end
    0 l) L0 g; M8 @, q7 W6 A3 K8 S
  791.     if mouse_y  item_y13 g, D% B- ]3 \; D8 E
  792.       mouse_row = -1" W& {# S1 c  ~4 p! q( {; w
  793.     elsif mouse_y  item_y2
    4 Q3 y# F" v& f7 }4 t" t
  794.       mouse_row = -26 J3 E8 q( J. Z$ [; C
  795.     else) A  E, |6 A% Q  E* g3 {% h
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
      C6 r5 Y7 Z" \4 h  `! y
  797.     end& H. X, R% e- U+ J" p
  798.     return mouse_row, mouse_col! J7 W  o+ `: ^/ ^. a! c4 Y, @
  799.   end# C  l9 v+ Q6 N2 t! a3 i
  800.   #--------------------------------------------------------------------------1 u6 W  C; C; P/ J
  801.   # ● 获取文字
    7 G6 ]9 d% m: v: O9 ~$ {! V" r
  802.   #--------------------------------------------------------------------------
    / m( ?0 P/ r! ~6 \4 `4 O
  803.   def get_number
    % O' c4 k2 ]. n) O+ u
  804.     return false if @index == 9  @index == 11
    / _5 [  `0 A& K3 \% m
  805.     return TABLE[@index]
    ' _" L. D' F1 q: \6 |
  806.   end
    2 Q' s/ C: E8 o6 G
  807.   #--------------------------------------------------------------------------% v+ U" `. l, w2 g
  808.   # ● 判定光标位置是否在“退格”上  U( ?3 q  ^% p3 K# Y
  809.   #--------------------------------------------------------------------------
    / i1 y+ u% d7 g( e* _) {
  810.   def is_delete
    / x* ~* K; j% p8 X# m7 q  Q
  811.     @index == 9& i/ g& i7 w" N' O8 ~
  812.   end
    & n1 x% y4 W) p$ K& x6 k' ~  S
  813.   #--------------------------------------------------------------------------
    2 P8 K9 e/ \6 X# H, y
  814.   # ● 判定光标位置是否在“确定”上! C0 R. ?: ]; [
  815.   #--------------------------------------------------------------------------" G! g2 m9 w5 L% S- T. E
  816.   def is_ok" y7 E4 j$ c  r7 Y6 r5 F
  817.     @index == 11
    + t* n$ ]2 e- x/ k0 [6 c, H: g
  818.   end) Z% g+ Z% B, U( u& L" G6 G+ f
  819.   #--------------------------------------------------------------------------
    2 T: `: }2 n7 N  \* v. i
  820.   # ● 更新光标
    6 u9 U; O1 E) C; H, d) F9 p& E9 G
  821.   #--------------------------------------------------------------------------: }0 H: s! m! x1 _
  822.   def update_cursor0 g3 A4 I8 j3 L' y3 o1 n
  823.     cursor_rect.set(item_rect(@index))
    8 ?0 t5 C1 ~. @' z- ?
  824.   end
    ! r9 \" D) q" K
  825.   #--------------------------------------------------------------------------
    8 R. D+ x) H4 C5 A0 u0 H' M6 }
  826.   # ● 判定光标是否可以移动' ~3 L% g7 u2 j4 h; @- P$ z
  827.   #--------------------------------------------------------------------------1 b- z4 @0 L4 W8 Y
  828.   def cursor_movable1 t. S& z# E- G1 E, X
  829.     active# M4 |8 u; Z; F. w  m) z, j( M
  830.   end
    + u. H: ^1 X8 }0 V; Y/ y5 i* P
  831.   #--------------------------------------------------------------------------4 a2 r# v5 G0 J2 ]% ^7 E
  832.   # ● 光标向下移动
    : R# {9 x+ n1 q3 r: ?' ?
  833.   #     wrap  允许循环' F( K3 r. k- ?$ D# @
  834.   #--------------------------------------------------------------------------
      X+ ]. f3 o4 b
  835.   def cursor_down(wrap)' ~( a: w! K% {5 `+ d6 j+ H6 d
  836.     if @index  9 or wrap: C/ r, p$ B8 Q8 |
  837.       @index = (index + 3) % 12
    , M: s6 s8 ^. p  [
  838.     end
    & i3 H$ y; c. _# ]* r" {- k6 ?
  839.   end* L0 a8 I7 A4 g/ |
  840.   #--------------------------------------------------------------------------: Q8 v  `) e6 u, b. a+ j" `- J
  841.   # ● 光标向上移动  B3 I. z' ~  B: x% n3 l
  842.   #     wrap  允许循环
    , h& ]5 f4 R/ R- g
  843.   #--------------------------------------------------------------------------0 Q9 m$ K" y8 j; T9 Z
  844.   def cursor_up(wrap)
    ' V& M  q0 [% v( Y' ]; P
  845.     if @index = 3 or wrap! O2 B4 i) `+ x" J1 Q
  846.       @index = (index + 9) % 12
    ) U( p" T1 ?4 a, I
  847.     end% o/ N- _) n' J& v# X
  848.   end
    * @) m# F2 M+ p2 p
  849.   #--------------------------------------------------------------------------
    ; Y6 d" y: _" T5 [! S- ~+ K
  850.   # ● 光标向右移动# v! f. `8 s$ a3 K- ^& V2 [
  851.   #     wrap  允许循环
    - T/ X' ~7 N! ]( R
  852.   #--------------------------------------------------------------------------. S$ K. l0 c: j8 B; t
  853.   def cursor_right(wrap)
    7 ^: o% p! M/ Z. R. o1 P9 k
  854.     if @index % 3  2: D) _# E; w( g0 z. V
  855.       @index += 1. B& U' C' }  {
  856.     elsif wrap
    9 z4 h6 @' A+ ?( N& n( `
  857.       @index -= 2; O( u, m0 `9 m. K  T3 f
  858.     end9 o  o/ t# g# P2 n9 Z
  859.   end
    " P' [9 E9 {2 K' E
  860.   #--------------------------------------------------------------------------
    # e* }  R" |" a; U- }5 Z* o
  861.   # ● 光标向左移动
    4 X3 y# o9 Z  B
  862.   #     wrap  允许循环
    6 a4 B* A# T2 ?* g# ^2 d
  863.   #--------------------------------------------------------------------------
    0 {' u3 \0 _1 y7 T& v% s5 h. w. o' Q+ x
  864.   def cursor_left(wrap)1 s1 P  e. w9 \  r9 ?4 Q8 O
  865.     if @index % 3  0
    ) I6 O6 g8 H: d7 M- W+ F
  866.       @index -= 1
    . n$ w( R5 F) e1 M' ~" i6 t8 r
  867.     elsif wrap
    ' J% J' t5 M, t
  868.       @index += 2
    $ [2 N3 O2 e/ l8 g- l
  869.     end: d4 i& c, x! _9 L
  870.   end1 Z) r) U, M3 v" `7 l: t' ?
  871.   #--------------------------------------------------------------------------
    8 e! |; C8 v0 b4 a: D* A
  872.   # ● 处理光标的移动
    9 o1 a" B; ~6 T, v* s  X
  873.   #--------------------------------------------------------------------------
    1 h: V' i( S# E/ j
  874.   def process_cursor_move
    + N2 V9 a6 m5 v$ o) I2 C: v6 }# I
  875.     super
    ! d; I8 i. s* v' I0 e
  876.     update_cursor2 L- {2 D  @5 m) l5 Z/ L% X6 z* T
  877.   end
    ' M2 ^' O9 |. p
  878.   #--------------------------------------------------------------------------) W- _2 V+ K5 O3 k) e
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    , C; |! r. G- ]6 y4 x8 R, [
  880.   #--------------------------------------------------------------------------
    . c( w4 @/ n3 j, X! [
  881.   def process_handling
    . |4 F! O' i6 p% X
  882.     return unless open && active8 h! G( q) A2 G; a, p3 c* C5 ^/ B
  883.     process_jump if Input.trigger(A)( r1 r! P$ X: `
  884.     process_back if Input.repeat(B)
    " t, b# }5 N  w" B
  885.     process_ok   if Input.trigger(C)% p/ h/ S1 W; f
  886.   end) {8 p# g% b, x/ l/ e$ H/ g
  887.   #--------------------------------------------------------------------------
    - W% T) e9 B( M# {! |
  888.   # ● 跳转“确定”
      O# j! t* w  U3 q; M
  889.   #--------------------------------------------------------------------------: h, R6 L% X5 j6 {/ m" l6 W
  890.   def process_jump
    & _8 a4 q. ^% V& ?
  891.     if @index != 113 E( m. q' O1 X7 S( V1 U
  892.       @index = 11
    $ T+ @* T! h3 d; a
  893.       Sound.play_cursor% T$ `6 h+ I9 J0 W3 J
  894.     end9 T" ?1 y7 ^, \
  895.   end: ]. ^- T8 O+ t$ J! d
  896.   #--------------------------------------------------------------------------
    + R5 F% x) E; m  @! f
  897.   # ● 后退一个字符- V- C4 t4 d9 J) a7 `/ a' e' K
  898.   #--------------------------------------------------------------------------3 g# }1 M& Z" Q. Y9 ^
  899.   def process_back
    " o4 E; P6 o3 }& ~; T' [  R( ^  O% y
  900.     Sound.play_cancel
    $ m; `. N) n( T2 p0 C+ F/ a$ }
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    - s! W6 h  v# B/ ~( |: {
  902.     n = (@number  place) % 10- A/ p4 A0 Q/ @2 E% [% w  K' N( T$ K
  903.     @number -= n  place- C- }) K+ e# L# ]8 D0 D* b
  904.     @number_proc.call(@number)
    2 k7 a1 r1 o. G1 G8 o8 d' R8 g
  905.     @old_window_index -= 1 if @old_window_index  0
    " l9 W6 S  A8 R
  906.     @index_proc.call(@old_window_index)# O1 h- ?" ~. ]) E1 o
  907.     @refresh_proc.call
    ) {0 ~$ \7 d0 @* [! u! q
  908.   end) _$ P8 G( _& ?- C. L1 J
  909.   #--------------------------------------------------------------------------
    , j  L/ i' H& S3 k: p. D
  910.   # ● 按下确定键时的处理3 z! ]# {: _. e/ |  @5 T
  911.   #--------------------------------------------------------------------------5 m5 k& s/ m! W4 J* H, d( B
  912.   def process_ok0 \8 E- ]  o7 W. C8 c9 ]
  913.     if get_number- a/ m( U) u/ }; d. g# I6 F- d
  914.       Sound.play_cursor
    6 k5 S0 U: G/ D
  915.       place = 10  (@digits_max - 1 - @old_window_index)' R* W5 ^, ?5 \/ d& l$ h
  916.       n = get_number - (@number  place) % 105 S  M: g7 V: y$ F8 j9 |
  917.       @number += n  place
    ; {) L( r" N. e" }
  918.       @number_proc.call(@number): E2 v- V6 Y1 u# `1 a' r/ {4 e
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1" ]$ Z5 V% i& T3 B: ?9 N
  920.       @index_proc.call(@old_window_index)+ o* S, C/ _6 t# Z! H, r) k
  921.       @refresh_proc.call1 P5 Q. a+ o; u6 V# \' n  T( [
  922.     elsif is_delete
    : E2 b. A2 t! U
  923.       process_back. C7 `1 U6 i  \. P$ A! A
  924.     elsif is_ok
    ' U; a2 H3 t" R
  925.       on_input_ok: a: N; l" O# g. X) I4 q
  926.     end
    ! e! L/ S2 x! [# w0 {$ J
  927.   end- t: h; @0 [; J2 I0 |4 `/ y8 t
  928.   #--------------------------------------------------------------------------0 W# Z1 T5 b: K& Z- [
  929.   # ● 确定
    ( C6 R. o8 |& f* B4 u- d' j
  930.   #--------------------------------------------------------------------------2 f' q, ^" A: m, W, X
  931.   def on_input_ok
    . e: S5 y6 W  |2 ?8 Q9 ]: \0 N
  932.     @index = 0
    - Q3 w0 ~' F7 X2 p5 ?5 `' e
  933.     @old_window_index = 0' R( J* \, L+ r( x
  934.     $game_variables[@variable_id] = @number
    + n/ Y6 J. i6 \& v
  935.     Sound.play_ok7 f  C7 |$ a5 H9 y) o
  936.     @close_proc.call6 m% Y4 `" C" P- d/ h3 }
  937.   end* I/ w2 M9 P1 C7 ]
  938.   #--------------------------------------------------------------------------
    + |* C) R7 K4 q4 @8 z' _
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置& r' c1 m& K. \- m
  940.   #--------------------------------------------------------------------------
    % Y1 I* N& ^. f! e4 Q; A
  941.   def set_mouse_pos
    6 n' k% n$ r5 L, J& a
  942.     if viewport.nil # necessary!4 M+ ^; E6 a0 U4 \+ R* B0 @
  943.       vp_x, vp_y = 0, 04 ]; F5 y! x; W# M; h- K1 w7 f" D
  944.     else" {% g4 P2 K2 V: _9 l$ X' t/ ^& d
  945.       vp_x = viewport.rect.x - viewport.ox
    ( [, y9 j1 i+ G. {# R. f7 [
  946.       vp_y = viewport.rect.y - viewport.oy
    " q/ D: j- A) v4 p$ o7 {
  947.     end
      P3 d4 N" D% E" _5 H7 T& r
  948.     item_x1 = vp_x + x + standard_padding # L9 N3 s! I7 U
  949.     item_y1 = vp_y + y + standard_padding
    ) u' c; R" w7 X' J
  950.     get_index = @index  0  0  @index
    5 C/ W5 ]! |7 Q6 C- B) f( z: R# `% p
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    , a! t7 M+ o2 b8 b  k9 l
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    : t, c, X8 I; @3 ]4 a4 M' _  s6 `
  953.     Mouse.set_mouse_pos(new_x, new_y)2 a* o. |8 Y4 x8 L0 q9 |4 @1 \$ ~
  954.   end
    ) x+ r* p7 }" r. l  D
  955. end3 ?6 G6 o3 ^* h- ?5 x
  956. 2 U/ [- N; D" M1 B
  957. #==============================================================================# `, O0 d. y, I4 s. [+ E3 F  \
  958. # ■ Window_Message
    $ f" }+ H+ L2 N9 n' F2 a
  959. #------------------------------------------------------------------------------4 o; a, @7 Z7 ~3 D; d/ j0 Z
  960. #  显示文字信息的窗口。6 i) }/ ~2 L7 D! u
  961. #==============================================================================4 D) s, ^; G5 k( J. n  o/ v; Y
  962. class Window_Message  Window_Base/ l' l8 H( ]9 _7 {5 c
  963.   #--------------------------------------------------------------------------
    ! Y1 ]- v. \) \+ I" f$ w
  964.   # ● 处理数值的输入(覆盖原方法)
    ' X+ C& K& V* _1 e# b/ m. n/ c, k
  965.   #--------------------------------------------------------------------------* P! n* a: `# [: h9 }
  966.   def input_number, Z, F1 U+ j# p$ V% s% ?1 q+ k
  967.     @number_window.start
    : y1 E7 ^: g- D: t8 |
  968.     Fiber.yield while @number_window.extra_window.active/ R5 Z( Q, [& \$ w
  969.   end
    3 s# @* @" K4 N' o' V
  970. end
    + n+ j9 p* s+ u
  971. 7 f) |. j1 l$ Y7 @* t
  972. #==============================================================================- Y- F4 j. m" Y/ Z7 Z, H
  973. # ■ Window_PartyCommand; ^& }! R( p" u5 G( ?
  974. #------------------------------------------------------------------------------
    9 |, j* t* N- t5 S! d4 u) G
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    - f  _( n* R2 X% @$ Q" B' e
  976. #==============================================================================
    0 r! {) I7 l: H8 ^5 O/ E7 G
  977. class Window_PartyCommand  Window_Command
    ) B/ {# p! ]1 X5 }# K
  978.   #--------------------------------------------------------------------------
    % @9 i, w- b% q8 s
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置% F! v- c4 v. W9 v% n
  980.   #--------------------------------------------------------------------------
    / ]2 s! N8 O5 o1 d
  981.   def set_mouse_pos
    1 @) p- R+ `" q4 ]- ^" o7 r2 D
  982.     if viewport.nil0 d  P) x6 Z8 P6 z8 ]: W, U( H; ?
  983.       vp_x, vp_y = 0, 0# M6 t! S3 G  e1 t
  984.     else9 _2 d. a' n9 |; N4 @; ^
  985.       #vp_x = viewport.rect.x - viewport.ox4 R7 k0 `& f: z& ~5 L, E8 b5 q
  986.       vp_y = viewport.rect.y - viewport.oy
    + F1 ^5 [& h0 g6 a# @7 H4 p9 `+ m+ f
  987.     end
    * E5 d$ Q! r2 x. |9 a
  988.     item_x1 = x + standard_padding . J  l, X# T0 {; P9 I/ E% i$ `
  989.     item_y1 = vp_y + y + standard_padding% k8 d2 ]2 @5 j  a2 `! w
  990.     get_index = @index  0  0  @index 9 k' J1 ?. n4 Z  J' ]
  991.     row = get_index  col_max - top_row
    " N/ M) x0 J* ]" U2 G" ~
  992.     col = get_index % col_max8 M; l% X6 m) X, @7 M& \; M& L
  993.     new_x = item_x1 + item_width  (col + 0.5)2 l: U" N3 }+ @6 S
  994.     new_y = item_y1 + item_height  (row + 0.5)3 H1 Z& ?7 }. z0 j- X' c
  995.     Mouse.set_mouse_pos(new_x, new_y)
    ; ?. t! u, @. _5 ]+ g3 i
  996.   end6 @4 a' C# v9 g% B
  997. end
      P. [6 ]4 j' j4 K- ^8 ?( L- R
  998. " S( {/ a- v6 q
  999. #==============================================================================% t6 }  z5 G: ?1 Q! M" c9 O. r6 x
  1000. # ■ Window_ActorCommand
    + v* Y6 H1 G3 g5 _6 I3 |# b
  1001. #------------------------------------------------------------------------------
    2 Z6 c. n( q9 h  C) {3 s/ w$ N' G
  1002. #  战斗画面中,选择角色行动的窗口。
    6 C, {; B) ^, i  Y; N! j/ f
  1003. #==============================================================================( b8 A+ X& K, {" X
  1004. class Window_ActorCommand  Window_Command+ d9 W- T: [: w
  1005.   #--------------------------------------------------------------------------
    " A. k/ n8 S  X+ Z$ o
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置, n  b& H1 v2 v: w; l; V
  1007.   #--------------------------------------------------------------------------8 R9 X% _; O7 h
  1008.   def set_mouse_pos  B! a- T8 I  t; R
  1009.     if viewport.nil
    4 ?2 m, [9 D/ @8 N6 }' a
  1010.       vp_x, vp_y = 0, 0
    ) C! K5 ^/ q# x# m- k7 \
  1011.     else
    8 U" M& ~& h, N: Z  Y2 P
  1012.       #vp_x = viewport.rect.x - viewport.ox" q4 u. ]  F6 c, `  t& Y9 A# C# ]
  1013.       vp_y = viewport.rect.y - viewport.oy/ o: V, m. N: l
  1014.     end
    & x* D7 j  u% r- t
  1015.     item_x1 = Graphics.width - width + standard_padding, V1 Q, `5 j/ }
  1016.     item_y1 = vp_y + y + standard_padding" n/ D, e' l% ~5 d% \* X
  1017.     get_index = @index  0  0  @index   C5 B3 N0 p- E( I/ ~- `- k
  1018.     row = get_index  col_max - top_row
    6 C  `' F* s& s+ y! x
  1019.     col = get_index % col_max% \/ C4 {, v# U
  1020.     new_x = item_x1 + item_width  (col + 0.5). d! ^9 o( p8 ^4 b  p5 }: O8 _
  1021.     new_y = item_y1 + item_height  (row + 0.5)6 i( }+ Q7 Q- R3 X5 y
  1022.     Mouse.set_mouse_pos(new_x, new_y)* T4 o* R) K( w% h
  1023.   end0 l( x( y' h( j- p. e
  1024. end
    6 u, G' ?$ a6 h5 {) r% e$ A' o
  1025. 7 @" _8 p4 P( Z4 i5 h
  1026. #==============================================================================
    6 v2 D+ _" {* p5 e3 h. |" E: M
  1027. # ■ Game_Player
    4 ]  W3 {2 f8 R4 L/ S
  1028. #------------------------------------------------------------------------------
    / s, r1 h+ s) R9 E$ W
  1029. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
    5 n6 [) a) u$ y7 J2 O. ~) u
  1030. #   本类的实例请参考 $game_player 。$ u& g) f* C0 z$ ^' t- t
  1031. #==============================================================================  M) r) `- X, N4 j9 I: j
  1032. class Game_Player  Game_Character. b: t. A  x8 J% g  ~0 v
  1033.   #--------------------------------------------------------------------------
    ( y  T8 ?4 O/ Y! m  Z& Y5 J5 d
  1034.   # ● 由方向移动(覆盖原方法)" x+ L( f& X* J5 A7 L, U! U  i
  1035.   #--------------------------------------------------------------------------$ {, y+ U1 P) a( C
  1036.   def move_by_input
    , n/ W" o9 z) b: h4 k, u* Y
  1037.     return if !movable  $game_map.interpreter.running  ]$ x# M9 x# t/ G. \
  1038.     if Input.dir4  04 b9 H' n: e: j! E0 @
  1039.       move_straight(Input.dir4)
    1 U; K) v; W/ ]) r$ G2 M
  1040.       reset_move_path
    ( o2 a9 Z3 }$ y' F9 n  \
  1041.     else5 l1 o* Z/ A% j
  1042.       move_by_mouse
    ' H5 i; c: P2 C3 Z% u; ^4 w& l9 n  o
  1043.     end; T; w3 c7 j1 G6 D$ ~  \6 v; }; h0 _+ q
  1044.   end
    2 V' \  ^/ F- U' O- S" n4 e$ r  T
  1045.   #--------------------------------------------------------------------------
    # y2 j: S* U, @
  1046.   # ● 非移动中的处理(覆盖原方法)0 P  W. f2 b" {/ G# |
  1047.   #     last_moving  此前是否正在移动
    0 X$ t- D$ t, ^' T6 o& [8 u- E1 N
  1048.   #--------------------------------------------------------------------------
    7 N8 N1 S9 |2 m* J% T1 f
  1049.   def update_nonmoving(last_moving)3 F# L( x% C- [1 i
  1050.     return if $game_map.interpreter.running; g1 I) J* H& i5 [8 q1 X& S) e( J3 o: ?
  1051.     if last_moving: z3 G1 ]! Y5 z: k% l5 f7 f) q
  1052.       $game_party.on_player_walk5 e- P" |) s6 f1 B4 z
  1053.       return if check_touch_event
    ' P+ k6 d9 c) t* ~  u0 e) C( B
  1054.     end/ ]( |" h( O2 v% k1 a
  1055.     if movable && Input.trigger(C)/ C! _; \/ X" r0 T4 |% C% g  ]
  1056.       return if Mouse.press(0x01) # 防止按下鼠标左键绘制路径时触发事件或载具切换9 e6 k" p" g* z6 m, B5 O- K
  1057.       return if get_on_off_vehicle
    ' S# x( i3 q: U) T* E
  1058.       return if check_action_event" R- F, |3 N; H6 h
  1059.     end0 r3 M$ ]+ _# B$ @
  1060.     update_encounter if last_moving
    - [1 q- [8 L* C& z5 M
  1061.   end
    . P- g2 Z7 ~& W8 V5 o
  1062.   #--------------------------------------------------------------------------) |6 l5 p) c1 v0 B, Q
  1063.   # ● 判定是否跑步状态(覆盖原方法)% ?" c6 m2 D; Y7 M0 U3 q
  1064.   #--------------------------------------------------------------------------; n$ ?2 B9 S- J5 x% q6 @# ?; s
  1065.   def dash
    5 G' v2 n; m5 W' i
  1066.     return false if @move_route_forcing
    9 S% q, I- W+ u9 ?2 L# C
  1067.     return false if $game_map.disable_dash
    ) ?& D% y7 G' r6 r9 E# n
  1068.     return false if vehicle5 _2 q1 ?: T5 O7 N  \: a, E- h9 c
  1069.     return Input.press(A)  @mouse_dash
    0 `1 B& O: Q, d
  1070.   end
    : d! {9 l. K  t' {5 A$ N
  1071.   #--------------------------------------------------------------------------
    ; G8 A1 `6 b* \! y9 F/ v' t/ ?
  1072.   # ● 初始化
    ! N) I/ Z7 `6 J, q7 \# j: |& M9 |
  1073.   #--------------------------------------------------------------------------0 j" @' |7 z. H1 B4 c! }! s# \" k6 s
  1074.   alias sion_mouse_initialize initialize
      p& H0 P" K2 [0 k9 {" ]
  1075.   def initialize
    4 @! z6 q4 `3 [" Y: Y9 p! [  o
  1076.     sion_mouse_initialize& ?) S0 g% P, k$ I/ E
  1077.     reset_move_path
    . _% V# ]1 P4 |( _
  1078.     @moveto_x = 0
    ; e  Y" G# ^" F+ W  |
  1079.     @moveto_y = 0
    , s" p! y0 i/ a- a
  1080.   end  k2 U1 _5 W5 `
  1081.   #--------------------------------------------------------------------------5 n$ l8 [! y; g3 Z
  1082.   # ● 更新4 ?8 {! o6 t! y! t, i
  1083.   #--------------------------------------------------------------------------6 l* Z  H5 t  [7 K2 G; s6 Y
  1084.   alias sion_mouse_update update
    7 Q% z/ _3 X6 v/ b8 K; _8 X
  1085.   def update6 s. u& g0 U- @# T
  1086.     sion_mouse_update* n% _0 Y/ e9 v7 r7 I% H( D: R9 |
  1087.     clear_unreachable_sign
    , R8 V6 N$ z2 Q$ T& w( h# d. h
  1088.   end- f- g2 }( u6 z; d6 T! ^7 G
  1089.   #--------------------------------------------------------------------------
    2 u# e$ E$ ~' q8 m- w  o( @
  1090.   # ● 处理卷动
    / a" }1 X" m2 E$ z2 b' k8 R
  1091.   #--------------------------------------------------------------------------* I( o3 c9 r8 R' N% x0 _# w
  1092.   alias sion_mouse_update_scroll update_scroll
    9 _4 G2 q# K7 ~7 O
  1093.   def update_scroll(last_real_x, last_real_y)
    / Z" _3 _9 V! x2 d# ~8 [0 I3 }* d
  1094.     return if $game_map.scrolling
    # e5 g/ r) U! k+ G
  1095.     KsOfSionNew_Scroll  new_update_scroll
    6 \3 }' [' _6 \7 z% F  n
  1096.       sion_mouse_update_scroll(last_real_x, last_real_y)( K9 c+ C5 y- e! h" C6 Y2 t5 e
  1097.   end
    ) c' D, Z+ J- |' H
  1098.   #--------------------------------------------------------------------------+ T2 U# Z: }7 A: b& u# y; A5 ~
  1099.   # ● 重置移动路径相关信息0 ~4 s9 U' o1 u; f" O8 ]- ^
  1100.   #--------------------------------------------------------------------------
    5 z' M' J$ I% D& z/ j2 [* T6 u# p. F
  1101.   def reset_move_path, \" I* S% A; `* O( W
  1102.     @mouse_dash = false! w( o7 K+ a9 B; A1 Q' H7 B" R
  1103.     @mouse_move_path = []- o  l. A& T) B% m7 C. I( o
  1104.     $mouse_move_sign.transparent = true
    0 J9 o) u/ d+ x! B" e' \7 A
  1105.   end
    0 Q8 d$ U6 X; z( ], T6 C* i
  1106.   #--------------------------------------------------------------------------% s0 b( k) F5 G- Y& y# z
  1107.   # ● 新的卷动地图方法
    6 r( e8 ?4 A* c' H
  1108.   #--------------------------------------------------------------------------' Z. u5 K( K) L7 \" z1 t
  1109.   def new_update_scroll, ^& j4 i0 D* D8 `
  1110.     horz_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.width
    & T# F* w; T" S& y$ T9 D
  1111.     vert_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.height! x2 O' y" i) r! w, O% D
  1112.     ax = $game_map.adjust_x(@real_x)
    + o& k! H* c& L( z& B1 V; b# T
  1113.     ay = $game_map.adjust_y(@real_y)7 S1 f8 K. ~; L
  1114.     $game_map.scroll_down (vert_speed  (ay - center_y)) if ay  center_y0 V+ N2 `0 a- ]5 p8 u
  1115.     $game_map.scroll_left (horz_speed  (center_x - ax)) if ax  center_x
    % R9 n4 h2 \5 g% a4 q- A
  1116.     $game_map.scroll_right(horz_speed  (ax - center_x)) if ax  center_x
    ( l5 b# a  {5 \& q- q9 Y7 v
  1117.     $game_map.scroll_up   (vert_speed  (center_y - ay)) if ay  center_y
      l# h0 Z* u! D. A
  1118.   end8 z# p% s* b/ s8 s; e! u
  1119.   #--------------------------------------------------------------------------- o6 Y! q" C/ a" w9 J, X" X9 [: W
  1120.   # ● 消除不能抵达图标6 U' F, D. {/ T" c- B9 x9 P
  1121.   #--------------------------------------------------------------------------4 g1 ~; Y) K  Q/ K
  1122.   def clear_unreachable_sign
    $ ^& y$ G6 q0 l! e9 A( `$ k7 K
  1123.     return if Mouse.press(0x01)! t7 v0 T8 Q5 C& ?6 ^$ h
  1124.     if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 0+ q( o) b! m" y1 |, ?" G
  1125.       $mouse_move_sign.transparent = true
    # W0 T( H$ N4 ?
  1126.       $mouse_move_sign.direction = 2
    ; Y; R- P9 B# n  r" c! I: ~
  1127.     end& d2 }5 @2 e' Q1 I" T; Y: B; Y
  1128.   end
    - ^4 ~& p9 J* Q. P
  1129.   #--------------------------------------------------------------------------4 q: ?7 _5 v" }% j
  1130.   # ● 由鼠标移动9 D; l: S: Y9 ?
  1131.   #--------------------------------------------------------------------------
    $ C# J& q! M+ j% P) L, n$ _" q3 R
  1132.   def move_by_mouse
    0 Y3 j$ q% _" B3 ]" @4 {
  1133.     unless @mouse_move_path.empty # 移动路线数组不为空则执行移动
    ( g- C$ K9 b2 n
  1134.       dir = @mouse_move_path.shift4 F  o6 a  s+ l+ I5 G3 M
  1135.       if passable(x, y, dir) && !@mouse_move_path.empty2 U& P0 e: C$ r  c, u
  1136.         move_straight(dir)( s. z# X. T/ z+ Z. W2 |; Z( J
  1137.       elsif @mouse_move_path.empty # 判断是否是最后一步2 a  N  O5 N' ?
  1138.         x2 = $game_map.round_x_with_direction(x, dir)
    * {/ k* U2 ]3 \1 X2 `% e, ^
  1139.         y2 = $game_map.round_y_with_direction(y, dir); s8 `+ h5 U& n' G1 U7 A1 G% f* ]
  1140.         move_straight(dir) unless dir.zero, r5 c: A/ d$ E& Q, s( o
  1141.         unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具5 ^" P2 |1 n% p. H
  1142.           check_event_trigger_there([0,1,2])9 t# @& w9 {$ {6 r! x
  1143.           get_on_off_vehicle unless $game_map.setup_starting_event
    ! ^% q  h; b% {; j. U
  1144.         end2 ^( P! n/ V. k$ h" w5 Z
  1145.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2
    : J1 Z6 g5 H" q. @
  1146.         @mouse_dash = false6 P6 s0 E, o8 d2 j* c
  1147.       elsif @mouse_move_path[0].zero # 目标点无法抵达,调整朝向→目标点8 ~& t) X; o4 b# t9 Z
  1148.         @mouse_move_path.shift" n0 y6 j) q* `* W5 J) e: U  T  n
  1149.         @direction = dir
    / N" c* u% v, F9 @& e
  1150.         @mouse_dash = false
    ; {2 l; O7 R+ k2 X6 \" b% ?
  1151.       else- X, b" W2 J$ \% z1 b! S2 C# w6 p
  1152.         draw_move_path
    & C! M( Z; J7 z2 J
  1153.       end; y, f7 \/ Y+ J& a2 P4 S8 w
  1154.     end& g, D1 f- A9 v- [. ?1 H4 n
  1155.   end
    5 k* w4 p! l+ E. N
  1156.   #--------------------------------------------------------------------------
    # Q! U) q! a! L& V' w# L6 T  E
  1157.   # ● 地图界面按下鼠标左键的处理
    0 Q0 U: I+ s* _! A3 A! o/ j
  1158.   #--------------------------------------------------------------------------
    : Z- S: @- V) H+ e: M/ j' E
  1159.   def left_button_action( F2 t6 U! w  A& O/ b3 G, v7 V3 y
  1160.     return if !drawable  $game_map.interpreter.running
    # j1 n1 ?1 j3 B* U) @2 A
  1161.     get_mouse_pos" Q  q# U6 Y" Z& X4 w; L4 a
  1162.     $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图, ~+ i5 F( y4 K: ~/ K6 ?: D
  1163.     if @shift_event
    * G, ~. Y- L$ K- o- n$ x
  1164.       if Mouse.trigger(0x01)
    8 B. ]2 O& \. N  V" [; T" p8 p8 A
  1165.         @shift_event.jump(@moveto_x - @shift_event.x,3 Y% R& l4 P7 m/ h3 |; X1 s0 C
  1166.           @moveto_y - @shift_event.y)4 Q5 A0 U' x! b
  1167.         @shift_event = nil
    4 J* ~# S1 t% u# Z3 {6 E
  1168.       end3 E! E* @* T! w; A! \
  1169.       return! X% \7 D1 T' c1 q
  1170.     end; P8 d" w+ i+ B% k6 t: Y2 p
  1171.     if @moveto_x == x && @moveto_y == y # 判断目标点是否与角色重合
    6 ^. T  |" `0 O- `0 b# S% w* d
  1172.       return if moving  (vehicle && !vehicle.movable)+ {" e5 H5 O" x# C; M6 H
  1173.       check_event_trigger_here([0]) # 判断是否触发重合点事件7 L5 r% b4 i% ]5 d+ _4 X7 s
  1174.       get_on_off_vehicle if !$game_map.setup_starting_event && % _) ^, }; h9 C5 M
  1175.         $game_map.airship.pos(x, y)  # 判断是否要上、下飞艇! e: D4 p  ^# V6 k" d
  1176.       return, r) a* U6 Z, ^4 }, P
  1177.     end
    $ H/ |- D. |- b6 T
  1178.     # 判断是否用鼠标启动事件1 h5 Z+ Y8 O0 C5 j! T
  1179.     $game_map.events_xy(@moveto_x, @moveto_y).each do event! e3 P+ b- I; V
  1180.       if event.mouse_start
    - p& T( d2 V) d7 y
  1181.         reset_move_path
    4 d9 c# B  }* z( ^; i2 T+ |9 y
  1182.         event.start if Mouse.trigger(0x01)( N1 U9 l/ Q: J3 n
  1183.         return$ M8 }% i; ^* g+ j( b5 H
  1184.       end
    4 P8 t7 ~. I1 G& M! |( P1 }' N$ P
  1185.     end# a7 g! o" o! `
  1186.     @mouse_dash = true if Mouse.double_click # 双击冲刺
    - u. z5 `4 w5 K7 }' v2 l5 s
  1187.     return if Mouse.left_state % 10 != 1 # 按住鼠标左键10帧绘制1次路径% \& I/ q$ k, Y
  1188.     for i in 1..4 # 判断目标点是否为角色周围四点8 F7 |7 I; Y4 A5 I. c/ c+ O! P
  1189.       if x == $game_map.round_x_with_direction(@moveto_x, i  2) &&7 Y8 R. u) ^# W7 S0 G+ t. D
  1190.          y == $game_map.round_y_with_direction(@moveto_y, i  2)& y6 P0 k: x& t  c5 o) _
  1191.       $mouse_move_sign.transparent = true
    ( U8 |' z" j' Y7 b
  1192.       @mouse_move_path = [10 - i  2] if Mouse.trigger(0x01)$ }& m: Z7 _0 `% P8 U, T3 O
  1193.       return; end& U1 U: q4 y9 X
  1194.     end  d/ p4 j# h1 g. E( X" f+ e
  1195.     draw_move_path
      _' c& h# h9 U/ k7 F
  1196.   end. u6 `  H1 h/ J4 Q
  1197.   #--------------------------------------------------------------------------7 A: q8 F! W) M# y+ c1 Y" v0 r
  1198.   # ● 取得鼠标处对应地图坐标点- d4 r0 d' J- C5 z- M
  1199.   #--------------------------------------------------------------------------
    5 P4 \; W# Q3 q1 h6 g- d% V
  1200.   def get_mouse_pos
    9 V, |$ l, V: r
  1201.     $game_map.get_mouse_map_xy3 j/ @# Y) D$ ^' F( A/ Z
  1202.     @moveto_x = $game_map.mouse_map_x, G) L/ U3 Q7 r4 e5 u# u! i3 W1 I
  1203.     @moveto_y = $game_map.mouse_map_y
    - [# N, a8 w+ X
  1204.     #mouse_x, mouse_y = Mouse.get_mouse_pos$ y, X7 t- T& I' D2 a
  1205.     #@moveto_x = $game_map.round_x(x + (mouse_x - % b% P2 G7 k& L& t
  1206.     #  ($game_map.adjust_x(x)  32 + 16).to_i + 16)  32)& L  a! R6 h; @/ z" W+ j/ \
  1207.     #@moveto_y = $game_map.round_y(y + 1 + (mouse_y -; T$ U# m7 ?7 Z; e" ?0 h3 j
  1208.     #  ($game_map.adjust_y(y)  32 + 16).to_i - 16)  32)
    ! z  g; {' |" d6 s2 l* l6 O$ f! u
  1209.   end
    6 I8 b: D% ^' B5 j% B  S6 w
  1210.   #--------------------------------------------------------------------------* L4 H+ v9 O* E1 U. r4 `4 u
  1211.   # ● 绘制移动路径 @array[move_directions...]
    6 C$ ?3 {' r8 o- x$ P4 s
  1212.   #--------------------------------------------------------------------------/ k: _/ ]* |5 f0 |% ~: |
  1213.   def draw_move_path! E4 [0 W' G; o7 C* P3 J- c
  1214.     #temp = Time.now8 ]& B9 b& u! R8 L' [2 v0 y6 N4 s
  1215.     case @vehicle_type. ?9 S9 N( h2 P; T- L: o9 Z
  1216.     when walk5 J7 ]7 L+ i" ]/ d
  1217.       draw_walk_path
    7 N; R! Y: b% `# P
  1218.     when boat
    5 m8 p) o* Q. n0 b' S8 U
  1219.       draw_boat_path
    $ A  _7 N- R' v
  1220.     when ship8 y/ L- y6 i! B0 u2 v
  1221.       draw_ship_path
    * F: A' q) ]2 k9 s3 E$ J
  1222.     when airship
    ( v( i7 Y2 ~& y# h, \% j% V$ Y
  1223.       draw_air_path6 M" t* Z9 z2 l# V- ]& ~: ~  O  ?% d
  1224.     end
    / R3 A) C+ K+ p" C
  1225.     #p (Time.now.to_f - temp.to_f) # 测试效率
    / Y; f& [& y3 X" W5 r
  1226.   end1 c7 c, T7 s# }' n' z
  1227.   #--------------------------------------------------------------------------
    ; m4 V* j7 L( F% i$ T
  1228.   # ● 判定是否可以绘制移动路径
    / y( c; u" N0 Q3 U; c4 W8 U
  1229.   #--------------------------------------------------------------------------
    ' w" P: u9 i1 n1 t/ b  q- m5 Q. t
  1230.   def drawable
    " I2 K. F( U7 v, G+ ~) Z. P5 ~
  1231.     return false if @move_route_forcing  @followers.gathering
    - }* H1 Z7 z" o6 T4 ?- ?8 v
  1232.     return false if @vehicle_getting_on  @vehicle_getting_off4 B5 b: H2 Y  j6 e; A0 Z, e
  1233.     return false if $game_message.busy  $game_message.visible
    ; ~* g" L( Q  i, R/ m
  1234.     return true# ?5 \1 {- K; }$ C8 @; d: S; L
  1235.   end' ?3 ^, G3 O6 ~5 `3 M
  1236.   #--------------------------------------------------------------------------
    " ]1 W3 l0 {5 q5 N5 r4 h
  1237.   # ● 绘制walk移动路径 @array[move_directions...]
    . X- y$ D2 U0 B4 l3 d
  1238.   #--------------------------------------------------------------------------
    $ S: g" \0 f2 p
  1239.   def draw_walk_path# X! J; c$ m) S  l" @" a0 @0 r0 Y
  1240.     # 准备绘制路径表格
    " {, i$ y: I) i1 T
  1241.     sheet = Table.new($game_map.width, $game_map.height)
    : \( Z3 b, W% H
  1242.     reversed_chase_path  = []; chase_path  = [], c; v# r1 V( C" ^' }+ }3 f1 H
  1243.     reversed_chase_point = []; chase_point = []4 Q8 {* \+ x% m9 m# I1 o" a
  1244.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
    $ J8 N4 o" @$ G# {& U3 U( f3 y
  1245.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2/ A6 d$ ?4 q9 Z7 d
  1246.     reach_point = false) h3 j" p6 \$ |2 h
  1247.     step = 3
    + E, q/ e4 V/ `
  1248.     loop do #loop1 开始填充表格: K! H; Y1 }6 x9 O
  1249.      draw_path = false! O/ H" c' g. h$ p& j: [* @+ y
  1250.      check_points = new_start_points, ?% P$ L0 B) [3 @6 C2 g
  1251.      new_start_points = []
    ! P  C4 H' d, E/ w, H; S! I" C+ e1 `
  1252.       loop do #loop2 从起点开始正向填充5 `2 v$ u* \! c" E& w8 V9 G
  1253.         point_x = check_points.shift
    0 L  {9 i7 ^, o! \# @
  1254.         break if point_x == nil
    ; F2 m$ p* m1 n  r- x' \
  1255.         point_y = check_points.shift- `1 ^' S6 ]2 e$ i# H1 I
  1256.         left_x  = $game_map.round_x(point_x - 1)
    % T& m; W4 X% h" O  ?1 O
  1257.         right_x = $game_map.round_x(point_x + 1)
    - P! v& @+ V# m$ M' s' ~
  1258.         up_y    = $game_map.round_y(point_y - 1)
    8 H# u. R& q2 t8 _& p  c0 m1 K
  1259.         down_y  = $game_map.round_y(point_y + 1)+ T1 i2 D6 C( ~; e0 ]% Y# C
  1260.                     # 判断路径是否连通7 {: D4 {! y% A9 @; c3 R" h
  1261.         path_step = step - 1. w3 D- g, B# [2 C
  1262.         if sheet[left_x, point_y] == path_step     &&/ @" n; v6 `& D1 J& y' n9 i
  1263.            $game_map.passable(left_x, point_y, 6) &&
    : }. z6 w5 G8 ^' C3 |4 c9 C! l
  1264.            $game_map.passable(point_x, point_y, 4)" [6 S$ m; s& T5 t, k" S1 I3 \
  1265.           chase_path.push(4)
    4 l( k( F- q' }7 a
  1266.           chase_point = [left_x, point_y]0 [" `* r9 C& h5 T$ F6 ^
  1267.           reversed_chase_point = [point_x, point_y]
    , U1 E: ]. v% }! g/ A7 P, L
  1268.           reach_point = true; break! B! ?" h5 c7 }
  1269.         elsif sheet[right_x, point_y] == path_step     &&+ f! N1 j- S2 ^2 v1 @- ]0 n  b  S
  1270.               $game_map.passable(right_x, point_y, 4) &&
    3 e3 y8 b' n$ \" U$ U! P! g% K8 C
  1271.               $game_map.passable(point_x, point_y, 6)
    / O2 a8 |& C; N
  1272.             chase_path.push(6)/ R) M1 ?- f4 m' [, v6 y0 M
  1273.             chase_point = [right_x, point_y]: _1 z& \- K. Z
  1274.             reversed_chase_point = [point_x, point_y]0 Y6 h1 C$ j  I3 f* U
  1275.             reach_point = true; break1 j1 w( i3 @- T! g1 p. F+ R. e
  1276.         elsif sheet[point_x, up_y] == path_step     &&: U2 r5 E% s/ L
  1277.               $game_map.passable(point_x, up_y, 2) &&
    ; B+ R. M3 J2 C5 r
  1278.               $game_map.passable(point_x, point_y, 8)
      m- e7 v/ G! O* P
  1279.             chase_path.push(8)) l, W2 v' i/ Y! ~
  1280.             chase_point = [point_x, up_y]
    , P# s- @6 M) w" r6 I
  1281.             reversed_chase_point = [point_x, point_y]
    4 q( m2 [' n9 r) Y) y* z
  1282.             reach_point = true; break
    3 K8 f9 `9 I" r. u- q/ Q
  1283.         elsif sheet[point_x, down_y] == path_step     &&
    - l. I% P# `- G$ W
  1284.               $game_map.passable(point_x, down_y, 8) &&$ J. F9 }) a1 X# S# I) D8 h$ V1 x
  1285.               $game_map.passable(point_x, point_y, 2)2 J& u3 f2 [9 Z: z
  1286.             chase_path.push(2)% }# s& H0 W1 _) w! H5 q% c9 G6 }
  1287.             chase_point = [point_x, down_y]
    8 t  \8 K6 S' w1 o% k( R- ]1 U
  1288.             reversed_chase_point = [point_x, point_y]
    5 f* K9 x# N& W2 @) K, U" b
  1289.             reach_point = true; break+ r7 q! A% g9 |% {! h9 U
  1290.         end
    & H4 ]" D, @' @8 L7 A) E4 s6 x8 k- B) j
  1291.         # 以需要抵达该点的步数填充路径表格 #
    - i) H/ k0 l4 w3 x9 M
  1292.         if sheet[left_x, point_y] == 0              &&
    5 ~  b7 G; K& N$ ~( q8 B$ N
  1293.            $game_map.passable(left_x, point_y, 6)  &&. {3 n5 G3 [5 U; a, q
  1294.            !collide_with_events(left_x, point_y)   &&
    % d. w1 j+ t: R& L
  1295.            $game_map.passable(point_x, point_y, 4) &&
    ' W3 Y. n/ p% I8 R9 y. V+ R. K
  1296.            !collide_with_vehicles(left_x, point_y) #judge_end
    " @" D4 j* E9 ]8 O
  1297.           sheet[left_x, point_y] = step
    9 x9 @: y& b2 P
  1298.           draw_path = true) l; B! ^  b6 J0 d. A
  1299.           new_start_points.push(left_x, point_y)
    ( R$ |8 X9 q2 E& F2 I5 a7 r
  1300.         end' {1 e* F/ A( X! A9 P
  1301.         if sheet[right_x, point_y] == 0             &&
    % H$ o2 T4 R" ~$ ]2 b
  1302.            $game_map.passable(right_x, point_y, 4) &&5 |. C2 A; z, d" C7 O
  1303.            !collide_with_events(right_x, point_y)  &&4 j6 I. G' S8 L& \) J* W
  1304.            $game_map.passable(point_x, point_y, 6) &&+ D2 T7 F# p, f' J5 t
  1305.            !collide_with_vehicles(right_x, point_y)#judge_end3 H$ K1 t/ C: M
  1306.           sheet[right_x, point_y] = step
    9 f$ A- k! u$ x0 n9 ^
  1307.           draw_path = true' K( v9 n5 u+ g2 Y( q- [& o
  1308.           new_start_points.push(right_x, point_y), p) i2 r( f/ [2 ~8 j; k( p% @
  1309.         end
    # U& a. j& c4 b: j- c# ]; O5 P
  1310.         if sheet[point_x, up_y] == 0                &&. B$ P" m8 Y6 I* f5 B1 b
  1311.            $game_map.passable(point_x, up_y, 2)    &&
    3 m) l/ L# e- O( m& I
  1312.            !collide_with_events(point_x, up_y)     &&
    * O5 F' \" r2 O* ]
  1313.            $game_map.passable(point_x, point_y, 8) &&
    4 @/ ~% H# r" U* x. _/ d' i2 F% B
  1314.            !collide_with_vehicles(point_x, up_y)   #judge_end
    6 @4 n5 {3 S, ~5 s% a/ H& N
  1315.           sheet[point_x, up_y] = step  x/ p& I  s+ _# @+ O% Z& C0 f; C
  1316.           draw_path = true3 ^9 J, S2 T1 [1 K9 U' P
  1317.           new_start_points.push(point_x, up_y)  q. c9 I  B/ b1 h
  1318.         end2 j0 K# y9 ^* F# j+ k) N0 p7 p
  1319.         if sheet[point_x, down_y] == 0              &&
    8 _3 C8 `# f3 A  L1 z1 l+ B
  1320.            $game_map.passable(point_x, down_y, 8)  &&  ^) _: T; h8 X" R' t3 t- ?- J
  1321.            !collide_with_events(point_x, down_y)   &&
    5 X( Z* g+ i3 @; k  g! H6 A! U
  1322.            $game_map.passable(point_x, point_y, 2) &&& ?2 t2 ^% I; w2 P3 A
  1323.            !collide_with_vehicles(point_x, down_y) #judge_end) H% R" G3 ~. X6 ]4 |5 K& |
  1324.           sheet[point_x, down_y] = step* Q$ h2 |5 ?# {
  1325.           draw_path = true
    ! b) b6 j: b- m7 ~
  1326.           new_start_points.push(point_x, down_y)
    ' ~1 |9 L) Q3 B
  1327.         end! o2 ^7 s' ^$ K
  1328.       end#endOfLoop2. ^% Y9 `& r0 R" I6 o* T
  1329.       break if !draw_path  reach_point; H8 e# x5 T5 S. l8 Q3 Q% g% @
  1330.       draw_path = false+ w6 c9 E% D2 t& A- V
  1331.       check_points = new_end_points
    6 b. q# z2 i* E4 D, D: z" d
  1332.       new_end_points = []4 h: O0 p# f$ W% R4 h4 n4 M0 A, F
  1333.       step += 1
    ( f& ^, W, ~$ R
  1334.       break if step  KsOfSionBreak_Steps &&
    4 W; j/ u7 k7 [  n# v- ^6 b
  1335.                !Input.press(KsOfSionFind_Path_Key)1 [: R6 k* F3 N, |# o& J' n7 Z
  1336.       loop do #loop3 从终点开始反向填充
    & ~( w0 U1 |" |, I9 L, ?
  1337.         point_x = check_points.shift
    3 s% {! a5 v6 t1 g& ]8 ]- s
  1338.         break if point_x == nil
    0 [2 r9 N) d1 g& O
  1339.         point_y = check_points.shift+ _0 J6 m( g) Q, l
  1340.         left_x  = $game_map.round_x(point_x - 1)
    + z, e3 e5 G7 _6 e, K9 [
  1341.         right_x = $game_map.round_x(point_x + 1)" _1 J( e7 D4 ^$ p3 o, T) W& ]
  1342.         up_y    = $game_map.round_y(point_y - 1)7 M' F* D$ N: G( T
  1343.         down_y  = $game_map.round_y(point_y + 1)
    ; x9 F; h9 g4 G- K# }
  1344.         # 判断路径是否连通  M; s- F# {( m- d2 F8 P- W; a) {
  1345.         path_step = step - 1
    + \/ q6 v! N1 h: e& a% j
  1346.         if sheet[left_x, point_y] == path_step     &&
    + a3 h% V4 o4 u5 d% C
  1347.            $game_map.passable(left_x, point_y, 6) &&
    & p# H7 d+ ?. Z3 K* [4 Q& K( n( o
  1348.            $game_map.passable(point_x, point_y, 4)
    ; x1 q$ j8 P5 f) o
  1349.           chase_path.push(6)
    4 e- @" S/ e0 N6 W4 P0 f1 J* v) Y
  1350.           chase_point = [point_x, point_y]
    % f/ q# ^6 L* }$ @
  1351.           reversed_chase_point = [left_x, point_y]
    ; c" ?' j" S) v: U. C
  1352.           reach_point = true; break! C1 z0 E/ m9 n  U: {, j/ l4 z* B
  1353.         elsif sheet[right_x, point_y] == path_step     &&
      S0 K; r( F- c7 }
  1354.               $game_map.passable(right_x, point_y, 4) &&
    " l# `" f' R! `$ l0 `( r
  1355.               $game_map.passable(point_x, point_y, 6)
    8 }  n/ K4 Z8 B
  1356.             chase_path.push(4)
    2 Y* k: Q9 l# w, Z' w+ k+ \
  1357.             chase_point = [point_x, point_y]) [- p' G( [3 I: U# F( w; U
  1358.             reversed_chase_point = [right_x, point_y]
    + _+ h% C0 b  c1 H: U/ A
  1359.             reach_point = true; break
    " |3 X9 e7 n, p) N
  1360.         elsif sheet[point_x, up_y] == path_step     &&
    : p+ n( U' l# u8 b
  1361.               $game_map.passable(point_x, up_y, 2) &&
    3 J5 \/ c/ B/ m, r+ W
  1362.               $game_map.passable(point_x, point_y, 8)
    , b- a! y1 x" j( ~# n
  1363.             chase_path.push(2): W+ o! O5 y& {1 V, |4 b; w
  1364.             chase_point = [point_x, point_y]
    - ]$ f3 n; Z; N7 m6 ^& |
  1365.             reversed_chase_point = [point_x, up_y]
    4 u( E" d8 U- B1 b8 q6 q$ ]) l7 h* A5 x
  1366.             reach_point = true; break
    / \! v: @+ S; [0 ~1 F
  1367.         elsif sheet[point_x, down_y] == path_step     &&
    & p$ U9 f8 B6 H" M
  1368.               $game_map.passable(point_x, down_y, 8) &&7 ^+ Y; e4 e  r! U5 q/ D5 |! M; ^: P
  1369.               $game_map.passable(point_x, point_y, 2)/ l6 \$ e8 e$ }
  1370.             chase_path.push(8)
    / n" B1 V. |& G4 X
  1371.             chase_point = [point_x, point_y]
    : p( i0 _! Y/ Q. Y' ]6 r
  1372.             reversed_chase_point = [point_x, down_y]
    % Q( ]# M; }3 L0 t) a
  1373.             reach_point = true; break# V+ @2 x' S' D/ b0 R! b
  1374.         end
    . H8 a' f8 w& [! X( }8 n
  1375.         # 以需要抵达该点的步数填充路径表格 #0 u' b  [% X' e
  1376.         if sheet[left_x, point_y] == 0              &&
    , H* |: k' M# K, u
  1377.            $game_map.passable(left_x, point_y, 6)  &&4 ~+ w4 I1 q9 S4 G
  1378.            !collide_with_events(left_x, point_y)   &&5 d6 F/ ]( L- R1 k
  1379.            $game_map.passable(point_x, point_y, 4) &&+ X" E+ c" h7 V
  1380.            !collide_with_vehicles(left_x, point_y) #judge_end
    ! M; c, R3 D- y5 C% i
  1381.           sheet[left_x, point_y] = step1 j2 l" _2 i: _' j/ L3 D- V
  1382.           draw_path = true: B( V& a& e" k: k
  1383.           new_end_points.push(left_x, point_y)0 |- P. f2 O1 Z9 S
  1384.         end
    3 i3 H1 K6 e: d* X( B
  1385.         if sheet[right_x, point_y] == 0             &&
    2 m7 h  T- ~+ \8 ]. s) I1 r) h: n
  1386.            $game_map.passable(right_x, point_y, 4) &&1 D; g/ ~# V7 n3 y
  1387.            !collide_with_events(right_x, point_y)  &&6 V( o8 y  z; X
  1388.            $game_map.passable(point_x, point_y, 6) &&
    + Y- O) Q4 |# {4 r: G+ Y- r% @* o+ O
  1389.            !collide_with_vehicles(right_x, point_y)#judge_end
    4 q! C  p: Z  u
  1390.           sheet[right_x, point_y] = step
    4 w; C$ Y9 ?" [
  1391.           draw_path = true
    / V/ y' K: R  `' m
  1392.           new_end_points.push(right_x, point_y)% \2 K$ `+ c8 s$ O# s. W
  1393.         end
    ! u0 o; C; I6 L3 z/ }2 L) y' g: @
  1394.         if sheet[point_x, up_y] == 0                &&
    ( w' C6 X" d8 J3 ^* _$ {
  1395.            $game_map.passable(point_x, up_y, 2)    &&" p! @8 C, K6 n# h5 q3 e* J
  1396.            !collide_with_events(point_x, up_y)     &&/ \2 o8 U) c5 c2 O
  1397.            $game_map.passable(point_x, point_y, 8) &&. f+ X# X% X$ l1 j/ a
  1398.            !collide_with_vehicles(point_x, up_y)   #judge_end
    . d8 _, P" v/ M- N- p
  1399.           sheet[point_x, up_y] = step
    . u" o% U9 u: c9 G3 D. |3 f* b
  1400.           draw_path = true
    " M8 q" w5 I8 q) b' ^9 @# ^; D3 c/ y
  1401.           new_end_points.push(point_x, up_y)/ ~  N5 T: c  p9 i' p6 W
  1402.         end5 k) X( K. T( s6 F' Z8 U$ T
  1403.         if sheet[point_x, down_y] == 0              &&
    * ]9 d% v1 R2 W- G  y5 f! s
  1404.            $game_map.passable(point_x, down_y, 8)  &&
    3 y/ ^- `# |& F6 p* [
  1405.            !collide_with_events(point_x, down_y)   &&
    6 q2 N% }# m: {: }
  1406.            $game_map.passable(point_x, point_y, 2) &&
    # n3 b; O0 g/ M
  1407.            !collide_with_vehicles(point_x, down_y) #judge_end+ D8 A- [- a# I% W0 o# T
  1408.           sheet[point_x, down_y] = step
    , }3 j1 k" u. ?
  1409.           draw_path = true
    3 L/ J( X% w& ^2 S- I9 ~
  1410.           new_end_points.push(point_x, down_y)' I3 G7 m4 R, l* w! L, g3 v
  1411.         end
    ; c% o; q- I0 F2 R
  1412.       end#endOfLoop36 d7 Z" w8 w- A0 I; F
  1413.       break if !draw_path  reach_point
    ! O( O- }2 Z) R' ?
  1414.       step += 1# K# V, I1 K& G9 a( y5 s. E3 f; k3 v
  1415.     end #endOfLoop1 路径表格填充完毕
    ! ~# z  d3 ]- I1 o1 ~
  1416.     $mouse_move_sign.transparent = false
    * B3 ~3 |; t. {( [& _3 t5 \# s
  1417.     # 判断指定地点能否抵达
    / }0 u! y: y% f! w5 q# N5 ?( s
  1418.     if reach_point1 u( g0 U$ Y% ?; G5 w4 m! S+ A+ u. K
  1419.       $mouse_move_sign.direction = 2  t1 w( Y7 n1 Z- G( R% J
  1420.     else, J, U6 |3 q3 z& l
  1421.       not_reach_point, {2 |! g3 O; R  o2 j: R+ |; C
  1422.       return; g! x+ t1 o# K  T
  1423.     end8 R2 b3 q2 g- g* ]
  1424.     # 根据路径表格绘制最短移动路径(反向)5 R# u4 j0 K) f
  1425.     steps = step  2  2 + 1, s% t( \3 f8 q5 P7 s2 \
  1426.     loop_times = step  2
    , w1 p% i1 j  M4 \4 Y
  1427.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]( F) ]( v$ S6 Q0 T# a
  1428.     for i in 1..loop_times # forLoop
    0 C8 @+ [/ [2 ?) X) r- K$ L
  1429.     steps -= 2
    - F7 W- F' u. m  ~
  1430.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs #反过来?蛋疼了……" a8 a0 P$ n; ^2 c9 y
  1431.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    & z) N" I) S: y+ w
  1432.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&9 d9 I6 p* H: T( m! ]
  1433.             $game_map.passable(point_x, point_y, 4)                #judge_end
    ( E5 a2 P  U; H! i/ s% V5 l0 e2 m" d
  1434.         reversed_chase_path.push(6)2 F7 R' L  S, a$ G" g) v2 I
  1435.         point_x = $game_map.round_x(point_x - 1)- n3 M# T) X+ `  b, D1 o
  1436.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&, s7 V& w( ^& C; _+ ^% `
  1437.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&! R- k! R" g6 q  t/ Z  ?
  1438.             $game_map.passable(point_x, point_y, 6)                #judge_end
    5 \0 M! o  w9 w9 a  y4 I/ L4 s
  1439.         reversed_chase_path.push(4)! p4 {8 g5 R8 v6 Z- c  y- x3 g: ?' m
  1440.         point_x = $game_map.round_x(point_x + 1). c; S7 ^5 V0 }$ g% U1 d
  1441.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&1 P. r2 ]; V; q; l/ o% \
  1442.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    : X& |& a5 ?$ P) E/ z# o
  1443.             $game_map.passable(point_x, point_y, 2)                #judge_end8 l6 T/ P: A$ f5 Q2 j+ I- n# ^
  1444.         reversed_chase_path.push(8)" [9 h, C5 W& H" ?& n
  1445.         point_y = $game_map.round_y(point_y + 1)
    * B& d1 R, C" v8 k  t/ u
  1446.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    3 Y" N  v7 w- P- u
  1447.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&4 j. A9 @+ g0 X  v1 ^
  1448.             $game_map.passable(point_x, point_y, 8)                #judge_end. x+ G5 M% R) {: }, S% u
  1449.         reversed_chase_path.push(2)
    , {. r+ x1 z3 b! F% }8 p7 m
  1450.         point_y = $game_map.round_y(point_y - 1)( U. x: g' X& T; C0 ^
  1451.       end! A5 v  k# P( j& x- G
  1452.     else2 |* p% I2 z% e; e
  1453.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
    4 F/ }8 B- Y! F, P5 }: w; }1 H
  1454.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    $ Y' }! C! \- _, @- }7 y2 A) h% f
  1455.             $game_map.passable(point_x, point_y, 2)                #judge_end8 V# b3 _& x3 \7 Q% H* r9 k( _
  1456.         reversed_chase_path.push(8)
    % L1 }* h# {; F- ~  W
  1457.         point_y = $game_map.round_y(point_y + 1)( {6 I: Y) i: B4 J8 Y8 w" p; N
  1458.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&! B1 k2 g/ f* X3 E+ G# j, `
  1459.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    ; H: L9 u/ b% ?  E& }& R3 k/ b
  1460.             $game_map.passable(point_x, point_y, 8)                #judge_end
    % ]3 b# c, _- s- {3 e
  1461.         reversed_chase_path.push(2)
    ' e9 m# Q3 K6 y  b
  1462.         point_y = $game_map.round_y(point_y - 1)
    ) N' X4 `7 z# G, H% b
  1463.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&- H& D0 j' _, c* j, E! |
  1464.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&4 c/ A) {1 T2 `5 P& Z* Q; B
  1465.             $game_map.passable(point_x, point_y, 4)                #judge_end
      }! a4 k& S6 c& O! h
  1466.         reversed_chase_path.push(6). ^0 m6 a6 y' s' k/ `
  1467.         point_x = $game_map.round_x(point_x - 1)& Z$ A0 }0 ^% U
  1468.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&$ u; e1 l! H3 @% h
  1469.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    2 ]( M1 u0 e: [6 V. K
  1470.             $game_map.passable(point_x, point_y, 6)                #judge_end
    7 Z3 D5 T" B0 ]( z8 w3 C- f
  1471.         reversed_chase_path.push(4)" n0 n2 |5 x( u: ~# ^; ~4 x* n' b
  1472.         point_x = $game_map.round_x(point_x + 1)/ e, j4 T( ^) R" r+ b1 I
  1473.       end
    * \) q4 R2 B. g5 \
  1474.     end1 m: J% j/ u$ R9 b0 H. `$ @
  1475.     end #endOfForLoop
    ) K* z4 e& q7 k, S  V2 U
  1476.     # 根据路径表格绘制最短移动路径(正向)
    5 b% ?# y' ]8 S1 ]8 {
  1477.     steps = step  2  2
    ' x! |0 H9 P" Q* i6 d- ^3 H7 x! r0 f
  1478.     loop_times = step  2
    8 K0 q  z" [, l1 d% [5 ?; S4 p; }
  1479.     point_x, point_y = chase_point[0], chase_point[1]
    ) f+ J3 d9 L/ I( s
  1480.     for i in 2..loop_times # forLoop
    - k4 e6 w$ J2 x' ^- S
  1481.     steps -= 2
    / k9 D' s% z& L$ t2 {! I
  1482.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    4 i% Y. C) ?% N+ v% |
  1483.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&5 h3 C) J; `" K7 @1 }4 w
  1484.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    . W# w1 t( c+ a6 A& f# m, H
  1485.             $game_map.passable(point_x, point_y, 2)                #judge_end* \- h4 \- f% H! b8 }+ R
  1486.         chase_path.push(2)& h, ^2 O% O, K8 }% h
  1487.         point_y = $game_map.round_y(point_y + 1)/ R& ~$ i& i( m5 _
  1488.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&" Z4 s3 N( `# p7 k; a& L3 D
  1489.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&- j. s7 k/ \# f0 C5 M
  1490.             $game_map.passable(point_x, point_y, 8)                #judge_end5 {' f; a, Z& C% F8 B
  1491.         chase_path.push(8)
    ( F; _6 t/ e( L- _* `  Q: R7 a' S
  1492.         point_y = $game_map.round_y(point_y - 1)8 W" D2 I3 w7 `: }6 ~! N$ {
  1493.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&9 i9 ~9 e9 }+ K
  1494.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
    - K4 t' u% K1 Y( z9 v# h
  1495.             $game_map.passable(point_x, point_y, 4)                #judge_end
    - W- x. k# `3 |4 h
  1496.         chase_path.push(4)5 _+ @4 J" F8 a
  1497.         point_x = $game_map.round_x(point_x - 1)
    " u! f  v! B: ~( D) n
  1498.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    * g! X0 j; T( e
  1499.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    ; n- a# S/ H( x% S* q
  1500.             $game_map.passable(point_x, point_y, 6)                #judge_end
    * g! @7 c, S/ v/ h% P  D. i) B
  1501.         chase_path.push(6)6 m. R# y6 e) l- o
  1502.         point_x = $game_map.round_x(point_x + 1)
    8 c+ }( e- G+ T  S+ s' g9 G$ ]
  1503.       end
    * v8 M& t* a( ^; f' F3 [( n) J
  1504.     else: ^4 H3 l9 g' C+ A4 S6 F& s) ~" L
  1505.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&8 Z0 @: Q( l8 o" k, a& C
  1506.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&+ k7 W, b8 \: o
  1507.             $game_map.passable(point_x, point_y, 4)                #judge_end
    ! S5 C# a. V# X
  1508.         chase_path.push(4)
    3 ~9 A# f% r6 A4 l, Z. j! `& t
  1509.         point_x = $game_map.round_x(point_x - 1)2 Z" Y( o2 V! F! [" w
  1510.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    ) r3 P7 j+ H& I, h
  1511.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    : t7 i, ^% Z* Q9 H" ?$ P( L4 z
  1512.             $game_map.passable(point_x, point_y, 6)                #judge_end8 R6 P8 J* u. D$ I( g. K8 Q- f
  1513.         chase_path.push(6)
    0 V0 [2 I( @! p2 [
  1514.         point_x = $game_map.round_x(point_x + 1)
    & M  A9 p7 o: W; [
  1515.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&$ G6 a% t3 j$ r" F
  1516.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&" `' }2 s; F6 X" F
  1517.             $game_map.passable(point_x, point_y, 2)                #judge_end- F+ @2 @, q" J! l
  1518.         chase_path.push(2)
    " @' |4 n- q2 w  T* w* t4 z
  1519.         point_y = $game_map.round_y(point_y + 1)2 Q+ S+ a+ a4 W0 X4 l8 `/ q
  1520.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    6 e* d4 f7 H7 g) c
  1521.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&$ M  O- }$ w" C4 |+ l  U
  1522.             $game_map.passable(point_x, point_y, 8)                #judge_end
    * L; J; R8 z' `
  1523.         chase_path.push(8)
    ! A# g! t; g1 C/ ~! O# b
  1524.         point_y = $game_map.round_y(point_y - 1)4 r  Y, M, Z6 r7 u1 p/ U8 `# z
  1525.       end( X7 ?( w, L0 \* O% y' x/ t
  1526.     end+ H/ D$ J( o! v2 l' L/ v3 {
  1527.     end #endOfForLoop
    : R6 W$ g$ l. Y3 W7 w0 @* s; z
  1528.     @mouse_move_path = reversed_chase_path.reverse + chase_path5 D4 n& E' S$ F0 p- j8 e* M. q
  1529.   end#walk
    % T" e8 \# |7 U) C9 z, X+ V# C
  1530.   #--------------------------------------------------------------------------/ O5 A5 Y& e, H- C
  1531.   # ● 绘制boat的移动路径 @array[move_directions...]5 c% X; q8 Z, Y! G% h
  1532.   #--------------------------------------------------------------------------
    / t. C* U- t% U# p* _
  1533.   def draw_boat_path
    , e: C+ C# a2 i7 x4 t3 B
  1534.     # 准备绘制路径表格
    . O2 c" r4 H# a5 d( `7 v8 C
  1535.     sheet = Table.new($game_map.width, $game_map.height)" s9 I2 R! s( T
  1536.     reversed_chase_path  = []; chase_path  = []
    * k% h+ O& ^6 \( n3 ]! g, M# ^
  1537.     reversed_chase_point = []; chase_point = []6 [: S6 M; Z$ I, c3 p1 r+ b( F
  1538.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
    ; W6 |" }+ J* \0 ~  X$ Z
  1539.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
    . H. L+ F: Y. n0 e+ Q; J4 b
  1540.     reach_point = false
    2 a8 M1 M6 `- w, l8 c
  1541.     step = 3& G' M: x0 g* w2 F7 d, u
  1542.     loop do #loop1 开始填充表格! t" `* g1 C4 c: [0 V- U3 t
  1543.      draw_path = false  I% }4 u- w2 F
  1544.      check_points = new_start_points- x9 ~! s7 P/ V2 B0 I9 a
  1545.      new_start_points = []# y0 X1 E3 \- ?; R; f+ G: Z
  1546.       loop do #loop2 从起点开始正向填充
    1 w% T8 U4 Y; G- J: i" B* N3 E
  1547.         point_x = check_points.shift5 d1 n2 Y/ Y+ P3 g# y
  1548.         break if point_x == nil; U; y; I. {5 L/ ?- j/ c
  1549.         point_y = check_points.shift
    8 d1 I+ T- i8 I0 G* j
  1550.         left_x  = $game_map.round_x(point_x - 1)* I- s! e1 w, p+ s1 y
  1551.         right_x = $game_map.round_x(point_x + 1)
    ; w; B7 |$ ^8 }) A( d( X  E
  1552.         up_y    = $game_map.round_y(point_y - 1)
    2 |4 R: @, }; {- w- i( D, i
  1553.         down_y  = $game_map.round_y(point_y + 1)& d) i  p, q2 g9 r2 v
  1554.                     # 判断路径是否连通
    ; ^+ j& p, j) V  U- _$ C
  1555.         path_step = step - 18 R+ i9 X2 g3 C3 h$ Q  y' L
  1556.         if sheet[left_x, point_y] == path_step0 }- b7 u0 j: S7 _4 m
  1557.           chase_path.push(4)
    ' z7 C* j5 T, }/ @$ S
  1558.           chase_point = [left_x, point_y]- F" x  _7 \7 p3 p+ D( t( Z2 x$ t
  1559.           reversed_chase_point = [point_x, point_y]
    . `& x6 r' A" Q' d$ ^
  1560.           reach_point = true; break1 V# r6 T7 b9 d5 q& n' ?
  1561.         elsif sheet[right_x, point_y] == path_step' f: s( v, @- b& d
  1562.             chase_path.push(6)/ }4 I) w' L* l% E! T) ]7 X
  1563.             chase_point = [right_x, point_y]2 {0 q0 R# q3 i+ {, i1 b7 W  T
  1564.             reversed_chase_point = [point_x, point_y]8 H9 ^6 ^. k8 o" W& N& |" _+ M
  1565.             reach_point = true; break
    , D' n* m5 n& N+ x& w; L9 n" M8 K
  1566.         elsif sheet[point_x, up_y] == path_step
    : H& {( x+ s" q/ D9 k7 z! r2 v  \
  1567.             chase_path.push(8)
    ; N8 }# u0 Q! d
  1568.             chase_point = [point_x, up_y]
    4 q9 V$ q/ ~* n+ q# N% r" f
  1569.             reversed_chase_point = [point_x, point_y]. n5 G- S- m$ ^' h/ T3 o
  1570.             reach_point = true; break% O; ]* C$ z5 y
  1571.         elsif sheet[point_x, down_y] == path_step; M- B) ^/ r" H+ f
  1572.             chase_path.push(2)
    9 K" n) B; ]% g2 e$ z
  1573.             chase_point = [point_x, down_y]( n+ C) l0 q' C# B; \+ e
  1574.             reversed_chase_point = [point_x, point_y]! p) X, O4 u# o# e
  1575.             reach_point = true; break
    5 A/ M6 M+ E4 k% D3 C) u# l
  1576.         end$ t5 `4 L7 x5 N! ^3 X
  1577.         # 以需要抵达该点的步数填充路径表格 #
    # ?: G4 a4 n8 @! G  k1 y
  1578.         if sheet[left_x, point_y] == 0                &&) {: c! a3 L1 W! g
  1579.            $game_map.boat_passable(left_x, point_y)  &&. b( T$ U6 d. }, \
  1580.            !collide_with_events(left_x, point_y)     &&: K4 m# o9 Z+ [) Q' P/ O3 N
  1581.            !collide_with_vehicles(left_x, point_y)   #judge_end
    $ U. z# s4 A+ T# U6 N: b3 I
  1582.           sheet[left_x, point_y] = step
    ' s0 u7 n# E; K6 h8 g
  1583.           draw_path = true% H: l: X7 t0 R" c% d+ _
  1584.           new_start_points.push(left_x, point_y)3 z- C0 c# Y9 l" O6 O- D5 D8 ?
  1585.         end
    / O5 a  _8 p7 [8 r' ^# W8 Z7 T
  1586.         if sheet[right_x, point_y] == 0               &&
    & n2 k) W" e0 G+ b2 ~& J: D6 r
  1587.            $game_map.boat_passable(right_x, point_y) &&
    $ F' n+ B0 t; }* _
  1588.            !collide_with_events(right_x, point_y)    &&
    . C% _7 T( g. z& m2 C
  1589.            !collide_with_vehicles(right_x, point_y)  #judge_end2 L8 ~2 `% I" |& d
  1590.           sheet[right_x, point_y] = step
    ' f* s/ l5 I3 i% N
  1591.           draw_path = true
    " f8 ~  k5 ^' r5 X; w
  1592.           new_start_points.push(right_x, point_y)& b0 \/ L! a. v
  1593.         end7 z% N5 \  X& I/ B8 |- |- Y
  1594.         if sheet[point_x, up_y] == 0                  &&
    . m& b+ x# M. W. a
  1595.            $game_map.boat_passable(point_x, up_y)    &&; y2 Q% b7 D' K, u/ O, z( G/ _9 u
  1596.            !collide_with_events(point_x, up_y)       &&6 u$ v+ e8 s9 ?! J6 L
  1597.            !collide_with_vehicles(point_x, up_y)     #judge_end% h* r1 W8 |" m$ {
  1598.           sheet[point_x, up_y] = step
      o8 ^& R# G1 b) `9 j
  1599.           draw_path = true
    . h: O. b# n5 j3 X$ y
  1600.           new_start_points.push(point_x, up_y)5 Y! `+ H& K( D7 v1 ~
  1601.         end
    & j  a5 P4 x& f9 m- X+ S
  1602.         if sheet[point_x, down_y] == 0                &&8 {' O# J# r+ e2 `
  1603.            $game_map.boat_passable(point_x, down_y)  &&
    / R9 W- F: l8 Y0 M. j  O4 A  R8 L9 M
  1604.            !collide_with_events(point_x, down_y)     &&
    : @- P. S6 v+ a4 d+ D* X& `9 v5 A# ~
  1605.            !collide_with_vehicles(point_x, down_y)   #judge_end
    ( ^( `. g( t% x6 P7 q) B
  1606.           sheet[point_x, down_y] = step
    : W5 [( ?+ ~& y6 S  Y: H
  1607.           draw_path = true! f2 S! J: \+ H! i6 g0 Z8 T
  1608.           new_start_points.push(point_x, down_y)
    + Y" F* t+ J& M' F  {
  1609.         end' I. G) U, f. c4 i
  1610.       end#endOfLoop2
      G. G# @4 R+ Q7 b- w
  1611.       break if !draw_path  reach_point( Y" N. Y# N* e8 S. b* e
  1612.       draw_path = false
    . i0 Z7 p4 C4 v7 K4 B
  1613.       check_points = new_end_points
    * [2 L& ]8 z- b' L* M) Y& B/ ?9 i
  1614.       new_end_points = []
    / I( g- \0 ?$ u, [* O# _$ Z
  1615.       step += 1/ U, u3 g9 Q+ Q" o( ~% g* @
  1616.       break if step  KsOfSionBreak_Steps &&% F- y. _- l/ w9 L" c- ^
  1617.                !Input.press(KsOfSionFind_Path_Key)  Y5 h) R) Z6 Z+ y6 N* q+ `2 c! N* d
  1618.       loop do #loop3 从终点开始反向填充- o& k$ |* m7 I$ J$ Z3 N
  1619.         point_x = check_points.shift( ~& _' `% h, C; r  _0 @$ F
  1620.         break if point_x == nil% v) {& F4 W0 i( f2 h( [6 C
  1621.         point_y = check_points.shift
    # K$ Q9 M! O% e, J' D
  1622.         left_x  = $game_map.round_x(point_x - 1)
    " R' O3 P+ A3 K/ S! g8 T8 G1 L
  1623.         right_x = $game_map.round_x(point_x + 1)% J, x# J. Z6 p6 H% O
  1624.         up_y    = $game_map.round_y(point_y - 1)! {) t; ^: h  V% S7 P+ I3 C- h1 F
  1625.         down_y  = $game_map.round_y(point_y + 1)) d+ _; I) s, L3 F  U6 ]& \
  1626.         # 判断路径是否连通4 H. T. |7 h" o6 ]$ l
  1627.         path_step = step - 15 `6 D* K8 Y1 c- v+ p) H% G0 K+ z" T
  1628.         if sheet[left_x, point_y] == path_step  T' L" W7 `" u) _' c( K& u0 r
  1629.           chase_path.push(6)4 D$ {1 `4 k8 C) E. C
  1630.           chase_point = [point_x, point_y]
    " E  E( q! z% I) N% c% w% M. ^; f! A
  1631.           reversed_chase_point = [left_x, point_y]1 s8 u+ d4 w1 r, f+ w  W8 O% W
  1632.           reach_point = true; break$ ^* R5 W! c! i3 z
  1633.         elsif sheet[right_x, point_y] == path_step
    * y+ t& O/ F5 U7 q3 Q
  1634.             chase_path.push(4)& e) K! w7 {3 r# s3 [3 U" ?
  1635.             chase_point = [point_x, point_y]
    9 ~; T" ]4 j) U! g' c2 k
  1636.             reversed_chase_point = [right_x, point_y]! [1 ?& b; Z2 R( s0 j  h. A
  1637.             reach_point = true; break
    % ~, O; u( P2 O9 }
  1638.         elsif sheet[point_x, up_y] == path_step! n3 h, P1 M. y
  1639.             chase_path.push(2)
    # Q, _. r- C! |8 o. x' @& ~
  1640.             chase_point = [point_x, point_y]
    $ Q2 C  K3 ^  J: k
  1641.             reversed_chase_point = [point_x, up_y]
    $ B: q$ b% C) n; e( j% T  Z
  1642.             reach_point = true; break+ j& s8 m4 G. Q* r5 ^" ~
  1643.         elsif sheet[point_x, down_y] == path_step
    - o9 L4 q0 i% o) {& [/ S: V3 a0 `
  1644.             chase_path.push(8)
    " S& _. s7 M! r9 p5 ~' ^& ^7 l3 i
  1645.             chase_point = [point_x, point_y]
    + D& J( z$ v' t2 E
  1646.             reversed_chase_point = [point_x, down_y]
    ! i0 T7 F0 |' Q3 s+ Q" `$ y: Z7 `
  1647.             reach_point = true; break
    9 r# m+ {# D8 g! q1 E
  1648.         end, Q" l# X( K3 h& p
  1649.         # 以需要抵达该点的步数填充路径表格 #
    " g2 e6 g( R, X4 _
  1650.         if sheet[left_x, point_y] == 0                &&
    ' }; E9 ^, Q: C" f; q3 k; z
  1651.            $game_map.boat_passable(left_x, point_y)  &&
    . _4 l1 Q2 B: j* \! R" V& H) h
  1652.            !collide_with_events(left_x, point_y)     &&( r; j9 w+ T1 }5 w2 ]7 w+ V0 h
  1653.            !collide_with_vehicles(left_x, point_y)   #judge_end3 r6 J: \& G" R' n& w
  1654.           sheet[left_x, point_y] = step
    4 u$ m+ `2 t1 W+ }0 c
  1655.           draw_path = true* a" L+ P  ]6 ^$ `% a$ T/ K
  1656.           new_end_points.push(left_x, point_y)
    5 W0 W+ |! k, K2 F4 t
  1657.         end
    ' D: ~: |/ d$ ^9 H7 s% M
  1658.         if sheet[right_x, point_y] == 0               &&/ q1 n! M8 g7 Z4 e
  1659.            $game_map.boat_passable(right_x, point_y) &&
    8 M) m0 ^5 i* z) e
  1660.            !collide_with_events(right_x, point_y)    &&
    4 E% }6 x( M6 z" `; M. X
  1661.            !collide_with_vehicles(right_x, point_y)  #judge_end
    : N% c" c3 E7 e; ]. |' u
  1662.           sheet[right_x, point_y] = step* U0 K4 F' D' u3 {/ i9 R
  1663.           draw_path = true
    , }7 }1 @7 x) k3 U6 U9 P; r
  1664.           new_end_points.push(right_x, point_y)
    ( l* x$ b& @2 F8 B' s6 ]$ w
  1665.         end
    ( ^' ?8 l' q+ i+ L0 O' Q: {9 {% W; e
  1666.         if sheet[point_x, up_y] == 0                  &&
    , a& ?% |* }! O" e' x  k
  1667.            $game_map.boat_passable(point_x, up_y)    &&  n! ^! |9 I1 j. E3 {: n
  1668.            !collide_with_events(point_x, up_y)       &&! U; P0 Z  ^+ Q+ q% f
  1669.            !collide_with_vehicles(point_x, up_y)     #judge_end1 {; x( Z( j- H" a
  1670.           sheet[point_x, up_y] = step. J$ ]4 X1 }) V& z. J" k4 ]
  1671.           draw_path = true
    ) B4 O: _" ^4 q3 l
  1672.           new_end_points.push(point_x, up_y)' x, I, q+ G5 R  k- o
  1673.         end
    * _0 D# J& l/ l( f2 S
  1674.         if sheet[point_x, down_y] == 0                &&
    # A1 L: R' p3 E
  1675.            $game_map.boat_passable(point_x, down_y)  &&
    & ?# B  ]7 m' d$ \; E: ]7 V
  1676.            !collide_with_events(point_x, down_y)     &&  v" L) d5 z9 x- Y
  1677.            !collide_with_vehicles(point_x, down_y)   #judge_end
    1 X; F5 _- h0 C
  1678.           sheet[point_x, down_y] = step: O9 A1 t  @9 Q. _3 J
  1679.           draw_path = true) x/ l- a% u! r6 R& |. N6 r$ l+ ~4 E/ i
  1680.           new_end_points.push(point_x, down_y)' g+ u7 a1 W/ M( z+ U# [
  1681.         end
    " S! I8 F) n$ v3 H! e: J+ k) t
  1682.       end#endOfLoop33 t  H7 z+ s" P1 r- c
  1683.       break if !draw_path  reach_point! P6 q' R% F& y3 }0 e
  1684.       step += 1
    6 Z9 I- ?. k: N
  1685.     end #endOfLoop1 路径表格填充完毕) L& h2 \$ @9 V, X$ u, j3 u
  1686.     $mouse_move_sign.transparent = false2 n( X; Q- t0 g& l
  1687.     # 判断指定地点能否抵达! m: l( {. Z- H8 [* X  E; {
  1688.     if reach_point
    " {% ~" x# z+ H7 o  n* ^* T; {
  1689.       $mouse_move_sign.direction = 2
    % l+ G+ h3 E  I- L# i
  1690.     else4 E. K# K8 K& x- L& X
  1691.       not_reach_point
    " {' {2 Z$ h, I7 w5 n
  1692.       return  ~* {+ {. K1 T
  1693.     end& a9 D4 i- ?3 E, [6 H7 t4 `
  1694.     # 根据路径表格绘制最短移动路径(正向)$ r1 N* k4 ~) {) U: H3 t
  1695.     steps = step  2  2- I& w/ P& j( I% o; @# @3 a9 ^
  1696.     loop_times = step  2$ ]3 B& G& [1 H1 z( }( e" q
  1697.     point_x, point_y = chase_point[0], chase_point[1]* y% w7 o% h4 ~% p: s. z8 X/ F
  1698.     for i in 2..loop_times # forLoop, {8 `: e) _: z
  1699.     steps -= 2
    ; J5 ]3 }3 b) {
  1700.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs; n/ p# D: e5 F' \% r4 E
  1701.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps2 N5 f6 c+ `. L1 h8 u9 T
  1702.         chase_path.push(2); x/ ]0 w' s6 }4 V
  1703.         point_y = $game_map.round_y(point_y + 1)( h- E6 E9 }, e0 L& q6 F( W. R# u% w
  1704.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps: y( l/ @# ~! t  `9 _  r9 P* t
  1705.         chase_path.push(8)
    # W. ?/ U9 j6 n' f/ F' b
  1706.         point_y = $game_map.round_y(point_y - 1)
    4 w& c# Y2 d5 U, }! e: S2 f' F/ J
  1707.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps+ |; B; J1 a. D3 d+ e
  1708.         chase_path.push(4)
    ( z5 t% A' R. e) E1 |, e, I! j
  1709.         point_x = $game_map.round_x(point_x - 1): q: e+ X8 R+ _, A! T" F
  1710.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps' `! U1 F! l# }! _4 w8 X+ z
  1711.         chase_path.push(6)$ n# c- n5 B* Y' i0 l  Y# A
  1712.         point_x = $game_map.round_x(point_x + 1)( n' P) l/ X: k, p
  1713.       end
    4 k. t( ^" P1 \( E3 C% ?
  1714.     else
    . K' T6 N' O0 b0 V# }% H
  1715.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps7 a6 a$ G% V, e8 i7 ]- ]' ?% S$ v
  1716.         chase_path.push(4)1 [7 O8 H% n, Y
  1717.         point_x = $game_map.round_x(point_x - 1)
    1 ?& x% s- ?0 c3 f5 \1 `5 E
  1718.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    2 n" U6 c3 W( g
  1719.         chase_path.push(6)
    " b* {! u: l3 j0 G# Z$ k2 R
  1720.         point_x = $game_map.round_x(point_x + 1)
    / o( x+ Y; m/ v& J& R) }/ ?
  1721.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    , ?: n! I, m( b0 h+ E
  1722.         chase_path.push(2)
    0 G2 l# j$ E% _" Y
  1723.         point_y = $game_map.round_y(point_y + 1)
    ' T6 q2 N0 D8 L' |$ b0 M
  1724.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps& N- P  m# ?( t. T
  1725.         chase_path.push(8)
    6 M4 A6 l9 S9 R, S: l+ `" \2 Y! b* Y
  1726.         point_y = $game_map.round_y(point_y - 1)
    8 ?# Z+ I6 `# m" e1 {* B0 y5 u
  1727.       end5 |! F9 i1 `" W5 h( m5 `9 e
  1728.     end
    : U# P* e! K. f; D- ~
  1729.     end #endOfForLoop: `- v8 H7 E% k
  1730.     # 如果指定点无法抵达或者登陆
    ; p& f7 e( \6 E$ `7 |% C) ~( Q
  1731.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)& ~4 a8 l: e, x6 U
  1732.     # 根据路径表格绘制最短移动路径(反向)( ]; O3 n! P- N  i& I
  1733.     steps = step  2  2 + 1
    0 v2 J3 H0 ?0 N! k* `; W8 o
  1734.     loop_times = step  28 |2 M' T% g2 n) E: O: D
  1735.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]; X5 l* K$ \3 e! s% d9 w6 L  J3 W) z
  1736.     for i in 1..loop_times # forLoop" K' K' ~( m. c1 ^- [# q' E9 y: q
  1737.     steps -= 26 m  j# G$ s. ^1 o/ R5 s# t
  1738.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    9 D# N6 \. `. z( ^
  1739.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps; W4 V& e. x4 w' |
  1740.         reversed_chase_path.push(6)( [# t* ~' r" }% e+ f4 x. j! ?9 ~
  1741.         point_x = $game_map.round_x(point_x - 1)1 ]( i8 ]# H, N  S( V5 a9 X4 |1 J
  1742.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps5 k/ O1 }5 j) M5 D
  1743.         reversed_chase_path.push(4)  T6 _3 u' |/ N8 v! N+ i: z" U
  1744.         point_x = $game_map.round_x(point_x + 1)/ [7 Y% \  f: f' d. N' ]
  1745.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps8 i4 |$ Q0 \# @% u; N
  1746.         reversed_chase_path.push(8)
    # }" b# M; ~! o! l
  1747.         point_y = $game_map.round_y(point_y + 1)
    5 R7 K$ J# m5 P& z
  1748.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    2 r- F8 G) z6 d
  1749.         reversed_chase_path.push(2)& \: Z8 n8 \( e' i; ]0 E: U
  1750.         point_y = $game_map.round_y(point_y - 1)
    . k8 f4 w7 k8 u) i" A
  1751.       end
    ; m8 B: Y% \! B1 K; V7 a$ b
  1752.     else
    % Z: o' ~  m8 r- K  }% c0 y
  1753.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps4 y# l' l; ^! D4 L
  1754.         reversed_chase_path.push(8)
    ( g; T. C; i9 L2 c* ]
  1755.         point_y = $game_map.round_y(point_y + 1)
    # y7 w0 w: \8 @  U# s% G
  1756.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    # v7 K/ ~4 Y8 ^& k
  1757.         reversed_chase_path.push(2)
    , @; Y7 x$ f" v3 A$ y* {0 x
  1758.         point_y = $game_map.round_y(point_y - 1)& t# l' ?' C7 a+ r, h) y5 e7 h. A
  1759.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    $ Y8 a! Q! W% Y3 F- t2 f
  1760.         reversed_chase_path.push(6)( N* m8 ?* p9 V+ @
  1761.         point_x = $game_map.round_x(point_x - 1)9 |% \" [# ]3 u( F, l4 W; `$ R' d
  1762.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    " s- p3 j7 N& U/ S! q
  1763.         reversed_chase_path.push(4)) h# r4 [  y- _" F" l
  1764.         point_x = $game_map.round_x(point_x + 1)
    & w) Q# O/ t4 {) v; v
  1765.       end
      u* ]1 p1 x( T/ ]% `* ]
  1766.     end6 Q& K' b4 Q$ Q7 A, ^
  1767.     end #endOfForLoop0 O" D1 A3 b. e$ A, b: L& K
  1768.     @mouse_move_path = reversed_chase_path.reverse + chase_path6 v; d8 H4 u2 U& r4 M8 z8 k
  1769.   end#boat
    % ^! m) G5 K9 L1 J# g, I4 p) j
  1770.   #--------------------------------------------------------------------------
    / F5 a2 ^0 Y: b3 Q$ p  G* B1 o6 g
  1771.   # ● 绘制ship的移动路径 @array[move_directions...]/ }8 U* d6 t, W# K3 I/ W6 b, P
  1772.   #--------------------------------------------------------------------------
    * H* Y7 ^' N3 I4 [. a
  1773.   def draw_ship_path
    ( g& Y8 P  K2 f+ }% G5 F2 z
  1774.     # 准备绘制路径表格8 K1 N! L; B/ u0 W- Z/ W
  1775.     sheet = Table.new($game_map.width, $game_map.height)" Y" h! n. {" i. F
  1776.     reversed_chase_path  = []; chase_path  = []" V6 J+ W& O, L( J+ Q2 y4 y+ Y4 {
  1777.     reversed_chase_point = []; chase_point = []7 U# d! A; F) i* N7 ^
  1778.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]# T, v) I' w3 Z. w( j
  1779.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2; p; e  l" \, j& Y. V$ X
  1780.     reach_point = false
    7 Q9 R" y. v% l0 x' c3 y% R: Z& k. N
  1781.     step = 3
    6 `, `8 e7 b. A5 z2 l
  1782.     loop do #loop1 开始填充表格$ P2 `) M2 i0 H
  1783.      draw_path = false9 z+ C2 b* D; Q! x* ^) b% M2 |
  1784.      check_points = new_start_points* p" N( b' g; G4 P5 d# x% ~
  1785.      new_start_points = []
    & S( I0 e, f, G% J7 N- r: j+ \$ }
  1786.       loop do #loop2 从起点开始正向填充
    1 ^  Z# M1 z. H
  1787.         point_x = check_points.shift& D: h; r1 v, W! a5 w9 k0 G4 v
  1788.         break if point_x == nil
    2 ]) H4 a% R. D
  1789.         point_y = check_points.shift
    4 i. J1 [5 E7 P# q. i
  1790.         left_x  = $game_map.round_x(point_x - 1)
    7 {& u4 m' ?' f
  1791.         right_x = $game_map.round_x(point_x + 1)0 S  l5 l" V* E8 x
  1792.         up_y    = $game_map.round_y(point_y - 1)
    7 ?0 |* N# v2 v! c2 z& _
  1793.         down_y  = $game_map.round_y(point_y + 1)) p$ Z! N) p( r6 ?5 T. a5 A
  1794.                     # 判断路径是否连通: L5 h, F' P" Q$ r% s
  1795.         path_step = step - 10 o+ g5 ~0 V! N1 i! F! J
  1796.         if sheet[left_x, point_y] == path_step5 r* H8 u0 y! T
  1797.           chase_path.push(4)3 n' @0 D  o8 W0 P0 p& N) u
  1798.           chase_point = [left_x, point_y]: i% F: V: l( C) B0 \
  1799.           reversed_chase_point = [point_x, point_y]
    $ H1 L2 X8 }4 w! |. i( h3 M
  1800.           reach_point = true; break
    7 m+ D" u: F8 G
  1801.         elsif sheet[right_x, point_y] == path_step6 L; m; ?+ d  r
  1802.             chase_path.push(6)
    + l. _" k; k7 W$ j5 s* j) u" I
  1803.             chase_point = [right_x, point_y]7 `+ o. p  g, l
  1804.             reversed_chase_point = [point_x, point_y], y% l9 Z$ i: H2 u
  1805.             reach_point = true; break6 }, D& k+ p5 p# Q0 T- Y5 p
  1806.         elsif sheet[point_x, up_y] == path_step
    . n: k) E* l0 I% N* Q
  1807.             chase_path.push(8)
    * J4 }- I5 V/ C" ~# L- W
  1808.             chase_point = [point_x, up_y]7 s8 J' A! g6 ~5 R2 n* c- h
  1809.             reversed_chase_point = [point_x, point_y]
      L' O% x  h1 O# q9 X
  1810.             reach_point = true; break+ T) {! N) P) a" v, z
  1811.         elsif sheet[point_x, down_y] == path_step) }- w- T3 x) \/ ?
  1812.             chase_path.push(2)0 {5 x& r8 j! C* G- m5 v
  1813.             chase_point = [point_x, down_y]0 k1 N9 r- @" H
  1814.             reversed_chase_point = [point_x, point_y]
    1 ^. m  I7 L6 I' m' E& H
  1815.             reach_point = true; break
    " @; G6 |8 ]: b0 V/ n. d/ ?
  1816.         end
    3 J! {  R, @! N* }+ }: a1 `
  1817.         # 以需要抵达该点的步数填充路径表格 #
    4 s* }+ n* ?) M- C1 c  Z/ w3 C! {$ u
  1818.         if sheet[left_x, point_y] == 0                &&
    ( c$ L8 t0 S% F! {& e
  1819.            $game_map.ship_passable(left_x, point_y)  &&
    ; C; ?- b/ P0 `, c
  1820.            !collide_with_events(left_x, point_y)     &&
    % R, X5 ~3 l; s0 }: G
  1821.            !collide_with_vehicles(left_x, point_y)   #judge_end
    - H) \6 T+ T+ d! b4 i
  1822.           sheet[left_x, point_y] = step
    # U" q) u6 S0 K. M
  1823.           draw_path = true
    / X% w0 e6 @# T; X2 n
  1824.           new_start_points.push(left_x, point_y): ?) j7 z$ [" e8 P' \
  1825.         end
    " _) u! s- p4 b" z* b* g4 P
  1826.         if sheet[right_x, point_y] == 0               &&
    " n2 K2 Z' t# C2 H; p7 Z
  1827.            $game_map.ship_passable(right_x, point_y) &&
    * e$ Q$ O4 n( ~6 t) Q
  1828.            !collide_with_events(right_x, point_y)    &&
    & R5 Q7 g% V6 _. C. e
  1829.            !collide_with_vehicles(right_x, point_y)  #judge_end8 W3 T6 B. }  Y( g9 ^
  1830.           sheet[right_x, point_y] = step4 T" Y5 i7 w5 M5 D5 S  \- W0 q
  1831.           draw_path = true
    ' V) s" b; ~5 k9 c
  1832.           new_start_points.push(right_x, point_y). F6 d* h7 v. E4 I9 |9 I6 ^# Q" K* X
  1833.         end
    % ?; d$ L1 x. ~, M
  1834.         if sheet[point_x, up_y] == 0                  &&
    8 w& f' X. K5 ?3 B
  1835.            $game_map.ship_passable(point_x, up_y)    &&' C( j; C0 F) r* ^) w& P5 h
  1836.            !collide_with_events(point_x, up_y)       &&
    $ O- F8 c  x; i# ?( b
  1837.            !collide_with_vehicles(point_x, up_y)     #judge_end
    8 U5 d3 Y3 a- E3 y, A  c
  1838.           sheet[point_x, up_y] = step
    1 h6 E; Q) |3 S& y' W
  1839.           draw_path = true
    2 A: H4 d- F; n5 n$ H' A* g7 N
  1840.           new_start_points.push(point_x, up_y), Q5 e. @4 W9 R) F) A% A
  1841.         end
    8 h  l$ Q! c) Y) ~5 m7 y* u
  1842.         if sheet[point_x, down_y] == 0                &&7 E9 y4 x, i2 \* k: a5 p
  1843.            $game_map.ship_passable(point_x, down_y)  &&1 p; M* i4 z7 z6 t7 A# R! i5 L
  1844.            !collide_with_events(point_x, down_y)     &&
    % G8 l5 a7 g+ I- d4 Z* X
  1845.            !collide_with_vehicles(point_x, down_y)   #judge_end7 C* ]  G9 @: l- a
  1846.           sheet[point_x, down_y] = step% _1 I+ M' n! q6 ]7 c) F4 ]
  1847.           draw_path = true; i) L" V+ A0 j2 @$ `
  1848.           new_start_points.push(point_x, down_y)* y* o6 h" Y4 }
  1849.         end
    # |: Y3 n3 u  X. C6 q
  1850.       end#endOfLoop2: u7 t7 ]/ u6 \% o) f3 c& m
  1851.       break if !draw_path  reach_point: ^. e- w: D3 L2 E7 b8 t
  1852.       draw_path = false8 }6 \" J8 z  U3 i
  1853.       check_points = new_end_points8 w  i) i( y1 i2 L0 W
  1854.       new_end_points = []4 C: `/ f& D* r" p
  1855.       step += 1$ M2 Z! F6 R# X- L$ }3 n7 }
  1856.       break if step  KsOfSionBreak_Steps &&
    0 A: ~( G3 T  A9 b9 G. V1 b* S
  1857.                !Input.press(KsOfSionFind_Path_Key)/ z" Z# F/ K( y! o; a
  1858.       loop do #loop3 从终点开始反向填充
    5 Z# a0 Y* a8 ]& D
  1859.         point_x = check_points.shift
    ( F& ]. P; W; c. J5 [1 L
  1860.         break if point_x == nil
    9 N+ ~9 _7 D7 R) G- C2 t
  1861.         point_y = check_points.shift# V: [4 a8 F1 U1 D! p0 f( ]
  1862.         left_x  = $game_map.round_x(point_x - 1)# n( \4 \+ u1 U0 p5 g9 I( e
  1863.         right_x = $game_map.round_x(point_x + 1), M/ m4 l$ |" U7 I7 V1 q6 @
  1864.         up_y    = $game_map.round_y(point_y - 1)
    ) Q1 j) B* _# I  q! W, ~/ f( H
  1865.         down_y  = $game_map.round_y(point_y + 1)
    - j: q% G9 z; b/ d
  1866.         # 判断路径是否连通1 U! e2 E. q& N
  1867.         path_step = step - 1
    * g" H. n1 ?6 [4 K* d4 j
  1868.         if sheet[left_x, point_y] == path_step
    . e) M4 U  L  r5 X7 V% w! m, I
  1869.           chase_path.push(6)2 b7 @$ ]  [+ j5 W* U
  1870.           chase_point = [point_x, point_y]
    . E* l$ t( x- W, D# d  B
  1871.           reversed_chase_point = [left_x, point_y]& Y5 w" ~( U5 w/ S; o8 L
  1872.           reach_point = true; break
    # U3 @# r+ W- X2 R3 M
  1873.         elsif sheet[right_x, point_y] == path_step
    * r7 l  ~0 q1 \
  1874.             chase_path.push(4)3 A- Y: F( i! u0 X/ J
  1875.             chase_point = [point_x, point_y]
    & ^# D1 D% q" x
  1876.             reversed_chase_point = [right_x, point_y]" l  G, `& @$ ~* {" x& {& `& y
  1877.             reach_point = true; break9 Z7 [! B0 g% x& r
  1878.         elsif sheet[point_x, up_y] == path_step6 K& f) E5 Q! n2 z0 F) F) u9 @
  1879.             chase_path.push(2)
    ' A  g! \: p; ^# U* d
  1880.             chase_point = [point_x, point_y]
    , P4 P& U7 ~3 p+ C$ A
  1881.             reversed_chase_point = [point_x, up_y]! _( L$ }7 I+ f) p& |" r
  1882.             reach_point = true; break
    , ^) G5 _: e7 C; N9 D' @1 R
  1883.         elsif sheet[point_x, down_y] == path_step7 S1 Q' A2 f/ J" |( S  O
  1884.             chase_path.push(8)+ R- i& ^. s' r3 Q$ A' D% ~4 j1 i
  1885.             chase_point = [point_x, point_y]
    - R; k5 b+ X5 v+ u4 _! [
  1886.             reversed_chase_point = [point_x, down_y]8 q& L" j6 N; s( A
  1887.             reach_point = true; break6 |4 y" R/ K6 Y) m
  1888.         end
    % k6 i& C0 d) u6 |) S6 h9 s& j
  1889.         # 以需要抵达该点的步数填充路径表格 #
    & y3 C+ ^) H0 b; @/ U
  1890.         if sheet[left_x, point_y] == 0                &&
    . \* y1 o8 E" `& X# W! V7 s
  1891.            $game_map.ship_passable(left_x, point_y)  &&0 {: w6 [3 p) G7 a2 }) y4 r, V
  1892.            !collide_with_events(left_x, point_y)     &&
    : U! z' i; O- I0 h
  1893.            !collide_with_vehicles(left_x, point_y)   #judge_end
    0 l5 O) H) P" e# A5 k7 P/ a) N
  1894.           sheet[left_x, point_y] = step+ }0 h( D& H% H& r
  1895.           draw_path = true
    ; [, h. U+ T/ ?5 o8 r
  1896.           new_end_points.push(left_x, point_y)
    % \3 `# X0 y. @" R
  1897.         end1 x; ~5 [# K+ @8 [
  1898.         if sheet[right_x, point_y] == 0               &&) j1 h3 N, A" e1 I" B
  1899.            $game_map.ship_passable(right_x, point_y) &&6 `) A. ~$ V$ _6 v
  1900.            !collide_with_events(right_x, point_y)    &&% l4 F# {: v- H, c
  1901.            !collide_with_vehicles(right_x, point_y)  #judge_end
      C5 r9 a2 w: t4 X- S6 \
  1902.           sheet[right_x, point_y] = step& X4 ]2 w, k* n( }- V! B2 T4 H
  1903.           draw_path = true
    : R$ j* o/ Q6 V6 D; L# C
  1904.           new_end_points.push(right_x, point_y)
    7 P& B7 x/ |$ I5 ?5 `! |1 X  C8 `  [; [
  1905.         end
    4 O# o2 D4 ^6 u* j8 Y! n7 c3 u0 S
  1906.         if sheet[point_x, up_y] == 0                  &&6 G, a; `: v6 L) E, ]4 [
  1907.            $game_map.ship_passable(point_x, up_y)    &&2 j% q6 p* S" D9 c7 c/ e5 Y
  1908.            !collide_with_events(point_x, up_y)       &&4 t6 T. D! A2 r/ f
  1909.            !collide_with_vehicles(point_x, up_y)     #judge_end' u- ^, h6 A* P2 M- a+ l' b1 t
  1910.           sheet[point_x, up_y] = step' b2 V2 E! N/ \3 S: a. w% {: S4 Y8 t
  1911.           draw_path = true
    ! g7 m# k7 U* `6 o$ |1 ]4 Y' E
  1912.           new_end_points.push(point_x, up_y)
    ( U. Z7 V2 M! R" O' `: p$ U
  1913.         end# E& f- f: M# L7 v
  1914.         if sheet[point_x, down_y] == 0                &&
    , a8 Z7 d( f) p1 Y+ r
  1915.            $game_map.ship_passable(point_x, down_y)  &&$ P$ l% j! [" D) K# @
  1916.            !collide_with_events(point_x, down_y)     &&* Z7 W7 m" @! k0 s) C/ F8 @' P7 E
  1917.            !collide_with_vehicles(point_x, down_y)   #judge_end
    ) P' E8 `0 U+ }4 O: |* d
  1918.           sheet[point_x, down_y] = step
      S7 \: {% m  [" e/ {" g. D- o$ O
  1919.           draw_path = true. |8 l& q# ^$ g
  1920.           new_end_points.push(point_x, down_y)  b2 O! ?9 e" M4 T# ^: ~5 X
  1921.         end: h; P6 P6 y% r* R
  1922.       end#endOfLoop3
    7 i$ U, Y6 k8 `; p0 U' ?
  1923.       break if !draw_path  reach_point6 s, h. a* g0 b4 _, A
  1924.       step += 1
    0 q# p/ R2 U& P2 j
  1925.     end #endOfLoop1 路径表格填充完毕
    ' g9 d  k- X6 v) [
  1926.     $mouse_move_sign.transparent = false8 z3 f/ L  {6 [! g5 N
  1927.     # 判断指定地点能否抵达6 x3 U+ E+ C' r+ n$ ?$ d  J
  1928.     if reach_point9 g% Q9 \- {7 Q- U
  1929.       $mouse_move_sign.direction = 2: F' r  u4 y9 A* X4 R; t& l! g/ @
  1930.     else6 M  E9 \) o+ _9 h" Y
  1931.       not_reach_point; E' v, E5 N" {  }; \2 m& |
  1932.       return
    ! Z" V' l& I4 c$ `
  1933.     end
    : x" n" z: p4 b; i. J
  1934.     # 根据路径表格绘制最短移动路径(正向)/ T! o: O/ W) ~& o/ \. j
  1935.     steps = step  2  2
    ! P* c( A9 S) n" s+ z- Q' V
  1936.     loop_times = step  2" \& A) T+ n  S
  1937.     point_x, point_y = chase_point[0], chase_point[1]8 n0 W7 x2 s6 L% ]- ^
  1938.     for i in 2..loop_times # forLoop2 u+ X) [, o5 D/ Y
  1939.     steps -= 22 e2 G) Y! }$ D) [* @& [5 v. V
  1940.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs2 g# W4 @, i$ Q
  1941.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps/ b* F& _  n5 X% d
  1942.         chase_path.push(2)) H; H( B' n# ~" ?# d1 o
  1943.         point_y = $game_map.round_y(point_y + 1)
    1 [/ Q7 ~- e5 b! ^. g6 @  e
  1944.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps. g) f  _6 p0 ~" ?$ k0 B
  1945.         chase_path.push(8)8 {# ^+ h9 o5 o5 ~
  1946.         point_y = $game_map.round_y(point_y - 1)+ \% x. C8 h+ t
  1947.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    $ Q* G8 i9 v' \, |4 q2 I8 M# ?
  1948.         chase_path.push(4)  }* d& i9 v2 F
  1949.         point_x = $game_map.round_x(point_x - 1)
    % A" V# g" d) J
  1950.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    1 ]  j, J& k+ z( h% ]
  1951.         chase_path.push(6)
    ; d5 @3 y- j$ T1 M
  1952.         point_x = $game_map.round_x(point_x + 1)/ k! n+ q4 ]2 Y7 ?, i
  1953.       end0 H7 \7 f) X) a8 S5 {4 ?. G4 K
  1954.     else
    5 u* c! F8 @/ n; M
  1955.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    7 U$ \' Y( |6 @; D2 R* J0 p' u7 ]
  1956.         chase_path.push(4)8 T( A: e# J0 \0 I+ T% L% E9 w( k
  1957.         point_x = $game_map.round_x(point_x - 1)5 K: G# D( b5 P7 F! n
  1958.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    9 i- m  Z& v* E  T: v
  1959.         chase_path.push(6)
    % W4 b$ ^4 _/ G' ^, U
  1960.         point_x = $game_map.round_x(point_x + 1)
    , C% J/ N2 _) j. S
  1961.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps/ A* M9 H9 W4 g9 |& ~8 |
  1962.         chase_path.push(2)
    ! |: q+ J9 }! c$ ?" u* M" |. _
  1963.         point_y = $game_map.round_y(point_y + 1)
    # C+ t! c0 H7 V
  1964.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    4 q. M  U# t* w% E: Z2 s
  1965.         chase_path.push(8)  _7 @' [' v: u% O
  1966.         point_y = $game_map.round_y(point_y - 1)
    7 m" I. O2 C: F0 p$ `% K2 w
  1967.       end
    : f+ y4 R/ Q0 u9 u9 m  ?
  1968.     end
    / C: i: `4 V& o8 I
  1969.     end #endOfForLoop+ i: g. e) V, N% x
  1970.     # 如果指定点无法抵达或者登陆/ |* F- K' j- P: i/ m7 E
  1971.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)
    $ E1 Z4 k9 k. j( s  r
  1972.     # 根据路径表格绘制最短移动路径(反向)
    1 {# y/ w: L4 W
  1973.     steps = step  2  2 + 1
    4 Z* }  v2 T2 Q# o; B7 Z
  1974.     loop_times = step  24 Y& w& v# H5 ]) s" Q' }9 c: x
  1975.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]) \! x. r9 B. o2 Y9 m, [
  1976.     for i in 1..loop_times # forLoop6 |8 n1 Z9 D, ~" Y5 I/ o
  1977.     steps -= 2
    6 [7 ^8 H$ q5 G. z
  1978.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    * w% {, O$ H6 H
  1979.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    7 R+ s1 w& ~5 I2 t
  1980.         reversed_chase_path.push(6)
    ( W6 W  l/ `* M0 N5 E4 q
  1981.         point_x = $game_map.round_x(point_x - 1)
      y+ b- V+ D0 m+ E& f3 @( E+ \3 X
  1982.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    7 Y7 p  G: j: d9 g
  1983.         reversed_chase_path.push(4)
    / I- O: K% C+ T1 W) m% |3 p
  1984.         point_x = $game_map.round_x(point_x + 1)
    ) ?! ]9 t2 G# o9 I1 W. L2 h
  1985.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps& V' a$ Z6 {9 C, N+ x2 t% d; [  C
  1986.         reversed_chase_path.push(8)
    3 l; P6 Z" b7 o2 e; N2 n
  1987.         point_y = $game_map.round_y(point_y + 1)0 T4 P1 h. T4 }* }
  1988.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    ( Y/ R( N; W( }4 L. W: L5 b7 c
  1989.         reversed_chase_path.push(2)
    $ u$ `+ [  Z: O5 l+ w# e/ s
  1990.         point_y = $game_map.round_y(point_y - 1)
    , |/ R8 @9 e, |
  1991.       end
    0 s' a  H: T* b+ q" N
  1992.     else. V, Y0 K( i( j4 @6 W, E2 e
  1993.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps* z7 P4 D9 d# B! p0 {4 c4 Y5 a
  1994.         reversed_chase_path.push(8)
    ! n( g5 `) n$ w; i) e
  1995.         point_y = $game_map.round_y(point_y + 1)" ?( {  l( E$ `6 w) ~9 n3 l
  1996.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    # L5 X; M9 U+ s0 @" y' |
  1997.         reversed_chase_path.push(2)
    7 \6 V& Z7 t4 m7 J! C
  1998.         point_y = $game_map.round_y(point_y - 1)
    * l  F: _, L6 Z* u2 ]
  1999.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    0 \1 ?( B2 d4 |6 [
  2000.         reversed_chase_path.push(6)% I3 a& {3 d0 Z0 T
  2001.         point_x = $game_map.round_x(point_x - 1)& _* u; W1 J' j
  2002.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    9 B6 ^1 q: U: u7 ~5 B  ]
  2003.         reversed_chase_path.push(4)
    # x2 c$ x6 h2 W
  2004.         point_x = $game_map.round_x(point_x + 1)
    9 \6 S  j1 |2 ~/ {  ], c7 O
  2005.       end
    ! B, ^6 U0 n" o
  2006.     end3 m2 c  \1 F/ ]$ b! q( ~
  2007.     end #endOfForLoop7 Q+ s! G: l' S& g2 y. @9 j& \8 }
  2008.     @mouse_move_path = reversed_chase_path.reverse + chase_path
    ! r2 [& l; @  b* O/ R+ h
  2009.   end#ship
    & [; s6 w* o) v! K2 T/ A
  2010.   #--------------------------------------------------------------------------
    ! F( V, g5 `$ C7 `  F
  2011.   # ● 绘制airship的移动路径 @array[move_directions...]
    / t4 A7 Q0 H4 ]. i3 H
  2012.   #--------------------------------------------------------------------------
    + ^# s1 u& Y: |8 W( {  T
  2013.   def draw_air_path& S( m6 {/ @& v8 k
  2014.     $mouse_move_sign.transparent = false
    1 o, o# I+ k1 e3 E4 Z/ E0 L) P9 O
  2015.     # 准备绘制路径表格3 ~2 r, H' P" E
  2016.     sheet = Table.new($game_map.width, $game_map.height)8 j  A$ y% Q5 `; w% \; F
  2017.     new_check_point = [x, y]; sheet[x, y] = 1* T  l: z( R; u% O
  2018.     reach_point = false;      step = 2
    8 o" _/ f, q: h" |) z) Y3 J
  2019.     loop do #loop18 k% [: i# b$ |4 d; a( [1 M/ T
  2020.      check_point = new_check_point
    2 y4 B0 d8 d+ Z. ]# s
  2021.      new_check_point = []7 m# g- N  |- A, W8 I- @. R
  2022.       loop do #loop2
    5 W+ X8 X+ |' W) G. D
  2023.         point_x = check_point.shift
    ' R  a7 e" D8 e, B: g% T  |
  2024.         break if point_x == nil) i  v  e' P" g; T, _
  2025.         point_y = check_point.shift# H) B, s, H! L) K" k" P( N& T7 W: ?
  2026.         if point_x == @moveto_x && point_y == @moveto_y8 b7 `6 H0 C7 ^: w8 J$ X
  2027.           reach_point = true; break1 g$ x- h1 d+ e" W1 E
  2028.         end2 ~' @' `) i6 j
  2029.         left_x  = $game_map.round_x(point_x - 1)
    ; X2 g4 z: `: P4 D: t
  2030.         right_x = $game_map.round_x(point_x + 1)
    5 k2 h5 J- V% C, Z. l+ L
  2031.         up_y    = $game_map.round_y(point_y - 1)1 m" T5 w) _7 N: W, C# g1 U
  2032.         down_y  = $game_map.round_y(point_y + 1)
    . T( s& d( k5 P' [( O
  2033.         # 以需要抵达该点的步数填充路径表格 #" Z& D- r% D% Z+ w
  2034.         if sheet[left_x, point_y] == 0
    " ~. b. @8 Y, H
  2035.           sheet[left_x, point_y] = step
    3 X' s/ \( ^! Y3 \* O+ H6 B
  2036.           new_check_point.push(left_x, point_y)+ Y- x$ B: k+ R( K) I# P5 l" X, r
  2037.         end3 m3 z$ N' I! v) }( s5 q
  2038.         if sheet[right_x, point_y] == 0
    - Q$ b1 K3 k5 S1 Y& Z/ `
  2039.           sheet[right_x, point_y] = step6 _9 a; w8 G8 ^- T6 F3 k' X) J
  2040.           new_check_point.push(right_x, point_y)
    % h0 F- `) w0 I% D
  2041.         end, {$ W) t' z9 J3 N
  2042.         if sheet[point_x, up_y] == 03 X. H! f* L% ]- W! ^
  2043.           sheet[point_x, up_y] = step$ \. @% @1 ~; r" x5 K
  2044.           new_check_point.push(point_x, up_y)
    1 c/ t  _+ w. U8 b# t' ?! ]" [
  2045.         end6 l0 n( ~/ l( y6 D' J" K
  2046.         if sheet[point_x, down_y] == 00 D& r$ E* P: c4 |" a) Q  }
  2047.           sheet[point_x, down_y] = step
      \: y' F* S. T9 e
  2048.           new_check_point.push(point_x, down_y): ]# N  y$ f% `# s" I
  2049.         end; j$ P* u7 f) _7 B9 u% _
  2050.       end#endOfLoop2
    , y; ]5 h5 L; B4 I% @
  2051.       break if reach_point8 Y# u1 Q* Z5 x" u  n" n1 N# T
  2052.       step += 1
    1 ]3 m5 H* ?" I) |( h
  2053.     end #endOfLoop1
    ) B, U$ x& T+ e; |" s* o, I
  2054.     # 根据路径表格绘制最短移动路径 #
    ! y8 {3 b( W% E# G, H0 ^
  2055.     reversed_chase_path = []; step -= 13 L# D7 N4 d/ i: u3 b0 Q$ s  `
  2056.     point_x, point_y = @moveto_x, @moveto_y3 f6 ~/ J2 Y; A& O8 G6 g4 V/ c6 ?) H
  2057.     for i in 2..step
    # g* j+ {9 P4 _: _
  2058.     step -= 1# W' `% a! a! K7 i
  2059.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    % H& U5 r& V$ _2 v+ n
  2060.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
    ; b9 F# i3 j4 {% x: t  I( W
  2061.         reversed_chase_path.push(6)% H& Z  x! a# y/ O; }2 L9 e
  2062.         point_x = $game_map.round_x(point_x - 1)% L' r3 `5 W8 f& N( T) n
  2063.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
    + q  l2 K# }; `' j9 G
  2064.         reversed_chase_path.push(4)/ I* P3 H$ a: ?, n8 k  o* i
  2065.         point_x = $game_map.round_x(point_x + 1)8 K0 V, A7 }" W1 D
  2066.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step) u; h4 A4 Q" |( O6 c7 _9 G% G' d
  2067.         reversed_chase_path.push(8)8 G& C6 `9 w9 q0 A' j1 _) _
  2068.         point_y = $game_map.round_y(point_y + 1)2 h& d4 r& J4 V" o- |" w: u
  2069.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
    + y) [" C% [, }& w% d
  2070.         reversed_chase_path.push(2)
    . l6 x, i" s0 J4 {
  2071.         point_y = $game_map.round_y(point_y - 1)
    + W; l7 T: z9 @0 ^3 n
  2072.       end  e5 Y! A- a+ U: `( j" y
  2073.     else) U4 |: c4 s; e6 N) L5 `" k8 W
  2074.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step( a2 |: Z5 D" q+ w  M3 g$ J5 @
  2075.         reversed_chase_path.push(8)
    % Q7 g6 X; M! q
  2076.         point_y = $game_map.round_y(point_y + 1)
    3 c( Q! R. X1 P3 t! Z0 ^
  2077.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
    : S+ D$ r  _) l! f* L
  2078.         reversed_chase_path.push(2)
    " L1 K- P. k# i! O. w$ R; ?& I6 F
  2079.         point_y = $game_map.round_y(point_y - 1)
    6 y' v  p" b$ }) @7 U
  2080.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step/ L& V$ M  {; h! j% O7 @& m7 M. @
  2081.         reversed_chase_path.push(6)* g* l6 Y! `8 Q- N
  2082.         point_x = $game_map.round_x(point_x - 1)+ J; V: }1 {- {, C
  2083.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step1 h" Z0 B7 b6 Y5 Z3 B
  2084.         reversed_chase_path.push(4)- p+ D$ Q8 A6 W% T6 t
  2085.         point_x = $game_map.round_x(point_x + 1)
    6 D1 y0 ?* M9 ~4 ~& A/ b& f2 n, A
  2086.       end
    ! d7 r: ~8 E2 ]7 A' j  `4 G) F
  2087.     end% e9 X- M+ k8 c. Z0 R% g
  2088.     end #endOfForLoop
    2 _- o  D) Z6 b* c" k0 Z; ^
  2089.     @mouse_move_path = reversed_chase_path.reverse
    3 h4 B5 D4 h# C2 B) B" N4 w
  2090.   end#airship
    + Q( S' I  d! y3 Z3 i% M
  2091.   #--------------------------------------------------------------------------
    5 i+ w) E5 j  `5 C
  2092.   # ● 目标点无法抵达时的处理,用于各路径绘制方法内部- o% C8 E( u2 _
  2093.   #--------------------------------------------------------------------------
    5 P  B, k+ a' |5 z% |
  2094.   def not_reach_point
      g' D; @: `! E) o* O  t
  2095.     $mouse_move_sign.direction = 40 _# U8 T, u6 W4 Z
  2096.     dx = 0; dy = 0; dir = 0
    5 }8 {7 u% g+ W/ e9 ?+ R
  2097.     if @moveto_x - x  0& Y3 o* ?/ Q$ Z2 r' U( w
  2098.       if @moveto_x - x  $game_map.width - @moveto_x + x &&6 F4 I1 n- r$ D
  2099.           $game_map.loop_vertical0 K- y% h" Z, a0 B7 S' C' C
  2100.         dx = $game_map.width - @moveto_x + x; dir = 4( l3 z8 |& N" p9 q- n& l1 B. W
  2101.       else/ M/ I$ {% X. z3 V; z
  2102.         dx = @moveto_x - x; dir = 65 Z9 x' t, T( D. r% L0 W! a
  2103.       end
    5 ^' b" h' \9 u
  2104.     else
    / K" j; l0 \, R% x: b
  2105.       if x - @moveto_x  $game_map.width - x + @moveto_x &&; ?$ _; l3 E7 a- C
  2106.           $game_map.loop_vertical
    8 t' z* L) x; d. V
  2107.         dx = $game_map.width - x + @moveto_x; dir = 6
    & b, U, K9 \/ S9 ]
  2108.       else
    & N7 L3 X* r# j7 g, J; ^) G
  2109.         dx = x - @moveto_x; dir = 4
    2 O& q, I3 d3 J# O$ ]) L3 o
  2110.       end
      g5 Y! w" E0 U' w. D8 I
  2111.     end
      i# y# q, _9 g9 Q- H
  2112.     if @moveto_y - y  0* N( i& d' l% ?
  2113.       if @moveto_y - y  $game_map.height - @moveto_y + y &&! x1 c: }3 L& [  I. I
  2114.           $game_map.loop_horizontal# w2 {) z& F% M6 S
  2115.         dy = $game_map.height - @moveto_y + y4 x- ?' [  u# a$ R, M" y! `! R- E
  2116.         dir = 8 if dy  dx( F/ K; L' }: \& t4 C* d
  2117.       else* G! _5 k2 s0 ?/ O+ e7 o% v5 S
  2118.         dy = @moveto_y - y1 p0 h6 x# N9 ]4 U$ ?! P
  2119.         dir = 2 if dy  dx- M# s( E& B  \9 V3 U
  2120.       end4 X; z6 b& r. h: H1 y6 u+ ~
  2121.     else
    ' }. C6 ~0 x0 ~5 q% d6 s. E
  2122.       if y - @moveto_y  $game_map.height - y + @moveto_y &&& w% @5 q- C/ d/ k% g3 P
  2123.           $game_map.loop_horizontal
    + h( M; [- C. T( ^* ^
  2124.         dy = $game_map.height - y + @moveto_y; q# r8 H$ r  L9 B$ Q
  2125.         dir = 2 if dy  dx 8 [$ V! H! }9 n  n3 s8 V' Z
  2126.       else
    % t/ ?( C7 ?% y. f3 n
  2127.         dy = y - @moveto_y
    . r9 `% a% M3 D. `- \6 U" e8 N
  2128.         dir = 8 if dy  dx4 R+ Q6 Q. P0 R+ u
  2129.       end
    5 z) q: s0 F* z0 c1 w$ M
  2130.     end
    0 n- B' v0 j+ H
  2131.     @mouse_move_path = [dir, 0] # 0方向用于防止移动过程中触发事件
    ; W2 n) `% k8 @* ?
  2132.   end0 ?/ d8 [9 U- p
  2133.   #--------------------------------------------------------------------------
      {# |, M2 `5 B4 }" `
  2134.   # ● 判断目标点是否能抵达、登陆,用于船只路径绘制: ^4 L$ ?* R7 H( h* S& C2 m
  2135.   #--------------------------------------------------------------------------9 x6 R  X2 Y' N* m( g" a
  2136.   def landable(x, y, path)
    4 W1 E2 k! I2 G* H0 v1 Z  P
  2137.     case @vehicle_type
    ' r' ]1 o/ ]% w" Z
  2138.       when ship; return $game_map.ship_passable(x, y) 0 S1 m$ \' I1 j9 z( J/ k# \0 R
  2139.         $game_map.passable(x, y, 10 - path[-1])) c# i3 ]# ~. r5 B; v! E9 Y% x
  2140.       when boat; return $game_map.boat_passable(x, y) 7 z7 a7 L  F! E+ Z
  2141.         $game_map.passable(x, y, 10 - path[-1])
    3 [+ w. l8 e- _* z
  2142.     end, a; y4 L4 k: }* z
  2143.   end: z" H) F. P1 A5 v0 E, a4 {
  2144. end) b7 z/ Y: q$ d! h

  2145. # t. n2 f. Q% V  Z6 W
  2146. #==============================================================================1 y; Y* Y, K! I  f
  2147. # ■ Game_Map
    7 Q% M( z/ u. E  v: {
  2148. #------------------------------------------------------------------------------
      c" e/ M( o1 f- a1 i/ M
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。9 M8 l* U/ i0 y& c
  2150. #   本类的实例请参考 $game_map 。* A- ~% }- p- j
  2151. #==============================================================================
    4 k0 u; b* w" K) g, T' `' N7 S
  2152. class Game_Map
    * T9 e9 y3 [. q/ S
  2153.   #--------------------------------------------------------------------------- ~* Y) }* @0 X; y+ A/ ^6 n
  2154.   # ● 定义实例变量5 T/ O4 L% |6 s" F
  2155.   #--------------------------------------------------------------------------+ m# v/ @9 H# y- D0 z, M
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
    ( h- y) Z0 ^6 t2 R  U( B: q
  2157.   attr_reader mouse_map_y # 同上
    9 @# n  D; H" j1 w4 |- e. ]; p
  2158.   #--------------------------------------------------------------------------
    4 G) v( M$ U- }  I% S, p
  2159.   # ● 初始化对象
    8 W' i8 \3 `  i3 z. Y
  2160.   #--------------------------------------------------------------------------
    ( V- V5 b: \" W# G# l+ N
  2161.   alias sion_mouse_initialize initialize/ \  C. H( }5 d* B
  2162.   def initialize
    2 ?7 {& W! c/ M$ S8 K5 N4 w9 D
  2163.     sion_mouse_initialize' m& b+ M2 L4 |3 T
  2164.     creat_move_sign  ###
    $ P: b6 ]& J* J
  2165.     set_constants) }5 {2 ]* Y1 c* u" K4 @1 \% m2 n
  2166.   end
    . Y9 R. s' ?2 x, C2 T
  2167.   #--------------------------------------------------------------------------
    ) M% S& {* l4 e0 z$ u1 D' ]! ]) G
  2168.   # ● 更新画面2 K7 l4 V6 G! w" s* V$ w
  2169.   #     main  事件解释器更新的标志
    9 L6 A' K  q0 r, [
  2170.   #--------------------------------------------------------------------------
    8 G1 X7 Q) G' n4 R6 [8 C0 X
  2171.   alias sion_mouse_update update7 x; g  Y; H2 g. T% [
  2172.   def update(main = false)" _" _- c- C5 n! U
  2173.     sion_mouse_update(main)
    ) D. E/ V" N; H% T% j
  2174.     update_move_sign
      H" Z. _5 D0 H4 T( H  l% o
  2175.   end
    7 X1 ^7 N( H- s- u
  2176.   #--------------------------------------------------------------------------; H5 l$ t# M" F+ V6 u
  2177.   # ● 创建显示路径点的事件7 P( v: M' ]& z6 N+ p
  2178.   #--------------------------------------------------------------------------
    + }: L- ~' U* _2 V+ a
  2179.   def creat_move_sign
    7 j) C5 o8 t2 G
  2180.     $mouse_move_sign = Move_Sign.new. I" Q% n% y: @* ^+ N/ I) @
  2181.   end) X* a& X3 p4 v4 E) F- a
  2182.   #--------------------------------------------------------------------------
    6 U) \  l! I! f9 Y3 F
  2183.   # ● 更新显示路径点的事件
    * X& j5 h7 l& {8 |( {
  2184.   #--------------------------------------------------------------------------; `# I* W) Z3 C" A
  2185.   def set_constants' A/ v4 n  _) P- p& i$ k. T( B
  2186.     @mouse_pos_setted = true0 ?# d- c- n  K, v5 t, K2 l* x$ |# k* i
  2187.     @set_pos_prepared = false
    . l+ |9 i& F. k8 F1 P
  2188.     @mouse_old_x = 0# E/ a& e& R; l& i0 Z8 }
  2189.     @mouse_old_y = 0: y  a1 w  @+ C( \6 K
  2190.   end7 T1 ?9 [* V) O1 l4 e) \( ~
  2191.   #--------------------------------------------------------------------------
    ) \4 r% e" H( K6 w
  2192.   # ● 更新显示路径点的事件
    5 l. h) b% h; ^  m( }7 G
  2193.   #--------------------------------------------------------------------------
    5 V' W- x$ ^* m/ H7 Z
  2194.   def update_move_sign9 X* h' }8 i9 @5 c  @. l
  2195.     $mouse_move_sign.update
    & L: ^% K) B5 y9 ]
  2196.   end
    3 B: m; p3 E, t) k
  2197.   #--------------------------------------------------------------------------
    4 F* @* C' k- [% e
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    ) F) c  i$ h: q; m
  2199.   #--------------------------------------------------------------------------0 @  |) A/ e2 M# ^
  2200.   def get_mouse_map_xy' S3 c$ ^# p& L! w3 |! l! c; V
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ) W0 O9 {6 v4 K8 X* a
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    9 w+ q# e* C! H- \% y. r5 n
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)# R% C% z& i1 q4 }
  2204.   end
    0 i. [1 s9 Q! g7 t; h
  2205.   #--------------------------------------------------------------------------- Z( x  k+ r- [, h. b+ u" l
  2206.   # ● 返回地图画面时重设鼠标坐标
    ! U8 _9 U* o4 K2 z
  2207.   #--------------------------------------------------------------------------* i. o8 ~0 g2 N6 S2 F5 D
  2208.   def reset_mouse_pos8 C+ O) V& Y% }* \
  2209.     return if @mouse_pos_setted/ a4 w. v  G. G* s+ H$ ]9 s
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)" l1 c& }( B1 w% V: o
  2211.     @mouse_pos_setted = true, N9 r% f0 M$ [
  2212.     @set_pos_prepared = false) }, \! I; |) V1 W) C' n5 n- D
  2213.   end" i' G6 ?2 j# X% ~7 O: t$ H
  2214.   #--------------------------------------------------------------------------
    3 h$ M# i' k( z( |! p) }
  2215.   # ● 重设鼠标的坐标
    7 _& L$ a7 A4 d4 ~2 o4 h, a  j0 s
  2216.   #--------------------------------------------------------------------------
    9 i; \2 O" `4 s5 X, C; |
  2217.   def prepare_reset_mouse_pos
    ) _& m" L4 L- d' Q4 u; A
  2218.     return if @set_pos_prepared
      P( e& Y$ \/ E- s
  2219.     @mouse_pos_setted = false
    4 A! L! r7 O* B# V/ [
  2220.     @mouse_old_x = Mouse.mouse_x  D1 W0 X6 k$ y
  2221.     @mouse_old_y = Mouse.mouse_y5 \/ B2 R) ]# L8 _! O0 X) E
  2222.     @set_pos_prepared = true
    0 C. P# |( _& ~
  2223.   end
    7 q! @: P! i8 v3 j! y' ?  x
  2224. end
    - f7 l! n. b& |, E5 W& ~5 X! ]

  2225. $ L: |8 I: r# H) D  ^& m/ j  ~
  2226. #==============================================================================7 c/ D+ q  L3 n% K* r* Q) o
  2227. # ■ Spriteset_Map
    " z. l. s- O6 c% f- h' b
  2228. #------------------------------------------------------------------------------0 n7 W! b' N. |1 c
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。" t& Q+ ]+ i6 m2 ^
  2230. #==============================================================================
    ' C6 {, L" ]% S
  2231. class Spriteset_Map
    " f  ]7 k4 G- U  F! j& e3 O
  2232.   #--------------------------------------------------------------------------
    4 M/ ]% o( v% C# u0 ^6 L
  2233.   # ● 生成路径点精灵% y' m5 }5 A2 k+ D# g0 o7 L* d
  2234.   #--------------------------------------------------------------------------. Z+ N3 }+ F6 X6 Q" E
  2235.   alias sion_mouse_create_characters create_characters9 O  ]* T' S6 z6 G
  2236.   def create_characters
    2 i( i/ B# W; x! H9 `1 @
  2237.     sion_mouse_create_characters4 T3 W1 \6 j" i& F, T4 G, o
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    ; Z8 c2 n2 O) _2 L0 f
  2239.   end; p) H1 W' _( x$ H8 i2 z) R
  2240. end
    . ]* \4 M6 ?% M; w$ j: D" ^# |/ G
  2241. $ y+ o5 M/ G' P; p5 Z3 A
  2242. #==============================================================================
    $ _0 ~9 |$ N/ t. p% I$ N0 ?3 N  J
  2243. # ■ Scene_Map3 @. [' v6 F  P; e. p
  2244. #------------------------------------------------------------------------------
    ' d: q! k1 \: Z
  2245. #  地图画面
    ) \8 _8 _1 F2 w! z1 Y% P  ?( ^5 s
  2246. #==============================================================================
    0 v6 N2 v9 M  {4 V
  2247. class Scene_Map  Scene_Base7 j, ?( J8 F8 Z9 E. a$ M0 G7 I
  2248.   #--------------------------------------------------------------------------/ F4 X/ |! P$ X" t% |
  2249.   # ● 画面更新
    ' G" E  R( o! N& [( ]8 [8 f
  2250.   #--------------------------------------------------------------------------$ k  H% J  v6 J  b1 T; X8 G/ c
  2251.   alias sion_mouse_update_scene update_scene0 A* Y& h. B1 Q. H( S. ^, C  F
  2252.   def update_scene
    ! r9 ?: k# v9 @0 b6 k& j/ R2 t
  2253.     sion_mouse_update_scene8 h1 m& H: A' v
  2254.     update_mouse_action unless scene_changing% a* P1 t/ @6 @8 H8 R/ i) g; F3 j
  2255.   end) F0 D4 Q/ w+ {* k) m- {
  2256.   #--------------------------------------------------------------------------
    1 W0 Z/ k* {( T' M% D: i
  2257.   # ● 场所移动前的处理
    9 M4 |3 O! U; M1 B2 u
  2258.   #--------------------------------------------------------------------------
    8 {. ~, u- D8 ?1 ~7 o
  2259.   alias sion_mouse_pre_transfer pre_transfer6 V& K' a( }2 g/ b
  2260.   def pre_transfer5 G" n/ D* {" P0 u  H3 D
  2261.     $game_player.reset_move_path5 ?& n/ t% `# z
  2262.     sion_mouse_pre_transfer2 w! O" F! R7 o1 i: f" w
  2263.   end. P+ @7 V8 U. i  M
  2264.   #--------------------------------------------------------------------------
    7 ?, e( [, W9 H" u7 G: C! |2 R& M
  2265.   # ● 监听鼠标左键的按下
    . O* @" u/ Y' r$ n5 E% E6 Q: A
  2266.   #--------------------------------------------------------------------------; a* Q( {6 C: o) L- {
  2267.   def update_mouse_action4 s# [1 k0 K. v
  2268.     $game_player.left_button_action if Mouse.press(0x01)  x- y- G# C7 C) g
  2269.   end2 p+ g3 g, v3 l0 F3 G* u# ~
  2270. end
    5 G% ^9 Y; c( p: ]. V8 |0 g2 M: m
  2271. 9 f) L" b' e4 r7 q) K$ f
  2272. #==============================================================================
    : M6 ^, n: g# C( K( U
  2273. # ■ Scene_File; w% e$ S& l! I! ?
  2274. #------------------------------------------------------------------------------
    6 K( V* u, P% {/ T: ]$ f) P) ?+ U
  2275. #  存档画面和读档画面共同的父类: k& ^( L0 M4 r( {' m; s
  2276. #==============================================================================; e& k% w2 T9 b. m& A% y
  2277. class Scene_File  Scene_MenuBase
    5 ~! \- [5 Z8 m: h+ W
  2278.   #--------------------------------------------------------------------------
    " Y6 W  W6 z8 v0 A6 b
  2279.   # ● 开始处理
    2 q8 l# G/ H4 T/ A' a
  2280.   #--------------------------------------------------------------------------% u" O$ X  u/ u8 z7 H. h
  2281.   alias sion_mouse_start start
    1 {2 Y2 V8 O1 e; O
  2282.   def start
    # g; @+ r9 s7 @0 w
  2283.     sion_mouse_start; H, v+ o$ W8 r" ?
  2284.     @move_state = 0* H0 `3 Y" `" S( y. z
  2285.     set_mouse_pos+ D) R. T) s$ c  X% a! @( W! K9 j. M
  2286.   end
    . b8 ^! F2 e) Q5 f0 E
  2287.   #--------------------------------------------------------------------------
    * {4 v" p% q/ z: t
  2288.   # ● 更新画面
    4 C# V$ c/ }( y% G- W1 E
  2289.   #--------------------------------------------------------------------------+ E: ]( s+ p" q% w1 m" k; u
  2290.   alias sion_mouse_update update% m2 [/ V* x5 ]
  2291.   def update! ^3 ?, S" w2 b
  2292.     sion_mouse_update/ U) I- T) c& j7 H  a& ^
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    1 \. s; ~, \' `/ K& _" x
  2294.   end
    , y# w7 y# b: z/ A
  2295.   #--------------------------------------------------------------------------
    5 D: X! J& i' X# @7 u  e) Y# v9 ?
  2296.   # ● 更新光标7 o4 u+ r2 U- w  }- B, W( I, t
  2297.   #--------------------------------------------------------------------------
    0 @  `) J. j& ^- K
  2298.   def set_cursor6 r5 J& P2 T/ E7 H. k0 }
  2299.     @move_state += 1
    ( c9 F& W6 Q% A2 ~# a: |
  2300.     last_index = @index
    * H% j! X5 _. |  a: G
  2301.     if mouse_which_window == -2( d) r; f+ S, F4 o+ a
  2302.       if (@move_state - 1) % 6 == 0  D4 x- n# d8 N. I: h: A
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    % Q: A$ \% L3 s3 n
  2304.       end
    2 S: O! Y( k  \! O: p1 m6 V
  2305.     elsif mouse_which_window == -1! L% \3 M  z! d  @
  2306.       if (@move_state - 1) % 6 == 0
    ' w2 a2 o: P3 z+ }! x6 h. ?+ |, O
  2307.         @index = (@index - 1 + item_max) % item_max if @index  09 L; y3 W+ f% Y& u3 Q
  2308.       end3 @5 O# s& x9 ^7 q1 S1 f5 k
  2309.     else
    6 I/ U" H# w* e" T7 G5 c* T9 _
  2310.       @move_state = 0" [0 G( Q+ g1 w
  2311.       @index = top_index + mouse_which_window
    # w# x- h1 j0 Z/ i6 x: ?
  2312.     end# {# d. a  y; {( p
  2313.     ensure_cursor_visible
    * `0 c. g2 O- X2 }
  2314.     if @index != last_index
    5 K/ F- h0 A5 K0 U6 l/ Z6 ?: X
  2315.       @savefile_windows[last_index].selected = false
    % q) S2 m  C" ?0 p; Y* V1 V
  2316.       @savefile_windows[@index].selected = true- ?" w. C, L! v. j+ f
  2317.     end
    9 V8 E: ^& `6 B' u8 g
  2318.   end/ Y2 |) a1 S8 v2 R( s4 w0 ?
  2319.   #--------------------------------------------------------------------------
    3 J+ |# b( N) X' |% c
  2320.   # ● 判断鼠标位于哪个窗口
    ( k6 m8 t& E$ e* N8 H- b# a
  2321.   #--------------------------------------------------------------------------
    8 ]( Y& t& Z  Q/ X" L
  2322.   def mouse_which_window# u' @% g0 J5 f# ^% E5 U6 y8 D
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    : e: @7 E+ S3 q; g
  2324.     if mouse_y  @help_window.height + 14' G* u2 w/ w2 C6 n2 Z1 c1 f
  2325.       mouse_row = -1- o" L. R; [; k( O' B' d) v9 I  [
  2326.     elsif mouse_y  Graphics.height - 14
    * b) j0 d& R2 {5 q# W- N- f
  2327.       mouse_row = -2! t' t) ~% ~# x  z
  2328.     else2 d( Q9 b% g/ G3 X
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    : m/ o# \  ]3 V1 u) D- X: r) M
  2330.         (Graphics.height - @help_window.height)
    " m+ o, m4 W3 T6 B$ ^' K
  2331.     end
    ( m& U; W3 E( a  z; J4 b
  2332.     return mouse_row# u. ^' Y! k( [( }3 Y9 ]0 B/ I
  2333.   end  o% R  Z9 l% H% l9 G! L( R; Z
  2334.   #--------------------------------------------------------------------------, }0 v! {$ {) E
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    / N# V% o' d8 B+ H1 x9 U1 C
  2336.   #--------------------------------------------------------------------------' d6 O, ^7 N, K& T6 M# S. u
  2337.   def set_mouse_pos
      d7 B7 U( R6 [' s
  2338.     new_x = 40
    1 i+ H6 H6 }8 I% \4 s
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    7 Z4 P7 o) `* W! D; O
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    ' c& p5 f0 ^0 X* S! v
  2341.   end
    6 E/ n- m& J0 j$ ^( v! n1 Z
  2342. end3 x- v4 ~& w2 r  M+ D  W1 v# S
  2343. ' F) |8 }* N& {
  2344. #==============================================================================, t7 m! e: w4 @0 `: i
  2345. # ■ Game_Event
    6 k: m+ E( Z/ G1 v
  2346. #------------------------------------------------------------------------------
    : O9 W, o+ }  m, H9 P. y
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。0 ~4 F9 l/ k8 d3 F! g7 ~+ r; s- i
  2348. #   在 Game_Map 类的内部使用。
    6 e3 L$ d( i  \0 d" z
  2349. #==============================================================================
    0 N& g1 Y6 _4 C' p. [
  2350. class Game_Event  Game_Character5 k( J2 p6 ]( o, s
  2351.   #--------------------------------------------------------------------------. j6 `- o6 f4 ^9 |% l" r  ^0 \4 A5 l" O
  2352.   # ● 事件启动6 V5 D  v( C& x" A/ @5 C
  2353.   #--------------------------------------------------------------------------( B+ ?% ?7 f6 d8 U/ ^
  2354.   alias sion_mouse_start start* e  x; [7 s  N/ U
  2355.   def start4 G2 @5 w7 J: }! t) H
  2356.     return if mouse_start && !Mouse.press(0x01)
    - b8 D8 P2 K  `
  2357.     sion_mouse_start/ g* o  I' W0 L0 S0 g
  2358.   end9 D6 |7 k& t: y1 r
  2359.   #--------------------------------------------------------------------------; g( I8 ~; ~6 Y' v3 v& M7 ^& P
  2360.   # ● 判断事件是否由鼠标启动* x% D' C+ }0 h) W( m' D
  2361.   #--------------------------------------------------------------------------
    / P4 z* o5 f* n- O) M! }7 u' z  e
  2362.   def mouse_start
    & f8 k1 m8 l. X/ x/ s
  2363.     return false if empty6 k4 k, e5 q  |( M- }4 r
  2364.     @list.each do index
    0 q( Z1 [3 a7 X0 r& `# u) u7 j2 Q5 j( k5 G
  2365.       return true if (index.code == 108  index.code == 408) &&% i1 ]% l8 _# l/ f
  2366.         index.parameters[0].include('鼠标启动')
    : m6 j: s1 |! c; Y1 D8 H  m
  2367.     end
    2 [" W4 H7 x3 D+ A. {
  2368.     return false! G+ m. |0 ?9 @: B. i- n7 K! U; l) [
  2369.   end  x& Z  }$ \) I6 u
  2370. end
    " E; A+ e8 O) D+ U/ f" B# v' `

  2371. 8 @# _- @- j7 x$ J$ W3 p
  2372. ####泥煤的height' ^" D0 ~: a# h* `( w4 f% l& j
  2373. # @height = height
    2 `& ?) q' T( B; e2 g1 R4 p$ J7 ]
  2374. : D2 n2 w$ b" s+ B, g  ?% r' h7 J& _; R
  2375. class Area_Response
    9 H! }. }: U7 o  t0 R
  2376.   attr_accessor type
    ! @+ J% u$ {; C' S/ c
  2377.   attr_reader ox
    ) y' W6 c  W$ Z
  2378.   attr_reader oy
    * T* i) ^/ i7 z7 k) [' e/ y
  2379.   attr_reader width
    3 d: D. U4 M1 r, }" |2 C) }/ @; U
  2380.   attr_reader height( o1 @% U! o1 T8 `6 p
  2381.   attr_reader switch_id
    / U( m, t2 j/ C+ H
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)5 Y3 c. I" A! }! M" Y
  2383.     @type = type( ]0 R* c' P( o. f
  2384.     @ox = ox8 o- C6 f2 H0 H2 I
  2385.     @oy = oy
    5 [/ g; \' K# p3 ?* X
  2386.     @width = width9 S2 ?8 y3 i8 v
  2387.     @height = height( n! a1 d+ I, R' i1 T3 G- @
  2388.     @switch_id = switch_id
    5 B9 R! B. j6 K0 g. o
  2389.   end
    ! H: I) G0 @6 M3 d  ?
  2390. end
    * l: A9 O% ]/ V& o+ q, \' M

  2391. 3 Z9 {' _; n. j! V2 O/ O2 }
  2392. $area_responses = []4 |6 b7 ]0 i) c) N+ c$ Y

  2393. ; j6 c6 q* D, W( U& W$ D
  2394. class Scene_Map9 y4 u, K' a# I% m# \" k$ f
  2395.   alias update_mouse_2013421 update_mouse_action
    & X  m1 ~6 c9 {( ^6 Y% [5 k7 T
  2396.   def update_mouse_action% q4 W! S8 U: g
  2397.     update_area_response8 e5 [; ]% ?3 V* u; u' L6 N
  2398.     update_mouse_2013421
    - x& Y5 L* g- T) F  b& N  L
  2399.   end2 I' t; K+ n) r: a
  2400.   def update_area_response, g9 m- b- t. r) k" G- Q7 s  w/ c
  2401.     responses = $area_responses5 E( L, Q; r/ d
  2402.     responses.each {response
    / }- v2 ~+ s" n) E& y  _/ h
  2403.       ox = response.ox* ~1 p" ^* w& C0 F  g- a8 Z
  2404.       oy = response.oy& C7 _, C7 |, F2 ?% ]
  2405.       width = response.width
    * X( b6 h' E9 U  Q. z! D* ^
  2406.       height = response.height2 T* h2 o- l, e/ f, B
  2407.       switch_id = response.switch_id
    1 R3 U/ i. Z4 ^+ t
  2408.       case response.type
    1 X7 l0 a; B+ X" U7 T; f% [) f5 }
  2409.       when 0
    3 x/ o. A) \" [% l4 ^
  2410.         if mouse_in_area(ox, oy, width, height)
    1 u9 `7 j8 t4 X5 c, c2 r
  2411.           $game_switches[switch_id] = true  e0 M/ R7 a; @; L8 a
  2412.           $area_responses.delete(response)
    6 N2 @" P% q5 T
  2413.         end
    # Y1 c  {* d( Y
  2414.       when 1* h8 }" |2 G) \7 J* r
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)9 Q$ i0 [2 N9 p) L
  2416.           $game_switches[switch_id] = true* P9 Z7 b0 d% Q; B9 R
  2417.           $area_responses.delete(response)
    % k1 z4 N- w+ g  B
  2418.         end- M( H( j6 Q* y# [6 O  z1 v! r
  2419.       when 2
    * }. U7 [; I; L& z" m" R
  2420.         if mouse_in_area(ox, oy, width, height)
    % ^1 v3 |# t( G8 c% r' u3 w! J
  2421.           $game_switches[switch_id] = true& g! j0 f: I- n
  2422.         else
    ! A* _: d% w9 j1 o  F* x- k6 b
  2423.           $game_switches[switch_id] = false+ U( A, i3 s) G) U( S! g; D
  2424.         end" H8 Q2 Q% E# B% y; C- o  z
  2425.       when 37 ^4 x) a8 @. b1 ~# {) O$ D! ?
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,1 Y+ Z8 `) |4 ^* E& T
  2427.             (oy - $game_map.display_y)  32, width, height)/ ~3 Z! ]2 z: G# ], T
  2428.           $game_map.events_xy(ox, oy).each {event
    8 h% l3 d% j- C% `
  2429.           event.start+ N/ P4 _% L* v7 D+ `& U
  2430.           $area_responses.delete(response)
    ' W0 u. ~7 k4 M5 n- }
  2431.           return' ^" ^6 l( H& M* G. o
  2432.           } / v: F# K5 }, Q8 F
  2433.         end+ u0 A& p6 O  o$ ^0 n2 f
  2434.       when 4/ D6 g1 u: u- Y8 @1 V, }* k
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,$ Q9 U/ O" N8 Y( n) C3 b
  2436.             (oy - $game_map.display_y)  32, width, height)
    ! x) `4 X" C+ G" \; Q8 c0 n- u" w' l
  2437.           $game_map.events_xy(ox, oy).each {event, C' Q' G. f  `" |5 Y7 I7 V' E
  2438.             event.start+ Y! i. x* r1 E  D
  2439.             return
    ! N6 b! W- v' |3 [) q
  2440.           } : A9 R" G# v3 W9 C. ~- H* _" r$ D+ j+ `
  2441.         end/ W1 K" g) Q* N  D. o# I7 y2 n* j
  2442.       end
    0 X! X0 _0 A/ O" D+ M5 C( {  g
  2443.     }
    0 N2 u& h5 K, H
  2444.   end$ I# s( I/ P; y  U
  2445.   def mouse_in_area(ox, oy, width, height)& z. S! o9 X  P) x9 ?. V
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&5 L  p- K+ U; V# O& p* B# @0 V* N+ c4 F
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height' y" i5 F+ j# F2 P* @$ \+ d
  2448.   end% v0 \0 k" t! ^# B& ^9 t( w
  2449. end
    3 O% ?% {* M( o  h6 x
  2450. class Game_Interpreter
    ) ]2 i6 N$ U6 y- I1 Q. v  R
  2451.   def area_response(arg)
    8 e+ H* Z4 L1 b  m% F
  2452.     $area_responses.push(Area_Response.new(arg))+ S: ^* v6 c% O
  2453.   end
    / T  Y- M7 O+ v% d2 @
  2454. end, ^" {+ E8 J4 ^: K8 V4 ?
复制代码

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

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

GMT+8, 2026-7-24 07:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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