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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================  @; d8 p! `0 d! Z9 H
  2. ' [! S- S7 I1 J! V( K6 ^" w
  3.   Sion Mouse System v1.3e
    * ]7 v9 x1 m0 `( J1 t1 c) m5 k* I
  4.   
    , h7 K; F0 n7 p% S' {
  5.   Changlog
    5 w8 I: s3 U& N6 _7 c' p
  6.   , W3 Z  d8 L) r7 H* u: x& a. ]7 X3 t- `
  7.   2013.4.21 v1.3f& ~. W; x5 q/ L# I; W: P
  8.     4 q( [, W+ `& i  Z
  9.     1.3f 卷动地图 bug 修正, K, e. X* L# ?7 B; |
  10.    
    3 \/ |) L6 j5 g# i1 f( @
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    ) B- D( v1 r2 X1 O  }! g$ h
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内7 g$ j5 F# @) a6 {) ?
  13.                               Mouse.unlock_mouse_in_screen 解除锁定9 t8 \" T5 u1 K

  14. # d1 ~8 U; ~1 u: B; w4 c% V
  15.     1.3f bug修正
      `$ m+ Z# d$ F; k
  16.   # Y6 f$ K  U; q, [! @
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及* u) U0 `# Q1 [5 B, Q$ A
  18.           关闭菜单时,鼠标是否移动到原来的位置。, J6 _; K; a9 ]& V1 w0 w! U
  19. 8 G) u$ E- ?* P9 l1 h
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处  Y3 n5 W8 s/ V' v' F
  21. 8 U. q% f2 M$ A7 y" P
  22.     1.3b 修正一些罕见的bug;
    ! h$ s! ^7 i$ @0 c9 y" Y0 z

  23. / G$ G# B& }6 S; ^, n; E2 d
  24.     1.3a 代码小修改;5 r6 r, P0 L, ?, ^+ C$ ]9 W8 ~: a
  25.           加入了鼠标点击启动事件的功能,& I( o0 v5 t3 @3 c! ]4 z
  26.           在事件中加入“注释”: 鼠标启动  ,
    0 X  B) y- L; ?" ]0 B
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    , c- V1 T( _( f) |1 h) ]
  28.   " O5 z% g/ _, @' `4 |0 }
  29.   2013.2.12 v1.2
    + t1 C/ \' @$ Q6 q2 u

  30. 3 c" O+ I6 A. a3 D
  31.     寻路逻辑优化;. J7 `$ t2 w, {) N# ?# o* I. o
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    5 V3 k5 M. s* j) \) R' d( j* x! e5 w
  33.     现在支持用鼠标来操作载具了。
    6 m/ [# a1 a0 x

  34. 9 W! r5 t9 s5 E7 U* ]
  35.   2013.2.8 v1.1
    & f- r+ N4 Z' q

  36. ) t& R+ G: d, ]5 `/ A7 `- s
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    8 Z; h# A* b- p4 Z8 A/ l3 @0 ?
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    8 M+ |  L" J0 O
  39.     移动时,路径指示点的绘制更加稳定;- c; H# |9 _0 K2 u2 O! Z
  40.     现在支持默认存档画面的鼠标操作了。9 S$ X6 R* k: V2 @$ s
  41. # k( t& w  e3 Y7 ~
  42. 0 c$ }/ A, ?7 U8 ]2 \- _# [
  43.   OrigenVersion" A& G& U) u9 F, L, \$ ]
  44.   4 w" i4 L& P) a( u; W9 ^- p+ P
  45.     2013.2.7 v1.0 $ c+ ~9 f. e: x7 H/ R) l
  46. & m& K2 L9 L3 K
  47.   主要功能
    ' V7 y8 v8 L7 }5 q8 k4 y$ [9 p

  48. 1 r0 k2 c  q( D( G% @
  49.       使用鼠标进行各种操作...- R- E4 Q) V/ e6 q/ y2 [( u* E7 y1 W' y
  50.       将鼠标锁定在游戏窗口内2 b; L* w) }* A# _+ u' h% A; j9 n
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    . p5 Z8 v; t6 A5 \! V" F; _6 d; p4 j, H: a
  52.       双击鼠标进行冲刺0 v2 W1 L- B( k' R+ m; L$ Z
  53.       更改地图卷动方式以适应鼠标移动
    " V7 ~& P) |: h7 q
  54.       变量输入框改良0 m; @& Y- G2 p5 @$ c' d; \9 F- y5 h

  55. 9 S. D% S  x5 \; K: z( X6 U# i
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹5 o- ^! V$ f3 m
  57. 2 V. M) H" q/ V2 s7 {* ?
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    3 S( x7 j3 o% S% J
  59. ) w0 K: Y0 }# ^9 i9 r) ~/ h# p
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    ' m8 _0 _; j) v# r. o* ^' d
  61. # ^' W( L, T, d- ]

  62. 5 M: L% |/ J- l8 _
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    - b& d$ S0 w  ?1 c( J3 `

  64. 3 l% r" O6 d  T2 y2 W2 ^/ q% D
  65. - J6 _: k0 e3 H% o
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示( z+ u& T" h+ G! \4 I$ A6 l

  67. ( W6 g5 l0 U! M* i( [' d& J
  68. #==============================================================================
    + j" `5 I  O+ ^5 `$ y- [, o
  69. # ■ 常数设置 . O/ b! o3 K7 r7 X
  70. #==============================================================================
    ! H/ N3 n, P( ~( M
  71. module KsOfSion7 w+ U# a+ a  \% A% |% l: E/ u& F
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false1 j2 f, \" @- Y( ]% a0 U! N
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    % X! n4 y8 q( Y& D9 Q5 u! i% u" u
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    $ ]! d% _  W' R! L
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    - [1 R$ u  D3 C& D
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处1 Q+ P7 v; K6 F# a
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    5 {& z! N+ ?4 ^
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    # l) j4 N; K" |% \5 ~+ U' f: r
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    . g9 {: Q" H/ P2 |& `% o
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)0 _  q" D3 p' p, f# ~' A! L
  81. end2 y2 u1 K6 o6 h' Y) D

  82. : Z* f% W; b5 A$ }: d8 c
  83. #==============================================================================+ E, `5 {) G% P% M& x
  84. # ■ 用来显示路径点的类4 ?3 v* a) {! j! r2 t
  85. #==============================================================================/ C. f; r, Y! i2 J
  86. class Move_Sign  Game_Character3 m* p7 y1 q& L1 l% n! Y. ]: i5 T7 y
  87.   #--------------------------------------------------------------------------
    2 k5 i7 N+ u4 |. \  `4 e3 N0 B4 P
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图6 S4 K7 F7 w. p4 o$ l4 n  a
  89.   #--------------------------------------------------------------------------$ A. P4 Y; C7 R% j4 @0 [
  90.   def init_public_members8 M: l/ M4 H/ w; r- X( I. x5 ^
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    1 T- J! U" P& B$ h
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    " n" c& ~" N8 q& v, `- `3 O6 [
  93.     @move_speed      = 5        # ★ 踏步速度  D" U% L# r- [6 M! N0 L
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    5 Z6 j! b6 X/ c: S5 }
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    9 Y4 ~! u: B4 v5 D" Z- l6 E
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)# w1 N2 u& t9 K! z& G; {0 ]9 c
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    % d( q- |# ~/ o- Z: x- ]: J2 s
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    ( @3 `  q! l8 R; J& R1 S; c
  99. 1 d) n$ M0 P$ \1 y. e
  100.   ]4 C9 l8 ]6 B* m6 X; J9 J
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    ' ~1 h0 d, E; q% E& ^

  102. " y3 i5 @) v% Y* r7 R
  103. : F: i2 m; q* Z
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图' K& b- G! S/ E9 L
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')" s: U. _  x% `% R

  106. + ?% }7 k1 f: M' ~9 u5 K% t9 Y4 c
  107.       if $no_arrowpic_warn
    6 Z# ?% z7 u. a/ O
  108.         MouseShow_Cursor.call(1)  |. b3 e7 E3 w* x2 M. B
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png9 ]& |' T* H8 _+ p8 R
  110. 8 H& Q! L5 B0 V# r$ j: K% O  D
  111. “路径指示点”将使用游戏自带图片
    : N  c* Z. [$ s) Y
  112. # {0 S6 C% k9 B. {
  113. 该提示可以在脚本内关闭')
    ( m, |' i, c0 ]' R2 F& P2 \+ g
  114.         MouseShow_Cursor.call(0)+ ]( j' u) M+ v+ d! g
  115.         $no_arrowpic_warn = false5 @2 V) p2 D* j+ |: u$ `% Q
  116.       end0 u2 O* W7 A4 R, H# r
  117.       @character_name  = '!Flame'5 N. m  e- a9 T" O/ _  m# d0 S
  118.       @character_index = 6/ V( Q" A7 \7 H* x# {) \/ U. a
  119. # o4 u; V' x/ ~% q9 O: z
  120.     end! T- m0 z3 {$ P/ V4 Z, \
  121.     @direction_fix = false  # 固定朝向5 d8 A- I2 ?( U& b+ I
  122.     @move_frequency = 6     # 移动频率
    6 I* w) I; s) Q# V: P- E: S: N& I
  123.     @walk_anime = true      # 步行动画+ j3 w* @% f& n
  124.     @pattern = 1            # 图案' J" n: [' d. V- {% _; n
  125.     @through = true         # 穿透8 H3 V4 L2 X* Q) u
  126.     @bush_depth = 0         # 草木深度
      D* v; V/ d4 n* C! c& q7 t
  127.     @animation_id = 0       # 动画 ID) V/ ?9 l; |/ }( Z7 i
  128.     @balloon_id = 0         # 心情 ID
    ; ~8 l/ D) a( W. _
  129.     @transparent = true     # 透明2 j( ?; r3 B% o! [; E, y2 r
  130.     @id = 0
    $ C/ z$ s5 p$ _) j; N
  131.     @x = 0- l6 n6 }# ^# Y' x8 u
  132.     @y = 0( t% F/ f% S, ?9 {  ^8 u% r$ I
  133.     @real_x = 0, m; ^# ^3 B; t1 ~" }% e3 b
  134.     @real_y = 0
    * z% X# Z1 J# r6 l
  135.     @tile_id = 02 o+ @8 _7 ^( N, ~9 b; [! n% a# j
  136.   end
    ) e. j# L/ w# f/ Y- |/ {1 a
  137.   #--------------------------------------------------------------------------5 V2 L6 D3 r! E0 t' Z+ d5 y
  138.   # ● 定义实例变量0 Q7 X( t# I( Z9 g) w
  139.   #--------------------------------------------------------------------------$ m1 L) @( w! x' E
  140.   attr_accessor direction3 M( ^4 j: c. E, a( U/ ?
  141. end
    , M9 F& ~2 [$ E) r

  142. % b3 P5 m* P1 b, c0 f9 Q$ m
  143. #==============================================================================" t9 b/ ]& K2 W
  144. # ■ Module Mouse
    3 m: `; D# }5 I" B5 d8 I- E) ~" X
  145. #==============================================================================
    ! P8 |( \* u( ~5 p' _
  146. module Mouse
    ) F9 c, ]% c6 e# _; m: ?7 u2 C$ P
  147.   #--------------------------------------------------------------------------
    2 k, ^* S) J2 l. x9 A% Q& K
  148.   # ● API' g5 S6 ~% E% M  ?* H4 A/ ~9 w
  149.   #--------------------------------------------------------------------------
    ( i# M7 w5 J% f- u
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')% u4 ]" v+ d! ^% f
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')4 {/ C) B9 ~! ?. O3 ^
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')! \) z. T7 a1 p6 l" L- b
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')5 A) i: T6 l! |* q  S
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    1 A- M' G, ]/ y" Q% F# T
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')( J: O% C* }. U6 U! M& u
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')9 m3 n0 j* ]* J7 M2 x
  157.   Window_Hwnd       = Get_Active_Window.call
    3 n$ R, ^  v8 L! g! d/ H7 t
  158. 9 y9 b9 N6 C- E" m4 N& q
  159. class  self4 [# S& s" ?. X0 I' V
  160.   #--------------------------------------------------------------------------$ m$ b" Q! S9 y! `- z
  161.   # ● 初始化
    8 [. }. C; u1 k: l* k5 j% _/ u
  162.   #--------------------------------------------------------------------------
    8 i" T$ r" L; A0 Z) [; \- [
  163.   def init
    ) e3 ~1 W4 d8 ^' [* Y
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor* t0 a; b$ g3 z0 I3 m5 P' `
  165.     @left_state = 0
    7 Z3 }6 N3 {3 ~, w0 l
  166.     @right_state = 0
    ; V( q! b# S6 h* a! w; l1 }
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    2 I" T% H# [8 L& T0 H# M+ q2 s2 y! n7 v
  168.     @dk_count = 0 # 用于双击的判定
    9 k' \8 E1 z4 m! P4 [
  169.     @clicked = false( T- t* U! a8 H. P/ N; M/ d: O- v
  170.     creat_mouse_sprite/ v# p- M: y5 U/ n; G6 q5 K# K
  171.     update0 P- Y0 R6 n+ Q; h8 ^
  172.   end. T0 U% ?6 c) S! S. z' J
  173.   #--------------------------------------------------------------------------
    % P6 [3 @+ V+ Y* \/ i# Q5 g8 l* d
  174.   # ● 鼠标指针精灵6 R4 x0 N) H; F9 C) O& ]) m
  175.   #--------------------------------------------------------------------------
    7 `( R! B* ^& b! `
  176. #~   def creat_mouse_sprite' j7 ^% T% p+ K& e
  177. #~     ) A, L$ d! ?# j0 G: J$ K+ F9 h
  178. #~       @mouse_sprite = Sprite.new5 o1 Q2 [  C/ ]: G5 J! ~9 M( M* F
  179. #~       panda = 2#rand(2)+1
    " x# X0 ]7 O! h: o' v5 w

  180. ( h. A5 V" ?) N+ s
  181. #~      if panda = 1
    / y# @( n& t$ U
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    . ?% r5 j: K( [* L- b# Z% O. ]
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')' x' b# |: M" Q9 D% r
  184. #~        end#with if File.exist
    & p0 `. j* y1 l+ b. A/ y" q; m
  185. #~    2 [% ^' A1 p$ Z" M
  186. #~     else if panda = 2 #with if panda=1
    4 ]  k" z8 O6 ]1 S; ~# h
  187. #~      
    % S: x# ?* U" k5 U
  188. #~      if File.exist('GraphicsSystemCursor2.png')+ Z+ e0 H* K, [3 w% K
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    5 z8 g% l8 l! P; U  O/ u9 @& E
  190. #~      end#with if File.exist* F- O0 P# S! ?" v0 \3 m8 O# g4 v
  191. #~      
      @7 g( K. p$ \$ d$ H3 k
  192. #~     else #with if panda=1* S( `# E, J% P" K
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    7 t0 R$ N  e" O9 Y/ h/ a' L% q
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),. x7 J; X' W( Q7 X0 B9 c
  195. #~       Rect.new(5  24, 24  24, 24, 24))) C, x& M: _0 r
  196. #~     end#with if panda=1
    - [! Y+ T* q# U# V
  197. #~     
    ! h8 Q5 }* y3 d) f3 B; a; I
  198. #~     #with def; Z; ^  R, W" s7 ~& w
  199. #~   end0 O$ i/ F' D: T% V2 E1 ?
  200. def creat_mouse_sprite
    0 g+ O1 m& p* \2 z
  201.     @mouse_sprite = Sprite.new
    , A4 `0 _: \/ q
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})+ J8 F. G3 s  z+ h
  203.     @mouse_sprite.z = 9999  g  S- ?2 n9 R* N5 {& R# B, {
  204.     Show_Cursor.call(0)
    3 H6 T0 B) Q1 ?
  205. end# N3 e1 B% h! a; k/ b8 k
  206. + x; b" ^( }6 ^; P
  207.   #--------------------------------------------------------------------------# W, b2 K% y2 Z" o
  208.   # ● 更新
    - R- b8 Z9 a& V6 R1 ?2 J
  209.   #--------------------------------------------------------------------------$ v; R$ p% b1 v2 e' L. @5 x
  210.   def update8 C  F3 f" D5 G- W/ ~1 W
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    7 ~/ g( W! A" ?1 L& p  Q
  212.     left_state  = Get_Key_State.call(0x01)
    $ b& F3 K+ Z0 j/ d$ ^, u' h
  213.     left_state[7] == 1  @left_state +=1  @left_state = 01 B1 T; ?8 q7 L8 U
  214.     right_state = Get_Key_State.call(0x02)( p1 t9 j2 R( M6 y* S' U
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0: N$ O9 _2 e& U- F+ I9 ^- ^+ z+ ^
  216.     update_double_click
    ) P; O+ V4 r7 \1 _& B
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    / e; J" I* ]  x' K% O+ X4 t# ?
  218.   end
    9 w4 _/ Q1 {' l# I1 u, n( j
  219.   #--------------------------------------------------------------------------- t6 A5 W" T$ F" [& F, u5 g( Y8 l
  220.   # ● 获取鼠标坐标$ b  a7 }) R8 Q6 d
  221.   #--------------------------------------------------------------------------# h. S. D& J& w5 F2 ]* Q) J; B5 Z
  222.   def get_mouse_pos
    1 Y2 F7 A7 c: y4 X7 j% m
  223.     arg = [0, 0].pack('ll')
    ) T! @4 ?  I; x+ W
  224.     Get_Cursor_Pos.call(arg), S& M6 F$ n1 a
  225.     Screen_To_Client.call(Window_Hwnd, arg)7 t7 C7 d! _4 L# Y$ a" p
  226.     x, y = arg.unpack('ll')
    " m$ v  A% G& {. [; V3 y
  227.     return x, y
    9 [" s& I! U: Z( v7 Q; s
  228.   end
    . N2 C+ b3 \- w, S: @0 `
  229.   #--------------------------------------------------------------------------
    , I" ]1 |. S: M- l8 {6 l
  230.   # ● 将鼠标固定在屏幕内- ?( N& S) H5 M% C- H# Y
  231.   #--------------------------------------------------------------------------4 |! M. C/ W; e% r) N9 l
  232.   def lock_mouse_in_screen( \7 g2 V7 d( ~$ L* l! K
  233.     arg = [0, 0].pack('ll')
    2 |# i# S0 K: ^/ _3 Y) V% w
  234.     Screen_To_Client.call(Window_Hwnd, arg)" P9 A7 R" J$ a- z: d  n
  235.     x, y  = arg.unpack('ll')
    3 X& b7 o/ |( ?; D3 x
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    " y8 A0 S2 J# ~# M
  237.   end
    1 l% }: ~* q/ w. X4 _
  238.   #--------------------------------------------------------------------------$ X+ f. U  Q+ P$ y
  239.   # ● 解除鼠标固定
    ; s. S1 d$ T* v% L
  240.   #--------------------------------------------------------------------------
    2 @3 v. k- G7 E3 b% n# |. i: [1 p
  241.   def unlock_mouse_in_screen
    0 H7 S( N3 a3 e# x  n
  242.     Clip_Cursor.call(0)
    3 f- F! R( y. ~6 e
  243.   end' G: d4 \0 B) i7 N% S  Q
  244.   #--------------------------------------------------------------------------
    0 m, j. A. c. e7 q' C
  245.   # ● 鼠标双击判定
    . o3 u$ e: s1 `; k9 }1 W' E$ G
  246.   #--------------------------------------------------------------------------
    5 R+ W$ F2 J! d9 x+ }
  247.   def update_double_click, \: G+ E9 p3 w
  248.     @clicked = true if @left_state == 1
    & J) F* e' l9 ]- c
  249.     if @dk_count  0 && @left_state == 1
      V3 s& k- ]' _0 Q
  250.       @dk_count = 0; @clicked = false
    + o5 [: [$ ?4 x7 D4 p
  251.       return @double_click = true
    - d( L5 s2 r' c6 T
  252.     elsif @clicked  Z; U# q- C4 m; T; `8 Z
  253.       if @dk_count  KsOfSionDbclick_Frame/ z/ `, |( I8 }
  254.         @dk_count += 17 S0 q" i& I8 q# {; Q
  255.       else1 z& u8 F, i: J& E; ]
  256.         @dk_count = 0; @clicked = false
    1 s/ I) v8 I& q/ H
  257.       end* w+ P( S0 ^6 F( {% f  ]0 [
  258.     end/ I, v2 v& z  W' M/ e" M, Q% w. @
  259.     @double_click = false
    ( O; \1 X# t: [- F+ ~9 G% R
  260.   end: D& _& G! W) d
  261.   #--------------------------------------------------------------------------: e3 [5 c& X, W7 {
  262.   # ● 按键被按下就返回true1 m# z- K# X( C$ L- D$ o  M
  263.   #--------------------------------------------------------------------------
    # i$ z. t# r. k) u
  264.   def press(button)
    ' ?+ X2 e( |: J. u- @5 B0 v) u8 A
  265.     case button
    5 H1 K, T6 I+ ~" V5 _
  266.       when 0x01; return !@left_state.zero% P  b% a! u; N
  267.       when 0x02; return !@right_state.zero
    4 K" z/ s- Z5 C
  268.     end
    1 ^8 s* K! F. E7 h4 o
  269.     return false
    $ Y1 _8 G" {) M  v$ _0 R
  270.   end" P' w7 j% D- Y
  271.   #--------------------------------------------------------------------------+ }: \8 f% t6 B7 A6 K
  272.   # ● 按键刚被按下则返回true
    3 g  E+ w/ E. I5 h0 o- h2 {  ?  C
  273.   #--------------------------------------------------------------------------
    : R! U& \1 |* G! h8 l6 ~9 P4 T; @/ L
  274.   def trigger(button)
    0 c5 h- u6 R6 `* Y0 ?; t# l3 ^
  275.     case button  e- @% P/ ]- a2 `
  276.       when 0x01; return @left_state == 1
    ; e% I( @2 R* U& ^* j
  277.       when 0x02; return @right_state == 1
    ) W5 ~+ x' A$ I# B0 {
  278.     end- e( b- N5 Q1 N; @) \% i  l
  279.     return false( ^* f5 D% a, b* L$ m& L* f
  280.   end9 |# E, [! E' `. G: ^5 S% I
  281.   #--------------------------------------------------------------------------
    * N9 a2 I. q, y) S
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    ; b* Z; K* \; E7 m( \
  283.   #--------------------------------------------------------------------------# g, x3 G8 r' W; a9 Z1 u% [; V
  284.   def repeat(button)* j/ U1 u( Q6 [/ p+ Z; G& m
  285.     case button
    , D- y+ h9 e; o  t$ w+ ~
  286.       when 0x01; return @left_state == 1
    % v3 P' L8 B' B2 x( |
  287.         (@left_state  22 && (@left_state % 6).zero): S  y8 w( c6 x0 O
  288.       when 0x02; return @right_state == 1
    ! M( M* R$ L! c  Q8 s
  289.         (@right_state  22 && (@right_state % 6).zero)% l( U' e! z" ?/ u3 S, M
  290.     end: i4 z+ v: `- y* m) T& p7 l
  291.     return false
    9 U! z2 p: ~. R& i1 P# \; A
  292.   end
    $ W& j" j& w2 w/ o7 |8 n
  293.   #--------------------------------------------------------------------------" V& q; D+ O) O& ~$ g
  294.   # ● 判断是否双击鼠标5 ]9 M5 I, }( X# A
  295.   #--------------------------------------------------------------------------
    " [0 t$ o5 a- m! _6 c$ s6 X
  296.   def double_click. U' C# @3 D, E7 ?
  297.     @double_click2 l8 q6 h- `/ k  @, o: Z8 i9 u  g
  298.   end
    & U! m# D4 T* M: u7 b9 X8 a* d8 N
  299.   #--------------------------------------------------------------------------
    1 ~' Q# J' |  B. i- @% ]: ]% u
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    : u4 k: {) U4 C1 v6 e) ]
  301.   #--------------------------------------------------------------------------
    ' g5 V3 u8 I1 J. Z
  302.   def click_count8 M4 u- P$ q( A) z8 L( g
  303.     @ck_count
    . }, f# O) D5 f7 I
  304.   end
    + d0 s4 i! A; {0 r
  305.   #--------------------------------------------------------------------------3 B* O: U. h, g7 }( i' U' _- \
  306.   # ● 获取@left_state(按住左键每一帧+=1)9 v5 i: p+ W0 p$ N
  307.   #--------------------------------------------------------------------------  q* v; l- \* K- c) b5 e8 H
  308.   def left_state
      O( Q* v) T7 \$ u# c
  309.     @left_state' h& ~% A3 v0 P3 \3 _4 R0 J
  310.   end: t( V; O# d9 R* p/ D1 U! s
  311.   #--------------------------------------------------------------------------% |  N9 o" n0 K5 O/ L
  312.   # ● 获取鼠标的x坐标6 Q. T4 J4 [0 z: C0 n: R( G! z
  313.   #--------------------------------------------------------------------------
    : j$ q$ U' S+ Y! f& `
  314.   def mouse_x
    7 K/ e: L) t& r4 ~5 @$ L: Z
  315.     @mouse_sprite.x
    " f# H. a1 V3 i4 }: [
  316.   end% J- x, |* Z0 o, {3 x/ p! g
  317.   #--------------------------------------------------------------------------
    + _* {3 V) ~  \" B0 N5 h
  318.   # ● 获取鼠标的y坐标
    ) N" O5 R! q5 K
  319.   #--------------------------------------------------------------------------7 P4 V6 t- Z2 Z5 K! E# h. p% X  N
  320.   def mouse_y8 j7 F) b: \0 \) U8 O% I6 @' v
  321.     @mouse_sprite.y' p# r! z/ ]3 ?7 S1 N3 B# o+ x$ _
  322.   end
    9 p& |9 ]( O- M$ t
  323.   #--------------------------------------------------------------------------; j3 ?; [7 s# S; E& ?: c
  324.   # ● 设置鼠标坐标8 m3 C0 I  @& P: T4 L) j
  325.   #--------------------------------------------------------------------------9 Z; e" \6 M7 y7 Q" G5 `: y- }
  326.   def set_mouse_pos(new_x, new_y)
    $ j! L7 r/ D9 d- K# T% E
  327.     arg = [0, 0].pack('ll')8 }) p  f2 W  a8 @) E( C
  328.     Screen_To_Client.call(Window_Hwnd, arg)& m2 _0 F' B6 E5 r  E
  329.     x, y  = arg.unpack('ll'), f+ \) G  h. c$ C3 W. Q9 E
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)! ]" K+ _4 g- V0 y5 @) Q9 b
  331.   end
    : T5 i8 k. `: C+ h$ v/ v: l% p
  332. end #end of class  self 2 Q, i' ~0 Z9 O! j& U

  333. ! \) i1 @% e  w! C8 L
  334. end
      x/ I0 F0 d) c

  335. . Q5 u( i- C: ~9 V4 o4 f0 N
  336. #==============================================================================
    : Q0 J8 ?; ~$ _, s, F& A
  337. # ■ SceneManager3 \8 x& |# D. W
  338. #==============================================================================1 U2 j* V# y  G. h/ @$ D$ K1 V
  339. class  SceneManager
    1 t0 w+ T3 S- p/ A8 |
  340.   #--------------------------------------------------------------------------" W# e0 E$ i$ V) Q# j$ O
  341.   # ● alias2 r& a1 R" z( L+ T. {
  342.   #--------------------------------------------------------------------------3 H$ a) w# H5 a0 W$ q0 k( ]
  343.   unless self.method_defined(sion_mouse_run)
    ) d. o: O) O( M5 Q5 L  p2 `, O
  344.     alias_method sion_mouse_run, run
    8 {1 }# I) \. \* E, c) T8 x
  345.     alias_method sion_mouse_call, call
    , }. Z0 i& C' v* [. a# o7 ?7 S
  346.     alias_method sion_mouse_return, return
    $ z4 d# J* t8 l7 M$ W
  347.   end, }: Q! Z: I4 U* }! J
  348.   #--------------------------------------------------------------------------/ C1 [, R/ s; O
  349.   # ● 运行
    ' `! o5 O/ T" K: i8 t; Z6 S! B" [
  350.   #--------------------------------------------------------------------------
    8 G: `: I' t$ t) F
  351.   def run
    " {$ _" c+ Y& \" w) R
  352.     Mouse.init8 u+ {- k4 k0 T+ l* d) z
  353.     sion_mouse_run/ A; H" A) _8 n" j5 b
  354.   end
    $ i* g2 f! S( p/ R3 s, G' ^. q
  355.   #--------------------------------------------------------------------------
    6 d4 w9 P  v6 Y1 f% ?- k
  356.   # ● 切换$ |5 z2 B8 b- \/ V% o- t3 f* b+ |
  357.   #--------------------------------------------------------------------------1 g! n" k0 b( S
  358.   def call(scene_class)8 {0 ?# j9 |7 U# B( y
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)8 T. u* u9 T( V; k# W
  360.     sion_mouse_call(scene_class)6 z$ c3 \* M9 A' X) v
  361.   end& P4 F8 C8 Q7 r  Q$ j6 e
  362.   #--------------------------------------------------------------------------) L& z# f; |( ]
  363.   # ● 返回到上一个场景/ D8 N( }3 n; _4 t& o4 N* g( q5 A
  364.   #--------------------------------------------------------------------------
    4 {+ v2 {) P/ n+ v" f
  365.   def return& f$ N6 ^; N' i& _! G; R3 H/ T
  366.     sion_mouse_return: V. ~: ?; x- u3 h
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    + ~. s4 o9 q% {4 r
  368.       @scene.instance_of(Scene_Map)9 I) b0 i) h- d5 \4 o
  369.   end
      x2 @- M: a* n, Y" v
  370. end/ `9 W$ e1 Y  u% E/ b/ n  N; j

  371. 4 G% v( Z1 L- m
  372. #==============================================================================* x, Q. K0 k7 I% r2 O5 j$ ?5 _  }# S
  373. # ■ Module Input2 u  a3 P3 r1 c% P6 E1 K
  374. #==============================================================================" W$ I3 V. ^" U6 O, s7 `4 W
  375. class  Input
    5 w: J; _& k: t
  376.   #--------------------------------------------------------------------------) a& r# N. l3 X0 D5 P/ o3 y
  377.   # ● alias2 i+ v$ C3 R/ ^( P
  378.   #--------------------------------------------------------------------------
    , ~4 B1 }: c3 U8 `# n' z8 s- I
  379.   unless self.method_defined(sion_mouse_update)
    8 e* D$ @6 m% k
  380.     alias_method sion_mouse_update,   update. f2 a: l; A" e+ n# o  e, o
  381.     alias_method sion_mouse_press,   press
    " X3 t7 y4 |9 z) B
  382.     alias_method sion_mouse_trigger, trigger
    : Y2 A( l) s1 |/ _9 v6 b  F
  383.     alias_method sion_mouse_repeat,  repeat
    % r. u5 d' A( I* _1 n9 h5 l
  384.   end7 ]. F! M+ m" C4 l! f
  385.   #--------------------------------------------------------------------------9 Y/ n; m7 V! j$ a2 b
  386.   # ● 更新鼠标: ]" i% M! x! K+ ?. z9 I6 W: b
  387.   #--------------------------------------------------------------------------
    0 A. ^9 X2 `7 u( [7 S& k: |8 T
  388.   def update
    + U5 t( N6 \& u* F) }5 ]
  389.     Mouse.update
    % ^$ A& {5 P5 `, y5 E% [
  390.     sion_mouse_update3 E( r( h* T; b# U+ [
  391.   end) X$ e1 J8 a5 Y- y) O! A* |  Q
  392.   #--------------------------------------------------------------------------* p) B$ A! t- l
  393.   # ● 按键被按下就返回true6 s6 `) R0 p9 h
  394.   #--------------------------------------------------------------------------
    1 `1 Z+ v2 L  O
  395.   def press(key)& z& N' B3 V: i% t
  396.     return true if sion_mouse_press(key)
    5 n8 {5 w. e! ]7 Z  V5 G
  397.     return Mouse.press(0x01) if key == C
    7 K5 z9 o8 P  S) d! F6 X3 }
  398.     return Mouse.press(0x02) if key == B  p9 n2 H  a6 i; N# e
  399.     return false
    ! ?* @, L% X" M
  400.   end( `" [) ], T5 O9 T3 _
  401.   #--------------------------------------------------------------------------
    ! D& ?; \4 ~/ [, \3 i3 r
  402.   # ● 按键刚被按下则返回true
    7 v; F+ @$ }( d7 Y6 x; K: a
  403.   #--------------------------------------------------------------------------% r1 @" y/ |$ ]
  404.   def trigger(key)2 }  h, @( |, y+ S5 _4 B) I
  405.     return true if sion_mouse_trigger(key)* S7 R6 Z: ~! ]/ r
  406.     return Mouse.trigger(0x01) if key == C; m* L) K# a/ a$ m2 j+ O+ Y
  407.     return Mouse.trigger(0x02) if key == B' M+ N6 l+ C7 z8 c$ }9 R
  408.     return false
    - z6 ^% }* i. S. E9 x% l! \' m
  409.   end
    , y# q; N% f7 M; A
  410.   #--------------------------------------------------------------------------
    1 w1 u# _8 K% h: F( c
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true. e! F! U& ^0 Y0 H. A$ F
  412.   #--------------------------------------------------------------------------  D* n, G- h  ~( B$ m6 d1 t9 s8 s
  413.   def repeat(key)) i2 B. x0 ]- j! b$ Z* q
  414.     return true if sion_mouse_repeat(key)( H3 r) z; o4 l; L4 \" ]+ U( W
  415.     return Mouse.repeat(0x01) if key == C
    % R! J2 e0 ?7 F8 T, u5 G% g
  416.     return Mouse.repeat(0x02) if key == B
    9 @* i' v! R; J0 Z
  417.     return false
    3 J( d, H7 |( i4 q# A6 R( @0 Y- H
  418.   end
    0 k& Z- S6 Z0 U7 `
  419. end
    ) e" Q7 u. a; e
  420. ) m) a) f! Y; C- z" D9 v

  421. ; M/ @4 q/ f0 S& O, `8 P( J
  422. #==============================================================================
    2 i. p+ Z+ j7 j
  423. # ■ Window_Selectable/ |( e8 K5 q9 {. W8 V
  424. #------------------------------------------------------------------------------3 ^* j8 ~5 @: R7 R
  425. #  拥有光标移动、滚动功能的窗口
    * X& m( A9 A5 G1 C9 L- M
  426. #==============================================================================+ E, j+ z* `: X6 f! k. z
  427. class Window_Selectable! J- a, o- ~+ m- t+ Y9 n: I+ n5 K
  428.   #--------------------------------------------------------------------------
    . B  x* ?( T! M9 J/ C/ m
  429.   # ● 初始化
    8 e' A, M- x8 ~5 t# P. b
  430.   #--------------------------------------------------------------------------7 J2 _# f2 W+ i! N9 P8 @! n
  431.   alias sion_mouse_initialize initialize
    1 T# x" J5 X5 z" T) e
  432.   def initialize(x, y, width, height)  t5 ?  `5 V9 o! @
  433.     sion_mouse_initialize(x, y, width, height)
    / n- H) i; q! ]# l6 h* ~
  434.     @move_state = 0
    / Q* K& D- ^# c0 T
  435.   end
    8 v- Q( D# o8 W$ L
  436.   #--------------------------------------------------------------------------
    2 I( S- E/ T* Y' E" x2 H8 w
  437.   # ● 更新
    , n& U  r5 @- `- N; L+ M# e
  438.   #--------------------------------------------------------------------------) r! o; {; @2 o$ B9 _
  439.   alias sion_mouse_update update
    - z: c# f1 I& K8 Q) B- E2 m4 P
  440.   def update
    2 c1 J) I! L0 a9 L  u" O
  441.     sion_mouse_update' {! Z( I9 a: a1 C# |
  442.     update_mouse_cursor0 ~$ R8 s% F  Y4 W
  443.   end
    & o, P2 L" s5 w2 P" i( U$ Y2 r
  444.   #--------------------------------------------------------------------------$ J$ L' O. M5 B4 E5 e% r0 H
  445.   # ● 启动后设置鼠标到index位置
    8 _' a( ^' p- R9 d& d0 N
  446.   #--------------------------------------------------------------------------# C) e9 p0 \* y
  447.   def activate
    ' q- N9 v" M. q5 a* V/ L
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    6 o6 h/ H3 G1 Y. ~) c+ C: g
  449.     super
    6 Q, o2 ^) Z$ J4 q- d7 i
  450.   end
    7 H$ C! O" w0 }' S
  451.   #--------------------------------------------------------------------------
    9 {7 Q4 P; u( P3 _# Y
  452.   # ● 更新鼠标和光标的位置/ C" M- W! {' _5 ]7 B) z9 p
  453.   #--------------------------------------------------------------------------) V# k/ E" |- G
  454.   def update_mouse_cursor
      b8 _+ `- [1 j/ j3 Z$ E
  455.     if active- }% `" z% ~* y& X" u  ]$ ^; g
  456.       if @need_set_pos5 H4 n5 J) j* u7 ]3 W& J* u5 m5 q
  457.         @need_set_pos = nil
    0 [+ e4 @# y- H( L4 ^8 z. d: X
  458.         set_mouse_pos# K" v  Q- l7 E; Q8 ^& G. b
  459.       elsif cursor_movable" g# [8 H6 B: ^' z
  460.         Input.dir4.zero  set_cursor  set_mouse_pos( e& p# s# p/ a: E  i/ g
  461.       end
    5 R& a0 \8 c* v
  462.     end* v' `. i. g  D( W& j
  463.   end+ W' X9 \2 c$ b6 t+ ~! y/ d
  464.   #--------------------------------------------------------------------------
    / ^" m, d# M: W
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能" }  ?# a4 g* S  l: ^3 d" W
  466.   #--------------------------------------------------------------------------
    ) M% X! i1 R2 T  Y2 f/ H% Z
  467.   def set_cursor
    . [5 [' w( z/ e3 E
  468.     mouse_row, mouse_col = mouse_window_area: o* }; R1 p0 j; M0 k7 X
  469.     if    mouse_row == -1
    0 E) G5 P( ?  {, B+ ]2 P
  470.       @move_state += 1 if need_scroll5 Q' m& |! y) z4 z
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    5 U- ]( ^3 C7 U* P( i* q
  472.     elsif mouse_row == -2
    + m3 }3 \" \; o# B
  473.       @move_state += 1 if need_scroll
    , z" Q4 L8 B1 Z  E' n6 S2 |( {
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand0 ^! u) q9 s1 n8 k- |7 E; Y
  475.     elsif mouse_col == -1( L, |; U( ?+ e; B3 o7 b* ^
  476.       @move_state += 1 if need_scroll! U6 ~8 u) F& e1 k
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    8 }4 t2 |9 ^2 G( d
  478.     elsif mouse_col == -21 r+ h5 Q: _6 w! u* S
  479.       @move_state += 1 if need_scroll4 Q# L& R$ Y  |& E( r  \7 D
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    ! H2 e" L6 Z' n- R
  481.     else
    $ M* Y( s; u1 h. }
  482.       @move_state = 05 ~) K7 e+ b% Y/ C$ H0 ~
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col: B  k* |% z! Q/ R: E8 Z1 a+ ~% `
  484.       select(new_index) if new_index  item_max && new_index != @index" x5 G( @0 K9 C1 e; Q7 f; J. L
  485.     end
    6 h: J1 j: B, N
  486.   end: u$ M7 H$ K8 C; H; {3 e
  487.   #--------------------------------------------------------------------------' N+ x! X+ b+ S+ R8 b/ i! ]) l
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    ' Y* V1 P* Z; A  y' N
  489.   #--------------------------------------------------------------------------
    9 b# s+ B1 K9 z
  490.   def mouse_window_area
    ) N# z! ~) N* \( _6 i( K# V
  491.     if viewport.nil # necessary!
      I+ Q* w! _" u$ ?/ Z
  492.       vp_x, vp_y = 0, 0. U4 U1 c: q5 G+ ~5 P! m2 r3 S2 E
  493.     else, o8 I. B, h! G( U8 `
  494.       vp_x = viewport.rect.x - viewport.ox- {& P6 O3 W7 T
  495.       vp_y = viewport.rect.y - viewport.oy! e) _* e* o9 s: t7 ]/ h' c7 M
  496.     end
    # x* W2 G! M: w1 K$ L
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    6 z# H! r2 |0 J, g2 D  Y, P
  498.     item_x1 = vp_x + x + standard_padding
    ' y( N7 F4 ]: f$ f2 C
  499.     item_y1 = vp_y + y + standard_padding5 j1 r- g; U* b2 I8 k" u
  500.     item_x2 = vp_x + x - standard_padding + width
    2 J! D& u! _7 x1 Y2 X
  501.     item_y2 = vp_y + y - standard_padding + height
    5 v" _/ [7 a* u" c: O3 X" J, `' s
  502.     if mouse_x  item_x14 P. F& I% [  @8 k% Y
  503.       mouse_col = -1
    2 n9 n  v; z+ p1 _- x
  504.     elsif mouse_x  item_x2
    # j4 V8 @6 z3 F3 q2 X) V! S2 c
  505.       mouse_col = -2
    3 Z6 f, m! ~- C9 W! V( G7 C, M
  506.     else1 t% x0 X5 g5 g0 C$ i+ d% g
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)4 M* y- q5 A+ O' W" N6 {7 I
  508.     end
    $ O8 n- ?: U! }, ^
  509.     if mouse_y  item_y1
    : M: S, u/ R, ?7 a( O$ d! o7 S/ X
  510.       mouse_row = -1. _; T6 M0 h; b* _" g3 h
  511.     elsif mouse_y  item_y2
    + R- P% Y3 x' b* M4 l5 e
  512.       mouse_row = -2+ u' M' V0 n6 H' i$ N& d4 L" k
  513.     else; k- R3 ?! N' ]6 p. n, O6 \* ?
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)1 h4 j/ [3 C+ G1 S) b
  515.     end; J, v1 j1 S7 S6 y9 v
  516.     return mouse_row, mouse_col4 p. Q5 g' e7 C4 I# N" L, `1 C
  517.   end
    ; _2 _- ~6 q5 ~& m. N) k" Z' P
  518.   #--------------------------------------------------------------------------1 S. l& O, w0 V" V3 F3 }
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    $ n5 w; O. ?5 A: l+ }
  520.   #--------------------------------------------------------------------------( M: D' N% E  I5 M8 X$ h
  521.   def set_mouse_pos1 l6 {: n- F' d
  522.     if viewport.nil # necessary!* ~7 g: L  i% V
  523.       vp_x, vp_y = 0, 0
    6 I" ~+ o9 Y' t$ z  E! g- a- K- g
  524.     else7 y) z7 u. Z0 v' c9 |
  525.       vp_x = viewport.rect.x - viewport.ox' j+ Q4 D6 K' `) X0 I
  526.       vp_y = viewport.rect.y - viewport.oy
      \0 l7 q; k  Z$ G
  527.     end
    ) u- U: x) z, i6 `$ X3 R: m
  528.     item_x1 = vp_x + x + standard_padding
    + k/ T+ D- @  B0 O! V% ?
  529.     item_y1 = vp_y + y + standard_padding& @8 w# f9 F3 d1 g- Y6 C4 m& k2 ]
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index 2 t. Y4 p; E  s+ ]% N
  531.     row = get_index  col_max - top_row  A0 P# B7 m4 R6 D
  532.     col = get_index % col_max( v' V! a- R: Q3 f
  533.     new_x = item_x1 + item_width  (col + 0.5)5 L+ z& [3 r* v& m7 V
  534.     new_y = item_y1 + item_height  (row + 0.5)7 N/ G, C9 J9 ~" p+ M
  535.     Mouse.set_mouse_pos(new_x, new_y)
    # {. F' t5 z, F5 @, ^$ Z
  536.   end
    3 \+ o2 }$ }: B  m8 z) O
  537.   #--------------------------------------------------------------------------0 b' A- t- `2 {4 v; m9 `
  538.   # ● 判断菜单是否需要卷动7 c2 \! x, _0 C8 P3 |
  539.   #--------------------------------------------------------------------------4 \! x/ q! @) b
  540.   def need_scroll
    ; r, C$ \# q7 _. f* a
  541.     item_max  col_max  page_row_max
    0 B: t& Y1 m7 o6 H5 W" h6 ]; e2 l! _
  542.   end
    % f& \; ?7 p# d. ]
  543.   #--------------------------------------------------------------------------' A% D4 p% _0 L2 e
  544.   # ● 判断是否为水平卷动菜单* _4 }! ^5 N9 @/ l! m8 ?: b
  545.   #--------------------------------------------------------------------------# h, E5 H7 E  L2 ?- D" `, ?
  546.   def is_horzcommand
    / \/ E9 f6 H; w/ K1 c! D, i
  547.     return false
    / e, x6 Y4 I/ h# |) G
  548.   end* b6 C* f; {% d+ F6 y5 k1 U+ D
  549. end( U. y0 h; V" `8 e& E
  550. - \6 ~- G3 |: ]% a
  551. class Window_HorzCommand
    ; p, s' a' L& d9 P& Q
  552.   #--------------------------------------------------------------------------: L, n( F' T8 u
  553.   # ● 判断是否为水平卷动菜单. m$ M5 S2 d; Y" h- k
  554.   #--------------------------------------------------------------------------
    + a+ E- }, q+ C7 l
  555.   def is_horzcommand
    ! h" i% G( V/ q$ r$ x" Y  I) g$ ~. H
  556.     return true: G# {( ~( e. R' \) c: }- u
  557.   end6 r5 o' f/ U# H1 ~  R% D* A
  558. end/ r  ?/ V. U) U# T) C& L

  559. 9 I* B. C; ]4 E- w
  560. #==============================================================================
    3 Q) Q" A) n3 ^: z
  561. # ■ Window_NameInput, |. ~# C: y2 a! c, w9 I  C
  562. #------------------------------------------------------------------------------3 z# r( x3 ~! Y0 b0 f, r
  563. #  名字输入画面中,选择文字的窗口。
    9 g' J" d5 i9 N; {/ G, C6 c
  564. #==============================================================================3 N* m- c! h, x7 v+ G1 M0 \: z. B) E
  565. class Window_NameInput* h; {- o% M1 l1 D4 h
  566.   #--------------------------------------------------------------------------. R+ [; o' H& r
  567.   # ● 设置列数1 O' v. ~5 |! `* k4 _
  568.   #--------------------------------------------------------------------------, i0 m. @8 [6 R' }/ M& X
  569.   def col_max
    9 w! @. b) E7 |/ ]6 f% ^
  570.     return 104 S" @+ h6 r3 q6 C( w& S: N
  571.   end( r/ A  q0 t% b' m# W
  572.   #--------------------------------------------------------------------------
    1 s& w- J3 Z8 i
  573.   # ● 设置填充的Item个数
    # b* U0 `% H, N; I  \
  574.   #--------------------------------------------------------------------------& P7 @$ C8 V) c2 f* Q
  575.   def item_max0 ]% B) E: l  J# g4 o1 }/ ~$ }% v0 G9 i
  576.     return 901 H" z% v- K- Q& v
  577.   end
    3 f: F% t/ C4 d) x: T
  578.   #--------------------------------------------------------------------------
    . S6 h4 Y0 O+ g. ^& c. i+ L! I
  579.   # ● 设置填充的Item个数
    4 d  W7 j! D1 ?9 y$ p. Q
  580.   #--------------------------------------------------------------------------$ _0 X! m" k% x6 p! O$ \
  581.   def item_width
    4 H6 x- l1 v1 D2 @0 Z/ j
  582.     return 32% ~9 k3 m7 |9 E6 ^" V, ~, R8 a
  583.   end, l# }) c: g' K) i: c+ {% t; f: [
  584.   #--------------------------------------------------------------------------
      q' K. j# D# e; S6 Q" D- X
  585.   # ● 判断鼠标位于菜单的第几行、第几列. H8 c/ u" R& B! b; o/ P; O
  586.   #--------------------------------------------------------------------------! o' H% x: W; ?
  587.   def mouse_window_area1 g; u+ Q; i8 D6 \; P- U5 L
  588.     if viewport.nil
    ; q/ |# \6 J, p2 @6 b6 E, G- G/ ^. ^
  589.       vp_x, vp_y = 0, 0; m2 m' T' |( b
  590.     else8 q+ z3 c% u, l3 l8 g7 e1 K0 L2 M
  591.       vp_x = viewport.rect.x - viewport.ox4 u" N6 A+ h/ j2 E7 ~% _
  592.       vp_y = viewport.rect.y - viewport.oy: K" X; W5 q* [
  593.     end
    1 K$ B7 m: C5 {: R% A
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    + c( N6 X1 l& _8 T9 X4 y' J
  595.     item_x1 = vp_x + x + standard_padding 3 V) Q0 Q4 F. C0 |- \/ K4 T
  596.     item_y1 = vp_y + y + standard_padding1 I/ F% b/ O7 \# X
  597.     item_x2 = vp_x + x - standard_padding + width7 i3 S4 Y3 e3 V% H
  598.     item_y2 = vp_y + y - standard_padding + height
    : t4 L4 ]/ X# v$ ?% l' j) L
  599.     if mouse_x  item_x1/ i* b. _- v" \* v
  600.       mouse_col = -1
    # ~7 {! y3 ]2 n
  601.     elsif mouse_x  item_x2
      M: H) ~8 A, }, w2 r/ k
  602.       mouse_col = -26 w' d& W. F/ U. s- g
  603.     elsif mouse_x  item_x1 + 160
    6 ?) N! U, T4 p+ u7 Z% u+ N
  604.       mouse_col = (mouse_x - item_x1)32
    9 p- S$ {& t$ {* j8 [
  605.     elsif mouse_x  item_x2 - 160
    + ]% C$ w% o; S; o& R6 P/ G
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    ; Q+ u3 s) e' [; ~& ]
  607.     else2 {: ]$ D2 R/ i
  608.       mouse_col = mouse_x  x + width2  5  43 ~' e" C  P# k7 ^5 ?
  609.     end
    ( U4 v8 A* m9 s5 J
  610.     if mouse_y  item_y1
    $ H9 [& Y$ v* D5 J4 x0 m* k3 q
  611.       mouse_row = -1( E; \" Z; y0 _/ y' Y( [$ g6 Y
  612.     elsif mouse_y  item_y23 A! w$ [3 n5 u) ?/ h
  613.       mouse_row = -2
    $ m# M7 J) j5 v) \6 g; i% j
  614.     else. U- \# P  c, m* q" A- {0 ~, k
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
      C5 j" Z' j( N; g7 o
  616.     end
    " c% q' B- @  F) K; p: ~6 O$ j
  617.     return mouse_row, mouse_col9 }: ~% m( Y& t6 z& F
  618.   end
    1 s) J6 y, G& Q# q) J2 ^$ t
  619.   #--------------------------------------------------------------------------; Q4 g* e- |% _8 A1 |! {. g
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    # j5 m; b+ z' P; n9 |
  621.   #--------------------------------------------------------------------------
    7 L1 S' B, ^. d; B* n0 ]2 C1 Q
  622.   def set_mouse_pos
    ( ]) O6 e/ w# {. c) [, S. Y
  623.     if viewport.nil # necessary!& L; G3 ^' J2 _
  624.       vp_x, vp_y = 0, 0. E0 }" m% a& b, N9 u, `
  625.     else6 ~, ^) R; c/ {; d% T
  626.       vp_x = viewport.rect.x - viewport.ox2 J7 u; N& w( N9 j0 q
  627.       vp_y = viewport.rect.y - viewport.oy; u) A) u+ q1 s. o. m) z9 V
  628.     end
    ' T+ R$ w- E! c5 c, z" Q6 K
  629.     item_x1 = vp_x + x + standard_padding ' t, m6 m5 s6 l8 O8 C
  630.     item_y1 = vp_y + y + standard_padding7 J% n. f& h7 E7 Q
  631.     get_index = @index  0  0  @index
    + S, l* e' \6 `3 I* w; L7 n# ?$ M; p
  632.     row = get_index  col_max - top_row
    4 W% h- o/ ^& O) ~4 H
  633.     col = get_index % col_max& [2 a! {8 I: c0 r
  634.     new_x = item_x1 + item_width  (col + 0.5)+ x2 K8 v2 U2 m( Q$ f" Y3 X0 q/ P
  635.     new_y = item_y1 + item_height  (row + 0.5)# W' L7 p+ r; E& j1 g' J
  636.     new_x += 14 if col  4
    # c( Q  j' `+ x# D
  637.     Mouse.set_mouse_pos(new_x, new_y)
    : w! S  R- [8 y. H, \
  638.   end" _& _/ |2 o- ?. g! d
  639. end
    ( z6 F0 u0 I0 o! m/ ~. e

  640. , M8 |1 D$ @4 w6 M
  641. #==============================================================================
      o& ?# l, }: h8 x
  642. # ■ Window_NumberInput
    : q" I( @! ]  _0 S# R
  643. #------------------------------------------------------------------------------
      {5 b6 S6 Q: ]
  644. #  重写了数值输入的方法以适应鼠标
    ) v' S- p3 q1 m) X% |, _% E' h( @
  645. #==============================================================================8 u& w5 t8 w+ O2 T5 v5 e0 ]+ |) O4 @4 }7 X
  646. class Window_NumberInput  Window_Base; ]$ Y5 c0 {8 }3 F  S( c. S' J8 M
  647.   #--------------------------------------------------------------------------3 p3 [6 l- C1 ~! e6 l8 ~2 W1 U# \
  648.   # ● 定义实例变量  f9 P5 b' k) A$ B: g7 l
  649.   #--------------------------------------------------------------------------
    6 n# b: u  x8 u% {' _
  650.   attr_reader extra_window
    2 A% E8 [  B2 f" Q5 s7 d6 I
  651.   #--------------------------------------------------------------------------
    5 I$ z4 a6 A0 U# Z" V
  652.   # ● 初始化
    4 X4 l  b: i$ i' a9 R7 p4 m! ^
  653.   #--------------------------------------------------------------------------; h2 P# N/ B; ]2 D  O; L2 b% X* v
  654.   alias sion_mouse_initialize initialize
    1 J# m& a: h2 U6 A/ P& }
  655.   def initialize(arg)
    5 p' O3 n8 U. k  Y
  656.     sion_mouse_initialize(arg)
    % Y& {0 m, t' w& K7 e
  657.     create_extra_window
    * h# J7 i# |, A, @0 g. [
  658.   end
    2 E' ~# j& a  U; T) |! q$ z7 B
  659.   #--------------------------------------------------------------------------
    # E  E7 c" y) U, u- f) b8 d
  660.   # ● 启动
    1 S  C# b- M( p
  661.   #--------------------------------------------------------------------------# o1 k/ h7 Q/ X
  662.   alias sion_mouse_start start( P' i' j/ C0 y9 O& W$ a" [" _
  663.   def start  g, |7 t( ^1 ^
  664.     sion_mouse_start! d0 G+ S: ]6 \  T& T8 {
  665.     deactivate
    . S8 i  _+ K3 ^7 ]6 U0 C
  666.     extra_start
    " p) O; M; v& a7 W! I
  667.   end
    0 t3 C. _0 d7 m! \
  668.   #--------------------------------------------------------------------------
    , w/ u  A- Q9 p. @2 E, w& x
  669.   # ● 创建新的数值输入窗口
    ! J5 b3 U, H6 F7 N) @
  670.   #--------------------------------------------------------------------------
    5 e2 s5 B) v3 ]# C9 Q  o
  671.   def create_extra_window) E* Q  q* G$ s: V1 d) m/ U
  672.     @extra_window = Window_NumberInput_Ex.new
    0 i1 I* d8 {2 ^  {) B
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    / q. m2 w# `( D0 M) m
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    , C+ g8 p7 H3 c6 X
  675.     @extra_window.index_proc   = Proc.new {n @index = n }$ k: \7 ~' B- \9 e# g
  676.     @extra_window.close_proc   = Proc.new { close }0 Q' r9 I4 b9 F+ I  J
  677.     @extra_window.refresh_proc = Proc.new { refresh }3 p& I( T! P) o8 ?( D! t
  678.   end2 h* m! O' A( |" S, }
  679.   #--------------------------------------------------------------------------8 z4 Z9 `9 j, q) T9 a# I
  680.   # ● 激活新窗口
    ) P: w" A1 d3 ]9 I
  681.   #--------------------------------------------------------------------------0 @5 L7 w0 W' h3 Y$ O4 x, {& F9 F1 Y
  682.   def extra_start0 W9 x' c4 x9 Q. H
  683.     case $game_message.position# p) l" d2 @2 F! y+ e. i
  684.       when 0; @extra_window.y = y + height + 4$ U% ]" b$ j$ H& t2 U, z1 e
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8. g5 C4 D! d. U3 ]' D
  686.       when 2; @extra_window.y = y - @extra_window.height - 47 G/ U* F, Q: Z% G# ~% |$ t  Q
  687.       else  ; @extra_window.y = 8( O) j$ k# G3 R/ A- s* ^- D$ N
  688.     end# r$ r2 e( q4 B, V+ V
  689.     @extra_window.variable_id = $game_message.num_input_variable_id7 H- Z# m' [5 N: \7 r
  690.     @extra_window.digits_max  = @digits_max: N+ h: `0 V  |2 C; Q" ]# ?
  691.     @extra_window.number      = @number
    ; e8 M* z1 c% h0 B
  692.     @extra_window.open
    & C  `& V9 D5 F2 N9 H# }
  693.     @extra_window.activate
    1 J; u3 r' L: e9 `. Y& j
  694.   end
    4 G4 G# `  k) C
  695.   #--------------------------------------------------------------------------
    , i  H) H% m3 p# N, F# d/ _3 `
  696.   # ● 更新- |2 d' W. j! a" K+ [5 e
  697.   #--------------------------------------------------------------------------
    7 }  H2 e+ N6 P0 t
  698.   def update
    : T7 }7 E. b4 R9 A7 u
  699.     super
    ( r6 Q" r2 D1 R! V: k- t3 ~5 ^; E4 Q' S
  700.     @extra_window.update
      ~: @4 o, B& t( N9 s$ f7 p# f
  701.     update_cursor' z$ i9 m' F. D, v
  702.   end
    / B1 ~8 ^0 a* M5 d2 U$ p% g, v/ z
  703.   #--------------------------------------------------------------------------. m) z  E7 P% ~
  704.   # ● 关闭窗口& z' D, M2 j! g
  705.   #--------------------------------------------------------------------------
    ) F* }# d9 ?+ ?- ~6 T7 m+ T
  706.   def close( `1 T% [5 A9 K9 z, ?# B0 Y" ?
  707.     super
    5 T6 I2 }6 r, N7 z) _, d2 c: k
  708.     @extra_window.close! c+ M& |$ r3 [$ u
  709.     @extra_window.deactivate" H& ^. }3 D: k( X8 b8 f1 u. H
  710.   end( I, [' }7 |! a4 _: N: d) T
  711. end- v: p: D- r8 j  N1 B; d

  712. * X3 o, \/ Q8 J
  713. #==============================================================================$ X' q$ K& \- j+ K8 X% d
  714. # ■ Window_NumberInput_Ex
    : }; v$ f. G( [9 Q8 e2 q
  715. #------------------------------------------------------------------------------% Z) x  E( m0 K% O/ n  ]' Q
  716. #  新的数值输入窗口(NewClass)
    / T% R* n- n" M4 ^# U
  717. #==============================================================================( u/ z+ h7 ^# s+ s1 f' s) H
  718. class Window_NumberInput_Ex  Window_Selectable
    + b" d+ P7 p  `6 ~5 E1 ?! F
  719.   #--------------------------------------------------------------------------
    , i) i1 y3 V5 Q9 a. N" n
  720.   # ● 定义实例变量; a) P$ o0 w0 `6 K$ F/ D' D9 l# m
  721.   #--------------------------------------------------------------------------
    2 x# Q6 X! ~1 P/ r9 v( o0 i
  722.   attr_accessor number_proc' Q' _/ x+ J$ ^" v$ r: ~  A! A; g
  723.   attr_accessor index_proc( W3 r+ f8 A9 j4 s+ d* c, o- l* U7 J
  724.   attr_accessor close_proc
    2 ^2 ~- Q0 r# Q  N
  725.   attr_accessor refresh_proc
    $ `% c6 z9 N# N1 q3 X% a- @( O3 K
  726.   attr_accessor number8 w6 k/ X9 U( x; S( A! Y
  727.   attr_accessor digits_max
    5 S& c3 L2 I$ h( U* j) G) ]
  728.   attr_accessor variable_id9 I9 L7 m1 n. e- R9 E+ a
  729.   #--------------------------------------------------------------------------' t4 u/ i0 s0 W. G2 C% @- a
  730.   # ● 数字表
    : I5 M4 H. a9 a9 j  H( v; W+ }6 D
  731.   #--------------------------------------------------------------------------
    " V# S) }$ G  p: i& }( u3 V3 X  X2 X# y
  732.   TABLE = [  7,  8,  9,5 v( d9 Q$ }+ v  F6 {5 L
  733.              4,  5,  6,
    , E; W2 Q  O3 M- u6 G, Q0 b
  734.              1,  2,  3,2 m) ]& c, S9 u% g+ \# x  {
  735.             '←',0,'确定',]! `5 @( O) |2 g) J7 ^( v6 y6 o# g
  736.   #--------------------------------------------------------------------------
    / B* x- J/ o" M$ u4 G2 E2 L0 @* i
  737.   # ● 初始化对象
    ) |6 `) d$ H, n; k% U* J
  738.   #--------------------------------------------------------------------------
    6 }, V9 _; q# e9 k) S+ f1 O
  739.   def initialize
    7 o% }8 o4 F& ?) a! ^4 S
  740.     super(0, 0, 120, fitting_height(4))
    ; F+ ]) H$ d7 U& _
  741.     self.openness = 0
    4 S7 v1 K! W. U4 e
  742.     @index = 0
    / Z% W/ U" f# I  T4 ]2 z% Y
  743.     @number = 0& h! G" K! F- e
  744.     @old_window_index = 0
    8 M- U. @9 v0 R. l  M  O+ n1 {/ Z1 J
  745.     @digits_max = 0
    ! O" K* {- f. T3 h: X# @' _/ c* F$ E
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }( K: B4 }9 w3 I+ _+ r) z! L
  747.   end
    : x* Z6 e! N3 D( H- P
  748.   #--------------------------------------------------------------------------
    ; ]# K1 Y6 N- V* S
  749.   # ● 获取项目的绘制矩形
    ( q6 H" @5 I# W6 o; D7 F. r! s
  750.   #--------------------------------------------------------------------------
    % ]8 Y0 [" ]8 }: y: O7 |
  751.   def item_rect(index)5 J. e4 i( S- z: A  |) C' g
  752.     rect = Rect.new3 W8 H6 W* j& H) T: {  s3 F6 U
  753.     rect.x = index % 3  32) f0 A/ H% t7 V  S3 g! s
  754.     rect.y = index  3  line_height
    : n4 M' C7 y; j4 B2 l  `; Y: K
  755.     rect.width = 32
    0 s. B6 u+ Y0 I" X6 R, e( q
  756.     rect.height = line_height2 i' p1 O. o1 _$ O1 o
  757.     return rect
    " L" `5 u4 d/ z$ u5 O
  758.   end5 L& u% G, G* @" T- b
  759.   #--------------------------------------------------------------------------& h* U4 ~8 O  s; e% f% l
  760.   # ● 将光标设置到鼠标所在的位置" O& P* |# t& e! R
  761.   #--------------------------------------------------------------------------
    0 d5 q/ E* I6 ~
  762.   def set_cursor
    7 }' p" E5 U" J9 F5 V) l/ s
  763.     mouse_row, mouse_col = mouse_window_area
    1 G/ A6 h/ `- \$ Q3 z  Z
  764.     if mouse_row = 0 && mouse_col = 0/ _: f6 Q5 q/ c3 V3 k" f& ^
  765.       new_index = mouse_row  3 + mouse_col& [2 j' s1 C8 Z" @& ?) `! ]
  766.       select(new_index) if new_index = 11  b" q+ ^. D6 u
  767.     end
    / \0 I6 {* x9 A2 Y; ?3 P3 p
  768.   end. b+ K3 q% e) w- R8 J# D$ Y
  769.   #--------------------------------------------------------------------------/ B7 k9 C- a0 v3 O
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列% Z9 c$ P/ \! X& {8 R
  771.   #--------------------------------------------------------------------------- X( |. x7 M0 P7 c6 P& G3 c( _0 l
  772.   def mouse_window_area
    4 A! ?1 X/ S. P- k! J9 e
  773.     if viewport.nil
    3 A/ ^  R0 w: y% B& h' p) V
  774.       vp_x, vp_y = 0, 0, a$ j2 x0 x  x" k0 g7 W
  775.     else# ^; P% y, p6 \# u
  776.       vp_x = viewport.rect.x - viewport.ox1 Z) `: J; {' I. q8 S: e: _
  777.       vp_y = viewport.rect.y - viewport.oy
    " I' F% }% \5 t8 t& P; P0 \
  778.     end2 c' \: Y, B0 [; A$ l
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y6 a$ j1 L( e* s
  780.     item_x1 = vp_x + x + standard_padding
    - K8 j8 T8 ~( u) Z/ o
  781.     item_y1 = vp_y + y + standard_padding
    0 G3 n. N) M1 p
  782.     item_x2 = vp_x + x - standard_padding + width) ~" N- f3 e! v
  783.     item_y2 = vp_y + y - standard_padding + height
    9 g3 T8 E1 Z* u
  784.     if mouse_x  item_x1$ X; @# _0 [$ T7 e
  785.       mouse_col = -1( y' f/ d5 F8 P! m: B+ b
  786.     elsif mouse_x  item_x2+ m9 D9 c$ C8 b
  787.       mouse_col = -2
    / t4 U9 q. N5 I" n' Z
  788.     else6 y$ `' q7 ?1 s. z$ g
  789.       mouse_col = (mouse_x - item_x1)  32
    + A% Z! C" m* Z) }" y
  790.     end# h1 B2 W) R" _# [1 U
  791.     if mouse_y  item_y17 [6 _3 {6 i3 }9 o8 E' {9 B7 D
  792.       mouse_row = -1
    9 z# p+ y. |8 P; m/ ?
  793.     elsif mouse_y  item_y23 W- d/ W7 m$ }* ]2 L2 `
  794.       mouse_row = -2
    % f; o4 o  I$ S! Y: J4 @, I6 j" Q
  795.     else
    ! n' \; W" u# r  p9 d7 D
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    ) a5 p/ F% i+ E9 z. _" M5 F: W& r/ f
  797.     end% s% G# Y/ i4 ~
  798.     return mouse_row, mouse_col* [$ t- d: \% O0 l
  799.   end$ Y! u6 N9 s# r3 F8 w
  800.   #--------------------------------------------------------------------------$ }( r$ f% r5 U: y
  801.   # ● 获取文字4 }* k+ D) I- {3 e, t8 N% k) ^
  802.   #--------------------------------------------------------------------------. |5 c& U2 Y: @4 f# {  K  }- p
  803.   def get_number
    , b) p4 h1 Q# H* A6 A
  804.     return false if @index == 9  @index == 110 |+ c) O# L8 u4 `1 [# T
  805.     return TABLE[@index]  a6 I7 m7 u1 g: i
  806.   end
    $ {$ [2 s2 g" j2 X" E9 R; O
  807.   #--------------------------------------------------------------------------
    ! r1 ]3 p; }5 H$ ]9 l
  808.   # ● 判定光标位置是否在“退格”上
    5 N, |2 i- k% P. `" `
  809.   #--------------------------------------------------------------------------
    6 O0 z. `4 @$ v2 h  c5 c
  810.   def is_delete
    , |, M$ A6 Y) w
  811.     @index == 9$ K" t! J0 a+ o. r6 @) H$ T& w$ c
  812.   end) I9 _8 m  x7 E4 n/ [" |
  813.   #--------------------------------------------------------------------------, x& M" @" k  E3 A# n2 U
  814.   # ● 判定光标位置是否在“确定”上
    0 y0 Z3 p/ ?! U( F" @: z
  815.   #--------------------------------------------------------------------------
    * f) f5 t# O$ F% ~- j
  816.   def is_ok3 a# h- I3 n. X. T
  817.     @index == 11
    ; t$ i6 m3 d) m" f& Q9 B8 q; K
  818.   end
    4 M4 i2 i8 p' b2 W5 {
  819.   #--------------------------------------------------------------------------* J: m8 [7 |. L5 d$ C
  820.   # ● 更新光标
    3 k% M1 a% X: r& G; Q$ u, Z; |
  821.   #--------------------------------------------------------------------------' l' q4 r# S. Q! k9 X0 B; k
  822.   def update_cursor
    $ L3 {2 g. K0 @
  823.     cursor_rect.set(item_rect(@index))1 [- K% a- u  S9 g  E7 s, _  v
  824.   end' i! U3 G, ]! s" h
  825.   #--------------------------------------------------------------------------
    6 b* E. X  J- G# }+ [
  826.   # ● 判定光标是否可以移动( p+ b! S6 |. d9 D5 e: K
  827.   #--------------------------------------------------------------------------# _' b0 d/ J/ K# v
  828.   def cursor_movable
    1 _$ t# R, [9 O4 e9 K9 q- q% V
  829.     active
    4 X4 S. O5 |' t# K9 G* m0 `
  830.   end5 `9 _" q! L9 ~& Q$ j7 M1 U% Y
  831.   #--------------------------------------------------------------------------
    : ^7 E0 @6 u& ?" r8 W9 d$ M
  832.   # ● 光标向下移动
    8 _& k8 U: R. M0 m; e
  833.   #     wrap  允许循环4 y3 x7 b" T- R+ |/ M
  834.   #--------------------------------------------------------------------------
    - h4 D# l# t6 l' }5 Q( x: V
  835.   def cursor_down(wrap)0 \5 B; [: g" Q
  836.     if @index  9 or wrap
    ' E9 w4 b# M4 q
  837.       @index = (index + 3) % 12
    9 r* j- ]7 a9 r2 T: O- D, Z
  838.     end
    & ]/ ?4 c( T/ w) |
  839.   end: t1 p' {) x9 t. J& |5 D7 G
  840.   #--------------------------------------------------------------------------2 \9 `. r5 S3 ^) y" W' Y
  841.   # ● 光标向上移动# {4 W0 c2 I1 @! ~$ u
  842.   #     wrap  允许循环" Q  W  x7 ?# }" v" [
  843.   #--------------------------------------------------------------------------' }  q) Z1 l. Z- y. ^
  844.   def cursor_up(wrap)3 D4 f; S7 C/ N4 U
  845.     if @index = 3 or wrap# U" N+ R0 |. j$ p' o: e- C
  846.       @index = (index + 9) % 12
    9 Y8 _! ^* z6 `) H
  847.     end
    . |# j- {7 d! b/ V; ?- b( @
  848.   end3 `7 c2 T4 {9 `8 \4 e4 G
  849.   #--------------------------------------------------------------------------
    + _7 g9 d0 Q: `% r
  850.   # ● 光标向右移动
    / L  W/ [" f3 R6 L# O+ k
  851.   #     wrap  允许循环
    1 y" e* [7 a) O( }* R* [# _6 [3 G$ v
  852.   #--------------------------------------------------------------------------
    # G9 ]/ U0 c. H
  853.   def cursor_right(wrap)0 {* o/ i5 M! e2 g2 n& P0 x
  854.     if @index % 3  2
    8 P( ]5 |, j$ J$ T8 z7 A6 M
  855.       @index += 1
    ) Y. c  L" x- N& X8 t& C
  856.     elsif wrap
    # D# P" C% s6 g9 E, h; r( G
  857.       @index -= 2
    - k# u5 K3 X6 B4 A2 [
  858.     end
    & v! m$ ?; h$ P0 ]3 ^
  859.   end
    % Z* ^% u5 X8 w: ?. r: ]2 t$ A
  860.   #--------------------------------------------------------------------------
    # U, [& Q; v5 \: T7 w. Q
  861.   # ● 光标向左移动
    . s& Z9 I, M' }
  862.   #     wrap  允许循环8 n6 {' t9 G) x/ l( i' J
  863.   #--------------------------------------------------------------------------. A9 H) c" [1 C  J" O
  864.   def cursor_left(wrap)
    : i& K' Z2 _( o9 K/ V0 l" d& s
  865.     if @index % 3  0! B# ]" f, F# f+ z9 L4 @
  866.       @index -= 1
    ' X, p# {# U0 Z7 b/ Q* F6 R
  867.     elsif wrap# X$ g% Q2 v5 K' r; G* `
  868.       @index += 2
    # R* d  n$ t8 C, [! \7 M' B
  869.     end
    $ m& M4 ?: Z" f  ^( \; V
  870.   end
    2 N2 K1 B3 s6 f% X/ M
  871.   #--------------------------------------------------------------------------/ R& h3 @5 Z, S; K
  872.   # ● 处理光标的移动$ l9 d3 ]4 d8 ~6 C
  873.   #--------------------------------------------------------------------------6 l2 e1 E' \, F  q
  874.   def process_cursor_move+ G! ~! a2 H  }
  875.     super
    ! `/ `" r2 o8 L- D; L/ P7 [, x+ e
  876.     update_cursor4 W  ~( p* H, z' V* d5 w  o1 Y
  877.   end
    2 {: W+ c, r; e7 A1 ?) n
  878.   #--------------------------------------------------------------------------4 x+ Y! D- L" u. n/ Y) B5 E
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    - H' q0 t( P  L1 o9 {: U
  880.   #--------------------------------------------------------------------------+ J4 {% p* W& s# e+ y
  881.   def process_handling* K  C8 _8 |# t
  882.     return unless open && active
    " k* s. u! |4 ]) M9 N
  883.     process_jump if Input.trigger(A)
    4 X: c( W( N! B
  884.     process_back if Input.repeat(B): b% [. U8 ]; o, I" l4 j
  885.     process_ok   if Input.trigger(C)
    - ?& p% Z* M$ `* V; |3 E8 g' W
  886.   end) ^2 u, y4 |  `4 e. _2 N9 I
  887.   #--------------------------------------------------------------------------
    ; h  L& j$ p1 j! Y: @9 k
  888.   # ● 跳转“确定”
    ) ~' P2 I5 ]$ E/ ?5 Y# V' P5 Z
  889.   #--------------------------------------------------------------------------
    * f. z; Q$ _; y; o
  890.   def process_jump
    9 t7 r4 j1 N/ s1 c  |
  891.     if @index != 115 w- \( @/ `' O/ V/ @+ m
  892.       @index = 111 V& f& E9 Y2 F( l8 o
  893.       Sound.play_cursor/ C# s# @. R& @( z5 @6 S8 K- j! F3 [
  894.     end
    8 q1 G0 o1 l: Y# F( c! n/ w
  895.   end
    ! L3 I7 N- D# n, ~+ `* g; S
  896.   #--------------------------------------------------------------------------) L2 }$ i0 b+ F1 v$ |* c& j
  897.   # ● 后退一个字符: J6 q' q# B8 s- \/ n, _8 {
  898.   #--------------------------------------------------------------------------3 o+ o% R7 f4 w) a
  899.   def process_back
    1 l* M2 n( x; L( _# R' b- d: O
  900.     Sound.play_cancel
      R! h4 u# {+ d' }8 l( B) g9 \$ T$ o
  901.     place = 10  (@digits_max - 1 - @old_window_index)" ~: H5 H5 {. P/ h; y
  902.     n = (@number  place) % 10- S* m. Q; H3 z1 J( Z; l6 I% z
  903.     @number -= n  place
    $ b) ]# {7 K1 \8 I; T
  904.     @number_proc.call(@number)
    ! L8 v) Z( a9 p/ _1 J* G
  905.     @old_window_index -= 1 if @old_window_index  0! c% y: l& v9 I6 G/ F
  906.     @index_proc.call(@old_window_index)! ]' y. a5 a/ I9 j, {; ]$ E
  907.     @refresh_proc.call
    8 V6 g# [6 Z7 y
  908.   end4 r3 b2 C& K# [! K
  909.   #--------------------------------------------------------------------------
    0 T% _7 H/ X  ~9 x/ e& i
  910.   # ● 按下确定键时的处理
      v1 d9 z7 Z1 t1 A% S
  911.   #--------------------------------------------------------------------------& O  J# [% G/ i7 E
  912.   def process_ok' T, L: ?/ P* b7 K6 c$ T# J
  913.     if get_number$ `. o6 G- z; g3 q8 o$ R" u; [3 \
  914.       Sound.play_cursor. t  v, w- a6 h4 N" k/ X
  915.       place = 10  (@digits_max - 1 - @old_window_index)3 s3 \6 b! Q5 I
  916.       n = get_number - (@number  place) % 10+ d& n' S0 c$ K2 k0 w
  917.       @number += n  place
    : P, g& \. E# T2 \8 v( R" P/ f: C
  918.       @number_proc.call(@number)' a& u* G* U, ]/ P  B, a+ z4 j
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 17 P; N* [# d! k$ T# P8 }
  920.       @index_proc.call(@old_window_index)) ~# F) Z# Z7 [% J
  921.       @refresh_proc.call
    3 w5 s  d! G$ G9 a5 I7 @+ A
  922.     elsif is_delete% z  `' }3 u  N) M0 x
  923.       process_back8 A( d( d& S4 V
  924.     elsif is_ok
    ( K& b0 T: b9 \. Y
  925.       on_input_ok# n+ m5 ^. H# S/ w8 _
  926.     end% k4 q$ N1 {$ b2 W% G9 H/ B" D
  927.   end
    ! I0 {6 m+ ~9 c9 ~* S; n  s
  928.   #--------------------------------------------------------------------------! N+ I4 y& Q3 E# c
  929.   # ● 确定0 S8 r- v# k$ N( I6 F
  930.   #--------------------------------------------------------------------------
    ! H+ V$ a# O7 L, d  |
  931.   def on_input_ok$ n) D: H+ ^) ~, f: ^% B& D2 B: @# s- X2 N
  932.     @index = 0
    + `% ^# P$ l6 v9 _; u% p3 V
  933.     @old_window_index = 01 h) ], B' Y' G$ a( f
  934.     $game_variables[@variable_id] = @number
    6 N% o7 g8 r4 A+ z
  935.     Sound.play_ok
    ! s; p) i0 }  N' z
  936.     @close_proc.call2 {$ l0 h5 U( v: _  s1 K
  937.   end
    " ^( E; j7 N4 H4 v4 M3 U) X& C& Y$ x
  938.   #--------------------------------------------------------------------------
    6 w+ Q8 T* r& H, L/ g- g7 u
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置; ^2 @: m: h. g/ e
  940.   #--------------------------------------------------------------------------: W) q. {* _! b8 B
  941.   def set_mouse_pos
    ( }% c$ d8 U' |5 F! U) _
  942.     if viewport.nil # necessary!* P& e1 O  n9 J; v" L
  943.       vp_x, vp_y = 0, 0
    ) J3 S  h+ P- ?( Z" a
  944.     else( u! R' z0 m( N: X* P3 i) q
  945.       vp_x = viewport.rect.x - viewport.ox
    : v" {6 b- o8 Q% U* B+ A
  946.       vp_y = viewport.rect.y - viewport.oy
    # Q8 o  |: p; @2 }" D+ {' z# S: F
  947.     end
    " X! X/ r5 s- |& g
  948.     item_x1 = vp_x + x + standard_padding : q- h. A6 n1 ^0 |* y7 u2 F
  949.     item_y1 = vp_y + y + standard_padding2 E  o. u/ Q4 T% ~; B4 j4 X
  950.     get_index = @index  0  0  @index 8 @9 `' T  A  G6 ?' P
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5), ~) V! q; ^/ i2 l: Y# r+ |
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    ' h4 p$ w3 H0 R* \% i. a
  953.     Mouse.set_mouse_pos(new_x, new_y)
    9 T, ]9 Y( L6 x5 Z. S
  954.   end
    ( m/ t1 b' A) i  L7 `
  955. end9 s# d" a2 ]1 a1 B0 Z

  956. . ^; {. _$ x) o- }+ V  }
  957. #==============================================================================
    / G9 j( G# q, v& _
  958. # ■ Window_Message" S$ x5 W9 V( t- C# ~% p$ T
  959. #------------------------------------------------------------------------------( f1 |7 o8 q' V8 U
  960. #  显示文字信息的窗口。
    6 H5 q  H, |3 e" y* D4 J, Q6 G0 Q: z
  961. #==============================================================================
    ; b7 n5 R* W  Y7 G  S& J0 Q
  962. class Window_Message  Window_Base, t" q9 S6 l, w
  963.   #--------------------------------------------------------------------------
    5 _; T7 `, B, p
  964.   # ● 处理数值的输入(覆盖原方法)
    ! `$ ?% D( Q$ X% }% K8 P
  965.   #--------------------------------------------------------------------------
    0 {/ T( _9 {5 \- @: B
  966.   def input_number! N4 ^& b, s$ s+ k% w
  967.     @number_window.start
    : ?0 T4 r( ?' U9 k' d1 R
  968.     Fiber.yield while @number_window.extra_window.active0 ^& L2 Y- `2 ~$ Y0 [) p. c& ]
  969.   end1 a# n! E0 \* T
  970. end
    " R1 i1 p" a* v8 [

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

  2343. 9 Q/ T; [- T; ]7 X
  2344. #==============================================================================
    5 o7 A6 D1 S' L
  2345. # ■ Game_Event
    ) g! E% V5 G- b- [3 W( q
  2346. #------------------------------------------------------------------------------* ~5 Q$ d) h) P* I, }+ _  a
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    ; U: _$ V, u3 P* Z7 y
  2348. #   在 Game_Map 类的内部使用。
    2 {" L3 S$ O5 G8 m  O
  2349. #==============================================================================
    - [% ]" I; g1 Q
  2350. class Game_Event  Game_Character
    % k+ c& N. h; a  x; Q: E6 m8 D/ x# ~
  2351.   #--------------------------------------------------------------------------
    ( j8 r/ I: P! l' ]% ], h# X4 h
  2352.   # ● 事件启动
    ! `/ U7 t. [0 c8 P- V* p) V
  2353.   #--------------------------------------------------------------------------
    8 ]% C) a& I! S  v
  2354.   alias sion_mouse_start start5 ]  F. Q' P; J
  2355.   def start
    2 V. ^; R% z& w- w. D% u8 _0 W$ ]' ~
  2356.     return if mouse_start && !Mouse.press(0x01)
    - ]; @) Q9 K5 q( H. j6 Q
  2357.     sion_mouse_start7 ?( m6 E# p$ a' P* g3 Z% [2 r
  2358.   end& `: Q* y& e* ?/ ^4 R8 s
  2359.   #--------------------------------------------------------------------------  c2 i" z3 _; i7 n# P, M9 n1 z+ C
  2360.   # ● 判断事件是否由鼠标启动$ {9 N- O( _& b$ r5 }
  2361.   #--------------------------------------------------------------------------
    & g6 M7 a3 [( u/ o3 ]& A
  2362.   def mouse_start
    + q9 N$ U8 \$ r. R, {' }6 i
  2363.     return false if empty$ {% w- D9 ~8 U5 ?6 u4 T
  2364.     @list.each do index
    7 F3 b. y2 J! Y9 p: u$ M% h
  2365.       return true if (index.code == 108  index.code == 408) &&5 |3 `* J. Z1 l  k$ e; [5 }
  2366.         index.parameters[0].include('鼠标启动')/ I5 o+ Q: t; g# m/ U: W: v6 }
  2367.     end2 h: r- z- B  }+ @2 H3 b6 g7 Q
  2368.     return false# w; v( e- p0 K: X# g8 B
  2369.   end
    8 Y; J9 {- b  Q% Q& r
  2370. end
    ) @1 I) C: a+ K  K

  2371. ; Y& G8 H; z) n/ K
  2372. ####泥煤的height+ }# Z* v$ Y8 T( h0 q+ P
  2373. # @height = height
    : O: G$ L/ E# W

  2374. 8 S# K. u  `1 Z( ]' h
  2375. class Area_Response2 O- [' q: N5 N& T2 M
  2376.   attr_accessor type
    5 v* q" M+ m: u& w& G3 i9 ]* o
  2377.   attr_reader ox
    / R) v0 Q+ Y1 I2 B
  2378.   attr_reader oy
    , s0 n. E$ Z9 j- S4 I
  2379.   attr_reader width- t0 {( B1 G( M
  2380.   attr_reader height: B4 I# n! M/ d4 {0 E; n0 d
  2381.   attr_reader switch_id
    3 \9 m2 j; w& [" g2 n6 ]) g0 l" Y
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    $ w& q% r6 Z% n9 I
  2383.     @type = type
    9 B/ l6 F5 |  Y+ i+ m' z
  2384.     @ox = ox
    " \) j8 q8 a( G5 }
  2385.     @oy = oy
    $ g! _8 y- s$ @; _  ?0 @
  2386.     @width = width
    + K4 r$ h9 m! f+ S6 h+ K8 [
  2387.     @height = height8 L$ Z6 j" b2 [5 m. @7 O
  2388.     @switch_id = switch_id
    . m5 H  \2 A! v) p- g6 j
  2389.   end' Y4 B/ c! \* A' Z& _; V; G" k  q
  2390. end) _# k# H1 ~4 x! R+ D
  2391. " u: W. o1 C4 T# g
  2392. $area_responses = []
    8 P; ^' d8 ~) m7 v: z& J

  2393. 2 N7 r6 c4 s. m0 ^
  2394. class Scene_Map
    - D6 N9 h/ w; L# q1 Q1 m
  2395.   alias update_mouse_2013421 update_mouse_action) w: u) v- W. v) E8 N9 c
  2396.   def update_mouse_action3 q1 R$ A& _- J1 s( g# v
  2397.     update_area_response. y0 I1 Y3 }: u- }
  2398.     update_mouse_20134213 Z' `+ e- P" N+ z. }1 b% H
  2399.   end
    % C  T) @, n4 o
  2400.   def update_area_response8 t) P% r, P1 k% H: s) j7 O$ E
  2401.     responses = $area_responses
    7 P8 x9 X1 X$ _" |  I/ Q
  2402.     responses.each {response6 E  R3 |+ C+ m, D9 O- ?
  2403.       ox = response.ox
    8 L5 O. A# V6 u: [
  2404.       oy = response.oy' G) N9 C7 z2 X0 p3 `: G& q, m
  2405.       width = response.width
    : ]2 G# U* @7 E
  2406.       height = response.height
    & j7 M( d7 f0 p2 b6 v
  2407.       switch_id = response.switch_id
    ( m, J; O  I- w3 A; u. g" s. q0 T! ^# U
  2408.       case response.type9 t; k, y8 I* q: C  K, h
  2409.       when 0
    ' X$ Q, u1 Q' Y3 j
  2410.         if mouse_in_area(ox, oy, width, height)1 R! N2 r( r$ R( [: {' x
  2411.           $game_switches[switch_id] = true
    " t6 t5 \* ]# v4 ]4 ?& x- C
  2412.           $area_responses.delete(response), u2 x. L" v7 K# w1 B
  2413.         end9 \0 S! u% N& V4 w' v
  2414.       when 1
      D. I8 s) C" G! k/ M/ |; C
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)/ H& H# f+ e; Z- D& c
  2416.           $game_switches[switch_id] = true1 }9 S2 Z! i7 Q7 J$ K/ ?; ]
  2417.           $area_responses.delete(response)
    4 \! F7 y$ f6 q/ M
  2418.         end
    2 t3 f8 E! D: r) w  M7 r' b( q; f8 c
  2419.       when 2
    - u! C7 Z# |+ u+ b: ~
  2420.         if mouse_in_area(ox, oy, width, height)
    5 d7 M3 i6 z( z
  2421.           $game_switches[switch_id] = true& m0 P, Y7 ~1 O
  2422.         else
    6 D4 |+ j! l5 u! D
  2423.           $game_switches[switch_id] = false" P. i6 M% }3 c$ h6 ^/ Z+ l1 H3 ?
  2424.         end
    + d6 `, b+ ?- t9 s0 q5 t4 I9 A
  2425.       when 3. K! J  [- ~! L- o* ~9 a" e7 j
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,7 U, x9 P; H" O5 v, m0 H
  2427.             (oy - $game_map.display_y)  32, width, height)" V. \. \0 e4 A% R1 Q
  2428.           $game_map.events_xy(ox, oy).each {event
    # T% L2 R* ~0 u' }# b
  2429.           event.start! W2 L5 F# {3 Q* r) s6 L. @
  2430.           $area_responses.delete(response)
    $ M7 w9 d. R2 L0 j4 N
  2431.           return* D5 G" ]. G3 e5 w/ y8 @1 M9 q
  2432.           } + k2 _  @" R0 r( l0 W
  2433.         end1 n) D" z+ w8 M1 O  V; I
  2434.       when 4$ l) M- w) Q5 o4 e. t* f
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,3 F& y0 x1 N" i6 ]; l% X
  2436.             (oy - $game_map.display_y)  32, width, height)# z4 b% H, s& b- b3 R: H
  2437.           $game_map.events_xy(ox, oy).each {event# W4 `# X. T* H8 |0 r0 F
  2438.             event.start/ S3 z9 u+ D6 t: Q8 {& u
  2439.             return
    ! g# p+ o$ P- g2 z, |! @/ G' k
  2440.           }
    9 ?1 h5 X0 m6 a% P1 k2 b
  2441.         end% s6 z" O0 c4 J5 q7 V  P
  2442.       end
    : l8 c! b! L% X- Z6 V3 N3 x7 U+ c
  2443.     }
    2 W: C7 i+ b1 m" Z& F- d
  2444.   end
    % q4 W+ a6 R; q% j0 m
  2445.   def mouse_in_area(ox, oy, width, height)
    , y- |  V5 ~+ G: k
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    5 ^  B! l4 x1 v' Q8 H% j
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height9 j* w" i2 ]5 m; T& e) z: m8 T
  2448.   end
    * i7 ~! h$ l3 q8 r0 \2 X7 D& p
  2449. end
    , R& G& ]' E7 x$ {) j: Y
  2450. class Game_Interpreter, d6 ]2 j8 ?) R0 N% L5 e) C
  2451.   def area_response(arg)
    9 i; U6 T  D$ S1 G6 V
  2452.     $area_responses.push(Area_Response.new(arg)). L0 W. r! J) g; w
  2453.   end9 [' |$ R: d0 X( K5 m
  2454. end4 U: Q% u: a* Q
复制代码

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

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

GMT+8, 2026-6-5 13:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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