Project1

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

作者: 熊喵酱    时间: 2013-8-29 09:01
标题: 存放腳本
純屬給LBQ腳本:
  1. =begin #=======================================================================
    / G3 K$ M, d, r- v8 W* |3 m; T
  2. 5 j/ b# T7 H6 v
  3.   Sion Mouse System v1.3e% U/ a/ a7 ]) b/ d/ P
  4.   
    $ `. _! d0 P( F/ v
  5.   Changlog
    ( V1 u) |9 {1 ?2 ?4 \. E' j! G$ O
  6.   8 B0 Q$ x- Z$ _4 O* I; R( T, m
  7.   2013.4.21 v1.3f
    " ^- o& Z8 [' T4 z1 V3 U$ J
  8.    
    / @, O$ A" K; {2 W9 ^* J8 i
  9.     1.3f 卷动地图 bug 修正7 z9 J: `; O" m; ?
  10.     & P* F- g0 _3 R. e8 L5 f
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口* |+ M# u" l& L. ]4 s( Y; J0 {7 F
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    7 \9 p0 T3 j1 s; a) j1 A/ w
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    " N4 @, j: U8 g0 j3 l3 J
  14. # n! ?0 t9 z( ^. x$ L( P
  15.     1.3f bug修正9 y+ V0 ]% m- y; Y
  16.   
    : n/ g7 |+ c# ]
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    & K7 E* A  j2 |( c3 w
  18.           关闭菜单时,鼠标是否移动到原来的位置。6 A# S& U+ G. V" V6 s$ d2 v

  19. 1 Y, G7 W; O/ F
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    4 ~$ H6 I* c2 ]; x
  21. 8 }) ]- n+ x; j5 W
  22.     1.3b 修正一些罕见的bug;
      [, f3 {9 b, T( P

  23. + c1 C! v# e  H
  24.     1.3a 代码小修改;/ S+ E/ S! J. q: F
  25.           加入了鼠标点击启动事件的功能,1 r5 ~+ t3 M% ]
  26.           在事件中加入“注释”: 鼠标启动  ,6 K- D; r5 h4 y0 D/ k
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。6 C0 A- K. ]% H
  28.   
    # N, {- i7 a0 T  |% J
  29.   2013.2.12 v1.25 C* C9 _! H7 {0 |/ m, C
  30. 8 }8 |5 t, n( {! p( r
  31.     寻路逻辑优化;7 U$ ^  u) K9 w3 p$ R- j
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;) F1 \) T- w1 M9 {/ E! V8 [0 Y9 k
  33.     现在支持用鼠标来操作载具了。
    6 i/ l; y1 ^, f5 @# C( B* L; Z
  34. ' ~, o) h1 }5 `' X5 E6 \4 l
  35.   2013.2.8 v1.1
    1 a. C' E2 g& O4 d

  36. 8 F! U+ y! c4 K5 K- [
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;0 B$ w2 G+ x+ U- p  y
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    : m4 K% J: ~$ c. R4 |' {
  39.     移动时,路径指示点的绘制更加稳定;6 ^" S/ i! V) r+ x! h' ]
  40.     现在支持默认存档画面的鼠标操作了。
    - [1 o* ?6 Y8 p! E( k
  41. " S) i6 y0 |) {' H; U! g. e, E' o
  42. : f$ \. l  X! [( I9 f% l
  43.   OrigenVersion
      [8 A% P7 H# S. {0 P# ]& ~: C! n
  44.   2 O  b" a( f1 o3 F' A# w8 a: E
  45.     2013.2.7 v1.0
    , J( O4 a1 W' ]  D3 b- W" t
  46. ! |+ D1 W# w" ?* ]
  47.   主要功能
    1 G* @( ?% \, ]
  48. ) A! p0 J# P7 l; Q2 y5 j& ]
  49.       使用鼠标进行各种操作...$ K& ~# m% L7 y$ \( a3 H
  50.       将鼠标锁定在游戏窗口内6 ?! C1 w, D: i: S) v! z
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    / ?6 l! p; E3 X# _
  52.       双击鼠标进行冲刺
    2 s! k5 g0 N3 p
  53.       更改地图卷动方式以适应鼠标移动
    # u2 y: R6 j7 e* H" t
  54.       变量输入框改良
    - {  `! w! p% k. X- R( T

  55. ' [+ n3 U1 d$ h, D% S
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹, q0 ~& x' V& |4 g

  57. # I- ~" Q5 o8 M4 @1 j
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹% P: ^0 }7 ]. Q6 \5 `
  59. ( K. @( h; E5 e' s
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭+ @. }# g4 }1 D. |8 o/ f6 D
  61. / m1 V) j- `, r- Z9 `+ u

  62. 2 Y: y' R9 @! R/ w  W1 a
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    6 s" G% C1 ]# ^
  64. $ Z5 }! O# m- l0 K1 F3 c' O/ H

  65. 4 N0 e$ V8 M1 e& J+ ~
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    8 P5 h6 l: v( q: j; z

  67. 0 c' Z+ g  W. X7 M, M- H
  68. #==============================================================================
    $ P- J; [5 I; p  b' y+ I9 H
  69. # ■ 常数设置
    0 c& G. \1 I4 {& n, z# B
  70. #==============================================================================
    : @; k( `1 E9 s1 j& @; r
  71. module KsOfSion
    " `; s7 F9 r8 R" e
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    ! B8 x: N9 {- ^3 P
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    7 ?9 e" c6 v  s6 B
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false! Z' q. d8 S9 s$ \0 ]$ _
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量! q7 B/ P% \, a* ~& V
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处& l' N5 O  L! W
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧3 Q& |8 {" J/ k& X$ q
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    ! ?- b3 h6 L0 K  j2 B! J
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键# @* i9 M9 `6 h! N
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    1 p. f) u! a& b! w" m5 Z$ t$ m
  81. end) u! v" f1 Z* b" Q
  82. 8 w: K4 v0 p* K5 e
  83. #==============================================================================
    ! U/ V) b& J# p
  84. # ■ 用来显示路径点的类, ]1 y# A$ O8 _
  85. #==============================================================================
    ' z$ k, m5 e  v5 A3 q
  86. class Move_Sign  Game_Character
    , b/ ]; U- U6 n( H# l0 g1 N, U
  87.   #--------------------------------------------------------------------------
    2 W( Y& H4 h" p- t0 P7 }" T
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    # T! r, e9 ]! Q  ~* V
  89.   #--------------------------------------------------------------------------) Y; T0 `+ N6 I, p: `
  90.   def init_public_members. h8 A2 ^- C$ C- V: ^* S" y
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    : @: O3 W* f$ u3 }
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0: Q9 |/ T. s5 o# N. U: _
  93.     @move_speed      = 5        # ★ 踏步速度
    0 ?" w, r1 n7 ]: A- o) H( x
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    4 T: Z" y: R% O
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度5 ~" w- Q/ d8 {. T% H& c1 D7 Z
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    : ?' i, A) [* j. n7 X
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    " ^% R1 }; h; ?% x
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    ! Z9 m7 A3 P4 Y+ `
  99. & @- k. B7 V7 D# C, i* Z
  100. 6 C0 a  h+ I$ b  K
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    2 C9 X; W3 X# B: g. I) D- o! u3 D

  102. " _' Y! N  }% ]/ F
  103. ' |$ c9 ~0 L$ X8 C  y( @4 Z
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图6 n* y, d: ~, _. M. D
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')5 a; I. s3 [/ Z0 I9 }+ y+ Q

  106. ' _# F' v4 J. i) Y0 H- A3 T( h
  107.       if $no_arrowpic_warn
    # M- U& m0 E: a& E& K
  108.         MouseShow_Cursor.call(1)
    4 n) g2 B9 o( L8 q* k
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png$ a) a" S6 j; E& C6 z7 M
  110. . X% ~8 ~2 A0 j5 I2 D5 W
  111. “路径指示点”将使用游戏自带图片
    3 w% s! X+ \* T

  112. ! l& z& A( E% L5 r! _2 x
  113. 该提示可以在脚本内关闭')
    ) g* G1 Y! h* S+ D
  114.         MouseShow_Cursor.call(0)
    6 h; r: ~- W6 Y! i: F" w7 Y, W
  115.         $no_arrowpic_warn = false2 ]" N! o2 [" c* Z- V) G9 H
  116.       end
    4 B, h+ V, s2 U
  117.       @character_name  = '!Flame'
    3 e1 X( w& o- [9 S
  118.       @character_index = 6
    5 ?1 {( w( Z' u- Y7 p
  119.   C3 q9 m9 h* S. L9 Q+ }: s, Z
  120.     end' q/ F) F' O0 j# q9 s- C
  121.     @direction_fix = false  # 固定朝向
    % Q6 d8 H' H6 N' l
  122.     @move_frequency = 6     # 移动频率
    0 r/ Q6 _3 U- ~4 f6 `
  123.     @walk_anime = true      # 步行动画% f8 c) Q: D. c  _& I2 G- X, k' \7 P/ [
  124.     @pattern = 1            # 图案
    8 c# ~6 j. j- G5 J9 k  T
  125.     @through = true         # 穿透
    1 w: V! W+ V" v" E3 i5 f+ ^
  126.     @bush_depth = 0         # 草木深度
    0 S0 N% W& O2 P/ m* y
  127.     @animation_id = 0       # 动画 ID! l9 a# M' g: Z; Y9 C0 D6 X
  128.     @balloon_id = 0         # 心情 ID
    % c- P( M  _( Z8 p
  129.     @transparent = true     # 透明
    & e: ]6 O. j& P* |2 ^
  130.     @id = 0
    ( c" ~/ e7 m1 [& {! D0 Y5 O
  131.     @x = 0
    8 O+ o; J9 d4 d0 H1 E( x6 g
  132.     @y = 0
    " o6 w% D2 o+ F* h3 n
  133.     @real_x = 0
    5 J% `9 H. \. C% R2 B
  134.     @real_y = 05 y2 }- i$ B0 `
  135.     @tile_id = 0/ ~, A: j, O' Z% {6 d
  136.   end
    # F1 F3 D0 g1 ^3 U# ^/ o1 _
  137.   #--------------------------------------------------------------------------
    - g3 V1 t& O2 @) L6 I/ S. u# K
  138.   # ● 定义实例变量7 Q( z$ _! M& G# B/ Y
  139.   #--------------------------------------------------------------------------
    . I  A( r* U; ^% Z) u  l* v- h  e! P9 j
  140.   attr_accessor direction
    * J. l, x+ A7 F" P' c. O, U9 H& T& K
  141. end
    6 ~6 C; [$ t0 H* g' n
  142. 6 L# v2 R) J- {% I' z, E) _8 D" q. p
  143. #==============================================================================
    # H! I/ E- i: k( _) y( n/ y
  144. # ■ Module Mouse6 x; p9 H" c( y" `: }
  145. #==============================================================================
    1 O  P2 j- d/ b; H+ {% c& k
  146. module Mouse
    3 }8 k5 _+ C* q. V: C- R' n1 s$ v
  147.   #--------------------------------------------------------------------------# O9 l4 x) i* y$ x" c5 @
  148.   # ● API- j# Q/ o- d' z) f9 n) `; \
  149.   #--------------------------------------------------------------------------
    . f: t9 b- Q' g1 f2 U! M' u
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    . \' ?0 k8 B, E; A0 _& P* Z4 {
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')8 u  b7 S# M3 y
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')" Q8 {& s0 m0 m* v* L
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')- o$ t0 y. o9 i5 Y2 C  l
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')% L( _0 H" a$ D! Q
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')% A" C6 {# O" o8 I7 r, n" A) v
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    & r) n; l# U) e9 `: W
  157.   Window_Hwnd       = Get_Active_Window.call
    - w2 g: k- e3 Q/ Z9 t! I$ ?
  158. 8 S3 z, D3 m5 @8 }0 Y0 G
  159. class  self
    $ _0 w# z5 ^* j9 x' U+ |
  160.   #--------------------------------------------------------------------------5 C# V% l- m2 y, T1 e9 M
  161.   # ● 初始化  ?9 T. q9 b0 S) ~5 m# H
  162.   #--------------------------------------------------------------------------3 M# r% s! c9 i- ~! D
  163.   def init
    8 b, ?+ _/ u- M. q6 h, F. [" x
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
      u' ]2 d' Q& j2 N# t+ ^
  165.     @left_state = 0
    4 k, z" c/ ~( W- h0 C
  166.     @right_state = 07 e6 x  H9 l  |; U: ]
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    1 y* ^. }" k: d* P; N0 E  t
  168.     @dk_count = 0 # 用于双击的判定. @8 q! U, t8 e; g
  169.     @clicked = false+ ~- |7 c. u/ G1 {
  170.     creat_mouse_sprite  h1 u0 X6 ^8 j
  171.     update. O  n3 K+ r4 H( _9 A7 w+ }
  172.   end% Q2 r/ s- [0 F) @( |' a. E. V
  173.   #--------------------------------------------------------------------------
    3 l8 {# o3 k* X! T0 r
  174.   # ● 鼠标指针精灵+ t0 s' `$ g9 N3 l- ]6 ^, V
  175.   #--------------------------------------------------------------------------
    ) h: x" e1 M% v
  176. #~   def creat_mouse_sprite
    0 x/ U+ e' m% ?2 y4 r* A
  177. #~     
      D% e) g0 r9 U
  178. #~       @mouse_sprite = Sprite.new# b( |$ m: q) I
  179. #~       panda = 2#rand(2)+15 z0 y) [# L! o" }! t3 \6 \

  180. 3 ?; p  k1 A. I3 c* E" w
  181. #~      if panda = 13 j0 a1 E4 ]* s) Z& k" ~
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    ' F) M- ^/ o3 Y7 @
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')$ T) l  l/ w3 k
  184. #~        end#with if File.exist- B% g2 |- W, ^0 ]; I' C+ Q6 ]# H
  185. #~    9 q' T5 z$ C' j" t! Z) x: g
  186. #~     else if panda = 2 #with if panda=1
    2 j1 w7 [: o( W4 ^5 M  \
  187. #~      
    1 ?  D. F; X. U, M0 L1 j
  188. #~      if File.exist('GraphicsSystemCursor2.png'): ]/ b% G0 W& `7 O6 q6 v
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')& l! j% P% r: A
  190. #~      end#with if File.exist
      L- ?! c1 T) @2 L# S' \* d- q
  191. #~       7 r8 W8 e) z. o: p6 N8 T
  192. #~     else #with if panda=1
    ) a2 l- y) A9 z, q8 C# w! J
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)( p% Q1 D( R$ S. x
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    4 L. T2 u& x2 F* X  e4 O
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    0 I2 @. T! U3 r/ _  G
  196. #~     end#with if panda=1
    2 I  b! o' \; V2 ]4 c
  197. #~     
    ( W7 {( Z# p- L  t5 ~
  198. #~     #with def- c) {) `+ M) n; W! ]9 {6 C9 k
  199. #~   end
    . i; n3 [3 o5 s% g* g
  200. def creat_mouse_sprite
    7 a6 p: ~$ b" Y& h7 r# |
  201.     @mouse_sprite = Sprite.new
    ( h5 E/ `" \3 q- t$ H4 R7 R
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1}): t6 T2 _2 n. O* k
  203.     @mouse_sprite.z = 9999
    . x8 \+ r1 |& i; m8 c3 b; B( |9 ?
  204.     Show_Cursor.call(0)
    9 F  }/ ~# k% [$ Y- v7 F
  205. end
    ( I+ B% Y* _5 q8 V4 n; V* d8 f8 L* b
  206. 8 |: k0 e8 ]' K4 L% E& x
  207.   #--------------------------------------------------------------------------6 }& M% y/ P8 Q1 x9 S$ _# A5 T' o
  208.   # ● 更新& r% }9 N  {0 h& ?/ F
  209.   #--------------------------------------------------------------------------  d3 W0 Q7 z3 |; |& d8 y) `
  210.   def update
    # h- d2 \, Q$ F9 X, c" \6 R; E
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos7 T! D/ _- a3 k; t' b
  212.     left_state  = Get_Key_State.call(0x01)' h1 W3 e; Y3 [) X2 h5 Y
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0% Q, \- I) g. o7 A
  214.     right_state = Get_Key_State.call(0x02)
    0 g1 I3 y6 n( O( s; t  }$ a8 X
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0: d" u$ H4 e# {& t. O- y) ]! B3 F
  216.     update_double_click& N& W$ u% ^* Y8 C& \  s
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    7 K0 ?. Y+ _8 T9 O1 w7 I* T, a
  218.   end
    ) v" k& w6 ]2 j" b% I
  219.   #--------------------------------------------------------------------------
    9 z& a, g+ K) E3 N3 }  C
  220.   # ● 获取鼠标坐标
    : w# x- a3 K' l$ k8 u
  221.   #--------------------------------------------------------------------------
    & @  x; G3 H) V3 s. A
  222.   def get_mouse_pos9 m/ ]7 Z. ~% w
  223.     arg = [0, 0].pack('ll')
    2 n% E4 M" C! C$ T" A; H. y
  224.     Get_Cursor_Pos.call(arg)
    $ m7 F  j0 J8 O: W
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    / V1 C* j" W# P& }
  226.     x, y = arg.unpack('ll')7 V9 P( X" Q: X
  227.     return x, y4 v1 }0 b: B$ l2 H$ E! [" m
  228.   end2 K0 I( k. W  V4 |- T
  229.   #--------------------------------------------------------------------------
    & w$ l" r* a5 s- Z3 }* \/ ]8 N
  230.   # ● 将鼠标固定在屏幕内' X9 H: e) K7 w7 ~6 X0 K6 s
  231.   #--------------------------------------------------------------------------5 E; u/ U1 z  \) s
  232.   def lock_mouse_in_screen% r9 G$ R0 U, h& F; B* i$ ~
  233.     arg = [0, 0].pack('ll')4 t$ @3 {+ f9 L& j1 C% W$ F
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    4 J& Q, J7 N+ K* e7 G
  235.     x, y  = arg.unpack('ll'); B' N2 B# ?7 ~8 t. _
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    . ~* a2 x0 i9 i1 V
  237.   end
    6 S, ]4 l5 f5 w! ?% P. ]; K1 g9 x
  238.   #--------------------------------------------------------------------------' k0 j# k' i( q
  239.   # ● 解除鼠标固定
      z( w* q( I( i  k( y
  240.   #--------------------------------------------------------------------------4 `8 t" U: a( k0 H. q
  241.   def unlock_mouse_in_screen6 ?2 c% C9 c6 B8 ^0 M4 @5 f- u* M: z" H5 s
  242.     Clip_Cursor.call(0)+ M) r8 _% `. H
  243.   end! v# [2 m6 @7 u; i+ k5 o8 v+ H: O
  244.   #--------------------------------------------------------------------------' t) x  H4 c" L" Q* Q" T
  245.   # ● 鼠标双击判定
    / ]3 F7 z# L( F+ H" D+ V
  246.   #--------------------------------------------------------------------------
    ) j6 x/ y0 v& M! M; D0 ?* ]; Z) ~
  247.   def update_double_click
    4 I; k9 Z7 E) g! D1 P' m1 \
  248.     @clicked = true if @left_state == 10 T2 o5 n8 [9 a* F4 D
  249.     if @dk_count  0 && @left_state == 1
    ! m4 z" P1 t6 u3 ~  ^# v1 P/ Z
  250.       @dk_count = 0; @clicked = false
    ' P7 w5 T- R* ~% T/ S# w# n
  251.       return @double_click = true$ Y, E) D! a. |4 m8 }
  252.     elsif @clicked
    ) \$ f! r/ E1 ~' |* b9 F2 ?
  253.       if @dk_count  KsOfSionDbclick_Frame' Y- L( y& {; d: a( N
  254.         @dk_count += 1
    8 r& T" |3 X7 r4 b, |$ ]
  255.       else
    % N6 v! ^) F- Z, ^6 i( l1 M3 N
  256.         @dk_count = 0; @clicked = false
    , F2 x0 w% z* \& q9 ]8 _' z
  257.       end  ]& T, D7 y" P
  258.     end" p# q; ~! V2 ~
  259.     @double_click = false
    1 R1 r+ S5 X) q: h
  260.   end$ f& w! M" y( o
  261.   #--------------------------------------------------------------------------" _, D7 u" y* j- f( f; u- ?
  262.   # ● 按键被按下就返回true
    & D% x& Q" a) f8 K4 f+ `
  263.   #--------------------------------------------------------------------------
    7 L4 ?( F' {6 i
  264.   def press(button)7 e" x1 @- |9 a+ F# F: _
  265.     case button
    1 I; ^6 R- E4 \( _+ i* r; |2 x
  266.       when 0x01; return !@left_state.zero+ S# B* {2 j- E2 S6 m* h* k2 W
  267.       when 0x02; return !@right_state.zero$ J* w7 A5 |" k& n! G
  268.     end+ p- V0 R5 H$ Z0 @4 f( S
  269.     return false4 m( Y1 C2 x" f; C/ E
  270.   end
    3 p9 J" Y- }1 O* g8 H  a
  271.   #--------------------------------------------------------------------------
    * g( J, V! k, G+ Z, d) b
  272.   # ● 按键刚被按下则返回true/ M/ l* g) h8 E. l3 c$ J# Z1 D  _
  273.   #--------------------------------------------------------------------------
    0 h4 y8 D* U! {
  274.   def trigger(button)
    $ j% h1 g5 E. S$ e: r5 s0 h/ W
  275.     case button
    ) O1 }! u$ w# T( H( y$ q7 e# |. l8 h
  276.       when 0x01; return @left_state == 1
    7 P0 N/ K; f, g+ V8 r" z
  277.       when 0x02; return @right_state == 1$ k9 }6 I5 z$ Y. i0 j
  278.     end6 w& n) S* U1 z- P+ c
  279.     return false
    6 c' a5 f; h8 d' A9 u1 @* a# q1 Q
  280.   end
    # t- n# H$ g# N/ ]9 l8 V
  281.   #--------------------------------------------------------------------------
    : C9 ~# m$ [4 g7 V6 S1 N
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    0 i) K9 c5 Y* |: x& X9 Q
  283.   #--------------------------------------------------------------------------
    - |) ]# l6 Y7 \! i0 D2 ^
  284.   def repeat(button)
    3 p5 h+ N/ Z1 W# g* X7 Z
  285.     case button
    + D0 b+ m" A* S3 D/ M. c/ Q
  286.       when 0x01; return @left_state == 1
    + s* Z2 B" L, s3 X6 u8 {
  287.         (@left_state  22 && (@left_state % 6).zero)
    4 z" y) X8 _& H! x* v
  288.       when 0x02; return @right_state == 1 & _* m* S" ^4 S1 N" [
  289.         (@right_state  22 && (@right_state % 6).zero)
    7 J: S0 d1 j3 V- e
  290.     end2 _3 ?( e. m5 z( m% \# d
  291.     return false' v3 E5 t& a2 b! {$ C
  292.   end0 ]% N5 O2 E9 M7 Q
  293.   #--------------------------------------------------------------------------
    2 g3 Q" H# J" Z: ]
  294.   # ● 判断是否双击鼠标
    ! D  q  T; `( M" J7 _/ r% p& |  p5 h
  295.   #--------------------------------------------------------------------------  d- g: x# u0 q- v7 H/ O( D: H/ C8 e2 v
  296.   def double_click9 v" S% p! q: c7 l
  297.     @double_click8 h* E4 I9 r2 j
  298.   end
    ! g8 T5 w  j; Z, f' T
  299.   #--------------------------------------------------------------------------9 Q% O) L! |. y' Q5 `  ^
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    , z4 }7 n( x  N% N; U
  301.   #--------------------------------------------------------------------------
    ; w' P" p2 ^9 O% T4 r+ W  ~
  302.   def click_count; o% S4 {, O+ @0 z; p+ r& ?
  303.     @ck_count0 |+ N# m4 g' M' v* w3 \' l
  304.   end+ q/ w/ x2 \8 b' Q6 p2 I
  305.   #--------------------------------------------------------------------------
    - F# j& Y. i! {1 K/ A
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    ; R% q9 w" o# Q2 I$ ?8 A# i( G' \/ l
  307.   #--------------------------------------------------------------------------
    . P* q1 `2 ], O4 r. l$ u( Z: f3 z( X
  308.   def left_state7 j4 p! P" E4 ~
  309.     @left_state
    * p: M! z/ R, \
  310.   end
    ( o: I2 a3 }  K7 s7 ]- [$ o. q
  311.   #--------------------------------------------------------------------------
      T0 E# d! F) Z) d! I$ ^
  312.   # ● 获取鼠标的x坐标
    " i7 {) r. `6 a
  313.   #--------------------------------------------------------------------------9 N4 U7 H  n7 T% ]
  314.   def mouse_x
    9 n. ?0 @( r; A& K( O/ L$ D
  315.     @mouse_sprite.x1 q. {0 P0 a# L5 c. D1 [
  316.   end
    - L: n* C" b3 [& J  [9 c0 q
  317.   #--------------------------------------------------------------------------( }. \+ V  A+ }! l9 F3 E
  318.   # ● 获取鼠标的y坐标
    # u1 X8 W* [& I2 s0 c2 H
  319.   #--------------------------------------------------------------------------% N1 V0 _( T+ L0 D; j% e5 i+ n
  320.   def mouse_y
    ) n; z' U4 `, U7 R. w. `
  321.     @mouse_sprite.y
    3 ]3 a% ~4 e0 o6 R
  322.   end: Y- u5 h  r& a/ }
  323.   #--------------------------------------------------------------------------) i- r; P0 k* s& p1 v5 k
  324.   # ● 设置鼠标坐标' q, c8 m0 i* p7 v3 n+ k0 f1 V
  325.   #--------------------------------------------------------------------------& c' }  ]& R  \
  326.   def set_mouse_pos(new_x, new_y)) {6 f* W* j9 |! ~: B. }3 Y$ |
  327.     arg = [0, 0].pack('ll')' k$ K4 y0 N% O0 U5 a
  328.     Screen_To_Client.call(Window_Hwnd, arg); z9 Y& [, q' S# G0 A( I' W
  329.     x, y  = arg.unpack('ll')4 B% D; r+ K5 w# f: n4 f" Z0 T
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)6 u, W- c- V! Y4 J
  331.   end
    7 `, t& z3 g: j# ^4 `7 c
  332. end #end of class  self ; O/ `, ?9 s% l
  333. 3 c. M  a( E: ~( X
  334. end
    ( g8 L# l" q1 S" s1 F4 w3 e$ E

  335. 7 l% q4 ]( z) \; |
  336. #==============================================================================
    ( W' ]5 j( \. R! s: J
  337. # ■ SceneManager
    1 @" C8 z5 [6 l& c, E" e, ]! [; s0 U
  338. #==============================================================================
    ( ^( h% I: z( n6 [
  339. class  SceneManager+ F3 m0 e+ ?/ ]  O( Z
  340.   #--------------------------------------------------------------------------3 \7 p# w- B! i' G" k& t1 |
  341.   # ● alias6 ^8 ^) r0 L8 o5 {7 T
  342.   #--------------------------------------------------------------------------2 |1 S& p' ]) u0 ^6 ~3 N8 H
  343.   unless self.method_defined(sion_mouse_run)0 E0 E2 o1 M! H& g
  344.     alias_method sion_mouse_run, run
    - M3 H( h( M1 V( U- m) }
  345.     alias_method sion_mouse_call, call! L$ L) x5 `/ _+ C5 ]/ D+ P
  346.     alias_method sion_mouse_return, return, U- j2 z8 J; k# I0 y( }* z7 l, b
  347.   end% H8 q3 S7 L, k- ^6 P/ b
  348.   #--------------------------------------------------------------------------
    1 ?' C5 K% V6 k& f: E7 [) I
  349.   # ● 运行
    4 |- u' ~- k+ _1 k
  350.   #--------------------------------------------------------------------------' U+ `. o9 t) [" Z- B; p( M; m
  351.   def run* X" J- W" N' T$ J7 `
  352.     Mouse.init
    1 Z' S5 r. q2 ~4 r9 o
  353.     sion_mouse_run
    3 X/ C) a% \: o, W
  354.   end6 |/ ?* c% e7 O" K/ H8 I
  355.   #--------------------------------------------------------------------------
    8 x% U: Z) J, E6 ~& @
  356.   # ● 切换$ g) F* O) Q( @3 C- P# F" n
  357.   #--------------------------------------------------------------------------
    4 y) T+ r9 j4 T$ o3 Z4 D
  358.   def call(scene_class)
    3 `; }! y3 q: J/ @
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)6 U' [0 K+ C$ z7 V! D
  360.     sion_mouse_call(scene_class)
    ( P. F# R, u( S+ u. f) X, M
  361.   end
    3 o6 M: M! N* @0 `2 Y9 m0 q  I/ n
  362.   #--------------------------------------------------------------------------
    ( O+ U4 G" j: e% s) n$ l
  363.   # ● 返回到上一个场景0 n2 Q% S' B6 _- J' t/ S4 n+ |1 Y
  364.   #--------------------------------------------------------------------------. y) |% G/ s) U
  365.   def return0 m2 E2 u1 Q' s1 B0 i
  366.     sion_mouse_return5 j' j! t0 ~6 F; X+ m: P1 O3 _
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    0 m6 j$ Z1 Z0 `6 x+ {8 R6 E& z
  368.       @scene.instance_of(Scene_Map)& h8 E- g* a) v0 Z
  369.   end4 ]- K2 S: _# A8 ~( M( e
  370. end
    ; N( k) S: W4 c0 `0 _  T% U6 W
  371. , U4 e- U  @' l
  372. #==============================================================================
      i  b7 o: F% ?1 s
  373. # ■ Module Input! R0 S7 ?! B, c. @
  374. #==============================================================================" G- J1 v# n5 g4 d# A, N. t
  375. class  Input" J8 p3 K0 y& O# e
  376.   #--------------------------------------------------------------------------5 O# J  _) [& A4 U- Y
  377.   # ● alias
    1 C) j2 p% L* u& z2 |
  378.   #--------------------------------------------------------------------------" u- d$ Y/ C- r  J" P
  379.   unless self.method_defined(sion_mouse_update)
    1 K& r6 I: P5 w4 w! y
  380.     alias_method sion_mouse_update,   update7 D& c- e$ Z9 \6 p) w2 f$ q6 x
  381.     alias_method sion_mouse_press,   press+ d3 H& x4 T, _. Y) u# Z5 P
  382.     alias_method sion_mouse_trigger, trigger; c$ k' F/ [0 M# h9 Z
  383.     alias_method sion_mouse_repeat,  repeat
    ; I3 n: R$ T4 X
  384.   end
    6 f8 [6 B9 ~; v/ ^3 G. U! C% B6 s
  385.   #--------------------------------------------------------------------------
    " o2 b6 l5 O) \! ^
  386.   # ● 更新鼠标
    6 B# E# K6 ]7 n% A. U1 i% Z5 ]2 q- p5 }
  387.   #--------------------------------------------------------------------------
    - ?& d/ H% D* j6 L) I1 t7 Y
  388.   def update7 o; S( g$ Y2 E
  389.     Mouse.update
    5 Q. v, g" E2 H; {
  390.     sion_mouse_update
    9 `2 }, w/ X8 b3 W- E0 y5 u$ k
  391.   end
    , F# B% {: N* q- X% ^
  392.   #--------------------------------------------------------------------------: o7 Q/ W; U( c  |% U
  393.   # ● 按键被按下就返回true1 C: `" A/ s  V0 U- B# v
  394.   #--------------------------------------------------------------------------3 g; v6 G" y4 F7 p2 p& e
  395.   def press(key)
    ' E7 b" ^; m+ h* H
  396.     return true if sion_mouse_press(key)& @- ]" X8 }% @
  397.     return Mouse.press(0x01) if key == C
    . M) K; Q( J) z' M4 p4 t
  398.     return Mouse.press(0x02) if key == B
    / A- ]- T6 l/ p. F# A! l1 p( I
  399.     return false5 H, r' l/ B3 l/ `( g, i
  400.   end
    $ G! }: M. t2 I* K1 u8 g
  401.   #--------------------------------------------------------------------------
    8 t& ~6 G' r2 i, ~. W) E# a
  402.   # ● 按键刚被按下则返回true% R; k* G" [& M3 G1 x. w# F$ r2 G
  403.   #--------------------------------------------------------------------------
    ! d( [- D3 u- S. F
  404.   def trigger(key)9 q2 H! }7 ?. h$ M5 X) K
  405.     return true if sion_mouse_trigger(key)
    5 _/ s( I5 o# U/ X7 ^, F) _/ [* l
  406.     return Mouse.trigger(0x01) if key == C& Q! u9 L7 m. k2 c# Q
  407.     return Mouse.trigger(0x02) if key == B
    0 }6 y" L; z) \) {
  408.     return false
    - p4 @$ u. m! Q1 j9 O$ _
  409.   end$ o1 R6 ^& D4 t; c, [
  410.   #--------------------------------------------------------------------------: U3 q& {# k1 ?/ j. T
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true. S0 S: x( s" V  K; N8 L  P
  412.   #--------------------------------------------------------------------------& u- @& `# K: n" Y9 ^& B
  413.   def repeat(key)
    ! _: z! U0 Q# q4 I& n
  414.     return true if sion_mouse_repeat(key)3 R5 [( ]. X* g7 G
  415.     return Mouse.repeat(0x01) if key == C- x  I5 {$ p  v* m
  416.     return Mouse.repeat(0x02) if key == B7 r. ~- _' ?# ?) J7 o( _3 i
  417.     return false) R& H. Q8 J3 r6 i# j
  418.   end
    1 H( i! L/ ]# Z* R% {: [
  419. end
    ) k5 c- b& l4 S' {' Q- H
  420. 2 z, L+ Q9 d# G% U9 Z" T6 l

  421. 1 a+ H; t/ |1 M( M6 G! z; r( Y8 R0 V
  422. #==============================================================================9 @5 N% O$ L: ?7 B5 \) R5 q
  423. # ■ Window_Selectable. |5 P/ {0 D; j1 J
  424. #------------------------------------------------------------------------------! f" |9 Y: _# O+ k; a! b3 M- q3 B' e2 j
  425. #  拥有光标移动、滚动功能的窗口
    & Y7 \' d; v- b% G
  426. #==============================================================================
    , t" z5 ?% U5 H
  427. class Window_Selectable& |0 O9 v8 a- R3 t/ J
  428.   #--------------------------------------------------------------------------
    5 U( T+ T: i3 ?( N
  429.   # ● 初始化
    $ _0 o) G/ x' M+ s
  430.   #--------------------------------------------------------------------------3 ^) w; G5 ]+ u2 k3 k3 E8 [& k1 i
  431.   alias sion_mouse_initialize initialize5 W! ?) H% L, K" L& F' h  s
  432.   def initialize(x, y, width, height)0 H  f2 w2 D. K. }' I' L
  433.     sion_mouse_initialize(x, y, width, height)
    : X" Q5 z( \0 E& T
  434.     @move_state = 0. H- S& x+ M; N- |5 A
  435.   end0 w0 E" ]3 }6 A7 D) p0 ?9 Q# W$ S0 _
  436.   #--------------------------------------------------------------------------
    0 H4 b/ J" l5 p/ p1 ]$ ^2 J& H2 }4 g
  437.   # ● 更新8 q8 M" x$ M4 ^2 O  X2 D" h2 W
  438.   #--------------------------------------------------------------------------, t' A/ d% y+ ?, G1 i  V" R
  439.   alias sion_mouse_update update
    * ~% r# ^. G  I0 a6 G! K* O5 V( X
  440.   def update& T! o0 a1 G# y: }" @
  441.     sion_mouse_update
    0 x2 _+ \8 S! m$ k
  442.     update_mouse_cursor, `$ r# m8 q; j9 ^, [; u5 z5 f5 Y
  443.   end6 s* T' `7 e/ u. k! R
  444.   #--------------------------------------------------------------------------
    # z) g- `  G" R) }* u
  445.   # ● 启动后设置鼠标到index位置6 V1 J0 D5 o5 O  H% j
  446.   #--------------------------------------------------------------------------: ^9 P9 H! X) c# l
  447.   def activate8 l: I+ v" j+ _9 V/ l: Q* N; Y: s
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos% b' D: N$ F; f8 k* i& M
  449.     super
    $ r0 |; ~6 i+ O7 z
  450.   end
    ; u$ z3 l/ x# \+ ?& z/ Z+ ?8 k; O7 O# d
  451.   #--------------------------------------------------------------------------
    $ _$ H6 y- B+ A. o1 N
  452.   # ● 更新鼠标和光标的位置* P9 V8 |% j2 P" T( y) n4 ]* M
  453.   #--------------------------------------------------------------------------
    7 R  J1 }( i+ k
  454.   def update_mouse_cursor
    * @" Z! v$ H& t) ^% _
  455.     if active, I' C- W' s9 r
  456.       if @need_set_pos
    ) x0 t8 m( ]( P
  457.         @need_set_pos = nil. g. M; O: Q0 X" A
  458.         set_mouse_pos
    , F/ l1 w* ]6 {' g8 h4 }: B+ r
  459.       elsif cursor_movable
    6 c4 R( v3 k( @! K& S1 L
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    / U& J5 m& A' z, I9 q9 `$ Z
  461.       end# ~  A) {9 {2 g1 T; B0 o( u
  462.     end; E8 A+ k2 n$ `/ `, [) ~
  463.   end# s# j3 @' A1 j
  464.   #--------------------------------------------------------------------------
    1 a9 z, r4 ?& ~/ v( B
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    ) G9 D2 ]7 V! H* i, W, ^: b+ R0 @
  466.   #--------------------------------------------------------------------------
    & n9 S5 p/ r$ @8 J. Q& \5 a6 Y
  467.   def set_cursor
    ; O( p- ]5 e, w$ s
  468.     mouse_row, mouse_col = mouse_window_area6 `$ x; n) z7 u8 z
  469.     if    mouse_row == -1
    6 r: C1 N) o) m2 M3 Z: ^  r
  470.       @move_state += 1 if need_scroll( g- q( M. N! F6 p  ]# P9 g' i
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand; n  a: I) d7 X! h! `& u* I
  472.     elsif mouse_row == -2
    % e  \( P, l; H( w- a6 Z3 w/ Q
  473.       @move_state += 1 if need_scroll
    & o, a, u  u9 C3 B. d, `  x
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand" j  n# U5 v4 M3 u1 R2 @
  475.     elsif mouse_col == -1/ ?4 \2 {* a) U: v5 d! C+ T1 b
  476.       @move_state += 1 if need_scroll, c0 i* N8 X% ?' |3 l0 a4 ~' P8 O
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand# Z  @- Q; Y/ S+ W# x( u$ z
  478.     elsif mouse_col == -2  d3 r7 l! {; t
  479.       @move_state += 1 if need_scroll* O% C2 U6 h7 a; ^4 a/ S
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    6 _+ j& [9 S1 [" M
  481.     else
    * f% _: y  K8 E+ `; a
  482.       @move_state = 0: l! z) d$ D' }  b
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    0 d/ Q, h% c! f* Y0 d
  484.       select(new_index) if new_index  item_max && new_index != @index
    1 ~% v9 M8 ~+ [: ^) O% t4 O+ V
  485.     end
    6 N: Y3 }$ K1 ]9 o( u- Q! L
  486.   end3 |: J: Q3 K- E/ C
  487.   #--------------------------------------------------------------------------
    5 j3 }8 O9 ]" s4 N# D
  488.   # ● 判断鼠标位于菜单的第几行、第几列- o9 u" G. A8 ~
  489.   #--------------------------------------------------------------------------
    % U8 V6 n" Z6 R. F- P! O
  490.   def mouse_window_area
    , s) J, Z& h. O7 O" S% h
  491.     if viewport.nil # necessary!
    . y) J) n, `& K: n
  492.       vp_x, vp_y = 0, 0, K0 O' F9 `8 T2 O5 W$ P
  493.     else
    - N- c- t/ H3 P
  494.       vp_x = viewport.rect.x - viewport.ox. @$ M' m0 G" J7 `3 t' i( u, Y' M
  495.       vp_y = viewport.rect.y - viewport.oy! n- y& Y* G$ v) c5 F8 i* p, R5 F
  496.     end8 I/ y( b( a2 F2 F) }. b/ l! r% y
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y0 f( W0 Z3 a4 V' u5 T2 L+ K
  498.     item_x1 = vp_x + x + standard_padding
    : X& l' `% a7 Q5 g2 e* |
  499.     item_y1 = vp_y + y + standard_padding4 c# b9 q' a+ I: ~' L8 f3 R
  500.     item_x2 = vp_x + x - standard_padding + width
    0 z' Y6 E& ]9 @* |$ N' n- b
  501.     item_y2 = vp_y + y - standard_padding + height4 j( ^( k2 Z* x
  502.     if mouse_x  item_x1
    6 M8 T* B) `9 W8 H9 r3 l0 {/ w) F
  503.       mouse_col = -11 Y: g" f7 |8 W( U6 N9 q  s
  504.     elsif mouse_x  item_x24 o" Q3 {4 k1 W; `* ?: t% R
  505.       mouse_col = -2
    2 Y8 I% [* d4 ^9 ~9 R% Y% S
  506.     else( p  @) B! f2 E2 U' `/ s
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    ! _; }) T  o1 z! c% V# O6 S. ~
  508.     end
    $ F. F2 F. u2 C0 ?0 O
  509.     if mouse_y  item_y1
    9 y* ~& T2 w$ z0 t5 [
  510.       mouse_row = -1: ]! e8 J- ]( a, s& Y
  511.     elsif mouse_y  item_y2
    ! _3 L# u6 a" S( b  l( ]  G2 D
  512.       mouse_row = -2
    * D! |" \  G7 H( U( z9 T; l
  513.     else& E" {  Q9 q7 O, ]
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)* Z) Y( \9 v: o9 P
  515.     end/ [# a2 D; s* B! \, k6 A1 X; J  g
  516.     return mouse_row, mouse_col
    2 z( M- d2 a" T7 u. I5 K2 u+ H
  517.   end
    7 T5 K9 T. V1 x; L  u# h4 Q
  518.   #--------------------------------------------------------------------------
    ! k, T( E! C/ r' W# T/ z
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置3 x* y+ D# z+ M. o9 n6 ~) e
  520.   #--------------------------------------------------------------------------! ?: G- K1 ]! o2 O) F; O
  521.   def set_mouse_pos: O3 f1 `" V% F6 C2 M  s
  522.     if viewport.nil # necessary!. l9 B1 N0 x% _
  523.       vp_x, vp_y = 0, 0
    2 L; x( Q+ Y) b1 G. A! i  G2 k0 v
  524.     else$ Q$ i" ?' L: F! g5 i1 o0 ?
  525.       vp_x = viewport.rect.x - viewport.ox
    # n2 A& ?  C1 V6 y
  526.       vp_y = viewport.rect.y - viewport.oy
    # l) F, [; [: d6 l& U9 K
  527.     end, W( Q+ y7 h9 r! f: F% h
  528.     item_x1 = vp_x + x + standard_padding
    + [) U8 O4 {. n  W6 G! s  Y
  529.     item_y1 = vp_y + y + standard_padding  r% |, r3 E/ Z* D& K
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index . |1 x+ V( A# l& ^" }
  531.     row = get_index  col_max - top_row, k, B0 Y& B) f, e2 E
  532.     col = get_index % col_max
    6 O6 Y. K) d* R- i3 g5 Z6 x5 H
  533.     new_x = item_x1 + item_width  (col + 0.5)
    ; i. c1 p) G* e& S5 ~
  534.     new_y = item_y1 + item_height  (row + 0.5). j2 |  }6 P. [' N9 Z+ ^6 W
  535.     Mouse.set_mouse_pos(new_x, new_y): l% C9 Q4 K0 S& `3 C- v
  536.   end% `; T! M  ^8 L$ f
  537.   #--------------------------------------------------------------------------- V/ C# H& h" E* B8 J3 [4 p1 m
  538.   # ● 判断菜单是否需要卷动
    + P- i7 }% S4 m5 k) D
  539.   #--------------------------------------------------------------------------) G8 Z3 E# w2 y7 ~" ?' R: d2 l9 l
  540.   def need_scroll, u2 y7 D+ _$ H3 ]9 b
  541.     item_max  col_max  page_row_max
    " i7 Z# _( C; E9 L* Y* s4 }( D
  542.   end
      `; @6 H: D; v; t1 E
  543.   #--------------------------------------------------------------------------
    # |1 y' g2 |0 H8 f: d; L& Z7 C
  544.   # ● 判断是否为水平卷动菜单' O# p3 |6 q9 C
  545.   #--------------------------------------------------------------------------% |9 \8 Z9 E) s
  546.   def is_horzcommand
    . o# s$ J' K  T6 x4 r
  547.     return false
    - W4 l6 h: ]9 L  v5 _
  548.   end" B! w& j- C; K2 t/ d
  549. end3 z4 m/ V. a, s5 d# W
  550. $ _! u: U$ `" i7 T$ A% v. e  K
  551. class Window_HorzCommand3 i3 ~6 _8 D- I5 ~% X, U; u
  552.   #--------------------------------------------------------------------------2 R. R$ F8 ~. I3 Z2 s4 |
  553.   # ● 判断是否为水平卷动菜单
    - f7 n/ x7 a5 K0 ~
  554.   #--------------------------------------------------------------------------
    ) u% C% n# s7 Q& N9 k
  555.   def is_horzcommand
    # s, q5 e6 i& A6 M
  556.     return true
    ' v( Z" I( l4 m
  557.   end1 t! C/ f" O7 x6 n( m5 S- A
  558. end
    # [8 O/ p$ j, U* ]9 d: t1 X

  559. ( X9 l6 F* g1 M' h7 B" }
  560. #==============================================================================+ p+ J' N8 U, L2 l* G
  561. # ■ Window_NameInput
    6 d9 p" B( E9 w
  562. #------------------------------------------------------------------------------, \1 b/ j" H1 O7 |; r
  563. #  名字输入画面中,选择文字的窗口。3 Y( V- v5 c3 k5 q7 o5 R
  564. #==============================================================================
    8 B; ?" Q5 q( l& _
  565. class Window_NameInput! d8 Y6 v* R0 Q1 ^3 ]( J
  566.   #--------------------------------------------------------------------------6 e; W: N& N" b8 o5 p( H0 q. \
  567.   # ● 设置列数
    # W& w2 g* f" Q' D. A* V3 A
  568.   #--------------------------------------------------------------------------9 Z5 ?0 Q) F  V: ^" X' @
  569.   def col_max$ `( L, j) T% c* |
  570.     return 10! H: M. j2 G9 b0 Z' h
  571.   end( b! d0 s4 {. [0 I
  572.   #--------------------------------------------------------------------------
    7 P' g( i8 b; M+ S4 e: v
  573.   # ● 设置填充的Item个数
    6 k7 `! u3 G% K
  574.   #--------------------------------------------------------------------------
    # p1 [+ Z3 B2 _) ?3 |6 M3 i
  575.   def item_max
    9 m, ?) R0 g& M) R
  576.     return 90
    - e0 C1 W/ j) Q. l. j
  577.   end
    3 r9 K- P  @3 ~3 i$ C1 |% `
  578.   #--------------------------------------------------------------------------
    " N! j/ i0 `: X$ H
  579.   # ● 设置填充的Item个数7 M7 Y$ Z( d' v: {0 ]
  580.   #--------------------------------------------------------------------------
    3 p+ m" g# I% r, ^4 `8 c9 v
  581.   def item_width: z1 [8 Z5 m  N6 A9 [' q7 B9 }
  582.     return 32; F( a; B9 r7 p" R# _- G1 L  M" @
  583.   end
    : u! U/ [8 w8 m
  584.   #--------------------------------------------------------------------------( }7 U; j2 K: @  q$ F
  585.   # ● 判断鼠标位于菜单的第几行、第几列+ N6 W8 U2 A4 @1 H3 j
  586.   #--------------------------------------------------------------------------! I3 ^2 M" @" I5 l5 S) J
  587.   def mouse_window_area
    % X8 K( V6 c$ ^0 W
  588.     if viewport.nil, F1 Q. B5 x5 `
  589.       vp_x, vp_y = 0, 0" Y. n3 |3 s+ m- n: `3 a$ F
  590.     else1 }6 Q% U/ F- Q2 A* ~# u8 g* |0 q9 ]
  591.       vp_x = viewport.rect.x - viewport.ox
    ' x/ I8 N1 k6 Q% {: x4 p5 a$ Y
  592.       vp_y = viewport.rect.y - viewport.oy
    : P) D5 N1 D0 r* i
  593.     end; x7 n; ?1 S( c
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    0 J' K# X! L9 q) z0 p9 x
  595.     item_x1 = vp_x + x + standard_padding , {0 w4 ]# P, l7 _1 D  K' h, l
  596.     item_y1 = vp_y + y + standard_padding
    3 E) d- p/ }6 `; V4 U! w2 b# p/ u0 k
  597.     item_x2 = vp_x + x - standard_padding + width
      a7 M; N+ u& d; ]$ L
  598.     item_y2 = vp_y + y - standard_padding + height
      N3 ]( P0 a" f: q, ]
  599.     if mouse_x  item_x1, }- c1 v# N2 R- N# N6 O. K
  600.       mouse_col = -1+ y, g& q, T. l& y& h
  601.     elsif mouse_x  item_x2
    0 C$ Y( _; z* E6 Y
  602.       mouse_col = -25 l: b* I8 r3 b! T( {5 S, K2 i
  603.     elsif mouse_x  item_x1 + 160
    2 A. F" X* P1 L$ L8 q5 K
  604.       mouse_col = (mouse_x - item_x1)328 ~% @6 A- t" K; g! q/ z
  605.     elsif mouse_x  item_x2 - 160
    % \: P- y2 K' d, a; h
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    ( G) b5 f0 [. E1 v
  607.     else
    ( G+ U( _4 u( l; T! C8 _
  608.       mouse_col = mouse_x  x + width2  5  4- M1 q+ H3 K  [  U: ?
  609.     end1 G: S9 r) u" J! T
  610.     if mouse_y  item_y12 x$ w  @1 J9 z% |5 P
  611.       mouse_row = -1
    ; z/ C$ Y% s1 h
  612.     elsif mouse_y  item_y2
    - h) I: r+ w$ m/ M
  613.       mouse_row = -2
    ( D3 x* U  p8 S
  614.     else
    7 ?9 E5 N2 I# q& @) ?& N
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1). ]# {+ m2 r0 V* \. w. F; a
  616.     end
    ! C( M4 a# e+ d" m' x
  617.     return mouse_row, mouse_col
    8 d5 i( |1 v7 ?8 Q* ^! p8 W
  618.   end, f! V3 A- {# z. P% u
  619.   #--------------------------------------------------------------------------( r  ?% S5 I& x' h- l( J! u
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    * c5 j4 U% C! {% W
  621.   #--------------------------------------------------------------------------5 v! t3 i% v$ f9 E) Y& ~9 H
  622.   def set_mouse_pos! }0 d5 N- {: M
  623.     if viewport.nil # necessary!
    . V3 |3 O& y6 w" [! a7 `
  624.       vp_x, vp_y = 0, 0
    1 u7 q' n8 P7 k) ]9 x
  625.     else: T& P& @/ \. ?/ D! N2 J/ Y9 D  @
  626.       vp_x = viewport.rect.x - viewport.ox
    % \3 V# Y7 s: w
  627.       vp_y = viewport.rect.y - viewport.oy) c0 ~* G/ p3 E$ I" t; M* @3 y) z% A
  628.     end7 |! x2 N4 n4 F( c) S
  629.     item_x1 = vp_x + x + standard_padding : t# @. ~. P" j& n8 R' ~, P% t5 f
  630.     item_y1 = vp_y + y + standard_padding! f& g. g6 S$ K. U0 F2 f3 {, w
  631.     get_index = @index  0  0  @index / Z( ^- @1 R5 \* E
  632.     row = get_index  col_max - top_row
    & k9 h* J4 w0 @, t* G/ y
  633.     col = get_index % col_max
    & |& M7 A4 o# h# V" e. L/ Y
  634.     new_x = item_x1 + item_width  (col + 0.5)
    " ^3 ]2 Z$ g8 b% ?
  635.     new_y = item_y1 + item_height  (row + 0.5)
    " z5 q; v" {4 i+ T8 _1 w9 m
  636.     new_x += 14 if col  4
    5 N3 p+ T3 l( i! ]5 B% v' V
  637.     Mouse.set_mouse_pos(new_x, new_y)' U* g% ~& C% Q2 [9 b& h
  638.   end
    - c3 o# E+ [- t' {5 ^
  639. end- t1 r- }' W6 H, @6 z/ x1 q% ~

  640. . `: |+ n- J) r1 d
  641. #==============================================================================$ S8 x# z: J% Y! X4 N& n, F
  642. # ■ Window_NumberInput9 E9 P+ E4 L5 _9 Z, N; g
  643. #------------------------------------------------------------------------------/ Z' w6 k: H4 a5 U1 l5 r1 V$ u  V& B
  644. #  重写了数值输入的方法以适应鼠标0 Z& x, `4 c' `, l, q, m
  645. #==============================================================================! o( O2 P. @5 _+ p1 D  w
  646. class Window_NumberInput  Window_Base6 K8 C; `6 S' K3 W% Y( o
  647.   #--------------------------------------------------------------------------0 v. A! C+ X& D# j" F
  648.   # ● 定义实例变量
    / V8 V# Y$ Y2 W. f
  649.   #--------------------------------------------------------------------------
    5 R$ ^) v) @* }5 \* e$ l* @- n' V/ r7 e: z
  650.   attr_reader extra_window
    ( S' z, e' x6 @% H
  651.   #--------------------------------------------------------------------------& o4 R9 Q  O6 g. g# w, w- }. c" _
  652.   # ● 初始化3 w0 r1 k5 i9 O4 j
  653.   #--------------------------------------------------------------------------- I& j6 L1 d/ F% v- \" n; u
  654.   alias sion_mouse_initialize initialize
    4 {- h  b+ k+ v% I4 G% J
  655.   def initialize(arg)( x# F# J, t! a' U6 X
  656.     sion_mouse_initialize(arg)
    - `5 Z% C* W1 O+ }! ?
  657.     create_extra_window5 {7 b5 p) p. b
  658.   end
    + m. D% i: {, f- x
  659.   #--------------------------------------------------------------------------
    7 W/ k# S# ?6 Q( n
  660.   # ● 启动7 {: p) l& @( i# Z! _" T0 i
  661.   #--------------------------------------------------------------------------7 m$ q3 {1 F: |2 s. ~) n
  662.   alias sion_mouse_start start2 c/ `& C5 v8 r5 K
  663.   def start) D* M0 y7 f" v+ a7 I9 n
  664.     sion_mouse_start  C; r' f9 ~# Q# r
  665.     deactivate
    8 V5 [, V& l. k- p$ n( i
  666.     extra_start
    : D# K' h9 s6 M# P1 ^5 `
  667.   end( x4 X7 T! K+ y5 s; g3 k: S
  668.   #--------------------------------------------------------------------------
    6 ], q8 I5 Y1 F9 k. n
  669.   # ● 创建新的数值输入窗口0 O& \) |2 `& |9 Y4 G
  670.   #--------------------------------------------------------------------------  ]4 A& R1 m/ k- g) w4 N/ X
  671.   def create_extra_window2 @$ c4 [( h4 t8 s
  672.     @extra_window = Window_NumberInput_Ex.new
    & t4 x7 a0 I" E! X
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    1 o% m7 W' ]/ j0 h! \. h! r6 V
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
      \  D2 X: b  _
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    / W1 A, ~1 E0 P* b' @
  676.     @extra_window.close_proc   = Proc.new { close }6 U, E2 {' u; Q& g" {# J* F  w
  677.     @extra_window.refresh_proc = Proc.new { refresh }( V6 L3 l6 @0 F" f+ M2 Z
  678.   end
      x* F. X( H7 g6 H$ l# ^
  679.   #--------------------------------------------------------------------------& D' _  k) V/ j' ]
  680.   # ● 激活新窗口
    . }% b$ q. u6 ~4 Y
  681.   #--------------------------------------------------------------------------! E, _! X0 B' L/ b# e, R1 y: M4 d
  682.   def extra_start
    : W5 ]+ z8 ]- Q. K
  683.     case $game_message.position/ p' z) }/ e& i1 \+ o2 s
  684.       when 0; @extra_window.y = y + height + 4
    2 l1 Z& Y2 L8 p0 u+ e' x
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 84 H4 r) D; d. t6 }/ ~' B
  686.       when 2; @extra_window.y = y - @extra_window.height - 4' {& k4 q4 G( R' p, e
  687.       else  ; @extra_window.y = 8- {% X. q2 j) z0 u
  688.     end( ]6 T- |! w6 X$ \0 @" {1 r1 f
  689.     @extra_window.variable_id = $game_message.num_input_variable_id. O& w7 c8 d% R! ?
  690.     @extra_window.digits_max  = @digits_max( M* i, Q, `; A; N* G3 T
  691.     @extra_window.number      = @number
    1 x& f! w; A5 b5 Q' r0 d$ j
  692.     @extra_window.open7 b0 C4 K: }, ~, Y; R7 J
  693.     @extra_window.activate
    $ a, R; o/ ~3 x+ @1 n
  694.   end+ h% y9 o3 a) ]/ L
  695.   #--------------------------------------------------------------------------/ `: _3 ~( G3 q' J( L; R
  696.   # ● 更新
    , d4 m( V$ H& e& b% u! a( j
  697.   #--------------------------------------------------------------------------% q: m( I* K# `% R( A
  698.   def update% m' O7 ]1 r% R
  699.     super
    0 c4 N: r/ Q) ^
  700.     @extra_window.update
    * f% l5 H! c! [4 d! R
  701.     update_cursor7 E; ~' V% z2 A' n3 H
  702.   end; E/ I- F; Z& a4 B0 `
  703.   #--------------------------------------------------------------------------
    2 H2 s! w& l/ w  F
  704.   # ● 关闭窗口
    $ t+ V; Q: l$ H6 T' b
  705.   #--------------------------------------------------------------------------
      f2 ?* T0 f! J& z0 S
  706.   def close, O% d" W5 Q( K; E* m! O( }
  707.     super
    ; V8 j4 M' ]# |; h( g( J6 G9 |
  708.     @extra_window.close
    & ~. }7 {9 |9 `2 b, ~- a* m. k
  709.     @extra_window.deactivate- I( y2 M  g% t9 f2 c+ G, L. K
  710.   end
    & V  k, |* F8 ]' ]- t' e
  711. end( d6 _' b. r( b) h9 H; o% ~0 P

  712. ) q# Q8 u) d& c9 t
  713. #==============================================================================) F# I5 O4 j' u( h$ z9 ]. ]  q
  714. # ■ Window_NumberInput_Ex2 E4 o3 q2 G) V2 a3 T( f% ]
  715. #------------------------------------------------------------------------------
    9 i0 u6 Q: A9 y5 Y( H4 I
  716. #  新的数值输入窗口(NewClass)) h, z' G3 d) S8 U) ?% t$ y+ B, E
  717. #==============================================================================
    % K8 }$ W( B# X/ @) ]; ]$ i+ g
  718. class Window_NumberInput_Ex  Window_Selectable0 c- S+ b( Z; k) E5 Y, T4 C7 I, K
  719.   #--------------------------------------------------------------------------
    . ~- S9 i+ Z) B3 k1 _% `3 |6 `
  720.   # ● 定义实例变量
    $ S& H8 e+ R$ D- c( c- U
  721.   #--------------------------------------------------------------------------: R. R" A- s# k* k+ M( g4 i
  722.   attr_accessor number_proc( h' x! D( w% I# I2 @1 s
  723.   attr_accessor index_proc
    9 R( B% L( `7 X, O7 {; k' j
  724.   attr_accessor close_proc
    ( G" s& O, p% \% G1 h# ~' t
  725.   attr_accessor refresh_proc
    + L: C" Y' [3 A, j4 o8 I  h& N
  726.   attr_accessor number
    . b( E4 @* N& U" W- U
  727.   attr_accessor digits_max- `  l8 ]- t0 N
  728.   attr_accessor variable_id0 R( G/ E" l5 [7 D3 T' W% q
  729.   #--------------------------------------------------------------------------: m3 O, ~# B  v
  730.   # ● 数字表3 C+ w/ }" Z1 @: Z, n' n  z. I
  731.   #--------------------------------------------------------------------------
    ; V1 w  V* {* D5 F( x8 r
  732.   TABLE = [  7,  8,  9,& C7 r2 r  W( t  N% k, h5 o4 U
  733.              4,  5,  6,9 s7 {% V, Z# ^$ _; ~/ `+ b
  734.              1,  2,  3,) ~; b8 z, L/ l$ }
  735.             '←',0,'确定',]
    : I0 D6 H4 g  y! z
  736.   #--------------------------------------------------------------------------
    & e0 C. {# B# w! B
  737.   # ● 初始化对象
    / t2 d3 H, R: ~) j0 I; {, L; i/ q/ q2 a6 f: X
  738.   #--------------------------------------------------------------------------
    ! e5 m! C( c( ]. N' D
  739.   def initialize, P% J. `* Z6 t# g
  740.     super(0, 0, 120, fitting_height(4))
    8 V, ^% w1 I# p( J% f
  741.     self.openness = 0, L+ Z, ~3 B) K5 R
  742.     @index = 0' ^6 x" w- S4 M- x- r& s3 |
  743.     @number = 05 |" v1 F5 v% P1 ?) o
  744.     @old_window_index = 01 H, T: a0 Q2 n5 K  d
  745.     @digits_max = 0& [, [6 ^7 Q$ }& J
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }; z$ ?9 o! g; V4 \5 F
  747.   end
    9 s, Q0 V0 V& _9 Q; a6 T: V
  748.   #--------------------------------------------------------------------------* F2 x- k9 }: y4 s
  749.   # ● 获取项目的绘制矩形
    + s: K( h& [; S7 r8 ~7 a6 f6 E
  750.   #--------------------------------------------------------------------------
    ) D3 R& c; ^6 r9 @8 _7 j* _
  751.   def item_rect(index)* B9 e, q0 J& ~$ ^$ \/ Q$ o
  752.     rect = Rect.new" T& m4 i1 g5 Y1 p5 {4 Z0 t/ o
  753.     rect.x = index % 3  32
    " C, r  f/ E) O! M$ `7 W) @" }
  754.     rect.y = index  3  line_height
    5 T: a$ |' Q' E, K' Y7 n' a
  755.     rect.width = 32& k+ V6 B( A$ j; S
  756.     rect.height = line_height
    ' k, T- \( }6 `7 I+ }' y
  757.     return rect
    6 \, G& w) e3 f% u5 a& {
  758.   end' `# r" l$ |$ U$ h2 e3 z
  759.   #--------------------------------------------------------------------------- {2 s7 M7 C3 i6 ?9 }1 G; y
  760.   # ● 将光标设置到鼠标所在的位置' p8 [* b5 U# F$ p; o/ Q' X6 b
  761.   #--------------------------------------------------------------------------% F$ _& p  G, ^- D. J
  762.   def set_cursor/ b4 t" \5 ^! ?8 m: r; n
  763.     mouse_row, mouse_col = mouse_window_area: O$ K$ l/ Y8 J
  764.     if mouse_row = 0 && mouse_col = 0
    ' F% u8 T8 P' V: |7 u- W7 Q
  765.       new_index = mouse_row  3 + mouse_col' U" _6 l; O& x- s0 p
  766.       select(new_index) if new_index = 11
    & K) X# k  [3 `9 Z" |7 p- B% i; _" b
  767.     end
    ! }5 d( p, d& ]% A6 F
  768.   end
    $ F. O7 J" q. B( d! m
  769.   #--------------------------------------------------------------------------; D/ l6 T. K/ t$ C5 b/ ^  s3 H
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列" e8 O% C% i# J2 P& Z
  771.   #--------------------------------------------------------------------------
    0 T- m  V% y0 u$ v
  772.   def mouse_window_area! x% @+ d+ Y9 Y* w7 }, N2 ?
  773.     if viewport.nil, \% P+ |6 W3 x
  774.       vp_x, vp_y = 0, 0
    7 {" ~9 |9 w. ]6 M% j8 J" p
  775.     else
    1 S* M! S2 e: N0 B
  776.       vp_x = viewport.rect.x - viewport.ox
    5 P7 p* `& b; {. _8 o+ V( f
  777.       vp_y = viewport.rect.y - viewport.oy: ~: x# Y) i! @' T9 ~
  778.     end
    ( F- C2 r0 c6 }0 N- d4 y; h
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    # u+ c& |/ b% k' E9 u
  780.     item_x1 = vp_x + x + standard_padding
    " U  d% L' R8 U, E' A2 m
  781.     item_y1 = vp_y + y + standard_padding
    . F3 I0 a6 G! V$ @6 K# `- I6 C
  782.     item_x2 = vp_x + x - standard_padding + width) `6 e. T$ g$ Q6 ]: w+ C  F
  783.     item_y2 = vp_y + y - standard_padding + height
    8 g5 O2 m, D0 u% o7 r
  784.     if mouse_x  item_x1; d" S0 s; X. I6 j
  785.       mouse_col = -17 u6 l+ t9 \5 v' i1 W4 n% U3 B
  786.     elsif mouse_x  item_x2, {6 v% \: l, Z# P4 W
  787.       mouse_col = -2/ A9 X1 Y8 D8 v7 V
  788.     else
    $ h0 R$ ~% H0 }) i
  789.       mouse_col = (mouse_x - item_x1)  32* A- I% A: w9 K
  790.     end
    - @4 F1 t7 a* |# B
  791.     if mouse_y  item_y1
    ; ~2 q8 I/ s0 s2 {
  792.       mouse_row = -1
    8 E3 P" G$ _3 D/ ^
  793.     elsif mouse_y  item_y2
    ! r. Q# [$ i3 a: q
  794.       mouse_row = -25 V- B( s$ C, S6 q4 K
  795.     else
    7 {+ u$ n. C; W& q6 g0 h
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)# |5 Q3 G7 p' a) r4 a! s8 N' H0 f
  797.     end: f4 k* g! w& l+ h. Y2 l
  798.     return mouse_row, mouse_col, ]* ]) s7 u! K; y' u8 H6 q5 z# S
  799.   end6 M# e4 w) j; P5 E3 m
  800.   #--------------------------------------------------------------------------
    " \& `" K. x" {2 O6 O+ c
  801.   # ● 获取文字- g  e2 v! F' ]4 t/ f- t5 i9 y
  802.   #--------------------------------------------------------------------------! P$ C2 R# {  R6 G3 `. |$ q
  803.   def get_number
    . m8 [9 [& c8 Z1 j% M) D
  804.     return false if @index == 9  @index == 11
    $ E( x# J- M. G. d. j5 r& c
  805.     return TABLE[@index]8 c. V% `2 c$ k) K7 k
  806.   end( q/ i7 s% J2 @/ R
  807.   #--------------------------------------------------------------------------
    : @$ `+ r& l+ k$ i" O0 Z0 ^1 Y3 R: m
  808.   # ● 判定光标位置是否在“退格”上0 v7 W5 z9 K7 m/ U- ~6 p" |; N5 e* ?
  809.   #--------------------------------------------------------------------------$ ?, l* n9 R: Q$ J- E! Y2 f  \
  810.   def is_delete" K8 C( s0 \, g" k6 i
  811.     @index == 94 |9 a9 L* d8 `: R! ~
  812.   end
    6 K- c: }- r+ i4 d* e4 W
  813.   #--------------------------------------------------------------------------2 Z& i: j% x4 [
  814.   # ● 判定光标位置是否在“确定”上$ o; M# f7 }! B5 u, I  U! }9 |# a+ T
  815.   #--------------------------------------------------------------------------3 l2 Q: G6 u: w3 }) r
  816.   def is_ok- O/ ~- p* n: g* c+ P3 W* _: l
  817.     @index == 11
    4 H  v, f% u, V  v; d8 ]3 K6 A
  818.   end
    ; N! v9 O/ U2 F; U9 e$ S
  819.   #--------------------------------------------------------------------------
      z( N- y9 }2 Y2 \/ z& A
  820.   # ● 更新光标" n, l3 Y0 E4 B: P" @
  821.   #--------------------------------------------------------------------------  Y0 Z6 Y; x; P2 e, S  b
  822.   def update_cursor/ s" D) F0 P3 q% K  s; P# y: w
  823.     cursor_rect.set(item_rect(@index))
    $ Z0 p& k) p2 X
  824.   end& P8 z7 e+ l$ @! o- t" G. a
  825.   #--------------------------------------------------------------------------3 S8 Y7 q7 S. E5 o: K- N5 x+ ~2 x
  826.   # ● 判定光标是否可以移动
    ! P2 Y8 Y( s9 g; J
  827.   #--------------------------------------------------------------------------
    8 p/ [) L! }+ t( j3 d* c) C2 @
  828.   def cursor_movable. E  D. R  O) w. V
  829.     active8 G" i0 X, n, _7 ]( d9 n) S
  830.   end
    7 [1 r2 }3 V: Z6 C2 C7 G% N
  831.   #--------------------------------------------------------------------------. |) e0 z0 \9 j. i1 B
  832.   # ● 光标向下移动/ M6 W5 q; d5 v) n* w3 ^
  833.   #     wrap  允许循环0 J8 d' m6 N) w* H5 z1 H
  834.   #--------------------------------------------------------------------------3 b( j+ U( u# \( B
  835.   def cursor_down(wrap)
    2 a# ?3 ]4 m) h/ g  Y$ A  x3 M
  836.     if @index  9 or wrap
    5 I. m' Q1 f7 \% S2 O% v* \
  837.       @index = (index + 3) % 12
    : [! C0 H/ @0 D
  838.     end
    9 }0 v7 _* ^7 W& f  W! b0 F
  839.   end
    7 m7 v' L+ f- m0 i& r& z! R; ~. M
  840.   #--------------------------------------------------------------------------  `: l  a4 q( X3 V
  841.   # ● 光标向上移动
    : T( p/ d( y- ?
  842.   #     wrap  允许循环1 E' N5 i0 r. G" w' \0 ?% M! Y
  843.   #--------------------------------------------------------------------------
    ( m7 k! X1 I' c9 K7 F& V
  844.   def cursor_up(wrap)
    % ]' P$ ?3 @2 H9 a$ R0 V4 G
  845.     if @index = 3 or wrap2 d  }2 A5 Q$ @4 S3 }$ q
  846.       @index = (index + 9) % 12
    - W: G) S& G  U  i% u: I
  847.     end
    # }+ A2 D9 b% o0 A9 [5 q. j
  848.   end& u" ?+ q/ p8 I% V9 I$ f# a
  849.   #--------------------------------------------------------------------------9 p$ ~7 _, H9 F- |4 a- B, m. `
  850.   # ● 光标向右移动
    , s$ f3 r8 P- `' T
  851.   #     wrap  允许循环
    0 e/ q* s0 O# X
  852.   #--------------------------------------------------------------------------
    8 b( W3 K* w3 n6 D2 S
  853.   def cursor_right(wrap)  j9 p, m1 k- C1 `4 X# Y9 y* H
  854.     if @index % 3  2
    0 D, T3 E- g, \+ V! P+ C
  855.       @index += 14 ^- c* B9 E8 V' @6 l3 p
  856.     elsif wrap
    & _! k6 Y, i/ N
  857.       @index -= 2; y5 k0 o4 p. L* ^
  858.     end
    3 [7 ?0 ~. L' a/ Q; M
  859.   end
      }' c- r% I% w( z" [
  860.   #--------------------------------------------------------------------------# H% \9 q; |% d3 f6 H
  861.   # ● 光标向左移动5 N. q9 k7 f  k9 q! C! h
  862.   #     wrap  允许循环+ T3 g1 O3 \7 q% _
  863.   #--------------------------------------------------------------------------/ J* g. }) h% [$ b7 j9 X3 r3 V5 @. d
  864.   def cursor_left(wrap)
    ) r* N" ?1 B0 Q  f4 X
  865.     if @index % 3  0) z. p4 v: C0 l  Z0 g. R7 ~9 J! N
  866.       @index -= 1, \% v, ^) `3 r0 l
  867.     elsif wrap
    5 L7 r8 S/ z: a+ }' s; e8 |
  868.       @index += 2# d8 k) y6 F! p' U% @1 ~0 i0 o
  869.     end- E2 z' Z! E+ q/ T
  870.   end
    , o4 ^$ @+ k( _' {1 X$ |! s
  871.   #--------------------------------------------------------------------------/ s9 C7 W" V) E- Q) A2 a
  872.   # ● 处理光标的移动0 B% I$ E. _. ]: N- e2 X
  873.   #--------------------------------------------------------------------------4 C3 l8 m( l5 p
  874.   def process_cursor_move
    - k- K0 l& X7 _5 P  o" r% t
  875.     super
    ; u7 l) G; [9 s9 @5 e
  876.     update_cursor, O5 a$ y+ m" ^
  877.   end
    1 r8 g$ |" E! D; W: n* z9 ?
  878.   #--------------------------------------------------------------------------
    5 P$ i0 }, z* K$ |2 {' a
  879.   # ● “确定”、“删除字符”和“取消输入”的处理+ [* j* S  M7 L0 T6 W
  880.   #--------------------------------------------------------------------------8 U1 K5 A$ j. s: u
  881.   def process_handling
    # ~3 b) V/ R$ X$ ~, B
  882.     return unless open && active- `5 w7 V6 j( u
  883.     process_jump if Input.trigger(A)' P/ h9 s4 c1 A2 |2 q3 K
  884.     process_back if Input.repeat(B)+ u$ Z! o# v1 ^2 N% r
  885.     process_ok   if Input.trigger(C)3 O. r, q1 Z- Y% y+ r
  886.   end
      j9 t3 g4 [  y, _! \5 }
  887.   #--------------------------------------------------------------------------
    3 g+ a6 D, Y! ~
  888.   # ● 跳转“确定”
    - D. D. ?7 j" z4 e& b/ [' p, l: A
  889.   #--------------------------------------------------------------------------
    + o5 Z% S# _( D8 s0 u5 s; N
  890.   def process_jump
    / C7 H- i- B, R' D7 v
  891.     if @index != 11( x! B9 x  n1 T
  892.       @index = 112 e* z! |$ E4 {/ S+ ?
  893.       Sound.play_cursor7 Y& R1 F7 d8 H7 E8 j5 F" u- F
  894.     end
    . d% c+ `2 ^4 Z1 c
  895.   end
    / e* k9 a2 I/ r5 O
  896.   #--------------------------------------------------------------------------
    * m. }' j6 x( p) z3 a5 L
  897.   # ● 后退一个字符
    : `* \5 Q$ _+ K6 I# _7 L& ]2 \
  898.   #--------------------------------------------------------------------------* r6 d; T# E8 B4 l+ i/ F1 d% \7 Y+ @. Y
  899.   def process_back
    : _3 n2 Y" m) n: e
  900.     Sound.play_cancel
    - O0 `3 W. \  B/ l3 y
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    0 o; ~! w& c' e& t% X0 y: H; [2 R( `" ^
  902.     n = (@number  place) % 10
    ' Z7 K& n! F! U0 G
  903.     @number -= n  place
    * n, Y, C8 n( m& W
  904.     @number_proc.call(@number)+ b' ?! s0 C- D& ]
  905.     @old_window_index -= 1 if @old_window_index  01 K2 f8 s- \2 A% Z
  906.     @index_proc.call(@old_window_index)( l. A8 D2 `4 m# c' P" b! d
  907.     @refresh_proc.call5 `9 B4 U( `9 I0 G: {' H
  908.   end6 g) V6 I+ ^( R: I) N1 Y
  909.   #--------------------------------------------------------------------------
    ; q% D/ e7 X& G
  910.   # ● 按下确定键时的处理. ~2 q/ e/ f1 P6 ^$ g
  911.   #--------------------------------------------------------------------------* y8 S; p) j8 |4 {8 ~- H
  912.   def process_ok6 l7 w5 C9 k3 k3 C6 i
  913.     if get_number
    - Y) j/ A1 a8 F1 c5 y; D3 j: g  e6 c( x
  914.       Sound.play_cursor
    ' o2 z  r( {* P1 a2 J( B: }
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    + G5 i' i- d* K* @
  916.       n = get_number - (@number  place) % 10
    # z8 j) Y- a1 t+ e1 \  d5 z
  917.       @number += n  place% Q5 F' r# L' D5 T6 \2 d
  918.       @number_proc.call(@number)
    ( r: ^) P" |" K
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1% a/ ]8 M2 U3 n
  920.       @index_proc.call(@old_window_index)
    6 Z. p8 F; p8 y3 C/ _2 e
  921.       @refresh_proc.call( i- p+ C' ^1 R% R! |0 M
  922.     elsif is_delete' [7 u0 e& u( g$ G0 `  o5 l
  923.       process_back2 P' u& n6 H& I2 Z
  924.     elsif is_ok/ E* R, f* y3 K
  925.       on_input_ok
    3 T1 u! K9 M9 Z- i% d, {( M% p( p5 p
  926.     end8 i1 g) B+ Z" l' [) L" I
  927.   end
    ! E0 i8 l' v( F6 e  K* H* ]1 T2 y0 K
  928.   #--------------------------------------------------------------------------
    ' U' L  v' [, W, R" M
  929.   # ● 确定7 ~& V- h: P. f3 f& _: B% U' x! H
  930.   #--------------------------------------------------------------------------
    " S; Y7 s/ e4 E& T
  931.   def on_input_ok0 g! `# D6 x- I5 f6 [+ ?
  932.     @index = 0- ?& ^7 F6 C& ~- q6 X* x
  933.     @old_window_index = 0
    5 b# E* N2 Y8 r' F' R/ e1 W
  934.     $game_variables[@variable_id] = @number" w& U" b) {: u5 s3 B2 n
  935.     Sound.play_ok0 c, F+ J! c, D( p/ L; s, Y" d
  936.     @close_proc.call
    9 {" Q" l, _2 F! A# `* S! ^
  937.   end/ Q3 K, U: u/ m8 E0 J
  938.   #--------------------------------------------------------------------------
    $ J( j, l% C, e) M: Y
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ' \  h* \8 I. x" _/ V; j
  940.   #--------------------------------------------------------------------------( n6 N& b& j# S# M# n
  941.   def set_mouse_pos. G0 w5 S9 v# P$ V$ G1 w
  942.     if viewport.nil # necessary!+ \7 `5 X7 ^6 J4 Q! H
  943.       vp_x, vp_y = 0, 0
    ; f& N) o! [$ I0 J: ]$ b4 r5 q7 u
  944.     else
    % e4 L* R- y* m6 W1 Z, |2 _
  945.       vp_x = viewport.rect.x - viewport.ox  N. ~* K" |0 j, w/ B/ U3 d+ o
  946.       vp_y = viewport.rect.y - viewport.oy
    ' x4 u( N) V. s6 ?' b5 `
  947.     end6 _2 m$ N9 z& O, Z4 I5 G
  948.     item_x1 = vp_x + x + standard_padding
    , x( L0 J8 l6 h2 F3 S$ h
  949.     item_y1 = vp_y + y + standard_padding: Y% L5 H8 o" R
  950.     get_index = @index  0  0  @index 4 X4 B" y) t- A* E2 _% _6 w" N
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    4 D: E- @2 t$ }4 _, H# z/ D) I
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    0 c  R  V( [2 ?
  953.     Mouse.set_mouse_pos(new_x, new_y)
    6 @4 j( v0 ~$ s
  954.   end
    # l6 B, E, ]; h' A" v7 ^  \
  955. end7 m' [( _9 ^2 ~/ C+ [* f7 v
  956. ) U* s% z: y/ A" c% X% v
  957. #==============================================================================
    6 S; P* @, j7 G0 w& N5 h! j
  958. # ■ Window_Message9 t/ M  b# O6 c- y3 s8 U
  959. #------------------------------------------------------------------------------( V# f1 X' O0 |
  960. #  显示文字信息的窗口。7 I& k( F7 C5 w; L( y
  961. #==============================================================================  z" f/ q" ]' b% M8 O8 i
  962. class Window_Message  Window_Base
    * r  W* D: g# G) J- v
  963.   #--------------------------------------------------------------------------
    , p6 o* K8 H( `
  964.   # ● 处理数值的输入(覆盖原方法)
    6 x: c/ |) K3 a; {
  965.   #--------------------------------------------------------------------------
    3 U- @. A. j; X& Z/ {
  966.   def input_number
    ) Z% I$ ?4 w! @4 ~) t& A; `
  967.     @number_window.start! u& V2 R. Y; y/ j
  968.     Fiber.yield while @number_window.extra_window.active
    ( z# A/ B% J8 s) Z
  969.   end
    . P' [' u6 |. T! b4 j# b
  970. end
    5 G& m& T+ j& g
  971. 2 O/ t2 ^% c; u, k( e& z/ Y- [3 P6 s
  972. #==============================================================================
    1 t, ]$ W: {- x" d9 c
  973. # ■ Window_PartyCommand3 B- L) l. L/ G3 O% S* \
  974. #------------------------------------------------------------------------------. S! `8 |3 f/ N1 O% G, s# Q; w; _
  975. #  战斗画面中,选择“战斗/撤退”的窗口。+ c) w/ g- L1 \' c" `1 S% d
  976. #==============================================================================
    & O5 W: I+ g/ G, G8 @/ |
  977. class Window_PartyCommand  Window_Command
    , L0 L2 g8 x  h$ N; _; V7 S
  978.   #--------------------------------------------------------------------------- N: x2 w0 z, r6 K% @( K
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置& c0 h. I/ H" ]" ?2 @5 c
  980.   #--------------------------------------------------------------------------1 q* s8 B- J: X/ }
  981.   def set_mouse_pos
    1 R# S4 Q: }6 t" S! t: \" I" `. H
  982.     if viewport.nil
    3 E" V: _; R& p7 J
  983.       vp_x, vp_y = 0, 0
    , G4 z- X& s: H* o! g$ m
  984.     else
    , E2 K# y4 A# J% G/ G
  985.       #vp_x = viewport.rect.x - viewport.ox
    ) K8 m1 Q* q" Q. B  Q- Q! b
  986.       vp_y = viewport.rect.y - viewport.oy
    0 m! X6 o0 p# {% P9 g  f
  987.     end  V4 B% t, \: p1 z
  988.     item_x1 = x + standard_padding
    1 W/ m3 X1 |1 T5 I; x; U* B
  989.     item_y1 = vp_y + y + standard_padding; u, l) [+ ?( P. {/ C$ S3 n
  990.     get_index = @index  0  0  @index 7 k7 w: y$ P# C' k: u  M  m$ l% G
  991.     row = get_index  col_max - top_row1 r9 ^+ E6 u' _8 Z/ E. W
  992.     col = get_index % col_max1 t' a5 r2 G& T3 H0 C5 K' i5 X
  993.     new_x = item_x1 + item_width  (col + 0.5)
    . [! [' k1 [2 N; w: H8 h  T& ^
  994.     new_y = item_y1 + item_height  (row + 0.5)
    ( T9 q1 u2 k  j5 w) c
  995.     Mouse.set_mouse_pos(new_x, new_y)
    - m, w! R: l$ D$ f2 j7 [
  996.   end/ d, [3 G. |7 ^* y4 F
  997. end2 s( R$ B$ G6 Q
  998. " X, Q* \' e; L" B( m
  999. #==============================================================================" [) g7 }  U) ~. e6 M  {7 i
  1000. # ■ Window_ActorCommand7 y9 {% n6 F4 n
  1001. #------------------------------------------------------------------------------
    . m5 o" T$ S& E: O* J
  1002. #  战斗画面中,选择角色行动的窗口。4 [; y! g  ~1 b! B; A& h2 F
  1003. #==============================================================================* m2 R5 U" m' D# j) r1 A) q2 d5 [6 Y
  1004. class Window_ActorCommand  Window_Command
    # p* f& d0 @9 v2 W# l8 a
  1005.   #--------------------------------------------------------------------------5 }: l& ^0 P" l( ]1 L
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    - `4 O9 ^% Z7 R2 |' R: m2 o4 W
  1007.   #--------------------------------------------------------------------------
    5 B9 Q  `; `% G) {$ P4 K6 g
  1008.   def set_mouse_pos
    . b0 F/ T. l! g5 m- `& y" m1 D
  1009.     if viewport.nil9 C9 f5 ]; U3 I+ A* O
  1010.       vp_x, vp_y = 0, 0
    # N* }; }" e& Y0 G
  1011.     else0 u+ j( h7 P0 f5 w8 Y# U8 J
  1012.       #vp_x = viewport.rect.x - viewport.ox
    , n* [+ {4 N7 R
  1013.       vp_y = viewport.rect.y - viewport.oy  j3 z! F+ J' {
  1014.     end
    8 |' c8 P) O$ X( \  `, F5 S8 k
  1015.     item_x1 = Graphics.width - width + standard_padding
    $ p( W/ U, i2 e/ f0 B& }1 j6 F
  1016.     item_y1 = vp_y + y + standard_padding
    : V3 O% p/ I7 L( {6 W) C# ^4 w
  1017.     get_index = @index  0  0  @index
    . a) e- C6 b; a; `' q
  1018.     row = get_index  col_max - top_row
    ; {, l, i; n8 z7 h/ v+ d
  1019.     col = get_index % col_max* m& Q! @7 u$ v* A. h8 @
  1020.     new_x = item_x1 + item_width  (col + 0.5)8 B- q  ?$ ?9 x- x' I
  1021.     new_y = item_y1 + item_height  (row + 0.5)) d1 H+ s1 g0 t, `! K! q6 x3 C  I
  1022.     Mouse.set_mouse_pos(new_x, new_y)& q  {+ m1 X! S: I& Z4 l( \- W" K
  1023.   end
    ( F7 ~1 J4 Q! ~3 H4 C, ^
  1024. end# s4 J! r9 C/ F' U3 m4 q2 f) \, E* n

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

  2371. * z0 v) }& j  {$ G, i- x
  2372. ####泥煤的height
    9 j. o) Y$ J$ ]- g( a
  2373. # @height = height* {' _8 u8 s3 m1 G6 W( d

  2374. 1 m+ @% x, m, q% z7 i% l' D
  2375. class Area_Response
    ) D; K6 W, |% f. m' \! L
  2376.   attr_accessor type- [# E6 W' l0 {5 `% u" h
  2377.   attr_reader ox
      Q: ?2 Z6 d( M# W& Z) Q; `2 v
  2378.   attr_reader oy6 ?6 K! {! I; j: B. M! E9 g! s
  2379.   attr_reader width# S& y) v% b" `0 u& v. M3 G: r
  2380.   attr_reader height1 \' F, n' v4 S2 n" R* Q
  2381.   attr_reader switch_id! \- q" s# b" P
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    3 S6 c6 B0 L0 u# t% D
  2383.     @type = type
    : |. ?/ f1 A& S
  2384.     @ox = ox
    , s/ t) a- q+ r0 k. A
  2385.     @oy = oy8 }! F% r8 |0 k" p
  2386.     @width = width6 l' ?! x! U" k- t4 ?* ^
  2387.     @height = height  B, _0 A" d7 y
  2388.     @switch_id = switch_id
    & x1 c- T1 z# U8 A
  2389.   end
    4 z( _3 S6 _+ Z8 a5 I* C: }
  2390. end# d' M* W' @- ^# p

  2391. 7 D# ]) u1 G7 n7 ?/ K6 }1 ^5 a, k
  2392. $area_responses = []: `+ ?. F5 l' z
  2393. 1 h7 j$ B- l; }
  2394. class Scene_Map  _* m/ j$ h! V# \/ x/ y
  2395.   alias update_mouse_2013421 update_mouse_action
    1 F4 V, L* i' X6 R3 F" b$ n6 `( J
  2396.   def update_mouse_action2 R0 ]) Q0 {$ E7 r% g
  2397.     update_area_response
    8 m: h4 {' p  d0 ^5 H6 ~  m
  2398.     update_mouse_2013421' d  `5 g; b; g# R3 |. s8 K4 I
  2399.   end
    # ?) p/ F; g9 c
  2400.   def update_area_response
    9 X8 G) `4 ]6 x% y7 J: W0 m
  2401.     responses = $area_responses
    . f% D. m& _- v% v8 c/ Z/ H
  2402.     responses.each {response# v9 M, G! n1 W# N
  2403.       ox = response.ox4 f6 z8 P! m+ _
  2404.       oy = response.oy' f1 \9 j, c; K% v5 A2 O! _  W
  2405.       width = response.width
      e) K1 F7 p! V$ z  I$ E8 z
  2406.       height = response.height
    & t; S* Q2 C6 I6 m' J0 ]) M
  2407.       switch_id = response.switch_id  p7 A: y/ P! Y1 }+ O; M! ~  v
  2408.       case response.type
    0 B5 E  Y3 c- I6 |7 Q, g
  2409.       when 0. G& F+ e! R* O5 L9 a
  2410.         if mouse_in_area(ox, oy, width, height)
    # F- A2 [5 c4 S
  2411.           $game_switches[switch_id] = true- y& {: o+ A- o4 a# v, w5 w6 I
  2412.           $area_responses.delete(response)
    2 U; q" f6 z5 z
  2413.         end
      A% y! r7 Q( w/ |& ~/ _
  2414.       when 1
    / y# j" N/ ?$ \
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    ( ^: n2 e* u( n5 N. a/ u5 g+ z
  2416.           $game_switches[switch_id] = true; r. K  l: M, \: \8 P
  2417.           $area_responses.delete(response)
    1 d9 M3 l! d/ @: R: m5 z4 H0 Q
  2418.         end
    % F% @8 w5 R/ K5 L! o
  2419.       when 2
    / `4 F0 r& w$ _; _5 L4 y
  2420.         if mouse_in_area(ox, oy, width, height)
    2 S0 Q! y+ j: U3 F; Z: h
  2421.           $game_switches[switch_id] = true. R4 l( \, F8 w& f) w
  2422.         else
    $ v$ _% g/ S# l- @
  2423.           $game_switches[switch_id] = false
    . C& T" v: Q: C' ^) g+ @
  2424.         end- l$ s0 p4 A/ m" B- z
  2425.       when 3
    2 K. F5 h: |8 y% V6 }
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    + ^* U1 K  |) d
  2427.             (oy - $game_map.display_y)  32, width, height)" c/ c4 j; w$ Q3 i) c% a, q/ K
  2428.           $game_map.events_xy(ox, oy).each {event, }! I6 `, T9 Q, }* G: z& T
  2429.           event.start, ^0 k" M5 |6 c; P
  2430.           $area_responses.delete(response)& f9 W. `: s* W$ P
  2431.           return
    - E1 p5 F: M3 w" J6 Y+ Z, z7 G+ z7 P
  2432.           } : k. |5 B& j6 Y" A3 b
  2433.         end
    # f* c# r6 |; g3 n$ W
  2434.       when 4& q6 L# j8 X1 E2 D  o
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    9 n- b/ d, s6 z
  2436.             (oy - $game_map.display_y)  32, width, height)5 l; y- ^5 v( s5 ]8 X& b$ V
  2437.           $game_map.events_xy(ox, oy).each {event
    9 ~7 M# [+ Z- v
  2438.             event.start
    , Z# U0 W* |& V. H+ z
  2439.             return  K6 |( q' r/ K1 w9 D2 }& W5 ?( W
  2440.           }
    2 Z/ P9 f5 }' k% x
  2441.         end
      ]# K) j' F7 j' B- C
  2442.       end
    ! w5 |/ l6 @  ~, [% q1 {6 y! n
  2443.     }
    3 E7 h0 X0 z8 B6 z
  2444.   end& Y0 `( b; c1 e$ f8 Z6 p
  2445.   def mouse_in_area(ox, oy, width, height)3 @* t1 F9 V) }- c+ I4 F& l
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    # Y; K3 G; s6 G; Y0 h
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height( {# r+ N  Z2 i: ]! w6 ?9 j
  2448.   end
    1 u* i" ~* W6 s! ~: n* t: E6 u
  2449. end- |7 \! A/ b. l
  2450. class Game_Interpreter! @" O- _+ }- R
  2451.   def area_response(arg)9 {0 H; \$ m4 k3 u2 i
  2452.     $area_responses.push(Area_Response.new(arg))6 P! }& V! M9 E: R9 Z! B) j2 J9 w- c
  2453.   end: ~$ q. j- U9 [, V7 H+ N+ C
  2454. end; L  p5 W2 X0 t
复制代码





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