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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    6 c  Y" O' Q) ^) y2 X# J+ W9 r2 @+ r

  2. 7 P1 J& z8 C( ]- |2 z
  3.   Sion Mouse System v1.3e! x0 {. k7 @2 Q: ?$ F
  4.   
    ! f- I8 E2 X* D* z# V
  5.   Changlog  w7 u, _# H% n: `( v1 h
  6.   
    9 @0 E  s# j: W3 ^  B
  7.   2013.4.21 v1.3f  |" S. e) i) Z2 @1 L: V* t* h& j
  8.    
    % f+ U7 K1 }7 @- m3 U$ I( K
  9.     1.3f 卷动地图 bug 修正% o' N$ W3 F1 `) l/ h9 y! A
  10.     8 l. w0 _9 T+ [0 A
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口' X+ a5 B0 ]$ O: o$ K! U( |0 O
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    4 A$ _6 u" C- K6 D
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    * i* A+ o9 H  b! V5 A2 W
  14. ; U( O6 U2 o0 v" T1 e
  15.     1.3f bug修正5 g! P5 f% h0 K9 v
  16.   # |* `' S$ f0 }/ l# q7 R% w
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    ) z# ?5 A7 ]  \, i
  18.           关闭菜单时,鼠标是否移动到原来的位置。3 Y" g. o7 j1 U$ _* a( d9 p9 B9 l

  19. ; ~! Q! O+ [. |1 B
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处( U) F$ ~( _( Y8 B7 W

  21. ( B* K, \& Q; Z
  22.     1.3b 修正一些罕见的bug;" U: |, c0 s# \( Z
  23. ( \( [# \3 o; n9 d$ ]+ N: g/ X% J6 F
  24.     1.3a 代码小修改;" @2 h: h" e' G: s: |8 {# m
  25.           加入了鼠标点击启动事件的功能,7 B3 m, p) `) l2 C! H! i6 i( m
  26.           在事件中加入“注释”: 鼠标启动  ,
    0 @1 \  K6 `) z9 [- W
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。: J/ X; c4 E9 X0 r$ @* Y
  28.   
    - @+ j) ^4 F7 X: U
  29.   2013.2.12 v1.20 [' r3 H& x0 T% ^, m
  30. ( w: W9 x" b2 n3 _; D
  31.     寻路逻辑优化;
    ' i( q6 J# N) C4 \
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    + I& ~* \+ b$ `% t( {
  33.     现在支持用鼠标来操作载具了。
      N" I8 {7 D/ d9 X2 T4 ]1 v6 z

  34. ( l* ^3 i; u0 n' w& y
  35.   2013.2.8 v1.1
    . h8 ]( y( m4 C6 g2 l7 ~- k% l

  36. 5 I* w! d0 \/ Y& z  A
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    7 q6 P, T$ s6 _& |  M
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;% I- h$ Z3 W8 X7 I2 m- }6 f
  39.     移动时,路径指示点的绘制更加稳定;9 T  d; T9 T4 k, T) B$ @1 j& W
  40.     现在支持默认存档画面的鼠标操作了。. j+ l" v  W" L6 K  \$ x
  41. 8 Y# C# ]: }" Z/ n6 ]

  42. 8 V$ l( ]/ u6 p+ `5 R/ I$ L9 O
  43.   OrigenVersion  }/ U& b& M. t* _) k7 L
  44.   
    2 v* ~6 w; N! q- B2 E& C8 e
  45.     2013.2.7 v1.0 * S% m4 ]- {9 N
  46. ! P0 o- z" ^6 S! U8 [5 S) C
  47.   主要功能. N6 V" m$ ~9 V7 ~2 m

  48. ' r6 o' B& j$ c' @& m! B) R
  49.       使用鼠标进行各种操作...
    - A6 y' N0 ]. i. m
  50.       将鼠标锁定在游戏窗口内( T" `- a  U5 D/ }
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    # A0 K7 c7 ?. Z1 `7 l0 e
  52.       双击鼠标进行冲刺
    + h5 a" `/ e9 o) R+ i
  53.       更改地图卷动方式以适应鼠标移动
      h' K+ L. Z! j
  54.       变量输入框改良' Z& y' J1 G( ?& c$ ^7 z
  55. + F" U( Y3 p% S1 j& `! S
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹. @" b, ^( n$ d/ u" \6 O+ ]
  57. + y# Y  T9 t( {% \# I5 i% r  ^4 G
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹& r. S0 D9 f" L/ E$ b2 a

  59. 6 n. N4 W4 o3 C. T% G! l. ~
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭% g8 d( M# T( \( y
  61. - O- S0 _  c- `2 Z5 [
  62. & K$ }5 A, m( E/ U" N5 \% ?. U
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★( F' [' s0 o3 C1 K
  64. 0 }/ @2 C6 J0 D

  65. 5 [' k6 e1 p5 L5 N/ B- l8 X
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    ! j+ x2 d6 `% c$ t: Z2 l; h% v" s
  67. 4 b6 \( E7 I8 b6 g6 u7 C& d: T( s# b
  68. #==============================================================================8 g3 ~) |, B" D1 t0 h1 J. x
  69. # ■ 常数设置
    ; S8 |$ K: q+ n/ p& N# I
  70. #==============================================================================/ W+ r& X0 D' _0 |$ J* a
  71. module KsOfSion5 \6 p. ~9 i  S; F( o
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false) o. P/ `9 g; P& v. U4 d
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    7 M8 a9 p& a  A" z6 E' D% U
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    , `, n0 y$ b8 i) P- [/ S6 I# K
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    ( m3 w3 B! n! W+ E( e7 g3 c& N
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    - G7 F$ j9 C1 h& L
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    9 h9 K9 T5 i- ~+ m* D( |
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    % X# i4 F& `" t9 C. j
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键, j7 V$ Y$ t( Z# \$ x
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)( A5 ]; F  j3 L( c9 [5 W1 S, {9 J9 _
  81. end* S" G! F7 D, @& d

  82. " O1 L* h' V4 L9 \# _0 h3 ?
  83. #==============================================================================
    , ?; ^. G; b3 M6 o4 M3 d6 N& a  w/ [
  84. # ■ 用来显示路径点的类
    ; t5 m+ m2 p/ e- t- |
  85. #==============================================================================
    " E( T) k- Z- h2 A: ?# D- R
  86. class Move_Sign  Game_Character
    7 b: |" o, g: Z) Y  t) k; j  w
  87.   #--------------------------------------------------------------------------
    5 B- p6 @4 A9 I
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图9 I6 i0 e3 H) [( ?8 F: }8 v% H
  89.   #--------------------------------------------------------------------------0 Y, m; d0 B3 K" f; ]; p5 z) K/ M
  90.   def init_public_members& F3 u1 v8 {4 F3 T' O$ ~
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹" a" r* |7 M1 P$ \% z0 R" J8 M2 W
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    0 x/ w( i. G8 f- l4 Q$ W* x) N
  93.     @move_speed      = 5        # ★ 踏步速度
    % K+ F( Y, L5 T$ j, |
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    . j; P  w- q- L/ K# d4 Y( k
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    8 ]+ a: J2 l8 F3 }
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)' Q* {' z; \' l" m. Z3 o+ l
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列/ m1 k4 _" R# n6 \
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    - u" V9 A! @, z# f6 d8 P4 P

  99. / C% q5 _: V! U8 P; V. t- f. P( O
  100. 3 c& T6 a9 ?: K/ L7 |6 ?2 i+ V
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    # X( {# E1 j; d& Z7 `% l1 E
  102.   Y9 Q& i' q2 a+ ^) s

  103. ! t4 L, }9 j, L- m+ F( o4 e
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图8 X* ~4 z- K! s$ B! P
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png'). N/ u8 \: Q  [
  106. " Q- b  B) a% S, r& ]3 V; Z' ^
  107.       if $no_arrowpic_warn) K# j/ {3 \/ g4 o% n
  108.         MouseShow_Cursor.call(1)
    ; V! K7 S' p: N2 u) k$ g6 Z
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png+ A( r5 N2 H' R9 A3 t  o

  110. ' l0 @; o7 J% r
  111. “路径指示点”将使用游戏自带图片
    - L& B$ C6 A& c& [5 [' }* ~0 c

  112. / \; i2 f  i; i6 \1 X, h9 O! q
  113. 该提示可以在脚本内关闭')1 R& }' c  s+ ], ]& ~3 k
  114.         MouseShow_Cursor.call(0)7 }0 K$ Y* I' |" s7 |: n& t0 H
  115.         $no_arrowpic_warn = false
    $ o1 X% v" P2 j+ A/ z- D
  116.       end
    + \1 v5 \# ]8 T0 r7 F( w: g
  117.       @character_name  = '!Flame'
    0 i  l: x; N4 [8 U" b& g
  118.       @character_index = 6: N5 Z- j; k' t. l" M" h: U# T% @8 n1 g

  119. . s/ n# c. U2 [" h: @2 G
  120.     end
    * z: o5 ]! ?1 @7 [
  121.     @direction_fix = false  # 固定朝向
    5 {3 Z; a( u' K- T& f. W' w
  122.     @move_frequency = 6     # 移动频率" m$ D2 V0 C; R) A$ e- L
  123.     @walk_anime = true      # 步行动画& Y8 N+ E3 n" x( I7 [9 y1 M: b
  124.     @pattern = 1            # 图案/ X# K& H5 k2 u/ X! \
  125.     @through = true         # 穿透  x4 Z. G0 G4 q( w$ h) g0 R. c
  126.     @bush_depth = 0         # 草木深度( N' R& N5 e0 I0 s! l) l) f, c
  127.     @animation_id = 0       # 动画 ID3 T# ~6 h# n4 X6 c
  128.     @balloon_id = 0         # 心情 ID
    " c3 F% I) J7 }; a" A
  129.     @transparent = true     # 透明; o! j& |. t" V' A# C+ p
  130.     @id = 0
    - b% b2 Z9 m- c
  131.     @x = 0
      [/ S, {9 U, K8 L9 |4 c
  132.     @y = 0
    + ^9 {3 @  N5 k. X  H5 |' `; V8 J
  133.     @real_x = 0
    ' x4 p* g3 `7 O  L
  134.     @real_y = 0
    - @5 {% B5 G8 h* b# y
  135.     @tile_id = 0
    9 J$ [2 Y# j1 r/ T# Z% z. N
  136.   end5 A& F" r$ e9 [  v$ I; [$ E
  137.   #--------------------------------------------------------------------------9 {! k& x  V  b3 M
  138.   # ● 定义实例变量7 D4 k( H) H, m5 C
  139.   #--------------------------------------------------------------------------7 U( N. F5 i6 |9 n' x' E
  140.   attr_accessor direction; @1 c$ r8 Y$ V6 C2 d/ b7 d
  141. end9 x/ j0 F2 A- I7 C  w# ]0 ]

  142. " p: U$ K1 d/ Y2 O; @( X
  143. #==============================================================================5 ~  V! ~% H' g; H, C, ]
  144. # ■ Module Mouse' b6 w5 u' |: v) J% `( q' H" A1 ]; n
  145. #==============================================================================6 ]. A# F6 I# _7 P: d% A/ G
  146. module Mouse( f8 ^9 g* w# y9 s3 H9 k
  147.   #--------------------------------------------------------------------------; j$ Q9 b( g% p% A7 b: q
  148.   # ● API
    ( d" u# A2 s2 e, w  ^3 q
  149.   #--------------------------------------------------------------------------0 c$ [8 p4 G: t! c* g$ T, Q9 m3 B  F
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')6 t; u  X# R$ O% ^3 a, J& [
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')$ h( a$ G9 C- t* ?6 O  ?5 Q4 j" s
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')2 C  Z9 @: h# `7 O8 t
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')' R( o+ n5 W. x
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    ! [! I" L0 i0 a) L' L( R4 z
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    6 z- v4 D5 N3 E  z5 O! p9 q1 k" `0 Q( b
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    & L! `8 `- F3 p9 ?- G. F
  157.   Window_Hwnd       = Get_Active_Window.call
    9 G  K) n) a& S' r

  158. 3 Z* y# e0 B7 v" f3 P% ], P
  159. class  self
    / \. y0 T8 O( |
  160.   #--------------------------------------------------------------------------
    5 G# U2 u$ W* c
  161.   # ● 初始化( O9 P( @6 b0 N- \. {7 I1 q+ n. w% R
  162.   #--------------------------------------------------------------------------8 P+ t0 \7 k. B0 k/ n! [1 `: Z; u
  163.   def init
    - A5 n1 ~; a6 S& L( F3 B
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    1 G+ g9 \: _  S* i
  165.     @left_state = 0: `; z" B% G$ @
  166.     @right_state = 0( B& J5 o& m5 o; o4 e0 S5 y
  167.     @ck_count = 0 # 帧数计,单击以后从0开始! Z( L8 F* w( [
  168.     @dk_count = 0 # 用于双击的判定
    * D" h+ F1 e4 q; [: G
  169.     @clicked = false
    % m. |( b& D7 R) c5 j. ^. p, J- c
  170.     creat_mouse_sprite
    & i$ J4 J! o% ?& w
  171.     update
    % C* w3 o: Y9 g8 j8 O
  172.   end! p5 j; ?' s+ ^" F
  173.   #--------------------------------------------------------------------------
    * j: U) g! |: \5 }' e& `% y
  174.   # ● 鼠标指针精灵
    * A7 o; v- u; X5 }& N, i! ^0 b. R7 `
  175.   #--------------------------------------------------------------------------: w6 F; L  {+ ^& x
  176. #~   def creat_mouse_sprite
    . d9 j9 B4 x4 d# A4 c9 m
  177. #~     2 ^; q! q! {& ~
  178. #~       @mouse_sprite = Sprite.new, e. _$ `( t, o; X' m% B* B
  179. #~       panda = 2#rand(2)+1
    / P; a* C* J7 f3 k8 e& Z  `

  180. 0 ^9 L7 a5 g9 P  p6 b5 W: G6 g6 [
  181. #~      if panda = 10 ~  \! f$ g' ~* b: f! I3 H6 K
  182. #~        if File.exist('GraphicsSystemCursor2.png')4 m1 H% \  U& v9 H5 C
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')9 T: N+ F% ^1 _* J
  184. #~        end#with if File.exist
    0 `" P3 s' \/ X) B
  185. #~    " p- ]8 [8 p3 v' @1 S' p4 O
  186. #~     else if panda = 2 #with if panda=1
    % y* k3 _9 B4 N% ~& g) p
  187. #~      % P, C- o, f3 k7 Q) m& e
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    7 c& O+ B. ~8 P% [( M+ O
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    * @4 a0 X# R0 s1 l$ q% b' B
  190. #~      end#with if File.exist
    0 X4 j0 l- N* d% t
  191. #~      
    ) l5 b  e' G1 w
  192. #~     else #with if panda=1
    2 t; r/ A" d$ I) g0 B
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    $ T& }$ n5 Q8 I
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),0 J) U: x7 \) @
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    6 i9 I5 V" @: g2 I: q7 t
  196. #~     end#with if panda=1% P! a. C! A. e
  197. #~     3 d# N' e0 o, V
  198. #~     #with def
    ; E, \" D! _% w6 L+ S3 L5 M8 J5 F
  199. #~   end* Y0 _5 h7 {0 E  M
  200. def creat_mouse_sprite
    4 r: o" m+ r' V' |: f# G
  201.     @mouse_sprite = Sprite.new
    # {% p% H/ c; M" M& C8 H4 o" @0 a
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    3 I1 B% ^5 l" G
  203.     @mouse_sprite.z = 9999
    8 f! {7 D0 B5 G6 U, L  M* ]5 J
  204.     Show_Cursor.call(0)
    9 s& q# E3 Y5 I% f: x
  205. end
    , i7 [$ D3 |6 [

  206. ' ], A2 y- V/ \/ l5 N
  207.   #--------------------------------------------------------------------------4 V! }0 S# ]2 D# r4 B
  208.   # ● 更新4 f$ O3 m* p  o& P
  209.   #--------------------------------------------------------------------------
    5 x6 M0 D2 a* f
  210.   def update; F1 g" t, Q  u1 P& \
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos1 j% A4 T, d6 `& y. X! b
  212.     left_state  = Get_Key_State.call(0x01)
    % t7 _2 |  b, k5 i
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    . p# i7 Y' K' z0 I: _% v
  214.     right_state = Get_Key_State.call(0x02)% [2 Q, f3 z' Q# h
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    5 K# p2 D; e- U: n$ p
  216.     update_double_click
    3 k' a3 T+ i$ S! p9 F' b5 c
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    % [5 B, @1 O0 x$ ]
  218.   end
    * H6 o9 A2 D) E0 R* G
  219.   #--------------------------------------------------------------------------
    1 Q# w- O+ O, O7 L* l, f1 Q
  220.   # ● 获取鼠标坐标1 j9 B. _9 F, o+ b5 o7 @
  221.   #--------------------------------------------------------------------------; j% U6 w8 O) s9 ]
  222.   def get_mouse_pos# \; f5 G0 G) ~  n  b* p( @' U
  223.     arg = [0, 0].pack('ll'): ^( z' @* [( ?" N+ h5 ?
  224.     Get_Cursor_Pos.call(arg)
    2 t" E4 e5 S; a1 n
  225.     Screen_To_Client.call(Window_Hwnd, arg)7 R% Q% H: n' |- F
  226.     x, y = arg.unpack('ll')
    , W9 M: d' H; Q& L) P* j8 |
  227.     return x, y0 n$ ^) j2 o$ s6 J" h0 v/ _
  228.   end
    6 {- W* c8 X5 G& B$ O# K
  229.   #--------------------------------------------------------------------------/ C" G/ o7 \$ b3 [% h% r+ M2 v2 M
  230.   # ● 将鼠标固定在屏幕内
    1 p/ l4 F& F! Q) E  E* Q: f
  231.   #--------------------------------------------------------------------------) D  h0 [$ ~$ Z& G2 [/ y  j
  232.   def lock_mouse_in_screen% U" Z8 Z6 I! p( b$ q; A# m! L
  233.     arg = [0, 0].pack('ll')
    , Q' k8 j4 {7 M1 w% x6 F
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    2 B, v+ {; I6 J3 [# q
  235.     x, y  = arg.unpack('ll')' H% N: K/ ^0 }3 r, t9 ~
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    * S  d. d" h( J' F' f
  237.   end
      W% _) L, H- K9 m, |" `
  238.   #--------------------------------------------------------------------------+ p% Q. V7 G7 g; h: q0 ]8 A( y: m; u
  239.   # ● 解除鼠标固定
    3 X, b# O. ^9 u2 H8 h: R4 o
  240.   #--------------------------------------------------------------------------
    & q, U) p5 g$ V. K& ]. Q
  241.   def unlock_mouse_in_screen; |7 L- I% b1 D/ y
  242.     Clip_Cursor.call(0)
    5 Y3 U; p/ Q% t! S0 X; M+ \& ]
  243.   end+ g7 Y. @( t/ W+ W
  244.   #--------------------------------------------------------------------------
    5 y( _9 F8 D# S. Y, f9 o# Q) u
  245.   # ● 鼠标双击判定8 W7 \7 j8 P$ [7 F7 e
  246.   #--------------------------------------------------------------------------
    2 X- X5 n+ h$ y, n1 r, o, t
  247.   def update_double_click
    4 i% H5 c* R2 T2 R
  248.     @clicked = true if @left_state == 1* n, y1 S9 F9 H+ G  r' M
  249.     if @dk_count  0 && @left_state == 1% L- C1 |& U6 m& L7 a
  250.       @dk_count = 0; @clicked = false
    $ D- ?3 a9 d  |7 C" R* N
  251.       return @double_click = true4 N9 m# M8 l2 H+ s$ }# R& n; H
  252.     elsif @clicked
    9 N! i# y: k# k( p* P; y! p
  253.       if @dk_count  KsOfSionDbclick_Frame
    * M, |) A* g3 h& I8 A. `/ M- }
  254.         @dk_count += 1
    4 N4 |9 F& a# B- ^4 F
  255.       else
    ; p& F/ H# R+ w) ]% F: x
  256.         @dk_count = 0; @clicked = false
    + W' N  S2 u" i$ H8 k
  257.       end
    / T* e; C) j0 Q% x2 |& s
  258.     end8 t! x+ {& s/ _, N+ Q" [
  259.     @double_click = false
    4 E3 ~& w% |4 ?& a! p
  260.   end
    3 L, ^/ P* I2 [6 N7 J  |
  261.   #--------------------------------------------------------------------------7 O" D( t! h) Z7 V/ Z
  262.   # ● 按键被按下就返回true
    8 Z# s! F% O& I" l
  263.   #--------------------------------------------------------------------------+ \6 f% C3 w1 V$ o/ V
  264.   def press(button)
    : C: u) j4 [; x8 E! A$ ^
  265.     case button  v, _+ e, U. p  R* X) X) j' C
  266.       when 0x01; return !@left_state.zero
    4 t. b, t5 G4 E- V
  267.       when 0x02; return !@right_state.zero
    % x$ N6 S4 \1 i! m  G
  268.     end
    1 C  z( I) ]" C: V4 X+ V1 C0 m
  269.     return false
    # o: J; \9 C5 F
  270.   end
    / l- s9 H; N, m( n0 E: w
  271.   #--------------------------------------------------------------------------
    # P6 X' B8 j5 I
  272.   # ● 按键刚被按下则返回true
    ( B0 H; v: ~% r2 V0 h- A
  273.   #--------------------------------------------------------------------------
    % }1 A; |4 w/ l3 I( i+ P
  274.   def trigger(button)
    ' r4 \0 r# L2 h- D8 K
  275.     case button
    * E2 o$ _, M( U  p1 [5 n9 f9 k
  276.       when 0x01; return @left_state == 1
    $ g$ O1 w2 ~$ o; S: C
  277.       when 0x02; return @right_state == 15 ^3 q5 d- \% P0 r9 L
  278.     end) _3 {% i( I$ Y+ {% X: J
  279.     return false+ H( l- y; ^# _+ L
  280.   end% ~2 i9 E3 q4 ^8 q5 w
  281.   #--------------------------------------------------------------------------* M% @. i3 t( d* h- N9 x
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    8 @9 ?* u. v( ?1 e: p; O4 Y; x7 s! l
  283.   #--------------------------------------------------------------------------( @" b9 r3 O. a4 A7 W
  284.   def repeat(button)
      B" a' \+ l4 F; S! D
  285.     case button
    6 g' M/ T0 y. E4 l# A5 y! j# ]; G3 q
  286.       when 0x01; return @left_state == 1 , b, Q3 M$ T) U8 @! e) }
  287.         (@left_state  22 && (@left_state % 6).zero)
    3 V4 w# s* Z7 r: B. a$ p/ j8 o0 `
  288.       when 0x02; return @right_state == 1 ! X2 R; T& k% I5 C* F1 t2 M
  289.         (@right_state  22 && (@right_state % 6).zero)
    ( b  k2 b# {* y
  290.     end
    4 j/ d# s! w: X- L* E
  291.     return false
    , h" E* z: i2 O. b% b# a1 L4 O5 z6 }
  292.   end7 F" C' S( ~4 ~
  293.   #--------------------------------------------------------------------------
    ; |1 q9 R: J# R+ P% `. i
  294.   # ● 判断是否双击鼠标
    / n2 |0 {% K- \! M$ p
  295.   #--------------------------------------------------------------------------
    , a% y% Q9 s0 m9 R4 r  F+ t
  296.   def double_click
    - i9 T. c8 ~! D8 c2 @, r  k
  297.     @double_click
    $ Q4 ?6 }7 h- W4 k
  298.   end
    4 s$ T$ p$ ~0 h
  299.   #--------------------------------------------------------------------------3 i! {9 }' Z$ e' h  l$ p
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    $ p0 q0 c) z+ Q. t# ~6 @
  301.   #--------------------------------------------------------------------------4 A9 L0 ]- r* Y0 {, H( F7 J
  302.   def click_count, M* |6 q* H; S# s; |- h. h# u( `# m
  303.     @ck_count' V$ h/ R" c/ ^, _
  304.   end' M, I3 n! ~  l' Q7 V
  305.   #--------------------------------------------------------------------------
    ' d$ K7 J% s& V; N: ]
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    9 w8 ?7 p# V* `: ~) k; o
  307.   #--------------------------------------------------------------------------
    ' ~4 W. M- \  ?) ~2 ^
  308.   def left_state0 x  I' Z( c/ h9 B
  309.     @left_state
    / V) g" k! e8 q  l# ]
  310.   end
    2 {8 o" _9 a/ m, D, d" L
  311.   #--------------------------------------------------------------------------8 Y2 w: G7 b' L# @7 k
  312.   # ● 获取鼠标的x坐标
    ; D! ^$ _. A! r, e2 T
  313.   #--------------------------------------------------------------------------8 e, D  A' x9 {/ g
  314.   def mouse_x
    8 r4 r5 ], M) V$ Z# c
  315.     @mouse_sprite.x
    1 v8 K6 z' ?/ {; J
  316.   end
    1 f6 O- y: b+ h
  317.   #--------------------------------------------------------------------------6 P! Q8 Y) j$ r9 f& y
  318.   # ● 获取鼠标的y坐标. J- W$ }& j4 m
  319.   #--------------------------------------------------------------------------& g, A' J2 l6 U/ r0 `
  320.   def mouse_y9 Q3 s: i; ^$ Z8 _; y3 Z
  321.     @mouse_sprite.y( A0 ]1 @2 r% s, W: Y
  322.   end
    $ v3 W3 u4 q- h4 z6 z1 ~% b
  323.   #--------------------------------------------------------------------------# h. w' C" {' H- V5 {
  324.   # ● 设置鼠标坐标
    ; o8 f+ C. `' P
  325.   #--------------------------------------------------------------------------
    , I( e# X( j  h3 z; _+ Y
  326.   def set_mouse_pos(new_x, new_y)4 [# e  B% k! ^# ?) S& Z
  327.     arg = [0, 0].pack('ll')
    7 K. A0 |+ h: h7 h  D$ @
  328.     Screen_To_Client.call(Window_Hwnd, arg)+ i5 e6 a6 Q) ^$ N# I8 s: I/ |, m
  329.     x, y  = arg.unpack('ll')& w' c* j$ r8 e) w
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y); @, R' p2 H5 d- o
  331.   end
    . H. e& D" _! B3 ^
  332. end #end of class  self
      L9 @5 `) G5 j) R- J! |

  333. . }! p5 k, R/ M- X- h6 ^
  334. end- S4 V6 M+ S4 o5 L, n
  335. # F. p$ C. y5 e% D' O4 _
  336. #==============================================================================
    * _! [$ L  i7 F7 \: I
  337. # ■ SceneManager% l8 D2 ?" F+ @0 Y( x6 q" ?8 E
  338. #==============================================================================9 Z! v" `2 K$ W" P
  339. class  SceneManager% U- T1 I" z, y+ o
  340.   #--------------------------------------------------------------------------1 j$ _1 [& H& L9 D- U
  341.   # ● alias
    . Y$ g; I' ~( W, Q1 P; G( k8 v- }
  342.   #--------------------------------------------------------------------------
    , h" I* S8 P9 l5 I0 Z
  343.   unless self.method_defined(sion_mouse_run)( W6 l4 P5 k  }) q
  344.     alias_method sion_mouse_run, run3 H* Y! r6 d; }9 {
  345.     alias_method sion_mouse_call, call
    2 [/ R( W* d6 J! ]; T5 t& a0 Y
  346.     alias_method sion_mouse_return, return
    4 f) k" f& V) ~) j  K8 ^' {
  347.   end
    % c9 {( z& y) U! R& f( G
  348.   #--------------------------------------------------------------------------
    9 U2 a0 @; I$ G6 h9 o
  349.   # ● 运行
    . y& g; G" J( w2 J, i8 a0 T  Z5 `% [
  350.   #--------------------------------------------------------------------------
    ! b. v& w, z& t3 S3 u# u* _% |3 q
  351.   def run$ }( X! G% K% m$ D! ], [- |6 R6 s
  352.     Mouse.init; D' B4 w3 V6 ^7 w. M) E
  353.     sion_mouse_run
    ( i. Y  F* g: M5 f2 S
  354.   end
    2 I% L3 o4 m: }& f" v( E
  355.   #--------------------------------------------------------------------------& C- R/ k" C% }6 W' ~4 m9 E; t( s* \
  356.   # ● 切换+ D8 _7 p3 b0 ]3 q4 D. u$ Q8 Q$ m8 r; {
  357.   #--------------------------------------------------------------------------
    " W5 [! o7 U0 ^/ k
  358.   def call(scene_class)- k: m, O; o+ t' U
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)$ e6 q0 |) x( c% ]; y
  360.     sion_mouse_call(scene_class)
    $ [8 Q0 x! @6 w; |1 r( x
  361.   end
    2 S/ S2 S4 }- w" L0 b
  362.   #--------------------------------------------------------------------------
    4 V- z+ T& q6 U+ u3 _6 t8 o
  363.   # ● 返回到上一个场景
    : W, A' [# v  ?1 W& p. A+ A% M
  364.   #--------------------------------------------------------------------------/ [  v$ w* h. t7 w, F; ^( y
  365.   def return
    5 R& S+ D" e( h' g/ g
  366.     sion_mouse_return
    % A% c8 K3 w4 E: t
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&1 Z. m: W" d# y2 e3 C
  368.       @scene.instance_of(Scene_Map)
    - o; z1 h& _! R
  369.   end1 v8 s& H5 O. ?
  370. end
    5 ]7 B8 N8 A2 ?* z4 q+ S  _. `8 Z

  371. 3 J+ x( n# c. B; o$ e( p
  372. #==============================================================================
    . J$ x5 E# N" Q% R' Q
  373. # ■ Module Input3 w5 S& Z$ S% I* J) G& s% T5 @/ ?( t
  374. #==============================================================================( G; N5 U0 c8 h, y
  375. class  Input
    4 r4 K8 h) A8 d( L$ r0 i4 J+ }
  376.   #--------------------------------------------------------------------------
    ' K3 A$ K  m+ `/ C1 o; g6 p
  377.   # ● alias+ @: S& {, k) V9 h1 i/ i; {% z
  378.   #--------------------------------------------------------------------------
    ; S' {" g6 K8 |" ?9 X! T7 }
  379.   unless self.method_defined(sion_mouse_update)
    2 L4 L: X  V9 o4 Z6 ^# U3 n
  380.     alias_method sion_mouse_update,   update
    * v1 m! ]5 }, T; m( `- Z! A, ?
  381.     alias_method sion_mouse_press,   press; B( M* B8 o. C0 ]& T
  382.     alias_method sion_mouse_trigger, trigger# @: B& e2 ~3 N8 ?2 ?8 p5 p6 |0 U- x$ E# m
  383.     alias_method sion_mouse_repeat,  repeat  C, ?+ _" `9 z, J/ ^# W; k
  384.   end5 P1 T+ K$ M6 q* o/ s8 T
  385.   #--------------------------------------------------------------------------
    2 {; ^9 Z  |- F
  386.   # ● 更新鼠标
    ! J' l7 u; Q& g* V1 M) w2 ?9 o
  387.   #--------------------------------------------------------------------------
    & [: A" T$ R6 D+ J) k% i6 g
  388.   def update
      y1 z# U% u  h: A7 A
  389.     Mouse.update
    7 H7 Y' D/ m4 n  A. \& v
  390.     sion_mouse_update/ i" d* |: ^  }; o
  391.   end
    + M8 z7 i7 `7 a
  392.   #--------------------------------------------------------------------------$ `9 t" I# v' ?- G( B9 F
  393.   # ● 按键被按下就返回true
    % |- [' Q3 E4 T) H* R, z) m# W% S
  394.   #--------------------------------------------------------------------------! W1 H- m% M4 r
  395.   def press(key)
    5 Q! G" ]  K1 z. `0 v8 g
  396.     return true if sion_mouse_press(key)
    * V2 F* f0 W' L
  397.     return Mouse.press(0x01) if key == C
    3 H4 O/ |9 F) [2 D1 w7 A6 X
  398.     return Mouse.press(0x02) if key == B
    8 q8 l. D7 K5 w( o* Z1 h  M* ^' `2 c
  399.     return false5 O; r0 S3 q! U5 z4 w0 i2 u
  400.   end
    , @1 L1 ?- p" n5 ?- k. @
  401.   #--------------------------------------------------------------------------
    ; J7 q+ W5 ?5 k
  402.   # ● 按键刚被按下则返回true* ^- h: z" a; Q- `; M# ]* S) \* \
  403.   #--------------------------------------------------------------------------, \. H- w! R$ X& Z
  404.   def trigger(key)
    % }3 _, ]2 G4 d
  405.     return true if sion_mouse_trigger(key)$ s' \0 D: \% `6 N% f1 b: Z
  406.     return Mouse.trigger(0x01) if key == C
    ) w" H  T" @! x' i0 J2 u
  407.     return Mouse.trigger(0x02) if key == B# ?6 Y& \' p( B' d+ A* |
  408.     return false
    : Y4 J* G; Q. e
  409.   end9 j( Q9 q" J, ?1 E3 m
  410.   #--------------------------------------------------------------------------! g1 C# i; s8 ~! ~1 b, ^$ u! `7 y: m) a
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    & h: w' @! s4 b
  412.   #--------------------------------------------------------------------------+ D' L+ a1 [* A1 d
  413.   def repeat(key)
    ' z4 g6 R' h- M/ q/ ^  e$ X
  414.     return true if sion_mouse_repeat(key)! L; i- N+ \- s4 E
  415.     return Mouse.repeat(0x01) if key == C
    $ ^  b0 }' o  e# A- W8 N
  416.     return Mouse.repeat(0x02) if key == B9 q9 \" F6 s% v. S: L+ r4 }
  417.     return false: O: j( m$ E" D, a' ?% X
  418.   end6 [7 |  T1 j3 I( o( c
  419. end
    * |9 X" g6 ^3 _$ r( _
  420. # c- o+ ^' S& l/ z, f# \

  421. 3 k4 J- u* |" b. F; D4 [0 _' @
  422. #==============================================================================
    + F3 O  O/ S) W% m* F
  423. # ■ Window_Selectable
    9 h9 v$ o3 o; {4 t' z  t/ r
  424. #------------------------------------------------------------------------------
    , k# o$ f. [) G/ f) I  d
  425. #  拥有光标移动、滚动功能的窗口
    : S( O) G" J+ {% j% O
  426. #==============================================================================
    + F1 A$ @* f) n2 N; U  V1 Q
  427. class Window_Selectable
    8 \2 A% [9 {' m, X, u
  428.   #--------------------------------------------------------------------------
    6 ?0 l5 \- k0 u) Y- V
  429.   # ● 初始化  ?6 @) o# \3 `; V% {' ?& i  K
  430.   #--------------------------------------------------------------------------4 L8 @$ A$ v9 e% z+ H3 T+ E
  431.   alias sion_mouse_initialize initialize4 y6 e, T4 a5 b  v
  432.   def initialize(x, y, width, height)
    , ]6 |9 {; L! H/ |9 g& w& M: A
  433.     sion_mouse_initialize(x, y, width, height)8 K1 S8 r# H% y; b
  434.     @move_state = 0
    3 U* @: u+ n4 m: y/ p4 B
  435.   end" e1 M0 F7 ?8 w4 D* y! C
  436.   #--------------------------------------------------------------------------, z6 b- V) l: W5 J/ ?: e  o8 O
  437.   # ● 更新
    7 U6 `4 g% t9 X5 S
  438.   #--------------------------------------------------------------------------
    ! `4 B9 d0 ?3 x
  439.   alias sion_mouse_update update/ \+ F" `) }. Y6 ~+ C+ _
  440.   def update5 }* `# R' S% R# ^2 s: r! ^7 U
  441.     sion_mouse_update! X( V, F6 p* Q1 z$ B8 v; r
  442.     update_mouse_cursor5 x9 z( r# S; T% O- {5 a7 a
  443.   end# p5 A5 b9 a$ s% t2 r2 p
  444.   #--------------------------------------------------------------------------
    4 d6 g! C. C: f/ I5 l: V
  445.   # ● 启动后设置鼠标到index位置5 m5 ~9 l5 J) K; ]4 a
  446.   #--------------------------------------------------------------------------4 ^2 v* M4 {) @, y$ @2 k! g8 |9 J0 w
  447.   def activate
    ' s* E, r7 N2 R& }# y) Q
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    - x' e* D; y" |8 ?% g
  449.     super0 o, Y/ w9 x) Y. V
  450.   end
    % a6 e, j! Q  J, j7 g
  451.   #--------------------------------------------------------------------------5 _0 H8 s- ~' \3 T0 k  i  c
  452.   # ● 更新鼠标和光标的位置
    , n, M1 S. l. e
  453.   #--------------------------------------------------------------------------( U4 X4 ?6 o$ W- g' ~/ g" K
  454.   def update_mouse_cursor
    2 p3 \# S% m  A& y% Z, u: Z
  455.     if active0 ]" l2 K3 O& U9 E4 P( g4 \
  456.       if @need_set_pos+ N- T& [8 x% Q  z8 q) k
  457.         @need_set_pos = nil0 `8 o+ l8 b' Y6 J$ d9 Y$ J
  458.         set_mouse_pos
    2 f% j" ~% G% l3 ?0 e
  459.       elsif cursor_movable6 c  Y6 v3 `) @5 U: t4 D
  460.         Input.dir4.zero  set_cursor  set_mouse_pos. V6 f% K, J! q# I/ F9 e% E- g
  461.       end
    7 N& p( L" i6 J3 Y  |) n9 S$ q
  462.     end
    ( Y' _( u% q5 o9 h3 g* O3 x! o+ G
  463.   end
    $ y9 w5 H/ V$ a) J) A9 L. {
  464.   #--------------------------------------------------------------------------, M4 A7 L) n  L- d- Q: ^: Z/ M
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    3 N# X- Q8 \3 [: H. w+ \
  466.   #--------------------------------------------------------------------------
    * `) r; @; Y4 o, X( M' Z; b
  467.   def set_cursor* Z  C4 ^2 P" p9 j5 c
  468.     mouse_row, mouse_col = mouse_window_area9 g9 w9 A7 g4 b
  469.     if    mouse_row == -10 L! k  i8 O! h) S
  470.       @move_state += 1 if need_scroll
    3 W9 c0 c5 v* z/ _/ L
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
      o1 @% g& @' Y3 v8 `- t
  472.     elsif mouse_row == -2* D0 c! J+ L5 R+ z, O& `6 L
  473.       @move_state += 1 if need_scroll
    " r5 o% h; C! u' r- C% @! d' R
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand$ G' i% g3 j# x2 P) k/ K) U
  475.     elsif mouse_col == -1% [4 A' n0 z  Q" r* s5 c
  476.       @move_state += 1 if need_scroll. }" P" F9 t8 R9 v2 y+ p
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand+ z4 H: F7 [) _" H# L
  478.     elsif mouse_col == -2
    8 m: q& _* A! h- b' A/ P6 d) f
  479.       @move_state += 1 if need_scroll: `- \, u% \& ^# }# Z5 C0 D; B+ }
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    ' g) s, ?7 v/ M' m' J; G
  481.     else
    8 k, |8 b8 h/ x0 O' N
  482.       @move_state = 09 z9 O% I" |2 N7 W+ ~0 W) d! e3 L
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    ' P: p- [. C- T( w# T6 {0 Y1 ]
  484.       select(new_index) if new_index  item_max && new_index != @index# Z1 c. `+ X( N6 n0 Z* z: {( U
  485.     end; G2 ]( E0 _0 V+ ~) |% R- p
  486.   end: r$ @( b# ]2 b# e! z) W1 X' U% \2 Y7 x
  487.   #--------------------------------------------------------------------------) r7 S( G% B6 j4 V: t$ t6 z
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    - f& r% A# z. {4 Q+ ]8 D" U5 L
  489.   #--------------------------------------------------------------------------' _) V- J, L) ?) N
  490.   def mouse_window_area( i& n# {% y: c1 ^
  491.     if viewport.nil # necessary!  O2 f! u  o: c0 ]! l
  492.       vp_x, vp_y = 0, 05 p0 e6 n( k+ P: Z$ i
  493.     else, m( ?1 M. Y; z- ?: m
  494.       vp_x = viewport.rect.x - viewport.ox2 k; h; ^+ \5 k2 T
  495.       vp_y = viewport.rect.y - viewport.oy
    : Y- `3 G4 Z4 |* z. ^; \
  496.     end
    ( |0 b- o9 x$ b. c6 e
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    3 p7 W. n! [7 t
  498.     item_x1 = vp_x + x + standard_padding
    + G4 w+ i6 I% ?9 \; k
  499.     item_y1 = vp_y + y + standard_padding
    4 c; r7 f9 r! |/ @
  500.     item_x2 = vp_x + x - standard_padding + width2 ?. y3 h5 D: O/ K; S2 x
  501.     item_y2 = vp_y + y - standard_padding + height
    1 o: V* {7 p6 Y5 ~; D. c. D
  502.     if mouse_x  item_x1
    + e2 Y+ \! F- s+ i7 ~
  503.       mouse_col = -18 I0 k  s; G4 y" g
  504.     elsif mouse_x  item_x2
    ' ^- M( ]1 q" j3 U% E
  505.       mouse_col = -28 t9 y9 E0 g$ Y; J& L( @
  506.     else
      V6 R+ ?* _: T& u( q
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)$ q, E8 C& u7 a; l: u
  508.     end1 `& o% S. n6 w! f
  509.     if mouse_y  item_y10 O3 @( t- T3 J9 J
  510.       mouse_row = -1- O( z; w8 |9 o# N4 d
  511.     elsif mouse_y  item_y2
    ! A0 \' _7 v9 Y; x
  512.       mouse_row = -2: F! e1 X7 `" Z& k/ G
  513.     else
    ' J; S9 }  F4 z( F
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)/ {# }5 M, d9 @* C2 f4 v7 C1 m
  515.     end
    8 }- w5 D" G  @( Z" R% C, d+ [+ P7 L
  516.     return mouse_row, mouse_col
    8 d+ V: ]) V9 t- f. }4 \1 P2 l! O
  517.   end
    + |0 B% [; a- h  r
  518.   #--------------------------------------------------------------------------+ A7 U% f% Y; n( A2 {% X1 X5 K
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置0 U* }0 Y: c4 [  r6 }/ x4 X
  520.   #--------------------------------------------------------------------------* R/ P. ?! L4 c2 G, F4 c9 D
  521.   def set_mouse_pos: e' N% l3 o, E& }
  522.     if viewport.nil # necessary!
    ( a  L$ W5 e' z
  523.       vp_x, vp_y = 0, 0  o7 w, p( n! F# Z% F
  524.     else- k) }/ b1 M1 P: c
  525.       vp_x = viewport.rect.x - viewport.ox
    # @# m- p! o& S
  526.       vp_y = viewport.rect.y - viewport.oy
    : |* D, M9 f6 Y/ b( a
  527.     end+ v* k9 `* A  k8 U2 p* w+ X
  528.     item_x1 = vp_x + x + standard_padding / Q+ f# t; x1 L0 e  r! G4 E, }+ e
  529.     item_y1 = vp_y + y + standard_padding, p' G7 u, k) b- X
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index   H/ X9 O: I0 [6 K5 C5 l$ \: s; _
  531.     row = get_index  col_max - top_row
    6 e& p. X# i2 s' P
  532.     col = get_index % col_max* I! B2 @: @0 ]. ~5 O/ p
  533.     new_x = item_x1 + item_width  (col + 0.5)0 K) X; u- f" F
  534.     new_y = item_y1 + item_height  (row + 0.5)% `8 X0 n. w* v2 Q
  535.     Mouse.set_mouse_pos(new_x, new_y)2 L& k0 k: c$ B0 M9 j
  536.   end
    9 M3 ?) D# p+ j0 G9 c9 L5 c
  537.   #--------------------------------------------------------------------------
    2 N" J& x: r- C. k( `# w
  538.   # ● 判断菜单是否需要卷动+ F1 `# B& E- O
  539.   #--------------------------------------------------------------------------6 N6 P' C, r. I3 {
  540.   def need_scroll  r) b. _, W! u8 ^, F; o3 x
  541.     item_max  col_max  page_row_max. _9 w, N- f  c
  542.   end  ~" w  C3 \# I  n3 a" Z0 v6 L
  543.   #--------------------------------------------------------------------------2 N; A. ]  `$ R5 }- M( f7 @+ U
  544.   # ● 判断是否为水平卷动菜单
    6 _, g; N' }2 H! A: g% {
  545.   #--------------------------------------------------------------------------
    $ F8 R) T& I2 A
  546.   def is_horzcommand
    : p6 j2 R- S/ |1 y
  547.     return false
    + U; {3 s1 [" X* u5 L; v
  548.   end
    5 |8 {0 t. Y( ^. G
  549. end- T1 S- A1 R& u3 s2 \
  550. 9 U, R/ f7 L3 ^9 O) }/ u& l
  551. class Window_HorzCommand& Z- F- Q6 H9 P4 V7 R0 q
  552.   #--------------------------------------------------------------------------
    6 `* H5 G  g* L4 H4 n1 z; v
  553.   # ● 判断是否为水平卷动菜单
    7 `3 w9 ~& i) F) ?
  554.   #--------------------------------------------------------------------------( ~7 k. s; r5 i/ V' a6 |
  555.   def is_horzcommand
    ) a$ _1 x: T- i) P, w/ t6 y; D* B# D
  556.     return true6 q1 \: i9 Q; w! @6 Z3 c
  557.   end& d4 g$ g7 x1 N# S- m8 E, o  W  c' Q
  558. end
    ) b, T' O/ S" J& v% }. ^+ h

  559. 3 L* O  w  ?" @' |
  560. #==============================================================================# @! u# v; K$ A2 X  a; b
  561. # ■ Window_NameInput9 K5 ^- B7 k* M+ ^
  562. #------------------------------------------------------------------------------& s* e- ~; p5 b) i% J& D
  563. #  名字输入画面中,选择文字的窗口。& d, f7 m. b4 g" O
  564. #==============================================================================
    * l) H) t) `/ q
  565. class Window_NameInput
    ( T3 g6 k# C# p7 r, Y# J5 m
  566.   #--------------------------------------------------------------------------
    " v+ X& D8 d4 ?. G5 W* L
  567.   # ● 设置列数
    5 q: Z; i- X4 F* n$ z0 m5 K/ ?; w
  568.   #--------------------------------------------------------------------------
    6 x! I/ u/ A2 N6 _( i
  569.   def col_max4 ]3 o! R% a5 d# b
  570.     return 102 x! e0 Z  B7 {& \* U8 i+ D, ?5 @/ Y
  571.   end0 C, l9 c1 K: c: ?4 d( L
  572.   #--------------------------------------------------------------------------" B$ h4 U/ v; b% d- @: a3 \
  573.   # ● 设置填充的Item个数
    0 C* K8 Z1 O2 K2 k: }4 r, m
  574.   #--------------------------------------------------------------------------+ j: C" Y/ f0 S) c' f1 G8 D
  575.   def item_max2 n; a4 T1 C, N% T- Q' `
  576.     return 90
    ( S# P1 t# ^; [  Y6 J
  577.   end( S( `0 ~# S, E! ~. E
  578.   #--------------------------------------------------------------------------
    + m0 {3 t$ L* N' F
  579.   # ● 设置填充的Item个数) s, Q) ~/ F. R
  580.   #--------------------------------------------------------------------------
    5 H0 k" u: Y+ _% x
  581.   def item_width( D1 W2 B+ b8 D1 S
  582.     return 32
    " [5 T( L: w# K7 h! R! m, Z2 ]3 r
  583.   end, Y, q  a7 ]  x% ?9 h: _1 b
  584.   #--------------------------------------------------------------------------
    # m8 ]7 l* p8 T+ D2 u$ o
  585.   # ● 判断鼠标位于菜单的第几行、第几列/ R+ i" A! b' Y5 C; v
  586.   #--------------------------------------------------------------------------
    5 u& a; f2 g2 h# c# Q4 F
  587.   def mouse_window_area. `  p6 ?; I- c4 x4 e. ]' p
  588.     if viewport.nil2 r2 H; s! _: H0 F9 F- `
  589.       vp_x, vp_y = 0, 0
    * U9 a7 g* ~2 X7 H" {) J" r$ X+ E
  590.     else. D2 H  M6 W) A5 Y! @
  591.       vp_x = viewport.rect.x - viewport.ox
    " G4 [/ \) {( Y7 `8 r
  592.       vp_y = viewport.rect.y - viewport.oy6 ?, M+ }8 j* T  n  L
  593.     end
    * i6 g% e' I% Y1 `7 }6 T; j3 l
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    # `- G$ z1 Z; |. G* n9 x7 C
  595.     item_x1 = vp_x + x + standard_padding
    / ]" p( o& Y4 w* j8 D3 N1 x
  596.     item_y1 = vp_y + y + standard_padding9 A, L* g1 h1 g. I" p% z
  597.     item_x2 = vp_x + x - standard_padding + width
    & H  }$ s5 B9 E/ R- P) r
  598.     item_y2 = vp_y + y - standard_padding + height; u4 e; m; c2 A& C1 m% T7 C' o2 Y
  599.     if mouse_x  item_x1
    8 t9 W' D5 W' l1 e* L
  600.       mouse_col = -1
    ! _- x9 K. i( Z& w$ A0 ]' G4 Y+ y
  601.     elsif mouse_x  item_x21 h( |3 X6 v. w) l2 M" i  b0 C
  602.       mouse_col = -2
    8 Q1 d, |8 C& C) q  B/ `  e" a6 x9 B
  603.     elsif mouse_x  item_x1 + 160
    1 U5 M0 J2 K! n9 r# N# |9 j. y
  604.       mouse_col = (mouse_x - item_x1)32
    1 L6 d7 m5 I) Y( ?( j5 ]- p' G
  605.     elsif mouse_x  item_x2 - 160
    - E! n1 ?" \3 [& y2 I. k$ {8 z
  606.       mouse_col = 9 - (item_x2 - mouse_x)321 \2 Y: [" P2 |# K9 Z) T! |
  607.     else
    ( e2 b4 d( X8 [) ]% q2 @
  608.       mouse_col = mouse_x  x + width2  5  43 r8 W0 @5 x" ]3 L% M
  609.     end
    , I1 Y5 H1 e3 a5 Z( s+ A
  610.     if mouse_y  item_y18 U0 u( V; K* q( F
  611.       mouse_row = -14 \% Z8 s! k9 `( D7 z$ r
  612.     elsif mouse_y  item_y2* Y" X% D% w8 I2 V
  613.       mouse_row = -2
    3 o& f: F- L# G5 N0 u
  614.     else
    . y5 i, c7 V: s. l/ p* W5 |# L
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    " I4 B! y+ ^5 h) ?/ m/ j
  616.     end
    - y" v0 u5 ?" z5 ^7 O9 J
  617.     return mouse_row, mouse_col* t& @9 [9 O( G+ F
  618.   end
    / C# L- Y8 A% q- x! C5 q
  619.   #--------------------------------------------------------------------------
    5 \5 s1 o8 s  _0 t$ g4 Q
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    7 U; G* l4 w" I1 c: {/ r
  621.   #--------------------------------------------------------------------------
    ) q0 C: B5 h1 p5 X
  622.   def set_mouse_pos
    5 l) w1 e2 v: E5 o/ i
  623.     if viewport.nil # necessary!
    * X) v' w) R$ B' m2 ^2 v8 \
  624.       vp_x, vp_y = 0, 0
    " _3 A7 [- s8 a' [( n" ^$ P% _
  625.     else, A5 M' {2 O- u" l) {* M
  626.       vp_x = viewport.rect.x - viewport.ox
    + @$ {5 Y( W3 B
  627.       vp_y = viewport.rect.y - viewport.oy, v0 _' `" I2 Z
  628.     end. e* d( @+ [+ ]; r7 f8 x
  629.     item_x1 = vp_x + x + standard_padding
    7 \  i! r  }) Z7 P3 M9 ]; }: P
  630.     item_y1 = vp_y + y + standard_padding
    5 z) G+ s8 H3 }: x1 E7 ]9 N7 x0 U
  631.     get_index = @index  0  0  @index
    & h/ C; {7 d; [+ M
  632.     row = get_index  col_max - top_row$ R) K+ C4 O: D4 F0 v/ B# \# L
  633.     col = get_index % col_max7 ^0 b  q- O  H
  634.     new_x = item_x1 + item_width  (col + 0.5)+ I0 e' ]: _3 ?9 }9 \
  635.     new_y = item_y1 + item_height  (row + 0.5)' q' R7 @1 K9 Z) a- v4 i0 k7 E
  636.     new_x += 14 if col  4
    . e* Q* Y" V8 |7 k
  637.     Mouse.set_mouse_pos(new_x, new_y)
    9 {: |1 A2 e6 X# B6 e0 H" m
  638.   end
    0 ^/ i5 [# }  f3 R. |# d5 g% V9 e
  639. end5 M) S3 d( O( g5 m* F8 r! w! H# z

  640. ; [. r6 k! M* V
  641. #==============================================================================/ [$ z; T. D. t/ z2 O$ T
  642. # ■ Window_NumberInput
    * w2 M  ~7 s# h- B+ h
  643. #------------------------------------------------------------------------------
    5 F9 L: d- d+ O0 y$ P
  644. #  重写了数值输入的方法以适应鼠标! {! Y& K  }/ b6 g5 T0 ~
  645. #==============================================================================
    4 X2 y6 v; B" w! q( z; O1 c5 `5 l
  646. class Window_NumberInput  Window_Base: K8 s* \5 {& @& Z
  647.   #--------------------------------------------------------------------------
    ' h1 T% w+ i: h" F
  648.   # ● 定义实例变量
    # E  i- ]" c( I$ `" J3 i* i: D
  649.   #--------------------------------------------------------------------------
    4 Z4 z& T; \9 n
  650.   attr_reader extra_window
    0 h; y# L' Z/ n$ E- L
  651.   #--------------------------------------------------------------------------
    ( G. R+ A2 x! A7 G
  652.   # ● 初始化
    8 S6 q/ v* r* F7 I4 K
  653.   #--------------------------------------------------------------------------$ a. S: q( [$ e5 ~2 U( u; I( {
  654.   alias sion_mouse_initialize initialize
    : Y7 D% k% D) ^
  655.   def initialize(arg)) A8 T6 N2 q& h3 b
  656.     sion_mouse_initialize(arg)# P0 Y0 r2 s, X. J# G5 \, }" O# _
  657.     create_extra_window) }$ d$ c/ n, }# f) E3 o+ Y$ j
  658.   end
    0 k. b2 s: I& d) m' W$ g
  659.   #--------------------------------------------------------------------------1 l% f/ }- Z2 p2 l
  660.   # ● 启动
    9 r8 j5 K# O* i5 \. i
  661.   #--------------------------------------------------------------------------
    8 e8 G. F6 r7 Z- X. H1 V4 e
  662.   alias sion_mouse_start start2 R, ^; k4 C9 V3 r* ^+ {4 b
  663.   def start2 L0 O9 q  w7 g1 V. u# ^
  664.     sion_mouse_start( o: Y+ Z$ H. e/ X5 G) }6 J" Q
  665.     deactivate
    & {4 @" t( }8 J% I
  666.     extra_start' L5 _: {( e& ^. {& d
  667.   end1 m0 z3 D: W% d( Z( Z- f$ r9 v
  668.   #--------------------------------------------------------------------------
    3 Q5 \0 Q8 s7 [( U6 R* g# z5 t
  669.   # ● 创建新的数值输入窗口. w" [- Q) N' {4 R  J0 r7 ~8 V
  670.   #--------------------------------------------------------------------------
      y  B" x* z6 x
  671.   def create_extra_window$ E  }6 P' R" a  M5 i9 x: G
  672.     @extra_window = Window_NumberInput_Ex.new
    9 x$ r0 z; d) _* Z2 `' U5 T) O9 m
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    6 I' y5 Z6 w& H$ E
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    % C, j# N- r) _  D# p5 X  {
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    9 O; n, _0 C% o) F, v2 _- U; H1 X
  676.     @extra_window.close_proc   = Proc.new { close }
    3 a) }- N. u& E# u4 y3 a) F5 r
  677.     @extra_window.refresh_proc = Proc.new { refresh }9 {- Z9 R5 Z: w% Z! M) t
  678.   end
    5 e  d, k% K& d" d# S, u! U% J
  679.   #--------------------------------------------------------------------------
    # B( C) Z2 n. H$ t
  680.   # ● 激活新窗口
    ; Q+ {, j8 p2 S( _$ i) b
  681.   #--------------------------------------------------------------------------
    % Q* ^  l: I0 B2 r4 Y% ~1 I$ j
  682.   def extra_start7 Y/ T' K- p/ q  X6 o
  683.     case $game_message.position
    , x( f! M; m5 i. b% T0 X
  684.       when 0; @extra_window.y = y + height + 47 x% N" F& K6 |! [$ x% M& y) K
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8! g! |+ }5 Y6 H0 c( T0 z9 H) q
  686.       when 2; @extra_window.y = y - @extra_window.height - 4# S, o: a1 b* q+ [; p% S0 ~
  687.       else  ; @extra_window.y = 8% {/ ?' @1 h& y5 v$ `
  688.     end
    , T& K' K2 f' {. Z5 r) o+ q
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    - o/ o! @8 {8 x% G4 G- ]0 t
  690.     @extra_window.digits_max  = @digits_max
    - ]- {, x7 a2 \8 U1 u" Q
  691.     @extra_window.number      = @number. @" U) `) t, C) h" T; ?  |9 R5 }3 v
  692.     @extra_window.open% M4 s+ ~/ R& T9 P
  693.     @extra_window.activate5 i# n3 C7 H4 ]0 F0 R
  694.   end
    / t+ O( u% {8 ?& L1 ^: R
  695.   #--------------------------------------------------------------------------6 b# V' _" F/ ^# Y0 K4 L4 i6 B7 Z$ Z
  696.   # ● 更新$ c0 U2 o5 m2 W7 e: O
  697.   #--------------------------------------------------------------------------% J# A' M( @5 [. S$ V4 E( e) Y
  698.   def update! b% Y; b" a  c, b$ W) j, p& X
  699.     super, W' i9 u* j  ]" d' f
  700.     @extra_window.update1 X; |: f; t" o
  701.     update_cursor
    8 Q+ C% u! r- p: v# B. {. r$ h
  702.   end- G# ]* C5 }+ y4 n; }
  703.   #--------------------------------------------------------------------------
    8 R) F" l: D" n, Q% S
  704.   # ● 关闭窗口
    ' A  t+ u2 n( _; y$ o' S  _
  705.   #--------------------------------------------------------------------------
    4 w& O* \- b: e
  706.   def close5 ^+ q; z% A% W. T& m; o2 _* J
  707.     super
    0 G% _- `  F+ D, n2 S6 M6 @
  708.     @extra_window.close) H6 k. c* f& b, I
  709.     @extra_window.deactivate
    $ q9 {( j, b- C, r4 Y
  710.   end2 \4 k  Z( Z* Z' b! m- g
  711. end+ X5 @$ W# v: k& K( _9 \% O- c

  712. 1 c4 x2 u; X3 c- b4 a
  713. #==============================================================================: O0 d+ X% y) M/ L4 Z0 P3 B+ R# P
  714. # ■ Window_NumberInput_Ex+ t0 T$ ]2 @) S4 v
  715. #------------------------------------------------------------------------------
    4 M+ T( i2 p5 b6 [. `; S/ U
  716. #  新的数值输入窗口(NewClass)
    2 h- F& X9 z& C: Y% p3 Q1 L6 ?
  717. #==============================================================================
    # }* R/ ?0 {. P5 V- J
  718. class Window_NumberInput_Ex  Window_Selectable$ Q- Y; x# t, J) P
  719.   #--------------------------------------------------------------------------
    3 a. j# a: n+ W* ?$ N
  720.   # ● 定义实例变量
    " F. [$ V/ w! _6 C7 D+ y8 `
  721.   #--------------------------------------------------------------------------
    / t# e# C/ g- I
  722.   attr_accessor number_proc
      G+ ?! S9 N# }! a
  723.   attr_accessor index_proc
    8 W1 U* U( D$ j
  724.   attr_accessor close_proc
    ! Z$ T: J( {" ~
  725.   attr_accessor refresh_proc
    . Z0 p( }7 A# y8 O" {
  726.   attr_accessor number( {% p# S* e$ G3 W8 d% [) \
  727.   attr_accessor digits_max
    6 a& _( j+ P1 k% v
  728.   attr_accessor variable_id
    ; d) W/ _. m4 t& ?  p
  729.   #--------------------------------------------------------------------------8 ?  Y8 ^/ M  n
  730.   # ● 数字表. X7 ?1 }9 ]& ?' |! k) f0 C1 q' [
  731.   #--------------------------------------------------------------------------
    * E$ ]7 d: b0 P2 D/ `; L
  732.   TABLE = [  7,  8,  9,# |5 K8 @. ], R& O1 y5 h& M) c
  733.              4,  5,  6,& C. x0 Q& J2 a' D
  734.              1,  2,  3,0 c7 e4 I3 ]: W5 ?, f% L+ Y3 Y' x
  735.             '←',0,'确定',]
    . B1 c1 X, ^3 A3 P* r
  736.   #--------------------------------------------------------------------------2 P1 `) g* Y  q) h5 y' D
  737.   # ● 初始化对象
    . o0 y" A* L7 i8 |$ N& D; w! f  k
  738.   #--------------------------------------------------------------------------7 x  \! i  S2 A3 h8 Z
  739.   def initialize
    " z; k' M# `# D0 R/ M
  740.     super(0, 0, 120, fitting_height(4))2 M( G1 z# t1 x( _4 y
  741.     self.openness = 0
    , Z! W& M% d& v
  742.     @index = 0
    ' A7 f# B1 \- `, L5 W1 N, I/ \
  743.     @number = 0  `1 o! ?$ P; p2 [
  744.     @old_window_index = 0* h8 [7 o  o8 n
  745.     @digits_max = 0
      T" ?$ v( A+ P8 n" T! x' C
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }0 ]: h; g! b1 `# D5 p( P
  747.   end% b- b7 k1 i& G- @+ e
  748.   #--------------------------------------------------------------------------
    1 y% g; W8 L7 X
  749.   # ● 获取项目的绘制矩形. I- B/ X/ h* k5 W
  750.   #--------------------------------------------------------------------------% b! n% G4 F# Q2 |$ Q
  751.   def item_rect(index)
    ' `' p" U' f: [0 K- A
  752.     rect = Rect.new
    1 @2 `6 N. o0 {- H
  753.     rect.x = index % 3  32
    1 }! ]$ Z2 S9 [( x. [# I  E: O
  754.     rect.y = index  3  line_height8 r2 P1 ~6 C! e* o
  755.     rect.width = 32
    7 n# T* w+ u$ \1 v7 h0 Y4 U* i5 R
  756.     rect.height = line_height! x! k& |2 R- D3 I$ s. X3 P
  757.     return rect' m" E! u% f% L7 \5 b1 b
  758.   end  z4 W+ }7 H- ]$ e$ L9 b+ f1 R- Q
  759.   #--------------------------------------------------------------------------
    $ I- _! y( D4 f( Y9 O0 Y
  760.   # ● 将光标设置到鼠标所在的位置) M) m7 s' h* S8 |4 W" c* L$ A
  761.   #--------------------------------------------------------------------------' Q" A$ h+ g$ N
  762.   def set_cursor
    7 V$ k* R1 ?3 c  ~3 n$ c
  763.     mouse_row, mouse_col = mouse_window_area1 \; N6 e7 R2 u
  764.     if mouse_row = 0 && mouse_col = 02 z5 R6 M+ `  G6 N* r& j
  765.       new_index = mouse_row  3 + mouse_col" o9 M# d) R( W1 d/ |& G
  766.       select(new_index) if new_index = 11* X2 N% F1 N+ Y0 d0 f* A7 v3 J
  767.     end
    4 A. i- ]1 W3 d! N- @* C
  768.   end
    ) x* X( E& Z) t5 C$ P% z
  769.   #--------------------------------------------------------------------------$ L% c) [* S0 V; G1 a2 U
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列4 B7 g7 }2 C# W
  771.   #--------------------------------------------------------------------------
    $ O1 L. X: K9 y8 D7 @5 G3 P
  772.   def mouse_window_area1 x" I/ c$ v5 j' n1 }  J
  773.     if viewport.nil$ ]/ z0 \  ]. \0 `* L. }1 g7 H
  774.       vp_x, vp_y = 0, 0
    7 {: B! ~3 _, x8 A, o
  775.     else
    ) Y0 u0 k$ E" g8 {
  776.       vp_x = viewport.rect.x - viewport.ox
    $ P0 y; Z" h, c
  777.       vp_y = viewport.rect.y - viewport.oy
    2 M2 ]) \+ O" G. p* C" L$ D
  778.     end
    # t& z) M" B4 ~% k8 r
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y5 w0 U, [/ S  s' Q6 y2 b/ E
  780.     item_x1 = vp_x + x + standard_padding
    6 }8 _9 A/ R$ B3 l2 o" ~
  781.     item_y1 = vp_y + y + standard_padding
    3 F* L2 n( J- m8 g
  782.     item_x2 = vp_x + x - standard_padding + width
    ' `! S0 y/ W. c# S( l9 }
  783.     item_y2 = vp_y + y - standard_padding + height
    - T' q. B2 Y! s; A8 S- |# g3 j, Q# ]! F
  784.     if mouse_x  item_x1! X; @( t2 {$ g; e8 ?- ]
  785.       mouse_col = -1
    ) g3 I5 z7 M" f3 }; m* c2 C! k3 o* x
  786.     elsif mouse_x  item_x2, b2 @% i" H% G# n7 h! E9 i
  787.       mouse_col = -2
      |8 M* W4 f4 X+ J( Y( Z9 v
  788.     else7 v1 z" {, H& ^9 B
  789.       mouse_col = (mouse_x - item_x1)  32
      X7 O$ L# J7 v" _6 T* R
  790.     end" g5 E4 r7 {0 z1 r6 ^
  791.     if mouse_y  item_y1
    # c2 p8 b* P; t% }
  792.       mouse_row = -1$ e  L, ]5 p. [# l
  793.     elsif mouse_y  item_y2/ Q0 j9 M1 q' D2 |8 F  I
  794.       mouse_row = -2
    & q" F* p/ d; J0 J
  795.     else
    2 c( g. T0 g! x! T1 c+ `0 ]
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    4 e0 `  g: _+ |1 h+ T
  797.     end3 |! v: C  P5 d+ h$ Z8 @% O
  798.     return mouse_row, mouse_col( F% ]4 C  t, X+ A* ?' Q
  799.   end9 |7 C, x4 u( o2 V- e
  800.   #--------------------------------------------------------------------------
    5 A/ m' X: i$ ]6 j0 m% i. L
  801.   # ● 获取文字
    ) ?& B* d, f8 c6 k- o
  802.   #--------------------------------------------------------------------------3 j% z; V% {: k" E" Z
  803.   def get_number6 v. A' Z  i/ Y% N' r% C
  804.     return false if @index == 9  @index == 11
    # p' j1 e, a: x* m
  805.     return TABLE[@index]
    - m& o3 v, T6 x/ E4 Z- d
  806.   end' N( e, ]7 x4 |. T! j$ r
  807.   #--------------------------------------------------------------------------" @3 Y  R; z1 p+ P' Q* t& T
  808.   # ● 判定光标位置是否在“退格”上7 K; G' N3 j% o* |3 T* b- k
  809.   #--------------------------------------------------------------------------
    . o- b% t" s0 R6 E" }4 Z
  810.   def is_delete$ Q2 X( G% u/ T/ v
  811.     @index == 9
    9 r. O, S6 {6 u
  812.   end
    & B7 R4 j* h1 k# c  O! Y1 Y1 ^( o
  813.   #--------------------------------------------------------------------------  p) U% q; R& i0 q! E
  814.   # ● 判定光标位置是否在“确定”上
    & c$ l! t9 f8 f: Q. y4 M
  815.   #--------------------------------------------------------------------------
    ) v  g5 E1 h) o% X% J( A3 w! W1 g
  816.   def is_ok$ L' u% X2 W- v4 f8 a& s
  817.     @index == 11
    ; i$ ~0 ?0 [0 ~
  818.   end. t9 t/ h0 K1 H" n, D
  819.   #--------------------------------------------------------------------------7 J3 r: u1 G  s) n, U' U
  820.   # ● 更新光标* R! S$ q0 U) x2 E# O& j
  821.   #--------------------------------------------------------------------------
    7 d, A- `1 C3 n% B0 N
  822.   def update_cursor' v2 u$ A* s& g$ ?
  823.     cursor_rect.set(item_rect(@index))% m* B/ ^! M# ]/ L
  824.   end
    0 I$ o$ Q% U& [( R# _( W% R
  825.   #--------------------------------------------------------------------------, o1 s0 _3 I; {; N* k7 z5 v
  826.   # ● 判定光标是否可以移动/ T$ Y4 H, W  N2 K* R# R
  827.   #--------------------------------------------------------------------------( C2 I. {, l5 C; R( d
  828.   def cursor_movable
    % D, r: T- E9 v9 q
  829.     active1 P5 ]  ~8 m* y6 |  T
  830.   end& p  a# u! ?8 Y/ D$ v7 m9 B
  831.   #--------------------------------------------------------------------------9 j+ g5 r. k3 S& U
  832.   # ● 光标向下移动
    + A1 x! o/ r* w  v  y; P) P
  833.   #     wrap  允许循环
    ! {! e8 Y) }% z
  834.   #--------------------------------------------------------------------------
    ) R+ j, g+ \! k: W0 e, X' ~2 D
  835.   def cursor_down(wrap)4 ]+ J& E* w8 ~3 l5 ~" J  A
  836.     if @index  9 or wrap
    % m7 ?! m9 w- }/ Q# k) q3 E) e
  837.       @index = (index + 3) % 12- @) z) P! a, m/ r
  838.     end
    7 o/ |: K! g/ Q' T* B
  839.   end1 _5 p) A3 s3 `; b0 N( i
  840.   #--------------------------------------------------------------------------) p; U- O. i1 x/ K( s0 `  e) u
  841.   # ● 光标向上移动
    0 T$ _8 {5 d4 A
  842.   #     wrap  允许循环( r6 c: d7 w' H. v& v
  843.   #--------------------------------------------------------------------------7 R5 Z2 j8 C( _" t
  844.   def cursor_up(wrap)
    2 V, @7 J: @( ]( w2 e8 o( T, T
  845.     if @index = 3 or wrap
    7 [: P! I9 w! v
  846.       @index = (index + 9) % 12
    / }6 {' ~' V) q. G# C9 h' N3 a6 l
  847.     end
    1 d4 J' }: s5 c
  848.   end
    & E8 P) O$ i9 O- P# u8 Z& M
  849.   #--------------------------------------------------------------------------0 |2 T. H3 |1 g3 D" i
  850.   # ● 光标向右移动, w1 a! w3 i/ l* l
  851.   #     wrap  允许循环) o- r+ o) F2 o5 T7 V
  852.   #--------------------------------------------------------------------------
    * F8 r6 M! J; k! Q/ [& P1 c; ]
  853.   def cursor_right(wrap)! P1 Q8 Q9 {# l8 \: \* }
  854.     if @index % 3  2
    , Z/ J$ t/ o. K9 i9 A; S. S
  855.       @index += 1
    9 D" i1 U! a* i& z5 \  f
  856.     elsif wrap
    7 O( G/ s4 v; `) y
  857.       @index -= 2
    . q; Y8 |: Y* p+ L% B
  858.     end
    * \0 C9 y% n" k) u
  859.   end" G6 z" ~% G/ B, {
  860.   #--------------------------------------------------------------------------6 H9 Z) A; F4 W  |: K7 e, L' ^) f, l
  861.   # ● 光标向左移动8 P2 b8 n9 |* N4 p4 \8 b$ Y) y
  862.   #     wrap  允许循环
    6 _, N) W8 E1 {
  863.   #--------------------------------------------------------------------------
    7 h. Y& v% R" E9 f4 c8 F' ~; b" k
  864.   def cursor_left(wrap)- b! I/ G, K8 `; q. ~' D3 K
  865.     if @index % 3  02 h5 E: ?  p7 K9 J. s
  866.       @index -= 12 _) x- d/ A3 W2 C. b# v
  867.     elsif wrap
    " s" v0 O0 w# N
  868.       @index += 2
    , l+ X/ `5 o8 ~
  869.     end
    # P; `$ @0 u2 n+ X
  870.   end* U$ n. f* O  U% u0 E/ e+ H3 ~
  871.   #--------------------------------------------------------------------------4 t; y. u+ V8 z) L3 {# ~
  872.   # ● 处理光标的移动
    3 l' @: Z* p$ G5 h% D
  873.   #--------------------------------------------------------------------------
    ; D& t, L9 D$ g) _: t. H5 N8 c
  874.   def process_cursor_move  U. W9 f9 U* x" ^( I* V( H
  875.     super
    / e) `2 E8 A* Q, L, B/ n8 A3 [
  876.     update_cursor; o4 U" G0 O  K# B0 h2 d
  877.   end
    5 b& Y1 a" y. I9 V  Y
  878.   #--------------------------------------------------------------------------- W6 E8 R+ S( {' }1 E: \; h
  879.   # ● “确定”、“删除字符”和“取消输入”的处理. i- Q9 Y+ _! x1 M
  880.   #--------------------------------------------------------------------------3 l9 A% Z! [( d) ^6 c
  881.   def process_handling
    0 C6 `+ n0 X& S( n6 u
  882.     return unless open && active
    . N* C- T8 Y( O" S$ v/ K8 P* ^  q
  883.     process_jump if Input.trigger(A)8 f( u: G  n) _2 H( o5 O
  884.     process_back if Input.repeat(B)
      a, L7 U3 H( n6 I. {+ O+ `) H
  885.     process_ok   if Input.trigger(C)+ q. J' c/ Q" f( k( M0 C
  886.   end
    " Q  Y, t; C& H# F0 ]1 o$ q6 M$ F! n, Y
  887.   #--------------------------------------------------------------------------
    ; F& R6 B% {# s
  888.   # ● 跳转“确定”$ A; n) _* f; u6 C  Z' _9 c8 v
  889.   #--------------------------------------------------------------------------
    % p) e, m: O2 _' j7 A) `+ |  d' D
  890.   def process_jump
    , ^0 b- e* m( ]7 J+ G% H
  891.     if @index != 11
    6 W" a2 k% {% p3 t4 n
  892.       @index = 11
      t( Z7 ^) o! W- I! ?
  893.       Sound.play_cursor
      I2 S1 {; t' i
  894.     end
    9 e4 N; c' V* V. C
  895.   end
    ( a) D/ v; l5 {) L. Z) W  H) J
  896.   #--------------------------------------------------------------------------
    1 c# [4 }7 n) n( [
  897.   # ● 后退一个字符5 F2 a! `) X% Z, y/ c1 w3 \3 s/ o
  898.   #--------------------------------------------------------------------------
    9 H, Y- j! h  ], u( d2 i
  899.   def process_back# A' u( l0 H- r5 r% U1 N- R: q
  900.     Sound.play_cancel- j8 }- D& h1 m) M! X6 b0 N
  901.     place = 10  (@digits_max - 1 - @old_window_index)! A' }6 @0 x+ l
  902.     n = (@number  place) % 10( p! c" G# ~! y' b# o
  903.     @number -= n  place. `5 m, E" o0 c: n' ]
  904.     @number_proc.call(@number)
    ) O1 r" q4 o' R% M7 z3 h
  905.     @old_window_index -= 1 if @old_window_index  0
    : W7 }# Y: x* A
  906.     @index_proc.call(@old_window_index)2 A/ o1 g& }" [
  907.     @refresh_proc.call
    3 v2 e- X6 |7 ?- q6 Z1 L$ {
  908.   end
    . m7 p3 N. E8 W# `" G6 ]8 s
  909.   #--------------------------------------------------------------------------
    2 x- a% N+ m( k8 e: H" Z
  910.   # ● 按下确定键时的处理
    1 H' l( }: p7 i5 v$ a3 }
  911.   #--------------------------------------------------------------------------8 B- V1 _6 a8 D
  912.   def process_ok& f; m, g; X8 w% |# j0 M
  913.     if get_number) i  ?- O" O7 F, a& q# z/ _
  914.       Sound.play_cursor$ G) v9 v; v& o/ L) s) e
  915.       place = 10  (@digits_max - 1 - @old_window_index)# `5 M: s" u2 C) |8 T
  916.       n = get_number - (@number  place) % 10: P, S* a) u8 _
  917.       @number += n  place$ [7 z5 [3 s4 Z/ C% p* u
  918.       @number_proc.call(@number)# k" P) r# U9 N7 G/ \5 M9 O' o: G) t
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    * U$ Y. A" p# ]
  920.       @index_proc.call(@old_window_index)7 w* k. X3 ~) [+ U% W  w' @8 q6 w
  921.       @refresh_proc.call* ?  _4 B2 O) t1 s
  922.     elsif is_delete
    4 G0 p: J6 w2 e7 ^
  923.       process_back0 m/ G+ k* L2 x6 X& V
  924.     elsif is_ok
    % j$ P2 s$ m! i& b
  925.       on_input_ok! `- `) f. ^6 ~9 w
  926.     end; y8 K  I* S$ s/ s8 s
  927.   end
    , t* L# t. q3 C2 ~$ V, _& e+ ]6 }2 D
  928.   #--------------------------------------------------------------------------4 @6 i6 s/ j: l) Z3 `, R
  929.   # ● 确定  S8 G/ R5 Z  Q6 y
  930.   #--------------------------------------------------------------------------8 @  L! }  t4 p( ]; Y
  931.   def on_input_ok+ ~/ v$ }! g8 R7 k( n, a& r
  932.     @index = 0
    : H. g/ r5 ~! }+ t- b
  933.     @old_window_index = 0& s6 ^! [/ B# H
  934.     $game_variables[@variable_id] = @number
    ( K5 J$ e7 u8 E6 j& g* f/ A
  935.     Sound.play_ok
    6 x9 w( W. t' e( O# y$ t5 a5 f8 z
  936.     @close_proc.call
    ; X3 y2 e( ], P: ?3 {8 g' I
  937.   end6 \/ [6 K8 @. v8 L
  938.   #--------------------------------------------------------------------------' G% h  B9 k1 b, X
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ! }/ d8 p/ q/ M5 J' n! Y% `6 h. `6 G
  940.   #--------------------------------------------------------------------------
    $ p% m. w( B" j# o1 c& q( ^
  941.   def set_mouse_pos4 Z# T: t8 R3 R
  942.     if viewport.nil # necessary!
    3 _3 X" x- h+ n! T# y$ \
  943.       vp_x, vp_y = 0, 0
    0 q$ n8 m1 q: v1 x
  944.     else
    2 h! |/ V8 v* r1 t7 M) m
  945.       vp_x = viewport.rect.x - viewport.ox3 [; ^, O0 F, }) l
  946.       vp_y = viewport.rect.y - viewport.oy/ T% Y( o2 [4 Z0 w% T8 `3 b8 S5 u
  947.     end4 S6 o/ I  t! c4 u! J+ _+ p3 e
  948.     item_x1 = vp_x + x + standard_padding
    . }" d' T' B' u, w6 {
  949.     item_y1 = vp_y + y + standard_padding. x* R* U' s6 F1 n( k* {% G
  950.     get_index = @index  0  0  @index
    ! x  ?* ^4 n' M2 @
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)8 q1 C# [& i6 T7 K1 r
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5): F; |: S' y% x! v, d5 Z
  953.     Mouse.set_mouse_pos(new_x, new_y)4 ]; s3 ~* Y# q( a: l7 T
  954.   end/ {3 w4 l" {5 [9 @
  955. end6 t9 s, u& O$ n
  956. # |1 j0 v) _; h. v, W
  957. #==============================================================================" _: l7 \2 ~! [1 n! D
  958. # ■ Window_Message
    6 ^% D5 S/ e1 A" e3 e% c2 ~
  959. #------------------------------------------------------------------------------
    5 Z: E2 p7 w' X2 e! _: v7 f
  960. #  显示文字信息的窗口。4 g( Y3 p* ~1 \  e0 t
  961. #==============================================================================1 `9 f; O4 A' n( B* O: E
  962. class Window_Message  Window_Base; g& g/ v( n0 i' K
  963.   #--------------------------------------------------------------------------  N; V& \/ @3 e; z2 K: v
  964.   # ● 处理数值的输入(覆盖原方法)
    $ a0 v- F3 P, u/ _2 ?8 U. u! M* E5 [
  965.   #--------------------------------------------------------------------------) c$ t5 H+ s/ g' [
  966.   def input_number5 ]. C, g$ K0 D" C! l: `/ q
  967.     @number_window.start0 A2 o# C1 H* g0 f$ }, a
  968.     Fiber.yield while @number_window.extra_window.active
    ! t/ w" o0 s" _/ f, h5 Y
  969.   end' y2 g$ B& X2 N+ L- A
  970. end; b% ]. o, c8 N6 Y, f

  971. , c" \: t4 \- `: {' S
  972. #==============================================================================/ n- Q( B2 w& T) o
  973. # ■ Window_PartyCommand- v! W$ b# f( g8 K& l. t" I4 }
  974. #------------------------------------------------------------------------------, |# K& f$ u: G
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    ( {- l4 K5 o. F' t% w4 U1 K
  976. #==============================================================================3 z) o4 V, c" Q# B8 C( q+ j
  977. class Window_PartyCommand  Window_Command) a' A/ p  |9 F& @  M
  978.   #--------------------------------------------------------------------------
    1 E& L( Q" A5 b. C* W- F" ?
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置# U; s! |7 g! f! \2 |2 j
  980.   #--------------------------------------------------------------------------$ g) Q0 b2 D; B6 t3 f4 V
  981.   def set_mouse_pos
    : p$ T: L) \1 c+ m" v! F* b
  982.     if viewport.nil
    - F' F5 j* o3 m, n$ n# l5 B3 o
  983.       vp_x, vp_y = 0, 0# x2 p; f7 [. q
  984.     else. p& f! L* H. ]" e1 b
  985.       #vp_x = viewport.rect.x - viewport.ox9 i* ]& q( U* e9 A- }) ]+ D
  986.       vp_y = viewport.rect.y - viewport.oy4 P: f2 e. Q5 w: }, w+ L
  987.     end
    6 W$ ?7 a6 H: O2 _. H3 ?- c
  988.     item_x1 = x + standard_padding
    : S4 p! M8 Z* W( X" C/ v' E
  989.     item_y1 = vp_y + y + standard_padding- a( D) u" c# s7 c9 t+ z( C' A1 h
  990.     get_index = @index  0  0  @index 6 Y; Y7 q! g  t( n  d2 L9 L
  991.     row = get_index  col_max - top_row* d2 e- Q8 F6 k8 A. L
  992.     col = get_index % col_max
    & t: \9 e" ^# ]) F6 c4 a' x+ Z" F
  993.     new_x = item_x1 + item_width  (col + 0.5)
    5 }2 h; O7 i9 X( y  `! h
  994.     new_y = item_y1 + item_height  (row + 0.5)
    8 r# `* u' I) J! [6 V: I: i0 x, A
  995.     Mouse.set_mouse_pos(new_x, new_y)
    ! y! A" ?$ n; R
  996.   end$ k, K. t' R1 |2 t1 j# `- T* c
  997. end5 x" S6 `" a1 C) ^0 ^! W+ @
  998. 1 `( \+ f- l4 v6 Q2 z4 E! o
  999. #==============================================================================& _* n* ~" P9 y. T
  1000. # ■ Window_ActorCommand
    & k, h5 S0 [! f
  1001. #------------------------------------------------------------------------------- C/ Y7 f) F0 B! E% ^4 I* I1 s/ U/ R5 I
  1002. #  战斗画面中,选择角色行动的窗口。
    4 O0 z- x$ F) y: g
  1003. #==============================================================================  ]  o- X; W! R" K% k' F/ z
  1004. class Window_ActorCommand  Window_Command
    " f3 p- S0 q) }6 U. `7 N% H
  1005.   #--------------------------------------------------------------------------! [8 T, F9 S. L: ^! `: W
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    4 P% _$ L0 C. A9 n# D
  1007.   #--------------------------------------------------------------------------
    0 B) H/ h& h" @& m" |/ Q
  1008.   def set_mouse_pos
    9 s. k8 g- l# q
  1009.     if viewport.nil: ~& d7 Y4 p) ]7 q
  1010.       vp_x, vp_y = 0, 0$ Y4 h  @8 ^, L
  1011.     else% R9 a" \1 _' v7 n4 t. ^7 O. h
  1012.       #vp_x = viewport.rect.x - viewport.ox" O+ Z! B" C% b; ]3 S" @
  1013.       vp_y = viewport.rect.y - viewport.oy
    % X% e; o3 z' j9 e' L  _* f9 c; c
  1014.     end
    / }: z* u, t6 _3 H
  1015.     item_x1 = Graphics.width - width + standard_padding% G0 Q8 A$ `; [0 P1 Y' k; k0 }
  1016.     item_y1 = vp_y + y + standard_padding
    0 S3 D6 t. G8 @# }8 F
  1017.     get_index = @index  0  0  @index ! q( C" n. ^! e5 v1 U( q  ^) g
  1018.     row = get_index  col_max - top_row
    8 V. C( b6 V$ h5 w. Q7 l
  1019.     col = get_index % col_max
    ; O& u: y/ A4 Y, ?
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    8 E& P4 l; |2 z
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    2 o. k4 F5 ~$ j( D
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    " ?. q% {1 b* _
  1023.   end
    1 I; g$ D! _( h$ R5 Q) A8 l
  1024. end0 ~' s! b" l( [+ n3 D

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

  2145. ' j: w/ U( ]! |+ _% z# _
  2146. #==============================================================================; p. V. O% u7 G2 v
  2147. # ■ Game_Map! g. x9 ^6 p+ ?7 n6 X" G# }/ L
  2148. #------------------------------------------------------------------------------4 ]. C5 a  v1 [
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    - V3 Z" Q- D% o& p) y2 `. Q; R
  2150. #   本类的实例请参考 $game_map 。/ D" P' I$ S, C. c- E% M: y+ M
  2151. #==============================================================================
    ( U9 r+ X3 c6 `  a" S+ [# M: f
  2152. class Game_Map* ]1 H& |1 b9 ~# j& ?6 z
  2153.   #--------------------------------------------------------------------------
    " k+ J) \4 |, e. |
  2154.   # ● 定义实例变量
    ; u1 _& i* Q2 y5 j6 M! c
  2155.   #--------------------------------------------------------------------------
    + B% J3 h+ I8 q, ]
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
    ! k6 |2 e% F, O& H4 r2 g3 k
  2157.   attr_reader mouse_map_y # 同上/ V$ b/ \3 Q; L# l7 V
  2158.   #--------------------------------------------------------------------------$ q" F! u0 w2 }
  2159.   # ● 初始化对象' M& S7 y. e; H% _- _
  2160.   #--------------------------------------------------------------------------
    1 U7 W" o) r' U7 f- n- q
  2161.   alias sion_mouse_initialize initialize
    6 O1 j0 N/ Z4 ?% c7 a  j- ^# ^7 S
  2162.   def initialize# D/ g+ m* q$ A( D% c2 M/ E
  2163.     sion_mouse_initialize
    0 e9 u1 g9 D0 p# _& a( B2 j
  2164.     creat_move_sign  ###! @4 K  w- P+ e: q8 w8 K( u+ ~
  2165.     set_constants
    % x) c5 w' R( l- m
  2166.   end* v! U6 i4 S7 b; M2 T
  2167.   #--------------------------------------------------------------------------/ a& p  x. d; A* A1 Y
  2168.   # ● 更新画面5 j# D4 Z2 h" D' K2 l; B8 P
  2169.   #     main  事件解释器更新的标志4 K2 O7 b8 f( a- T# g
  2170.   #--------------------------------------------------------------------------
    ) O* b' e, C1 n) G/ q9 }
  2171.   alias sion_mouse_update update
    ; K  m  q; m' A9 s  Z2 o1 A
  2172.   def update(main = false)
    # R% }: P! R& L+ Z) ^9 z/ h
  2173.     sion_mouse_update(main)$ \8 O+ J4 x  f: q
  2174.     update_move_sign5 J: F' K9 ^, _2 J
  2175.   end. N5 d% ]3 n4 [6 x6 E. c# P9 m
  2176.   #--------------------------------------------------------------------------  ?" ^7 p; E1 @. z+ H5 a& [
  2177.   # ● 创建显示路径点的事件- ]% p6 j: ]5 s: J0 |
  2178.   #--------------------------------------------------------------------------7 c! G  }6 y; n: {% Z8 r
  2179.   def creat_move_sign5 j) I% [3 Z9 j) m2 y) s* j5 O
  2180.     $mouse_move_sign = Move_Sign.new
    . B) C3 t6 h) e) t# ?* i# \
  2181.   end2 K$ |0 \* N3 ~4 h" x
  2182.   #--------------------------------------------------------------------------# V/ G8 W! M5 `% E, D
  2183.   # ● 更新显示路径点的事件; c/ J' s  K7 b2 [" _5 l
  2184.   #--------------------------------------------------------------------------/ _7 X/ [4 d8 s& t3 \0 i- F
  2185.   def set_constants
    3 |# |+ }8 R  [# O# `8 g7 T
  2186.     @mouse_pos_setted = true
    $ i' {4 o2 Z4 O7 u' g3 ?
  2187.     @set_pos_prepared = false( c* w" P  Q& I2 f1 W2 H! D
  2188.     @mouse_old_x = 0
    & t$ P0 ~. d+ `1 G3 }6 C
  2189.     @mouse_old_y = 0
    6 D& E. m) M- \
  2190.   end
    ) ~3 z1 d6 p) \* w. ^
  2191.   #--------------------------------------------------------------------------5 Z. V2 `6 `  ~/ t% @- _
  2192.   # ● 更新显示路径点的事件0 L; C; I' u" ?
  2193.   #--------------------------------------------------------------------------
    / c% z) l* S8 E. D$ q" q" _
  2194.   def update_move_sign7 c2 v* A( X1 G4 ?: e. B1 f! w
  2195.     $mouse_move_sign.update
    ! N: U6 m8 w6 ]. M  F  I8 U  b+ j. F4 D
  2196.   end
    5 u  m" ~6 i+ ]! o+ I: O- V
  2197.   #--------------------------------------------------------------------------
    0 i; J# X8 K4 S$ i: e
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    7 s+ b2 T+ S2 e& f: ^
  2199.   #--------------------------------------------------------------------------
    ! p* n- H8 K1 K; f9 T  W. \
  2200.   def get_mouse_map_xy
    8 u8 ^( O4 s' c5 q5 F! X: G
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y0 |+ Q* h% W2 v2 Q* ~- G
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)# i( O, e- C/ f) V$ Q/ P: U
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    2 r8 z# E2 x! K" A
  2204.   end5 A. {, u% M2 ?/ N, T$ T1 ?  U% ^
  2205.   #--------------------------------------------------------------------------6 g" W6 \& v. Y7 p+ }5 p4 `
  2206.   # ● 返回地图画面时重设鼠标坐标
    ( Z: a' z- f2 h  q
  2207.   #--------------------------------------------------------------------------
    5 M5 |$ A/ J% l% q
  2208.   def reset_mouse_pos
    # u* T5 T& O" t% ~3 s3 P7 k
  2209.     return if @mouse_pos_setted6 I" `) n  k" m' S& Z
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)# ]$ D9 e$ z/ R
  2211.     @mouse_pos_setted = true/ b/ x* y0 x- G; e2 X* L2 O8 ?! l
  2212.     @set_pos_prepared = false; X; y  S! h4 n' T
  2213.   end4 C  l# O% N& }
  2214.   #--------------------------------------------------------------------------% Q+ |/ U: t5 C2 N* z  O
  2215.   # ● 重设鼠标的坐标
    7 V& _5 \+ N2 D' L! l$ n( \
  2216.   #--------------------------------------------------------------------------1 t% H. M9 D6 \# x
  2217.   def prepare_reset_mouse_pos2 z9 X- e8 Z1 U* a
  2218.     return if @set_pos_prepared
    4 X1 f# u+ R0 s0 X: ~5 B. q
  2219.     @mouse_pos_setted = false
    . A  x; b- w6 e8 I" q8 J
  2220.     @mouse_old_x = Mouse.mouse_x3 D( ?1 P9 M9 a+ e7 L6 t
  2221.     @mouse_old_y = Mouse.mouse_y
    ; Q8 {, \$ i- P# L* ~
  2222.     @set_pos_prepared = true3 a0 p8 P% O$ h$ f& B5 r
  2223.   end5 B/ Y2 C, j- Z2 D- c4 K  I
  2224. end( B) _: N& D: M
  2225. & u8 @& ~% y( s/ @
  2226. #==============================================================================/ C- @# h; W# T2 @/ o8 I  e
  2227. # ■ Spriteset_Map9 @8 c4 P" R7 {/ k8 E
  2228. #------------------------------------------------------------------------------- b) m6 }) W6 B' Z& o) ?
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    - Y8 M) z; W- ?' |2 Z- d
  2230. #==============================================================================
    9 ]: w: t8 h( C; l( ^
  2231. class Spriteset_Map7 n+ ^) c% B9 V3 k; ^4 |1 \
  2232.   #--------------------------------------------------------------------------
    ( P0 f8 ?- g9 a$ I: j
  2233.   # ● 生成路径点精灵
    8 n: R) ]8 |( w$ _* t
  2234.   #--------------------------------------------------------------------------
    6 H. n0 x6 _" y4 g3 ?; Y1 D
  2235.   alias sion_mouse_create_characters create_characters) A2 A0 C% u2 K; ~  O0 A
  2236.   def create_characters' q# h0 r3 I! }2 c4 N- x
  2237.     sion_mouse_create_characters+ A' J/ ?# E, Q" W
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    + X& f7 x3 n- T% D* s: q6 u
  2239.   end
    # p* D0 {, J% R4 _
  2240. end* o1 K. H  n1 ?+ z- \
  2241. % T+ X( q+ }& U1 L
  2242. #==============================================================================" X3 H# X/ u( e
  2243. # ■ Scene_Map3 \" f; o0 t. A, W
  2244. #------------------------------------------------------------------------------$ s5 Q% n( l+ j; A
  2245. #  地图画面
    ! e' Q4 U  L8 T# K' K" ^( r$ ^1 G6 U
  2246. #==============================================================================
    0 X. B1 v3 T) U; L& U9 K' r
  2247. class Scene_Map  Scene_Base
    * }( s+ r/ p+ R$ z% Y$ P8 n
  2248.   #--------------------------------------------------------------------------
    9 _& H: M6 Y7 \" s$ U- {7 z, G
  2249.   # ● 画面更新
    / b0 i6 S; v4 N9 G! o
  2250.   #--------------------------------------------------------------------------/ B( i6 n( e# J% |+ y& w
  2251.   alias sion_mouse_update_scene update_scene
    2 w: G* t( l, N4 O# m
  2252.   def update_scene* Q# Y1 |0 ^+ O+ d6 N
  2253.     sion_mouse_update_scene$ V2 O$ m' U. N4 J( a! q( ~% e
  2254.     update_mouse_action unless scene_changing1 x3 O  i. w. L, G1 R# Y& O
  2255.   end! h/ t) Z) {( l* d+ \$ w% x' {
  2256.   #--------------------------------------------------------------------------  k; g0 E& E" c/ k, B2 B# b5 l' L  C
  2257.   # ● 场所移动前的处理
    % [1 H) H& g8 d- `$ Z
  2258.   #--------------------------------------------------------------------------
    , k3 j$ v: g3 a& o$ `  u
  2259.   alias sion_mouse_pre_transfer pre_transfer( W6 L5 Z, u; J$ i( y
  2260.   def pre_transfer% I6 _: H/ c9 R) |5 S* R2 Y& F
  2261.     $game_player.reset_move_path4 C5 M; K, s8 b, M" R
  2262.     sion_mouse_pre_transfer
    * T5 z7 A3 z5 d
  2263.   end
    6 i, J1 R- X2 I6 O0 P6 h: i4 D& ?' _
  2264.   #--------------------------------------------------------------------------
    , _; C( X1 i7 P; _6 x
  2265.   # ● 监听鼠标左键的按下
    0 U2 d, J/ i* a; M7 Y* E! c( A
  2266.   #--------------------------------------------------------------------------3 L8 ]: q2 w8 v: R$ N) K
  2267.   def update_mouse_action+ A% a8 f# X: }* a& C
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    5 f1 j3 e% b. n7 v" l$ ?
  2269.   end
    % j' P. I+ M. a/ K, O5 N8 m
  2270. end9 p8 _' a7 v6 @; c' _
  2271. # U1 V1 {2 D8 o
  2272. #==============================================================================& |9 i! @) z9 B
  2273. # ■ Scene_File
    9 K( @$ W# H4 d- _
  2274. #------------------------------------------------------------------------------( S2 [* v0 e, t
  2275. #  存档画面和读档画面共同的父类, d# E6 Z, Y: U5 ~! C
  2276. #==============================================================================
    & T( d0 H7 v; u
  2277. class Scene_File  Scene_MenuBase
    9 O! F$ v# W" w& k) }# Q1 F5 }
  2278.   #--------------------------------------------------------------------------( M: p3 I1 A9 z+ j9 a8 l
  2279.   # ● 开始处理0 j; n) N1 o+ V# F0 v% G) H% P7 y- Z
  2280.   #--------------------------------------------------------------------------. n. f+ p# @9 X9 A. C" x6 }
  2281.   alias sion_mouse_start start
    9 U3 [7 y7 B9 L
  2282.   def start
    0 r2 {/ o1 o) g
  2283.     sion_mouse_start
    # Z" a- P5 G8 u6 u! L
  2284.     @move_state = 0
    : k6 {/ j4 d: d; b5 W: A4 ]4 W, m
  2285.     set_mouse_pos
    , s2 S$ c  E! q/ c
  2286.   end' Q# ^$ @2 ~- d. U$ @+ Q
  2287.   #--------------------------------------------------------------------------
    1 n0 n& a7 T! S3 q
  2288.   # ● 更新画面& u# A! A( ]! u" ?" W$ t
  2289.   #--------------------------------------------------------------------------
    " {9 w8 u8 p& ?( B- H0 T2 i0 y
  2290.   alias sion_mouse_update update
      D; E( N% w( a( h$ m+ p! L
  2291.   def update3 p$ \' w! ?# i0 u
  2292.     sion_mouse_update
    ; g$ \( n4 Q- N
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos4 u! E  i5 e' L5 ~/ u$ Y
  2294.   end+ P8 f# J' U; {$ y5 W
  2295.   #--------------------------------------------------------------------------
    $ c6 S$ K$ U/ |3 q
  2296.   # ● 更新光标
    ' ^$ ^; f: {; ~/ l6 O3 M4 b3 L
  2297.   #--------------------------------------------------------------------------6 b! W* D$ f  i
  2298.   def set_cursor5 l7 c2 \/ ?! M1 J
  2299.     @move_state += 1
    1 }# E- B7 ~/ d3 b6 g  O
  2300.     last_index = @index3 ^  _: m" [- u( `
  2301.     if mouse_which_window == -2- d% ]! X: p/ w6 B; E9 `$ ?
  2302.       if (@move_state - 1) % 6 == 0/ d8 {* P$ r+ |
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    9 o; b9 G3 N6 s# l
  2304.       end) V5 t% }  Q8 W' X$ t# h; ?
  2305.     elsif mouse_which_window == -1
    " `$ L+ \6 Z5 H2 s9 M
  2306.       if (@move_state - 1) % 6 == 0
    $ E# [  \. @% E1 o+ J
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    ' Z+ G4 M, z3 e6 E. T+ K8 [
  2308.       end
      i$ e) P1 X9 f/ _
  2309.     else. Y8 Q; m) R$ N5 Y( E( p2 i, g) o# O
  2310.       @move_state = 0  I% Q: G5 e- [
  2311.       @index = top_index + mouse_which_window# C: V" U$ n% x  A
  2312.     end
    $ A5 m' x/ T! E, Q0 Z2 w; Y' Q* d
  2313.     ensure_cursor_visible
    ) z7 Y4 g- [8 E
  2314.     if @index != last_index; c% U9 |9 |) M( o
  2315.       @savefile_windows[last_index].selected = false+ a5 u5 P* G4 q' C( H
  2316.       @savefile_windows[@index].selected = true
    . |- t3 E' }) g' k
  2317.     end7 c: G# n* C" @$ g& O
  2318.   end
    $ R) h8 o& ~& k$ i
  2319.   #--------------------------------------------------------------------------
    % @5 U0 a3 @3 s/ g- I
  2320.   # ● 判断鼠标位于哪个窗口
    ! {% j. N, ]- M2 n5 f  Q
  2321.   #--------------------------------------------------------------------------3 t9 {/ U' _4 _- l
  2322.   def mouse_which_window
    7 U2 |3 z5 c4 I/ V8 T: F" S$ ?
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ) \% V8 g/ M- v* R# m
  2324.     if mouse_y  @help_window.height + 14
    3 N: s* F! ?& ?- a
  2325.       mouse_row = -13 ]0 y5 I7 w1 t- J) G
  2326.     elsif mouse_y  Graphics.height - 14
    ; N$ l3 ^7 R% w( g/ S/ N8 L
  2327.       mouse_row = -27 J6 S( y# }( Y& K( p
  2328.     else/ h. L% F- b- N- o( d9 I1 T/ X  W
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
      @/ t# T: U1 Q! q( L9 G7 p8 S
  2330.         (Graphics.height - @help_window.height)  N! h( {2 z/ x2 I
  2331.     end! n3 B- w/ \. }6 W, E" X
  2332.     return mouse_row
    ! i, h9 }5 k! W0 v1 c- s+ j
  2333.   end2 Q2 V% C  w  M. @& u5 s1 p0 @
  2334.   #--------------------------------------------------------------------------! ^' P6 E, F1 j5 E
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    + q: N  b& P7 Z! ?
  2336.   #--------------------------------------------------------------------------7 z# N5 h0 q' Q
  2337.   def set_mouse_pos
    7 F! }) y2 F0 q9 P' g( V. A
  2338.     new_x = 40
    8 n% b+ w+ z( y
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    8 W1 n( N5 E1 m3 O
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    9 [* N  P) o  e6 [8 t
  2341.   end  t1 W4 k. Y- N' u9 B
  2342. end7 _& u' d5 A- W+ w

  2343. & Y1 b$ N& p$ X9 o
  2344. #==============================================================================, |2 m. Y% [5 {: P/ T0 X
  2345. # ■ Game_Event0 O% e2 t" I7 }& t8 d. {9 i
  2346. #------------------------------------------------------------------------------3 n2 }9 T' F: i) z
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    : ]: v4 U4 |2 T0 ], e5 O3 f
  2348. #   在 Game_Map 类的内部使用。
    + c1 h: F/ E# s8 d% b- S$ v% c
  2349. #==============================================================================9 y2 |- Y2 f9 I; F/ c0 K0 n9 H# b
  2350. class Game_Event  Game_Character0 n; W4 m# q% O2 f
  2351.   #--------------------------------------------------------------------------+ L/ h) C: O! [+ h
  2352.   # ● 事件启动
    9 t3 f) ~2 E- x0 \
  2353.   #--------------------------------------------------------------------------( w( b# O" d4 e5 M+ @3 K
  2354.   alias sion_mouse_start start
    - _: g5 w! }& k" D: g3 p) Q
  2355.   def start
    " D6 W- k8 [- Y6 {. t4 J
  2356.     return if mouse_start && !Mouse.press(0x01)
    7 ?. x: p# b/ }  c  Z# }
  2357.     sion_mouse_start
    & m" {# ^# N8 o1 U6 i+ K' {
  2358.   end% k4 ~6 h. V& y& j7 D
  2359.   #--------------------------------------------------------------------------
    : f5 S$ [2 w9 x8 L6 D4 |: |
  2360.   # ● 判断事件是否由鼠标启动
      O6 s) u$ B; t. D; E, X/ D
  2361.   #--------------------------------------------------------------------------
    6 c0 U* P* u% X/ t% _. V8 N) z
  2362.   def mouse_start
    * X% I: E9 \- X' P- |0 N
  2363.     return false if empty
    % ^. r$ X. q/ k9 {5 U
  2364.     @list.each do index5 B$ t- ~( t) y8 _  E( m
  2365.       return true if (index.code == 108  index.code == 408) &&4 I' R. w' r2 \+ s2 f+ G2 ~
  2366.         index.parameters[0].include('鼠标启动')
    . z# t0 ]! p2 V8 h
  2367.     end4 j$ p. J/ r3 c) B
  2368.     return false( V6 }7 Y# Z7 q+ x6 r
  2369.   end; P2 [+ B( @  t% J' N  J
  2370. end: d8 K2 r& A( j# f  j: R5 T( ?
  2371. ' J+ X+ j% z: {3 I0 a- n; r8 c
  2372. ####泥煤的height0 e- z% l) t" e: w5 K, d; n8 M- S4 Q6 X
  2373. # @height = height% }  _' }: X  A) I* z) g3 Z5 h

  2374. " a4 G! V' [2 _% z; i! Y0 `
  2375. class Area_Response- A1 S7 m1 s. W+ N+ {2 F
  2376.   attr_accessor type# `; P; t, q# A4 X0 N7 p
  2377.   attr_reader ox
    ; l6 l( G( d* q& v& s- R
  2378.   attr_reader oy
    , ^1 w/ {( Q: h  T
  2379.   attr_reader width
    3 O! u2 g0 V4 I% K1 N) j; \
  2380.   attr_reader height
    , m+ y" S3 h) P% h; q) D
  2381.   attr_reader switch_id
    ; s# a- r- d. u
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)5 W, H9 `% q9 y3 R9 [
  2383.     @type = type1 n2 G7 b1 M2 m' s! G
  2384.     @ox = ox1 o- P4 c" T7 `& b
  2385.     @oy = oy
    8 s5 Z: Q  _1 `5 g. Q& @6 U
  2386.     @width = width& k$ d& s) n$ T& U
  2387.     @height = height; x3 y/ w- x4 e/ b1 c7 u& B# \
  2388.     @switch_id = switch_id
    , j, _) x. o* M* h  ^3 j8 Y5 i; Z* I* [
  2389.   end
    4 Q. U3 e+ t# p1 c1 z4 s8 _3 q
  2390. end
    / r  U: n- g* H7 G9 X+ q5 h; o# h
  2391. " u; n- z; H: I
  2392. $area_responses = []
    , D! b$ m: s: j" n. X9 E6 k1 ]
  2393.   t6 h/ D1 L& G0 j
  2394. class Scene_Map9 _+ O- y3 V1 G$ B% o2 v
  2395.   alias update_mouse_2013421 update_mouse_action3 |; @, |7 T2 I, S) T3 I/ u- i. K
  2396.   def update_mouse_action; \7 y! G  G; |8 W; ]
  2397.     update_area_response
    % @% k3 h2 _; F: A
  2398.     update_mouse_2013421. I4 h  f" A+ N3 Z
  2399.   end6 Z- ^" ?( d6 |' `6 F
  2400.   def update_area_response
    " q* |% j# _, J6 x& e
  2401.     responses = $area_responses
    1 l/ U0 A7 c" {7 _- o2 r, h% G0 |5 {
  2402.     responses.each {response% }* P# V+ U1 i! Y4 L
  2403.       ox = response.ox/ I6 ^( W% H* p0 d5 |
  2404.       oy = response.oy
    : u  E& l7 Z  e: Q. F% K
  2405.       width = response.width: K: o( T3 ?" c6 ]
  2406.       height = response.height4 A! B" S6 p2 h9 S2 [
  2407.       switch_id = response.switch_id
    / N* A5 u* D4 V5 K* p$ g
  2408.       case response.type
    8 a% u2 H" i- a. `* F* n- M8 j
  2409.       when 0- `( M+ [; O: i' C+ M( o( u
  2410.         if mouse_in_area(ox, oy, width, height)% G. d5 [' S" p# F/ K2 n
  2411.           $game_switches[switch_id] = true* Q: P2 R5 C, }0 J# o9 j3 v
  2412.           $area_responses.delete(response)9 E7 B2 Q4 l* N  D7 r* ^4 O
  2413.         end
    4 E/ v: v) l1 V2 v1 n' }
  2414.       when 1
    9 `8 \4 P1 K" V% G% s/ N
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    $ D; z+ G6 `5 z5 b6 y7 `: v4 Q
  2416.           $game_switches[switch_id] = true
    ! u0 @. N0 ?: a( s/ A  {+ d+ I% J
  2417.           $area_responses.delete(response)
    + o. V' L: C" A0 G1 t5 w
  2418.         end$ ~6 h/ u+ |( ~
  2419.       when 24 z' d, z; A# `0 v* E# s
  2420.         if mouse_in_area(ox, oy, width, height)
    ) n8 }4 a9 G) Q. [
  2421.           $game_switches[switch_id] = true
    " O1 |/ C# ]& V" |" h- L. w
  2422.         else
    ( r$ R" G4 x9 t3 w3 o2 t  b
  2423.           $game_switches[switch_id] = false, c0 S4 f2 L! G# g0 W& k
  2424.         end
    * q- \7 i, _$ S, ^- s: I( x
  2425.       when 3
    ' }$ a& v% p: H+ i& s
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    7 t9 S9 O+ Y! ?3 A3 ?9 }5 X$ F5 [
  2427.             (oy - $game_map.display_y)  32, width, height)
    0 p0 {. \) e9 ?
  2428.           $game_map.events_xy(ox, oy).each {event
    * D1 x" U/ J* K, M
  2429.           event.start( H0 ^3 e( d4 Y% ^% q# H
  2430.           $area_responses.delete(response)
    5 c, H7 z& U/ u8 Y& o
  2431.           return
    : S. Q/ {5 `$ p- x0 Y
  2432.           }
    2 O1 j  ^/ I8 t' Y, k8 K
  2433.         end
    / P7 M  F) @4 l# T7 s0 H
  2434.       when 4; @7 ^6 i7 q7 d' o! k+ Q2 w
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    : v' J4 l2 B' h" A! ]/ {2 y
  2436.             (oy - $game_map.display_y)  32, width, height)& Q7 C% m5 H5 E- J$ }
  2437.           $game_map.events_xy(ox, oy).each {event
    2 V% |) Y1 |/ d$ u0 p% E0 w$ V
  2438.             event.start* J# f, x1 Y' c* v$ X# D! I) W2 i- U: d
  2439.             return: _1 N% W0 r5 W7 t
  2440.           } , a2 Z4 k' D6 G
  2441.         end0 M/ e  n* e' v) c% t3 y; b7 y
  2442.       end  z6 S- Q$ t4 O% j- A1 [! S* t& j
  2443.     }5 v7 S, ], z: \# g; k. t1 u
  2444.   end$ G" y+ Z+ Y1 ^9 l
  2445.   def mouse_in_area(ox, oy, width, height)& S) A+ F" F" h; z8 t6 \
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    # N5 x$ M* E$ W; R
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height* [- I9 R/ @" c: x( U" j) a9 W
  2448.   end! I: K" M4 O" [% Q- J
  2449. end
    4 Y( @' D/ d9 x0 `7 |9 N3 v2 W& O. ^
  2450. class Game_Interpreter
    : u! j- F4 V- F( Q! w: S
  2451.   def area_response(arg)
    4 }' D; M" K& Z$ A
  2452.     $area_responses.push(Area_Response.new(arg))
    - I" a& Y  w5 x4 g; J4 U
  2453.   end% {, h- S; @8 o
  2454. end3 y) Q! f2 D0 {1 z2 [" o3 f
复制代码

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

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

GMT+8, 2025-10-31 02:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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