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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    , \# q: D% [9 j! {; j$ [1 k6 `

  2. " Q; W) I  T+ \# y. ?
  3.   Sion Mouse System v1.3e, y5 q" f  k+ R9 k5 ~* ~1 f1 P5 N
  4.   
    ( j) M! c5 J8 Q0 G' T
  5.   Changlog. w. N! G( `; f; p( Z
  6.   8 p4 W5 ~# s; q9 `9 m
  7.   2013.4.21 v1.3f
    / H2 M6 w5 _, @- g* C" M
  8.    
    * P: I4 f  `+ o/ [
  9.     1.3f 卷动地图 bug 修正
    4 v$ Z4 H$ l/ K+ c, ~
  10.    
    # g, e4 Z" g, S
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    & p9 q9 z( ~- K8 Y1 h
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    * r2 i1 L7 ]3 J% ?6 k* ]& P1 H
  13.                               Mouse.unlock_mouse_in_screen 解除锁定0 x: Y9 j8 E! B5 I( [/ J3 [  v
  14. : @) ]% F1 X, V0 V
  15.     1.3f bug修正
    $ s  g  ^1 Z: S. q2 {/ s
  16.   , e, }. {6 n$ C) ^6 i$ G/ Z
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及& l# S& Z+ M  k: h% l
  18.           关闭菜单时,鼠标是否移动到原来的位置。9 j+ h0 n/ M- N

  19. , Y2 R$ h7 p$ c7 S
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处6 h( b! p1 {6 x, W

  21. 9 V: l" S/ a) }) ^6 j& O
  22.     1.3b 修正一些罕见的bug;
    2 W; D. ?4 G* w+ B, d, z
  23. 3 y* }1 s/ B/ b! s, @1 I% P
  24.     1.3a 代码小修改;
    1 Z4 @5 Q  u0 [7 `1 Z% m0 B
  25.           加入了鼠标点击启动事件的功能,
    & C' L/ v5 T. O- F
  26.           在事件中加入“注释”: 鼠标启动  ,) T1 E# u: e, b
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。, |% R. [/ G+ g& B) g
  28.   2 u% Y& s4 R! L5 ~( v6 l8 _
  29.   2013.2.12 v1.2
    ( ~$ Y. z6 `7 Y6 D5 p; Y

  30. & Q( D; a  }! \: g2 V8 E9 `1 j
  31.     寻路逻辑优化;" ^% p( d! x+ X9 \
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;" a4 c( H3 {) j4 A# U0 O- u
  33.     现在支持用鼠标来操作载具了。
    1 v8 c5 \& Q) B# E/ g4 R+ A6 S

  34. , z6 G6 e3 s: P. Y& B$ r) R0 h, F
  35.   2013.2.8 v1.1
    7 L( S' a5 {8 o, K8 R
  36. : ?5 e8 V5 ], X. M5 W& `3 y
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;8 e, [  F' E% w$ h  L+ f3 X
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;* V: S3 ]) E' k7 L1 ~' ?9 _
  39.     移动时,路径指示点的绘制更加稳定;
    ! e' l8 l* J* |, S8 E: q: g  C
  40.     现在支持默认存档画面的鼠标操作了。
    ! G* k# @( f( P1 w/ U
  41. 8 s# M1 N; k' w' A$ K

  42. & S3 S) D; W) Q$ m
  43.   OrigenVersion6 S9 J6 l+ ?) u7 `/ E( A, q% w
  44.   
    4 D7 V& Y# D% \4 ~2 J
  45.     2013.2.7 v1.0
    ; L: O1 O. V% `* [. P  y
  46. " O9 t. h, q7 q- p! ^+ U8 n) K7 c
  47.   主要功能
    , E5 r/ x* }, ]' V( m
  48. & X" R+ j3 m' N  C
  49.       使用鼠标进行各种操作...: {+ t$ I, x+ m$ h7 {9 j
  50.       将鼠标锁定在游戏窗口内5 l& f2 s! R3 t' T  L4 b3 S, o
  51.       自动寻路,按住 D 键可以扩大寻路的范围! w9 O5 f7 F  z- {  {
  52.       双击鼠标进行冲刺" _$ i2 i3 j; T4 }9 l6 x. o6 V; P
  53.       更改地图卷动方式以适应鼠标移动" I) c9 C+ B0 `9 Z$ B3 Z! M" P+ n% V! E
  54.       变量输入框改良0 F/ b" V( @7 r/ U6 v7 @) ~2 O

  55. $ V/ O$ G7 H8 D8 p( w0 w
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    ' S; K+ U7 M! j
  57. * J5 X* d/ Z! D  u: \4 E4 N9 t
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹% p/ D! z0 y0 G8 n1 T$ o
  59. ; i( c# P2 e6 H) D
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭# l* f( R  \9 p# r
  61. 9 Y' }5 U( y( A# }5 C2 d4 G
  62. $ H6 O+ v* q8 z% m2 j9 V( T
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    # V4 Z3 b% Q: J  ^: u$ R% S
  64. + L8 r2 H& ]" n

  65. % x* [5 l; o% Y$ w6 N8 k: E
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    8 I/ Y1 {4 n8 R- J1 R

  67. 1 n! Q/ C8 ^6 `0 [
  68. #==============================================================================  w9 F; }( J0 V7 r$ R
  69. # ■ 常数设置 " ^) n; k# }5 d  u# c2 Q3 X
  70. #==============================================================================
    3 H1 h6 n" D! h. F8 y$ w( S; g8 ?
  71. module KsOfSion5 R+ c4 A$ H4 g  ^: \1 u' J0 g
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    0 \5 Z# |2 [7 e. X! p& e( R
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    , m* e$ S6 g; F
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false" _2 g8 l( a7 L0 T$ t( V
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量* |( `) v; |. p
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处3 g2 x" k) E, v# L4 y
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧; ^" W1 w9 r( K* f# A
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)$ f1 A; C+ A$ K4 Y
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键1 m* G, H4 H5 J$ w
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    / G; o- Z3 _" q+ E7 q( B" G
  81. end
    $ `& B& n& \  Y# Y1 a# H3 z

  82. 4 _" `7 c, h  d+ [0 B
  83. #==============================================================================
    . z1 p) p" E% G* h0 W# A4 B
  84. # ■ 用来显示路径点的类
    : w' v. |. ?# K3 d* x
  85. #==============================================================================& N! p! t6 Q8 {; l" L* K) E4 x+ ]
  86. class Move_Sign  Game_Character
    , k$ |; R8 o! x" `, X4 }/ ^: N
  87.   #--------------------------------------------------------------------------7 l0 i" t1 y, q6 X& k. k
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    * c+ ^) X/ m$ O, n# r* g& S5 ^( _
  89.   #--------------------------------------------------------------------------
    4 a6 M: D' {1 }- M
  90.   def init_public_members* E2 N3 D& `/ i" |& ]2 E
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    8 @; S9 c- ]1 G  d
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为07 m# `2 r: \% J: f1 G( O5 K; I9 ?
  93.     @move_speed      = 5        # ★ 踏步速度
    / b8 B3 ?. h6 i: L2 `' o
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)) K' Y- D" k' P% @; ~$ M
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    / m# K* _. _! v# P1 I. i% b  q
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    $ P& I" S' e8 @
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    1 I$ [5 G1 ?6 x( G# j. H
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)3 l" J( B- c& \# C8 c& B
  99. 5 J. p% ]5 w! f, c

  100. 9 D9 L* b9 e9 w4 @
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    , Y8 E9 w( ^0 k

  102. / ]/ x8 ?4 s0 H
  103. * X) k3 Y+ C, Y2 f" A, U  j
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图2 L  `6 Y3 ^& I
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')  C. j  D; }' b  E" N) p: W

  106. & }3 L9 \/ |8 P" T/ z0 o
  107.       if $no_arrowpic_warn# R7 I  v2 V  L# Y, L3 x
  108.         MouseShow_Cursor.call(1)
    , l2 f. D& Z8 o2 p, s: H, M/ D2 U
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    " Z& B( f) Q" [, o9 i
  110. 1 d; N  D7 t4 I  K& R/ c/ f9 P
  111. “路径指示点”将使用游戏自带图片7 n4 |; z3 d8 v6 J4 Y( l9 L
  112. $ Z/ l; t7 E1 `3 N" Q7 C3 S& ^
  113. 该提示可以在脚本内关闭')
    % f" o1 b) X9 j( q2 w0 C
  114.         MouseShow_Cursor.call(0)) y2 q  y/ u: y" Z2 |  {
  115.         $no_arrowpic_warn = false
    ( b6 [2 G; o/ M/ o5 ?& o! a
  116.       end" M" }8 o) C( `, R+ y
  117.       @character_name  = '!Flame'& o- n( N4 J! _4 D2 D! }
  118.       @character_index = 6; x" Y6 r2 G5 J; h! L& g  R
  119. ( U0 E1 \4 J' j- x( D
  120.     end, X4 l5 i; E, ]- y7 B6 R
  121.     @direction_fix = false  # 固定朝向  b& E2 h  @4 b  J
  122.     @move_frequency = 6     # 移动频率2 x7 U: n/ e, z, v$ H
  123.     @walk_anime = true      # 步行动画
    , {5 n* o9 i4 @! S! Z8 y5 T+ `
  124.     @pattern = 1            # 图案5 e5 x0 u' K8 a
  125.     @through = true         # 穿透
    ! y, k% [" j  L+ L6 K5 W: V
  126.     @bush_depth = 0         # 草木深度
    9 |5 C7 @5 I& U& q6 K# P
  127.     @animation_id = 0       # 动画 ID
    , B# ~4 u% ?* ^% R7 C
  128.     @balloon_id = 0         # 心情 ID
    ( A' }* P, M6 c8 c/ s! v& Z
  129.     @transparent = true     # 透明
    " v6 g! A8 [6 R# ]$ X
  130.     @id = 0
    $ M$ k  ]# H% s* n8 W3 f2 }3 C4 t
  131.     @x = 0
    ) o! E* R/ U& @# Q5 p" `# D
  132.     @y = 0
    1 S. h3 ^7 h7 {" A& r0 O
  133.     @real_x = 08 D3 M7 s+ ]( R/ P: l9 c8 I
  134.     @real_y = 0# a0 d6 u9 u$ L3 R; j/ o
  135.     @tile_id = 0
    . U$ D. s9 b' v) T% }" {% w
  136.   end) a; L% d2 c0 U) d5 P) t# \
  137.   #--------------------------------------------------------------------------8 R* g, u; I  M4 k4 ~
  138.   # ● 定义实例变量/ N5 ~1 q% i  N4 |( [4 n0 `
  139.   #--------------------------------------------------------------------------) h1 n( I$ [2 C
  140.   attr_accessor direction
    * U1 v% I5 [6 r+ @0 Y3 X6 K
  141. end" U& o# ?+ O! {  U, N" U. f9 ?( B
  142. ( |! u5 |- Z( k1 Y1 |- A" A5 e
  143. #==============================================================================: E  c+ d, t' `* Q$ t. y" X
  144. # ■ Module Mouse
    # L* b" d4 s+ T# P/ D& X
  145. #==============================================================================
    1 W5 E, I6 K" c' Q# X5 l0 Z# t
  146. module Mouse
    ( _% W4 r% U! p
  147.   #--------------------------------------------------------------------------
    $ S$ D% }& X6 T, I  ?
  148.   # ● API
    ' Y( j8 w: T, }# x' s  L
  149.   #--------------------------------------------------------------------------# }6 ?! r; [6 R# m
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    . z: a/ t! d# b$ E6 U3 a8 f+ h
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
      T* J! }) p7 E: Z
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')4 Y6 T$ f- Q/ R
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    5 Z! i! g& v; N* w* Q9 }
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    - |( J, y! {9 i, H! d
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l'); T+ ~4 W; p+ Q' V$ L- S# M9 r
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i'); b$ v9 X5 L5 Y2 t# Y9 _/ ^! S4 `
  157.   Window_Hwnd       = Get_Active_Window.call
    # |3 X$ a- Y% ~6 s1 W4 J5 j

  158. " U2 y- M, i. {0 @' l7 N8 o* K7 B
  159. class  self
    4 J  ~3 R! |9 ]$ {
  160.   #--------------------------------------------------------------------------; f, B$ c2 ~4 L6 j  |9 h
  161.   # ● 初始化( ?! q3 E/ L# f) \- @( r
  162.   #--------------------------------------------------------------------------: i, l* g2 y2 `* K
  163.   def init
    . e. `, K% |+ ~9 Q2 w' X
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor" s; p; g3 l; @, m  {* f: s
  165.     @left_state = 08 y( r' k7 p* [) T( N1 q/ W" K
  166.     @right_state = 0
    6 g3 c7 k2 T2 q$ k2 n
  167.     @ck_count = 0 # 帧数计,单击以后从0开始% w$ ?+ j2 b% i
  168.     @dk_count = 0 # 用于双击的判定2 R$ `4 P* H8 A: P7 i
  169.     @clicked = false/ m, I! W$ C# V3 X2 g9 a( @
  170.     creat_mouse_sprite3 A( q. d4 M, I$ j
  171.     update' r* h, w5 |/ d
  172.   end
    3 D3 Y* f$ e+ {
  173.   #--------------------------------------------------------------------------9 F" ^9 m5 V1 e$ G# S6 a$ ?9 f
  174.   # ● 鼠标指针精灵4 Y9 Q7 _9 p( P+ M
  175.   #--------------------------------------------------------------------------
    & {) L2 e6 q% ~: n( g+ Q7 T
  176. #~   def creat_mouse_sprite, B# \1 Q, v' d9 I( ^
  177. #~     , ]- S. y5 G( T8 X
  178. #~       @mouse_sprite = Sprite.new
    7 ?6 q# o# C+ W& P7 h
  179. #~       panda = 2#rand(2)+1* K8 i' H% G0 Y1 H/ n

  180. ' s  ^' O) G: o* s6 T; n
  181. #~      if panda = 1
    * _) G# b& @2 @* D
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    8 H% |4 X( J4 M1 X+ O, I
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2'). \( d+ m9 f  H: u* Z9 S
  184. #~        end#with if File.exist$ t' C3 B. K$ y2 ~
  185. #~   
    + X! F! P+ ^, F/ b+ {* I0 j" n
  186. #~     else if panda = 2 #with if panda=13 V; W: V3 I" C7 t4 l% `8 Z/ a! A
  187. #~      
    6 }1 m! J6 }6 @- o
  188. #~      if File.exist('GraphicsSystemCursor2.png')$ E5 t+ d5 g  d; x& f$ t
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')5 z2 b) D$ Y1 _  G3 K# H4 _0 ]* q* D- s
  190. #~      end#with if File.exist) U9 R) ~& |% N* T2 o) O
  191. #~      
    . G4 d4 B7 t8 n# ?4 R
  192. #~     else #with if panda=1
    8 P4 X5 Y' U1 L2 Q
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    " u6 t" y1 B4 K
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),# e( ?& G( n) ~; n5 B& X
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    + v' Z, R( H8 F4 p+ Y
  196. #~     end#with if panda=1
    4 S# @% M/ e! L$ ~- s
  197. #~     
    ' X9 }0 ]% [/ ]
  198. #~     #with def: d) ~4 E" X" H5 {$ |& S" |
  199. #~   end
    & g+ @) Y: \+ N6 i9 x. }  D
  200. def creat_mouse_sprite% ^" Y3 u5 I$ R6 o" n; i% _
  201.     @mouse_sprite = Sprite.new
    4 E5 ]7 |2 z' A% ^' j2 d7 p& A, G$ r
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})% Z+ n+ x7 k8 w* G! D$ K/ F
  203.     @mouse_sprite.z = 9999
    , e7 e, g' G6 t) `
  204.     Show_Cursor.call(0)
    3 i) B" ]0 d& O# F& j
  205. end
    2 j5 W% c2 ]# p. _: m

  206. ! `7 s+ L: |0 J# Y/ n4 d- L
  207.   #--------------------------------------------------------------------------  }1 j; l1 `8 ~! s5 e4 D
  208.   # ● 更新
    ' G! P3 ~1 e% N% \4 Z
  209.   #--------------------------------------------------------------------------7 S! C& d0 Z  N( V* ~
  210.   def update3 o$ S. ?% j2 `; b% g$ L
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    + U$ M8 S8 @5 G. Y3 R$ o3 o5 c
  212.     left_state  = Get_Key_State.call(0x01)
    , h$ }/ Y. G" Y. S' G0 b) j: H
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    - Q$ N; |* a! ~, B% H
  214.     right_state = Get_Key_State.call(0x02)4 n8 w# K  s3 U# }9 R4 B7 M( s
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0# E* x' m+ D. G& K; W# o
  216.     update_double_click
    0 A9 }$ [2 D# \$ l/ h& H
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1+ Y+ i9 N; L: G& h  y: j
  218.   end6 P6 f* a. b3 g$ t+ u8 B
  219.   #--------------------------------------------------------------------------1 u3 ~! h4 b0 d
  220.   # ● 获取鼠标坐标2 L' T5 j; P) F% P" m( {, m
  221.   #--------------------------------------------------------------------------
    : X; N2 L  f/ Q, J) j
  222.   def get_mouse_pos* [* ^9 B* M; E" t
  223.     arg = [0, 0].pack('ll')+ K: M) B/ x5 ]% J( W, k
  224.     Get_Cursor_Pos.call(arg)6 \4 C4 N  T& m! x
  225.     Screen_To_Client.call(Window_Hwnd, arg)6 j1 E- y1 X% U$ C3 }
  226.     x, y = arg.unpack('ll')
    8 u1 H) \1 I! ]  _. F4 E
  227.     return x, y
    * Z% w  z' r$ k* m" }
  228.   end
    5 T: u) w! U% a1 X
  229.   #--------------------------------------------------------------------------
    9 ~2 Y( M5 ?& U- P6 o) P
  230.   # ● 将鼠标固定在屏幕内
    # t+ C! g3 d2 \6 J8 t0 X) ?. a
  231.   #--------------------------------------------------------------------------: Y9 T% g6 \/ o% Y: U. o
  232.   def lock_mouse_in_screen
    - O1 h. K, |- f- j9 o) Z
  233.     arg = [0, 0].pack('ll')
    9 A, ?7 j. w$ N/ o( Q3 |( v' n
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    $ k6 o+ a7 ^2 e0 J( v- o  ~8 {
  235.     x, y  = arg.unpack('ll')
    ; o. M0 ?0 V' {$ c1 E/ d- w
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll')). F) v- Q9 n, |. X. X& Y% V
  237.   end0 s' ]& y! I# j5 L  O+ w; Z
  238.   #--------------------------------------------------------------------------
    , Q) n( g6 ^. o6 A. I: _* U4 R
  239.   # ● 解除鼠标固定: Q. V' g! D1 X! _* S
  240.   #--------------------------------------------------------------------------
    & o$ q: G# u$ S7 q
  241.   def unlock_mouse_in_screen
    4 k6 T9 v# M# p3 f
  242.     Clip_Cursor.call(0)4 R: q1 [/ m7 h6 J8 {
  243.   end9 ~& c9 s2 ~+ C# e6 H3 J
  244.   #--------------------------------------------------------------------------
    ; y# x5 p2 w- a
  245.   # ● 鼠标双击判定
    2 H2 J0 D0 p" J% u" b9 S6 f  w
  246.   #--------------------------------------------------------------------------
    : k8 M" d  F! ?5 q, J
  247.   def update_double_click, P. H# p  `5 T' S8 A
  248.     @clicked = true if @left_state == 1. ~) j$ }' p# v& V
  249.     if @dk_count  0 && @left_state == 1! Q& D; y9 _8 A
  250.       @dk_count = 0; @clicked = false3 t% g8 X7 J7 s: Z! T
  251.       return @double_click = true
    $ _, S. F4 U$ b+ a5 L! s
  252.     elsif @clicked
    3 o! T/ p0 \9 L9 A
  253.       if @dk_count  KsOfSionDbclick_Frame; [4 q( U/ ~; v/ i7 N1 ?& P
  254.         @dk_count += 1; Z- K2 q5 ?2 G# \
  255.       else$ m; y, |: u7 r  [9 J
  256.         @dk_count = 0; @clicked = false+ p0 t2 u4 E/ ~5 `
  257.       end
    + X1 ~: W9 ^8 M' V6 R3 _& E
  258.     end) |. F7 i7 U+ i: T9 e
  259.     @double_click = false
    # U  q4 J# @$ S+ ~" p- `
  260.   end
    : ^  \+ d3 k, u0 I* E
  261.   #--------------------------------------------------------------------------. W, c5 g, f8 Y% m- f6 i1 k0 Z) l" v
  262.   # ● 按键被按下就返回true1 H- i2 ^2 Y) F: u7 b  ^& d
  263.   #--------------------------------------------------------------------------
    ! F" R8 S3 I+ p
  264.   def press(button); o2 ]" \4 ~: }# ]. X! B2 p7 }
  265.     case button
    - j# H8 N- R0 W7 w) p1 \
  266.       when 0x01; return !@left_state.zero" R; x8 {2 h& `3 X" y) @$ ]/ k4 ]( [
  267.       when 0x02; return !@right_state.zero. {6 g3 B5 C6 X
  268.     end
    9 Z& j6 {, \+ d+ m1 L' W, Q0 V7 Q
  269.     return false8 \8 m8 i  k9 f8 u+ W' t
  270.   end
    . }; G2 I( x# I) D
  271.   #--------------------------------------------------------------------------9 |: a! X0 K1 k! @* ^, B- @
  272.   # ● 按键刚被按下则返回true6 O0 b) c$ l( M; {
  273.   #--------------------------------------------------------------------------% F9 z7 d: g! B% m* _3 J0 k. b
  274.   def trigger(button)
    * ]. E. ?0 k, F5 `8 e- T# z6 I$ j
  275.     case button
    , v& \6 H0 ^3 `% C0 Q/ M
  276.       when 0x01; return @left_state == 1
    1 V" W+ d& H4 h4 Q* q; F* E
  277.       when 0x02; return @right_state == 1/ D2 D/ V* r. o1 w% u
  278.     end
    9 g. v6 K  j  H* ^* O! x" O+ C
  279.     return false
    8 E, K) U4 O) b) b  Y% C# \' r: e
  280.   end. `* q5 R! ]; L$ T* u0 E6 o
  281.   #--------------------------------------------------------------------------2 O+ ~; C  I! H9 u, F& ^6 l
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true* |% p1 @. Z( p2 U- n
  283.   #--------------------------------------------------------------------------
    ( @7 |/ C1 @6 `  P
  284.   def repeat(button)% P) a+ O- s7 Y, d5 M! w5 V
  285.     case button
    & H; v* f4 R9 }0 v2 M1 T
  286.       when 0x01; return @left_state == 1 : p% t" Y  Z  l0 C! Y$ [# Y1 k
  287.         (@left_state  22 && (@left_state % 6).zero)
    # S0 i# y5 n! Y; J
  288.       when 0x02; return @right_state == 1
    " r' z6 i9 M- v! z3 ^& S; [! ?' M
  289.         (@right_state  22 && (@right_state % 6).zero): F& J. {/ Z! `6 w( S) r4 P
  290.     end8 J+ M. a2 u  m
  291.     return false+ Y. T( v0 i/ [' e$ ?% F
  292.   end
    / D  L; F, L; t& j# M! k
  293.   #--------------------------------------------------------------------------
    ) y. }! f+ V; u/ \: k" D
  294.   # ● 判断是否双击鼠标& J( h+ z  O6 p2 G+ `1 w( b
  295.   #--------------------------------------------------------------------------% u9 {) F- a1 }( y: r2 ?6 |
  296.   def double_click
    # `! }0 O. |2 @: e/ J4 V6 S' F7 `
  297.     @double_click' x0 q* a4 }* g, E2 J6 n4 c
  298.   end- Y& e  U5 L: b& G: F7 Z/ x
  299.   #--------------------------------------------------------------------------
    ' v( r- O$ y$ ?
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)( E6 y$ c' p7 O$ ]$ L8 s
  301.   #--------------------------------------------------------------------------
    $ i( s8 `9 `0 l$ t9 R: b
  302.   def click_count
    & E2 N4 ^7 S- k6 b3 H  A, u
  303.     @ck_count) V: N9 ^0 D  W. h+ `
  304.   end
    & T# e4 |6 C+ _; W
  305.   #--------------------------------------------------------------------------$ w1 z+ h! r6 c# Z) K
  306.   # ● 获取@left_state(按住左键每一帧+=1)0 C8 M9 m- t4 ]1 Z9 b$ `" n
  307.   #--------------------------------------------------------------------------
      K; R: T- [9 x# \. [
  308.   def left_state  _! r2 @! @% ?; S! w, u
  309.     @left_state2 ~) a% ~9 A3 y" V  g% B, q, `+ A
  310.   end+ p9 Z' R0 Z/ O1 H6 j4 w7 T1 r" i
  311.   #--------------------------------------------------------------------------
    / P4 W& d* m; e0 M- E! _; L1 u9 o
  312.   # ● 获取鼠标的x坐标4 Z9 s! Q/ b2 g- a5 V  D- L& A
  313.   #--------------------------------------------------------------------------8 t: l( [/ P& ^7 z; E6 s
  314.   def mouse_x, _0 b5 G/ f. X! x3 V" i8 X
  315.     @mouse_sprite.x
    % Z% ]# ]% h3 K' D( P( q
  316.   end
    " I0 \* O7 [) O' U4 h$ c
  317.   #--------------------------------------------------------------------------3 A* `3 n+ A( l8 V
  318.   # ● 获取鼠标的y坐标  C/ L8 B" W+ Y, f$ `$ s
  319.   #--------------------------------------------------------------------------
    7 D" @2 t. P3 Q. q. V0 D& n
  320.   def mouse_y
    * ~' o. G/ T4 l; e* i& M
  321.     @mouse_sprite.y
    + M' n* s/ q3 b2 g- a3 O
  322.   end
    $ O; H5 w* a  |! q$ A( c/ p' X9 p
  323.   #--------------------------------------------------------------------------* ~9 D* v+ q7 {, p8 ]
  324.   # ● 设置鼠标坐标& m9 \( Y' U9 Y# l; G- N& k0 @* q
  325.   #--------------------------------------------------------------------------9 |  T) e/ a% X9 t
  326.   def set_mouse_pos(new_x, new_y)0 D: S' p: C: }  C2 f, ~% n
  327.     arg = [0, 0].pack('ll')
    5 M1 `* j: H8 @1 R
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    2 j2 V1 [6 ~3 [
  329.     x, y  = arg.unpack('ll')3 S2 b; g( k$ O0 F. U- _7 y
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)! q1 G" I6 j5 H8 T
  331.   end. y, j: L$ P9 V* O
  332. end #end of class  self
    ! s6 t& K4 n- Y$ [' Y# N/ {

  333. ; o* n- @! |8 E' x) K1 B& C9 G
  334. end# ]/ N2 {  ^/ |$ a+ j. Y* c* c

  335. 3 c' j4 _. o! C
  336. #==============================================================================# w" k: T  j6 \$ W
  337. # ■ SceneManager3 w& D; u2 ?$ B' J0 x
  338. #==============================================================================
    9 w0 r, u7 l. D. I: ~3 Z$ i- v* }
  339. class  SceneManager
    8 S$ O" p6 s4 y; h6 N6 b* Q% G
  340.   #--------------------------------------------------------------------------
    # p  |  n- F3 Z0 x  M% v
  341.   # ● alias+ G' H1 H  P  H
  342.   #--------------------------------------------------------------------------3 z# u  B3 A) u
  343.   unless self.method_defined(sion_mouse_run)7 F0 s; Y4 u5 x0 z  K4 |
  344.     alias_method sion_mouse_run, run) L* {) U  E0 Z
  345.     alias_method sion_mouse_call, call( k4 s" o; p$ p. D" F2 `3 E6 I6 v
  346.     alias_method sion_mouse_return, return, o* ?" y# R& v$ x9 }+ b
  347.   end
    # r- Z2 ?1 c5 l2 Y
  348.   #--------------------------------------------------------------------------3 ]4 |9 g& J; F, d3 z- Y7 u% F
  349.   # ● 运行# X- @. x& M1 j% J0 M4 }+ a
  350.   #--------------------------------------------------------------------------' A3 X; p- z. W# U  ^; R+ m
  351.   def run
    % H: m7 r+ F5 V1 t
  352.     Mouse.init
    , i/ e* R) F7 l' E: B
  353.     sion_mouse_run0 ?6 u6 s2 {. t
  354.   end
    + u9 t2 a5 ]" p
  355.   #--------------------------------------------------------------------------9 \0 V5 k$ A- H
  356.   # ● 切换  I% N% L1 \* Y1 \  n" O
  357.   #--------------------------------------------------------------------------
    * s4 j' a' B) L# V0 X$ e8 G
  358.   def call(scene_class)
    9 x. G6 D/ w  l: q, q2 I
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)! }; |- ~1 {0 Q) b& ~; f4 W4 w6 v
  360.     sion_mouse_call(scene_class)" H6 O: A7 c0 Q: E
  361.   end
    . U! u! b+ i* z" x7 P
  362.   #--------------------------------------------------------------------------
    8 q4 p& X" n" E; P* d* l2 Z6 ]
  363.   # ● 返回到上一个场景4 i6 l- ]2 n. r* V: {' U
  364.   #--------------------------------------------------------------------------( \& w  y, W/ t9 n) l" C# J" i
  365.   def return
    ) Z6 a7 f1 F+ l5 V8 N. \% r$ C
  366.     sion_mouse_return& M1 I1 |( v! q! B0 S/ T* B: q
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    / M1 v! ~* }% K: c, I
  368.       @scene.instance_of(Scene_Map)
    0 O4 j/ P4 J/ V0 U0 H$ _
  369.   end
    2 _: ]9 E8 p- E" _. V/ S5 }" Z
  370. end7 t  ?, P, b! v; R2 f

  371. 2 f3 U* ?5 K3 z' g3 f' H. f+ G
  372. #==============================================================================
    ' |! M+ s( a" e" _
  373. # ■ Module Input
    ( t* A9 {6 P; j2 e8 F
  374. #==============================================================================
    $ p' J* |2 c* @: \) k
  375. class  Input3 t0 n5 h/ u" P, Z5 [/ a
  376.   #--------------------------------------------------------------------------
    1 ?& `! V3 C5 y2 K- C  M
  377.   # ● alias9 {7 M1 }" W0 P" f: l1 p  M- w
  378.   #--------------------------------------------------------------------------* |% @1 D! \5 |' }8 G( ^( {& B
  379.   unless self.method_defined(sion_mouse_update)8 Q$ @/ T* _- o9 t0 b
  380.     alias_method sion_mouse_update,   update
    " n( ]/ X: n) z2 [! x7 Y# n; b+ c8 T
  381.     alias_method sion_mouse_press,   press
    1 v$ T0 \: \" Q7 |
  382.     alias_method sion_mouse_trigger, trigger
    * N) b* Y" K& ?8 ~- V1 I
  383.     alias_method sion_mouse_repeat,  repeat
    0 a; u, A' E2 j) g3 @6 e
  384.   end0 a4 _2 Z  }: r- v  D. Z  R/ b
  385.   #--------------------------------------------------------------------------5 Z$ K6 `+ L5 o! J
  386.   # ● 更新鼠标7 K* k* i- t* Y0 {& m
  387.   #--------------------------------------------------------------------------# r$ @. [: i. d5 V/ q
  388.   def update" T4 H) G) n, O: q) L& D
  389.     Mouse.update  v; Q' M3 C! S4 M! P. w& Y& [
  390.     sion_mouse_update, P2 o$ [& `6 b) f3 I9 Z
  391.   end# q$ n0 ^. B6 L3 V5 i2 J: r& ^+ M+ H
  392.   #--------------------------------------------------------------------------
    ( l* j3 A+ o; U0 k
  393.   # ● 按键被按下就返回true
    - e% k. e* k7 c- e; F9 [
  394.   #--------------------------------------------------------------------------9 ?" G5 J4 `( J+ ^5 K8 ~' w; r! U" g) D
  395.   def press(key)0 {5 B. Q4 o  g
  396.     return true if sion_mouse_press(key)
    6 d- Z8 X/ S$ D& g3 u8 B4 g% M
  397.     return Mouse.press(0x01) if key == C# P; [& n% y6 v- `, [( g9 n/ w
  398.     return Mouse.press(0x02) if key == B2 d0 H: k7 \5 }* s* N  e4 Q
  399.     return false: R2 \7 Z" @0 u8 ^% r+ n
  400.   end$ `; ]# A( D/ \: N/ X
  401.   #--------------------------------------------------------------------------
    / }' k; E# C+ ]7 f; I
  402.   # ● 按键刚被按下则返回true
    # X3 m* I( Z5 F) b" R  D
  403.   #--------------------------------------------------------------------------
    " n5 h. q. }7 q4 h% R0 e- |7 b5 D
  404.   def trigger(key)
    & m/ ^, M5 @; A/ ]9 |" e
  405.     return true if sion_mouse_trigger(key)
    3 B' J2 W' T. C) L, d) _% p& E
  406.     return Mouse.trigger(0x01) if key == C+ M6 O8 I. L) ~
  407.     return Mouse.trigger(0x02) if key == B! ?) L* H. l! L. i  R
  408.     return false
    $ }% i3 t$ }0 J; x( C
  409.   end
    6 ?2 O# O, t" K* q4 b5 d
  410.   #--------------------------------------------------------------------------
    % w5 l1 j5 r6 Z) t! _
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    * O+ j3 g: h+ y0 T
  412.   #--------------------------------------------------------------------------3 F0 r) Q* d3 U: L9 `: E, l8 x
  413.   def repeat(key)
    4 @) U: P6 k& ?! I. j, z4 |! Z4 L) ?: e
  414.     return true if sion_mouse_repeat(key)
    ( i1 a4 O' H* y. A* b. S
  415.     return Mouse.repeat(0x01) if key == C% G$ F6 r) s; {& s
  416.     return Mouse.repeat(0x02) if key == B$ o2 l2 B$ v, ]- x1 ]
  417.     return false0 D& {+ J' r1 ?% j9 }
  418.   end" V; V1 D+ _% M" [
  419. end
    ' l3 P. t# `) c8 _- ]% u. Z
  420. $ Y2 e! s2 i; e% z0 s, U/ y
  421.   }2 v4 c1 m5 ^: M* w( ?
  422. #==============================================================================
    ! b/ l9 n; T) n
  423. # ■ Window_Selectable
    & b9 s5 z- o% H
  424. #------------------------------------------------------------------------------
    , a  }( m" [% v$ |* r
  425. #  拥有光标移动、滚动功能的窗口- g* C5 H( t! c
  426. #==============================================================================
    & Q! @0 t7 T9 y! l* }
  427. class Window_Selectable
    3 n: r* n0 Y* V1 J" Q
  428.   #--------------------------------------------------------------------------
    + B1 [& ?! {/ V2 K
  429.   # ● 初始化
    & _# G6 b" m: {6 \! X/ p
  430.   #--------------------------------------------------------------------------4 L0 D8 z7 _9 o3 }* J- o- H
  431.   alias sion_mouse_initialize initialize" p% J3 ~! a) f6 |
  432.   def initialize(x, y, width, height), O# u/ f- k: [* v$ {4 r4 I
  433.     sion_mouse_initialize(x, y, width, height)
    + ]5 ?! N2 v' M% C* j9 \' U
  434.     @move_state = 0
    5 V# D+ v7 g  i
  435.   end
    * o3 U( `& F. Z3 o5 D" M
  436.   #--------------------------------------------------------------------------' e9 m& }. N1 |& o* B4 r
  437.   # ● 更新
    ( D+ p* {# H" j
  438.   #--------------------------------------------------------------------------
    / O  C) ^  O) s# a  O/ _
  439.   alias sion_mouse_update update
    7 l4 b/ S, k! ]* A. r. z; H
  440.   def update
    0 b4 d. F' Y0 X6 G1 K) j+ ]
  441.     sion_mouse_update% m" q8 w9 }/ E2 ^4 ?
  442.     update_mouse_cursor
    # K! \; W# _5 r4 r$ q
  443.   end, @9 X2 o( H! M! }/ X9 ]+ K
  444.   #--------------------------------------------------------------------------" D8 O8 {3 R1 {* B
  445.   # ● 启动后设置鼠标到index位置# O. l0 O$ X" A- t6 R* {
  446.   #--------------------------------------------------------------------------
    5 E( w6 X5 l; M6 @$ V4 Q( N' b
  447.   def activate0 R4 c% n4 Z' E0 M$ L' K: X  E/ [
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos0 J0 c7 C" U; v
  449.     super
    - i8 N- o) b, C* h
  450.   end6 S( C7 Z! L. r, X6 h& z( N
  451.   #--------------------------------------------------------------------------7 d2 I  N2 ]: U$ n! G
  452.   # ● 更新鼠标和光标的位置! w3 V  k* H! r6 F& E
  453.   #--------------------------------------------------------------------------( r' }* p5 p% E
  454.   def update_mouse_cursor' U& }3 @  t! ^/ W# _
  455.     if active
    " c3 ~2 g: b0 n5 F8 V9 @
  456.       if @need_set_pos" y1 [! ?) b7 h* ~/ v
  457.         @need_set_pos = nil) z4 R( n: A- z8 y" Z
  458.         set_mouse_pos
    : t! L. r, m: W" J  V
  459.       elsif cursor_movable
    # S5 I& P) M0 T0 g# ?8 A2 h" Z
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    # j! m+ x. m; J* u! o# d5 a
  461.       end
    & }$ ?" o- {* a. \
  462.     end& D& R, c- }. X! Z; L. O# |$ _
  463.   end
    6 H# q& E5 B/ v3 Y
  464.   #--------------------------------------------------------------------------, @/ H$ z) Q: J( I+ s( Y
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能* q, v; z$ T( D" P! ^/ d* A0 T
  466.   #--------------------------------------------------------------------------
    & M' r- L: D! E
  467.   def set_cursor
    ( j) B; C3 e5 u
  468.     mouse_row, mouse_col = mouse_window_area
    + j/ E. e2 ?- w8 u
  469.     if    mouse_row == -1
    $ m. V  Y( B6 I- s( q
  470.       @move_state += 1 if need_scroll) p% i; h) \- ~1 M- a2 ?
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand- E& R& U/ R) ]- X% s) s0 a0 t
  472.     elsif mouse_row == -20 U) E3 R7 G. M# Z: w
  473.       @move_state += 1 if need_scroll/ D" B% H, V% l" m, ]# q
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand' q/ g) ?% f2 G# ~3 K& _- ~! S( Q
  475.     elsif mouse_col == -1& m" h$ r  s% W  a7 G, J/ \8 f
  476.       @move_state += 1 if need_scroll4 t1 i; v  P! i2 a7 S/ i; z- Z" e
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand' h& \6 g) X- x2 S+ \& l  e
  478.     elsif mouse_col == -2
    ) J, E5 p: |8 n( R4 a- `! R" i# z
  479.       @move_state += 1 if need_scroll+ I9 o( i  u% M2 d/ [* y
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand  _! V+ o) w$ c7 k* }) l6 x' ?; r
  481.     else& p, u- p! q2 q3 S3 r
  482.       @move_state = 0
    , Q0 W+ Z& b9 l* W4 t
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col4 K% u2 r; b- \3 z; X9 |1 E
  484.       select(new_index) if new_index  item_max && new_index != @index
    8 e8 `" H5 d$ s1 ^" b! V
  485.     end
    8 C" a3 A( g4 l, D3 m
  486.   end
      U$ m* m+ u) ?/ u% G% o
  487.   #--------------------------------------------------------------------------
    1 x/ G: b( [7 X1 ~# h
  488.   # ● 判断鼠标位于菜单的第几行、第几列. G% j0 b2 S* e/ V
  489.   #--------------------------------------------------------------------------. v' H* j4 S: L/ q5 h& j. M
  490.   def mouse_window_area9 Q, X$ D$ c+ J- h
  491.     if viewport.nil # necessary!5 Q  Q( r! Q9 h8 m$ @6 v# o
  492.       vp_x, vp_y = 0, 0
    . y- I' w( |; n( `
  493.     else
    , u2 P/ m% M, H' t1 K
  494.       vp_x = viewport.rect.x - viewport.ox5 Q2 k  {4 e) q5 D
  495.       vp_y = viewport.rect.y - viewport.oy
    7 r, ^: H0 D8 A
  496.     end
    - u# C8 H, c# X) Z
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y. O7 M' P6 F& a
  498.     item_x1 = vp_x + x + standard_padding
    $ X7 S! l3 z0 T8 m! f
  499.     item_y1 = vp_y + y + standard_padding0 Q, g& @6 R7 }8 D$ g
  500.     item_x2 = vp_x + x - standard_padding + width
    ' _( c% q! C( P! e" a- Q
  501.     item_y2 = vp_y + y - standard_padding + height& J" h, O! h( e% c' W! w
  502.     if mouse_x  item_x1
    0 l; x& x3 T$ @. }5 U
  503.       mouse_col = -1! r4 r  [, d- m* t/ }
  504.     elsif mouse_x  item_x2& R% s% t% T. v( w
  505.       mouse_col = -2
    ( w- Y0 Q4 L! v: @: r3 r
  506.     else: `( E6 J  y8 h. X9 W0 p5 |
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    $ R! i$ C( U1 w  ]# W: d
  508.     end6 M1 \* R1 N  X+ }' n$ v/ T  ]
  509.     if mouse_y  item_y1
    5 j; v$ v; K& G. R" V
  510.       mouse_row = -1% n: b. k; Y* Z' T7 R, _7 x
  511.     elsif mouse_y  item_y23 x2 b3 a3 d$ H
  512.       mouse_row = -2' k$ K' @4 g$ c8 K
  513.     else
    2 X; U7 h, P& K7 h- m# M
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)% T  Q  O/ Y7 V! B5 ]3 P0 G' Q
  515.     end
    ! [  n2 c, b( G' c
  516.     return mouse_row, mouse_col
    % ?8 T( C" [" N3 }
  517.   end0 I. f. t" q+ E' Y  I' r9 v
  518.   #--------------------------------------------------------------------------2 ~) C- X' L9 r; Q9 c8 r) ~" H
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    2 X) G# ^- b- k  a/ C
  520.   #--------------------------------------------------------------------------
    3 H4 q/ x& e8 n, X3 y/ i
  521.   def set_mouse_pos; x% E# w9 }6 q0 s' _
  522.     if viewport.nil # necessary!
    + z* r# X; Q% W6 ^( R) T4 n3 r
  523.       vp_x, vp_y = 0, 0
    + c2 ^1 j% E, `" q* G& S
  524.     else
    " n4 i9 d$ N+ F9 G: u5 ]9 h
  525.       vp_x = viewport.rect.x - viewport.ox, F. u: b# W- Y& h" R* N+ T
  526.       vp_y = viewport.rect.y - viewport.oy* O% Z: z$ `" A3 ~# d
  527.     end
    ( H5 B1 ^% n6 ?" C6 t
  528.     item_x1 = vp_x + x + standard_padding . I, D) o! r8 c6 j) V" ~
  529.     item_y1 = vp_y + y + standard_padding
    2 Y. e0 ^3 Z/ q$ L1 ~6 g0 t
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    6 R& h& g" r9 D/ l
  531.     row = get_index  col_max - top_row
    - F2 s, r/ K$ j9 }
  532.     col = get_index % col_max
    0 m3 O5 F, c/ F& N- y
  533.     new_x = item_x1 + item_width  (col + 0.5)" h; _0 P# ~# c0 H/ @
  534.     new_y = item_y1 + item_height  (row + 0.5)4 ]( i7 a% }& [, _% f! C8 I6 N
  535.     Mouse.set_mouse_pos(new_x, new_y)4 _8 d" J0 K& {" f/ R/ W
  536.   end" c% h, d0 I, ]- n) `: x
  537.   #--------------------------------------------------------------------------
    : |) L+ d: V# n0 J& M+ [" h
  538.   # ● 判断菜单是否需要卷动& G* i, e# s2 S. Q- X. I8 d- {) l
  539.   #--------------------------------------------------------------------------
    5 z2 [% m& e* ^0 a, o1 x
  540.   def need_scroll$ p. o, c6 l& K2 k, y
  541.     item_max  col_max  page_row_max( n0 D& m" U- E  y  ]8 q' b0 Y
  542.   end
    & E- Y- R. S( u! N, N" i
  543.   #--------------------------------------------------------------------------
    ; {. v4 W' q% r! O
  544.   # ● 判断是否为水平卷动菜单5 I. r7 d( v/ M$ ?- h
  545.   #--------------------------------------------------------------------------
    5 Q% |5 S$ G4 X9 E$ b2 E
  546.   def is_horzcommand. J* Q2 @, ^! w# C
  547.     return false6 d7 p7 v! a0 m
  548.   end
    # H8 B/ S- r# j% ~
  549. end( ~5 ~7 N! A+ Q# L& x5 Q* R0 f8 O( g
  550. ! v  k9 {2 G; @( V
  551. class Window_HorzCommand7 B( Q) o' ?1 o! G8 ~0 ^
  552.   #--------------------------------------------------------------------------
    4 U. R9 l5 U: b2 Y
  553.   # ● 判断是否为水平卷动菜单. D& J% p" a/ T
  554.   #--------------------------------------------------------------------------
    # N$ e. Z/ ^) Y$ F& ?- u/ `# z
  555.   def is_horzcommand7 K8 S8 W4 G. a8 ^# Y6 K3 M( [
  556.     return true) e, B) s& l) @# z3 a, o
  557.   end
    0 R& x  h3 J- g
  558. end
    2 e* t, k( n7 ~) W2 p' F% i

  559. : L( z! R9 Q- e7 Z/ @" ~& Y
  560. #==============================================================================
    4 N" {9 P  J  R* e8 D4 V- Z. W
  561. # ■ Window_NameInput
    + F/ q# `" |( H& I' L
  562. #------------------------------------------------------------------------------
    7 D0 H5 G: e! |# Q
  563. #  名字输入画面中,选择文字的窗口。3 j; U: W9 X( R% {8 f
  564. #==============================================================================
    ( X9 x# `+ M/ D" P
  565. class Window_NameInput! Y2 n8 n. j$ N; R5 Z& R) v
  566.   #--------------------------------------------------------------------------
    4 K# F' r: e, Z- p
  567.   # ● 设置列数
    9 S$ q  ?2 u9 b9 {# U
  568.   #--------------------------------------------------------------------------) I! W: v8 t- j7 E1 Z
  569.   def col_max
    * b" X: Y+ {9 v/ C5 h
  570.     return 10
    7 e  \; |  V" U' s4 A0 T
  571.   end1 Z8 C. N; g' g- y& O) u7 r
  572.   #--------------------------------------------------------------------------9 f8 x( B! A( [, N/ A  c1 S
  573.   # ● 设置填充的Item个数
    + A9 |% d7 d% T" I# y( n
  574.   #--------------------------------------------------------------------------1 i; v; m8 k3 O0 c3 k
  575.   def item_max/ t% x: t6 K. z+ M9 H3 R: Q1 k& v
  576.     return 90; t, t; v6 g* |* {) e
  577.   end1 X+ @/ a  l. b" x- c
  578.   #--------------------------------------------------------------------------
    . ^' U! Q) j* I! ~. p5 H
  579.   # ● 设置填充的Item个数' m' p; T- Y; J; C- @$ q& Q
  580.   #--------------------------------------------------------------------------
      F- F& z$ s( ]& @. k' ]8 z( J1 d
  581.   def item_width
    + H9 R0 {/ a3 J( k  ?! ?; v, L2 A& ?& w
  582.     return 32/ X1 F( J$ z0 x7 |% q  a
  583.   end" k# D5 n; T" S6 `; V" T
  584.   #--------------------------------------------------------------------------
    : R2 j6 Q; z. @
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    6 V3 ]2 P$ b* l, M& i  i+ _
  586.   #--------------------------------------------------------------------------1 _3 r; I8 \+ |! ]; f& K
  587.   def mouse_window_area
    ; y. ^$ k. _; l* L( @
  588.     if viewport.nil
    2 \) u/ V6 O  Q/ b
  589.       vp_x, vp_y = 0, 0
    ' K+ M3 `) E4 e) j! ^" R
  590.     else
    ; F1 h6 j8 Y: c% [
  591.       vp_x = viewport.rect.x - viewport.ox, S5 U( x! {4 `, f8 b$ p
  592.       vp_y = viewport.rect.y - viewport.oy
    6 n/ W) \; `: C& ?. j& z
  593.     end
    8 Y( p/ @& y3 S" l7 X" R, ^
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    9 W6 E" \+ b" p9 O: u; E, I
  595.     item_x1 = vp_x + x + standard_padding
    + H& V0 g9 o# t1 {- y# h! L
  596.     item_y1 = vp_y + y + standard_padding1 S" R& |# w+ U( M- h( \1 F
  597.     item_x2 = vp_x + x - standard_padding + width. o( h9 m: a2 H% l+ o
  598.     item_y2 = vp_y + y - standard_padding + height
    1 X5 A1 Y+ @; I
  599.     if mouse_x  item_x1  T* D( A9 F' t/ X6 h
  600.       mouse_col = -13 m( n( z7 ^0 Q$ r) w9 n: Y3 z/ @, ^
  601.     elsif mouse_x  item_x2
    . i8 i# Z+ L5 f" {0 F
  602.       mouse_col = -2
    ! l5 M% x# }# O5 J) i
  603.     elsif mouse_x  item_x1 + 160
    # ^" T5 G2 ]: J! g: g
  604.       mouse_col = (mouse_x - item_x1)32! \. _. a( a) U- }
  605.     elsif mouse_x  item_x2 - 1609 L: u+ |$ E- Y: c$ [
  606.       mouse_col = 9 - (item_x2 - mouse_x)32# l: }- t0 f$ ]( }. W: t4 ]
  607.     else  {* A  A# Y; z% s' g
  608.       mouse_col = mouse_x  x + width2  5  4
    2 z3 }$ z, c1 N0 P
  609.     end# L: E+ q* ^, D0 R* g4 z8 ?
  610.     if mouse_y  item_y11 Z1 n8 o" r2 i0 `5 O* `; W
  611.       mouse_row = -1
    2 y' j4 z! x) m- @, w
  612.     elsif mouse_y  item_y2
    8 a* G. _& ]8 Q% H
  613.       mouse_row = -25 T% A4 ^7 b. y! m/ i0 Z* v
  614.     else' o& h7 r1 b, _7 B6 j$ |0 F
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    5 D" T7 M% f; C0 D) e
  616.     end6 q! k. @- Q. D% x, J7 F* u% M& F
  617.     return mouse_row, mouse_col
    & ]; s( M6 B+ o% c: r3 t
  618.   end4 l& C' E# B0 |1 U  G- Z& f& A
  619.   #--------------------------------------------------------------------------
    5 o. s) }4 S* |) m9 W
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    - N; |4 ^* [) O9 O5 }* G3 \
  621.   #--------------------------------------------------------------------------
    5 u# q* E( X# x5 g
  622.   def set_mouse_pos# G  J5 Y* k3 O4 \8 o2 q
  623.     if viewport.nil # necessary!
    0 k& Z+ W$ I& w- x" Q6 R" {
  624.       vp_x, vp_y = 0, 0
    5 g3 P5 y& G3 f8 x5 J5 h
  625.     else
    5 g" f* q; _" @+ A4 ?1 B4 L1 K
  626.       vp_x = viewport.rect.x - viewport.ox
    ; \; ~* S; G  |
  627.       vp_y = viewport.rect.y - viewport.oy! |! g1 F$ Q! E$ y' ^
  628.     end
    : E) E& p9 }" Y$ D8 S7 C% Q
  629.     item_x1 = vp_x + x + standard_padding
    * R0 A( F6 Q& H' [
  630.     item_y1 = vp_y + y + standard_padding
    0 [3 k8 t; U& v7 [1 e
  631.     get_index = @index  0  0  @index ' d- v5 x2 y$ A' r# D
  632.     row = get_index  col_max - top_row, O: G  B) Z! O7 t5 j
  633.     col = get_index % col_max: Q  E5 Y* M: r2 w
  634.     new_x = item_x1 + item_width  (col + 0.5)
    ; s6 p  ^, ]# r0 d
  635.     new_y = item_y1 + item_height  (row + 0.5)+ S. J& I8 A% l# F7 O8 ]% _
  636.     new_x += 14 if col  4$ E  l! C- g1 s& u6 A/ q) H
  637.     Mouse.set_mouse_pos(new_x, new_y)- f; G: N$ l% ~
  638.   end
    5 H! j$ |+ d  M  A1 Q7 t' i3 @
  639. end9 O% ?! G( e4 G3 n+ S

  640. , A1 W4 v1 `' d9 m" B% g) U
  641. #==============================================================================
    ; E5 V1 Z! o1 e
  642. # ■ Window_NumberInput3 u. J' p1 d8 ^4 z# J) Z+ s: @
  643. #------------------------------------------------------------------------------
    8 u1 q- {+ V% q' f4 ]) T
  644. #  重写了数值输入的方法以适应鼠标3 c; @% T" B/ i/ S+ ]) |5 U) D- u( r! d
  645. #==============================================================================: v4 ~1 U) G" V% j
  646. class Window_NumberInput  Window_Base
    : x/ b* q, ^5 i, Y, G' X: t
  647.   #--------------------------------------------------------------------------6 o' T- `! o/ J8 I* Z
  648.   # ● 定义实例变量
      F. A6 [$ }* v! O8 Q
  649.   #--------------------------------------------------------------------------# [* ?5 y2 U, S5 p6 p
  650.   attr_reader extra_window
    8 k$ \. I6 X8 y% ~
  651.   #--------------------------------------------------------------------------+ m9 g- S1 r+ |. |8 Z. l* W" ?1 a
  652.   # ● 初始化8 N. a" g0 O# [; V. W
  653.   #--------------------------------------------------------------------------( ?8 b" |" X- `. C( P  v3 Z6 W
  654.   alias sion_mouse_initialize initialize
    5 o9 X* ^' K5 J( L3 p2 V
  655.   def initialize(arg). g/ q, p2 H0 n+ K
  656.     sion_mouse_initialize(arg)
    ; n) g! D6 }* F  |7 u, d: T
  657.     create_extra_window
    ! G0 r7 u$ j3 H. J" T
  658.   end+ w4 g! g( ?9 W* p9 B: Y" `( H
  659.   #--------------------------------------------------------------------------/ W- T  q( r' B7 a$ |
  660.   # ● 启动
    ' S% L+ @. P# q9 _- [0 J$ i
  661.   #--------------------------------------------------------------------------0 ]' J$ Z0 D1 F6 l; N2 X
  662.   alias sion_mouse_start start# H/ ?. W" O2 G  r) g) E
  663.   def start* p1 r( F" i) ~, N/ n1 z
  664.     sion_mouse_start: n) u4 m/ T5 N
  665.     deactivate
    5 U, w. f0 v& W
  666.     extra_start
    2 g' i; A; L7 u* o
  667.   end, S6 t7 D, W9 S7 B- j9 H
  668.   #--------------------------------------------------------------------------
    4 h; k4 W/ P: [5 w( g" r# f
  669.   # ● 创建新的数值输入窗口- w+ M+ C# }* Q, v/ }+ {
  670.   #--------------------------------------------------------------------------& V. C, R+ \4 F/ s6 \7 y- r
  671.   def create_extra_window
    " V9 H& x; @; A  x) G4 x% H" M
  672.     @extra_window = Window_NumberInput_Ex.new" x, H8 m: o0 Q6 q# `9 M8 a
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    ; f1 C- _' h' Y6 y2 ]
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    4 y2 M+ a2 |: l$ b, ^. I% o2 H
  675.     @extra_window.index_proc   = Proc.new {n @index = n }( P& U+ T* S7 m- U
  676.     @extra_window.close_proc   = Proc.new { close }
    # F8 z* K0 f# i2 X' h
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    3 Z8 N1 A8 R- s8 Z" s
  678.   end
    0 p  B% }6 }7 C- |3 Z% f
  679.   #--------------------------------------------------------------------------! j* H6 @; K8 @, Z
  680.   # ● 激活新窗口( C. q. a9 h: r1 U9 n
  681.   #--------------------------------------------------------------------------" k  v6 K6 s7 w- y/ _
  682.   def extra_start
    3 Y+ F+ ~% x* ~) g6 }& o
  683.     case $game_message.position
    & Z$ v9 Y, y+ z: T- Z" ?
  684.       when 0; @extra_window.y = y + height + 4
    4 R/ k7 h+ Y0 [  _3 Q: D
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8' h* d4 r( Z: m. g; i
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    ! S/ ~' K# o8 u# x
  687.       else  ; @extra_window.y = 8# o! @, H, F2 S1 |
  688.     end" S! O0 _  E2 U# U
  689.     @extra_window.variable_id = $game_message.num_input_variable_id7 `  R% S$ S& Y) Y
  690.     @extra_window.digits_max  = @digits_max/ i# y9 E2 S  ?" v& \2 `1 T1 l
  691.     @extra_window.number      = @number& Y. y, f6 x) m0 A/ ^9 |
  692.     @extra_window.open3 l/ P8 ?5 E% u# c$ |5 g2 _
  693.     @extra_window.activate9 k8 A3 F+ g+ w1 B! a9 Z+ ]1 ^
  694.   end
    ( d! @, I4 I: l- O
  695.   #--------------------------------------------------------------------------( X  a; f$ `% i& C' t
  696.   # ● 更新* n  {$ Y% T, V& U% n# X
  697.   #--------------------------------------------------------------------------
    ) @7 |6 u- b" \7 ^4 ]
  698.   def update
    ) ]& A$ k# e! A3 b2 H
  699.     super$ x0 x; g9 c$ K- N
  700.     @extra_window.update
    8 Y: j& f5 S% F
  701.     update_cursor
    ; x! {$ J+ V# Q9 U- e
  702.   end
    8 P, l# k6 N/ K; F9 Q$ ~& f  X
  703.   #--------------------------------------------------------------------------7 g# G' L0 T* d
  704.   # ● 关闭窗口- x; D2 g7 U4 |
  705.   #--------------------------------------------------------------------------
    ( {; o' R' `% f  N& C0 B
  706.   def close
    0 L" O; Y* T1 B! V
  707.     super
    1 b- Y' L1 p" a3 H+ U7 @+ |9 |
  708.     @extra_window.close
    6 `; F) G0 v7 l1 ?3 H5 _6 F
  709.     @extra_window.deactivate% Y# l* ^. C5 E! u$ o0 l4 t, U8 d
  710.   end
    / U/ p9 N# M, p4 r8 U/ W6 F
  711. end  n- G3 D1 y* W6 K: N& W1 T

  712. 3 ?' F+ N/ L$ K7 R8 R2 \
  713. #==============================================================================
    / ]# X3 y$ v3 j+ t
  714. # ■ Window_NumberInput_Ex9 V! r. ?: W1 K9 m7 [/ e6 @$ J
  715. #------------------------------------------------------------------------------
    5 m0 t$ j/ C% w2 k/ U
  716. #  新的数值输入窗口(NewClass)
    9 a# [0 A3 V; j/ H9 o
  717. #==============================================================================
    3 E* X5 S! z) X* ]0 U
  718. class Window_NumberInput_Ex  Window_Selectable0 d+ a* x7 ?7 I* m0 S
  719.   #--------------------------------------------------------------------------$ {0 R+ D7 C1 j9 K& {
  720.   # ● 定义实例变量' b3 l* X, H. b7 M6 m) t6 p
  721.   #--------------------------------------------------------------------------, b# {0 T" t: g) S/ U" F
  722.   attr_accessor number_proc7 G& o1 V9 E7 X4 }2 }; j6 @
  723.   attr_accessor index_proc
    % Y) {# `$ s* _" c- Q+ @% @, M
  724.   attr_accessor close_proc# L: \% z/ Y- a  O6 C' Z6 r
  725.   attr_accessor refresh_proc
    2 M+ i7 G/ g  U& E3 ^2 P, d
  726.   attr_accessor number$ ^: k( B8 c: B0 b& q7 _
  727.   attr_accessor digits_max; ~$ l' P7 N9 d& a) _
  728.   attr_accessor variable_id7 [: \6 w/ b: q8 E+ H! h# C# Y3 o5 x: e
  729.   #--------------------------------------------------------------------------
    ' N3 a3 \; z6 w/ n* B& V, ?" r
  730.   # ● 数字表
    3 o3 ]9 l  z! ~3 ?* n5 R/ W
  731.   #--------------------------------------------------------------------------, Z0 U5 A! S" K: A# v' Q  z
  732.   TABLE = [  7,  8,  9,! s; }5 H( @3 p* p
  733.              4,  5,  6,1 \6 w1 |' m/ u* n. ]4 t$ ?
  734.              1,  2,  3,5 a3 }3 g2 s! U& n2 {1 {5 c5 ~
  735.             '←',0,'确定',]
    0 a% {/ s5 |0 i) |( {: V& v
  736.   #--------------------------------------------------------------------------8 h3 P% a; G# @) B
  737.   # ● 初始化对象- d4 W- o' L6 N3 a
  738.   #--------------------------------------------------------------------------
    . t* ^3 ]2 `" w  s5 X7 }
  739.   def initialize
    1 _1 Q6 X( P0 F) B: m2 P
  740.     super(0, 0, 120, fitting_height(4))
    ; A$ Z, l, N! f! W2 C
  741.     self.openness = 0
    3 @% ^* G. h% C" Y" S' A/ G# `3 @$ `
  742.     @index = 0  @& V. g- I1 a/ l* ~" M9 R9 o9 o) Y
  743.     @number = 0
    6 A! M+ s5 B: ?3 C9 E
  744.     @old_window_index = 0
    1 U8 O' D: G4 w0 |
  745.     @digits_max = 0
    1 K9 x0 b! E2 U  z
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    & F( }1 l  F+ o1 k" C
  747.   end$ E& N# y! ^9 t, ^( t8 S) c
  748.   #--------------------------------------------------------------------------) ^$ Y- o" Z/ i5 S
  749.   # ● 获取项目的绘制矩形
    7 F5 `; R$ l1 W' z7 ]0 ?2 o# g
  750.   #--------------------------------------------------------------------------& s, U- q) R# ?+ s. N9 K8 A
  751.   def item_rect(index)
    ' ^+ B: g4 T& M0 i# R7 F* g
  752.     rect = Rect.new
    4 _9 q6 B" R- f1 W9 U6 D# p$ v
  753.     rect.x = index % 3  32
    7 Q+ i& v7 `2 Y' e4 Y- L
  754.     rect.y = index  3  line_height5 {" e4 _* [6 c9 y& U1 \
  755.     rect.width = 32* P9 k9 E& _- `" n- I2 N
  756.     rect.height = line_height
    # V+ i/ R, w6 _) p. t! F3 A
  757.     return rect
    : P3 @0 t  E3 K) J
  758.   end
    * I: {; C% S& ^1 K7 M, {4 @, u
  759.   #--------------------------------------------------------------------------
    & Z( p8 ]' U9 l
  760.   # ● 将光标设置到鼠标所在的位置" m& e1 m+ g/ P7 |$ P! F& N
  761.   #--------------------------------------------------------------------------
    % k7 H) G- I0 w9 }1 h4 m
  762.   def set_cursor
    0 J' l$ c% ], b" D: F" f' U
  763.     mouse_row, mouse_col = mouse_window_area$ |- ?3 O5 Z2 C- Z* H, C7 q
  764.     if mouse_row = 0 && mouse_col = 0+ V/ Y5 s+ W. |6 ?1 p
  765.       new_index = mouse_row  3 + mouse_col
    8 J6 j& [' A; C, ~
  766.       select(new_index) if new_index = 11
    + r, u4 r* z% C2 v
  767.     end
    # {1 |# i; B1 R: v, {
  768.   end
    3 H4 E' E; j) v4 t0 i$ N# P
  769.   #--------------------------------------------------------------------------6 k0 q: u& i) D
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列# B& I$ ?" B, C2 ]& Z2 D' s
  771.   #--------------------------------------------------------------------------( t& T. m6 X$ E, j; O& S
  772.   def mouse_window_area% J' _+ o% w0 a, w9 ^/ z: M  u
  773.     if viewport.nil
    7 y1 e, [' f( Q8 d, a$ r& t  b4 A
  774.       vp_x, vp_y = 0, 0
    2 I7 N8 `( k& s/ ~' N
  775.     else
    ( i( D2 Q' z; n9 S
  776.       vp_x = viewport.rect.x - viewport.ox
    2 ?$ D; c. ^0 b9 I7 l5 {! n/ N2 ?; |& Z
  777.       vp_y = viewport.rect.y - viewport.oy
    % a' c1 m% d5 y
  778.     end
    # h( _% C8 w6 s2 D( R$ M
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y5 p/ ~# Q8 j% I. X1 r& b
  780.     item_x1 = vp_x + x + standard_padding
    3 s# |9 F+ j& @. U( q
  781.     item_y1 = vp_y + y + standard_padding
    6 ]# X1 k1 L1 `+ y5 y9 e5 a% q% ~
  782.     item_x2 = vp_x + x - standard_padding + width
    * z9 T* j& h+ L7 ^1 g6 O
  783.     item_y2 = vp_y + y - standard_padding + height
    . L" n- _0 t9 Z& V
  784.     if mouse_x  item_x1
    ; ?7 ]4 Y+ K( M! [
  785.       mouse_col = -15 j2 ?$ j2 O" ~4 c7 n9 g
  786.     elsif mouse_x  item_x2
    7 c. E; T' J; _' W& R
  787.       mouse_col = -2
    ( D/ h4 R( y9 k8 U0 P% U  t
  788.     else& D  R- A- D: I0 d0 z
  789.       mouse_col = (mouse_x - item_x1)  321 R& ^: d) d' [
  790.     end2 H3 S: J7 f* g& N
  791.     if mouse_y  item_y1
    * a7 C4 E' ]$ K7 [5 M0 S. D9 H
  792.       mouse_row = -1
    6 A( Z/ x9 S& G: L. X! I
  793.     elsif mouse_y  item_y2
    6 \. F. S" p0 q' a( g& i# t7 K
  794.       mouse_row = -2
    6 G% k2 g9 s% V6 @$ b6 p! V1 Q
  795.     else
    5 X# y1 Z# O. W# L) \& T
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
      a# O; N5 T6 Z7 w, B
  797.     end
    # o; p  }' Q* @/ \. k% l
  798.     return mouse_row, mouse_col* @& N, Q9 }7 q& s. P+ C
  799.   end, V" J" Q# p2 l7 w: {- a- T( i/ P
  800.   #--------------------------------------------------------------------------$ ^$ z. U6 d9 c0 X
  801.   # ● 获取文字
    ( u2 t5 ?. Z1 Q* s+ Z, I
  802.   #--------------------------------------------------------------------------/ X& |2 E; z1 }7 q3 V! }8 X7 H
  803.   def get_number* m6 s. O; b" ?9 K( Y* Y  ^! S7 K
  804.     return false if @index == 9  @index == 118 {6 R2 J( I8 E; N' h
  805.     return TABLE[@index]
    $ V. @! d- U; d( Z( Z
  806.   end
    + U, R& ~: R2 ^* w. F5 J
  807.   #--------------------------------------------------------------------------
    2 |, V3 d; @  G& y' @
  808.   # ● 判定光标位置是否在“退格”上
    1 }; c  m+ o$ L* v9 C
  809.   #--------------------------------------------------------------------------8 R+ ~" C+ P# d' y
  810.   def is_delete: J+ y5 B9 U( L# |
  811.     @index == 9
    % M8 ~: W9 w0 i1 |5 ~8 o
  812.   end+ t2 W! F& u( Q( U" m
  813.   #--------------------------------------------------------------------------2 T# u! U# F/ p' {
  814.   # ● 判定光标位置是否在“确定”上
    3 R# f! h" V* e# ^4 E: s
  815.   #--------------------------------------------------------------------------
      e* [3 E9 @1 X5 F$ |/ K
  816.   def is_ok* g0 A& {' A6 o/ s4 c. o% v
  817.     @index == 11( ^/ u% k) I: G. d7 W* o
  818.   end' T# B1 ?, D) B' O+ k) S1 h
  819.   #--------------------------------------------------------------------------
    " y  j2 F" @% b- h2 ^
  820.   # ● 更新光标
    $ P; B9 V) a6 W. B/ V2 j
  821.   #--------------------------------------------------------------------------
    0 g. N; w6 g, g+ J  _6 u/ m
  822.   def update_cursor6 R; k# L. o7 x+ B2 _
  823.     cursor_rect.set(item_rect(@index))7 @" \% K% B: z1 I, B
  824.   end. a2 [4 w0 T9 X/ J( c- T  ]
  825.   #--------------------------------------------------------------------------
    " Q  B% n  ^, v) m/ V7 J9 r" r
  826.   # ● 判定光标是否可以移动
    8 m9 t, ?' J& d) E
  827.   #--------------------------------------------------------------------------& S) ?7 `: w  @( H; p2 y& i8 m' j
  828.   def cursor_movable( ]( Z3 c& a+ p: c% j9 I2 F( u
  829.     active
    4 K6 A% q3 Z! q* I
  830.   end
      |9 r% \% f( C) B/ F
  831.   #--------------------------------------------------------------------------1 c  O* _$ c1 O3 G
  832.   # ● 光标向下移动: N/ z% i, A* F# g
  833.   #     wrap  允许循环
    5 {7 f! e2 f9 P% p) a; S
  834.   #--------------------------------------------------------------------------! ?0 l. W5 f5 T: j; e# p
  835.   def cursor_down(wrap)) u# }7 R# n; [# \' T3 s# W" f. R
  836.     if @index  9 or wrap
      K( R7 m$ L* A( @8 T5 z; O
  837.       @index = (index + 3) % 121 J6 d5 l0 q+ I$ ?
  838.     end
    1 T" i1 b8 C" g
  839.   end- r0 {" {5 }1 U6 [9 A5 k
  840.   #--------------------------------------------------------------------------
    $ m, z/ [! Q- T
  841.   # ● 光标向上移动% Z2 a' U0 j4 Q! e9 b4 O
  842.   #     wrap  允许循环
    , A( K0 J# Y& p. M  m7 t
  843.   #--------------------------------------------------------------------------% H' H! x4 N% `
  844.   def cursor_up(wrap)
    ; w8 s& B; a- a7 P! c+ L
  845.     if @index = 3 or wrap
    2 W; e+ O# j& o. t
  846.       @index = (index + 9) % 12
    + D3 {, E7 L3 @9 D4 m
  847.     end
    % P9 |$ M+ y9 m/ [
  848.   end
    & }# J9 e2 u& D& S4 J  @4 t4 b
  849.   #--------------------------------------------------------------------------
    1 H& w6 v1 n  R0 @) r' P
  850.   # ● 光标向右移动
    2 B1 r& L4 [4 q! d* ~- h; ^7 d6 ^
  851.   #     wrap  允许循环
    + s4 S5 V2 O1 P) Z
  852.   #--------------------------------------------------------------------------
    , P  B3 Y! V$ j/ M
  853.   def cursor_right(wrap)
    & q, j! h. n4 t
  854.     if @index % 3  2
    , |  E6 X# K9 V  A$ r; v7 o/ u
  855.       @index += 1; m1 W4 N* J/ C! M, Q# I
  856.     elsif wrap
    ) x0 F" \, p! V/ `
  857.       @index -= 2
    $ p1 |9 |1 d+ ]; A+ ]9 L
  858.     end
      ~( k4 }7 y: [. R! w4 {# x3 [
  859.   end) y5 t0 c* J7 V& w0 I
  860.   #--------------------------------------------------------------------------
    9 h) X. r4 U# p2 `  m1 h
  861.   # ● 光标向左移动+ X4 z# k: Q, E' M1 }
  862.   #     wrap  允许循环
    0 ~/ R5 ?- T1 }5 e% ^8 N
  863.   #--------------------------------------------------------------------------& s( n& T2 x' `' i2 }& J+ O* F
  864.   def cursor_left(wrap)8 j4 a4 B" [) e
  865.     if @index % 3  0
    $ v* ]* O: B7 t0 f& n  X4 v% e( ~
  866.       @index -= 1
    0 e% c  c9 _5 s9 z4 ]8 ^6 d
  867.     elsif wrap
    4 m: w$ M; B, D" e2 R
  868.       @index += 23 L: M5 U2 z5 W; S' M
  869.     end  f* |8 L, A/ |) V6 A6 s
  870.   end0 v& E, x! [) H, b+ j0 d
  871.   #--------------------------------------------------------------------------1 S2 j2 v/ o; I
  872.   # ● 处理光标的移动
    + m5 j5 V+ c& z6 ^
  873.   #--------------------------------------------------------------------------
    - o* |8 i, F% @. S0 v/ @
  874.   def process_cursor_move
    9 J+ z2 w4 }4 N* x, p3 s' ~+ Y8 k
  875.     super) ~2 \' q9 X; F% O% D
  876.     update_cursor1 b7 E8 F6 E7 R6 T+ K$ r. t. ?
  877.   end+ W6 g7 V3 w/ f  F8 z
  878.   #--------------------------------------------------------------------------$ E+ v, @: y% U7 f* {/ [4 p
  879.   # ● “确定”、“删除字符”和“取消输入”的处理9 E- ~. ~, T# m* c( \4 W* j
  880.   #--------------------------------------------------------------------------
    , O. ~* J  C1 t+ {/ I
  881.   def process_handling
    # \1 E, N+ x8 q8 q1 p
  882.     return unless open && active4 T1 U3 [, e7 e  A
  883.     process_jump if Input.trigger(A)
    2 B+ X9 w- `( s  B7 C. E
  884.     process_back if Input.repeat(B)
    5 [4 k% y- x; Q% N5 n
  885.     process_ok   if Input.trigger(C)0 W6 t: V" a- s3 a
  886.   end0 C6 f0 z  c+ v' C3 Z1 ~' j! Y: {( o
  887.   #--------------------------------------------------------------------------
    1 e& C; P# \( b
  888.   # ● 跳转“确定”
    4 I5 k( z& X; S- Q: \
  889.   #--------------------------------------------------------------------------
    6 c& M5 o+ s0 b
  890.   def process_jump
    # M$ Z+ V8 _+ }( R$ T
  891.     if @index != 115 @  s3 z8 L6 p8 P4 T, m2 `
  892.       @index = 11+ y2 w" L9 g. ?- h
  893.       Sound.play_cursor2 U' C2 T5 W6 v( ?, ~
  894.     end! k* P, O; l$ n) V
  895.   end
    0 R1 x, K8 R9 ?! J5 @
  896.   #--------------------------------------------------------------------------
    5 q/ \# u, c, c8 V5 [; z4 Q, g& Y
  897.   # ● 后退一个字符
    * ]3 j3 `9 ?8 T/ T
  898.   #--------------------------------------------------------------------------6 [! K6 _7 _8 ?
  899.   def process_back+ P" d" S, ^6 i8 H) ^- J- B
  900.     Sound.play_cancel, ]3 M2 x: I9 R0 b( L8 X
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    1 C. x1 q* ~/ V* o
  902.     n = (@number  place) % 10
    - v% }0 l3 O% N& P" M. E, }
  903.     @number -= n  place7 O$ Q- _- e& w  `. y
  904.     @number_proc.call(@number)
    # f! D! x& ^; `) L
  905.     @old_window_index -= 1 if @old_window_index  0
    1 }' U/ z" E4 T. @8 E
  906.     @index_proc.call(@old_window_index)
    2 b( r# {3 f7 Y& l$ ]
  907.     @refresh_proc.call
    % t# p- T* ?# m
  908.   end
    ( O  C% |4 F% A6 k$ M: a
  909.   #--------------------------------------------------------------------------
    ) c- ?/ d/ p  B' P- ~8 {5 f: R4 k
  910.   # ● 按下确定键时的处理0 ^3 ^/ t4 r8 d+ o
  911.   #--------------------------------------------------------------------------
    6 F  }  W3 S/ X
  912.   def process_ok
    4 I( D5 _3 W" E+ z/ o+ O& a0 e6 @6 i7 y
  913.     if get_number
    8 [* t" T  Y# y4 o- c/ F
  914.       Sound.play_cursor
    / z2 c5 `# P* w7 G1 y, }0 U, \, _
  915.       place = 10  (@digits_max - 1 - @old_window_index)9 ]0 z, }7 g/ |1 k8 u$ E6 g! o8 O
  916.       n = get_number - (@number  place) % 10$ B" h% p! N; S- I$ k
  917.       @number += n  place0 \! O9 a3 I8 U" X9 Z& X, N
  918.       @number_proc.call(@number)
    1 b1 M5 _' s. ^: {: A
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1& ]5 ^! w3 G+ U* Q, z8 {( h! ?
  920.       @index_proc.call(@old_window_index)
    $ K& M9 R+ Z2 D4 o# n& x2 e
  921.       @refresh_proc.call
    9 m$ E' T9 r0 q8 w
  922.     elsif is_delete. t& s/ Z0 F7 }% q! w% p9 N, R2 E
  923.       process_back. z1 ?$ C' I/ f6 @# M9 ?
  924.     elsif is_ok
    5 S$ f! G- b0 ]$ T$ ]
  925.       on_input_ok9 X( H8 g; j7 L4 ]4 E; `
  926.     end* Z8 J5 R! M. @$ w2 i( L
  927.   end
    # h1 Q  B* H1 ^/ @4 j7 s
  928.   #--------------------------------------------------------------------------
    9 o7 t1 g  E! f
  929.   # ● 确定
    / M0 _/ ]+ c& f
  930.   #--------------------------------------------------------------------------, N/ F+ k5 r% P/ P4 K5 g# t" Y
  931.   def on_input_ok
    3 P  p7 h  d! Y1 S2 h
  932.     @index = 0
    0 k0 E8 E) ^, {- ]% U: r4 Q& n
  933.     @old_window_index = 06 B3 n- G( A& U' |) J+ I
  934.     $game_variables[@variable_id] = @number  i( S' w& ~- v0 {* C: S
  935.     Sound.play_ok5 D$ y$ h, @2 ?
  936.     @close_proc.call- J% h& v' S" l0 B+ v6 s& J- F* k: s
  937.   end7 l0 Z( H% m7 ]; m
  938.   #--------------------------------------------------------------------------
    ! c3 e3 Q8 f# e' ^& L
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置7 w! x4 N. A, J& Y  Z
  940.   #--------------------------------------------------------------------------5 Z* L) ]# f% ?# _2 q  g
  941.   def set_mouse_pos& T! q1 M. v/ j, i8 v- j/ e
  942.     if viewport.nil # necessary!
    3 A5 j. O4 N% U% ^% \9 a: I
  943.       vp_x, vp_y = 0, 0, J4 e  i$ m/ w& x1 w: U  o
  944.     else
    ; x2 {" Y$ r! v: p' W7 \$ t. g
  945.       vp_x = viewport.rect.x - viewport.ox
    5 A9 K  G. O1 {/ c( O9 A. k
  946.       vp_y = viewport.rect.y - viewport.oy1 x/ s: `/ C- I# x. d( O3 @
  947.     end
    + v- P/ x4 E- j
  948.     item_x1 = vp_x + x + standard_padding / P& o8 b5 ]# j# n
  949.     item_y1 = vp_y + y + standard_padding
    : @+ Y' C( D9 g4 [( ]
  950.     get_index = @index  0  0  @index
    : ?& D% B$ x. e* J! d6 S% ~
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
      c$ [! \5 S5 S& \' _
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    1 m4 M0 [6 `5 w" F7 u7 N
  953.     Mouse.set_mouse_pos(new_x, new_y)
    1 I- R3 z% `  S8 y3 e- S7 N8 X1 `# C
  954.   end
    / K+ e# R  `7 w) E- {# t4 Z1 I  ]
  955. end
    " s- ^0 J6 Q' r: b
  956. $ L0 h; J& h+ w  ]3 `$ |
  957. #==============================================================================, N! o. I' G/ m
  958. # ■ Window_Message5 r; Q1 U9 K8 L" u/ u
  959. #------------------------------------------------------------------------------- z- f( ~9 a8 z8 ]/ i
  960. #  显示文字信息的窗口。
    6 d, g9 o4 @" O. K9 S. O& o! J
  961. #==============================================================================
    # R1 e$ z* Y% y" u) C
  962. class Window_Message  Window_Base9 w) x$ d5 M& d# y3 x/ k
  963.   #--------------------------------------------------------------------------
    2 A+ X  B, ]. \- R0 y& d- W9 W
  964.   # ● 处理数值的输入(覆盖原方法)
    * b0 r" S' T% u3 [6 l6 S
  965.   #--------------------------------------------------------------------------
    : P/ \7 i' _3 d" ~, ?
  966.   def input_number1 o6 T; N7 k% ^' q
  967.     @number_window.start1 M" @2 \6 i, k- x# z3 r% D# |
  968.     Fiber.yield while @number_window.extra_window.active
      ~$ Z8 y' J  k7 r
  969.   end. p) a3 ?, c) n6 t; ~7 B$ R# B
  970. end' U4 t$ _/ o1 r$ l/ |% u/ i

  971. 6 h/ @' d( k9 [7 ?' o+ f
  972. #==============================================================================
    ( J7 _4 i; _0 L5 a/ y
  973. # ■ Window_PartyCommand0 O! e- }/ u% d. I1 d5 m; L
  974. #------------------------------------------------------------------------------* q. t1 K" b  f) q
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    4 a7 j7 y! D9 `  _; B, {
  976. #==============================================================================& E1 D6 ~$ C  i. a4 o( g  M& q
  977. class Window_PartyCommand  Window_Command7 M  Z" v% p- O- z& N" k9 ~7 O
  978.   #--------------------------------------------------------------------------9 N8 I7 [/ f6 |- O+ `) V
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    5 k4 I0 r, s, J2 F) S& F3 B
  980.   #--------------------------------------------------------------------------- \4 Y  K! I8 E, x
  981.   def set_mouse_pos( W3 @) Y5 q) ?8 Z+ U2 ^! j& O
  982.     if viewport.nil0 R) [; {- m- j( D; C' p0 s
  983.       vp_x, vp_y = 0, 0
    . |+ }8 ~( `2 ]: ?1 H& R
  984.     else5 b" k% T# Y$ h* z
  985.       #vp_x = viewport.rect.x - viewport.ox
    3 \5 }7 b1 \; P- ], T
  986.       vp_y = viewport.rect.y - viewport.oy4 _+ U8 I3 ^% y
  987.     end
    * q$ t9 N: n% s! p+ H2 V
  988.     item_x1 = x + standard_padding % Y9 x, O1 H( t4 T
  989.     item_y1 = vp_y + y + standard_padding9 s6 }: `& \. p* Z$ E* n, ~
  990.     get_index = @index  0  0  @index
    ' B3 {  B$ T# P# b; B5 i6 ^' b
  991.     row = get_index  col_max - top_row
    $ S$ ]) ]7 y) B" E2 Q6 J
  992.     col = get_index % col_max
    / D0 [! D+ m* T
  993.     new_x = item_x1 + item_width  (col + 0.5)2 K: Q, r9 @8 V9 t7 l# k1 g7 x
  994.     new_y = item_y1 + item_height  (row + 0.5)4 Y3 Q* o  S* t8 A
  995.     Mouse.set_mouse_pos(new_x, new_y)
    . N1 m+ D+ I; c3 q
  996.   end5 O7 H' ~7 w$ x* }
  997. end! d" N1 h2 u. M1 Q( T: Y* S

  998.   n7 V$ }- O# D% J4 {
  999. #==============================================================================$ n% B  ]0 `6 p9 b0 `
  1000. # ■ Window_ActorCommand
    # M) X5 r3 A/ |
  1001. #------------------------------------------------------------------------------
    " }! I  {5 u" n( [" s( O- ^0 k
  1002. #  战斗画面中,选择角色行动的窗口。
    * A1 j6 ~4 r7 \, ]" E: ~
  1003. #==============================================================================' t+ v/ V5 Z- e/ D- {
  1004. class Window_ActorCommand  Window_Command
    & ?7 q$ w' D7 V
  1005.   #--------------------------------------------------------------------------. K0 w/ _  E! F9 W+ r" T
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    9 i. g- u& s; R+ _
  1007.   #--------------------------------------------------------------------------2 ^. v! S, Z7 @! Z: X& j; i8 P
  1008.   def set_mouse_pos- Y' T' g" K1 _( x; G3 F9 `
  1009.     if viewport.nil' H; K- v8 C$ l* n- }( E7 R6 z
  1010.       vp_x, vp_y = 0, 09 ]' \7 G: A0 h, `. k1 d8 E. N
  1011.     else* a% x$ [# G. W0 m. u
  1012.       #vp_x = viewport.rect.x - viewport.ox
    " y, J/ o/ B8 n' B$ Y+ `
  1013.       vp_y = viewport.rect.y - viewport.oy
    6 }0 V( g$ Q4 _2 I$ \  E
  1014.     end
    $ n, |* O, ^4 Q- @4 e1 H
  1015.     item_x1 = Graphics.width - width + standard_padding9 s6 B% E! U* v4 K- l3 N
  1016.     item_y1 = vp_y + y + standard_padding2 |* a( J9 C: m" d
  1017.     get_index = @index  0  0  @index   D! l4 y& T0 ]6 R4 N! Y' s
  1018.     row = get_index  col_max - top_row0 n2 V, p3 `( j
  1019.     col = get_index % col_max
    ' Y7 k( `- E9 |  D
  1020.     new_x = item_x1 + item_width  (col + 0.5)2 t% a8 l% y! D, L4 d3 n) P1 o
  1021.     new_y = item_y1 + item_height  (row + 0.5). o$ ~4 Y- R$ I3 A7 E+ Y! j
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    % H0 l% J" Y/ q- c2 [, i
  1023.   end6 Q( B2 ~, B3 p. V2 g$ ~
  1024. end" ~( p* L8 |5 u. G

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

  2225. * q/ ]1 ?8 t1 c& \: R
  2226. #==============================================================================; Q: y: c% b! O+ \1 Y/ |
  2227. # ■ Spriteset_Map- p$ \6 \' Q* u5 t# H
  2228. #------------------------------------------------------------------------------7 i% L, I/ ]' I6 ?. ]6 W
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    : ~, N: ~- E* ^4 c9 P: q; G9 v0 L
  2230. #==============================================================================, r$ J1 ^, i& T
  2231. class Spriteset_Map8 C8 g7 h- {# y& I$ Y
  2232.   #--------------------------------------------------------------------------; C5 r1 v, w* l. r( z$ W0 }
  2233.   # ● 生成路径点精灵
    # c4 K: d/ ]3 e; I7 ?& n4 K
  2234.   #--------------------------------------------------------------------------
    ! a" W7 _+ ^" H* y4 }
  2235.   alias sion_mouse_create_characters create_characters5 W4 y- L  y' t' p' F2 C
  2236.   def create_characters* {! R+ L6 E( t6 q( x/ \
  2237.     sion_mouse_create_characters
    + A6 s* B/ q  Q' \
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))4 w+ A  o+ \/ q1 u9 k; J; ?
  2239.   end; A6 |* X4 ^! a" g; g
  2240. end
    , ]- q) j* ?: o, h$ m& a, D

  2241. 6 J6 @* M' K. H! n0 `# k1 l
  2242. #==============================================================================# Z/ y9 T" p3 k6 G+ l
  2243. # ■ Scene_Map
    - K" }0 r/ ~# J1 f. b
  2244. #------------------------------------------------------------------------------' R) H4 E; [% v
  2245. #  地图画面
    * b4 a4 N6 E: T5 d% V# d
  2246. #==============================================================================) H) l6 B! h: A
  2247. class Scene_Map  Scene_Base! i$ v  z. r' g# W
  2248.   #--------------------------------------------------------------------------
    % O- x3 [2 c) D- f# c2 l+ ]
  2249.   # ● 画面更新
    , A/ e- v2 _8 F6 T0 w1 W
  2250.   #--------------------------------------------------------------------------
    8 O8 B& ]" b" I* z
  2251.   alias sion_mouse_update_scene update_scene
    5 T8 L! S  t2 D
  2252.   def update_scene
    8 }% t* x0 ^9 T  b% E
  2253.     sion_mouse_update_scene6 u& `" c5 G2 k9 P, i% Z  o6 |) v9 o. v
  2254.     update_mouse_action unless scene_changing
    8 o, O3 Y6 j5 }% _. i
  2255.   end
    3 z) Q1 f6 [! P$ D& g" o  p5 R
  2256.   #--------------------------------------------------------------------------
    + g3 a) V4 M2 U- [% p+ [$ d
  2257.   # ● 场所移动前的处理
      ?! }* v( G& T: E
  2258.   #--------------------------------------------------------------------------
    ) b6 D  f3 H0 R/ ^" k# r
  2259.   alias sion_mouse_pre_transfer pre_transfer
    0 |: V. g) Q, r3 y
  2260.   def pre_transfer8 B- G& H& F! N& U
  2261.     $game_player.reset_move_path) q- o7 V$ O, D$ w' H% O
  2262.     sion_mouse_pre_transfer
    2 ?& s/ f  t7 ^
  2263.   end2 M$ H5 h4 O" `/ m" m
  2264.   #--------------------------------------------------------------------------9 b* S# F0 i, q4 i" F9 e
  2265.   # ● 监听鼠标左键的按下
    & G4 `; p1 N$ O% ]
  2266.   #--------------------------------------------------------------------------' C2 }# P5 f4 p. z+ I/ Z$ n7 u
  2267.   def update_mouse_action$ N  Z5 {9 |  r! f9 S  T* I% _/ z; J
  2268.     $game_player.left_button_action if Mouse.press(0x01)! X, T0 |; T( P. _/ s) ^  A7 [
  2269.   end
    # k, u7 \* [) E; ^- p
  2270. end/ B0 {, J; _5 N& k
  2271. + d3 l1 d8 y. O0 q( }& G5 w. P# G
  2272. #==============================================================================
    2 U; u7 f; q$ ^
  2273. # ■ Scene_File2 z9 m8 _7 I* C% D4 \0 I& F
  2274. #------------------------------------------------------------------------------4 f" ~, ?5 G% N! u6 n
  2275. #  存档画面和读档画面共同的父类
    5 ]& E& {' P" Q" U
  2276. #==============================================================================
      E6 W; z: \7 Q' A
  2277. class Scene_File  Scene_MenuBase
    ) c6 B- C/ Z( c4 f* t; B
  2278.   #--------------------------------------------------------------------------2 S0 \% Z: p9 C$ t
  2279.   # ● 开始处理
    : c, h0 E0 P) P
  2280.   #--------------------------------------------------------------------------8 K1 ^$ p" t  Q9 _4 |! n" [
  2281.   alias sion_mouse_start start4 R4 {5 S) }) X( c" U
  2282.   def start3 ^+ t6 O1 B" m( a8 S, Q6 B! C3 I  F
  2283.     sion_mouse_start, `/ L2 V) r7 s( N. Q
  2284.     @move_state = 0, s# {& R8 E- c3 a
  2285.     set_mouse_pos
    . ?7 H# M* I" H( b, |
  2286.   end
    : f& I9 j* ]7 U: D1 {
  2287.   #--------------------------------------------------------------------------
    - t3 K1 |& y( j: W8 _* o
  2288.   # ● 更新画面2 @0 B) a( y' D+ V) K% h
  2289.   #--------------------------------------------------------------------------, z* C3 l0 a+ I  d
  2290.   alias sion_mouse_update update
    3 X, m7 m3 i7 _% P8 ^) E, i! B( T1 ~
  2291.   def update/ O; c0 b& g8 q: M
  2292.     sion_mouse_update8 g! p& F) Y% F( c$ m% n6 A% h  z) q0 W
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
      g4 q7 B0 J0 s; i
  2294.   end5 F4 v* s3 X' k+ f9 q& f7 g
  2295.   #--------------------------------------------------------------------------( }! I+ p$ r  F1 B. I
  2296.   # ● 更新光标
      |3 Z& }9 ~, `& h. ]/ r
  2297.   #--------------------------------------------------------------------------/ k0 f: G; l  K" U
  2298.   def set_cursor
    7 O0 _* z' N1 d5 l
  2299.     @move_state += 1
    3 y+ Q, b! w4 X/ B
  2300.     last_index = @index* K. @# T) e. M
  2301.     if mouse_which_window == -2
    , ^3 W) y5 a* d* f; s; ]6 x) ~
  2302.       if (@move_state - 1) % 6 == 0+ u( _' B9 x; i
  2303.         @index = (@index + 1) % item_max if @index  item_max - 18 x% r6 M2 c  |$ E# v
  2304.       end
    1 l# q, f. u( g8 [0 j& a* U. f
  2305.     elsif mouse_which_window == -1- w$ b" f' {7 u' m; L; `: r
  2306.       if (@move_state - 1) % 6 == 0; \7 K7 L. l8 X. a8 K7 C# Q, ?
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0; }; e$ n3 D! C/ }) Z+ z; X; q
  2308.       end- x7 W+ u5 R4 x: u8 Q
  2309.     else
    ) S# \$ O5 T/ i1 T
  2310.       @move_state = 0
    ! \- }4 R  h6 j% |: o# |: Q
  2311.       @index = top_index + mouse_which_window- `" }: d. k# e- D4 \
  2312.     end4 U5 i& a( q: r. j, S+ i' r
  2313.     ensure_cursor_visible
    - I7 T0 `, t& P4 M1 T
  2314.     if @index != last_index
    ) r+ r/ R/ o& ~+ ^8 T$ I4 ?+ S  d  e
  2315.       @savefile_windows[last_index].selected = false
    : Q2 k0 V& O6 e: A3 z
  2316.       @savefile_windows[@index].selected = true
    2 t( J' y: _: B) `
  2317.     end
    . X. p7 o# \/ i) m& q% M0 |
  2318.   end
    2 d4 J. C6 F9 z& x2 Y6 [
  2319.   #--------------------------------------------------------------------------
    8 p- y& _% A! ^* \9 b
  2320.   # ● 判断鼠标位于哪个窗口; u3 T( [9 V" x4 p, I. A
  2321.   #--------------------------------------------------------------------------9 _9 ^0 k0 z' f0 h& ^9 `$ o0 d
  2322.   def mouse_which_window
    . ^* v- e% y' L3 _% v9 d
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    " V: s0 @7 g. L! A2 l7 `6 A* \# g9 S
  2324.     if mouse_y  @help_window.height + 14, _* R. [* v6 n. R  C
  2325.       mouse_row = -15 g' a% Q# J8 X# Q& e
  2326.     elsif mouse_y  Graphics.height - 14/ {2 ^) S, S7 s1 g3 ^
  2327.       mouse_row = -2
    2 F( k& _' L4 s% N0 Q0 Y3 R3 r
  2328.     else
    7 f$ T6 Y6 p) e. I1 t8 v
  2329.       mouse_row = 4  (mouse_y - @help_window.height) $ m1 m+ i# Q4 }+ j/ z
  2330.         (Graphics.height - @help_window.height)! i6 O2 ?; u% V5 G) r' [- R# N
  2331.     end
    & m1 G# a) C. B' L/ L( @
  2332.     return mouse_row
    * q% V7 F' ]) o, F$ Y: N
  2333.   end7 X* a# p% E  \% Q* f/ _( |$ q
  2334.   #--------------------------------------------------------------------------( Q/ g# ?8 x# a& L' w
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置% {! k; i+ }, I( g; _4 X5 T& q- X( ]
  2336.   #--------------------------------------------------------------------------! Z$ B9 m' p; t9 V
  2337.   def set_mouse_pos' C7 D1 d& P# Y" d) v
  2338.     new_x = 40
    1 I, x! X; I9 r4 g
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24) a; i2 K, A2 [8 I" F
  2340.     Mouse.set_mouse_pos(new_x, new_y)  G, v4 c8 ^8 l) {3 o
  2341.   end- ]" E, g' C, A2 Q" z
  2342. end
    / V, P& I% Q0 e2 j5 ~
  2343. ) `$ A  B' F7 ?# U4 ^5 p  w, Q
  2344. #==============================================================================
    # o! K( I* s) D% P. \
  2345. # ■ Game_Event
    4 c+ R& Q9 n3 w3 ^/ P7 m% c
  2346. #------------------------------------------------------------------------------! J( c$ l+ {; {) U) c; ~
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    5 J# G& O+ m! S/ B5 @9 u
  2348. #   在 Game_Map 类的内部使用。
    * y9 S* q6 ~" S  x+ ?
  2349. #==============================================================================
    ! r7 t4 I4 X) R, H& `, h
  2350. class Game_Event  Game_Character
    " d5 a$ b" Z1 y- _7 W1 H
  2351.   #--------------------------------------------------------------------------2 T" u% x/ D/ w! G7 }
  2352.   # ● 事件启动
      {' O$ y/ z9 q* l" j/ X4 R
  2353.   #--------------------------------------------------------------------------
    2 _1 @. b3 q/ R! l! j' x! E( ]
  2354.   alias sion_mouse_start start- c4 J9 Q9 Z) e' A, Y% }- t' y6 V
  2355.   def start
    9 ~7 Q: z- |# U: E5 o
  2356.     return if mouse_start && !Mouse.press(0x01)" a3 h6 P# p- j* R
  2357.     sion_mouse_start
    " [/ E$ q: k+ F. k$ y
  2358.   end& Y4 f& L% L9 r3 {; g: W
  2359.   #--------------------------------------------------------------------------8 t# t! ^+ V, [$ w/ S. b
  2360.   # ● 判断事件是否由鼠标启动
    ; o1 b0 d0 ^  Z  \
  2361.   #--------------------------------------------------------------------------- r0 t4 G" u% C6 ?5 H& C
  2362.   def mouse_start
    ; M, X) k1 ~% c, w: m- z3 j
  2363.     return false if empty
    & j. i% a% O, X" [0 P9 R9 o
  2364.     @list.each do index$ ]8 Y9 T$ U& g
  2365.       return true if (index.code == 108  index.code == 408) &&4 T- ]$ y( ?& X. h. L1 X
  2366.         index.parameters[0].include('鼠标启动'). V) r" i% ?$ ?9 e# x6 }
  2367.     end5 q% O- j6 i& D" d
  2368.     return false
    3 N; V8 n! ^. S$ S: g) K1 |% c
  2369.   end; `0 ^* p4 B& ?$ B2 H( {6 t/ O
  2370. end! B  w, \- v; `7 x* R  P% l1 Q* o; T) k1 h
  2371. , F3 r# w) L# m& {8 i* i
  2372. ####泥煤的height' z) I5 ~# n0 c, h; X
  2373. # @height = height% ~9 Y1 l' O3 S1 l7 n  D, d6 l6 z

  2374. 5 |# J' G3 v+ C3 R+ Q
  2375. class Area_Response' Q+ H/ j$ w2 n
  2376.   attr_accessor type$ k. X9 M2 S/ Y- z) H
  2377.   attr_reader ox
    # H  B/ r: p: r0 \# }7 |4 K% i
  2378.   attr_reader oy+ I- ]8 F: L. E3 F4 x4 ~+ M
  2379.   attr_reader width
    ! ^% @' h% E2 O# G: h, k
  2380.   attr_reader height# u4 L' w+ o$ X) A
  2381.   attr_reader switch_id
    % R. E; e  g4 b! ?
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)2 d" ^/ s8 B5 I& _; e
  2383.     @type = type- ~3 U0 n1 b/ P5 E6 i
  2384.     @ox = ox
    ! M, B) e8 }) M4 D* A; v, t7 O
  2385.     @oy = oy$ Y+ X* {4 o* `" y1 Y" S/ ?
  2386.     @width = width2 p7 w: W9 U$ ^# ?1 J. I
  2387.     @height = height
    1 M9 V+ r' I; [; O$ x! ^4 H4 d
  2388.     @switch_id = switch_id
    . x& ^+ Q4 W3 x0 w7 @, K4 M
  2389.   end  M9 u& L, z+ z8 A8 H
  2390. end
    + v9 ~* _/ [# G/ Z& ]( ^% w  C

  2391. : n1 o: v; v0 C% L
  2392. $area_responses = []* Y0 O2 {9 J' T  ]
  2393. ; \: G$ r5 Z+ o6 w
  2394. class Scene_Map
    5 l1 S0 _0 w; X0 X
  2395.   alias update_mouse_2013421 update_mouse_action3 V0 h3 K1 K" t& h
  2396.   def update_mouse_action
    ; w' T/ z0 c% ]9 m2 i
  2397.     update_area_response3 f" H, ^1 [) W
  2398.     update_mouse_2013421& y3 W9 ?6 Z9 e) z
  2399.   end
    7 J0 K, L# e' |6 U
  2400.   def update_area_response; |3 p* S/ _) P: H) ^8 L! P& y
  2401.     responses = $area_responses
    * p, {4 |% e8 ~
  2402.     responses.each {response0 C/ d* H. _. M9 j$ _
  2403.       ox = response.ox5 V. @1 h4 Q! ^  P+ P
  2404.       oy = response.oy
    % v+ r- U/ H% Q7 l
  2405.       width = response.width# {& c; L8 E9 l. r1 m" r, \
  2406.       height = response.height
    , E; X+ @4 e" C) B( k5 z6 Z
  2407.       switch_id = response.switch_id' H# [- i+ D8 l# l# l4 J9 t
  2408.       case response.type
    3 f# |$ M1 r2 a2 ?7 O8 Y2 s) V
  2409.       when 05 Z& R7 R' j; F6 S& t9 {
  2410.         if mouse_in_area(ox, oy, width, height)
    4 X7 E; V! C1 T! e; k1 @
  2411.           $game_switches[switch_id] = true0 f8 I8 M& D" H" c# J* S8 s+ e+ u9 y
  2412.           $area_responses.delete(response)
    / ^7 Y( q1 M5 l
  2413.         end- D- G4 f' u% f! {
  2414.       when 1
      ?! Y; T! C( d: {
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)% g, E" C9 _0 d% j
  2416.           $game_switches[switch_id] = true
    : p  W" p( e% T* U8 F$ z  A
  2417.           $area_responses.delete(response)+ M( D8 }: @! v! ^5 v' e
  2418.         end
    # I5 t) M. i8 R  u& l0 M
  2419.       when 20 j$ D7 v8 ^# ~. d
  2420.         if mouse_in_area(ox, oy, width, height)
    $ F/ ]* n9 \6 r7 ~) O, f/ i
  2421.           $game_switches[switch_id] = true! O4 {) W+ \2 t1 P$ l: E+ k! y0 n
  2422.         else
    8 q4 {, _' O  G" X7 K3 H7 k
  2423.           $game_switches[switch_id] = false1 E$ R. R. w  Q3 [9 ~9 U
  2424.         end1 a$ g$ Z6 O9 B' |8 J& R' H
  2425.       when 3
    . y, |5 K/ C, D, |8 J+ b& e
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,0 X4 S: v8 c, C: j2 u
  2427.             (oy - $game_map.display_y)  32, width, height)% w4 A4 |# g! |# o- m7 Q
  2428.           $game_map.events_xy(ox, oy).each {event
    $ T/ P' b7 |5 I9 i. W. x6 _0 [
  2429.           event.start9 }; q& J/ ]4 X8 M
  2430.           $area_responses.delete(response)1 P+ M- _6 k  B9 S$ m0 k& ~
  2431.           return
    ! h$ f) }: A3 E8 f9 G5 n
  2432.           }
    . X! u& q( L5 [/ L6 c3 \
  2433.         end& s, w8 z3 @( y4 S
  2434.       when 4' y* q1 X3 h7 x7 K; U$ I' e
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,/ L  o" B+ p" h7 \! p$ u0 I8 k
  2436.             (oy - $game_map.display_y)  32, width, height)
    ) A1 F& {1 u5 D+ N0 G
  2437.           $game_map.events_xy(ox, oy).each {event
    3 I& E5 f3 Y8 r
  2438.             event.start
    * f- u3 V8 A- V. ?. q5 {
  2439.             return' s5 W6 }5 N3 H7 v/ D1 |* N* D; L
  2440.           }
    6 ]+ a" G, v1 i* ^7 i0 A
  2441.         end
    * `; o# i) d2 k' |( d
  2442.       end
    / r1 [  x- l6 A. _# c
  2443.     }
    ; ]- z* S( N! v' b- ^5 c
  2444.   end
    4 R4 y( j" x4 F' Z  n8 i4 x
  2445.   def mouse_in_area(ox, oy, width, height)
    9 O" W7 @, n7 W; p% c! c  d$ a
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    , e" ^% h9 _. |3 X' r: u% J  ~* t
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height4 y5 y6 [8 z3 W# o0 l' M: O$ m' a$ ~
  2448.   end* V) {; V+ L4 f! {( ?6 p4 |* z
  2449. end1 T4 n* Q3 Y( j5 G8 n6 R4 B* T; T- L
  2450. class Game_Interpreter8 Q. r" n1 k6 z7 L# ^, k# P: ~) ]
  2451.   def area_response(arg)
      s$ G* |0 d+ X& t$ c
  2452.     $area_responses.push(Area_Response.new(arg))
    - @  K: P5 n* H1 r* r) s9 e
  2453.   end
    5 H2 N( {  F4 x+ ^1 ?; k  X: C
  2454. end  y8 d0 \5 o! H9 F: o2 R0 m% `  y- r
复制代码

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

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

GMT+8, 2025-7-20 11:04

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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