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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    0 X9 M2 ^1 J4 S1 A7 r+ X
  2. % d1 M) [  T8 D) f) {" k
  3.   Sion Mouse System v1.3e! u7 ]" m9 o3 P4 D  H
  4.   
    1 H% R) u5 A) J
  5.   Changlog0 [) {$ }5 Y( B! j/ E
  6.   ( r1 _& q$ n9 G+ o  o" U1 ~* P
  7.   2013.4.21 v1.3f
    7 `5 H0 `6 [+ v/ m" d3 t
  8.    
    $ }. C' s+ s& x' m- D
  9.     1.3f 卷动地图 bug 修正
    $ a+ f4 ]7 Y/ B$ l
  10.    
    1 ^8 t( A4 h2 q
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    , r. i' j+ x( ^/ v7 }- m' W8 Q$ E
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    ; o. m! r: o7 v& j& I
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    3 E- }" L7 \/ C5 v5 O2 Q
  14. : M" b, [8 r- W' R
  15.     1.3f bug修正% n" f* t* m7 B0 ~8 T
  16.   
    $ ]% v5 m6 z" w. Z
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    3 g: l: I( K5 f' z
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    % H$ W: d* b' {& P. c

  19. * r/ v" L$ |% e5 X2 U& n
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处8 Z. E( J% u* ^9 U5 w

  21. 1 \4 Q, ?+ V  l3 h' L; D/ q
  22.     1.3b 修正一些罕见的bug;
    ! ]" C# k+ M$ p8 V
  23. , R# L# `' }8 H& S8 e4 T
  24.     1.3a 代码小修改;
    . m; r& ]: G; X" W& L$ D. ^+ Q7 T
  25.           加入了鼠标点击启动事件的功能,
    - _8 T( `7 d! f2 d4 v  ]! g" I: t* A
  26.           在事件中加入“注释”: 鼠标启动  ,
      R$ J; M6 W) C: H) {% x) D. J9 y
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。0 h* b+ w7 h' H8 T9 p+ e( x
  28.   " P+ z( U6 b+ C/ m# w+ Q
  29.   2013.2.12 v1.2
    3 ?. k; E# P& _+ z0 f7 {& }

  30. * X9 u' d/ J- S1 y8 v' X9 C0 A5 m5 J
  31.     寻路逻辑优化;
    ' `/ U5 c, P: {7 k8 O& S8 g
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    , Q1 e1 F& X6 j; E; @' Q
  33.     现在支持用鼠标来操作载具了。* X: G+ N5 I* K/ x- ^" A: n; d

  34. # S) u0 I2 u. m! n
  35.   2013.2.8 v1.1
    2 J% V. q4 S" n
  36. + G  i# ]' R* `# _$ x9 _
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    4 s1 N+ d' q( H, @) \5 ?
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;4 j6 n8 h& i/ k7 ?
  39.     移动时,路径指示点的绘制更加稳定;
    $ X2 H/ `) J& k$ M5 G  X1 k
  40.     现在支持默认存档画面的鼠标操作了。) u9 q+ h. s7 C* Y2 R
  41. * B0 @' f- T1 a7 t- M# h
  42. & h1 j# s+ l) J5 ?
  43.   OrigenVersion6 a! k0 n7 l, Q; d2 [. h1 L- {
  44.   ' P/ Q+ T3 Z: J. P4 H8 P+ p, }
  45.     2013.2.7 v1.0
    " o1 j  N8 g: R* f

  46. : @5 {, m4 T# K' U
  47.   主要功能+ Y6 X2 h/ w5 H7 D# R
  48. 5 W& B5 j8 b5 j, M7 {8 g
  49.       使用鼠标进行各种操作...5 }, w2 }0 f- K" B& G9 y+ z( D
  50.       将鼠标锁定在游戏窗口内1 z4 J7 J  O2 S5 t! Z' |$ `0 P
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    ) E* L3 n! P! `4 r, R) B
  52.       双击鼠标进行冲刺( U) {, L' Q' c: g. O
  53.       更改地图卷动方式以适应鼠标移动
    * J$ a0 p5 |0 q/ j/ \. `5 W: w* f
  54.       变量输入框改良
    5 |; B+ g* ]- E+ _) I

  55. 1 }8 g' p9 ?% L4 s6 o' S
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    8 s2 g/ i( L( c  N* H% U% I
  57. ; f! ?# w; @4 t% I3 \
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹8 W- V/ |$ \) r/ @( X9 R% U

  59. 5 n7 T: s1 n8 m
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    6 m& Q( Q3 D8 `
  61. ) t* J; y+ H4 h

  62. 2 _" o" O4 G$ K5 F! P
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★( W; y" P: p. o. K
  64. # l! N( n0 u! X

  65. ; N0 e8 r4 O! d. i
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示/ d8 S( w7 o" [  ^" D1 L

  67. . b5 H' l3 t7 m7 x- O- W
  68. #==============================================================================
    2 E" R. s% l3 Z3 h. ]8 _
  69. # ■ 常数设置 ( `+ U: p0 w- E5 U, |- h* E8 p( c
  70. #==============================================================================7 V4 t6 Z6 ^4 x3 V9 L
  71. module KsOfSion) Q% _# l$ r/ `2 @8 \! u  I5 @
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false2 j& c  c* H4 c4 |
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    1 {$ K" w# O$ D' ]& B& C+ n9 ^, W
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    6 G& ]8 S5 Y. |$ u6 V
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量7 A2 [: F& @& l6 }6 Y# b
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处- @0 a( z$ E. E5 E- S
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    8 A2 B- G/ F5 H% J1 j# [' J- ]6 Z
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    9 K$ A! ]+ @% Y& l# v4 V7 @4 d. R
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键1 q  N+ W& ]1 s( T& y
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    ! q2 x; T. f  K- Y1 H
  81. end9 |- ~7 Z9 O" k) n
  82. 6 P( ^5 |1 x3 V! d
  83. #==============================================================================$ X4 w/ c  C8 X4 a& a9 o
  84. # ■ 用来显示路径点的类
    / Y  i  l9 f" g( e- j* z
  85. #==============================================================================
    % Y* K1 D9 s% d9 E* a/ O2 z" h
  86. class Move_Sign  Game_Character
    , ^# |  B! H% W: A
  87.   #--------------------------------------------------------------------------
    6 |5 C: W$ Z; M; c& f: v/ D
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    ' @& c5 p$ f' f0 }2 O1 x4 w4 N
  89.   #--------------------------------------------------------------------------
      ~/ s) T. g: U; K7 Y. ?
  90.   def init_public_members
      V7 Q% v1 r2 a9 V+ t2 c
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    ' q% B& Y' g; i! w4 w" C, e- P
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为02 t3 _2 r5 s) \5 d$ A" f4 L
  93.     @move_speed      = 5        # ★ 踏步速度  m% C- x$ u0 v/ h) L
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)6 {8 Y. i6 }* U4 O
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
      w" T5 T8 d4 l7 l. ?4 ^
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)7 ]0 {0 u" \. J) w
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
      C% c/ R# `4 U1 v
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    $ ^  q5 g; F8 P  o3 S( F
  99. $ @- `- P* `9 T

  100. & _0 L0 x/ P( l1 k
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★' O1 @5 [9 B3 u1 s. D
  102. 7 q/ b; c: h: n; _! Y  Z& H5 E' h
  103. 5 ]: j( V/ v/ P- c  j
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    & Z) e+ @1 ]7 K. G
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
      c( J0 {3 j9 L; g, X& W& K3 \* W! ?
  106. & Y8 r" _- ]) y' R+ @0 F) X
  107.       if $no_arrowpic_warn
    5 }2 R9 r1 N  B) O: F0 e
  108.         MouseShow_Cursor.call(1)- y5 Z( w5 x5 A6 ]3 J. o6 ~
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png8 t2 P/ u8 P* X
  110. . t8 q/ K8 o1 r6 H5 O" {. M
  111. “路径指示点”将使用游戏自带图片
    4 k0 L: x; g$ k8 d( r" |, g
  112. 6 v: b& J2 t9 P/ c
  113. 该提示可以在脚本内关闭')
    6 l" X+ t4 Q" N& m  P5 D! Z
  114.         MouseShow_Cursor.call(0)
    0 f% j+ ?6 _" ~! r5 n9 R# L
  115.         $no_arrowpic_warn = false  n5 z( S0 \7 Z6 U& F2 e
  116.       end
    - X9 @6 s( q5 c! H) p
  117.       @character_name  = '!Flame'
    $ n5 ]7 M# z1 c" A: S$ M% B. q
  118.       @character_index = 66 q* z$ Y$ e: N' B  n/ |& v! h& r

  119. 8 P: o7 a+ [, t" ^  y9 p
  120.     end' j7 @6 z, H. m4 P/ O) J
  121.     @direction_fix = false  # 固定朝向
    . d: h6 A9 l' z, v" v* h+ ~  }# C
  122.     @move_frequency = 6     # 移动频率9 C! a' q8 ]' u3 R% D
  123.     @walk_anime = true      # 步行动画
    2 A! H& v  |$ |0 M. J
  124.     @pattern = 1            # 图案
    $ J  C# \7 W3 M5 _7 B
  125.     @through = true         # 穿透/ S: h1 z+ A5 L5 |9 z5 g
  126.     @bush_depth = 0         # 草木深度
    6 g, m5 `8 M' O0 S1 c) d$ `
  127.     @animation_id = 0       # 动画 ID
    6 h4 ^9 W# ?5 |! b5 `# U
  128.     @balloon_id = 0         # 心情 ID
    - F3 t  {9 ]# d5 P. J- L
  129.     @transparent = true     # 透明  ^7 T  M6 E0 a0 r6 M8 m
  130.     @id = 0
    ! \, q; O+ Q# n6 m" X( K/ o& i2 d
  131.     @x = 0, E1 g% C3 t0 }4 k4 B
  132.     @y = 0
    ' ~4 Y! L  U, |1 [
  133.     @real_x = 0+ p6 [- r- q( ]& T" z# o
  134.     @real_y = 0
    0 R6 `+ v1 z' @1 y; b$ q
  135.     @tile_id = 0
      @6 P# t# u& y0 x
  136.   end5 v8 d( h4 D% I' r$ J1 T6 H' X
  137.   #--------------------------------------------------------------------------
    & a# Z0 j( e9 a3 o
  138.   # ● 定义实例变量5 D7 X/ `8 \+ s/ m. E/ R/ h% ^
  139.   #--------------------------------------------------------------------------& Z; d4 f: y. K$ V4 ]- q' }; v  \
  140.   attr_accessor direction
    # `% v  M( l% h& z# }
  141. end
    - }- }! ~" K( n3 x+ }; z
  142. ) g$ i9 t3 A+ X* ]( F$ e+ k
  143. #==============================================================================
    2 Y3 m6 ~7 ^3 ^! U
  144. # ■ Module Mouse
    9 f" `% Z8 H1 ~
  145. #==============================================================================8 T4 k6 j4 G, _9 j% R
  146. module Mouse& @7 f* ]6 Q0 H: a+ ?
  147.   #--------------------------------------------------------------------------
    / D- f' d) O7 y5 [/ l
  148.   # ● API
    7 e, V. \2 F9 y' A9 n3 S% _0 n
  149.   #--------------------------------------------------------------------------
    7 x, L; Z& k' B% W" N
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    7 _2 s! Z, r; W0 Q- T7 Z
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')4 G3 G! Y) k" C% x
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l'). g' d3 r4 G$ O  G- k
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    1 Q' t1 N2 k3 _: L& b) l
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    $ `$ b/ e; p! G( t! A- d( Y& i( O8 P; k
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')4 W2 V) P" U( v5 j5 L1 v2 j4 J
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')9 {& j& i5 ~; N. S  ]3 W, m
  157.   Window_Hwnd       = Get_Active_Window.call
    6 l% a% H  p' ?) S3 s: m
  158. " X4 B& T: O' t( _  `' H, D
  159. class  self
    ) M' b! O  t  e3 z: Q! V# O
  160.   #--------------------------------------------------------------------------% w% b( x9 y$ T$ I3 G6 L
  161.   # ● 初始化# |: v, Q: ^- ~, G. `5 j. Z
  162.   #--------------------------------------------------------------------------
    7 u; Z2 p7 O6 p9 Z- m
  163.   def init) Z4 r2 z  S3 N, m
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    " Z! `0 \! c8 ^2 g
  165.     @left_state = 0
    / Q3 B" H2 R, Z8 o1 [0 {1 e
  166.     @right_state = 00 l* l3 b* e1 S% S4 g* f
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    ( S) I6 a. Y9 e7 I( t1 w& @8 N& d
  168.     @dk_count = 0 # 用于双击的判定
      J% G& {& r0 O9 A4 d
  169.     @clicked = false) o5 E& M) k/ m) ~
  170.     creat_mouse_sprite/ n$ j  F  r4 ], j1 t: C7 a( R
  171.     update
    / y6 t4 R- ~# C( d; i
  172.   end" D! t$ x0 O' o$ r5 b, k
  173.   #--------------------------------------------------------------------------
    . l! Q+ G2 o% A& G' C  u  }+ H
  174.   # ● 鼠标指针精灵
    ' ]( g& w2 y  V4 a9 p- F" X2 }
  175.   #--------------------------------------------------------------------------
    7 q# d: g: ~5 J) h% }9 \
  176. #~   def creat_mouse_sprite
      r: Y% D/ h; h; z
  177. #~     
      I- m2 Y6 v! a6 }1 [8 g/ @
  178. #~       @mouse_sprite = Sprite.new
    + x' N$ Q+ s( S7 A% A
  179. #~       panda = 2#rand(2)+1
    ! u/ g  X0 }* s' w, r, y5 t# f

  180. ; ^- I; Z: l% h; w0 a
  181. #~      if panda = 1: g8 l% S  z; L4 G- m
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    9 W' q4 M& B" ?0 A) X, u
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2'). Q& H4 o. k- Z4 N4 C; ^
  184. #~        end#with if File.exist( S" ^  k' E5 J* J( x
  185. #~   
    * N0 m) [; F; ]) v& v
  186. #~     else if panda = 2 #with if panda=1$ r/ i, t4 q3 m' c# y( s5 o
  187. #~      
    3 E) |2 L1 T# M) T4 ?
  188. #~      if File.exist('GraphicsSystemCursor2.png')# e- f+ J. Y& j: J
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    7 k; u0 v! R4 M; d: n( }# o9 u
  190. #~      end#with if File.exist
    ' a) G% r# d3 T; E
  191. #~      
    " `/ l6 Q! ?2 c/ W$ o
  192. #~     else #with if panda=1, F3 N$ @5 ]6 |8 o+ F' w
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)/ S8 ^! `' u2 i) y$ `* S8 ?
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),, l. d4 n+ t: `" e
  195. #~       Rect.new(5  24, 24  24, 24, 24)). ?/ _, c' t6 F) W
  196. #~     end#with if panda=1. N9 R4 n6 ]6 t$ n
  197. #~     
    9 L  B# A) k: q; h% ~  m
  198. #~     #with def
    & e# p! d2 h* ?/ a
  199. #~   end
    6 N5 i3 Z+ D: j* Q3 s
  200. def creat_mouse_sprite
    % Y, k, o% W4 Q1 L8 Q! c" N& D
  201.     @mouse_sprite = Sprite.new
    + I* k, f: M! e8 J+ K
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    % A/ c) i+ ^, [& Z. D" _% A$ S
  203.     @mouse_sprite.z = 9999
    ' ?- L: b/ E% O* q+ M: m
  204.     Show_Cursor.call(0)
    % x) B; O/ q6 n+ }9 \' u, K5 P
  205. end- u5 P* I8 o+ O
  206. - _. l% h1 ]9 N0 V
  207.   #--------------------------------------------------------------------------: a3 G" Y8 k$ v- K' [
  208.   # ● 更新
      @8 X/ k+ v) m& Y, x6 ?
  209.   #--------------------------------------------------------------------------4 A# J  i& m0 a
  210.   def update
    " v$ Q+ e" S0 x* x7 }
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos, X8 j8 ^1 x4 ~" c8 D
  212.     left_state  = Get_Key_State.call(0x01)
    " ?* z# U. h# w( Z4 w) i
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    2 o0 Z* v# D; C9 f; f' |2 m
  214.     right_state = Get_Key_State.call(0x02)
    5 B: f7 h6 e2 E# Z$ ?# l1 L
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    " Z* C5 n2 @+ ~$ \
  216.     update_double_click
    " x2 X; w. }# x% P
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    2 f" n5 _. R5 V
  218.   end1 M  x$ S9 c7 A% i2 x/ d% b8 P. m! K
  219.   #--------------------------------------------------------------------------
    0 I3 V5 G8 R/ p+ J
  220.   # ● 获取鼠标坐标
    4 V4 Q  ~9 N& G$ N9 C: _! M: b
  221.   #--------------------------------------------------------------------------
    ) e% X/ o& A- X& _/ F' h
  222.   def get_mouse_pos/ Z  S  G  z; X- G* u4 p2 A
  223.     arg = [0, 0].pack('ll')
    5 l9 `& {0 h! B# Q7 _5 x8 V$ {
  224.     Get_Cursor_Pos.call(arg)
    3 D1 o. k' k* o. W# P" i, {  U
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    , c/ M/ P5 A' T7 Y( C
  226.     x, y = arg.unpack('ll'). e, ^$ B% d3 j/ N& X. z
  227.     return x, y3 I% P! u; }( u' r+ b  A
  228.   end
    5 }! A2 S- @7 ^* j( o
  229.   #--------------------------------------------------------------------------1 r" _9 }) e" T* o* W8 B, j3 t9 i
  230.   # ● 将鼠标固定在屏幕内7 L0 M. d5 p+ r) F3 Z- `
  231.   #--------------------------------------------------------------------------
    7 R* m, c) T, ~: _- I/ _1 ]
  232.   def lock_mouse_in_screen7 x- f: q* Z" j* D/ y
  233.     arg = [0, 0].pack('ll')
      i! V! |2 C! \" v6 I* n  T
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    8 O/ M$ P6 ]2 f1 n6 ~1 ?
  235.     x, y  = arg.unpack('ll')
    + o4 i& D# p! n1 D3 b' `* S
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    $ v/ M2 o) y* h" g
  237.   end
    % n' V* |0 |" G  W+ x! W5 V  {
  238.   #--------------------------------------------------------------------------; k/ u9 P$ g5 [6 A% o, b
  239.   # ● 解除鼠标固定+ S; h( [- |: X6 V% [* J7 E$ l+ }% ^
  240.   #--------------------------------------------------------------------------5 m! @5 t; v( ?& p% @8 l
  241.   def unlock_mouse_in_screen6 e8 `) U# {( o
  242.     Clip_Cursor.call(0); |# c+ k1 [* K' T
  243.   end
    $ t) u; S3 C3 \+ |- L
  244.   #--------------------------------------------------------------------------" e: K; q+ \* K+ g$ r
  245.   # ● 鼠标双击判定
    $ F0 M6 N4 R8 r. X  _
  246.   #--------------------------------------------------------------------------
    " {4 S7 b" ]  @
  247.   def update_double_click
    ; {! u& q* |" Z
  248.     @clicked = true if @left_state == 1
    5 [; h/ C. T. v1 y
  249.     if @dk_count  0 && @left_state == 13 \" u5 X8 e2 i0 \
  250.       @dk_count = 0; @clicked = false
    6 o  C3 n2 s+ W) a1 H
  251.       return @double_click = true
    3 V6 a  I" d8 R0 P- T
  252.     elsif @clicked) {" P! w8 s6 K% _9 M2 A% n) U4 A
  253.       if @dk_count  KsOfSionDbclick_Frame
    # V& d& T! V5 U5 T( u0 ]
  254.         @dk_count += 15 T) Q! z6 Y7 |. P# ?! j( K
  255.       else
    1 k. P) \0 z8 h# g% K2 ?) c
  256.         @dk_count = 0; @clicked = false
    & C8 W6 w! A7 d2 ?; m2 p
  257.       end
      k0 o* q: ~$ t- s  X
  258.     end
    9 o5 _" p! ]* }* S7 l9 r
  259.     @double_click = false% J# K/ `6 X& l
  260.   end
    , j6 [: t) o1 o; V4 m$ L
  261.   #--------------------------------------------------------------------------: _; K  `! Q8 i9 x' W3 `/ y
  262.   # ● 按键被按下就返回true! Z" J# m7 J2 T* S5 X
  263.   #--------------------------------------------------------------------------  E- b! F4 a8 q; e3 D1 i+ [
  264.   def press(button)
    % I% i* k2 C. T$ K( p/ Y
  265.     case button
    : n' d/ Y! E& R1 Q7 F( i4 R
  266.       when 0x01; return !@left_state.zero
    : p: O! y% A) e9 K8 B
  267.       when 0x02; return !@right_state.zero6 C" x# U7 q* ?. D6 \& C) E! v
  268.     end
    4 J) {# I* k8 p3 w
  269.     return false
    ' O7 F2 ?, B$ o) ~7 m4 M% T
  270.   end
    & a7 w" h+ q: \# `6 O$ D
  271.   #--------------------------------------------------------------------------$ E, t. H8 Q+ x
  272.   # ● 按键刚被按下则返回true( }, u) N# N8 e+ X6 a
  273.   #--------------------------------------------------------------------------: W9 L, U: g" G& b" p, l
  274.   def trigger(button). ?& o/ z& M" U2 [
  275.     case button
    $ h, A% r% ?1 G: ?: C9 B
  276.       when 0x01; return @left_state == 1
    3 |3 U8 I7 O/ J& _) T9 [
  277.       when 0x02; return @right_state == 1
    % T: F& R2 c4 t$ e# q9 ], ~% c1 P
  278.     end
    ! T' W) m; a, f8 H
  279.     return false  B9 y8 N  h9 n5 x1 e
  280.   end: w0 ~+ }/ l% f% g5 f
  281.   #--------------------------------------------------------------------------
    $ `$ j' l0 F8 u& n& i
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true/ g) F- z, A: y+ r: k; U. }
  283.   #--------------------------------------------------------------------------
    , ~: r; ]- ^& d. r, Y
  284.   def repeat(button)
    % q% t. Q; Y+ l8 G9 H
  285.     case button
    1 B' a1 h7 x3 \$ R6 j. ]3 H
  286.       when 0x01; return @left_state == 1 , Y& v: }1 \; z1 a8 }
  287.         (@left_state  22 && (@left_state % 6).zero)9 M9 o. e4 [6 _+ A( K( x+ y! ]
  288.       when 0x02; return @right_state == 1 ' i; o) N* }& S% v# o# \, M
  289.         (@right_state  22 && (@right_state % 6).zero)
    3 K$ A. O0 N2 u5 M: X) G
  290.     end
    ; i7 |9 s$ p' ^3 s5 W, {
  291.     return false
    2 J1 w5 T/ f/ T0 V- Z8 q
  292.   end# N% y# r. e4 J+ a! @2 E& ?5 J4 C6 a  T
  293.   #--------------------------------------------------------------------------4 G6 E; I: }9 z% ?- N+ _! _
  294.   # ● 判断是否双击鼠标
    7 I9 M) [! S  T9 J# \
  295.   #--------------------------------------------------------------------------! ^" D5 v4 v# Z
  296.   def double_click
    * v; A& S1 M0 y$ t) q$ E
  297.     @double_click& p  B1 W; ?% l# a6 f4 D0 s4 G7 N7 k
  298.   end
    + Y0 f7 X" h9 h# C
  299.   #--------------------------------------------------------------------------
    # O) k7 R' f7 a% z
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    1 e% F3 p& b0 v  f
  301.   #--------------------------------------------------------------------------
    , }) E" \5 H( z- j9 q8 D" p' G
  302.   def click_count7 M) S# J6 X0 d' }% r
  303.     @ck_count
    2 I$ f/ t# Z) [9 o7 D" j3 [6 e
  304.   end
    % h1 I3 W& z% M  l
  305.   #--------------------------------------------------------------------------
    9 \; N" D5 d  q9 a) g4 `! `# V
  306.   # ● 获取@left_state(按住左键每一帧+=1)' f$ f0 H; e# n2 }
  307.   #--------------------------------------------------------------------------' m1 f5 x( E& ^
  308.   def left_state
    # u" t- [/ d, ~( M+ J; B& f/ n
  309.     @left_state
    ! @- Z- Q* @" E8 S
  310.   end
    & ^  ~! [# |9 t
  311.   #--------------------------------------------------------------------------) G: w8 ?  y6 V# y& x' n1 S
  312.   # ● 获取鼠标的x坐标
    2 S/ b8 H8 p3 f# J- G
  313.   #--------------------------------------------------------------------------& J% Z% c$ d4 S+ D' Z
  314.   def mouse_x
    ; V, j# G  ]1 y4 F
  315.     @mouse_sprite.x- Y" @" @3 H% [. a" c( a4 Y
  316.   end3 p& C! a1 r" `$ f/ Y
  317.   #--------------------------------------------------------------------------3 D- q& q5 ~. `3 f
  318.   # ● 获取鼠标的y坐标7 S5 H" C8 k( S4 @
  319.   #--------------------------------------------------------------------------
    ( S/ z! w% I0 \( {
  320.   def mouse_y7 r7 P2 ]! b* ^
  321.     @mouse_sprite.y2 c5 b3 E0 H8 j, T) N
  322.   end
    7 \/ S! {; h  Y; U4 q; @
  323.   #--------------------------------------------------------------------------* I8 l3 c: |& z8 A6 l
  324.   # ● 设置鼠标坐标
    $ T9 Z+ X+ W4 @6 G; ~. ?. ~7 Z" v* [  g
  325.   #--------------------------------------------------------------------------" c! O0 _  K# m
  326.   def set_mouse_pos(new_x, new_y)
    8 h/ H" Y, y# ^1 u3 P8 a9 g
  327.     arg = [0, 0].pack('ll')
    $ |+ T, U& I. d+ _" h
  328.     Screen_To_Client.call(Window_Hwnd, arg). K$ g+ ?, }3 w) ?( ~' ^6 C# E
  329.     x, y  = arg.unpack('ll')
    / V2 h+ ]& v6 S" R* ~
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)+ x1 D  q4 D! \, L7 x
  331.   end
    $ M- I0 R0 w$ I6 H& S7 e
  332. end #end of class  self 3 Q0 A9 b+ j. U5 t* F" M( O  C
  333. 0 A, y$ J. {) u
  334. end
    # z4 W. F7 j7 T1 L3 a* C! R
  335. 3 h3 U" Y' c& y: V6 j* Y  I
  336. #==============================================================================( `& r! \3 F& X4 A" Y# i& P
  337. # ■ SceneManager0 b0 V/ L& [$ M
  338. #==============================================================================3 y* B3 k8 W* W
  339. class  SceneManager, S! T! R5 H$ H) u$ H7 n
  340.   #--------------------------------------------------------------------------
    " |. K% [% n5 j1 V6 J
  341.   # ● alias* l9 I- v  i& E: }9 u1 z
  342.   #--------------------------------------------------------------------------
      k, A! R$ |4 T* A
  343.   unless self.method_defined(sion_mouse_run)4 V$ u: i9 h  D4 E
  344.     alias_method sion_mouse_run, run+ w6 f+ I& U' A1 Y! d% m/ x
  345.     alias_method sion_mouse_call, call
    7 \: m. B: d9 u! x
  346.     alias_method sion_mouse_return, return
    & ?7 ?2 a' [) w% M  I
  347.   end
    % i! ]# k; A3 I& j2 K
  348.   #--------------------------------------------------------------------------+ v8 l7 q- j' }0 e+ L+ _; `9 l
  349.   # ● 运行
    ; {1 c+ B5 e5 A: N* o
  350.   #--------------------------------------------------------------------------
    0 m, l# [/ u- N5 Z
  351.   def run
    8 F- T7 i. A! Y! k$ G0 k3 _4 a
  352.     Mouse.init
    0 i4 M3 m+ c( o! m# D* l1 J- F
  353.     sion_mouse_run
    + @' b$ q: e/ i* r! f
  354.   end. O- V% y2 y. ?& e
  355.   #--------------------------------------------------------------------------
    ( |2 f* T0 z: U2 k- y- O
  356.   # ● 切换7 `2 I6 d% j8 ?% y% K
  357.   #--------------------------------------------------------------------------/ {  D) `9 g3 h4 l  G
  358.   def call(scene_class)
    / |; E# G: ^7 j2 O: k1 d
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    8 X. J; h% k( H( N- c2 q, E! V
  360.     sion_mouse_call(scene_class)
    5 w9 q7 v# J8 {% Y- W* a$ p
  361.   end1 d6 `1 c/ W. Y- m
  362.   #--------------------------------------------------------------------------  C# s& k; ?4 A1 x* Q, n- h2 b
  363.   # ● 返回到上一个场景( x* i( {+ f. K* I
  364.   #--------------------------------------------------------------------------
    - Q$ ~7 o$ P& y3 g: W' u
  365.   def return
    , _9 y+ Z: V8 f: z: E5 @$ Z
  366.     sion_mouse_return' f6 p( |' h, d3 C6 ]; j# l
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&' O" ^# [+ W+ g* I' B$ o
  368.       @scene.instance_of(Scene_Map)
    * ~# @, h9 T# {7 c( ]7 m. C) }
  369.   end8 {  \( t0 v% X9 m
  370. end3 M: R9 _0 `+ N) ^
  371. 6 _! X+ e8 e8 {: e  U" H
  372. #==============================================================================1 {3 t) {- \. U" ^! C
  373. # ■ Module Input2 g0 z. \( [3 ]1 t
  374. #==============================================================================
    / v4 M4 e$ y: J; \
  375. class  Input
    / K8 ]( }7 Q( n$ Y
  376.   #--------------------------------------------------------------------------
    # B4 b" u$ {5 `# d
  377.   # ● alias
    8 i; I: o; ?9 W# v( R% P
  378.   #--------------------------------------------------------------------------
    + g4 L: _& J& d3 @* ]; ~8 }* L
  379.   unless self.method_defined(sion_mouse_update)
    + V" L  u: S# l3 P6 ^4 c
  380.     alias_method sion_mouse_update,   update4 n7 e3 ?! y: l
  381.     alias_method sion_mouse_press,   press
    % F9 F- u3 o+ h1 w( V' h
  382.     alias_method sion_mouse_trigger, trigger  v3 v9 G+ B, J6 r
  383.     alias_method sion_mouse_repeat,  repeat6 `% R& w; P, U1 N" o6 Z# z) v
  384.   end  ^+ F; e: K  o, j0 v9 Q, s" a, @2 J
  385.   #--------------------------------------------------------------------------
    ; G% q4 H' m/ |8 o8 C
  386.   # ● 更新鼠标9 ^0 e* A3 ]6 u2 f  t
  387.   #--------------------------------------------------------------------------
    4 C$ @9 B' F8 B+ P, O$ d
  388.   def update
    % B1 I, Y8 Z! r; t7 L) z, n
  389.     Mouse.update
    ' B& S5 X! J* K3 n, q& b( l
  390.     sion_mouse_update
    , N' q( D& n' j$ i8 Z
  391.   end
    ( i! R0 Z( i* r% F
  392.   #--------------------------------------------------------------------------( h" O0 x0 {* ^3 X- |
  393.   # ● 按键被按下就返回true. _" a) L  E5 y4 p
  394.   #--------------------------------------------------------------------------- ~' ?0 H% O3 d: o
  395.   def press(key)4 Q( q7 b9 p, h" C# s6 Y
  396.     return true if sion_mouse_press(key)
    3 o8 k1 y& H( l5 P+ s& Z, o: n2 d
  397.     return Mouse.press(0x01) if key == C
      {) ^4 @% E  e
  398.     return Mouse.press(0x02) if key == B
    6 `* o& K/ \2 f# g
  399.     return false# {& z, E- W' {4 B# F+ `3 w
  400.   end* j$ V4 H! k' z5 W
  401.   #--------------------------------------------------------------------------
    , {2 g, T8 g/ e( D$ G
  402.   # ● 按键刚被按下则返回true1 P" S$ X0 C1 B- @6 k' e
  403.   #--------------------------------------------------------------------------
    3 J6 e) h, \  ]4 ^3 }
  404.   def trigger(key)& S5 [" Q# g9 J6 V" q  V, f
  405.     return true if sion_mouse_trigger(key)
    1 r' G* d& Z6 M3 N0 k/ ]/ K4 f: a
  406.     return Mouse.trigger(0x01) if key == C
    2 l5 R+ x' Q2 q  N0 a% z9 g
  407.     return Mouse.trigger(0x02) if key == B
    ; c! i# Q' g4 y( V# c. b
  408.     return false
    $ _( ]/ y  J( |/ e- R
  409.   end, F' L& i; Y/ B4 [- W: H
  410.   #--------------------------------------------------------------------------, z* q: s+ r$ Q5 S; r5 c
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true/ ]  Y0 r3 _9 ]' F: u/ C' B
  412.   #--------------------------------------------------------------------------( I, T1 f$ I6 I
  413.   def repeat(key)
    2 J8 `9 S0 L# [' ~# t% S3 D
  414.     return true if sion_mouse_repeat(key)3 }- }# e; T7 R% w8 H7 k
  415.     return Mouse.repeat(0x01) if key == C
    . W7 o7 O; R7 a9 M7 i; f
  416.     return Mouse.repeat(0x02) if key == B; w6 y: _1 w: T' ^
  417.     return false
    " |4 T0 {; ^; i  n$ [( \
  418.   end" y# x) O" m/ o4 n, g
  419. end
    ; B: \* ]6 q* c

  420.   e4 L: x* L5 A  w1 c& M* ]

  421. 4 U  V/ y2 m4 x2 b) P: m8 F
  422. #==============================================================================
    7 }9 S4 j0 m% _
  423. # ■ Window_Selectable/ ^& S6 c; z; U5 K9 H8 F7 p3 E) u
  424. #------------------------------------------------------------------------------6 [+ X5 M$ U- b% @5 w
  425. #  拥有光标移动、滚动功能的窗口
    " l6 _6 S2 C/ n' `
  426. #==============================================================================; g7 |) L. {% _
  427. class Window_Selectable
    $ I: _- L* B+ d, Q
  428.   #--------------------------------------------------------------------------( ~6 k7 d: L# V
  429.   # ● 初始化
    9 z& ^% e8 f+ d8 M# {
  430.   #--------------------------------------------------------------------------
    % m) }; [: @, H9 r! S: {% p. I& J
  431.   alias sion_mouse_initialize initialize9 r! p3 [( z* P/ E
  432.   def initialize(x, y, width, height)& \. G& R4 J" B* r) J4 B
  433.     sion_mouse_initialize(x, y, width, height)2 t2 G# w3 {5 z+ Z1 i/ s1 t: ^7 U
  434.     @move_state = 0
    ( z+ L, d' u8 [9 q3 Q* K$ t
  435.   end8 r8 H: @' s( P
  436.   #--------------------------------------------------------------------------
    % c, p& [- t. z4 P6 e- f/ S# j
  437.   # ● 更新' Z+ F- l/ K7 o( t" t. ?
  438.   #--------------------------------------------------------------------------( V- n- l6 }3 `) A% ]
  439.   alias sion_mouse_update update
    2 k* r4 I: R; ?; J* y
  440.   def update
    0 {- \5 |$ ]1 }% E0 `: g8 _5 a
  441.     sion_mouse_update
    9 N9 ?. \  t2 r
  442.     update_mouse_cursor
    6 U' U) c8 p+ C; b- {/ q
  443.   end
    * x0 \3 V8 q3 @$ K
  444.   #--------------------------------------------------------------------------
    2 g/ p% A' T! Q7 k7 @
  445.   # ● 启动后设置鼠标到index位置
    - C0 r& ]' ~% D, ]) V- @
  446.   #--------------------------------------------------------------------------2 l0 i( ]" E6 z8 N0 Q: y
  447.   def activate
      h2 q! h/ u+ E" J* Q2 @
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos( _$ G! _/ t9 y! U2 x
  449.     super9 @1 u. \7 E' ~
  450.   end
    $ k% a$ W2 b. U  H% i
  451.   #--------------------------------------------------------------------------; f2 M1 P# M# G9 X. [3 \& M
  452.   # ● 更新鼠标和光标的位置
    1 P# |7 H% I3 q, W: L6 C& V/ s( a
  453.   #--------------------------------------------------------------------------
    / w4 O4 _- q: U9 ]% v. w
  454.   def update_mouse_cursor% r1 h; `3 J2 v7 Q( s  y
  455.     if active
    3 ^" J) j2 k) j# q. E
  456.       if @need_set_pos: ]% z9 v' a" t/ z4 ]6 P+ r
  457.         @need_set_pos = nil
    1 w* a& O+ ~3 F; b. w$ g6 x
  458.         set_mouse_pos0 L: [3 K' w5 b. y
  459.       elsif cursor_movable
    6 ?, R+ m) D) m1 X' W( T
  460.         Input.dir4.zero  set_cursor  set_mouse_pos! z2 A$ ^3 ^+ s: c6 [* [
  461.       end
    9 j8 u1 K4 L- D3 F
  462.     end7 N9 |! k3 N: a& R" r; q
  463.   end
    : _# ]' O9 C; }2 s" I
  464.   #--------------------------------------------------------------------------
    ! _  H- [! q8 C0 G% Y+ U5 L' l
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能% m$ N& \( l$ x2 U" _7 m: ?
  466.   #--------------------------------------------------------------------------$ D8 P, X" Y% i  N
  467.   def set_cursor
    ' D' k# |( \$ C% d1 \+ e$ `
  468.     mouse_row, mouse_col = mouse_window_area( b, [0 j3 C4 t; @5 f
  469.     if    mouse_row == -1
    7 p& [3 V; J7 L+ _- ?" ]9 \
  470.       @move_state += 1 if need_scroll  `, ~3 C2 q" y6 z8 }
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ( x  B+ w# p3 p: [6 D$ |1 V+ w, F* |# z( d
  472.     elsif mouse_row == -2
    4 J; B: v3 i: s+ Y) k
  473.       @move_state += 1 if need_scroll. Y/ Q8 |3 a5 ~8 z! J/ j" P/ D
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    . l; ~, m1 |" H0 V$ `: q
  475.     elsif mouse_col == -19 L. N! u3 o3 O* _
  476.       @move_state += 1 if need_scroll
    ! z2 r& o: ^8 A& j" I, S* y# }
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand' v7 J4 j0 N) R
  478.     elsif mouse_col == -26 b0 S& B* ]# E, g/ @
  479.       @move_state += 1 if need_scroll: m$ x! o; {" H5 b0 t# J# Y0 @  a
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand- A8 t6 I/ J8 e+ `
  481.     else
    5 f: W6 ]" _1 T& f  E+ }
  482.       @move_state = 04 }- f* F" m6 |2 Z0 c& w# k
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col4 J2 `9 r. Q8 r
  484.       select(new_index) if new_index  item_max && new_index != @index. n- h9 p( q+ f( r/ O
  485.     end
    6 g$ j+ d2 ~3 g' Y- p
  486.   end
    7 U- @( I) V8 w6 n, S+ [- T
  487.   #--------------------------------------------------------------------------  O4 A1 D8 m% A2 D$ T" F' Q4 V
  488.   # ● 判断鼠标位于菜单的第几行、第几列2 L& ~/ @/ b5 \
  489.   #--------------------------------------------------------------------------
    . H7 R6 N+ R; O- M- }# \6 P
  490.   def mouse_window_area
    5 R: l. L/ A4 L5 G: e% J
  491.     if viewport.nil # necessary!% `8 W* u. K9 u- k: O$ Z
  492.       vp_x, vp_y = 0, 04 o. g' ?* F3 d: N4 I+ \0 f
  493.     else
    ) J5 H$ W. F* |3 \& [; Y. m
  494.       vp_x = viewport.rect.x - viewport.ox
    & _+ w8 m8 F/ ~, U3 E# f( [" C. s- N
  495.       vp_y = viewport.rect.y - viewport.oy
    4 y& x, o/ }. o2 R( [8 S- l/ m( a
  496.     end3 s" I$ V: h* z- W
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    & H# W& p5 z) ^
  498.     item_x1 = vp_x + x + standard_padding : X6 M- m% R( Q: T0 u$ {
  499.     item_y1 = vp_y + y + standard_padding' j& l/ H9 Q/ R, Y# H  t( ~
  500.     item_x2 = vp_x + x - standard_padding + width  }" u8 O5 Q' I/ K6 W' _
  501.     item_y2 = vp_y + y - standard_padding + height8 a( H+ j2 c# s7 ]
  502.     if mouse_x  item_x1* o8 E0 l$ }8 A; ~
  503.       mouse_col = -1
    4 C2 i( `+ j! O  `& n  [
  504.     elsif mouse_x  item_x25 g& h6 ]- f( g; l- P2 j* Y
  505.       mouse_col = -2  w, K  u+ K2 o  ?2 k  T6 ]
  506.     else0 ~0 k& V8 X6 }/ s
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    4 [7 a$ e) d& R6 ?
  508.     end
    " D0 ?3 n& i; k8 E) P  i" L9 B( C
  509.     if mouse_y  item_y1
    6 [( M  Q/ S% r* f0 ~
  510.       mouse_row = -1+ S: W! u& {; k* {6 r
  511.     elsif mouse_y  item_y20 c# }: x& v+ d; x! W
  512.       mouse_row = -2
    ' p% z1 s# \! M* X. `1 R3 e
  513.     else$ o( X) z, ~5 _9 ]8 q
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    : W* |1 a1 R7 B9 P" z; Y  y2 b
  515.     end
    : T2 w/ H8 `- w
  516.     return mouse_row, mouse_col
    + Y% i: f( a9 |; C. J( h
  517.   end
    % Q1 v  ]. a" J; k
  518.   #--------------------------------------------------------------------------5 ^) ^4 b4 ~, k/ ?/ X2 @; ^! y6 t
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    $ E& q( S& P# a+ D$ @" C5 y
  520.   #--------------------------------------------------------------------------+ @+ G+ ^; _8 S
  521.   def set_mouse_pos
    9 M* \* T' G* |4 m" K- t; g
  522.     if viewport.nil # necessary!3 C2 M2 c  H4 Y8 L1 {
  523.       vp_x, vp_y = 0, 0" v: j0 D6 c7 \& P4 _& _+ {
  524.     else% k, H* G, a/ c- G2 C% l7 N
  525.       vp_x = viewport.rect.x - viewport.ox2 H- x7 ~5 u5 H; @: [* a
  526.       vp_y = viewport.rect.y - viewport.oy9 ~; T$ {( A6 y3 t
  527.     end
    , U0 z7 k/ @& B* q
  528.     item_x1 = vp_x + x + standard_padding & W0 |3 w& `6 X0 k5 ]
  529.     item_y1 = vp_y + y + standard_padding5 A' T/ X' ^" S2 j0 J# k3 _
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    ! _" U; K# W! {. D9 E: U
  531.     row = get_index  col_max - top_row/ k2 F8 F8 ~/ Z
  532.     col = get_index % col_max8 e' c0 I3 o( ]& m/ _9 e
  533.     new_x = item_x1 + item_width  (col + 0.5)
    & |2 ?) K$ _# f+ {
  534.     new_y = item_y1 + item_height  (row + 0.5)# y  b3 N* ], j7 ]/ d& V' Q. x
  535.     Mouse.set_mouse_pos(new_x, new_y)! B  S9 s! Y1 ?4 w! I! A+ v  P
  536.   end2 d, l( X+ w3 F& w, _% ~
  537.   #--------------------------------------------------------------------------# P- x1 Z2 }8 Y! _# W  B& _% j. Z
  538.   # ● 判断菜单是否需要卷动! q1 H$ v( o9 @3 J: ^
  539.   #--------------------------------------------------------------------------0 S3 {+ d, h. A; f0 _7 |
  540.   def need_scroll
    . D1 K' \' }5 a# N! y0 v
  541.     item_max  col_max  page_row_max" m" L+ N8 z4 B& p6 f+ s1 }' E) W$ j: B
  542.   end
    ! U4 C4 O9 g8 R& A9 w8 J
  543.   #--------------------------------------------------------------------------" f% O3 k) O' A8 ^: d
  544.   # ● 判断是否为水平卷动菜单# s& M# M: I+ g1 E2 M9 K
  545.   #--------------------------------------------------------------------------
    6 g! x- ^$ _5 N8 x" [2 h
  546.   def is_horzcommand
    3 F  ^; P. w; X
  547.     return false9 w8 m/ w2 U, c# Q. v) f
  548.   end
    ( c% J! _$ H5 B: a4 t3 B
  549. end2 p8 ?5 j* X2 L
  550. 6 v) d) G8 G$ N0 ]
  551. class Window_HorzCommand; y6 i6 q5 G6 c) [) A# w
  552.   #--------------------------------------------------------------------------
    $ F* ?' e0 p. K* f
  553.   # ● 判断是否为水平卷动菜单
    / o/ g: s# c6 F& d3 V: c0 S- D
  554.   #--------------------------------------------------------------------------2 G7 f" m5 w9 N# m1 R6 Y) P, w
  555.   def is_horzcommand3 f. f' @& B- k8 K  O" l3 @
  556.     return true
    1 c- a- Y8 c9 A% f
  557.   end% V; Z) B/ K2 R9 D4 z1 p
  558. end
    8 y6 t" N* W. u" u' E2 i% ~

  559. 8 R( Z, X% W. r* Y+ F
  560. #==============================================================================
    ( s3 L3 \$ h! Y! q, {! g
  561. # ■ Window_NameInput' H: o8 F) p% l# c8 F- e2 W/ _
  562. #------------------------------------------------------------------------------
    . _) W5 _5 b1 e
  563. #  名字输入画面中,选择文字的窗口。
    ' o7 X. s! y* t; q, Y8 |. l8 O+ g
  564. #==============================================================================
    3 o5 t# W/ q1 K4 ^, U$ O
  565. class Window_NameInput
    ! s- M$ D7 K+ O8 V  L4 W
  566.   #--------------------------------------------------------------------------
    0 b( A4 D2 r1 j: w; Z3 K8 _( H* s
  567.   # ● 设置列数$ w4 b  u3 c. \, w
  568.   #--------------------------------------------------------------------------
    4 ]7 r" P' Q2 L* I
  569.   def col_max
    - w. E4 _7 G" s' O7 y
  570.     return 10
    % c5 r/ M+ F3 y4 U; z! M; H
  571.   end
    + Q- A1 C; t2 D; V
  572.   #--------------------------------------------------------------------------! {) X8 S- d: S1 e& [. v! J, D/ g
  573.   # ● 设置填充的Item个数
    7 m, {4 ?# |# h0 J, Q) v4 ~
  574.   #--------------------------------------------------------------------------5 y' e% j1 \! f- `  m
  575.   def item_max
    # ]6 H! c: R( W, z- {$ y
  576.     return 90! I, E& m0 u1 \4 i: b
  577.   end
    ) e5 M" [4 z& E4 o+ C) l
  578.   #--------------------------------------------------------------------------3 g8 g, B3 z" X& N4 [  A2 K, v
  579.   # ● 设置填充的Item个数, s" [" |" M( f' p8 {; k
  580.   #--------------------------------------------------------------------------
    / y% C  O) Q4 G' G* @4 J, W, w
  581.   def item_width
    . A- V( k* L& `* t; _- g3 B
  582.     return 326 Y  D; B6 E% P- p& }8 g8 @
  583.   end
    4 y/ G+ H* Q$ O# Q; s* z8 D7 x1 S, _( A
  584.   #--------------------------------------------------------------------------8 E$ A: w/ Q' \
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    " i! F8 z3 r* E5 F1 a
  586.   #--------------------------------------------------------------------------: b+ R  Q& P4 N/ K/ X: Q
  587.   def mouse_window_area2 s, i( g) Q% y; R! N, C  J5 a
  588.     if viewport.nil
    5 r. F; }' A! V4 U4 \' e" O+ Y6 m
  589.       vp_x, vp_y = 0, 0
    . T% L& d  M6 l( @+ I
  590.     else) _% T$ J6 E( w
  591.       vp_x = viewport.rect.x - viewport.ox% t0 M- e7 _9 J1 l" \
  592.       vp_y = viewport.rect.y - viewport.oy
    ; Z6 t6 C4 t: G' ^7 d1 @5 v
  593.     end+ \* Y5 z3 @3 X6 s- P2 p
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y" m  f- b1 Q. |& L) C- N
  595.     item_x1 = vp_x + x + standard_padding
    % @7 H$ |4 o! n3 }# w( |
  596.     item_y1 = vp_y + y + standard_padding% ~; u3 n7 a% n2 e5 {
  597.     item_x2 = vp_x + x - standard_padding + width5 R; {( a" `% Z
  598.     item_y2 = vp_y + y - standard_padding + height
    2 _/ }) r, ~3 K
  599.     if mouse_x  item_x1& K1 Y2 v1 l# L5 \4 c0 ]
  600.       mouse_col = -1  \8 S7 Y& ^+ G- I0 d: V7 O8 E
  601.     elsif mouse_x  item_x22 M: ]! S) c5 A5 M
  602.       mouse_col = -2
    $ Z6 X+ Z1 _" y* V" M: m7 u
  603.     elsif mouse_x  item_x1 + 160. M- I9 N0 }0 e/ ?! @
  604.       mouse_col = (mouse_x - item_x1)32# H9 j: H$ J- c  ]* [
  605.     elsif mouse_x  item_x2 - 160
    : g+ U  Q7 L/ b" A( \
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    ) ^  [" p! I4 \* t4 ?) ]
  607.     else+ n; o8 L' Y  D
  608.       mouse_col = mouse_x  x + width2  5  4) P* E- `) E' k$ {; `; E& A
  609.     end
    ) Y' E  k  O7 |: u; w3 c1 o
  610.     if mouse_y  item_y1
    3 c6 a, M% P9 o4 n
  611.       mouse_row = -1
    ) c' w' p+ ]* F& g1 ?
  612.     elsif mouse_y  item_y2- z; R6 J0 i; k5 M: ~2 D3 e
  613.       mouse_row = -29 V7 s$ m2 f- V. s# {$ x% Q
  614.     else
    ' W8 h8 Z( ?2 _2 u! v$ V
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    1 \+ ~( p. d" |! ^, d2 D  L, Z0 E
  616.     end6 {6 e7 `8 d1 ^) X' F' X
  617.     return mouse_row, mouse_col
    ) {$ X5 N: j" f) Z/ r
  618.   end. K8 f* l1 N( G8 s. h- b
  619.   #--------------------------------------------------------------------------' J* k) F1 o9 u  \4 t% o
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置: F% h. Q2 d1 k. e4 _. C$ R
  621.   #--------------------------------------------------------------------------& I/ T1 h2 f9 X  `! I
  622.   def set_mouse_pos- j# ^: W9 g9 `
  623.     if viewport.nil # necessary!
    % q' G, ^! E8 _; i( Z0 g  f
  624.       vp_x, vp_y = 0, 00 Z4 B! w% X+ _6 u
  625.     else  o! V7 C) t0 w8 x# q: I7 [
  626.       vp_x = viewport.rect.x - viewport.ox
    9 t. a& U* m: D- e% r5 \- J; q
  627.       vp_y = viewport.rect.y - viewport.oy
    6 b4 E" u9 @, V( v
  628.     end
    - V- U9 o( f0 ?$ s/ p3 k0 g" f1 W
  629.     item_x1 = vp_x + x + standard_padding : A7 f9 n" e+ G- S
  630.     item_y1 = vp_y + y + standard_padding
    $ {/ s4 E: ^7 @" W1 _% A
  631.     get_index = @index  0  0  @index
    - P4 f4 |! [6 b; e& K
  632.     row = get_index  col_max - top_row: C7 d. e3 u% D% q. E* M
  633.     col = get_index % col_max  D6 T9 t5 @8 Y
  634.     new_x = item_x1 + item_width  (col + 0.5)( y# [5 w" f7 T; {* W  u+ B' `
  635.     new_y = item_y1 + item_height  (row + 0.5)
      f7 \+ n( r, ~
  636.     new_x += 14 if col  4
    1 \' l& Z- E# I) d
  637.     Mouse.set_mouse_pos(new_x, new_y)
    1 U2 @. i$ h% N1 @7 r% e
  638.   end
    ! _0 i5 i2 ]1 O" o& S/ I
  639. end
    ) F- c0 o9 B% [6 p

  640. 0 n$ \- q5 c8 I! b4 v0 O1 h% A8 o. a
  641. #==============================================================================
    1 @2 X3 S1 {, t9 {' f8 w2 e. ~
  642. # ■ Window_NumberInput9 b  c6 j& ]$ N) ^' Y, o5 ?$ V# @: K* d
  643. #------------------------------------------------------------------------------  D1 X; ]2 f) z* v4 D
  644. #  重写了数值输入的方法以适应鼠标
    % z$ T; G$ e$ j0 q% A$ W
  645. #==============================================================================" m9 S1 v* V& Z1 d1 g
  646. class Window_NumberInput  Window_Base
    6 \4 R9 U$ A- N$ H, \$ P
  647.   #--------------------------------------------------------------------------( h1 D; m( D* F
  648.   # ● 定义实例变量" H  N5 Q$ V& D& Y% V/ ^% c
  649.   #--------------------------------------------------------------------------
    " ], f, n9 x, G- ~
  650.   attr_reader extra_window
    ! f- T. v- D- r0 V; |# P1 U
  651.   #--------------------------------------------------------------------------
    ! G2 f- `, m* K
  652.   # ● 初始化0 N/ g- |8 R* v6 O4 c* O
  653.   #--------------------------------------------------------------------------; S" _, Q$ x, g- C/ x+ M' y- V
  654.   alias sion_mouse_initialize initialize* l5 t: Y6 y( y7 ^
  655.   def initialize(arg)
    ' _9 M' V0 P1 _0 `# H0 V9 j! ^
  656.     sion_mouse_initialize(arg)
    3 _0 @8 g. r; `" C2 _
  657.     create_extra_window6 m/ U: e: V4 `* Q! t4 m
  658.   end2 M6 d( f6 n* B, Q
  659.   #--------------------------------------------------------------------------; v- w3 {2 B1 b* @( _
  660.   # ● 启动
    : }/ H2 h4 U3 ?4 C
  661.   #--------------------------------------------------------------------------
    $ G; k" z  Y; y
  662.   alias sion_mouse_start start
    - p1 m+ w; v; g; w* [5 U, p
  663.   def start7 f( e; f# e0 \( ^4 q7 {
  664.     sion_mouse_start
    ) V: c( @% s+ g
  665.     deactivate+ ?7 q# q# A8 j& I  |
  666.     extra_start
    . c1 }+ X! j: t3 `. n: D
  667.   end4 Q" F" i1 ^6 J# C4 z3 r8 G% L
  668.   #--------------------------------------------------------------------------8 [% b5 \' |/ c0 R2 c
  669.   # ● 创建新的数值输入窗口
    9 z: W5 V/ [$ `" ~% _  }' }
  670.   #--------------------------------------------------------------------------9 r1 U3 n# L1 I7 r8 p% N/ h8 M
  671.   def create_extra_window
    ' Z7 Y% G3 Z& a1 n- [
  672.     @extra_window = Window_NumberInput_Ex.new
    $ F4 v) q6 e% q" l+ C- B
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    % |' F% v3 K+ P3 {
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }- w! K: |: H4 l+ A
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    7 N- d4 _8 ~/ J4 t1 {
  676.     @extra_window.close_proc   = Proc.new { close }0 ~, e5 V/ [# e7 w5 k
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    2 _, U  Z' s. }5 \# m
  678.   end
    ) _: _' Q. M$ i4 h
  679.   #--------------------------------------------------------------------------4 e! e* f' i  E+ y9 q/ }2 I% l! u
  680.   # ● 激活新窗口
      O8 C: O3 x/ M, J, u1 L7 {  a& W
  681.   #--------------------------------------------------------------------------  B( L) i5 J( Z6 c, L9 i; G) m
  682.   def extra_start
    ) q. Z9 ~8 V3 [; X/ ?7 _( h
  683.     case $game_message.position
    8 M& o! M# v# V7 |3 U% g  V
  684.       when 0; @extra_window.y = y + height + 4
    ( S( Q; Y& h0 z
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 84 X* [  u" D! Y9 r& \
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    , @8 M6 d3 m" b* m: ~, }$ Y
  687.       else  ; @extra_window.y = 8. c, A% F0 n1 o3 F/ F
  688.     end# m( U* p; }! P' K8 Y% q2 ]7 [7 K$ g
  689.     @extra_window.variable_id = $game_message.num_input_variable_id' f. x, Y0 ^) d; {; {
  690.     @extra_window.digits_max  = @digits_max! b4 u$ z1 ~. h: y2 i! X
  691.     @extra_window.number      = @number
    3 d% _0 Y0 w4 H  g
  692.     @extra_window.open
    , S- Z; h" `# C- O3 {. A# x( A
  693.     @extra_window.activate
    8 T* y! `' p* Z" F+ S
  694.   end' n* @. P; m% \) `5 W6 b  p3 G  s. M2 K
  695.   #--------------------------------------------------------------------------
    7 l3 `$ a9 ~1 [1 \. O
  696.   # ● 更新3 F4 i! \" d) n& W% r8 E, v
  697.   #--------------------------------------------------------------------------* V* }. {5 m! _
  698.   def update2 j" `- B3 V9 m3 C2 L2 G  q
  699.     super
    ) h8 J( O9 u9 S' w, Q1 G
  700.     @extra_window.update0 j5 n/ t' `% p, D* j' h# V
  701.     update_cursor1 f) d/ I# }0 z0 g6 x$ p- A; L0 z
  702.   end# h+ |% h( J; M$ O
  703.   #--------------------------------------------------------------------------
    - D  D0 F0 Y, q  F% O$ [' |6 m
  704.   # ● 关闭窗口
      I, @( z9 R% \* X- `0 R
  705.   #--------------------------------------------------------------------------
    - }0 H: n/ ]: D+ f) Q! ]+ x
  706.   def close
    1 Z% ~3 i, g6 M5 e8 _
  707.     super8 f- y' \, u7 b8 Q% _" t! t
  708.     @extra_window.close% c9 t# J; G5 F8 c
  709.     @extra_window.deactivate, T- Q& {) d9 T, s. z& C
  710.   end
    ) E  q9 O, l2 A3 G# }4 H5 [( O
  711. end( e- Q* v8 {' R! J* }& A/ C$ M6 e

  712. ) S, i0 @, P4 |! A" o9 x7 f
  713. #==============================================================================. X/ F) a( ^6 |2 Q, ~1 h
  714. # ■ Window_NumberInput_Ex0 F) e- a/ |8 o" i
  715. #------------------------------------------------------------------------------8 U2 B0 n  o5 L7 L& \) _1 o
  716. #  新的数值输入窗口(NewClass)
    + h8 M/ G2 V4 ?( A  ~5 @: j7 O1 O
  717. #==============================================================================0 M; t: u6 M5 q; _
  718. class Window_NumberInput_Ex  Window_Selectable7 ^1 x" W1 C+ F! z  p
  719.   #--------------------------------------------------------------------------
    - ~* O4 C. N) a1 i( p  H; `
  720.   # ● 定义实例变量8 I8 L0 k( o5 f) j8 l* ~
  721.   #--------------------------------------------------------------------------
    7 e% d3 y% T! r# z: D
  722.   attr_accessor number_proc  n) W3 M0 q: _1 |; a/ V
  723.   attr_accessor index_proc
    % g8 l& ~" g' x
  724.   attr_accessor close_proc( P, B* T4 m/ D6 X  T& c6 v
  725.   attr_accessor refresh_proc) _. W; l: H9 z1 @
  726.   attr_accessor number
    ! h8 x& I7 [" d. [2 U; V3 I
  727.   attr_accessor digits_max( D+ z. i6 @& V+ G
  728.   attr_accessor variable_id6 P5 ?) K* q2 Q2 ~
  729.   #--------------------------------------------------------------------------6 J0 W# o0 i; z# ]: h5 t" |
  730.   # ● 数字表2 }8 n: d( `7 t: j: }3 N0 W: h
  731.   #--------------------------------------------------------------------------9 S0 J; |1 Y# F4 J3 Y2 O
  732.   TABLE = [  7,  8,  9,
    0 E  H& U! m1 S1 s5 d
  733.              4,  5,  6,
    4 K  X% I& ]7 c, ]& z: C1 d% D
  734.              1,  2,  3,- b* y8 E$ \4 I& Q
  735.             '←',0,'确定',]9 _/ y# B6 M: N5 x
  736.   #--------------------------------------------------------------------------( ^9 x( `# r3 A2 G. Y( h5 m
  737.   # ● 初始化对象1 b8 m4 H$ @0 G5 B2 f+ y) _
  738.   #--------------------------------------------------------------------------
    . r1 U# Y0 E  o
  739.   def initialize! S$ s2 Y1 n9 I5 w* b+ `1 y5 N
  740.     super(0, 0, 120, fitting_height(4))+ t, s) [  f7 X- _% B6 V
  741.     self.openness = 0
    . N1 m3 @/ i$ f5 O" U7 P! O
  742.     @index = 0
    ! x  S# X& x$ e  M' S) n$ S( n
  743.     @number = 06 E3 A8 V2 t; h6 U. h
  744.     @old_window_index = 0( t- I# X5 x; O$ G3 Y: e, O
  745.     @digits_max = 0/ X9 k* A* T! q) `
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }: H6 e) I- ]1 a) l) u4 @
  747.   end
    ! ^6 j7 K# l2 x8 R- g$ L
  748.   #--------------------------------------------------------------------------  s5 _8 ?6 @: v  X! v2 q0 t
  749.   # ● 获取项目的绘制矩形6 V, c6 w7 v: M  p8 U% d$ W8 L
  750.   #--------------------------------------------------------------------------: j4 y/ q- _+ n' m$ v. d
  751.   def item_rect(index)5 Y8 V' Z& y( H4 a
  752.     rect = Rect.new. [4 w8 y9 p4 d$ }6 R
  753.     rect.x = index % 3  32
    3 w$ P. r9 z! [6 x
  754.     rect.y = index  3  line_height4 r, t5 s- t. o" k7 c- t) m
  755.     rect.width = 328 v7 h5 ?) l4 l; s! G
  756.     rect.height = line_height4 i* k* e3 z+ v3 K& n
  757.     return rect! y) T8 f( U4 n& {
  758.   end
    0 ~/ N. u7 b, t, n# _( U4 |
  759.   #--------------------------------------------------------------------------
    6 p; r" j( R% x# E/ a- V
  760.   # ● 将光标设置到鼠标所在的位置
    , }) q1 F% S0 c) r6 j- u. f- H- Z
  761.   #--------------------------------------------------------------------------
    7 g' U3 e( e8 k7 q4 b
  762.   def set_cursor
    ( S# S1 C7 `5 u  y: K; ]: ]2 w. ?
  763.     mouse_row, mouse_col = mouse_window_area
    # ^6 |+ Y! s$ ]. @9 }
  764.     if mouse_row = 0 && mouse_col = 0
    - r# A' g: G+ Q" \% }- A; e7 [
  765.       new_index = mouse_row  3 + mouse_col
    ( I5 G1 x6 F( K4 d7 F4 a0 n0 U
  766.       select(new_index) if new_index = 11
    $ ~) s2 Z# F' z9 v
  767.     end
    7 N4 p- t( L& ]) L8 U5 [# {: ~* {7 t
  768.   end
    4 f/ a  w  @& G$ Z; A
  769.   #--------------------------------------------------------------------------
    ) J0 m6 D8 N. \0 Z  I4 \1 R# m
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    1 [- x  G$ W, ^6 m8 ]& c  h
  771.   #--------------------------------------------------------------------------
    ! I7 w: B. H/ ?2 Z; z
  772.   def mouse_window_area4 V- U1 ~6 A! [, u2 b' H7 i
  773.     if viewport.nil
    / t) W6 E7 w- H( s! y
  774.       vp_x, vp_y = 0, 04 N9 y% P0 Y* E/ X* `
  775.     else
    ; G& a+ K( U7 r, f# h
  776.       vp_x = viewport.rect.x - viewport.ox( R/ B9 |2 E* A0 Q- b
  777.       vp_y = viewport.rect.y - viewport.oy
    3 ^. w3 S; U, P: W6 e2 v: C& M
  778.     end
    $ U2 C3 E) [0 ?: ?, E5 A. z
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    3 s$ y( |: F+ P! O" w. h) m% ^
  780.     item_x1 = vp_x + x + standard_padding
    + l* v( d1 B( y6 z  c; d
  781.     item_y1 = vp_y + y + standard_padding
    ' @* l, Z* `+ V  i: M
  782.     item_x2 = vp_x + x - standard_padding + width0 T! g0 u9 `( L) @$ R6 N) Q
  783.     item_y2 = vp_y + y - standard_padding + height& Q9 t; I$ F% F
  784.     if mouse_x  item_x1, ^2 \% w% o) |, Y/ r
  785.       mouse_col = -1( p( j+ y- R0 B
  786.     elsif mouse_x  item_x2
    ) k! V. i* Z/ {  k% ~
  787.       mouse_col = -2
      ]2 P1 S# c: H; @
  788.     else! ?! ?8 O  [+ X3 B8 z
  789.       mouse_col = (mouse_x - item_x1)  32
    0 o* U, A: y4 c' B$ a% q" l6 c  L% g
  790.     end
    " }  ^; D2 ~9 a
  791.     if mouse_y  item_y1
    ! x7 {* K4 W) J5 M
  792.       mouse_row = -1
    5 w- A: k2 j3 e5 ~1 ~/ G8 M8 T% n
  793.     elsif mouse_y  item_y23 V3 C" w7 J8 e0 z0 n$ u
  794.       mouse_row = -2* N, U# k( e; \$ T3 t: D3 M- F
  795.     else
    : g( e/ R. s- P) v% u9 `
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    5 w- s% w: `, a* U
  797.     end
    $ P9 C' {( ]. z  a. X7 x2 \
  798.     return mouse_row, mouse_col
    ( b# ^- h# R2 q  [6 W/ u
  799.   end
    " Q% T: j  b9 t( z, o! g* k
  800.   #--------------------------------------------------------------------------
    : G4 e+ n  f( x3 [/ S* F
  801.   # ● 获取文字
    0 d$ H1 W1 V+ ^7 g8 P7 e/ c
  802.   #--------------------------------------------------------------------------& y4 o+ c4 O( H
  803.   def get_number
    9 b, V4 O6 m- ^
  804.     return false if @index == 9  @index == 11
    4 i7 a5 U( u( m, `" g: P7 v
  805.     return TABLE[@index]
    7 y2 H( {" t8 }6 Y' V! H
  806.   end, X' e" f( ?% D* x2 r
  807.   #--------------------------------------------------------------------------" w' [( Y. Y4 \3 @7 _' [6 r$ G
  808.   # ● 判定光标位置是否在“退格”上& x. E, _2 I5 y8 t  F
  809.   #--------------------------------------------------------------------------9 n# ?& w+ X7 x) S( k- J) [( R
  810.   def is_delete9 ~9 Z% X) _" v( o1 @
  811.     @index == 9: q6 A3 f; E: J
  812.   end
    6 N4 S) t4 D# q' h5 l- b3 W  {8 K
  813.   #--------------------------------------------------------------------------
    0 H9 `7 k: D# P6 W! ]. l
  814.   # ● 判定光标位置是否在“确定”上
    " h) ^3 D( @5 o) C& E  n6 @
  815.   #--------------------------------------------------------------------------) J: i) M& p! s1 D+ u
  816.   def is_ok
    ( }# a1 ]) T, b$ N
  817.     @index == 11, n4 ]' u+ y% R( z7 J0 N1 E
  818.   end
    + g- H0 c4 ?6 |; [
  819.   #--------------------------------------------------------------------------
      v7 Y1 S3 G0 c% O, r& m) J
  820.   # ● 更新光标. v* T, m5 R& c; H5 |, _# l
  821.   #--------------------------------------------------------------------------
    ) ~9 L; Q& k) h( @5 k% i
  822.   def update_cursor; s1 r, t( E% [3 k
  823.     cursor_rect.set(item_rect(@index))
    4 X( l" G5 U% x3 \
  824.   end1 d3 t( \7 ~* N3 X( O  o5 X0 O6 {
  825.   #--------------------------------------------------------------------------
    8 Z+ H  z1 e( y
  826.   # ● 判定光标是否可以移动/ q2 D# f: W# x  m' ]" y
  827.   #--------------------------------------------------------------------------
    - X5 L- G! l" {& I3 _
  828.   def cursor_movable
    * F2 ^. P+ F9 A4 I0 I# D) h" d; x  I
  829.     active
    3 E, \4 H2 f& `. ^8 Y7 D2 n( ]
  830.   end
    % `- L2 }9 Y' R% {" X
  831.   #--------------------------------------------------------------------------8 |! J( q" T' w) s8 m& H: L
  832.   # ● 光标向下移动
    % {( t( ~! B4 f+ R* u
  833.   #     wrap  允许循环, w& A# ^* j+ `, J7 P
  834.   #--------------------------------------------------------------------------7 J0 Z! R* L( a8 t9 J5 R. [
  835.   def cursor_down(wrap)
    6 s: l' V7 s# P% Q+ W. a2 O
  836.     if @index  9 or wrap
      x5 T) e5 g5 j4 _$ I4 B, e% O
  837.       @index = (index + 3) % 125 _/ }1 X8 c  ~" N0 A1 K
  838.     end& Q3 y/ m9 h9 m$ @5 T! W! E
  839.   end* R3 p& f+ U3 ?8 `, b- ~: d
  840.   #--------------------------------------------------------------------------' p% {7 h5 A: i  h5 z* U9 w
  841.   # ● 光标向上移动% U( z- ^! F1 n- R  o) I! G. R
  842.   #     wrap  允许循环
    6 @* Y4 P" ]% G* i# r+ [. z
  843.   #--------------------------------------------------------------------------1 H1 E+ P% g" b8 w1 G& g. z' Z5 H
  844.   def cursor_up(wrap)# T: l; W% q7 K" G1 I. x
  845.     if @index = 3 or wrap
    + C" _' @. h3 L
  846.       @index = (index + 9) % 12$ w/ n4 D1 O1 u2 d* h" c7 C
  847.     end/ N4 i! o# B( t" p. A
  848.   end
    ! n! B* q3 H5 N* R& d/ |
  849.   #--------------------------------------------------------------------------1 e' B. i5 T5 W6 G1 {
  850.   # ● 光标向右移动- v7 i: Y- V: u3 W9 U
  851.   #     wrap  允许循环
    2 Z% i1 U4 m  P8 o* d4 s
  852.   #--------------------------------------------------------------------------
    + t3 {0 m) _) f6 s. Y+ ~( j
  853.   def cursor_right(wrap)0 Q: z1 q7 B7 {! P5 Z1 |( I7 V
  854.     if @index % 3  2% ]; x, [  |5 w: |6 S2 [! N
  855.       @index += 1# o. J% C5 d( S( P* U0 L) P& E4 J
  856.     elsif wrap1 _  P+ Q3 u$ |( R
  857.       @index -= 25 P& x( Q* L/ [" n
  858.     end
    7 L0 m  F. O% g6 \8 P
  859.   end
    % k% I1 k7 A! @! K" s! M( T, w2 m
  860.   #--------------------------------------------------------------------------' \$ F/ F5 s" M: i
  861.   # ● 光标向左移动
    - G7 |0 A; i( Q) p$ I4 ]1 Y) A
  862.   #     wrap  允许循环
    + I# f7 V- B6 J( S! i$ w/ F
  863.   #--------------------------------------------------------------------------0 O& x5 }; q" E! V; H+ H
  864.   def cursor_left(wrap)9 k0 Z9 ]5 @+ f0 s7 ^3 p
  865.     if @index % 3  0' F- F  ?. A' Z4 ~3 Q2 v/ t
  866.       @index -= 1
    8 }# p' O% y: d2 J! t
  867.     elsif wrap; e& |/ {. {$ H3 C2 k) J
  868.       @index += 2; b/ `6 u. L2 O  Z
  869.     end1 |2 s! W6 S. `! Y6 Q% B! o
  870.   end
    7 l  t5 _! W; R. e3 Z
  871.   #--------------------------------------------------------------------------
    $ ?! `) A8 U! k9 G4 q+ @
  872.   # ● 处理光标的移动
    : `$ x! a4 z9 K7 L2 X* [. G
  873.   #--------------------------------------------------------------------------
    8 v4 ^0 ?) \) e6 r+ W; ^
  874.   def process_cursor_move
    ) O4 |, n* E/ P4 d2 c) f3 p2 B
  875.     super8 F" @6 a6 S# [" W/ _! d
  876.     update_cursor, t3 f% a6 U9 S) j! s6 h9 f
  877.   end
    + r* j6 q! [+ G- J; G
  878.   #--------------------------------------------------------------------------8 C7 v8 u3 m9 y9 m% n
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    7 G/ {3 q' V+ |* a  O
  880.   #--------------------------------------------------------------------------0 y$ F1 J) T+ `
  881.   def process_handling
    1 x2 ]# O2 y6 T% }! z
  882.     return unless open && active
    1 V0 z3 ~7 T* ^4 Y4 |8 z) n
  883.     process_jump if Input.trigger(A)# M3 y  b2 C- z% V4 f; {" _
  884.     process_back if Input.repeat(B)
    " w# i2 ~: o1 R& S5 Y; B
  885.     process_ok   if Input.trigger(C)) p. r- T9 A5 w8 u! l
  886.   end
    + ^- o' n0 Z7 B8 s
  887.   #--------------------------------------------------------------------------
    5 n3 Q  q* v$ a" o+ a3 ?! G
  888.   # ● 跳转“确定”
    ; t/ u' E" P# w& n3 s/ X
  889.   #--------------------------------------------------------------------------
    * L9 L8 P* k) f) f4 _) S3 ]
  890.   def process_jump6 g1 y2 e) C" Y3 U! V# N
  891.     if @index != 11/ |& Z2 p% z/ v# B
  892.       @index = 115 l/ }$ y, \3 t3 S
  893.       Sound.play_cursor; c3 O* ~4 i' c* H/ x- D
  894.     end
    ! u) ^, N  g( Y- e
  895.   end
    " |" j) W) s9 B$ r0 ^
  896.   #--------------------------------------------------------------------------
    3 i1 e" X# S+ R1 z3 Z+ {/ t$ N
  897.   # ● 后退一个字符' j- E$ s- |0 f; {" l
  898.   #--------------------------------------------------------------------------
    % v' b* w6 W% ]% O
  899.   def process_back
    . a& v. f8 o* {. W
  900.     Sound.play_cancel& d! T' X) z1 F+ Z8 _/ o4 J8 ]; L
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    ) n0 z6 m+ G5 j
  902.     n = (@number  place) % 10
    1 _1 J5 h' g4 M+ j0 G
  903.     @number -= n  place
    4 i4 C, U. d. A
  904.     @number_proc.call(@number)+ ]/ ?+ ^& U' `0 C
  905.     @old_window_index -= 1 if @old_window_index  0
    7 x, K  q4 {" r+ b8 u- a, h
  906.     @index_proc.call(@old_window_index)
    ' T% j1 W7 ?$ D6 r: I8 b
  907.     @refresh_proc.call
    4 E+ X; I! R7 o, v
  908.   end
    + l% b; C) ~1 m$ |9 C) b( U
  909.   #--------------------------------------------------------------------------
    . L. K9 r9 M! J* q0 l+ \
  910.   # ● 按下确定键时的处理
    , I' V4 A/ }/ }. ~
  911.   #--------------------------------------------------------------------------
    ) ^/ L; g: z' t6 b3 p1 y
  912.   def process_ok7 E" G& I; x0 b/ `+ q$ f
  913.     if get_number4 t1 B; }3 _3 Y0 ?$ f  d  K
  914.       Sound.play_cursor6 g4 F1 G. d/ z7 {: C0 \
  915.       place = 10  (@digits_max - 1 - @old_window_index)" ]7 i# k& ?: A5 F* U1 l
  916.       n = get_number - (@number  place) % 10# H% e% L( V7 N9 H3 Z- @6 D1 U
  917.       @number += n  place
    2 ?1 d8 E/ |! Q+ v
  918.       @number_proc.call(@number)6 k: @( V* H7 E( C
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1  @: g7 Q: h+ B3 D2 Z
  920.       @index_proc.call(@old_window_index)
    . s! A* Z* x% H" y4 M! ]) o
  921.       @refresh_proc.call% D+ L, Y" b$ p5 I' c, F+ N4 Q; F5 r
  922.     elsif is_delete
    : s5 w8 T* U+ |9 n; p
  923.       process_back$ D! X1 v' \9 B( O1 S
  924.     elsif is_ok
    . e8 M" |7 o6 E! T  P$ v
  925.       on_input_ok2 ^, |8 P0 P( ]2 D- F  K" f
  926.     end
    ) J( i- e4 |0 N3 N; s; D
  927.   end' E# L( G! B; O( r& I" J7 K- q5 @
  928.   #--------------------------------------------------------------------------% v$ y7 y1 f, |$ }  ?) A; c/ L
  929.   # ● 确定
    * H7 |$ w/ n) N1 f9 r6 ^
  930.   #--------------------------------------------------------------------------
    ( z( F5 Q  U$ J& x+ r2 }
  931.   def on_input_ok* ]3 f: v& N) t
  932.     @index = 0
      A# {+ W  W6 W3 i8 h4 P
  933.     @old_window_index = 0% N7 J, p! z+ P/ ^  H+ R
  934.     $game_variables[@variable_id] = @number/ c: j8 ?* k) J( N
  935.     Sound.play_ok
    1 J0 D7 y5 f0 U  N; g
  936.     @close_proc.call
    5 b& F4 J5 B6 B- ?% L0 K/ \
  937.   end3 I" e$ S  q$ O4 W
  938.   #--------------------------------------------------------------------------) w1 ^- C5 a1 E; @" g% g
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置4 B- A1 W9 o: `8 r" x
  940.   #--------------------------------------------------------------------------
    . r% X2 V2 Z8 U" |
  941.   def set_mouse_pos2 D% s8 [) `1 G7 s
  942.     if viewport.nil # necessary!9 x3 k$ z: i3 b
  943.       vp_x, vp_y = 0, 0
    ; Z3 [- q0 w3 O1 e3 Q$ A7 ^, [
  944.     else+ G  Z) K* O' F% z' c  j/ \& Q
  945.       vp_x = viewport.rect.x - viewport.ox
    , f7 j5 g& X  C# c0 k" p
  946.       vp_y = viewport.rect.y - viewport.oy2 H' x% E* p8 Q+ o
  947.     end* t& q) @/ d, v( G$ K" j
  948.     item_x1 = vp_x + x + standard_padding 7 n- A1 h' X* h
  949.     item_y1 = vp_y + y + standard_padding
    8 X/ y' i* k9 w# x/ X% N5 H
  950.     get_index = @index  0  0  @index $ @9 d* h: U  ^) N* B4 `5 g$ B
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
      d; ~/ q# v# x. F  W+ _- B" G
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5): f/ |3 M. [. {3 ]3 a9 `
  953.     Mouse.set_mouse_pos(new_x, new_y)
    5 U8 Q/ A$ c1 f2 a
  954.   end, p. H/ l, w( m* q$ z  y* z! X
  955. end
      \% l! z% }, f5 \0 g

  956. & d5 T4 l* t7 i7 q: R7 d
  957. #==============================================================================3 z4 n7 b! S+ e3 S0 o5 V( @
  958. # ■ Window_Message8 ]1 l4 g7 |3 k. I- g% H* R
  959. #------------------------------------------------------------------------------
    2 x7 D# t! M! U& e+ d2 L* ]0 ^3 R4 P, j
  960. #  显示文字信息的窗口。& i+ @( |: ?) |+ \' r
  961. #==============================================================================* |+ F* {1 J3 m  h) H
  962. class Window_Message  Window_Base
      Y" ]4 i+ Z. Q) _# m
  963.   #--------------------------------------------------------------------------$ g/ e8 O$ }6 B, |5 Z4 w2 A) }. C
  964.   # ● 处理数值的输入(覆盖原方法)- r0 y: y0 B; {# ]. w
  965.   #--------------------------------------------------------------------------
    0 F$ o( H3 s  o; }; j, z9 c
  966.   def input_number
    + G4 o' [7 k3 s
  967.     @number_window.start/ r& ^# B0 {( D
  968.     Fiber.yield while @number_window.extra_window.active7 m# k2 `( ]5 [3 t% D% S4 E$ }
  969.   end
    8 [# @2 [. C( u
  970. end$ m& E% X5 Y" C5 ]2 ]- X

  971. ' f- L# e1 A* ~5 X2 l8 y. C
  972. #==============================================================================$ M! {( M# k, _* a$ P! |5 t# D' K
  973. # ■ Window_PartyCommand
    3 d1 Z, ~0 t3 M6 d
  974. #------------------------------------------------------------------------------
    ' I! o' z+ L- Y0 m
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    8 K" ?, \' c. [
  976. #==============================================================================
    . d: }. d+ Z9 R8 z' x$ X8 V: E' l
  977. class Window_PartyCommand  Window_Command
    : \! A8 f6 v! }2 S
  978.   #--------------------------------------------------------------------------
    $ \" c2 X$ b) G! m, h9 D
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置$ R1 P7 W% r% X1 i% N
  980.   #--------------------------------------------------------------------------
    $ H( L7 ~4 R  g  P* \3 [; [) E
  981.   def set_mouse_pos$ y' r* M) t$ O
  982.     if viewport.nil" n( ?4 |! ~. b) ?! M( h0 c2 B
  983.       vp_x, vp_y = 0, 0( m% _1 s2 U4 B# K- P0 i/ {- p: J" R# w
  984.     else  C. f7 L. Z* b+ y6 L  c
  985.       #vp_x = viewport.rect.x - viewport.ox+ k- `6 `0 g5 x/ P* |
  986.       vp_y = viewport.rect.y - viewport.oy. Q& V) w; [5 p! q' R9 h
  987.     end% Q' M" a7 c1 u& E1 x! O4 ?2 d# E6 i
  988.     item_x1 = x + standard_padding 3 r* u% y( r+ d+ o' F3 w" N
  989.     item_y1 = vp_y + y + standard_padding
    $ O' Q+ O( W/ h0 |% U$ ~
  990.     get_index = @index  0  0  @index % S  u) F% S2 t/ S/ F# ?
  991.     row = get_index  col_max - top_row
    * {4 t, c  J9 e$ c+ s/ h0 M* L! b7 E
  992.     col = get_index % col_max- T) q# `9 z$ B1 a1 g' ^; f% d
  993.     new_x = item_x1 + item_width  (col + 0.5)3 V( p+ j0 n- |) j5 Z
  994.     new_y = item_y1 + item_height  (row + 0.5)
    ' O2 i3 Y$ D9 R5 a2 `# `
  995.     Mouse.set_mouse_pos(new_x, new_y)
    ) j, F+ O& j; f- Z7 [* L; \8 ~
  996.   end6 }- Q8 K7 R" d, a) P
  997. end. [# J8 z) w$ U0 C; X

  998. 7 L6 J! D% a% i$ W5 X
  999. #==============================================================================
    0 T& ^& i  @7 p
  1000. # ■ Window_ActorCommand
    3 A& C$ b* I. z; C& _
  1001. #------------------------------------------------------------------------------
    6 G6 g3 _# o( }3 ]& o* q" g! C
  1002. #  战斗画面中,选择角色行动的窗口。- y4 ^4 v) a" W' L* Y" I" j4 n/ u
  1003. #==============================================================================+ A  M8 F  @0 d
  1004. class Window_ActorCommand  Window_Command
    # A. h. G. u' s  u% m
  1005.   #--------------------------------------------------------------------------
    & [! p/ O5 O6 a6 }% x, H
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ) t3 V$ b6 ?. A9 f
  1007.   #--------------------------------------------------------------------------
    ) w" D4 d2 U! w7 W: i+ q
  1008.   def set_mouse_pos
    4 r5 o7 W& q; I8 X, d1 n
  1009.     if viewport.nil
    . a7 {: e, p& K( S- A" Z3 Q
  1010.       vp_x, vp_y = 0, 0$ x/ D# O+ N% ]8 m2 M9 V" t
  1011.     else6 _" u4 G6 O  e6 x, j$ W3 x
  1012.       #vp_x = viewport.rect.x - viewport.ox
      [0 `9 i( {% E8 x7 h
  1013.       vp_y = viewport.rect.y - viewport.oy
    ; g0 J1 G. o) n3 B
  1014.     end, [6 w' m6 w  q
  1015.     item_x1 = Graphics.width - width + standard_padding
      M+ @1 H' y& p( P
  1016.     item_y1 = vp_y + y + standard_padding, M2 z1 ]: J  D; M4 o+ r( E
  1017.     get_index = @index  0  0  @index   R% M# E7 s9 |. K0 f3 o
  1018.     row = get_index  col_max - top_row- m4 e; O2 b2 l$ t  g; ~. }. I+ [
  1019.     col = get_index % col_max4 x( g( N3 w1 ^6 u! G4 K
  1020.     new_x = item_x1 + item_width  (col + 0.5)$ e* e  A% x# Q- |2 a. p- T
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    ! v5 r: n, D& T
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    ; G7 \% Z+ ?! R) N
  1023.   end. C; \+ t% p7 }, y  a
  1024. end7 \5 I* V) e$ Y% m

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

  2225. ' ?" q: h# N- r  u" i% O6 }
  2226. #==============================================================================
      a- c; ]% \6 Q' p, I! Z. p
  2227. # ■ Spriteset_Map
    : f/ ^4 @( N) m' o" a
  2228. #------------------------------------------------------------------------------/ q  U+ }6 X5 y6 B
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    / A) O3 \6 X  a
  2230. #==============================================================================& l8 c/ \" Z  e- a8 l4 k% E% n. @
  2231. class Spriteset_Map- B/ e. U2 {( h" E) X
  2232.   #--------------------------------------------------------------------------
    $ ^; s# e. F# B: U
  2233.   # ● 生成路径点精灵
    ; @# R% a- O0 u, R( g; p* P2 E: ?
  2234.   #--------------------------------------------------------------------------4 g: F. v8 l4 D
  2235.   alias sion_mouse_create_characters create_characters, T5 T. o1 F1 d: k2 X" S
  2236.   def create_characters* B4 _0 q0 ^$ T! f2 ^
  2237.     sion_mouse_create_characters
    4 C6 r& R9 F1 m0 A# t
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    : ?3 S- X: F$ }+ A8 O
  2239.   end
    6 w% B1 H& _( @" Q: l- C" }
  2240. end
    - n3 g  F2 `6 X: B- z6 {$ g

  2241. ) V! \( U$ q. h2 a2 y
  2242. #==============================================================================
    4 {+ P$ p# Z3 }& {' n& {
  2243. # ■ Scene_Map8 I" W4 I# W" A; l
  2244. #------------------------------------------------------------------------------
    ; L. T+ _$ h5 d; c+ r
  2245. #  地图画面" P+ Q: h( _, \% l$ |# i
  2246. #==============================================================================; t* `3 I  J* L$ a; ^
  2247. class Scene_Map  Scene_Base
    % }; O% w9 o5 O) @3 k% k1 c
  2248.   #--------------------------------------------------------------------------3 k5 V: @9 c! }
  2249.   # ● 画面更新
    + Q& ?& A0 G9 _% l
  2250.   #--------------------------------------------------------------------------
    + x; T" t6 |  \3 x5 W
  2251.   alias sion_mouse_update_scene update_scene: Q) W% N7 B7 y7 |# ?5 J
  2252.   def update_scene( c& y' C& E7 b  h# z5 K
  2253.     sion_mouse_update_scene! s( \$ a( m7 |
  2254.     update_mouse_action unless scene_changing0 O: S9 u$ d6 @; v
  2255.   end) U" G% J3 B# ?% d6 c* f2 y( k
  2256.   #--------------------------------------------------------------------------$ V# u: D% u+ t& W6 m$ @
  2257.   # ● 场所移动前的处理! Y" I9 e5 J& c' f) U8 @, X2 y( ?$ [
  2258.   #--------------------------------------------------------------------------$ B; ]) Z( x/ K6 M
  2259.   alias sion_mouse_pre_transfer pre_transfer! f' B& m, }# `/ P$ i
  2260.   def pre_transfer
    7 W; U7 L3 e# v
  2261.     $game_player.reset_move_path
    ! z+ o5 j5 b! o/ |# w
  2262.     sion_mouse_pre_transfer
    ) v" o1 f. `( ~$ w* ]3 Q2 C
  2263.   end$ E4 V6 x4 W, R$ a1 H& p
  2264.   #--------------------------------------------------------------------------2 C' h0 Q! B' g2 I! V) Q" b7 G
  2265.   # ● 监听鼠标左键的按下
    - n: H: q( L9 m5 g: P2 @) J
  2266.   #--------------------------------------------------------------------------
    ; Z4 A" R6 m9 H4 A
  2267.   def update_mouse_action" D- q  G: b& J9 I6 D
  2268.     $game_player.left_button_action if Mouse.press(0x01)! i/ p( B! I: F+ J: G  ^3 l
  2269.   end
    ) k* [, l7 o0 E# Z; H9 j/ o4 S0 P
  2270. end
    ( T7 G: G; D6 q- y8 i) b7 C& @

  2271. : d7 Y; V) s- `, M2 E# {
  2272. #==============================================================================
    . G/ [6 Z8 Y& s" j5 S# ]* G8 [0 \
  2273. # ■ Scene_File
    % i* z- u- \3 s: v/ c3 |, L& V) d
  2274. #------------------------------------------------------------------------------  N) m7 Y, a, W0 b! ^/ A& L
  2275. #  存档画面和读档画面共同的父类) |/ s: i" M  A( M! ?
  2276. #==============================================================================
    1 a+ q, j, ?' m$ K( p
  2277. class Scene_File  Scene_MenuBase7 {, q2 _0 [4 q/ b: |( j9 \( }
  2278.   #--------------------------------------------------------------------------- v# ?/ [! e6 h% M6 L7 n8 B
  2279.   # ● 开始处理2 i: ]% D3 g; Y. Q3 R2 \9 J6 m
  2280.   #--------------------------------------------------------------------------
    9 F' ^0 w/ X2 W9 n; u0 Q3 |( o
  2281.   alias sion_mouse_start start
    " Y4 _- J, a8 ?$ ]3 {# ]7 F5 r, Y
  2282.   def start
    % |% O+ k+ a1 f# B# j. t$ m
  2283.     sion_mouse_start
    # p% N1 ], X) K: i& z) M
  2284.     @move_state = 01 s9 h# L7 a1 Y' j4 q8 o
  2285.     set_mouse_pos
    " I" Y; @. a. l% ~
  2286.   end
    6 \2 ~% K1 p5 ^
  2287.   #--------------------------------------------------------------------------
    # e2 Z6 Q7 ^6 R: b0 X+ _
  2288.   # ● 更新画面  E+ ]/ S. K. w6 `* y2 y' D: _
  2289.   #--------------------------------------------------------------------------
    6 G) A" A* W6 y$ a2 u
  2290.   alias sion_mouse_update update+ Q7 [# i) H8 _' n, \! z( b; w
  2291.   def update. b" \& A; \% k
  2292.     sion_mouse_update7 I; L" Q9 u, `  R4 Y8 J+ n8 V
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    . s4 z! B. l, o; c
  2294.   end9 ?+ ?3 x2 y# g0 M1 K; D6 J
  2295.   #--------------------------------------------------------------------------
    ! e* I) L% k9 E$ y. T
  2296.   # ● 更新光标0 `" W) l8 t6 b) i
  2297.   #--------------------------------------------------------------------------
    8 U' U  ^2 \+ ~6 ~) J& K, @) C
  2298.   def set_cursor- V6 E# ]3 E4 r& L* I9 t
  2299.     @move_state += 1" N' A& o1 U7 h+ d) e' }& O* I3 _- z
  2300.     last_index = @index: c2 q( j7 r; z
  2301.     if mouse_which_window == -2! L% c# z8 x! N5 S
  2302.       if (@move_state - 1) % 6 == 0
    2 U0 ]5 R3 M9 @0 X- h
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1# B8 Z- |( R$ J9 H* H
  2304.       end
    # g% t; n9 s0 {. M# h$ n6 y# [5 Y
  2305.     elsif mouse_which_window == -1
    " r. w" i" G4 r, r# P7 V% ~) y! g
  2306.       if (@move_state - 1) % 6 == 08 \% ], z9 `) P
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0& q+ D* v/ K! d$ r* B8 R; U6 @
  2308.       end7 G' e. _3 c$ W* S
  2309.     else7 H: |" \* q; E( r+ Q  f  P
  2310.       @move_state = 0
    2 b  _/ ?8 t- ~# A' x# m
  2311.       @index = top_index + mouse_which_window8 j* T% E7 Z: V& N- ^
  2312.     end
    4 m  `6 Z* g2 p, A
  2313.     ensure_cursor_visible
    2 L1 t% H; P6 v" D, i
  2314.     if @index != last_index
    ! \4 N' g) c( ]- V) G! v# F% S6 L4 N
  2315.       @savefile_windows[last_index].selected = false% k! p- n* U# F4 F, }) @; h- N
  2316.       @savefile_windows[@index].selected = true8 y$ l% f% a; x1 D5 B0 W' Z$ c6 b0 S# D% M
  2317.     end8 g7 g8 h; Z& |5 |$ k# X; C
  2318.   end; j$ {# p% W/ i& v& O! z
  2319.   #--------------------------------------------------------------------------7 p( J) v0 k, A. U# }- Q
  2320.   # ● 判断鼠标位于哪个窗口
    3 w! n; m# f$ }$ y% ?
  2321.   #--------------------------------------------------------------------------# G5 T. `$ _5 |( m
  2322.   def mouse_which_window7 ~' W5 Q) l3 x
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y1 t, m5 l# w, ~
  2324.     if mouse_y  @help_window.height + 14. V, `- I* m& G( j
  2325.       mouse_row = -1
    5 ~: p; D/ c# R# i7 S
  2326.     elsif mouse_y  Graphics.height - 14) b& d. V# ~8 g: ~
  2327.       mouse_row = -2- N. w7 B1 N! T' H6 c
  2328.     else
    , P2 f" V/ U% p( j; _1 F. i
  2329.       mouse_row = 4  (mouse_y - @help_window.height) 7 p/ P$ d/ i4 {: ~
  2330.         (Graphics.height - @help_window.height)
    ' G) r/ {' j- \/ T& I+ s
  2331.     end
    , g7 C* g& o- V3 B: B
  2332.     return mouse_row
    ; u  _3 e+ x! ]: q$ x0 N& a8 ]" y) O/ B' j
  2333.   end4 L% I- V$ f- ]# F+ G/ D
  2334.   #--------------------------------------------------------------------------$ P9 d9 |8 R5 F$ L9 m7 A; [
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置3 X* X0 V0 X: j
  2336.   #--------------------------------------------------------------------------
    & f) n& C+ `( p* n
  2337.   def set_mouse_pos" U9 l4 [/ V2 f, {- ]3 F5 Y
  2338.     new_x = 40
    , R( j2 a, c1 x3 O; K" c) u
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    3 z4 ?! P+ F3 b# Y
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    8 b% S9 R3 E; Q
  2341.   end
    2 S3 X/ K6 J# Z5 ~: @% z
  2342. end
    6 n( l% t  k: K. q

  2343. ! E) Q& B" T7 o& w- ^
  2344. #==============================================================================: J& I4 D6 j, j/ B0 T5 y* b
  2345. # ■ Game_Event& W1 b8 L. T  }+ s! w; @* P( h5 r5 K
  2346. #------------------------------------------------------------------------------
    2 c* w4 j- i! Q- c* T* M7 ]  l
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。  V2 R) F$ C. \& Y! o
  2348. #   在 Game_Map 类的内部使用。
    ' }  Z6 B8 o4 ]
  2349. #==============================================================================
    9 Y% b3 v  n" v" o
  2350. class Game_Event  Game_Character
    % E: n% B% X) A
  2351.   #--------------------------------------------------------------------------
      {  G. A$ N6 ?! H. Y- E
  2352.   # ● 事件启动& \5 q: U) p& \% v; |$ I
  2353.   #--------------------------------------------------------------------------, e7 }8 K! J; D+ P1 b
  2354.   alias sion_mouse_start start
    6 U% B7 {6 w' C' \) L2 E8 h
  2355.   def start4 F1 ~, j- f7 i6 m$ `
  2356.     return if mouse_start && !Mouse.press(0x01)
    + H6 _* g: z+ ^4 n: m
  2357.     sion_mouse_start
    2 B; f* W8 I- V( f1 H
  2358.   end
    ; i2 a- I- F- B3 _+ u4 ]: C1 g
  2359.   #--------------------------------------------------------------------------- @  b: @3 E: q" ~$ m, H
  2360.   # ● 判断事件是否由鼠标启动& P3 i( ~2 |! n1 U7 w& j7 ?# f
  2361.   #--------------------------------------------------------------------------
    ) F4 i! E, G/ d8 ~) f" Y
  2362.   def mouse_start* u/ M! L) ?; b( I2 N
  2363.     return false if empty4 [  q* o$ P+ [0 f9 u6 |
  2364.     @list.each do index
    % m' d1 N% E6 D' Y; E( L
  2365.       return true if (index.code == 108  index.code == 408) &&( s4 T  J/ r9 @) h$ n! U1 g! ^
  2366.         index.parameters[0].include('鼠标启动')
    % ^. \( I: `# }7 ^4 T8 R% Q
  2367.     end
    . l  w& q; q1 h2 o( i" {
  2368.     return false2 J' _3 \  W2 E: R: a$ v: k
  2369.   end2 v5 i5 v  v( q; B2 y+ U0 s& t
  2370. end% V& `( R* `9 D$ p
  2371. / U. P' w7 P1 h  F
  2372. ####泥煤的height7 a* h/ z$ p4 D6 H
  2373. # @height = height2 Z( H* Y8 d5 d# T$ B
  2374. - y, @5 U6 k4 h1 X) r$ S+ r
  2375. class Area_Response
    5 y  ~- o* v* u) u0 M0 c  L
  2376.   attr_accessor type# P$ k; F! b; k6 l' z5 h8 u, e
  2377.   attr_reader ox) Z# S* D& {0 x% c; e+ \9 k! u! [
  2378.   attr_reader oy
    . Y5 a( ?5 d$ n, a- x
  2379.   attr_reader width
    - ]( B" H$ Q% ]+ L# o
  2380.   attr_reader height4 {9 p- ]7 m/ S
  2381.   attr_reader switch_id1 D0 ]& s! X2 y0 N; d2 y
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)9 ^  R' u$ v8 O2 G  s2 Q
  2383.     @type = type! g% q9 L- B% l0 `
  2384.     @ox = ox. x/ ?9 w6 s" M8 S% j# F/ \
  2385.     @oy = oy
    ) F6 j' d2 J. ~$ {  ~1 s& S
  2386.     @width = width
    ; N4 [5 }: w. _) Z
  2387.     @height = height6 g# g2 \/ n4 U8 y
  2388.     @switch_id = switch_id
      b! k  G8 Y. D4 d4 D5 E- y
  2389.   end
    " x. m. P9 }% ?; K% g
  2390. end
    % T6 K! B: `& X$ m" ?

  2391. * u4 Y, A) m/ f: G: v) r/ v
  2392. $area_responses = []% F( M" O: I/ _; |" Z  \

  2393. 8 N" H/ [! p( |- ?4 }" S8 ^
  2394. class Scene_Map" w- _$ s" |# s4 q1 U! n
  2395.   alias update_mouse_2013421 update_mouse_action
    9 {* ^7 P3 U8 [) p7 I8 h8 K
  2396.   def update_mouse_action
    5 J1 E: ]1 P7 k6 U
  2397.     update_area_response
    8 H* {9 ]0 j& Y  D  T; U! F9 s6 P, {3 |: G
  2398.     update_mouse_20134217 Y8 t7 N  b8 z$ S: Z4 k
  2399.   end
    7 k' [1 {$ A5 e+ x/ i8 t
  2400.   def update_area_response6 b, \/ T5 z- @; T, b2 q
  2401.     responses = $area_responses
    1 l2 F. q* u- c. h6 Y3 Q
  2402.     responses.each {response
    3 Y, |1 Z9 g# a8 C  [
  2403.       ox = response.ox' A: d5 n3 s" N6 j, m
  2404.       oy = response.oy
    9 x# m. T! a5 \" S
  2405.       width = response.width
    5 x9 c3 K8 z5 P5 H* x
  2406.       height = response.height
    ) R1 n4 @5 g' w1 o( j& U; Q
  2407.       switch_id = response.switch_id) ^7 h1 c* F- p  W: q
  2408.       case response.type
    ) c( C" L5 r, n& F% d
  2409.       when 0
    6 B- u4 v0 T. c9 u, I$ }
  2410.         if mouse_in_area(ox, oy, width, height)8 g1 W/ y( ]5 v5 k
  2411.           $game_switches[switch_id] = true$ O3 V; Y: x+ d3 y3 h: r
  2412.           $area_responses.delete(response)
    1 J: t1 G. U( |
  2413.         end9 M2 b) R8 \2 ]3 N1 J# S
  2414.       when 1& Z% b0 {1 D+ i9 |! d! e# D/ n6 r
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    / ~+ n3 e% Q1 k/ i$ s1 f* l4 n) G& e
  2416.           $game_switches[switch_id] = true
    ( d/ m$ x+ V" Y7 R
  2417.           $area_responses.delete(response)- j0 C6 i4 n( \% E+ a. _$ V
  2418.         end) \" P0 Y" w! X3 e5 O
  2419.       when 2
    2 E( h- g' k- E
  2420.         if mouse_in_area(ox, oy, width, height)
    7 k! W7 [# m" i' V( c3 e
  2421.           $game_switches[switch_id] = true
    % w) J9 p1 N, T. i1 j4 ]
  2422.         else
    * W% u3 g% G! M, h7 r( b
  2423.           $game_switches[switch_id] = false4 q6 b8 N& S# p8 N* j% |
  2424.         end
    ; j9 X) I  j3 F0 ^
  2425.       when 39 q& A: F1 k6 A. G1 b: x  A' y6 N
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    & f! \/ ~- ?3 O: o
  2427.             (oy - $game_map.display_y)  32, width, height)
    4 E: d1 D8 ^- @( k* W
  2428.           $game_map.events_xy(ox, oy).each {event
    3 E$ k# c' e! v* W7 ~6 N7 o5 I- p$ g
  2429.           event.start2 F4 G8 f$ I$ A' [
  2430.           $area_responses.delete(response)
    , y) h6 N$ d: ~. h, f% D5 a2 B( k: N
  2431.           return
    6 y' c: I" a0 J( n# x
  2432.           }
    8 V% L6 N' l4 U% P0 [! t9 [
  2433.         end, ]/ l/ t2 C. M+ A
  2434.       when 4
    / b- g  y) g) k( W
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    9 _3 x" Z; A: ~; l! A
  2436.             (oy - $game_map.display_y)  32, width, height)# c# U9 S3 U# p
  2437.           $game_map.events_xy(ox, oy).each {event
    ! a6 p) U3 p5 O# d. R. p. t
  2438.             event.start
    2 i  A5 d7 n0 L
  2439.             return
    4 {# C+ P% |6 s# d  U( N
  2440.           }
    / u' u9 J" p* y
  2441.         end& v1 Z. @" }3 I9 y# k. b5 B& ?- k. ]
  2442.       end2 o2 v  z& w$ `% A: z% ^+ x
  2443.     }/ I$ ~9 f* \5 [
  2444.   end6 `/ J6 M5 w( S' \
  2445.   def mouse_in_area(ox, oy, width, height)
    8 _6 N8 s; Z8 w0 c1 ~
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&5 y* G6 X6 X9 l2 ?! X' Y7 i
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height  a- Z/ \) e, H2 ^# S
  2448.   end
    % V: m! u) G0 ]7 h% Z$ K  Q6 Y
  2449. end
    5 d8 ?4 R1 V4 f: n" `5 F+ v
  2450. class Game_Interpreter
    ; t0 _# d8 J( a2 ]7 B# m9 L
  2451.   def area_response(arg)
    + r8 h' E/ A# \- \6 e
  2452.     $area_responses.push(Area_Response.new(arg))
    $ y. O; |! u) c) G5 U
  2453.   end
    5 Y( F5 Y; @9 V% w1 V+ X* R4 [
  2454. end
    ; ?( |! ]. o! o5 A/ S2 w
复制代码

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

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

GMT+8, 2026-6-8 06:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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