Project1

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

作者: 熊喵酱    时间: 2013-8-29 09:01
标题: 存放腳本
純屬給LBQ腳本:
  1. =begin #=======================================================================
    2 O$ h7 g1 a( h
  2. 0 ~, R4 n8 V# a3 O# O
  3.   Sion Mouse System v1.3e+ y. Z8 O; U, [. k* H2 ?, \; N4 T
  4.   % r! a' v# K5 W, s8 Q: a
  5.   Changlog$ C( E# F9 m* j7 D  ?: Z
  6.   
    ; }# n* A* ]3 `/ l, U; H8 u0 t# I, g
  7.   2013.4.21 v1.3f
    " U9 y/ @6 U# V' j
  8.     2 C$ V2 o: [2 F# c
  9.     1.3f 卷动地图 bug 修正
    * I1 A# w4 N% v3 Q8 p/ X1 t  f
  10.    
    ; Q! g# B2 ?& I: o2 c3 ]
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    * u+ T; q$ X3 k
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内) J+ R  ~1 i: K9 h' ?
  13.                               Mouse.unlock_mouse_in_screen 解除锁定5 m0 v  ^  K1 W. d
  14. 4 [" [# D6 z. i/ U0 g
  15.     1.3f bug修正! z: Q- R& s- m" ^/ e
  16.   ) q  U/ q3 j% r9 q1 c
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    $ d$ a9 M" A0 H; k; N3 U
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    9 I5 ]' l- \* G4 f! C# ?

  19. " p3 g( `" E3 ~2 ~
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    - I2 X0 T: d, P' }8 T8 m
  21. 1 M# o$ S/ t7 _5 F! Z; @
  22.     1.3b 修正一些罕见的bug;( h1 P; ]. ]: r5 c" b; w9 t% Z* X

  23. - I# c8 `8 D1 ]1 m, G: o0 h  B
  24.     1.3a 代码小修改;' s9 G, U" @) F3 |6 K3 s; J
  25.           加入了鼠标点击启动事件的功能,
    3 z/ C, [. Z6 r; w
  26.           在事件中加入“注释”: 鼠标启动  ,
    9 V8 A9 @3 J5 M( l
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。, M; O* T  ^' N4 u
  28.   * M. ^; F. W1 n( r7 z
  29.   2013.2.12 v1.2, D/ m, y' ~' ^2 i, q3 `

  30. $ \! k* f  h4 U( o; n; D/ N
  31.     寻路逻辑优化;9 ~7 O% {- @$ f, v& o
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    ( o" E9 S3 M7 l0 ?1 \7 I
  33.     现在支持用鼠标来操作载具了。" I4 ]6 C* d, T

  34. 8 X% p' z% y0 P9 A9 I
  35.   2013.2.8 v1.1
    9 A- y0 i, k0 v8 @. h
  36. ( I* j  Y6 G. K" k/ G2 ^
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;3 t: r6 e# B' J8 [: s
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;7 ~" _1 A- L7 U
  39.     移动时,路径指示点的绘制更加稳定;
    ' o; b5 n0 Q; }5 v- M
  40.     现在支持默认存档画面的鼠标操作了。
    , r4 T+ D$ m& o. l/ T

  41. : o2 j% X2 Y  T( V9 E
  42. 5 o" u+ T, h1 M! c2 _
  43.   OrigenVersion. b" c. u1 {/ p. d
  44.   
    9 B# x3 z# g5 g9 p
  45.     2013.2.7 v1.0
    ( W7 c) r6 D! |2 G4 X
  46. 3 U9 r1 ~& Y( Y, o, k
  47.   主要功能: K# E" p5 `5 E& D8 E( V# j% \
  48. ( g2 r$ S% ^4 d- I1 p
  49.       使用鼠标进行各种操作...- N( \/ E5 T* \0 y- n7 K1 a  C
  50.       将鼠标锁定在游戏窗口内
    . X' S9 z4 |: G' Z( j, W
  51.       自动寻路,按住 D 键可以扩大寻路的范围" x7 m/ S7 Q2 I% T0 l5 N
  52.       双击鼠标进行冲刺; u4 b% y/ e9 Q3 G" K
  53.       更改地图卷动方式以适应鼠标移动% m' K& e# K* d/ ?' s. z2 h; m
  54.       变量输入框改良0 n# W0 e) j4 V  Z
  55. ) W! D+ A# a9 t: X- O* L
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹7 C' u2 C4 |2 a! f' r  s
  57. ) j0 D5 C. n2 c$ l
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
      s" [5 h; o9 R2 A
  59. 8 N7 v) a2 G4 ^4 C+ Z% r
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    ( q- _# P/ b# i8 F' N  s

  61. 5 g6 s2 n' S/ Z9 M

  62. . D$ y* Q8 V5 s; F
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★* P' ?! @0 H( ^5 v
  64. ! ~5 R( _4 b: L  l9 B7 i3 e1 `" ]

  65. & b8 I! F9 W- p2 L
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    : t5 |5 k% T* k  \& O! h0 g( I

  67. 6 N3 j6 {' h' u7 @( o
  68. #==============================================================================' l- B1 a! D# Y0 |8 B2 s: u$ z
  69. # ■ 常数设置 & Q% b5 a) r' D$ }9 P- ~6 m8 l
  70. #==============================================================================4 N9 P$ ]3 Q' V8 _/ h
  71. module KsOfSion' y+ o. n4 u3 f% M, D% V
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    ( r1 ^2 r7 c9 I- k  O  @
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    ' n7 L, D; Q9 v0 B: Z* h2 ]) d" [
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false1 j/ r1 l% l7 {/ [( d5 w2 J$ S
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    $ f7 U! n6 V( K0 B/ t
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处& H2 W2 c) I. d& {* Q
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧* T* W/ S# E3 }0 Z( V
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    / n6 ]0 A7 N  P' V3 k2 k2 ]
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    7 x- o* f6 i" }4 T
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    9 B' ?, r" ?/ J* r9 o! s
  81. end
    7 p: a1 `  d+ c8 i% ^' B0 d

  82. 7 \5 k7 m5 _! g% o& ]3 ^# Q
  83. #==============================================================================
    0 a' B  y0 x% U
  84. # ■ 用来显示路径点的类
    5 l( a! |& G- E
  85. #==============================================================================# M* b" j% _  A& e! Q; V
  86. class Move_Sign  Game_Character
    " I9 [* B3 H/ g7 ?$ x
  87.   #--------------------------------------------------------------------------4 S. X! v" s) E; w) O1 r3 b
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图0 b% u0 L- r+ I7 H% K( T9 D
  89.   #--------------------------------------------------------------------------( m7 s( F; F7 k1 g, L
  90.   def init_public_members
    ! N+ ^" M) Z: ~5 z  O4 I8 K
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹( m. b$ |  D$ C$ b2 K! }( d. Q
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为04 T/ o4 A/ G0 A
  93.     @move_speed      = 5        # ★ 踏步速度
    " b) y, H/ x: b6 w8 z4 v. s" `
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    - U' \/ c! P8 J5 i
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度/ f, [+ B- }2 O# M, W0 t
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    2 U4 g6 F1 e9 T+ r  C! `4 v9 k
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    % U. ]6 W8 X. }) Y; g+ _6 K
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)7 J) u: o1 @) ?3 _/ O0 K3 A
  99. " e6 \+ W, R- O  U$ }
  100. 1 N: Q& ^9 V9 Q- D. Y8 R7 I
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    ( R2 ~9 x: Y8 \5 V! n2 f5 N5 B' a
  102. ) c( E# w. x7 F2 q+ K

  103.   C9 h. b2 P- K* K4 B
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图9 Y+ O( J& r' ?' L: B/ k
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    0 [5 |; f9 H  q4 [
  106. 1 ~  s8 f3 u3 b/ v* x
  107.       if $no_arrowpic_warn
    4 N: r7 A3 _4 I: Z, ]5 Q# d
  108.         MouseShow_Cursor.call(1)
    1 o# R- c0 c: H& S# S' N* A1 F1 b
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png. A* B8 U! J# l7 m5 e" R7 V/ G3 E

  110. ) w% s7 W; R- R3 H3 W1 ?7 F+ W, }
  111. “路径指示点”将使用游戏自带图片
    ! f' g7 C0 E4 ]) Y
  112. & v) G" B- a6 T) O
  113. 该提示可以在脚本内关闭')( b% {4 c- s7 ?% z: C' D, G
  114.         MouseShow_Cursor.call(0)
    $ d; }. i7 g, s0 \: a* n
  115.         $no_arrowpic_warn = false
    ' p1 P+ o$ G7 H* z( ~  g
  116.       end! t5 R" n: @, @2 J$ Q
  117.       @character_name  = '!Flame'. I- b& w3 V1 m+ ~; ^1 l- D
  118.       @character_index = 6
    2 s& P) j' |1 B+ p) p: g/ |
  119. - H! ?2 R6 c. L; W+ w# O8 @
  120.     end
    + {% u) F) @0 k8 z3 C: i
  121.     @direction_fix = false  # 固定朝向
    + P) H4 W' y& b) g
  122.     @move_frequency = 6     # 移动频率0 Q- L0 W% L4 v; `: \1 O: P) d8 C/ _
  123.     @walk_anime = true      # 步行动画# k: L1 p0 P! n8 R" [' j
  124.     @pattern = 1            # 图案
    / r# K6 V! ]6 F/ }8 D
  125.     @through = true         # 穿透
    + S7 T4 f# m" K) H: O: F, t1 K5 O
  126.     @bush_depth = 0         # 草木深度1 U/ y! I: ?7 P( E
  127.     @animation_id = 0       # 动画 ID
    ) J3 u* w: E1 J* h7 X6 X( m
  128.     @balloon_id = 0         # 心情 ID( M; X6 k( k- H, m
  129.     @transparent = true     # 透明
    . Y7 [/ G- U2 d  B* t+ @
  130.     @id = 02 X, B, S7 B0 _4 q" `8 O$ [
  131.     @x = 0' S  L9 b) D2 i1 r' M
  132.     @y = 0
    2 v6 K: f( q, O& T+ |# I' ]/ {
  133.     @real_x = 0
    3 ^: s, K! X3 s) a8 q: r
  134.     @real_y = 0
    ' t3 J+ b+ {5 b/ o4 p+ r
  135.     @tile_id = 0! p% C. l: o0 R( c' @. v( l
  136.   end* K. h* M  w+ Y! {" [1 s
  137.   #--------------------------------------------------------------------------
    " j/ X! s2 W) |2 ]% a
  138.   # ● 定义实例变量
    9 e9 S5 |9 H0 _# M
  139.   #--------------------------------------------------------------------------
    " a/ [, s1 S$ x, X0 F0 B
  140.   attr_accessor direction
    ! ^  P* D& P' w  P$ L$ t
  141. end6 A9 Y" v/ }9 x' A
  142. # ]! K3 W( T, ?; _3 W
  143. #==============================================================================  W% N3 b4 l" D7 Y; t
  144. # ■ Module Mouse
    / Z7 ^0 I' c. s2 t3 w
  145. #==============================================================================8 x0 Z3 \! Z- o! e( B8 g
  146. module Mouse8 B- ]1 M" K# y, R0 A) @
  147.   #--------------------------------------------------------------------------. _) c: R* S% P; h! }, c0 c, x
  148.   # ● API# w3 s/ S0 s0 N" Q, q/ N. H6 R
  149.   #--------------------------------------------------------------------------
    : s/ L3 H3 V2 _* P/ m* T
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    ; L* s& P9 s/ j0 a
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    3 K1 q, b- y' F6 E2 B& q8 p( ^
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')/ @" u3 w( W# j: G- ]
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i'): Q- f! P* r6 @* M* B' M7 S
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    % a2 E1 j+ n3 {6 f9 W
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    8 x' k7 O  r0 f1 f. U% E
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    ; j8 c  r. L0 A5 u! @8 ~& x
  157.   Window_Hwnd       = Get_Active_Window.call
    * {8 ~' E- ]- m5 {$ I

  158. , I; ^% e0 j$ [) m
  159. class  self
    - v( J( [: N3 r3 B  L; z
  160.   #--------------------------------------------------------------------------
    6 |& y; j) h$ U- G2 d
  161.   # ● 初始化+ M! n" W, p# z. R
  162.   #--------------------------------------------------------------------------" U4 \- p, r) g1 r5 o5 x
  163.   def init
    2 [. c/ J1 t/ F1 K
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    4 K' Q6 _1 d4 D4 H
  165.     @left_state = 0
    / J' i8 R% g% [$ |2 x$ C% l8 }
  166.     @right_state = 0
    $ Q( F) t- `+ I" g# m- T0 g
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    & G% j5 W  L2 p' E# U  N
  168.     @dk_count = 0 # 用于双击的判定! K; }4 n( ?: u+ a9 M3 k+ q' s0 P
  169.     @clicked = false
    " Z& K* J" v7 L! s3 e/ J* b
  170.     creat_mouse_sprite
    $ }" ~( |" L8 l# a: o, {
  171.     update
    ; J$ z5 ^- x% I" h
  172.   end
    * I. I( x/ B; J: f
  173.   #--------------------------------------------------------------------------2 g! R& n4 y# m: |
  174.   # ● 鼠标指针精灵
      L; v1 j: H  ~$ b
  175.   #--------------------------------------------------------------------------
    6 e. E& p; O' p  ~7 e- M# Y
  176. #~   def creat_mouse_sprite3 H$ _) V0 u4 V& g: I' N+ |
  177. #~     
    0 a. E& G  P3 G' D8 t
  178. #~       @mouse_sprite = Sprite.new
    ! ^* J. v% Y9 b% M
  179. #~       panda = 2#rand(2)+1
    , m4 p4 w, b) z4 w* |7 T
  180. 1 j- O- F# j! |, P0 R% Y  `
  181. #~      if panda = 1
    ) G2 b, S" P: j
  182. #~        if File.exist('GraphicsSystemCursor2.png')* k( b( s- J& O! a& I
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    " K8 [5 ~: }6 P, M$ X
  184. #~        end#with if File.exist
    ) o) t) n: Z8 V$ p
  185. #~    1 _( k9 @( R2 ^/ t
  186. #~     else if panda = 2 #with if panda=1, Y5 p5 F  }6 K- b/ k" p
  187. #~      7 P* C* l3 w- L  I& S# ~: S
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    ; \5 m/ `8 o% J$ G- M1 E1 Z/ N
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    . T# \; J3 Z' j" g( T
  190. #~      end#with if File.exist% T$ R% u! R1 r
  191. #~       4 l- c, Z7 e* Q) b9 b4 Z; w
  192. #~     else #with if panda=1- ^& D- ^% U8 f
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24); W3 R' x" z7 q" r! T. `
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    9 d! ~8 T; y! u3 F0 |
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    5 M7 Y) W; n8 l/ J9 ?: W0 ~
  196. #~     end#with if panda=1% |  m4 P8 c5 [0 G: z
  197. #~     
    # S( f$ H) t5 d# k
  198. #~     #with def
    4 c, i, z4 f. W/ q- v
  199. #~   end& o; z9 d7 \9 u/ D" O) a0 q1 U  Z
  200. def creat_mouse_sprite. V6 m$ J' O) d# O% r  v
  201.     @mouse_sprite = Sprite.new
    * g7 I7 ~! ~8 b. e; g" g9 T9 D
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})3 ], Z! ^! H7 n; l! k/ z' R
  203.     @mouse_sprite.z = 99993 A7 b5 `* e: @- E: d
  204.     Show_Cursor.call(0)
    ! n3 W# L( o5 }3 T
  205. end# Z8 W7 w/ l0 \" v  h& g
  206. ' R, j- E. V2 S, U5 h4 d2 A
  207.   #--------------------------------------------------------------------------
      T4 [' a; W- V/ L/ E
  208.   # ● 更新2 M( \+ O% Q# M
  209.   #--------------------------------------------------------------------------
    8 d5 M' ]% m: O6 F3 F. M
  210.   def update' W7 k; ~8 n7 l
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos6 e7 o8 E- {3 c+ n$ p, j( S
  212.     left_state  = Get_Key_State.call(0x01)8 v3 m6 C% C& [; V) T* y
  213.     left_state[7] == 1  @left_state +=1  @left_state = 08 P6 l; Y: x1 B2 w5 t0 b) L
  214.     right_state = Get_Key_State.call(0x02)8 u1 y+ ~% c7 ?2 r* X+ q# A9 ]
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    / ~: l! u1 Y/ h6 a; c
  216.     update_double_click% R6 w3 b- @# w* F+ b
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1% N! n2 I( \  \- w# D& R" c5 b2 v
  218.   end
    3 L2 _# P! Z4 ?* Z0 p: V% p: m! e
  219.   #--------------------------------------------------------------------------
    : j; ~) @8 Q, a6 I5 c1 C0 ~
  220.   # ● 获取鼠标坐标% B5 E9 A; g" Y: @( o% p, t( Z
  221.   #--------------------------------------------------------------------------+ y" ^$ M9 h) Y$ `- O- v
  222.   def get_mouse_pos& i: R# @  U' {  V( Y7 B4 D* s
  223.     arg = [0, 0].pack('ll')
    : L) \1 ^0 e) |# i9 I
  224.     Get_Cursor_Pos.call(arg)
    " t4 J' T  t, ~( k& M
  225.     Screen_To_Client.call(Window_Hwnd, arg)5 g% m( Q  [8 F* H0 Y# m
  226.     x, y = arg.unpack('ll')8 \# Y& |. X8 V$ F. C# b5 ?
  227.     return x, y7 W. g* Z4 A3 G. W1 P
  228.   end
    3 J: c6 m  u& X
  229.   #--------------------------------------------------------------------------
    8 i7 c( n7 L) _3 Z* D' G. c6 ?
  230.   # ● 将鼠标固定在屏幕内& U/ c  J/ x' j- x
  231.   #--------------------------------------------------------------------------
    ( v! U  ?! j/ ?, e) P' p
  232.   def lock_mouse_in_screen% y  u/ C4 _0 G. ?9 E5 S5 x
  233.     arg = [0, 0].pack('ll')( E- X; H3 g- w# u0 g; h; r
  234.     Screen_To_Client.call(Window_Hwnd, arg); Q" |5 b7 r& F$ t- L, j
  235.     x, y  = arg.unpack('ll')
    : c) @, `, J3 Q9 w4 W2 z
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))2 Q+ b, q6 J  \1 ?
  237.   end* d, D/ e7 q: G& d( \- _/ o/ m
  238.   #--------------------------------------------------------------------------; P6 o- n2 n7 C0 k4 I
  239.   # ● 解除鼠标固定
    ' v6 q4 U! q& o# h2 z0 R" {) x
  240.   #--------------------------------------------------------------------------
    ' z! C1 Y6 K1 k9 R# c
  241.   def unlock_mouse_in_screen- ?; }+ ]4 y) {1 c$ C' e1 W8 @7 h
  242.     Clip_Cursor.call(0). w; [7 x$ h& k6 f, f
  243.   end$ g" O  P' g' s8 }4 s7 L( L
  244.   #--------------------------------------------------------------------------
    4 M/ z' T6 y/ {+ @1 c3 H
  245.   # ● 鼠标双击判定4 A7 k& A  q/ V1 i; R) h
  246.   #--------------------------------------------------------------------------
    6 {+ q& ]% s) i- R0 O
  247.   def update_double_click
    4 E2 q7 s9 I4 r( }7 i& N
  248.     @clicked = true if @left_state == 1
    : f$ Y) _: E) Z
  249.     if @dk_count  0 && @left_state == 1- R3 J( |2 I2 H2 y9 R
  250.       @dk_count = 0; @clicked = false: N' u; g' g4 F
  251.       return @double_click = true* Q' I5 b# k; ?* A/ u  e" F  K$ y
  252.     elsif @clicked" R% ?" k/ U5 @% I) k6 e# e  e- u; g
  253.       if @dk_count  KsOfSionDbclick_Frame6 Q' Q6 N" z9 X) q" ^
  254.         @dk_count += 1
    # b' z7 a8 n# E  G& A
  255.       else1 @# H' @3 R' r$ K1 e
  256.         @dk_count = 0; @clicked = false! K7 ^1 u/ i2 }  H" }. `) g
  257.       end6 o! r8 ]6 z% C- y8 h
  258.     end
    6 {* }8 S2 ^$ B* A( c9 T: P' |
  259.     @double_click = false
    ' J& z0 r9 b9 H. z5 H6 s  V
  260.   end$ G  [6 K& t: |4 f* t* f; _
  261.   #--------------------------------------------------------------------------: {8 k. ]( S7 ^6 A: M
  262.   # ● 按键被按下就返回true
    # ~- |& C$ b+ y0 K( q
  263.   #--------------------------------------------------------------------------: P  S- U" A0 N. G* P. ^
  264.   def press(button)9 i; I7 w. F1 A9 Y: \
  265.     case button. T9 L, q  v; R) r9 V, `: D
  266.       when 0x01; return !@left_state.zero9 d: B/ |- M% P- `
  267.       when 0x02; return !@right_state.zero% j; D& j2 X3 Q- X
  268.     end
    5 p* Y$ l* b3 V
  269.     return false! E+ h' |5 V% a( Q
  270.   end& K1 M( W& ?. q( i. A0 x
  271.   #--------------------------------------------------------------------------1 c& q- Q, A& |! G1 O+ t7 L
  272.   # ● 按键刚被按下则返回true
    - i+ t9 @6 o0 t8 A- L
  273.   #--------------------------------------------------------------------------+ X3 J; [0 b7 q* f2 a: R: V
  274.   def trigger(button)5 U6 s2 G& ]  R: ?
  275.     case button
    ) D" b8 T( e* g. m: O1 k7 x
  276.       when 0x01; return @left_state == 17 g5 V0 I+ G( }) o! G0 H/ z* k
  277.       when 0x02; return @right_state == 15 p1 V; {! a* `# j+ v2 V
  278.     end  o) p* R+ B6 x
  279.     return false! _( s' `# {" X3 _% Y& m8 c
  280.   end3 ?9 D$ }$ G; S
  281.   #--------------------------------------------------------------------------: o+ m+ F2 k" ^  _8 ~; p2 L$ J: v
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    5 M4 W/ U  n" z9 h7 V2 r$ [
  283.   #--------------------------------------------------------------------------
    7 ~$ x7 \9 A6 \& F3 ^4 y
  284.   def repeat(button)
    3 A, i% U+ A( R7 Y- L, e
  285.     case button; B3 O+ U* D: {
  286.       when 0x01; return @left_state == 1
    ! q! i6 A& y; `( E" I3 V
  287.         (@left_state  22 && (@left_state % 6).zero)% y/ ]) n- W6 S4 ^/ A
  288.       when 0x02; return @right_state == 1
    2 [9 C) Y0 Y; j4 C
  289.         (@right_state  22 && (@right_state % 6).zero)" R: @) U8 w$ k8 j9 Z; `
  290.     end
    , h3 i) `: j# J
  291.     return false
    6 e( b3 ?9 N. \4 g( |; L+ R
  292.   end- w& L! b: V4 P+ q' ?: Z2 b' l
  293.   #--------------------------------------------------------------------------( j- W  c9 O$ v
  294.   # ● 判断是否双击鼠标, F) T/ Q" Y) N9 _; d
  295.   #--------------------------------------------------------------------------) J* b( _* h3 R. y" M
  296.   def double_click
    5 o: r) B5 d- N; {  _7 n$ Z
  297.     @double_click6 B3 m: [" `5 A5 x4 q, ~0 J
  298.   end* b6 }& j0 D* y" U: |* h6 k' A
  299.   #--------------------------------------------------------------------------
    6 |3 o. [7 y" Z" K) ~# E; O. z# t
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)/ [. X( j$ D- R) t. u$ C" L
  301.   #--------------------------------------------------------------------------! _6 P3 P/ J0 B
  302.   def click_count
      I  o8 @* r8 I6 W" V
  303.     @ck_count
    ; |( {/ p: h* f( D; S
  304.   end
    8 |2 ^+ g2 T4 C. Y1 ^9 N
  305.   #--------------------------------------------------------------------------0 |8 t% L3 {; F: q: u1 d
  306.   # ● 获取@left_state(按住左键每一帧+=1)2 U/ u  T  h# F  }9 v. B. W! {
  307.   #--------------------------------------------------------------------------
    & m4 U. b- ]" h+ l
  308.   def left_state3 U) q+ b; m/ L$ s
  309.     @left_state
    / w; h( P6 x  H4 U
  310.   end" k! O7 d6 P  \/ u/ v$ w
  311.   #--------------------------------------------------------------------------# `8 r/ ^4 G8 n6 p$ f
  312.   # ● 获取鼠标的x坐标
    " y$ X/ b3 e& N- I8 R
  313.   #--------------------------------------------------------------------------0 [; B% T2 x% U8 }2 j3 _# h/ w
  314.   def mouse_x
    4 K! }4 c) ]$ k4 @5 x. t
  315.     @mouse_sprite.x: B0 i1 r) U9 Z! v
  316.   end
    ' D, T' b2 L6 S% V! @. c' F
  317.   #--------------------------------------------------------------------------
    " ~: X  w1 ~5 m
  318.   # ● 获取鼠标的y坐标. {2 e4 s6 ]9 s. ^" G5 T
  319.   #--------------------------------------------------------------------------
    5 u; K! @5 Z) F% A1 j* ^$ s6 i/ `/ f
  320.   def mouse_y: ]7 y$ [% S: Q# w& C% m
  321.     @mouse_sprite.y
    3 ~5 x5 u9 |& H( @% J- p# S. f
  322.   end
    7 V2 J( ]/ ~  a  q1 A
  323.   #--------------------------------------------------------------------------! K2 f! I0 ~/ R( i1 r8 t  {0 A
  324.   # ● 设置鼠标坐标) h- i; v5 L8 `
  325.   #--------------------------------------------------------------------------' h' F9 x. E3 ?
  326.   def set_mouse_pos(new_x, new_y)0 L9 f  r1 Z6 u) C( _1 W& n
  327.     arg = [0, 0].pack('ll')( [0 {: d" Z* X6 O
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    8 v3 f, Y4 h! i0 v
  329.     x, y  = arg.unpack('ll')$ w  t  E1 p( ]; d5 N
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    ! ~+ L0 g, ^' g1 f0 a/ u# ^
  331.   end" G1 H! f; w( @6 \, E2 l/ \$ g7 O7 G
  332. end #end of class  self 5 ?5 ]8 o0 Z1 z9 q# A3 v& ~
  333. - [' `5 Z  L( u; y+ e/ K; M
  334. end
    & {4 J$ B' q9 a# l7 V/ C

  335. / m7 `( A! u8 r9 i
  336. #==============================================================================
    7 E9 T5 d3 A2 _) B. f7 D4 x
  337. # ■ SceneManager
    . W8 i$ i5 C. k* u
  338. #==============================================================================1 Q* a# M/ I2 z; f7 s9 X: }
  339. class  SceneManager4 _5 \  B& ~+ B1 k! h5 G( P
  340.   #--------------------------------------------------------------------------
    ! L/ ]1 T) \% h* ?% k* o
  341.   # ● alias% H8 s- t! y% K& u
  342.   #--------------------------------------------------------------------------. [# F( `& }1 L8 C6 P2 a
  343.   unless self.method_defined(sion_mouse_run)
    6 U+ M) i2 B6 y
  344.     alias_method sion_mouse_run, run
    7 v( l3 z0 b" y: B/ A4 J' z9 t6 E
  345.     alias_method sion_mouse_call, call: j) X* o* ~% E1 I
  346.     alias_method sion_mouse_return, return
    ' \) Y! N1 R5 v# h8 T
  347.   end! a' D, ?# u: g4 a: D. X+ T0 e
  348.   #--------------------------------------------------------------------------' @7 Y& R# i- {6 j4 X
  349.   # ● 运行
    3 l; s# W, @) o; j
  350.   #--------------------------------------------------------------------------
      m1 _" S- h  k5 V8 t2 d
  351.   def run- y3 H) u" v( |2 n
  352.     Mouse.init
    , d: M  _  ~2 q) |7 w9 r1 ~
  353.     sion_mouse_run
    ' P, n4 ^7 v2 Y3 b, O
  354.   end
    % O7 B* L6 f* i* v$ j" O, Q
  355.   #--------------------------------------------------------------------------0 H, L- ~7 J! A9 D, Z" D
  356.   # ● 切换' @8 h/ j0 N' j4 {: `/ J, K
  357.   #--------------------------------------------------------------------------
    5 H; g: u# ]9 ~. j
  358.   def call(scene_class); u8 O9 J2 F, I* E0 {/ \
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    3 j9 b  R0 c0 K+ S
  360.     sion_mouse_call(scene_class)' l4 f% U. u* f3 m! C$ J: K
  361.   end& K. Y: ?$ H, R5 U
  362.   #--------------------------------------------------------------------------
    5 i) B! J1 i8 U/ V
  363.   # ● 返回到上一个场景4 @- P/ T) `1 D$ G' U7 ^! e
  364.   #--------------------------------------------------------------------------
    ( P4 J% Y4 p4 g! z) G  w& N
  365.   def return2 W0 H7 {6 X% {5 N- l( c
  366.     sion_mouse_return
    ) q; q# v3 H, Y+ o0 n2 J. c
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    4 E# @& [9 H6 d' H2 x
  368.       @scene.instance_of(Scene_Map)
      i1 |% D* g9 @& r, I
  369.   end
    0 i, H- c4 _4 N; H
  370. end
    ' D8 ?3 S5 H' \/ @+ r) {5 I" b

  371. 0 u& \& @. H( J/ v
  372. #==============================================================================, E* A# e) {2 f' K
  373. # ■ Module Input7 }1 r- c  c' i8 U
  374. #==============================================================================2 Y6 b( Y. F. f, Q
  375. class  Input
    : A& o; H. d4 |" [" _
  376.   #--------------------------------------------------------------------------
    ) F; t) n8 q5 N- _: f' V2 L
  377.   # ● alias
    * t8 v- D7 m; ?8 X: {) L
  378.   #--------------------------------------------------------------------------
    - B' H+ y5 h9 s  S
  379.   unless self.method_defined(sion_mouse_update)( I+ C1 P" C' c3 }8 H0 i
  380.     alias_method sion_mouse_update,   update
    : \; B7 f9 X- G# o/ a7 l! M7 ^4 X
  381.     alias_method sion_mouse_press,   press# |" z9 z7 v! v9 J4 n
  382.     alias_method sion_mouse_trigger, trigger
    1 ]  a/ B0 H3 q0 D- h% p0 T
  383.     alias_method sion_mouse_repeat,  repeat$ x* j& S4 q9 [$ W" [6 I9 F/ i& _- |
  384.   end1 y6 h6 G( T- Q, q
  385.   #--------------------------------------------------------------------------
    % |/ V/ s  c- e5 d, a  M& V
  386.   # ● 更新鼠标
    . v2 F. X2 p' j; q
  387.   #--------------------------------------------------------------------------
    . `, v" |5 D" Q" j; n
  388.   def update
    8 K) B* C" S3 n" u6 R3 `
  389.     Mouse.update
      W" _3 p, `; x- S; ^0 A+ F
  390.     sion_mouse_update
    ' K3 ]. A3 ~: u) P6 A. C
  391.   end3 f) a, _9 C6 b6 M, s
  392.   #--------------------------------------------------------------------------) t0 w7 ~* ]$ {5 t: K5 ?/ S' ^
  393.   # ● 按键被按下就返回true
    8 i/ b+ S: N8 _: N% a6 Q
  394.   #--------------------------------------------------------------------------
    " |) h  Y+ p' h  x
  395.   def press(key)
    + \/ X7 o# W  M: E- G3 H' u& c
  396.     return true if sion_mouse_press(key)
    ) X) |% U, k) a: f
  397.     return Mouse.press(0x01) if key == C$ h  I; H4 b4 F" |- [2 K% b
  398.     return Mouse.press(0x02) if key == B- a" f9 \5 d" c
  399.     return false4 z. x2 g- X1 U
  400.   end6 _; m$ L( g" V+ C; K& I% Y8 ?
  401.   #--------------------------------------------------------------------------, Z! l* _# C9 C7 I2 X4 G8 T
  402.   # ● 按键刚被按下则返回true
    : c) E+ W& ^9 j3 [+ ~. n* a" x4 k
  403.   #--------------------------------------------------------------------------
    : b& g+ V, o& r9 _# i- U, t
  404.   def trigger(key)
    2 s  {' K/ |: ~
  405.     return true if sion_mouse_trigger(key)7 K5 P2 n1 b: h1 c/ [3 \
  406.     return Mouse.trigger(0x01) if key == C: e+ B1 y; @0 a' a
  407.     return Mouse.trigger(0x02) if key == B: v0 d' F" N! R9 ?! ~) v# |! @
  408.     return false
    / a- L. h$ L& N. A, d# i  c
  409.   end
    ; w! L$ I6 N& _& K. g
  410.   #--------------------------------------------------------------------------3 T* N% [2 E  p5 E% c
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    , m, v' Q7 I: u( @: l$ n& S
  412.   #--------------------------------------------------------------------------  E$ Y' p/ G, o6 @2 A5 e! Z" j/ K2 ]
  413.   def repeat(key)
    1 ]# r5 @5 g8 D' u9 U
  414.     return true if sion_mouse_repeat(key)
    0 ?/ B% V; i2 n0 ^$ r9 s
  415.     return Mouse.repeat(0x01) if key == C: `2 n7 U  e1 Z" v1 s
  416.     return Mouse.repeat(0x02) if key == B
    $ _7 M# B+ M  T" v7 s
  417.     return false
    * U0 Q* E& Z7 V% E4 h, \1 t6 T
  418.   end
    % r2 a* l2 w" f& l# A
  419. end& [, J. b6 p8 E2 O" f+ f% _

  420. - Q# J7 f  b/ Q1 ~$ H; A2 g
  421. 9 j/ p2 S1 w2 L$ Y3 W
  422. #==============================================================================( c5 u( s. _( E/ L/ E: _; A. I
  423. # ■ Window_Selectable
    ! s* T3 H: s, R
  424. #------------------------------------------------------------------------------
    6 x1 i8 C# N7 G7 D5 j+ n# R
  425. #  拥有光标移动、滚动功能的窗口4 \; ]4 Y$ J( L
  426. #==============================================================================
    & \* b  x4 C  K2 E2 v% E
  427. class Window_Selectable2 \  p+ j2 t" o$ ^: Q
  428.   #--------------------------------------------------------------------------
    ' K8 d3 k1 `0 W- I5 D5 g
  429.   # ● 初始化4 K& d$ D- `9 ]1 ~& P  C, g
  430.   #--------------------------------------------------------------------------: B9 i2 K- _0 @* u8 @6 B* l  Q
  431.   alias sion_mouse_initialize initialize
    1 B" V' G( s+ m9 L' R
  432.   def initialize(x, y, width, height)
    " U) v! [4 p/ ~! L+ u, q
  433.     sion_mouse_initialize(x, y, width, height)9 \1 F! t, H1 D" h9 S
  434.     @move_state = 0
    : Z# x2 n; b. x8 Y8 _$ L
  435.   end* u# v1 _& p, m
  436.   #--------------------------------------------------------------------------
    - ]' z! ?9 q& _0 a  M9 R8 P! h
  437.   # ● 更新' h; v# W$ a. w0 f( F. A
  438.   #--------------------------------------------------------------------------7 R0 v5 [7 a( t2 X
  439.   alias sion_mouse_update update: f  X+ X! C" g, V1 ?
  440.   def update
    8 ^! m. C+ ^% @) h
  441.     sion_mouse_update
    8 u2 M- C+ d  t& S
  442.     update_mouse_cursor6 x  r& o* s, C, i/ a4 I
  443.   end
    ) U7 k& e* [+ h. Q1 q/ f4 b9 C
  444.   #--------------------------------------------------------------------------: g/ B' Z: S! b  A2 U3 d( w
  445.   # ● 启动后设置鼠标到index位置
    - ^9 |. y3 ^. {( ~
  446.   #--------------------------------------------------------------------------+ C) j5 w5 [# G
  447.   def activate% u& {' ~5 K6 p; _+ A
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    . M: d7 Q2 x& w$ q# z3 d5 a
  449.     super, Q& b7 s0 S2 ]% O/ b! d  Y
  450.   end8 K% K; t8 ]9 V$ g: K0 {. Y
  451.   #--------------------------------------------------------------------------4 Q, Z2 {& S  r/ B' a. s
  452.   # ● 更新鼠标和光标的位置
    : _/ {  r& K0 U9 R' _' C
  453.   #--------------------------------------------------------------------------
    9 D1 E' f( O: Y8 K7 K
  454.   def update_mouse_cursor9 y# B" P( ?3 m$ T6 Z
  455.     if active5 H8 P2 T1 Y3 ~* @  h
  456.       if @need_set_pos' P2 ~# S& [2 b  }3 x. t; G/ q
  457.         @need_set_pos = nil3 S% i" U7 K! x9 r
  458.         set_mouse_pos
    . i9 L9 `/ n- `0 B
  459.       elsif cursor_movable
    ! c, K2 F. g- s
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    . y4 c2 d7 H4 U4 ~) D1 D6 y/ a" m
  461.       end
    . o1 Z; _: g( ]5 t) k0 z
  462.     end; L+ x3 b3 f& j% h% e0 u
  463.   end
    . L8 W) n/ @5 a* n! S
  464.   #--------------------------------------------------------------------------) u2 T! s0 s$ M( }5 c. k
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    5 b! b4 o9 X! w2 Z4 |3 U( @
  466.   #--------------------------------------------------------------------------& x, L9 n4 N1 |, W# Z
  467.   def set_cursor
    " ]$ S2 p5 S* H3 G3 B
  468.     mouse_row, mouse_col = mouse_window_area  g- s4 M& F* V
  469.     if    mouse_row == -14 A$ [+ Q0 Q* Y4 F& `# c0 Q
  470.       @move_state += 1 if need_scroll" ]5 N; {8 o9 `9 V% o2 |' X
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    0 ?4 @" D, @) r% D% E& P$ o8 `
  472.     elsif mouse_row == -2+ L% m: l+ n3 z8 r, A+ b6 ^- r, n& `/ Y
  473.       @move_state += 1 if need_scroll
    2 }$ X' Q. l. B1 N4 T. u, F' b
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand0 u8 C. R1 \3 s6 [1 }( s8 I5 }
  475.     elsif mouse_col == -1: D, D7 g6 L7 t* p+ E2 J
  476.       @move_state += 1 if need_scroll- d. M9 U( t0 i% n) H8 m+ g
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand1 i- h  \- a3 X  B2 _+ h9 M
  478.     elsif mouse_col == -2+ P: [. w9 b" W: ^  A1 f
  479.       @move_state += 1 if need_scroll
    5 M8 I# K1 Y. r4 `2 }, q
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    : w; L+ f& Y" H( _' t2 z" D0 u
  481.     else) i/ s  l5 J. Q- P: {* t
  482.       @move_state = 0: ]- \& s* Q7 I' Y
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col# x& S9 M% O8 f
  484.       select(new_index) if new_index  item_max && new_index != @index; A4 C9 C) v; c) \: M% \# ?( O
  485.     end5 L% o* \( Y" R) ?+ K! r
  486.   end+ L( Q# T# Q. C, ?* M5 v( ^; m
  487.   #--------------------------------------------------------------------------
    4 s2 ]. H, ^1 [( @% l7 T% e8 I
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    - L5 u0 ^5 ]# R+ U
  489.   #--------------------------------------------------------------------------
    4 I: X* y4 E& }/ \& k3 l
  490.   def mouse_window_area
    9 |5 S, Y  ]+ [! d- O9 n
  491.     if viewport.nil # necessary!
    * U, }2 j4 N5 w4 ^/ T3 x
  492.       vp_x, vp_y = 0, 0
    ; g+ T' L3 m6 {' j
  493.     else
    + d! w( i. a/ `0 G) K0 t' ^
  494.       vp_x = viewport.rect.x - viewport.ox
    # c8 h8 T9 Q# J$ g# [/ L
  495.       vp_y = viewport.rect.y - viewport.oy- U) V, H9 \8 ^- }) ^" s" c: v
  496.     end5 ~( x/ r/ E% ?( {! F- g
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ! p* F7 w4 O, v$ H
  498.     item_x1 = vp_x + x + standard_padding
    & [% N8 h6 L( G  I
  499.     item_y1 = vp_y + y + standard_padding8 {1 h; [' E& A" @" p
  500.     item_x2 = vp_x + x - standard_padding + width; \, L; g; `, K, R8 p  u( Z
  501.     item_y2 = vp_y + y - standard_padding + height, g- x7 t* w: m& M& J% M
  502.     if mouse_x  item_x1
    5 W$ M4 s/ r- }/ h7 D5 {" b" W
  503.       mouse_col = -1  {0 T& i$ Y# [& _- g' {+ Z
  504.     elsif mouse_x  item_x2' K, [/ a8 ^: Y9 L7 d: `' s
  505.       mouse_col = -2" S% i4 Z2 ^9 X$ M4 J
  506.     else
    . U( V+ D7 v& m5 @
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)% z0 ]% r8 c3 _! {
  508.     end
    6 K; k7 l! C6 M. b  E5 I
  509.     if mouse_y  item_y1
    , s. s+ E" v, M7 ]  t! D* ]
  510.       mouse_row = -1
    5 M, g0 Q) \# j; J& w- ~
  511.     elsif mouse_y  item_y2
    2 }6 d4 `" q& `
  512.       mouse_row = -2' P, o* B6 c- _; t
  513.     else
      t; B5 c4 ]5 m0 I( j( q! o& [+ ?
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    5 f1 v& y6 \2 [
  515.     end
    3 W& S: Z( K) L
  516.     return mouse_row, mouse_col
    8 k' B* a" P0 v9 h9 P' D0 W6 A
  517.   end
    * {$ c& ]  d7 c7 G) s( l
  518.   #--------------------------------------------------------------------------
    6 ~  {+ Y! l4 c/ j" R( L
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置* P/ P9 _# G, d$ R( c5 h+ Y
  520.   #--------------------------------------------------------------------------
      Z3 |8 V- f6 B$ T3 o3 q- f  f
  521.   def set_mouse_pos( ^2 ~# p" F# l
  522.     if viewport.nil # necessary!6 `" r  m5 x  ]
  523.       vp_x, vp_y = 0, 0
    ! U5 j5 ]8 h/ V% \
  524.     else# k0 y5 h4 S6 m8 y) a
  525.       vp_x = viewport.rect.x - viewport.ox0 {( H1 N. Q( N! \6 X
  526.       vp_y = viewport.rect.y - viewport.oy5 n4 Q/ m, g( X8 S/ F
  527.     end
    ' Z1 C3 P  }5 T' `7 j6 U2 u6 w. H
  528.     item_x1 = vp_x + x + standard_padding 2 b) B) `6 E9 M9 o3 k  r' W% ]  ]. g
  529.     item_y1 = vp_y + y + standard_padding6 W/ K" y5 h) ?# d+ T# h9 A
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    ( \* `4 a* w) a; R
  531.     row = get_index  col_max - top_row. _; g( q1 n' \4 H4 e- M
  532.     col = get_index % col_max
    3 ]- H- Q# a! S  H5 Z
  533.     new_x = item_x1 + item_width  (col + 0.5), x4 V2 x5 z/ ^; y
  534.     new_y = item_y1 + item_height  (row + 0.5)
    " v. L. @5 W6 O; T6 t1 n+ F) S2 e
  535.     Mouse.set_mouse_pos(new_x, new_y)3 T6 v' [2 ^2 g; k# |' x, y! Z
  536.   end- o6 d! Y- X% Y" c: s
  537.   #--------------------------------------------------------------------------
    0 \" Y# {+ L( _
  538.   # ● 判断菜单是否需要卷动% p! B  I" I- S+ B" H+ R
  539.   #--------------------------------------------------------------------------
    & S' I+ }. i' S6 u
  540.   def need_scroll
    $ j7 M0 ?: @8 ~2 [# d: f% v
  541.     item_max  col_max  page_row_max9 V8 ~, c$ _0 h2 i3 y  z' L
  542.   end: ~- H5 q7 ~( Y0 `# Q, f5 H
  543.   #--------------------------------------------------------------------------
    : y: K9 X: D- L  ~' y
  544.   # ● 判断是否为水平卷动菜单
    ! z7 \$ D  C" A# b+ c# K6 ]
  545.   #--------------------------------------------------------------------------
    ) ?5 m& f; ~$ E5 k0 ?
  546.   def is_horzcommand
    & n: y. \' o: b1 @$ s
  547.     return false
    ' o6 P( ^- E/ z* H( ]
  548.   end& V- h) d, _0 e. n2 u4 `( X
  549. end6 C/ Q8 C8 S9 w. _1 i( u

  550. % D, K9 s/ d7 Q8 G$ W5 N$ _
  551. class Window_HorzCommand
    : D: a% t. F: Q4 d7 x1 ^- @# `
  552.   #--------------------------------------------------------------------------
    3 Q! Z; i, q6 ~" d& s
  553.   # ● 判断是否为水平卷动菜单
    / R8 r( f/ v, V  M$ }4 o4 v' E
  554.   #--------------------------------------------------------------------------
    ) {' P# D- J$ K7 [2 K
  555.   def is_horzcommand1 a2 Q: i$ n  e1 G# G5 w. f3 h$ ?
  556.     return true
    & `# B% }/ {( i
  557.   end  W6 }+ L4 ?* ~) [% L
  558. end+ c6 T3 G. |5 u7 r  W& n
  559. 3 ], j# A- k# V7 m
  560. #==============================================================================& h$ r4 O$ X; b2 g1 ^8 l& o& D
  561. # ■ Window_NameInput
    8 o8 b/ P, B; N5 n% E0 |- K
  562. #------------------------------------------------------------------------------2 j; F. ~9 D. P4 Q$ G1 t( O$ ]
  563. #  名字输入画面中,选择文字的窗口。" X% f$ l3 G, {% W4 s! m
  564. #==============================================================================
    ) j, z" \. R3 \& b
  565. class Window_NameInput
    0 h; z3 s& P& U
  566.   #--------------------------------------------------------------------------
    5 g8 [- G& c( O& G( n
  567.   # ● 设置列数+ |' t" y( e# z
  568.   #--------------------------------------------------------------------------
    ; ?8 s# w! x0 E! [9 |6 t
  569.   def col_max. }3 _3 ?" K2 C  g, c
  570.     return 10; S& x  M1 U* S& |9 j3 {
  571.   end& N7 p% r" Y3 g8 a
  572.   #--------------------------------------------------------------------------- V. E/ \8 {' y) B3 x. s
  573.   # ● 设置填充的Item个数% c3 Y! }/ t! K; S" |) C
  574.   #--------------------------------------------------------------------------
    ; L& w( x& ^+ _7 E$ d
  575.   def item_max8 `; V8 p# ^+ ~, e4 ~. \
  576.     return 900 L4 A% x) N  P" H
  577.   end7 _, i# U( e" t# j9 C5 v" ]
  578.   #--------------------------------------------------------------------------& M  J5 p! K! v$ H# X, J
  579.   # ● 设置填充的Item个数
    9 v5 @1 d# E. @* F: U
  580.   #--------------------------------------------------------------------------
    5 |" O6 ^3 h' T: c
  581.   def item_width
    : ^6 p$ D7 S( c: B
  582.     return 329 Z+ ~3 B) {4 R" V8 f+ Z. d/ `+ F
  583.   end3 X3 ~. A* j$ {4 d
  584.   #--------------------------------------------------------------------------' V% m' Q7 V2 d# Y$ G
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    ' j& X) Q! t1 U2 i. O* \+ B, `, f5 V
  586.   #--------------------------------------------------------------------------$ B, p5 b4 T% ~6 D
  587.   def mouse_window_area
    ; c6 q# ?" M+ h
  588.     if viewport.nil
    # `$ q4 j4 m/ v. J8 b
  589.       vp_x, vp_y = 0, 0" I& a# I8 n5 Q  T8 U0 G
  590.     else
    1 @8 V& t7 Z' |. `! |+ P
  591.       vp_x = viewport.rect.x - viewport.ox& b( Y3 M3 j& Z0 r9 r6 n
  592.       vp_y = viewport.rect.y - viewport.oy! N, t: w/ L: b2 V
  593.     end
    : m4 O( o, E, o" @' u8 w5 s. G
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y- ?; b$ r9 d8 n2 B* U! A) g
  595.     item_x1 = vp_x + x + standard_padding + O' [4 F, J- H/ R: R4 v
  596.     item_y1 = vp_y + y + standard_padding9 B9 B3 \4 u2 Y* N, I7 R+ K
  597.     item_x2 = vp_x + x - standard_padding + width
    ; W" @; g. s) G# P
  598.     item_y2 = vp_y + y - standard_padding + height
    - A' m+ Q+ }& N& b% _# l
  599.     if mouse_x  item_x1' |% }0 m+ R% [( c2 G5 E
  600.       mouse_col = -11 b$ E& G& K1 h# X( ^/ F3 y1 P
  601.     elsif mouse_x  item_x2- j- S+ ^5 E/ y
  602.       mouse_col = -2
    1 O% I: Q7 k" a' p& P  a1 H
  603.     elsif mouse_x  item_x1 + 160
    $ U6 j9 w  [' s; `3 k( S- L
  604.       mouse_col = (mouse_x - item_x1)32( u2 _' E4 [3 @& ~1 r" t
  605.     elsif mouse_x  item_x2 - 160
    1 ?8 n1 A4 B3 n/ y* q0 f
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    , ^) V, G: U; E* O5 z  k
  607.     else
    ' Y5 p  E0 ?/ @% u6 c
  608.       mouse_col = mouse_x  x + width2  5  4
    : @; i6 N6 X! w( n
  609.     end
    4 C% K, I4 w0 [- c
  610.     if mouse_y  item_y1
    : _; Q* u+ e( l% [& |- i4 x8 D
  611.       mouse_row = -1
    8 V- ]/ T' T: k8 z
  612.     elsif mouse_y  item_y20 ~: X1 F5 \7 C, x* Q' T1 x; H0 |
  613.       mouse_row = -20 }$ e( a4 A' e) r  @
  614.     else) B! N+ W  y/ K' m, p! s5 E
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    ' o1 r+ V, N. M; ~' g. l
  616.     end
    & W. j5 m6 f. U0 u0 c6 `3 u4 L
  617.     return mouse_row, mouse_col
    " @$ m2 u7 U- v. k/ \
  618.   end2 W* C$ P) I$ @; B5 h
  619.   #--------------------------------------------------------------------------# d+ h* j3 j* C& {, u. J( Y
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ! w; J# @; T2 I' X$ q( C2 p
  621.   #--------------------------------------------------------------------------& n5 E( u$ i3 Y0 t
  622.   def set_mouse_pos
    8 y; \& d" A% W* a0 x
  623.     if viewport.nil # necessary!; ~2 g# W  E+ G4 Q8 R; n; c
  624.       vp_x, vp_y = 0, 00 a+ _" ?' O) _" j2 a* K! [
  625.     else
    % R& T3 }+ a3 f* @2 Y0 B
  626.       vp_x = viewport.rect.x - viewport.ox9 p, m# k8 D, H8 Y9 K, g
  627.       vp_y = viewport.rect.y - viewport.oy; R& S! Z6 b9 a. H; `: |
  628.     end" [1 @- Q2 K. A4 w! n
  629.     item_x1 = vp_x + x + standard_padding $ O) K6 k1 U1 k# U% a9 k
  630.     item_y1 = vp_y + y + standard_padding- k, D) @5 T  G+ g: W: U
  631.     get_index = @index  0  0  @index , x! p+ q% _) U) i3 S7 f4 R
  632.     row = get_index  col_max - top_row1 h/ d5 S0 A3 s2 H% Y
  633.     col = get_index % col_max
    ) w  N! |: k- M! e& y3 A3 v
  634.     new_x = item_x1 + item_width  (col + 0.5)
    0 u5 n; L2 j) I+ z
  635.     new_y = item_y1 + item_height  (row + 0.5)3 L$ U( S5 I) m+ r3 d6 ^
  636.     new_x += 14 if col  4
    * N. ~" F- u# ]& `' R* |* ~
  637.     Mouse.set_mouse_pos(new_x, new_y)" I% W& h6 ?" @7 Y2 |: K6 S
  638.   end
    6 @1 i8 C' H+ [. z7 B5 G& c
  639. end/ T/ Y$ T% |# [- ^1 R6 c2 R! b

  640. 9 F2 w# ~) m) [# n# o; G! f
  641. #==============================================================================
    5 L  v4 a, I: U+ ?/ p3 a8 g% @" P  I
  642. # ■ Window_NumberInput
    1 s2 o! N0 M* i* }; t4 [0 _
  643. #------------------------------------------------------------------------------0 k$ a( r5 s* r- N6 ]
  644. #  重写了数值输入的方法以适应鼠标8 {. P7 Q% V: L9 g
  645. #==============================================================================& ]  T9 m4 D- b
  646. class Window_NumberInput  Window_Base: i% o9 @, d; J) @
  647.   #--------------------------------------------------------------------------9 W: D$ V0 o. A; a
  648.   # ● 定义实例变量
    0 n" C$ a7 x6 w2 g1 p( {. O1 g
  649.   #--------------------------------------------------------------------------
    0 A) S! x/ j* t8 T! c8 f! K% ]! j
  650.   attr_reader extra_window
    " e9 Y8 E& {* m; C$ @* ], h/ N
  651.   #--------------------------------------------------------------------------" `9 @' P2 j5 L$ }7 [
  652.   # ● 初始化
    ' R: ^1 z9 Q4 M, e
  653.   #--------------------------------------------------------------------------
    ! v; t% ^4 H0 ]4 B
  654.   alias sion_mouse_initialize initialize% Q/ z" G; q7 M: }& s
  655.   def initialize(arg)/ n( }' v9 ~0 ~5 k
  656.     sion_mouse_initialize(arg)! L- z# ^3 C7 ~% d* v, N0 i  F
  657.     create_extra_window
    ' D' Y* L$ i& U5 I( J: j/ y$ c
  658.   end7 _# t( U, Y, x- `9 c$ q3 W  `
  659.   #--------------------------------------------------------------------------
    # l# T; T3 {7 ~: d
  660.   # ● 启动
    3 A4 p6 j  v3 j8 c" @' F9 a
  661.   #--------------------------------------------------------------------------! z( u1 F. ~4 K/ Q+ @7 v0 M
  662.   alias sion_mouse_start start
      u1 A( _0 s1 s  S; b- s# b% U
  663.   def start6 B# ?  z" w8 y( O/ _8 G" {$ {
  664.     sion_mouse_start4 m  A7 y, ?& A) x
  665.     deactivate& x; H- X9 ^  n0 }
  666.     extra_start1 _% @# h. }# q8 S  g
  667.   end
    2 _  v3 X% G/ H0 e9 Z1 Q% m6 ]
  668.   #--------------------------------------------------------------------------
    / ~* A/ s$ {" P% K. E
  669.   # ● 创建新的数值输入窗口
    $ D: x1 c* _6 v* r
  670.   #--------------------------------------------------------------------------
      {: E/ C8 h+ `( I; |( x7 x
  671.   def create_extra_window
    4 g$ _( o4 c/ a8 x$ D
  672.     @extra_window = Window_NumberInput_Ex.new& m( |# m7 w& S/ s
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    2 W! w3 t3 R, u  q  @; Z
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }6 v/ h7 w& R- d
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    + K% d9 y7 s9 @3 D& j6 c
  676.     @extra_window.close_proc   = Proc.new { close }" q  U- d  w$ D# d5 Q% k  w
  677.     @extra_window.refresh_proc = Proc.new { refresh }0 L* n; n' g; l4 i
  678.   end
    / h4 R5 K. \. U. o
  679.   #--------------------------------------------------------------------------
    / D" l8 i  M7 Z$ ~. K
  680.   # ● 激活新窗口, @% \7 ]8 \) T
  681.   #--------------------------------------------------------------------------
    # r3 p; H- B) R6 I
  682.   def extra_start( X9 }8 j, A! q" e* ~) K
  683.     case $game_message.position
    0 C1 Z5 V3 g; l( i/ P
  684.       when 0; @extra_window.y = y + height + 4; e; Z% Q8 z( Y# M4 F  e9 |
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 87 }. a# {" l* b6 L2 `1 y8 G7 C# }
  686.       when 2; @extra_window.y = y - @extra_window.height - 4. [- t" J# M5 o
  687.       else  ; @extra_window.y = 8
    + P( p( S# k( T$ H' x4 b% N3 M
  688.     end+ f2 p3 R9 i9 F
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    5 X8 o3 p% w5 z: P6 d, D/ N/ G
  690.     @extra_window.digits_max  = @digits_max
    0 B1 ^3 t6 b9 Z2 @% M
  691.     @extra_window.number      = @number: J& l1 f% Z- n: F2 C+ Y# a
  692.     @extra_window.open( U0 `0 a( L7 \
  693.     @extra_window.activate
    : n0 n  g: c6 m
  694.   end
    ) S- P9 N/ I1 R1 t: E! s! a  |
  695.   #--------------------------------------------------------------------------
    ) j. N, S( F, O: X- W
  696.   # ● 更新7 M+ {- a. V" ]
  697.   #--------------------------------------------------------------------------
    ' A  _$ Y" P) X( }6 b( l1 M
  698.   def update
    1 C. U1 Q' K, k4 @" k5 i
  699.     super, |* Q: G" U; n
  700.     @extra_window.update
    - ]9 Y5 D* u! E1 b+ F7 A4 j
  701.     update_cursor
    , T9 L' A  C0 ?. w2 D
  702.   end
    & X4 Z9 O* x' L8 C# P( b
  703.   #--------------------------------------------------------------------------0 [5 J( s& W3 e
  704.   # ● 关闭窗口1 B* P; P; C; F' M0 X
  705.   #--------------------------------------------------------------------------: V9 d) X  P  E: V4 C! n
  706.   def close# N0 C' x( Y( g& t* D' U
  707.     super
    3 g8 M" x9 J- s1 {# y
  708.     @extra_window.close
    4 L+ A1 l8 [, K# L; q0 \
  709.     @extra_window.deactivate' D9 J1 n' }) X9 r4 d4 l& @
  710.   end
    * _& T' m! t3 N
  711. end
      k) S! g% Y1 C8 \% @, x

  712. / H4 C6 |( n/ }  ]: g
  713. #==============================================================================. @8 V0 P! M& N5 {, ]$ p( }" N; [5 U: j1 d
  714. # ■ Window_NumberInput_Ex
    9 n- A, n% \6 L( W& l7 }# f
  715. #------------------------------------------------------------------------------6 L1 J/ b" }( j6 E  t" o* \0 h' W
  716. #  新的数值输入窗口(NewClass)
    : [3 I4 B* z( g) Q* `
  717. #==============================================================================
    7 |( e- m- A3 o3 E; D0 I+ U
  718. class Window_NumberInput_Ex  Window_Selectable
    & j) `' b+ S& {
  719.   #--------------------------------------------------------------------------- A0 M8 t2 j; W: n! k& y
  720.   # ● 定义实例变量
    ) [; H) P7 F" b. D. W2 |
  721.   #--------------------------------------------------------------------------# l6 L$ C0 {' ?% ~" Y1 x9 G
  722.   attr_accessor number_proc/ p0 i' P, v* s( ]$ n$ Y' @. `
  723.   attr_accessor index_proc# R( c9 R1 B$ y
  724.   attr_accessor close_proc
    3 ~) g: B, G3 y4 c& ^8 q8 @; |; w
  725.   attr_accessor refresh_proc5 J9 ^8 n; V6 I
  726.   attr_accessor number
    6 N  ?% E6 E+ V( O$ I8 q! Y0 ~
  727.   attr_accessor digits_max. X: L( D' e. v+ ~. O" q- d
  728.   attr_accessor variable_id
    , |$ B" U8 x4 `6 b. M: G0 t
  729.   #--------------------------------------------------------------------------
    ( [0 Z4 s( D, C
  730.   # ● 数字表% Y, r: {( b& H0 S8 t
  731.   #--------------------------------------------------------------------------
    1 s- Q/ g- d1 P* e0 k
  732.   TABLE = [  7,  8,  9," |- I. L) b' t
  733.              4,  5,  6,
    : {, W, _( W- y1 _! h2 V, A; N
  734.              1,  2,  3,
      N9 Q! p3 L* X* N0 [; n; _
  735.             '←',0,'确定',]
    & N: ]9 q3 S0 Q( \# H. k
  736.   #--------------------------------------------------------------------------
    5 y' f7 o/ F7 P, m1 e! X& `- L: m
  737.   # ● 初始化对象
    & j7 d4 A2 p5 R7 X! g- H1 U5 D
  738.   #--------------------------------------------------------------------------
      J0 I) J8 E6 _& W8 a; ^. z
  739.   def initialize% F3 d5 ]+ L+ P' z1 |. _/ \4 X
  740.     super(0, 0, 120, fitting_height(4)): x6 G; B& k1 E: m  _5 q6 m- N* y
  741.     self.openness = 0
    ' k1 L, p8 Z  P2 i! Q, G! Y* X
  742.     @index = 0; {$ O: q! [- N6 X7 X6 o
  743.     @number = 09 h" f% \, h: o8 _3 P
  744.     @old_window_index = 0
    2 o* L& y$ F8 B0 ]9 V1 c& {
  745.     @digits_max = 0
    6 [7 S! G8 W. \' B
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
      t2 \- w0 a4 H4 y0 i) f; e
  747.   end
    ( i- z) H, O9 d5 O% b% l$ i
  748.   #--------------------------------------------------------------------------
    # R) c! G1 j2 |% i
  749.   # ● 获取项目的绘制矩形2 T* K) e: k6 _& |( b
  750.   #--------------------------------------------------------------------------
    + ^+ ~. L1 X2 D" X
  751.   def item_rect(index)
    7 H) {0 w+ \( L; x
  752.     rect = Rect.new
    / r% J; w( c5 d; h0 F
  753.     rect.x = index % 3  32
    3 `, O' D- z. g+ x
  754.     rect.y = index  3  line_height
    . J* _2 ?0 I" K
  755.     rect.width = 32
    5 J  M$ f* i5 m0 k! O* |: S4 v
  756.     rect.height = line_height
    " e, D" q) M3 f
  757.     return rect
    $ T- Z( P5 z' L4 q/ L6 y! W
  758.   end
    - n0 H1 f) ?: P  t3 k( N
  759.   #--------------------------------------------------------------------------
    2 b4 Q) Z$ O& L( L( l4 e
  760.   # ● 将光标设置到鼠标所在的位置" P; t5 F) P! o' T1 k' H
  761.   #--------------------------------------------------------------------------* c8 s2 s6 w/ e% q& i
  762.   def set_cursor& w9 N8 O& u" J" @+ k) v
  763.     mouse_row, mouse_col = mouse_window_area, k- @  F* b# ^- |" w# E5 c7 D( D
  764.     if mouse_row = 0 && mouse_col = 0
    5 ^$ H/ s5 P0 y4 U7 m
  765.       new_index = mouse_row  3 + mouse_col
    # a4 D3 m: s! q
  766.       select(new_index) if new_index = 11
    * U" k3 W" |+ [# Q, H5 A- w
  767.     end8 a( @. s8 w; I' F, n
  768.   end9 I7 s" b- u& O3 m
  769.   #--------------------------------------------------------------------------
    % b3 _& B* a' h  U, f
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    5 R! Z( K2 Q. G# |2 B$ j# u# U( ?2 G
  771.   #--------------------------------------------------------------------------
    * b7 m- t; S% q) ~% v$ C. w
  772.   def mouse_window_area
    : \7 n8 E) W! o' Q1 G7 ^
  773.     if viewport.nil1 W- l3 D* C% j0 z
  774.       vp_x, vp_y = 0, 0
    2 @+ T: J, P, M: K" t; x, e8 M4 W. A
  775.     else. w, o' z6 ^" f* b* O2 N: q
  776.       vp_x = viewport.rect.x - viewport.ox
    & z) A/ v9 ~6 K9 H6 E  U5 J9 U
  777.       vp_y = viewport.rect.y - viewport.oy) {/ f% M& ]" d. N' t" G' a
  778.     end
    0 ]0 i# u4 ?5 |5 Z& D0 x
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y+ E8 s  _  b: Z1 d
  780.     item_x1 = vp_x + x + standard_padding & h. t: @/ g6 @8 R
  781.     item_y1 = vp_y + y + standard_padding- s$ |8 i. v9 z6 q
  782.     item_x2 = vp_x + x - standard_padding + width
    ) ^# x/ N4 e0 g
  783.     item_y2 = vp_y + y - standard_padding + height. ?- a! s/ o9 D- Y- ^
  784.     if mouse_x  item_x1
    : M% |. ?5 {1 U1 c
  785.       mouse_col = -1
    8 r: x, b& n9 S& r, n
  786.     elsif mouse_x  item_x2
    ! b/ j4 r, d% h6 \, X) W8 `! i" x
  787.       mouse_col = -2! g8 y+ L0 r, O! y$ L+ @5 m+ {  Y
  788.     else
    % |  j1 }( Q9 X) E2 w' O8 K5 n
  789.       mouse_col = (mouse_x - item_x1)  32
    * c% L/ e: q# b/ o# j
  790.     end+ I( ]/ k! K. U5 l" ~0 m' |
  791.     if mouse_y  item_y1! ~/ C# l- E3 k3 B
  792.       mouse_row = -1$ a/ G" F! ^) F
  793.     elsif mouse_y  item_y2
    $ Z" m2 ]- J" Z* k
  794.       mouse_row = -2
    ( P) V6 G$ n- t. W" l- A, {
  795.     else
    , Z, L# f$ V. i% r- B( e* t
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)8 r# l7 R8 q; G4 B% G& O% N
  797.     end. p2 J! W$ b( N6 j' f
  798.     return mouse_row, mouse_col
    2 G! [0 \0 w! J( v
  799.   end; E. L. W% K- c3 D
  800.   #--------------------------------------------------------------------------
    % J- J! q0 y! @$ _4 Z0 f% b; l# b
  801.   # ● 获取文字
    % L- G) \# k$ \! L( U3 V* w
  802.   #--------------------------------------------------------------------------
    1 Y4 v( U( j) |, J+ Y* O
  803.   def get_number
    ( a, k1 {" }9 g  s/ ?3 S2 M% ]2 [
  804.     return false if @index == 9  @index == 11
    ) C* O0 u! k3 j- [
  805.     return TABLE[@index]4 ^: x/ O) [/ H3 j; `
  806.   end
    $ e( ^. @+ k, S( K: m/ H% y1 M+ N
  807.   #--------------------------------------------------------------------------
    - d# l, N' u7 U, G$ c. q& B$ k
  808.   # ● 判定光标位置是否在“退格”上7 }1 _: S2 @/ q* V  e9 x! m
  809.   #--------------------------------------------------------------------------8 t; a5 _& k6 C
  810.   def is_delete
    ' F1 m7 q' h8 _' b8 g3 C9 H+ @
  811.     @index == 9
    6 W. [7 ~1 J4 t) x6 F
  812.   end# m8 l) c8 e; C# c* Y; R5 O
  813.   #--------------------------------------------------------------------------
    3 {3 X4 v% a! |- C8 E
  814.   # ● 判定光标位置是否在“确定”上
    # G. W0 t! G, ~" P* s( i6 D
  815.   #--------------------------------------------------------------------------. ~8 p# E/ f0 C& h9 Z' G5 `: t
  816.   def is_ok
      ]* T3 k* N. `. Q6 v& D
  817.     @index == 11
    ) }- Z, W  \3 t& B. m3 l7 d. R
  818.   end
    9 |+ _6 s! F( F5 H  {/ J" X2 L
  819.   #--------------------------------------------------------------------------; q' F, p# O- I2 {
  820.   # ● 更新光标( _8 k6 z  `- a$ t6 ?0 H( T5 }
  821.   #--------------------------------------------------------------------------6 s! N9 M- y4 x& Q9 P, w. }- V0 L
  822.   def update_cursor) v3 s6 [/ Q# C! j& @
  823.     cursor_rect.set(item_rect(@index))$ M3 g3 s7 {& X+ }5 |
  824.   end
    . n. S/ e  n! K* K9 }5 D
  825.   #--------------------------------------------------------------------------
    2 u5 b4 L; V2 @) |+ V
  826.   # ● 判定光标是否可以移动
    2 J* H' E+ q7 ]9 ~9 @% W; V
  827.   #--------------------------------------------------------------------------& G: y1 p# W6 c4 @3 u
  828.   def cursor_movable  h& Y+ v8 \/ g8 X  h* V- y3 q, Z
  829.     active
    7 |- P$ O( K8 U4 a) T
  830.   end
    % \/ z. A: A  `- P$ C! ^! o
  831.   #--------------------------------------------------------------------------; P: ]; N+ ^, m- R  R1 {8 |! L
  832.   # ● 光标向下移动
    - }: Y2 p2 |* ^% T* k$ k
  833.   #     wrap  允许循环
    6 R; m7 ]. ~7 Y* F! l
  834.   #--------------------------------------------------------------------------( t9 o1 O3 \5 }0 _% N/ U, ?
  835.   def cursor_down(wrap)0 V8 n. ]5 J- T0 R7 D; z
  836.     if @index  9 or wrap1 g. [, W" g: c+ ^( u( F- M6 V# ~
  837.       @index = (index + 3) % 122 @: @- }9 `2 ]! Y2 O$ B5 p# d
  838.     end" Z* B4 G! m( G
  839.   end
    5 p% X% ?( T% W- n
  840.   #--------------------------------------------------------------------------
    * p9 _! n$ t' a4 p) N, _6 ?: |
  841.   # ● 光标向上移动) j& d# I: E( _& M# n4 L
  842.   #     wrap  允许循环9 ]9 Z% D* {% `% K. h) w( V
  843.   #--------------------------------------------------------------------------
    ' z8 t8 P2 X8 ^( [7 B: x8 x0 f! [
  844.   def cursor_up(wrap)7 @$ L! |" r4 l* W' Y
  845.     if @index = 3 or wrap
    ) f/ |( A( u/ O& V$ X' t* z( ~$ `
  846.       @index = (index + 9) % 12
    2 N5 Y# W  U6 V! K5 z. t
  847.     end' c% ~3 q( m1 m, _! A6 z0 ]
  848.   end8 H$ e  U. h  V# Y/ ]1 x8 _
  849.   #--------------------------------------------------------------------------
    8 K% }4 s& b' M, W
  850.   # ● 光标向右移动- d5 ~# C6 f) t- e, z/ S5 Z
  851.   #     wrap  允许循环8 a+ K0 B' O( t: a  i
  852.   #--------------------------------------------------------------------------
    3 c3 C7 `; h% p4 n8 ]1 ]& S. ~/ C
  853.   def cursor_right(wrap)# W& n- m& q2 A% K) L
  854.     if @index % 3  2; t) d) p% M$ y4 L, C/ [/ i3 T
  855.       @index += 1
    7 |! P& x9 M7 [, Z7 u
  856.     elsif wrap
    2 S5 x* S  [# R: J9 U+ x) N8 b* [( F
  857.       @index -= 2" R. Z2 Q' L6 ?& ~8 w7 Y5 i1 [
  858.     end
    ! c1 M1 j' o1 q: M3 m+ B/ b( F
  859.   end7 c. G4 K2 _; W. s! x1 N6 A
  860.   #--------------------------------------------------------------------------
    5 p* B$ _& h) u. z4 h
  861.   # ● 光标向左移动- {9 O/ g! {/ z- s" ]5 A+ z8 K
  862.   #     wrap  允许循环
    . }& x$ o9 ]) B
  863.   #--------------------------------------------------------------------------, {6 ~, a! z# k, B, n
  864.   def cursor_left(wrap). Y& L! w4 Y2 h  R8 a8 n+ ~
  865.     if @index % 3  0) J) V7 m8 a6 g0 r' ?3 l6 T3 i
  866.       @index -= 1
    ( E* Z( R+ }) q3 Z+ j# d8 S% E; ~' g- H
  867.     elsif wrap
    + X1 w1 T+ _4 d8 C$ q
  868.       @index += 2
    ) d9 D  O; j( A3 j
  869.     end3 g6 r8 \3 H& `4 D. l! L
  870.   end
    5 [$ r! K4 J$ V1 I/ N! v" y$ e# d
  871.   #--------------------------------------------------------------------------
    9 e8 y- ]9 j$ S& q
  872.   # ● 处理光标的移动* q# j& P4 c3 Z# p
  873.   #--------------------------------------------------------------------------
    ; C1 P- J- S0 ?7 B7 {
  874.   def process_cursor_move+ L! j' _! Y0 n5 l0 a4 {" s' ]
  875.     super. V8 a8 P) y  ]5 [' R. x' G
  876.     update_cursor, S, O4 k% e* }
  877.   end& j, t2 }$ E0 {% U  L
  878.   #--------------------------------------------------------------------------+ S: J7 u( [* L3 ^9 `
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    ) z4 C! G) B/ ], ]& j! G
  880.   #--------------------------------------------------------------------------( L5 h; [! g0 t
  881.   def process_handling
    ( s; y  b6 |/ C: I7 H- |
  882.     return unless open && active
    - g& U2 R- G+ k" m! ~
  883.     process_jump if Input.trigger(A)
    , x2 Q6 ]& l; S2 Q+ I
  884.     process_back if Input.repeat(B)! a& E0 v% z- m
  885.     process_ok   if Input.trigger(C)% R$ f3 {. H2 P/ S4 W
  886.   end
    2 l$ x1 [/ @: m9 X& C
  887.   #--------------------------------------------------------------------------5 ], e* X( A. h8 U5 I! _2 J5 ?! ~
  888.   # ● 跳转“确定”
    # ]# _9 z# }) h; G) m) f3 b
  889.   #--------------------------------------------------------------------------! o( v( w) Y( ~7 r, B3 V6 b6 u6 s
  890.   def process_jump
    % X, T  y/ W0 h3 u% @
  891.     if @index != 11
    1 ?1 e# j3 L- r5 W( x1 `
  892.       @index = 11
    . ]' N+ h# i9 n0 U( O3 ]4 m0 u
  893.       Sound.play_cursor9 n; R8 A- Z' \0 ?/ A8 |
  894.     end: q3 J. e/ E+ e, U
  895.   end
    2 K& w! @3 @( Z& _7 ?* E
  896.   #--------------------------------------------------------------------------/ ]7 h+ ?  S9 j- f1 E. r3 O
  897.   # ● 后退一个字符
    ( _+ Q' M( }/ Q  v' d' f  i: r
  898.   #--------------------------------------------------------------------------4 i0 ?# v# v" p4 u5 z
  899.   def process_back+ d" X$ j6 f' e' {6 @, x! F
  900.     Sound.play_cancel$ a, Z. G2 e# A3 a- m5 d. |) X
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    & {: O" ^  r9 K
  902.     n = (@number  place) % 10
    , T3 F+ v$ N5 _$ s6 e* a
  903.     @number -= n  place7 O, W) O2 `" K( P7 D8 ?: Z9 c9 c
  904.     @number_proc.call(@number)9 H3 q+ S8 c$ c7 k, N
  905.     @old_window_index -= 1 if @old_window_index  0, q! J3 D- N: A( l& [
  906.     @index_proc.call(@old_window_index)
    " B& k" I. H/ v/ ?! S
  907.     @refresh_proc.call
    0 }6 P9 O8 ], M
  908.   end& p$ N" R1 J( p* M
  909.   #--------------------------------------------------------------------------
    / d5 y" B  K: z( z
  910.   # ● 按下确定键时的处理( c" j) k. r: V1 a0 E) @/ w
  911.   #--------------------------------------------------------------------------
    , C! @- ]! S1 p; [- [& `
  912.   def process_ok
    # c2 l* h1 S3 x5 k4 @
  913.     if get_number
    $ M2 R! R. x3 s1 m
  914.       Sound.play_cursor
    % k* }) U0 v/ t) h) Z, N5 ^" H
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    " ]  Q8 E# a* \9 `+ q9 g4 }
  916.       n = get_number - (@number  place) % 10. p1 {" v. C" S" g
  917.       @number += n  place( V4 _# b9 D. d$ S) s9 w# a  v
  918.       @number_proc.call(@number): O+ A3 u4 [9 \5 e0 l9 R
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1  M, y2 O& V* \9 A5 |3 U
  920.       @index_proc.call(@old_window_index)
      R) h: k% s' M4 @; w0 Y5 K6 t
  921.       @refresh_proc.call$ P7 U4 [9 o5 C; f7 V* l1 T
  922.     elsif is_delete4 w7 T3 q  N# M
  923.       process_back
    0 E2 F+ [( i. m8 R3 A
  924.     elsif is_ok$ _+ k2 v& \# a" W
  925.       on_input_ok
    6 F+ p5 W" f* N, ^' D
  926.     end! S9 c: A! j' j8 J" j
  927.   end
    5 s) q; ^7 H, W: A8 }
  928.   #--------------------------------------------------------------------------) S$ ?, m9 ^# v! _, U8 U
  929.   # ● 确定
    9 z% h! Q: B) u% r0 X
  930.   #--------------------------------------------------------------------------# [. ]8 M0 E5 y- s# v
  931.   def on_input_ok; t' q, \7 i  \; m) ^. u
  932.     @index = 0
    # j5 B8 b( `- w: o* i5 A
  933.     @old_window_index = 0. Q- [4 b6 O0 [, p/ M
  934.     $game_variables[@variable_id] = @number! d1 A& s% K- Z
  935.     Sound.play_ok# t( I  k+ D- }5 K6 W5 q( G
  936.     @close_proc.call5 H4 T) @2 l; \2 s2 e, f
  937.   end) }# K" z* x% O1 I& n: \$ ^0 h* l
  938.   #--------------------------------------------------------------------------& A7 j* M, O3 U- Z- n
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置1 L! @/ L5 ]; H. y
  940.   #--------------------------------------------------------------------------
    1 i2 H4 J. [$ T" |
  941.   def set_mouse_pos. N9 y( P7 k& p$ w; f* t
  942.     if viewport.nil # necessary!8 @' z* Z' R1 l& c1 q
  943.       vp_x, vp_y = 0, 09 ^! {" ~' m# e  c
  944.     else! F2 b, `) L7 Q* O. }% s
  945.       vp_x = viewport.rect.x - viewport.ox5 [! A% z1 r1 _. a- q: s$ l
  946.       vp_y = viewport.rect.y - viewport.oy
    ! d5 O* s& P& `3 T2 c; t. a6 Z3 I5 N
  947.     end
    ' b6 h4 h# J* u: ?% H4 M
  948.     item_x1 = vp_x + x + standard_padding $ u4 w. s: M7 l
  949.     item_y1 = vp_y + y + standard_padding
    + G9 x  ^$ b5 R" u( Q; r$ z$ E2 L
  950.     get_index = @index  0  0  @index
    - {' l: E: L1 P! I
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    + C8 d2 ^$ D- y
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    ( m0 q0 T" {8 S- Z
  953.     Mouse.set_mouse_pos(new_x, new_y)
    9 U$ {" m0 K) t! F4 V
  954.   end; K/ l* }2 m& ^3 r- O0 |. r  `
  955. end
    , h& l0 T. p5 o' E, M7 C/ }/ E7 @

  956. 1 ?; n& q' R* I9 C* P4 v# M( W
  957. #==============================================================================
    ; ?- a5 g/ `% f  m- M$ u/ s8 D: N
  958. # ■ Window_Message
    # T) ~3 F9 w+ Z
  959. #------------------------------------------------------------------------------
    % |/ Y: R% P$ o- o: ~0 X6 M1 _
  960. #  显示文字信息的窗口。
    : Q# C4 u% N0 x. s2 V9 F) [
  961. #==============================================================================' j- }, e& a) ~
  962. class Window_Message  Window_Base
    " [. d0 y4 J; P1 m2 ^
  963.   #--------------------------------------------------------------------------9 A$ d$ A+ i" S$ D# B
  964.   # ● 处理数值的输入(覆盖原方法)
    2 F3 ]. v, c- [: P, l
  965.   #--------------------------------------------------------------------------8 j- d. E+ d% g6 _2 U3 }" B, k  z
  966.   def input_number
    ! c) o# P6 P* R$ s& X& P. y5 p
  967.     @number_window.start
    ( u* l/ b, O( G9 o$ X
  968.     Fiber.yield while @number_window.extra_window.active$ A4 [) P! f: ?  C7 R
  969.   end
    * q0 j1 \) F* {/ ~
  970. end# B" _; x8 k2 o: ~' D; i
  971.   }" B8 E$ G/ K+ `: O$ N5 G! r
  972. #==============================================================================; c& b* s, o( `
  973. # ■ Window_PartyCommand1 n4 N7 Y" a3 x$ }! g# ^
  974. #------------------------------------------------------------------------------
    ! A: ^9 i1 F; u6 t; Z8 t: F# E
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    4 i3 d2 H5 u- ^  Z  ^. T# ~+ U2 r
  976. #==============================================================================4 ~) |0 C( D3 J5 L# J
  977. class Window_PartyCommand  Window_Command. k) d2 S* B1 X- o5 g
  978.   #--------------------------------------------------------------------------
    ! c, {$ n; r2 H, D; b5 W
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置( a) J- Z2 O& {0 M% H9 g" P
  980.   #--------------------------------------------------------------------------
    # P) ]  V  O& ^7 |  {0 a
  981.   def set_mouse_pos7 d3 p' G1 U: T  D& s$ q" O
  982.     if viewport.nil
    ! T4 [4 H& [' x8 u5 x  ]4 v
  983.       vp_x, vp_y = 0, 0
    / F8 f3 B$ D6 }0 A* ^
  984.     else4 o4 R2 o: {+ K2 J5 T
  985.       #vp_x = viewport.rect.x - viewport.ox
    . a& e6 s0 ]( K" q
  986.       vp_y = viewport.rect.y - viewport.oy7 a$ o; ^- D% J
  987.     end) ], X3 x  O8 Z7 e& F; C+ S
  988.     item_x1 = x + standard_padding
    $ ]1 ?3 M" j% ]# u6 ~( J# _
  989.     item_y1 = vp_y + y + standard_padding
    7 ?, W' N  P6 u) d) J
  990.     get_index = @index  0  0  @index
    ; J2 Q8 J) w' g# C: x* p
  991.     row = get_index  col_max - top_row
      j$ e* ]" b+ M7 U
  992.     col = get_index % col_max' O& W5 g9 {8 [: S
  993.     new_x = item_x1 + item_width  (col + 0.5)& f. q3 f) S2 |
  994.     new_y = item_y1 + item_height  (row + 0.5)6 k* i. N# y1 u2 f% t* v0 [
  995.     Mouse.set_mouse_pos(new_x, new_y)* M* O0 E" O3 q7 i' J
  996.   end+ s* ?3 Y, R- l9 g
  997. end9 m" z: L; }& j

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

  2225. . ~; c! u6 [. x5 M# ^
  2226. #==============================================================================* d2 V+ Y& I2 b' K" I
  2227. # ■ Spriteset_Map5 V( d. t4 [3 V9 Y) j
  2228. #------------------------------------------------------------------------------
    ! v' m5 a. r- ~; H4 _
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。$ g$ s1 N  i2 r7 N; z; Q3 W
  2230. #==============================================================================/ Y; d1 |- U5 [& p7 V/ H
  2231. class Spriteset_Map
    / m1 U7 g; e; `4 e
  2232.   #--------------------------------------------------------------------------
    3 o. j% i9 `7 r4 ^6 j( n
  2233.   # ● 生成路径点精灵( L- ~0 `( o! }- O) U/ b
  2234.   #--------------------------------------------------------------------------8 i. p. Y' K; F' u, J
  2235.   alias sion_mouse_create_characters create_characters
    ! w5 i! }8 u- m! g
  2236.   def create_characters
    1 n' M8 t7 l% R
  2237.     sion_mouse_create_characters
    ) L9 M+ N* e/ B  C
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))6 Z) m9 f1 R/ }! d: |& x; h0 u
  2239.   end5 z$ N) I0 H1 H7 t
  2240. end) m! M$ [6 L- @0 o3 F) u
  2241. + U& l" ^5 F3 I+ w$ U! N0 _8 e
  2242. #==============================================================================: {+ p: @; G% }
  2243. # ■ Scene_Map. ^. o2 B) o5 W+ f( g& U
  2244. #------------------------------------------------------------------------------2 }% g, u; j( N; ]9 ]( ?: ~2 v
  2245. #  地图画面
    ! n3 e. a1 M/ S8 P' |
  2246. #==============================================================================7 q* n3 o7 h$ S
  2247. class Scene_Map  Scene_Base. e0 m8 n$ n6 F9 Q& S
  2248.   #--------------------------------------------------------------------------
    4 k5 R8 D, q7 o9 E
  2249.   # ● 画面更新$ J# k2 H1 l& b# U2 p
  2250.   #--------------------------------------------------------------------------
    9 T3 M# X# V- J$ x2 @2 l$ s* o
  2251.   alias sion_mouse_update_scene update_scene
    3 ~1 k& d. X7 e  [2 T# o
  2252.   def update_scene
    ) B% y" j* h+ B" N( T: H
  2253.     sion_mouse_update_scene
    3 I8 A2 q% H5 `, |* M6 c* Z
  2254.     update_mouse_action unless scene_changing8 z7 B2 s. v5 h. u) c* A/ s
  2255.   end4 C, F1 ~5 t: N7 E7 Y
  2256.   #--------------------------------------------------------------------------( f( r6 `6 b9 [: v
  2257.   # ● 场所移动前的处理. |3 `1 k3 A' P- f' z0 G
  2258.   #--------------------------------------------------------------------------
    ) w' b7 h. a7 a# g; }
  2259.   alias sion_mouse_pre_transfer pre_transfer
    " D: t$ f7 i3 p4 |& z& t6 r, S
  2260.   def pre_transfer
    : g# ?$ \* h" S% k2 d2 c
  2261.     $game_player.reset_move_path; F7 z* e; \! @2 g$ ~4 M: X* j
  2262.     sion_mouse_pre_transfer
    $ y+ i& h4 [$ e( W6 ~
  2263.   end5 ^4 }0 ^% ?3 j3 e
  2264.   #--------------------------------------------------------------------------2 z6 ~& ~. `8 D- T0 w1 x
  2265.   # ● 监听鼠标左键的按下
    " c5 T, l' c6 J$ a; x" h2 `6 j+ X
  2266.   #--------------------------------------------------------------------------
    9 O: ?- s1 ?& p9 I) n
  2267.   def update_mouse_action/ o8 |" _9 ?% b  Q0 m
  2268.     $game_player.left_button_action if Mouse.press(0x01)7 i2 O+ n( a' d( u2 `% J" A
  2269.   end/ f( i# `4 f% a3 b
  2270. end7 K6 o  y. I' ^8 J
  2271. * h0 w. o3 n  k
  2272. #==============================================================================' P: o4 F# _3 `) t# O
  2273. # ■ Scene_File7 F9 k3 I" w8 {2 q3 V; k
  2274. #------------------------------------------------------------------------------
      G. _- s9 m( W" n7 c9 w! S/ t. H
  2275. #  存档画面和读档画面共同的父类
    ( y' B' [8 M) [- ]9 J' n1 p5 S) w
  2276. #==============================================================================
    2 |3 H8 \0 u  q. f& J/ L
  2277. class Scene_File  Scene_MenuBase
    ( [: c* `  ?2 i7 L+ e; s
  2278.   #--------------------------------------------------------------------------
    - e0 m1 ~. m( v- C8 R& B
  2279.   # ● 开始处理
    9 J# \1 L& R- G% z' M" h
  2280.   #--------------------------------------------------------------------------# ^. `4 Y; P* _) {5 ?4 K
  2281.   alias sion_mouse_start start
    2 a1 o1 U9 Y2 v  ?- B
  2282.   def start' c  g( x, c  G5 [
  2283.     sion_mouse_start
    2 I. Y: `1 S- _2 b1 s
  2284.     @move_state = 0
    0 w' E1 F; V2 _+ d4 A( r" p& T
  2285.     set_mouse_pos5 \! P+ f  y1 M7 A3 i5 Y
  2286.   end
    7 ^6 t6 P& K' I# ~; k( [5 G
  2287.   #--------------------------------------------------------------------------
    % [4 U! V) u' R6 K- t
  2288.   # ● 更新画面; X% h1 h8 H6 Y
  2289.   #--------------------------------------------------------------------------: U$ F* A, _& e; g4 n$ c
  2290.   alias sion_mouse_update update  q+ J; N: D  J2 F6 u
  2291.   def update
    - t* V' E0 l8 D
  2292.     sion_mouse_update$ Y+ X/ y$ C, d/ |) z; W" Y
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos, O" `% w1 m! q7 N$ h+ J5 o
  2294.   end! J* I( X# F5 f% J+ V
  2295.   #--------------------------------------------------------------------------
    & F. Y! I* ^5 X! F4 P7 u
  2296.   # ● 更新光标; N9 S8 E7 o- F, R8 T& |
  2297.   #--------------------------------------------------------------------------9 F6 P; l& Z2 v+ t4 E2 H
  2298.   def set_cursor
    6 j' U) |- o, M+ n) n
  2299.     @move_state += 1
    : ^/ i7 f' l" }4 o, k/ i
  2300.     last_index = @index
    $ e, C0 L$ {6 n# C
  2301.     if mouse_which_window == -2/ d+ y% ^* A1 Q9 D/ g6 s1 N
  2302.       if (@move_state - 1) % 6 == 05 x% C: f# U% B! Q* x# F
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    $ y; T5 x9 G0 k/ L9 L& U; q% K  R9 s* U
  2304.       end
    $ Q, C6 L) K6 [
  2305.     elsif mouse_which_window == -1' t5 M2 N2 u0 G; ]% C6 I( K
  2306.       if (@move_state - 1) % 6 == 0
    7 R7 {& E+ e" R2 l! ~' y
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0" |: l  S$ f) {; m
  2308.       end
    1 W+ h* W+ ], J7 B) x8 \
  2309.     else
    9 U( V3 f- L" [/ u, I3 N- S
  2310.       @move_state = 0
    - T0 W3 f+ y6 {! U, f
  2311.       @index = top_index + mouse_which_window; M" r$ }. C) A
  2312.     end" e( G5 X. l0 o/ k; X
  2313.     ensure_cursor_visible, L/ B* S3 L; D; D$ I3 S" e' u4 |. |
  2314.     if @index != last_index
    ! N8 b" K  R" `1 ?# k  u
  2315.       @savefile_windows[last_index].selected = false
    6 ~: j7 o6 j  N% R$ [
  2316.       @savefile_windows[@index].selected = true/ q* T1 |, t- E( W
  2317.     end
    0 D1 n. X7 P" z3 n* [, _# v
  2318.   end
    7 x5 d/ z! D- H: [' m
  2319.   #--------------------------------------------------------------------------
      n# s, @( Y: P! u( K
  2320.   # ● 判断鼠标位于哪个窗口" h- O3 y2 J8 Z3 B" B
  2321.   #--------------------------------------------------------------------------
    , U) z: _3 N. ~1 v, g. n9 j
  2322.   def mouse_which_window8 q' `3 Y1 M0 }" x; _) {: \
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    / h8 n* @* L% w, m  k
  2324.     if mouse_y  @help_window.height + 148 l$ h' [! y4 b0 R' s, ~. ?
  2325.       mouse_row = -1
    % V0 W& R6 [0 E  C" o
  2326.     elsif mouse_y  Graphics.height - 14! S4 Y' G% K4 |  [5 g$ n
  2327.       mouse_row = -2
    # T! V9 a2 q, H+ x* @& p
  2328.     else
    2 y6 _! ^, O1 [
  2329.       mouse_row = 4  (mouse_y - @help_window.height) $ u( q3 a$ I/ n; ~+ z
  2330.         (Graphics.height - @help_window.height)
    + J0 f" i8 ~8 ?, p$ ]
  2331.     end
    9 _$ H0 @7 [8 X/ i
  2332.     return mouse_row
    ) U3 c) g( {8 b! a# n8 R+ ~2 {, ^! A
  2333.   end
    . Z2 L9 Z( _) d+ x3 Q
  2334.   #--------------------------------------------------------------------------
    : r+ U" j6 l( P, Q7 P6 s" v. D
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置, v  \( u  ?# U5 }
  2336.   #--------------------------------------------------------------------------
    0 G0 _- D0 N9 {
  2337.   def set_mouse_pos  d6 q# i$ S9 ^8 B( C& _$ [; N
  2338.     new_x = 40/ O0 d7 x  T; d7 [( ^
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24  R) w& S- `9 A, ]
  2340.     Mouse.set_mouse_pos(new_x, new_y)0 o/ [3 f& v* R8 H  O# p& U' |
  2341.   end
    ) v# N2 G% F% a( A$ q# f! I
  2342. end( U- W4 o5 w) a* t7 V5 |
  2343. 2 w% D& h" [& u" `. [8 `' `( k& L
  2344. #==============================================================================+ ~2 B$ |6 z9 V3 h" L# y9 D+ q
  2345. # ■ Game_Event
    # j; N9 U0 h2 Z+ I1 {
  2346. #------------------------------------------------------------------------------
    2 }$ T. r# Q+ Y9 \# v  L
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    . M# J# d. K) U( n( L( h& v
  2348. #   在 Game_Map 类的内部使用。
    ; B8 J+ v: C  {& K# r
  2349. #==============================================================================
    . w- P: s2 {# h0 i' B: {$ R
  2350. class Game_Event  Game_Character* g0 X5 r9 ]: W" T: D+ r
  2351.   #--------------------------------------------------------------------------
    ; O2 y- C" R9 m% Y& K
  2352.   # ● 事件启动! \# p( E, |* K7 f9 g" |
  2353.   #--------------------------------------------------------------------------
    ! D! i& a1 L2 m$ c) R
  2354.   alias sion_mouse_start start
    . D  l: |1 ?+ s& f# L! b
  2355.   def start( s; W& d1 A6 S( m' P2 |
  2356.     return if mouse_start && !Mouse.press(0x01)4 ?  y% y1 v1 s# b4 C  b
  2357.     sion_mouse_start
    9 D$ \- M3 n: E+ T
  2358.   end
    ; I/ V  U" z9 E& k9 Y
  2359.   #--------------------------------------------------------------------------1 u0 s( g- [/ X& t/ r6 t  P
  2360.   # ● 判断事件是否由鼠标启动& M. F$ w6 m( t8 Q7 c+ W
  2361.   #--------------------------------------------------------------------------
    3 k5 {  n4 e& d# Y7 C/ {6 X( o0 m& [
  2362.   def mouse_start: j) ]! R" n, L1 Q: S% Q% x
  2363.     return false if empty, D9 R2 c# w9 Q) l: U% Z: x2 V
  2364.     @list.each do index$ I+ W8 v0 d7 \0 m+ G$ j+ \: |7 v
  2365.       return true if (index.code == 108  index.code == 408) &&$ [9 }! F$ v  W7 ]
  2366.         index.parameters[0].include('鼠标启动')) v0 S' n3 G$ i
  2367.     end
    ( P! J% g8 t: a
  2368.     return false# I4 O- V; S8 w
  2369.   end* ]& h. p0 l8 [$ M7 c
  2370. end
    5 S* z" Q! ?& O1 X

  2371. 1 E9 [* q" v* N9 D  N6 s- K
  2372. ####泥煤的height1 G) r. c. J7 Y
  2373. # @height = height
    0 L' i) T7 u! g5 B

  2374. 7 S3 \7 m! Z" N
  2375. class Area_Response3 a9 A3 U' e3 R' n
  2376.   attr_accessor type
    & S& S" G; O' h) l. O9 T
  2377.   attr_reader ox
    4 Y, z; D  m$ f/ O
  2378.   attr_reader oy& F; }/ T! a( [
  2379.   attr_reader width
    , a9 `+ n0 q/ l2 r7 P7 F- _
  2380.   attr_reader height0 Q8 q) a$ i0 F% T# h
  2381.   attr_reader switch_id
    " }, V: a  i* X0 L
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    2 m8 `- y% y- `9 L7 Z1 E" j$ S0 `" q
  2383.     @type = type6 {( }0 m" \' H; b
  2384.     @ox = ox7 T) w& f; T# b
  2385.     @oy = oy9 O& p# H# B9 ^( l) B! O
  2386.     @width = width
    & g* Q5 Q# ^3 f- Q' w
  2387.     @height = height9 }2 O+ l3 c; ?! J. \: h
  2388.     @switch_id = switch_id
    $ Z$ {9 V' F! f0 P
  2389.   end
    , ~& I4 q1 F8 E/ V( v" Y
  2390. end
    8 p/ S$ k4 L/ C; Z3 [; @+ [
  2391. $ C3 q# q) b, O+ }( r; z
  2392. $area_responses = []
    ( l& t) }) M4 ?: I# s

  2393. 6 s, \7 S1 Z& v$ p- v; M/ }; v) i
  2394. class Scene_Map
    , D: x& S- M8 i% P
  2395.   alias update_mouse_2013421 update_mouse_action! M" i. Q# n- I5 |4 o) R+ l
  2396.   def update_mouse_action
    ( Z: z% u, z, b$ s5 \
  2397.     update_area_response
    * U% {) b) Z! O8 [& m& S
  2398.     update_mouse_2013421
    ( m% {1 R7 S; c& t: Q
  2399.   end
    7 h: P7 U5 ?% b0 O3 j  h) k
  2400.   def update_area_response+ f' n  b8 u# v. m7 h6 Q
  2401.     responses = $area_responses
    ! N+ n' {* w' T, J2 q$ b
  2402.     responses.each {response" |$ g- K! E, d* v7 Y$ e
  2403.       ox = response.ox
    - G9 H8 r& ]* K: b5 p( t; T
  2404.       oy = response.oy0 q) _1 V# f0 ?/ w' H' h! B
  2405.       width = response.width4 E: H* v5 O; S2 z& p
  2406.       height = response.height+ v/ ?, y5 z. B1 {- H! i
  2407.       switch_id = response.switch_id
    4 S# j0 y4 L( s* V
  2408.       case response.type
    2 A, \' e( G+ e# m
  2409.       when 0
    / T$ x( h$ U0 I
  2410.         if mouse_in_area(ox, oy, width, height)
    * Y8 c: W. c$ T" s
  2411.           $game_switches[switch_id] = true% p) ^# Z! n9 g, I) [$ t( R& X
  2412.           $area_responses.delete(response)1 ?2 i4 |' ?0 D% W
  2413.         end
    # N' M6 D, J/ ]2 u
  2414.       when 1  Q9 j/ u0 g" R: \
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    8 H+ P) V5 K# J" R% r
  2416.           $game_switches[switch_id] = true
    0 I- V6 Q- p6 z5 O
  2417.           $area_responses.delete(response)1 U! e: `6 }+ _9 ^
  2418.         end) h" Z8 W% T5 I+ J4 y
  2419.       when 20 U8 O3 Z/ v4 j& }! s9 j
  2420.         if mouse_in_area(ox, oy, width, height)
    8 f& d! J1 }5 C( x' p1 i
  2421.           $game_switches[switch_id] = true
    8 Y' s0 ~$ H  G) K; m1 `
  2422.         else& S2 M3 z3 k0 D; Q4 y9 A. G+ z. `
  2423.           $game_switches[switch_id] = false
    ( r% v& k1 M6 N# a
  2424.         end! o& B( o/ K4 J8 K0 e: M5 E8 g9 l
  2425.       when 3  |$ M( y5 Q2 E/ N4 E: \/ U
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,7 ~7 {4 Z! J  p7 x9 k4 [
  2427.             (oy - $game_map.display_y)  32, width, height)7 J+ h( _0 W3 q* X  z
  2428.           $game_map.events_xy(ox, oy).each {event
    3 `' w! w3 }4 U! ^& T, F( b; J
  2429.           event.start
      @1 G2 b! o$ ~% i3 U
  2430.           $area_responses.delete(response)+ [+ Y. U! X( \& ]! ^
  2431.           return7 t7 }0 d/ |. f
  2432.           }
    2 W3 @# W/ l& U/ V+ ]
  2433.         end+ c4 U( h4 d4 g! e2 b
  2434.       when 4( p0 m9 @4 N! |+ `2 A
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,# c, X" z( F! m3 j; N& [( u
  2436.             (oy - $game_map.display_y)  32, width, height)
    " V( H( N9 b% {! q& q& |' h2 V6 w
  2437.           $game_map.events_xy(ox, oy).each {event
    ; B6 t. H% Y* n( U- q; U
  2438.             event.start/ N  V0 z5 L6 L* m$ `
  2439.             return" R2 O. W1 T1 {+ e5 q/ K
  2440.           }   S3 j- V6 ~, o) a5 g7 d
  2441.         end
      c# c9 H) g. I3 Z3 J- j
  2442.       end+ `+ L3 _9 Y6 w
  2443.     }
    / ~' ?8 l  _3 k( `; O9 Q
  2444.   end
    $ H# L: K1 B! a& r" Z
  2445.   def mouse_in_area(ox, oy, width, height)( L5 Z8 R& i5 F2 X
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&. @% |4 Z) m/ y$ I
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height+ i* y' @' t) b8 E+ m
  2448.   end& W% u, a$ R9 X& S' @
  2449. end
    ) _* G' b+ N5 a- W
  2450. class Game_Interpreter! P' ], s/ r8 A, Z8 e
  2451.   def area_response(arg)
    0 X0 j8 d' H4 M0 e- d
  2452.     $area_responses.push(Area_Response.new(arg))* ^3 V# X  V& Q# M2 i' p
  2453.   end. w2 B; ~, y3 b8 s# z# q$ ^
  2454. end( n7 P+ e5 n9 h' f+ Y) K. e) D' _
复制代码





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