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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    ! ^4 U9 U' D6 P$ K1 t
  2. , u  `0 n7 m/ l3 V# C* \$ h: P
  3.   Sion Mouse System v1.3e% _1 K2 L8 }8 ?4 ^1 E" B
  4.     {/ g5 Z0 ]0 j5 c, b
  5.   Changlog/ x+ \3 |& X  z; m$ \
  6.   8 S4 u- V' f  Y# E0 S
  7.   2013.4.21 v1.3f
    7 V# `2 T9 ]9 t( S+ X& Q9 o
  8.    
    # j4 v; v- F* I' h7 d2 u' T
  9.     1.3f 卷动地图 bug 修正0 J- O& V/ {, c+ q1 P3 w
  10.     # E) G  ?  [, u# ~  i3 m
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    4 A; h9 Q" R7 P0 j% C0 v8 Y
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    . o) V6 w$ p6 G0 W; G7 j% J
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    3 @* ]5 p; N5 N7 f  v
  14. 2 A8 c2 f/ A6 @. L0 k6 @
  15.     1.3f bug修正
    6 P, m; i# r/ ^) s6 P' A
  16.   # N% X' [( ~5 {, E4 _! R5 r
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及  u9 J/ F8 O' b, t1 N
  18.           关闭菜单时,鼠标是否移动到原来的位置。* u: g- V: Z* g) v% L
  19. ' a0 R+ h3 d& ^2 v* v# U- b
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处! a3 J' j2 {* J8 \

  21. 2 j( R+ y! B, d% t0 x
  22.     1.3b 修正一些罕见的bug;
    4 ]( K( g+ |6 X/ U

  23. " K+ H0 j# N, {9 Y- J6 P& O0 g
  24.     1.3a 代码小修改;
    1 e2 k$ {% |. j" c+ {, L
  25.           加入了鼠标点击启动事件的功能,+ }0 [' m, T) f3 u' P
  26.           在事件中加入“注释”: 鼠标启动  ,
    0 b' p  C+ E$ V
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。  }8 ]7 M4 h+ s7 Z
  28.   - S7 _5 Y7 h( e+ H" E  l: }
  29.   2013.2.12 v1.2% |- C4 \+ }, {9 a+ j$ G" B; R
  30. / \6 V$ e' y: `
  31.     寻路逻辑优化;, I  Q  u# S+ R; B4 q! _4 c% l- z
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;- W* v9 v) F, J
  33.     现在支持用鼠标来操作载具了。4 G/ b* c1 C6 K& b8 X7 D8 g
  34. 5 {; S6 w5 w  W. y4 ^3 h5 x# z1 W
  35.   2013.2.8 v1.1
    0 F: b6 r6 Y5 M5 ~: S: [

  36. 8 T" g( x2 `% d2 l" U
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    . X' q" r" u( C* d' c
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    $ r! b, L( P# l$ h" n
  39.     移动时,路径指示点的绘制更加稳定;
    / k9 }: b1 P! W. s( D  C5 I
  40.     现在支持默认存档画面的鼠标操作了。* c) ]. s# i3 A7 y/ B

  41. + h& R# S% z& g1 W

  42.   n$ F, H+ S$ ^/ a8 K1 ^
  43.   OrigenVersion7 ?/ ?- w* \2 K3 c  X+ U
  44.   
    ) M1 }9 b9 @! P
  45.     2013.2.7 v1.0 ! E6 r' Q+ @5 s. g# Q# T8 l! v

  46. 3 M/ C) v2 P7 t! J2 }  J
  47.   主要功能
    / S' a3 R6 {* u# a

  48. : A4 ?2 `) y" j: p4 a  e4 m
  49.       使用鼠标进行各种操作.... B; D& K$ j, I% _$ d3 Y
  50.       将鼠标锁定在游戏窗口内
    - _$ a6 m* Z& y! D: z
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    8 i8 E) M: I8 z1 ^" X9 B
  52.       双击鼠标进行冲刺; u/ |* C. Q& B
  53.       更改地图卷动方式以适应鼠标移动9 S5 M) B2 c* c6 g! ]" }
  54.       变量输入框改良3 Q8 Q7 j5 a+ m: C5 v
  55. 7 n: z7 P: f$ _* `& f2 D
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    # v! k! K. t$ F( ?6 P( @9 k- H

  57. ! g0 b" V! w$ i+ _/ N9 h& T
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹+ w( m: O  X. u( J  |, u2 B- }3 U
  59. 0 ]$ z/ s1 p2 V/ O% d. o, q2 q
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭. R2 B: o$ [7 T; q0 F+ V
  61. 5 {9 `( N% H/ Z' {0 S$ w. h

  62. , L- o- X3 E$ J/ U& ^
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★* `+ X: ]+ G9 d% b3 `: r( T

  64. + S- l2 [8 v' u( o$ O+ F7 @1 K

  65. 5 V1 M2 ~: m& n" v) X9 Y( ~
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    3 Q4 W2 K" X( V0 |
  67. # c6 V6 j& w8 @- j6 v
  68. #==============================================================================4 f) F, A* f$ b: p' P, X- N7 L
  69. # ■ 常数设置 # V! |( H9 d! O5 x6 Z
  70. #==============================================================================+ s2 a$ j% B8 [8 M
  71. module KsOfSion
    ' G8 v; F# A# i6 |8 d8 o$ P
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    * C- e. }3 i1 d: R! {# p
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑6 N% l: j) g& g5 q0 s0 @
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    ' l! T& W: J. y5 @
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    1 `6 a. i4 o/ D/ @  X
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    & _8 `$ B+ W* O$ U4 |
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧& m# ^8 P/ f- {4 K, ]
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)% r5 z0 P# W6 o
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键; J  f; t- c9 b0 ]
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    & I6 |$ b% [# _1 Y  U. m
  81. end
    . ?$ l% o9 R. q; W' U6 L
  82. ! I2 b: _$ e7 E5 t3 E: v
  83. #==============================================================================7 h( V; L& X! f
  84. # ■ 用来显示路径点的类  \; a* B% ^2 w5 W; k3 k
  85. #==============================================================================
    5 N) {. G* h& h6 T* J
  86. class Move_Sign  Game_Character
    " c9 U$ w  M3 v! {3 n; `' R
  87.   #--------------------------------------------------------------------------
    " G/ U2 x9 u3 x1 k
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    . F8 x6 e6 B. {" j1 ~
  89.   #--------------------------------------------------------------------------3 W: d6 k8 y2 R1 A
  90.   def init_public_members
    ' W$ F6 m' ~) d  V. v( F8 u
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    0 ~; F/ ~8 V8 g6 v. H
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    * Q' }! u2 B( R' P. M
  93.     @move_speed      = 5        # ★ 踏步速度, A& q  A, U( g
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    3 o5 |$ V8 d; X: m' `4 C
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度. ^$ k* \0 L- T0 x, W9 ~
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常), e- `% U! g1 i0 }: p; A$ Z1 x
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列' i8 A: h! n; |/ Z% [
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    . N) g& W4 U7 ?5 H# t6 Q  Z
  99. + t# T/ }( c9 c2 j* W- r# x9 I

  100. & s5 M: z) K+ [" }/ E. E: I  l
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★7 G2 Y. |" f( G& F  F

  102. : f5 Y3 E- L7 z. c: h! N3 j2 c* z
  103. ! E* s( X: y) S
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图! A# X) q9 @+ q* @
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')- G/ q( Q+ @% b- z
  106. * w+ V6 K# k( Q6 R* k" I# I( z
  107.       if $no_arrowpic_warn
    6 M: U- l7 @6 R9 Y  Y; z) K) m
  108.         MouseShow_Cursor.call(1)1 F( ~$ _* [' z3 t6 y; I; d
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png( r! j0 P/ f- [, D1 V9 C& J

  110. ! r: }- p4 V( @) a% T: M
  111. “路径指示点”将使用游戏自带图片7 [! y6 ~3 B' j. K0 Z

  112. ' l) h1 e2 a" N5 C8 Z% A6 _* ?- x6 H
  113. 该提示可以在脚本内关闭')
    / Q$ u/ s& H! `8 C0 r! q: h  V- [) s
  114.         MouseShow_Cursor.call(0)6 m4 A( c2 w  U8 t7 o
  115.         $no_arrowpic_warn = false7 I. {& `6 Z, g' X+ p$ B4 F4 T
  116.       end
    1 a- q  G& |! K) G- H* M7 i+ |
  117.       @character_name  = '!Flame'* h: x1 Y! _+ S) g
  118.       @character_index = 6
    + q# @( u/ Z  n% s: b

  119. , v' P4 r0 A. W. S
  120.     end% j# E1 Q4 S! a" ]9 U
  121.     @direction_fix = false  # 固定朝向' ^0 r1 Y! G9 y
  122.     @move_frequency = 6     # 移动频率# d/ V  A* o4 |
  123.     @walk_anime = true      # 步行动画( P5 W; O1 Q) ]* w2 m' n7 C( z
  124.     @pattern = 1            # 图案& ?% `% v# k- ?5 J8 T5 y; X9 a7 m
  125.     @through = true         # 穿透
    * A. d+ k- U' d6 c  ?% v
  126.     @bush_depth = 0         # 草木深度' t$ C2 s- c8 Z2 f. L
  127.     @animation_id = 0       # 动画 ID3 A$ l0 |5 _  {' f
  128.     @balloon_id = 0         # 心情 ID
    9 H4 q0 w7 b' s5 d
  129.     @transparent = true     # 透明1 R- L9 E! E& K3 e; W
  130.     @id = 0! X. M0 W% k3 s" w- E" O2 c: ?/ y! T$ _
  131.     @x = 06 }# b- Q; f5 b" D9 r
  132.     @y = 0- B* e( ~- U# ^: L
  133.     @real_x = 0
    3 R6 f, H1 ~. v$ ?0 u0 W
  134.     @real_y = 0
    2 h5 c" d- B% q$ I: G0 l8 ~3 N
  135.     @tile_id = 0
    . ~9 S) R4 i1 u& M. X/ ]" A' V
  136.   end
    . R; T0 @+ b8 n( w
  137.   #--------------------------------------------------------------------------
    6 y" H, k; ~/ K. D. V5 f8 G
  138.   # ● 定义实例变量
    ' I' u* v- G) C: O8 `
  139.   #--------------------------------------------------------------------------
    # r& s% z  ]8 v# s1 O+ v( z
  140.   attr_accessor direction
    # q) A7 E2 |- S9 d# E, p
  141. end. G  p. U8 F. B' c

  142. & j% G  t& g, D! |3 V5 [* j
  143. #==============================================================================7 \1 z7 \1 C% E) t; h
  144. # ■ Module Mouse
    # j- G: J0 ]0 D0 d) a( m
  145. #==============================================================================. d- n+ d# F" E& p- Q% G2 r
  146. module Mouse
    / h/ k; c( A8 S% V6 u8 h% ]( P  A
  147.   #--------------------------------------------------------------------------
    # m$ d, M, ^2 o: A& d
  148.   # ● API
    0 |8 T; ?, V4 X8 ~: |1 `! V
  149.   #--------------------------------------------------------------------------8 J& U6 q1 A% z% b9 y8 h' O
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')) q: S. z1 a+ c/ F  @
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    5 Y5 S% e, A( Z% m3 w! U' r
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l'), @; x) a, q$ D7 ~
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    : d: N1 [/ M3 u9 i# \
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    $ ?' q7 U$ j7 W7 E
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    0 o% t4 o1 u  c! ^; B2 r
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i'); x( ]7 N2 K& d  ]
  157.   Window_Hwnd       = Get_Active_Window.call8 k6 |/ X8 @! K2 n7 b2 }/ r
  158. " E9 \6 ?1 s; V, o& O- M
  159. class  self9 r! p, G1 @) v  O
  160.   #--------------------------------------------------------------------------( S2 w+ R$ c8 J  ]. Z1 K% s& o
  161.   # ● 初始化
    * q6 G2 `. M) Y# w3 q6 y# `: j  }
  162.   #--------------------------------------------------------------------------. A2 Y. _7 R# R1 K: T1 N$ k/ P+ L. O
  163.   def init9 A! F  j/ q3 T" P! m7 u( h
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    3 r# ~5 V4 `/ p. U8 [
  165.     @left_state = 0
    7 i8 T8 v; ^) @$ O
  166.     @right_state = 0
    ( g0 _3 a3 u$ w! A
  167.     @ck_count = 0 # 帧数计,单击以后从0开始" Z0 x0 j( O" r) ]) _+ [- T
  168.     @dk_count = 0 # 用于双击的判定! C" v2 x4 J) ^0 D. O  V) B9 y) r7 D
  169.     @clicked = false
    3 j5 t( w& l3 z( m( _
  170.     creat_mouse_sprite
    ( E# X( I9 y! F/ |; O$ u* Z
  171.     update9 i4 s8 b  l% H0 E+ h+ h3 [! R9 N7 v
  172.   end
    ' R& ~2 A1 l, N0 _" U' N
  173.   #--------------------------------------------------------------------------
    0 p% a4 f2 F1 h$ v: h# G
  174.   # ● 鼠标指针精灵
    / q- t! M1 x: p- k
  175.   #--------------------------------------------------------------------------/ a+ c1 O$ l5 r0 H
  176. #~   def creat_mouse_sprite
    - J: m, I4 B2 U7 g: K
  177. #~       X+ F4 }5 [) t  B& v% C+ K  n8 ]( N
  178. #~       @mouse_sprite = Sprite.new* |' g- v/ e9 ]( Z. S' g$ k
  179. #~       panda = 2#rand(2)+1$ C0 Y1 C5 E& q2 G2 \( k4 L8 F

  180.   `, L0 s1 \. u, A5 w( L  [
  181. #~      if panda = 1/ _4 O9 l7 p3 T9 V+ q
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    6 N  i* [, U/ ?8 K! |2 e5 r
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    8 [( g3 F, \  ~: \# }$ N8 \
  184. #~        end#with if File.exist
    0 f% @0 x  ]& j5 _
  185. #~    1 P/ k4 C$ z4 E. Y, d6 Y
  186. #~     else if panda = 2 #with if panda=1
    2 z1 W, T1 q( E  A1 F) |$ B
  187. #~      # C/ v) E/ v4 Z! J# ^9 r$ B3 t
  188. #~      if File.exist('GraphicsSystemCursor2.png')6 y$ B$ `$ \2 }- c
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2'): w  R9 q5 O4 _& s, f! W. I0 g, d
  190. #~      end#with if File.exist
    : b4 E: y3 `2 l' j+ p
  191. #~       1 l. s7 A( w+ Y
  192. #~     else #with if panda=16 T- c# L6 S& D
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    ' O$ N3 Q! Q7 R- S/ K5 y5 }2 m
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),# o  ]9 J8 }- j7 k# r* u
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    ! R% A( w6 ^; t
  196. #~     end#with if panda=1
    ( R: o5 |/ f6 K: C7 d3 c
  197. #~     ! P6 n, a. z; [4 x; }
  198. #~     #with def
    + `' o$ r% x+ S" C9 D' N" J
  199. #~   end
    4 m, V* C1 Y& n/ Y9 c
  200. def creat_mouse_sprite% u3 M7 f( M% Q3 w
  201.     @mouse_sprite = Sprite.new
    1 e/ D; `' ]; g
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    $ C4 Y9 m6 a& P+ Y3 J
  203.     @mouse_sprite.z = 9999& z- k- m  P! p0 e+ k+ d
  204.     Show_Cursor.call(0)$ e& O8 J& z/ {1 K8 Y- d4 s3 m+ b& O
  205. end
    3 f' \  E- U9 G9 U
  206. ) D  l! A% ], S5 D( c$ o
  207.   #--------------------------------------------------------------------------( Y9 V/ o4 F7 h, d5 w8 a
  208.   # ● 更新
    ( z# I  l- H3 r- n( U1 X5 z8 i
  209.   #--------------------------------------------------------------------------6 O$ S- I  r$ `
  210.   def update, D0 D: }7 V* O6 W6 [; Z
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    ) M' e% n3 C3 R3 g: }
  212.     left_state  = Get_Key_State.call(0x01), n7 I3 g/ p- d2 b( a! V
  213.     left_state[7] == 1  @left_state +=1  @left_state = 03 v- F0 Y& o: J4 e4 s; T- c
  214.     right_state = Get_Key_State.call(0x02)
    ) J  ^% d+ A" ]/ X. h
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    ; i; r! c5 b4 B+ X& v% \" A
  216.     update_double_click% v8 _- I+ B( ?% r  n& V
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1/ `8 B- h$ |4 c) N( d/ @7 U
  218.   end; D; ?: b" i) @
  219.   #--------------------------------------------------------------------------
    - g) P% L) k( k0 F, n0 |
  220.   # ● 获取鼠标坐标
    / n5 h5 G7 I% v3 P$ I9 i& d7 g- H
  221.   #--------------------------------------------------------------------------
    8 d" u/ ~4 k' l. L8 Z# X$ Z0 u, M7 h2 S
  222.   def get_mouse_pos
    - k. y2 w) k/ N3 C! |9 v! o
  223.     arg = [0, 0].pack('ll')( N! G# _9 z) l! u8 L
  224.     Get_Cursor_Pos.call(arg)' T( n% o( o2 N1 S: N, P2 r
  225.     Screen_To_Client.call(Window_Hwnd, arg)! v; Q$ B" L3 D) J' x8 W" |
  226.     x, y = arg.unpack('ll')
    * ?1 c4 A1 T1 O9 l' Y5 q' O1 T
  227.     return x, y. Q: m  G( e* q* f- g
  228.   end
    " T7 q) L1 g; u$ l- N8 {9 x% p
  229.   #--------------------------------------------------------------------------. I5 n% }% c7 {' a$ x; t. ^
  230.   # ● 将鼠标固定在屏幕内
      X8 l7 ]/ [+ _0 P& H( b
  231.   #--------------------------------------------------------------------------
    2 u2 P$ Z) ?7 t) w  {, K
  232.   def lock_mouse_in_screen* ^! D5 V. N: i* T) [8 i" n
  233.     arg = [0, 0].pack('ll')
    ' S7 v+ r. n, b+ Q6 c
  234.     Screen_To_Client.call(Window_Hwnd, arg)7 @6 t2 [# {( L( z0 D% E
  235.     x, y  = arg.unpack('ll'); I; g8 H6 m1 O  [5 Q. p1 ^5 g
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
      w- O" |" w8 \, `
  237.   end
      X( L; r" L* D$ L, w. B! ?' Z
  238.   #--------------------------------------------------------------------------
    ( B6 u, I1 y7 L$ Y' I
  239.   # ● 解除鼠标固定
    + t9 l7 V8 ~2 G. }) }, J, q! [: |
  240.   #--------------------------------------------------------------------------7 p- ^: u) d  ~" b7 L- S4 W
  241.   def unlock_mouse_in_screen
    2 Z$ }' c- [1 B7 V
  242.     Clip_Cursor.call(0)- r. @2 U" L' A: L5 e& e0 m
  243.   end& J. q# @* [  X2 j
  244.   #--------------------------------------------------------------------------
    % L' V' k7 J5 \$ k4 V
  245.   # ● 鼠标双击判定6 _6 u, ?6 X2 L( w
  246.   #--------------------------------------------------------------------------
      d( K/ R9 V& A' v1 _5 `' \# P2 S
  247.   def update_double_click! Q( L  l+ Q- p
  248.     @clicked = true if @left_state == 1; d/ d7 o# |( ]. x) O! p. i
  249.     if @dk_count  0 && @left_state == 1
    % A: q$ i9 i2 ~# }: }
  250.       @dk_count = 0; @clicked = false9 U; Z( D& m! ~0 g' D% b+ }+ u
  251.       return @double_click = true9 c+ W; n4 ], T
  252.     elsif @clicked
    1 s( O' a: P% Q3 |  _8 B) X
  253.       if @dk_count  KsOfSionDbclick_Frame
    * X) ]& ]3 k1 Z
  254.         @dk_count += 1
    * v3 x8 q( L- U) R* k6 _
  255.       else- x* H% s( j$ o
  256.         @dk_count = 0; @clicked = false1 G& n# w4 c( W- d' [8 z- z
  257.       end% v! Q+ C% i6 B" l5 Q" n
  258.     end
    ! y( C! V$ Y" n
  259.     @double_click = false
    * e5 I4 k7 d0 v- }
  260.   end
    ( H  E. {) ~8 E0 t
  261.   #--------------------------------------------------------------------------; J% ~# y$ D* D& s" r
  262.   # ● 按键被按下就返回true3 ^1 e* {; j* g# c
  263.   #--------------------------------------------------------------------------9 }/ `3 E8 f: ^1 C! b+ l5 u6 P
  264.   def press(button). ?# [! K: V' C+ e+ N2 e
  265.     case button
    : U& t  x/ C5 ?+ H; K$ O
  266.       when 0x01; return !@left_state.zero
    , q$ o5 L, R) B) U# u
  267.       when 0x02; return !@right_state.zero: S, u$ _" D% c6 C0 Z5 L
  268.     end
    ( z! M# p7 n& {8 t; x' B
  269.     return false: o( O: T$ D9 J- Y4 i3 X2 U
  270.   end
    0 `. Z/ p, Z1 F- W7 b- @9 b
  271.   #--------------------------------------------------------------------------, t0 j7 u, d6 u' v
  272.   # ● 按键刚被按下则返回true
    1 R6 N' L( K+ \
  273.   #--------------------------------------------------------------------------3 Y4 n: ~$ K8 b. g2 N. K3 z5 J& i  _
  274.   def trigger(button)
    & h$ c5 ?( @# A( ^' U
  275.     case button2 ?4 V: k& ~- g3 h" c& G* F
  276.       when 0x01; return @left_state == 13 M/ v9 J0 o+ G8 s- G$ w
  277.       when 0x02; return @right_state == 1$ c* M8 e, e* Q+ }* D* I
  278.     end* y' q5 X/ B$ {7 x2 g
  279.     return false
    : [" C( T1 p4 _! o; ]# r: `8 h/ g8 |
  280.   end# N) H' k# f: g: F
  281.   #--------------------------------------------------------------------------
    6 b- t* E+ f2 |) I) Q! J& Z* h! Z
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true  Z( H6 a4 L. U$ ~
  283.   #--------------------------------------------------------------------------
    ' X3 g2 {) v! M9 p$ F# v9 y5 T" T
  284.   def repeat(button)  U3 |  I9 K$ n  a
  285.     case button# q+ q( p! M3 D: o) L. q- V; ~- p
  286.       when 0x01; return @left_state == 1 3 y# q( L, ]# W; v
  287.         (@left_state  22 && (@left_state % 6).zero)8 h8 k# Z& Q8 Z  E" \. V& w+ {
  288.       when 0x02; return @right_state == 1 ) e1 |, K! ^& E" k1 c8 [: C( o; S
  289.         (@right_state  22 && (@right_state % 6).zero)/ B$ g7 ~6 ]7 E" d. e
  290.     end  c( R" h; j7 O/ Z% `% h9 H
  291.     return false9 f6 d# g) N: ?9 O3 k6 s! {
  292.   end
    % s; L1 A$ H0 h# X, a- W
  293.   #--------------------------------------------------------------------------. G3 |9 r# Y. u* a& c, x+ j: z
  294.   # ● 判断是否双击鼠标
    ! L% Q' G% T; K- c" b5 c8 R. {
  295.   #--------------------------------------------------------------------------$ R/ A3 l+ w' I# f8 i8 ^4 _, F
  296.   def double_click
    / ^/ O7 E, q0 K) q4 L6 g$ A: n
  297.     @double_click# E1 j1 S% W0 s4 F
  298.   end
    " P1 y3 Z0 m! T8 ]2 P1 ?- m
  299.   #--------------------------------------------------------------------------$ j$ G3 \8 p0 I8 }( u9 F) b; |9 \  a( n
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    6 A/ R6 g6 |" t9 ~2 R, E  g( z
  301.   #--------------------------------------------------------------------------: \  `- f# `' @" ?" z
  302.   def click_count
    . F) T+ `$ N: D( V
  303.     @ck_count
    + T8 \1 W  S+ D
  304.   end
    : h6 H* ]) x& x' C3 o' K+ E" z% H
  305.   #--------------------------------------------------------------------------
    ) F& [4 ?" D$ F+ U5 U
  306.   # ● 获取@left_state(按住左键每一帧+=1)9 u1 z# C- g1 _2 S% D! o* b! C1 b
  307.   #--------------------------------------------------------------------------
    ' ?$ D2 H! ]4 l. |
  308.   def left_state: R9 X- T+ w' l4 K
  309.     @left_state% e2 v! g% J  W3 f
  310.   end
    4 F* K: H9 w4 M  ~* |0 P* e
  311.   #--------------------------------------------------------------------------1 ?, Y0 d! C; B' w6 m1 {, ~1 ~- W
  312.   # ● 获取鼠标的x坐标. p2 U, }" F5 S: U" q. A" l
  313.   #--------------------------------------------------------------------------( I" b' [  w/ B, K
  314.   def mouse_x3 k2 ]& ]5 ^/ M8 Y$ C+ m2 c+ U9 w
  315.     @mouse_sprite.x
    3 W- a0 g2 O' O" R
  316.   end
    1 B6 U1 b" G3 |3 D+ d& g
  317.   #--------------------------------------------------------------------------5 W/ X* P! o3 r5 p
  318.   # ● 获取鼠标的y坐标
    $ m! [' m$ x# R, W0 G  q
  319.   #--------------------------------------------------------------------------
    2 A% n, a' I% V: b8 _
  320.   def mouse_y) D2 c7 c. H  c$ z6 q9 \
  321.     @mouse_sprite.y% q- ]9 ?6 w* }! k8 z) G* j, f
  322.   end. J: j" N: a! \* D( a& S
  323.   #--------------------------------------------------------------------------: G# ]/ V, S: y; R
  324.   # ● 设置鼠标坐标2 A' \5 m0 z0 m# m# l
  325.   #--------------------------------------------------------------------------
    ' z- h  G% e) j7 y
  326.   def set_mouse_pos(new_x, new_y)7 ?7 O& l$ b8 D
  327.     arg = [0, 0].pack('ll')
      Q# l- l2 O, B7 B1 R
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    ' X# b  w8 B, s) J; s
  329.     x, y  = arg.unpack('ll')( V+ v$ Y" F$ F' i. }: A. }
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)  M$ x5 G' `0 E/ g5 [
  331.   end6 |& a* l; E7 W8 ]
  332. end #end of class  self / A: e: b4 o( d) B% A, K0 z3 R" ^
  333. ' `  V( J1 E$ h! Q( b3 ^+ P
  334. end+ O) x/ p; q& y; r% T1 y
  335. 1 Q. J0 ?8 Z/ _
  336. #==============================================================================
    ' x3 I& p, f  n) ^9 y
  337. # ■ SceneManager
    ) M% L& j; D2 a  t' c3 H8 r2 ?
  338. #==============================================================================
    ! t' S4 q6 N0 ]0 s, G# U% u
  339. class  SceneManager
    8 ~" F" A+ w7 z$ X' x4 F
  340.   #--------------------------------------------------------------------------! Z4 V6 R) ^, z- V8 D# N5 o) v
  341.   # ● alias9 S/ x8 r+ O) S3 J: h0 T
  342.   #--------------------------------------------------------------------------
    ' R! M" J' ~: t; w. ~: z9 C
  343.   unless self.method_defined(sion_mouse_run)
    0 a9 b0 p' |4 I* [, G3 M! S5 p
  344.     alias_method sion_mouse_run, run
    + {+ Q; @$ ?0 u6 d0 ]
  345.     alias_method sion_mouse_call, call
    & }1 a/ K% O9 y% V* C# M1 w) M
  346.     alias_method sion_mouse_return, return3 \% u. T! z1 d" Z- t& A
  347.   end. h" \) s& a3 u; @2 X+ @- z8 r
  348.   #--------------------------------------------------------------------------' A) W9 U& Q; v  D& t* b4 b
  349.   # ● 运行
    9 Z  S7 x8 A+ T2 j9 o- `( f$ P
  350.   #--------------------------------------------------------------------------5 z, X, v1 x4 Y( }
  351.   def run/ O* C. j7 e( S( h
  352.     Mouse.init
    . @0 W, M% @, X8 |
  353.     sion_mouse_run) N) [' @# x, m# Q6 I
  354.   end  i4 H8 y) Y$ n- G4 l
  355.   #--------------------------------------------------------------------------# |  k) R9 R7 T; u9 P7 e: a% ?! w
  356.   # ● 切换9 u" G: U; u4 P
  357.   #--------------------------------------------------------------------------
    ) c! J6 Y' Z1 J# z9 q* i
  358.   def call(scene_class)3 E7 S: P2 V8 b, S; i8 c$ H
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)  @  U: f- U+ l; o, O
  360.     sion_mouse_call(scene_class)8 B* |- A( y3 y4 N' C# ]0 T  ?% N
  361.   end
    " @* g6 Y7 F5 D( K8 u6 T( r! ^' V; p
  362.   #--------------------------------------------------------------------------
    4 h9 r0 ^- i4 L- L. o: B; K; g
  363.   # ● 返回到上一个场景1 a% K: c' O. u6 Y
  364.   #--------------------------------------------------------------------------: o8 M* a) w* ^7 F) w3 Z
  365.   def return' n7 H2 T+ q/ C- ]% ]  ?* f
  366.     sion_mouse_return
    6 N! g- U5 C7 r% [6 h
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    ; I: N8 N% |) u! D
  368.       @scene.instance_of(Scene_Map)! f' C$ w6 {" G6 m8 i/ ?
  369.   end3 |0 [! X( I* W* D  y  n
  370. end1 Y- F/ B- L7 y5 s2 ~) s3 e2 `$ m
  371. ) s- t% N4 N$ K, M
  372. #==============================================================================2 b2 X, ]6 [4 {$ P% w5 E( _
  373. # ■ Module Input
    5 \! {: l$ T; z# F
  374. #==============================================================================7 C' _9 b6 f% i. J3 Q6 d
  375. class  Input
    : l" R% ^# ~$ _. ?4 |, P* w4 B
  376.   #--------------------------------------------------------------------------! l2 l+ l% _; f% `0 [! L2 d
  377.   # ● alias
    0 M9 H  J3 }2 V. c- g5 k! y8 w9 E3 v9 Y' J
  378.   #--------------------------------------------------------------------------0 ^( q7 X- ~' L% E6 H
  379.   unless self.method_defined(sion_mouse_update)' A* V7 q4 q: D
  380.     alias_method sion_mouse_update,   update/ O  m9 p0 Y' {4 D8 ]
  381.     alias_method sion_mouse_press,   press
    # m+ ]/ C. ~) {1 Y' A
  382.     alias_method sion_mouse_trigger, trigger9 e; B0 ^5 I; Y. W& U
  383.     alias_method sion_mouse_repeat,  repeat
    . @" N0 r" D* M9 A. E+ }
  384.   end, J6 E: L" K/ h2 A! O. ?7 N7 F
  385.   #--------------------------------------------------------------------------0 P8 u# N9 k" x% N2 v. q
  386.   # ● 更新鼠标) p! B5 b6 b/ B7 j* k' S
  387.   #--------------------------------------------------------------------------
    ) P5 B  Q/ k, p; _. h3 J
  388.   def update
    1 G2 e$ e, f  Y0 s4 h! [' `. \. T
  389.     Mouse.update
      l: e% T( \0 @
  390.     sion_mouse_update4 ?/ W1 L1 j5 f* |& E% k: K
  391.   end  }5 Z" _# R- X
  392.   #--------------------------------------------------------------------------9 \$ x5 ?+ ]) b7 t
  393.   # ● 按键被按下就返回true
    ! p0 i! R1 R6 r
  394.   #--------------------------------------------------------------------------
    + J" Q. Y. t) M: y" ^
  395.   def press(key)
    5 Z, M. [; A7 N) X* o5 w
  396.     return true if sion_mouse_press(key)4 [' ~" X( [; c/ Y4 G! b' N
  397.     return Mouse.press(0x01) if key == C4 Z" ?" G9 m" L% c
  398.     return Mouse.press(0x02) if key == B
    ! Y5 t+ g1 d: f' K' U! A
  399.     return false
    . {6 I) `8 V- N
  400.   end0 O6 n. d- N9 [0 s# A& x! K
  401.   #--------------------------------------------------------------------------* `" F# U- B. `1 Y" j* R
  402.   # ● 按键刚被按下则返回true
      u! c7 h" D$ }0 {1 o! g0 G2 H% l' `
  403.   #--------------------------------------------------------------------------) N# e1 g; ]: |2 f' X4 d5 Z7 `
  404.   def trigger(key)
    & B$ N/ |1 J: i! b; Y. d2 C
  405.     return true if sion_mouse_trigger(key)( ^9 m6 z6 Y. h- T2 q6 p
  406.     return Mouse.trigger(0x01) if key == C
    + i0 t5 y) ~* g/ t7 l* L
  407.     return Mouse.trigger(0x02) if key == B
      R8 ~4 V' K: D7 U9 U
  408.     return false
    , A: T4 J5 {. Y$ Z# a8 r8 x4 X6 N, b3 n
  409.   end3 Z" c( p% L9 J8 r+ [0 U+ z* x
  410.   #--------------------------------------------------------------------------6 t0 |% H' w  k& w7 W, @% l. R
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    * g- s& H9 ?3 T1 v3 \& L& D4 i8 S
  412.   #--------------------------------------------------------------------------% T" H* z' D1 @+ h& G8 q2 S
  413.   def repeat(key)" Z) q, Q. W- Z
  414.     return true if sion_mouse_repeat(key)
    1 S/ N3 S0 }" p, e. [& `
  415.     return Mouse.repeat(0x01) if key == C* u2 E' H! H# R) e; {6 {: H  F' v
  416.     return Mouse.repeat(0x02) if key == B
    : |# ^4 B& r4 M+ @+ Z& I6 Q
  417.     return false
    8 ]* W0 P  S; V$ d
  418.   end/ Y- F, h: _, r- [, ?
  419. end
    & e0 m" I9 W4 ^$ `( ~
  420. 5 R8 z& ~/ h1 c7 c; j

  421. $ J  @% f: Y& S4 |
  422. #==============================================================================
    & h( i1 `! V6 m' e" `
  423. # ■ Window_Selectable
    / A; N- ~1 n5 F* R5 T, X; }8 c
  424. #------------------------------------------------------------------------------- |  v! B: y$ ]% T# F3 G# K2 ^  S
  425. #  拥有光标移动、滚动功能的窗口: G5 m8 ^6 H( ~$ d- Z! i: z" i. t
  426. #==============================================================================# o. y# i, v$ \( K/ z* n
  427. class Window_Selectable
    ; T% w: n4 A: j6 t/ Q7 O
  428.   #--------------------------------------------------------------------------5 C0 F  L, _; n: L5 W, N$ V1 |3 z
  429.   # ● 初始化
    $ E* C5 S/ T# X7 I; l8 k; s
  430.   #--------------------------------------------------------------------------, k2 Z+ ?- R' k6 Q# [/ U
  431.   alias sion_mouse_initialize initialize
    & n+ z3 Y% j  Z1 s) f# J
  432.   def initialize(x, y, width, height)
    * @; H/ x9 ^' U2 `/ M$ |! Q+ O2 V
  433.     sion_mouse_initialize(x, y, width, height)
    # E0 q8 z, l, b- |  _: J3 h
  434.     @move_state = 0
    9 m& f/ l* E1 i$ Z/ V
  435.   end
    $ x% E) y2 G, d6 z: b
  436.   #--------------------------------------------------------------------------
    ( E2 ?- a  W# ~* v3 k3 P6 E- }
  437.   # ● 更新
    : |+ E  |( [' o7 @% H* U' l! D! k
  438.   #--------------------------------------------------------------------------
    3 a0 z. t' B& g' q! M% P: M0 H- P
  439.   alias sion_mouse_update update# m8 X: U( i  W
  440.   def update
    / b* w, ]7 o, R- O7 U$ {, {. r
  441.     sion_mouse_update7 S" V# Y& L9 N" T0 ^8 T6 e
  442.     update_mouse_cursor! X7 q1 R; L) v; u" c* x. A
  443.   end
    9 t  G: H+ {. ]4 T- R8 [
  444.   #--------------------------------------------------------------------------
    " n# E2 E$ q) F& r0 \; ?; O  D
  445.   # ● 启动后设置鼠标到index位置; D3 Q9 r+ z  t7 p* B- A5 @$ _
  446.   #--------------------------------------------------------------------------$ W8 Y' m- ^$ r& d" P& a
  447.   def activate, [' s5 F4 s" ]) D  O
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    , p1 L8 d7 {6 ]1 C7 E
  449.     super
    8 O  b9 r) F! x/ F% V' i
  450.   end
    + N  y+ L) d& q
  451.   #--------------------------------------------------------------------------% {8 E5 m* n8 F* M% J2 v
  452.   # ● 更新鼠标和光标的位置! u6 w/ Q5 {; ^
  453.   #--------------------------------------------------------------------------
    & ^0 u! R5 ]/ K- }
  454.   def update_mouse_cursor- q$ i+ H* s  \" ^
  455.     if active1 R6 k. Q4 Q( ~6 F) P8 `' y
  456.       if @need_set_pos: ]: Z/ j9 |9 D9 v+ V0 S! X4 c
  457.         @need_set_pos = nil! }4 r9 N* h- Z! |3 [' M
  458.         set_mouse_pos
    ; y3 Y  V) x# E
  459.       elsif cursor_movable6 S9 L  e# `  a. \, S
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    ; F% R3 P6 W! T/ D8 [
  461.       end
    # K( e( e- ^. d. p( ~% ]+ f1 P
  462.     end
    $ Q5 a2 I: W' G3 P- V
  463.   end1 l& `0 l' a; t0 K- s
  464.   #--------------------------------------------------------------------------  q; y6 Q( ?5 @6 `% }1 N
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    6 x% c) P  V, L# ]& Q1 c
  466.   #--------------------------------------------------------------------------( V& @# D3 Q6 B0 n
  467.   def set_cursor
    7 g$ V! F7 z) K: X
  468.     mouse_row, mouse_col = mouse_window_area" F3 u' V% x" Y5 G- v6 p. d
  469.     if    mouse_row == -1
    4 ^4 b+ C3 e' p9 @% B
  470.       @move_state += 1 if need_scroll+ f. Y" J& L2 t/ S
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    7 o1 H! k8 y8 x% G! v' Y
  472.     elsif mouse_row == -2( ]0 \9 v: i6 _; v+ P
  473.       @move_state += 1 if need_scroll
    9 W% c3 j: j0 X7 _% |) j$ `
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand2 ?* L' Y/ p1 b# o
  475.     elsif mouse_col == -1
    8 f& w# ?: {+ I- f
  476.       @move_state += 1 if need_scroll" a* S1 j" f2 ]4 D
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    " l9 \# @9 Q1 {0 |, |5 D+ g' _
  478.     elsif mouse_col == -24 Q, b5 Y, W; m4 p( B8 Q* A0 \
  479.       @move_state += 1 if need_scroll
    2 J; v6 p% N3 h2 Z# [$ T
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand: J! U2 w# w( ]6 X; n* A
  481.     else' s; L5 l4 ?) T: V' G0 R, G
  482.       @move_state = 0/ j( a. P, c. A$ P
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    3 g8 }" E+ D, e$ n+ P+ ?
  484.       select(new_index) if new_index  item_max && new_index != @index
    # y5 u/ e/ s! ^# ^, O. V0 ^
  485.     end
    6 V, S8 m0 Y' G$ l, g' R9 s
  486.   end
    * G  I( Y; g+ P& \: u! \- \$ b
  487.   #--------------------------------------------------------------------------5 x. |& ]3 d' e0 z" h
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    ( m6 v) r7 [' h6 q) s
  489.   #--------------------------------------------------------------------------/ Q  y* R9 n+ \( c% X) H, Y1 i
  490.   def mouse_window_area) k% y, C" g9 D( r: \) S6 @( u
  491.     if viewport.nil # necessary!/ B# f1 ^& i4 V/ u/ Q) P% x' t
  492.       vp_x, vp_y = 0, 0
    $ Y$ R+ q! x# O2 c; d
  493.     else
    0 @8 T; o3 I8 g9 F9 g7 B4 k& T  K9 U
  494.       vp_x = viewport.rect.x - viewport.ox3 s# g7 g& k$ i* t
  495.       vp_y = viewport.rect.y - viewport.oy
    9 g4 t( e& q4 y/ L" x8 q, \; i
  496.     end
    7 e+ s* q9 f( n$ `# u
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    + T9 f5 n' o" y7 J* j5 b$ ?8 K% k
  498.     item_x1 = vp_x + x + standard_padding   U8 U( }# P- @( I# _& Q
  499.     item_y1 = vp_y + y + standard_padding
    ) E8 Z+ _* f3 t) \" q8 }5 Z
  500.     item_x2 = vp_x + x - standard_padding + width
    $ u* s( `( H3 U7 j
  501.     item_y2 = vp_y + y - standard_padding + height- ?0 {8 P) M2 \4 u
  502.     if mouse_x  item_x13 M8 {. Q0 V4 E; s) `
  503.       mouse_col = -1( d/ v3 e  }5 l8 `
  504.     elsif mouse_x  item_x2
    8 T+ h9 y' h; j
  505.       mouse_col = -2
    1 I# @' A, E% u1 I3 N3 G
  506.     else
    . g/ Q, |& [9 O. v
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    , J* \( C! \7 `
  508.     end# Y( B3 E7 L. W, r7 O0 J: k" j
  509.     if mouse_y  item_y1$ `  Q1 V6 m' B! _: Z7 j+ h
  510.       mouse_row = -1/ u: Y4 ^( N0 e
  511.     elsif mouse_y  item_y2; n; M4 {0 \6 j8 `! z
  512.       mouse_row = -2
    ( O' t1 a9 h3 b- E. _$ O  G- ]9 u
  513.     else, }$ n6 M: h4 s  n4 A
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)" i* |% d; Q. @& W! `8 A
  515.     end
      e: `7 x9 Z9 J! N( L+ ~0 l" J
  516.     return mouse_row, mouse_col8 P. |5 u3 @2 {  A; Q1 N
  517.   end
    3 u2 ^; s' p( U3 U6 w, _0 J
  518.   #--------------------------------------------------------------------------
    2 W3 I+ ^" D) |1 a2 b0 t
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    7 H' p' W) \, {; t7 `7 U/ [
  520.   #--------------------------------------------------------------------------
    ( _  E3 E8 F7 b; R6 ~
  521.   def set_mouse_pos
    . W$ P9 T: p  b. M+ c: m# p% b
  522.     if viewport.nil # necessary!
    2 E: g% |# a" r. U- y5 V
  523.       vp_x, vp_y = 0, 0
    1 F( A& u# X# I7 O7 t# G
  524.     else
    % k+ [' n4 d3 S4 c: D: w
  525.       vp_x = viewport.rect.x - viewport.ox
    ( {8 O4 Q0 }7 ]  a  L+ `. E
  526.       vp_y = viewport.rect.y - viewport.oy1 N& i) T4 n4 I7 f6 R
  527.     end
    " c  b1 C# N2 T
  528.     item_x1 = vp_x + x + standard_padding
    ; p2 z7 u3 {- \% n4 I
  529.     item_y1 = vp_y + y + standard_padding
    . b6 W+ p7 K% W% G/ M3 [7 [
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index , P' d" t/ I* r. C. K
  531.     row = get_index  col_max - top_row5 A) H" l( i$ `  R4 P1 }4 X
  532.     col = get_index % col_max
    ! H: a8 c$ E: e6 g* T' |% Y
  533.     new_x = item_x1 + item_width  (col + 0.5)
    9 p. ?( p1 m- I2 V8 h. H# k' g; e; S5 \
  534.     new_y = item_y1 + item_height  (row + 0.5), d* @2 I1 d7 F/ l. d
  535.     Mouse.set_mouse_pos(new_x, new_y)
    9 S( d: b$ k+ H' d2 h' G) c& k+ [
  536.   end9 ]% Y  I5 a! ?% z  r
  537.   #--------------------------------------------------------------------------& s' s% W: U( H! f2 v0 L
  538.   # ● 判断菜单是否需要卷动
    0 X' ~' M6 u8 T* ~
  539.   #--------------------------------------------------------------------------$ q5 ?6 z. J. [, {
  540.   def need_scroll4 P8 x$ {+ ?1 e3 q
  541.     item_max  col_max  page_row_max
    ) w" e0 M0 W- j7 B# S
  542.   end- w8 v, [9 E6 Q$ S$ e9 m5 O5 Z
  543.   #--------------------------------------------------------------------------: K. J1 Z, u0 p% y( V7 ~3 H. T
  544.   # ● 判断是否为水平卷动菜单0 A, [& Z  k" Y8 _: H9 T
  545.   #--------------------------------------------------------------------------5 Q4 e" Y/ B; o, X
  546.   def is_horzcommand
    8 c* j2 `' q: K( w" g+ B
  547.     return false0 ~' C9 m" c! H$ \! p1 ^! Q; u
  548.   end) w; Q  C' i+ A0 J& ~7 @8 u& G
  549. end
    / h9 C% G5 r4 U7 [! k

  550. 8 `8 o8 }" f+ R$ _$ ~
  551. class Window_HorzCommand0 j9 Q- g5 {: U$ }# Q! N
  552.   #--------------------------------------------------------------------------
    0 R& ]; O2 O, o
  553.   # ● 判断是否为水平卷动菜单
    ; r4 o6 J9 I7 T+ h
  554.   #--------------------------------------------------------------------------
    8 [* F1 u5 Q  u8 K
  555.   def is_horzcommand
    + B: t  }  O/ l* P+ T" N1 r
  556.     return true
    9 [) z2 I/ _0 {- ^, p& }2 G  B
  557.   end
    * n6 W) L+ l& ^! }! o9 P8 f; h" J
  558. end
    * i" _; P/ A* [% j4 O: b$ K
  559. * Z# Y" X# M1 \0 t" h
  560. #==============================================================================
    ( O  y; G8 c1 O& O5 H
  561. # ■ Window_NameInput7 y+ ], Q+ P" P9 U
  562. #------------------------------------------------------------------------------
    ; P6 S$ p  k) d7 O, N  t
  563. #  名字输入画面中,选择文字的窗口。
    3 R, p% ~- j( \
  564. #==============================================================================
    - j/ _1 I3 b- S* ^7 U& k. K1 h  F7 I
  565. class Window_NameInput
    1 A0 Y3 a" j) V4 C& F- U6 y$ |$ [
  566.   #--------------------------------------------------------------------------. X" T+ g/ b8 A0 `7 N& o
  567.   # ● 设置列数
    * B7 X4 ?- e$ b# R& M9 l7 P- m
  568.   #--------------------------------------------------------------------------5 b' j2 d( h* m  x0 o( B
  569.   def col_max5 |0 n# h  o8 \
  570.     return 103 u+ Y1 v5 ?, \; M3 {2 i' v
  571.   end) S* N. D2 e/ i7 x. o, ]
  572.   #--------------------------------------------------------------------------
    ( q3 q; W1 X* _6 c; |! V! L+ H
  573.   # ● 设置填充的Item个数8 k* i1 J! ^6 |6 }
  574.   #--------------------------------------------------------------------------
    6 r& b, }" S& G& \' ]5 v; \. M
  575.   def item_max
    0 a7 N2 B8 {3 I5 d, E6 o0 {
  576.     return 909 F! B# n! b7 I7 T1 a% s* T# e5 w
  577.   end' `  K0 r& }2 _! c+ |& f
  578.   #--------------------------------------------------------------------------5 ^( Z2 \, ?, ]# _
  579.   # ● 设置填充的Item个数3 }; a, r; g+ r# a5 s3 L
  580.   #--------------------------------------------------------------------------( c  z: u8 f) h: p4 h
  581.   def item_width
    * y% I4 ^( ?0 T. @$ U$ O
  582.     return 328 z# `, y& ?4 Q9 G" Z. G
  583.   end
    * W& f8 i2 q, c, C/ y9 C- t1 n
  584.   #--------------------------------------------------------------------------
    , I( d" z1 b9 K) U0 c8 N
  585.   # ● 判断鼠标位于菜单的第几行、第几列5 e# i/ M- G+ y' D# w
  586.   #--------------------------------------------------------------------------
    1 K4 T: o1 y- Z. z' |; a5 z7 s& ?' H
  587.   def mouse_window_area' Y% E1 U& A( ]3 _
  588.     if viewport.nil; O4 n6 X9 L  x" n, p, D0 L
  589.       vp_x, vp_y = 0, 02 A% o; g- q3 F5 ?! c  t
  590.     else
    ) p% r9 a3 x# @" f9 f
  591.       vp_x = viewport.rect.x - viewport.ox! _# ^  y9 m: x, x5 }& Q
  592.       vp_y = viewport.rect.y - viewport.oy' i( `+ V% n/ _; x- X
  593.     end
    % y3 C+ q$ b/ `# h0 N
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    - T) q) H" y3 f* ~% K/ Z
  595.     item_x1 = vp_x + x + standard_padding
    4 r2 A4 x# z. {
  596.     item_y1 = vp_y + y + standard_padding
    & t- C  c6 W1 U7 `
  597.     item_x2 = vp_x + x - standard_padding + width
    * \- T3 c' ?- S
  598.     item_y2 = vp_y + y - standard_padding + height
    0 ~' g& G( V2 ]; C+ O& @2 l2 w
  599.     if mouse_x  item_x1  v- \# a( N/ `- a6 S8 A) L6 H
  600.       mouse_col = -1
    % j) D. W/ e8 n
  601.     elsif mouse_x  item_x2
    ! y& ?% _6 Q* ?5 h" t2 }
  602.       mouse_col = -2% t7 M0 m' X5 t4 ?  ]5 }" P8 N
  603.     elsif mouse_x  item_x1 + 160
    % F7 y; l. N7 d1 p$ Q. ^, o
  604.       mouse_col = (mouse_x - item_x1)32
    / \. x# k' L4 c; F* f. g7 u9 J  ~
  605.     elsif mouse_x  item_x2 - 160
    / @% b( L$ o5 R$ M7 [* s6 V
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    4 v9 j, ?; s: ]" n
  607.     else* P1 x) j, H0 q, b; z5 J3 q
  608.       mouse_col = mouse_x  x + width2  5  41 u% V" H. `3 J  L) d
  609.     end
    9 [5 D% J+ w) R
  610.     if mouse_y  item_y1
    . b. K. F5 R; A
  611.       mouse_row = -1
    * z& B5 R: ?% c6 m) d" f
  612.     elsif mouse_y  item_y2" P  U: d7 I, E/ g3 c* T/ z7 ~. L7 k- W
  613.       mouse_row = -2
    5 G- s" B3 f& l; H( V6 F1 X" K1 E
  614.     else
    5 \( F( H; P2 I" n
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    & d; ^. U; M7 c. f1 _( s; O
  616.     end
    2 ~: v) T% T4 M7 _7 v- V
  617.     return mouse_row, mouse_col$ i; l" u7 y1 V. S5 {5 R/ Z
  618.   end
    8 y+ X. s: V4 V4 A0 p
  619.   #--------------------------------------------------------------------------- [* m9 M* F5 m/ i+ W
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置* b$ P6 @' _$ e6 {0 e2 Y
  621.   #--------------------------------------------------------------------------7 B  L' ^3 C. g6 j$ T. x# [
  622.   def set_mouse_pos) w. K; G2 S3 |+ u' G8 m8 H3 g
  623.     if viewport.nil # necessary!
    . @/ u3 r5 A/ E6 X. _) e
  624.       vp_x, vp_y = 0, 0% L* E, v( N$ `! q2 \9 ^
  625.     else1 B7 o1 a# b& _8 F# |
  626.       vp_x = viewport.rect.x - viewport.ox0 ~& ?8 {0 R, R; ~) M1 Y0 y
  627.       vp_y = viewport.rect.y - viewport.oy% g$ v1 @7 y, _- c7 ]
  628.     end6 h$ k4 l: j  S- B6 K
  629.     item_x1 = vp_x + x + standard_padding . Y3 [& m" z! H
  630.     item_y1 = vp_y + y + standard_padding; _4 @$ p0 ]1 _! j5 l
  631.     get_index = @index  0  0  @index " X2 P2 g% J& a$ d3 y6 Y* Q
  632.     row = get_index  col_max - top_row
    ! s* H. ~) g7 k( j3 e
  633.     col = get_index % col_max: {% _! F+ s' f: W+ \0 }
  634.     new_x = item_x1 + item_width  (col + 0.5)5 f) C7 m; H" p  {  @
  635.     new_y = item_y1 + item_height  (row + 0.5)! W$ w; ^2 B9 ^: |2 Q
  636.     new_x += 14 if col  4: T4 ]$ x& B& O' z: K
  637.     Mouse.set_mouse_pos(new_x, new_y)% l2 ~: l  k: X
  638.   end
    ; f! p2 u: N6 i) K$ a% p
  639. end
    & `( [, A8 n/ V1 j; u

  640. 3 A* F. j; U- j* O7 o
  641. #==============================================================================
    " R# O9 L: F* ]. d; z) g3 W  s$ M5 z
  642. # ■ Window_NumberInput
    ' Z* T1 G6 t) P! s1 X( t
  643. #------------------------------------------------------------------------------
    : S; [- x" J  k1 b
  644. #  重写了数值输入的方法以适应鼠标% {: @) I6 ]- X1 m
  645. #==============================================================================% O7 s' c3 G* C  t/ b
  646. class Window_NumberInput  Window_Base* J. z" a; f* l- F4 C# {
  647.   #--------------------------------------------------------------------------- Z3 n8 G* ^* y  s( q4 L
  648.   # ● 定义实例变量$ B. w$ P0 X# C1 t7 {
  649.   #--------------------------------------------------------------------------
    $ e! F" ^& }6 `! x9 F8 \' V, H' p4 u
  650.   attr_reader extra_window
      w4 w+ z& [# Y$ l
  651.   #--------------------------------------------------------------------------
    $ C- J- y1 d- f8 V" }- S
  652.   # ● 初始化' y/ R( _2 ?' n9 l# B5 y6 z
  653.   #--------------------------------------------------------------------------
      F8 p1 H; C1 a2 Q8 ~
  654.   alias sion_mouse_initialize initialize
    - N& F( B: O5 M8 c9 ]6 I* s! o4 c
  655.   def initialize(arg)5 r3 ]( \  i9 I$ q5 W% C% Y
  656.     sion_mouse_initialize(arg)  o4 X% |7 x0 P8 i, ~
  657.     create_extra_window
    1 @9 y! Y  L6 [5 I5 a- s* Z3 c
  658.   end5 ]6 t: U) }8 k
  659.   #--------------------------------------------------------------------------" v; p* D1 k+ E& w. S
  660.   # ● 启动
    7 d7 f: r9 M5 u$ x/ e7 ~) n
  661.   #--------------------------------------------------------------------------
    ! @+ c0 X5 N$ w
  662.   alias sion_mouse_start start
    4 D6 p/ r1 W9 T. t1 n; @
  663.   def start* r& ~( O1 J, x2 j6 o, z) X
  664.     sion_mouse_start
    ) w) Y5 L6 k# i) o' ]  l6 b/ X
  665.     deactivate" R4 ?& i9 w/ W$ t5 u* H4 ?
  666.     extra_start
    / e0 S7 `" e+ r9 U
  667.   end
    . J" L! G6 }7 R4 L  ^7 K
  668.   #--------------------------------------------------------------------------
    , W# {1 {* n" }( L1 q% c
  669.   # ● 创建新的数值输入窗口: t- t9 l+ I( }! f1 r4 x* b* O
  670.   #--------------------------------------------------------------------------- m7 F, H/ u) B
  671.   def create_extra_window
    1 x: h7 X4 }* c# H9 u! ]5 u
  672.     @extra_window = Window_NumberInput_Ex.new
    ) n+ f3 e3 r: O1 P4 P8 ]
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    % @% M) f$ Z; o9 y6 ~) Z
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }  [1 s* e6 H& \
  675.     @extra_window.index_proc   = Proc.new {n @index = n }; g" I+ Z8 v- Z/ z
  676.     @extra_window.close_proc   = Proc.new { close }8 ]/ g4 f# k, a' R6 X( e
  677.     @extra_window.refresh_proc = Proc.new { refresh }, v1 d* F* I1 o* e" l8 X' V
  678.   end
    # |. A# c) K4 H' W2 X0 V8 K
  679.   #--------------------------------------------------------------------------
    0 N2 M: H6 Y) ]5 A5 T# D8 F
  680.   # ● 激活新窗口5 f4 I/ q5 A5 ^3 O
  681.   #--------------------------------------------------------------------------! x3 r- K' ^7 y. s
  682.   def extra_start
    9 b# w+ P+ M4 B
  683.     case $game_message.position& a, l1 a8 s1 W6 _( ?# F5 a3 m/ q
  684.       when 0; @extra_window.y = y + height + 47 ]: E7 a0 I1 E6 L4 E1 v
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8$ X, {7 I/ [% o. d3 C1 ?. ?8 m/ t
  686.       when 2; @extra_window.y = y - @extra_window.height - 4. m: B; J/ h2 d8 m3 ]" v
  687.       else  ; @extra_window.y = 8
    3 m- |! c. r9 W6 x
  688.     end3 ]1 [/ y! A" {: l+ l
  689.     @extra_window.variable_id = $game_message.num_input_variable_id0 N* u* F& P4 Q/ i! B! z( a
  690.     @extra_window.digits_max  = @digits_max
    % F. ]0 B( S+ s4 r' \
  691.     @extra_window.number      = @number
    % n+ t* e/ ?5 w" O! O
  692.     @extra_window.open& j8 K. c: M) \" E7 K4 @
  693.     @extra_window.activate
    % g4 p7 i% T/ G2 J! Y' N+ {/ i
  694.   end  O6 D/ t& V' \) y  U7 ]+ v
  695.   #--------------------------------------------------------------------------& U$ H8 h- a6 O" y( ^$ n- x: r
  696.   # ● 更新
    + p. z% q1 t  r* ~/ X
  697.   #--------------------------------------------------------------------------
    ; i+ G% g+ A9 ]/ r& M; p
  698.   def update
    6 `; F1 n- [. j) G. n, D
  699.     super5 i* g4 b' T* I1 f6 f  \$ I( z
  700.     @extra_window.update4 j2 o* v8 [- E& H
  701.     update_cursor- h2 j6 v2 `6 g( E$ i, g* c8 Z
  702.   end
    7 ?+ F) I/ i: i( ~& i
  703.   #--------------------------------------------------------------------------
      }* k3 w' X: S# T8 F/ E
  704.   # ● 关闭窗口, N1 i9 o' l' x1 J! p- ^
  705.   #--------------------------------------------------------------------------
    " T6 P1 o) J" Q: C% u9 p" a
  706.   def close0 |3 X5 i% I% r" k" Z9 P2 X
  707.     super1 A% d7 s8 s6 E
  708.     @extra_window.close
    # j+ f* `+ s8 P/ O- M- {
  709.     @extra_window.deactivate; @$ s( L& T4 W1 a5 u
  710.   end
    : z8 W: ^% H7 W1 K4 a
  711. end! |* @6 u2 k6 I2 }/ s$ |* i
  712. ; r$ z$ M. D3 {5 j
  713. #==============================================================================
    % W2 Z6 }( g& Y7 A4 J
  714. # ■ Window_NumberInput_Ex6 U% q0 Y. B6 [
  715. #------------------------------------------------------------------------------
    2 Y/ e! n' {1 c
  716. #  新的数值输入窗口(NewClass)
    0 }) P* z/ b1 E
  717. #==============================================================================, S# p: Z1 p/ L& p9 E4 }
  718. class Window_NumberInput_Ex  Window_Selectable
    % u% B6 t9 \8 H$ c: ]; r* z
  719.   #--------------------------------------------------------------------------
    * f! m6 M: N. |+ D; p* S6 c
  720.   # ● 定义实例变量) ?; I1 _2 {% u; i) g9 i/ ]
  721.   #--------------------------------------------------------------------------
    5 z3 n& [; f4 k, C6 x' Z
  722.   attr_accessor number_proc
    ; {. @3 v9 I9 n0 p" G' f
  723.   attr_accessor index_proc/ l3 p" P/ L+ G8 [
  724.   attr_accessor close_proc
    , u6 C1 f9 H, ~4 j
  725.   attr_accessor refresh_proc2 `4 N+ o: R1 M
  726.   attr_accessor number8 y  B% X. `: q" f! L1 A" B
  727.   attr_accessor digits_max
    4 U* O9 j- X& K8 |
  728.   attr_accessor variable_id/ _- g4 N6 w2 L7 J4 y! Y4 z/ B
  729.   #--------------------------------------------------------------------------3 B  `9 V- n; d6 Z" y+ ~
  730.   # ● 数字表3 s( ~  H6 |2 N. F0 B) `, O9 b: B* w
  731.   #--------------------------------------------------------------------------3 r2 ?" u4 W5 i* E6 `$ n2 W
  732.   TABLE = [  7,  8,  9,
    4 J) }1 e3 @# O: Z$ }# G
  733.              4,  5,  6,8 r& z. X1 y/ G* q' Y9 i
  734.              1,  2,  3,  G1 ?) ~1 z% o5 N5 J" L) J
  735.             '←',0,'确定',]" o' b- _; K1 l# i8 T7 Y
  736.   #--------------------------------------------------------------------------# i4 M7 f# N4 R' L
  737.   # ● 初始化对象
    " p% Z% c6 i; h- |% q' O
  738.   #--------------------------------------------------------------------------9 A( g0 p( R5 a8 J
  739.   def initialize
    3 j( D& S# v3 g7 r4 q7 k4 \) r
  740.     super(0, 0, 120, fitting_height(4))
    ' y9 Q; W# Z* k6 r
  741.     self.openness = 0
    & H: g# a; b0 Z2 d1 Q9 w  [
  742.     @index = 0; O& n# P  t' u8 O* h3 [$ M- b7 _8 B" w
  743.     @number = 0" ]2 c- P( @/ D2 i4 g
  744.     @old_window_index = 0. l: i; \# S! M  {! b7 Q) p: G
  745.     @digits_max = 0$ D' L9 n2 ^1 ?% R& S5 v
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    8 S9 m5 [9 T% U1 F5 n  i* N& |
  747.   end
    7 J6 r, _# b$ v! X: s' S! j
  748.   #--------------------------------------------------------------------------2 ]' E6 s, T# R
  749.   # ● 获取项目的绘制矩形
    * F2 D$ X! e; c+ W% R- h
  750.   #--------------------------------------------------------------------------
    5 f' M( F( w& q
  751.   def item_rect(index)
    ( F  [1 g" K- o2 i. V
  752.     rect = Rect.new
    9 d0 |& a5 G% U
  753.     rect.x = index % 3  32" ?" R7 c. s3 ~; v+ ~/ {
  754.     rect.y = index  3  line_height8 E& M* c+ [# J( [( Z# F$ D
  755.     rect.width = 32
    : K( U: {$ @8 z) B0 w7 c" ?, r
  756.     rect.height = line_height
    1 d" Y1 x5 @$ i, b0 `
  757.     return rect
    ; d* Z- v) H7 B: x1 x
  758.   end
    * G1 _8 A3 c- i6 F
  759.   #--------------------------------------------------------------------------
    ; D7 n1 Y, c% V  r0 r8 D+ H  X
  760.   # ● 将光标设置到鼠标所在的位置, k. p/ P! k# a9 C; i
  761.   #--------------------------------------------------------------------------4 c  i5 @$ Q7 _2 c! E1 m
  762.   def set_cursor6 f/ [/ Y7 d' Z* j) ?3 f5 Z
  763.     mouse_row, mouse_col = mouse_window_area
    6 |8 }6 Q9 N2 N4 {
  764.     if mouse_row = 0 && mouse_col = 0
    ' z& n2 A7 K9 p% |6 J) ~: ?
  765.       new_index = mouse_row  3 + mouse_col
    8 `4 h2 \2 v% K4 l0 B
  766.       select(new_index) if new_index = 11
    2 J  u2 _, G& w' I; ]
  767.     end
    . [2 y' Z& N" R% R; d4 g+ i. G3 S
  768.   end+ m) T8 ^9 Z5 ?" c3 M
  769.   #--------------------------------------------------------------------------+ A4 U$ E. I' J  j0 O$ W
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    9 O5 x1 {' {4 l
  771.   #--------------------------------------------------------------------------
    & ^* `3 E* \: u* ?) ^: V
  772.   def mouse_window_area# p9 y9 x- l5 p: M- Q7 {( l- @
  773.     if viewport.nil% w; v9 L0 d/ d0 V
  774.       vp_x, vp_y = 0, 0
    1 v' p& `# ~5 a7 v* x. v, \
  775.     else
    : g- j. ?( \( E0 y3 ~
  776.       vp_x = viewport.rect.x - viewport.ox
    & [4 k7 [0 f& c! v0 O$ ^9 O
  777.       vp_y = viewport.rect.y - viewport.oy7 N! Z  u! H7 A) `
  778.     end
    3 Y7 d) {& V) [5 h- }' W3 ^6 x" J
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    8 K1 G3 ~+ b$ z$ c1 _6 W- K! ]4 E
  780.     item_x1 = vp_x + x + standard_padding
    5 m5 C1 S* D  S. r4 u
  781.     item_y1 = vp_y + y + standard_padding: y5 j4 o  F" E9 @6 R) V" R5 s9 Y- Z
  782.     item_x2 = vp_x + x - standard_padding + width
      P" J2 {! a) O/ C* p$ C4 b
  783.     item_y2 = vp_y + y - standard_padding + height- W1 r! J$ @1 o
  784.     if mouse_x  item_x1, P6 \) {- m# E7 q2 C* s) M
  785.       mouse_col = -1  ?0 m) Y7 K$ Y$ k6 T" z8 Y
  786.     elsif mouse_x  item_x2' ~# f+ X' q( _+ d
  787.       mouse_col = -28 Q& `, X2 N7 G5 i/ X* P
  788.     else5 f+ i1 E: u' M0 T6 G. v
  789.       mouse_col = (mouse_x - item_x1)  32
    ( i4 ^5 B$ a. Q; H1 ]& w
  790.     end* Y: D1 S2 c; j+ P
  791.     if mouse_y  item_y13 U, z* E" o8 N
  792.       mouse_row = -1
    + X' ~' ~* l# g8 ^0 Y
  793.     elsif mouse_y  item_y2
    % h1 B, `& q  W/ q$ ^( b# q$ {: k5 {
  794.       mouse_row = -2' |0 i% N! ?$ j- M
  795.     else
    # ?- E# y# R- V
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)0 V1 B& h& u; j
  797.     end8 L- X  H6 T8 H7 E" U  `# H
  798.     return mouse_row, mouse_col
    * h! D% p9 u+ D( V
  799.   end+ v6 `) h2 c2 {  U$ H
  800.   #--------------------------------------------------------------------------
    ' d6 A: i* ?* r
  801.   # ● 获取文字
    * {# |" w. [/ ~5 r' v) y
  802.   #--------------------------------------------------------------------------
    ) f: \+ ]8 K/ y& _, G2 ?/ I
  803.   def get_number% g* M! d0 W! f3 f% |! Q
  804.     return false if @index == 9  @index == 11
    7 g* T! E8 S/ c$ s+ ]0 S* ~" Q' _
  805.     return TABLE[@index]' i. H4 A" O9 \7 V9 H
  806.   end
    ) t  }5 w3 v! W9 ]' ^6 \# [8 S
  807.   #--------------------------------------------------------------------------
    1 y& Y/ c3 ?! [1 W  u) v
  808.   # ● 判定光标位置是否在“退格”上7 R  M) b7 a/ X4 K) K2 c
  809.   #--------------------------------------------------------------------------  z; O' A6 y' E
  810.   def is_delete: ?. W+ k& q; O( z4 k
  811.     @index == 9: f$ D5 k1 J7 M0 v; k9 }0 j8 W! e2 k
  812.   end' A1 R3 d" Z8 {
  813.   #--------------------------------------------------------------------------
    / X& p& G/ s0 I. g- `/ u
  814.   # ● 判定光标位置是否在“确定”上8 y. m5 e, t" Z
  815.   #--------------------------------------------------------------------------
    4 k! P% H& J! k
  816.   def is_ok; Z# H0 E4 @+ \. z. v7 M; C. x
  817.     @index == 11* u% d' N! B; a( H- y$ t' L" N7 ]
  818.   end: h* P7 o( t  y" l! @
  819.   #--------------------------------------------------------------------------
    : h: r" r0 n  c: X
  820.   # ● 更新光标
    & ]/ y, u# G; m1 x/ U+ Z
  821.   #--------------------------------------------------------------------------6 n' F' D0 H8 s" K8 `
  822.   def update_cursor- l0 t. i/ w: @* n' G6 r
  823.     cursor_rect.set(item_rect(@index))8 \# a2 m% p. f. F9 J3 F
  824.   end, S0 l6 p8 W5 W& N7 l6 o3 U
  825.   #--------------------------------------------------------------------------* q8 u/ h5 t  \% x
  826.   # ● 判定光标是否可以移动
    : S( @' [; z, ^3 U
  827.   #--------------------------------------------------------------------------
    7 U9 Q% J: ?  `8 Z
  828.   def cursor_movable0 U( N  H% x9 N
  829.     active3 v) E! ~' Q! E( C5 n
  830.   end2 s' n0 N8 w$ @9 K3 r& e
  831.   #--------------------------------------------------------------------------
    ; e/ E4 ~* Q; o/ l. a" q
  832.   # ● 光标向下移动0 n$ Y" Z- A! Q
  833.   #     wrap  允许循环
    ) ?, P7 @* b& o6 J
  834.   #--------------------------------------------------------------------------
    2 n. Z( B% q% Q# T
  835.   def cursor_down(wrap); ]& j1 o1 `' e  Z! t) \0 W
  836.     if @index  9 or wrap" n% @: ~* y  o
  837.       @index = (index + 3) % 12
    ) A6 H- x# E6 K( D! d
  838.     end- e1 M. e; c( @8 N  R% O
  839.   end; J+ M- X+ b* Z" K6 M$ N8 g
  840.   #--------------------------------------------------------------------------8 ], P4 y( k$ ?9 O/ ]$ i7 H
  841.   # ● 光标向上移动
    ' Q! a( [* o( X: C/ w4 Z# q
  842.   #     wrap  允许循环
    # `. M$ F3 b! |; X5 r
  843.   #--------------------------------------------------------------------------
    " U4 r& U. ?9 R. l( C7 }4 h& M
  844.   def cursor_up(wrap)
    5 p- C! g2 Z/ m
  845.     if @index = 3 or wrap
    3 k9 m  {$ _8 ~4 ?9 c% ^3 _
  846.       @index = (index + 9) % 12+ Z- I4 x3 i& e5 T' O/ o+ i
  847.     end
    . g$ [, G! f. z2 X
  848.   end! W/ H- h0 Q! Y% {/ Z- Z
  849.   #--------------------------------------------------------------------------- H( {: j3 {* ?5 q3 Y( i) j" \5 e
  850.   # ● 光标向右移动! I; O  E- z- R2 |0 }' U" R
  851.   #     wrap  允许循环
    % {) ~( b' f6 f  F9 C# A
  852.   #--------------------------------------------------------------------------3 O% `2 ~7 u* l6 s, B
  853.   def cursor_right(wrap)5 u/ |: V& s5 _, z
  854.     if @index % 3  2! X0 J7 Y" D' a9 J! J- l' J
  855.       @index += 1& j5 U% ]# q" W8 ]( Y7 k. @  h
  856.     elsif wrap5 ]5 w2 N1 U7 P: i* X' U) B$ j
  857.       @index -= 20 R  y; g: n0 L5 w8 O
  858.     end
    & F( F- F. y" v$ B3 N
  859.   end% W/ I: O( J) ?$ d# F4 r8 A+ _
  860.   #--------------------------------------------------------------------------
    ; i9 f0 E' J8 x! K' r* x( u
  861.   # ● 光标向左移动5 {6 p, I; Y, k5 o; S( w
  862.   #     wrap  允许循环& j4 s& K! G3 q. N* t. ?8 e+ k  d$ r  j
  863.   #--------------------------------------------------------------------------
    4 D7 O. u% D2 k+ v0 m/ X
  864.   def cursor_left(wrap)4 ]3 h+ i- M( J: M( ]) K; H5 {
  865.     if @index % 3  0
    * g: |8 P- J% u$ h3 l; A$ @
  866.       @index -= 18 `) f+ G3 g( D  w. b, {
  867.     elsif wrap
    ; T- _/ q0 o! r# T* x& q7 J
  868.       @index += 2
    ) h) T3 ^, t! L& s# I0 z& e4 x
  869.     end1 o$ Q% F6 a3 J$ d3 {8 r; r
  870.   end  ^7 Z+ w3 P7 ?, H7 R! W
  871.   #--------------------------------------------------------------------------
      Q; B$ a0 N: W; G% }9 f3 H
  872.   # ● 处理光标的移动
    ! J: m& ]' O" N, K8 J  i
  873.   #--------------------------------------------------------------------------
    & a1 L0 n0 C' m5 \$ S* M: y
  874.   def process_cursor_move
    # T* ~  i4 P2 K
  875.     super2 H- U" R2 b* ?
  876.     update_cursor0 ^8 W5 y! f, d7 n/ K9 T& W# k
  877.   end8 d# _9 ~2 O) u3 n, N& n: P
  878.   #--------------------------------------------------------------------------
    ! k$ ]6 |2 S* f3 g# [* Y) U- n# p
  879.   # ● “确定”、“删除字符”和“取消输入”的处理; }" G6 Q) ?% v, l: H7 \4 X' R5 d
  880.   #--------------------------------------------------------------------------
    , r* J, J6 q! e) L* [: E9 g; q4 U
  881.   def process_handling
    . c6 |& C4 g" q+ N' w7 e
  882.     return unless open && active' o$ x1 H; W1 P+ f8 {% F! I* p1 C, p
  883.     process_jump if Input.trigger(A)
    2 ]" A  T, D* q
  884.     process_back if Input.repeat(B)
    % e6 i! @$ a9 t, g% W7 a
  885.     process_ok   if Input.trigger(C)
    0 h! {3 _( C1 T& s; S
  886.   end' D/ w+ }$ n" i" E
  887.   #--------------------------------------------------------------------------
    : m! {3 [  T: H' I, w& M
  888.   # ● 跳转“确定”
    ) L  D- q7 C% H
  889.   #--------------------------------------------------------------------------
    / F; V0 q- k3 \! g' V2 F0 s# a
  890.   def process_jump
    2 z0 i/ t6 o+ f; F4 O
  891.     if @index != 11; n' N5 ]" O" p0 J7 h, z
  892.       @index = 11. t: @+ E" q: S* f& F& ?' b' ]
  893.       Sound.play_cursor
    : b* g0 U/ m: e. j1 f( e8 M
  894.     end
    1 N: J: Z5 I/ }' K) c
  895.   end
    + t% U$ [. ^' I! g
  896.   #--------------------------------------------------------------------------
    0 P; T( N6 M$ D1 g# v! Q6 X
  897.   # ● 后退一个字符' s! v$ Z% X: ^8 @3 }4 X' U
  898.   #--------------------------------------------------------------------------" ?7 R* r* u3 W" w* A
  899.   def process_back
    / F) ^" ]) O" H
  900.     Sound.play_cancel' h9 N# }( I2 l( U1 Z; v: M6 S; V, Z
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    - e* \3 i% k+ s
  902.     n = (@number  place) % 107 s# ^+ L) f2 Y( v! h3 l
  903.     @number -= n  place$ E  a1 z# x7 t  P& d6 Z6 L& q
  904.     @number_proc.call(@number)6 F" `* r0 r; f2 u. `
  905.     @old_window_index -= 1 if @old_window_index  0
    % ]7 E1 c8 O6 w2 r8 _0 E8 K
  906.     @index_proc.call(@old_window_index)
    % P# Q1 A( c! E4 h2 ]
  907.     @refresh_proc.call
    , e" n9 w% Y, U" Q- q
  908.   end: ~3 t- X, Y8 b+ v
  909.   #--------------------------------------------------------------------------* a9 }5 }0 D. t( @- I0 N7 ^
  910.   # ● 按下确定键时的处理- H( S9 B- K: ]% U5 m$ q
  911.   #--------------------------------------------------------------------------
    * [! F9 x; ]8 \0 x9 z( D/ r+ W4 s
  912.   def process_ok+ z2 m% F+ ?9 j, \! H1 z  `
  913.     if get_number3 K  Y: L6 O% t# Q8 r4 o3 Z8 @
  914.       Sound.play_cursor# q8 A, w2 ]( B4 ~2 K" j" z
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    # P7 [0 S3 p: o3 ^( e6 X
  916.       n = get_number - (@number  place) % 10
    . }, T/ L1 Y0 Q; M$ x! H- G3 Q2 s
  917.       @number += n  place. z' o5 h* w# d9 |3 O/ z2 \% a
  918.       @number_proc.call(@number)
    $ l1 P- J2 {: g. Z' K
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1+ c( ?. _9 f2 j% N
  920.       @index_proc.call(@old_window_index)
    $ b7 C( {* f7 R( ?3 D) O8 T6 e
  921.       @refresh_proc.call
    7 P2 q& V9 N  ~$ V
  922.     elsif is_delete2 e, G' d4 t7 a9 k$ G3 A' K* t
  923.       process_back
    4 D3 i7 z2 m6 V  p& B
  924.     elsif is_ok
    " t# @0 w: b8 e/ J3 g
  925.       on_input_ok
    ( h0 X4 T, }4 @" {5 v& @# ?0 U6 }' ~) J
  926.     end9 ]- R& D1 o9 q
  927.   end* D3 m/ l2 Q! S' V* q
  928.   #--------------------------------------------------------------------------
    6 c( }( N! \* m2 `- v) |, C
  929.   # ● 确定
    7 S) ~/ Z. Q3 U
  930.   #--------------------------------------------------------------------------* M) a- |7 x$ |( w' Y6 T) o# n, N
  931.   def on_input_ok
    , m, Z3 c. A( v, t
  932.     @index = 0, w! f! e/ A+ x, L8 O& |7 k. E3 v- V$ w
  933.     @old_window_index = 0
    9 f: i8 T/ }% M+ _: U
  934.     $game_variables[@variable_id] = @number
    + {! s5 d/ a6 y8 H
  935.     Sound.play_ok
    " y# n5 Z/ C6 a9 Q4 X
  936.     @close_proc.call
    " A; e0 K# Y4 F6 [$ J
  937.   end: C$ N' ?1 s+ X, d1 ~6 _
  938.   #--------------------------------------------------------------------------# h+ M: o) F/ Y! g' }" x
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    5 G  r* q- r1 T' k* m
  940.   #--------------------------------------------------------------------------
    1 ]6 k! U$ p. t+ ?' ]. f
  941.   def set_mouse_pos
    . I' \: }( [$ i' B4 T1 p
  942.     if viewport.nil # necessary!
    3 V( `$ T' F/ k9 U; G+ p! }' S0 B
  943.       vp_x, vp_y = 0, 00 q6 k# U  o0 b5 d1 u+ A2 s
  944.     else
    ( y9 D. ~2 B' Y: F) E
  945.       vp_x = viewport.rect.x - viewport.ox3 p4 \% I) I+ i
  946.       vp_y = viewport.rect.y - viewport.oy
    ' G* `& b2 H- u8 N9 f! d# O) P* z
  947.     end1 ?  ]9 G: P( e% Y8 [5 B
  948.     item_x1 = vp_x + x + standard_padding
    + S  G9 f8 R$ K; |
  949.     item_y1 = vp_y + y + standard_padding- a, z+ q9 G) V0 \! d3 ]+ V* |2 r
  950.     get_index = @index  0  0  @index
    6 I( E, T% Z: B. F% t! d# R/ P
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)* g5 v5 z2 A3 n! _7 f3 Q
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    2 b" U* D8 }8 a: M! G) n
  953.     Mouse.set_mouse_pos(new_x, new_y). r2 L) }9 h2 A
  954.   end
    1 {2 C2 I% H; E
  955. end7 E0 }  t* A, B" e" n3 W

  956. 2 g7 c! j: J7 H2 B
  957. #==============================================================================
    ) Z, o( }  D# u& K/ y
  958. # ■ Window_Message
    7 o5 K: d0 R/ F5 N. s) V! P
  959. #------------------------------------------------------------------------------: Y* I# R8 b+ B
  960. #  显示文字信息的窗口。
    , a4 H; p, |$ }" D' ]
  961. #==============================================================================
    ( {3 @* W& ~0 z+ f
  962. class Window_Message  Window_Base# A( m. [. Z+ e
  963.   #--------------------------------------------------------------------------' T" P  q& `2 D  X2 Q4 H6 i) J3 G; F
  964.   # ● 处理数值的输入(覆盖原方法)+ s9 L2 L4 t, F" j
  965.   #--------------------------------------------------------------------------$ \/ q0 U* d, |
  966.   def input_number
    0 A; n8 e& R8 z  ^- M, }6 l
  967.     @number_window.start
    + b. p& I6 v1 k# u+ G( I  ]: L
  968.     Fiber.yield while @number_window.extra_window.active  x/ R# i$ \* G. [1 P' e
  969.   end, L; X3 |3 ^: E; E
  970. end8 o5 b" W* V% M# |+ d3 ?

  971. 5 h. I7 \& l6 `/ H6 u5 B6 t
  972. #==============================================================================
    # B3 [* W. [5 v: k
  973. # ■ Window_PartyCommand
    " A  s$ \* e9 Y# {! X1 _
  974. #------------------------------------------------------------------------------0 K4 B, S2 Z% ]1 g, ~0 w
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    ( a2 O6 B/ J$ E
  976. #==============================================================================
    ) d+ E( }( @2 E! j9 L+ c4 V* `, v
  977. class Window_PartyCommand  Window_Command
    ' e' }* s) @' H( b0 j! Y
  978.   #--------------------------------------------------------------------------/ M: q; S$ s( [1 I
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    6 h7 H1 P  @: L$ b3 K* Y
  980.   #--------------------------------------------------------------------------
    1 }8 E: n5 B! s$ H7 B% g
  981.   def set_mouse_pos
    $ `$ f& d  {* w# z
  982.     if viewport.nil
    ; A8 O5 M& @' R7 h! }+ V# _# h6 |
  983.       vp_x, vp_y = 0, 0
    $ w0 R) c% v" V
  984.     else
    $ o% S0 t- X7 X$ G
  985.       #vp_x = viewport.rect.x - viewport.ox) Q) R' \8 G8 C* v+ z4 X
  986.       vp_y = viewport.rect.y - viewport.oy3 A; y, M8 p, ~1 e% T  b. w
  987.     end& a. G. \7 P9 L( o$ j/ q
  988.     item_x1 = x + standard_padding 7 a% [) A& \+ Q& e& D' W8 M; f
  989.     item_y1 = vp_y + y + standard_padding2 j3 v- W  a, q
  990.     get_index = @index  0  0  @index ( s  t0 I6 j# u" [7 e: b
  991.     row = get_index  col_max - top_row
    ! Y! g; q# m2 _$ `  y
  992.     col = get_index % col_max8 Q0 m- ~4 W9 k; J/ r: u
  993.     new_x = item_x1 + item_width  (col + 0.5)) F5 |# D; H% p4 o
  994.     new_y = item_y1 + item_height  (row + 0.5)7 W/ f% P% V: ~4 J7 s$ o
  995.     Mouse.set_mouse_pos(new_x, new_y)# T6 P* o  N% L' F1 Y5 i
  996.   end
    ( c  N7 j- H' C1 D
  997. end/ e  x8 l" f0 k$ D( U8 v
  998. 0 h& `& S, }4 p# h% A
  999. #==============================================================================
    ; w' ?3 C4 i1 W2 J  W
  1000. # ■ Window_ActorCommand
    & a$ }, x$ ^# q+ Z; `& F% X  w
  1001. #------------------------------------------------------------------------------
    . |) M% s) ^- c- w7 P# Z
  1002. #  战斗画面中,选择角色行动的窗口。
    & k, n1 b5 K& p6 h) h; s  _
  1003. #==============================================================================
    7 ~+ _4 K& e) S+ g3 y
  1004. class Window_ActorCommand  Window_Command) X5 m7 C2 L5 m$ j
  1005.   #--------------------------------------------------------------------------$ g) _+ A) A. \5 d+ z5 k
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    2 J& x8 p; g! L0 T7 p) V* _
  1007.   #--------------------------------------------------------------------------
    8 [. H% j( U4 v/ G& y$ _
  1008.   def set_mouse_pos
    / L! X0 d: G  ?0 s1 `) U
  1009.     if viewport.nil
    ! e2 T, O& @# y3 k, {
  1010.       vp_x, vp_y = 0, 0
    / x: N% j# @( B! O6 V/ n2 f3 R
  1011.     else
    6 M; l7 |* a3 g
  1012.       #vp_x = viewport.rect.x - viewport.ox
    ! ]2 g: b' s8 f$ R
  1013.       vp_y = viewport.rect.y - viewport.oy
    : ^2 ?& ~2 i: S7 U6 f6 m" s
  1014.     end
    5 I: p& V# H/ L5 R$ K* f2 M
  1015.     item_x1 = Graphics.width - width + standard_padding
      Y! c. m, |# E( b4 L) h0 R
  1016.     item_y1 = vp_y + y + standard_padding( v6 G+ q! E, M+ B" g
  1017.     get_index = @index  0  0  @index
    * k$ t6 t* a; p( I: Q' y
  1018.     row = get_index  col_max - top_row
    # n  n! ~! W9 o' H" {. W
  1019.     col = get_index % col_max
    3 c- n" y) G# R7 l$ ?
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    " I- x3 W! J4 i$ [  ~7 j
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    7 w! U5 n+ W  L* u9 G3 Q
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    ) E, r7 P; E7 B7 S6 Y! m( i9 ^
  1023.   end  M+ g) u+ R' r8 [+ B4 E' s
  1024. end
    ) q& N0 X* l0 w9 w4 A6 {

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

  2145. " W' `. C) I. G* W8 `8 T
  2146. #==============================================================================# D& d) n5 c2 n* P+ v# ^8 ^& ]/ S* G
  2147. # ■ Game_Map
    ) r2 E) w/ P  N) N
  2148. #------------------------------------------------------------------------------, c4 k2 d) ~. Y) D4 z, V+ I
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。) t& n; ?2 C. i- F% @: }8 m3 }
  2150. #   本类的实例请参考 $game_map 。
    * x# H& ]9 }" V. |$ ?8 I  {
  2151. #==============================================================================- c, }! u! m- q
  2152. class Game_Map9 h' d; b! V6 m
  2153.   #--------------------------------------------------------------------------
    / @5 f' C0 I0 w1 K7 }8 q
  2154.   # ● 定义实例变量" E: d. z0 g# |4 x5 ~9 x; A
  2155.   #--------------------------------------------------------------------------2 g: H6 D+ d" h  M9 u
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
    0 U0 K! K; Y2 T$ U) B* _
  2157.   attr_reader mouse_map_y # 同上
    - v( B; I9 b% F% w& a0 w+ P
  2158.   #--------------------------------------------------------------------------+ p& K, ^$ s% z
  2159.   # ● 初始化对象
    4 e% ]- u* e: T0 U1 \6 y% x
  2160.   #--------------------------------------------------------------------------7 h" {$ \0 [. t% t  f8 c/ S
  2161.   alias sion_mouse_initialize initialize/ E" i3 \- o$ R( D
  2162.   def initialize2 ^2 }0 X2 Z  H6 G- L/ w" _: a
  2163.     sion_mouse_initialize$ U5 J3 {$ ~( R+ |6 i: |: r
  2164.     creat_move_sign  ###
    / T3 n1 P8 m  P8 N- W1 m$ K/ t4 W8 a
  2165.     set_constants0 [  N( C/ n8 m: m
  2166.   end, N3 a, ~/ _) L+ S4 L
  2167.   #--------------------------------------------------------------------------) M9 |* I/ d4 F& s0 N
  2168.   # ● 更新画面
    % P% I1 O; _* e& G& W  t
  2169.   #     main  事件解释器更新的标志
    $ v1 A- h# d" Z
  2170.   #--------------------------------------------------------------------------
    9 \3 Q9 L& ~! P# n- p2 t- l$ {
  2171.   alias sion_mouse_update update* ]+ d5 D6 F7 [5 |7 k: Q
  2172.   def update(main = false)1 _# r' E* r0 m+ f
  2173.     sion_mouse_update(main)
    - L9 M7 k4 V4 v+ F, G- v: z
  2174.     update_move_sign" U7 j+ q& b& B) n# B
  2175.   end! f- A9 i# U3 b$ d( v2 Z
  2176.   #--------------------------------------------------------------------------
    # u  U- U2 B. ~6 f: m2 k8 h
  2177.   # ● 创建显示路径点的事件
    3 v, ?9 z9 J1 C' [5 T
  2178.   #--------------------------------------------------------------------------4 v% A6 M/ y- h8 l  i- E8 ~3 b
  2179.   def creat_move_sign
    ; ]: D. ]* \- p7 W" r6 V
  2180.     $mouse_move_sign = Move_Sign.new! a7 y6 j4 L5 K4 C4 D
  2181.   end2 s. b5 `) [) T/ s- d* B! W
  2182.   #--------------------------------------------------------------------------
    / S5 @4 e8 R: m  u; @& t
  2183.   # ● 更新显示路径点的事件+ g* _1 C" i0 l9 f: Q3 G
  2184.   #--------------------------------------------------------------------------6 x7 R$ i4 H# r
  2185.   def set_constants
    " y6 i/ E1 l: T! [
  2186.     @mouse_pos_setted = true
    - K" X9 ]7 e, Z  Q3 |
  2187.     @set_pos_prepared = false
    ( f% C: m; U9 k% v; b- b* l6 t
  2188.     @mouse_old_x = 0
    . n7 c( p" _3 q' o
  2189.     @mouse_old_y = 0
    6 {% p/ j) u$ `2 w( V9 j
  2190.   end
    ' c& j- U1 U" x2 ?0 E
  2191.   #--------------------------------------------------------------------------, a% ~4 w; w$ e  c- I4 u8 j
  2192.   # ● 更新显示路径点的事件
      ?6 a! x) a/ q% K2 x, F, d3 K! A
  2193.   #--------------------------------------------------------------------------1 J0 k+ ?. I  k' y
  2194.   def update_move_sign
    , N! K* f5 w; j
  2195.     $mouse_move_sign.update
    0 D; V) m3 X$ k3 e
  2196.   end; h8 ~& i  {- }
  2197.   #--------------------------------------------------------------------------
    8 g, H$ [1 p+ w- k  ~* h
  2198.   # ● 获取鼠标位于的地图块的x、y坐标- U- T8 o1 U) M- Q: x
  2199.   #--------------------------------------------------------------------------3 g4 f' D* e/ x- `; w3 z
  2200.   def get_mouse_map_xy
    ) _# F- Q2 f' E1 a
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    $ m2 V8 i/ f+ C" E1 H& k' ^
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)7 }. y) ~8 e0 [3 U
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)/ @) e, S& W, N  O0 t9 x, Z
  2204.   end
    ; D* b" \4 x4 w# L
  2205.   #--------------------------------------------------------------------------! u8 Y$ d2 C7 t2 N! y8 d' L
  2206.   # ● 返回地图画面时重设鼠标坐标
    ! n9 U8 ]1 I3 C% n* R* o' c
  2207.   #--------------------------------------------------------------------------
    % g  x# T7 \0 O) U/ a
  2208.   def reset_mouse_pos
    * {; E& ^7 W/ ?
  2209.     return if @mouse_pos_setted
    # P( t. F6 t+ c  W8 B- |
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)& ^8 n! \$ b2 ~" B2 ^) r
  2211.     @mouse_pos_setted = true
    6 M4 r6 @  O2 ~) u, V, x
  2212.     @set_pos_prepared = false
      M6 Y. N, f3 N3 q" o% \
  2213.   end
    ) D- p; t: F' s1 \
  2214.   #--------------------------------------------------------------------------
    / h0 J2 K0 \: L  T0 q. T
  2215.   # ● 重设鼠标的坐标
    & B$ g0 i1 b3 V9 R8 u  O9 [; X
  2216.   #--------------------------------------------------------------------------' {) M* m" F3 D1 y6 X% ~
  2217.   def prepare_reset_mouse_pos. z7 W! j$ k/ A5 i
  2218.     return if @set_pos_prepared1 n0 f. C- C, E, M2 S2 C# A
  2219.     @mouse_pos_setted = false
    - H7 \; N& G7 c) o2 y
  2220.     @mouse_old_x = Mouse.mouse_x
    * y) ], q: G& Q
  2221.     @mouse_old_y = Mouse.mouse_y) r4 m4 Q: ]& `* M5 _& A
  2222.     @set_pos_prepared = true3 e  \  m: H, l" k9 Z- w
  2223.   end) H" |) H8 F# |2 y0 h. T- l1 Z
  2224. end0 h2 k1 x! D8 m  u5 W( P

  2225. 5 @6 M: f5 x! b5 h# r: H& n
  2226. #==============================================================================1 J( k+ ~, G$ r
  2227. # ■ Spriteset_Map# `* U7 t  p1 E
  2228. #------------------------------------------------------------------------------
    $ Z- ~. d, f4 Y! Q
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    & H5 ]5 F  v* D/ f
  2230. #==============================================================================
    9 u5 K$ j  r; _1 t7 {" k) m
  2231. class Spriteset_Map
    . }  [& n: s% i* g/ @1 y
  2232.   #--------------------------------------------------------------------------$ `9 a- G9 i( i
  2233.   # ● 生成路径点精灵% d1 ]) u* l* ~) v* N  s3 O8 Q4 Y
  2234.   #--------------------------------------------------------------------------4 _0 {7 h; F. Z9 Q! L1 @
  2235.   alias sion_mouse_create_characters create_characters
    * w' U  r) n8 T: d( E; d1 o
  2236.   def create_characters
    , y; f: _5 f! K: e# ^4 M
  2237.     sion_mouse_create_characters$ C$ T* m* M6 ~
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))% Y- w1 Y* F1 C
  2239.   end
    3 q/ N2 v" P; t/ w. Y, ^8 @
  2240. end
    % }& b$ W' q' K2 O# P( [0 l

  2241. # Q* i9 U% x6 O% S3 d5 P
  2242. #==============================================================================
    9 g& @  q# j) I
  2243. # ■ Scene_Map5 j0 L$ j6 }/ ~. Z' \- s, j
  2244. #------------------------------------------------------------------------------+ b2 d  g9 f6 \9 H) r
  2245. #  地图画面! x. V+ n' t# `0 v, ?! {- o9 t% j
  2246. #==============================================================================
    2 s! R8 {, u( i
  2247. class Scene_Map  Scene_Base
    & F2 |/ F/ W1 Z
  2248.   #--------------------------------------------------------------------------- P9 i7 t- i0 `2 V  d& ^; \
  2249.   # ● 画面更新
    8 O. b. x' T5 F$ t* q+ `+ ?2 o
  2250.   #--------------------------------------------------------------------------& i7 S: p7 k* x6 r: [* q( G
  2251.   alias sion_mouse_update_scene update_scene
    8 r! i* I9 G! q/ j3 e
  2252.   def update_scene
    ' Y+ @5 P  [2 ]5 }, _, m5 v, j
  2253.     sion_mouse_update_scene5 S' P$ K' x9 Z% S% T% ]0 g- D, P* u
  2254.     update_mouse_action unless scene_changing& `2 E& h) j2 V6 i1 U4 ~
  2255.   end( M! K0 [6 C, B. G3 r* u6 m1 \
  2256.   #--------------------------------------------------------------------------
    : g9 k" i" K! n( Y& C$ m
  2257.   # ● 场所移动前的处理( V: }1 W. f9 d2 R
  2258.   #--------------------------------------------------------------------------
    + |: J; o6 h, O) K& J3 u
  2259.   alias sion_mouse_pre_transfer pre_transfer
    6 `) c# s  F  i) V' y
  2260.   def pre_transfer
    6 i$ r0 i5 f$ Z
  2261.     $game_player.reset_move_path% W: j* ?# I9 ~
  2262.     sion_mouse_pre_transfer) ~% Z5 p  E) t, L/ ]
  2263.   end$ S- P( B0 s8 ~; Q% @# u; z
  2264.   #--------------------------------------------------------------------------
    5 D2 ^( z. o' l! W/ S& Q
  2265.   # ● 监听鼠标左键的按下7 i9 V3 y. T8 H' Q) v0 [
  2266.   #--------------------------------------------------------------------------
    ' U, y7 Z( ~/ F8 h! d& j8 z0 i
  2267.   def update_mouse_action. U& L% z* ^% j+ E6 x8 p) \
  2268.     $game_player.left_button_action if Mouse.press(0x01)  S" q" _! B, h6 D1 z
  2269.   end- e; r1 {) ]; [  N, u8 G
  2270. end
    - l5 `5 D1 q. \" D

  2271. 4 k; v7 A4 f) B# ^, |
  2272. #==============================================================================( f' w2 B. \# Z* t$ l: D
  2273. # ■ Scene_File
    ' ?+ j! V( \  B' I# x5 G
  2274. #------------------------------------------------------------------------------+ K6 I+ i( C% s5 g0 e# G# x
  2275. #  存档画面和读档画面共同的父类
    ; R7 z2 o5 S6 g8 @
  2276. #==============================================================================2 l* L" q, D5 N5 G" h2 J* \3 ]
  2277. class Scene_File  Scene_MenuBase
    3 Y6 p7 W% E' v; S' F
  2278.   #--------------------------------------------------------------------------& n0 X4 Q: [. J. j
  2279.   # ● 开始处理" y5 a7 v+ b! q% Q5 d6 k: Z
  2280.   #--------------------------------------------------------------------------
    # p% u' y4 h' i% [. j- k/ y
  2281.   alias sion_mouse_start start" m+ _- J2 U2 c! ^
  2282.   def start
    2 b) x% K7 z; Z
  2283.     sion_mouse_start* E9 W8 P; b+ G9 c  `3 p
  2284.     @move_state = 0
    9 t* H( {& n6 [, T9 O
  2285.     set_mouse_pos
    2 e: y$ J  ]8 Y, a
  2286.   end
      P8 E9 E$ \, S4 u- T  ]6 a; a. i
  2287.   #--------------------------------------------------------------------------# B; z' D# Z" P" V
  2288.   # ● 更新画面
    5 M6 T; z- `3 W$ l% H1 B
  2289.   #--------------------------------------------------------------------------2 ]% f; P* H! t: G6 x  x0 i. B% Y
  2290.   alias sion_mouse_update update
    ; N. \" b* o/ b0 e$ m1 g+ Z4 o
  2291.   def update
    2 Z6 r, }0 O/ ?+ r; j' d8 C$ g
  2292.     sion_mouse_update. g* h/ h" l1 S4 j' k
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    7 z% {' C. A2 J9 t1 B1 D
  2294.   end: o  t& @6 C3 |5 I: ^) z
  2295.   #--------------------------------------------------------------------------
    - O4 I) o; h4 G8 @- k$ H- P
  2296.   # ● 更新光标
    / b: e$ k- ]7 K5 P9 ]$ _
  2297.   #--------------------------------------------------------------------------
    + J2 p& j) ?) d: `: p1 `6 `
  2298.   def set_cursor, ?: E8 W, h) e  n2 s
  2299.     @move_state += 1) ~2 i+ K' ~( `+ o; W) n6 ?
  2300.     last_index = @index* n+ u, ~/ `" n0 `# ?
  2301.     if mouse_which_window == -2
    , D4 [% Q. [4 q: c: M
  2302.       if (@move_state - 1) % 6 == 05 S0 y; u, k  q) `9 A& U& d
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1. X. w. \1 v$ V' L$ X+ |/ Q
  2304.       end
    & I; Q& w& d( F( g- Q1 m1 c' h
  2305.     elsif mouse_which_window == -1
    5 A' e. ~' d4 q- D  {% l9 f3 g
  2306.       if (@move_state - 1) % 6 == 0
    8 T6 G+ \( s3 O5 ]& m
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    % m  `- ~! N( N; v5 P
  2308.       end
    % S- |; c2 Q' }4 G
  2309.     else& I3 q  k/ d6 W# V# ]) g- u
  2310.       @move_state = 0
    ; }# x' N" M+ W- p
  2311.       @index = top_index + mouse_which_window
      r5 C$ J2 n& j3 m2 G3 ~9 A, \
  2312.     end9 M  ?. K, [# P# N& b. l
  2313.     ensure_cursor_visible
    3 f. C5 K0 V9 h( ]+ k* I5 P% J
  2314.     if @index != last_index
    $ w" k* z7 A/ N! S- k+ z- ]4 p1 w
  2315.       @savefile_windows[last_index].selected = false
    8 D2 a( G8 d- y5 R, z
  2316.       @savefile_windows[@index].selected = true1 V' E8 L3 l- I! t3 X7 h+ S
  2317.     end( g8 Y$ W  _5 `3 C- @. x( }$ I
  2318.   end
    4 s* l' ?2 @4 }  A  _0 t7 \% T
  2319.   #--------------------------------------------------------------------------+ a* {  }' i$ U2 A, t/ ]; ^
  2320.   # ● 判断鼠标位于哪个窗口
    5 e+ V+ @8 h( J% W
  2321.   #--------------------------------------------------------------------------: N1 L# G. ^% ~
  2322.   def mouse_which_window
    - J/ Z0 ]: p* Y  V9 ]+ @
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y  J7 \$ w4 {2 c; c# R
  2324.     if mouse_y  @help_window.height + 14
    " n1 K, s6 y- F# X3 T& |
  2325.       mouse_row = -1
    ' ?3 O0 \# H& J+ u
  2326.     elsif mouse_y  Graphics.height - 14
    & V1 u$ N  H5 g5 o" N& K/ t
  2327.       mouse_row = -2
    . I# t6 b8 V' a6 V* W: S8 Z
  2328.     else0 U+ K9 _: G) W) d* V
  2329.       mouse_row = 4  (mouse_y - @help_window.height)   K" u3 D. D4 v4 o$ `& C4 n
  2330.         (Graphics.height - @help_window.height)
    9 }3 o2 o' U/ S  c) j: w- c
  2331.     end$ U% c4 h* }! I; d; G, R7 n
  2332.     return mouse_row) H1 V0 M& O4 e7 {% a( I( ~
  2333.   end6 k5 n9 x/ i7 C" ^# y) e
  2334.   #--------------------------------------------------------------------------
    8 [) W- ?4 \6 V7 m. v" C
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ; u% y; q$ b5 H+ ]
  2336.   #--------------------------------------------------------------------------, r* @- u3 e3 K! }6 D
  2337.   def set_mouse_pos
    & q$ |' t* X+ ]" I& n
  2338.     new_x = 40
    ; Z# r( t* w" @: i2 q- g
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24. B  x! ]1 A  Q) N: X
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    ; Y9 g5 ~' U) n1 I" d9 k
  2341.   end
      c$ j( Z  x$ ]5 J) n- }
  2342. end
    : B' _3 @  P" D- f2 ?, O( _% |( D

  2343. 8 X7 n6 L. ^2 D$ H) Z) |
  2344. #==============================================================================; |5 j9 v% F5 c4 v0 O8 |
  2345. # ■ Game_Event3 a% C" Y. H8 z! v! ?  s5 u) T! h
  2346. #------------------------------------------------------------------------------& h8 f/ V- R' g) }! y9 n
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    - Z6 B) |2 X- L/ L
  2348. #   在 Game_Map 类的内部使用。' s! w' o1 ?8 N' @0 ]) M
  2349. #==============================================================================
    7 b$ K- R7 N. k- U/ |; L
  2350. class Game_Event  Game_Character/ S8 d6 h3 Q( O' x8 Z
  2351.   #--------------------------------------------------------------------------5 M. |& n) I3 d) B  n3 b3 Q% {
  2352.   # ● 事件启动/ z& t" v( v) f8 }8 |
  2353.   #--------------------------------------------------------------------------
    8 h8 b7 ^- w! u9 ]0 t" F
  2354.   alias sion_mouse_start start
    7 s7 g7 E) c* ]8 T% Q1 r5 h0 c
  2355.   def start
      X9 G  A! p- f8 ^3 I' J3 w& L
  2356.     return if mouse_start && !Mouse.press(0x01)
    / O: S5 R0 H' Z% Q
  2357.     sion_mouse_start$ Y, V: A% [- Y9 X
  2358.   end
    & B2 m% m! P! Y4 H
  2359.   #--------------------------------------------------------------------------; v8 C9 @& G% v; W4 |9 D5 G5 m/ W
  2360.   # ● 判断事件是否由鼠标启动
    + m7 z0 M4 `/ G0 Z/ z
  2361.   #--------------------------------------------------------------------------2 a. i1 s0 I. K0 N1 X
  2362.   def mouse_start) Y; b- X  x/ r& B( C* A
  2363.     return false if empty
    , L: K% R% K$ Q) E  H; n- y) ~2 f. w) }
  2364.     @list.each do index
    ( Z5 [6 E; i# n) }1 f9 u; m/ C
  2365.       return true if (index.code == 108  index.code == 408) &&
    8 X) Q6 ~' }3 `5 C, Q4 k# N
  2366.         index.parameters[0].include('鼠标启动')
    5 g* T$ [* S% a* p
  2367.     end, d/ e2 ~  o/ O# n
  2368.     return false
    7 Q9 h: o4 K3 P! W; i1 g9 a
  2369.   end5 A3 O6 i" d$ e- x- m7 {
  2370. end
    4 C3 s$ T5 b1 E& f

  2371. - s& {3 o$ I( N) V' j' D6 l
  2372. ####泥煤的height" Y8 Q# J: @7 h+ K3 S( U& W$ _: d
  2373. # @height = height+ Y# p" j3 L! E# S/ ?0 Z+ n
  2374. 0 r5 v( D/ s2 b' y# X" u
  2375. class Area_Response
    8 @: `% v# x! ^$ w# ?* f: h7 S
  2376.   attr_accessor type$ c4 p2 Q$ g* ]/ |
  2377.   attr_reader ox
    7 ~  p2 T# V( Q* J  x) u2 d
  2378.   attr_reader oy
    ' W# u- Q$ u, t4 O1 w
  2379.   attr_reader width
    5 ]6 v4 t" e8 x
  2380.   attr_reader height
    0 K! M5 `( ^% l9 `; M5 H5 w, H
  2381.   attr_reader switch_id, t' `0 j, u' D
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    ) j6 P4 I! ~: A0 {1 O
  2383.     @type = type" ]) D+ J5 J1 I6 E( Z
  2384.     @ox = ox
    - _6 P, I# q3 ^8 Y! u5 d- [
  2385.     @oy = oy/ O5 u# l0 N1 ^: |7 r3 `
  2386.     @width = width- q4 }8 C) H/ f1 g
  2387.     @height = height0 B' I" x7 P; L: V% p# h
  2388.     @switch_id = switch_id' m4 h* D# N7 c
  2389.   end3 x8 o4 c9 K& ]4 V* J1 [2 h9 d" c( R$ k
  2390. end" G* ?4 L3 z, ~

  2391. 3 I% H" X; N0 u. Z
  2392. $area_responses = []$ X3 Z; h4 Y$ K$ w- K$ b& F
  2393. , T/ Y& t0 m5 ]$ L+ ~; C6 `
  2394. class Scene_Map, U' S6 {1 w3 m# x  [1 `
  2395.   alias update_mouse_2013421 update_mouse_action$ a1 z: ^0 J3 @! a+ U
  2396.   def update_mouse_action: t- }$ R! A& X( ?1 Z' A
  2397.     update_area_response* \! g# L; H6 B; b
  2398.     update_mouse_2013421
    . h5 n, ^) b) h) `
  2399.   end1 F# I( w3 B' V% d
  2400.   def update_area_response
    ) C! Y# u9 @( y- c/ h/ y5 I4 Y
  2401.     responses = $area_responses
    3 K( J, s" E/ t- C
  2402.     responses.each {response
    % c0 x# m. l) u& [9 Z
  2403.       ox = response.ox
    1 d. a7 j, z* C$ {  A. Y3 T0 C5 i& E
  2404.       oy = response.oy
    % p: Z# q, T, X9 C  Z" A( ]) U9 j
  2405.       width = response.width
    / @/ h9 J; `) p, A
  2406.       height = response.height
    2 u3 Q" w0 [" v2 _+ w7 D
  2407.       switch_id = response.switch_id
    2 l( w5 d" \+ M, G( q! n% O: M3 L( R- l
  2408.       case response.type5 j2 ~5 S+ ^# G+ A3 M7 m7 P0 ~$ B8 c
  2409.       when 0# y& N. j% S% h* ~: Q( a* y
  2410.         if mouse_in_area(ox, oy, width, height)
    / s4 L3 {" v3 {6 q
  2411.           $game_switches[switch_id] = true. b/ s8 g! C9 X9 X& w* A% m
  2412.           $area_responses.delete(response)
    3 x4 t0 |7 C+ `9 E
  2413.         end; O, n3 Q* c* c
  2414.       when 1
    3 s$ L: ]% }9 z2 \& S$ X6 a" E( u( Y
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    2 [( |6 t9 l0 r
  2416.           $game_switches[switch_id] = true1 J/ b. O2 L; r- \& S
  2417.           $area_responses.delete(response)
    # w# f1 v1 x; @4 G# }# Y+ @: N
  2418.         end
    5 o2 v8 R+ C7 m$ V* W( p
  2419.       when 2; \; }% i9 j7 P' V7 l' S6 O
  2420.         if mouse_in_area(ox, oy, width, height)
    ' P7 ^9 O/ c( }4 z
  2421.           $game_switches[switch_id] = true
    7 `! a( [$ [* J+ g+ c* w
  2422.         else
    ' {/ f: B5 \/ s4 D
  2423.           $game_switches[switch_id] = false; L$ x9 y/ X) f: q0 X
  2424.         end
    ; j3 d, W) R1 V
  2425.       when 3
    " Z( f( S6 l" K/ D6 _
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    * ]+ Y+ j; {& B$ m5 R7 w/ d
  2427.             (oy - $game_map.display_y)  32, width, height)
      ?/ ^; M# W2 V, f
  2428.           $game_map.events_xy(ox, oy).each {event) v( {3 y  ?8 K3 K" R8 A
  2429.           event.start; G) F9 G6 @, `+ {0 x% z
  2430.           $area_responses.delete(response)
    ( A) J% X2 r& x" \
  2431.           return; p8 p+ D: s; z& m$ }: O: `
  2432.           } % {3 q% h2 k0 L2 @7 W5 u. H. B
  2433.         end
    , B# Y1 y+ }$ ~8 O5 D  e, i
  2434.       when 44 h  p/ u: e' J9 ^+ I
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,3 h1 f5 d! n& ~
  2436.             (oy - $game_map.display_y)  32, width, height)
    ' C4 r5 X7 v- B! D, U" p  F
  2437.           $game_map.events_xy(ox, oy).each {event3 @6 e& P7 v5 V& A: s6 m
  2438.             event.start
    : T9 M$ H; \" C$ g- a* D
  2439.             return
    4 G8 ?' T9 m* D. v: [9 d+ S5 [
  2440.           } 6 f0 d1 p9 _+ |9 Q" e- L: i
  2441.         end2 @; k* ]* {: d6 z5 C6 y6 x7 ]
  2442.       end( I/ u) s8 ^' b7 w2 w
  2443.     }
    : {. n5 J2 q! |
  2444.   end3 {4 ]5 r% u& k1 R: b; Q. ~" ?
  2445.   def mouse_in_area(ox, oy, width, height)2 t( H: P( x% ]. S% m# g) A" ~3 Y
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    7 x& o) \: V4 L2 p/ n9 ~& l
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    # P* r6 Y- h1 i% B
  2448.   end' n+ H/ l2 [) [7 t3 O
  2449. end8 O+ w  a1 h" {- ^+ m
  2450. class Game_Interpreter
      }" }" z! S  ^0 \
  2451.   def area_response(arg)
    ! L0 s" s& }( H; k9 M
  2452.     $area_responses.push(Area_Response.new(arg))
    9 [; a$ J3 c/ m3 P/ Y
  2453.   end
    6 x  w+ \' _% z& }
  2454. end/ R8 ]3 m7 b. @' Z& P. v, q
复制代码

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

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

GMT+8, 2025-9-11 05:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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