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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    2 _- s5 S4 h, X! h
  2. ) K5 O# |9 {4 t. y1 q7 O% H
  3.   Sion Mouse System v1.3e
    : \$ G1 n/ d0 X* ~: [" {) L7 T
  4.   
    5 O- X4 P. [+ H% C5 y3 l
  5.   Changlog  `$ }( |7 |+ `* z# [
  6.   
    & k- e- U+ ^( c( Y
  7.   2013.4.21 v1.3f
    + |; n5 ]0 B; o4 W0 u8 f! b- i* Q5 E
  8.     4 b' m8 |$ \9 y, U, y
  9.     1.3f 卷动地图 bug 修正
    6 R( E( i9 F5 D4 ]& G4 q8 s
  10.       f( W, y) z5 R# k0 K
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    " _8 ]* A" o; ]) u4 E. G$ M. K% C' i
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内% {# w9 r$ v2 m6 Z  o
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    % }7 e- q7 J6 I1 y0 ^; G+ ]1 g  S

  14. # J2 T5 E2 k  L! B8 p# e
  15.     1.3f bug修正
    ! l$ l4 M. M5 y- o
  16.   - t2 t' f8 x0 U) C$ I+ y( J
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    $ f. l2 ?( u3 D" S# u
  18.           关闭菜单时,鼠标是否移动到原来的位置。( Z' w- E5 M- u; Q
  19. % Z5 c# B% {  x6 A
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    7 k$ A' |2 f) K, ]& l' Q) a; E
  21. 2 s5 P7 y9 Z( T! Z3 z. x% I9 Z
  22.     1.3b 修正一些罕见的bug;  P) _9 d( n5 A, ~1 s

  23. 3 B0 O3 ~: Q0 l
  24.     1.3a 代码小修改;6 x7 N( F) u1 w& Z6 F
  25.           加入了鼠标点击启动事件的功能,! W$ ~( j* i9 e
  26.           在事件中加入“注释”: 鼠标启动  ,) N, j2 E$ D0 e9 @  E5 Q/ {
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    6 P9 {- g* f, J& [) m" }/ Z; ]  C
  28.   
    & G9 ^: L9 i8 ]
  29.   2013.2.12 v1.25 E  L: E7 n+ n$ ~0 ?5 X$ |
  30. ! Z/ O( @% A8 y3 z( o$ t( \3 ?
  31.     寻路逻辑优化;
    ; X2 h+ `$ Q& B- d& ~$ Z1 K
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;1 p& t5 w2 ?( Z6 f  a0 o
  33.     现在支持用鼠标来操作载具了。
    % G0 L! X6 z- K

  34. . I8 g* p: G8 `( K3 I$ I$ v
  35.   2013.2.8 v1.1
    / p3 O$ y3 t8 R+ z% e

  36. 3 A. Z6 R- C9 p* O
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    / C5 r( r3 I' l0 T
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;( `  {/ M0 X) _. ?0 \' M
  39.     移动时,路径指示点的绘制更加稳定;
    - O/ ]' S4 h7 @" P# F. M
  40.     现在支持默认存档画面的鼠标操作了。6 a4 x, A7 ~$ G8 T. w1 O

  41. 3 N/ L. D- Q+ a5 L3 o

  42. 0 P& J9 _$ t( b) i1 J
  43.   OrigenVersion( p2 a2 W! o* \4 t
  44.   
    / J8 Y1 N; T) m! h: z) T
  45.     2013.2.7 v1.0
    ) Y% V! V% e* t; G8 n
  46. - }* j- y* w, r1 R4 @8 {5 d' u
  47.   主要功能9 m- U8 y4 N# J+ j5 b' |
  48. ' z* I$ |" r3 k
  49.       使用鼠标进行各种操作...) e: H* {$ {1 h# C0 {0 E0 g, k
  50.       将鼠标锁定在游戏窗口内. D) N5 P( V) i7 M$ Q, }1 b3 \% M0 x
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    1 e$ E5 X: J! d, ?& x9 L/ {
  52.       双击鼠标进行冲刺4 l: J5 _7 P( V# i/ \
  53.       更改地图卷动方式以适应鼠标移动! \# j. {8 i* n" C- m
  54.       变量输入框改良
    % K$ @4 z, M8 X- B
  55. - v4 c+ S7 @6 M0 Y4 E4 u
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    $ @! u, l4 \) y  b6 ^0 _4 ]/ \" g

  57. / V$ V5 E" S  Y0 a
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹0 f( E% p# G5 Q- z. O8 B8 X
  59. 3 l4 _3 d1 {3 n% u0 U) o; f
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    ) P( [' D$ O$ f: c7 h2 ]: r

  61. . B  A7 Q8 Y# ?/ B: n0 |
  62. / c9 J* _, G& a$ V
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    : Q' C/ D$ X5 r+ v7 s
  64. # \: \) x$ ?! f6 t9 p: `+ l$ P
  65. ; ~* H5 p7 q! _5 `
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示& }- P' ^% }: R

  67. 3 w( \! o( ~1 b+ v1 G0 T( J
  68. #==============================================================================
    " W: c" d( D7 m+ V6 D
  69. # ■ 常数设置 " f! M6 Q: K# I+ }! @9 S
  70. #==============================================================================, I5 L! j0 ]& o) d' j" Q( e
  71. module KsOfSion" w! ]" n% V7 U# k0 P! h  k
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false: `' w3 b! A) e  y* D' g  w! |/ P# d
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑# \4 _* N& V8 n) {) C) a! f3 M
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    3 V- U) G, _: |2 z- {  R+ i4 [
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量* V7 f: h+ w4 p# x
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处, u) u0 \, |0 S! P6 d8 T
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧" Q; r) \2 v3 Z* {- g! l
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)8 J. q. Q( p5 `/ i& [! }. I
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
      ~% Q* h. I$ g. c: \  c
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)+ v/ H* p9 f  s9 Y
  81. end4 U6 e; {- p1 M" j9 A
  82. , B' t+ [% G. V" ~! }) a
  83. #==============================================================================
    , r! n" x8 N' O) [
  84. # ■ 用来显示路径点的类
    ) K, `) Z% k% P5 \1 K- U
  85. #==============================================================================
    . V5 e+ T% W6 a! c! E: \; R, {
  86. class Move_Sign  Game_Character9 _9 ~, G( J3 b# |  W( c1 P! ^
  87.   #--------------------------------------------------------------------------
    $ N& u% X% [1 d3 e& {4 W8 K
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    5 v# T0 w' ?/ [. L: l, a
  89.   #--------------------------------------------------------------------------
    3 e$ j' R0 l5 [! w* X/ q& F
  90.   def init_public_members% O- t' \6 \2 e
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    4 o& l8 o# e" p- }! }/ y
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为01 R- w( q) i* x/ Y1 L6 Z8 U6 _$ L
  93.     @move_speed      = 5        # ★ 踏步速度
    % m4 I( k$ x. Q, h1 i% {
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    4 M* k2 z" h$ O' p! y: @
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    # ?% v! a* y) z0 o; [+ H0 p, Z. j
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常); T0 a9 H- Z+ d
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列- r0 c. m; Z* s
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)9 i" e. }9 W# t% X! g) r
  99. * r' C7 h% J9 a. G5 N

  100. ) z4 W: w7 ^0 D
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★, Y+ p+ G( d5 `5 s$ n: A

  102. 3 A6 u1 O9 j# N( C4 X% c/ W4 ]( S

  103. 2 v2 A0 K) N& s6 S6 r; ~) s
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图3 I& q6 ?3 N- }1 b
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    9 v4 {* U1 H! ^

  106. * q9 z1 y# t9 l" ~, f# w: R: |$ C" g
  107.       if $no_arrowpic_warn" f% Q5 I$ i; I1 N0 i* B
  108.         MouseShow_Cursor.call(1)9 m5 P9 l1 P% f  `1 K! D' L& A
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    ( Y+ Y3 M$ G0 z9 W9 x  q
  110.   B* ~8 e- `* F" \7 M+ t' s9 I
  111. “路径指示点”将使用游戏自带图片; u4 K2 b4 _% `, p2 @6 ~

  112. ' O$ T7 m/ `2 k( E: i3 c
  113. 该提示可以在脚本内关闭')6 P. J3 q5 j2 u% N: ]1 L
  114.         MouseShow_Cursor.call(0)' A* d# ]0 y9 g& B! Q) Y; v
  115.         $no_arrowpic_warn = false
    9 s5 i2 }; p# H) ]! l  s* D
  116.       end
    ! e! m. i/ c# ]: `% {
  117.       @character_name  = '!Flame'
    4 v* ]) z: a, M
  118.       @character_index = 6# X0 ^$ ^0 R9 q, {; w

  119. # j; o$ B1 p1 p( l2 }' R
  120.     end4 {* G4 t% D' f1 D/ `
  121.     @direction_fix = false  # 固定朝向2 J8 F" o6 _! V- J+ d
  122.     @move_frequency = 6     # 移动频率7 s9 I, `  r: }: P. F
  123.     @walk_anime = true      # 步行动画
    $ J) q! \  l- {+ k: T
  124.     @pattern = 1            # 图案& `: o( Q# I4 W# H" G* d+ g1 ^  E' W
  125.     @through = true         # 穿透: l5 v( n  S& b. `1 K
  126.     @bush_depth = 0         # 草木深度- O* B/ |7 c- f2 c' T2 D
  127.     @animation_id = 0       # 动画 ID- A, c; Z7 W; w5 P5 `6 ]  W1 B
  128.     @balloon_id = 0         # 心情 ID
    8 A* Z, t6 u- x% p. b, }: H
  129.     @transparent = true     # 透明
    - j: L- y4 D+ t& P. W% [
  130.     @id = 0
    5 W1 {! Z1 o# ]7 ?) l& N
  131.     @x = 08 w9 b. }- J# V1 ^; b2 q  f  O
  132.     @y = 03 B" \+ c" ~5 q6 W, L: \
  133.     @real_x = 0
    0 y: W5 A0 ?" \3 s8 {. E1 Z: ^" E
  134.     @real_y = 0
    4 v" ]& t" J+ `5 R' j
  135.     @tile_id = 0
    4 B& T$ y! F5 v5 L2 J
  136.   end
    8 G2 I$ S4 D1 p* _& }- |
  137.   #--------------------------------------------------------------------------1 H+ J4 A! p9 M
  138.   # ● 定义实例变量
    + }- R( p4 p8 h- N, _
  139.   #--------------------------------------------------------------------------
    9 n0 c: C, L0 [- @# g
  140.   attr_accessor direction
    8 g$ P4 e+ B4 }# l
  141. end8 m1 p: }" G+ G" ]

  142. & z7 T$ ^. e5 V
  143. #==============================================================================. O) g: [6 L9 b" ^7 i
  144. # ■ Module Mouse
    ) W6 N4 J2 w- Q6 C
  145. #==============================================================================
    ; p$ {1 \+ Z1 {5 o& O; l, X7 T0 K
  146. module Mouse
    " O3 M0 ], b; H4 P( e& S4 b
  147.   #--------------------------------------------------------------------------: f& L+ F1 D3 h
  148.   # ● API
    * ^* a7 w. f& c) c- f& D
  149.   #--------------------------------------------------------------------------
    3 R. o$ f; n  N# d5 r8 d
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    3 p! B- {# Z8 M7 W# i
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    + I8 C% Z0 h) k; R% A, i" W  Y, ?
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')4 ]* B  F- h/ f7 `7 D
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
      Y# s, u4 D2 K  a5 ~* H
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    - a: }2 T# I( y  u' u! w
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')! z5 J4 c7 f( d/ [! E1 {" N
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')4 w  \! m, `* |' {; C$ }
  157.   Window_Hwnd       = Get_Active_Window.call) @- k5 `! T! @$ X6 S9 V5 v0 }" S
  158. + A, x& P" v$ S$ J* f/ q
  159. class  self
    : k: H2 b0 a* r9 I7 W
  160.   #--------------------------------------------------------------------------3 l" l& D7 q' P8 o) `! [( b( x6 _) X
  161.   # ● 初始化) Q/ j2 u1 v( A0 H/ ^) R
  162.   #--------------------------------------------------------------------------! c" ~9 c4 z9 Y# H
  163.   def init
    4 u' d8 H7 O3 R
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    # j4 c& b! z3 J% b. u
  165.     @left_state = 08 R& G+ Y0 m3 C$ D4 r. G- N
  166.     @right_state = 08 K: N6 ^9 z1 Q* Z9 ?
  167.     @ck_count = 0 # 帧数计,单击以后从0开始& |3 k5 s  l. j  U( Y1 I
  168.     @dk_count = 0 # 用于双击的判定
      H/ V% ]7 A4 f' W5 T4 @3 _8 \$ z
  169.     @clicked = false& k  _/ p9 _* M# @& F% L( k
  170.     creat_mouse_sprite
    * z. s3 O. f$ r& j/ n% X4 C
  171.     update) e5 M9 |9 w  u/ d5 V6 J
  172.   end: _4 J8 `! w7 @
  173.   #--------------------------------------------------------------------------
    6 u. [1 x7 v- Y( J: o) a
  174.   # ● 鼠标指针精灵
    * ]3 F9 _- H1 e  p" \
  175.   #--------------------------------------------------------------------------/ U2 a2 R3 f, G+ Z
  176. #~   def creat_mouse_sprite
    : ], S- W* w1 K$ S
  177. #~     
    6 e1 T" @+ Z% z! E
  178. #~       @mouse_sprite = Sprite.new' k) n: k9 w: N# N' O' J! t6 E& Q  g
  179. #~       panda = 2#rand(2)+1
    * b& Q  c+ D# u: s

  180. , d3 k8 o! @+ X# j5 Y, g
  181. #~      if panda = 1. ~) ^# Q2 a* Z
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    9 ~0 v1 j5 r  x
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')( |8 a- N; c1 x) `* u! `& L9 Q
  184. #~        end#with if File.exist1 j+ k) {0 b  q" _
  185. #~   
    ! ?2 |4 g* `* \/ l" J
  186. #~     else if panda = 2 #with if panda=19 o0 ~4 ?! ?4 G8 \/ B$ U& a) Q
  187. #~      ' X' i6 A9 O+ F$ F
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    8 U3 O, R9 f, u
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    5 K' X) Y- z6 I3 q
  190. #~      end#with if File.exist: A6 L  D' e* I( u/ `8 V
  191. #~      
    " h& y7 b* r0 {% Z* ?3 j
  192. #~     else #with if panda=1, O3 h: ?$ f/ Q# R" C
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)1 O+ Y. X. T2 V9 a9 X& Q( ^
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    6 z+ _! z( \- R. z
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    $ W0 n# z5 e) j" P! x. k
  196. #~     end#with if panda=1% z6 `: q1 m# ^  o" C
  197. #~     
    $ M1 N, _7 e/ W) |3 Y
  198. #~     #with def
    2 G; c' E) P6 }3 s+ y7 t/ ^/ P
  199. #~   end
    . m( Q. _( h! b5 z9 q0 Q3 s
  200. def creat_mouse_sprite
    8 ^% ~9 O: B- T- o
  201.     @mouse_sprite = Sprite.new
    1 g2 Z+ `: Y# w; n' j3 x" Z: M: ?
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1}); R4 w# T8 T- L2 T
  203.     @mouse_sprite.z = 9999
    3 W- C2 u0 \! G2 U% [# ^
  204.     Show_Cursor.call(0)
    , F. K* L1 F& a7 Z
  205. end
    7 d6 ^' i4 r6 ~
  206. + W# w3 w+ N' h4 g
  207.   #--------------------------------------------------------------------------
    4 G8 I. K4 x7 s  k
  208.   # ● 更新2 |! s1 V! v8 @; \3 w+ d6 P" [+ m7 N
  209.   #--------------------------------------------------------------------------
      u+ F' M2 y) b3 _+ U) R
  210.   def update
    , o/ r- W& f1 l) w3 E( u
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos5 i! u7 w4 H4 c6 j( D! H
  212.     left_state  = Get_Key_State.call(0x01)
    : r) Y6 C4 S+ Y% e% D' {
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0* e$ p' Y, G" U
  214.     right_state = Get_Key_State.call(0x02)
    1 P/ ]% J: l4 `2 d  c& g  y$ [
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    2 [2 F& N; u8 d! L% J4 d
  216.     update_double_click
      d: m" R7 O; ^& }
  217.     @left_state == 1  @ck_count = 0  @ck_count += 17 s# M1 i( F$ _
  218.   end
    8 ]' S5 `) n/ V/ M9 `( t
  219.   #--------------------------------------------------------------------------" {( s0 y/ U$ {8 x
  220.   # ● 获取鼠标坐标  _, d# a$ Z0 z3 F$ x
  221.   #--------------------------------------------------------------------------
    0 k& g" d  _8 A5 E
  222.   def get_mouse_pos
    + v- h$ H8 S9 S& p/ L% Y
  223.     arg = [0, 0].pack('ll')
    $ f" Y- [2 z1 m0 f- c
  224.     Get_Cursor_Pos.call(arg)) M9 k: }1 v( [0 q
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    $ G9 `+ i! r: \( ~1 e
  226.     x, y = arg.unpack('ll')' g% I2 e$ v3 r, {: c# x
  227.     return x, y" l8 {1 d8 {1 q
  228.   end4 q5 ~7 T3 }/ Q5 \) c) y
  229.   #--------------------------------------------------------------------------
    / z5 q0 Y' p* |1 v
  230.   # ● 将鼠标固定在屏幕内) D+ Y1 g: {( M: d0 ^1 K& S
  231.   #--------------------------------------------------------------------------1 ]" U- B, t' D: C; c0 G+ {
  232.   def lock_mouse_in_screen, ]+ I5 f$ F4 S. L% b/ c, P
  233.     arg = [0, 0].pack('ll')7 o% q4 x9 Q* Z& n. t/ I
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    1 Z' I$ f* e4 o( |( r% y
  235.     x, y  = arg.unpack('ll')
    ( l$ @1 o6 X9 `* W2 }' D" P
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    & R- C1 ~0 x( m& f% C/ H' W; D
  237.   end
    0 P# g( D0 I5 D3 n
  238.   #--------------------------------------------------------------------------
    : o* G) ?$ Z5 ?% J! o* O3 ?
  239.   # ● 解除鼠标固定  o$ g/ W; T3 b4 X. _2 r5 H2 w
  240.   #--------------------------------------------------------------------------& W4 j! ^( W( `& `8 E, ?
  241.   def unlock_mouse_in_screen
    * r2 a" S  m  ~
  242.     Clip_Cursor.call(0)
    ; b; C# w0 u; m. j; t$ K1 A4 g
  243.   end
    # c: [7 w" `% X. Q3 h* S. l
  244.   #--------------------------------------------------------------------------
    ! [/ F% C; I' A( V! X0 }# l% B1 Z
  245.   # ● 鼠标双击判定9 Z( H' n2 K% K; {0 Y& ?/ M2 f
  246.   #--------------------------------------------------------------------------% x+ {) [  ^! h
  247.   def update_double_click$ F+ |6 i6 V. v* v1 C, _8 b4 h$ g8 K
  248.     @clicked = true if @left_state == 1( Z6 _- P. y8 A2 J
  249.     if @dk_count  0 && @left_state == 1
    9 G9 O, N: C( ^6 D
  250.       @dk_count = 0; @clicked = false
    . B$ b! a& {1 @9 v* F
  251.       return @double_click = true# O, n& P: H# w9 ?" V
  252.     elsif @clicked
    / Y- }0 \0 t2 m. M  I
  253.       if @dk_count  KsOfSionDbclick_Frame0 M) t4 }, |3 w! B+ J
  254.         @dk_count += 1
    4 \  i1 ^' ?5 M9 Q. b4 }0 }% S
  255.       else4 {. H- k5 q$ ?  N$ M
  256.         @dk_count = 0; @clicked = false
    ! s0 D6 {$ b  e6 g8 {* \
  257.       end
    ; `, Z- h+ ]/ h# h- W; h9 J' \4 m
  258.     end
    $ s( I2 k% f" h; M+ k: v9 H" N. A$ `$ ^
  259.     @double_click = false
    - G4 s4 F& f. z& y5 `  r
  260.   end
    1 g3 ~- x8 }* g8 D
  261.   #--------------------------------------------------------------------------
    ' ~7 F1 J9 g, l: \! u
  262.   # ● 按键被按下就返回true) X- [. {, v6 b6 w  X1 P9 ]4 b
  263.   #--------------------------------------------------------------------------
    " A* z: I# p7 |) c
  264.   def press(button)5 B8 o7 `1 T, S
  265.     case button+ J$ Y: G' V! n; A  e
  266.       when 0x01; return !@left_state.zero7 m2 o2 q" t$ r; E' l" D
  267.       when 0x02; return !@right_state.zero( e' d1 y8 A7 i% U) O  }
  268.     end
    1 w# y/ [2 ?9 J; u7 f4 |1 p9 U
  269.     return false
    # R5 S, k4 I/ g
  270.   end* A& T9 C3 c: N7 E* ?
  271.   #--------------------------------------------------------------------------
    9 Y7 r4 A3 ^6 M0 i9 z
  272.   # ● 按键刚被按下则返回true: [9 q4 {% H% q3 @
  273.   #--------------------------------------------------------------------------
    2 X: w$ x+ V6 ~
  274.   def trigger(button)
    ; S4 B( q# F2 Q  F; g0 `
  275.     case button, _2 n, ^* E4 n8 ?
  276.       when 0x01; return @left_state == 1: M# n5 }' `' E; s# H1 N8 m
  277.       when 0x02; return @right_state == 1, G% W' ~; y, Z6 u. {
  278.     end+ s. K) h3 o" s
  279.     return false
    9 f1 y$ D) l8 w' m
  280.   end
    : E8 W2 d, N( w5 L) h: Y2 k
  281.   #--------------------------------------------------------------------------
    2 Z9 K' b6 D7 @. N+ ~, u
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    " H# @+ d6 c' I0 e% h- u
  283.   #--------------------------------------------------------------------------
    5 ]. F" I% {1 l, B( O$ C$ t: _) D0 T
  284.   def repeat(button)3 |2 U7 E% T; ~7 I: D% B
  285.     case button* T7 ^' d$ B; r! l2 J1 O1 [/ P
  286.       when 0x01; return @left_state == 1 1 e0 ]$ G& S( i0 Q* {8 ?! S: _& c2 t
  287.         (@left_state  22 && (@left_state % 6).zero)6 A# J$ Y/ S8 @5 y) W+ W/ H
  288.       when 0x02; return @right_state == 1
    1 Q; V) D4 U: }0 Q' l+ w! m. @& r
  289.         (@right_state  22 && (@right_state % 6).zero)0 B! Q8 m# p  j7 X" k
  290.     end
    0 q& Z0 s1 N% d; i: v! Z# Q
  291.     return false5 K# Q) ]6 @; U3 L7 c. a9 I
  292.   end
    ) n/ E# C% c, B4 V- m% @1 }
  293.   #--------------------------------------------------------------------------( K% x3 R2 Y7 R; Y" u: |, @
  294.   # ● 判断是否双击鼠标
    3 n: [7 ~6 I; Z  @' {
  295.   #--------------------------------------------------------------------------* x0 A# ~7 h0 j8 F( {
  296.   def double_click
    9 U9 i: L, y0 W/ j: B* M
  297.     @double_click
    " T* [) D; `7 M- z5 ^: ~
  298.   end
    ) S* M2 b' {" @- M7 g* }9 N/ N3 X
  299.   #--------------------------------------------------------------------------4 n" J8 ~6 Y# ?& ?( B( Z6 b9 j
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    - h% W' x$ S% s! C4 ~2 ]; p
  301.   #--------------------------------------------------------------------------1 e5 Y; Y. q% D
  302.   def click_count8 f* [& _9 O$ [7 H
  303.     @ck_count. ?& T0 G/ ?/ P/ K" M
  304.   end" r4 q# n* U  Z2 e1 R* z( C
  305.   #--------------------------------------------------------------------------
    - h( V9 P2 w3 N- N! G# y' @
  306.   # ● 获取@left_state(按住左键每一帧+=1)7 a: S: Z+ ]; {5 e- |* l% R
  307.   #--------------------------------------------------------------------------7 N' w4 q+ p; D5 I! Y
  308.   def left_state2 l" i6 c% V2 B/ a3 v8 _$ A
  309.     @left_state
    ' l2 o! ~# D7 B/ f2 M
  310.   end
    4 R) I* t7 p+ c2 a2 t6 u
  311.   #--------------------------------------------------------------------------
    , {8 u' M% K+ j% G
  312.   # ● 获取鼠标的x坐标
    ( x8 M9 o0 {, L# l  y  b" T3 s# V
  313.   #--------------------------------------------------------------------------
    3 h/ X' f5 Q: c' A- j. R
  314.   def mouse_x
    3 M0 s& J! ?" s
  315.     @mouse_sprite.x+ R& A: `/ a, w- T: x( E/ h9 ~
  316.   end
    1 V9 ^/ \+ e9 R# x3 p1 D5 m; {
  317.   #--------------------------------------------------------------------------
    0 g6 B' i' k: d/ y
  318.   # ● 获取鼠标的y坐标
    ; p! `- u( e+ S& X  P8 [. U
  319.   #--------------------------------------------------------------------------/ ~0 |1 v& ]# L; |0 p
  320.   def mouse_y+ |9 s5 C% s2 f0 Z
  321.     @mouse_sprite.y1 Y" T% `. p% k' Y
  322.   end
    - P; \, @0 m' r# K: q7 a  U4 K- g  o
  323.   #--------------------------------------------------------------------------
    ) F0 @& M5 g0 h* z
  324.   # ● 设置鼠标坐标' J: v# }" M5 j! `7 f
  325.   #--------------------------------------------------------------------------
    9 t9 @9 n, P. W( ]' K; b( n
  326.   def set_mouse_pos(new_x, new_y)
    4 o7 X$ H4 }* \4 J1 S& H, o1 R" ^
  327.     arg = [0, 0].pack('ll')) u+ Z% m) ?" `& P
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    $ D. U+ m1 j  Y2 P  Y6 K, j
  329.     x, y  = arg.unpack('ll')
    6 b; |/ \+ G; \( Y0 V2 v
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    $ a" F6 I5 q& T1 q2 |$ U
  331.   end
    ) A  V+ h, o9 u6 K, k. u& Y7 @9 S
  332. end #end of class  self
    9 R# F! O8 Q/ O3 e4 i$ n

  333. 2 g# e1 T# o+ S2 Z& Z
  334. end; ~& N2 z5 |, U, q! z% K) h

  335. 2 Y( K3 l& w+ A4 F( t& v
  336. #==============================================================================, Z9 X( O2 _6 z. M* q1 p4 ]6 R
  337. # ■ SceneManager) }3 x/ e: W6 n$ f0 K+ A) d
  338. #==============================================================================
    3 a6 E  ^$ ~6 f! R
  339. class  SceneManager
    ' k2 f% i7 w4 i& A0 X
  340.   #--------------------------------------------------------------------------
    7 ^2 |; @, f5 r
  341.   # ● alias, h" E: f  z4 e) }" H( r( R
  342.   #--------------------------------------------------------------------------
    5 F$ H6 U4 M; }2 E1 B% w) u, p2 C8 f
  343.   unless self.method_defined(sion_mouse_run)2 h- U) W' v. w0 I; Z$ K
  344.     alias_method sion_mouse_run, run
    5 q' f$ O' e0 U9 e& M- [/ B
  345.     alias_method sion_mouse_call, call5 e. w1 |' y1 i* M( R# N% d
  346.     alias_method sion_mouse_return, return( D* ^" ]3 o7 H& G! W3 ^
  347.   end" w5 H, j1 `( b& j" N% A  L+ T
  348.   #--------------------------------------------------------------------------
    6 W$ q0 s7 K. [4 `
  349.   # ● 运行. x$ x5 I9 b+ g& i9 S
  350.   #--------------------------------------------------------------------------
      q2 `- o' ~% q' {
  351.   def run7 }* ]3 w0 ~' r8 q' D! a
  352.     Mouse.init
    . V3 k; ^% }7 g5 F, G4 `
  353.     sion_mouse_run+ C/ q* `& V; k# r5 e2 ~, O
  354.   end9 n# C8 D( k* V% W; x& n9 o  W# p3 g1 X
  355.   #--------------------------------------------------------------------------
    ) B# O6 `; B. u! D3 S4 M, s
  356.   # ● 切换
    & h$ @0 D  I) Z3 T* `' ]
  357.   #--------------------------------------------------------------------------1 R7 N9 Z; V  ^+ [' I: S
  358.   def call(scene_class)
    9 i! C! n; G/ M2 |* r
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    7 g6 q: X( g+ A; E
  360.     sion_mouse_call(scene_class)/ Y/ z) v6 r% E3 Y3 E) h+ C
  361.   end7 c* |5 d5 T0 m* }! S
  362.   #--------------------------------------------------------------------------4 R9 E0 O* f8 t
  363.   # ● 返回到上一个场景$ ?9 K; ]% u+ o. y
  364.   #--------------------------------------------------------------------------2 Y! W3 y; V' K2 D% B4 S- k7 I
  365.   def return
    ) Z) n; e" ^- W, x2 j* M0 R6 i
  366.     sion_mouse_return! _8 M, B- @3 ?3 s* W- b
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    7 Z6 c) D3 V7 W( e/ w: ?
  368.       @scene.instance_of(Scene_Map)
    1 R0 ^3 N1 u  D& C
  369.   end
    * [( E9 l* y: e, D3 f; d- e) P
  370. end  Z; u& O$ E# [; B# S- |

  371. - Z3 A/ u( G: z6 K  ~/ N
  372. #==============================================================================! R# d& w# a7 h/ D) v& Q
  373. # ■ Module Input8 V4 u/ p% b( L
  374. #==============================================================================/ _0 U, ]4 f! |/ e* L& {
  375. class  Input
    & [0 n$ L; t# N: r
  376.   #--------------------------------------------------------------------------. A) B8 L% B4 R& J7 P% x8 ~; O
  377.   # ● alias
    * ~- m5 J3 E7 ~  @# {" ]. ^" y0 B6 p
  378.   #--------------------------------------------------------------------------
    1 U) j  ~- q6 M6 C2 W6 W2 H
  379.   unless self.method_defined(sion_mouse_update)
    + b4 _2 J. x( \& f% \
  380.     alias_method sion_mouse_update,   update) R" ?! X- |2 i* d' \$ r
  381.     alias_method sion_mouse_press,   press- C4 ]; h5 Y4 w, H4 U, }9 B
  382.     alias_method sion_mouse_trigger, trigger+ p* T7 B4 c* E0 |  I" O; a
  383.     alias_method sion_mouse_repeat,  repeat2 w7 u% Y, d6 d& r
  384.   end
    7 f. v, m; p" l( a
  385.   #--------------------------------------------------------------------------+ M. L# ?+ M& R
  386.   # ● 更新鼠标
    2 o" W/ f& K* i5 r
  387.   #--------------------------------------------------------------------------; G" \% e7 I$ c9 X( J
  388.   def update0 q* I, H. w5 Q& T
  389.     Mouse.update# a" `) D% ]9 @6 ], [9 L2 v
  390.     sion_mouse_update
    ( u2 K9 Y5 c+ B) Z% F; t
  391.   end
    6 \; L7 h0 l3 B( n
  392.   #--------------------------------------------------------------------------, y- M6 F* R2 i6 v8 G+ a
  393.   # ● 按键被按下就返回true, v  a  K- L- ~; a/ j* O; k
  394.   #--------------------------------------------------------------------------) a) J( I+ ^7 [0 I8 O
  395.   def press(key)
    6 b) d+ p* w) W/ u, K# r0 d( @9 T
  396.     return true if sion_mouse_press(key)  f6 a, ~( K! _1 X& ^5 z6 J' I
  397.     return Mouse.press(0x01) if key == C
    . S$ p1 V2 K0 z- c9 {
  398.     return Mouse.press(0x02) if key == B- z3 j: ^/ L5 U# r/ {
  399.     return false9 ?/ Q, T( n0 p& [
  400.   end
    5 d7 e) @( T$ ~& s8 A6 T
  401.   #--------------------------------------------------------------------------: {3 ?, P# f2 b* S% G1 ]
  402.   # ● 按键刚被按下则返回true, G* V6 p7 P& G2 J' _
  403.   #--------------------------------------------------------------------------
    / @0 Y( E+ G; b' j; y
  404.   def trigger(key)) }$ k5 l1 |6 m+ ~1 J2 o/ Z
  405.     return true if sion_mouse_trigger(key)
    ' v' B2 l5 A8 X1 G
  406.     return Mouse.trigger(0x01) if key == C( o; v% c1 P, c
  407.     return Mouse.trigger(0x02) if key == B
    $ H/ Z3 w& q! T+ Y5 Y
  408.     return false
    3 I* E+ ~; G; G0 W, K
  409.   end: A. @9 _' E0 b+ N( c
  410.   #--------------------------------------------------------------------------/ ]+ o& W" I( J$ k7 I: C0 F
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true% p  R$ j$ w/ Z& k! m
  412.   #--------------------------------------------------------------------------5 @+ `: L, f& r2 C
  413.   def repeat(key)5 ~+ d4 d8 w6 c
  414.     return true if sion_mouse_repeat(key)
      C1 p+ L& S2 n4 U7 N
  415.     return Mouse.repeat(0x01) if key == C
    5 r, W8 k5 v9 ]+ b& c7 I
  416.     return Mouse.repeat(0x02) if key == B+ b. a+ [# F. _; L! @5 R$ W
  417.     return false
    % V  O, [# r, d5 V7 ?+ i- b! c9 S
  418.   end. Z5 m+ }8 G4 u4 i: D* L0 o
  419. end' |. F- Z, O* s3 \1 Q& w  q
  420. ! e3 O8 e+ K: M( w. Q) d4 L
  421. . b/ c  B  J# }. K9 d* D
  422. #==============================================================================
    , g" r# O1 R% X$ n' Y" _0 ~8 r
  423. # ■ Window_Selectable$ o' e) m( H  {# E  C- A
  424. #------------------------------------------------------------------------------) ~$ N9 }' [, r
  425. #  拥有光标移动、滚动功能的窗口
    0 c- m( `2 c# O8 m% a
  426. #==============================================================================
    " e9 d/ a9 t, v% f% |( R6 Z
  427. class Window_Selectable+ P+ Y8 h; S. ?$ j. k
  428.   #--------------------------------------------------------------------------
    7 W' |- L' M& O' H* V3 o: Y% G
  429.   # ● 初始化" ]% B; P: L; S" C1 ^: o
  430.   #--------------------------------------------------------------------------
    . a# o) [3 ]2 J
  431.   alias sion_mouse_initialize initialize
    & r- I1 x6 P; ^/ o9 j/ E
  432.   def initialize(x, y, width, height)
    . U. ~; c( L; {  {: }  `  E
  433.     sion_mouse_initialize(x, y, width, height)* R+ z4 e- w. c1 U2 o
  434.     @move_state = 0
    4 h1 A+ n5 j( z1 B, }: s/ V; O
  435.   end
    5 e4 }) J6 F2 m; y# N
  436.   #--------------------------------------------------------------------------
    ) {5 D$ T0 @. @7 {7 ~: p1 x1 j
  437.   # ● 更新
    2 I' I0 n. w1 c$ j/ u
  438.   #--------------------------------------------------------------------------5 G' m5 c& e7 A" w7 d
  439.   alias sion_mouse_update update; h/ l" B/ `/ t/ \% w2 I- D1 }
  440.   def update
    / m* F4 W1 Y. e1 E! d
  441.     sion_mouse_update
    ' M' N* a& b# m8 g9 ^7 T
  442.     update_mouse_cursor* S1 }" _  y" c6 b
  443.   end
    + i' q- b* c3 K9 J
  444.   #--------------------------------------------------------------------------
    1 a1 @" T, P$ M* g4 T
  445.   # ● 启动后设置鼠标到index位置/ n! @* j9 Z  ]
  446.   #--------------------------------------------------------------------------
    8 }6 S! M" `8 c3 K& G; F
  447.   def activate
    * _8 {* E0 Z3 N( e7 z7 E
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos" v# Y% f/ L  b* R* g9 e7 c
  449.     super- I5 d4 E# t# x
  450.   end
    7 ?! V5 ~# x+ K: n: B, r0 N$ @
  451.   #--------------------------------------------------------------------------9 R, V6 W0 G" w2 w6 f! q' }. ]" k
  452.   # ● 更新鼠标和光标的位置3 ]% P7 A, {; w% s
  453.   #--------------------------------------------------------------------------* V( h- r% d& P7 c7 B9 ?8 Z, }
  454.   def update_mouse_cursor( l! o5 x, |! V) H5 \
  455.     if active1 u' W& ^0 @6 P
  456.       if @need_set_pos
    , K, z$ c* C* b  {: _! ]
  457.         @need_set_pos = nil( Q4 j$ A2 [9 I, n
  458.         set_mouse_pos7 n' U5 Z% P+ X1 U, O( G4 O% p
  459.       elsif cursor_movable5 z: {1 ^3 j1 e: y2 r+ @. f3 B- Q
  460.         Input.dir4.zero  set_cursor  set_mouse_pos0 F- x- |7 a9 K8 [& P
  461.       end/ V% v9 U' h/ v/ X# U, M
  462.     end
    ; p0 b5 T/ ^' v" r
  463.   end
    0 }( {% z: o$ `0 b6 w
  464.   #--------------------------------------------------------------------------% T1 M% P8 A' v" ^+ }# \' K& A* a
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    - j& Q, a; N$ z$ l0 s
  466.   #--------------------------------------------------------------------------+ n2 A8 t; B' m# A; n) y7 H8 M
  467.   def set_cursor  F$ r' s" ]& {7 u* n
  468.     mouse_row, mouse_col = mouse_window_area
    4 c* S& F# g$ E: |$ u- k
  469.     if    mouse_row == -1' i3 n/ c! N7 h! {7 @
  470.       @move_state += 1 if need_scroll% V) {( ?, h' p
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand7 S: Q1 j6 H* o6 x% ~3 O
  472.     elsif mouse_row == -2" j) j. R6 i) ?# ]( C: Y& ?) {
  473.       @move_state += 1 if need_scroll
    " F  Y, K, s5 E' z3 r
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand/ f% Y0 q; g3 w" F# U3 u
  475.     elsif mouse_col == -1; E$ T+ J( f, ^3 A) F( B
  476.       @move_state += 1 if need_scroll
    ) Q, ~+ ]0 w7 _1 k1 v* j
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    / ^8 `, h3 p  s  R0 X
  478.     elsif mouse_col == -2
    / w& _" }: ~: t' U7 l8 r/ |
  479.       @move_state += 1 if need_scroll% m& J7 C1 n% }# ^% L+ i! {  o" f' w
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    ) F: @5 d$ }, K6 ~1 v
  481.     else
    5 K. y7 M; ^  L  t: u+ p
  482.       @move_state = 05 p7 Y( c$ K! R; r0 p
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    , N! u& @7 R9 U! s' c6 c  z
  484.       select(new_index) if new_index  item_max && new_index != @index
    0 l8 ^2 e# @! Z1 f% C
  485.     end: a; Y8 @4 n+ t) P. E
  486.   end
    - A! i! R- D' _+ T+ t* o. F  l/ b
  487.   #--------------------------------------------------------------------------! X  P; F" T' Z9 f/ f
  488.   # ● 判断鼠标位于菜单的第几行、第几列7 S5 [8 F" a; ]+ h/ @
  489.   #--------------------------------------------------------------------------( @  B% D! J! P$ k
  490.   def mouse_window_area$ A; A* Q1 l9 _" n& V. V4 b" G- b
  491.     if viewport.nil # necessary!
    5 s6 A1 |6 j' ~
  492.       vp_x, vp_y = 0, 0* A$ k2 I; |3 L# {7 C, Z- A
  493.     else) \9 \( ]9 T, F5 j; b6 u
  494.       vp_x = viewport.rect.x - viewport.ox
    3 o) u& B% V" J% `
  495.       vp_y = viewport.rect.y - viewport.oy8 e% l$ [# p; z  `' }
  496.     end! N8 w% V$ Z2 o: V- p9 o1 o$ O
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    + B0 k8 i' C; }7 M& a" G5 @( i
  498.     item_x1 = vp_x + x + standard_padding 5 {: g( _. T8 G: d8 w6 |
  499.     item_y1 = vp_y + y + standard_padding
    ; d! O3 [& y" Y
  500.     item_x2 = vp_x + x - standard_padding + width% x+ M" ^5 ~# d/ T; w! B- |+ C5 d
  501.     item_y2 = vp_y + y - standard_padding + height
    , T( j" W! a; U/ E- |0 z
  502.     if mouse_x  item_x14 y% S" m6 o* \& K$ a
  503.       mouse_col = -1
    6 v. J0 T( s  V$ e
  504.     elsif mouse_x  item_x2) E. n1 l/ o; z- v( g
  505.       mouse_col = -2
    ' X7 C1 n0 Q/ n1 q7 b. T
  506.     else7 B/ `6 r4 |, }
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)1 x2 s' c4 a% a9 f
  508.     end/ `0 O6 S! P! I) O
  509.     if mouse_y  item_y1$ L2 Q5 E8 o2 t* b# F2 \* P
  510.       mouse_row = -1/ y3 w! G% w7 E( @/ @9 m
  511.     elsif mouse_y  item_y2# O& ~# s! [1 Z
  512.       mouse_row = -2
    6 ?* I- {$ [' P9 M3 n6 s. d& j6 a
  513.     else. ?, K: Z9 O2 Y1 J
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)! n9 x" L2 u: t  z
  515.     end8 N! E1 q% p$ ?! Y' t
  516.     return mouse_row, mouse_col
    ) J4 l, Z: F" Y2 l+ r, g' k
  517.   end; h7 o: L9 P4 d
  518.   #--------------------------------------------------------------------------! \7 G: c) r. w8 y
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    " V$ F: o- `6 A) {+ h! q6 @0 m
  520.   #--------------------------------------------------------------------------
    ; f9 F3 @/ u5 ?
  521.   def set_mouse_pos- Q0 B6 Z, w4 q( T; X5 T2 I" k0 b6 C
  522.     if viewport.nil # necessary!0 `% S1 U  s8 v8 D
  523.       vp_x, vp_y = 0, 0
    9 K: T  B* [* s/ W
  524.     else
    8 a: ?; |/ {9 j4 K' c! Z# a7 n, S
  525.       vp_x = viewport.rect.x - viewport.ox' z" U* w9 S6 _9 h7 o
  526.       vp_y = viewport.rect.y - viewport.oy
    3 ?% x' r; a/ `! P7 v+ V
  527.     end6 Y. e0 e+ z+ z* z5 C" M7 F& `
  528.     item_x1 = vp_x + x + standard_padding $ Y* ^5 S# I8 p
  529.     item_y1 = vp_y + y + standard_padding
    # F( L: A" t1 p/ r# @
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    0 G& s9 `' d( E  K
  531.     row = get_index  col_max - top_row
    6 C' b( r8 K8 ^, d( [! b2 ?/ [) j7 m( @
  532.     col = get_index % col_max
    - C& @/ @0 j. ]
  533.     new_x = item_x1 + item_width  (col + 0.5)7 H. [$ n$ v0 \% }
  534.     new_y = item_y1 + item_height  (row + 0.5). C4 Q$ w' `* |2 E- t
  535.     Mouse.set_mouse_pos(new_x, new_y)3 `" S9 {# h8 @
  536.   end
    0 Z5 w0 `/ j% b/ I( x; @5 T, l
  537.   #--------------------------------------------------------------------------
    ) _% r( Z# A& B6 x1 R! }
  538.   # ● 判断菜单是否需要卷动' t& }& T! @$ W; ^* P
  539.   #--------------------------------------------------------------------------6 j& q3 H1 l0 f6 g5 j& h# ]9 i& G% |
  540.   def need_scroll3 M% L: k( Y* ]3 i0 r0 X5 r" h
  541.     item_max  col_max  page_row_max% c# S& L* ?5 R& k+ l
  542.   end
    / O7 `" E+ [7 A# \9 H8 f
  543.   #--------------------------------------------------------------------------
    ; y1 L5 @' t7 x3 _# T. ]7 O
  544.   # ● 判断是否为水平卷动菜单  K. ~" z- s# o4 m9 M8 ^) L. Q$ G% h- i
  545.   #--------------------------------------------------------------------------
    8 |. p# ]' I- |% j( \- u6 @
  546.   def is_horzcommand
    5 O7 O  j# j8 L- ^" B
  547.     return false
    / b- C0 o% Y, {6 a0 G1 b
  548.   end
    ) F* o# a3 {3 B3 t" ?1 z7 i" q9 w
  549. end% G* V: U: z/ \, j* B3 x. J) `

  550. 0 G3 m. l  _: B! _, c% Y+ J" G
  551. class Window_HorzCommand; K% q+ X* i# v2 H
  552.   #--------------------------------------------------------------------------
    ; I5 B+ Y) |, E7 c; ?' U7 S
  553.   # ● 判断是否为水平卷动菜单
    2 o' X; o, M4 }
  554.   #--------------------------------------------------------------------------
    $ p2 |& F2 b; @" U2 L! w0 Q: t
  555.   def is_horzcommand' M. v) E9 u7 t( s9 p: f
  556.     return true
    - u2 ]9 v+ C- ^, `2 W! Y/ c% S
  557.   end. J. x* |: n+ Q0 l
  558. end3 |- U/ O) Z+ J' p. l9 R# |
  559. $ R: S  s# p- {4 j" V! n/ @
  560. #==============================================================================
    , u- N1 r; B3 ?+ D7 e
  561. # ■ Window_NameInput3 }" I  K- O6 Z
  562. #------------------------------------------------------------------------------
    : @4 M. u1 |4 u' m
  563. #  名字输入画面中,选择文字的窗口。/ p7 M: I' z+ T* S3 v
  564. #==============================================================================3 b3 p- R0 I: E7 y. v. t% Q! O
  565. class Window_NameInput
    3 I: J  G& A! C4 R" V9 b
  566.   #--------------------------------------------------------------------------- N! Q! K8 C  q8 @. b
  567.   # ● 设置列数
    9 s7 v7 n! n4 g& D& ^$ U
  568.   #--------------------------------------------------------------------------
    % U* R: R9 `6 q2 m4 J+ h. }& u- i
  569.   def col_max9 C- h! ^( K( j8 {8 _
  570.     return 102 l; _! S  O. F2 _) v
  571.   end
    5 d" L9 y2 L# p- V1 D. x; ]+ d
  572.   #--------------------------------------------------------------------------
    5 Z% N5 g9 p9 |+ B
  573.   # ● 设置填充的Item个数. P9 Y; y8 b" }  @# y
  574.   #--------------------------------------------------------------------------9 H5 k! l" |# N( x9 }; ?
  575.   def item_max
    / Y% @! `0 w$ ~% T+ {; o* p8 n4 F. B
  576.     return 90+ d( l/ U: Z+ H  s  h
  577.   end! B: ]- X/ s- g$ g' ~  e2 [/ Y: C
  578.   #--------------------------------------------------------------------------) Y9 G6 x6 s+ g& f1 m
  579.   # ● 设置填充的Item个数0 D8 S1 {1 p2 P1 S& ^
  580.   #--------------------------------------------------------------------------6 h* i& Q! p5 {" p8 @" b1 M
  581.   def item_width
    ; u6 B" B, _* B9 o  @6 u$ h5 ^
  582.     return 32, u  b7 V0 {% J. y" F1 {8 _, Z
  583.   end
    , k2 q- X& v. r3 `8 T6 V
  584.   #--------------------------------------------------------------------------0 [% A* P9 |8 v; o2 b
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    * s% q/ [" v& e( V( }
  586.   #--------------------------------------------------------------------------8 q. n; @, }5 X1 c. n( X( M
  587.   def mouse_window_area
    7 k8 k/ A, [6 v3 T+ k1 U* P  Y
  588.     if viewport.nil
    ' l8 q4 B& z" m% r( O
  589.       vp_x, vp_y = 0, 0+ C. [; k+ \* P
  590.     else
    ) _# {& E2 B( g8 [8 k
  591.       vp_x = viewport.rect.x - viewport.ox7 W: n5 p: e2 N- y1 V4 [% w. d
  592.       vp_y = viewport.rect.y - viewport.oy
    - z" u/ ]; H& x+ W
  593.     end, U% O, }4 c9 e5 b- r) J( @' _
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    - t# U$ c/ o. [4 C
  595.     item_x1 = vp_x + x + standard_padding
    8 t  S/ s0 e( W0 I3 o2 g
  596.     item_y1 = vp_y + y + standard_padding* P: \/ O& k5 v2 M3 m
  597.     item_x2 = vp_x + x - standard_padding + width
    7 l0 k3 Z" }* ]1 M0 Z
  598.     item_y2 = vp_y + y - standard_padding + height
    $ e1 O( C  T: \' H, V- m% C$ p
  599.     if mouse_x  item_x1$ t& w3 j/ l8 F
  600.       mouse_col = -1
    % [( |% u8 a, Z0 B" L/ t8 L) g
  601.     elsif mouse_x  item_x2& }0 q) Z6 x3 H' m0 c" v0 F: ^
  602.       mouse_col = -2
    ' g0 j: b7 ~* t: o, A2 S
  603.     elsif mouse_x  item_x1 + 160
    * D. T, X  @2 G* l, o8 s3 S3 d" l
  604.       mouse_col = (mouse_x - item_x1)325 d: @0 F- g+ l/ f+ _/ j+ w1 K
  605.     elsif mouse_x  item_x2 - 160- q5 C/ G' R1 [% k7 n/ e2 s! S
  606.       mouse_col = 9 - (item_x2 - mouse_x)32( x8 P# N: {: C. \, H( ]3 o4 ~
  607.     else
    ( v1 g! |( v3 @% _% Z5 X5 H3 e. P
  608.       mouse_col = mouse_x  x + width2  5  4
    + V5 p! J% U9 v! a6 v
  609.     end( y* L/ V- m. q$ J$ ~& X9 a! ]
  610.     if mouse_y  item_y1
    - [/ c5 S: D* ~
  611.       mouse_row = -1! x2 U9 K# W3 N  U; G+ c- ?
  612.     elsif mouse_y  item_y2
    ! v! r. g( l% Z! |- d4 x
  613.       mouse_row = -2
    ! ^  E& F" i5 F! V6 n& P+ j5 ]) h# a" w
  614.     else
    8 @6 \8 g7 L0 J1 V+ |4 G
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)2 t. s8 b, J5 S/ N7 y7 n: [! J' a
  616.     end' g. L1 V+ E5 B  Z$ f% t# {
  617.     return mouse_row, mouse_col/ l5 m1 `" Z" k; V  N8 j  j6 Q
  618.   end5 _0 Y# B4 T# e% J  e% f
  619.   #--------------------------------------------------------------------------
    ' L, B; `3 N: T* u
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ! h3 ?/ P( W) f) b( F
  621.   #--------------------------------------------------------------------------7 |% g8 k1 Q% B# p+ H& v4 M
  622.   def set_mouse_pos$ _8 ^, q9 t2 b7 L
  623.     if viewport.nil # necessary!0 v; L6 @. n1 Q2 O0 v5 r5 O
  624.       vp_x, vp_y = 0, 00 S# c$ A* d4 U" D; l
  625.     else
    8 b4 V* z8 Z$ K6 s8 H; e- C
  626.       vp_x = viewport.rect.x - viewport.ox
    / s8 K; J. V. v, I2 @: }
  627.       vp_y = viewport.rect.y - viewport.oy
    ( @. t. `2 u4 E2 |4 N0 b2 W7 `
  628.     end% l# s! x" g% W& c! G( P
  629.     item_x1 = vp_x + x + standard_padding
    ' p  A8 }0 v: L  d0 {1 K6 K6 G
  630.     item_y1 = vp_y + y + standard_padding1 N4 L2 E6 B% M) O; D- I
  631.     get_index = @index  0  0  @index ( g9 N7 i; O( |
  632.     row = get_index  col_max - top_row
    7 ^9 h6 }: S+ l: ~, d+ b1 l: W
  633.     col = get_index % col_max
    0 c, N) M" y7 O8 {6 O
  634.     new_x = item_x1 + item_width  (col + 0.5)
    & e7 Y' p4 ]" f5 J+ g5 p: k, U
  635.     new_y = item_y1 + item_height  (row + 0.5): k) B- \- R7 g; E2 M
  636.     new_x += 14 if col  4- e5 m' ^) l7 j# l# y. j, X! u
  637.     Mouse.set_mouse_pos(new_x, new_y)
    4 G" G4 |% v% L, z9 J
  638.   end
    : H$ I% C7 ~, P6 W0 {! ]
  639. end
    % B8 B9 h( R# v5 h2 T5 r+ k
  640. 9 s" |/ ^+ e: S9 R. r
  641. #==============================================================================" @8 i7 v1 B8 q1 N6 j' w
  642. # ■ Window_NumberInput6 R7 E  k  }1 o" W$ v- f( d" p! E1 [" n
  643. #------------------------------------------------------------------------------- t- |8 z/ H0 N1 N/ g! L$ w
  644. #  重写了数值输入的方法以适应鼠标
    ) r2 w( Q* z; ]& V  R8 U
  645. #==============================================================================' [! i7 ~9 U0 V# h6 E6 d
  646. class Window_NumberInput  Window_Base
    5 v6 f4 Q( ]! s; F) U0 P* d
  647.   #--------------------------------------------------------------------------
    % F- ~! T* x# o- _* g
  648.   # ● 定义实例变量
    5 F: q8 \+ |/ T0 M) Q
  649.   #--------------------------------------------------------------------------
    2 L- t8 ]( Z' r2 R% `" S6 j5 w! z2 F
  650.   attr_reader extra_window
    6 Y$ n* u2 k- {
  651.   #--------------------------------------------------------------------------0 N5 i$ t' g; Q& a
  652.   # ● 初始化
    , Z% _/ }9 H) K- `: U* n6 L
  653.   #--------------------------------------------------------------------------
    , [! j( {3 `  V) t; q9 t
  654.   alias sion_mouse_initialize initialize
    ! x9 |3 |5 M! Z% T4 h" i* m# u/ x
  655.   def initialize(arg)
    , x3 n3 l& S) I3 c' V0 e
  656.     sion_mouse_initialize(arg)
    . N5 D9 O7 \; e! c
  657.     create_extra_window
    - j% m* U4 z# V" A
  658.   end  n- P0 r' ^" J1 J
  659.   #--------------------------------------------------------------------------- q7 [) j6 k' V
  660.   # ● 启动
    & z) }7 D' w4 h% j" e7 Z4 V% x
  661.   #--------------------------------------------------------------------------' H0 v  A8 V9 {$ O( g0 u
  662.   alias sion_mouse_start start" x+ W* l0 \  ?$ ]% l2 u( ?
  663.   def start
    0 G# O3 t& i$ ~/ ?
  664.     sion_mouse_start
    . S* U* v3 y5 Y
  665.     deactivate. W! H$ i0 I4 k7 C/ m9 R) |
  666.     extra_start5 B0 u6 m% y/ a6 }# Y* }# u
  667.   end8 m0 G4 v" H! Z7 d+ @
  668.   #--------------------------------------------------------------------------
    ) }# d/ A$ m9 e5 Y% g% H
  669.   # ● 创建新的数值输入窗口
    - v1 @2 U% E8 `+ [6 [7 A8 {$ |
  670.   #--------------------------------------------------------------------------
    ; l: S+ t2 F" q# f! s
  671.   def create_extra_window
    + |, w% A/ B/ J% C; c, ]
  672.     @extra_window = Window_NumberInput_Ex.new
    . u, {: c: `4 m% Y+ x  s
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2* d# q: X. B/ K8 [! k: ~
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }  U8 H$ q6 Q4 I" V8 [" H  |# |
  675.     @extra_window.index_proc   = Proc.new {n @index = n }; M' `1 x& a+ a  q! A5 p5 E0 B; \
  676.     @extra_window.close_proc   = Proc.new { close }% M. l+ m, s8 }; f) E* D# r: k. \
  677.     @extra_window.refresh_proc = Proc.new { refresh }5 n2 q+ E+ X3 @6 o
  678.   end
    4 N$ k/ R& g1 H# D- @
  679.   #--------------------------------------------------------------------------
    ) f) t) {5 {& u, y2 U/ @7 @4 ]. ~
  680.   # ● 激活新窗口  q+ [- j" S7 Z8 ^- M& B
  681.   #--------------------------------------------------------------------------
    4 h6 u) Q% i6 b) R: c6 ~- b( w" C5 U
  682.   def extra_start2 k1 G: C+ ]& t
  683.     case $game_message.position, G8 C+ z/ G" o9 V
  684.       when 0; @extra_window.y = y + height + 4) b. f. {& s1 D/ k% M; N! E
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    0 _! ^. l% d; t. t7 V2 E) C: b
  686.       when 2; @extra_window.y = y - @extra_window.height - 48 L9 Q+ P$ e4 Y5 [2 d3 e% m4 v
  687.       else  ; @extra_window.y = 8
    * d+ i2 i1 ]$ K  }, ?- \: V
  688.     end
    * r8 }$ D$ b% V; \
  689.     @extra_window.variable_id = $game_message.num_input_variable_id1 ~: N  q/ d: m- b$ C
  690.     @extra_window.digits_max  = @digits_max$ ^8 ~# c) t9 c# z# |, O
  691.     @extra_window.number      = @number
    , y% t! h2 X. @2 v2 ~$ N
  692.     @extra_window.open# C, `% s* [# K/ Y/ |
  693.     @extra_window.activate
    ( V% _2 g9 ~7 W
  694.   end* j8 D  t  L+ ^1 ~
  695.   #--------------------------------------------------------------------------$ b7 j. p. {/ ~/ Z. n# D; i8 Q
  696.   # ● 更新9 j, e6 u- i* ?: }  c* q
  697.   #--------------------------------------------------------------------------
    / @1 E  T3 f) H& L
  698.   def update* h: |* A% K+ ^$ Y9 }5 Q/ x
  699.     super
    ! E* c; Y; c: k: s8 z2 E- k# o- f
  700.     @extra_window.update
    2 {, S+ Q! v7 _8 `3 O% [5 t* u
  701.     update_cursor
    ! c3 M3 K; Q2 @$ y8 j# P- P
  702.   end4 J1 m' A8 E" q8 ?9 c
  703.   #--------------------------------------------------------------------------
    : x+ W: s9 l6 E
  704.   # ● 关闭窗口
    + h% o4 K2 J+ T3 q) C& ]. g
  705.   #--------------------------------------------------------------------------; i* ]" O0 E, \) L* x9 B0 E* R
  706.   def close# I6 r; @' w" ?9 N1 X/ C$ c
  707.     super
    2 N9 X8 v+ P) R: [6 \0 F
  708.     @extra_window.close0 H8 L+ [0 u  ]) l7 O1 Q
  709.     @extra_window.deactivate' ~( B! R2 y# {6 f* i
  710.   end& r$ J8 L4 L! N7 x
  711. end' v+ A" E7 G- b' k
  712. 1 {. p$ R& {- i' @9 [7 k8 ?
  713. #==============================================================================
    7 D% r# e+ Y( Z& P5 |9 R( l0 t
  714. # ■ Window_NumberInput_Ex3 h  T( @* d/ ~
  715. #------------------------------------------------------------------------------
    5 L- t  x) `$ F0 v
  716. #  新的数值输入窗口(NewClass)
    . y+ H0 \; H: ?" r$ f- }4 @
  717. #==============================================================================7 s/ l: g3 ~+ h; ^; d! d1 \; y
  718. class Window_NumberInput_Ex  Window_Selectable
    4 P0 @/ X$ v  n* p+ R
  719.   #--------------------------------------------------------------------------6 D- t" r4 [2 U0 q  b6 p, P# e! H) W
  720.   # ● 定义实例变量5 V, F! `& O0 G) D. G# R( n
  721.   #--------------------------------------------------------------------------; I* N- l" r' M; d1 Z# F
  722.   attr_accessor number_proc
    + r; C2 M' A" k0 K+ B- J0 i
  723.   attr_accessor index_proc
    8 }8 j3 e+ w$ O. ~! _" B$ o
  724.   attr_accessor close_proc
    9 \2 f( l  o9 g  |  x5 G' t1 ~" G
  725.   attr_accessor refresh_proc
    # A7 ?* F( S! \4 c3 k; h3 R. C
  726.   attr_accessor number+ B! [4 Y. C7 X
  727.   attr_accessor digits_max- G, d# \  R; X
  728.   attr_accessor variable_id' n+ s- O9 y( S5 G1 |8 s
  729.   #--------------------------------------------------------------------------
    ' E7 H( ~+ V" _% @. w2 a/ `
  730.   # ● 数字表
    4 ^# F7 f& d' _5 G
  731.   #--------------------------------------------------------------------------
    0 c9 `3 W. a$ a+ _+ V
  732.   TABLE = [  7,  8,  9,4 \5 v$ J& S& P  W4 J
  733.              4,  5,  6,! s% R. V; Y/ k
  734.              1,  2,  3,4 i; ?+ ~0 M1 Z: h& K' g" x. b9 T& d
  735.             '←',0,'确定',]* \4 j% P$ t2 F" v7 B4 k
  736.   #--------------------------------------------------------------------------5 a. n% l9 ^5 F% [* T
  737.   # ● 初始化对象
    : ^0 }: Y) U* a. d9 X
  738.   #--------------------------------------------------------------------------# s2 |, p9 R$ r/ d
  739.   def initialize# }4 ?. Q+ J" B6 I" u
  740.     super(0, 0, 120, fitting_height(4))2 e% |8 a* ]+ a& Z1 ]$ r
  741.     self.openness = 0: {  o0 L, z. T: q; j5 w2 R
  742.     @index = 0
    ' t' m9 T/ o$ a# K% p5 u) F  Y
  743.     @number = 0
    ; P8 j6 B# u3 s. F$ n! Z% ^
  744.     @old_window_index = 0
    ; {! R' ^* r$ h1 r& M
  745.     @digits_max = 0+ j( }( a( ~. M( R; Z) \1 o' c. L
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    0 D) P# |2 d* W: s
  747.   end
    / G0 P, n2 u" ^/ {
  748.   #--------------------------------------------------------------------------
    4 [7 L/ s% g& `4 I. V; @1 L
  749.   # ● 获取项目的绘制矩形
    , P- x1 r& y2 Z1 i, }/ e  V
  750.   #--------------------------------------------------------------------------
    / i' m' S3 x! j2 [# _
  751.   def item_rect(index)6 d. {1 ^+ q- L% D9 A, ]0 z$ \" I
  752.     rect = Rect.new  d- }! O! J. Q. ?" w( O
  753.     rect.x = index % 3  32- |5 Y( K: S) A0 v4 k
  754.     rect.y = index  3  line_height7 ]9 y  ^' i/ [
  755.     rect.width = 32' D3 m: f. W) a/ w2 V: C6 \+ I
  756.     rect.height = line_height' g* m, a" w4 U4 S. y1 G- j
  757.     return rect& E% L3 P# `8 d, s) g6 ]
  758.   end
    ' t, f2 V; I# ?4 X+ C6 o, m
  759.   #--------------------------------------------------------------------------
    . u. r, ^" q# q; G1 r5 U
  760.   # ● 将光标设置到鼠标所在的位置) n8 d# g2 I  C" r+ y
  761.   #--------------------------------------------------------------------------9 n4 L7 \9 A4 i, g
  762.   def set_cursor5 C* d  o3 ~) r/ z" g3 ]( Q3 A
  763.     mouse_row, mouse_col = mouse_window_area+ x2 V6 N: |( \: s) p7 Z
  764.     if mouse_row = 0 && mouse_col = 0% @6 U& V3 S/ `) @* @# c
  765.       new_index = mouse_row  3 + mouse_col  L' M) y, m* Z/ \  ^. N: i2 k; p
  766.       select(new_index) if new_index = 11
    ( m- P8 A4 F# i) |; }# v& D
  767.     end6 U! h% L6 [# Q( v7 K$ i  l, B' e
  768.   end
    3 u0 w4 `6 S) n8 |* m8 X* H
  769.   #--------------------------------------------------------------------------
      |; Q; S+ ]6 J/ Q. m- k- c4 ?2 a! V) @
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列- @% \" Y& L0 J. s- d
  771.   #--------------------------------------------------------------------------& g9 I' I% E4 F- |' \7 \
  772.   def mouse_window_area
    ' |9 k6 K; i$ }* I9 K/ p
  773.     if viewport.nil
    : ]3 S  t  X2 q2 a0 N! d
  774.       vp_x, vp_y = 0, 0
    , T: P7 a. l6 s5 c9 u  [' X4 O* Z
  775.     else
    4 _- P5 j! n0 h7 w
  776.       vp_x = viewport.rect.x - viewport.ox1 H3 w2 c2 H  X! j* z& r' y
  777.       vp_y = viewport.rect.y - viewport.oy; |7 ^. H) l, Y, Y9 Y3 K( w
  778.     end  M  i. Q! s: q. {; C
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y7 H# v% V( E! u% J) e
  780.     item_x1 = vp_x + x + standard_padding
    8 h8 Q4 {) i$ B" X9 n2 n
  781.     item_y1 = vp_y + y + standard_padding
    0 j$ V0 J- \- B$ S) u: I
  782.     item_x2 = vp_x + x - standard_padding + width' u7 O8 J9 v: c
  783.     item_y2 = vp_y + y - standard_padding + height
    6 T2 O, p1 o( F2 N  z3 r) k& ]" A6 L
  784.     if mouse_x  item_x1
    4 P1 ~! G" M  d. K
  785.       mouse_col = -1
    4 r1 J5 I# K: f+ C; x
  786.     elsif mouse_x  item_x23 H) D8 d) q4 \! ~( n  j
  787.       mouse_col = -29 D+ J# T3 [8 W2 V8 X4 c$ i
  788.     else) B, L' k6 [% X' P0 y2 q1 p: _
  789.       mouse_col = (mouse_x - item_x1)  32* R, }( I8 E/ s4 Y( y+ d
  790.     end
    / ]# b9 g1 w! }1 d; F
  791.     if mouse_y  item_y1
    $ b0 H9 v. i$ P) r  O
  792.       mouse_row = -1
      o5 Q' @. Z0 {* L* ^' [+ U/ v
  793.     elsif mouse_y  item_y23 M! h7 Q- q# s7 n
  794.       mouse_row = -28 e6 Y- t  H5 F3 v7 j
  795.     else
    + ]( c  _* o# M' i
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    9 m) X4 P1 g% g4 f' a! Z9 T* d
  797.     end* b) p: Z! ], r* l% a8 z
  798.     return mouse_row, mouse_col
    0 a0 y  ?; T8 \3 i9 y. H  _
  799.   end
    - g" A- @* V  v' L/ g4 F, `
  800.   #--------------------------------------------------------------------------  i- X8 x2 ]$ }. A* v' Y3 s; N, @
  801.   # ● 获取文字
    ( f( y. ^1 C' B8 M3 S' u
  802.   #--------------------------------------------------------------------------
    # n% y* ]$ N& y0 \' K# B+ ~
  803.   def get_number$ z2 z* T  U6 K4 e& ]
  804.     return false if @index == 9  @index == 11/ R1 Z; H% i  E: ~3 Z* y( u9 r
  805.     return TABLE[@index]# P% h" P9 n0 i- v! f
  806.   end# W) y) \7 t6 W0 I6 P/ b" M
  807.   #--------------------------------------------------------------------------2 p0 A6 P. ^! _2 Q
  808.   # ● 判定光标位置是否在“退格”上  w5 z6 S6 _- R' ^. B; y. P
  809.   #--------------------------------------------------------------------------
    8 M  Q. m1 u! Q3 j/ l+ x9 ]  @# M' f6 w
  810.   def is_delete  T2 A& I6 @1 @) u2 `& U: E& `
  811.     @index == 9
    8 {5 V; B" V: C
  812.   end
    : n( h. b7 U2 Y  y4 B( C9 v
  813.   #--------------------------------------------------------------------------# c3 q) C6 J9 D1 h7 A8 P
  814.   # ● 判定光标位置是否在“确定”上
    5 r7 c4 E5 Y8 l' C: Y  H3 P
  815.   #--------------------------------------------------------------------------
    $ d- d: v. s6 e# `; t& `& A
  816.   def is_ok0 y# A  p' U* m: n7 q! R! c9 h
  817.     @index == 11. B$ c: T4 `8 A4 d
  818.   end' Y/ U; R/ o' d4 w6 Z8 z4 F5 R2 ?
  819.   #--------------------------------------------------------------------------' {9 W  ?8 y! j
  820.   # ● 更新光标( m6 s0 a8 v9 ?$ L/ S7 J
  821.   #--------------------------------------------------------------------------% `2 A( m2 `- b
  822.   def update_cursor
    & A. e# T( H' e1 N
  823.     cursor_rect.set(item_rect(@index)); E! a" A; g+ ]5 l  j
  824.   end; W. |% S7 Q6 O8 @: x) b
  825.   #--------------------------------------------------------------------------
    1 X' z# P3 A* n+ o. |0 x
  826.   # ● 判定光标是否可以移动
    / v0 [  M3 Q& Z8 Y+ e2 N! S$ ]# F
  827.   #--------------------------------------------------------------------------
      o+ l1 A  ]: F3 l% [1 Y! ~, `1 x
  828.   def cursor_movable
    " \1 F/ J3 i, G( p( V- J
  829.     active; T: H4 {7 J; C# k+ I( q. w; t4 F
  830.   end$ N$ D- x1 ]1 R, u7 B
  831.   #--------------------------------------------------------------------------8 `8 ]0 o7 B+ \& E
  832.   # ● 光标向下移动
    ) `6 i. j! f- ^6 I5 s
  833.   #     wrap  允许循环: y0 J5 E+ e/ [. T; \% C
  834.   #--------------------------------------------------------------------------8 A% j2 g) s, w+ F
  835.   def cursor_down(wrap), q$ X! X/ e( G9 ~/ |9 p$ x
  836.     if @index  9 or wrap
    % X6 }% ]/ Z& b
  837.       @index = (index + 3) % 12+ R$ V0 U/ e7 x$ {" ~* }& v4 W8 t. Y2 K
  838.     end* a0 A1 H; {" |
  839.   end+ e9 G9 [9 x( I& z+ j. \# F; d
  840.   #--------------------------------------------------------------------------- G8 O2 f3 Z, p2 E3 V; p1 A% V; d
  841.   # ● 光标向上移动
    : |. |- o4 V4 w. l" n0 \
  842.   #     wrap  允许循环
    8 E1 _6 j2 W2 r7 m) R3 F
  843.   #--------------------------------------------------------------------------
    # B6 X8 f* d, h4 X" W( N, F
  844.   def cursor_up(wrap)+ v% }. b$ o; Z6 V% a
  845.     if @index = 3 or wrap
    " |( \0 f2 I' s0 `6 T3 C9 J
  846.       @index = (index + 9) % 12) N: [% Q( j7 Q# n! C
  847.     end1 i: A! m2 M$ ]
  848.   end
    : C2 u6 l' w9 u. q% X0 ?* R
  849.   #--------------------------------------------------------------------------
    : B- w/ c9 d: s5 s% N* L* K
  850.   # ● 光标向右移动
    - j8 \- x' R# z1 T1 U4 z" E
  851.   #     wrap  允许循环
    4 ~2 ~# f1 o* V' \$ y" H
  852.   #--------------------------------------------------------------------------5 B. I( `8 S6 p5 I  L% M
  853.   def cursor_right(wrap). U( I$ M- g+ F  T
  854.     if @index % 3  28 x7 [& ]& e4 `* u$ n
  855.       @index += 1
    % `  j7 k1 P' E3 W" v% h
  856.     elsif wrap
    ) ]8 p4 t& u: w% j  Y7 T( b
  857.       @index -= 23 S0 e- T# E1 w% z9 ^% R6 B
  858.     end
    2 c; `9 a* j; B+ j9 L- L% I0 c3 ^
  859.   end0 ]% N( G3 x- F
  860.   #--------------------------------------------------------------------------
    ; S* f# M! i$ K2 t* E: j8 H
  861.   # ● 光标向左移动+ F& z+ u/ ^7 L6 ]/ l" G$ f) J
  862.   #     wrap  允许循环
    % m. j. h' I8 ?$ ]3 M9 Y' S* b; Z
  863.   #--------------------------------------------------------------------------
    & o* n' s5 ^1 p1 t* P( }
  864.   def cursor_left(wrap)) z) ?3 F% ]  C, N& z
  865.     if @index % 3  0' l7 [, H; `: t1 a! I
  866.       @index -= 1* K; l4 j3 ~: k8 e  q3 R8 ^
  867.     elsif wrap
    1 j) y! p2 X7 s! Z* M- ?, i
  868.       @index += 2
    ) h+ B' p9 @/ D9 y+ T5 P1 J
  869.     end# P. q4 k! B% h: p
  870.   end
    * E& x7 \, Z2 [9 \/ q8 B6 `# T
  871.   #--------------------------------------------------------------------------
    3 n$ R' e/ U) q; K
  872.   # ● 处理光标的移动
    ! t9 H0 Y& h5 Q) S3 x4 s) @
  873.   #--------------------------------------------------------------------------
      U* o3 Y1 l( G' E. B' q  A
  874.   def process_cursor_move
    ; A! I. _1 e. ~9 q' F0 |
  875.     super
    9 D0 U1 _2 S* y- M6 M- D
  876.     update_cursor6 d2 d+ P5 O& Y8 b9 i" |
  877.   end
    ; o0 j, ]6 N. S5 G, b( \; \! \
  878.   #--------------------------------------------------------------------------  n# f) G# V% T5 i& M
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    4 Q$ W2 G5 }( l/ M# e8 T% H
  880.   #--------------------------------------------------------------------------
    ; l: y2 v& T3 Y' ?  h
  881.   def process_handling0 c1 C, \  w. y! |7 @; O+ S
  882.     return unless open && active
    7 _! [. ^8 A% j6 d. a7 K% M
  883.     process_jump if Input.trigger(A)
    6 ~2 {) P; ~' u) }. z; W+ [% g
  884.     process_back if Input.repeat(B)
    ! A9 m! c* C' ^$ r
  885.     process_ok   if Input.trigger(C)
    0 i! @: H4 ]- F, b! k
  886.   end0 M' a  n. ^; w! k$ c
  887.   #--------------------------------------------------------------------------
    ; S$ @/ z2 h- F' B, o/ p* z
  888.   # ● 跳转“确定”) b% b  l: s* H9 J( t# `+ Y
  889.   #--------------------------------------------------------------------------4 C0 V& }* a! N
  890.   def process_jump7 p: y) Z3 g! ^8 i" }
  891.     if @index != 11
    % q. u9 D; O( J/ V( P2 ?0 e- ~
  892.       @index = 11
    ) ~" I: Y: X: X) m/ ^. W
  893.       Sound.play_cursor- Q3 o: Q' e8 ]! ?! V1 `  _
  894.     end. a9 ?0 C, ^7 H; `
  895.   end
    9 k; A9 y5 U2 k' e; {
  896.   #--------------------------------------------------------------------------
    " Y9 ~$ M, ^) }6 i" {- H
  897.   # ● 后退一个字符
    & p) Q: d4 l8 D) f
  898.   #--------------------------------------------------------------------------: N3 M5 o( C/ H& y
  899.   def process_back& E$ J4 B. I, ?, C
  900.     Sound.play_cancel
    & {' w# G+ L* ?
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    $ X$ u: `4 W3 v$ q. d
  902.     n = (@number  place) % 10+ R& D6 Z) _! e9 H
  903.     @number -= n  place
    % s0 I6 G: c2 H2 ^' p5 i3 [6 ?- P
  904.     @number_proc.call(@number)
    : a3 _3 c" N* N( T
  905.     @old_window_index -= 1 if @old_window_index  0
    * K1 w; T- W+ r% |3 I2 \8 r3 t
  906.     @index_proc.call(@old_window_index)3 @( b+ I7 N0 ^1 z5 g
  907.     @refresh_proc.call$ [3 r: e# S, X. m" ]
  908.   end# k; `5 j' J( S' v9 I
  909.   #--------------------------------------------------------------------------( n8 X/ q2 [1 `. Y
  910.   # ● 按下确定键时的处理
    . G1 k' ^) }  M( n; c% O
  911.   #--------------------------------------------------------------------------
    " _1 Q  o7 e; Z) o
  912.   def process_ok
    # L( R& X" M7 Y3 R! U  y
  913.     if get_number4 A* u5 _* o3 I& L( }$ w1 q3 F
  914.       Sound.play_cursor
    ! f% E. R" ~6 r- a0 L
  915.       place = 10  (@digits_max - 1 - @old_window_index)# M' D* _' C, I& z! h2 U/ _
  916.       n = get_number - (@number  place) % 10
    ! @- X; {7 A5 Z
  917.       @number += n  place
    2 R/ o$ W/ o9 V/ e* U
  918.       @number_proc.call(@number)
    * y+ H  N) q; \- E2 i
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    0 [( e( [$ j! j- C8 [+ b
  920.       @index_proc.call(@old_window_index)9 N  L+ ~% ]. @/ m
  921.       @refresh_proc.call
    1 d3 Y& a5 q) s$ t! P
  922.     elsif is_delete* r$ |2 \0 s/ P( K) ^  b" S
  923.       process_back& C0 N5 a, S7 U( A) O
  924.     elsif is_ok
    ( r' `) P4 ~. y
  925.       on_input_ok
    6 t6 P; v& W; ?9 c2 R5 S. R
  926.     end
    , ]( T& A4 @0 ]. F% t' E
  927.   end
    - Z# N5 P+ ^7 B1 [
  928.   #--------------------------------------------------------------------------( X. E3 O2 F- i+ J' ]# X
  929.   # ● 确定% B% [! t" K' U; d( ^1 P- a: L( @# G4 w) \
  930.   #--------------------------------------------------------------------------
    2 A3 w  t% x, j2 G1 o- S- z; y* T
  931.   def on_input_ok3 X1 p7 B/ l6 H# X
  932.     @index = 0
    6 n, E+ t; M0 U2 w: N
  933.     @old_window_index = 0
    * n+ w% @& p+ w( \# Y8 r6 M
  934.     $game_variables[@variable_id] = @number9 B0 r) u/ C- ]7 e+ k/ P! I/ I
  935.     Sound.play_ok( k( g3 Y4 t- ^# X5 V
  936.     @close_proc.call
    ( N- c" q: s( I/ U( B9 x
  937.   end
      C9 a7 {6 f, s' ?1 ~
  938.   #--------------------------------------------------------------------------8 s+ L/ W0 L9 ^
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ) Q* m( ?  Y# ^8 f
  940.   #--------------------------------------------------------------------------+ o7 `3 {, Y" F+ Z( y
  941.   def set_mouse_pos9 u4 x  P* t( s, n' D
  942.     if viewport.nil # necessary!% F) F1 s/ B$ u" F# U
  943.       vp_x, vp_y = 0, 0, b5 P4 h7 J/ h  X
  944.     else3 {# u8 g: P2 O+ [. S$ @
  945.       vp_x = viewport.rect.x - viewport.ox
    4 Z3 u# l* r! _# l$ H( P
  946.       vp_y = viewport.rect.y - viewport.oy4 N5 `1 V" {; q/ a
  947.     end
    # m4 d3 ]/ ?6 Q1 t: @- Y; V! t
  948.     item_x1 = vp_x + x + standard_padding ! ^% @9 |; X) l6 D0 v6 r
  949.     item_y1 = vp_y + y + standard_padding
    % s+ O  ~1 N6 ~* J
  950.     get_index = @index  0  0  @index
    , |; E9 {+ R8 T2 Z, J
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    5 p6 l# y5 j# g2 ]
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)! G- F& A4 s- |8 a1 k
  953.     Mouse.set_mouse_pos(new_x, new_y)
    % Q: p! ^; P( d8 O: ^
  954.   end
    . U8 l  h4 u' F1 s' V  ~4 ^; }
  955. end
    8 s1 v& ]. k- M

  956. 9 r" f" S# s+ O6 a2 `- C
  957. #==============================================================================
    5 {0 t# c5 w8 q+ U# ]! r
  958. # ■ Window_Message
    ; Y0 i# i9 S" c: G! z1 [0 @
  959. #------------------------------------------------------------------------------
    1 n6 I$ m) S) b9 K! [8 C& F% Q
  960. #  显示文字信息的窗口。
    3 O$ _' K. v, V: k( V
  961. #==============================================================================! X( [# o  W: p
  962. class Window_Message  Window_Base
    * e; B* B% m8 S* L7 V* w% _
  963.   #--------------------------------------------------------------------------
    ) x+ E( d, S& n: Z4 m6 L
  964.   # ● 处理数值的输入(覆盖原方法)
    ) s# ^; o5 w* C4 ^. x9 O/ e$ z
  965.   #--------------------------------------------------------------------------- B- L) Y4 z) Y; S! N  |
  966.   def input_number
    $ I% T' E9 [+ R2 q+ Q. c
  967.     @number_window.start
    * L( ]/ g4 {+ \+ d: r) m/ E
  968.     Fiber.yield while @number_window.extra_window.active
    + W8 I  S) B4 J3 m( u/ j
  969.   end  ], B( }6 V; p( T: m$ p
  970. end
    & y1 L+ _1 C* m7 f% U  h3 @2 K

  971. 8 N. \# N$ j2 ]8 f8 N8 R8 `! o
  972. #==============================================================================
    " j$ v& l- w/ u! B5 S" T# \
  973. # ■ Window_PartyCommand
    + p# F) \1 C3 ^2 l
  974. #------------------------------------------------------------------------------
    + g! n, p9 z& l" i
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    & b  W8 O+ ~5 E& D  b" i
  976. #==============================================================================
    ' @9 |$ Y. H3 |6 m' t
  977. class Window_PartyCommand  Window_Command
    ! K/ p% v  z# K' _
  978.   #--------------------------------------------------------------------------
    - _, V* @) P: H8 Q; r
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置' E4 y" A6 D& K! |" Q+ `
  980.   #--------------------------------------------------------------------------+ g- X7 g- N  L0 X( L
  981.   def set_mouse_pos( l; _* [) R  W2 u* S( t9 b
  982.     if viewport.nil
    7 D0 s$ I$ o/ {" o, B
  983.       vp_x, vp_y = 0, 0, e( w# v; E& G8 X
  984.     else
    ' N) ~( A. k1 ?
  985.       #vp_x = viewport.rect.x - viewport.ox" m: L/ y0 l& V- ?% d/ ~
  986.       vp_y = viewport.rect.y - viewport.oy
    7 A. U& ^5 C! W& M( t& }
  987.     end- X) w! f2 c0 V% P0 f# X" J
  988.     item_x1 = x + standard_padding & U* Z8 f+ n) a. _! Q. _3 j4 ?  ~
  989.     item_y1 = vp_y + y + standard_padding
    5 H8 d# p2 n- a& j
  990.     get_index = @index  0  0  @index
    / i' p7 y6 p6 K* L2 M# Y. J
  991.     row = get_index  col_max - top_row
    # b- J( X# t2 a" l& B
  992.     col = get_index % col_max1 k& P" c' ^% i9 B4 @$ Y
  993.     new_x = item_x1 + item_width  (col + 0.5)
    * Y" f# a: r1 f7 X+ E/ V
  994.     new_y = item_y1 + item_height  (row + 0.5). F! W! t8 Q( S; A. R
  995.     Mouse.set_mouse_pos(new_x, new_y)
      K4 m& w) F; |% i0 W. w* a; ]6 P
  996.   end4 W) L7 H' {0 F4 c
  997. end
      G& `8 v% K3 v% A( A6 ^

  998. 5 R- e$ ?% Z$ a) f% h1 v
  999. #==============================================================================% j' M) L) @. \' u
  1000. # ■ Window_ActorCommand5 e1 t' g: d. C& y8 E9 z
  1001. #------------------------------------------------------------------------------
    / J4 P$ c1 g" }; W7 e
  1002. #  战斗画面中,选择角色行动的窗口。
    ! D* j, B+ e  a, R; Y6 c4 b1 w
  1003. #==============================================================================% X2 @; P3 |7 P+ Z" X) q( J8 v/ {
  1004. class Window_ActorCommand  Window_Command% w6 d/ q/ }: I6 M" h7 R3 t8 I
  1005.   #--------------------------------------------------------------------------- i8 R. e( z+ q8 y2 C$ s
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置. ?2 n4 U7 E  z- M1 i  W
  1007.   #--------------------------------------------------------------------------
    1 i: N  ^, {# |* C4 n7 K2 C
  1008.   def set_mouse_pos
    : p2 R/ @1 ^$ y) |* T& k. ?
  1009.     if viewport.nil% ^% d1 G7 ^$ q% x) N/ s3 d' l
  1010.       vp_x, vp_y = 0, 0
    & X0 U  z  A6 A3 {/ ~
  1011.     else
    ! I2 z' c9 U6 p& G; z
  1012.       #vp_x = viewport.rect.x - viewport.ox
    3 U" l% X& M( p* T9 |2 P
  1013.       vp_y = viewport.rect.y - viewport.oy
    8 J, _2 [/ {$ Y" G9 i
  1014.     end$ H/ _& W3 [% j( d" W
  1015.     item_x1 = Graphics.width - width + standard_padding, ~- Y5 p. I6 g: V7 x, r3 Z
  1016.     item_y1 = vp_y + y + standard_padding; @, A' x6 }4 x5 ]: Y
  1017.     get_index = @index  0  0  @index 4 [9 ]6 a7 c7 v/ N: o% {& o6 E
  1018.     row = get_index  col_max - top_row
    1 Z, ?% ?5 M: j1 b1 ?- w
  1019.     col = get_index % col_max
    8 k" M: I, {# U, }  z- w
  1020.     new_x = item_x1 + item_width  (col + 0.5)) T. }1 \& M& m/ \9 A0 s: h
  1021.     new_y = item_y1 + item_height  (row + 0.5)3 `6 b9 `2 `- |0 L8 J5 h
  1022.     Mouse.set_mouse_pos(new_x, new_y)5 N" z- H: T) H) [
  1023.   end
    ! `7 C9 e) H. O5 x$ m* |
  1024. end
    1 R! S4 @! s" C' D

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

  2225. # I1 p1 X8 G6 \1 Z% v7 B
  2226. #==============================================================================
    : ^. I; D  a3 w5 g; Z; D
  2227. # ■ Spriteset_Map
    6 e1 }$ r2 {% l. q. \! ~
  2228. #------------------------------------------------------------------------------
    : H5 a' q2 {0 p" ^) `' ?
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    2 c$ S! C% t9 G% z! G
  2230. #==============================================================================4 U$ \0 e$ T4 ^( c1 n( R+ ?* x
  2231. class Spriteset_Map
    , [7 z5 U, x# ^% c' I
  2232.   #--------------------------------------------------------------------------% f: E$ e, b& v8 F' L4 e- ^1 Y: W- @
  2233.   # ● 生成路径点精灵
    . ^3 T' r8 D7 d8 B  {, R
  2234.   #--------------------------------------------------------------------------
    : a) J8 G) }8 J  n& w, h# x
  2235.   alias sion_mouse_create_characters create_characters
    2 R! {5 \  U9 \$ M
  2236.   def create_characters8 N# x$ g/ [4 z" [# I
  2237.     sion_mouse_create_characters
    7 B! z7 u9 y' g3 P0 z
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))# @: _0 `2 `6 K. e+ g
  2239.   end
    ; e5 z4 R2 L! M1 Z5 h5 \; ?- H5 s1 t
  2240. end
    , x7 w4 k" U* Y; q) O

  2241. . J, [; n$ h2 t2 e4 g9 j0 g
  2242. #==============================================================================
    # M9 o- |* g0 L/ P& P8 a- m& |
  2243. # ■ Scene_Map
    3 }3 L9 b3 {: ]8 O( S
  2244. #------------------------------------------------------------------------------
    ; ^5 u# {! @: ~* z" ^- T2 k
  2245. #  地图画面
    ) G: f# R$ }) W6 ~- |
  2246. #==============================================================================. x3 H1 Y( b8 B- _
  2247. class Scene_Map  Scene_Base% b% i9 C( L! `: g) k+ o3 v
  2248.   #--------------------------------------------------------------------------, u! N! O( q4 y! G6 X! U
  2249.   # ● 画面更新
    9 o) F/ a' L) p1 }+ B- b8 C" _9 J
  2250.   #--------------------------------------------------------------------------! X1 `) a, d/ `
  2251.   alias sion_mouse_update_scene update_scene
    ' h1 [7 o6 f3 c
  2252.   def update_scene
    9 L  V! [& f: [5 n% Y% Q& e
  2253.     sion_mouse_update_scene
    3 ?& H% b1 q& f3 c- p9 F: i/ A
  2254.     update_mouse_action unless scene_changing3 Y, H4 C1 q$ ?( F/ G
  2255.   end7 W6 C3 V+ l) E# A- T! `
  2256.   #--------------------------------------------------------------------------7 r; r% X/ p) B7 D6 C
  2257.   # ● 场所移动前的处理3 f! b. q4 ]7 A: R  x
  2258.   #--------------------------------------------------------------------------8 I5 w7 a; ?& T5 A+ A
  2259.   alias sion_mouse_pre_transfer pre_transfer
    / u6 s" s- O' ]: `/ h. O, P; t
  2260.   def pre_transfer# u- a5 C# C6 f) J; @
  2261.     $game_player.reset_move_path) L) I/ V7 D+ B2 ^. E( e( d! Y
  2262.     sion_mouse_pre_transfer/ |' [9 X0 p' K
  2263.   end! i' G3 s! i1 Y* c7 d
  2264.   #--------------------------------------------------------------------------2 |7 V" `1 D2 s  z/ T/ o( n! j
  2265.   # ● 监听鼠标左键的按下5 [) n4 G9 T, v1 j% |1 ?; f3 D
  2266.   #--------------------------------------------------------------------------
    " b6 P, r# t4 R& @- n4 ?
  2267.   def update_mouse_action
    , x5 G* F! F) G) O5 A/ }( p6 I
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    ' I4 R* b8 q* G* r, y  s9 A
  2269.   end
    + l" k, k- r5 C$ [& |" U' Z# `1 s
  2270. end& Q. e3 R1 [0 p6 c" i

  2271. 2 J8 c4 d! m# K- w: A' A% Y
  2272. #==============================================================================1 ~  l4 v) Q& D  |* p# s/ O# x
  2273. # ■ Scene_File
    ' x8 ^  u* e: x- \7 l( {6 m- ^
  2274. #------------------------------------------------------------------------------
    $ i( A2 \9 i) s; a0 l
  2275. #  存档画面和读档画面共同的父类& x9 |9 I* `+ W% e; b: Y' l
  2276. #==============================================================================
    ! |: u) `3 m- V6 R
  2277. class Scene_File  Scene_MenuBase
    8 }, b! ?6 C" b* ]. x8 k" z  s. J
  2278.   #--------------------------------------------------------------------------5 R5 l, J7 a; ?7 n$ N. o
  2279.   # ● 开始处理
    + y$ p- V4 g, H* _
  2280.   #--------------------------------------------------------------------------3 R# E) F6 D6 z% t+ e
  2281.   alias sion_mouse_start start
    : E2 u9 G5 c; p, ~# p; A% ~
  2282.   def start! f+ U, _3 s+ L7 {6 s+ W: v
  2283.     sion_mouse_start7 M$ Z7 h; s1 o7 z9 k& i
  2284.     @move_state = 0' R6 c% t$ i4 N
  2285.     set_mouse_pos
    ( u. X7 H$ \9 S1 }  r
  2286.   end
    $ T8 u) q: o6 E  c$ I% G
  2287.   #--------------------------------------------------------------------------& z7 P- K4 q6 c. F; q5 D7 R: E
  2288.   # ● 更新画面* X4 h  `. A1 b6 G8 \2 c7 M
  2289.   #--------------------------------------------------------------------------5 m+ T# t% z& i3 l% Q
  2290.   alias sion_mouse_update update
    - E) J' ]8 |* c. v& B
  2291.   def update: ?& Q& d; K! \
  2292.     sion_mouse_update
    5 K$ b2 T, a" ?+ B
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    5 ^& h: a0 T. E/ z8 O
  2294.   end
    6 R3 F2 G7 m9 L
  2295.   #--------------------------------------------------------------------------/ \+ z0 I+ Z6 S$ s$ K9 \) P7 t- {4 T
  2296.   # ● 更新光标" s; Z( k; r/ K- @" z
  2297.   #--------------------------------------------------------------------------( t) a1 p- V+ }$ h
  2298.   def set_cursor# A6 x5 i4 y0 `1 K
  2299.     @move_state += 19 |" ^% p6 q, M1 X7 u( C
  2300.     last_index = @index$ E$ D  {. |; G  e
  2301.     if mouse_which_window == -26 S6 I. h9 w. F: {! ]
  2302.       if (@move_state - 1) % 6 == 0
    3 ^! O7 w3 j3 y' u
  2303.         @index = (@index + 1) % item_max if @index  item_max - 11 E3 s" Z' J2 z$ `- n/ J
  2304.       end, x4 i- @5 M0 j
  2305.     elsif mouse_which_window == -1
    ) n& Z+ |- o- u# f
  2306.       if (@move_state - 1) % 6 == 0
    6 y" {7 w0 b$ h0 ~7 |9 b6 R
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    4 f5 i" {  c; w
  2308.       end
    4 @( N! l8 b( e* \5 b7 N: M) t0 E0 l
  2309.     else
    4 T8 Q# i4 [1 T9 J2 n4 E7 Q7 z
  2310.       @move_state = 0' z  }, u2 z4 |4 {& G2 s* t! S8 T" X, x
  2311.       @index = top_index + mouse_which_window
    ' B! ^  ]2 h& h' G
  2312.     end, d! g- K( R  h$ u" e  C
  2313.     ensure_cursor_visible6 y  G) ?! o" j* }0 R( `/ Z  s
  2314.     if @index != last_index5 k% ~9 f0 Q8 C! R
  2315.       @savefile_windows[last_index].selected = false
    2 z' P( T3 M/ x. c: V' u4 i
  2316.       @savefile_windows[@index].selected = true
    / {) K6 b* H9 k+ \6 x7 W+ L% C
  2317.     end0 O  |* d- w* L+ v# ]
  2318.   end
    8 R5 N0 E, s2 r3 p
  2319.   #--------------------------------------------------------------------------7 L- d: E% s' M5 r
  2320.   # ● 判断鼠标位于哪个窗口
    6 l, C1 ^" \/ F7 I3 s; ?7 M
  2321.   #--------------------------------------------------------------------------
    $ x. `" y  U6 e7 u) j% u
  2322.   def mouse_which_window0 |( u8 C: k5 w4 z4 l% \
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y8 J/ S- q! E% w* g
  2324.     if mouse_y  @help_window.height + 14
    , O/ {( l9 n2 @. P
  2325.       mouse_row = -17 A$ X# a- V: ^' T9 h
  2326.     elsif mouse_y  Graphics.height - 14
    $ E  a6 v$ k7 r, H8 F6 o( p$ f- [( V
  2327.       mouse_row = -2
    + E1 Z4 g# F# f5 x/ _; C
  2328.     else
    " T8 v9 ?. Q- r
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    8 u$ G5 O$ V3 p1 m/ K& x% x
  2330.         (Graphics.height - @help_window.height)
    , E$ L5 C* g' i' b+ o
  2331.     end
    8 B% m3 H9 ^: f0 o( K
  2332.     return mouse_row; [+ C0 R+ o3 J
  2333.   end4 T4 w( `. v: {; \1 C
  2334.   #--------------------------------------------------------------------------0 D1 N$ d$ e$ t: k) D
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    , n# ~2 ~) h8 Q: N* V  Q
  2336.   #--------------------------------------------------------------------------
    7 m8 G  `( I0 o9 |5 g
  2337.   def set_mouse_pos
    & r* K5 d& ]* ?5 G* J3 e/ _% L5 \$ N/ U
  2338.     new_x = 40
    ( I. V" A3 y* j% w! r% U8 {' _
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24: [- ]. v/ b4 U% ^
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    4 z* a/ a9 k0 O: B. l
  2341.   end+ F) l7 t1 q( E+ V2 L
  2342. end" ^+ S/ Q( t  @% N; y9 B* X1 X2 Z

  2343. ) x2 P4 W" R0 y
  2344. #==============================================================================, g2 I! G- `5 ~6 n5 f' S
  2345. # ■ Game_Event5 V6 q. w" y: [
  2346. #------------------------------------------------------------------------------
    4 E% ?1 v, E8 ^' S5 K8 v* [
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    ' [2 d9 U! t: s2 A7 A7 a& `  o2 S
  2348. #   在 Game_Map 类的内部使用。, F% ~- e1 S& T+ s9 E
  2349. #==============================================================================% F( H+ o4 c7 l. _9 y% u- E8 t; _8 o' l
  2350. class Game_Event  Game_Character# A% ?' I" y8 g# Q
  2351.   #--------------------------------------------------------------------------
    ( ?. b' Y) k: w, ^& C
  2352.   # ● 事件启动
    * j- U# X+ N4 H6 i2 G
  2353.   #--------------------------------------------------------------------------
    ( ^& }! x% ?& F1 A' Z
  2354.   alias sion_mouse_start start
    3 ^: J4 y* U5 J$ M' N
  2355.   def start! Z5 e) \# O% Z: X1 k
  2356.     return if mouse_start && !Mouse.press(0x01)
    ' |4 y. ]! o/ {1 I- w% f0 A) r
  2357.     sion_mouse_start
    8 G4 _- {6 ~! ^3 d7 N0 P. m
  2358.   end
    ; l' V6 J- N! k/ q# s
  2359.   #--------------------------------------------------------------------------1 H  I8 i! k' ~4 S% |
  2360.   # ● 判断事件是否由鼠标启动
    $ M3 t# U! ~& w% s( E$ _' J
  2361.   #--------------------------------------------------------------------------" {  s  `  [( x, q; ^: {$ g+ |
  2362.   def mouse_start& j& A" ^& J8 }; ^% m
  2363.     return false if empty
    4 f, d# }: f' C7 D+ H
  2364.     @list.each do index, u1 ?: w1 q& V$ l: P3 Y
  2365.       return true if (index.code == 108  index.code == 408) &&9 L# u2 O/ p  }* r9 {
  2366.         index.parameters[0].include('鼠标启动')/ E: v9 ~' f6 D4 L9 L4 Y0 r
  2367.     end4 G/ X1 N5 B# r0 J9 P4 L
  2368.     return false
      l: Y/ V" c  D6 D
  2369.   end
    : e" h: y" F5 {& Z& P0 q
  2370. end
    ' m; E5 s4 q8 d( P9 q5 ], j; x8 Q6 Y
  2371. ; u' x7 {8 e3 @$ A
  2372. ####泥煤的height6 N' Q  a) Z$ ]9 v3 W' l% u
  2373. # @height = height
    7 X" ~* {8 d$ |% h5 R+ a

  2374. * _" N; h% B  e
  2375. class Area_Response
    ! s# N3 {9 U- r0 d# f
  2376.   attr_accessor type
    , n3 D& f6 o4 y# x2 y
  2377.   attr_reader ox
    ) O( e4 T& P. b3 E5 t; \
  2378.   attr_reader oy
    0 V- w/ v, j4 p# I- O% ], V
  2379.   attr_reader width
    # A3 z/ _$ B! ~& O# B) w1 G) J8 ^$ c
  2380.   attr_reader height
    ) L- ~. P; F- D  e% \, @& h
  2381.   attr_reader switch_id  v9 {2 v2 N- C1 p! O
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)7 M* R* ?# P- t- S, V3 A! ^- b
  2383.     @type = type
    2 O% ^, U- L2 `- W' p
  2384.     @ox = ox% ~  j- M6 H, D2 O# N5 g$ H3 k
  2385.     @oy = oy
    8 f, k: ?$ M- g. t- K. |
  2386.     @width = width
    7 H6 H4 S3 Y, q( j$ K- h
  2387.     @height = height
    ! D# j% W% \9 _2 X1 i- ?  v
  2388.     @switch_id = switch_id
    # _, o- j/ m9 r8 B" r$ W  r' `
  2389.   end! W1 R+ j" F) v5 |4 w# \; y1 Y" p
  2390. end
    6 V& N, l( l4 c$ n2 w
  2391. " U  [  v! i  H: f* A9 G
  2392. $area_responses = []3 ~( W. o# G/ V  u% c9 q
  2393. 8 d9 D. k9 x$ G* U/ f
  2394. class Scene_Map
    $ [' t* H8 W4 x
  2395.   alias update_mouse_2013421 update_mouse_action
    1 g# `; M$ C" l' h
  2396.   def update_mouse_action% H2 m& j$ D- _( @
  2397.     update_area_response
      a8 ^' g8 D5 A+ r* V
  2398.     update_mouse_2013421
    2 k& A; l! `4 m' X$ Q3 ^3 V5 i
  2399.   end& y5 k8 u! d* {5 o
  2400.   def update_area_response6 w, k: V  f5 O
  2401.     responses = $area_responses3 H3 ~1 M7 p$ F8 j  W5 M& x/ Q# k
  2402.     responses.each {response! U7 t/ U8 b& W* Z0 w
  2403.       ox = response.ox' p1 [* t: V% H4 y2 Q
  2404.       oy = response.oy
    ! s" j: ?# x, `* g" \1 q
  2405.       width = response.width
    6 w4 I9 F4 B2 _" `
  2406.       height = response.height1 q9 `# Y" O3 ]  `  Q9 {
  2407.       switch_id = response.switch_id$ [# P$ Q: k& Z) `" k
  2408.       case response.type' j- F$ A+ H% ]+ V3 O: _, j
  2409.       when 0: |/ d. C+ i' c/ E' x
  2410.         if mouse_in_area(ox, oy, width, height); M4 k' g4 L8 n# `( E
  2411.           $game_switches[switch_id] = true8 O4 ~. t7 \9 q( F3 p
  2412.           $area_responses.delete(response)  [6 n1 d" M( d& V8 K0 D
  2413.         end; Y; q4 a+ B( b1 P3 k" q! V; [# {
  2414.       when 1
    4 I6 ^2 S- U3 }" L" b6 L3 I+ E1 C$ U
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    9 v4 p; n! q$ y
  2416.           $game_switches[switch_id] = true# S- _# t0 C3 F% w9 e7 k# N
  2417.           $area_responses.delete(response)
    3 Y/ }; k. Y4 O
  2418.         end6 Y" {* a) |7 I7 C$ e6 ?
  2419.       when 2, Q9 q: X! U- ?0 `5 t
  2420.         if mouse_in_area(ox, oy, width, height)
    - A0 w+ b( X( _& l; z
  2421.           $game_switches[switch_id] = true2 n3 N4 e2 N1 `' z- a
  2422.         else
    8 r( G) B6 j# t# e
  2423.           $game_switches[switch_id] = false
    ' b8 w# y" y7 O& T
  2424.         end* f- x, z# }% z( q( U" f5 ]+ _
  2425.       when 3* q! A" Y: D7 R% E% I: @) h9 G: r
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,, }( c5 E3 y2 R
  2427.             (oy - $game_map.display_y)  32, width, height)
    7 @  X8 I  k/ A3 w9 z9 k$ Y
  2428.           $game_map.events_xy(ox, oy).each {event1 ~: B6 ]/ z' E- u% O( Z( s9 e7 |
  2429.           event.start
    , Y, G1 @: `3 |9 M$ q" z
  2430.           $area_responses.delete(response)- X; E6 `9 A' G& D  U9 ]6 P
  2431.           return
    4 G' R4 W+ ~: ?# n2 q
  2432.           } 0 n  |; q: d% n; C9 t
  2433.         end
    8 G  ?, s+ c) t9 X) \- i8 V/ T
  2434.       when 48 Z2 s8 ~1 K9 M- x
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    , _# X5 `1 S' [4 A
  2436.             (oy - $game_map.display_y)  32, width, height)
    : i5 @' f4 b$ u2 D
  2437.           $game_map.events_xy(ox, oy).each {event
    6 X. U0 u7 @0 W: u7 J2 k
  2438.             event.start" y+ d5 q7 H# z0 w
  2439.             return% H$ _! m2 Y8 |& g* f3 p# p. V4 X
  2440.           }
    4 w; B" V% w' M1 F0 I
  2441.         end
    ' }5 V2 m+ j- |! Y
  2442.       end
    # r1 Q& O" j# g6 m- X6 f6 t
  2443.     }
    : H( K3 ?' r' f2 Q0 B, V. T
  2444.   end
    - i* S% Z' d; _$ A% v
  2445.   def mouse_in_area(ox, oy, width, height)1 f: o! b, V0 n3 m
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    ; Q$ z1 Z% r. o" R+ a8 l
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    # d& F7 A) Q/ E, ?
  2448.   end2 p+ Y3 X3 L" h2 M- z
  2449. end- q7 y& z  d, J4 _2 k$ Q
  2450. class Game_Interpreter: P, k9 d' o! S7 f$ r- o
  2451.   def area_response(arg)
    8 T% ^; r0 ~6 A  O7 ]+ z  l. v
  2452.     $area_responses.push(Area_Response.new(arg))
    - b, [' r) K3 W+ J
  2453.   end  B( F6 z3 q1 X- o! F" Y' a) m
  2454. end
    ) o3 t* ?$ P8 T; q% l+ i
复制代码

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

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

GMT+8, 2025-7-15 20:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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