Project1

标题: 存放腳本 [打印本页]

作者: 熊喵酱    时间: 2013-8-29 09:01
标题: 存放腳本
純屬給LBQ腳本:
  1. =begin #=======================================================================* K( Y+ u# ]3 r& m
  2. 9 E2 }( r# e0 W3 v% S+ {( @
  3.   Sion Mouse System v1.3e1 u9 Z; s5 c" ?  o. u$ _
  4.   2 Z( f7 d; R: f# t
  5.   Changlog
    " _9 B- d. I" `) E2 B4 v5 X
  6.   
    * e( C' {7 c( W5 ^3 h7 p& L. g
  7.   2013.4.21 v1.3f
    9 [% j" X* J( p$ B! L
  8.    
    % A8 H" L# P" C3 L) M% E% ^
  9.     1.3f 卷动地图 bug 修正
    6 U- g  R. g& l% F
  10.     1 P$ S5 }7 V, r0 S$ u: s
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    : |: G2 Y0 I3 N$ x" F
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    . j" a3 ~  I4 I/ @" Z! `
  13.                               Mouse.unlock_mouse_in_screen 解除锁定% b* ?0 _1 T2 {4 x3 ]7 n3 L

  14. 4 A3 D( A& f) v  W) o( A5 \
  15.     1.3f bug修正
    ' Y% }' u" @3 g6 e% @6 g
  16.   3 p5 m) y7 }. y3 [! b' O
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及* \; X1 d3 w$ R" _1 w
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    ; }7 u6 K; ?# W4 \

  19. 4 b- z8 ?2 D/ R+ s! [# ~
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处* r* H! `  ?5 h; w. ^

  21. % x, D5 n/ y+ b( c9 |6 V" S' k+ c' _
  22.     1.3b 修正一些罕见的bug;
    7 e) `  T+ w# K: F6 `$ e

  23. ( G+ b7 ^/ U' C$ G1 q
  24.     1.3a 代码小修改;
    / t' J1 N7 x/ ?1 N
  25.           加入了鼠标点击启动事件的功能,/ W: m: N/ g. x2 A& c; [4 u
  26.           在事件中加入“注释”: 鼠标启动  ,1 q! g( c5 C+ {4 U* R' ~; L
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    % `! u. {5 N  P; k
  28.   
    3 }, m+ _( B* r4 u! D& x
  29.   2013.2.12 v1.25 W7 h7 }' ]  `$ y7 h

  30. 6 n+ f) l# m5 G
  31.     寻路逻辑优化;
    2 x4 h  [( E6 J' E1 S' h3 C/ r
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    9 X3 Y- p% w! \9 `5 _* u
  33.     现在支持用鼠标来操作载具了。( }; z  d# \5 }) G2 e
  34. 4 m; W) z( U: e! @
  35.   2013.2.8 v1.18 Y' I/ m! v5 ]4 w* W9 b+ ]

  36. ( @" N* {$ E' _# Z! C
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    1 \" Z3 ]. I$ Z! _
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;$ G+ q" k! r3 D; A& Q# ]
  39.     移动时,路径指示点的绘制更加稳定;
    : Q! \) M7 e3 s7 s8 r- X; b
  40.     现在支持默认存档画面的鼠标操作了。
    " N* N3 f' K% a7 _0 l, O8 f9 F

  41. , }" N5 j6 K! T3 ~& {+ J
  42. 3 I% m, ^& P$ Y7 @
  43.   OrigenVersion, C2 _& s  V3 h1 f" ?6 R' ^2 L. z
  44.   " g$ {% y# ?4 b8 z! Z
  45.     2013.2.7 v1.0   K5 o% R5 w( e; |- W

  46. - [  f% j3 M0 Q2 W+ K! H; F& s; a
  47.   主要功能
    ) t3 Q) F( u" s/ [1 L4 S
  48. + n  n4 ?! ]( a1 P" W
  49.       使用鼠标进行各种操作...
    9 z8 k( l! X2 M) D, f
  50.       将鼠标锁定在游戏窗口内
    $ Z8 R1 G3 ]1 d9 z6 b' \0 ?* f
  51.       自动寻路,按住 D 键可以扩大寻路的范围: Q1 ?  `$ [0 ]4 o9 W/ |; t
  52.       双击鼠标进行冲刺
    $ x9 I- h+ E6 ]5 ~/ D3 a
  53.       更改地图卷动方式以适应鼠标移动" G8 h0 ~; M( |8 X
  54.       变量输入框改良, L- J4 j, F# w0 M

  55. 2 {. G; z3 E, V7 h+ n
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹0 r1 \6 Y$ v3 r: I, U

  57. : U4 b' y8 |3 m! e! k; q
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹9 n7 o0 \+ P  o1 [

  59. ! o' F6 t  }) N/ H/ q3 L8 ~/ V. P
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    9 A$ D' R6 ]+ ]
  61. ( l8 s( t* C: _, j& E) o5 _5 J8 A
  62. # v2 Z: v0 ?% m- L; a& u
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    5 c+ j) m' S1 X

  64. 6 L& w: h& ~4 }2 M6 Q) ~

  65. , g# b, b: r# v' @
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示( i  S9 q  j5 G0 [) k
  67. 4 J# Q: p. D& b6 e3 J% Q" v
  68. #==============================================================================
    6 }% R# i8 ?: K
  69. # ■ 常数设置 * J$ D3 V0 I2 ]( R& J
  70. #==============================================================================/ V1 M; O; {% B. L* Z4 ~8 D
  71. module KsOfSion' M2 z7 C1 z% I, H2 X# q
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false8 T, i) p. L4 e' i, d( X8 W2 w% p
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑5 ]- E, K( a" R! _/ r7 h* m
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    ( o7 D7 P# |- s% l* I- V
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量3 y) X8 f, K% r2 N5 p3 u2 v
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    " j6 ^: V2 T- g, C. J) |
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧2 P; J  n" Z& P. r6 ^
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)) F/ ?" I+ Q; a% w4 F, T
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键, C' ?  u/ k7 q3 [* Y
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)2 f- M) h  _2 y2 e, O) y9 A
  81. end* @& X" G5 {; d$ D2 ]
  82. ! h: }2 E! q" a
  83. #==============================================================================
    * T3 O+ x2 [3 c. `5 O# q7 r/ u% a
  84. # ■ 用来显示路径点的类/ a: S5 p  K0 H& }4 y
  85. #==============================================================================
    ; W) p2 z& x: }9 i* t- w/ I! x  |
  86. class Move_Sign  Game_Character
    . g5 n6 _5 ?! o( C' L
  87.   #--------------------------------------------------------------------------8 K3 e3 H+ w/ a  [4 L9 e
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图+ k% G* B0 f5 ?; t% @
  89.   #--------------------------------------------------------------------------
    / _0 ~% V' w) |: s$ ]
  90.   def init_public_members
    5 Z7 k- {) u4 ?- r! b( ]1 j
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    / X( U( J& s* S  d
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    : U% |2 _5 E8 p, g
  93.     @move_speed      = 5        # ★ 踏步速度" s" P& _; T( d( M1 _, p
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)' y# t8 W, I3 S
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    6 M! R3 u$ p2 G) @
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    " l, T7 e, B2 m8 m
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列& I" H: R2 f4 A' h, ?8 G, o
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    ( x( x; S- b3 j: F5 H
  99. 8 J  O( m8 e# H+ X" a3 ~

  100. + o# S- r, @& H9 S  _
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★$ {  S  X0 q( o' n8 U9 a

  102.   i7 r0 Y4 g3 H, B6 ?7 Z, c3 m

  103. 4 F4 c: i: H# e7 _8 |
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    - [/ i. H. y) J9 x1 r# o+ K
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    ; Q3 g7 X( a+ T

  106. ( e- |- U3 g) y/ U" C3 A
  107.       if $no_arrowpic_warn* V: g% {# A0 L5 v
  108.         MouseShow_Cursor.call(1)1 i" Z/ g  W/ q3 s
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    * m7 T4 M- |$ F; X# Q
  110. 6 i% _! h+ ^" A- n/ J6 Z% F: n4 _
  111. “路径指示点”将使用游戏自带图片
    ; \/ j: R; i* P: D# g& y& u' R% i4 B9 K

  112.   T% z8 w1 X2 d
  113. 该提示可以在脚本内关闭')+ b+ y, e( N# J* v
  114.         MouseShow_Cursor.call(0). a3 D3 F8 r. g$ G
  115.         $no_arrowpic_warn = false
    2 w- \$ L+ w% T4 t( @
  116.       end
    4 o4 h9 J4 \# _0 S! i$ b, w
  117.       @character_name  = '!Flame'
    2 W; \; m$ [3 e; V! X2 R
  118.       @character_index = 6" O0 K& x$ j5 P$ A' p

  119. & `$ t( n6 u1 R, w% k- T! ?  J
  120.     end5 E* K' Y( g- S- x8 g
  121.     @direction_fix = false  # 固定朝向* @* [& @; u3 }% k( s$ Y# I9 B
  122.     @move_frequency = 6     # 移动频率9 D+ \0 w5 K( m  F/ E9 d; k
  123.     @walk_anime = true      # 步行动画
    $ j- K$ O# y0 [/ y* x7 g
  124.     @pattern = 1            # 图案7 G( o( q9 ~3 f: k% |& G
  125.     @through = true         # 穿透
    ' T1 R$ r3 \" w
  126.     @bush_depth = 0         # 草木深度# [) i' \4 S5 G' _5 v/ i: F+ z
  127.     @animation_id = 0       # 动画 ID
    $ s8 J/ ]  a. [' f: I+ t
  128.     @balloon_id = 0         # 心情 ID: {4 d; R9 h1 k& O! ~+ ^
  129.     @transparent = true     # 透明
    ( ]# O+ L; n6 `% p
  130.     @id = 0
    ( x5 O  i7 P9 P. @) {
  131.     @x = 05 L# j: B# z8 n6 b0 i
  132.     @y = 0
    ( F% Q8 ?# P% j- f( q
  133.     @real_x = 0: B0 k1 d0 `1 A- b, L- W7 P+ c$ y
  134.     @real_y = 0
    0 c0 i! Q* c" Z7 u$ w7 |6 S6 j: h
  135.     @tile_id = 0+ c( J4 S# M) [6 h4 X
  136.   end4 ]6 M' _! ^# d$ E# {, p6 X
  137.   #--------------------------------------------------------------------------: L( w  I, t" c+ k! _5 x+ i
  138.   # ● 定义实例变量
    + S7 b! w( c% S# L  c- a
  139.   #--------------------------------------------------------------------------$ i, H* Y$ V# R
  140.   attr_accessor direction. Z+ `5 ^4 z& F, k; q
  141. end( b' A; M5 V" h

  142. ( e$ {; E) }7 p( Q4 q
  143. #==============================================================================& w) h( g$ s3 S) g! F1 V9 s0 K
  144. # ■ Module Mouse" u+ K+ a* \5 r$ s  M
  145. #==============================================================================  X8 w1 o/ G" F$ ?: Y) C! T# D: Y  ]
  146. module Mouse+ ?8 N- }; L  B; Q+ c9 W$ @
  147.   #--------------------------------------------------------------------------0 C3 {4 y: q! Q0 e+ Y- T
  148.   # ● API4 _) v( L$ Y5 K" k, p; K
  149.   #--------------------------------------------------------------------------
    ; L" t2 i# q& M9 r6 x5 U
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l'), {8 x/ K) t. \2 r6 E% u
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    ! g1 T& _* Q0 S
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    0 {' |* v: X( A. l% S
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')- u- L! v# g% d6 o1 A
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')0 e4 C7 V/ N0 F
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    % z8 y* W" I6 |4 f8 c
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    + h* s( Y2 P) ~, D1 t
  157.   Window_Hwnd       = Get_Active_Window.call
    % c9 V# ?1 M' S5 c
  158. ; z6 t4 C1 P# H) s% \
  159. class  self. J% V* ^) V# N0 Y4 l
  160.   #--------------------------------------------------------------------------2 e: ^+ S8 k  k. o* _
  161.   # ● 初始化' X' l& H3 d: l: o& M6 J5 d6 j
  162.   #--------------------------------------------------------------------------
    * `' K: n* D$ p3 s; r6 ?& Y. b8 G
  163.   def init
    & N. P4 @7 J: R/ e6 W6 `' u+ h
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    & h7 P  P; `# k
  165.     @left_state = 0
    ' z8 `8 @/ }: _' ?
  166.     @right_state = 0; u; A9 p- n  g. l7 G( K
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    - G  Y' L8 A$ l4 t
  168.     @dk_count = 0 # 用于双击的判定8 `6 c' L, O" w4 c* M6 |( F
  169.     @clicked = false
    ! i5 [) [1 h5 t& s* M3 S
  170.     creat_mouse_sprite4 Y% j& x$ P) B/ `, J# o2 u
  171.     update
    & W- T9 X0 H4 ^5 H
  172.   end% Q5 h( c& ?; H' f1 S
  173.   #--------------------------------------------------------------------------. I" d- \/ d* Q8 g* t# K% q
  174.   # ● 鼠标指针精灵
    8 `0 ?* J9 d6 ^+ b5 a1 ?1 I8 I; k
  175.   #--------------------------------------------------------------------------7 k) _0 c. ^6 H! x0 {0 r
  176. #~   def creat_mouse_sprite
    * h1 l0 a# o6 r" h
  177. #~     # e- k7 R, t, J' x; I
  178. #~       @mouse_sprite = Sprite.new; H5 Q9 [5 l6 N% f
  179. #~       panda = 2#rand(2)+10 Z' j$ [& ^  z9 Q; G/ b0 b. g
  180. # t. X# d" a- j4 K0 z
  181. #~      if panda = 1+ \0 i8 v& l3 y
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    8 N, |8 @9 ^# a" B
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')% b5 M" L+ p+ j' E" t. B7 t
  184. #~        end#with if File.exist' n. ?. g9 \5 u7 u4 J8 f
  185. #~   
    / \+ R, A$ z# i& |" @
  186. #~     else if panda = 2 #with if panda=1
    ' h' j1 s; W/ l; |% }, b
  187. #~      
    0 m/ ~" t" H: _
  188. #~      if File.exist('GraphicsSystemCursor2.png')/ E% o& p$ U* H/ R
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')' s3 {4 F! h& q# L/ u
  190. #~      end#with if File.exist2 C4 d. H7 i9 e) L
  191. #~      
    % L7 J4 d) R9 \2 _
  192. #~     else #with if panda=16 L9 P) c3 [" V" b2 w6 [) A% b
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)1 R) |( ^* o- {3 o2 p- @3 A
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    ! }) M" Y3 B+ u2 }7 ^! C- T) q
  195. #~       Rect.new(5  24, 24  24, 24, 24))$ C; n5 O# u- q) F6 a1 j
  196. #~     end#with if panda=1
    4 ^! Q( T$ V* z1 T' C1 e3 j' R
  197. #~     2 S+ w4 H- p( U$ Z5 c8 M9 C) [
  198. #~     #with def8 d6 g2 V# ^* e7 t
  199. #~   end
    5 ]5 y" b' w9 ?( K
  200. def creat_mouse_sprite6 [8 m* \; ?8 Y5 A
  201.     @mouse_sprite = Sprite.new
    , O- p* d7 T% z- t  W( `
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    & l' J) j- G2 h5 [0 D
  203.     @mouse_sprite.z = 9999  Y- X6 |' d" |8 g
  204.     Show_Cursor.call(0)3 I# O0 h* p7 K" M
  205. end* J4 q) Y8 l3 l  ?1 z: X; Y

  206. & A, }7 ^8 U; x' U* _
  207.   #--------------------------------------------------------------------------
    3 ]& K- d3 _' I: H2 }# j' b$ t
  208.   # ● 更新# I% z; L+ a; ~! p7 L# g
  209.   #--------------------------------------------------------------------------
    ; U5 }4 ?0 u: Q+ C! M0 K
  210.   def update
    9 _# J  L1 M# @  i' f9 O7 j
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos' m3 ]  K( @( j3 `; n3 Z5 R
  212.     left_state  = Get_Key_State.call(0x01)% H5 [; N3 x# p  n( ?
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0* O2 [) o' d5 ?0 u; C
  214.     right_state = Get_Key_State.call(0x02)
    - y2 G9 [' }4 t$ T. _
  215.     right_state[7] == 1  @right_state +=1  @right_state = 08 N* p6 L: j5 z3 E" T# B
  216.     update_double_click
    3 g% l( j! d; O( \9 g/ ]! I* v
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    / {' }- k1 {* J7 b; F/ z# A  [
  218.   end/ p( @* @8 r- |( m
  219.   #--------------------------------------------------------------------------- s& ]1 F- h% h( A; O
  220.   # ● 获取鼠标坐标( Y$ Y0 L& j+ A" A$ h
  221.   #--------------------------------------------------------------------------" K2 ?8 ?" O7 d- e; h: c* ?
  222.   def get_mouse_pos! p8 }& D. v1 B5 A
  223.     arg = [0, 0].pack('ll')! V6 I6 p2 T# w7 n1 a, f% G
  224.     Get_Cursor_Pos.call(arg)6 b/ \) T: z, m- `, ]
  225.     Screen_To_Client.call(Window_Hwnd, arg)9 R: T0 P) K! ^; W( B
  226.     x, y = arg.unpack('ll')$ V1 E1 @* o( g6 w+ ]) }
  227.     return x, y; K* V) X1 k) D0 b4 w
  228.   end8 k8 o9 A6 L4 v/ J
  229.   #--------------------------------------------------------------------------: ]9 M+ N* @) \+ {5 W" w
  230.   # ● 将鼠标固定在屏幕内
    # A! [  A$ U2 }; D2 O2 C
  231.   #--------------------------------------------------------------------------  g' x" N$ Q9 F2 O2 R
  232.   def lock_mouse_in_screen; @+ V2 x1 D4 h* Z* D% N
  233.     arg = [0, 0].pack('ll')
    - R. U- b* R  q4 U, X8 }; g, t: B- {
  234.     Screen_To_Client.call(Window_Hwnd, arg)# K' i, O  D$ P/ d' l5 h: E
  235.     x, y  = arg.unpack('ll')8 @% ~5 M2 U6 \- S* H" h: I
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))* R8 [' X( p2 o2 `  N7 k1 X" u0 T
  237.   end
    ! h, B$ O; X2 ~$ W  L# M2 b- h
  238.   #--------------------------------------------------------------------------
    % @' R# c9 n4 J- C$ ?3 p
  239.   # ● 解除鼠标固定
    9 s8 Z# F+ {. C' H( ~
  240.   #--------------------------------------------------------------------------1 `8 e, \. @) v! w' L; S
  241.   def unlock_mouse_in_screen
    + D8 v" y+ ^# f; A- ]/ {0 f+ `) `
  242.     Clip_Cursor.call(0)# \( {' X9 \& d6 Q
  243.   end: A0 M4 O; w2 Z* l+ n
  244.   #--------------------------------------------------------------------------
    7 T* w9 j# M4 v9 h) Q
  245.   # ● 鼠标双击判定
    # k4 u; N' I, d$ s* X8 _
  246.   #--------------------------------------------------------------------------
    ! T% n9 z& M) A2 t) S9 E- X) l
  247.   def update_double_click
    $ c* b/ O1 }) B2 s
  248.     @clicked = true if @left_state == 1
    - P) m/ o+ t3 t
  249.     if @dk_count  0 && @left_state == 1
    ! X( [& f. R) f! n# U
  250.       @dk_count = 0; @clicked = false9 h, O$ K0 D- l% C
  251.       return @double_click = true
    0 _# k4 h* z/ h# o' n, @# ^
  252.     elsif @clicked; n/ X, l7 Q" C8 L
  253.       if @dk_count  KsOfSionDbclick_Frame
    5 L3 [2 Q4 |4 ?
  254.         @dk_count += 1. W5 ~" j2 M/ u! H
  255.       else# c: h4 j2 F* c- c% s
  256.         @dk_count = 0; @clicked = false7 O( w0 e; j1 X- l: @" z
  257.       end/ e! \% g' ]- k, {+ E- R, E; J
  258.     end0 Y) _0 j( K; G  b
  259.     @double_click = false
    / Y- u) R, V0 p' E6 ]: I! g$ Y
  260.   end; Y- s+ |- y8 Z; C' s5 a
  261.   #--------------------------------------------------------------------------
    % L; A" @% z6 w
  262.   # ● 按键被按下就返回true4 P. g9 B! e, r
  263.   #--------------------------------------------------------------------------; G" u! ?3 u4 L$ u/ o3 c' J! c4 W9 U
  264.   def press(button)
    8 @, M. p: T& y# I- g0 P5 _1 Z
  265.     case button
    7 F0 e" v* }' u
  266.       when 0x01; return !@left_state.zero
    % R" n% h- C) W9 A% k( c$ l' i% @" Q
  267.       when 0x02; return !@right_state.zero
    * R4 ?6 c/ D3 H! b! C( q3 p; h
  268.     end; Q* V% U! B+ G4 W" m
  269.     return false
    6 @% E  c# I/ q: j7 [
  270.   end6 }1 r+ O- i4 q0 v5 B: q4 k. e
  271.   #--------------------------------------------------------------------------
    5 g, _& J: |* Q; d' c
  272.   # ● 按键刚被按下则返回true6 g7 a# n: Z5 f
  273.   #--------------------------------------------------------------------------- p! f" E0 G  q' L. K7 n; h8 a
  274.   def trigger(button): G, T: O# J* E% a% o3 J9 X, ]5 O
  275.     case button
    0 U" L' i# M% ^. [" \
  276.       when 0x01; return @left_state == 1
    ! v: e8 B$ X( {9 f8 j% M& T
  277.       when 0x02; return @right_state == 1/ B+ C4 y! m5 [1 f: T
  278.     end- s1 S% T% ~$ ?) I! e+ R- F, m/ e
  279.     return false
    & g- O4 d; z2 e( S& @" ^
  280.   end
    6 B$ z% p) [* B; ~
  281.   #--------------------------------------------------------------------------5 c; ~; `+ @# o- B: R+ R
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    8 {( x- h" [$ [5 [9 ^
  283.   #--------------------------------------------------------------------------6 [+ c$ a, a1 T. l8 F- f
  284.   def repeat(button)
    4 {7 r: a* O" B9 g2 I. J
  285.     case button
    ! Z' u' d' S9 C  d3 c
  286.       when 0x01; return @left_state == 1
    % R* w, j6 T! K( I) c7 g
  287.         (@left_state  22 && (@left_state % 6).zero)
    9 J: V* v# S1 f6 P
  288.       when 0x02; return @right_state == 1
    & w1 Y2 i" v. b7 v) }+ S
  289.         (@right_state  22 && (@right_state % 6).zero)
    6 P1 ^- E: [  o1 A
  290.     end$ I8 P# r& b3 l
  291.     return false8 y* `- p' f; f+ a  d( P: t
  292.   end! o' ^  s- R! J% H+ x8 l
  293.   #--------------------------------------------------------------------------
    6 }: j. n3 j. W. ]& @
  294.   # ● 判断是否双击鼠标* r  W* ^/ c" H- U* f) f" Y
  295.   #--------------------------------------------------------------------------; G, F1 M* i5 P- b: E( X
  296.   def double_click
    " T9 P* \" z/ M9 L# ^! w7 @, z9 Q
  297.     @double_click
    , {' [! Y+ z8 Y$ ?& {& r5 e3 }
  298.   end
    2 ?+ d8 `1 h% ~7 J. P" Q+ w, y2 E
  299.   #--------------------------------------------------------------------------2 [. |* y' D2 c0 n9 n! [$ B4 [5 f, I
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    5 \& B% l, ^9 A* ~, m7 P
  301.   #--------------------------------------------------------------------------
    # U3 A9 I$ T  p: J: h
  302.   def click_count& Q4 J( ?4 s" ^# G7 ?: J9 J' B6 q% @5 f
  303.     @ck_count
    - t0 ~" \  q* k+ t3 |& z; K
  304.   end
    ( C8 ^2 s$ l( z& @. l4 \# [
  305.   #--------------------------------------------------------------------------& o% A+ \- i1 f$ R4 ~! V
  306.   # ● 获取@left_state(按住左键每一帧+=1): j+ B1 Q' Z' U6 M! ~
  307.   #--------------------------------------------------------------------------
    " ^& [! l% u2 L
  308.   def left_state! Z. E1 c8 c# H; H
  309.     @left_state
    0 B) P. J! E* \3 d* ^! t
  310.   end" e7 S9 M1 E- G
  311.   #--------------------------------------------------------------------------7 f! @. K2 N4 q
  312.   # ● 获取鼠标的x坐标4 ]4 O. @/ L$ m. I6 t! Q  _4 g8 Q3 R
  313.   #--------------------------------------------------------------------------
    0 l, v7 _- @) M! n( I. B4 w
  314.   def mouse_x
    . Y6 m( \% X# N
  315.     @mouse_sprite.x
    9 T4 e: [: ?7 e+ ~
  316.   end
    : T, A+ Y0 S) f# ]  O; ^
  317.   #--------------------------------------------------------------------------% u& @  Z6 T) i, i8 l# I$ x
  318.   # ● 获取鼠标的y坐标( a. B; j; ]* ]1 Y1 s+ y* X
  319.   #--------------------------------------------------------------------------. U0 v8 T' ~4 t
  320.   def mouse_y
    6 F$ W* B4 n% L3 y% `
  321.     @mouse_sprite.y' E6 m- [5 h; I8 O7 J7 k
  322.   end
    4 K3 y0 T) h- K
  323.   #--------------------------------------------------------------------------" r& i: ]" s: }0 K6 P7 ?
  324.   # ● 设置鼠标坐标5 O& c0 k2 i" P, M7 K; h
  325.   #--------------------------------------------------------------------------- _" g- ?2 E+ Q2 j! @. I) O/ x
  326.   def set_mouse_pos(new_x, new_y); m( N* Z) u  l
  327.     arg = [0, 0].pack('ll')
    / L1 a3 C7 v! i6 w* z# _2 k4 a; f9 r
  328.     Screen_To_Client.call(Window_Hwnd, arg)8 e* k/ j- r6 \0 L' h: O. m
  329.     x, y  = arg.unpack('ll')5 f8 S4 X- H2 h+ p: i
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)% X4 {( C/ T2 F9 [4 ?
  331.   end
    7 D3 c/ w; c3 a
  332. end #end of class  self
      f! c# z' E' j  ~4 j6 P

  333. 8 C& u9 f- W: M7 M7 q) X
  334. end
    / Q; e# I9 f9 `  ~
  335. 5 \$ j' I$ i, ]  Y# Y9 r
  336. #==============================================================================2 I# ?% c( k6 S+ X
  337. # ■ SceneManager
    . c  K  T# p7 e3 @! V) [
  338. #==============================================================================# o% _& @) l4 {  t6 \  `6 H
  339. class  SceneManager0 d/ i0 S9 C) h( X+ D. s+ g" n9 n
  340.   #--------------------------------------------------------------------------
    : g, {1 U9 e+ R6 K3 l1 u) c' N6 W
  341.   # ● alias
    ) ^# n8 Z1 x0 D9 P# R' u  G
  342.   #--------------------------------------------------------------------------
    $ @; E/ G: K; d; c" F# ^
  343.   unless self.method_defined(sion_mouse_run)
    & P9 H  c4 ^) V. Y
  344.     alias_method sion_mouse_run, run# Q) v) d# O/ o# t1 a6 i# Z% |
  345.     alias_method sion_mouse_call, call
    : N" F  [. a/ Q
  346.     alias_method sion_mouse_return, return7 U1 V% A( Z# t/ j1 i) U% i
  347.   end. ]1 T9 G/ F3 j' x) S* E+ d+ }
  348.   #--------------------------------------------------------------------------
    2 C! s* X& O4 v
  349.   # ● 运行
    + H8 Y: U; O) E( P: ?0 \
  350.   #--------------------------------------------------------------------------
    + M, [7 E4 x8 W3 X+ u& B6 F5 o% Y
  351.   def run
    . ]8 |& o, K1 {
  352.     Mouse.init
    0 v* L2 e: k* h) s  N
  353.     sion_mouse_run+ `" B  B( x' V0 e8 a
  354.   end; n; [- m* J# s$ G7 Q5 o& O) N
  355.   #--------------------------------------------------------------------------: H) r1 V7 ~1 K
  356.   # ● 切换
    5 J" ?8 |4 L& M# R: i' ~/ K
  357.   #--------------------------------------------------------------------------" m/ B) d: }, |+ ^: j
  358.   def call(scene_class)
    9 @0 i3 e, O: _# J
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    ) @$ A) T% a) K* W; s
  360.     sion_mouse_call(scene_class)( {3 k# ~0 S& W8 ^: o, H
  361.   end
    1 L* Y1 o! ~4 s' O8 N
  362.   #--------------------------------------------------------------------------3 l; Y$ H1 v- ~4 \
  363.   # ● 返回到上一个场景
    ! b% V3 N! Y. R. P
  364.   #--------------------------------------------------------------------------5 F) n" ~& H1 W5 m# L; S" \
  365.   def return/ V" m. ~9 G, W# U" y
  366.     sion_mouse_return
    7 }, Y+ v- m! H3 ?, l# r" N3 \: f
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&) x$ J; u2 V. l/ j( m+ h+ i
  368.       @scene.instance_of(Scene_Map)  v# k7 C  ~( o
  369.   end
    4 @+ U# t9 H% M# d- ^
  370. end
    ( q* L: @5 S& O4 ^  b  B* {
  371. 3 w# _1 V4 w8 v* Q! l4 n
  372. #==============================================================================4 L3 g7 X3 Y7 W
  373. # ■ Module Input3 |# d% I5 N8 ]5 }. r( U
  374. #==============================================================================: r; x" A- M. E+ W, \' l
  375. class  Input! K$ ~: W7 x# |$ ]" D
  376.   #--------------------------------------------------------------------------' [; S$ @5 e( [& n2 |" q6 Q2 l  ~: A
  377.   # ● alias
    * ]+ a" L+ b9 }- w/ u0 y/ c
  378.   #--------------------------------------------------------------------------* k+ k% x4 i) Q3 r% c8 `8 Q4 Q! R
  379.   unless self.method_defined(sion_mouse_update)/ D  a$ |. [9 y3 f7 g2 L
  380.     alias_method sion_mouse_update,   update4 V+ R4 F& D: u" a
  381.     alias_method sion_mouse_press,   press
    1 p5 ]/ ^* U4 e" d9 j" \$ Q
  382.     alias_method sion_mouse_trigger, trigger! `7 c0 j! l9 o5 L, I
  383.     alias_method sion_mouse_repeat,  repeat
    ! |. C# L/ ?! n+ k
  384.   end
    4 R. T. |, d+ b+ _. Y8 S
  385.   #--------------------------------------------------------------------------+ b7 E2 Y4 M5 ?- Z: I# T
  386.   # ● 更新鼠标
    " U1 T& j% j( R2 V1 t- W
  387.   #--------------------------------------------------------------------------3 G5 o1 h% B9 q  \( I' W
  388.   def update
    1 v* `7 y5 v2 R8 u0 b
  389.     Mouse.update
    0 @9 m+ |9 \4 \' V, c& C
  390.     sion_mouse_update
    1 h! V; P, g6 E% T% F6 X6 l/ N
  391.   end
    1 i# B. s) @% L) n
  392.   #--------------------------------------------------------------------------
    1 i: f/ |8 F& X2 W# V* |# R$ ?
  393.   # ● 按键被按下就返回true
    0 p& x; N' c' R6 I# ]( C! ?/ T7 d8 n
  394.   #--------------------------------------------------------------------------  A6 \+ H3 ]7 u/ o* ~$ C& f: j
  395.   def press(key)$ b5 [: o6 M$ [3 C: q
  396.     return true if sion_mouse_press(key)
    - o  J; d$ m# ?* s
  397.     return Mouse.press(0x01) if key == C
    ; u/ \* b% K& R' [0 r7 t8 ^
  398.     return Mouse.press(0x02) if key == B
      l3 i) v' ]3 W
  399.     return false
    " X0 J8 d. c9 b! G, y
  400.   end
    % s. I$ ?, j  S, F4 [
  401.   #--------------------------------------------------------------------------
    - Z  ~( V* p$ i5 l5 Z. N% h1 f
  402.   # ● 按键刚被按下则返回true. r$ \$ ]& O1 S7 m1 U' I/ P& R. T
  403.   #--------------------------------------------------------------------------
    ( i3 Q7 r2 h* D% I$ B) D5 z
  404.   def trigger(key)
      W, u2 f& f$ t5 k1 Z  v$ X
  405.     return true if sion_mouse_trigger(key)7 R1 ]- ^7 P' y; Y& u  t$ k! f
  406.     return Mouse.trigger(0x01) if key == C) E0 {4 x% O. S" {( U
  407.     return Mouse.trigger(0x02) if key == B
    3 r& X4 V. y1 L! l) F, x6 w
  408.     return false
    & n3 j3 W3 K# ~! N  l
  409.   end7 h! b2 K: b" K' d
  410.   #--------------------------------------------------------------------------
    : ]+ v: ^0 x, U( R1 b7 n
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true& v! u' J! O4 P( @) f
  412.   #--------------------------------------------------------------------------1 Y- a7 d3 w6 `8 D; S' h
  413.   def repeat(key)
    % f+ _, P8 D5 i7 U, A: b
  414.     return true if sion_mouse_repeat(key)
    7 ^( A' `7 \& u" n9 `
  415.     return Mouse.repeat(0x01) if key == C
    - y( Z4 ~, V- U4 q9 C/ X
  416.     return Mouse.repeat(0x02) if key == B
    / S* b4 i# |$ N5 C+ W8 g! G
  417.     return false6 q% A$ w4 o6 Y' z' w7 s: [0 |
  418.   end
    % R) T  u+ c  X) w4 Y0 d
  419. end* `' R: ^' E% H- R% P3 ~
  420. / f" {8 m' L/ N8 l2 ]

  421. " }: Y9 W9 S  m* }/ f( t
  422. #==============================================================================
    6 v+ K, G& J' G$ f$ g1 f: T  g
  423. # ■ Window_Selectable
    4 H% E: e. [$ a# T7 q% |0 g
  424. #------------------------------------------------------------------------------
    / z8 a8 L, ]% M) x' m3 T+ Q
  425. #  拥有光标移动、滚动功能的窗口
    + L0 F9 ~; r! r) v
  426. #==============================================================================) k8 P1 |' R; Q) r! K3 O3 l
  427. class Window_Selectable# G9 U5 M: K4 s* \% U3 J$ x
  428.   #--------------------------------------------------------------------------
    ( x3 \$ H+ e- R
  429.   # ● 初始化* C! ?7 g2 }% b  ~, O; j
  430.   #--------------------------------------------------------------------------
    / {3 O$ U  g! m# s& X, C: _
  431.   alias sion_mouse_initialize initialize
    . {, [# a) l2 v' S* I5 J
  432.   def initialize(x, y, width, height)0 p) S/ @# M2 I
  433.     sion_mouse_initialize(x, y, width, height)7 n6 c$ x, r! L
  434.     @move_state = 00 |- ]) _9 J# ?( H! x* S. b2 \" O
  435.   end
    $ X' b5 S3 ]% f1 w
  436.   #--------------------------------------------------------------------------+ \6 n4 R0 U/ |! z! C6 b4 M
  437.   # ● 更新
    " K; N/ k( A2 W
  438.   #--------------------------------------------------------------------------2 o% z# L0 l6 h
  439.   alias sion_mouse_update update! m4 ^* n" ~6 g  l
  440.   def update
    9 q6 A; Z) `- Y9 z5 s$ [( Z
  441.     sion_mouse_update
    # ]1 ^# X0 o' {: W# x
  442.     update_mouse_cursor
    " w( L9 Y- k' z9 }: n2 \+ l
  443.   end; p  F( r; I( I+ p
  444.   #--------------------------------------------------------------------------
    * z) O5 i: E& [
  445.   # ● 启动后设置鼠标到index位置
    + g  z  s% Z3 o. X
  446.   #--------------------------------------------------------------------------
    1 \4 W, }- ^0 d5 w: D, m4 |: y
  447.   def activate+ h5 f: ~5 b7 x4 L, U& r# B+ q% @
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos# d: b$ m- ^6 b; H+ ?5 _
  449.     super; e. d+ a& @/ G' @' y8 e5 n, T- S  J
  450.   end8 S  f: m9 x# y5 U  D4 M6 T
  451.   #--------------------------------------------------------------------------" c2 z4 W- y) Y4 V
  452.   # ● 更新鼠标和光标的位置- i  J$ h7 s; E
  453.   #--------------------------------------------------------------------------1 X: d4 R. A  w- O- M- r5 w% [
  454.   def update_mouse_cursor
      f7 s4 T' _4 M3 _
  455.     if active0 p3 G' X( E/ A1 k0 L
  456.       if @need_set_pos
    $ @0 ~2 S+ z8 @
  457.         @need_set_pos = nil) T. E3 _& r; J) t
  458.         set_mouse_pos
    # f* r2 a$ `& q
  459.       elsif cursor_movable$ y/ J5 y& [0 j1 D
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    % v* m* Z  B" F8 y6 _
  461.       end
    ) J9 {$ K! Z0 i3 \0 F$ v
  462.     end
    . @' P2 O2 J7 b. L1 |( H( x" }
  463.   end
    " c* J9 W! A- U4 J" V9 }
  464.   #--------------------------------------------------------------------------5 A' y7 E, s+ o2 \# t5 B: m. m/ i
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    " b: H5 Q& ^7 V% W
  466.   #--------------------------------------------------------------------------
    , _/ `# [4 W/ V5 B
  467.   def set_cursor. n$ j9 }$ X" ~5 D  m
  468.     mouse_row, mouse_col = mouse_window_area" v% F# }0 ^" c0 H  s  m8 x
  469.     if    mouse_row == -1/ o0 M2 O# t" ~. v$ R2 q' d
  470.       @move_state += 1 if need_scroll
    , @! D# D% ~5 u+ w7 X$ K6 u
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ; D& K6 _- {7 h- W5 ~
  472.     elsif mouse_row == -2
    : M  T9 t% `& u0 ?" Q0 s2 D+ O
  473.       @move_state += 1 if need_scroll
    , _: z* j3 a7 w4 u; f) Y
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    6 M1 ^3 a- ]% l# A( i: E% n1 Q
  475.     elsif mouse_col == -1
    0 z  k% J* G# _9 I
  476.       @move_state += 1 if need_scroll; N8 P: K; A+ N) |/ U* U
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    ! S! A7 ]0 X& p3 C4 u
  478.     elsif mouse_col == -23 p( M, u" R, N+ H
  479.       @move_state += 1 if need_scroll! r% A5 p: Z" U9 t2 E! n5 g( {& U8 J
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand) E0 D" Y) ?' U: z' f# g% I
  481.     else
    " I3 O* F& T- j; u7 x) m/ @+ K
  482.       @move_state = 04 Z0 A4 A& N6 Q8 O( m
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col+ K! N/ @! i) \& L# n) x8 X
  484.       select(new_index) if new_index  item_max && new_index != @index9 N# l' ^0 W7 E) J3 q6 W% J% f( k
  485.     end
    9 E$ U0 i+ a$ M3 h
  486.   end
    7 a6 D7 s" D- X& Y5 n8 h3 w
  487.   #--------------------------------------------------------------------------
    , e& p- Q5 b% q) n$ ?; F, z4 J
  488.   # ● 判断鼠标位于菜单的第几行、第几列5 N8 G  l" `0 x1 Z' J8 O
  489.   #--------------------------------------------------------------------------- D5 B; D; ]$ Q. D- x
  490.   def mouse_window_area- q5 b8 R; J% Z& C$ _% i
  491.     if viewport.nil # necessary!1 ], A6 i: O5 d. a* r
  492.       vp_x, vp_y = 0, 0
    " z0 ~# |  D- q& }* p
  493.     else
    3 x9 [  n- w3 G4 J3 A8 m5 h) b
  494.       vp_x = viewport.rect.x - viewport.ox
    1 v9 |4 J$ I- [0 H8 }
  495.       vp_y = viewport.rect.y - viewport.oy
    / W5 g7 a9 Y6 _9 ]: a1 q/ v
  496.     end
    " Y9 S; M4 Y" l  G  A
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y1 _* B: v* K7 f7 H
  498.     item_x1 = vp_x + x + standard_padding
    : U) _2 n: _6 v! r. V6 q$ |
  499.     item_y1 = vp_y + y + standard_padding
    # i, x' W% X. S
  500.     item_x2 = vp_x + x - standard_padding + width
    ' p7 Y7 _8 x; L5 a0 h& C4 N$ W! c
  501.     item_y2 = vp_y + y - standard_padding + height# a' K3 @! L4 ]1 F# m& Y& b+ a& p$ ?
  502.     if mouse_x  item_x1( ?8 a8 {. s9 k8 C
  503.       mouse_col = -1+ p+ X3 `8 Y. N6 `. o# j$ i, m
  504.     elsif mouse_x  item_x2
    / W+ d  u, Z0 [# n6 g* l
  505.       mouse_col = -2
    1 H- Q. Y1 P, i7 [
  506.     else
    ' W% R0 L- ?5 G1 a9 V! \! r% p
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    5 u, f8 a; a1 x) j) O
  508.     end
    # M, a  n2 p/ h: H$ \
  509.     if mouse_y  item_y1
    1 [& ~! _& O: Z8 U
  510.       mouse_row = -10 D$ Z, c# V0 e5 [- A( R: o
  511.     elsif mouse_y  item_y2
    ( h+ ?! q) s; L: {# e$ s! `4 M
  512.       mouse_row = -2
    5 s! P/ L8 d. ?2 y9 D9 A; D
  513.     else& e+ H& D% I* V# R
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)- ^3 f( a8 |' Y- D; t
  515.     end% }; J" x' ], r) F% H
  516.     return mouse_row, mouse_col, V% t9 z/ x5 E" t5 @, y9 W+ k9 v
  517.   end
    : U- g0 u. ^) k- z! O) I
  518.   #--------------------------------------------------------------------------
    + V5 `! K& b; B. G4 q: c- R7 v
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置5 K& N6 D& d  _/ o
  520.   #--------------------------------------------------------------------------! m* S- h$ i5 ^2 y& @
  521.   def set_mouse_pos
    ' t! l' M7 u/ \% v) o7 [
  522.     if viewport.nil # necessary!
    ) K& S/ W0 g1 g* }2 ~+ M
  523.       vp_x, vp_y = 0, 01 M! R0 K: B8 b. q( j% b( V
  524.     else
    $ ^% j& r( n' I$ H" e# [' G
  525.       vp_x = viewport.rect.x - viewport.ox
    & ~7 _6 D# ^; _3 \) p
  526.       vp_y = viewport.rect.y - viewport.oy
    ! o; ~4 U4 U7 w: \& c- T
  527.     end
    ! j! q: _$ S' P  {  h
  528.     item_x1 = vp_x + x + standard_padding 7 a4 |% r7 Z% H2 v' n# b& z
  529.     item_y1 = vp_y + y + standard_padding
    % q; g# {0 N) j& ?
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index 4 {. V1 T: a. s% m1 L) F3 x
  531.     row = get_index  col_max - top_row' o! |, P' Y$ Y  W$ V% I
  532.     col = get_index % col_max. i7 N2 C3 R- g( F- T
  533.     new_x = item_x1 + item_width  (col + 0.5)
    % s5 P. h9 R0 V: c
  534.     new_y = item_y1 + item_height  (row + 0.5)8 H( \8 G# X/ h: I  G8 u0 {# Z  [
  535.     Mouse.set_mouse_pos(new_x, new_y)3 g; x6 v6 F1 X" S" g$ a$ h
  536.   end
    % V, L9 t% [6 W$ d! m4 ?; R
  537.   #--------------------------------------------------------------------------
      r; u* ]( m4 K) C6 H% q/ W
  538.   # ● 判断菜单是否需要卷动2 d# L+ a  j) j. d6 n
  539.   #--------------------------------------------------------------------------- Y$ _) L% ]& @4 S7 j6 H" F
  540.   def need_scroll
    2 l' F8 L8 ^8 Z9 E8 K: B% ?
  541.     item_max  col_max  page_row_max; j' k  k: K1 c/ ^. M% D
  542.   end
    4 a' N6 k) B. S+ M3 x  O" w5 ~$ r
  543.   #--------------------------------------------------------------------------: W$ F& t& c9 [6 ~/ a9 W
  544.   # ● 判断是否为水平卷动菜单7 w$ V, r/ X/ {1 b( b/ K% Y5 q
  545.   #--------------------------------------------------------------------------2 o, F6 B& y, U/ D0 c  }/ H' l
  546.   def is_horzcommand
    0 J3 o" y/ C; f( H4 N
  547.     return false2 ]5 k0 b3 \( H+ w4 I8 n
  548.   end
    0 f# ^/ _  N+ t7 W
  549. end
    , ?# p7 O" s( n2 N; d! o
  550. ! @, B  `# p* C5 b
  551. class Window_HorzCommand
    ( q6 h* h+ P  x# f5 G4 f
  552.   #--------------------------------------------------------------------------
    9 a) ?7 ?, X5 @
  553.   # ● 判断是否为水平卷动菜单6 H' x  ?- j$ f# D6 y
  554.   #--------------------------------------------------------------------------
    4 o' i! X4 y1 q* T
  555.   def is_horzcommand
    7 I: {# j3 E" @7 S& H" K$ H# J
  556.     return true& C1 @2 o, ~! L, K+ m3 |# [' G8 `
  557.   end
    $ D( f; D1 {+ z* K
  558. end
    6 P8 W7 N: n& C$ d( u5 t* l

  559. ) |* N- u# F5 I( `3 b* c( J
  560. #==============================================================================! X0 e; Y2 T- o( G2 W; [0 ~( L
  561. # ■ Window_NameInput
    4 M9 M! A  T2 a4 a$ V; b
  562. #------------------------------------------------------------------------------. c  s/ f, D- L( e6 k
  563. #  名字输入画面中,选择文字的窗口。& T. G$ K* S2 Q* b
  564. #==============================================================================  _: |; z1 i- D# d2 }9 s6 G" J# \
  565. class Window_NameInput
    # Y+ u, C# x3 ]3 B6 I/ [
  566.   #--------------------------------------------------------------------------7 v9 c9 q. L. \: v+ C% |
  567.   # ● 设置列数5 h8 t9 [* \2 }
  568.   #--------------------------------------------------------------------------
    : v7 T( E- J3 X, ?# d* k  E* U
  569.   def col_max
    ' _# ?. @5 C3 m9 L) x
  570.     return 10
    4 E) J+ m5 J* U2 W
  571.   end/ h9 d& m- m! y) D# q# v, V0 _
  572.   #--------------------------------------------------------------------------# w: |& [# q' c! Q! \, r) k* n
  573.   # ● 设置填充的Item个数- F% J- M& E* m. ]$ B$ V2 y# V
  574.   #--------------------------------------------------------------------------
    6 m7 a3 k) u. H, h
  575.   def item_max
    , U+ a+ m9 p7 l1 N* `, K% x% m2 U' S
  576.     return 90
      W. p, D9 C" c- Q
  577.   end
    . Q/ F8 v# P7 j6 i5 ^1 I  e
  578.   #--------------------------------------------------------------------------7 X8 H' K) n# |7 t
  579.   # ● 设置填充的Item个数
    , F! h  q% B4 I& N5 S6 R
  580.   #--------------------------------------------------------------------------
    8 N- r+ s" W" T. k; \
  581.   def item_width
    , J$ k  s- r/ V, y+ j, H
  582.     return 32
    - T) T( `: |8 M( i. U
  583.   end
      d1 w9 E2 s4 O5 r; O& h- I
  584.   #--------------------------------------------------------------------------
    3 \: p! Q) C0 W
  585.   # ● 判断鼠标位于菜单的第几行、第几列" j5 u, L0 y  F7 u- q+ b& }
  586.   #--------------------------------------------------------------------------
    3 _  b7 }/ ^' m4 Z
  587.   def mouse_window_area% e, N7 _. g1 V9 r1 t( i  P: t
  588.     if viewport.nil
      b9 G  J$ n  P) z4 r' M7 V
  589.       vp_x, vp_y = 0, 0
    & W6 ~) P* h! q! X5 m2 _7 k
  590.     else
    : j, V* H, N. x, ?) Y2 ~7 N
  591.       vp_x = viewport.rect.x - viewport.ox0 x! ^; S- b+ ]! Y/ s, a
  592.       vp_y = viewport.rect.y - viewport.oy$ l7 z0 l3 o' a# x! v
  593.     end
    ; k0 G2 [: ^% b$ j& _; C' N3 ~
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    0 n* X! M& N& e% V; ]8 e0 b$ g
  595.     item_x1 = vp_x + x + standard_padding % j. Z5 n) u5 L4 l
  596.     item_y1 = vp_y + y + standard_padding
    9 ~6 G* P  Q) S7 w  O
  597.     item_x2 = vp_x + x - standard_padding + width' _. d  \# q# O2 e  D
  598.     item_y2 = vp_y + y - standard_padding + height1 g9 A8 }# @3 R  u( n
  599.     if mouse_x  item_x19 x  s8 t( ]4 f7 T! R' \! X
  600.       mouse_col = -1& P+ i( I6 R/ A/ X2 @0 {
  601.     elsif mouse_x  item_x20 M9 i$ F' v/ s- _/ m
  602.       mouse_col = -2# @6 e; _$ m& P, n% a
  603.     elsif mouse_x  item_x1 + 160
    - j$ Q1 c' U$ F7 J& v* ?
  604.       mouse_col = (mouse_x - item_x1)32& R* g( O& K" `
  605.     elsif mouse_x  item_x2 - 1608 {/ b3 r5 I3 l' _% i4 X# d9 p( b
  606.       mouse_col = 9 - (item_x2 - mouse_x)328 E2 G3 e1 b- ?/ x
  607.     else
    , K. \& J# `% z6 e: |0 N
  608.       mouse_col = mouse_x  x + width2  5  44 k3 q. O" S; s6 r% i
  609.     end4 r0 ^$ b1 _  a$ Q
  610.     if mouse_y  item_y1
    % C7 V5 a9 H* s; z, o
  611.       mouse_row = -1
    # S/ I; R% j2 p: N% w* C, L! X& n" X
  612.     elsif mouse_y  item_y2: n! G( E$ h! g) E
  613.       mouse_row = -2
    ' {  S( x6 b: J! O0 T5 I
  614.     else* j0 {. g+ A7 u! t" l/ G
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    3 h& c4 F! u# s# F
  616.     end
    9 K( D3 V6 b7 c3 q/ R! g
  617.     return mouse_row, mouse_col6 |3 T$ }+ ]0 C4 W1 T, r
  618.   end4 f- X, |4 H5 W5 S5 d7 d& o( b8 ^& i
  619.   #--------------------------------------------------------------------------
    / v4 v- s. {4 s) n
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置# D  V+ Q4 O& @6 J* Z& |( `8 J
  621.   #--------------------------------------------------------------------------
    : g, J1 t, K/ v: q( j2 `, p' i
  622.   def set_mouse_pos
    . a' s, P$ A+ F9 G8 e2 I! A
  623.     if viewport.nil # necessary!: L; d  y8 Y. n
  624.       vp_x, vp_y = 0, 0' j0 W# X0 X, G  k' J! W  A* Y( S
  625.     else! ]3 {' _5 k" ~3 [1 a( V, \; q) S
  626.       vp_x = viewport.rect.x - viewport.ox
    ' s4 P0 e" T/ Y: O: G+ H
  627.       vp_y = viewport.rect.y - viewport.oy
    7 W  ]  r* ^2 y% x3 s
  628.     end8 R' `! b8 e; j6 _1 i5 \: b
  629.     item_x1 = vp_x + x + standard_padding   e! w3 w8 j/ p' @7 H$ c" n
  630.     item_y1 = vp_y + y + standard_padding; k: M" y) ?1 m/ q+ ~6 q  {
  631.     get_index = @index  0  0  @index
    2 J& a( d- U- A3 K: M$ P7 o
  632.     row = get_index  col_max - top_row
    8 p' ^$ t+ ?& `  b
  633.     col = get_index % col_max; ]0 Q- G4 |2 V' g0 ~, P
  634.     new_x = item_x1 + item_width  (col + 0.5)
    9 e5 L: M# u7 s& j# ]) R6 }
  635.     new_y = item_y1 + item_height  (row + 0.5)
    0 o  e3 S# d' q. o# ?
  636.     new_x += 14 if col  4
    # P% {1 z3 P8 T
  637.     Mouse.set_mouse_pos(new_x, new_y)
      {" ?# ~) `7 A1 Z) f* |- W* [  _
  638.   end! S% ~; H9 J, Z+ s" w
  639. end9 {: m5 S* a8 v: i* M' }' c* D
  640. 9 Z; X; p( ?$ j$ k7 L
  641. #==============================================================================
    / X: H( ?2 f$ B% e3 a
  642. # ■ Window_NumberInput
    ' s, {3 q# x- o! [7 c: Y! k/ v& P
  643. #------------------------------------------------------------------------------# i/ l  S; G$ g6 J$ w& T; Q" K2 d: ?3 m/ C
  644. #  重写了数值输入的方法以适应鼠标7 P: T: A6 ~( Z# I1 _% x
  645. #==============================================================================
    1 T, s% ]+ F% \. H  x
  646. class Window_NumberInput  Window_Base
    8 K& F0 A; Q7 a& ]- I5 O2 |$ o
  647.   #--------------------------------------------------------------------------
    9 l. ?+ L2 N! J; [
  648.   # ● 定义实例变量
    4 }8 s1 h$ f6 t- w9 b% E, @$ D
  649.   #--------------------------------------------------------------------------
    / }4 \/ n( W: a/ X5 j6 \
  650.   attr_reader extra_window/ Y% W( f' w3 h% C5 X, Q
  651.   #--------------------------------------------------------------------------
    ! u- R6 {  X/ {5 `( Y
  652.   # ● 初始化2 j8 m8 r: g' M! r4 `
  653.   #--------------------------------------------------------------------------5 y& G3 ^$ {) f- L5 o9 L
  654.   alias sion_mouse_initialize initialize
    4 d8 ?4 j" k/ q( h
  655.   def initialize(arg)
    0 m2 y9 U* o! z; a! j9 Q. j
  656.     sion_mouse_initialize(arg)
    % _) `" g/ @5 D, a& K
  657.     create_extra_window
    : P; Z  s( d3 J: C) D
  658.   end
    : A" q* b2 B6 [% w9 S/ k* p
  659.   #--------------------------------------------------------------------------
    + ?: y+ a% i7 A  u
  660.   # ● 启动' |5 V6 e% p  s' u1 V* j& K0 T5 r; l
  661.   #--------------------------------------------------------------------------
    " m4 g- ^1 {2 }: |3 r
  662.   alias sion_mouse_start start5 k4 S- ^. a* o8 S
  663.   def start
    ) ~+ i5 X( R- }: J8 q( w8 o) z8 o
  664.     sion_mouse_start
    ; A3 Z( V! a: p5 ]  m, O: \
  665.     deactivate
    * ?" A/ U( ]! k; U; A! A
  666.     extra_start
    # P. B: N7 n# Y3 t/ }
  667.   end
    6 t- Q) ]# c) \8 e8 K; c
  668.   #--------------------------------------------------------------------------3 |' c2 m: [+ z8 J4 M1 ~
  669.   # ● 创建新的数值输入窗口; |' V" Y) l2 f
  670.   #--------------------------------------------------------------------------( B. D% C( `9 P/ F" D3 D; w9 z
  671.   def create_extra_window
    7 D3 p/ |; `5 Z$ G1 x0 ~" j; j
  672.     @extra_window = Window_NumberInput_Ex.new
    : a- {8 `4 v5 \  ^
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  20 @( n0 m8 h) {1 c  C6 A
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
      @7 o: {) W+ ^4 ^9 x5 E
  675.     @extra_window.index_proc   = Proc.new {n @index = n }) }9 o% w# d" O0 K$ O
  676.     @extra_window.close_proc   = Proc.new { close }. O% w4 ^5 \( O; @. J* z
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    , X- d* I' r# N4 E# H1 _
  678.   end3 g- q0 b4 K5 }+ @6 O
  679.   #--------------------------------------------------------------------------
    ) D9 w6 ?, m: n# I/ n
  680.   # ● 激活新窗口
    + P% V% E/ S- L; f& D; R  X% x
  681.   #--------------------------------------------------------------------------. c  q9 C' ~  K% g( v6 ^
  682.   def extra_start
    # j  B* k' t6 v# w# W- h
  683.     case $game_message.position3 o) Z& D' k- m% _3 f
  684.       when 0; @extra_window.y = y + height + 4
    4 W' J' ?! K( [
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    3 T( `% m2 ]1 ^) Z
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    3 s" X' X5 g' a) A
  687.       else  ; @extra_window.y = 8$ S' M% X2 F* w0 {" r
  688.     end+ H/ \2 s& B1 K* [7 Q% Y
  689.     @extra_window.variable_id = $game_message.num_input_variable_id1 B! Z4 p4 G7 {& y$ k5 J" t; Y
  690.     @extra_window.digits_max  = @digits_max! d' ~/ p( T, _# u9 G; K1 X5 S+ h
  691.     @extra_window.number      = @number, w5 `# k7 |* d2 O: m
  692.     @extra_window.open  c+ F7 q# H  a7 o4 M7 ?( K
  693.     @extra_window.activate+ ?6 l& A! A; s. U) H, m
  694.   end
      Y  n! X$ V0 b, v
  695.   #--------------------------------------------------------------------------$ r5 E6 b# i8 n- R
  696.   # ● 更新
    $ s2 T6 M' A: R5 G/ F/ m
  697.   #--------------------------------------------------------------------------8 N5 j* k% c+ I& q$ B# d1 j6 O
  698.   def update
    # T5 x  T. ?, T( W3 g6 O" z& h+ I
  699.     super
    - H- t3 w4 g& P1 S# H9 {& t1 I
  700.     @extra_window.update( d1 y% D$ H6 w6 U. |4 L  B
  701.     update_cursor/ O+ s2 Y' R1 G
  702.   end' x) i% e  E2 S4 J5 A
  703.   #--------------------------------------------------------------------------, J* u+ b7 F. g" u4 A  z# j4 W
  704.   # ● 关闭窗口
    6 b: a) Q% ~: [9 h, {8 ]0 `* ^" b
  705.   #--------------------------------------------------------------------------2 m1 e& |. h. ?/ ^  \) B9 P+ o: |
  706.   def close
    , V: U& f0 v9 L% s7 ^. U5 r
  707.     super" e# s0 |. R( M
  708.     @extra_window.close
    9 q  n: K: G  `2 ?6 M
  709.     @extra_window.deactivate$ R+ g$ C4 V4 F- X" [
  710.   end; J7 d# V1 k# S
  711. end
    ; _4 `/ F# H; W# |4 i  H5 G. V

  712. 5 ^8 R; E& g) \" H; w2 V$ r
  713. #==============================================================================; n( }: {& c3 E1 D( ^
  714. # ■ Window_NumberInput_Ex: X+ c9 P6 I6 J6 r+ s% u9 u5 [
  715. #------------------------------------------------------------------------------! N) z1 y5 Z' g7 c
  716. #  新的数值输入窗口(NewClass)
    $ m' P/ k! Q) ~6 I. [
  717. #==============================================================================+ j1 y* ~4 ]" I$ j3 N
  718. class Window_NumberInput_Ex  Window_Selectable
    # W  Q2 ]5 N& _
  719.   #--------------------------------------------------------------------------
    2 {" L/ F/ l- b
  720.   # ● 定义实例变量9 ?* r: Y; w3 G0 n% g1 x
  721.   #--------------------------------------------------------------------------) Z6 |4 x$ V$ {* d
  722.   attr_accessor number_proc% o4 v8 w8 o% O7 U' l4 V1 q0 ^. V
  723.   attr_accessor index_proc! P; N4 r8 l1 m2 p
  724.   attr_accessor close_proc
    0 z# O8 ^* o4 H* \4 q; I
  725.   attr_accessor refresh_proc* r+ I% c2 J, Z" u- I
  726.   attr_accessor number
    3 g3 P5 _( O3 A& S
  727.   attr_accessor digits_max
    % K& b! L. P' R4 F8 a5 z
  728.   attr_accessor variable_id2 `) }5 {+ e( H3 ^2 C
  729.   #--------------------------------------------------------------------------; Y0 J* I* \" T2 j0 j8 X5 f; A/ l
  730.   # ● 数字表- m* h+ k4 n! }4 i# i2 b  \1 W
  731.   #--------------------------------------------------------------------------
    ' |- I: Q  L+ j$ w5 b. a
  732.   TABLE = [  7,  8,  9," T$ ?. V$ }) D+ C
  733.              4,  5,  6,
    : y- y9 {; X" K, f6 a& [
  734.              1,  2,  3,& c" B8 B  i. k+ s. e& }
  735.             '←',0,'确定',]
    ' ~1 T& R( [0 s! ~, ^
  736.   #--------------------------------------------------------------------------
    7 M! v* t+ U- a% H/ D: Q5 k4 T
  737.   # ● 初始化对象; W$ N( b0 K) x* d
  738.   #--------------------------------------------------------------------------
    7 c$ p3 i+ Y4 a
  739.   def initialize6 m* O+ {% x, j
  740.     super(0, 0, 120, fitting_height(4))
      o9 L. t8 x8 r; L* `# I: q1 s) W
  741.     self.openness = 0" B, v/ C  |3 x1 h9 ~' Z
  742.     @index = 0) E7 n8 ]6 s8 y
  743.     @number = 08 c+ N$ ~/ p' b2 R
  744.     @old_window_index = 07 j+ b0 z- T( T# L# k2 |
  745.     @digits_max = 0& T) Z+ X* L$ {+ I
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    # u! S2 a' p6 t; I' N
  747.   end
    9 K6 _6 [# ^% d4 M0 P$ s: v
  748.   #--------------------------------------------------------------------------
    + |  l2 B- S" V8 X5 S2 G$ g2 U
  749.   # ● 获取项目的绘制矩形
    , B' F" ?3 B' q7 B; `
  750.   #--------------------------------------------------------------------------
    , G. p" s+ H. W$ s; H' y) ]; T" x
  751.   def item_rect(index)+ V! F0 v7 ]3 q* z7 @
  752.     rect = Rect.new, N! F- s1 Q1 q* H7 k
  753.     rect.x = index % 3  32; O. Z+ t" H, l$ }
  754.     rect.y = index  3  line_height
    ! m2 @" U6 i0 c: H* t
  755.     rect.width = 32
    * o' z  j  Q# u. U9 A& Y  a
  756.     rect.height = line_height) e" ?2 A% r' K0 Y' h
  757.     return rect; t" s8 g! ?6 T% {& @
  758.   end
    1 G" o% R0 ^# U1 \6 E
  759.   #--------------------------------------------------------------------------
    8 G  B; q& t% p; y. T
  760.   # ● 将光标设置到鼠标所在的位置
    ; @/ h3 u0 N5 i
  761.   #--------------------------------------------------------------------------
    " Z5 c1 L+ N! K! X* K
  762.   def set_cursor: A1 N& k- S/ P) K! z
  763.     mouse_row, mouse_col = mouse_window_area
    6 a1 J3 ~9 e4 r4 h( }9 w* M( a
  764.     if mouse_row = 0 && mouse_col = 0/ O: i7 P! ?+ g6 W3 Z
  765.       new_index = mouse_row  3 + mouse_col) R: L& H7 E: }
  766.       select(new_index) if new_index = 11
    3 Q, f$ t- O8 E
  767.     end
    ) a/ z/ U# a: D" e
  768.   end; O* Q- N; G' V7 m
  769.   #--------------------------------------------------------------------------
    % V: t. }( \" r
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    * I# _- e8 o' M
  771.   #--------------------------------------------------------------------------
    ( X. c5 \7 r0 f, x' M) ?
  772.   def mouse_window_area
    ; ^" |% m9 b" e6 }/ V6 u" Y
  773.     if viewport.nil5 Z4 P4 |9 c; L0 u" J
  774.       vp_x, vp_y = 0, 07 l8 V( M8 B. _  M
  775.     else
    ! {# z0 c6 p  X4 K
  776.       vp_x = viewport.rect.x - viewport.ox% t- X$ s3 ?+ o4 i5 A
  777.       vp_y = viewport.rect.y - viewport.oy. w) F; i/ [! j5 J
  778.     end/ e1 w3 c- F4 }/ `, _  J0 f
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    + V8 {) C! F) D# p& w
  780.     item_x1 = vp_x + x + standard_padding 9 @' \" R4 l6 k7 z2 H  e
  781.     item_y1 = vp_y + y + standard_padding& w, z; B1 U- _/ P/ x$ T  e
  782.     item_x2 = vp_x + x - standard_padding + width
    1 C$ V  L( Q" R* C1 _
  783.     item_y2 = vp_y + y - standard_padding + height
    ' P' l% J" y' v. {5 Y8 G
  784.     if mouse_x  item_x15 N: N7 K1 K# w2 Z6 v" ?6 Z% y
  785.       mouse_col = -1
    6 E. r; A( l; p% ]# }1 R2 p
  786.     elsif mouse_x  item_x2
    . ~/ t1 O$ e- B: A" E5 a* U
  787.       mouse_col = -2
    ' G& q' i. B5 e+ N  I
  788.     else* U7 l& S# ?4 A2 W5 l) U
  789.       mouse_col = (mouse_x - item_x1)  32
    / l  a+ j  N1 g
  790.     end
    6 P3 d% \; C9 [, B8 m5 g
  791.     if mouse_y  item_y1
    / u, C, u$ m3 J0 x4 R
  792.       mouse_row = -16 o  N' o: H: h
  793.     elsif mouse_y  item_y2/ W; ?& ~2 H8 ?+ ]2 U+ B
  794.       mouse_row = -22 h" V' {( r# q# E9 G: n
  795.     else, [8 _0 R* G; o0 _% j
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    ; s- x. O  v3 \+ V- Q! e, l
  797.     end
    0 g  {% ?* ?. B% S" A2 B3 J. \- C
  798.     return mouse_row, mouse_col
    + g% G3 I8 }; F
  799.   end
    7 y3 Y# ]: `, I6 h) \+ E' n
  800.   #--------------------------------------------------------------------------
    # F  U) c4 ^$ F1 X
  801.   # ● 获取文字
    & _" h  T: P/ W5 H2 |& ]
  802.   #--------------------------------------------------------------------------
    7 Q% |' Z8 G( r
  803.   def get_number* P1 V- p; {- z# s2 t' ?8 {% b
  804.     return false if @index == 9  @index == 111 v8 j2 \0 s" H, |- o+ w5 `" [8 T
  805.     return TABLE[@index]: Q1 B  d. [0 _' t
  806.   end
    0 s5 G( ~) D6 |  p% o$ W0 V5 ~
  807.   #--------------------------------------------------------------------------+ G  G3 \9 \# e  `) C' A. l
  808.   # ● 判定光标位置是否在“退格”上
    * U; d& ~: c$ ~! k7 Q' R& L: P' J
  809.   #--------------------------------------------------------------------------
    5 g6 h4 k9 a, X; C0 d
  810.   def is_delete7 x- }: t3 f+ _( ?# `
  811.     @index == 9
    ! f. v' x7 t" I3 K0 @9 [: N
  812.   end& J* ?1 V) z' {, r& Q4 }
  813.   #--------------------------------------------------------------------------
    : h8 _- q& i2 n; J5 u4 @
  814.   # ● 判定光标位置是否在“确定”上
    6 K2 E: b1 t2 x: I2 H
  815.   #--------------------------------------------------------------------------5 u4 V! U& p# x( S4 @
  816.   def is_ok" T/ h- e" m7 o' r- H% K- ?/ b' X
  817.     @index == 11+ ]6 v  a. c8 d3 Z2 B
  818.   end
    , ]/ D& o: P7 z- i
  819.   #--------------------------------------------------------------------------( ], ]  _) ^5 X/ t
  820.   # ● 更新光标  k1 \5 G6 v+ D9 H( ]4 C6 v6 |
  821.   #--------------------------------------------------------------------------+ f2 d, u+ ~& z- ~1 ^. ]
  822.   def update_cursor$ E  w4 A$ R+ d
  823.     cursor_rect.set(item_rect(@index))
    1 F4 J$ N6 J/ \+ l7 q* Z
  824.   end
    & R2 }. v4 F% N/ _7 e2 |4 t
  825.   #--------------------------------------------------------------------------
    $ W6 L: p. Q. t: R( I$ u1 q
  826.   # ● 判定光标是否可以移动
    9 c% \: w0 m+ S% Q+ L
  827.   #--------------------------------------------------------------------------, V. i( M* _) B$ d
  828.   def cursor_movable
    # M3 v- U& ^% \: t
  829.     active# x+ ?( W/ N- Y6 w' P, u1 e
  830.   end
    $ d2 K$ v8 O2 X
  831.   #--------------------------------------------------------------------------7 [0 U6 V7 I! j( m# ^" k  v
  832.   # ● 光标向下移动! f5 y! _1 j7 m1 s
  833.   #     wrap  允许循环
    " @" d; i- Q( y4 U7 J
  834.   #--------------------------------------------------------------------------5 z5 m( N& O& i5 ^
  835.   def cursor_down(wrap)
    6 H, H- h( L% }& Q6 r$ E. v4 _
  836.     if @index  9 or wrap
    9 V+ o0 T1 s- X0 E: v: G5 r( C. }6 Y' S
  837.       @index = (index + 3) % 12
    ! z2 E6 G1 x) f: E9 F, S+ _
  838.     end
    . b4 y' X2 C9 t
  839.   end
    & ^2 d" Z5 {( Q% h
  840.   #--------------------------------------------------------------------------! c( n* B* A  P3 H; u4 C; N- X
  841.   # ● 光标向上移动
    ! g* n- p2 y; l/ b0 w. O2 G; [9 X  f
  842.   #     wrap  允许循环9 d( Y5 n9 ~+ T6 Z, d# |, L1 X5 ^
  843.   #--------------------------------------------------------------------------5 @; C' t8 f9 A# @0 @
  844.   def cursor_up(wrap)* g9 @0 }- X( Z
  845.     if @index = 3 or wrap. L' X- b7 k; z# f! z, X! E9 }- V
  846.       @index = (index + 9) % 12
    0 R! T$ B- R; C& r% k3 c
  847.     end' u) N( {, J, l( P" M  i
  848.   end4 T8 h( G( [# H# w9 [  i. s9 s
  849.   #--------------------------------------------------------------------------: B' _  p! D, o7 M6 x/ \
  850.   # ● 光标向右移动
    & y; m! i: u( @) ]9 D
  851.   #     wrap  允许循环+ q7 K  F& l. R
  852.   #--------------------------------------------------------------------------0 {* Y; r9 n- i8 K1 X4 [) p0 N
  853.   def cursor_right(wrap)
    6 q8 S" i, m: n9 M
  854.     if @index % 3  2, H8 V! ?$ q, c$ r5 g1 h+ c
  855.       @index += 1
    ; o0 r8 u, d$ M& q) K, t
  856.     elsif wrap/ a) W3 i$ E9 _. p! M& U, T7 m
  857.       @index -= 2
    1 s, W# }+ Y1 E" U# T
  858.     end& O% l4 T$ ~6 C* _- M
  859.   end
    5 e9 P. H+ U6 }
  860.   #--------------------------------------------------------------------------
    , h+ ?" ?$ |! E7 p, d" E
  861.   # ● 光标向左移动7 u! f, ]  V  H
  862.   #     wrap  允许循环
    ) G# s- d2 ^& E
  863.   #--------------------------------------------------------------------------9 H! A. R2 @9 Z; T
  864.   def cursor_left(wrap)
      k7 e6 i" G4 f0 w$ z8 i. U
  865.     if @index % 3  0- H& t9 c9 n+ [! @, p& @. _
  866.       @index -= 1
    & O/ G0 j- U- b: X' m; r* d& x
  867.     elsif wrap
    ! \% i7 P9 T& ?; h. u
  868.       @index += 2
    * B5 C" _+ c0 J) l: D
  869.     end
    0 r. k5 W$ u8 ?
  870.   end" p- c3 C! ^  \! M/ ]. O6 Q6 X
  871.   #--------------------------------------------------------------------------
    5 b) o7 D, h% p$ n
  872.   # ● 处理光标的移动( w( ^- L2 ?- r( C- i
  873.   #--------------------------------------------------------------------------/ y6 P) d, W; P0 @$ _' v
  874.   def process_cursor_move" a1 h+ E/ e% B. N% }; C# m
  875.     super) h, B( `7 f$ F) z
  876.     update_cursor3 A# ^  ~2 o. u  a
  877.   end2 y7 n. o  T& f3 b* {# S# ~
  878.   #--------------------------------------------------------------------------0 [+ A% w4 G9 ~* P7 T& b$ m
  879.   # ● “确定”、“删除字符”和“取消输入”的处理' x3 v. ?. U7 w% u2 F
  880.   #--------------------------------------------------------------------------
    - C. ?! h# L' F$ H7 l
  881.   def process_handling5 n$ s/ y7 _0 l" g
  882.     return unless open && active6 u% ?3 Q5 j7 a' S8 s& L
  883.     process_jump if Input.trigger(A)
    . e9 |1 a. d5 g) Q; S
  884.     process_back if Input.repeat(B)
    - _. B6 Y( e% i# y' y
  885.     process_ok   if Input.trigger(C)
    , b. U! j* J9 m: i& F: n3 e
  886.   end5 A1 z1 F% t) w0 A7 t) i( E+ [
  887.   #--------------------------------------------------------------------------
    / K' \% U$ n. g
  888.   # ● 跳转“确定”1 u9 T3 Z  x. ^9 K, j9 k
  889.   #--------------------------------------------------------------------------- w0 p! l! ?  Y& \. w* n6 m/ R
  890.   def process_jump
    9 b/ P5 r9 L: Y7 y3 D! z7 [: H! S2 `
  891.     if @index != 112 |; [$ K: H8 f3 P2 X
  892.       @index = 11# S% |9 U9 F! J
  893.       Sound.play_cursor
    0 j+ V( H$ }. I. g
  894.     end  t9 W* k  b& {
  895.   end
    # J: ]& g: @4 @% V  K4 v
  896.   #--------------------------------------------------------------------------4 ~8 `) p/ m' {$ z- M- \# M
  897.   # ● 后退一个字符% O; Q" L' q9 {
  898.   #--------------------------------------------------------------------------
    + z4 `. [; j' X/ A1 l- n
  899.   def process_back
    7 T2 P% o+ k. D% c: M. d
  900.     Sound.play_cancel
    * `$ W/ F; a$ |+ n6 h) r
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    9 ]3 U- F8 T' D: h7 X
  902.     n = (@number  place) % 10
    5 [7 g' h% J  ?6 w
  903.     @number -= n  place8 `& x4 Y* ?( c1 F% B- N& f
  904.     @number_proc.call(@number)6 d+ z% i" W0 B
  905.     @old_window_index -= 1 if @old_window_index  05 P# t4 N. |6 P2 g3 s
  906.     @index_proc.call(@old_window_index)( |; h9 G" i5 ?' D1 H8 ~
  907.     @refresh_proc.call8 ^! F$ l. H3 t2 N# v( |
  908.   end2 i. I; k0 \( X0 Y* V
  909.   #--------------------------------------------------------------------------. p5 R" a+ ]1 y2 q
  910.   # ● 按下确定键时的处理7 e# p# N0 [8 {" K3 W2 ~! q4 }9 H) G
  911.   #--------------------------------------------------------------------------8 q' Q! o7 ?% a7 L. V" j# K4 H
  912.   def process_ok3 i! |% e( I" M7 S- |6 v
  913.     if get_number* k  b7 e3 Y6 a3 ?2 I3 u& C8 u- o
  914.       Sound.play_cursor
    6 J4 L: w1 ^1 T6 A+ L+ {" X  u
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    1 O9 L# Y( ~( i% n, a7 l- U
  916.       n = get_number - (@number  place) % 10
    4 S5 I! P% e+ B# ~( ^) C9 e' ?& R; R
  917.       @number += n  place
    + H6 F! O8 B! [( K' F* B
  918.       @number_proc.call(@number)  }0 E/ C8 {2 k: r/ s# b$ J! o7 Z
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1+ e& X5 M7 L& v* [
  920.       @index_proc.call(@old_window_index)
    ' T8 M8 f6 D% H* G% G7 u
  921.       @refresh_proc.call
    $ r: `( o0 W* U! k
  922.     elsif is_delete: O' a$ i6 [) g- _7 R) x% f
  923.       process_back2 R0 Z  }) B( G& {# W. ~. O
  924.     elsif is_ok9 _6 u! |6 O% q5 \
  925.       on_input_ok2 W! e7 s8 T" l+ ^
  926.     end
    . i6 q2 S$ j7 W! F
  927.   end! d2 }: R  }0 p: O2 p# ?% J, p: v# k: K
  928.   #--------------------------------------------------------------------------1 G  U/ |) U1 i
  929.   # ● 确定# h: C7 s. y5 p+ `# b
  930.   #--------------------------------------------------------------------------
    ; T! |  ?7 a0 e: v% R
  931.   def on_input_ok
    2 J9 {" r5 m! s% l0 ~: I
  932.     @index = 0
    ( l7 q, Z2 M: [+ W7 K# v" J- M, h
  933.     @old_window_index = 04 q5 M9 [1 @  D  l% `
  934.     $game_variables[@variable_id] = @number9 ^! @  t* f' [$ J9 E
  935.     Sound.play_ok
    " g9 p( u7 ~% M) C( u% M2 I5 F8 }
  936.     @close_proc.call6 @6 {  b3 `$ X$ B3 i
  937.   end
    ; J6 P7 `% L. H- o+ A/ K) r
  938.   #--------------------------------------------------------------------------& j0 m$ J4 Z; q8 J# G
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    0 j/ q+ h+ S7 H$ t
  940.   #--------------------------------------------------------------------------
    + E4 ?" A$ ^7 X# H- V) [
  941.   def set_mouse_pos, C/ j5 o  N) ]' N& K1 C1 O
  942.     if viewport.nil # necessary!9 S4 \, }4 L7 r! q( U; ?
  943.       vp_x, vp_y = 0, 0
    6 \( U2 Z7 I& u0 }/ a3 ]
  944.     else+ _6 @7 @0 d- n7 c4 `& j7 i& A
  945.       vp_x = viewport.rect.x - viewport.ox
    3 a2 @% _2 C% V8 B9 j1 w$ Y: ~
  946.       vp_y = viewport.rect.y - viewport.oy
    ' T0 _# s2 p0 \4 x
  947.     end: J0 i: i3 T4 h
  948.     item_x1 = vp_x + x + standard_padding : m4 @8 ~/ l& z* S
  949.     item_y1 = vp_y + y + standard_padding& Z( q, D) F1 X  F' ^( I3 j
  950.     get_index = @index  0  0  @index . ^( v2 c+ B4 }  |1 Z
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    ' s. n" _! G1 L- m9 c% Q
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5), }2 D! P' W  v  A2 p! ^$ F9 m
  953.     Mouse.set_mouse_pos(new_x, new_y)$ u- Y! _: e) r- Y' {" I+ u
  954.   end
    / z( C9 O3 j3 T, d/ j# n
  955. end
    8 `5 \$ ^3 L# d2 U3 ~; ?7 }
  956. 2 W% a8 }4 E; V7 l) g
  957. #==============================================================================
    . g$ g. s! _0 A+ O) H. A
  958. # ■ Window_Message8 n1 s$ ]9 a. m0 r  W# K+ y2 V
  959. #------------------------------------------------------------------------------
    : B0 I  T4 c5 Q6 j
  960. #  显示文字信息的窗口。( A" j1 ~4 `! k" ]3 R
  961. #==============================================================================
    1 w# }5 D" F  L& U4 T4 u
  962. class Window_Message  Window_Base4 p/ Z( T) S# W4 v7 H* e( k
  963.   #--------------------------------------------------------------------------# r7 \  c5 ~- \3 x) X3 c+ l) s
  964.   # ● 处理数值的输入(覆盖原方法)
    # `0 ^( |4 A! `, m
  965.   #--------------------------------------------------------------------------
    $ P9 h7 e) l% {2 x4 \2 O: l9 g
  966.   def input_number
    8 e. T, @' I" ]
  967.     @number_window.start
    3 k- M' d; A, V2 c) a
  968.     Fiber.yield while @number_window.extra_window.active
    ! \1 R/ n4 n" D5 @
  969.   end
    ) W9 X0 x/ |  e+ T$ o
  970. end
    # t1 u, s; C! v% g4 P$ f

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

  2145. + b; i. L+ o! A  b+ d
  2146. #==============================================================================
    0 s9 [0 h9 J$ R; b4 C6 `# C
  2147. # ■ Game_Map" V5 L" E1 ?- e" n. U
  2148. #------------------------------------------------------------------------------8 `8 V6 r9 [- c. l9 S, R$ e. N
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。6 N$ g# P8 p* n; N0 U2 \
  2150. #   本类的实例请参考 $game_map 。
    8 y) H( N. L; T. b  j
  2151. #==============================================================================  Q0 }; i/ ?% W3 l8 `! w; P3 n
  2152. class Game_Map
    9 w# v  K; D, s4 T% ]7 K: a" P2 O
  2153.   #--------------------------------------------------------------------------# @* U: m0 p7 P; Y8 V
  2154.   # ● 定义实例变量8 E1 \. S% @( P9 k
  2155.   #--------------------------------------------------------------------------4 G8 a3 U' C) o8 E
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
    ( g/ _! z, v2 v& f* o2 O
  2157.   attr_reader mouse_map_y # 同上# k* n0 U: A* U+ G7 B
  2158.   #--------------------------------------------------------------------------
    * J9 c6 \( ?: ]" b+ P
  2159.   # ● 初始化对象
    " {. _/ P# Z1 o; T. t7 t
  2160.   #--------------------------------------------------------------------------
    " X8 W$ M) j( \# I
  2161.   alias sion_mouse_initialize initialize( v/ F8 I- k5 `' j
  2162.   def initialize
    * k" e  B9 D" `  D
  2163.     sion_mouse_initialize
    . z+ i% b7 S7 V. O1 u0 p0 i0 |" S9 N
  2164.     creat_move_sign  ###
    1 B' j$ y5 L$ h) D" L- a
  2165.     set_constants9 ^0 G% h( M8 h. m
  2166.   end
    $ e, o- ~0 n# \$ m3 W' ]$ {
  2167.   #--------------------------------------------------------------------------
    ' z6 G$ X, Q: n/ X3 q4 q8 S) O! F
  2168.   # ● 更新画面2 G2 H5 s  q0 }5 d
  2169.   #     main  事件解释器更新的标志! k' Z) E1 S8 y% S  z3 W
  2170.   #--------------------------------------------------------------------------4 M; x9 s: w1 M: {
  2171.   alias sion_mouse_update update
    : ~+ z- k; t! d
  2172.   def update(main = false)
      O* a9 U) s" r$ C& \* g
  2173.     sion_mouse_update(main)7 v( p2 G. z: K0 `3 Y. |+ W& o' `
  2174.     update_move_sign# f+ A8 z$ F# t, _0 v( @7 x
  2175.   end
    # z9 h+ g) n8 m# S. e( i0 \: G
  2176.   #--------------------------------------------------------------------------
      V! H+ Y8 V# h) l% M; [. G
  2177.   # ● 创建显示路径点的事件& }# v) K% B- d: ]+ B# h" J- C5 `
  2178.   #--------------------------------------------------------------------------
    , Q! a4 b  C5 E/ k& W
  2179.   def creat_move_sign
    6 h2 F$ |- ^: B% G% P, Z
  2180.     $mouse_move_sign = Move_Sign.new
    / F  M/ W- W: ~5 G+ Z' O. q
  2181.   end7 g  P  P/ r7 P6 L2 `* I
  2182.   #--------------------------------------------------------------------------
    ) D. e3 W5 t% P& Q8 b& m
  2183.   # ● 更新显示路径点的事件" Z7 }8 W6 f( o5 F
  2184.   #--------------------------------------------------------------------------
    $ O' D4 I/ g# T; w& ^3 M
  2185.   def set_constants4 N! K9 B% ?6 Q1 R
  2186.     @mouse_pos_setted = true8 X! h+ _) M  y2 ?6 Z# j" G- S5 L' h
  2187.     @set_pos_prepared = false
    ! a" A$ B  x4 v
  2188.     @mouse_old_x = 0
    ) H0 C- y( I/ ^* ~! M) Q
  2189.     @mouse_old_y = 0
    * u6 l9 u# U: M* ], U: Z
  2190.   end
    , B" b3 @) M3 n: \5 I* N
  2191.   #--------------------------------------------------------------------------: m, {0 `& g: [- k+ k
  2192.   # ● 更新显示路径点的事件
    ; T, }3 q) m( V
  2193.   #--------------------------------------------------------------------------
    & N4 r4 A3 l4 F
  2194.   def update_move_sign/ x* b' e/ g9 N8 \% d5 c1 ?+ Z
  2195.     $mouse_move_sign.update( U! u! t4 z2 Q9 z4 L
  2196.   end
    % a# r4 m, M: d2 \7 G' w) K/ `3 ~
  2197.   #--------------------------------------------------------------------------% a) w3 Y, `7 r! ?8 S! v
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
      |& R" ]! ]: s+ G4 S4 H
  2199.   #--------------------------------------------------------------------------- s; b* d/ H$ U4 r7 g
  2200.   def get_mouse_map_xy
    3 V0 _" Y1 B- r( ]: x) b; H4 N
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y1 o' `4 c- J$ A
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)  l1 B8 d! }; z9 o+ z& g
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    * `$ c/ ]& H( T: H
  2204.   end2 \0 X( {1 a; l- v- O7 n+ `( w3 Y  P
  2205.   #--------------------------------------------------------------------------6 ~1 `. c% c- f& [* U6 Z  i# o
  2206.   # ● 返回地图画面时重设鼠标坐标) o. v% A! R# j& G0 w
  2207.   #--------------------------------------------------------------------------; M1 b9 D( `+ i
  2208.   def reset_mouse_pos# y0 x. E: Q+ W! V, F" R4 R/ K1 n
  2209.     return if @mouse_pos_setted
    ' W0 u' Q: i& Z7 L7 A2 @8 A
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)9 l- `( b6 J" g& Y, t
  2211.     @mouse_pos_setted = true  S7 T9 j$ o. c/ w
  2212.     @set_pos_prepared = false+ s. Z- o! S+ B. A% C- M% X
  2213.   end+ }1 A' w4 s; G& Z
  2214.   #--------------------------------------------------------------------------  ?$ Q$ M% a, }
  2215.   # ● 重设鼠标的坐标  i% O: ?! U, ?. \7 o( K
  2216.   #--------------------------------------------------------------------------
    ' a& [$ h( X- g+ z0 @, l# P
  2217.   def prepare_reset_mouse_pos( ^5 U8 {% R6 C3 Z& U
  2218.     return if @set_pos_prepared
    2 c" T, K9 [' V# J0 ^
  2219.     @mouse_pos_setted = false2 f) ^! h- ]# m5 d5 v4 e
  2220.     @mouse_old_x = Mouse.mouse_x
    ( N7 j+ K: t8 J3 C
  2221.     @mouse_old_y = Mouse.mouse_y
    : Y1 ^1 p. W0 y. [! T( ^. X
  2222.     @set_pos_prepared = true
    # F* I- g/ I& A& c# S( ~  i7 E
  2223.   end
    5 g4 t4 V6 @  W- L6 y% x9 Q1 f, A
  2224. end
    9 N, b! u; h" [+ K1 B+ _

  2225. , q. ^- Z" t: n
  2226. #==============================================================================2 g0 I  C5 b; t3 s- A8 e  z" k
  2227. # ■ Spriteset_Map$ B) i+ i- W$ }; Q2 f
  2228. #------------------------------------------------------------------------------
    . N3 G, ~' W7 D2 l+ z1 n$ e: ?
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    + E6 _1 d, H' C- y
  2230. #==============================================================================, w2 a% w) W0 |! [8 a5 V2 p
  2231. class Spriteset_Map
    $ T- P7 }5 @# v5 _+ A/ q
  2232.   #--------------------------------------------------------------------------
    . \7 a' c' e( d  V
  2233.   # ● 生成路径点精灵
    8 k! e& i" V: h3 u; c
  2234.   #--------------------------------------------------------------------------
    & ]9 L% [, Q/ {* u4 _) k0 e: R
  2235.   alias sion_mouse_create_characters create_characters: Q) y3 `4 [) }! U4 }
  2236.   def create_characters$ X$ P+ J9 m: }- C' A7 m
  2237.     sion_mouse_create_characters4 p/ M" |( b' c/ K
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    ) p. f' T8 ?4 @1 A5 A  X
  2239.   end" j6 Q2 y6 U! H% H  C% {/ K
  2240. end& F- D5 D; [; {: |1 m
  2241. 4 x; q1 R7 Y7 l. Z, ~) F6 }* L
  2242. #==============================================================================
    : K( M" L/ r. |# h- R0 U
  2243. # ■ Scene_Map# D/ Z3 K0 l- J6 ~& \' ~
  2244. #------------------------------------------------------------------------------
    ! U0 ~( F+ R' w3 H& q, g
  2245. #  地图画面: J! i  Z; b$ I* u8 g
  2246. #==============================================================================2 O0 Z  p1 S' L, T) s+ o+ U
  2247. class Scene_Map  Scene_Base! H3 Y8 L% e% Y
  2248.   #--------------------------------------------------------------------------
    . H% B, E# Z$ e  O! \( c
  2249.   # ● 画面更新9 d# i' ^  D: @
  2250.   #--------------------------------------------------------------------------  x1 s4 D  Q9 U6 M, i. o7 E
  2251.   alias sion_mouse_update_scene update_scene
    ! g$ X$ J' P2 t) O
  2252.   def update_scene2 z( _7 b7 L6 P  h0 Y. e! A
  2253.     sion_mouse_update_scene9 c8 V3 a4 A) g- E6 {( h4 l  f
  2254.     update_mouse_action unless scene_changing
    0 s1 U$ V. k; W: E& M
  2255.   end
    6 g; q# [0 X7 a5 ^) U$ G# v) d
  2256.   #--------------------------------------------------------------------------, O. d, N( M5 x4 p
  2257.   # ● 场所移动前的处理* s5 S' I4 d* _( P( J& x" o4 y" C
  2258.   #--------------------------------------------------------------------------; @& [4 [. z+ ?3 U
  2259.   alias sion_mouse_pre_transfer pre_transfer
    9 T! x* ~) ]  c% R2 N2 g; H# f
  2260.   def pre_transfer- d1 X6 c  g' N5 \
  2261.     $game_player.reset_move_path
    ; K5 z1 G# Z, F0 t1 O7 c0 S( C! T
  2262.     sion_mouse_pre_transfer3 `4 y" G9 g9 C0 o; a3 s7 X
  2263.   end- q1 n8 Y- y; w6 a; K3 r
  2264.   #--------------------------------------------------------------------------) h* _0 i) m1 R& q$ Z9 O
  2265.   # ● 监听鼠标左键的按下
    3 b/ B( s+ S* V  m' I, Z' r( f' \- v
  2266.   #--------------------------------------------------------------------------
    9 z- U. |3 Q0 Z5 y0 M! W0 ]
  2267.   def update_mouse_action% V; V( D# m2 n7 s6 l/ [1 J5 F: l
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    6 f4 f% y2 a3 b4 C7 B3 E$ x
  2269.   end
    ( G  W( f+ m- Q6 ^. o  x& H
  2270. end  J1 b- S' I% _$ Y/ I3 j+ k, H
  2271. ' q9 x$ N) ~  D1 f2 \, R
  2272. #==============================================================================
    5 I/ R9 W; a' E7 b
  2273. # ■ Scene_File" d" C( A! p. f" n7 z7 Q6 E
  2274. #------------------------------------------------------------------------------
    4 B5 L! d: K( @- |  g
  2275. #  存档画面和读档画面共同的父类4 p- U/ {* c2 b$ q
  2276. #==============================================================================
    $ b; ~% d% p8 R# d
  2277. class Scene_File  Scene_MenuBase
    / Y* |* j7 a6 C
  2278.   #--------------------------------------------------------------------------
    1 d9 V& e& k$ o& ~& K
  2279.   # ● 开始处理
    , Z; T! H+ N2 d/ n+ y% Z
  2280.   #--------------------------------------------------------------------------
    / Z' v/ {( c3 r* |
  2281.   alias sion_mouse_start start
    ! u6 g* H$ r, ?; s. d$ W
  2282.   def start
    4 x  @1 P+ b- q+ h1 H" N
  2283.     sion_mouse_start: K1 Z+ S1 ~/ Z
  2284.     @move_state = 0, O4 n+ C5 @5 A% `6 ?2 n/ I
  2285.     set_mouse_pos1 t$ L' p7 _* e& k$ Q
  2286.   end
    3 ~! u2 F+ }, P8 ?$ C
  2287.   #--------------------------------------------------------------------------; ~+ ?/ |$ w3 a' }- F* ]5 j
  2288.   # ● 更新画面
    5 F) C% m; {. x6 f" D* J- s5 z
  2289.   #--------------------------------------------------------------------------
    5 y1 A# C. d, X
  2290.   alias sion_mouse_update update
    * |$ M2 v2 z8 y. B: \
  2291.   def update) x. y$ K( H. k( z4 r6 s2 q
  2292.     sion_mouse_update
    0 t/ {# X6 j6 a/ S
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    ! O& J$ C' N4 ]; Q: ~# F
  2294.   end" [9 b3 F0 r: S7 E; c- O
  2295.   #--------------------------------------------------------------------------
    ) |" J3 A! U. v; |7 ^- v2 J1 r% O
  2296.   # ● 更新光标
    0 n" p- B4 g1 i- B4 Q
  2297.   #--------------------------------------------------------------------------& i  d" O$ Y( k# J' l
  2298.   def set_cursor
    , I+ w: g. z+ D8 F& m3 \* d5 p$ P
  2299.     @move_state += 1
    * k" [) y; A* y5 G
  2300.     last_index = @index# a) p2 P9 H# T' \4 S
  2301.     if mouse_which_window == -2
    . x# c& I. S/ Q4 v
  2302.       if (@move_state - 1) % 6 == 0$ y/ }; H8 W( S7 c# I: I
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    0 o) x& K3 \+ z, ^8 ?
  2304.       end, _' [) I+ O) @4 n
  2305.     elsif mouse_which_window == -1
    , J( N- ]: M: e$ c0 i, C
  2306.       if (@move_state - 1) % 6 == 0) `1 m0 k! p/ k* A8 X
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    $ i. Z/ j, {: p7 h. W
  2308.       end
    8 R7 {, Y! a) ]8 b8 `0 ]; [
  2309.     else4 W. Q( f& o) a
  2310.       @move_state = 0
    ( q9 ]' A  M9 \8 `. ~
  2311.       @index = top_index + mouse_which_window; G& C7 u0 M4 ^! l1 H8 }! ]
  2312.     end
    - e. x4 b6 I( c
  2313.     ensure_cursor_visible
    6 `8 a3 `% q" {. ]
  2314.     if @index != last_index/ M6 m8 R& I1 z0 v9 R4 b: A+ n" }& I  Z
  2315.       @savefile_windows[last_index].selected = false
    . N3 S4 q8 Y7 e  r+ x
  2316.       @savefile_windows[@index].selected = true( x8 U  L; a& [3 {- f' j
  2317.     end) n/ v9 G0 B9 b7 L" i
  2318.   end
    ) G1 {$ a5 Z# g
  2319.   #--------------------------------------------------------------------------# B# T5 }8 A8 ^* Z$ ]
  2320.   # ● 判断鼠标位于哪个窗口
      k8 h  w8 P; O1 B
  2321.   #--------------------------------------------------------------------------
    / w% W) h7 L. v; Y
  2322.   def mouse_which_window
    7 S8 ]/ |) H7 T
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y+ k9 \) l, a1 a, F/ v: y$ x
  2324.     if mouse_y  @help_window.height + 141 ~5 K! v( [4 ^: V
  2325.       mouse_row = -1# Q4 t; K( k- R+ _9 S0 u
  2326.     elsif mouse_y  Graphics.height - 14' p  Y9 q+ t# k: Y. F
  2327.       mouse_row = -2) f' o' b& m+ l8 {: B# e
  2328.     else
    ' t; d' v* e! b, C
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    2 |- G+ X3 C0 e# u2 \( s9 L
  2330.         (Graphics.height - @help_window.height)
    0 Y  I% x8 t5 `1 }, q4 U4 y
  2331.     end6 a/ f8 @# t0 i- z" q
  2332.     return mouse_row
    4 n  V% e; i/ M7 |( ]
  2333.   end
    6 ?& q* N' @/ H8 @1 |  r
  2334.   #--------------------------------------------------------------------------* @& e/ O8 l* v% ~$ m8 S6 `4 ]
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置1 p+ b% R4 [3 n3 b6 Z5 _
  2336.   #--------------------------------------------------------------------------+ `! f' Q6 Q# Y
  2337.   def set_mouse_pos
    4 g) H) ^8 r0 A& ~) g  e
  2338.     new_x = 40
    : `& a* |" H3 _
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    * r) ~9 a% S: q7 D0 v6 a4 X
  2340.     Mouse.set_mouse_pos(new_x, new_y); h6 l3 ?% I% W; E0 K0 s  d* L' I
  2341.   end9 q; p( S9 `4 H% y5 h+ i: p( @( \
  2342. end
    - N) f2 w+ N  W7 J" d7 @6 |

  2343. % l* K9 q) w9 Q# q% n2 h) V
  2344. #==============================================================================& d& S3 R" G( o8 M
  2345. # ■ Game_Event
    3 j2 b7 N/ _4 u& f4 x. L
  2346. #------------------------------------------------------------------------------
    4 n, W) d  _; a1 e2 d- @; L
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    7 P6 A% A- p# u2 c* Q" N) L
  2348. #   在 Game_Map 类的内部使用。
    * G. y3 g8 L! N; T+ N2 j
  2349. #==============================================================================4 v3 @7 W* R, }1 q$ Q3 ^
  2350. class Game_Event  Game_Character( m# b- T; @0 ?  A
  2351.   #--------------------------------------------------------------------------* u% j3 F" Q* v/ d- U/ ~, ?8 D# [8 f
  2352.   # ● 事件启动
    $ v; Y# k" N' V' X, z
  2353.   #--------------------------------------------------------------------------
    2 G- x  w0 n. y! q& M+ q* a7 Y
  2354.   alias sion_mouse_start start: X/ o) {; G$ m, r
  2355.   def start8 G6 X/ C4 M, O' ^! g
  2356.     return if mouse_start && !Mouse.press(0x01)
    ) ^6 f2 J! ^3 G! J
  2357.     sion_mouse_start) c6 t2 E, h4 J" F- \0 [0 }) W
  2358.   end/ {3 [" a& y: Y2 t5 V+ O8 }
  2359.   #--------------------------------------------------------------------------9 u9 N- x+ T+ ]- n
  2360.   # ● 判断事件是否由鼠标启动
    % x$ P! e6 _. Y8 r& n; l, J
  2361.   #--------------------------------------------------------------------------  t0 `* h  V% s* b' ?
  2362.   def mouse_start
    ( B& [; f7 q; e: B6 m; B# F- n% H
  2363.     return false if empty* I) g% l% c# l2 x: t& A6 o  D5 s
  2364.     @list.each do index- |& q2 a/ v8 @3 w, k$ s
  2365.       return true if (index.code == 108  index.code == 408) &&8 l7 `( \" b7 f& a
  2366.         index.parameters[0].include('鼠标启动')0 K1 ^& [! Y# }  Q6 w
  2367.     end
    & \5 k3 U8 z5 S: M
  2368.     return false) m) V: e2 F! C0 B' `5 K3 B% k
  2369.   end" l+ t+ W. [- r8 z2 S
  2370. end) y; `% ~; s# V
  2371. 4 \7 I" ~5 S: l9 ~% j+ H
  2372. ####泥煤的height( H8 A* f+ f: r
  2373. # @height = height
    ' ]* i0 X2 z" k5 o8 H4 M& ~" G# v
  2374. ; l9 e5 h  L. r  V, a& p( a6 ]6 e7 x
  2375. class Area_Response
    " ~3 K" K0 [# f1 s. c
  2376.   attr_accessor type7 K8 ?' g, ?' i9 e) z6 K, D0 ?
  2377.   attr_reader ox- i+ v7 X( v) i  ?2 O) o2 A
  2378.   attr_reader oy5 n- k1 W! y1 U: e2 U* R
  2379.   attr_reader width
    / J& ]/ C6 C. {$ H1 V0 H
  2380.   attr_reader height
    % z0 K9 g" I8 J
  2381.   attr_reader switch_id0 o7 r  ~0 x0 \6 @4 o4 o
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)6 Q$ K+ E9 @* h1 M5 c1 r; a
  2383.     @type = type
    0 f$ |. e7 N! [+ Q8 v4 N
  2384.     @ox = ox' U# F( f* X. J
  2385.     @oy = oy
    . P7 O2 l  ?4 ~6 H* X, r6 [2 s/ _
  2386.     @width = width5 j3 P$ B3 b& C  X# n- h- I+ l! k
  2387.     @height = height
    9 t4 u8 _7 j% w  Y" m
  2388.     @switch_id = switch_id- i1 E* u5 U" B  w6 p6 M3 ]- U
  2389.   end( F6 s* p% @) K, `" w! l3 W
  2390. end
    " C, t9 F  u# w- A5 ~

  2391. 3 n) p) k9 a, a
  2392. $area_responses = []6 H5 B, t$ t/ w

  2393. $ z2 T0 g4 y8 n" f+ c8 G9 A
  2394. class Scene_Map: H: c: D* V! h$ E  |
  2395.   alias update_mouse_2013421 update_mouse_action& O; q0 d2 f8 L: N* v
  2396.   def update_mouse_action
    % y5 I: B. T4 b8 }! ]
  2397.     update_area_response
    4 L: w$ n3 Q% `7 n* [. v
  2398.     update_mouse_20134217 q) n6 r+ I* f: Z1 l
  2399.   end
    # u2 G' h$ B2 l: Y
  2400.   def update_area_response" h# J2 e6 N* o) o. m6 v
  2401.     responses = $area_responses8 S! _+ X9 |  I- }" h- S
  2402.     responses.each {response# E5 o* @8 `- l( p+ J
  2403.       ox = response.ox
    ' c) b4 e! b4 Y# D' m: ~5 Q0 Q3 u
  2404.       oy = response.oy
      C: c) M+ [; ~
  2405.       width = response.width) z5 l( S( b# i' s1 |, L
  2406.       height = response.height
    " f9 M- |$ C2 N# H
  2407.       switch_id = response.switch_id* r. X9 t) X# {# L: u' p# A
  2408.       case response.type
    ) W/ n. F. {( ^$ ^5 t( l7 P
  2409.       when 0
    9 t# O# e  l/ u3 u
  2410.         if mouse_in_area(ox, oy, width, height). {% V& X$ f0 v3 o0 M4 s
  2411.           $game_switches[switch_id] = true% T4 o7 |5 K3 z
  2412.           $area_responses.delete(response)
    " [# m7 l3 y% Z
  2413.         end
      c; q- Y* @9 p/ i' l( s  G' c! S' e
  2414.       when 17 K3 f2 U/ ]0 E, I8 b
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    # A' i5 C0 s+ ]; R( L+ @  j! H
  2416.           $game_switches[switch_id] = true
    ; [/ z& e, M( \5 f/ b2 O
  2417.           $area_responses.delete(response)6 d9 A  H+ P) Q3 D$ R/ K
  2418.         end
    6 g9 W* a4 @2 A* b% D0 P
  2419.       when 2; j4 @, |- e0 M2 W% N% v1 U: E, x
  2420.         if mouse_in_area(ox, oy, width, height)
    1 v9 y  }  \* y8 N7 V- R
  2421.           $game_switches[switch_id] = true0 M* y9 k8 a2 P
  2422.         else
    8 \9 Z/ r- Y( D6 ?2 v- @! _
  2423.           $game_switches[switch_id] = false  `3 g& C5 f0 f8 {
  2424.         end
    3 C6 f  Q) e. ~
  2425.       when 3
    / N& s' ]1 \0 K, Z7 h) K7 @
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    . K) m1 c  \7 s* ?1 F' p
  2427.             (oy - $game_map.display_y)  32, width, height)9 w; p0 a+ l1 |! p  @: D
  2428.           $game_map.events_xy(ox, oy).each {event
    , r+ f5 C* O1 }  O! Q
  2429.           event.start+ D& H; v# N# J  y" c2 ?, h
  2430.           $area_responses.delete(response)
    / R& J: _* x! A- m
  2431.           return
    " C( P2 Q* r% j; ^" {! F
  2432.           } % t/ g0 T) O8 Q; b8 V3 `
  2433.         end
    / N1 d1 v% [) O3 |+ w
  2434.       when 4
    3 t/ M5 c; }( t+ J
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    / R5 ]0 C, d5 i9 K9 T
  2436.             (oy - $game_map.display_y)  32, width, height)
    4 e: P. [; H# K; `- w4 }
  2437.           $game_map.events_xy(ox, oy).each {event
    3 t- H9 m  V5 t
  2438.             event.start" l% }1 p: v0 C- d6 P! l$ \5 v
  2439.             return) q0 L; l$ T1 O$ H8 y
  2440.           }
    3 W, R6 D( F$ Y& f
  2441.         end
    , s9 S: h8 k* v( Y! y
  2442.       end& n& r, ?! ]5 M; c2 _
  2443.     }7 T0 n. ?& A/ }* H; L7 g7 D
  2444.   end
    4 J2 _9 h( t+ x* I/ K( n
  2445.   def mouse_in_area(ox, oy, width, height). \% [; W  i* }8 l
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&( n& A6 f5 R" ~5 q9 H
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    ' i' J! _1 i  ?, Y! \2 Z/ z
  2448.   end
    ( d1 d0 y  l: f
  2449. end, x4 q5 |1 B( h0 b
  2450. class Game_Interpreter
    0 C9 ^9 B+ [/ `9 A$ x3 a: y
  2451.   def area_response(arg). i: Z2 h) s9 }
  2452.     $area_responses.push(Area_Response.new(arg))
    ; D: ?# H4 _5 o$ l4 r8 L( H
  2453.   end, s2 k! S$ N( I3 e" j: W7 W! I
  2454. end- a+ g* U5 N) ~- |- j
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1