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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================" V7 A6 t( @$ x/ U
  2.   W+ w6 _4 m( d2 @
  3.   Sion Mouse System v1.3e; g  c; \: W$ }6 ^
  4.   5 l0 w) R( h, R) ^0 l, z
  5.   Changlog7 L/ U7 c: n0 @; F) `) P
  6.   
    " W7 ~% N0 H: c* |8 K
  7.   2013.4.21 v1.3f) h" K9 T# x6 n3 k
  8.     / p  r- X, k) T* G; Y1 b/ P
  9.     1.3f 卷动地图 bug 修正
    / z& P9 @0 e* S% e* J" x! O
  10.     6 t+ k( Y5 [* j; \. B
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口# f* T5 r5 P& T& z- ^
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内% h5 I8 i6 x+ X" t8 E
  13.                               Mouse.unlock_mouse_in_screen 解除锁定5 o( J  A; Y9 k) J8 g) _/ Z7 g2 [

  14. ; L; H% {& v% N4 h7 t7 e, d
  15.     1.3f bug修正
      Y( j, ^) ?% \" a3 r/ `
  16.   
    9 X3 D1 K$ s" P
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    ' v+ x) l) D8 t* u
  18.           关闭菜单时,鼠标是否移动到原来的位置。. l. V& |0 ~9 Z8 n6 w! H
  19. ) F: e' f0 M0 d7 v8 Y6 y
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处7 J3 t' F0 P" r/ {* D
  21. " Q  Q6 F' }* B
  22.     1.3b 修正一些罕见的bug;
      g9 L) ?. {/ ?/ Y4 c  d, t5 Y* L
  23.   N1 k! S# f, @
  24.     1.3a 代码小修改;
    8 Z7 t3 O2 s1 |
  25.           加入了鼠标点击启动事件的功能,
    8 G, k' y- k% r* L! k) x
  26.           在事件中加入“注释”: 鼠标启动  ,
    : |4 w0 {5 [- W: G
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。0 |+ R! ]7 L! \4 C5 t/ e7 n
  28.   * y# e+ c# J/ V# j2 c! N& L: W
  29.   2013.2.12 v1.22 E/ j' `' x0 L  @
  30. 0 f+ H' h4 w5 [' u
  31.     寻路逻辑优化;
    2 F' b6 ?; L9 J! c
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    1 {9 X; W, r# u9 d& A
  33.     现在支持用鼠标来操作载具了。
    1 E5 a* u; l6 \! P$ {" d5 I, E! ~

  34. ! K  A' o0 V0 n9 I
  35.   2013.2.8 v1.1( h4 Q" A( K  i2 g' |
  36. " B" P7 v: T# g( r
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    9 `7 Q* A3 ~* a1 k; b2 ~( m: c
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    4 ]/ C0 z+ w5 w5 l' y: R2 m3 T2 h
  39.     移动时,路径指示点的绘制更加稳定;/ b5 |% v; `+ L6 t  {
  40.     现在支持默认存档画面的鼠标操作了。6 {& s) S1 s6 l+ u
  41. , ^6 C8 L4 l+ K9 U. @  ?6 u

  42. ; z4 `# \& l3 x, U
  43.   OrigenVersion
    4 ]- ?  T) C$ q- L
  44.   
    5 |- ~3 _) }5 l3 B7 H( M
  45.     2013.2.7 v1.0 . p" i; ^( i0 D# ^
  46. 9 [' ~, s# N$ T/ u0 z+ i8 {, d
  47.   主要功能) M+ v/ f6 D: P$ y4 Z: _3 v+ Z7 _$ \
  48. ! ^( k4 Y2 g0 [: |' e3 o; s
  49.       使用鼠标进行各种操作...! i' d# E2 k, E0 d6 d
  50.       将鼠标锁定在游戏窗口内2 C+ Q" ^  X3 P  `9 d
  51.       自动寻路,按住 D 键可以扩大寻路的范围2 ^1 j' k: ]9 I
  52.       双击鼠标进行冲刺
    ( F8 f* y* A2 ^' u5 e- O9 P
  53.       更改地图卷动方式以适应鼠标移动
    8 {9 Q& A9 F! [- m
  54.       变量输入框改良) l" E2 `% K% e8 U) B8 a
  55. . e3 U' W2 d* X9 f+ s- X6 \% L" r
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    0 n( _7 [! y8 t

  57. 0 R5 Z* C& R+ V& z- ~6 q
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹$ J- o# V4 F, P9 g
  59. 4 w7 l# S9 u( O6 K4 j
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭8 v+ |1 K5 ]. _
  61. ' S- G8 H* l4 s$ _- Z4 K
  62. * k7 q3 o# \/ B5 y- \. v8 |
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★/ I: ]8 O) v' \! Z0 q, j4 H

  64. 1 Z% B, T# Z) {

  65. 9 w/ o$ e5 F& G1 m
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    # S6 j# F$ X" |+ K6 @
  67. ! T% x! M* `% I3 I2 y) \
  68. #==============================================================================
    1 y3 L7 F" Q* n( P% F& b) O! o
  69. # ■ 常数设置
    7 m: D& `6 _7 r9 R6 c  t, ~
  70. #==============================================================================* t2 O" O1 d# T4 |$ f7 e3 e/ ^
  71. module KsOfSion0 V9 B) d- F( [: N" U
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    * x) D) j* P0 e* e# X
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    7 }! i' n2 M9 r( X( ~& T
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false  }( M  ?- `: v% m; l. O
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    5 h- k1 `1 L* z$ A' r
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    * d7 p0 G; K' b' i5 y; P
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    ' h/ y9 l3 }4 C) D+ x
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    - J2 H$ Y4 P! z4 m" `
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    7 e* |( F! j# V! c' Q$ n  C6 M
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
      t/ u( J0 z2 Y% L
  81. end
    9 C5 Q- K, W' M2 b

  82. ! Q6 n7 L+ `& n) w& A
  83. #==============================================================================
    ( ]  k+ p4 V) _7 t( C0 j+ H
  84. # ■ 用来显示路径点的类0 P3 f8 v" p9 h" Y
  85. #==============================================================================
    % f  ]  k5 r6 G+ o; V5 H  m
  86. class Move_Sign  Game_Character
    3 z( C8 t6 E1 |+ Q0 P" J. L
  87.   #--------------------------------------------------------------------------4 \* C( u- W+ `  c2 h* Z
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    0 Q0 P# P( {4 y, \4 q
  89.   #--------------------------------------------------------------------------
    : q! a4 e$ i/ v2 o
  90.   def init_public_members3 c* y6 ]# w  s4 y) N/ m# |
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹. ^9 e) n! n. @7 x* p  ~
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0- o- h  P/ H5 O4 R& _9 ]4 U( c
  93.     @move_speed      = 5        # ★ 踏步速度' G2 ]9 Q, C1 @( D; ^) }+ V+ u
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)6 q; v; i/ j7 D% X. [, q+ @
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    : \1 g- n0 d" H+ C0 G, w+ B: H
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)9 E- ~0 Z& A* h' l# g
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
      M1 l, P- F( j; p/ G
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    0 O% h( H: @4 N( l8 `) _% d$ k( W

  99. ( Y- \& j" `- f0 H# O
  100. 4 o# V$ G) l- ^
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    1 [; N( w7 w6 w- ~3 y, P2 y
  102. : B# c- w: f( k+ ~
  103. , T+ k5 w7 b9 n! y& C; G8 G
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图' D- d/ c1 m1 d, Y! y
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    2 f1 Z: z$ ~! f+ P
  106. * k! ^# B0 Y$ C7 p
  107.       if $no_arrowpic_warn
    ( b- {: N% L9 w, `" D( b7 }
  108.         MouseShow_Cursor.call(1)
    6 J- k  r9 n! E+ r' s
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    ' o9 [# }( `, }* F
  110. " Y9 G; G; C! l- C5 g: x
  111. “路径指示点”将使用游戏自带图片. W/ d8 n: q1 I0 w$ M

  112. * b2 l' H0 h/ G/ f+ P
  113. 该提示可以在脚本内关闭')8 D6 [5 ?1 J/ c* k! m1 k# u5 u
  114.         MouseShow_Cursor.call(0)
    1 v" f$ O( a1 F4 ?. V
  115.         $no_arrowpic_warn = false
    5 p) C0 u; h, ]" F% D7 ]
  116.       end
    6 i9 g4 C, k0 k& ]# T/ ~: `
  117.       @character_name  = '!Flame'+ i9 |' J0 [" g# S$ L2 Z" c8 C
  118.       @character_index = 6; Q1 j" f& y- {# |
  119. & Z4 k0 W: u1 _' I3 s7 ]/ U
  120.     end
    0 y6 f! j6 B( e2 `* o
  121.     @direction_fix = false  # 固定朝向
    - n$ L  f; W3 W6 a
  122.     @move_frequency = 6     # 移动频率
    1 U3 I) P* w) p+ G3 t: n
  123.     @walk_anime = true      # 步行动画! K1 [! k9 k! u
  124.     @pattern = 1            # 图案1 p. X8 v! g" M2 `6 m6 d5 m
  125.     @through = true         # 穿透
    . U' H/ z/ F2 Z$ j' e3 b" q) \
  126.     @bush_depth = 0         # 草木深度+ {6 Z3 A- R4 Y; s4 B# G7 D1 z
  127.     @animation_id = 0       # 动画 ID
    " u) }( ]% i$ _
  128.     @balloon_id = 0         # 心情 ID( p! p4 E, w( U; u* o; F/ G5 K
  129.     @transparent = true     # 透明9 c8 c, n8 ?! w: i9 I- }
  130.     @id = 0
    ( X/ s! r2 C2 U& {, @
  131.     @x = 09 Q0 R2 w4 \# m* q3 Y
  132.     @y = 00 {. ]5 m' v/ E0 F2 }4 e6 M
  133.     @real_x = 0
    0 O! ]2 Y8 ]1 H7 y9 ]2 r
  134.     @real_y = 0
    1 K% ]/ @# E* s& P' O
  135.     @tile_id = 0
    4 q; f: B" C  O( F. x; Z
  136.   end, f$ W0 l0 l8 L0 G. B
  137.   #--------------------------------------------------------------------------& H) F# y# U9 Q" X
  138.   # ● 定义实例变量+ G9 j# b9 m6 {. ^) H
  139.   #--------------------------------------------------------------------------
    4 s# u! ?8 E( z& M+ R9 g
  140.   attr_accessor direction
    3 X- X; J2 {& x( Q& d3 ^$ u2 P4 e
  141. end
    / \( s4 [# Z3 O6 |7 i2 Q' N4 L, [) g

  142. % P  I* x- X) Z" I  K
  143. #==============================================================================' _5 K7 ~/ x6 {% y7 J3 {6 p7 w
  144. # ■ Module Mouse
    / P; X( w, M, N5 F. i) |& d$ [9 G. j
  145. #==============================================================================0 V, c" I; t4 k7 M9 u# t2 j
  146. module Mouse
    ! T, g# R. Y; w/ }5 w4 l6 E' m
  147.   #--------------------------------------------------------------------------' _9 q" u$ I& q) {/ k: t9 g' A
  148.   # ● API
    8 C% P" E( n1 @1 m1 r2 H
  149.   #--------------------------------------------------------------------------5 Q1 R" P& m; L+ p* N, a
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    ) |3 e- \% N6 S( w
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    - L$ n# H% r5 T- n6 s/ b6 z  F- t
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l'): a6 ]& n( A: K" q
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    + l2 G1 d: F( v9 w! e; J6 \
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')% L' r; K9 y$ k" T
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')2 P2 g+ C1 X9 M# s- @
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    5 P$ d3 r- _; [8 l" l
  157.   Window_Hwnd       = Get_Active_Window.call
    7 f0 t8 e+ V4 \/ Z' P( W8 G4 X
  158. 9 j: f, G' f3 Y  [& @% B
  159. class  self  ^5 L' D& Z* C8 |1 x4 H4 o: \
  160.   #--------------------------------------------------------------------------& Y3 o9 g6 E" q- M& K2 a9 D5 E
  161.   # ● 初始化
    3 h  T+ _( ]4 m5 [' r* j) ]6 _
  162.   #--------------------------------------------------------------------------! q* E+ E' b- J0 Z( v8 P
  163.   def init1 z; ^* Y9 X+ B
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor/ I) o3 j( E' ^; x! X; Q
  165.     @left_state = 0( ?# ^0 m: G9 }6 X2 Q) I& C3 y
  166.     @right_state = 0+ M/ Y$ }- z, |
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    0 l' i3 `2 ]& w( E# M1 M) D
  168.     @dk_count = 0 # 用于双击的判定% X$ b4 D# L. R. o& \
  169.     @clicked = false, X- V- i/ B; }4 t. d3 S
  170.     creat_mouse_sprite9 u: V& H- O2 o+ @
  171.     update1 p2 A' y( ~- J( {
  172.   end
    $ |+ A; A! C# a% L3 Y) T# D: B
  173.   #--------------------------------------------------------------------------
    2 X$ D/ ~  }- [$ o# V7 L+ U, ^
  174.   # ● 鼠标指针精灵4 }  e1 v" i6 {
  175.   #--------------------------------------------------------------------------
    - y( i2 W' m  t7 J
  176. #~   def creat_mouse_sprite
    $ G5 Z- L  Q' \0 w
  177. #~     1 p$ b" x5 I# F2 u
  178. #~       @mouse_sprite = Sprite.new
    7 V- P1 }  a7 f2 r7 I6 \. |
  179. #~       panda = 2#rand(2)+11 _" {6 k8 ^8 g/ I1 b1 X/ c  \
  180. 8 P& m  P5 L; n3 D4 C( g9 w+ t
  181. #~      if panda = 1- ^  o* H; Z! h, V6 o/ a
  182. #~        if File.exist('GraphicsSystemCursor2.png')! j+ v6 N3 i, V, g" h
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    4 g4 N2 _) v" h& [0 _% A
  184. #~        end#with if File.exist1 E) T3 s3 i: M) y1 X! y" {- W2 m
  185. #~   
    1 L+ Y/ D8 `8 z, O! @2 l/ z0 b2 I
  186. #~     else if panda = 2 #with if panda=1
    7 ?0 P9 ^; L, R8 k: S# v/ D' v3 W
  187. #~      ( @" ~. ?  v0 f- [9 q
  188. #~      if File.exist('GraphicsSystemCursor2.png')2 n& J6 n8 C% {4 l
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2'), r9 }1 y* [+ z
  190. #~      end#with if File.exist
    : }1 n, U& x2 S5 T, f8 o
  191. #~      
    ( L5 T1 u/ S5 l0 G1 [
  192. #~     else #with if panda=13 c, Y+ n; q4 G( U: E) y- U1 U6 Q
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    ) W/ {- C9 e" @. V
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),& d  \6 o0 m0 [8 K
  195. #~       Rect.new(5  24, 24  24, 24, 24))' E) [, P* x$ j7 [1 O
  196. #~     end#with if panda=1
    ) I# ?! N3 U) r& R3 O5 c
  197. #~     
    7 ?& S+ S$ B. w9 E" {- a- @
  198. #~     #with def
    1 n! K" N3 Z/ @0 i
  199. #~   end: R! p0 g0 \, V* J
  200. def creat_mouse_sprite' u' k  `9 q/ B( X( N, r9 c
  201.     @mouse_sprite = Sprite.new
    % T9 M& V% o  o
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})2 Q2 R) h) S7 ?
  203.     @mouse_sprite.z = 9999
    8 K' S( q7 G9 J( I5 R
  204.     Show_Cursor.call(0)
    * o) w% H. f' B$ T+ [
  205. end  r! {7 ~$ T* }. u0 @2 _4 M
  206. ( D' m6 d* `5 t! b# ~. i) v  T4 J
  207.   #--------------------------------------------------------------------------
    ! L$ h+ H, H8 ^
  208.   # ● 更新
    5 i- C' o8 v  A- p3 h" c! j
  209.   #--------------------------------------------------------------------------
    ) U1 d, w5 s: K6 {9 z( Q
  210.   def update) w5 R: [! ?2 \, v, T# O
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    * K& x9 ]8 D, f0 k! [: o/ y! T
  212.     left_state  = Get_Key_State.call(0x01)
    $ n" K& _5 J) e  C: X! ^& S8 S
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0& T5 i" G  U) `+ p/ B  y' U3 ^
  214.     right_state = Get_Key_State.call(0x02)8 Q6 A- Q) e% u" r
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    7 c% Z$ P# ~4 ^# ^9 z" I1 [! D
  216.     update_double_click% Q' o1 ^; m5 j: H! U
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1, \4 `! C  u# Y' H5 F' s% r
  218.   end, R5 R* O5 o% `' O
  219.   #--------------------------------------------------------------------------
    4 b6 G- h* f) F% Q
  220.   # ● 获取鼠标坐标
    " N- ^, b, C$ f6 D& a2 W1 p( B  L5 S
  221.   #--------------------------------------------------------------------------
      A  K7 K2 V* j0 n9 i' V, Y5 D6 L
  222.   def get_mouse_pos
    . q- o3 U5 h5 Q1 b
  223.     arg = [0, 0].pack('ll')
    $ }9 h  E. i; I
  224.     Get_Cursor_Pos.call(arg)
    , K- ^8 t. v" I) R  h
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    ; D0 ]* N$ f5 o3 W. T/ x+ ~
  226.     x, y = arg.unpack('ll')! {9 M' }4 ?! `' e9 H
  227.     return x, y
    " N4 n. T4 a: V! m
  228.   end
    8 U# C3 O7 b0 E
  229.   #--------------------------------------------------------------------------: L; s1 ^; K7 {. j) F" q2 S' z, g
  230.   # ● 将鼠标固定在屏幕内& P% U! R8 c  ?# t# F: h
  231.   #--------------------------------------------------------------------------
    + m, L* p0 |) B0 K( V  P+ V
  232.   def lock_mouse_in_screen
    2 _  j+ P0 u$ P" c5 T
  233.     arg = [0, 0].pack('ll')) N6 r$ X; T8 `- t  H6 h
  234.     Screen_To_Client.call(Window_Hwnd, arg)" b- \! ^. y3 S0 Y/ O  S; r2 f% A
  235.     x, y  = arg.unpack('ll')
    & e; `9 W! |& ~/ A0 z) W
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    * V4 U, F; w7 I) }5 k; i: Y* n+ f
  237.   end% s8 X9 c1 l( c
  238.   #--------------------------------------------------------------------------
    3 A6 X8 y) H( N' }
  239.   # ● 解除鼠标固定! P, I. t8 v- a; r& E+ `
  240.   #--------------------------------------------------------------------------
    9 N- K: L/ s6 N( D. n$ }! _
  241.   def unlock_mouse_in_screen
    " H; F# |' t( Y' G$ p
  242.     Clip_Cursor.call(0)
    , n1 b" L- p' {8 L+ O" k
  243.   end
    3 ^6 K2 V' ^! W8 f' L
  244.   #--------------------------------------------------------------------------
    " d# U  A+ ~  q) X. `3 }" k7 ]/ Q, w
  245.   # ● 鼠标双击判定
    ( T4 x$ Z- r' d4 O1 G: E0 S5 K4 z
  246.   #--------------------------------------------------------------------------
    . f2 P2 C  N8 \, O  e5 U
  247.   def update_double_click2 S9 x9 u/ f5 p4 ?. v, J7 }7 O7 F
  248.     @clicked = true if @left_state == 1  {6 y2 ?! e/ L* j3 F5 p
  249.     if @dk_count  0 && @left_state == 1
    9 l6 D2 n7 R- C9 B/ l% n4 O6 h
  250.       @dk_count = 0; @clicked = false( v4 F2 A, Y- H" I( m2 Q) S9 Z
  251.       return @double_click = true! X# q- f  d$ G# b
  252.     elsif @clicked4 H6 _4 K1 U6 ~
  253.       if @dk_count  KsOfSionDbclick_Frame
    8 V* E' [: }) [" W1 e7 }
  254.         @dk_count += 1
    7 m  ^6 k" O& o8 M5 c. H1 c; a2 J
  255.       else; V! U  u1 m1 u8 r5 J* K3 M' r# j
  256.         @dk_count = 0; @clicked = false
    / ^  m: W+ T9 P( w, L* U! k# Q
  257.       end
    1 D$ K: H" G  \
  258.     end
    7 L/ J, a6 i; T: r
  259.     @double_click = false& F4 ~0 V( T2 \; R8 ^5 H! z
  260.   end$ {$ D( k+ C6 G
  261.   #--------------------------------------------------------------------------3 |9 P1 f/ e+ B. ~' F& D
  262.   # ● 按键被按下就返回true: ]$ Y" t0 e4 T+ J
  263.   #--------------------------------------------------------------------------
    ; u; A* {0 C& w5 Z4 W" }
  264.   def press(button)' p( W/ B, q$ ^. V
  265.     case button
    ) \  M2 A+ I: s9 H
  266.       when 0x01; return !@left_state.zero$ S1 n9 {- y2 h1 J
  267.       when 0x02; return !@right_state.zero
    2 Y) }7 [  I/ }7 m7 r' v8 c5 m
  268.     end
    5 ?$ X  s7 V; H' X8 T) d# }0 L
  269.     return false' z+ h/ \6 S4 F0 X  f# J2 N% K( g
  270.   end
    ' ]0 B1 ^  _# W! G+ W, F/ A
  271.   #--------------------------------------------------------------------------
    ; D6 U' {8 {* N* c
  272.   # ● 按键刚被按下则返回true1 U# K1 T3 G8 R5 S2 v. C; n4 Y
  273.   #--------------------------------------------------------------------------/ r/ @. U9 e9 O
  274.   def trigger(button)5 l% R& M0 g: g/ s' L# w4 T
  275.     case button
    5 H7 H( I2 K# m5 U7 ^, w: m7 w
  276.       when 0x01; return @left_state == 1
    % Z8 P1 e* G& K: \0 T; n
  277.       when 0x02; return @right_state == 1; d' g8 S% r9 ?; e" @6 J  r# C
  278.     end6 i9 I) Y3 [- q' ~+ U
  279.     return false
    ! X7 }9 n1 S4 W2 {9 Y
  280.   end
    1 j3 C- m# q7 t. q, g$ d7 q- x
  281.   #--------------------------------------------------------------------------( R- @  ]4 f8 @
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    $ g, O% g. v" v% T! M$ L6 @
  283.   #--------------------------------------------------------------------------1 k/ P  D+ T" ]5 u) h; o" z' V" z
  284.   def repeat(button)9 Q7 C4 B* T" B
  285.     case button! Z2 _5 r* e% n( G: u& g
  286.       when 0x01; return @left_state == 1
    . X" W( \# o- S5 Z! v
  287.         (@left_state  22 && (@left_state % 6).zero)* R; V' H2 T! `/ }+ i" D
  288.       when 0x02; return @right_state == 1
    0 i3 _, H# W; s* w
  289.         (@right_state  22 && (@right_state % 6).zero)/ [9 `( S8 W9 r
  290.     end
    * {% R4 k4 H) _# v) B
  291.     return false
    5 Q( X8 @) |9 K( ~
  292.   end
    8 _1 G. \( s8 g2 y. `2 f
  293.   #--------------------------------------------------------------------------6 S1 m9 o  t, {& I7 L0 D+ c
  294.   # ● 判断是否双击鼠标2 n- x# o- q' B2 v  ]9 s; s
  295.   #--------------------------------------------------------------------------* H: q. }0 R; O1 X+ q9 G* C
  296.   def double_click
      ^* r5 Q/ X: q
  297.     @double_click
    3 y: S. A- q5 y
  298.   end
    # |6 @- r; K+ t+ t1 G
  299.   #--------------------------------------------------------------------------
    . M4 H5 ~- {. q9 S# \, F6 r& l
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    + O! N5 I* v, b) T! F: W
  301.   #--------------------------------------------------------------------------
    % v( [; G' l1 q% W3 @! x. G
  302.   def click_count
    ) s9 \1 F7 g8 {& z9 ?/ g" k$ ]: a
  303.     @ck_count
      M- z# ~8 g& }0 l
  304.   end& F# ~! l; O3 p2 V! ~; w" A
  305.   #--------------------------------------------------------------------------3 z0 i4 T+ b9 O% q  }
  306.   # ● 获取@left_state(按住左键每一帧+=1)8 F. p$ s7 Z4 E$ w' a& S
  307.   #--------------------------------------------------------------------------, n& N# ~) c' j$ O, X9 }
  308.   def left_state" [& S7 I/ I+ B# J* P1 _  F& J+ c
  309.     @left_state0 d( d" q- d9 f6 e5 ]& k
  310.   end
    * q( k  N. V% L+ K5 D: W4 Q
  311.   #--------------------------------------------------------------------------
    - O7 l8 V* _5 `/ I3 ]% C# H
  312.   # ● 获取鼠标的x坐标; w6 m8 b7 Q9 w9 D
  313.   #--------------------------------------------------------------------------
    4 Q+ O2 j% p* t0 A& d, F; q: G
  314.   def mouse_x" g7 t3 H# y; C/ ~7 }
  315.     @mouse_sprite.x' u( \5 r4 s0 F1 r) d$ J. h: f+ s: X
  316.   end
      g/ m! ]3 J$ H" y$ S
  317.   #--------------------------------------------------------------------------
    - K0 y5 V2 V3 J( J$ f/ b( [5 C( ~
  318.   # ● 获取鼠标的y坐标% O$ I9 n2 s9 V0 \! F  v/ i
  319.   #--------------------------------------------------------------------------
    8 Q% o& Y( K/ v2 W) r  G
  320.   def mouse_y
    2 V. W+ R( |/ T& g* m
  321.     @mouse_sprite.y
    ( V" g" a  g. [2 G, b* ^* b
  322.   end& Y0 L& d: |$ a( l; [0 |) d
  323.   #--------------------------------------------------------------------------
    & {4 a8 y4 e2 q! k6 W" W
  324.   # ● 设置鼠标坐标) s( w5 i3 k# B; ?3 f- j8 B
  325.   #--------------------------------------------------------------------------
    " Z3 W# r, G1 L: h, i& ^
  326.   def set_mouse_pos(new_x, new_y)
    9 j) G- \1 w, |
  327.     arg = [0, 0].pack('ll')- J9 T5 o5 B, _1 S4 q2 o% S; u
  328.     Screen_To_Client.call(Window_Hwnd, arg)* i! [- O: Q  h7 g* v- r2 P4 |
  329.     x, y  = arg.unpack('ll')
    # y  C. I! d: D+ r0 i; U2 `
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    * t: T9 c" h* U- t5 K, H
  331.   end
    $ \  `* N5 k4 o5 D; E+ u) Y2 h1 o
  332. end #end of class  self ) P+ R# W# G5 ~8 O& N

  333. ; h) e, D* T, M* q+ i9 q9 i
  334. end
    2 ^& e6 n: H6 k6 y

  335. ! n* T4 e4 R6 [# W) g
  336. #==============================================================================
      Q. ?! Y& `! r: t) k/ g7 v& L
  337. # ■ SceneManager
    9 y0 h& s$ ]/ ?2 E8 s- o8 D1 b
  338. #==============================================================================
    6 Z" i9 G% o5 R: e  I
  339. class  SceneManager
    / z; ]% d4 Z9 W5 r& i# U" ^  w9 u3 \
  340.   #--------------------------------------------------------------------------
    ; U2 I0 _' Y- v
  341.   # ● alias5 P4 V- n8 e4 F% c- c$ i1 ^% X
  342.   #--------------------------------------------------------------------------
    7 K! Q  g" |( [7 [7 ~2 G
  343.   unless self.method_defined(sion_mouse_run)
    : m, Y* @6 F5 |4 L/ K7 Z- U; d6 G3 P
  344.     alias_method sion_mouse_run, run4 Z4 [6 w+ u9 T" B1 L% D4 B7 o! N1 J
  345.     alias_method sion_mouse_call, call) P9 m# N3 ]8 z/ s+ e
  346.     alias_method sion_mouse_return, return
    8 X( [2 n6 W8 l* F
  347.   end' h. `0 R  ~9 g5 n% F% @
  348.   #--------------------------------------------------------------------------5 A: M" m0 i- X: z
  349.   # ● 运行6 D% \$ @8 F! z7 ?( f6 _3 Y
  350.   #--------------------------------------------------------------------------% D% A3 s  P9 s$ a% @0 z
  351.   def run7 F! c, R* L6 {+ G" \8 _
  352.     Mouse.init
    # O7 B1 ^+ @$ M
  353.     sion_mouse_run! O) L' Z; w( H8 ?4 @+ S. M
  354.   end
    7 |  P- H: O# g! h
  355.   #--------------------------------------------------------------------------0 I- c+ I' q1 v4 s; W/ n0 O
  356.   # ● 切换
    + I- ~+ K  ~+ z  _) R+ L
  357.   #--------------------------------------------------------------------------
    4 {( _7 ?$ s+ H" b& \
  358.   def call(scene_class)
    ) l: g5 B  g$ k1 w# _
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)6 p# _# O; k3 p! T
  360.     sion_mouse_call(scene_class)
    ) i/ f: {* E1 e- M& s$ Y( N+ N+ q
  361.   end
    ) f2 O+ d4 A0 [! R9 Z' L
  362.   #--------------------------------------------------------------------------
      T" i& n# g5 r( z, S2 @4 Z8 {
  363.   # ● 返回到上一个场景1 j9 W* L; T5 M; q2 Q/ v
  364.   #--------------------------------------------------------------------------
    . K9 q! ^) R4 r& `$ h" M
  365.   def return
    5 g' f* l* d( D; }" }7 i
  366.     sion_mouse_return
    3 Q4 K9 |% I" Z" b6 S$ w
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&. e1 E3 ?' C6 t, k
  368.       @scene.instance_of(Scene_Map)1 g% Y- W0 y7 P8 S( U2 Z+ e. @
  369.   end: W1 j4 U  t; j: t1 c
  370. end; n) C8 f1 N& U
  371. 4 ~. z6 \; A, T# E3 {. K0 U1 P
  372. #==============================================================================( i1 O! ]% g; Y* W+ ~: X
  373. # ■ Module Input
    ' U& `! O4 m/ s7 ?6 o9 L1 h
  374. #==============================================================================
    0 k5 A8 F: f" y
  375. class  Input' W$ h# }" m" h' g' g4 p
  376.   #--------------------------------------------------------------------------4 r0 H9 G3 k7 v" o
  377.   # ● alias0 ~- R& i& q# L
  378.   #--------------------------------------------------------------------------
    * O/ Y9 d8 O7 D9 V( o1 T* q8 Y7 r: a8 `
  379.   unless self.method_defined(sion_mouse_update)
    . B) G6 ~8 |* {# S
  380.     alias_method sion_mouse_update,   update
    % o' ?. B* R( |' Y# P, @
  381.     alias_method sion_mouse_press,   press
    " v8 V9 L# P+ d/ O' I
  382.     alias_method sion_mouse_trigger, trigger! ^) g! u' g( Q  D, x: S+ T
  383.     alias_method sion_mouse_repeat,  repeat
    6 r4 l! o5 g" b6 J0 y: }, M8 i7 f
  384.   end) |& H% v1 E/ m* J% s" \7 b
  385.   #--------------------------------------------------------------------------
    : b  `* B2 t9 ?9 n
  386.   # ● 更新鼠标6 k- y8 C' Z" W* N1 D
  387.   #--------------------------------------------------------------------------+ Q9 h, f2 f+ \
  388.   def update
    - l7 i( S4 a- ~/ x1 ]2 }
  389.     Mouse.update
    : l8 `- I3 V7 _# w5 [( k" Q7 r
  390.     sion_mouse_update
    5 i4 r" X* ?1 b3 D0 i+ T1 x, Q
  391.   end
    8 I$ j7 F2 }1 U: E6 [- o5 w
  392.   #--------------------------------------------------------------------------
    . Y% I  M) d' f& F  d: g
  393.   # ● 按键被按下就返回true
    # p. ?  e" o! ]; z0 X9 J
  394.   #--------------------------------------------------------------------------
    ; b' [5 @  h& q7 K/ r% V& {$ S' q
  395.   def press(key)6 O+ P' z* @* g
  396.     return true if sion_mouse_press(key)' k' g0 M: j/ \' V: w/ V9 @
  397.     return Mouse.press(0x01) if key == C) B# Q8 T0 C6 v  {
  398.     return Mouse.press(0x02) if key == B
    6 A: m6 W+ ^/ s9 @5 Z$ ^- j; z( A
  399.     return false
      P3 t- l" P# V- u. x  K  _
  400.   end( O4 t7 x$ u2 G% D3 D
  401.   #--------------------------------------------------------------------------
    " \$ J* q, E3 M, s) \9 \
  402.   # ● 按键刚被按下则返回true: Z, F' K; V1 k# y! h+ e; l6 G
  403.   #--------------------------------------------------------------------------6 O; ^" n& Q0 B7 p
  404.   def trigger(key)& Q6 e0 f8 e0 E8 h. K8 O# o8 Q9 U
  405.     return true if sion_mouse_trigger(key)
    ' d, B; z0 J* L' S+ n7 s* Z
  406.     return Mouse.trigger(0x01) if key == C' |* w. {. q3 _2 ~: a
  407.     return Mouse.trigger(0x02) if key == B1 n3 a( c* S8 C6 S* m+ p: u+ P
  408.     return false
    $ \) W3 O: }7 [5 w& i
  409.   end1 P/ X; f" [& y, M1 u  r1 S( K
  410.   #--------------------------------------------------------------------------
    " {/ c7 }9 ?. q; D7 ^1 Q
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true, h6 T" B9 k6 S/ B
  412.   #--------------------------------------------------------------------------) H4 x8 j& E! E# e- A7 m4 N
  413.   def repeat(key)0 G4 H) N8 ]* p' h: r9 R! G
  414.     return true if sion_mouse_repeat(key)8 s+ b* w. o* Y4 U; O' N. W
  415.     return Mouse.repeat(0x01) if key == C5 o& B& L5 W9 O7 D( k% N
  416.     return Mouse.repeat(0x02) if key == B1 c" `5 ?5 O$ Y1 f* u4 W
  417.     return false
    7 ?% a* P: Q6 R. Y0 x  O
  418.   end
    , f3 h/ v8 d7 i6 u, {6 I; W0 {% \* s5 q/ f0 d
  419. end. P/ T; }+ r; r$ _
  420. 1 B* |% h, x  o+ j5 L+ f

  421. 5 q8 s) T. M% q9 f3 X0 Z3 w
  422. #==============================================================================
    8 \; k- h( J& H* i; O! b$ H
  423. # ■ Window_Selectable
    * [0 ^  F4 f# \- f" |
  424. #------------------------------------------------------------------------------! K( z3 |, }  ]  |" z
  425. #  拥有光标移动、滚动功能的窗口! _: ?; f# V# c4 P9 H
  426. #==============================================================================4 c. d  G- o2 g: q" B
  427. class Window_Selectable
    1 J1 s; k, z- S) Y8 _) Z
  428.   #--------------------------------------------------------------------------; i! q% P8 B) r
  429.   # ● 初始化
    . [2 M5 C6 w0 e4 F
  430.   #--------------------------------------------------------------------------
    * H" y0 `  b/ q" ~) e( t
  431.   alias sion_mouse_initialize initialize4 e& A/ q4 t  Y9 l/ C, X
  432.   def initialize(x, y, width, height)5 P1 T) s1 n, y& m4 n
  433.     sion_mouse_initialize(x, y, width, height)
      y' D3 A# S: p7 {; \
  434.     @move_state = 0
    ' Q; U- H) f9 C' M& D$ m5 _
  435.   end) i9 x6 {4 k4 b
  436.   #--------------------------------------------------------------------------
    * h2 r& |; W$ U3 J" s& L. c" E
  437.   # ● 更新  `* L- s$ {8 t- A/ c/ V$ j) S
  438.   #--------------------------------------------------------------------------
    ( `# A1 r# |- z1 \9 s7 ]
  439.   alias sion_mouse_update update$ I# x/ Z9 O0 a( w
  440.   def update8 C( F- l" W. V+ ~6 F
  441.     sion_mouse_update
    - P4 S9 x: N. K! ]/ v
  442.     update_mouse_cursor
    9 X8 L6 c! x8 k# V$ N7 k& x2 k7 A
  443.   end1 H  X% U1 Y- D1 p6 t; [
  444.   #--------------------------------------------------------------------------
    4 R% b4 i$ Z+ w4 T$ T7 p
  445.   # ● 启动后设置鼠标到index位置  N9 [1 i7 {5 j
  446.   #--------------------------------------------------------------------------7 i' m7 f; v$ x3 C/ d0 a
  447.   def activate
    , t; H  C( E2 a. Z/ s- e! V
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos& r$ ^5 r6 n7 }& J3 R
  449.     super! C. k( s" w5 f3 `1 R
  450.   end# G' O' o/ k8 T' z
  451.   #--------------------------------------------------------------------------
    3 t0 c0 N4 ]0 z# T: E" m2 A  C. r
  452.   # ● 更新鼠标和光标的位置
    2 r8 b+ g# K$ U' N( f+ x, g
  453.   #--------------------------------------------------------------------------+ n! [3 p8 J+ ]# H6 q( I
  454.   def update_mouse_cursor
    + b/ ~1 Y( B2 l( Y4 x
  455.     if active
    $ T% o; M. ]$ V1 o" L% V
  456.       if @need_set_pos" B  r  Q! t" E6 G! x
  457.         @need_set_pos = nil
    ) r' T' B0 c' ^2 h
  458.         set_mouse_pos+ _" z0 s2 N$ V! d1 s* p3 Y3 ~
  459.       elsif cursor_movable; F/ C" R1 w4 O2 ?
  460.         Input.dir4.zero  set_cursor  set_mouse_pos" P6 {2 q) O/ u5 |5 P0 M8 ~
  461.       end) [9 S( M$ O( z
  462.     end7 r' F! U9 P3 p% n
  463.   end2 d. P; J2 E6 j/ F$ X0 B* Q- J5 x
  464.   #--------------------------------------------------------------------------
    + N7 u6 C9 Z+ B; P9 d
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    0 Y7 J3 x/ d0 I+ Y5 Z) S' ~" ^
  466.   #--------------------------------------------------------------------------$ o" a) Y. Y4 v6 r( P: k0 _- R
  467.   def set_cursor( i" @3 p4 G0 Z, G7 Q( f
  468.     mouse_row, mouse_col = mouse_window_area5 ]  X, I  C* M- {+ N, o! y
  469.     if    mouse_row == -14 k+ C! f: ?: O& R
  470.       @move_state += 1 if need_scroll
    9 I. I# i; ?+ F* g
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    * y3 H4 t7 J% |+ ^( N/ S0 e( {! f
  472.     elsif mouse_row == -2; E( t+ @  p# e" o
  473.       @move_state += 1 if need_scroll
    ) |* {' _3 e/ {* H. m7 z
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    , B/ q5 H5 I* u2 s5 r( ^2 ?
  475.     elsif mouse_col == -1% a( K% O0 R# d3 ?0 z2 A
  476.       @move_state += 1 if need_scroll; I4 E; u. R* Q8 @% c, B& B
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    $ x5 w6 Q1 w% n3 T8 B$ v; U6 d
  478.     elsif mouse_col == -2
    7 n4 L, [8 j6 ~1 K( _  d' ?/ `$ T/ P( S
  479.       @move_state += 1 if need_scroll
    " a9 o! f; N7 T8 b" S% f' `/ D) v
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand- n* b, ~7 H7 O  n! G1 D
  481.     else; d9 g" u" ]7 a& ^$ W; b: Q
  482.       @move_state = 0
    % y: v/ e( _/ F; ^# g5 D8 B! K
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    - v  E) e# p1 ?. |3 b
  484.       select(new_index) if new_index  item_max && new_index != @index
    & O- X' U: f, N' b$ [- |
  485.     end
    & |3 \4 |) Q- ?4 N% Q; D
  486.   end+ B' N2 I2 t9 x' R( {& N
  487.   #--------------------------------------------------------------------------" S4 \+ m- e6 j- z# \* f# Z0 G
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    6 k( R2 F2 d" [6 o0 Z% x0 Q2 Y
  489.   #--------------------------------------------------------------------------6 S3 Y5 ~% ^$ d: v
  490.   def mouse_window_area
    : P$ M% K; }% H2 e
  491.     if viewport.nil # necessary!. C# N1 k% F5 U
  492.       vp_x, vp_y = 0, 0
      ?6 W/ ~+ x" U
  493.     else
    1 m0 m. T+ r  K, G( I( P9 ?
  494.       vp_x = viewport.rect.x - viewport.ox
      ~# ]* t* h% N8 Y9 ~1 L
  495.       vp_y = viewport.rect.y - viewport.oy. |% E7 q. b( O& [5 c
  496.     end
    ' G9 ^, m5 I2 e
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    5 F( m6 v% D9 W" ?  b& A
  498.     item_x1 = vp_x + x + standard_padding 5 _! J; {1 Y3 V' j5 s
  499.     item_y1 = vp_y + y + standard_padding1 d& Y$ P: v" V; u1 x
  500.     item_x2 = vp_x + x - standard_padding + width
    1 [6 @; j8 E! g5 c! q/ z4 C( h
  501.     item_y2 = vp_y + y - standard_padding + height
    ! @' y8 P$ |3 C
  502.     if mouse_x  item_x17 W  W) F! i+ D6 R, v5 w0 J' R& C3 q
  503.       mouse_col = -1
    ) q* H7 [( f" f7 _1 e5 K5 a$ f: c* z. \
  504.     elsif mouse_x  item_x2
    6 A8 h! |: I# m
  505.       mouse_col = -2
    - l! s- s6 F2 W# h8 _
  506.     else
    " E: @/ B" K# P8 l& X0 ~6 \
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    % w% t: h, Y. b8 g2 X
  508.     end
    ' ~2 b: i# x  X- E
  509.     if mouse_y  item_y1
    : N0 T+ |8 U8 v8 x+ s, t
  510.       mouse_row = -1- v; ~. Z/ T' d3 @% ~1 k5 u. O2 A% n
  511.     elsif mouse_y  item_y2" `0 U5 f+ z0 I1 }" L
  512.       mouse_row = -2
      G* i! d9 w/ ~1 X- ~) t
  513.     else
    ' S3 S' U4 [5 ^
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)0 P2 `6 e* i  I' {" C2 e
  515.     end
    % R/ n/ j5 J2 [/ f  p" f" O
  516.     return mouse_row, mouse_col
    & E. Q4 N$ Y- Y& s7 ?! b
  517.   end% q. h  M) y' C6 D4 m" f  k5 j' V
  518.   #--------------------------------------------------------------------------' h. P, K. p. j) A) p7 G; N& \
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置7 t' J" X. F" w& I- T5 ?
  520.   #--------------------------------------------------------------------------* g! c( w# p: t7 e4 V# q, x
  521.   def set_mouse_pos
    6 o8 I1 z3 s4 W8 T+ B
  522.     if viewport.nil # necessary!
    $ n; J# J$ x# X. `
  523.       vp_x, vp_y = 0, 0
    $ y7 s3 I1 Z7 D/ ]) w: I. L
  524.     else
      n; D8 Y7 p5 f$ B( t3 P
  525.       vp_x = viewport.rect.x - viewport.ox3 Q3 H$ y, [3 z( H/ c6 G* e: a
  526.       vp_y = viewport.rect.y - viewport.oy  h& {$ E; G7 G
  527.     end4 n! V5 G' v3 f
  528.     item_x1 = vp_x + x + standard_padding
      w6 n0 o3 H: K! p8 d: u
  529.     item_y1 = vp_y + y + standard_padding% h4 I# S6 d, b9 P6 }1 b$ B$ V
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index 1 L2 b6 F3 Y) N$ P0 p" P
  531.     row = get_index  col_max - top_row
    0 i+ S4 o( Y$ \
  532.     col = get_index % col_max
    3 H7 ~4 U5 h) I  n  e# \
  533.     new_x = item_x1 + item_width  (col + 0.5)/ L$ i% k  B4 c0 ~3 O5 D* n
  534.     new_y = item_y1 + item_height  (row + 0.5)
    ( ?) B* x: N1 p, p; ^
  535.     Mouse.set_mouse_pos(new_x, new_y)
    : }" C, o+ w" @, O0 A7 o
  536.   end. @- I- \  f. X  L) h9 E
  537.   #--------------------------------------------------------------------------6 M/ T/ ~" o& n1 [7 b+ u
  538.   # ● 判断菜单是否需要卷动
    % z2 ~7 e8 [% [3 z' k
  539.   #--------------------------------------------------------------------------/ q) y$ L8 M" n% M: l5 n# B
  540.   def need_scroll
    $ _7 S  J- ?+ n* _1 K* i
  541.     item_max  col_max  page_row_max' t- D" H1 {$ S
  542.   end
    9 K+ ]! U. m3 j6 W7 S0 B$ S
  543.   #--------------------------------------------------------------------------
    : k1 \8 `# q! X8 ~1 O: x
  544.   # ● 判断是否为水平卷动菜单  m& O& I7 B, w2 V5 Q, F  N
  545.   #--------------------------------------------------------------------------3 m6 S0 J5 }3 h) ?- x' z, W
  546.   def is_horzcommand6 ~. d/ F# U' Q1 X# M0 d
  547.     return false
    ; I/ U6 @, G0 A  ^8 L1 N
  548.   end
    4 B9 i+ B: S; C! _
  549. end/ {  Y9 q# u8 C) @, }7 e# c

  550. ( w3 |- ?* z* u% P
  551. class Window_HorzCommand  P4 V& y+ V* P0 q- o+ g- u
  552.   #--------------------------------------------------------------------------' X+ @: B" g! s; y
  553.   # ● 判断是否为水平卷动菜单) j& e' {; D  r  G
  554.   #--------------------------------------------------------------------------
    ' v. M( K2 S2 ]
  555.   def is_horzcommand
    / I" X+ B6 M5 F
  556.     return true
    7 ^1 M" V/ a, k2 X! C( n" u/ s" c; Y
  557.   end
    7 \0 h' E8 n/ y' R+ [
  558. end
    4 R4 V/ i3 F$ U# i9 J; X! m

  559. % Y+ W7 R. o$ e: O' o$ u5 L2 R6 W
  560. #==============================================================================
    5 s% m) t3 g5 o3 Y6 m" B! F- e
  561. # ■ Window_NameInput5 [+ l. u0 I+ S# r% `
  562. #------------------------------------------------------------------------------$ P* l; s: M  W) T) B
  563. #  名字输入画面中,选择文字的窗口。
    + W3 M4 E/ ~+ s
  564. #==============================================================================2 K& x4 ~& L+ M- D
  565. class Window_NameInput
    8 b+ l4 V3 R' r/ J- F
  566.   #--------------------------------------------------------------------------4 p8 V3 i; a. b5 R
  567.   # ● 设置列数
    ! L- p" c9 O+ s' W. i
  568.   #--------------------------------------------------------------------------
    & I* S+ a) ]; s3 \2 r- p; m0 F% K
  569.   def col_max5 F* C; G2 ]9 {) u6 o
  570.     return 10( |/ r. L( c! L4 r- L3 [
  571.   end
    ( @7 {" I# T8 C, ~9 E  J) N
  572.   #--------------------------------------------------------------------------. O: t: ^/ o: I
  573.   # ● 设置填充的Item个数
    6 s4 y. c9 l. W+ T4 O
  574.   #--------------------------------------------------------------------------
    : |1 M+ m0 `8 U% a. P; n1 G
  575.   def item_max7 Y+ `6 D1 n; X
  576.     return 90/ ?; P6 K, z3 W& ?1 {
  577.   end1 ^: X0 T. B' l& g
  578.   #--------------------------------------------------------------------------
      v, ^- G# _( _7 ?3 u/ s
  579.   # ● 设置填充的Item个数
    1 o& w, G6 g4 ]0 o$ n  r
  580.   #--------------------------------------------------------------------------, K% P& c( N# ~
  581.   def item_width
    0 z+ \8 Z" y5 ~3 x# O
  582.     return 32
    % L, v: u( s6 P, B( x( T
  583.   end
    7 y& F% A# g3 t* n$ X- h' g* l
  584.   #--------------------------------------------------------------------------
    ) L  {9 B0 t1 u) `5 X
  585.   # ● 判断鼠标位于菜单的第几行、第几列$ N8 G! P9 |# S5 X  Q$ t" _/ I
  586.   #--------------------------------------------------------------------------
      W6 g& R! h; ?9 A
  587.   def mouse_window_area& i& }; P! p! ~( p; G
  588.     if viewport.nil5 v3 J; y6 B6 X+ X+ ~
  589.       vp_x, vp_y = 0, 07 m8 V6 }; X! b0 l0 ~9 G8 N) K
  590.     else
    " R% e: I: H: S& K/ I
  591.       vp_x = viewport.rect.x - viewport.ox1 M7 A7 H5 ], l
  592.       vp_y = viewport.rect.y - viewport.oy
    * p! S; p6 Q9 ~+ E' z, a0 L! M
  593.     end
    ; d3 E4 [* N9 @
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ) L! n) g9 y) v7 y
  595.     item_x1 = vp_x + x + standard_padding
    ) W# @: E8 t% \' _2 c9 [7 R' z
  596.     item_y1 = vp_y + y + standard_padding
    / D) v3 P) O3 s5 c
  597.     item_x2 = vp_x + x - standard_padding + width
    2 }# Y' X$ G1 Y- s9 u: B
  598.     item_y2 = vp_y + y - standard_padding + height5 U3 A+ r" B! I. f
  599.     if mouse_x  item_x16 ?' c/ F# [2 W$ R: c0 s
  600.       mouse_col = -16 a( u$ c$ n, y& P6 h2 `
  601.     elsif mouse_x  item_x2
    . R. f9 p" |$ P3 Q" J
  602.       mouse_col = -2
    , U& q2 U' q# i1 u9 e$ q$ N
  603.     elsif mouse_x  item_x1 + 160- ~* s/ W% P+ V
  604.       mouse_col = (mouse_x - item_x1)324 b- Q& z" J1 ^7 \# e+ l8 @7 L% [
  605.     elsif mouse_x  item_x2 - 160- }8 g6 L: L4 M0 M! L' t
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    4 @* y6 T! I: i+ L4 N2 \
  607.     else
    - N/ f+ \7 K/ y- K# H, |3 m
  608.       mouse_col = mouse_x  x + width2  5  4
    . q7 Y, b/ o7 a& S3 x
  609.     end6 p3 `2 p2 w+ k, I
  610.     if mouse_y  item_y1, D, r' T3 `' @/ I  m' N, a( W+ _/ z
  611.       mouse_row = -1
    ) v8 ?, K. S4 l
  612.     elsif mouse_y  item_y25 m2 Q2 ~2 e3 q+ ?! S: t
  613.       mouse_row = -2
    0 g$ H* G7 D% T1 g
  614.     else/ @& B0 q1 z+ `3 S
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1); T$ B0 d: a' U" |2 Q+ Y
  616.     end1 M6 e6 F8 E5 f
  617.     return mouse_row, mouse_col2 c4 z4 T" L& b, S
  618.   end0 B* r4 C- R8 k7 ]
  619.   #--------------------------------------------------------------------------# p) |$ N3 k5 I2 S* y0 C% ]+ c; s& q
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置6 P  y, W9 A( w, U% D9 O
  621.   #--------------------------------------------------------------------------+ [+ ?0 o+ I2 o: j8 {
  622.   def set_mouse_pos
    6 J9 a7 b; j2 e9 q8 ^
  623.     if viewport.nil # necessary!
    * E3 O! E4 V- b2 N% s' o
  624.       vp_x, vp_y = 0, 09 @" D1 {, ?. v# `- u' n$ o$ |- e0 Q" K
  625.     else+ M8 d3 z3 v. B/ K
  626.       vp_x = viewport.rect.x - viewport.ox! o/ m6 W0 x% o+ U% u, |
  627.       vp_y = viewport.rect.y - viewport.oy* }( A/ p0 y0 f! P/ b
  628.     end$ y( _, k. J& i! P
  629.     item_x1 = vp_x + x + standard_padding ; x9 q( T: X7 I1 m9 e" L
  630.     item_y1 = vp_y + y + standard_padding
    / \8 q/ C2 ~- F, a( @" }1 {1 E
  631.     get_index = @index  0  0  @index
    5 I* E5 ?7 z5 M) G  C
  632.     row = get_index  col_max - top_row( n1 C3 Y' g$ {! l* H6 E/ \. @% g
  633.     col = get_index % col_max, M+ j. ^! J6 a
  634.     new_x = item_x1 + item_width  (col + 0.5): X. [: i6 |0 j
  635.     new_y = item_y1 + item_height  (row + 0.5): F4 a6 W3 D% I: |6 X2 M; y
  636.     new_x += 14 if col  49 O( I! j- G! _) z8 F0 b
  637.     Mouse.set_mouse_pos(new_x, new_y)+ F- W* {: Q' V) }7 @
  638.   end2 H; r# m* B, X9 s
  639. end
    : L5 |! B+ z' V. @0 F. U
  640. & i/ I& J, {* |/ f( m. u) t
  641. #==============================================================================% b* D3 k1 j9 `& Y
  642. # ■ Window_NumberInput+ v7 y& d3 z1 J: B, i% t3 F! Z
  643. #------------------------------------------------------------------------------
    0 A$ o% l* {8 D8 E/ u2 t6 A
  644. #  重写了数值输入的方法以适应鼠标8 J* L1 ?0 a2 q8 n, X- X& M
  645. #==============================================================================% X  J* C- T; G8 W
  646. class Window_NumberInput  Window_Base# s. K4 _7 m* a2 s+ M
  647.   #--------------------------------------------------------------------------
      x2 _- z/ M/ ?, \; B" X/ g1 B
  648.   # ● 定义实例变量, Z- F( t) l4 L4 G4 S' s/ `1 j
  649.   #--------------------------------------------------------------------------3 }9 O: b+ u& p* H4 S( i. R
  650.   attr_reader extra_window' w+ U: M. y9 P! h9 \
  651.   #--------------------------------------------------------------------------2 }6 f2 U$ U# _" ~0 f3 E3 |
  652.   # ● 初始化
    / J, s9 Q6 ]" m+ J# s
  653.   #--------------------------------------------------------------------------8 U( \# O# R; l; N5 a% Z5 a8 \! e2 l
  654.   alias sion_mouse_initialize initialize
    8 R( [9 S" f" }: ~/ L+ v
  655.   def initialize(arg)5 `7 v7 I2 g+ z% h/ h' |2 D
  656.     sion_mouse_initialize(arg)
    9 D: f, U! T! I' m- |8 O
  657.     create_extra_window
    2 O' [* }! U7 p0 t% k
  658.   end  T7 `0 {( Q) M! z4 v* M3 ^) p
  659.   #--------------------------------------------------------------------------
    $ |7 C, |! z% K6 a7 F  a7 K
  660.   # ● 启动3 ^8 U, a8 `: s0 c) Y- s* y
  661.   #--------------------------------------------------------------------------
    0 l% X- b2 s: s8 p0 s+ p+ F
  662.   alias sion_mouse_start start
    8 N% ^% x/ P- D! p0 U
  663.   def start4 r0 L% j/ X7 M, E0 Y
  664.     sion_mouse_start0 ?  ~( Y2 w. C
  665.     deactivate
    6 D+ P7 E0 f5 O& _
  666.     extra_start* @, o, y# K9 Q3 H, ?4 ]
  667.   end) W  ^3 [% V% A+ @: |3 R
  668.   #--------------------------------------------------------------------------
    4 O1 F! G4 {/ K3 A# B% C
  669.   # ● 创建新的数值输入窗口3 r  E0 s2 k+ z$ y( S* i
  670.   #--------------------------------------------------------------------------! N& H6 F3 t6 \8 Y* }/ N' ?+ J
  671.   def create_extra_window
    3 `/ h, Y9 g. O# V2 a2 t/ S
  672.     @extra_window = Window_NumberInput_Ex.new
    9 a9 O) _( c& P% H) c
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    1 f1 S, o" x; y
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }7 n7 _! |% H2 a( v
  675.     @extra_window.index_proc   = Proc.new {n @index = n }$ h: {' N  @+ Y. T( i: ?3 l; S
  676.     @extra_window.close_proc   = Proc.new { close }
    + o" B2 m8 A, s& l
  677.     @extra_window.refresh_proc = Proc.new { refresh }! G$ \1 y" U+ O" D$ }  E& a
  678.   end) c7 M, r8 o1 I& |
  679.   #--------------------------------------------------------------------------+ u( G; K' {: e' R4 p0 g
  680.   # ● 激活新窗口9 f6 R, e( e. a3 u! |8 s/ E
  681.   #--------------------------------------------------------------------------0 U& K4 x( z) f4 K
  682.   def extra_start
    7 [0 d& L$ I+ z2 T+ C
  683.     case $game_message.position: {# S) T( y$ t, d" y- C
  684.       when 0; @extra_window.y = y + height + 4( y6 V0 U$ S9 d8 E# l
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    ! P6 e' d% p5 k7 y
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    + {" v5 F7 X5 |% H
  687.       else  ; @extra_window.y = 83 c2 B) m1 \; {
  688.     end
    5 N  C: F: a, [( C) B
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    6 ?/ g& R, r2 }. R/ W( |
  690.     @extra_window.digits_max  = @digits_max2 L4 p* i0 B# K1 W! Y
  691.     @extra_window.number      = @number) B* a* B. J: A
  692.     @extra_window.open
    - J  O2 D9 A* N7 e3 B/ ?- V
  693.     @extra_window.activate
    3 U7 w$ m& }) h6 w7 ?3 ]3 |
  694.   end
    0 p* @3 `# f' P+ o
  695.   #--------------------------------------------------------------------------
    6 X( o; Z* W6 V$ ^
  696.   # ● 更新
    $ Q2 |8 r, I9 u; z- t6 b$ D* A
  697.   #--------------------------------------------------------------------------& }: k( I0 F5 g
  698.   def update
    $ f" `) }0 G2 U0 G
  699.     super, v' m& |/ }( n. L* z- {3 K
  700.     @extra_window.update/ s! F3 S+ ^) Z' l& q- y
  701.     update_cursor
    / }! Z0 y5 v  I5 o* N9 G
  702.   end0 Z, c6 _5 `4 {' ]  `4 i# k
  703.   #--------------------------------------------------------------------------1 @& t* {; B* d8 H' r
  704.   # ● 关闭窗口
    ) c& g# P9 B1 ~' A1 {, j
  705.   #--------------------------------------------------------------------------
    5 E/ l0 S& P! N% H, J
  706.   def close) S. t" {( a) W0 g1 D$ W/ ?
  707.     super
    ' W2 h5 l$ ]1 _, m1 M% C; k- S1 O: P
  708.     @extra_window.close& ]: \- Y/ f) g6 v* c# Y
  709.     @extra_window.deactivate% W* u+ g2 g4 y- |+ u1 r
  710.   end9 a4 z, q/ H+ {$ `
  711. end
    $ O: [( p/ O" h& R; R/ q+ V, {2 e7 _
  712. & Q1 Z* W) b1 t, R+ ~2 c  i' a- ]
  713. #==============================================================================& X" I# |8 `$ f% S2 z# L8 M
  714. # ■ Window_NumberInput_Ex  q6 h. U5 x2 O+ @- y8 O5 R
  715. #------------------------------------------------------------------------------
    0 Q2 t( d+ Q2 l5 ^8 M
  716. #  新的数值输入窗口(NewClass)
    $ g3 R5 ^9 Q7 g3 }# C
  717. #==============================================================================
    6 q8 b- v2 m" C9 u1 i, J0 i$ Y
  718. class Window_NumberInput_Ex  Window_Selectable* b( o( R" h8 n
  719.   #--------------------------------------------------------------------------' }/ U6 E; E+ C+ n; U
  720.   # ● 定义实例变量& F* P# z) y! U6 O5 W
  721.   #--------------------------------------------------------------------------
    , o4 B* H/ |3 {2 f, `' f
  722.   attr_accessor number_proc
    * m2 X* |. m! m. s( ~( _( ^
  723.   attr_accessor index_proc
    , Y7 S' V0 Q5 \- A2 w7 w
  724.   attr_accessor close_proc  n% B: z( B3 |* t4 l
  725.   attr_accessor refresh_proc; b) D" N4 O4 ]! l
  726.   attr_accessor number
    * G5 y. U2 a! ^; s" J
  727.   attr_accessor digits_max
    4 K0 L/ `' q$ f% m6 X: g7 m1 ~0 ]
  728.   attr_accessor variable_id
    8 l/ Q9 N! k: k* ~1 [
  729.   #--------------------------------------------------------------------------
    $ m8 ]" K) i* k9 Y
  730.   # ● 数字表
    - E# U0 e6 @9 c8 @- C
  731.   #--------------------------------------------------------------------------
    - f! t2 Z1 n( L2 x9 D1 _0 ]( A9 E
  732.   TABLE = [  7,  8,  9,
    7 |, H" L2 x$ T1 D' B  c- H
  733.              4,  5,  6,
    3 v( E% p; a4 C
  734.              1,  2,  3,
    ( {; q. y1 Y' P) g  Q
  735.             '←',0,'确定',]
    ) b! N6 s2 x! }9 T, ~; z
  736.   #--------------------------------------------------------------------------
    ; j' B. R! \! W/ g( D9 R' g
  737.   # ● 初始化对象
    ' _' _8 O1 [( M$ J9 `& |
  738.   #--------------------------------------------------------------------------
    3 }0 G7 Y7 R+ t: M/ S! d" n1 I" o8 h
  739.   def initialize" @4 C% p7 a% N" M) v. o4 T" i8 c+ |
  740.     super(0, 0, 120, fitting_height(4))% ?' n6 z9 `2 p; D
  741.     self.openness = 0
    7 J$ y& ^3 Q+ O& n9 X
  742.     @index = 05 c& [: Z# x. w" m8 }' \
  743.     @number = 0
    " ]3 M6 B6 y0 R! }5 r1 k5 f+ y! W: z
  744.     @old_window_index = 0, l; B& n/ f9 q2 T8 z3 M) e8 F$ r4 e+ h
  745.     @digits_max = 0
    4 H. y* d1 @* E, l% X* d
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    4 l& j) ?) }; A
  747.   end) g& P9 r1 @5 o3 K
  748.   #--------------------------------------------------------------------------
    ! ^9 ]7 c( F$ Q1 q6 T5 g0 i
  749.   # ● 获取项目的绘制矩形  I/ `) i4 D3 b7 l
  750.   #--------------------------------------------------------------------------
    $ y6 x! L0 O0 e9 z  d. y
  751.   def item_rect(index)3 @! ?0 e$ K$ q1 k
  752.     rect = Rect.new
    0 M, y. ?' o2 X" h5 H0 g
  753.     rect.x = index % 3  328 W0 s, ^- W  B7 h+ y9 D2 E6 p  i
  754.     rect.y = index  3  line_height
    ; j7 Z( [# ]8 W  I
  755.     rect.width = 328 [- }# t+ T% m* J. f* E* @
  756.     rect.height = line_height( }# y4 ^8 \  n: n& m) p0 w( N1 g
  757.     return rect/ a" k7 B6 Q) z
  758.   end
    0 w, C- ?6 u1 k( a
  759.   #--------------------------------------------------------------------------
    $ N" L0 H# |7 G, K- s
  760.   # ● 将光标设置到鼠标所在的位置! Z: D1 f+ b& G# s) l( i4 x% k
  761.   #--------------------------------------------------------------------------; U6 v/ ]* g- G2 y# e" K
  762.   def set_cursor$ w3 x0 Z8 S8 C5 k: U
  763.     mouse_row, mouse_col = mouse_window_area
    : K2 _  |) t' x  w, ], n7 `
  764.     if mouse_row = 0 && mouse_col = 0+ \3 ]) ^+ r0 z" ?: w& ?
  765.       new_index = mouse_row  3 + mouse_col
    - [/ V7 U% J( w% B% I% Z4 y# ]( G
  766.       select(new_index) if new_index = 119 B  n/ w6 M& q1 B
  767.     end2 O' a$ s( W$ K$ u: k" B7 ~9 W
  768.   end% {- N0 m, ?! T8 M( N2 r! i3 m
  769.   #--------------------------------------------------------------------------
    % ^0 u% f$ _: X( m7 R) E$ L
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列7 p* `4 X, C4 N& m
  771.   #--------------------------------------------------------------------------
    6 ~4 F: K/ \6 {0 d9 }
  772.   def mouse_window_area
    + w  p: q3 `- b
  773.     if viewport.nil
    $ _2 k, T4 ?) c; l$ S! [
  774.       vp_x, vp_y = 0, 0
    0 y3 }( i2 `4 L  _; F" r
  775.     else5 O$ U2 `5 z7 F- i4 z0 p, F
  776.       vp_x = viewport.rect.x - viewport.ox7 F* H0 K- A. K' Y& L
  777.       vp_y = viewport.rect.y - viewport.oy
    0 [6 W- `% Q0 l+ @6 z
  778.     end' o8 w: Q" S4 b: [* D
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ; A/ H; w( h# x) Z9 A( d5 H8 O
  780.     item_x1 = vp_x + x + standard_padding , p; R5 G/ _- [
  781.     item_y1 = vp_y + y + standard_padding+ ?. }3 l0 l' S  J1 W& q
  782.     item_x2 = vp_x + x - standard_padding + width) P8 W: x5 B0 v3 w$ b
  783.     item_y2 = vp_y + y - standard_padding + height: F2 Y0 B1 O- c% U
  784.     if mouse_x  item_x1  g% E0 s- Q4 T+ b
  785.       mouse_col = -1
    4 U1 @: R( S5 G" ]4 {: U
  786.     elsif mouse_x  item_x2) Q  g) c1 h! t
  787.       mouse_col = -26 l% V* v5 r, N* F, r
  788.     else
    / z/ U' J5 [1 l" {8 V: P
  789.       mouse_col = (mouse_x - item_x1)  32
    3 \$ z' ^9 x. v6 P- L
  790.     end+ t3 X" k9 ]9 y: a" \0 `
  791.     if mouse_y  item_y1
    ! P# g) u/ q/ u
  792.       mouse_row = -1
    7 P2 @9 r1 ^7 Z% b( G2 r( a8 f$ P# j. [
  793.     elsif mouse_y  item_y2
    ! h! D7 `6 H5 H
  794.       mouse_row = -2! |; U7 _! E. S5 L9 }
  795.     else1 t7 A0 S# j  e# M- `+ l
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    , A" R) \! B( f! |
  797.     end) H8 {& S! l7 _! _- K' N
  798.     return mouse_row, mouse_col+ I$ N! Z5 L% T6 f' N1 M3 s8 X, z# d
  799.   end
    % W8 L: V3 [0 L" B6 b8 E  w; g- d
  800.   #--------------------------------------------------------------------------
    + {4 W' P3 V8 o* B2 V4 h% B
  801.   # ● 获取文字, O4 M2 w7 Q+ q3 v5 b. G1 B3 o
  802.   #--------------------------------------------------------------------------
    9 s! I+ j( y  G4 V- a* n
  803.   def get_number$ O4 i, D) `/ `  K
  804.     return false if @index == 9  @index == 11# f$ `3 ^& f( B
  805.     return TABLE[@index]4 _4 I1 R. D) E! ?* K
  806.   end
    - Z+ o" l. i& w1 }
  807.   #--------------------------------------------------------------------------
    ) E" z: {" T- n8 V9 \* A2 x
  808.   # ● 判定光标位置是否在“退格”上
    9 t) F1 s8 N" w" F  }( v# U( t
  809.   #--------------------------------------------------------------------------3 P; ~6 J( ~% N; K0 @
  810.   def is_delete
    / O3 C5 X3 }7 N( ~2 \& q/ r
  811.     @index == 9
      _% f8 T4 m4 l( j, w! t
  812.   end
    " w* f! m2 T( w# [/ ?" t- @( P8 v
  813.   #--------------------------------------------------------------------------4 X3 \8 H( Z# Y! R$ m
  814.   # ● 判定光标位置是否在“确定”上
    ( c) q) J3 c2 S
  815.   #--------------------------------------------------------------------------6 \( ~' q6 T  R( d+ \% d" y& Z
  816.   def is_ok
    1 E4 j: ]7 s! ~  z# W' l( Z4 H
  817.     @index == 11
    # ~4 e' W) X* t8 v) d8 q
  818.   end+ J8 R/ X8 N! D2 k. a
  819.   #--------------------------------------------------------------------------
    " X8 O$ U' ^" a5 \& d$ S
  820.   # ● 更新光标$ K: s. _3 E; d9 O& b7 q
  821.   #--------------------------------------------------------------------------+ N1 Y$ i  e% D, h3 s
  822.   def update_cursor
    * E# ?- l+ K) r
  823.     cursor_rect.set(item_rect(@index))
    : j7 `3 p1 f  q) ~- f  _
  824.   end4 }$ E1 h/ B2 ?2 z9 U  F
  825.   #--------------------------------------------------------------------------1 T, T2 [, I6 U6 C
  826.   # ● 判定光标是否可以移动, W/ n2 W0 `& \9 k! p
  827.   #--------------------------------------------------------------------------* D$ f$ c4 m; _' c! ]( L9 A
  828.   def cursor_movable
    6 P7 p' f. n" K7 X6 m
  829.     active* R2 f0 v' t+ z" b* O
  830.   end
    1 |0 q, L6 j5 h
  831.   #--------------------------------------------------------------------------+ P& ^1 ~- _: G6 d& E7 r
  832.   # ● 光标向下移动
    & ?) E3 a( \7 ~3 U. J: |+ z6 I1 ?0 x
  833.   #     wrap  允许循环
    ) k; C6 }9 f8 F# F3 ]3 C
  834.   #--------------------------------------------------------------------------6 t5 J7 r, A+ v* O. ~
  835.   def cursor_down(wrap)# i/ }% h& r( l- g) ?" h+ H
  836.     if @index  9 or wrap/ `! M# w# i7 O0 K
  837.       @index = (index + 3) % 12. h0 {6 v; l. g
  838.     end
    ' W2 R8 B2 P+ y- f
  839.   end" z- }; e) e3 a
  840.   #--------------------------------------------------------------------------- k: `4 @  q! t5 [$ z
  841.   # ● 光标向上移动1 z, L1 T' ]- Y$ K7 G5 G5 P: C. d
  842.   #     wrap  允许循环- |; ?) C- P, y* n
  843.   #--------------------------------------------------------------------------. v% z1 K) D  e' ?$ T; ~
  844.   def cursor_up(wrap)- g  C1 u' |" \7 [% ]
  845.     if @index = 3 or wrap
      Y) S/ u* c$ e: f
  846.       @index = (index + 9) % 12
    6 j# ~, Z" s+ |) ?' W- V
  847.     end* \. `* s$ |2 ~* S3 P
  848.   end) W7 F# e9 n  s& u$ o
  849.   #--------------------------------------------------------------------------6 j: B& ?/ e$ j& R* [1 {# ?
  850.   # ● 光标向右移动- ~+ X! {, J  L, L9 d
  851.   #     wrap  允许循环
    7 g5 |9 ^' _3 j7 a
  852.   #--------------------------------------------------------------------------
    5 [6 w* F8 j5 X
  853.   def cursor_right(wrap)5 {  u: j% m9 X! `9 j/ d; @1 M
  854.     if @index % 3  2" l: L: N5 s) n5 e1 s5 ]
  855.       @index += 1, }8 k* P' c) t
  856.     elsif wrap7 q1 ]' D+ L( [) f8 T
  857.       @index -= 2
    3 ^* J& B, w7 C: D. t  f
  858.     end9 \. K7 u1 f1 h& t3 k# y. M
  859.   end, f% W' l* ], S
  860.   #--------------------------------------------------------------------------
    4 u# [  Q# I& g- d; H3 K# l
  861.   # ● 光标向左移动
    + ?! F# t% {. P% a
  862.   #     wrap  允许循环. A  y" ~- a6 \& D- K0 @
  863.   #--------------------------------------------------------------------------
    6 c; Z( _5 d, ~* K/ C" T
  864.   def cursor_left(wrap)6 `- X( o9 @; U8 \. N
  865.     if @index % 3  0- q! a6 _5 b( i8 e& [
  866.       @index -= 1
    ) A! C  S! b' z
  867.     elsif wrap- ?1 I) f' Y& E, @0 a5 ?/ u
  868.       @index += 2
    6 h9 J, W$ r7 k/ m
  869.     end; G( L  h; B% C. u% ^
  870.   end* J0 C, p/ o1 H" `
  871.   #--------------------------------------------------------------------------
    0 ~, `: }& e- U% `5 f5 q1 a
  872.   # ● 处理光标的移动
    % l2 y( n0 d, n3 ^/ j2 w
  873.   #--------------------------------------------------------------------------
    ) l% t$ }- ^; f; R4 G) W4 N
  874.   def process_cursor_move& B7 S; `$ T% M
  875.     super+ ]# C7 W- P7 W
  876.     update_cursor
    " X$ y) G1 C4 s. r4 H6 h
  877.   end
    ! O5 m7 \% A+ A" ]( ~. h
  878.   #--------------------------------------------------------------------------$ Q# T+ ]5 E/ n
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    $ n% [) c: b) m* ^; ?
  880.   #--------------------------------------------------------------------------
    & Q: G  K3 K- w& E4 w- D6 U& F
  881.   def process_handling) f, K& s: u; c: M0 {
  882.     return unless open && active
    + ]2 @/ J/ _" ?9 h3 k. _' Z6 Z
  883.     process_jump if Input.trigger(A)
    1 ]9 q. s# |, a# G' M4 _6 S
  884.     process_back if Input.repeat(B)! w/ U/ p0 H; n) a6 H# j' R5 [% M; p
  885.     process_ok   if Input.trigger(C)) h- t2 v4 ?9 X& L6 i6 u9 S
  886.   end
    0 q" }8 Y1 A# w5 d
  887.   #--------------------------------------------------------------------------* k+ j- R6 v6 h  ^& q$ L+ [
  888.   # ● 跳转“确定”$ l+ _2 |5 a: ~: ]0 s
  889.   #--------------------------------------------------------------------------+ T5 N7 [9 [8 |3 ]
  890.   def process_jump9 H3 \/ ^! l5 v& p9 B& M6 L, Y
  891.     if @index != 11
    3 g1 {+ b: Y0 b! j4 T# x6 |
  892.       @index = 11# Z0 r2 u( g/ H! b
  893.       Sound.play_cursor
    ; V, D; \7 z& `0 k; u
  894.     end8 M: D1 v9 E# g. ^! {
  895.   end' z6 |+ Y# I$ F( ]8 @1 K" x
  896.   #--------------------------------------------------------------------------
    . H' q; b) |" n4 `0 S
  897.   # ● 后退一个字符
    ' W. L# U7 X* g, ^2 w
  898.   #--------------------------------------------------------------------------. W$ d; z! ]  }" X8 F! C% R8 {1 J
  899.   def process_back6 O. p; `" O  }5 \! V+ E
  900.     Sound.play_cancel
    , n& G& T2 O1 B
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    ) j( F1 n3 G5 k. t/ S
  902.     n = (@number  place) % 10& S" N# c' t) k' h
  903.     @number -= n  place6 X+ W/ C, L: M6 P6 o9 Y
  904.     @number_proc.call(@number)
    # B9 o" E& T; F5 F# Z
  905.     @old_window_index -= 1 if @old_window_index  0
    ; v. c9 H: h( Q  z) d& K" E2 W( N8 X
  906.     @index_proc.call(@old_window_index)+ @; y/ x' p7 Y5 d, `
  907.     @refresh_proc.call) n) ~5 y0 I" |! E- R# L; b8 \2 H
  908.   end* s! H: \4 S! ]. O
  909.   #--------------------------------------------------------------------------' f4 \+ |8 |  x
  910.   # ● 按下确定键时的处理
    / R- k3 H+ V3 y* z
  911.   #--------------------------------------------------------------------------
    * w$ Z. r4 r1 \; ^2 z' F
  912.   def process_ok0 p( h+ p3 V# `0 _
  913.     if get_number
    & t5 L: s# |4 }  d
  914.       Sound.play_cursor
    7 d; J7 n3 d- N
  915.       place = 10  (@digits_max - 1 - @old_window_index)6 Q& V) c# y" ^7 ~2 Y4 z
  916.       n = get_number - (@number  place) % 10
    : r, }" S9 |/ U( h# ~
  917.       @number += n  place
    # n* @8 E; E0 f% x2 n0 P
  918.       @number_proc.call(@number)
    % T. g% ?4 t- X) z) s# u
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1) w5 H/ W& y% ^/ P8 _; d+ B
  920.       @index_proc.call(@old_window_index)
    # W: M8 N! j/ S) t
  921.       @refresh_proc.call0 C; Y1 q" ^, w; z! x5 s
  922.     elsif is_delete( c7 j( R0 V, q# A/ R
  923.       process_back- t% M+ m- j2 R) ^$ L
  924.     elsif is_ok* f$ J( V3 g( x( @  B% r& ]9 S
  925.       on_input_ok
    7 k% Y( o  Z" f5 i) Y2 j7 x
  926.     end
    2 i. E) W4 J  s0 ]( x* D
  927.   end
    3 K) P( L& ^" Y9 H' Y) C9 d/ r
  928.   #--------------------------------------------------------------------------9 H" J; i$ ~, m
  929.   # ● 确定
    6 e7 ~' H. U, D' X9 j: Z
  930.   #--------------------------------------------------------------------------
    ' k, x) q* M( U2 F# J5 b
  931.   def on_input_ok
      R$ H& o- a+ r% y8 @
  932.     @index = 0. T! n+ u' |1 ^
  933.     @old_window_index = 0
    5 K5 A1 _4 `* N5 s" x
  934.     $game_variables[@variable_id] = @number: z2 i' T" G2 i/ |, y$ |
  935.     Sound.play_ok  a! W1 ^* k8 q6 F& E6 v% p
  936.     @close_proc.call
    ; B3 [) N( j% |; Z
  937.   end8 Y# \( F3 Y1 o/ W+ ^9 ^" }
  938.   #--------------------------------------------------------------------------& D5 y3 B0 V' ~2 r5 E& a* r
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置5 L* h. @( Q, h8 V' H
  940.   #--------------------------------------------------------------------------7 N+ b  N$ _9 i% z8 |) T( Q* W
  941.   def set_mouse_pos2 j- @8 l) ~7 E2 n7 J
  942.     if viewport.nil # necessary!
    8 f9 u' J- U: W
  943.       vp_x, vp_y = 0, 0/ u) P3 C+ j( g# p* b' i+ p  R4 Y
  944.     else& v8 F, M6 `( j- \6 Y0 W8 l. X
  945.       vp_x = viewport.rect.x - viewport.ox
    1 ]7 h# J/ I9 h, g4 T  f
  946.       vp_y = viewport.rect.y - viewport.oy
    6 G. r. b1 o/ k' h2 ^1 W% p% x. y
  947.     end8 ^# r) a7 V& k: l5 H( ^9 w
  948.     item_x1 = vp_x + x + standard_padding , a0 H# v2 l% p8 ]* O, ^
  949.     item_y1 = vp_y + y + standard_padding/ D( w# U% z1 w! w5 B" K+ D
  950.     get_index = @index  0  0  @index ; t4 N( z+ {/ y9 C
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    + P4 b" K: t( f
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)6 y% F9 Y: b. H' j$ Y6 F. c
  953.     Mouse.set_mouse_pos(new_x, new_y); L/ j4 m# |7 L* G7 @, b& r% B
  954.   end) m5 b( k) J2 W9 a2 B7 F" N1 [
  955. end: q% b$ [. K$ K
  956. 8 |% v2 a& ]$ U/ t; I0 ^
  957. #==============================================================================
    - D8 ]9 ?6 [. _6 S. m! h
  958. # ■ Window_Message
    7 j! J- `& f( a# T( l; F9 ^
  959. #------------------------------------------------------------------------------' R& B' \1 O; W1 p9 N  s7 j1 d
  960. #  显示文字信息的窗口。
    . C; ^% e, m9 ?% `1 s6 p& n
  961. #==============================================================================
    + y. g/ `6 l& M0 E
  962. class Window_Message  Window_Base2 T; z9 Z, f. r$ v# Y
  963.   #--------------------------------------------------------------------------
    ; A$ S/ c& ~! I
  964.   # ● 处理数值的输入(覆盖原方法)0 s# n  ^* P7 o- R, W0 G! r1 `* G
  965.   #--------------------------------------------------------------------------
    % q- X5 S9 I- A( l& |
  966.   def input_number
    " x; M2 b1 E6 Y: C* x9 C- }
  967.     @number_window.start
    # E" N1 B* d! o/ W9 k1 e# R2 u9 z
  968.     Fiber.yield while @number_window.extra_window.active+ G1 E3 t0 F3 S! C
  969.   end
    6 p, t6 ]3 U% p' ^2 G8 @" Q! \
  970. end, P7 Q) C3 K6 z$ Y$ V

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

  2225. & s# D/ _% q6 \. E$ k  ^
  2226. #==============================================================================
    . B- ]" j; o; U+ w  A  ~
  2227. # ■ Spriteset_Map
    6 f: ?& s/ U  ^
  2228. #------------------------------------------------------------------------------
    2 K4 Q0 k: i  P# R1 S+ m
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    4 [' X, B' k) l% y' J
  2230. #==============================================================================
    - D4 g# _  G- r* f; x8 A9 D4 s$ h
  2231. class Spriteset_Map
    ! x$ q( U' |( n3 |9 B2 N  ~( D
  2232.   #--------------------------------------------------------------------------" A% F3 @9 d* Y
  2233.   # ● 生成路径点精灵, X" L+ r) |% i0 o8 f
  2234.   #--------------------------------------------------------------------------. y' P8 F  s9 x. S
  2235.   alias sion_mouse_create_characters create_characters
    6 Z& f: B' G* w3 b" T
  2236.   def create_characters' N, L$ v7 q+ |$ [2 v
  2237.     sion_mouse_create_characters
    ( l6 d7 t8 ]. r( o! K" O# r
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign)); W  ?1 q5 \  l. D
  2239.   end) V1 Q% r/ g0 d$ g- X: Z0 M" x
  2240. end  E( Q) Q' `4 Z

  2241. , T: g9 l) X9 ]6 y  D" F
  2242. #==============================================================================6 \3 h, P* x0 h" g. w6 @' f; v, ]
  2243. # ■ Scene_Map
    9 t- B& ?* j8 f/ I+ |# J1 S4 `" D
  2244. #------------------------------------------------------------------------------
    9 C; ?6 @, e9 B" j7 y3 j; ~7 C2 P# r
  2245. #  地图画面
    " q" n/ u2 R1 @% @, J
  2246. #==============================================================================# P6 }# s. X5 g
  2247. class Scene_Map  Scene_Base
    : {/ e# s( n4 A1 s) H+ D& o
  2248.   #--------------------------------------------------------------------------  s% r: `- f, v) b1 N" Z
  2249.   # ● 画面更新5 J- k% J7 G  |0 y
  2250.   #--------------------------------------------------------------------------+ j# F& y4 W: S
  2251.   alias sion_mouse_update_scene update_scene% S1 y2 r3 k; z0 T+ }* E" _
  2252.   def update_scene$ {* W8 z( n  `8 v/ P$ R$ U
  2253.     sion_mouse_update_scene
    2 K+ z* Z2 R. k5 c+ [! V
  2254.     update_mouse_action unless scene_changing6 Q( t2 K6 I- W+ b' m' B$ |- O  x
  2255.   end
    , K- R; Z2 I4 X  \1 {
  2256.   #--------------------------------------------------------------------------
    ) O0 k4 d0 m7 O! s4 P
  2257.   # ● 场所移动前的处理
    ' A( C4 D1 t& h" k* Y# f2 I
  2258.   #--------------------------------------------------------------------------
    ' f7 _6 I, `1 {
  2259.   alias sion_mouse_pre_transfer pre_transfer
    ; z  g* W! m8 j3 J6 h$ w) _- W
  2260.   def pre_transfer2 M; ^# f% Y" G4 w# e" M7 d, Y
  2261.     $game_player.reset_move_path3 X- U" B% u( U3 I
  2262.     sion_mouse_pre_transfer7 p4 u" d- _) R2 D2 I
  2263.   end. G# f' a; ~9 g
  2264.   #--------------------------------------------------------------------------
    * W0 U# L+ E: T& p5 \
  2265.   # ● 监听鼠标左键的按下5 u0 G' b7 F6 P) a' S
  2266.   #--------------------------------------------------------------------------
    , k. ]) t; ~) u% A" U4 m: [
  2267.   def update_mouse_action3 `9 k% E$ ?" g! }; ]
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    4 p% P: O  a" }" s6 G2 A  C) t  o1 n
  2269.   end; F* t: Y- S' C1 h% {% g, |5 g: F
  2270. end1 M# h1 M# x" W9 o
  2271. 9 N- Z3 q/ F& G1 `8 i; z
  2272. #==============================================================================9 J% `  f  ?3 B4 e" S; k
  2273. # ■ Scene_File9 Z% w' N, N8 i
  2274. #------------------------------------------------------------------------------
    7 y0 e. u. ^8 |5 x+ \2 \
  2275. #  存档画面和读档画面共同的父类" |8 ^/ {5 ]" V( z7 b1 `( |
  2276. #==============================================================================2 o* W1 X) O2 L
  2277. class Scene_File  Scene_MenuBase4 B5 F$ p. ^# ]% ^$ p2 L
  2278.   #--------------------------------------------------------------------------" L' `& G$ H5 f
  2279.   # ● 开始处理
    / c/ i1 r7 v2 m+ K1 P
  2280.   #--------------------------------------------------------------------------
    1 q) ^* P. M/ E$ Q, [
  2281.   alias sion_mouse_start start
    ) [/ N) o( Z: j0 J* v& e
  2282.   def start% M7 y; }4 y  Z1 }2 d0 E6 A
  2283.     sion_mouse_start
    ; Z4 f% U5 t5 K: L7 A9 i3 a
  2284.     @move_state = 08 f/ g( s" z; @! O! K
  2285.     set_mouse_pos
    0 f/ I+ S8 \) s! W9 n) H6 b
  2286.   end% y0 _  e% e2 B  p: i; i
  2287.   #--------------------------------------------------------------------------
      o# _: y% M# \; B, h9 I3 E
  2288.   # ● 更新画面: g- i& A0 j1 e6 |& S0 q5 _
  2289.   #--------------------------------------------------------------------------
      F& H& ?; V  x' W7 B
  2290.   alias sion_mouse_update update
    2 s! z/ o; p( A0 J
  2291.   def update+ W  l' n+ ~  n5 C1 P" L6 i
  2292.     sion_mouse_update  l; v* J* w# G0 v  D5 n
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos: S# D: J/ X  a( w( q4 G8 b
  2294.   end
    / m0 Q' |8 A+ H6 i4 h
  2295.   #--------------------------------------------------------------------------
    $ }/ O) T) S4 n9 T
  2296.   # ● 更新光标  ?) G( k, L$ g% i/ t: R. L) P8 G- H
  2297.   #--------------------------------------------------------------------------
    ! K9 `. ~1 N5 l6 m# Y
  2298.   def set_cursor5 q. e6 p; `+ F7 K
  2299.     @move_state += 1
    8 U; `7 l* c- Y1 F3 f# u
  2300.     last_index = @index0 u2 B3 X$ X$ n' F. K' n
  2301.     if mouse_which_window == -2
    : P# e+ \' k: G# Q9 z
  2302.       if (@move_state - 1) % 6 == 0
    : O) I- m9 _" {4 I- A
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    : f" g+ d: m" ^3 l7 t" ~" T
  2304.       end' C3 S& B, v. v/ {+ s- ~$ B- D# a
  2305.     elsif mouse_which_window == -1% i$ L0 |. n1 a# {
  2306.       if (@move_state - 1) % 6 == 0
    ( A% i: j; K$ x$ j5 ~
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    ) d* E! p5 U8 ^$ U8 w
  2308.       end9 w3 H% f  c8 a5 U
  2309.     else% }2 k# _% Z& D# v) U  I
  2310.       @move_state = 0; z; S  f5 y- @7 X. f4 I. B
  2311.       @index = top_index + mouse_which_window
    / E5 ]$ S; V, [" h
  2312.     end4 P# Z3 u' T4 Q- O2 Y; X- ]
  2313.     ensure_cursor_visible6 G( h0 r! L% {9 {
  2314.     if @index != last_index1 n9 l( p* {* x
  2315.       @savefile_windows[last_index].selected = false
    - }' O! t) N, {5 Z: o
  2316.       @savefile_windows[@index].selected = true
    ) u. `3 s' t' x6 \8 I) ~# ~
  2317.     end
    2 F) t1 e" r" h7 {1 |
  2318.   end
    ! c; D0 _2 ]/ `0 D; H
  2319.   #--------------------------------------------------------------------------+ g" r: O5 X) G! [- N
  2320.   # ● 判断鼠标位于哪个窗口
    5 b3 Y: [; U) a! q
  2321.   #--------------------------------------------------------------------------
    ( W2 D- g  `  z9 F' P% S6 p3 t
  2322.   def mouse_which_window7 o: p+ k" g( n$ N# P
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    0 t1 v4 o, V4 E) c6 H  }
  2324.     if mouse_y  @help_window.height + 14. u; H5 ~) `% A9 H
  2325.       mouse_row = -12 _( R9 v& _" I+ }  a+ z
  2326.     elsif mouse_y  Graphics.height - 140 Y6 x* A& X' o
  2327.       mouse_row = -27 [, s0 {) _+ D' I! S
  2328.     else5 P" H7 q$ x( g1 i* H) h9 L+ N6 ]
  2329.       mouse_row = 4  (mouse_y - @help_window.height) ; a! H- M% b8 m/ z6 X
  2330.         (Graphics.height - @help_window.height)
      I" C2 }4 h6 m, M% L
  2331.     end9 \7 O$ G3 f+ N2 A0 R" D
  2332.     return mouse_row- d, q# R5 J3 q" w, T* \6 Z
  2333.   end
    - e; m% R+ C4 R" N- w
  2334.   #--------------------------------------------------------------------------
    2 N+ p+ [7 q$ E7 x8 h
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置7 |' p$ U& t/ q2 n2 y" l* k- {1 u
  2336.   #--------------------------------------------------------------------------
    / Q8 s- n& E, d8 ~4 N5 {
  2337.   def set_mouse_pos5 K- y4 {: l5 c5 R
  2338.     new_x = 40+ @1 R( {- ]" \# Y, m2 \& G
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    7 N# J# b5 d# ~, E( E, l
  2340.     Mouse.set_mouse_pos(new_x, new_y)  A3 O/ t- _% G2 y) t) q, |9 J* M, v
  2341.   end$ W( D2 a: n& z% G
  2342. end; l- w$ s# x. m( S, b: x8 R" h
  2343. % f/ b9 k5 ]' a9 _8 w
  2344. #==============================================================================. R) w7 Z" K2 \3 @8 c& E3 `8 Q
  2345. # ■ Game_Event# G$ {6 n$ Q! v' }" H
  2346. #------------------------------------------------------------------------------% V3 u' b+ V7 H4 V( M
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。7 G0 u, \# b  {( a' `& G
  2348. #   在 Game_Map 类的内部使用。! i; X( M3 k6 V9 c
  2349. #==============================================================================
    % D7 o6 s) L- c; m* s
  2350. class Game_Event  Game_Character
    ( C& c2 f  ~8 m0 k+ ^$ X! q+ l
  2351.   #--------------------------------------------------------------------------8 [. m2 H, s1 ]
  2352.   # ● 事件启动0 Z, O1 C  Q$ R' u' i
  2353.   #--------------------------------------------------------------------------8 e' |$ z& q) d% J6 F- D! _# q' K- `
  2354.   alias sion_mouse_start start
    9 T+ T4 `; K0 Z/ B5 h
  2355.   def start
    % R9 p$ X0 D( Y* Z3 w& x
  2356.     return if mouse_start && !Mouse.press(0x01)* t3 ~& [2 r5 u$ X( |# U9 c
  2357.     sion_mouse_start
    6 d. q5 o) I& c- g
  2358.   end: c- E$ Y9 @+ i% B. J1 m( N5 Q8 U
  2359.   #--------------------------------------------------------------------------
    ; x. u7 t- A2 O# H% w3 i( w
  2360.   # ● 判断事件是否由鼠标启动$ S% R; M5 i) H5 }; ?- U: ^
  2361.   #--------------------------------------------------------------------------2 ^) T1 L6 O+ p, E) {6 Y
  2362.   def mouse_start& q  E' K& n  y
  2363.     return false if empty
    2 g3 D* T, Q+ ^5 ~. @" @
  2364.     @list.each do index
    6 ~# O# r- N0 j+ F0 P% w
  2365.       return true if (index.code == 108  index.code == 408) &&( @; g7 o$ i4 @, [3 x/ _
  2366.         index.parameters[0].include('鼠标启动')% A( ]7 k( @( n/ Y2 X' h2 J* \
  2367.     end
    , }& g8 ?$ {  h- l
  2368.     return false& `8 c0 [! M0 H  u8 ~; L
  2369.   end9 m* S7 F: I4 I; ^3 {( p6 k1 }  O
  2370. end* p  e) J3 H, X4 S+ A+ |5 n
  2371. + A( U9 H6 s: M! g( A' F; c8 L; y
  2372. ####泥煤的height, K. e/ b8 x8 }" C( @! l- V" X4 E
  2373. # @height = height5 Y8 ^( N) c6 D
  2374. - C7 {$ U3 a5 M6 M8 K: [) K
  2375. class Area_Response8 h. {' Z8 }* X! ~5 p: E9 Q
  2376.   attr_accessor type, W( a; f6 q, S9 q1 m1 y9 t  Y  Y' A
  2377.   attr_reader ox4 |* _( {; [3 T
  2378.   attr_reader oy+ r8 t# O% N/ ~/ S, B# C0 s, b
  2379.   attr_reader width1 w  E1 ^5 ^/ k( m! C5 L" ?
  2380.   attr_reader height
    ! }1 ^  B0 B) t8 F8 A7 e
  2381.   attr_reader switch_id
    ; z8 G: Y: Y' ?1 j6 n
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    : T, I, f- [8 v* B
  2383.     @type = type
    ( p! ?1 \0 `( p) d
  2384.     @ox = ox
    ( X5 |; h3 ]6 J, i7 o; l5 ?# l
  2385.     @oy = oy
    6 l: h9 k% o, |$ R0 m* U
  2386.     @width = width% l  g( e% P- p
  2387.     @height = height
    - f, S" d3 P' c! j6 b$ s9 o
  2388.     @switch_id = switch_id# u, s) U7 V: D  F  n$ {
  2389.   end
    ; ~2 x  I7 q) v/ m
  2390. end* {. I/ S; L. _1 M$ f2 O
  2391.   t. O9 D* v8 b8 b/ P
  2392. $area_responses = []. Z4 e  ?4 P$ x
  2393. $ L/ ?3 I& |& ~* D. D7 I+ ]
  2394. class Scene_Map
    6 j$ O  ]+ G' |7 Q" Q2 e# g
  2395.   alias update_mouse_2013421 update_mouse_action* L& t2 d+ j5 P6 ]/ C; u$ k* d
  2396.   def update_mouse_action2 c% p& q% t5 C. A1 q4 h5 ~8 q
  2397.     update_area_response
    : P) P! x% K1 O& d( A
  2398.     update_mouse_2013421
    8 e. Z8 }& l/ @( c# A1 S. y
  2399.   end
    2 X, z. A* ^4 d( u$ [$ {
  2400.   def update_area_response
    4 e+ _% r& O% {4 U. S
  2401.     responses = $area_responses9 `1 x: R$ O* L" z! b* i
  2402.     responses.each {response
    & U  u6 ]) C- a1 y4 L6 Q
  2403.       ox = response.ox4 u1 F+ ?  G7 ?5 v% X# ]
  2404.       oy = response.oy
    $ N4 N' S3 M! k1 K, c' ?
  2405.       width = response.width' |1 B- w* c# D. \) |/ \$ M
  2406.       height = response.height2 R# N" R+ i- T6 b" T& v: u
  2407.       switch_id = response.switch_id* M$ c( B. q; Q1 F
  2408.       case response.type: ~/ @2 G$ `2 v+ h  m5 f4 u, R# S
  2409.       when 0
    1 J/ W4 d$ J$ r' x7 K
  2410.         if mouse_in_area(ox, oy, width, height)" W9 O# e) J8 X1 i
  2411.           $game_switches[switch_id] = true2 Y; Y4 w  G& e$ D
  2412.           $area_responses.delete(response)2 T8 G0 A/ L& l$ `: }, q
  2413.         end! v) l$ G/ l, h8 B3 o/ Z
  2414.       when 1
    , i& |3 h" c1 c* q- @4 N+ Y
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    + G# ~& T; h# y
  2416.           $game_switches[switch_id] = true& q2 m) s9 A2 p, l1 v9 I
  2417.           $area_responses.delete(response)
    ! m# _) `; v% u7 P$ M) X/ u
  2418.         end( Z' d# j# @, m2 e7 h# w* \
  2419.       when 2
    6 x0 c  c& ?5 Z& u1 l; N/ r: D
  2420.         if mouse_in_area(ox, oy, width, height). P: [9 q  C5 y
  2421.           $game_switches[switch_id] = true5 U6 M1 N$ T4 b( _- g
  2422.         else' n7 H4 Z. S' b# E; r6 t
  2423.           $game_switches[switch_id] = false
    & M: f3 `  [, W" r
  2424.         end! y0 a. Z/ M' i+ `& ?, G  y! w! s: k9 e
  2425.       when 3
    9 n' q# u- a) T# r8 f! G
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,! ?/ u% [+ m# i7 Y
  2427.             (oy - $game_map.display_y)  32, width, height)1 l& M# V, h" \
  2428.           $game_map.events_xy(ox, oy).each {event
    & x6 ^6 l7 w1 b: ]" g$ B' O* z
  2429.           event.start
    ; Y' v7 G% j2 k8 _6 d5 ~( b
  2430.           $area_responses.delete(response)
    5 E1 {; v/ f2 V! I
  2431.           return
    6 k3 U5 G# q( E( _
  2432.           } 6 E6 V( u) O7 f0 n2 W
  2433.         end4 h! [5 l* A3 G: s% v0 l4 a; c
  2434.       when 4
    5 j# E* }! D+ C7 v7 w
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,' O; n( ^2 a# M8 U
  2436.             (oy - $game_map.display_y)  32, width, height)
    % k0 c( t! C/ z& Y
  2437.           $game_map.events_xy(ox, oy).each {event
    ) _3 k3 |  W' s% i" i
  2438.             event.start; v1 R: Z$ n. }  M4 D/ y& [
  2439.             return! Q) i! V/ r# ?9 N+ ~
  2440.           }
    9 e: k; b; {$ q5 A/ \' F
  2441.         end1 T* X0 \6 y" |1 h; Z. p1 L/ l$ I
  2442.       end
    # L8 S2 k: H' y
  2443.     }) p5 Q: v' `: W6 O* `! P/ r
  2444.   end$ c# x5 K5 n& ^, E+ O( B% L' [2 D, V
  2445.   def mouse_in_area(ox, oy, width, height)
    ) I2 w0 P8 A! T
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    $ T6 c& y3 S1 Z  Y) v) D4 R/ k, l3 W/ a7 m
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    2 @$ e) y1 ]% O. c! ]
  2448.   end; G. a4 U# C# l$ ^
  2449. end
    " O& z0 b. x# V8 ^1 F6 ]& [
  2450. class Game_Interpreter
    % ?( v. {) D9 H- h
  2451.   def area_response(arg); m0 Z5 w& ~! ]3 w, ]
  2452.     $area_responses.push(Area_Response.new(arg))
    ! T0 x* H# p8 O7 i! L/ |: L1 J, M
  2453.   end6 J1 N# X' a# [+ v7 g4 B  Z6 V
  2454. end' M4 u4 C+ m' c; b+ E! z
复制代码

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

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

GMT+8, 2024-5-23 08:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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