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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    - q; n# n1 d3 m6 ^+ I

  2.   W: H2 U/ n4 I  W- |& ?. I
  3.   Sion Mouse System v1.3e
    1 @& B+ F* |* M3 ?0 m! _! q
  4.   
    ) k; Q! R) d2 c
  5.   Changlog9 N1 q: T" W' p5 g  y8 V1 N6 i8 t
  6.   / r/ J% S* K( N4 k2 g# q7 f
  7.   2013.4.21 v1.3f
    $ h; u* E9 E% p  ?5 P9 R: E
  8.    
    ) `' u. F; n9 y/ z  R" o1 c1 Z5 h
  9.     1.3f 卷动地图 bug 修正- i% q* l' N2 c% q
  10.     7 l3 U7 L1 s% q$ ~- T
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    1 k1 J  G& \# o8 ^! N% c  E
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    . W9 {& x% o% `; j% }0 Z. J
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    - k1 m# ^7 R* D7 q7 z1 c) S1 W1 F& b
  14. 4 U# `/ I. S1 ^$ U8 C. }/ ?2 _9 ?
  15.     1.3f bug修正
    4 j- j, n# w. E& q" M
  16.   ( X0 g, A' E" _1 o& e/ Y/ e
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及; |1 _8 e. J$ O
  18.           关闭菜单时,鼠标是否移动到原来的位置。# i8 l+ K5 C6 Q  H

  19. 2 _. h% I' ^" h) u; b( x/ b
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    % @' A5 o# S2 {, l/ v

  21. / f6 U8 I- Y) W  q3 H2 ]3 J
  22.     1.3b 修正一些罕见的bug;
    7 l6 m  G& L- @; Q9 q* D

  23. + o0 f  ]$ }9 x: C  D# U
  24.     1.3a 代码小修改;6 ^6 \1 o1 m' Y: ~
  25.           加入了鼠标点击启动事件的功能,8 D, }  r6 ^3 }- O
  26.           在事件中加入“注释”: 鼠标启动  ,
    0 q, J& I/ u! q% b' G* L! V0 g
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    6 M5 u; ~6 H% h% `8 H
  28.   
    # ^  w2 k7 `2 w% k( l3 O
  29.   2013.2.12 v1.2; U/ R/ ^! y. M" `$ [7 N( j5 }5 S

  30. " }7 v# H& U8 t& ]
  31.     寻路逻辑优化;
    ( S# U) q" x' T
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;" f( o8 l$ t( N' {) ?
  33.     现在支持用鼠标来操作载具了。
    4 k  ?" o3 }: x, ~# C
  34. & x: z# {; W8 u
  35.   2013.2.8 v1.1
    - D( x9 m+ m4 v

  36. + q" B2 F8 s: B5 c& _- v5 n
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    , Z( |% I& g  A! O0 M
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;5 p3 Y) N1 T( U8 K
  39.     移动时,路径指示点的绘制更加稳定;. i. r7 \+ @7 K$ v9 S; a# k7 \
  40.     现在支持默认存档画面的鼠标操作了。
    4 D8 v* [5 f; a; E) w0 k  m) m

  41. - y" I! n- a" i7 h1 s

  42. 5 o: e% D5 e; h
  43.   OrigenVersion& L6 ~9 J0 o4 p* k  Z
  44.   2 H6 h; R8 b* `. x& K/ x1 E
  45.     2013.2.7 v1.0 9 l5 M. T; o" N

  46. ! o' C2 i8 P" p" z; o1 A* b
  47.   主要功能
    # r) Y% x6 k) q( Y2 F, ^
  48. , B! g" f, l( D0 R
  49.       使用鼠标进行各种操作...
    - e5 ^+ g+ P% k0 M3 ~& ^
  50.       将鼠标锁定在游戏窗口内
    7 A% `9 Y9 f4 m& X) C4 D
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    9 T9 z/ @! G. b+ a/ r, `3 i
  52.       双击鼠标进行冲刺
    7 n  p- r6 c/ s
  53.       更改地图卷动方式以适应鼠标移动0 a" J8 f* N7 t2 b* z2 W
  54.       变量输入框改良/ X1 D& d+ N! z

  55. & C. }6 z" G  ^0 q. v
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹2 w" N/ q; \) {( c* r, a7 K% K

  57. : b9 W, U4 F/ t6 r' m
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹% z. [( h  r0 U1 B1 q

  59. " L6 g5 E8 Y- n: |
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭% E& W( e5 {% l$ q- U! t

  61. , U' i: I. y3 @) b- G$ J

  62. ; V, @) V; U5 e" r" c' B/ [/ \
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    . n- G6 X. g6 Z8 s  D! _
  64. 6 ^* C( Z& ?1 V) J) b! S
  65. 0 C$ t. J! o( Q, ]* s5 W- r& A
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示, N8 z( Q3 x1 m, H5 k. b. R

  67. - M4 v2 C. L% t: r  h* ~0 A" }
  68. #==============================================================================, C" ~: v7 P6 h1 q( R0 J( z
  69. # ■ 常数设置
    , [( @1 K& m; O/ Z& I6 n* f! N8 T# w! X1 V
  70. #==============================================================================
    & d7 Y4 D3 E# M2 ~
  71. module KsOfSion0 L; J3 I6 e+ k7 o: R8 N; a4 N
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false/ j3 ]  X! S# F5 X
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    ; e& `+ _& _3 S- i( X" ~. j
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    ( Y5 t+ i/ b4 [& ^
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量6 k7 y& n$ w/ B
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    * c1 R" X- V1 c# o
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧/ K: A3 b/ K& F. n) l
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    3 i1 L2 o8 b/ k) C: S
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    ( X# `% P( r. {3 i- a1 g9 H( H" J
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)  ]4 N% C2 ~* c9 |6 y" @
  81. end
      L/ T4 `# [( C; K# I+ @8 y
  82. / V1 l7 ?. J" Y- D/ G% f/ p0 f- N
  83. #==============================================================================+ ^! C9 j2 a3 q  [% W6 q% g4 q8 H
  84. # ■ 用来显示路径点的类: H- Q, {% g7 w! q
  85. #==============================================================================6 A& M" b  W5 X7 H7 |
  86. class Move_Sign  Game_Character" @$ a0 `1 {0 i; D$ v' W, b* Z0 J1 U% U
  87.   #--------------------------------------------------------------------------
    , W, s0 q% A* i$ V, v4 ~4 T
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    & `/ j3 C8 C0 c$ V7 `7 A) M. _
  89.   #--------------------------------------------------------------------------
    ; w" M3 Q% ~+ f& P; U) R
  90.   def init_public_members- c6 u) E7 F9 l; S
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    ; k7 K. d9 O2 y" B' K4 L2 R: g* Y$ r
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为07 j( ]" @! H+ I* I1 U  X% q- P
  93.     @move_speed      = 5        # ★ 踏步速度$ o8 n+ e' A8 u" }1 r" p% {
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)" y( a7 z9 ^/ u& M5 X/ S7 t3 t
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    7 u  X- b8 i, e8 U8 `
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    1 O1 j" B2 O8 R- i8 _# i9 A' F
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列2 _$ o4 X  _* ?
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)# B3 j4 x3 J1 H/ s! f% Z; {' e

  99. " z9 g- i5 T! m) x
  100. , W* X' h5 G4 E% i  b& L
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    9 d( Y: O2 T# P* u

  102. ; x6 {6 D0 @  p* m
  103. 4 N" M( {+ w1 ^- [" T, F$ x
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图# s* q. {: V; Q% o
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    , V) W5 [9 u" [! z% z

  106. 4 V2 H; m  K& N# }1 _- z' T
  107.       if $no_arrowpic_warn5 S6 ]7 p* ]' R# ~+ c' v
  108.         MouseShow_Cursor.call(1)
    6 v6 Q  c2 E2 [: ^; s
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png1 {$ }( P' A" J
  110. 6 b- q$ e, V9 Z7 n; W$ L
  111. “路径指示点”将使用游戏自带图片, F6 ?- z, S# [1 J* }  ]+ s. l5 Q( u

  112.   J/ U/ h( ?( W; z
  113. 该提示可以在脚本内关闭')- s1 |/ M4 _! x" [
  114.         MouseShow_Cursor.call(0)+ P; z) K- H4 y+ J+ [! c- N7 _
  115.         $no_arrowpic_warn = false; d7 y6 J9 i; e: [% o0 ?
  116.       end
    ' Q3 q- V! e6 e3 E" p% T: t
  117.       @character_name  = '!Flame'
      y" ?6 J+ }, t! G  r- C) O2 t8 F
  118.       @character_index = 6
    . N6 p" r! a& S, D

  119. ) d, L' d9 V. X) q' r. w* ]+ `5 T
  120.     end
    7 @3 s) q/ b8 M! C$ G  v
  121.     @direction_fix = false  # 固定朝向( C0 `  j5 Z8 H6 E' Z
  122.     @move_frequency = 6     # 移动频率
    % S' b6 p: k- j. j" U- ^. @$ i4 a% L4 n
  123.     @walk_anime = true      # 步行动画
    5 o5 v3 I* Y& p4 c1 ]
  124.     @pattern = 1            # 图案- q+ M9 g- j6 a* n& b' d
  125.     @through = true         # 穿透5 g# |: J9 S& _$ `
  126.     @bush_depth = 0         # 草木深度2 h# X& }5 d/ M$ X/ I
  127.     @animation_id = 0       # 动画 ID
      _1 i! @4 s3 l& F  D, Q3 j4 x6 M7 s
  128.     @balloon_id = 0         # 心情 ID
    . H3 ]5 O9 s0 r" _3 U
  129.     @transparent = true     # 透明( s) c7 t# Z& H0 I2 G/ S* h
  130.     @id = 0, o2 J8 d% ^: J; r4 G% C9 u
  131.     @x = 0: o7 T; U' s2 E' M  i- @0 c
  132.     @y = 0
    5 t, n. @% o6 z
  133.     @real_x = 04 S, g* B( r3 }
  134.     @real_y = 08 o: l: n4 t( T
  135.     @tile_id = 0  |2 M2 @, H- b  Y
  136.   end, I: Q& F0 R  w' o$ J  u  k
  137.   #--------------------------------------------------------------------------" }, h: V- J( H
  138.   # ● 定义实例变量
    3 B1 E% l5 s% ~- s- y- [
  139.   #--------------------------------------------------------------------------
    4 E" ?2 Y! D" [8 j5 B0 ?4 B8 u
  140.   attr_accessor direction
    8 R, T' m$ @9 z% B- A" m
  141. end7 E  l  M( s% K. h* u" x

  142. ( d( _6 ^  L7 [7 p
  143. #==============================================================================$ ~! w# r* S1 \- q& a  }
  144. # ■ Module Mouse" `8 C, }# \* d  \% O, L2 P
  145. #==============================================================================; M/ }' ~9 M% k4 p2 x! r. R
  146. module Mouse
    ; k( h6 }- t7 m
  147.   #--------------------------------------------------------------------------( G) D! s6 m% A4 d, u
  148.   # ● API
    ( O8 Q+ N* l! Y; q5 r* S0 L
  149.   #--------------------------------------------------------------------------
    & v) {0 T' d9 Y& N$ k8 W  e. ~
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')  X3 a# ]7 D" F: z  L
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    3 ^/ F7 x  E1 o6 y* f
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')$ f3 H% u4 v6 t7 Y' n
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    3 s/ G, G4 a  s0 C7 g
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')1 o" q  n& h0 d, C$ G+ V/ o
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    3 S/ `$ D9 b( v! ]& F
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    ( ^/ S* g& @6 T) e
  157.   Window_Hwnd       = Get_Active_Window.call
    1 Q1 D) a  A/ `& n7 Z' S8 A* \# h/ T
  158. / w7 D1 }' E8 n' i- ~
  159. class  self5 G- e8 P4 q& M" v/ e# _  \
  160.   #--------------------------------------------------------------------------
    8 v) C  N$ D4 K3 Y) G% q5 B  ?
  161.   # ● 初始化" x. u: _# j8 A8 l! E
  162.   #--------------------------------------------------------------------------
    2 Y( \2 e7 y3 x+ n
  163.   def init3 G+ b2 c' }+ W
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor, U  ~5 @! G9 \' j: V
  165.     @left_state = 0
    ' E  [: E& l# D' U# C5 d5 t
  166.     @right_state = 0% j2 t3 p, n  a4 [, `4 z8 S
  167.     @ck_count = 0 # 帧数计,单击以后从0开始6 Q+ x7 {4 ?5 |
  168.     @dk_count = 0 # 用于双击的判定# J( ]; G( u8 q7 C: b5 v0 d1 N
  169.     @clicked = false
    5 R* W% b6 j+ Z! L; ]3 u$ D
  170.     creat_mouse_sprite% w3 t: i1 F- o3 c, ?2 T
  171.     update6 s% {, s% q% P, X; U% l" {) N
  172.   end( \  P1 Z' c5 Q* ?
  173.   #--------------------------------------------------------------------------
    # R* l" ?7 ?% P
  174.   # ● 鼠标指针精灵2 k4 r" i! l) v* @8 J$ G% V
  175.   #--------------------------------------------------------------------------
    / j, E4 z6 x" D! T0 g
  176. #~   def creat_mouse_sprite/ `4 u, F; G: F8 P) _0 W
  177. #~     
    ; t% ^3 ]+ R# n# o3 j( O! @- p( f
  178. #~       @mouse_sprite = Sprite.new
    & R$ z; C. C! c  ]
  179. #~       panda = 2#rand(2)+1! Z% `( G; m2 F5 S6 y

  180. " @9 f, p( O0 b7 X+ q
  181. #~      if panda = 12 O' e  h; H# r( Z; ^* q7 f
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    # L( h, o6 H. t; F
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')( y; H0 n, q5 e) c! P5 l% N
  184. #~        end#with if File.exist' [5 E$ d$ G2 N1 G# ~3 T
  185. #~   
    # h8 s1 |4 N, L
  186. #~     else if panda = 2 #with if panda=1; J7 S0 ]4 t5 j) d$ i4 p
  187. #~      4 t- T3 |! |/ f+ h
  188. #~      if File.exist('GraphicsSystemCursor2.png')0 U# d* T4 J& V2 |: S
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')7 A+ p; z2 L5 g9 R  D
  190. #~      end#with if File.exist% C2 O  l, d( l) d1 q
  191. #~       " ]7 f; `+ I& {6 x
  192. #~     else #with if panda=1
    4 U8 F: ]9 e% v
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)  q: n6 `# s  P: p" ^" A; [7 X( i0 h
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),% X& U2 |* s: b. n( c
  195. #~       Rect.new(5  24, 24  24, 24, 24))8 f5 O4 j5 O; f+ G- \* Q
  196. #~     end#with if panda=1
    * h8 P7 x/ H$ _$ s: }& {. }
  197. #~     3 b& D9 z4 r, J2 U
  198. #~     #with def5 Q+ F$ w( Z' N  Y  j- D8 `
  199. #~   end
    % a/ j, d) w% E! H% c
  200. def creat_mouse_sprite
      n' B( k( b5 L6 b. Z( b! M
  201.     @mouse_sprite = Sprite.new
    7 }& x, ^! a: t9 _3 t# X% ^
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    $ r5 U% I1 D8 V, @" P4 f, Y2 z
  203.     @mouse_sprite.z = 9999
    2 c' U) I' ]$ E* B+ d8 x1 k
  204.     Show_Cursor.call(0)6 t! l  r; j+ u7 j' A$ Q
  205. end
    ( e7 c% X" Q: T! u. N

  206. : Q; `. b( o3 t7 H5 x$ A
  207.   #--------------------------------------------------------------------------- v; d6 l/ M# o8 J
  208.   # ● 更新' W' L& C3 n. I+ P! [5 W2 j2 x
  209.   #--------------------------------------------------------------------------3 U9 \( f. L6 ]3 r7 o
  210.   def update4 Z" A# ^3 h. t8 g! q
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    2 @! z" n9 T, y
  212.     left_state  = Get_Key_State.call(0x01)& v* l/ O% U; V! S) `: g. L. j
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0. b! G# b) ~+ W
  214.     right_state = Get_Key_State.call(0x02)
    & n. ~- x# L% o; D4 w* U
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0, i" C5 i& o8 d) {
  216.     update_double_click9 N# D2 |( d; `
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1! _3 J9 L& b0 l9 R
  218.   end& x% c& p* G' P' F
  219.   #--------------------------------------------------------------------------4 ?2 N8 R7 i5 z4 K  q
  220.   # ● 获取鼠标坐标
    4 k3 A5 G4 ^1 l* M
  221.   #--------------------------------------------------------------------------# w; D# N" S5 c9 `/ D
  222.   def get_mouse_pos) c# \4 u5 _: J. [& ?( n9 c
  223.     arg = [0, 0].pack('ll')5 N4 q9 a0 K) B2 l* c9 J/ _$ N$ R
  224.     Get_Cursor_Pos.call(arg)
    - X- l2 L* A; Z
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    9 Q8 m2 d1 x0 m! p
  226.     x, y = arg.unpack('ll')
    ) ~* e, D) }' M8 ]! x7 ~# c9 r
  227.     return x, y
    1 W, S6 w) @  `8 w  k
  228.   end4 a: a; _& N5 e7 l
  229.   #--------------------------------------------------------------------------
    9 e' K$ k2 }+ e7 A) R/ |
  230.   # ● 将鼠标固定在屏幕内
    , ^& o, p6 c* ^! V. w  [) Z9 N% {2 n
  231.   #--------------------------------------------------------------------------
    0 B& K; s5 I! M8 U0 Y5 n  Z
  232.   def lock_mouse_in_screen
    + y( U0 \% m: W$ W7 V
  233.     arg = [0, 0].pack('ll')3 w' E$ J6 ~" m  P) l
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    7 O. }, S) o: _# t0 t$ T
  235.     x, y  = arg.unpack('ll')
    ( X4 x# d: A: ~5 U5 q4 I  @6 f
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))$ J2 F4 x1 Z3 l0 _
  237.   end, M! S0 t# J+ N  l, [! t
  238.   #--------------------------------------------------------------------------: c& v* T- @4 C' T3 x
  239.   # ● 解除鼠标固定- O' h5 t# d/ x; e5 `! `
  240.   #--------------------------------------------------------------------------3 `  M4 Z' D! u# \8 b. s
  241.   def unlock_mouse_in_screen' M; x. g0 o- c9 p0 x+ Y3 `9 d
  242.     Clip_Cursor.call(0)
    1 j/ g; d6 C" Y* J# h- B* n( U
  243.   end
    5 f5 O. w2 d7 o# g& c% Q, U
  244.   #--------------------------------------------------------------------------: }; P/ ]* Q% {) U4 m
  245.   # ● 鼠标双击判定  H6 X: P: I& a: |  t; u& ~; C
  246.   #--------------------------------------------------------------------------
    ( g5 f& H2 E# V- @9 T
  247.   def update_double_click
    ) {+ {, s2 h" `; K: P5 a
  248.     @clicked = true if @left_state == 1
    ( B* G0 P8 w4 \# L  N
  249.     if @dk_count  0 && @left_state == 1- V: w  K/ w& {8 B
  250.       @dk_count = 0; @clicked = false
    ( g" J/ H/ ~' L, X
  251.       return @double_click = true( ?% x" c0 y, x0 f( n2 |
  252.     elsif @clicked
    + `. r+ f& Q+ j' g0 a8 `( S  ^
  253.       if @dk_count  KsOfSionDbclick_Frame
    8 S5 C& Y. a7 n
  254.         @dk_count += 1
    . |2 w) z9 y6 X8 O) h8 q0 |7 Y8 P
  255.       else
    # }. {/ h' O) ^  S1 {
  256.         @dk_count = 0; @clicked = false/ I% K7 p+ B6 o5 ^9 O
  257.       end
    0 R7 A. j( E7 b2 _
  258.     end
    - n* b( B" [% L
  259.     @double_click = false
    8 T5 d8 u5 e# z7 a: I: `
  260.   end( t1 _. F3 v" Q; J6 B( q8 k  v
  261.   #--------------------------------------------------------------------------
    % w) ^& c/ I+ h5 o
  262.   # ● 按键被按下就返回true
    ; t: h& D/ T- G8 n" C& z0 C8 i) \: t
  263.   #--------------------------------------------------------------------------
    9 t& C; Z3 W5 `) }! ]& z; ^: j
  264.   def press(button)
    ) g. W+ S  G2 k1 v" M7 B2 X/ ]; A
  265.     case button
    ! L9 a/ n' `3 a' M. f% h
  266.       when 0x01; return !@left_state.zero; X1 L8 E+ e6 F7 B; {
  267.       when 0x02; return !@right_state.zero
    ) S$ F) z- z0 g& W5 D1 e6 u
  268.     end
    + x. q+ R8 x! |, G9 q  {
  269.     return false
    3 C' z5 x4 j& P
  270.   end& O/ D0 L& m$ D, S& J
  271.   #--------------------------------------------------------------------------
    0 L+ t$ D: }7 }1 r" m7 l
  272.   # ● 按键刚被按下则返回true* b; [& I0 r% U( {- C3 s( L6 O
  273.   #--------------------------------------------------------------------------
    ) F& D6 X, H  I  |5 J
  274.   def trigger(button)# R7 z7 \1 M9 \& y& X
  275.     case button! x& J. f: v7 d5 M
  276.       when 0x01; return @left_state == 1
      J* O8 k3 ^' |
  277.       when 0x02; return @right_state == 1
    # b5 L# o+ F- \+ r
  278.     end
    # }$ k3 m/ h. i5 E/ N' `
  279.     return false& }8 I7 O' U& ~+ \5 A1 Q8 h/ ]
  280.   end
    1 I) |  ]3 T; _& l
  281.   #--------------------------------------------------------------------------
    9 H# ?3 K1 T7 A* \+ F. \8 o
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true1 G: W& Q9 C! v) y- \% O" h9 N: I
  283.   #--------------------------------------------------------------------------; S) P2 e+ n& u+ i
  284.   def repeat(button)+ J& j9 n; E4 [* i& ~! o9 Q
  285.     case button# }: H& M/ W( {4 w( n
  286.       when 0x01; return @left_state == 1
    2 W  M; C* g* j+ h- z! a, j
  287.         (@left_state  22 && (@left_state % 6).zero)
    7 T" V5 S( A- {
  288.       when 0x02; return @right_state == 1
    ; B8 i7 Y$ C$ l5 S1 M/ n
  289.         (@right_state  22 && (@right_state % 6).zero)
    1 N: M% M7 K( N( v8 y, x: o. M" l& Y+ y
  290.     end
    ( \7 Z5 _! z: F9 Z- B% Y7 m
  291.     return false9 X0 d8 D4 J% j4 q1 e2 g: B
  292.   end9 b- W, r# t. H" X$ T6 R
  293.   #--------------------------------------------------------------------------
    + X- H9 M# A4 @& [( ]% {7 k- O
  294.   # ● 判断是否双击鼠标
    4 d- ^' w" r$ i+ Z
  295.   #--------------------------------------------------------------------------+ b0 V+ M! F# z0 N1 H
  296.   def double_click
    / @1 [/ O' r4 [. y. A
  297.     @double_click
    + c* ~4 R0 U: j2 t
  298.   end
    9 y( Y7 P# ]9 v) }! X: d
  299.   #--------------------------------------------------------------------------; Z; O0 F3 K; W0 j
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)3 R1 r) k) r4 D% w
  301.   #--------------------------------------------------------------------------
    ! Y7 i/ S3 f6 _6 t; S
  302.   def click_count- ]' I- Z7 h+ D# G9 S
  303.     @ck_count6 {, S1 Q  @) w+ A( q7 D
  304.   end
    $ v& P% v+ `' z2 Z" q  z! y
  305.   #--------------------------------------------------------------------------
    % k) G5 b$ E# [
  306.   # ● 获取@left_state(按住左键每一帧+=1)0 `2 p% X; C" }' P# g7 a1 M
  307.   #--------------------------------------------------------------------------
      W6 Z; \  ^. O4 n! q. w
  308.   def left_state/ C- _: S. `% n& W6 n  W
  309.     @left_state
    : Q9 G+ A' L1 h9 G) F- a
  310.   end
    : s3 c; N8 C+ Y% l% X
  311.   #--------------------------------------------------------------------------+ r+ Y, u% z/ k/ r$ t/ N
  312.   # ● 获取鼠标的x坐标
      s* S& m& h1 ^$ Y2 Z$ P1 N
  313.   #--------------------------------------------------------------------------
    1 c# O: b* k( k  L+ A
  314.   def mouse_x/ _6 Y# |$ n8 }, l! V# w& o
  315.     @mouse_sprite.x4 ^5 w1 W0 n! I
  316.   end6 s3 z6 E& H3 g5 C/ W
  317.   #--------------------------------------------------------------------------0 C5 @- W# \$ P( ?- F; M
  318.   # ● 获取鼠标的y坐标
    ; h1 Q8 n( s' Z0 h  Y5 k8 n; V
  319.   #--------------------------------------------------------------------------: Y$ n4 o' o6 D6 r
  320.   def mouse_y8 G6 r2 V, [1 Z" _4 K% Z5 z* M3 ^6 ^" ^
  321.     @mouse_sprite.y
    ' z3 L* ^3 P; a! j" w% e, v
  322.   end) |3 u3 A. b7 L6 N
  323.   #--------------------------------------------------------------------------. z5 m- j7 u+ ]1 A9 Z/ s% P
  324.   # ● 设置鼠标坐标
    3 f! C* o* j) u' ~+ {
  325.   #--------------------------------------------------------------------------7 [; E! ]- R5 X' ]0 D
  326.   def set_mouse_pos(new_x, new_y)5 n  ~: k. A3 b6 E
  327.     arg = [0, 0].pack('ll')& c1 U5 z" U7 n
  328.     Screen_To_Client.call(Window_Hwnd, arg)& j: }/ m" u4 L0 _) t
  329.     x, y  = arg.unpack('ll')) y1 P. {; H( D. w: `& L: \; r
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)7 `! e" i9 ]" r3 p
  331.   end
    6 y/ G5 n4 H4 ^- ~; O$ n% z* m
  332. end #end of class  self 5 P* x1 {- M4 W/ e6 M/ |

  333. 5 O- O% v$ k& p. ^
  334. end
    7 D% u- K" ]: L8 s+ S6 @4 v

  335. 7 {- E; q. k# i! C, f* v
  336. #==============================================================================* W( S7 R$ v- m9 x9 L
  337. # ■ SceneManager
    1 R, b' L* \5 \9 L7 B: b! |
  338. #==============================================================================* p; N% ~4 U  a" z# H) W% ]
  339. class  SceneManager$ w  {" ^( ^& R$ v! F( }2 h
  340.   #--------------------------------------------------------------------------
    " S3 O+ y7 ~2 H. F: u
  341.   # ● alias# G4 s- F; J1 Q) I- B4 F
  342.   #--------------------------------------------------------------------------
    6 }2 H7 |+ |* a' [
  343.   unless self.method_defined(sion_mouse_run)
    4 @$ H" C$ Z6 C$ Q
  344.     alias_method sion_mouse_run, run
    5 n& e! C% t9 ~6 f+ _" j+ T
  345.     alias_method sion_mouse_call, call& ~3 u* w) V8 E6 x7 [
  346.     alias_method sion_mouse_return, return# x& {& N- ^/ p
  347.   end
    * E& @' W+ ~. k5 ]4 i
  348.   #--------------------------------------------------------------------------
    7 f3 r" p6 V/ J& k
  349.   # ● 运行
    ! j! ~: L2 c) h/ y2 F
  350.   #--------------------------------------------------------------------------8 W: F% D/ e1 n% M  z
  351.   def run
    % q, T9 q& v- x$ C* Q7 _; ]
  352.     Mouse.init
    & P1 {' n! s1 G, c. S( C
  353.     sion_mouse_run
    % F  }5 b! L  H" h1 J* |2 t: P6 k
  354.   end
    - F: |! D, F1 C% Q
  355.   #--------------------------------------------------------------------------. H( i) P3 A9 e4 s
  356.   # ● 切换4 m# U: o9 W2 v* _
  357.   #--------------------------------------------------------------------------! y) |; @4 _' J
  358.   def call(scene_class)
    ) l9 ?! {5 d6 y, `% r6 u; ]
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)1 [6 C6 T9 |, j9 ?7 k
  360.     sion_mouse_call(scene_class)& c8 _' X1 I4 U
  361.   end
    + M' a5 d3 b: i0 Q3 O
  362.   #--------------------------------------------------------------------------
    9 P  d) A) o2 I7 g9 F6 N7 ~! o: t+ _" @
  363.   # ● 返回到上一个场景) z/ _; \( @: V  ?+ r# q8 P
  364.   #--------------------------------------------------------------------------
    1 E2 d& U" B- c/ `
  365.   def return( f. u( h0 r' s4 ^
  366.     sion_mouse_return
    5 s$ Z1 n  I' c% M
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&/ S' A2 N) }' }( e
  368.       @scene.instance_of(Scene_Map)
    2 ?5 T2 P/ N& g7 a8 E+ w
  369.   end
    * ~- L$ F2 E# j
  370. end1 {; T) m; J3 x! j! A

  371. # N# _  h0 y. D& |0 H6 H
  372. #==============================================================================
    - g) z% _0 ?6 V4 Q
  373. # ■ Module Input
    1 h. t. K& a9 c
  374. #==============================================================================
    # p8 r: T" \( C- _8 F
  375. class  Input9 e  E$ T( ~) q2 x0 d7 ^" Q( Y
  376.   #--------------------------------------------------------------------------
    % ?3 T' \7 T0 F4 O5 C
  377.   # ● alias& @4 z* g1 q" }6 C( v9 e8 N
  378.   #--------------------------------------------------------------------------+ b6 U1 T" D' t- Y: m. B9 l8 |" x/ s4 \
  379.   unless self.method_defined(sion_mouse_update)
    : d! @1 ^; b7 M' ?% S- {1 Y& [
  380.     alias_method sion_mouse_update,   update) D, @0 g6 O# E$ a+ N
  381.     alias_method sion_mouse_press,   press% {1 y$ u) E- R* i- U
  382.     alias_method sion_mouse_trigger, trigger
    1 Y4 S4 q( z' e6 u
  383.     alias_method sion_mouse_repeat,  repeat
    % n: ^3 f6 Z& z% P  N
  384.   end
    0 S4 |( {/ f! b, I5 U
  385.   #--------------------------------------------------------------------------
    5 z- |5 P, O. P
  386.   # ● 更新鼠标8 Z! W4 r2 h) s, f
  387.   #--------------------------------------------------------------------------) d4 y2 h3 d  u2 J
  388.   def update& h( [+ i1 g2 U7 a( o3 Q- b
  389.     Mouse.update2 ]( h) v0 h# d7 u/ F( M8 t
  390.     sion_mouse_update1 W5 n/ X9 C! V3 W$ n  F
  391.   end
    $ a3 V0 u9 k) A. Y6 l
  392.   #--------------------------------------------------------------------------
    * m& K$ O; p! k1 M% U$ F+ E5 q
  393.   # ● 按键被按下就返回true  D$ s+ ]2 D( q# ]  H) M" v
  394.   #--------------------------------------------------------------------------2 H, @( ]! \  @4 h' F
  395.   def press(key)7 `. m/ V8 t' g' j/ \. \" @- H
  396.     return true if sion_mouse_press(key)7 U6 U) \! K( \8 w( i
  397.     return Mouse.press(0x01) if key == C$ x' i! u) n3 ^; a6 \
  398.     return Mouse.press(0x02) if key == B" e& ~' C3 R) w- S
  399.     return false
    1 {( }# B3 A- y
  400.   end7 o: P0 i; o* ?4 E$ m
  401.   #--------------------------------------------------------------------------
    1 R" m5 g" a8 p- \* o; \) I( A
  402.   # ● 按键刚被按下则返回true
    % D$ G/ w) O! U  n; h8 `3 Q6 n+ t
  403.   #--------------------------------------------------------------------------
    - ?; @7 R7 Z# A, q, X6 S
  404.   def trigger(key)) w/ T) G6 s9 W; p, R
  405.     return true if sion_mouse_trigger(key)2 `  f. Y! l# j8 n8 s
  406.     return Mouse.trigger(0x01) if key == C0 [" p3 w2 }* V5 _; ?
  407.     return Mouse.trigger(0x02) if key == B# f0 z- X: s6 O1 `( p" J) U5 f. Y. x
  408.     return false9 V; |2 F' ]- D
  409.   end. Q3 x6 C! i; s5 k
  410.   #--------------------------------------------------------------------------
    ! h' Q7 \& z) f! M6 k! ?0 J
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    . f4 [6 ~8 u: d  s( `/ o! D
  412.   #--------------------------------------------------------------------------
    % S3 R: [9 ^( Z
  413.   def repeat(key)4 q1 o' a4 w7 }$ ^$ e- T) ^# E
  414.     return true if sion_mouse_repeat(key)" j- h1 g1 X7 a6 I3 ^0 n
  415.     return Mouse.repeat(0x01) if key == C" U- p1 j6 Y- ^
  416.     return Mouse.repeat(0x02) if key == B, i- T6 ^+ K7 d! X
  417.     return false- u, q2 C) I' U1 w6 @9 }9 R
  418.   end
    # Z+ Z: J; b8 c5 f
  419. end
    6 A7 `) W$ O7 o' H

  420. ! M: K' _" _* c

  421. 0 s. h5 H% w, B/ c; w# e
  422. #==============================================================================1 `- `6 W3 q/ @/ ^; ^4 M
  423. # ■ Window_Selectable
    4 Q" Z# p/ V" C: ~9 b
  424. #------------------------------------------------------------------------------5 r* f$ x9 b$ Z6 q3 M+ Y: k
  425. #  拥有光标移动、滚动功能的窗口0 h( v* S, S. N! D* Q$ b+ ~
  426. #==============================================================================8 }" v) k( e" A, O5 j: I6 u
  427. class Window_Selectable" K& N4 A9 F" N7 Q' z1 \) u' |
  428.   #--------------------------------------------------------------------------
    ! T0 u0 _1 v3 w
  429.   # ● 初始化  y8 s' n* I% }5 x) v( D
  430.   #--------------------------------------------------------------------------' {" C9 J4 g' {( ?+ b0 [; o9 F
  431.   alias sion_mouse_initialize initialize
      T4 f3 S* y4 |. J9 a
  432.   def initialize(x, y, width, height)
    , |) b) X( ^# V% [" E# F0 i+ \+ T
  433.     sion_mouse_initialize(x, y, width, height)
    9 r9 ^* K% x% S
  434.     @move_state = 0
    ! P  t% k# t4 Q1 s# R: p) @
  435.   end
    8 h$ _- Q. O( z8 R+ h6 h+ I/ s
  436.   #--------------------------------------------------------------------------: L$ B9 [2 X! a  w
  437.   # ● 更新% U$ \" _  F1 z; X! o* w. u
  438.   #--------------------------------------------------------------------------0 p' v+ H% X% L# i9 E1 u2 ^9 r
  439.   alias sion_mouse_update update7 i- [8 a% b  f
  440.   def update
    ; x8 \( t( y& H4 \
  441.     sion_mouse_update
    * c; U* k" y  M3 t
  442.     update_mouse_cursor5 w/ o. a4 R% ]# o8 @! F/ p
  443.   end
    / I. r8 S5 {3 ]9 X% U4 G
  444.   #--------------------------------------------------------------------------, k* Y2 T1 ], h8 u1 X' R* j1 ^& ^
  445.   # ● 启动后设置鼠标到index位置
    + U  G, w+ w& Z$ r* U$ }
  446.   #--------------------------------------------------------------------------
    5 ^8 l! W4 ^" M+ G8 b
  447.   def activate
    2 G4 {4 C% R' ]4 K* G
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    , p* [% @6 m. K6 j
  449.     super
    , V7 [4 A2 Z- h2 |2 b- o
  450.   end
    ! ?6 x/ o  E2 y6 }  s5 ^
  451.   #--------------------------------------------------------------------------
    4 o: L3 @0 I2 {: i
  452.   # ● 更新鼠标和光标的位置
    : K+ l' }' O1 r3 X, [
  453.   #--------------------------------------------------------------------------
    - h0 R4 H! G2 M
  454.   def update_mouse_cursor& n; }( ^: s' l& _  s  G9 \
  455.     if active
    : g$ V0 ^' o- U& Z1 Q4 _
  456.       if @need_set_pos
    # B. r4 D0 ^, D: u6 ?6 j; W
  457.         @need_set_pos = nil% U$ K6 ^# |; s) Q: G4 J& u
  458.         set_mouse_pos
    / p" v( y3 a+ }% w
  459.       elsif cursor_movable
    % Q5 G7 `/ x: r5 R" ^% {
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    + I% b) V0 x6 `+ l$ f0 W$ L' o* f
  461.       end
    ) A+ a9 _7 w5 ~# f3 l
  462.     end
    6 Q. _" q& z7 d5 b5 ~
  463.   end  Z3 l9 ?2 B7 S% E* r+ ~
  464.   #--------------------------------------------------------------------------+ Z3 b5 w3 ^6 D- t" ?( j" [
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    * q/ q/ w" z5 C" j' y) x% b1 B
  466.   #--------------------------------------------------------------------------% d# P$ o* i7 P
  467.   def set_cursor
    $ j* P* y6 ?+ F- [, p
  468.     mouse_row, mouse_col = mouse_window_area
    ' |1 S" W/ O9 W5 n
  469.     if    mouse_row == -14 I" c, j- ]1 R& l& n
  470.       @move_state += 1 if need_scroll
    2 t" m' y/ o& W6 Z( |
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
      ?; Z" ]; |" |3 V7 A' \3 `
  472.     elsif mouse_row == -2* O! o" n& B  ~+ A% E* W* p
  473.       @move_state += 1 if need_scroll
    ) [- p0 ~+ G& [, j
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    5 k& p1 c0 t. x) q) W3 {
  475.     elsif mouse_col == -1% T6 g# ~7 P- ^0 Q6 A7 Q0 `7 M( m
  476.       @move_state += 1 if need_scroll
    - n; U8 F  E  A; P5 w# S% F) S
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand  N- |# P( f3 l( n7 \2 l8 i& `
  478.     elsif mouse_col == -2
      H4 J+ S3 B6 h% q6 m
  479.       @move_state += 1 if need_scroll
    ( }) _. \. U0 l7 ~
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    9 a4 e8 \5 U7 K: Y
  481.     else" G0 K/ [; h  v0 H8 T4 Z
  482.       @move_state = 0. \: b$ ^) G. j7 x& S3 W4 h& d8 t
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col' r/ ^1 c1 j9 O" D1 _1 L: h' F. e% ?
  484.       select(new_index) if new_index  item_max && new_index != @index
    ( y1 N6 K  T# A' b0 c. |
  485.     end
    : d. S% q9 _& ~# q$ R0 l! i' a
  486.   end
    0 T4 y$ P3 m% i- X% M; y$ I4 d
  487.   #--------------------------------------------------------------------------4 d! H* S- Y7 H! Q2 i
  488.   # ● 判断鼠标位于菜单的第几行、第几列0 i9 u; N# H; t! M
  489.   #--------------------------------------------------------------------------
    1 w" F) p3 B4 l6 \0 W- q, L
  490.   def mouse_window_area
    6 t6 v" R+ _& z6 I' A( w
  491.     if viewport.nil # necessary!$ C/ x; ^3 G2 ]* N0 ^
  492.       vp_x, vp_y = 0, 01 P3 \) ~% Q. Y9 L
  493.     else4 e" p: V: s% R
  494.       vp_x = viewport.rect.x - viewport.ox
    - X! |1 |1 N* h2 X
  495.       vp_y = viewport.rect.y - viewport.oy
    9 _0 r3 x- V( I
  496.     end
    ! z( c6 [2 L7 S! W/ P2 T
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    - F4 v" D2 Z) b) x
  498.     item_x1 = vp_x + x + standard_padding
    $ D& p) N' Z. }, [( v* l- b: f3 i! }
  499.     item_y1 = vp_y + y + standard_padding
    , r" R! N' I, \& q' I% Y( v
  500.     item_x2 = vp_x + x - standard_padding + width: ?+ s% c- i) H* A4 a+ X) u
  501.     item_y2 = vp_y + y - standard_padding + height. e) K1 i3 p7 A- h& Z+ v+ C
  502.     if mouse_x  item_x1
    - E$ R$ x! N/ r& _6 n5 b
  503.       mouse_col = -1
    ' Y( @# B" ~9 U
  504.     elsif mouse_x  item_x2* t- n, g8 z' |+ ]0 I
  505.       mouse_col = -2
    2 z  o* k( R$ g( g2 L
  506.     else
    ! I. @1 s% e/ ]' }1 q3 ^6 m# {
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    % E# j: c* ^4 b( y0 u/ D4 L# U' l
  508.     end: h' \  r. W) |0 e( b. y
  509.     if mouse_y  item_y1# a% n4 p. K1 F( P4 m3 m
  510.       mouse_row = -1* W9 F  o9 m: A6 e1 x0 _
  511.     elsif mouse_y  item_y2  s# G3 S5 g0 j9 m
  512.       mouse_row = -2
    6 K# N! k" ]) O
  513.     else2 _- O( e1 n6 y+ _* t0 O, o
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    % |' V) |+ n5 n  }# l. ?
  515.     end
    2 D! t* k3 L* t- L' t
  516.     return mouse_row, mouse_col
    ( |$ ~" C! h- t- N. {4 q( V8 b! W3 i
  517.   end
    ( U  I/ V: B+ X3 `: E* Q5 c5 Z% Z
  518.   #--------------------------------------------------------------------------
    % ]7 {4 Z2 b: w6 k
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    8 O6 r  v/ x6 K5 \  {6 |2 m3 a
  520.   #--------------------------------------------------------------------------5 r# Z, s2 `; T5 f& u
  521.   def set_mouse_pos0 K" i7 {) n" k6 r2 R
  522.     if viewport.nil # necessary!
    ; l& @7 D* z) u
  523.       vp_x, vp_y = 0, 0
    ( w/ ^4 e- \$ v) P
  524.     else+ S7 j" W( V, T, l! A: k8 v  N' H; s
  525.       vp_x = viewport.rect.x - viewport.ox
    ; L; W/ k* U% m9 m
  526.       vp_y = viewport.rect.y - viewport.oy
    ( j8 n0 j2 Y7 ~/ k: B
  527.     end
    $ K0 D% s) Q; r1 I  P) o& p
  528.     item_x1 = vp_x + x + standard_padding - }) Z! e1 J8 s  H7 I9 j
  529.     item_y1 = vp_y + y + standard_padding
    - w3 U) U  {$ g0 [! f1 u" K
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index 6 P# s, ~  y! v) X, m
  531.     row = get_index  col_max - top_row
    - P. B) Y6 L6 C, N5 @4 K# p+ r
  532.     col = get_index % col_max
    5 h1 f6 X0 t/ [
  533.     new_x = item_x1 + item_width  (col + 0.5)
    % v# x9 b) y/ h6 v# O+ I
  534.     new_y = item_y1 + item_height  (row + 0.5)9 O% R" k8 Y% x0 P$ k+ @& q
  535.     Mouse.set_mouse_pos(new_x, new_y)# r8 C+ j( I! X  L. J0 Y6 i  S
  536.   end
    5 F, k7 n/ C+ u# M6 X9 k9 z" p
  537.   #--------------------------------------------------------------------------
    9 P: {5 ~. S3 D% o+ x( n# H
  538.   # ● 判断菜单是否需要卷动' n+ @! d- ]* J) j
  539.   #--------------------------------------------------------------------------7 R" T5 M; W$ c( i$ |0 ~2 O
  540.   def need_scroll
    4 m% E6 I. O3 D0 s5 c, Y, g
  541.     item_max  col_max  page_row_max
    ; K9 _& w5 l& n; U4 W& I
  542.   end5 Y) m, u. M3 {: Y: [% Z6 N" n
  543.   #--------------------------------------------------------------------------
    : L- _- t8 H4 Y2 o# N
  544.   # ● 判断是否为水平卷动菜单
    $ `: L: K7 t: s" j7 t" W
  545.   #--------------------------------------------------------------------------
    . m" U( J. \0 X$ l' L
  546.   def is_horzcommand; S4 e( v6 l7 H5 I0 I) Y8 S$ }2 `1 e
  547.     return false
    / b! t+ A3 v4 l0 Z4 s% p
  548.   end
    + k, I5 u0 C& n% N2 `- p
  549. end
    : h# z( F3 M6 G+ n
  550. % R  @8 L6 {+ z
  551. class Window_HorzCommand
    % O9 m5 i* A# r) o' a: ^7 x
  552.   #--------------------------------------------------------------------------  q2 |' r" m5 l- t1 {
  553.   # ● 判断是否为水平卷动菜单
    1 p+ w7 B$ P  g4 i. ~
  554.   #--------------------------------------------------------------------------
    + \2 o" a2 Z4 z1 p) R
  555.   def is_horzcommand
    1 H4 E- C- Q; P9 p" U$ ?
  556.     return true
    / H* @3 U; x2 c6 X3 V
  557.   end
    * F9 q$ G9 |/ r4 n" i+ x* p
  558. end
    , r5 V# _7 `+ ^  w2 p
  559. ! H0 d. j# E& o5 C
  560. #==============================================================================5 A" {3 x! R- j7 C! t
  561. # ■ Window_NameInput
    2 P2 E/ v: M8 K" n* I0 N
  562. #------------------------------------------------------------------------------) R" Q& x9 B  w  e0 R" Q- e; y+ ^
  563. #  名字输入画面中,选择文字的窗口。
      U- P' e( m1 y# c0 R$ h$ l0 ]
  564. #==============================================================================# Z/ P7 w, g9 ^6 a& [- B
  565. class Window_NameInput
    5 J! S. B. E; z$ n: ]
  566.   #--------------------------------------------------------------------------6 J- r  q5 {9 a+ E4 ?% w; ?, D  Z, T
  567.   # ● 设置列数
    & a1 _; m: ?: n  D+ J) }
  568.   #--------------------------------------------------------------------------# W3 `$ u- ], a# r' P
  569.   def col_max
    , y1 H8 J( R! i+ n
  570.     return 10" u6 |) F2 |0 ~: s' H
  571.   end
    9 Q( h. H8 J! @& Z8 b
  572.   #--------------------------------------------------------------------------7 Q) P, e, M+ n8 w) e( g
  573.   # ● 设置填充的Item个数9 c: s3 N! w9 S6 N& a
  574.   #--------------------------------------------------------------------------6 Z: h  U# h" o$ N' G
  575.   def item_max: ~9 s# X, z# I, J1 C# d
  576.     return 90
    2 z4 z2 u7 B0 q6 R" r
  577.   end
    9 S# c5 x6 i4 v: x9 Y
  578.   #--------------------------------------------------------------------------  S7 a7 m4 S  A: K" f, z) V
  579.   # ● 设置填充的Item个数
    ! k" N. V! O! ^1 U+ x3 J
  580.   #--------------------------------------------------------------------------& }  s. o8 P! q7 }# s% Q" r
  581.   def item_width5 e  K9 |* }* U7 _
  582.     return 32
    $ y" L- u& ^) Y1 y) N
  583.   end4 @! B  S9 @, I9 G) P- g
  584.   #--------------------------------------------------------------------------6 v. u& _! W% L, Z1 v
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    : F/ S9 }( f+ }& t% W4 r  D
  586.   #--------------------------------------------------------------------------
    . ?, C" J+ w& n; ?' b% P( {* ~& K
  587.   def mouse_window_area' ]/ d& i0 g* q% n, B* z
  588.     if viewport.nil
    * V, P9 t+ M2 h1 t7 s) R5 o
  589.       vp_x, vp_y = 0, 0- t' n6 a% p+ D: j
  590.     else. [$ p9 T( w& Y4 w. ^
  591.       vp_x = viewport.rect.x - viewport.ox+ D, a5 y( x( d# s' c& t( `
  592.       vp_y = viewport.rect.y - viewport.oy
    ' y: \9 |& {. R) N0 \4 s/ m8 F
  593.     end
    5 c! U) `7 Y- N9 O( F
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y. v; N  X! K2 t5 X) T
  595.     item_x1 = vp_x + x + standard_padding ' z# k" |7 d. ^( m% {
  596.     item_y1 = vp_y + y + standard_padding
    0 x- X# T( t% X% H& x" _
  597.     item_x2 = vp_x + x - standard_padding + width
    " z# J5 R" L. @6 v* b
  598.     item_y2 = vp_y + y - standard_padding + height
    9 H2 i8 ~3 q/ r) [
  599.     if mouse_x  item_x16 Y- X8 {: u7 Q( _# t$ J1 S# r
  600.       mouse_col = -16 x) K6 c! @1 T% V3 c
  601.     elsif mouse_x  item_x23 I! q% `0 Y' s4 [5 t0 o
  602.       mouse_col = -25 K2 h3 P4 X+ z6 F1 r/ k- i
  603.     elsif mouse_x  item_x1 + 160
    . r; W: c6 y/ [+ i! \: l3 b$ `
  604.       mouse_col = (mouse_x - item_x1)32
    2 E1 `% h/ o% v/ o6 H) V# n
  605.     elsif mouse_x  item_x2 - 160
    - G; E) o1 [$ X* Z
  606.       mouse_col = 9 - (item_x2 - mouse_x)327 f5 k) ?* [' ]) y) g. J8 k. u
  607.     else
    9 o3 A0 I- B# F( z
  608.       mouse_col = mouse_x  x + width2  5  4
    $ y8 O& a6 d( E$ {
  609.     end
    * d  h, [: p4 S% K
  610.     if mouse_y  item_y18 w  V$ T1 b5 E. h
  611.       mouse_row = -1
    % w5 W. \! `! l/ I% l) H, N
  612.     elsif mouse_y  item_y2
    ( _6 L- W) ]' ]4 `. x! l5 A
  613.       mouse_row = -2
    : [5 K) q" n; \7 x) e9 |
  614.     else1 k3 @$ B/ N7 |: }9 c( W
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1), t& V, E3 b: C
  616.     end' Y% g! I, o3 x7 i2 E/ m( F
  617.     return mouse_row, mouse_col/ g+ w5 g/ }: Y0 ]6 X- @
  618.   end2 U6 @. N6 L3 k$ U  a
  619.   #--------------------------------------------------------------------------
    . K3 q# \) \9 s" W' v
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
      {& T* F) m. k1 n
  621.   #--------------------------------------------------------------------------
    5 p/ b  I; c7 Z( V8 _2 b5 `
  622.   def set_mouse_pos
    % l! o: J. n( V; _7 ~  `' s( i( |
  623.     if viewport.nil # necessary!
    : Y# `% ^! w% N
  624.       vp_x, vp_y = 0, 0
    + l- A2 Y7 D6 }0 E
  625.     else
    9 W) e4 s5 H3 J$ H% a8 p
  626.       vp_x = viewport.rect.x - viewport.ox
    ' b) V/ v. f( D
  627.       vp_y = viewport.rect.y - viewport.oy) x8 h* g' @1 q6 A$ l
  628.     end( |: I/ c7 F' |5 D! |
  629.     item_x1 = vp_x + x + standard_padding
    * n0 v# A1 o8 D; {
  630.     item_y1 = vp_y + y + standard_padding
    / i/ I2 K! ]% R
  631.     get_index = @index  0  0  @index
    1 p. q; G3 I. B! S
  632.     row = get_index  col_max - top_row1 s* w+ |2 ~% r3 k" H9 k% [( i) W1 L
  633.     col = get_index % col_max0 C3 ^2 r$ l/ C/ \. F# b
  634.     new_x = item_x1 + item_width  (col + 0.5)+ D/ t2 }0 }( j; V8 V! k0 I
  635.     new_y = item_y1 + item_height  (row + 0.5)
    / x: b2 S( q0 ?0 P0 U6 p& a
  636.     new_x += 14 if col  4
    9 E/ _, Z* N% G
  637.     Mouse.set_mouse_pos(new_x, new_y)* H. w6 {/ M; |  I3 s5 |& ?
  638.   end7 y" M, w8 J+ A. }, U+ N
  639. end
    % R! R0 x2 i3 x. c

  640. 6 F$ q8 B, X, [
  641. #==============================================================================
    1 J& W& }- H6 H, V0 S5 S
  642. # ■ Window_NumberInput- ~! X0 @- s8 P3 Y) D
  643. #------------------------------------------------------------------------------! _5 h  s, \8 u! T
  644. #  重写了数值输入的方法以适应鼠标
    2 a0 ]" b' K& F/ l% X7 _' z1 g
  645. #==============================================================================9 Q" S# V: w' c. w
  646. class Window_NumberInput  Window_Base
    8 {3 a7 P* l& C5 G% F
  647.   #--------------------------------------------------------------------------# P4 F3 Q1 Z. A
  648.   # ● 定义实例变量3 s6 `9 O. e8 |& j# ~" n# z: ~
  649.   #--------------------------------------------------------------------------
    9 [' ?) v; U' ~2 V! ^  ^
  650.   attr_reader extra_window
    1 @* s* e; K4 T
  651.   #--------------------------------------------------------------------------
    * T$ h3 ^& N8 P" }
  652.   # ● 初始化  E: w6 x7 z! J- A) T# x/ E7 O
  653.   #--------------------------------------------------------------------------
      L6 p$ B6 m& p# B3 d6 v& ~
  654.   alias sion_mouse_initialize initialize
    % ^% q. [0 r2 _" @+ ?# j) f; _; P) w
  655.   def initialize(arg)" b9 I+ t' ^$ f
  656.     sion_mouse_initialize(arg). C- d" w2 z  h% |  q
  657.     create_extra_window
    * s. p" n* t5 Z! l' E  ]: j
  658.   end3 T$ Q- U1 C) X( {
  659.   #--------------------------------------------------------------------------
    9 C; G% l! B- s2 B2 W
  660.   # ● 启动& L0 ~6 c6 ]4 r. k
  661.   #--------------------------------------------------------------------------
    * Y% Q7 N3 ^2 f# j. y
  662.   alias sion_mouse_start start1 N( Z2 u+ V* T, a4 f! i3 {
  663.   def start6 G- w; Q$ S5 D+ f$ K) e" z' t; c
  664.     sion_mouse_start
    ; N! y# x  _, q% E" O/ J
  665.     deactivate
    # h2 d3 w. G) h7 ~2 W! L
  666.     extra_start
    3 v7 E. R% F/ @  S6 b  f
  667.   end. r. l7 n, l  o, D$ ]2 F
  668.   #--------------------------------------------------------------------------! W2 M' p- J9 X
  669.   # ● 创建新的数值输入窗口
    4 l% V" ?4 o( `% A/ y" j
  670.   #--------------------------------------------------------------------------
    / q0 I0 G& c* l
  671.   def create_extra_window
    7 F% o( \( A, O; d
  672.     @extra_window = Window_NumberInput_Ex.new, n# v4 I$ {& j3 H  R
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
      Z- g& }# T) m- \3 h7 Q; `
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }1 P5 Z: R3 U( ]  D1 i% d/ D
  675.     @extra_window.index_proc   = Proc.new {n @index = n }) i; D1 Z  G- z: F. U$ |
  676.     @extra_window.close_proc   = Proc.new { close }
    ' ]7 V/ L1 Y! |
  677.     @extra_window.refresh_proc = Proc.new { refresh }: o3 O4 G$ a& N% Y0 ?5 a8 g
  678.   end
    2 U* y9 M; _1 l/ @& h
  679.   #--------------------------------------------------------------------------
    9 M  B( e6 F: t$ n/ l: [7 p' F3 a/ ?
  680.   # ● 激活新窗口4 b* t3 d5 t; _6 K
  681.   #--------------------------------------------------------------------------
    5 ]+ B$ U' P( p: Q- c! v
  682.   def extra_start
    ) a, |- s, L1 N! \
  683.     case $game_message.position2 @1 O; w4 V2 ?$ }/ O! p0 q) l
  684.       when 0; @extra_window.y = y + height + 4
    ( B; c, o* o' I  S
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    1 k9 Z+ R% J+ B9 K$ O( D+ e
  686.       when 2; @extra_window.y = y - @extra_window.height - 4* v& X9 C$ X5 E/ A+ s
  687.       else  ; @extra_window.y = 87 ?! y7 x- {( T7 Q7 q+ a
  688.     end
    + W* F" V  g4 C5 J6 C2 E
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
      X, w8 y; A( h. |5 ]
  690.     @extra_window.digits_max  = @digits_max4 I/ q; E" D' p# g4 Z$ ?  Z
  691.     @extra_window.number      = @number( q  c8 c; `, Y, a
  692.     @extra_window.open
    0 E" N) C/ s* J+ f8 Y
  693.     @extra_window.activate" d( J: U" h% g% N3 x
  694.   end+ S, a, i) J  f5 g& x$ e
  695.   #--------------------------------------------------------------------------7 i$ }+ ^; M6 _; w- V! X3 N' W( S
  696.   # ● 更新; T) {+ T  B- X2 M4 d/ G1 E
  697.   #--------------------------------------------------------------------------
    & q* @. v' ?$ v7 i8 h( l$ P
  698.   def update
    3 k: u, i- o) T+ ~- X
  699.     super, |/ j: Q2 O* n* _' ~
  700.     @extra_window.update
    ' I. m$ H7 ~2 z" w6 A6 o% b8 h+ q( S
  701.     update_cursor
    3 r1 K) Z& h5 I3 {5 R, u' ?$ j
  702.   end
    $ ~1 v3 x7 _* y9 V# S" v
  703.   #--------------------------------------------------------------------------+ i# Y. x9 |( D6 w/ u" p
  704.   # ● 关闭窗口
    $ W8 @  Z) H3 F) }/ M
  705.   #--------------------------------------------------------------------------
    & [& D' I0 r; O: _) P1 ^+ Q% n5 F3 g
  706.   def close
    ( [; Z# Q, A; [3 _
  707.     super
    % G9 Z3 b! ]& a0 `7 y! f8 F
  708.     @extra_window.close
    # h" E9 |+ L+ `) m  Z: v5 b
  709.     @extra_window.deactivate5 D, k$ M, y2 I0 F/ ~9 J
  710.   end' }) t3 H" o7 j6 X& b3 s4 C
  711. end
    ! y) B8 {" Q, r6 H2 N  T4 k* @

  712. 1 Z) V* u" G5 ~) x/ C& U8 N1 o
  713. #==============================================================================! W9 _+ g9 P8 D- X2 A6 H
  714. # ■ Window_NumberInput_Ex8 |5 |% w3 J- p$ Y7 I. P- [: W
  715. #------------------------------------------------------------------------------
    7 S0 N+ J4 g$ O
  716. #  新的数值输入窗口(NewClass)
    ! j9 c, U% x9 J. n' @
  717. #==============================================================================
    ! Y! }# A. v+ ?
  718. class Window_NumberInput_Ex  Window_Selectable
    $ q8 [' Q. l0 j# K  I* ^" ]$ J
  719.   #--------------------------------------------------------------------------- F9 @& e  ~0 l7 l" g- n# d
  720.   # ● 定义实例变量
    . }4 u- @. h) F; }4 E' b" I+ I7 w
  721.   #--------------------------------------------------------------------------
    + r' f- q+ }+ H4 q9 C! @8 e& s& K
  722.   attr_accessor number_proc
    0 H( r7 ~/ o; P
  723.   attr_accessor index_proc) ~0 k5 y8 z; r9 e; E$ u/ D9 B
  724.   attr_accessor close_proc3 {# G( C) n8 S6 Q  ?
  725.   attr_accessor refresh_proc
    - q& Y, W$ ]% @0 F2 c5 O
  726.   attr_accessor number
    $ b- `' y7 t* z
  727.   attr_accessor digits_max
    8 `5 M- b  B/ o3 b
  728.   attr_accessor variable_id/ `2 V* q$ r. R) F  Z. w
  729.   #--------------------------------------------------------------------------0 f% A, E- M8 |4 H- u
  730.   # ● 数字表5 g. w& O" r. U6 Z
  731.   #--------------------------------------------------------------------------  P% X) o: t& R+ A
  732.   TABLE = [  7,  8,  9,# w  o0 x( h4 b- z
  733.              4,  5,  6,
    $ H/ l+ g3 k% I. J
  734.              1,  2,  3,
    " d9 f$ C$ \8 C( H
  735.             '←',0,'确定',]
    % H& ~1 d& z' [0 y  P8 D  R
  736.   #--------------------------------------------------------------------------. j4 @, Z5 L/ ]
  737.   # ● 初始化对象9 ~# v& @* F0 v5 ?
  738.   #--------------------------------------------------------------------------- R9 d0 a1 \4 U
  739.   def initialize
    , z" W8 x1 H6 t" [( Z# l+ V
  740.     super(0, 0, 120, fitting_height(4))
    # t: x$ }1 B& T! G# j% n  w9 h
  741.     self.openness = 0
    ) m: s' Q# A- Y; ~
  742.     @index = 0: J' n; l  h6 ^4 A1 E$ A& g
  743.     @number = 01 H# y0 _$ {" y+ X
  744.     @old_window_index = 0
    # E0 f$ x- J# R  X6 q& S1 c6 H6 L
  745.     @digits_max = 05 d3 k9 g0 o$ _- a; a
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    ; y! L5 D) E  {
  747.   end
    * ^' a0 [2 K6 \' F
  748.   #--------------------------------------------------------------------------
    . f5 }# ]0 v4 B2 e7 f
  749.   # ● 获取项目的绘制矩形& M1 k) E1 J5 }2 ~4 b. X
  750.   #--------------------------------------------------------------------------2 s  z  r, G. p2 k
  751.   def item_rect(index)! u/ Z9 d3 G) t1 r- P" D
  752.     rect = Rect.new
    * _, }1 j" B$ x. Z# h
  753.     rect.x = index % 3  32
    . r) S* n$ ]( B) _! r- }: R7 I7 s
  754.     rect.y = index  3  line_height4 b' _* W  _9 M! `' q
  755.     rect.width = 32
    0 x2 e  W  N) e
  756.     rect.height = line_height
    0 E+ K2 D" c# i1 V8 c; z
  757.     return rect; B, H  c5 }5 J( g
  758.   end+ }6 L3 I$ P$ O  C: m: z
  759.   #--------------------------------------------------------------------------
    $ x: b( {! y0 F
  760.   # ● 将光标设置到鼠标所在的位置
    , G# u5 E& e9 Y1 e
  761.   #--------------------------------------------------------------------------4 G! V9 \& [( T2 f" n
  762.   def set_cursor& E  R  f% f% V, b- @# @6 v6 F
  763.     mouse_row, mouse_col = mouse_window_area  G2 R) {5 |7 B: F' R
  764.     if mouse_row = 0 && mouse_col = 06 ~* f9 H7 ~2 m6 K" f- v$ v$ o7 }  P
  765.       new_index = mouse_row  3 + mouse_col; E4 m  u* E9 U5 n& a
  766.       select(new_index) if new_index = 11
    9 h, ~- `/ K3 P3 ~, }' B/ m
  767.     end
    # x9 |% ?' m) T5 s: F* S
  768.   end
    . l# t& q* r5 h7 Q
  769.   #--------------------------------------------------------------------------
    " X1 W! Z8 l  A7 l5 ^) j
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
      V/ ]3 L( F# j5 P; J% q% h3 ^
  771.   #--------------------------------------------------------------------------1 [+ f+ H7 L* P$ X9 l0 Z. T4 [
  772.   def mouse_window_area8 i; s' N/ T  k4 j
  773.     if viewport.nil
    0 R5 V! l! y7 P* p0 v
  774.       vp_x, vp_y = 0, 0
    8 O& T# s/ p* t0 s7 S. i
  775.     else; K( E7 k5 r/ O8 |- }$ r  p+ ]
  776.       vp_x = viewport.rect.x - viewport.ox
    & ^5 V1 o5 ^- ^# E: Z+ \: ^3 @
  777.       vp_y = viewport.rect.y - viewport.oy
    / h& t6 n0 {4 C) l$ [6 g
  778.     end* W) U0 z9 T: ~- m  b+ [
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    / {, Q4 z, d* P) t2 d
  780.     item_x1 = vp_x + x + standard_padding 2 O1 T7 ~1 c7 T; }! j
  781.     item_y1 = vp_y + y + standard_padding7 W$ X' Q9 p- X2 ^% J9 T
  782.     item_x2 = vp_x + x - standard_padding + width
    & y0 k0 D- s' I7 E* R
  783.     item_y2 = vp_y + y - standard_padding + height+ Y0 y9 ^. n3 t0 w
  784.     if mouse_x  item_x1/ ]4 l7 T& h8 w
  785.       mouse_col = -1
    $ _6 M- y. N* i+ C. c' J
  786.     elsif mouse_x  item_x2
    ( P( u* D' F1 m% n( t3 H
  787.       mouse_col = -20 T! f: z, e9 O. o+ j* t
  788.     else
    ' w4 ?' R- |9 V; M1 p+ W
  789.       mouse_col = (mouse_x - item_x1)  32  `( c4 q5 z4 S) x% X3 @; q4 \
  790.     end
    " c3 D( U# ^4 e7 m/ h6 i6 p
  791.     if mouse_y  item_y1+ `7 S. w! j, n6 S
  792.       mouse_row = -1
    - K( p" E, h' l- _! Q$ f
  793.     elsif mouse_y  item_y20 Y/ h7 P9 R2 V
  794.       mouse_row = -2" ^) {8 }! Y2 B1 ?
  795.     else
    1 F; `. O5 R% s& z0 y1 b: j
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1): s' a$ v/ E' }5 c$ R0 _3 H
  797.     end8 }2 @/ e! [5 x/ x# i0 t- M
  798.     return mouse_row, mouse_col
    3 H' x4 F- N+ Y7 U8 y8 l* O
  799.   end: D5 S. x4 @7 A4 @6 l+ @  }
  800.   #--------------------------------------------------------------------------. S. v6 B7 N; Z* L
  801.   # ● 获取文字1 J, [9 Q1 k; J& _# ], x2 U  ]  Y
  802.   #--------------------------------------------------------------------------
    3 B% S# e6 n3 i+ y1 x! k
  803.   def get_number* O6 ^+ w( q  Y
  804.     return false if @index == 9  @index == 11
    ; |: ?9 ]3 R/ T2 i, f
  805.     return TABLE[@index]" z; f2 D; J% b8 X
  806.   end- l. P3 m4 T* Q8 b
  807.   #--------------------------------------------------------------------------
    . X; ?+ z: z  k- Q$ U$ Y% n7 P9 t+ ~0 E
  808.   # ● 判定光标位置是否在“退格”上
    + l9 N3 p8 O( N8 R! ^' l; a# B
  809.   #--------------------------------------------------------------------------0 L  @+ A0 r1 G+ Z
  810.   def is_delete( i! t: i$ c/ j; N( Q
  811.     @index == 9, Y) ~+ D4 |: W  x# R5 D
  812.   end9 ^7 @  `( b$ a& N$ z9 q% |
  813.   #--------------------------------------------------------------------------+ D  f+ T% ^2 B' I' L1 h9 |
  814.   # ● 判定光标位置是否在“确定”上% g. O3 d) J+ I* m( p/ a$ T) z
  815.   #--------------------------------------------------------------------------$ P. z$ R, q  w0 q4 G
  816.   def is_ok
    8 X* @) F. Q" F% ]$ F6 m
  817.     @index == 11
    / T! J: ]$ Q: }+ F% {
  818.   end# a* S/ ?3 n, w$ M$ ^
  819.   #--------------------------------------------------------------------------
    7 r, G! c+ y8 k' h' q; j
  820.   # ● 更新光标/ X- _' U; j6 J
  821.   #--------------------------------------------------------------------------8 B, {0 H7 V* s: C; b
  822.   def update_cursor
    2 S/ |* g" m2 w. u& M
  823.     cursor_rect.set(item_rect(@index))
    8 P! a: R% N% }$ S0 Z0 ~$ j1 d
  824.   end: a1 r# _$ F, Z" t+ R
  825.   #--------------------------------------------------------------------------  m* I+ @% p$ N# R/ }
  826.   # ● 判定光标是否可以移动; ]3 c8 A4 v2 c1 u  R
  827.   #--------------------------------------------------------------------------( Q( S" m& _4 G+ G
  828.   def cursor_movable
    6 z7 p- j' l! {* c- Q
  829.     active
    " W1 `2 B) c. B. c4 ^4 n% h* J
  830.   end+ r. N# A8 {( J6 ?9 s
  831.   #--------------------------------------------------------------------------/ {6 t9 h/ G# f
  832.   # ● 光标向下移动
    2 v( K1 E) V8 V4 g2 J3 M) K
  833.   #     wrap  允许循环! ^* k: _5 k# ~! ^8 K  ]3 b
  834.   #--------------------------------------------------------------------------
    0 m+ e% p+ X$ v) O8 K
  835.   def cursor_down(wrap)
    / g) F/ p: j! L5 ^% i' O. J' q
  836.     if @index  9 or wrap
    ) C+ e# N. N9 M1 C( t
  837.       @index = (index + 3) % 12, }4 v8 [5 H% u
  838.     end
    : c" n4 x+ s! [4 ~+ c, {
  839.   end
      V/ J7 _" ~! P6 H+ p- c
  840.   #--------------------------------------------------------------------------
    ' n' P0 b7 I) d6 }+ ]2 b1 }3 ?
  841.   # ● 光标向上移动
    ' q9 y4 g3 r0 t9 y+ l! Y$ S
  842.   #     wrap  允许循环) T+ l* H$ v2 G0 m! Y  B- @8 r
  843.   #--------------------------------------------------------------------------
    & h: {$ K3 I8 @
  844.   def cursor_up(wrap)) l8 x) g+ M" E& S) I- i4 O2 ~6 u
  845.     if @index = 3 or wrap
    : b' a/ b/ T  H( c# X; Y
  846.       @index = (index + 9) % 12; Y2 ?. |& v! O3 {& ]' F
  847.     end
    . R6 U( A9 p  g; J( q
  848.   end2 Y% k  c, P% K, }! O: B
  849.   #--------------------------------------------------------------------------6 y; [8 w. K: u, \
  850.   # ● 光标向右移动
    ' J, ], f; x) R; d7 }$ ?
  851.   #     wrap  允许循环; g- {3 H) I6 ?' s
  852.   #--------------------------------------------------------------------------
    ( r9 u6 |+ B7 @! w* F% w1 d
  853.   def cursor_right(wrap)
    # f+ d+ U9 i7 o. j  U% k
  854.     if @index % 3  23 D0 B) y' l9 s) I: T. c( \
  855.       @index += 1& w# \0 C& g" U9 }8 D
  856.     elsif wrap1 X! h, l. X' m1 N9 v" B2 @) y
  857.       @index -= 2
    ; I6 s: U- P( M- ^6 Q& d
  858.     end
    9 B+ S4 F# `9 P; r0 t( d* Q7 b% g
  859.   end
    8 Q* }& c" Y( _
  860.   #--------------------------------------------------------------------------
    + k" G( a! k# R1 X2 u0 w
  861.   # ● 光标向左移动9 p. b' \. ^+ D4 X/ a' `" U
  862.   #     wrap  允许循环( P- Y) f' o% ?2 O2 A, l' h! z/ }2 n
  863.   #--------------------------------------------------------------------------
    ; ?, \1 C. m( h
  864.   def cursor_left(wrap)0 a3 F& \' v. o: w% D
  865.     if @index % 3  0/ ]" O: Y5 v+ d5 A9 H
  866.       @index -= 1: ?. ?. p# i+ `; ^
  867.     elsif wrap; I8 e- Q( g& b- J
  868.       @index += 2
      K+ F1 b$ k& p* _' F
  869.     end) d* m, t' h/ w( |) r
  870.   end
    / E1 o+ t8 ?; u; m5 y
  871.   #--------------------------------------------------------------------------
    ! i) X% ^# J( l3 q, Z
  872.   # ● 处理光标的移动
    : p0 [; U5 D7 z: N7 K4 P
  873.   #--------------------------------------------------------------------------  s0 \4 j* v9 @* y& I) W: E
  874.   def process_cursor_move! v. F( t9 d* l0 _+ A
  875.     super1 e+ Q3 }5 j2 H! ?8 B4 C0 \' `* [& A
  876.     update_cursor9 I; ~* I& ]% W4 s6 F
  877.   end4 {  B) `1 C1 d" `" O
  878.   #--------------------------------------------------------------------------
    ! t/ ^1 O# F* ^3 q6 s. A
  879.   # ● “确定”、“删除字符”和“取消输入”的处理( `8 ?3 e9 z, q9 @! `/ i
  880.   #--------------------------------------------------------------------------6 z+ e6 T$ A$ j
  881.   def process_handling; z% K% u% u3 v; R/ c- J
  882.     return unless open && active
    ( L/ o7 A- T. j+ g2 E
  883.     process_jump if Input.trigger(A)6 e3 J9 O' p2 S; b
  884.     process_back if Input.repeat(B)
      C5 u4 ]$ m2 L
  885.     process_ok   if Input.trigger(C)
    6 J. Z+ d  `0 F& Q
  886.   end$ G0 @; g; ^0 `
  887.   #--------------------------------------------------------------------------
    ) {) Y# Y: z5 W4 p
  888.   # ● 跳转“确定”7 J4 j" s: F" u
  889.   #--------------------------------------------------------------------------% s) P! |, {% [- T+ I! l) T$ o
  890.   def process_jump: j/ c- l- b, Q9 K6 P% G
  891.     if @index != 11# J2 ^: H1 U( `: c0 N7 @( @
  892.       @index = 11
    7 ~4 ]2 \9 S) A$ I: L
  893.       Sound.play_cursor+ |. \0 M, U: w8 F
  894.     end
    3 n3 ~; o0 _1 [4 T& ?* I
  895.   end3 K8 C5 J9 i" i7 N
  896.   #--------------------------------------------------------------------------9 L- k6 Y$ t8 D' u% G! h" ], O
  897.   # ● 后退一个字符3 r# }: Q/ x' d2 y! ^* J0 Q+ V
  898.   #--------------------------------------------------------------------------
    " H6 V/ H" J8 x& E) @  \6 p" v
  899.   def process_back
    ' s: x% g3 c; P3 m8 ]" _& L1 h2 O
  900.     Sound.play_cancel
    " H4 ?5 }7 C# M- H( F* q7 [# `9 b
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    * l$ \& a! P6 g
  902.     n = (@number  place) % 10
    / k+ ?" m# f$ Z
  903.     @number -= n  place
    ) ^. p% O2 ]" V) o* A+ g% \& r: p
  904.     @number_proc.call(@number), a8 F& b5 c, e9 ]
  905.     @old_window_index -= 1 if @old_window_index  0
    $ P8 {3 l" H6 w/ T7 o: I& v- B! O
  906.     @index_proc.call(@old_window_index)
    1 h* k0 \+ g7 K
  907.     @refresh_proc.call0 }& v4 M6 ^& u) p, ]0 D
  908.   end% ^, T# k, }! c  b2 ?% N" e
  909.   #--------------------------------------------------------------------------9 p+ P% X6 L! b2 C
  910.   # ● 按下确定键时的处理  ^' E% ^' E/ ]; X5 G3 ]) D
  911.   #--------------------------------------------------------------------------2 V& m6 k& |; b+ x& V
  912.   def process_ok
    ; P9 `4 _) C, j3 b6 g0 a7 v
  913.     if get_number  Z7 H% j3 v0 Z: V
  914.       Sound.play_cursor
    8 n, K+ N0 ?. H8 c) I( _, z8 |
  915.       place = 10  (@digits_max - 1 - @old_window_index)2 q! C/ ]* X  o% T2 v& t. f1 `5 P" v! u
  916.       n = get_number - (@number  place) % 10: t8 u' j* s2 ^* b% N: @
  917.       @number += n  place4 Y  q3 ^6 g8 q/ L! N6 S& Z) ?
  918.       @number_proc.call(@number)
    ! j+ |$ h$ P$ d( H! `! l6 m- F9 C
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    " Y7 l: h. i! {+ h: `0 d
  920.       @index_proc.call(@old_window_index)8 Z! ~9 h! m5 E1 t0 f6 N6 y+ O
  921.       @refresh_proc.call8 q& l% T. U6 S. O0 W8 M- u
  922.     elsif is_delete# Y* K: _: r3 R2 k. U
  923.       process_back- A& _0 M7 ^! A. y5 B  X( E2 J
  924.     elsif is_ok
    2 o# d: Y/ |# K; v4 k* M" |
  925.       on_input_ok, W! O9 R( n% x, }/ a  I& N
  926.     end
    / ?6 W- B" O6 }7 N& _
  927.   end
    # D: Q5 G8 F: _1 f* i
  928.   #--------------------------------------------------------------------------+ b- q7 `9 z8 M9 |
  929.   # ● 确定
    6 p+ z  U6 }: g* S* v  L1 P9 |
  930.   #--------------------------------------------------------------------------/ H7 K3 g7 x- A4 M* I% z1 D& R  n
  931.   def on_input_ok) v' Q4 Y+ l1 ?" [) i$ W; o: v$ G
  932.     @index = 0
    - m+ m  Y" e3 ~( b* M8 G
  933.     @old_window_index = 03 o4 }" p2 h# R- R+ v
  934.     $game_variables[@variable_id] = @number
    ( W2 a5 X0 N) i. j- s: Z1 ]
  935.     Sound.play_ok4 R* e0 [% {$ E+ ?
  936.     @close_proc.call; g! N' t3 h3 D, \9 t
  937.   end! t+ s8 m5 F+ ]% O* h
  938.   #--------------------------------------------------------------------------
    - p: ]# P- u( d4 B, w/ }) d
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置; O0 g: d  U6 K7 _5 m: T: i
  940.   #--------------------------------------------------------------------------
    0 W3 T7 g) K3 x1 j, C5 o( w( N- f& V
  941.   def set_mouse_pos
    : D# ^& c& O( ^9 s' f8 g) R
  942.     if viewport.nil # necessary!
    ! M  V  @6 M  m, ^! N
  943.       vp_x, vp_y = 0, 0
    : q! q3 b0 Z- Q7 z# ?6 A% J$ h
  944.     else
    8 Z7 |+ f+ |  t5 w* c% `" V( N
  945.       vp_x = viewport.rect.x - viewport.ox
    * j; z/ a! }- O2 w5 f$ Z4 b2 r
  946.       vp_y = viewport.rect.y - viewport.oy, T: g! R+ \$ ?/ h1 }) Q9 ]
  947.     end
    4 u1 k( X4 W* C+ }$ N
  948.     item_x1 = vp_x + x + standard_padding $ ~$ {# q& |' E! t
  949.     item_y1 = vp_y + y + standard_padding$ c9 ~" N0 \* H' U/ p
  950.     get_index = @index  0  0  @index 6 ]( J' h. C9 J+ e
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    7 I7 b9 G2 ~( H6 v
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    8 H# F" g/ K" P
  953.     Mouse.set_mouse_pos(new_x, new_y)
    & e9 m5 L2 k$ i6 a2 X7 ^: y
  954.   end6 A& u9 p' S3 x& F
  955. end
    $ T# R4 X7 U5 w' s

  956. $ p8 n9 Y' Y: m  G6 g1 w
  957. #==============================================================================4 {7 S: l" ~- `/ Y: r8 p5 s
  958. # ■ Window_Message
    0 S/ P% X5 }- _& ?
  959. #------------------------------------------------------------------------------  A  d& g# w% E5 n6 q
  960. #  显示文字信息的窗口。
    / j: P# L: z! q+ {( _0 Y0 J
  961. #==============================================================================
    # n; d. Z: y- V, y* t+ S8 |1 V
  962. class Window_Message  Window_Base
    5 w6 \+ p9 v; @2 H- t
  963.   #--------------------------------------------------------------------------# g1 |' K" x5 C( Q
  964.   # ● 处理数值的输入(覆盖原方法)1 x* |' q  M! E9 w4 ~1 T
  965.   #--------------------------------------------------------------------------# P" l; N) Q8 D! V) l
  966.   def input_number
    ! m) X6 @4 E) e2 d* ^
  967.     @number_window.start! c. }' K$ W" j4 a: S
  968.     Fiber.yield while @number_window.extra_window.active9 ?. [) v7 j$ Y% w) i
  969.   end
    ) @% d  ^7 S9 u/ k! @
  970. end
    ( n) ^$ ~% h$ b- B% m

  971. 7 h+ s% h7 h/ m/ Z
  972. #==============================================================================
    % b& j( N. |5 |9 W4 W: r+ A1 Q
  973. # ■ Window_PartyCommand% V: J) B* R% c/ T( g: W
  974. #------------------------------------------------------------------------------
    & C* c' S/ L0 |4 n( ~1 [; O3 X8 A* O
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    8 B) g! i* E# J: x
  976. #==============================================================================1 O- v; ~3 l" A) {$ U$ C2 Y4 |
  977. class Window_PartyCommand  Window_Command# ?' ^* Z' u- ~; e6 g
  978.   #--------------------------------------------------------------------------) c3 k. m" [' U- ]8 S& X3 `/ W
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ( x3 l2 L% `. J8 B7 l, ?% l
  980.   #--------------------------------------------------------------------------
    ' z: c& v. y8 v7 x1 R% [# B
  981.   def set_mouse_pos
    3 [5 I+ a- g" x  B7 n4 @
  982.     if viewport.nil
    % H% s/ a: h" J. j, e; w
  983.       vp_x, vp_y = 0, 0
    2 t0 u; o0 \' ]7 h# r0 L4 W
  984.     else0 n$ ?1 i! M; \
  985.       #vp_x = viewport.rect.x - viewport.ox
    ) r$ O# k  w$ t$ V$ R
  986.       vp_y = viewport.rect.y - viewport.oy: N( J! r0 F; _! k3 v; ]+ E! h& R% e
  987.     end
      I2 @! J( ~! `# ]* y) G
  988.     item_x1 = x + standard_padding / X' }1 O+ z3 c+ m4 a, o& _# e/ K2 u7 m% V
  989.     item_y1 = vp_y + y + standard_padding( ^% f. }' |! [. w
  990.     get_index = @index  0  0  @index
    9 n! d& {# [/ {! Q$ T* `5 |) ]
  991.     row = get_index  col_max - top_row
    % E! _/ ?% t  I- [/ }: }; U6 n+ E9 s
  992.     col = get_index % col_max7 U6 s+ \; E& e0 }" ]/ }3 }6 T8 Q, i/ y# k
  993.     new_x = item_x1 + item_width  (col + 0.5)
    $ ~$ y; k* N" S5 A$ k2 u+ E4 A
  994.     new_y = item_y1 + item_height  (row + 0.5)
    - R$ b+ a# x$ c3 b3 k
  995.     Mouse.set_mouse_pos(new_x, new_y)5 P0 _1 Y! ^: N3 P& J% k7 X" B
  996.   end
    - d3 S. |0 c6 t" h
  997. end6 H( j+ H. Q/ ]9 g9 c1 `! s' V- E

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

  2145. 7 s) a, n& b* J# @
  2146. #==============================================================================
    ; {, M% u$ u3 q, U0 {, Q
  2147. # ■ Game_Map+ X! D: R5 s7 D' u/ t* i! q
  2148. #------------------------------------------------------------------------------
    8 q( W  T7 H. o4 m7 M5 x
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    7 z* C" [  t- i1 N1 f! q
  2150. #   本类的实例请参考 $game_map 。  i. v  F7 G: A# Q( n
  2151. #==============================================================================
    # S% P- }" C0 d+ O3 I& R5 x- \1 N3 V
  2152. class Game_Map! Q; N0 S& q# K1 x/ H( X
  2153.   #--------------------------------------------------------------------------& Y4 N  \; w0 T9 A( c- n
  2154.   # ● 定义实例变量
    : t" X* e. l; e+ V7 f& e  u4 k, J
  2155.   #--------------------------------------------------------------------------
    % T" w5 E0 P  _* P: j3 P+ h
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据5 c4 q& {3 [. C
  2157.   attr_reader mouse_map_y # 同上+ p* Y9 b7 ?' R& x1 m, D9 V
  2158.   #--------------------------------------------------------------------------
    ; K( _& \& p1 \( Z# R  s8 D
  2159.   # ● 初始化对象
    . h& V) A, b' X+ R/ q, `
  2160.   #--------------------------------------------------------------------------" `1 w  R) T0 g. @* B
  2161.   alias sion_mouse_initialize initialize1 i/ R* Q: ?! M
  2162.   def initialize
    ! L& Q) S& M5 A- U8 X. u
  2163.     sion_mouse_initialize
    0 r, Q' o, S$ f3 V5 d* M' {
  2164.     creat_move_sign  ###1 N7 P7 I! E  `
  2165.     set_constants
    . K0 C. p" {( w" r. Q1 T8 w! x
  2166.   end! P+ c& ~+ Q& K
  2167.   #--------------------------------------------------------------------------
    2 {; h" K- y: g( K) O- J
  2168.   # ● 更新画面
    + b  z3 l# S2 k* o: b' ~  k
  2169.   #     main  事件解释器更新的标志
    : ~' a! y% ^4 ^  `$ q3 h7 S/ [, }) }
  2170.   #--------------------------------------------------------------------------- }8 S2 }; o4 T8 e( n
  2171.   alias sion_mouse_update update! d) T0 k6 o, b$ e" F& c1 v
  2172.   def update(main = false)
    * d  X* c6 f7 g" C- i4 L9 e" I
  2173.     sion_mouse_update(main)
    / @' |8 V! B, T* w. H$ P3 Y, l+ z
  2174.     update_move_sign: J  N2 N* j9 b: }
  2175.   end. A; |7 s* l" H% V2 b! V
  2176.   #--------------------------------------------------------------------------+ {. N% }5 b( k4 U
  2177.   # ● 创建显示路径点的事件
    % e! O% c& w& Y% N
  2178.   #--------------------------------------------------------------------------
    % I- f; c, P' E" h1 E  @& I8 S" q
  2179.   def creat_move_sign/ Q; m/ z+ X5 U; ~2 H( R
  2180.     $mouse_move_sign = Move_Sign.new
    % Q& ]) o# x% z6 j+ C
  2181.   end
    5 l% y+ U* B- w) N
  2182.   #--------------------------------------------------------------------------
    % V3 k+ c( p( O, g7 c
  2183.   # ● 更新显示路径点的事件9 d9 `- ^8 A* D. S! v6 D
  2184.   #--------------------------------------------------------------------------
    , k  k/ Z6 q$ T# B% d. w. }) ^' G( e# M
  2185.   def set_constants' y# H$ y, o+ z; J% M2 W
  2186.     @mouse_pos_setted = true
    + ~; r0 f4 X& V: Y7 f: U
  2187.     @set_pos_prepared = false; T8 g3 T- t1 T
  2188.     @mouse_old_x = 0  V! b$ b) j& {8 Z- C9 P
  2189.     @mouse_old_y = 0, E  e9 I( @( \4 f+ d9 P, W
  2190.   end) c6 V4 j1 M, ]
  2191.   #--------------------------------------------------------------------------4 g3 i( h4 x8 X8 j; p+ u3 G0 U; V7 ]
  2192.   # ● 更新显示路径点的事件
    0 A4 s8 s9 z, o4 @6 M6 I
  2193.   #--------------------------------------------------------------------------+ r4 I5 f+ e5 O) U% x
  2194.   def update_move_sign
    $ x( Z" H) |0 k+ i& p) Q3 ~+ N( Q
  2195.     $mouse_move_sign.update. t! ]! H" _7 E+ b* L; Z. A+ p( p
  2196.   end8 m, X& l, v9 D1 f6 z  n" r* ]$ R
  2197.   #--------------------------------------------------------------------------( W5 T% ?2 \* b2 S% w+ n7 E
  2198.   # ● 获取鼠标位于的地图块的x、y坐标4 X% s4 B  J# M8 a; @; I
  2199.   #--------------------------------------------------------------------------. t! T0 F) ?$ \6 j6 t
  2200.   def get_mouse_map_xy
    ; X) y  G+ e' }2 c$ |7 K4 v1 L; ^( O
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    $ _2 [, S- ?) b/ d
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)  x9 z8 Z* _+ Q+ p+ [, L
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)6 x- _: l4 J" Z6 A, ^  G' L
  2204.   end
    / P* v/ R4 X9 y; j7 y- L9 j/ @
  2205.   #--------------------------------------------------------------------------
    4 F2 U6 q# h9 E  k7 W- X
  2206.   # ● 返回地图画面时重设鼠标坐标
    " V: ^: s8 w8 l
  2207.   #--------------------------------------------------------------------------( r0 e& }% P! {, S' B
  2208.   def reset_mouse_pos, T) _- f9 L. k- q! h) h
  2209.     return if @mouse_pos_setted
    . ~; Q1 q% b9 @3 u: ~- ~
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)  K. a* f6 b( D2 m, m/ Z
  2211.     @mouse_pos_setted = true
    : e' E7 @9 G2 }5 W1 C
  2212.     @set_pos_prepared = false
    2 W1 t+ Q1 N+ n  J2 P' Y, {8 X
  2213.   end  d6 G0 f* z  P2 G: @! Z; {- |
  2214.   #--------------------------------------------------------------------------9 j; B$ n/ h$ |' }( c: H' w! g
  2215.   # ● 重设鼠标的坐标
    # {  `7 \& F% M( d+ k
  2216.   #--------------------------------------------------------------------------
    # R  I! [0 U4 A0 e
  2217.   def prepare_reset_mouse_pos! t$ s3 g* s1 U; H/ ]. S. _) p
  2218.     return if @set_pos_prepared) t6 _+ b# P5 O( v* m- {/ \
  2219.     @mouse_pos_setted = false
    ( I7 l" g3 r& Q6 `
  2220.     @mouse_old_x = Mouse.mouse_x
    ! E' j. B) `! H, y6 {: _
  2221.     @mouse_old_y = Mouse.mouse_y* m' }4 J4 O$ h9 ^3 H0 L
  2222.     @set_pos_prepared = true
    ( u: ~( o+ H0 o, ^
  2223.   end$ d  X) V7 ?( ~
  2224. end
    1 x. q3 \8 J+ K$ i9 t0 n0 U( z* l
  2225. $ w3 }+ n, C; u5 ]. |
  2226. #==============================================================================% K% P1 i- H& M* M
  2227. # ■ Spriteset_Map3 C: R" w$ A) V9 b2 b" y
  2228. #------------------------------------------------------------------------------. O& _3 g  ]# v: ?9 P/ @7 g6 y: {
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    % Q" Z$ v7 I" U9 x/ G) Q4 w* Z  {
  2230. #==============================================================================
    * g4 ~1 u' i' d4 S6 _# w5 P9 n
  2231. class Spriteset_Map
    ' b9 G1 x% z2 w2 o
  2232.   #--------------------------------------------------------------------------5 C3 e2 N2 Q! N) k  y6 a
  2233.   # ● 生成路径点精灵5 P, E* s! z0 g% s, Q
  2234.   #--------------------------------------------------------------------------/ {1 @; k* ?0 F) l' w1 i9 l$ J
  2235.   alias sion_mouse_create_characters create_characters
    : W/ |1 {3 M& v7 h
  2236.   def create_characters
    2 |1 E1 O4 h: b' C- Z
  2237.     sion_mouse_create_characters
    3 Y+ q/ O% D3 R$ v; m: f
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))- _) t$ ^8 q5 U9 V8 N0 A: n% F
  2239.   end0 W1 g- ?- l  R% y
  2240. end- c+ c/ z7 `: a5 G* P

  2241. % Y! m' K" J; j  N/ G
  2242. #==============================================================================
    : F+ c' p8 f5 g9 u/ z5 D
  2243. # ■ Scene_Map1 @9 l3 C* U) L
  2244. #------------------------------------------------------------------------------2 S4 }" i* o. S
  2245. #  地图画面6 [, X: f8 n- f
  2246. #==============================================================================: T3 _; M+ }5 t0 ^) x
  2247. class Scene_Map  Scene_Base
    - B. x5 w2 W- ?1 `$ B2 G0 u
  2248.   #--------------------------------------------------------------------------9 h2 F# Z' o' ~& L
  2249.   # ● 画面更新
    $ B7 r' ]3 H9 }: ?
  2250.   #--------------------------------------------------------------------------
    $ V  y7 H# Y6 F/ K0 D
  2251.   alias sion_mouse_update_scene update_scene3 {" F' ~1 Q9 |6 ?% k, a$ W2 F
  2252.   def update_scene  r6 e! s, f# A
  2253.     sion_mouse_update_scene1 X/ e4 V$ e$ u1 K& E( S9 x
  2254.     update_mouse_action unless scene_changing: m3 z) l. j3 R0 g8 C6 X' M5 l6 T1 h" `1 ~
  2255.   end9 P! c: V* M& Y( a% \! x6 U
  2256.   #--------------------------------------------------------------------------) x4 }0 }3 v9 X
  2257.   # ● 场所移动前的处理
    ( y# {: R/ A  L7 f1 G
  2258.   #--------------------------------------------------------------------------
      r/ f) T9 F7 H+ I6 c
  2259.   alias sion_mouse_pre_transfer pre_transfer, @6 U6 u( u# F' f# E
  2260.   def pre_transfer
    , d' h; M5 R; W
  2261.     $game_player.reset_move_path
    3 |' E( s- B6 y  ]- D
  2262.     sion_mouse_pre_transfer% C& J: m, [/ ?; ]8 X
  2263.   end
    $ X+ P. A" v1 s5 Y
  2264.   #--------------------------------------------------------------------------( p8 Z& M5 D0 s/ j/ ^* j7 {
  2265.   # ● 监听鼠标左键的按下
    $ J! Z2 a! }; U
  2266.   #--------------------------------------------------------------------------
    3 W' r  z$ Z6 `3 u) b% s- H0 q
  2267.   def update_mouse_action
    . A3 x* R; a& x
  2268.     $game_player.left_button_action if Mouse.press(0x01)! ?6 e8 b0 G- D5 c6 q9 Y
  2269.   end
    " n) ~* _: f& {3 a8 p
  2270. end! I8 j. c0 e! ^; ?

  2271. / ?1 ^' ]) _; }0 D; P8 n
  2272. #==============================================================================
    . Y2 U+ X# C; j5 _- b
  2273. # ■ Scene_File
    ; w5 O" Z" Y/ H$ [- F1 y
  2274. #------------------------------------------------------------------------------$ U/ C# w9 e8 p+ m* T
  2275. #  存档画面和读档画面共同的父类
    : `) L6 o2 U! {" _& _
  2276. #==============================================================================
    , A  q) n/ t8 c3 S: d& p
  2277. class Scene_File  Scene_MenuBase, _+ X' u  B& t* U) ~; l
  2278.   #--------------------------------------------------------------------------
    5 s! u: H/ d* C4 f
  2279.   # ● 开始处理
    3 B% O$ B9 [: N9 j8 }0 I
  2280.   #--------------------------------------------------------------------------0 G- a7 f  q0 c- K
  2281.   alias sion_mouse_start start
    * l5 F9 }' z# }% v( w# D8 z, D* R. ^
  2282.   def start
    . j# L+ D3 y; \& g$ ~( A8 T" T
  2283.     sion_mouse_start
    6 c* H/ Z* |$ {! d4 a
  2284.     @move_state = 0# D* X  r8 w: P8 A
  2285.     set_mouse_pos
    , D2 q3 y0 E; K( y7 C! D5 M" Q
  2286.   end& ?1 }6 K( ]* a" {& @+ \' ^
  2287.   #--------------------------------------------------------------------------
    5 U2 R- w3 S: @  x
  2288.   # ● 更新画面
    . b; |  |0 w. ^, K
  2289.   #--------------------------------------------------------------------------' n' K' C+ f" ?% Z
  2290.   alias sion_mouse_update update
    3 X) P0 b) y, U
  2291.   def update
    5 W8 [* F/ Q+ @8 a4 B
  2292.     sion_mouse_update
    3 t! [0 c. s: t3 L
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    : p/ m/ [' w+ C/ V1 g* T* e
  2294.   end
    6 c+ r) x3 H. S5 k! l
  2295.   #--------------------------------------------------------------------------3 `( [$ N+ ~9 F1 j6 c
  2296.   # ● 更新光标) j( y  d( k* \+ h% }; @
  2297.   #--------------------------------------------------------------------------, z7 l% o: _$ ~( Q3 r, }$ `* n' d! g
  2298.   def set_cursor, v( x) D- f# S. p- a
  2299.     @move_state += 1/ y) s/ l( a3 d+ V2 N
  2300.     last_index = @index  b5 D3 z# [0 f: M
  2301.     if mouse_which_window == -2
      }0 f. `( \" w! _$ ^: F; z1 {9 J3 |3 ]
  2302.       if (@move_state - 1) % 6 == 0
    / c3 C4 p& o: @9 E9 z# b
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    0 r- P8 H& u) ~& C! o* h% ~; x
  2304.       end
    & N" H) a% ^$ z: A5 D
  2305.     elsif mouse_which_window == -1
    ( |+ U. G, w& ?0 w5 l+ f
  2306.       if (@move_state - 1) % 6 == 0
    * v5 K: e, o- O7 M
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    - J' J! `9 c9 n- B+ y4 |) v8 m; S
  2308.       end
    5 J7 X$ T* S* y2 \' Y- i
  2309.     else8 |2 o, p1 `: J. g+ o
  2310.       @move_state = 0, U6 s8 Y, _% A
  2311.       @index = top_index + mouse_which_window
    , ]) k1 ]3 T2 G0 c- S$ B
  2312.     end
      s. H" w, k$ T0 W
  2313.     ensure_cursor_visible
    8 s* S8 C" I! P$ R& h4 q
  2314.     if @index != last_index
    ) r4 Z# h: W3 M8 D
  2315.       @savefile_windows[last_index].selected = false
    3 J. z7 G- }: ^9 r& S) w: ]" K
  2316.       @savefile_windows[@index].selected = true& D+ f  J. P  r2 ?( I" o" P; |2 q
  2317.     end
    . j* ~4 m3 ~/ Y/ k+ t; Q
  2318.   end8 R. @& j. V0 `) J9 Z' l. Q
  2319.   #--------------------------------------------------------------------------
    2 `7 ~0 `# G8 L6 s: r! `1 [
  2320.   # ● 判断鼠标位于哪个窗口6 h7 C: n; x& V/ M. O% K
  2321.   #--------------------------------------------------------------------------
    % G& c+ g3 {  M5 n8 i# @0 S
  2322.   def mouse_which_window
    2 H3 O1 N/ u7 e$ ?
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y7 R# B. N/ n' N/ ?% ?* m
  2324.     if mouse_y  @help_window.height + 14, k/ h2 @0 R* m1 a: S& C' O
  2325.       mouse_row = -1, r) E; l( N$ Q8 G- V
  2326.     elsif mouse_y  Graphics.height - 14
    $ O+ O/ f; x' X
  2327.       mouse_row = -29 N" r& M9 B4 L8 w0 Q" @4 [
  2328.     else/ J# P% K7 U# n, _
  2329.       mouse_row = 4  (mouse_y - @help_window.height) 9 U: z: h, a' ]/ [; h
  2330.         (Graphics.height - @help_window.height): K7 p. i, d' G* `' v5 U4 k6 [
  2331.     end; Z6 H% T2 o6 K. f$ d
  2332.     return mouse_row
    ) C, p: X) X" I
  2333.   end6 m- S0 Q$ z$ n; f7 \, k/ g
  2334.   #--------------------------------------------------------------------------: H& P- A- `: K0 _
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    : H# ~9 J8 X# L9 z5 e8 X1 E
  2336.   #--------------------------------------------------------------------------
    % B- S/ W# m+ z: P. w9 @
  2337.   def set_mouse_pos
    / B# S$ G) u' B6 |7 u& W( r
  2338.     new_x = 40# e9 e4 c! u- V; u% }3 l; w
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    # m: N* p1 [7 ?. \- S
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    8 v! ~- f, A4 P! Y
  2341.   end
    4 o; `4 v" U9 P! [/ H1 `
  2342. end
    ( A. l0 o5 q" [- S; y: c
  2343. ! @- H# o6 e. l
  2344. #==============================================================================) {  k  q* v: Z8 E/ b. o; N
  2345. # ■ Game_Event+ D, p+ q9 _! w  k- V+ H
  2346. #------------------------------------------------------------------------------9 @! R- a4 a- a7 f
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    ) r  q) q& L# y. o7 d
  2348. #   在 Game_Map 类的内部使用。. u2 l/ J* u1 _( A
  2349. #==============================================================================
    , U; G; Q7 C3 F0 W( u" }& N
  2350. class Game_Event  Game_Character+ r6 }6 s/ ]$ Y3 }+ q$ Q% u8 g% ^
  2351.   #--------------------------------------------------------------------------
    $ }! @2 N0 |) i% i; K
  2352.   # ● 事件启动8 Y1 T, g! k5 i3 H
  2353.   #--------------------------------------------------------------------------
    7 |% F: e1 F  x4 r
  2354.   alias sion_mouse_start start$ j7 \& N( O0 v1 ]" _
  2355.   def start, V- b+ m2 G5 |: s1 ?+ v5 M1 F. b
  2356.     return if mouse_start && !Mouse.press(0x01)
    - ?' v& B! R9 T5 e. m5 p( h
  2357.     sion_mouse_start+ T8 b6 }5 F% `+ d" B
  2358.   end5 ^4 v. n) K0 D& v, r. h/ _) _
  2359.   #--------------------------------------------------------------------------
    3 Y8 H) `% y: w$ z
  2360.   # ● 判断事件是否由鼠标启动
    ' R( A5 F! G8 i- `- r, Y: B- t
  2361.   #--------------------------------------------------------------------------5 b. Q! K1 }* z
  2362.   def mouse_start. w- w& p0 \9 W. }0 n" P, v
  2363.     return false if empty2 A, i; D; L9 U; ]6 A8 p- f! |
  2364.     @list.each do index6 n; f7 a0 R# K
  2365.       return true if (index.code == 108  index.code == 408) &&
    : r) F2 Y- b5 ~7 K/ L9 \9 o
  2366.         index.parameters[0].include('鼠标启动')0 y3 T, r7 ]$ M, k: \! \' g
  2367.     end
    7 ^/ E/ t8 k; L
  2368.     return false- _# ?; M6 G# A. H
  2369.   end# a  l3 n" M0 A& C8 ~& G; v% d( H+ S) N
  2370. end
    $ ^' b. v) X( [' P( r( k
  2371. & @2 w2 O9 i, a& q0 @
  2372. ####泥煤的height. _* j6 c0 {+ w2 i$ H# I
  2373. # @height = height3 w" J0 y: W- t% O3 H. f

  2374. & _" x7 A0 \& G- T& j8 P- ~
  2375. class Area_Response# o% H- Q. P8 w, A
  2376.   attr_accessor type, C" f) Y+ P' a
  2377.   attr_reader ox# c* E" o) v! ]' l
  2378.   attr_reader oy
    8 X; s9 R! _+ R' Z/ o% S( A! p. I
  2379.   attr_reader width% s' p! [1 r; d  u$ ^7 Y5 r- L3 N
  2380.   attr_reader height
      e1 V* V/ L! f' y( Q
  2381.   attr_reader switch_id
    % l  w$ X0 ]0 W; E, Q* ^9 _
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)3 U1 z) H5 F: H: d
  2383.     @type = type
    : Y$ _( _3 D9 h( P, s' \
  2384.     @ox = ox
    5 s& v5 m! Z, F" u) S
  2385.     @oy = oy8 v( ^& c6 p" H; `6 `- b
  2386.     @width = width
    / V7 R  C$ q3 o
  2387.     @height = height( G; o  S' _4 ~5 P+ I
  2388.     @switch_id = switch_id7 c  c3 {+ v- n" Z9 o
  2389.   end
    ! m2 P4 L9 B0 z/ A/ v8 \2 V# g
  2390. end
    * |% O( \+ E/ c7 y/ C! |' L

  2391. 6 ?; K/ o% P" S) U$ ~; v+ l' d
  2392. $area_responses = []
    " ^8 z$ m; h. H# t8 `) J
  2393. 7 @' i3 l" P4 _6 H- q" }7 ~
  2394. class Scene_Map3 O* n: G: O& [4 v( p
  2395.   alias update_mouse_2013421 update_mouse_action" U' U. w  R4 L5 R9 \
  2396.   def update_mouse_action; E/ _/ H  q' @2 g" K" S8 M
  2397.     update_area_response
    ( S# X. Q* C: {& o& X& K
  2398.     update_mouse_2013421
    2 A! g; S! B- M; Z4 `
  2399.   end* v: I  a" R2 R. N0 J( ?2 V
  2400.   def update_area_response/ G0 |: B% @& E" S6 c! D: p& o
  2401.     responses = $area_responses
    0 e. {# E; f, K* ?/ q0 o
  2402.     responses.each {response
    : i7 I8 A( O' Q/ m" O# c- O
  2403.       ox = response.ox
    + ^" ^+ x  M# n2 e5 i, |8 E
  2404.       oy = response.oy
    ! ~4 b+ E0 O/ V7 E
  2405.       width = response.width# I+ B$ J5 u1 s0 V0 A% ]6 U
  2406.       height = response.height7 I" i2 T( U; m% ^
  2407.       switch_id = response.switch_id
    * X& A7 x- \6 ?$ ^" B7 k
  2408.       case response.type
    8 V: L4 x) |  |
  2409.       when 0
    # r8 }" V7 z/ j$ ~% E6 S
  2410.         if mouse_in_area(ox, oy, width, height)
    $ m: k- e# l: X5 P" B9 C% Z4 @
  2411.           $game_switches[switch_id] = true% o' A# F  p5 P4 q# {+ h% G' E( l
  2412.           $area_responses.delete(response)
    + t! d6 e( u9 H4 m6 l' Q7 ]- r; O& P; _
  2413.         end% N2 k' j- _; L6 f4 n6 F+ c3 s
  2414.       when 1! E8 _* P% z% ]$ o* }. B2 G# i0 Q
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    , i% w7 l3 S* ^  ^/ t- m8 p2 N1 J
  2416.           $game_switches[switch_id] = true. v# v7 M  {9 I3 i% U+ g+ E
  2417.           $area_responses.delete(response)5 N& Y% T  q2 N
  2418.         end
    : q6 Y( i$ k4 Q2 `' F
  2419.       when 2
    - Q$ B  l# w+ y: m" n3 q
  2420.         if mouse_in_area(ox, oy, width, height)' B2 w0 ]7 l  w7 ?1 D% ]& e
  2421.           $game_switches[switch_id] = true+ M4 w# D3 \; u: d% r7 `/ Q
  2422.         else) F6 N2 v) ^6 ?  m7 ~
  2423.           $game_switches[switch_id] = false
    . h) T; V5 f  L- v6 c2 `
  2424.         end
    7 I5 m. x( k" y4 ^- {( [, |  [# B
  2425.       when 3, K" w. i; f0 o5 M) G# _6 u
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    - s8 B* {/ }0 I" M, t+ R' ~
  2427.             (oy - $game_map.display_y)  32, width, height)' y  R; `, L2 D# y. b3 k8 ?
  2428.           $game_map.events_xy(ox, oy).each {event
    & q. o  d& V3 U4 |& ]* u) t
  2429.           event.start
    2 B5 ]+ b' N' |
  2430.           $area_responses.delete(response)  H8 J: L$ Q4 F) T
  2431.           return6 w* P  y( E1 [: O0 Z4 q
  2432.           } # c" A( k; c5 J- D# A- y6 J
  2433.         end
    $ D) e; c/ @- i4 |
  2434.       when 4$ w! P/ p$ p+ D5 @8 c1 F9 E/ M" T
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    : H( k2 `& r9 I. H# R4 _4 O
  2436.             (oy - $game_map.display_y)  32, width, height)
    - H( x5 V, u& I: t  K) k+ U4 s3 v# z
  2437.           $game_map.events_xy(ox, oy).each {event
    1 S* v: Y  U" E
  2438.             event.start
    ; p& ~) }0 Y- Q/ d$ E4 ]
  2439.             return: X- e, O) x& d& [7 E! w
  2440.           }
    1 d/ z) U" ]$ `5 S/ l
  2441.         end
    * p2 u* n/ p  Z
  2442.       end
    : X+ D; N: R' {5 k$ I# T0 ]
  2443.     }5 ~) _( Y. R0 N1 b$ k
  2444.   end
    " V1 F) M/ m( ]8 Z
  2445.   def mouse_in_area(ox, oy, width, height)
    ) D( C( H  q; c: F
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&/ G  {  e: ]. l5 A0 H- E/ U
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    8 y7 y( w/ h; F3 Q8 U% ^
  2448.   end
    % R" m6 t% ]% `# K9 k
  2449. end7 k8 Q) v6 ?. d2 T9 W7 U+ Z
  2450. class Game_Interpreter
    8 J- L: W+ T5 \  w* K4 v: e! |5 E
  2451.   def area_response(arg)( d) d2 t1 l! N
  2452.     $area_responses.push(Area_Response.new(arg)); |; U! q- O1 D0 v' \5 t  H
  2453.   end
    . y0 ]5 d# Y. A$ q" k
  2454. end& W. [1 V* W. h( U
复制代码

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

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

GMT+8, 2026-7-28 03:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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