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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================, a/ Q/ O5 V- f! E

  2. ! o7 R2 g  @7 w3 o$ v/ n1 k
  3.   Sion Mouse System v1.3e
    " }$ Y" G, c3 M$ r& e: N
  4.   
    3 X7 G2 p) P! G5 D4 M
  5.   Changlog4 {( e/ v! l- i
  6.   
    : R- ~& _- G! \7 ^; i( o  o3 P
  7.   2013.4.21 v1.3f
    6 _7 E# V2 O- d# [/ v6 V
  8.     & `( V( Y6 s4 t. R2 s* L8 L9 T
  9.     1.3f 卷动地图 bug 修正% a$ I: s0 B* O1 ]
  10.    
    & z# [$ j! d4 A
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    8 B5 T) N: ~8 A  v- w  K
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    8 @* L* \* n3 O0 J$ x- `
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    2 T2 N: z1 Y$ n0 v; q1 X

  14. # f6 C) v2 `3 _
  15.     1.3f bug修正
    ( h/ K9 K" c6 b* _6 R; s
  16.     R- A; W5 c; x# L
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及! t# q( V5 j' ?9 b' k
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    / N! P, y+ {* x1 b* j

  19. 2 p+ A- V/ a% [9 m) V+ b9 G
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处1 t% \2 G  N: ~! Y
  21. : `$ w  y% e6 Y. N" H
  22.     1.3b 修正一些罕见的bug;  l* P% o0 v  |
  23. - }5 J, }. _% ?$ u* b- Q
  24.     1.3a 代码小修改;
    & f4 G# ^& A7 V/ W! s0 o* s
  25.           加入了鼠标点击启动事件的功能,- _0 K0 T. }# S/ e
  26.           在事件中加入“注释”: 鼠标启动  ,8 h3 ^4 R/ {2 G+ ^" G5 ~5 k: H
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    # \$ D' V* O5 Z+ L# j7 I. p
  28.   * B; G$ _- W2 O6 F! Y+ J: x
  29.   2013.2.12 v1.2
    * r! u0 c0 Q  A% ~7 q$ j& k
  30. . Y# {& u) K- h" X8 E4 F' ]; w
  31.     寻路逻辑优化;& |+ d, E, U. C- m' g
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    ( D2 P9 ^4 |! A3 H6 P& R2 e
  33.     现在支持用鼠标来操作载具了。
    8 F0 c1 m7 d& r7 h- ?2 {. N, z% S8 p
  34. 6 M" }; C9 k  i* X% M
  35.   2013.2.8 v1.15 b9 k1 m/ m5 b9 n

  36. 4 E# U7 R" Y# i% x& O* u. {
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;0 V0 K- @5 E0 f% b
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    , g+ u% k0 j5 V
  39.     移动时,路径指示点的绘制更加稳定;4 F& w) I8 p+ ?2 ~' i7 ]* J, f8 D
  40.     现在支持默认存档画面的鼠标操作了。
    9 r/ @: O# E, d* b7 U/ h

  41. + k& B; Z' A9 \8 T+ |6 X/ p# X

  42. # l! k" m$ @' [8 S
  43.   OrigenVersion' H) Z. q* D( \( y. O3 ]
  44.   % \- [# [( ?( ^
  45.     2013.2.7 v1.0
    3 A6 d' U; u9 a" O/ i2 |

  46. 3 P9 [0 N4 K+ |" N3 c' G
  47.   主要功能$ L( E6 v, ]# d( M% V
  48. * R$ S0 ?( y. ~" d# G
  49.       使用鼠标进行各种操作...
      a2 i8 Y3 K1 r  q4 B1 T0 o
  50.       将鼠标锁定在游戏窗口内
    6 i  E7 Z# a1 h% h4 t
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    $ J$ Q4 S" a, L" ?
  52.       双击鼠标进行冲刺
    * p1 ~! ]! X& ]/ c8 I
  53.       更改地图卷动方式以适应鼠标移动
    8 G; q( l& b, e0 y
  54.       变量输入框改良" x- F' V7 g. w" s7 t! b9 S

  55.   ?2 E( @, o* G3 u' `1 o
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    $ V/ e$ t6 f! A) m2 L* k
  57. 1 x4 b2 ]* X3 d/ b- U
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹# x. X. O/ f+ v7 c& T

  59. 4 c+ o6 `2 [  @; t& r* p
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    + m8 D, V5 t# Z% H* G

  61. 5 _9 C- f$ I0 @- h2 l/ d

  62. . Y9 _5 W" i1 m0 r) v6 x) ^1 X' r# S
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
      e3 E6 N" A8 n- E. k" a- v6 L

  64. 4 V8 c# S' B) _, C+ a# ^
  65. + P4 \- o0 @- |- [$ U
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    ) \) b, a# m" o0 A5 b+ W5 ^$ J7 p
  67. % J& w7 V" S3 T3 _
  68. #==============================================================================( q& A! R. ^* q* e
  69. # ■ 常数设置
    % e3 a" M: `- N
  70. #==============================================================================& i0 F: W5 q" c; \
  71. module KsOfSion; ^, \% F4 E2 K3 V
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false# e- T- t) j& m; N  o$ d$ T3 A
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    ' M; `9 ^# ~3 ^* L( g( {, E- {
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false$ r; @6 o8 [$ o! f' T0 ]. X6 C. q
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    6 @/ ~  e9 e2 Q
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    + h4 Y1 O  Q  D( I0 N
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧" t# P! r+ O! e0 \1 }8 r- F3 d
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)$ p2 s3 [$ Y6 ^$ v$ y% _
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键6 E( Y. T5 A/ _$ O( K: Y7 k
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D); [( O5 G5 G! b0 o: ^2 R3 c% b
  81. end
    3 S4 |# q! m2 Q: l" V5 y! w3 U
  82. . v. D# U8 i, b8 [" S
  83. #==============================================================================
    / H* @# G/ y% G4 C, g/ V
  84. # ■ 用来显示路径点的类
    2 o: `& ]" y3 }5 [$ o  \. h
  85. #==============================================================================# e3 d/ l2 m: q$ Y
  86. class Move_Sign  Game_Character7 y" ]. _) F  _. k, z% d
  87.   #--------------------------------------------------------------------------* s% z% C6 Z+ I" k9 r* n7 K
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图4 s: U. w  ^$ e7 F: S3 X# U
  89.   #--------------------------------------------------------------------------" t2 k+ {& j0 ?. y) W
  90.   def init_public_members
    1 U: H* e4 m7 H
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹- S" q' ?. p4 T" [0 P% l9 Z/ U
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    . d5 _1 ?' w4 Y+ f/ |% l; J1 D
  93.     @move_speed      = 5        # ★ 踏步速度
    3 ?0 N0 q6 c4 b; e
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)& k, z& t. r8 @% Z
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    ( p: A; B3 D* d( h8 B+ u( z+ }+ n
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)8 c7 |+ t! M0 B5 a
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    " B3 E% y' P- \  X, E
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    # q( S. ]5 u1 ~; s, V* W5 d% y

  99. 9 W9 N) j4 {: {2 \! A& F: ]
  100. 2 ^, d$ L* h+ h& A* L3 m
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    9 }, Q( f5 Y) j! j4 Z

  102.   Q% d7 ?2 W, G  N( u
  103. 8 b7 j" m' w3 K
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    , S  f  f; n7 z/ j3 Y
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png'), u9 A1 o3 r% z1 u) L! g0 p( b

  106. # I0 x6 o$ [& ?" d
  107.       if $no_arrowpic_warn
    , p' ~6 a: u: y) b
  108.         MouseShow_Cursor.call(1)' j. E' i. c4 N
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png9 I+ \3 l! c9 w& I) p" n* v
  110. 0 e4 a8 c$ g5 [7 t
  111. “路径指示点”将使用游戏自带图片5 s& Y- l3 A+ d+ Z$ |
  112. 5 F' d" v7 r6 O
  113. 该提示可以在脚本内关闭')
    + u$ A6 C" P( X9 F$ {- v  R1 w; y
  114.         MouseShow_Cursor.call(0)7 A/ m6 p* t9 E0 t% S4 K+ W4 q) w
  115.         $no_arrowpic_warn = false
    0 i) c. ?- A" Y; G& B
  116.       end& m& R; F$ {9 t+ a$ d/ x! E8 Y' ~
  117.       @character_name  = '!Flame'. |: \  J% Q$ n2 A! O. ~6 x
  118.       @character_index = 6
    5 i* f7 ]) n4 [# j2 j

  119. % i) X$ o% Q# L
  120.     end4 t# @0 p* E, f3 ]1 v! w
  121.     @direction_fix = false  # 固定朝向7 K( U5 k" q6 a0 T( P2 Q+ z
  122.     @move_frequency = 6     # 移动频率& J7 v4 q9 T+ i  X9 x, O
  123.     @walk_anime = true      # 步行动画
    ) ~" h3 i  f' f6 {/ W
  124.     @pattern = 1            # 图案3 G1 D5 u' ^$ H
  125.     @through = true         # 穿透
    2 o- J3 a5 p9 @; c
  126.     @bush_depth = 0         # 草木深度
    0 U$ e' F( H* i# z" U
  127.     @animation_id = 0       # 动画 ID
    3 l) T. |; T7 U- o( ^4 x
  128.     @balloon_id = 0         # 心情 ID: |4 x. Z5 a1 {2 W4 t! z/ y
  129.     @transparent = true     # 透明7 Z6 ]. j; Z9 z2 g
  130.     @id = 0
    $ T+ B' s$ f1 X
  131.     @x = 0
    , C% |& K; U* a1 `
  132.     @y = 0! O7 N% V5 M; J; E- T+ _
  133.     @real_x = 07 _- q" m, Z' A( S6 Z# i
  134.     @real_y = 0) h% K' u' K1 c$ |; T% R: A
  135.     @tile_id = 0
    & \5 m, J; K9 h9 ]" G: W/ w) R- H) g  n
  136.   end
    $ d6 N% A  R" A+ }
  137.   #--------------------------------------------------------------------------& X4 z3 F4 G: g* {9 t3 z7 N3 q
  138.   # ● 定义实例变量* o% G5 g* J8 n  o% P5 U2 X: j$ |4 Y( W$ P
  139.   #--------------------------------------------------------------------------( Z  w" g) m/ }3 ]6 X
  140.   attr_accessor direction
    + s4 J* A/ _; h5 H  e1 {
  141. end
    $ N6 X* J4 D6 N: h, C

  142. : b9 c# Y) P9 `& p' E" w
  143. #==============================================================================
    0 U) d9 Z- Y1 ^6 c5 Z( j
  144. # ■ Module Mouse: l; X+ j$ b5 F# G1 o+ e& @
  145. #==============================================================================" G: f" i3 e2 f. b% y
  146. module Mouse
    2 L! F$ R8 `) J. E2 O5 c( B3 |
  147.   #--------------------------------------------------------------------------) n5 R0 B4 o( \" U+ r! s+ b0 @
  148.   # ● API  I/ C) g, ~# [( a2 q1 r7 ?* P  u
  149.   #--------------------------------------------------------------------------: q! w$ g. g# g* n
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    0 C; [$ C0 F8 I* K2 H
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')6 A6 `+ A- E, a2 y% b
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    2 O; ~3 k. r4 O; }$ c
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    / c# ?3 t. Z" g/ B
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    : |  \- ~% j! Y8 ]) F3 b! W
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')+ Q5 f' c+ l: l) S/ c% v1 r' b
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    7 g8 p) J' _" W7 b6 C. u8 r
  157.   Window_Hwnd       = Get_Active_Window.call
    9 g; r5 M9 w' O1 x4 v* k7 ^$ m

  158. # \  D0 f$ x9 o% O* Y
  159. class  self% _9 R. ^1 U- B8 k" F
  160.   #--------------------------------------------------------------------------
    * r/ |7 z; y9 n- E& K# S" X
  161.   # ● 初始化
    - M( Z1 v. p2 U" k2 S; ~0 T
  162.   #--------------------------------------------------------------------------# [; r1 x& g5 I/ @6 Y3 M/ e
  163.   def init
    ; w- P3 H1 K0 Y7 Y& [; o& |; V
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    3 b5 f7 t  n' G' E! ^, d- a
  165.     @left_state = 05 g4 ~4 m1 n1 B
  166.     @right_state = 0
    # [* Z; ^' w8 D; r) P( [5 h* W/ `- _" \
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    ! ?( }. _6 n. Y( U$ o
  168.     @dk_count = 0 # 用于双击的判定$ g8 {  p" c7 x& V8 z- ^
  169.     @clicked = false
    * _' s* s/ p3 d  Q8 F
  170.     creat_mouse_sprite
    6 N8 |2 j( D  ^  q- s: Q* {4 l: ^
  171.     update
    : h) I" W4 S* t+ j
  172.   end
    8 g( _0 t% O6 F8 z; w
  173.   #--------------------------------------------------------------------------. p( R- b4 E6 r3 A2 j& i9 l" v
  174.   # ● 鼠标指针精灵
    ( F( d6 Z; k9 ~" M7 S' h
  175.   #--------------------------------------------------------------------------/ K6 _6 R  Q/ H+ H# V9 i$ ?
  176. #~   def creat_mouse_sprite, z# y9 A( e4 X# e
  177. #~     
    , d. {4 ?2 r" e: L  A
  178. #~       @mouse_sprite = Sprite.new! \% D; s$ Z; t1 p+ e0 t
  179. #~       panda = 2#rand(2)+1
    - w0 z- d! F% Q- W# s, H

  180. 6 ]& T; W% y) t; G* m
  181. #~      if panda = 1) @" K. h9 x1 O  ?! ?
  182. #~        if File.exist('GraphicsSystemCursor2.png')7 |7 D- ^/ r; Y9 w0 W
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    : O; D+ N# c. [1 l5 r5 E
  184. #~        end#with if File.exist
    # b2 G& {$ D9 \7 t& e: J
  185. #~   
    ; Q1 Y/ \  R; Y
  186. #~     else if panda = 2 #with if panda=1
    7 P' }% {8 d" e# F$ W
  187. #~      
    : |% U( D) @4 [) S" H" n
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    : Q5 C, I* S7 b0 c8 I) V
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')$ b  z9 i8 z2 ^4 q4 n
  190. #~      end#with if File.exist( X& w% \' |9 |# S/ \
  191. #~      
    " b# c0 W3 z' k5 |
  192. #~     else #with if panda=1$ A5 u: o. q4 z2 `4 D% m
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)& Z* l1 N1 t- o8 y4 S  P2 L8 D
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    - D! s9 }- @* Y# |
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    . l5 w2 p/ V- D9 l
  196. #~     end#with if panda=1
    ) \& X. j/ n, \, |, G4 h  J4 O
  197. #~     & J7 p0 r6 x/ _2 h
  198. #~     #with def/ V0 X  |1 Z/ ^- I2 t5 O
  199. #~   end( p2 i5 z" O: T5 f4 d
  200. def creat_mouse_sprite
    ( s2 r; X5 J& c& s
  201.     @mouse_sprite = Sprite.new* L3 K$ ~8 Y( v  F" [& a
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})8 C, K& [3 _! h4 h$ A
  203.     @mouse_sprite.z = 9999
    4 @+ v1 h/ E" R. ?
  204.     Show_Cursor.call(0)5 _4 j7 ~- V; Q* g/ w" c$ z7 I( f
  205. end
    # a/ Q; r& y+ v! Y9 g
  206. % {% \2 k2 d- B" j& J. B
  207.   #--------------------------------------------------------------------------
    1 k! R' l4 i# q* t% [" f. E  i# ]4 X
  208.   # ● 更新9 f# D3 d- L$ p) g0 p
  209.   #--------------------------------------------------------------------------, M% x2 M& D# K/ w. l/ o5 E1 J
  210.   def update
    0 {# F. U% \8 }! ]
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos6 U; E0 n& h2 S0 U' F' m2 q
  212.     left_state  = Get_Key_State.call(0x01)
    5 c5 {5 t0 z) D" `/ P% j
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    5 M+ }8 w( ]5 r. B" J
  214.     right_state = Get_Key_State.call(0x02)1 l# L% g+ t# Q, _/ g
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
      t5 B% b, W) w
  216.     update_double_click: Y  q$ w) ?$ H( ^( L
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1$ m& p% t' {, f8 D+ e. r% f+ Q
  218.   end: l4 E, Z: T6 B$ t% A& p" u
  219.   #--------------------------------------------------------------------------
    9 f; R  l4 M6 S. t  r! j
  220.   # ● 获取鼠标坐标
    * m$ j: ^7 Y  @
  221.   #--------------------------------------------------------------------------: [- E4 v& M8 {  K
  222.   def get_mouse_pos
    - c* F. ?! J# T( }. R
  223.     arg = [0, 0].pack('ll')
      a7 v; K7 v% |
  224.     Get_Cursor_Pos.call(arg)
    $ p  T/ E2 }' J- x) h9 r
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    " H/ ?' H$ D' r+ F, Z, b
  226.     x, y = arg.unpack('ll'): m' ~3 D6 ^4 U# L
  227.     return x, y! F5 c1 I+ T4 R% f7 ?
  228.   end+ l# B9 F6 N! K  Y- a- K9 V  Y
  229.   #--------------------------------------------------------------------------' M! i- ?) ?! D2 ?
  230.   # ● 将鼠标固定在屏幕内
    ; ]+ o9 x" }; R' N! d0 _4 u
  231.   #--------------------------------------------------------------------------1 ]2 o% t7 k5 s; s6 l- H
  232.   def lock_mouse_in_screen
    8 @  U: \3 {- Y$ a1 m) u- y
  233.     arg = [0, 0].pack('ll')
    # q: k- k/ E1 t% F
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    2 R* D2 G- e1 K( Q
  235.     x, y  = arg.unpack('ll')
    / \# D) [6 o/ A5 k* M. \+ Q
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))- l  p% X9 I. m8 W5 ?
  237.   end. z4 C. \% y/ X( k/ w
  238.   #--------------------------------------------------------------------------) \' ], H) O8 W# }. Q
  239.   # ● 解除鼠标固定  l+ _& Q) Z0 S- h5 f4 A
  240.   #--------------------------------------------------------------------------
    0 Y. j( ]* {7 r9 ?; t. _; T+ s
  241.   def unlock_mouse_in_screen
    : j& e3 R) u: A9 g' K1 p# O' }
  242.     Clip_Cursor.call(0)
    + j; _& @4 i  m) V& F' p
  243.   end
    " P8 J4 B/ `* v. R* U
  244.   #--------------------------------------------------------------------------: t, S: H4 c/ ?7 H$ j0 Q6 X
  245.   # ● 鼠标双击判定) J% |( t% j8 H4 @) B, Q$ ~& s+ i
  246.   #--------------------------------------------------------------------------
    & w, E  `0 p6 Y% c
  247.   def update_double_click* c. u; v3 J2 V4 e" e6 D1 \
  248.     @clicked = true if @left_state == 1; R4 k; l6 ~" C
  249.     if @dk_count  0 && @left_state == 1
    - Q, R5 n* Q" A( R( W4 ~7 Y
  250.       @dk_count = 0; @clicked = false
    . {6 a+ M' w+ P6 X. `# D
  251.       return @double_click = true
    9 T& u: ~& z6 P" z) z+ p# L4 w
  252.     elsif @clicked
    ' J& v; N# X$ J# i# \' H4 j$ z2 Z
  253.       if @dk_count  KsOfSionDbclick_Frame- g8 W) [- [  [" y& R
  254.         @dk_count += 1
    * H* h+ f! _0 I5 ^" R( ]
  255.       else
    0 W8 X2 U4 I+ [4 w, r. _' u7 n* L
  256.         @dk_count = 0; @clicked = false; b5 W1 m3 e# j, \: {( R& G. q
  257.       end1 y3 C" |, x1 I: [7 s# Y
  258.     end2 X7 \5 j$ ^5 {7 w- J& J7 J4 `/ \
  259.     @double_click = false% E! e; C# ^. H: @
  260.   end  B7 d! c/ M" Z  Q
  261.   #--------------------------------------------------------------------------
    % ?% L* ?, I# S( y" N* E- J$ |; ?9 c
  262.   # ● 按键被按下就返回true! `8 v0 A9 ?: p& _! O4 P+ B
  263.   #--------------------------------------------------------------------------
    3 Q. t5 p/ e. \2 ]
  264.   def press(button)0 n- Z* U/ u6 U- \) e7 x- ]
  265.     case button0 u' f$ p. `; r3 p* u- A0 n0 l
  266.       when 0x01; return !@left_state.zero# j0 ]5 T* r1 I) _
  267.       when 0x02; return !@right_state.zero! }$ [5 }% |6 p1 S+ t! [' M. }
  268.     end) E5 b  S' q; X* v, r
  269.     return false: I, ^' I7 C7 K
  270.   end" c0 q4 T- E9 D; a
  271.   #--------------------------------------------------------------------------
    ) J4 Y: z1 O$ m
  272.   # ● 按键刚被按下则返回true
    0 X/ o* t! {* b9 f- o
  273.   #--------------------------------------------------------------------------7 }9 j7 ~0 c$ q, J. W
  274.   def trigger(button)4 z+ b2 d) G* j" e$ D! q6 G) u6 K9 ~
  275.     case button
    5 z) I8 f; t# c0 x3 G
  276.       when 0x01; return @left_state == 1
    ( K! U# t+ d; W# P0 B& [
  277.       when 0x02; return @right_state == 1
    ' E4 k+ m6 ?- a% v, }
  278.     end' t4 p9 n5 e# J) a: s! G5 v' l( \
  279.     return false
    2 z; K' v3 p% e
  280.   end
    4 [# V' A% @  {. u1 }: [
  281.   #--------------------------------------------------------------------------" b1 o; w$ S  k, f. {
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    7 v# i9 Q7 m' p/ S
  283.   #--------------------------------------------------------------------------
    ; B4 a: i' [% p: P! \* E& _
  284.   def repeat(button)5 ]' k+ r2 \% K/ {" o
  285.     case button: U3 S+ J( e0 W$ c4 f* l
  286.       when 0x01; return @left_state == 1 3 v4 Q' U7 i" |" ~% B0 o$ c
  287.         (@left_state  22 && (@left_state % 6).zero)+ J  Q. y' b4 W
  288.       when 0x02; return @right_state == 1
    # `7 D( j4 A; X! ?' q
  289.         (@right_state  22 && (@right_state % 6).zero)0 d! X" @& k$ S( w/ ^
  290.     end2 z% g' P* V; v6 e- p/ P
  291.     return false0 Y. O# t! e9 a7 c* @! H7 t
  292.   end
    , W0 N* y  T( G  E& x5 ?" S' I; `
  293.   #--------------------------------------------------------------------------
    ' O: Z7 K5 J( [# Z" L: Z
  294.   # ● 判断是否双击鼠标, v+ O& Y6 v0 y1 U4 M
  295.   #--------------------------------------------------------------------------9 t' N; |( r7 ~% k
  296.   def double_click
    ( n) T. c, Q& X/ s9 W$ }
  297.     @double_click4 g7 ]$ d9 m' L& y( G6 F
  298.   end8 }: u6 j$ t; \5 O$ P
  299.   #--------------------------------------------------------------------------7 W) r/ q! Z1 d# A+ t
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)9 {4 D0 S: S$ p( D# Z: p9 U
  301.   #--------------------------------------------------------------------------) r6 v. f8 B/ \' ^" P1 M0 w
  302.   def click_count$ w4 [. A! X$ k
  303.     @ck_count) j6 L8 |) `8 X. g
  304.   end9 k- @' d/ p( v* h  {+ L. p! p+ C
  305.   #--------------------------------------------------------------------------" L# j( }/ Z; V5 `- r- C- {
  306.   # ● 获取@left_state(按住左键每一帧+=1)6 z4 l8 v) n- \" G
  307.   #--------------------------------------------------------------------------0 s3 R8 t% o9 H! N" A# s
  308.   def left_state
    : R; y! k, z4 K' I* {/ [. r
  309.     @left_state
    7 z( B9 x1 ~5 E* @# A- U
  310.   end
    1 S; X3 q: t( [& p, O
  311.   #--------------------------------------------------------------------------# t, |8 q" y- [8 Y
  312.   # ● 获取鼠标的x坐标
    4 Z; ]+ K% }& _( i3 i8 H
  313.   #--------------------------------------------------------------------------; f. ?' j$ J9 _# {7 q) Q
  314.   def mouse_x
      ~9 m- g% L3 S, @
  315.     @mouse_sprite.x4 W- s9 F) b  Y- i( g/ l' l: u
  316.   end
    5 Z7 P. N, O5 @
  317.   #--------------------------------------------------------------------------
    , P3 E( Y& G5 v; M
  318.   # ● 获取鼠标的y坐标
    3 Z. E; _2 y" l. L; o) p7 [0 ^8 [4 ^: A
  319.   #--------------------------------------------------------------------------
    ( G8 F' ~; Q% x! Y6 c; ^
  320.   def mouse_y
    # ~! K# t* r$ F7 v2 e
  321.     @mouse_sprite.y% N. w+ f/ ?/ v' D6 c
  322.   end9 c' d! b0 P1 U6 L
  323.   #--------------------------------------------------------------------------
    9 u( |* b: N/ j  Y" H6 Y3 g6 v  t
  324.   # ● 设置鼠标坐标4 G4 _0 S1 R1 @3 ~3 ~+ g) m
  325.   #--------------------------------------------------------------------------
    . z$ }1 ~$ K: n
  326.   def set_mouse_pos(new_x, new_y)
    , S: c9 Z4 S! t' ], M" }" m
  327.     arg = [0, 0].pack('ll')
    + }) r! K) ]  y. z9 z' q
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    5 j5 \6 C; h* s( s
  329.     x, y  = arg.unpack('ll')0 \. P7 s/ n, J  ~5 v
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    " E' C' V* Q9 O6 @  U+ ]/ B
  331.   end
    1 D! K' t" P) k) P
  332. end #end of class  self + b5 b" v1 F  c8 E1 n$ F0 n  l

  333. 1 e2 a8 |8 p0 C- g9 F
  334. end+ Q1 P* D& \8 A' `

  335. # u; @* t3 e& R8 ?6 l
  336. #==============================================================================
    4 A2 @7 x& W6 `5 f  K
  337. # ■ SceneManager' q  s' {' `! g  X" F; H1 _
  338. #==============================================================================
    + X3 t/ G& u6 B5 V  A
  339. class  SceneManager, y) V- o0 Q" e2 _. g4 {2 F
  340.   #--------------------------------------------------------------------------
    - }. A" i/ @2 d
  341.   # ● alias
    . U% g' a5 E: A
  342.   #--------------------------------------------------------------------------
    7 x, F; k( D: `) Z: O5 o# l- J  r
  343.   unless self.method_defined(sion_mouse_run)
    5 [' \. a8 Q1 X7 n9 f  p
  344.     alias_method sion_mouse_run, run
    & k+ B6 t8 {* @4 \7 f6 p2 b9 O
  345.     alias_method sion_mouse_call, call
    : s0 C5 J+ b! H6 P* O
  346.     alias_method sion_mouse_return, return- |' z3 I# t  m4 |2 X6 A
  347.   end
    + }! J; M% o( M( a; C
  348.   #--------------------------------------------------------------------------. l: S3 F/ D0 A; U/ A; J, |1 n
  349.   # ● 运行
    6 Q/ T! H; v5 L" M8 y" I, L
  350.   #--------------------------------------------------------------------------
    6 r* \. D' V: y
  351.   def run
    . V' S8 @& ]4 q0 n  W2 B! e/ C* C
  352.     Mouse.init
    1 X, k/ j/ o8 q
  353.     sion_mouse_run
    " G6 s4 Q0 E* W8 H6 p
  354.   end
    , H8 m7 n, B! }5 e
  355.   #--------------------------------------------------------------------------# U, [% c$ [# m
  356.   # ● 切换2 O& L/ ?; z1 |
  357.   #--------------------------------------------------------------------------
    $ H4 Y3 i% n. _( e& G- Y
  358.   def call(scene_class)
    ( x/ r1 H. u$ Q0 j- ^: R9 l! f
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)" w' Q0 i8 t+ k$ B1 G; A% N
  360.     sion_mouse_call(scene_class)
    5 R; U3 B6 r: U+ P& F: a
  361.   end
    ( c% W/ `, e! {6 U
  362.   #--------------------------------------------------------------------------
    & P+ k4 J2 ^2 A4 [( W9 R
  363.   # ● 返回到上一个场景1 |( r4 H  b- a! k: V
  364.   #--------------------------------------------------------------------------3 u4 b& X+ F4 z/ [5 j. D
  365.   def return
    / o" ?& J1 k  s" j( T
  366.     sion_mouse_return
    * c2 Q0 N) }) I4 q( Y4 d
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    ! i/ {6 Y4 x( X. A& `
  368.       @scene.instance_of(Scene_Map)  J& r/ ]3 Y) p9 x
  369.   end
    # V" H2 B5 g2 X) P4 g% Y
  370. end. R. \, @6 @3 p5 i2 s

  371. ; ^- z# y; i6 Y: M
  372. #==============================================================================
    / p( |: F% O; [
  373. # ■ Module Input$ d& o. `! N: f! j* I
  374. #==============================================================================
    ! O" _. X8 a. U% R" M
  375. class  Input
    3 K; H/ C. _5 H7 g
  376.   #--------------------------------------------------------------------------
    ( S: Y- A# {( a  S5 [. D
  377.   # ● alias
    ' B" i& g% L0 N. k" q
  378.   #--------------------------------------------------------------------------  C0 y. |9 w- g) _; ~3 A$ b
  379.   unless self.method_defined(sion_mouse_update)% ?3 _5 F7 M9 ^
  380.     alias_method sion_mouse_update,   update9 w) f7 N$ ]- V  \( g6 ~- }
  381.     alias_method sion_mouse_press,   press. ^" e" \7 y3 S+ M! [0 ?
  382.     alias_method sion_mouse_trigger, trigger
    5 \' ]+ l' ~2 G' E7 o
  383.     alias_method sion_mouse_repeat,  repeat. j; ?( Z1 p/ V
  384.   end0 @" m6 Q7 F. R. E7 L7 f
  385.   #--------------------------------------------------------------------------
    ! K) a) `' k( \8 U* V7 m$ T4 F
  386.   # ● 更新鼠标
    + _/ U8 l1 x3 z' u
  387.   #--------------------------------------------------------------------------  p# u* A) r% ?* P$ i
  388.   def update
    - ]. s0 H. `3 W7 o& P8 X
  389.     Mouse.update
    . M, Q" q" S* F# r; t
  390.     sion_mouse_update
    ! \7 M( V, \4 @+ y$ b1 x
  391.   end8 f9 o# s! J" U+ I7 B- ~% ?
  392.   #--------------------------------------------------------------------------1 ?/ m5 V" W( x, W; I0 g+ C; z- S  _8 E
  393.   # ● 按键被按下就返回true' ^1 `6 [* |$ t& H) b# M5 o( C
  394.   #--------------------------------------------------------------------------. a5 p# U  a' H5 Z  |
  395.   def press(key)
    ; ]$ P$ P3 o: f+ n! ]) {4 k' C
  396.     return true if sion_mouse_press(key)* r7 H+ R0 W, C7 w: J
  397.     return Mouse.press(0x01) if key == C- o  O7 [! ?. s3 }0 V, }
  398.     return Mouse.press(0x02) if key == B0 T" K/ d  ?, n" s; v& d
  399.     return false
    : d$ w7 G  u( ?4 h# X! z2 s7 |8 h
  400.   end
    ; U" v! D* b1 N6 \
  401.   #--------------------------------------------------------------------------$ v- P, P: n9 D  X# r6 t
  402.   # ● 按键刚被按下则返回true
    ! Z: U1 |' q5 j# R  H
  403.   #--------------------------------------------------------------------------
    / n9 H) X+ w' P4 K4 ]8 B
  404.   def trigger(key)
    9 a4 w4 K+ f$ \: x, g  K- q( u+ l
  405.     return true if sion_mouse_trigger(key)
    % {+ p  o3 ?$ \
  406.     return Mouse.trigger(0x01) if key == C
    " g5 B( [- F$ P' Z; c$ H
  407.     return Mouse.trigger(0x02) if key == B& d5 B- X1 `( q. T
  408.     return false
    2 \# W+ ~! g! q6 m/ M
  409.   end0 O1 B/ e: F3 O" e% d$ K- F8 {
  410.   #--------------------------------------------------------------------------
    1 y0 y. \0 }7 k
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    2 }# L, w  ~5 i
  412.   #--------------------------------------------------------------------------/ t) P  a: P( {4 P5 X8 M' j' o. D
  413.   def repeat(key)
      R" G: ^8 r) k4 m
  414.     return true if sion_mouse_repeat(key)
    4 _9 `1 I+ E- B
  415.     return Mouse.repeat(0x01) if key == C/ U" a  o/ |; C  u  D; w' y5 C6 t1 _
  416.     return Mouse.repeat(0x02) if key == B
    - b8 [' j+ `1 d+ J2 i9 _
  417.     return false
    3 D4 {- d" _0 W  [% G) g! {, t
  418.   end+ `9 N* {/ p9 v$ X
  419. end0 D4 e  ?. e( ^  @. L
  420. 4 a9 U* `' v* e/ I( x0 A

  421.   D  Z9 }. B  J3 e
  422. #==============================================================================& Q* Q- u- ]: o( W+ h
  423. # ■ Window_Selectable. Z: w; l  B( j
  424. #------------------------------------------------------------------------------# o% W. ]6 x% H$ W& N$ M/ b7 m
  425. #  拥有光标移动、滚动功能的窗口
    5 r* v) \( W( W! r- x/ a# V
  426. #==============================================================================
    ! `8 v/ z& K$ \% \" p; U) T. t+ I7 ^
  427. class Window_Selectable
    % z0 c4 M( ]% N6 `5 }- |
  428.   #--------------------------------------------------------------------------! v/ U3 j8 y+ `3 G! U5 B! o
  429.   # ● 初始化* }; K9 u& t  A7 z5 I
  430.   #--------------------------------------------------------------------------
    ! |! ~4 ~: i9 h. z- r) r5 w( E3 a% d
  431.   alias sion_mouse_initialize initialize
    + b4 f: P$ q3 u
  432.   def initialize(x, y, width, height)
    : G7 b$ s* f0 t/ f& M% W! g$ R
  433.     sion_mouse_initialize(x, y, width, height)
    5 H$ H6 L( v2 ?. D/ ]1 \
  434.     @move_state = 04 U0 }( N+ q7 X7 z: ]5 ~& q
  435.   end+ c: h. T4 Z+ N, ~6 U3 U
  436.   #--------------------------------------------------------------------------
    0 ?0 t5 x4 }/ @. I
  437.   # ● 更新
    & o  v: g- h7 P$ j) }
  438.   #--------------------------------------------------------------------------% A( K1 a/ h1 \# U1 _7 Y: C$ u$ G
  439.   alias sion_mouse_update update
      w% s  H9 O5 [  ^2 g, G# S
  440.   def update
    " d2 b: c" ?9 k3 y, b- a
  441.     sion_mouse_update
    . a$ e3 h/ S" l7 o5 |
  442.     update_mouse_cursor2 c! j4 A$ a' w1 @1 l
  443.   end
    % u6 u/ T/ s. F( s& Y( u7 r: f
  444.   #--------------------------------------------------------------------------
    # p2 ?7 D) e9 z: U# ?
  445.   # ● 启动后设置鼠标到index位置, n% U7 V6 k" `
  446.   #--------------------------------------------------------------------------
    " b4 Y  v6 j4 V$ C
  447.   def activate+ _# r4 |% q. a" C( N  v
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos' D  s* ~* h* Z5 a
  449.     super
    ( q- C$ s% U* q" Z' @$ P
  450.   end
    9 b  U3 L) W; t
  451.   #--------------------------------------------------------------------------
    ( k, P, t3 ^8 |" j% h. _! `
  452.   # ● 更新鼠标和光标的位置" c2 b6 G8 N- }' H! Z6 Z+ X
  453.   #--------------------------------------------------------------------------$ \- G$ s: ?9 F0 q
  454.   def update_mouse_cursor* q; b/ ~% p$ Q
  455.     if active) O3 ^& ?5 }! _
  456.       if @need_set_pos
    ! ~- W: d9 t% Y5 ?0 j1 K% p
  457.         @need_set_pos = nil. m' |. v( B5 g$ A% v
  458.         set_mouse_pos( ]" V$ e- j& @# Z4 ^& h/ o
  459.       elsif cursor_movable
    4 f6 u0 f) F8 L; [2 l! E
  460.         Input.dir4.zero  set_cursor  set_mouse_pos4 s5 P- M. N. @: H
  461.       end* D. Z2 Z# m1 l) A1 r4 y8 Q: M
  462.     end4 }$ J8 z+ _7 L- F7 D) v
  463.   end# p# a: J2 b2 F) P* \+ y* J
  464.   #--------------------------------------------------------------------------6 J6 k3 f: ]# q
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能  A. Q/ X1 U- L, e
  466.   #--------------------------------------------------------------------------; y! S0 S. H" e6 i, `1 `- n
  467.   def set_cursor: ~. E5 f1 i" @3 ?" q5 S/ \; K
  468.     mouse_row, mouse_col = mouse_window_area3 M4 W9 ^5 V& f8 a: C( ^  E9 s
  469.     if    mouse_row == -1" p& q( W  E/ \' O* k
  470.       @move_state += 1 if need_scroll
    " {: d) O2 F, x4 n9 I% ^  g
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand1 E" ?( z$ o- W- ~4 x% e2 o- b
  472.     elsif mouse_row == -2+ |% E3 f& O+ v3 y, s8 j7 B" @
  473.       @move_state += 1 if need_scroll
    0 ]8 Z; q* o6 h1 x" s& ^- H9 u  L
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
      i" U! C- C) I, Z3 O4 f# H
  475.     elsif mouse_col == -1
    9 x% L5 f9 K" e) A: \  b
  476.       @move_state += 1 if need_scroll/ d8 i. Z3 u- m) ]* K+ z' g
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand8 Y7 C0 b1 F. R& l' K/ |6 l: N
  478.     elsif mouse_col == -2
    9 @  ^- _# q3 a& S) X5 {$ I
  479.       @move_state += 1 if need_scroll: z; i4 C5 Z: ~/ }9 w! T
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand$ j' O* p; h: ~5 n# r
  481.     else
    # \* @& ~( g& ^. R2 |3 @! a
  482.       @move_state = 05 O8 N9 g8 Y9 @, m/ j9 P9 _0 f
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    " Y( R* x" ~# ^! Y$ H
  484.       select(new_index) if new_index  item_max && new_index != @index+ d& G% l8 C' y+ q, J
  485.     end. N4 T$ @  t  _6 C0 C) H
  486.   end
    3 v+ I( {' `1 [! U, D% _; K. x: P
  487.   #--------------------------------------------------------------------------
    ) c! ]  s4 R2 U6 p
  488.   # ● 判断鼠标位于菜单的第几行、第几列# V1 ?! @. E: t0 m
  489.   #--------------------------------------------------------------------------/ v! ^; ?( a7 b* }
  490.   def mouse_window_area
    5 E; v0 B, X  n( N) d$ E
  491.     if viewport.nil # necessary!$ ?7 z4 Y5 D  c' }5 v
  492.       vp_x, vp_y = 0, 0' u. @0 w( J! s2 a5 e
  493.     else# c1 X) w. C" x0 g
  494.       vp_x = viewport.rect.x - viewport.ox
    8 Q6 a. d; |2 n5 v# ^9 l0 N0 F
  495.       vp_y = viewport.rect.y - viewport.oy
    " m  P, p) K; X- C
  496.     end
    : T; t8 B" b, {  i2 i
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    + o$ h: y' y& D5 d
  498.     item_x1 = vp_x + x + standard_padding
    ' \: {1 \1 R- S
  499.     item_y1 = vp_y + y + standard_padding( b) z0 a3 G& Q' j4 y
  500.     item_x2 = vp_x + x - standard_padding + width) D6 \6 y4 {  I2 x1 Q" X5 D
  501.     item_y2 = vp_y + y - standard_padding + height
    , T2 `# b/ Z; E, Q% M) Y- q
  502.     if mouse_x  item_x1
    3 R7 r, V7 j( p9 Y2 F
  503.       mouse_col = -1% W9 V0 ?4 J0 U  t6 U7 w7 X; Z
  504.     elsif mouse_x  item_x2
    8 V% `; q1 V. @/ A" S( i5 n
  505.       mouse_col = -23 v. V% a# {5 k; b, g- u- l4 i
  506.     else! a" ?. B; [6 @0 X0 @! u
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    6 t7 `  j" u% F. l% A( P+ A/ @
  508.     end# p) F9 T' z8 J8 ?; l1 R: d
  509.     if mouse_y  item_y14 L+ K1 x1 X' o) ^
  510.       mouse_row = -1# p/ }2 B% L2 z6 v  |. z
  511.     elsif mouse_y  item_y2
    ) K* f- M8 i8 F6 z
  512.       mouse_row = -2- u8 J3 k. C; @* v3 c) v# Z' s
  513.     else
    ; A* z- O5 i* c
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    . G1 n! c+ W+ O$ Y; j) z
  515.     end" `$ o& P4 f9 ]
  516.     return mouse_row, mouse_col% U& K( ?/ F1 {& t  G/ `5 }
  517.   end+ r  [/ n( K6 H! f* f
  518.   #--------------------------------------------------------------------------: N0 C  w4 m  {2 o% k  m, \
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    , \) I7 @* Q6 x$ X. A4 d# N# x" ^' ^
  520.   #--------------------------------------------------------------------------; c; [( d9 }& A$ ?9 p1 M
  521.   def set_mouse_pos
    2 D( K- m/ p) c2 r* T, x/ W
  522.     if viewport.nil # necessary!% S1 N( G. K7 F
  523.       vp_x, vp_y = 0, 01 @6 k8 l2 Z* c% E3 b; q  G
  524.     else# k6 \3 m7 l* x8 X- H
  525.       vp_x = viewport.rect.x - viewport.ox
    - P  S! b9 F- k: ?; \( L
  526.       vp_y = viewport.rect.y - viewport.oy9 K+ n  l: z# G& a* ?1 c" \
  527.     end
    1 Z% N" @' s5 p% E
  528.     item_x1 = vp_x + x + standard_padding 7 e- {: s' |7 q) C% o9 z# O
  529.     item_y1 = vp_y + y + standard_padding
      |2 N- E& S* `# A3 }! R
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    , h- `! H. A. g
  531.     row = get_index  col_max - top_row8 e; b: a; B  @* V
  532.     col = get_index % col_max
    3 U) D1 }, e9 V2 d
  533.     new_x = item_x1 + item_width  (col + 0.5)
    - H5 q2 H& k( A4 ~: S9 D  f7 f
  534.     new_y = item_y1 + item_height  (row + 0.5)
    4 P+ f, b  w0 X+ x7 c5 ?5 A
  535.     Mouse.set_mouse_pos(new_x, new_y)
    8 S" J" k+ E3 ]1 H& R
  536.   end8 a& V, d, \, d
  537.   #--------------------------------------------------------------------------
    ( U! m: L3 O9 ?+ Y' n2 @
  538.   # ● 判断菜单是否需要卷动& h7 ]- z5 |0 P, B5 O
  539.   #--------------------------------------------------------------------------, U# O. ~, u( K0 v2 z" `
  540.   def need_scroll! F! y0 [0 [* o2 G* t$ o9 k
  541.     item_max  col_max  page_row_max
    % Z. X: U( y5 d3 P7 z, C. v' e
  542.   end" k: Q3 g0 q( }3 C8 y* t4 l8 F
  543.   #--------------------------------------------------------------------------
    1 h2 P7 k8 ~( N9 w' T7 k$ b
  544.   # ● 判断是否为水平卷动菜单* Z: t6 {1 I, x: c$ L
  545.   #--------------------------------------------------------------------------
    8 U) }. g* K! W: K7 U
  546.   def is_horzcommand/ U' D0 C* A5 m( w$ o- j- T
  547.     return false  y. B, a$ W- q$ R0 R, U
  548.   end
    1 z* x& ?: D4 @2 x4 e; v5 p9 }. t6 w
  549. end
    3 ~: k) H" y3 k. V$ j3 q0 i
  550.   S+ B' f9 {" b6 I. Q" o
  551. class Window_HorzCommand5 ^1 h; r8 L5 n% m2 u
  552.   #--------------------------------------------------------------------------9 `$ A. |' z! K: c
  553.   # ● 判断是否为水平卷动菜单( w: H$ ~$ n( a% R
  554.   #--------------------------------------------------------------------------7 X: T" P6 V# B
  555.   def is_horzcommand: O/ A0 Y1 O. ^) ^, ~" Z7 a  _
  556.     return true
    ) T# }2 a* B* c" P
  557.   end+ [' v7 Y; |, T( a- u3 X9 O
  558. end( E0 ?1 @7 f4 P' e
  559. & v" o7 C5 T% W0 K2 D4 B
  560. #==============================================================================
    ! z8 H' M! M. J% ~: {5 R
  561. # ■ Window_NameInput
    - X* F/ X' x2 Z6 B  t
  562. #------------------------------------------------------------------------------
    ( K" I! D2 h1 A" m0 A
  563. #  名字输入画面中,选择文字的窗口。
    8 n) X6 r$ }  f" d
  564. #==============================================================================
    ! w, T7 F2 m7 \/ X5 Z, m- F$ K
  565. class Window_NameInput+ E: h" E' _  q8 g4 T1 X8 b% [# H
  566.   #--------------------------------------------------------------------------
    " n7 K1 L: X+ B- r+ J) t, e7 J4 B
  567.   # ● 设置列数+ K- M! K5 D! a1 b
  568.   #--------------------------------------------------------------------------
    2 h3 Q# E: f0 D& O/ X6 `* e
  569.   def col_max
    9 H: j$ n& N  c; z  C
  570.     return 10
    9 a! d1 q3 s( \7 P3 L5 X
  571.   end* g7 o" b) A4 B* p2 n& y
  572.   #--------------------------------------------------------------------------( }0 l& b4 x( r$ B' l  j+ p
  573.   # ● 设置填充的Item个数! g0 O% J: Q) l: @8 [* [5 n) x3 Y
  574.   #--------------------------------------------------------------------------
    # u, D' P2 B6 Y/ S$ x
  575.   def item_max
    8 o7 _# P) R7 x8 p" g6 g* d- e) W
  576.     return 90- i: Q7 K' {: h* t8 Y* [
  577.   end
    2 Y3 H# n# G4 A1 y1 V
  578.   #--------------------------------------------------------------------------
    " f2 l. f1 Y2 i6 c/ R
  579.   # ● 设置填充的Item个数
    $ f$ g, ~. f, P1 G) n7 I
  580.   #--------------------------------------------------------------------------
    $ |* t1 b" o+ H# M
  581.   def item_width
    ; [2 @( w5 t0 @# ~, I! i3 P( q% H( F* }
  582.     return 32* F# I. s" n- y5 H1 C1 N" u+ G
  583.   end
    , M8 h% U# \- R# \" A
  584.   #--------------------------------------------------------------------------: J6 }" S' C# S& f0 L
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    8 _! j' L/ f! Q: a2 K( G7 C
  586.   #--------------------------------------------------------------------------0 e  u$ N# B0 f8 c7 ]
  587.   def mouse_window_area
    ; l4 R) J+ y5 r
  588.     if viewport.nil. e. W$ d) e6 D; [) v% t
  589.       vp_x, vp_y = 0, 0
    / s+ O7 S6 Y( ]0 O& J/ d# \/ a$ f
  590.     else
    + O0 R; T1 @$ j6 K/ i& q1 m' D* [
  591.       vp_x = viewport.rect.x - viewport.ox
    , w, @" t1 o; b8 J1 r. g' f) g# P
  592.       vp_y = viewport.rect.y - viewport.oy0 H, K4 ^! c# f% i& k
  593.     end4 f/ g# R- k7 J' n6 i
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y2 Q# V! x/ |: x4 d6 P3 M6 Q
  595.     item_x1 = vp_x + x + standard_padding " v+ o- `! ]9 |
  596.     item_y1 = vp_y + y + standard_padding
    0 W, ~1 q5 @( S: q7 z: M" X# S: U
  597.     item_x2 = vp_x + x - standard_padding + width
    9 P+ ]& Q: g6 R0 I
  598.     item_y2 = vp_y + y - standard_padding + height9 a) s0 o0 N1 Y2 o6 y& m9 z
  599.     if mouse_x  item_x1+ P. ]- w# U9 c3 v6 m8 W
  600.       mouse_col = -1
    1 I1 D% F+ W0 k, u) x2 ^
  601.     elsif mouse_x  item_x2
    & c! M  p8 Q5 C3 `0 u8 e9 ?
  602.       mouse_col = -2: B& K2 o" R3 ^" T  G1 P
  603.     elsif mouse_x  item_x1 + 1609 r) c6 L+ G( Q, K+ _
  604.       mouse_col = (mouse_x - item_x1)32( j8 b! K% i, O3 c
  605.     elsif mouse_x  item_x2 - 160. g; G! b; q5 D( h( t1 Y' t6 e( X
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    $ Y% T4 O8 p) i: V
  607.     else
    ! V" a/ \9 I* w8 {# H/ `
  608.       mouse_col = mouse_x  x + width2  5  4  i/ d2 Y* u1 m1 [5 t+ F+ t
  609.     end
    - R& V8 ^7 W4 C; K: I' U8 c
  610.     if mouse_y  item_y1
    $ c+ |5 U/ V, x$ o6 r3 n; ?" u
  611.       mouse_row = -1
    ( O* }# J- v2 e) R& `
  612.     elsif mouse_y  item_y2. [/ I0 r" T* B* f5 o! _! L
  613.       mouse_row = -2
    ' R# r5 D9 v; Y
  614.     else7 _1 j9 {! ^9 h8 n1 E- M3 m
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    $ d' t& n( v$ B' G
  616.     end) p8 \, n5 j; @& S
  617.     return mouse_row, mouse_col
    , X( N! u& g3 ^  l
  618.   end  y( @' {. H- k/ I# R# f$ a, r- b
  619.   #--------------------------------------------------------------------------
    # w! ]" @1 [* ~
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    $ T7 @  P4 G! Z' C
  621.   #--------------------------------------------------------------------------
    3 b1 N# }! F6 m) A  `
  622.   def set_mouse_pos  p. n( D! L( N4 X4 w
  623.     if viewport.nil # necessary!; _6 |6 f5 S* A" l8 x* a. [8 k
  624.       vp_x, vp_y = 0, 0% Z- i& H! b6 m" e
  625.     else
    0 g" `. E7 o# J. }' M
  626.       vp_x = viewport.rect.x - viewport.ox
    ( l4 c- d* A; {6 d! J* J; H
  627.       vp_y = viewport.rect.y - viewport.oy( F! A' f' A  J+ S
  628.     end% u/ l. p) q& b7 D
  629.     item_x1 = vp_x + x + standard_padding
    # O% @( A' q% c7 h
  630.     item_y1 = vp_y + y + standard_padding
    6 [" n! n9 O7 j# h  ]
  631.     get_index = @index  0  0  @index ' N' ?  R. _7 m) F$ A' I  Q4 _
  632.     row = get_index  col_max - top_row5 R  E/ ]' y7 m1 q
  633.     col = get_index % col_max- p" Z9 P& p7 k) {2 A
  634.     new_x = item_x1 + item_width  (col + 0.5)
    5 e# K  {9 M( e6 \5 L
  635.     new_y = item_y1 + item_height  (row + 0.5)
    $ V( F( V- b& b( i8 ~
  636.     new_x += 14 if col  44 \' r, i% C9 U* @' ^9 x
  637.     Mouse.set_mouse_pos(new_x, new_y)
    8 I9 A. p: C  j/ M3 I
  638.   end
    % ^+ {3 r0 h/ V; Z& {; H! h9 g
  639. end" c/ t* l0 J) i

  640. 9 X  T6 d8 @1 D: w- C, v
  641. #==============================================================================7 |2 u* a8 w4 Q; B( `& p: |2 G
  642. # ■ Window_NumberInput
    3 ]' L& q3 D2 U) z% E4 b1 U
  643. #------------------------------------------------------------------------------
    ! ?* s6 Q" `; J. A0 i0 D3 w
  644. #  重写了数值输入的方法以适应鼠标3 u6 k1 A7 i' R9 Q1 i8 T* U
  645. #==============================================================================
    " j# n! X, R+ F  R0 ^
  646. class Window_NumberInput  Window_Base
    3 t1 e8 O9 e$ {3 R
  647.   #--------------------------------------------------------------------------% J3 O0 P0 k$ |$ r( f8 m
  648.   # ● 定义实例变量
    : H) j& H7 }. o7 l
  649.   #--------------------------------------------------------------------------$ V( w  D; e/ G5 f
  650.   attr_reader extra_window3 \5 x5 Y. Z' F1 K, C, J1 O
  651.   #--------------------------------------------------------------------------/ n4 \9 g. L" J( f
  652.   # ● 初始化
    . ^. O) F4 a2 H8 p  N) y) w
  653.   #--------------------------------------------------------------------------
    * i- _$ L+ y2 O$ \5 g- o
  654.   alias sion_mouse_initialize initialize7 z' s& p! W$ C, u
  655.   def initialize(arg)
    3 Z3 q; M" r+ s; L+ S1 N8 x9 z4 R
  656.     sion_mouse_initialize(arg)% X9 s$ b8 O" W: G- z5 X6 k
  657.     create_extra_window
    8 {8 V7 T5 g$ d9 b7 F
  658.   end
      y. v5 _4 s4 F3 X0 s1 J
  659.   #--------------------------------------------------------------------------
    2 {. [/ N9 s# P% E, Y/ p* a
  660.   # ● 启动! d3 f. x' ~, R- |7 l
  661.   #--------------------------------------------------------------------------: X& D3 _5 a8 D2 M+ ]1 U
  662.   alias sion_mouse_start start# W9 i" B1 U' _- j
  663.   def start
    % u3 p( D* l/ [8 i% d' T' y$ n
  664.     sion_mouse_start
    & u! Z5 |  J( T" E7 F
  665.     deactivate
    " V6 i  d9 _+ O2 z# g- f- V& J$ e
  666.     extra_start3 J+ r7 j: z, _4 T& {7 E
  667.   end" W: y* [$ \! t4 b- [+ p- d8 f# ~
  668.   #--------------------------------------------------------------------------
    0 d! G, F4 a$ g
  669.   # ● 创建新的数值输入窗口
    / E" b2 d' |# [
  670.   #--------------------------------------------------------------------------
    ( |/ s. e. W( M# O+ C0 l# i
  671.   def create_extra_window
    ' d3 I. D$ j; e1 ]/ A7 M
  672.     @extra_window = Window_NumberInput_Ex.new/ `- z2 B# P, b
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2- `; v* f8 U2 ?) N1 d* [
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    $ L8 D' L4 M; G
  675.     @extra_window.index_proc   = Proc.new {n @index = n }& K# q. y6 o1 }4 V. `7 A* h
  676.     @extra_window.close_proc   = Proc.new { close }- V2 O" e7 p3 _2 _+ S) W* S
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    ' T$ Q9 G/ M" T( M8 O
  678.   end. C3 W! c- p1 x4 \# k- Q
  679.   #--------------------------------------------------------------------------1 Y9 i5 U2 `  c# C! I" J3 [' r
  680.   # ● 激活新窗口
    ; d' J$ o1 A* [+ T3 {9 r
  681.   #--------------------------------------------------------------------------. G# _# R% D# f( c
  682.   def extra_start
    7 J) V+ z5 b, |4 U4 L
  683.     case $game_message.position( x+ V1 e2 z; N' M
  684.       when 0; @extra_window.y = y + height + 4" u2 N1 t8 v$ _" l
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8% Q, ^$ s! X* R& @( x( ?
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    8 f; o+ Y0 L  X
  687.       else  ; @extra_window.y = 8' b; P1 e* L8 _5 Q- J
  688.     end7 r7 ]: F) {" [' x, u
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    + c0 Q8 ?( c( b+ n6 D2 t: q2 b
  690.     @extra_window.digits_max  = @digits_max
      Y! s& o6 T3 z, M: w9 g- j+ S
  691.     @extra_window.number      = @number* V6 N# X0 ]" Q
  692.     @extra_window.open, L# ?+ F' x( D3 L2 t& i" [$ R
  693.     @extra_window.activate
    * e! c5 ], p" K, S2 ^% j6 e2 z- _4 K3 m
  694.   end
    # {& {- {/ R8 O  ^$ G% \: P
  695.   #--------------------------------------------------------------------------1 c. B# l& P8 W, a' K* b9 W
  696.   # ● 更新) k  S% b4 k" F! @3 o7 c  e! ~
  697.   #--------------------------------------------------------------------------
    9 W8 k0 X, H/ k5 D# n. V# T
  698.   def update$ k8 J$ {4 x' g3 ^$ p2 ^5 g. z
  699.     super8 d, P: C2 z: g& C! V( C9 b$ r
  700.     @extra_window.update9 Z: L& y9 u9 ]
  701.     update_cursor* @- _" _& m+ o) j- \2 p; E
  702.   end
    6 Q  k9 V- u& g6 P7 \
  703.   #--------------------------------------------------------------------------: k2 _5 C- k( W. |
  704.   # ● 关闭窗口
    : {  Z, V$ x: \; L* e  p5 X  K
  705.   #--------------------------------------------------------------------------
    " `! D& m2 L+ n0 {- r8 a
  706.   def close) g3 J/ f. ^, M* ^  G0 k& Q
  707.     super2 |$ O, U; W8 v5 k1 I
  708.     @extra_window.close
    % F/ s( p- a: U5 ?' @; T6 [# _
  709.     @extra_window.deactivate3 k" F1 f7 m# @* c& p
  710.   end8 y- ], F+ e+ E1 m& ^- y
  711. end- B6 e9 r! G) Z2 K* J! b
  712. ' _# y- p# e& c+ `: }. k
  713. #==============================================================================9 B" t0 M- Z! [6 \
  714. # ■ Window_NumberInput_Ex
    + u2 U9 K( {. Y
  715. #------------------------------------------------------------------------------
    ; ^/ @6 I' z6 i3 A
  716. #  新的数值输入窗口(NewClass)! j$ g; r# x, Z0 `$ l
  717. #==============================================================================
    ( S9 d# r% [4 v8 V; X* W* K
  718. class Window_NumberInput_Ex  Window_Selectable. p, q8 {- U( n3 O
  719.   #--------------------------------------------------------------------------9 r" v1 s; f4 m2 J; ?
  720.   # ● 定义实例变量
    3 j2 N$ s6 B- y% F) p1 [, p0 ^
  721.   #--------------------------------------------------------------------------" i% P" A* d) g) W) ^/ \
  722.   attr_accessor number_proc
    " d  p+ E' \4 Y4 m
  723.   attr_accessor index_proc( X2 e; j6 G. k: e3 Q5 o
  724.   attr_accessor close_proc
      ^4 ^# [6 S, S7 [% m' v8 H( f
  725.   attr_accessor refresh_proc: ^: r( o6 u9 x+ x
  726.   attr_accessor number
    ! |$ ?5 @* i: a. l/ X+ s
  727.   attr_accessor digits_max: K' p( |- h. I
  728.   attr_accessor variable_id  c) z4 }5 C- x5 s0 i+ z4 U
  729.   #--------------------------------------------------------------------------
    8 c* G& p% c/ m6 {; y/ E2 ~
  730.   # ● 数字表
    5 g/ C: |0 _- O9 t. F8 b1 _9 l2 V
  731.   #--------------------------------------------------------------------------
    % B. T3 D! Y0 y& |9 s2 A
  732.   TABLE = [  7,  8,  9,; S( h6 Y! Y, G$ N3 k  G9 x  Y
  733.              4,  5,  6,
    - X8 y7 l- g4 h& r
  734.              1,  2,  3,
    ; `  {, L4 d, u: P
  735.             '←',0,'确定',]
    # k8 v. l8 W/ ]7 s' H; ~5 V
  736.   #--------------------------------------------------------------------------- [7 L1 E0 H2 z1 p1 x
  737.   # ● 初始化对象
    8 ~, j0 ]; s; ]  s
  738.   #--------------------------------------------------------------------------# Y6 w) X$ e" F4 U
  739.   def initialize) e; V5 F) Q; w
  740.     super(0, 0, 120, fitting_height(4))' y& K( s* _# v2 h! c! ?- [
  741.     self.openness = 0
    ! A9 P7 O- r4 X8 R  G* \
  742.     @index = 0' i& W- m. @* k
  743.     @number = 0
    6 i& _, Z* }/ n( J3 M+ U1 F* B3 ?
  744.     @old_window_index = 0
    1 ^: Z: H7 \5 X  o# f
  745.     @digits_max = 0. v" o$ G0 \4 k
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    & X; ^& B/ z) e* Y" Y- n& E
  747.   end7 j. c$ S9 o7 t: A! E2 n  W
  748.   #--------------------------------------------------------------------------% J3 w0 t6 {- E) K
  749.   # ● 获取项目的绘制矩形
    0 Y5 R1 A+ \% `$ Z: i
  750.   #--------------------------------------------------------------------------) v5 g; B! ?+ L# w
  751.   def item_rect(index)
    ) v( k  }& {2 t6 n$ g3 {
  752.     rect = Rect.new
    : ]4 F: R5 o6 G/ K9 b% W" T3 h
  753.     rect.x = index % 3  32
    - _! a) _) ^1 o9 v/ @3 Z
  754.     rect.y = index  3  line_height* B' B; c9 c1 P" G7 N- x3 F
  755.     rect.width = 32
    * |6 \, X8 ?' V/ @; O. j5 H  b3 W
  756.     rect.height = line_height& ?  j4 s! \3 G% E  R) X' U/ D
  757.     return rect
    * c+ |4 Y4 |3 `
  758.   end
    1 X, F# d: r: W+ o
  759.   #--------------------------------------------------------------------------8 _& s* t$ L8 Z  c' N/ t
  760.   # ● 将光标设置到鼠标所在的位置
    * w0 a( S# o! t& Z" e3 Q% e# s
  761.   #--------------------------------------------------------------------------
    $ Z% K' c$ z7 k1 h5 m
  762.   def set_cursor
    / p( y: |: p) f. i- Z- q
  763.     mouse_row, mouse_col = mouse_window_area
    6 H8 F0 g# ?6 l1 I0 y1 [+ K
  764.     if mouse_row = 0 && mouse_col = 0
    , R) v6 m% h$ i. x! m. C
  765.       new_index = mouse_row  3 + mouse_col& O9 L, Z) R3 w" j# G+ z' R
  766.       select(new_index) if new_index = 11
    ( n0 u  N8 c% F! Y+ p# I9 o
  767.     end9 S. B7 l/ D" v$ \  O
  768.   end
    & v( v% M4 a1 t% U+ C$ P
  769.   #--------------------------------------------------------------------------3 Y  ]3 T4 _# ]  B& ], ^
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    8 K& i. `) [" m7 V& b: I
  771.   #--------------------------------------------------------------------------
    8 H+ l, k- s9 O1 O/ F& w* |2 C
  772.   def mouse_window_area
    4 ?# j6 I( e: g' X2 J% j
  773.     if viewport.nil- v* D0 S% i+ t, @3 c* `
  774.       vp_x, vp_y = 0, 0+ |. d1 O# Q$ f! Y) p+ L! K/ m
  775.     else; Z. i& J- r4 ~* p4 I: K/ E+ a# }
  776.       vp_x = viewport.rect.x - viewport.ox8 I# |5 ]- b* |0 K/ q' s' d8 Q
  777.       vp_y = viewport.rect.y - viewport.oy
    ' f) h3 s* z) z% x4 B' E
  778.     end' ?: l9 A8 d& z' N6 j
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y/ i/ n9 R1 \  A$ d7 ^
  780.     item_x1 = vp_x + x + standard_padding , R% P& V' h+ ?2 y* ^
  781.     item_y1 = vp_y + y + standard_padding
    3 ?- O- ?* ]  P) G# @9 l6 D
  782.     item_x2 = vp_x + x - standard_padding + width
    . g* T6 O, f/ S
  783.     item_y2 = vp_y + y - standard_padding + height9 d' w$ A/ g7 B! w* B2 t
  784.     if mouse_x  item_x1
    . t0 K: g3 N$ |
  785.       mouse_col = -1
    $ k( f2 F' i9 m+ a( |" t! ^! g/ v
  786.     elsif mouse_x  item_x29 X% z' d$ v0 t% q+ B0 A' i
  787.       mouse_col = -2& v8 v8 P9 P; Z( o4 _5 D
  788.     else
    0 P. h: h+ y* X8 l* s( L
  789.       mouse_col = (mouse_x - item_x1)  32
    , p0 M( R* a0 L; I# {
  790.     end5 w6 h3 k+ N5 M" W, g! U$ _
  791.     if mouse_y  item_y1
    0 w4 }! r8 J4 W& m& V
  792.       mouse_row = -15 o4 o* Q7 m+ Q! [- A( X! D
  793.     elsif mouse_y  item_y2
    % r7 m, `4 w. H& F2 b9 S
  794.       mouse_row = -2: p" \' n1 D7 Q6 O8 a- {3 U
  795.     else, x0 z; @  T" `, G
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    0 k) q8 t) \: q, ^5 O
  797.     end
    - {) [* h. K3 W
  798.     return mouse_row, mouse_col) M/ z5 B$ e2 {
  799.   end' d7 v$ Q1 J. {5 [2 S
  800.   #--------------------------------------------------------------------------
    . c$ r) o1 [2 I8 G
  801.   # ● 获取文字
    ! @( C2 m% x/ o' [7 E
  802.   #--------------------------------------------------------------------------
    # `" Z6 l6 K0 r5 z( s) g& h' z' ^0 r6 [
  803.   def get_number
    / q4 D* l4 y# [- E; y5 t2 a
  804.     return false if @index == 9  @index == 11
    8 K9 x+ j7 Y7 q! F
  805.     return TABLE[@index], G9 S5 _7 Q, }+ H5 l5 [( s
  806.   end6 b) }  F% T* b; a" s
  807.   #--------------------------------------------------------------------------
    / G' J$ Y7 |7 J: `2 \; N
  808.   # ● 判定光标位置是否在“退格”上4 F; S; q+ c' T' p7 Y0 w( F* s
  809.   #--------------------------------------------------------------------------: J& l+ J& G  ]: }" C0 B% b: Z7 R
  810.   def is_delete
    $ n9 O! f4 c' y. [* }$ p4 ^; ]
  811.     @index == 9
    0 o' A, {* f2 {
  812.   end$ m$ E) r0 S! f) f& i* z
  813.   #--------------------------------------------------------------------------$ k& }4 n' g( F
  814.   # ● 判定光标位置是否在“确定”上
    % K/ F7 C' u% D5 R3 `+ s# }9 g
  815.   #--------------------------------------------------------------------------: s. s1 P$ e) G
  816.   def is_ok. Z9 V' W. F9 x4 l& b  y
  817.     @index == 11
    5 w. {: y0 }; y  ]' ~% A- ~; x. A7 `
  818.   end; F7 p; g7 B2 R1 c
  819.   #--------------------------------------------------------------------------/ r% r2 d1 N$ P! d' y
  820.   # ● 更新光标3 y6 U+ ~6 h  X4 T9 B
  821.   #--------------------------------------------------------------------------
    5 L! j/ t- O9 H% I
  822.   def update_cursor3 u: |* D8 N& t5 U- ^( m! A
  823.     cursor_rect.set(item_rect(@index))
    & K# {9 H1 l" _4 J0 R& K
  824.   end0 p/ ?; j6 X1 ]  c, e% C7 ?
  825.   #--------------------------------------------------------------------------( {! z6 t% t3 _# ^/ j' K" s
  826.   # ● 判定光标是否可以移动
    9 y% h5 S3 c1 ]  R  S, V5 D% x- {; j( C
  827.   #--------------------------------------------------------------------------- ]# `" E' I* o3 V% i
  828.   def cursor_movable
    # `: u. T! F  k% O5 ]  [
  829.     active& r0 g, |. A7 `, n+ M& y) q: F- S$ E
  830.   end& D5 e5 H+ ?- j7 J2 ^
  831.   #--------------------------------------------------------------------------& w$ F% `  Y  n( \0 o& M: S  c1 z) I
  832.   # ● 光标向下移动  d$ A8 o4 T5 N9 b
  833.   #     wrap  允许循环
    : b1 v5 a& |  j. D
  834.   #--------------------------------------------------------------------------
    ) t; o# h; w; t
  835.   def cursor_down(wrap)
    ( z. C# o: O4 k/ {
  836.     if @index  9 or wrap9 v" ?2 p3 i; y8 V
  837.       @index = (index + 3) % 12- R# ?) F" ?  M9 h+ d% `( U
  838.     end
    0 R# V# _: X# N, w* b( k
  839.   end
    9 Y4 ~- X4 H& L! ]1 f
  840.   #--------------------------------------------------------------------------
    * K5 q( S( V/ j' L
  841.   # ● 光标向上移动
    % x7 h4 L+ Q+ W- j6 C- m4 a7 H* o
  842.   #     wrap  允许循环$ p! @3 {* d% N2 u; Q# G7 t1 ^
  843.   #--------------------------------------------------------------------------: [& Q- Y) x3 m6 ?' m$ r
  844.   def cursor_up(wrap)% B. @; N9 R6 x1 F6 n: }3 w' U
  845.     if @index = 3 or wrap
    % {/ G) g5 n: F0 j
  846.       @index = (index + 9) % 12$ G/ B  E3 i; S" S5 U: z7 ]- r1 [
  847.     end5 H4 p  p8 U9 x/ A- y6 ?6 B
  848.   end
    9 A7 T5 F9 }5 v$ k6 r/ r$ p
  849.   #--------------------------------------------------------------------------
    ' A! ?; ?6 B: q4 Z& p( N
  850.   # ● 光标向右移动
    2 T$ G$ U8 D, w. k& _- w
  851.   #     wrap  允许循环' _! t8 T8 Z# u3 {( E+ L! f
  852.   #--------------------------------------------------------------------------
    ; a9 M( l. k( b' _- f+ y) Z" N
  853.   def cursor_right(wrap)
    / l+ N& l4 M7 A' W+ R2 B
  854.     if @index % 3  2. J3 ^& F9 {6 Z# A9 s
  855.       @index += 1
    $ a+ Q0 i4 _1 _( q
  856.     elsif wrap2 z7 S) J5 `8 V8 @! o4 w+ s1 G
  857.       @index -= 2
    3 y: O7 C" w; N: B9 J/ j
  858.     end
    ( \3 G& |) B" K7 L9 _, V/ ]
  859.   end! F7 x- [3 O& }! z- E7 Q
  860.   #--------------------------------------------------------------------------2 S! h. K: Y( M3 v) A! ^2 C
  861.   # ● 光标向左移动
      m" d, u" u0 u6 ]  z2 `% X
  862.   #     wrap  允许循环
    # C6 I* @+ W- {5 n
  863.   #--------------------------------------------------------------------------
    8 @! Q/ R* o! r
  864.   def cursor_left(wrap)$ J* t) Y2 G1 [( f. g
  865.     if @index % 3  01 l% O' k) t, W' g& n
  866.       @index -= 1
    ) i. v. ~$ x# }% Y1 E7 Z
  867.     elsif wrap& R( S0 V+ X8 h
  868.       @index += 2
    4 I7 p) ?7 J2 x' O$ o
  869.     end5 x# }3 R& G/ S5 M! e1 j  H) H8 D8 \, E
  870.   end
    2 j" s+ Q0 q2 W, i/ C8 ?- T7 h
  871.   #--------------------------------------------------------------------------4 F% v+ ^: [8 W# Z: L
  872.   # ● 处理光标的移动
    0 N  w% h- I7 q7 N- \6 O" R$ `. Y
  873.   #--------------------------------------------------------------------------, _6 C" Q9 S& U2 i% @# C
  874.   def process_cursor_move
    ! x7 c5 F0 W* y9 f) \4 m8 m
  875.     super( W* O. D+ Z3 @+ H
  876.     update_cursor$ W0 s  r7 p" V! B+ D* c
  877.   end
    ' [  ~9 t* w4 J5 G; Y6 U9 W
  878.   #--------------------------------------------------------------------------/ K! h# F8 |; A9 `
  879.   # ● “确定”、“删除字符”和“取消输入”的处理8 R4 G& N2 r0 i8 H, n( ]% S
  880.   #--------------------------------------------------------------------------
    5 ^7 g& |! ^3 b& D0 Z; L
  881.   def process_handling
    ( E! j) {; Z) d
  882.     return unless open && active
    7 J" }* g8 Z. k  A' `- T
  883.     process_jump if Input.trigger(A)
    ; ~0 z2 {% M* K9 ^$ X7 I- F8 i: Q
  884.     process_back if Input.repeat(B)
    # K3 E! y* h5 N8 e8 u# U" @
  885.     process_ok   if Input.trigger(C)
    ; r/ C1 M  u; y
  886.   end. f( _) w' t. R* q& b3 @" D4 N2 w
  887.   #--------------------------------------------------------------------------
    7 ^6 M9 w* B; S1 s5 t7 O. q
  888.   # ● 跳转“确定”8 F$ \$ k: D+ L% F
  889.   #--------------------------------------------------------------------------) p6 [6 T+ r  }" e2 ^0 z1 v
  890.   def process_jump
    ; O* F, e9 r6 q5 q# {# \
  891.     if @index != 11
    6 o) g( A$ K# l& v: N% t
  892.       @index = 11" D) }! h' ~* K6 }% o
  893.       Sound.play_cursor. A  b3 d  j7 `! {/ Y
  894.     end
    4 d4 p& r# z) D; `) J$ }
  895.   end0 x5 K, ~- P% A+ ]% u9 s1 O' {
  896.   #--------------------------------------------------------------------------
    9 ]+ g7 M! ?  c
  897.   # ● 后退一个字符
    $ j, D8 B4 P1 y7 O  @; m# [
  898.   #--------------------------------------------------------------------------
    $ @/ v: w1 D: G$ k/ w
  899.   def process_back2 M6 e4 q7 K" l
  900.     Sound.play_cancel
    + P% o3 v" v# u2 Y
  901.     place = 10  (@digits_max - 1 - @old_window_index), W  B8 ^3 d; Q, h
  902.     n = (@number  place) % 10& {) h2 C3 Q3 S
  903.     @number -= n  place
    7 ~3 b6 W8 V1 N8 U% v/ u3 v
  904.     @number_proc.call(@number): D- T+ P& o5 k$ Q: |3 \' f$ z
  905.     @old_window_index -= 1 if @old_window_index  0
    1 b( D6 Y& e  D+ B' U3 R+ Q0 Y( C
  906.     @index_proc.call(@old_window_index)
    ) l; n; r( n( c; K* j5 R
  907.     @refresh_proc.call7 i% a- p8 K  O# s& s
  908.   end
    % N6 e+ q% m% M0 @
  909.   #--------------------------------------------------------------------------+ h+ k7 ^6 L- i
  910.   # ● 按下确定键时的处理
    . N7 ~: Z) V% M4 I% H; t" |
  911.   #--------------------------------------------------------------------------- Y' E) C: V3 c$ r- d
  912.   def process_ok/ C  ?. N6 b2 W5 O  Y( G" C
  913.     if get_number
    - G8 {1 l+ h; p7 U( f
  914.       Sound.play_cursor" r% |4 X- t) t0 P  L6 J. {
  915.       place = 10  (@digits_max - 1 - @old_window_index)+ ^6 p3 G! G( `' S
  916.       n = get_number - (@number  place) % 10
    ( I" O9 c: x/ H. C/ r
  917.       @number += n  place
    1 [/ ?+ ]+ q6 I# i
  918.       @number_proc.call(@number): J* |0 s5 Y! G
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1$ _" k3 c& Z2 a$ k9 W0 P
  920.       @index_proc.call(@old_window_index)
    2 Y2 V: B, d6 [/ p
  921.       @refresh_proc.call& \  K, ]- Y3 I: ~
  922.     elsif is_delete& Q% K. S$ T# w, A* t4 E5 B* d
  923.       process_back9 n4 p% P5 t* L3 G- k% k
  924.     elsif is_ok8 l  d2 |9 A8 e% D, y5 x
  925.       on_input_ok# J: z- y( i6 C! z6 s) S5 m3 X" F
  926.     end
    - |7 a# |/ K/ K4 e; U
  927.   end. O6 I; s0 U: c$ c3 ~7 W# d
  928.   #--------------------------------------------------------------------------
    & U8 c  \5 R) i! I; a
  929.   # ● 确定
    ! [5 _  y% W# ]
  930.   #--------------------------------------------------------------------------
    5 m( |" U- O& E7 _1 l6 U$ T+ G
  931.   def on_input_ok# o9 t# t+ _6 V) W( f
  932.     @index = 0* J# V  T+ w" U/ _
  933.     @old_window_index = 0
    ( Z" @+ ~! e" e5 S3 @
  934.     $game_variables[@variable_id] = @number7 y5 y5 z; r; w- [6 P; @7 C7 _4 |
  935.     Sound.play_ok
    . N# f* \* }" x
  936.     @close_proc.call6 P9 M/ q+ W) w7 G. e3 z
  937.   end7 I' g9 S6 I: J) e+ I
  938.   #--------------------------------------------------------------------------
    , P4 Y6 l) S1 ~8 V* [
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    1 l+ P6 t7 }0 F' U  `! E
  940.   #--------------------------------------------------------------------------, g$ J; U/ c/ f+ j" D
  941.   def set_mouse_pos
    - q, Z& A1 J9 V3 u! p9 W4 s: j( Y
  942.     if viewport.nil # necessary!2 H/ t% l# r7 V& [  [% \8 @" L
  943.       vp_x, vp_y = 0, 0
    / ^# T1 n: _' m1 [. O, _4 ]; r
  944.     else
    : a( K- h2 H$ W, D& A7 i
  945.       vp_x = viewport.rect.x - viewport.ox8 b$ e& G4 u9 |+ T. \
  946.       vp_y = viewport.rect.y - viewport.oy1 b3 P9 h  r9 s( B+ E: {
  947.     end  I4 o# n* R$ }* e0 G1 M, ~1 \' E% x
  948.     item_x1 = vp_x + x + standard_padding . B/ O  F# C& M  B
  949.     item_y1 = vp_y + y + standard_padding
    7 ]0 f! N. Q% H  S- u
  950.     get_index = @index  0  0  @index : k3 S; n' ]+ J! h$ s% V
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    + y8 [# w' Y7 I
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    ( G/ l$ H1 W/ S- P* a9 R6 s3 i
  953.     Mouse.set_mouse_pos(new_x, new_y). ]5 j7 k' u/ `! K. }; f- @
  954.   end" F9 p9 ?. \( w: C4 V
  955. end- X' |) F/ {" \1 K5 O2 _

  956. . @% c# U1 @1 [1 V8 R7 ]+ f
  957. #==============================================================================
    # z( N3 {) ~; [0 y' K' [% A, |
  958. # ■ Window_Message
    ! [, d! D- x1 {* ^: p
  959. #------------------------------------------------------------------------------
    " v5 Z" \: n- ?
  960. #  显示文字信息的窗口。
    $ F4 v% M* B; n3 D" [% O
  961. #==============================================================================, v. y7 V9 d( E, e/ N/ ^5 F, ^9 E
  962. class Window_Message  Window_Base0 Q0 d& I1 }( X# b+ y
  963.   #--------------------------------------------------------------------------
    7 i+ b& E, Q, y+ r; [& N! u
  964.   # ● 处理数值的输入(覆盖原方法)
    , x/ M9 `5 R) ?6 i/ m0 Q2 e9 \
  965.   #--------------------------------------------------------------------------
    2 t$ ~( R; f. {. w, [, N
  966.   def input_number
    - D8 O1 j( B2 a( w2 z- y
  967.     @number_window.start
    9 j0 C$ J7 v# U, s2 p) j
  968.     Fiber.yield while @number_window.extra_window.active' }) g4 }3 U' }% V
  969.   end
    " M. J, v# r, e. C+ E' v/ ~; [
  970. end$ B  S2 \0 t1 _

  971. / b. H( U- i- J1 T& y7 k, @7 S
  972. #==============================================================================: z1 L0 {+ T$ r: B
  973. # ■ Window_PartyCommand! e& e6 q( p$ ?: Y5 {1 v
  974. #------------------------------------------------------------------------------/ ^4 F3 Z  p2 ?6 X
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    3 ?+ R' m. s: X4 M
  976. #==============================================================================% ]: I- A5 {- T- o; b" z# [$ I$ s
  977. class Window_PartyCommand  Window_Command& K- v* q  f7 T& a; Y0 G
  978.   #--------------------------------------------------------------------------! B$ Z$ L9 U, r  B2 |1 T7 v# k" _
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    $ h: J5 Q! e0 Z. ]
  980.   #--------------------------------------------------------------------------9 _4 n- V$ O" N5 e
  981.   def set_mouse_pos- S+ A- T; h5 l# O( s2 N' ?
  982.     if viewport.nil& I1 N2 |9 M. t8 s7 B
  983.       vp_x, vp_y = 0, 0: z1 B& M" f) A2 m* V7 Z" d
  984.     else
    3 D& ]( F8 v# _; T% K
  985.       #vp_x = viewport.rect.x - viewport.ox
    8 R. [* c( s& u1 {6 S
  986.       vp_y = viewport.rect.y - viewport.oy
    , m  A2 X' n: ^& }* N; k$ T! Y' A
  987.     end
    + `/ V6 r. O" U/ x# `% w3 |* H2 D) J4 {
  988.     item_x1 = x + standard_padding
    9 Z) M9 R0 [( t4 I0 s# I0 {! T
  989.     item_y1 = vp_y + y + standard_padding1 z  r# {2 e9 [3 }
  990.     get_index = @index  0  0  @index , ?+ |' D9 ?" Z  z! t/ O
  991.     row = get_index  col_max - top_row
      Y6 [+ u4 W/ K6 h& M
  992.     col = get_index % col_max
    % I' z6 q8 N7 M1 F: }9 K( ~7 v. r% r6 }
  993.     new_x = item_x1 + item_width  (col + 0.5)
    1 {( N) l5 ]( Z
  994.     new_y = item_y1 + item_height  (row + 0.5)4 @- V# X1 F+ q/ L/ G6 P8 X& }
  995.     Mouse.set_mouse_pos(new_x, new_y)
    , y! u, M& u) _& `6 M: F
  996.   end  Z1 d! ^5 A# R  C. B/ C  ^
  997. end
    - W* W/ d8 m, x

  998. 3 [+ Z, g, ?  D
  999. #==============================================================================
    8 C$ S8 {$ d7 B7 w: Q/ }% c! n8 @
  1000. # ■ Window_ActorCommand
    8 r* N! l7 _! c3 O) f# h
  1001. #------------------------------------------------------------------------------
    1 b+ F' u- Y$ j* e7 s* j
  1002. #  战斗画面中,选择角色行动的窗口。8 b8 y9 _0 P: P1 t! e# {: U
  1003. #==============================================================================: q  a- n* t' c8 P
  1004. class Window_ActorCommand  Window_Command
    ) n$ L4 \, t4 ]# ^* m$ o
  1005.   #--------------------------------------------------------------------------$ M1 j4 G$ p& V/ `. V4 c6 Q
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置3 U2 D  ^: ~: l1 H
  1007.   #--------------------------------------------------------------------------6 ^4 z6 t1 m( ?) H6 t
  1008.   def set_mouse_pos4 u6 [  S) f! @' J! C
  1009.     if viewport.nil
    % `  R' E' w" k  N
  1010.       vp_x, vp_y = 0, 0
    + v3 E( e: G" s) p
  1011.     else
    ; g' d4 D, \8 n7 g& @. j
  1012.       #vp_x = viewport.rect.x - viewport.ox+ i# `  J$ k: i# c! a  y
  1013.       vp_y = viewport.rect.y - viewport.oy
    , }* K4 G9 `( l+ q6 P( y; S
  1014.     end
    ' r3 g2 i8 h4 i, a7 f
  1015.     item_x1 = Graphics.width - width + standard_padding0 p9 ~" J5 U: r- I) ?+ P1 J$ j( a4 U
  1016.     item_y1 = vp_y + y + standard_padding
    4 ^& k/ H% H6 E) C6 m
  1017.     get_index = @index  0  0  @index : w% q! D! {9 Q( ]6 k6 V) M1 a( I" Y5 V
  1018.     row = get_index  col_max - top_row
    : J. M* K* j" x* J
  1019.     col = get_index % col_max
    % ]' _+ y( x( ]" e/ _* e
  1020.     new_x = item_x1 + item_width  (col + 0.5)" O7 |: r! V5 y6 h/ J
  1021.     new_y = item_y1 + item_height  (row + 0.5). a8 _, V  H# a/ n5 V# D: D
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    : h0 x0 f3 b7 r: i  k2 g
  1023.   end
    1 ~% b, V3 P3 z8 |
  1024. end
    * I3 w& a: r: \7 W8 v+ i' Q0 R% J. ^5 q

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

  2145.   v2 `0 O& _% u$ L! ~2 m
  2146. #==============================================================================
    7 t$ C/ K0 P# l& ^& s1 ?
  2147. # ■ Game_Map3 R1 ~8 _: G" V8 I; o  }/ C
  2148. #------------------------------------------------------------------------------
    0 m/ s$ @" {5 m8 n. u( s; R  f
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    ' l" A6 e. y+ R
  2150. #   本类的实例请参考 $game_map 。& {5 s9 X; K7 s
  2151. #==============================================================================
    6 w  L1 [) v2 a) q4 e- W
  2152. class Game_Map
    * G; T- m2 m" O. }8 l! n; @5 L
  2153.   #--------------------------------------------------------------------------0 `) t! ]; F$ S' i+ i
  2154.   # ● 定义实例变量. x. `+ z' A4 _& p; d
  2155.   #--------------------------------------------------------------------------
    7 a! z. q- B( E! h6 |; T  Q  s6 g
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据) x  X& Z* s; n0 l# b" S! j
  2157.   attr_reader mouse_map_y # 同上
    : X- e" o% j1 p5 l
  2158.   #--------------------------------------------------------------------------
    - q% i- T  b% `# \6 \+ m
  2159.   # ● 初始化对象
    " d( u5 q" C) g( L# Z
  2160.   #--------------------------------------------------------------------------( Q2 w- x  s0 |6 [! U6 \! N
  2161.   alias sion_mouse_initialize initialize1 R5 t  d/ L9 q3 m7 U# A0 `) z
  2162.   def initialize
    - Y5 P( n' d8 H  l. l/ b% k
  2163.     sion_mouse_initialize
    ! x2 @! v* i5 H: a
  2164.     creat_move_sign  #### y/ r* l  ^$ `, N3 B% h* m
  2165.     set_constants9 z- w$ M: \9 ^* p
  2166.   end+ I8 e/ f" C5 T( @5 k5 A  u
  2167.   #--------------------------------------------------------------------------
    ! l+ i4 ]+ [# ?! |4 |) h4 e
  2168.   # ● 更新画面
    9 g) K$ g1 f# s) U1 @
  2169.   #     main  事件解释器更新的标志: G6 u( o# W2 U" h- T# I  H/ C1 y
  2170.   #--------------------------------------------------------------------------7 u: L" d- m; }7 j
  2171.   alias sion_mouse_update update3 ?) ~6 P$ a1 U: B% H* F
  2172.   def update(main = false)
    " c$ ]; s7 F% q' g2 M! E1 L6 P
  2173.     sion_mouse_update(main)
    1 c* `- x' U( x
  2174.     update_move_sign
    6 z  m# z/ N. {1 A, h
  2175.   end$ d2 ]5 \# M' Z! @8 Y- ~
  2176.   #--------------------------------------------------------------------------$ R' c4 K- s0 a! _, {# W
  2177.   # ● 创建显示路径点的事件! O, d5 w1 Q& b! f: N' o( D0 n% u
  2178.   #--------------------------------------------------------------------------3 ]9 e6 B) Z3 G
  2179.   def creat_move_sign
    8 Z( p/ I$ [& Q. p/ U
  2180.     $mouse_move_sign = Move_Sign.new
    8 e5 R- v0 [+ P: D5 N+ h& x# e
  2181.   end
    ; Q! ?4 A. u8 x# g" }9 D2 d! }
  2182.   #--------------------------------------------------------------------------$ l( a6 E# i  l. H
  2183.   # ● 更新显示路径点的事件
    ) `9 o6 O6 T& O) Z  o
  2184.   #--------------------------------------------------------------------------6 s+ L/ t. X$ H' I* p9 u# T! E
  2185.   def set_constants7 v: ?% S9 p) V" W6 L
  2186.     @mouse_pos_setted = true/ P! o0 K3 t$ k: b. N* `& o
  2187.     @set_pos_prepared = false
    9 t' y% a" V' G
  2188.     @mouse_old_x = 0
    , f- m0 ^' a6 B! F7 D! J
  2189.     @mouse_old_y = 0' y- K9 {: ^$ I  L$ p, `- @; ]
  2190.   end
    + a, L+ h% g; Z3 ^6 V$ q4 k. C
  2191.   #--------------------------------------------------------------------------
      \" W$ {$ d7 l9 n7 o
  2192.   # ● 更新显示路径点的事件
    5 z; j$ Q- S/ j4 ?: ?3 K! p, w
  2193.   #--------------------------------------------------------------------------
    % M# e* v% P1 h2 k: A+ S- J
  2194.   def update_move_sign+ M- c$ t. m) m1 `7 C+ U
  2195.     $mouse_move_sign.update
    1 y+ }/ ?0 P% W& L
  2196.   end8 H  T, ]" D: f" t& q. k* `
  2197.   #--------------------------------------------------------------------------
    & M) Q0 `3 y$ Z. f# _
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    * k! _1 ?+ D: z, v) D% b
  2199.   #--------------------------------------------------------------------------+ q# c8 e" J6 t
  2200.   def get_mouse_map_xy1 V+ N" e4 i9 L1 e
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y3 l# I5 C5 L& Y: c$ f
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    ( ~& U. @9 u/ p( s* ^# F
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    / M' F0 M0 w# `+ b  Z
  2204.   end/ d2 O/ D+ a6 e
  2205.   #--------------------------------------------------------------------------7 w- K: g7 h: E2 j0 n; |+ C
  2206.   # ● 返回地图画面时重设鼠标坐标
    5 w" w! P: [" F- ?) }' Z' o4 x
  2207.   #--------------------------------------------------------------------------
    & c% ~# l" L  k+ e, x9 s
  2208.   def reset_mouse_pos
    3 k( P4 x3 Z% P1 A
  2209.     return if @mouse_pos_setted/ K7 h  d$ g0 l6 E1 ^7 g- L5 P
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)( m4 y# L$ g  U+ e/ F
  2211.     @mouse_pos_setted = true
    $ A0 t. ^, V' t4 I' o* B
  2212.     @set_pos_prepared = false
    ( o& r! D- D8 g4 x' \3 z* x* v
  2213.   end
    " i3 h' v. B' R
  2214.   #--------------------------------------------------------------------------
    ' h( L4 C2 P& t* T5 i" {  _+ V% ?4 u# s
  2215.   # ● 重设鼠标的坐标
    ! Y( S8 D( @: v8 N" h& r" c
  2216.   #--------------------------------------------------------------------------% ~8 ~! S. k0 o7 N
  2217.   def prepare_reset_mouse_pos/ u# s& v. k& A5 H" a3 D$ s
  2218.     return if @set_pos_prepared% X! V: a) V) J
  2219.     @mouse_pos_setted = false
    ) }) l" }: _/ L& u0 N
  2220.     @mouse_old_x = Mouse.mouse_x$ M& N' T4 ?) j* ^, Y+ J) ?3 g
  2221.     @mouse_old_y = Mouse.mouse_y
    2 l! h" D, s, \9 n8 d* ?' ~; l
  2222.     @set_pos_prepared = true9 N' a( ]' ]1 A* N( v+ [: k2 K) F
  2223.   end
    ! g6 q) z  S. u2 A. B- j+ I3 x0 n4 ?
  2224. end
      \5 n" _" n; M
  2225. ( ^7 C3 H3 L3 l
  2226. #==============================================================================
    3 z! S  d0 d% o" {, v% c
  2227. # ■ Spriteset_Map2 F' K/ h: z1 G1 x
  2228. #------------------------------------------------------------------------------5 p0 |, Z5 F) `9 e' |
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。0 x- X1 C* x/ ]1 M2 S
  2230. #==============================================================================- U+ B( `- c& K0 W! `. g0 K
  2231. class Spriteset_Map1 T" j, |2 m0 ?7 F4 V3 ?
  2232.   #--------------------------------------------------------------------------
    - T, l! P* b  E# }4 X
  2233.   # ● 生成路径点精灵6 f+ y6 ?. V  u+ o
  2234.   #--------------------------------------------------------------------------$ g2 ?- z7 t) `8 T
  2235.   alias sion_mouse_create_characters create_characters
    & y( Z; e& T# t  c
  2236.   def create_characters
    # C" @, H. P, P2 |1 G: x* _! U+ s" t
  2237.     sion_mouse_create_characters- I, T' b- q3 j5 i6 u
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    / J8 a  X; t/ L' B" W
  2239.   end
    4 S" w7 D, b( v+ L: Y7 ~
  2240. end
    ! J- S! k1 W( a4 N& x! U5 S8 g
  2241. . f/ G3 \' p/ r* D" [9 s
  2242. #==============================================================================9 t9 g9 e9 u# d- D
  2243. # ■ Scene_Map
    + Y2 d4 G& s' y: n% B; d' Y
  2244. #------------------------------------------------------------------------------
    7 f: |% |1 d# U
  2245. #  地图画面2 `# F( o5 T) z' K7 s
  2246. #==============================================================================
    ' |; b. @- m2 j2 K$ H
  2247. class Scene_Map  Scene_Base
    6 \' i5 |9 ]/ i! u
  2248.   #--------------------------------------------------------------------------
    # s; z% T* w/ q3 ^& Z$ @" S; `
  2249.   # ● 画面更新$ t( t, o, l" H2 b
  2250.   #--------------------------------------------------------------------------
    * b6 c- S: T& C& k1 k0 ]
  2251.   alias sion_mouse_update_scene update_scene
    " P4 a( u. u! c: o, T
  2252.   def update_scene
    " W+ K, O: c( T7 I
  2253.     sion_mouse_update_scene6 @( d+ u0 W6 h, D5 W/ ?/ A% v* X3 p4 ~
  2254.     update_mouse_action unless scene_changing3 q" G2 E  q- @& b
  2255.   end! G, ?2 \8 e4 W9 f
  2256.   #--------------------------------------------------------------------------
    - y% t8 |$ u8 _# J, q) Y
  2257.   # ● 场所移动前的处理1 q9 B) |. p: T' f+ d9 o; n1 k
  2258.   #--------------------------------------------------------------------------, D+ Q# n9 o( C' b* B1 ?
  2259.   alias sion_mouse_pre_transfer pre_transfer$ J# t! H- z$ ]2 @7 B3 F
  2260.   def pre_transfer0 }2 a9 X* e- u0 [5 ]3 x+ ~; c
  2261.     $game_player.reset_move_path+ \) z) P! l8 W, w  p
  2262.     sion_mouse_pre_transfer
    ; P: t. h5 c  p' f2 a
  2263.   end/ K0 Y, [5 x& q: q$ G
  2264.   #--------------------------------------------------------------------------7 F. v: l  f, f- M( R7 u
  2265.   # ● 监听鼠标左键的按下
    & P/ k1 c( d, P8 o% L& Q
  2266.   #--------------------------------------------------------------------------0 `: v$ u, O9 V; g
  2267.   def update_mouse_action
    $ l+ s5 A- Q* d8 P! a( c
  2268.     $game_player.left_button_action if Mouse.press(0x01)0 B( S' N9 U* |, J& L
  2269.   end7 j% @; ?( f' A. ~; @& g  J% Y& j0 U
  2270. end
    ' G/ C( g% Q$ g5 e
  2271. ! ?$ P2 h2 U2 v' T& m% L1 G$ }9 \/ l
  2272. #==============================================================================
    1 r; J( W2 B3 g) e% L
  2273. # ■ Scene_File5 \. @# D! E+ [" e6 V% c5 |& q7 y. K, V
  2274. #------------------------------------------------------------------------------' J! ?0 e  {2 u0 S
  2275. #  存档画面和读档画面共同的父类( E$ [, [: [: S9 {
  2276. #==============================================================================- z' q. U& o- a8 K6 u4 q* C
  2277. class Scene_File  Scene_MenuBase
    8 |( c0 a( S1 Z6 R. d
  2278.   #--------------------------------------------------------------------------$ J4 z/ k  i% N: r
  2279.   # ● 开始处理2 a  M0 l8 w5 p# Q' e: b- ?
  2280.   #--------------------------------------------------------------------------6 W7 g" [" U# o  k# B/ _: r
  2281.   alias sion_mouse_start start7 H4 C6 W3 t" h% z* W: N
  2282.   def start6 b- U6 Q2 O7 i' q
  2283.     sion_mouse_start
    0 y/ _3 }2 `0 ]' g6 V9 H. |
  2284.     @move_state = 0% M2 }  u2 a' S) w
  2285.     set_mouse_pos
    4 s* a9 }4 e$ ~9 W2 P# P! o
  2286.   end
    * ^% O9 F  Q) S3 Q/ V' c
  2287.   #--------------------------------------------------------------------------
    ; |$ ~' U- L. L6 |
  2288.   # ● 更新画面) s0 m( z% R3 \$ y, i+ u4 m
  2289.   #--------------------------------------------------------------------------
    * }( f/ y4 \6 ?8 K7 m) B# t
  2290.   alias sion_mouse_update update" O- V1 W$ V  C, G7 \; g
  2291.   def update. Z& Z: i: `: t# z; w
  2292.     sion_mouse_update3 Z3 D( A0 R. N" `0 T* }: j
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos' o& X) C+ |$ Q5 {" h3 i& M
  2294.   end
    / ~- J3 Y2 z1 V  E2 I9 u1 ?5 r, C
  2295.   #--------------------------------------------------------------------------( R! g, q& u" q# H
  2296.   # ● 更新光标
    ) M; {7 l3 t3 H% V( N1 H
  2297.   #--------------------------------------------------------------------------
    7 v  m- M2 z/ l# A; k. G1 J
  2298.   def set_cursor3 _' N5 x, s+ D1 I0 E/ ?% {* K4 j. e
  2299.     @move_state += 1$ }# ~( k  k, N3 g
  2300.     last_index = @index
    , }, y3 t0 L: ]6 R$ [3 W& H
  2301.     if mouse_which_window == -2
    % ~  A8 {% c0 {/ K. b
  2302.       if (@move_state - 1) % 6 == 0
    8 q! ?/ o, g8 T3 D
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1% H* R) O7 u. `/ {! z& g
  2304.       end) o% K$ c3 o4 d  b: S
  2305.     elsif mouse_which_window == -1( V: F: g3 z7 e1 H4 f/ Y
  2306.       if (@move_state - 1) % 6 == 0
    # l; g# H7 u' D" ]" y
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0, ?2 F6 [1 \- Z% Z" T# J4 P
  2308.       end
    2 b+ D& F* O* d  |4 F0 w! ?
  2309.     else
    5 P( l1 A& Y$ Z3 y# I3 U
  2310.       @move_state = 0
    ' Z1 p+ g: g+ e! a2 U
  2311.       @index = top_index + mouse_which_window1 u2 _, d9 X+ ^5 v# i
  2312.     end* G# l6 P8 K/ [. G  @
  2313.     ensure_cursor_visible8 V) R2 ]* K% U* J! O6 e
  2314.     if @index != last_index% q7 \* m9 E1 i5 F8 ]! i, |
  2315.       @savefile_windows[last_index].selected = false
    1 m! g) S2 Y6 N* r1 S! m
  2316.       @savefile_windows[@index].selected = true9 \4 ~* c% h- }. p1 E
  2317.     end
    / e% p! E1 ?7 j& s  J4 e* p
  2318.   end0 v8 ^8 o1 T- U; w
  2319.   #--------------------------------------------------------------------------
    % H- }( k  O7 G+ ^" {/ r4 ~
  2320.   # ● 判断鼠标位于哪个窗口
    ( t3 x: U+ ]* o. t! M( O
  2321.   #--------------------------------------------------------------------------
    3 {% [5 A: W! L4 f7 z! D* V
  2322.   def mouse_which_window
    9 u! _' k0 v# w" k
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    5 d0 M6 T3 L+ ~* c0 s7 n3 Y( r
  2324.     if mouse_y  @help_window.height + 149 ^' h) q) ~" b4 n5 M" \
  2325.       mouse_row = -1
    ; X0 Q( `. g) C4 f  G
  2326.     elsif mouse_y  Graphics.height - 14
    ) D  A; M4 x6 R1 f' D- S2 n$ G* T
  2327.       mouse_row = -2/ A) e% ~2 o, _; Y5 K
  2328.     else
    , F; K2 h" l% j9 V- M
  2329.       mouse_row = 4  (mouse_y - @help_window.height) : \% Y5 E0 q% X* A, [
  2330.         (Graphics.height - @help_window.height)
    2 U2 S7 n  o  B: t8 ?  S
  2331.     end
    ; N- w( ?3 d0 v8 T8 Z
  2332.     return mouse_row. o, b1 M6 _) z) W7 b  z# Q
  2333.   end
    ! w1 P' e  a7 z8 h
  2334.   #--------------------------------------------------------------------------* N$ s6 N0 B+ p. @0 r* V
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    + U1 N$ N4 T7 v1 c% O* Q  ?
  2336.   #--------------------------------------------------------------------------
    & q9 S/ ?' L+ O% {  ]( o5 K
  2337.   def set_mouse_pos% ^, z! q! s" R* ?( v# z
  2338.     new_x = 40) w# y  h, H9 Y. y
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    ; M' K$ Q$ _; Z* U
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    8 e: L! T  Z; w
  2341.   end# ~2 Y' @/ B' d# c4 ]6 u3 d1 ~
  2342. end
    * B/ z; t; V! C; H
  2343. ' X( O6 a# w8 O& p3 Q4 ]
  2344. #==============================================================================, N3 h4 o: q9 |; d$ i) Y1 S7 f
  2345. # ■ Game_Event
    6 |0 R! T7 V0 ^  e
  2346. #------------------------------------------------------------------------------
    6 C- d) I3 {( v. o8 l# Y) w+ ?
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
      E, I& g% `- h& F
  2348. #   在 Game_Map 类的内部使用。
    ! H( C# ^" M, V' `  q, d; [
  2349. #==============================================================================' B, ]; I/ F7 {$ @  `7 `7 _% W
  2350. class Game_Event  Game_Character
      S: K1 ^6 C* U- y( b
  2351.   #--------------------------------------------------------------------------* H1 X  w" i1 V8 a5 G
  2352.   # ● 事件启动7 _" g4 z& E& K  s5 U, X
  2353.   #--------------------------------------------------------------------------
    0 o+ z- P/ t% O
  2354.   alias sion_mouse_start start: J/ W. f4 M4 I. g/ P# j2 o
  2355.   def start4 m/ D2 t* E& P
  2356.     return if mouse_start && !Mouse.press(0x01)$ g7 z& N: j! x8 [0 V$ ^7 W
  2357.     sion_mouse_start& w& _2 F7 D/ N5 I: S
  2358.   end
    6 Z/ x+ G: ~$ S3 s$ G- h
  2359.   #--------------------------------------------------------------------------! [0 u  P+ \& l+ q( ]5 v, {" A
  2360.   # ● 判断事件是否由鼠标启动+ H0 C0 `" ?2 s/ [# g! F
  2361.   #--------------------------------------------------------------------------& L* I' }& Z$ @  a* z5 o0 r
  2362.   def mouse_start7 e/ p, D+ H: U
  2363.     return false if empty
    7 I. _4 n& K, z) {+ q5 R% i: ]
  2364.     @list.each do index' d( V% Y4 w0 p) M
  2365.       return true if (index.code == 108  index.code == 408) &&/ i5 V$ G) C/ }: F# H5 X
  2366.         index.parameters[0].include('鼠标启动')
    3 H0 |7 p1 _( F( j; S+ R# N' b
  2367.     end: F9 d! X! ]- U/ \3 F
  2368.     return false
    ( D+ z$ x& A. G* c
  2369.   end5 o5 W" F* _" V, x) Z% {
  2370. end; ]# X( W, i: J5 a  }3 k

  2371. + D- o! g  @, w! t
  2372. ####泥煤的height# v0 H/ S- |) U3 n
  2373. # @height = height
    " }& x' m$ S  b$ k7 L) a5 U# E; t

  2374. % N7 X# y" h9 n2 a+ M
  2375. class Area_Response
    1 J7 u0 }* [' ~* n
  2376.   attr_accessor type
    " _, Y8 W. ^5 v# K1 r# q
  2377.   attr_reader ox3 V" {1 h: h( O# G; q( b8 P8 M* k
  2378.   attr_reader oy
    ) j1 W$ p' _5 e$ N3 C; p& K$ n
  2379.   attr_reader width
    : l+ t3 Q# t+ s% z# i2 c' ?4 T
  2380.   attr_reader height1 u$ O6 K9 f( Y. t  e( E
  2381.   attr_reader switch_id
    + G4 M) }$ q& U) |/ y7 l
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)4 ?; p8 a9 s- a2 z3 j5 b- k
  2383.     @type = type
    " R( s9 p0 K' Z" }9 |; [
  2384.     @ox = ox
    - H8 J$ W5 S1 _9 T% X) |
  2385.     @oy = oy3 E3 l4 e/ \/ ^( n: i$ R
  2386.     @width = width
    # y. `( `! y* s- Q
  2387.     @height = height. o+ Q5 w3 z" }) o
  2388.     @switch_id = switch_id
    7 N( ?& R1 N- U' f
  2389.   end
    . L0 [+ g. l1 N/ i
  2390. end
    + V0 \6 G4 C- x/ O  e3 y+ R$ m
  2391. % X9 [* W& T: t& E7 G. f1 K
  2392. $area_responses = []5 e" w( j! ]! L1 N. [2 J: }6 T

  2393. 3 ^" S4 t/ ]  m- j
  2394. class Scene_Map
    $ \' m( O' z1 r, G- Z% f
  2395.   alias update_mouse_2013421 update_mouse_action9 c: w: G( X, d! J! n
  2396.   def update_mouse_action/ L( _* D" @4 l* w% h
  2397.     update_area_response# W2 @8 m- K* }' w" b
  2398.     update_mouse_2013421
      E6 R& x( m* d2 j( b
  2399.   end. l% n6 T; c3 g2 ^+ k
  2400.   def update_area_response3 x7 x& i' W" Y* ^1 M
  2401.     responses = $area_responses
    ! m4 J* O# K' L" ]. j
  2402.     responses.each {response
    3 ?  ^- a" W/ ^6 p1 I
  2403.       ox = response.ox! [& R( ?" o$ X4 F6 Y7 B
  2404.       oy = response.oy6 [* m0 C' V6 L7 H8 i& @) g; C2 `
  2405.       width = response.width
    9 C: `: s+ x; j! g% o
  2406.       height = response.height3 ]; O; o8 @0 {4 J3 f/ I
  2407.       switch_id = response.switch_id
    , _' y9 B- g/ `1 i/ T2 m) v
  2408.       case response.type& @0 h7 |8 k8 c0 o- U2 F
  2409.       when 0
    5 ]3 o, `9 o0 p  p- p* `& Q# V" O( D: t
  2410.         if mouse_in_area(ox, oy, width, height)* S. B4 F5 V) j& V6 r  S3 U; _1 H* K
  2411.           $game_switches[switch_id] = true
    ; T5 S1 b6 N# p, u+ t& p7 s
  2412.           $area_responses.delete(response)5 u; d& p- K  u6 P- v3 d9 Z
  2413.         end
    # Z5 U6 ~( ^! C7 r5 M
  2414.       when 1
    * Z' i- |" V+ t( @3 h$ R& x' T, E5 {
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    ! M9 R- n5 K. N) R6 K! H
  2416.           $game_switches[switch_id] = true
    / U% B) i1 s' A1 ^6 w
  2417.           $area_responses.delete(response)0 s" y8 l4 e5 z% c* O9 r
  2418.         end
    ! X' k$ Z0 M# S9 e
  2419.       when 2
    " X; ]0 W  b- V: F( }
  2420.         if mouse_in_area(ox, oy, width, height)/ f3 ~1 Q( |$ }# w5 L3 J6 W
  2421.           $game_switches[switch_id] = true
    4 N9 l1 s) M8 M. ]$ v& u! n
  2422.         else' x$ ?/ i0 i+ j5 h
  2423.           $game_switches[switch_id] = false+ [/ x9 J" x1 B$ d6 `' q+ u
  2424.         end/ x9 L0 h- W. j
  2425.       when 3; C+ V+ h- V' E" f. _# E
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    " I" h4 p0 \, v+ p) }2 N
  2427.             (oy - $game_map.display_y)  32, width, height)
    - W7 X; r" m: t, B, e8 y$ R
  2428.           $game_map.events_xy(ox, oy).each {event5 d! P+ s1 D# Y5 u
  2429.           event.start
    2 E+ d! Y6 Q1 U+ R7 b$ R
  2430.           $area_responses.delete(response)& o3 b2 l6 W2 P4 m2 D
  2431.           return* K1 \9 q- k5 C- }5 ^
  2432.           } ! J6 C9 D, E4 N6 Y' v
  2433.         end
    & R5 e! {7 b6 u) ?1 A; X
  2434.       when 48 J+ m6 D6 @' x
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    4 r$ h# y# E. C. J* d$ X5 |& C
  2436.             (oy - $game_map.display_y)  32, width, height)( Y( W5 Y( y) m$ M4 s0 ~! r
  2437.           $game_map.events_xy(ox, oy).each {event8 P5 d( A7 ?1 [9 Q+ ~+ _/ b, [# d
  2438.             event.start
      c4 ^/ o4 c. I
  2439.             return& _" q/ U4 Y) _) b: u! f' D
  2440.           } 6 [9 [3 `$ ^! h( b  e
  2441.         end# L$ w' C0 N( K
  2442.       end
    % k$ ^# u8 {8 B% x" G
  2443.     }
    ' J! y5 v" v" ^# F( O) ?
  2444.   end3 |+ V8 P% F& w7 D. c
  2445.   def mouse_in_area(ox, oy, width, height)( H7 `) ]4 o: e1 Q7 ~4 Q6 @8 a& J
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    4 a6 v1 y* a& G3 h) S1 V3 w) o
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    3 k6 @; t3 `& a+ h7 _' `0 _
  2448.   end
    5 M. c3 Y1 M& b% V! u
  2449. end. q) q0 }) y0 ^( J# }  ]& K6 x& R. W
  2450. class Game_Interpreter
    % \7 |, J. h* l7 \9 {. \% Z
  2451.   def area_response(arg)8 e, t" m( A# _7 k
  2452.     $area_responses.push(Area_Response.new(arg))3 J2 G" E/ ^! `8 D: P* _
  2453.   end
    8 ]# [: _8 j4 M
  2454. end
    $ V5 h$ i7 r- q9 K  |- W2 g
复制代码

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

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

GMT+8, 2026-6-5 09:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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