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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    . f3 j) w* F  W5 R+ \5 {
  2. 2 F# [1 t; I' t- f/ y( s# r
  3.   Sion Mouse System v1.3e! l. }: x- f# q# I/ Y+ `' d
  4.   
    ' }& A3 o* T! f7 G( z" s$ Q
  5.   Changlog
    $ |! g# ]6 ^' ?2 l" i& h4 L
  6.   
    ' J; ]/ n/ V, Z7 y( Z0 p) t; ~
  7.   2013.4.21 v1.3f
    4 D, x& d! V. f! {. S" M& L
  8.     0 X4 L/ t' A; W9 k& ]& C
  9.     1.3f 卷动地图 bug 修正/ Q: t& y- O4 ^# N, i( ^% m* L
  10.       T  I) h4 g/ _% Y& e8 S. m
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口9 G: e  P( R  l
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内& ?7 }" W8 I$ {; K. G
  13.                               Mouse.unlock_mouse_in_screen 解除锁定( x) h) w: I1 f8 m/ J3 ~" t
  14. 1 h" `7 U- H7 U/ r0 D6 W; L
  15.     1.3f bug修正6 `6 C' `( p( T0 d- l& i
  16.   
    ( L% }4 ]/ h5 N% [
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及. s% ~. Y6 ^4 i& {9 i
  18.           关闭菜单时,鼠标是否移动到原来的位置。8 i+ W6 s6 o  R2 I. e! N
  19. ; I9 h' [6 a' P/ q2 z: r
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处/ |/ h! d, Y& B& W/ v

  21. $ t. @$ C/ |8 Y
  22.     1.3b 修正一些罕见的bug;9 g9 l- Z5 e" v6 d7 r/ p

  23. 2 r' Q) e8 e; o  I/ n7 |
  24.     1.3a 代码小修改;
    / b- s& \% R; O! V' Y8 H
  25.           加入了鼠标点击启动事件的功能,7 r8 r+ C9 @1 e1 s0 o
  26.           在事件中加入“注释”: 鼠标启动  ,+ c/ W2 U* P% T3 {" t' P+ P1 x
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    7 }& b, P* e  s/ A4 z1 {& e
  28.   ( Y4 J5 E  [$ F! `# I- ]% k! `
  29.   2013.2.12 v1.2
    * Y5 A/ w0 x+ I& E
  30. + X+ ?7 Y: [7 g' K
  31.     寻路逻辑优化;9 e; E. ^# ], x# t. n
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    + ^7 G2 h' g$ O( ~' ~% f
  33.     现在支持用鼠标来操作载具了。
    , u; B! I7 H' K  T1 s
  34. 1 h; V$ _2 M# E8 P. O7 e
  35.   2013.2.8 v1.1, a" ?. i  s; S& y& {: c, U4 x
  36. 4 h$ h3 l/ K& f) ^
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;: Y1 J1 a* Y  k% v. e2 n  k9 Q
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    8 g6 z0 s  ]% a2 d7 {) \) _% V
  39.     移动时,路径指示点的绘制更加稳定;
    ) D0 x6 g. ]/ ]! _1 ~
  40.     现在支持默认存档画面的鼠标操作了。: a) @' H# R- t. a! b( a( ?, c
  41. 7 e8 H" K0 i' ^2 j
  42. 6 q- Q# v+ ~8 F7 \. J
  43.   OrigenVersion
    8 a& s2 Q$ M( M1 L& F# j0 O$ `
  44.   - w' R- j$ u# y7 @( M$ S6 x
  45.     2013.2.7 v1.0 / u$ Y3 ~; c/ n! Q/ }5 W$ a
  46. # ^) V! Y% u3 A! ?- R8 ]+ d6 |5 k
  47.   主要功能  N* f1 E; H2 n  I& T1 s- C! c

  48. % l! \: ~9 C* C7 R0 I( c0 Q) t6 x
  49.       使用鼠标进行各种操作...
      \, x. l, S1 [4 U2 @; ^: c7 Z) L1 S
  50.       将鼠标锁定在游戏窗口内
    2 s, r/ w( d# Y
  51.       自动寻路,按住 D 键可以扩大寻路的范围- m" q" q, L) [( `7 p5 r* i+ d' ~
  52.       双击鼠标进行冲刺9 y% z( c& H" q9 y! b8 S
  53.       更改地图卷动方式以适应鼠标移动6 U& Z8 x  t! I. U$ y
  54.       变量输入框改良
    & H! p0 C) z: y- d$ S1 y
  55. $ I  X. b5 b9 {- f& [6 x
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹( \, U, _; p% w4 u5 Z6 E; m  U
  57. - q- J+ A6 O+ A9 \2 @
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    $ g7 T/ V; M& Y# \
  59. ( z3 G4 c5 m1 I3 Y& t
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    ; D* {+ ~( K1 A
  61. - F  C0 x9 K- i5 P( F4 P

  62. 3 @  I% h8 f5 m- @7 p' X
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    . r0 I/ g7 p* d3 s
  64. 3 E- r- \  z) G7 y. h1 ^
  65. - f0 t! \9 J2 }- i( V
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    - Y6 M( I7 l- R, y
  67. 5 ^9 q! l( z7 D! C) v% _7 }# c
  68. #==============================================================================
      X+ V% D! Y: l3 ^
  69. # ■ 常数设置
    ! o& z3 {; s: i5 U5 E6 w6 x
  70. #==============================================================================, Y2 O9 E2 I" q
  71. module KsOfSion$ m# f2 y' G/ Z& y
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    1 m! T# P$ J) l2 ?
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    9 H4 Y, r. F* Y0 c
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false% v' l  s$ f" D4 z
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    ! C2 h6 `2 R+ O, j! G( J7 M* ]
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    % V  n  K: X9 C$ E' D. _5 S
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    : k$ Z. ?8 D9 |0 v0 c& R/ L
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13): o6 a9 T1 w& }  u2 R
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    & J8 f1 F6 k5 \1 n
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    1 K9 O1 }( y6 H# t: Z
  81. end
    - T, H- V! Q9 @3 b, T7 p- i

  82. ' N. ?2 t, j, _% G! k6 ]
  83. #==============================================================================
    * f! r# `. b3 \: D" C9 O# a
  84. # ■ 用来显示路径点的类- @& i1 E1 e2 C0 E' Y
  85. #==============================================================================
    + i+ b1 q5 O" q$ Y" h
  86. class Move_Sign  Game_Character
    7 d( w9 R) a' V  S2 o
  87.   #--------------------------------------------------------------------------
    " ~4 I" v7 J) O* N# l$ D
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图* K$ R( s% H2 r/ K+ ?' B
  89.   #--------------------------------------------------------------------------7 V6 G% a5 U$ C# u
  90.   def init_public_members
    3 d% [' n: |. r' v- D: h
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    8 _0 P; Y- \$ h
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    . B( x# m: S" l- |
  93.     @move_speed      = 5        # ★ 踏步速度8 O  i" r! z' {- ~1 \" d
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    $ G  G3 R8 n/ R" S/ i9 T$ n
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    ( V& @9 R) [* i0 }4 L
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    . a* Z, t- r. I' K/ h( I
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    5 ^/ J& `: }# o2 N4 Y
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)7 a1 m) X3 I& d3 n. P- Y, p

  99. * B0 z" _% J7 D7 `& x4 H

  100. & B  f3 t$ n, F3 F- V; o
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★( V: m& j5 n, G5 s9 A
  102. 8 [5 u7 J. @6 ]
  103. 4 e5 ?" F/ m' l3 y( y/ h
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图7 q0 }. V! d2 s. A& z; R# v* D; p
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png'). B, }1 W  M0 o) N) {
  106. + _! n4 c( n6 O5 T# a/ F% T
  107.       if $no_arrowpic_warn5 Y! k  h) w7 T  O$ N& n' G
  108.         MouseShow_Cursor.call(1)/ |, E7 Y- p) P
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    / h% j2 n* Q  N2 P' g4 h: ^: ?
  110. $ x: [0 B8 y/ @8 o- u
  111. “路径指示点”将使用游戏自带图片; b: w' @' D6 Q

  112. 8 R5 \2 s& `+ R8 Q5 F
  113. 该提示可以在脚本内关闭'), ^" V2 H: N$ a: W0 c4 D
  114.         MouseShow_Cursor.call(0), [& y3 J9 h9 ?) Z; C; S6 j- k. Y5 }
  115.         $no_arrowpic_warn = false- D0 a2 @- N6 |4 l( |3 b
  116.       end
    6 K0 ], C/ f  }- g* s
  117.       @character_name  = '!Flame'5 _  a1 M, ^# i. N, |7 Q9 m4 D
  118.       @character_index = 6" \* g7 f& r* P  X
  119. : x4 G4 O3 E2 p' N, |
  120.     end
    / ?* x/ ?& S; K  @9 \
  121.     @direction_fix = false  # 固定朝向- o9 E9 e* e+ _; W. q6 J+ H" s
  122.     @move_frequency = 6     # 移动频率- k$ k/ A7 P4 ?
  123.     @walk_anime = true      # 步行动画
    2 h; S  ~+ T) e
  124.     @pattern = 1            # 图案- R/ p/ W1 n/ u' Z; \. Q
  125.     @through = true         # 穿透( ?! V% Z, V0 Y/ h
  126.     @bush_depth = 0         # 草木深度
    , X! y4 I: E8 T& x0 D+ e3 q
  127.     @animation_id = 0       # 动画 ID$ d, S' @4 S+ r% B0 _
  128.     @balloon_id = 0         # 心情 ID
    ) u3 Y0 A8 k, z4 z% w( Y
  129.     @transparent = true     # 透明
    : c1 }2 s7 e# l4 g
  130.     @id = 0
    & p0 t3 Y! I( j4 y9 M$ j, ]
  131.     @x = 00 \. ?# j3 S* O* S7 E3 }
  132.     @y = 04 E% P& n' I$ x
  133.     @real_x = 0
    # Z1 Y; O) i+ |9 y- n: E
  134.     @real_y = 0
    % i, [- p1 O* j2 K( l. Z
  135.     @tile_id = 0
    4 R7 V! ?7 |. F9 K. C1 H1 b
  136.   end
    # N$ \. ~3 \4 n/ g- V
  137.   #--------------------------------------------------------------------------, A, i" `7 f& X, @7 |3 D9 b
  138.   # ● 定义实例变量
    ) _3 `2 _8 \" ^; a8 M
  139.   #--------------------------------------------------------------------------
    9 G4 }2 _( h$ \/ o( a! v: U
  140.   attr_accessor direction+ ^4 b- {& W0 p
  141. end4 M1 ?/ h  v) _% r7 ^5 y& [. _
  142. * ~2 h! i1 u, y8 X2 ~
  143. #==============================================================================
    , D6 [+ t, S0 \3 I, e) b
  144. # ■ Module Mouse
    - V" s. c" x2 c$ c9 V
  145. #==============================================================================
    ; F+ q( J# K5 q& E3 f  N
  146. module Mouse
    . T+ G, D# q' X+ H% d
  147.   #--------------------------------------------------------------------------5 t; _0 L3 P) `# S& F5 S
  148.   # ● API
    6 E, `- {, S* s6 F! ~
  149.   #--------------------------------------------------------------------------
    - R% ^5 Z8 [9 u
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')6 G" R1 m* ]$ U* o' E& i4 U
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    3 r( C1 ^4 V5 x
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    7 d% l9 j2 X0 j* w
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')) n+ M  R) e* j1 i( K9 j
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')0 i% p3 l6 c) e
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    , M9 {" R! Z0 ]5 c
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')8 I: @) k) t  X1 R6 n, w+ c
  157.   Window_Hwnd       = Get_Active_Window.call
    1 p1 W' H8 t& P0 H) c7 M# Z
  158. $ \: W% o$ o* L2 s; P, f+ W3 `
  159. class  self
    5 |1 B) V0 c8 c' x
  160.   #--------------------------------------------------------------------------
    * K: Z; |# k  J9 {3 X: ?" N) P
  161.   # ● 初始化) }. X5 B* L+ c
  162.   #--------------------------------------------------------------------------
    . _! _5 p7 y& n! n
  163.   def init# j2 E! l1 D# Z( f; K9 k5 s/ [
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    2 {4 r' q* Z& T7 l( H% g+ u2 m2 P
  165.     @left_state = 0
    # n/ R5 l. g& }4 _5 u! N" W+ ^
  166.     @right_state = 07 _3 E5 f2 h7 E# a4 z& H6 V# Y
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    - `) ~3 A5 C) T) f, s) [% R
  168.     @dk_count = 0 # 用于双击的判定/ z: [) H* a; Y0 r, S
  169.     @clicked = false
    0 E  r, z! |0 Y( a# R
  170.     creat_mouse_sprite# \# q9 v( j* ^4 t7 f5 N
  171.     update
    . t$ G- u* @, a1 q
  172.   end6 j7 o( s2 u& p) d9 l
  173.   #--------------------------------------------------------------------------, j( f3 Q" `/ n+ Z' X' z
  174.   # ● 鼠标指针精灵
    + V% b/ K% b8 Q$ y# ^) U3 Z
  175.   #--------------------------------------------------------------------------
    # G- d7 @; Q) Z; Y- o9 Y2 _
  176. #~   def creat_mouse_sprite2 R# ^/ {# u' V% c4 Y' n% @2 Q
  177. #~     8 v! b) G% J5 }, q( A0 q% T5 e7 [/ p: l
  178. #~       @mouse_sprite = Sprite.new
    ( L7 s/ \) \/ T% u. e% I
  179. #~       panda = 2#rand(2)+1* Z! [- K" y' W9 f8 E- h8 V

  180. 0 |! \* e, p# N& K
  181. #~      if panda = 1
    5 T3 u6 O- n; h( E5 B7 x
  182. #~        if File.exist('GraphicsSystemCursor2.png')' Q0 }8 I) }: _$ \1 d
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    1 L3 r+ N+ F8 @1 z' M' c
  184. #~        end#with if File.exist& [) c9 l# H- q% a' K
  185. #~   
    . C- ]5 C  L7 C) N  I0 [
  186. #~     else if panda = 2 #with if panda=15 ^% t. R" {+ P5 q7 f- h
  187. #~      , n3 J2 s( Y6 X- n! e) Z% u
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    & _% i" ^% L" \0 g0 z
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    8 y! l9 @9 r9 y1 e2 |! F
  190. #~      end#with if File.exist  S. b( a8 X/ b7 c5 v' Z. V# M
  191. #~      
    - z# n- T( g( \4 g
  192. #~     else #with if panda=1. }1 t, U# I. f8 Q
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    - i5 L6 }) {/ Q/ K5 C
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    - A$ u- d: L8 w# @+ \
  195. #~       Rect.new(5  24, 24  24, 24, 24))9 m( u9 h6 W% t3 h! P
  196. #~     end#with if panda=17 G! j* Z' q" D/ J
  197. #~     4 c- W& O$ S0 Q6 `6 y2 D2 E
  198. #~     #with def5 k- _. W! y; a, c8 i* d/ P7 k6 h6 F
  199. #~   end$ S& q: Y4 m# d% O, H
  200. def creat_mouse_sprite
    0 j7 s9 o  f+ E' ]5 ?+ E
  201.     @mouse_sprite = Sprite.new4 @; y2 G1 w% a7 n* S
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    ! N6 G3 _; i* |* _7 e! H* P
  203.     @mouse_sprite.z = 9999
    8 q: B! u2 l0 a/ i) u! |
  204.     Show_Cursor.call(0)
    , m3 F; \2 ~- B' ~& w% H5 g0 w+ I
  205. end0 C8 Q2 U9 u* m' W

  206. ( v9 X& B! m* s3 l, D5 i9 Y$ g; w4 C, s
  207.   #--------------------------------------------------------------------------
    ' U/ U0 ]: v8 R
  208.   # ● 更新
    ( x- x0 x, N9 g
  209.   #--------------------------------------------------------------------------
    ! d" x0 J2 K3 k7 Z7 t0 d4 u
  210.   def update" v3 j+ v5 c, W+ o2 T2 p
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos+ }) u$ J# l$ V
  212.     left_state  = Get_Key_State.call(0x01)8 I# r! `* X) Z, R  z4 m, S5 v
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    8 S. {5 r3 t9 j
  214.     right_state = Get_Key_State.call(0x02)
    2 T2 {/ i1 D$ \
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    , f% C, ]: l2 L
  216.     update_double_click) b$ c" c: c, V( h  @
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    * B' I* [2 V! d+ o. o/ s' U
  218.   end
    5 ^' ]$ K( X( k9 w: h
  219.   #--------------------------------------------------------------------------
    * Z4 \) [/ h1 K. ^
  220.   # ● 获取鼠标坐标* w$ w! A& D8 y! u0 h1 Q
  221.   #--------------------------------------------------------------------------
      A( z6 A8 X! U$ l# h2 V  p5 y
  222.   def get_mouse_pos
    % ~, n2 ^$ q6 H7 {
  223.     arg = [0, 0].pack('ll')5 B8 x1 |6 S* x! K' ?% W
  224.     Get_Cursor_Pos.call(arg)$ Z; ~" V+ c+ y/ o+ Y
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    " l1 L( B& x: Y# n" M
  226.     x, y = arg.unpack('ll')5 F  f' K  h% T6 y. ^
  227.     return x, y
    / u9 `! }9 [  \7 X6 f
  228.   end
    6 K& T4 s- z  }' R9 A
  229.   #--------------------------------------------------------------------------, q, Z( g, o& z3 ^6 U1 s; u: P
  230.   # ● 将鼠标固定在屏幕内( y" b- d; C6 }. _1 B' t9 D; k+ I
  231.   #--------------------------------------------------------------------------
    ; u; k  c: O1 W: l' X( Y
  232.   def lock_mouse_in_screen
    ) e' ^! W. o8 m# k. F1 n
  233.     arg = [0, 0].pack('ll')4 F  ], y8 x& I% \/ f: u, `
  234.     Screen_To_Client.call(Window_Hwnd, arg). ]' y$ h0 W+ u- k$ }& W
  235.     x, y  = arg.unpack('ll'). a# Z& a6 [% Q) {* _1 _
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    . w2 W* E+ B, @. F
  237.   end3 l$ d( x5 ~! m6 o, R
  238.   #--------------------------------------------------------------------------8 W; X/ L! ^2 v: L! Q% x0 o
  239.   # ● 解除鼠标固定
      S- k! q/ f: C! N
  240.   #--------------------------------------------------------------------------1 o7 \; i9 v2 Z4 }. o( V
  241.   def unlock_mouse_in_screen
    . n0 z* O5 x; w4 Q! S
  242.     Clip_Cursor.call(0)
    $ E0 W4 ~" f/ D6 t0 I+ V$ }. G! F
  243.   end# h1 \* m" r: H( ^* u
  244.   #--------------------------------------------------------------------------% T( Z, e( e, [* h+ W
  245.   # ● 鼠标双击判定
    2 U0 L. g4 t" d" Y. O
  246.   #--------------------------------------------------------------------------
    & @( O$ D9 ]$ A) c7 Q1 m
  247.   def update_double_click
    6 e, O$ l; Y1 d8 p! p# o& c
  248.     @clicked = true if @left_state == 1
    0 K; Y# i+ `) {2 i+ b/ R
  249.     if @dk_count  0 && @left_state == 1; i; d3 a" Q2 W' k: J
  250.       @dk_count = 0; @clicked = false
      ]( m1 X% ]# l: N' p
  251.       return @double_click = true! d# l; Z$ ^2 w( c. H, L) i
  252.     elsif @clicked
    . d8 f( b4 `9 L; @7 k
  253.       if @dk_count  KsOfSionDbclick_Frame/ Z  f4 G" y% a+ r" Y7 W/ a5 a
  254.         @dk_count += 1
    # f3 d% @& V# C$ S9 l3 x/ B/ K
  255.       else
      g$ M" d# ^! k# J
  256.         @dk_count = 0; @clicked = false; f$ x$ v' s4 x( p& |* e$ R
  257.       end
    6 H' \8 z+ n% x+ e- k
  258.     end
    4 }3 t" o* h3 }1 K. d3 N
  259.     @double_click = false
    ' t: Z( u* Z* m3 _2 K
  260.   end# D- |8 W5 s2 W4 n! m
  261.   #--------------------------------------------------------------------------
    2 V1 G$ \+ |& _' m- H- D
  262.   # ● 按键被按下就返回true
    2 p9 N1 Y5 A7 A2 y" x: ?& l$ V; E
  263.   #--------------------------------------------------------------------------3 r2 \3 m, g- i. j. r) l
  264.   def press(button)
    2 X6 T$ e4 [) m2 e; N" X8 x
  265.     case button
    / K& q7 Q; I( ~" @" i: H4 W
  266.       when 0x01; return !@left_state.zero! `3 a! W, q" C, }3 y; ~- T
  267.       when 0x02; return !@right_state.zero. G/ ~6 f, [7 \# Q" l) _
  268.     end
    & t! l  X7 Y/ l" j& n3 k" C+ H$ }
  269.     return false
    * @# Q, H, V- s7 J
  270.   end
    1 I. I" L6 _5 v, o! R5 H7 }
  271.   #--------------------------------------------------------------------------
    ! D0 @- Q; i2 m2 ?+ s+ }6 J
  272.   # ● 按键刚被按下则返回true4 ]& z* H$ ^# h2 M& V" s2 o1 @
  273.   #--------------------------------------------------------------------------
    0 c$ P* l7 Z4 F: B' H: s
  274.   def trigger(button). |6 j% ~5 z1 H" l3 f
  275.     case button
    4 g0 m9 E0 A1 R% s, x7 R1 |
  276.       when 0x01; return @left_state == 1
    9 b# g( g" c$ q2 O/ c$ Z$ b( T. p
  277.       when 0x02; return @right_state == 11 p5 Z7 s! l. z* J5 ]! h
  278.     end
    4 R# |0 B* D. g0 p5 D/ }  ?! I; [/ u
  279.     return false5 w6 Y' X$ k4 j' j# |- y. h/ h
  280.   end
    ! I0 \. C. Y5 \% x1 v
  281.   #--------------------------------------------------------------------------4 \7 e: P5 [- P( F+ i  `# w
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true, a1 i, \4 Z3 v, I7 m
  283.   #--------------------------------------------------------------------------
    ! }: g! l; B& i8 m/ R! B
  284.   def repeat(button)' _1 U! i' h+ c) X- z
  285.     case button- q' z* W& B7 h6 d! v
  286.       when 0x01; return @left_state == 1 # g- @8 i& t$ H/ ^9 e
  287.         (@left_state  22 && (@left_state % 6).zero)8 ]. }1 ~6 m0 _$ I8 m2 V! j
  288.       when 0x02; return @right_state == 1
      q6 [1 X9 E% E. f/ a
  289.         (@right_state  22 && (@right_state % 6).zero)8 R# i/ A9 d+ d  l7 U2 U
  290.     end" C4 Q, t5 L+ _
  291.     return false
    3 |  m( _# O# C+ S+ z
  292.   end
    , ~' _1 X; F/ g! T& s
  293.   #--------------------------------------------------------------------------4 b- d& r) |; `
  294.   # ● 判断是否双击鼠标
    7 s8 d' x9 x6 n
  295.   #--------------------------------------------------------------------------5 u( j! U/ I! {2 u4 Q4 L& ?
  296.   def double_click
    $ S4 D* z' ]1 W: `8 a% x7 Y
  297.     @double_click  W  s& ?0 @5 y% r7 @  w# \7 `
  298.   end
    6 P7 ^/ L7 U( o  ^: p
  299.   #--------------------------------------------------------------------------! m% b& D7 s7 U( A9 u9 e& Q  |; L
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    6 p% l8 k4 b( O9 C1 j  M
  301.   #--------------------------------------------------------------------------
    ' i* f7 s0 `3 O5 N" C
  302.   def click_count. c* Y8 O; `+ I( r4 Y+ o7 M1 \
  303.     @ck_count
    9 H1 ~( f: z. q% m! d/ p  H" M  h
  304.   end' ], }; _7 X* A3 q/ d: U
  305.   #--------------------------------------------------------------------------
    " i" z' E& a: b0 m8 N
  306.   # ● 获取@left_state(按住左键每一帧+=1)( j  i( V$ H" a: H! [
  307.   #--------------------------------------------------------------------------
    ! q/ a9 S( T. E
  308.   def left_state$ n" B. c& b- x( D. I
  309.     @left_state+ O" \4 I4 a. q5 K
  310.   end
    ) Y" G( X% Y0 s! b3 T) g1 H; q
  311.   #--------------------------------------------------------------------------
    ' y1 J, T. O0 ~7 ?. s
  312.   # ● 获取鼠标的x坐标; m/ e0 L* ^6 f
  313.   #--------------------------------------------------------------------------6 n# Z: q! ]- J, s: c
  314.   def mouse_x1 `" e- O0 b% \; X
  315.     @mouse_sprite.x
    * ^, T% S# w$ a6 M" A  Z4 |
  316.   end
    # f# f$ e4 I+ b$ g: Z: M$ p1 ?
  317.   #--------------------------------------------------------------------------) t. V- C$ _: F7 f) p
  318.   # ● 获取鼠标的y坐标! t, o# z1 Z) ?0 K$ s  |1 ?: |+ M
  319.   #--------------------------------------------------------------------------
    * m' S! B: K. a, s. h/ p2 m
  320.   def mouse_y
    4 p) \: p! m; c9 K% r; Y
  321.     @mouse_sprite.y
    * o4 T; u7 v6 c
  322.   end( F5 f$ j0 L* [
  323.   #--------------------------------------------------------------------------
    * p* z0 p# {4 a. u3 c
  324.   # ● 设置鼠标坐标3 L4 f" N0 M+ R1 V% d. X
  325.   #--------------------------------------------------------------------------7 T4 B8 w9 m  \# Q
  326.   def set_mouse_pos(new_x, new_y)
    6 i2 @& W" M+ X! H6 C% ~# Q
  327.     arg = [0, 0].pack('ll')
    : r  V, E5 }  j* E
  328.     Screen_To_Client.call(Window_Hwnd, arg)
      C/ i% g) ~% ]7 s+ Q- h, M
  329.     x, y  = arg.unpack('ll')( n4 _, R: N! v" h# y  u/ A9 ?" `
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    ( n. M: r# b5 g
  331.   end! I) @$ y0 N% L* @) V! ?+ z
  332. end #end of class  self
    ' t7 t. `$ \4 w! t3 y
  333. 4 P* a$ M5 q8 P0 w' R
  334. end5 o$ H) @/ I$ \& D

  335. 7 R. ]4 b! P+ C2 m  W9 \3 f5 O4 `. J# L
  336. #==============================================================================# _% I$ S7 K$ u  f
  337. # ■ SceneManager
    9 N4 F: z" r% s& u9 f$ N
  338. #==============================================================================
    * r6 Z7 Z6 w5 {6 @' N
  339. class  SceneManager
    9 I' M" T. E6 t
  340.   #--------------------------------------------------------------------------2 Y5 l: |8 v  o8 V8 y8 A/ S; ?) [' C# W
  341.   # ● alias
    / `% S; m, C+ \9 a$ H+ c
  342.   #--------------------------------------------------------------------------
    ) k* `1 U, v# F( d" y2 }
  343.   unless self.method_defined(sion_mouse_run)  a* u7 E3 r) ]
  344.     alias_method sion_mouse_run, run* M! r  A7 G! K% _) i# Z9 D
  345.     alias_method sion_mouse_call, call% T4 q- k8 f! _8 l
  346.     alias_method sion_mouse_return, return
    . |0 o1 S) K: A! n
  347.   end
    6 Z# `0 f) j: K, @0 J( I
  348.   #--------------------------------------------------------------------------
    % o, o, Y# K6 N9 Z+ l
  349.   # ● 运行$ D' l$ L- W% `9 l6 J4 b4 G  h
  350.   #--------------------------------------------------------------------------4 [9 c# F& U- ?
  351.   def run
    9 f. |+ v2 ^' ~6 W% H7 N
  352.     Mouse.init% E( \+ e1 M- y
  353.     sion_mouse_run3 N' V8 |9 P6 F& \
  354.   end
    . p# |2 S. n+ M* w
  355.   #--------------------------------------------------------------------------
    6 L0 q$ W  b% v: n$ v' [
  356.   # ● 切换
    / X. f" {9 j; k1 e
  357.   #--------------------------------------------------------------------------$ n: D4 z6 Y" [  `
  358.   def call(scene_class)9 o% S2 V# Y% d  V5 _: m
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)/ w; u; d) Q$ ^" y7 Z% |7 x8 ~. n
  360.     sion_mouse_call(scene_class)
    + E, D2 x' D$ x  X
  361.   end
    9 b( V/ C4 y: U
  362.   #--------------------------------------------------------------------------
    * e: }' F6 f7 U& g
  363.   # ● 返回到上一个场景' D; ?5 M: Y) D* P: [
  364.   #--------------------------------------------------------------------------- b0 q& ]" s6 p# D3 y( p1 w! d! N
  365.   def return+ p/ {6 `0 r- o: B. f
  366.     sion_mouse_return
    % ^& ?: K0 I( c9 {; `5 ~
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&" c0 ]# T, f: T/ F7 ]0 X
  368.       @scene.instance_of(Scene_Map)
    9 ^! N" D5 @# I0 X
  369.   end0 n3 U' M7 b, W* M- B) B% p+ V% Q
  370. end
    7 d$ i2 L* j" G# h
  371. 0 F8 T3 l5 E5 B: U" O5 k! ]6 f
  372. #==============================================================================
    $ C1 o. T0 U4 W* H  a. _
  373. # ■ Module Input
    * l5 ~" N: t. f7 T7 O
  374. #==============================================================================
    " V1 t" `; |* i/ T1 N* o  p
  375. class  Input
    + n8 B5 m, i: l( e  b
  376.   #--------------------------------------------------------------------------8 n8 y4 E) {+ ]. Y
  377.   # ● alias
    # s  i4 f  u+ |+ e/ t, E8 R5 D
  378.   #--------------------------------------------------------------------------& k( K' H. y. S/ v
  379.   unless self.method_defined(sion_mouse_update); a9 e4 Q; H+ O6 L# o
  380.     alias_method sion_mouse_update,   update5 f6 V: D0 Q* N
  381.     alias_method sion_mouse_press,   press
    & W9 v' R$ L; \) i7 R, d( a! _5 S
  382.     alias_method sion_mouse_trigger, trigger+ c! d# l# E, T0 N* k& z
  383.     alias_method sion_mouse_repeat,  repeat
    9 d: _6 ]0 K, O) }2 k2 a
  384.   end. v" m  q# L$ S) ?5 @% `1 O# h! X2 P& F
  385.   #--------------------------------------------------------------------------
    - X8 o; N; }' A5 l
  386.   # ● 更新鼠标
    , A5 h' |" L% V+ i
  387.   #--------------------------------------------------------------------------
    ! V  g/ [0 {1 m
  388.   def update) H, @: L% ^! e& t, e# h- t
  389.     Mouse.update* s- V4 t' r0 |: A6 k
  390.     sion_mouse_update. \" q. u  b2 [" ?" L! l8 [
  391.   end
    3 e6 o: L6 p* C# p1 T! W& d
  392.   #--------------------------------------------------------------------------
    ' l2 q8 ^! B" d: Q
  393.   # ● 按键被按下就返回true
    ) R. N6 \  l) t7 I2 A
  394.   #--------------------------------------------------------------------------- s; k  m+ y& O! b) b. [
  395.   def press(key)5 L/ m' p# q. R; h, O$ S
  396.     return true if sion_mouse_press(key)
    . w1 O. E0 A3 D% K) [8 |2 a
  397.     return Mouse.press(0x01) if key == C  }6 j4 j( ~2 d8 l( k
  398.     return Mouse.press(0x02) if key == B
    5 K0 `: k, q4 ^8 E# F( T
  399.     return false
    ( ?6 Z# D* t/ V: O) n8 D" o
  400.   end
    % ?! N  g- M5 f  N1 k7 C
  401.   #--------------------------------------------------------------------------
    8 t4 p$ i1 O3 [
  402.   # ● 按键刚被按下则返回true
    1 T# F! M5 e, y0 X# P9 ^
  403.   #--------------------------------------------------------------------------% L4 K, s9 i" _/ K" W8 J& i, A
  404.   def trigger(key)4 ^2 c; ?$ \: m( C- @
  405.     return true if sion_mouse_trigger(key)
      t2 F) r4 q/ X
  406.     return Mouse.trigger(0x01) if key == C" Y# X$ j2 A. ^. l
  407.     return Mouse.trigger(0x02) if key == B
    : s8 L) c4 m" o. r
  408.     return false- ?/ t8 P; s$ O/ o$ I
  409.   end# B  ~" V5 k! n9 `; d, q
  410.   #--------------------------------------------------------------------------% o( r( j2 v, a# H' O) L
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    4 T# s3 v2 _5 G: Y; y) N6 F$ c
  412.   #--------------------------------------------------------------------------- ?, T$ j) N0 }+ z4 E2 j
  413.   def repeat(key)
    ; O7 e7 h1 X. m7 h; o& [- `  ?
  414.     return true if sion_mouse_repeat(key)2 [) K6 h9 V2 C, c
  415.     return Mouse.repeat(0x01) if key == C
    ( o9 n. u' v, `* G; Q( b
  416.     return Mouse.repeat(0x02) if key == B8 T4 U* m2 @$ L
  417.     return false
    & s; @# A% V: v1 X* ]- P  g! ]
  418.   end
    8 |0 z) ^3 r5 s, h: _$ y
  419. end
    ) U9 Z3 ~  Q8 ]2 Y+ _

  420. 7 r0 n* I# d2 U/ X  T9 f

  421. / r  Z) @$ F% `7 f. v' P7 l
  422. #==============================================================================
    ) K8 t5 q3 V$ Q* _
  423. # ■ Window_Selectable8 T1 B& X; W5 W2 q# k+ h
  424. #------------------------------------------------------------------------------% ?& E' q- ]% ]- I2 |# s  x
  425. #  拥有光标移动、滚动功能的窗口
    ! s* }: i6 x( S3 R7 O& f* \' Z
  426. #==============================================================================/ ]1 K6 M9 B. P* K8 }) ?- b* K
  427. class Window_Selectable, l& K' r1 I% d  T0 Q: O% \$ f
  428.   #--------------------------------------------------------------------------
    9 R5 |+ v0 K( N0 Q- Z. X- \6 v
  429.   # ● 初始化
    : o# k6 k# U1 ]
  430.   #--------------------------------------------------------------------------- @' q: h  Q1 R% L0 }
  431.   alias sion_mouse_initialize initialize
    ; @" e: t! ~/ d4 a
  432.   def initialize(x, y, width, height)
    - F6 G* x* }* g$ E1 B/ x
  433.     sion_mouse_initialize(x, y, width, height)
    ) I1 M- Z! X+ ]' A1 c4 z
  434.     @move_state = 0
    4 m& A9 X' B5 R- V. h2 C% a6 s
  435.   end8 f( Q# m* d& V6 l) {% u8 ?2 P
  436.   #--------------------------------------------------------------------------
    6 k+ v3 ]: w0 Z( @% {
  437.   # ● 更新& M. s6 g; Z: p8 H; s7 u* T
  438.   #--------------------------------------------------------------------------
    " l% Z( M6 d9 M1 z- m
  439.   alias sion_mouse_update update2 b( v8 U) D- b, e% t; S* {" G' N/ w  F
  440.   def update
    % i6 e0 c  \* N1 b+ V( O/ E
  441.     sion_mouse_update( R( w% F% z& y' e/ [+ x& m  P  ^! I
  442.     update_mouse_cursor# _% q6 G3 C, m5 k) _- n" k
  443.   end
    2 G: w! x7 Y  P! g
  444.   #--------------------------------------------------------------------------1 d( g5 V) H0 i2 }6 t* Y! {: @  D4 B  M* p
  445.   # ● 启动后设置鼠标到index位置
    5 n: |* v9 q& g: i5 k
  446.   #--------------------------------------------------------------------------
    9 A8 B4 f% [9 K4 h
  447.   def activate8 y4 e- J+ @9 N* p' u- {/ s
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos! s7 t: i1 l0 c! L+ |7 `# a: ]
  449.     super2 w% I9 f5 y$ f. ]$ I- ~% u
  450.   end0 ^5 W: d5 j- I' T* i) |5 V# ]
  451.   #--------------------------------------------------------------------------+ y0 \5 ^) o. h3 P6 k' K
  452.   # ● 更新鼠标和光标的位置" J. H. J" J% S: J
  453.   #--------------------------------------------------------------------------- d4 D$ S; s1 Q$ \/ |& Z
  454.   def update_mouse_cursor
    9 }8 \/ B% n3 S; N/ \0 @* D
  455.     if active
    ; d% S/ l: x' O) B. Y
  456.       if @need_set_pos# {) h. O1 w  J6 q' `7 F
  457.         @need_set_pos = nil' S/ [- g8 \, v. \7 k+ t
  458.         set_mouse_pos+ V# t8 e- U4 ~+ X7 C3 `
  459.       elsif cursor_movable
    ( G& b6 g; \9 F5 J3 u! ?3 U
  460.         Input.dir4.zero  set_cursor  set_mouse_pos1 k: M. p9 M, f3 k" D# Q$ e
  461.       end
      i( p- d. G) s2 ~% x
  462.     end
    # G2 l6 a" _1 j# c+ A2 F% T
  463.   end# T' I# F; t9 `& h  D) U
  464.   #--------------------------------------------------------------------------
    $ |( o, t4 a5 S# d' K
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    ; U) g' Z' D! l9 j/ T
  466.   #--------------------------------------------------------------------------
    + z% |: }2 c/ K$ y3 C/ _: @8 ~
  467.   def set_cursor
    1 V' v2 l+ k* X0 V' M$ O1 E0 F
  468.     mouse_row, mouse_col = mouse_window_area4 s- s/ m( g: i/ Y& {( N
  469.     if    mouse_row == -16 q* z, Y" ?" h! P' k& p/ h
  470.       @move_state += 1 if need_scroll/ o0 u/ ~. K$ d( \/ G
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ; A2 S* U0 ~% X4 S
  472.     elsif mouse_row == -2' l: R/ a/ }6 w
  473.       @move_state += 1 if need_scroll
    4 [1 t  k  d. T9 n- y: |
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    : W- Z6 k9 w' S; _
  475.     elsif mouse_col == -1
    ) q3 X/ ?1 Y0 d3 E2 S  n7 ?" {
  476.       @move_state += 1 if need_scroll& V+ x$ L7 s: Q" F
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand4 s4 X) e4 W3 `7 }* E& b4 Q0 E
  478.     elsif mouse_col == -22 ^. Q, e: i9 p* D# ^& q. M
  479.       @move_state += 1 if need_scroll
    1 C" }$ g; }  _3 H2 m
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand9 {) {% D9 |. E3 l" o
  481.     else
    " M' `7 p+ O, I$ z
  482.       @move_state = 0
    - X; b- l" y7 ^; [  n$ L/ Y
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col$ h+ \: o3 {4 i: E" u9 w# G% F
  484.       select(new_index) if new_index  item_max && new_index != @index
    - i) X* }* v9 V0 p. R
  485.     end  h9 H( j' M! K6 B& i) Q- ?
  486.   end
    / X! p: D4 T+ N% p9 Q
  487.   #--------------------------------------------------------------------------& g2 o5 p: C1 o6 u8 [; [: z1 z
  488.   # ● 判断鼠标位于菜单的第几行、第几列2 l: m& Y6 @( L2 ~  p1 A
  489.   #--------------------------------------------------------------------------5 B1 M$ z3 w6 v! \# Z& j; w
  490.   def mouse_window_area4 H3 x, ~6 [' Z: g5 U
  491.     if viewport.nil # necessary!5 r/ P. N! ^3 y" k4 l1 e; Y; y) M
  492.       vp_x, vp_y = 0, 04 q# w* i5 l$ `( m( b, Q$ I
  493.     else
    & V0 ~5 x: [+ ^5 r7 d$ T$ a
  494.       vp_x = viewport.rect.x - viewport.ox. B2 L2 @* l3 O; P4 H- ^
  495.       vp_y = viewport.rect.y - viewport.oy  \$ f$ ?. u5 G' H" t2 e
  496.     end
      I  J4 ~1 n1 N: V6 K, f! s+ j
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ' x! w5 z# E6 k- S( t
  498.     item_x1 = vp_x + x + standard_padding
    1 z+ z* d5 F0 \, {! _3 M# s6 g2 H8 X
  499.     item_y1 = vp_y + y + standard_padding
    7 v. \( b+ e2 H+ @. H3 B+ W6 V
  500.     item_x2 = vp_x + x - standard_padding + width
    - ]) b- g9 A, b* P" E
  501.     item_y2 = vp_y + y - standard_padding + height+ R: G0 ^# X& u' d$ q- V# D
  502.     if mouse_x  item_x1
    5 q5 }; n7 {8 ?) }1 W
  503.       mouse_col = -1
    : q4 x  l( @$ Y+ C& x
  504.     elsif mouse_x  item_x2( @6 y* Y5 a. r- r& ~! N, G
  505.       mouse_col = -2. ~- k- V9 O, U! j; T& m1 \
  506.     else+ ]' }6 ~% U1 a2 ]# ]7 B
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)' [/ {+ ?, Y7 b1 x
  508.     end9 |) d; a) f" B
  509.     if mouse_y  item_y13 I. X: ]1 H0 K3 ~
  510.       mouse_row = -1
    * J2 t$ V3 F/ E0 O
  511.     elsif mouse_y  item_y20 _+ c) V9 k- a. f6 \+ I( Y7 y* v
  512.       mouse_row = -20 s4 H- U- k& }
  513.     else
    2 h/ m7 y4 C; {$ b- n
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)! ^7 c2 {0 b+ |
  515.     end( f3 x. a4 b  j, S+ X7 Z0 |( t9 h
  516.     return mouse_row, mouse_col
    ) t# b) {) z) \  C. t* F; E; n
  517.   end
    " Q+ n, v! t: P7 ~7 N) k
  518.   #--------------------------------------------------------------------------
    1 U4 A# F& e0 w$ [: @
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    6 \# s3 q! s3 k. v/ O) m
  520.   #--------------------------------------------------------------------------3 T& ^5 X3 B! K/ m
  521.   def set_mouse_pos5 h2 z' x% n7 z4 |
  522.     if viewport.nil # necessary!
      e* N6 K$ ]8 ^9 c8 a$ P* a
  523.       vp_x, vp_y = 0, 0$ N# L' `3 ^0 C8 R) d. U0 k0 ?
  524.     else3 r8 z$ C% i: W% Q3 C( S- U
  525.       vp_x = viewport.rect.x - viewport.ox# \. c$ k$ J! f- F6 j
  526.       vp_y = viewport.rect.y - viewport.oy" l/ G. m; Z1 M2 Y8 R& r2 ?
  527.     end: f4 L( X$ B' K
  528.     item_x1 = vp_x + x + standard_padding 1 b- d6 P' X: u3 L
  529.     item_y1 = vp_y + y + standard_padding, w* ?" X4 U+ l2 ^; T2 i
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    + [: X) W  ~2 O2 y* Q) d
  531.     row = get_index  col_max - top_row
    4 m2 Y5 Z! H, \/ t0 r. W
  532.     col = get_index % col_max9 [: f- p2 n( B% n& U
  533.     new_x = item_x1 + item_width  (col + 0.5). V+ U0 w1 `8 j2 r. u  l  X
  534.     new_y = item_y1 + item_height  (row + 0.5)
    : A2 y/ I) N" E, }, U& y5 ~: M. G
  535.     Mouse.set_mouse_pos(new_x, new_y)8 h, ^, W+ X" ?" x, l5 S8 ?
  536.   end
    . A3 D( d4 y1 G. f2 c" H0 i  e4 ?
  537.   #--------------------------------------------------------------------------
    , t  d; r* q( j
  538.   # ● 判断菜单是否需要卷动
    % C% N2 Y/ t9 v5 i5 P
  539.   #--------------------------------------------------------------------------
    $ @( [- E1 {2 Y; m7 s
  540.   def need_scroll
    2 A" E0 O' X0 x9 c! G- t4 ~
  541.     item_max  col_max  page_row_max# A7 ]8 f% T/ ~* M+ A0 e
  542.   end7 B9 i" g2 d' {0 {3 K+ c7 g
  543.   #--------------------------------------------------------------------------! i& z- {; S) `4 ^% K# D
  544.   # ● 判断是否为水平卷动菜单
    . y5 Z& b& h* {3 s) t$ I, N2 L
  545.   #--------------------------------------------------------------------------& r  s* m2 g( A5 t+ G0 v/ V
  546.   def is_horzcommand! w5 x  r* ~' Y
  547.     return false
    * d$ z& R4 G  l: l) j
  548.   end
    * F0 e; r5 o% z3 ?  [) S
  549. end4 k3 e9 v5 i  N

  550.   J. T9 D' m$ x9 _1 o5 P
  551. class Window_HorzCommand$ Q; E/ p3 j2 `2 \+ F+ \. ]  f
  552.   #--------------------------------------------------------------------------) m. t6 }5 U! e6 Y
  553.   # ● 判断是否为水平卷动菜单
    * R  ^, a4 c; e9 P/ y
  554.   #--------------------------------------------------------------------------& Q6 m+ v! h" u( A: p
  555.   def is_horzcommand" X( u  e9 q& l. U3 w+ d! C
  556.     return true
    3 s: ?5 v) e; g: {" x
  557.   end* b% b- q' l! ~! s
  558. end2 D0 g0 T5 l* J2 k, S

  559. / H7 w+ F" q6 ]) e5 a2 E7 Z
  560. #==============================================================================
    ! M/ r# h# H! T2 m6 k+ d
  561. # ■ Window_NameInput' L* H' j6 ?! }! y) B! S
  562. #------------------------------------------------------------------------------
    - I1 C. |) F( _0 ~# Z
  563. #  名字输入画面中,选择文字的窗口。
    2 F. v/ h5 t2 p  A- p8 Y: x+ s. d* s# F
  564. #==============================================================================: x; P* f6 M- I# a
  565. class Window_NameInput$ M7 Q  x% F9 K* g$ y
  566.   #--------------------------------------------------------------------------& i4 i6 {, q1 e, U  A* Q5 a- p
  567.   # ● 设置列数' @) Z( e! X' ^) H$ I, M3 C
  568.   #--------------------------------------------------------------------------
    ) L' x2 a: v" \  H4 {6 R
  569.   def col_max
    3 c; }0 G: D/ z- m3 P1 B
  570.     return 10# g& f) R' G6 a$ X* S; X# e: ]
  571.   end6 O0 d3 a) j. Y! [' V1 j
  572.   #--------------------------------------------------------------------------
    . l+ o! a! H% E3 T" s
  573.   # ● 设置填充的Item个数8 w1 T0 ]5 P. U& l6 V0 s3 G+ T
  574.   #--------------------------------------------------------------------------
    7 r  \. A) G8 ?' r. K' O* k: d% J
  575.   def item_max( [5 S5 [$ y6 r: ?% K3 m' D
  576.     return 90
    . s% v% V( T5 Y4 W6 |" q
  577.   end
    0 S& o/ u  z+ `6 `" ]3 u( K- a
  578.   #--------------------------------------------------------------------------, c3 S; g8 ~7 o5 V0 T" ^
  579.   # ● 设置填充的Item个数+ w* C% s: W7 D# n
  580.   #--------------------------------------------------------------------------
    : ^% m+ _) @" i
  581.   def item_width, B9 l  d: O; r( F
  582.     return 32
    ! `0 O# U0 t2 ~  z+ l8 j
  583.   end2 Y0 d; e) ]8 |9 H- o, m8 Q
  584.   #--------------------------------------------------------------------------5 E8 u. t% d, R/ w" o/ h/ d8 A
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    % F; ]' d" v6 r1 N& m* H
  586.   #--------------------------------------------------------------------------' Y$ R1 S4 c% t1 \
  587.   def mouse_window_area
    / }& }5 }! k+ [6 H# m2 u. u8 U
  588.     if viewport.nil
    6 q7 R- b( V" b' @
  589.       vp_x, vp_y = 0, 0& L# T5 M4 C* Z  o* Q% V% e
  590.     else
    ! n# Y5 ]2 x7 D5 ^7 n$ Z
  591.       vp_x = viewport.rect.x - viewport.ox" J8 [7 y* u* y1 ?  {: M* Y- Y
  592.       vp_y = viewport.rect.y - viewport.oy
    % U6 Q" \  `! ^( O8 o* g) V# k
  593.     end
    / z% g' L2 L# H5 L
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ' h6 v( d) v1 a. Y4 w5 [
  595.     item_x1 = vp_x + x + standard_padding
    1 ^; k& a% v1 M3 Q
  596.     item_y1 = vp_y + y + standard_padding7 a, z& z+ y* i$ Q" w  r
  597.     item_x2 = vp_x + x - standard_padding + width6 K! O2 u4 q8 r& H: h1 c5 P
  598.     item_y2 = vp_y + y - standard_padding + height
    ( K; [9 A3 w) H" `6 e  }! i0 j4 w9 W
  599.     if mouse_x  item_x19 O+ I' z5 N! E2 n3 z5 s
  600.       mouse_col = -19 S5 M+ h8 k' d  q: f
  601.     elsif mouse_x  item_x2" A4 R& J9 W5 J# G
  602.       mouse_col = -2
    3 d- j9 }  f# D5 R) o# M& r0 y" }
  603.     elsif mouse_x  item_x1 + 160
    * m3 f& K3 F7 `4 P% E5 W5 V" Y$ A
  604.       mouse_col = (mouse_x - item_x1)324 a; P6 ~; k. |) Q' M+ ]
  605.     elsif mouse_x  item_x2 - 160
    6 k8 [% C5 P& j1 X- \, Q3 L
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    ( M3 N* \3 w! k# X/ ?& X
  607.     else
    2 ~+ r# l' i( y
  608.       mouse_col = mouse_x  x + width2  5  4- }$ N+ Y% a& v  X+ o
  609.     end
    - P2 m+ o+ o( _0 I4 T6 C
  610.     if mouse_y  item_y1
    : e; w1 N! D; p4 v% N' Z
  611.       mouse_row = -1
    $ P; v: v6 L1 f7 w0 s) W2 i" B
  612.     elsif mouse_y  item_y2  o" D9 m" {( V- K* i
  613.       mouse_row = -24 l7 ]5 {- Z8 ?2 H( [! @1 B
  614.     else4 u! i7 }+ D5 [' w' ]
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    $ k7 |4 Y- \0 z
  616.     end
    8 {3 U7 I$ S9 I1 _! ?
  617.     return mouse_row, mouse_col7 b' N1 ?. F; l2 ]1 f( j! x
  618.   end
    0 N* ^- s" ]. v3 o) M& o
  619.   #--------------------------------------------------------------------------
      ?: m* y5 L* q7 S+ j
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置; K* h2 g' M% C  m: A
  621.   #--------------------------------------------------------------------------9 M& d5 m/ k: @/ p
  622.   def set_mouse_pos
    " r" n( U1 N4 t8 |. _
  623.     if viewport.nil # necessary!
    0 e) P) v2 {  M
  624.       vp_x, vp_y = 0, 03 E. d* M; T" b
  625.     else
    + _8 o! A; o5 Z( e
  626.       vp_x = viewport.rect.x - viewport.ox( M+ H( i7 i+ q0 D& x8 C/ P1 z
  627.       vp_y = viewport.rect.y - viewport.oy
    5 s+ B# }1 L. m6 @/ U3 P
  628.     end
    + a" V9 _) h2 s
  629.     item_x1 = vp_x + x + standard_padding
    + m& h' q8 `+ \4 Q
  630.     item_y1 = vp_y + y + standard_padding
    - m# R8 K* M4 v1 N5 M4 J* X7 {# T) R
  631.     get_index = @index  0  0  @index
    7 k) x7 J* l; ?- g2 p3 Q( r
  632.     row = get_index  col_max - top_row
    ! X& I2 f( {/ f& n
  633.     col = get_index % col_max
    5 `# o- f: \( o5 \+ _
  634.     new_x = item_x1 + item_width  (col + 0.5)+ x6 j8 T( B4 g5 _9 p7 z% A
  635.     new_y = item_y1 + item_height  (row + 0.5), e8 n) o- }  E, e3 `
  636.     new_x += 14 if col  4
    ' D3 n) D1 G  b; E& y
  637.     Mouse.set_mouse_pos(new_x, new_y)" {+ A' ?; d9 _
  638.   end
    . P5 n# o: h( W& d8 E* ?
  639. end$ {  T2 M; ]1 b+ d3 w8 w! m
  640. 9 {; I. H+ \9 t" Z. f
  641. #==============================================================================* F9 P, y/ a. O& ?. D# y
  642. # ■ Window_NumberInput- B% Z& f: ]) ?# o
  643. #------------------------------------------------------------------------------; D1 D$ b2 j$ i  X! m! b
  644. #  重写了数值输入的方法以适应鼠标$ l; u& E4 F. l9 h
  645. #==============================================================================
    0 T$ W# o5 |, h" U
  646. class Window_NumberInput  Window_Base" p6 \7 y. R% p) c' G3 Y, m
  647.   #--------------------------------------------------------------------------
    6 L6 z! m3 m# U0 D
  648.   # ● 定义实例变量
    * M( X% }8 \; n8 d* R$ h& ~1 p
  649.   #--------------------------------------------------------------------------. t: ]# M) U+ m% i+ Q6 v9 U( `# x
  650.   attr_reader extra_window0 w: Q- H+ X2 g( C1 x3 P' M7 L( _
  651.   #--------------------------------------------------------------------------9 e0 f, l4 t- Y% h
  652.   # ● 初始化" ]$ U; M: l6 V
  653.   #--------------------------------------------------------------------------
    9 ], z6 g; k) G! E. ~
  654.   alias sion_mouse_initialize initialize* j5 ]: ~. u& K3 I$ ]
  655.   def initialize(arg)& v4 R; t6 `4 T0 P# L
  656.     sion_mouse_initialize(arg)" p: F9 i$ T, w" Z2 C
  657.     create_extra_window
    ; {" f% R# Y) `/ P# N7 G
  658.   end% U9 y2 X: F& ?" i3 t
  659.   #--------------------------------------------------------------------------
    6 o/ m. g3 ^2 L9 ^$ @1 a
  660.   # ● 启动
    ; [( u& A, }% K: i% C6 k7 N
  661.   #--------------------------------------------------------------------------
    : x! b& \0 v4 g+ I) y; h
  662.   alias sion_mouse_start start  _/ [1 o- i) W9 d; F1 |
  663.   def start
    " H- U6 H9 |% T; _
  664.     sion_mouse_start
    # t, q9 ~7 a& b9 N6 |8 A2 _2 Y
  665.     deactivate; V. e7 z4 z& r
  666.     extra_start
    9 v2 C8 B# }# H6 T* O6 S
  667.   end
    , ?* M( w2 l% k% T# g" C
  668.   #--------------------------------------------------------------------------
    ( w" ~( t, |- b$ }. ]
  669.   # ● 创建新的数值输入窗口+ L, f# \4 g5 C3 e$ c9 x
  670.   #--------------------------------------------------------------------------  N: `7 ~; l' Z$ G& L( X
  671.   def create_extra_window2 A) X. C5 }9 f. @2 j8 {; a/ j
  672.     @extra_window = Window_NumberInput_Ex.new) I* |- \, ~  \7 V& q, v1 T
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2/ w+ i( E, D9 H! s
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }3 n/ D7 b2 y1 Q& [
  675.     @extra_window.index_proc   = Proc.new {n @index = n }$ m' k8 v1 k- E7 q' t7 o
  676.     @extra_window.close_proc   = Proc.new { close }) q. G: l- R9 S4 ~
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    4 n  d0 b, M1 ]; w4 q
  678.   end+ B; P3 L3 ^: {0 A
  679.   #--------------------------------------------------------------------------
    ! P8 l/ T! g: V$ a: i/ E
  680.   # ● 激活新窗口
    * R  J7 \  T$ H% I
  681.   #--------------------------------------------------------------------------
    $ D3 t3 G$ n6 ?. I- K
  682.   def extra_start
    / Z3 U8 ^8 ~! [5 A
  683.     case $game_message.position6 ]5 ]6 m! ?  g* N" N- i( O
  684.       when 0; @extra_window.y = y + height + 4, f" `: G) X& G# p
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    4 l& R( J. T9 t( ^% M" Y/ v
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    6 @$ V6 ^: _! `  s- v8 Y* ~
  687.       else  ; @extra_window.y = 8. {' c2 y3 h+ l  A
  688.     end
    # D: F/ \7 z) p' n  X
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    2 K: C. A) Z% ~5 u" t0 u
  690.     @extra_window.digits_max  = @digits_max
    4 @/ z" M3 F- O1 l# @, A: x2 [) _
  691.     @extra_window.number      = @number
    # ~; f6 x  s8 v) \
  692.     @extra_window.open
    9 q0 D# F3 z6 A" r# ^7 |4 T
  693.     @extra_window.activate  i& E% |" o5 u5 R
  694.   end
    4 @8 D! {4 b2 v* j8 A
  695.   #--------------------------------------------------------------------------6 R' x4 a3 k0 @# J# l) C8 g2 ^2 q
  696.   # ● 更新
    4 p  m' V! C. |& W- w
  697.   #--------------------------------------------------------------------------
    5 p9 \$ @# p. _) V% A- Q- U
  698.   def update
    8 w" d0 Y5 E6 g# [0 X  ?
  699.     super, c7 N" p1 l& Q5 N# W( x
  700.     @extra_window.update" u  m4 Q: J7 S' T2 I7 Y; N9 S$ m* E
  701.     update_cursor* P. ^1 G& m, l2 R) j7 e
  702.   end
    4 O: ^/ w' d3 S- K  L
  703.   #--------------------------------------------------------------------------$ g8 g$ J9 J6 ~9 N+ j5 T) |, z+ T0 j- j  ^
  704.   # ● 关闭窗口
    * f- u6 ^! k6 E4 E% {! j
  705.   #--------------------------------------------------------------------------
    9 Y- O2 ~# V* M
  706.   def close/ p3 \/ b! _& ]5 f& U+ R/ j- b
  707.     super* C0 G0 @) V* e% U! l# F8 N+ B
  708.     @extra_window.close
    - N. X* y2 v7 |; ?7 l
  709.     @extra_window.deactivate
    : L+ j) \; I; c3 K; q
  710.   end
    % B5 Y; ]; V( C9 M6 u
  711. end
    : M3 X" c- d4 X8 P  m
  712. 7 Z% c+ [6 p1 i" A  u
  713. #==============================================================================
    . k6 d" J: O5 s- a7 k4 Y$ z/ g
  714. # ■ Window_NumberInput_Ex
    0 _' B: @  \/ w/ }9 m
  715. #------------------------------------------------------------------------------
    ' q1 s0 [' M3 R3 O, j" ]
  716. #  新的数值输入窗口(NewClass)
    ) A+ Y% k4 {' y6 Z6 v
  717. #==============================================================================& x2 N  y0 f6 c, d" d0 T* U, T
  718. class Window_NumberInput_Ex  Window_Selectable/ l) g1 y  E! I4 f$ q7 }# ]
  719.   #--------------------------------------------------------------------------/ ?3 g6 c$ t; N. L
  720.   # ● 定义实例变量
    , I; U; l+ C! f3 T! W8 q
  721.   #--------------------------------------------------------------------------
    9 K: |3 }# y0 ]6 F/ n: \0 S
  722.   attr_accessor number_proc, U! [/ _% C* w) m& H/ F
  723.   attr_accessor index_proc. u  q$ ]- \: V- U* h& h
  724.   attr_accessor close_proc. `+ z4 d" N5 P1 {
  725.   attr_accessor refresh_proc
    * d+ a$ c" [5 M5 v
  726.   attr_accessor number
    4 I% M( m, @" [( V. I; ~& _+ @5 j
  727.   attr_accessor digits_max5 r4 `0 n0 L6 y: ^4 Q3 s
  728.   attr_accessor variable_id
    8 h  k* b  Z2 m) O6 ?5 s
  729.   #--------------------------------------------------------------------------( L8 H: s  N! ^3 s) x) V! @& }+ t
  730.   # ● 数字表9 B8 p% ^" `& X, O4 O& `
  731.   #--------------------------------------------------------------------------. g- p0 v( m1 I1 u) Z% @9 o0 m
  732.   TABLE = [  7,  8,  9,
    3 c9 h' Q& r. T& u
  733.              4,  5,  6,
    " {4 V/ S) m9 z3 ^, R3 {
  734.              1,  2,  3,3 o5 h, D" h  T- b0 K
  735.             '←',0,'确定',]% D6 k8 e4 J- Q" P  T6 c' Q
  736.   #--------------------------------------------------------------------------+ T( S3 i+ @, D- s1 N( T
  737.   # ● 初始化对象
    " d- N" R7 \$ z3 p" R
  738.   #--------------------------------------------------------------------------
    & P- o* U5 S9 ]0 x/ ]
  739.   def initialize
    ) u; E# I$ P; `
  740.     super(0, 0, 120, fitting_height(4))% [2 G  x: @& T/ x' j& I! D6 \  c
  741.     self.openness = 0
    % r6 c* {0 Q" v
  742.     @index = 0
    0 Z" K! p9 G' p7 y4 i3 v* d7 C
  743.     @number = 0
    1 h" X- x& `8 w( u( E. b# \' N
  744.     @old_window_index = 0
    0 v/ Y) E6 m# k6 M. i: Y
  745.     @digits_max = 0
    6 w- N/ `1 X' [6 l0 d9 a3 f
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }7 g0 ^6 z; r3 l: H, D
  747.   end. {" x" e! N/ t# J- f7 s6 c
  748.   #--------------------------------------------------------------------------
    2 {! X2 e6 S+ Q  d/ l  b1 o
  749.   # ● 获取项目的绘制矩形  }# d# y: `* g# Y4 o
  750.   #--------------------------------------------------------------------------
    5 }6 k6 @0 [$ U- X4 n4 w- p3 c
  751.   def item_rect(index)2 h# C' A4 }1 P0 R7 t" p8 u
  752.     rect = Rect.new
    ) A+ x5 a5 ^( v9 P9 V
  753.     rect.x = index % 3  32
    , a' r- v0 }) D% z& m
  754.     rect.y = index  3  line_height
    , N( ^( g% }* a# O
  755.     rect.width = 32
    ( x7 }0 L+ K! ^6 y" ^
  756.     rect.height = line_height1 d6 b3 ]% g! S( s
  757.     return rect6 r- g% I7 A# r4 P
  758.   end6 c* l* S! g, G* d7 l* Q
  759.   #--------------------------------------------------------------------------
    & o' w; X1 x6 e$ s& I/ K  f# M7 ]% {
  760.   # ● 将光标设置到鼠标所在的位置
    1 v; m' n6 B8 w
  761.   #--------------------------------------------------------------------------
    7 Y% T9 N4 W* o6 R) }
  762.   def set_cursor' F8 h) T5 ]9 @/ g
  763.     mouse_row, mouse_col = mouse_window_area4 J) V& [6 n$ q% T/ e+ Q5 j+ I; W. O
  764.     if mouse_row = 0 && mouse_col = 0
    " f+ D" F. H# a. S
  765.       new_index = mouse_row  3 + mouse_col- M& K; @! g: W7 N# I3 ^  K
  766.       select(new_index) if new_index = 119 `- i4 v2 V5 ]# b$ p) W
  767.     end
    : w% W$ D+ H* C0 Z7 ^, ]
  768.   end
    : K& I; Y, L6 q
  769.   #--------------------------------------------------------------------------5 K% D% [  u" Y! g' P1 X
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列2 N( q- Q% [  A5 A9 {2 K* v' A
  771.   #--------------------------------------------------------------------------2 g1 ~6 q# T) B
  772.   def mouse_window_area5 W/ {. F% o$ j$ B$ b4 l
  773.     if viewport.nil
    1 N' ?) Y7 n/ l- c' N+ D
  774.       vp_x, vp_y = 0, 0
    ! r+ z0 }1 v' p# B
  775.     else
    6 [4 I+ ~2 Y5 k+ i" M- \8 |
  776.       vp_x = viewport.rect.x - viewport.ox
    : ~& z8 e& {) H: H
  777.       vp_y = viewport.rect.y - viewport.oy
    - `, Z$ L4 [. p4 o8 x
  778.     end4 H1 a) [6 y0 @) I: \' `4 s$ y
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ! O% F! y1 E5 X; l1 a
  780.     item_x1 = vp_x + x + standard_padding
    ( q& u% u+ S/ J9 C& q4 v
  781.     item_y1 = vp_y + y + standard_padding
      g9 |+ s, ^+ B$ S1 ~' o
  782.     item_x2 = vp_x + x - standard_padding + width! g. C' e& X* L
  783.     item_y2 = vp_y + y - standard_padding + height
    ! S8 e/ c6 z$ C; O9 n. S# `5 b
  784.     if mouse_x  item_x19 \5 h. X& x$ J
  785.       mouse_col = -1
    5 j+ _* E/ _) M5 {1 F) C
  786.     elsif mouse_x  item_x22 U- ~1 i  `; b4 b; t
  787.       mouse_col = -2! {/ `" H/ x6 X, _( n
  788.     else
    3 Y- t) o% ~2 ~% k
  789.       mouse_col = (mouse_x - item_x1)  32
    . y/ l5 |. l4 [0 @# b$ P9 @4 u) G
  790.     end! e( J. j7 z5 `4 z
  791.     if mouse_y  item_y1, a1 ]% d% T  J# F( {) e. H. j$ w
  792.       mouse_row = -1
    % ?( i) M- l. w( g( N
  793.     elsif mouse_y  item_y2
    % l. B& @$ \4 v1 g5 Y( D4 s9 X9 W
  794.       mouse_row = -2
    ; O7 f0 V; |! S' s- Q( j
  795.     else
    + S9 o* j0 }1 q, }! q0 o$ ]
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)% E' Q1 m& c$ k" U8 S% P, k' V
  797.     end" d/ h* k) d8 y' ~& l8 v* R
  798.     return mouse_row, mouse_col( q9 L1 }+ p; @2 m
  799.   end
    . K' ?9 c8 r+ z( g8 v+ u
  800.   #--------------------------------------------------------------------------
    ; `1 b6 X; H% S3 C, N* I: z
  801.   # ● 获取文字
    * ?. u, `; c( X* `. A
  802.   #--------------------------------------------------------------------------
    " X4 Q1 d5 Y9 m2 W' E5 H
  803.   def get_number
    ; s$ z" P$ A) {# P0 Q* b
  804.     return false if @index == 9  @index == 11
    - I5 \5 R6 c5 C  d3 P) n+ e; J
  805.     return TABLE[@index]( Z# e$ Z; n* }" [# {9 z, z- a
  806.   end
    + k/ O0 A& y/ K7 a
  807.   #--------------------------------------------------------------------------
    : j; m' B9 V$ i8 ^" d; L/ ?
  808.   # ● 判定光标位置是否在“退格”上
    # s: J% x6 z$ g
  809.   #--------------------------------------------------------------------------
    1 S) V8 W& i/ d* m
  810.   def is_delete
    5 L' i" a" e' P5 I$ m; e# _. E, r3 K
  811.     @index == 9+ y2 Q$ p4 |2 b$ D( @( b0 m
  812.   end
    6 Z; C* y2 y# e1 E* E) R8 K* \3 B1 D
  813.   #--------------------------------------------------------------------------# ]. }. \& g7 O9 B( r; Z4 U- r7 ]
  814.   # ● 判定光标位置是否在“确定”上5 b# H( M% c  D5 M5 Z
  815.   #--------------------------------------------------------------------------3 G" `7 ^" c1 Q) P5 b+ c% F  T( r
  816.   def is_ok
    & b. T8 M# c. ?( w& g( i) g
  817.     @index == 111 e' r/ j  x! @6 n) Q: x- R
  818.   end( V6 F, M' i; M3 |8 D4 l/ v& l, U
  819.   #--------------------------------------------------------------------------3 o, B! m" Y: E! I( ^
  820.   # ● 更新光标! F2 E0 i) e! t$ N  c! [
  821.   #--------------------------------------------------------------------------5 I0 o9 {6 q' I0 U2 ^
  822.   def update_cursor6 {" P' v, c7 Q0 |+ N
  823.     cursor_rect.set(item_rect(@index))
    4 e1 Y( |8 `8 |- w3 i
  824.   end& \" W" t; v. H. }
  825.   #--------------------------------------------------------------------------
    ( J# a) D; C. a$ W  O4 F3 O8 F
  826.   # ● 判定光标是否可以移动
    1 v" @3 {2 W6 D6 {" l; U1 k; m3 }
  827.   #--------------------------------------------------------------------------) j, |! t+ h8 D6 F
  828.   def cursor_movable
    5 y' p9 |6 @) [9 C
  829.     active! @) c! R5 H2 q
  830.   end. R( \5 o) ]1 n' c5 M% x9 K
  831.   #--------------------------------------------------------------------------8 Z3 J* _3 |" c( t7 A/ n5 {
  832.   # ● 光标向下移动( w( e$ z5 m" d# D8 T# V9 h2 _
  833.   #     wrap  允许循环% h  ^" d$ g1 x" @' b1 T. }) m4 G
  834.   #--------------------------------------------------------------------------; M8 U" `5 b) h
  835.   def cursor_down(wrap)$ w$ s9 `6 U8 |) C) U) ^
  836.     if @index  9 or wrap
    - j8 G$ K# p; O" b
  837.       @index = (index + 3) % 12
    * Q4 |1 Z5 `& K. i* F) o
  838.     end
    , v( a/ e; o# t" O, A  `( d
  839.   end
    : F# L0 k, O  i) B9 k2 d/ C
  840.   #--------------------------------------------------------------------------
    - l- }6 s. T5 A: R5 Q% U- E
  841.   # ● 光标向上移动
    % N3 C) ^+ l4 Y% O, x' l
  842.   #     wrap  允许循环& \4 j8 F& ^+ q! k
  843.   #--------------------------------------------------------------------------
    ' D7 o; V7 y8 C8 v3 \0 \  s
  844.   def cursor_up(wrap)
    : k5 Z$ _  r6 k/ b$ }
  845.     if @index = 3 or wrap+ \# c% z: d& I! C) [* y) c
  846.       @index = (index + 9) % 12
    % K7 T5 N- }$ a! Z$ S
  847.     end
    6 s& b$ O# F+ V/ {6 [0 j* v) {
  848.   end! P8 j; K, Y( h- f1 }+ P6 @' {6 m
  849.   #--------------------------------------------------------------------------
    7 O. X6 v0 T) P: M! Y, B9 }
  850.   # ● 光标向右移动/ M/ g  a# D6 l: y
  851.   #     wrap  允许循环/ V& Z$ k, S% h" E5 }- E3 Q" p
  852.   #--------------------------------------------------------------------------! |2 s% z) i0 S
  853.   def cursor_right(wrap)
    . G" {* u2 E; g) z6 O& n- T
  854.     if @index % 3  2
    ' ?. F! w) B& K# e
  855.       @index += 1
    4 \8 E6 d1 P  r2 R+ L
  856.     elsif wrap  u+ S9 {% d, |
  857.       @index -= 2- d* o" J, n/ C: y( r. t
  858.     end" f4 K; H! o7 h* E! T9 {
  859.   end
    8 k" ?8 t1 @" ^( y0 V' Q
  860.   #--------------------------------------------------------------------------; x; m0 c" {2 |1 `9 K' G9 L
  861.   # ● 光标向左移动6 K! k. _$ w1 f" U
  862.   #     wrap  允许循环
    * W2 F/ g- P7 q( [* E: q8 j! N
  863.   #--------------------------------------------------------------------------/ y6 w+ ?- _- U0 U
  864.   def cursor_left(wrap)( l2 I6 P! \9 X. \( c9 E
  865.     if @index % 3  0) u/ \% p( J) @  H1 R
  866.       @index -= 1
    2 f; M4 Q: B$ w/ {( J: e
  867.     elsif wrap
    " F& k' r( e- ^7 N; D: t( p
  868.       @index += 2
    8 V7 o" Y" ^. m- `4 {. y
  869.     end
    8 L. ~! G2 T' v0 |% d" L& }
  870.   end
    " d* E" b  ^9 V& D, E
  871.   #--------------------------------------------------------------------------
    0 M0 ?7 g$ w. V" R) j3 s
  872.   # ● 处理光标的移动! H3 q2 j# F/ t: a" f  P2 V0 u
  873.   #--------------------------------------------------------------------------- Y: P! Y% i' Y) B3 @9 ~
  874.   def process_cursor_move( t) C8 o: [9 B3 s+ h( I
  875.     super+ O# H  I4 v0 V4 L4 X2 Y2 }1 B- _: @; r
  876.     update_cursor: \+ _0 X- t7 `
  877.   end
    ' v2 M& c" g6 v) ?* P% ~
  878.   #--------------------------------------------------------------------------
    ) m* R6 R6 e4 u- R9 D
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    ( Q: I" o; P2 g6 ~! S
  880.   #--------------------------------------------------------------------------
    & H. e+ H: W7 D' r; g; r5 T
  881.   def process_handling9 g2 h' s  Z' K! f& n3 a9 F' ]
  882.     return unless open && active8 q0 e8 Y9 h8 ~% L$ j
  883.     process_jump if Input.trigger(A)0 B+ n1 \6 I/ b4 ^& b  o' x& p' G
  884.     process_back if Input.repeat(B)9 F$ C( D# J, E6 j. ?! r* r. x" C
  885.     process_ok   if Input.trigger(C)
    , ~& @9 Y$ g. M% Q) t8 B' _; @" x
  886.   end
    : c# O% J0 }* r2 Y1 |/ s5 f' m9 O
  887.   #--------------------------------------------------------------------------' H' p* R$ \& d( q+ ]" N
  888.   # ● 跳转“确定”2 \# p6 R4 \: w0 Z
  889.   #--------------------------------------------------------------------------+ {+ G: E5 v( Q4 L) [* G$ N
  890.   def process_jump
    ) b* y* N+ h$ o- X. X1 }! Y
  891.     if @index != 11
    $ m4 p: N$ Z' J8 m) E, V
  892.       @index = 11
    # B. P# Q% |+ f$ |
  893.       Sound.play_cursor% [0 }# _, V$ @( H0 ]
  894.     end
    7 ], }8 X, q$ M  F& k
  895.   end
    4 h7 R% P3 \9 N, Z5 K/ X
  896.   #--------------------------------------------------------------------------" a& t& |; ^5 f6 j" w
  897.   # ● 后退一个字符
    0 b( N, {9 X9 Y2 Q9 [  ]% G
  898.   #--------------------------------------------------------------------------0 w3 P4 v4 n" l; I4 f9 @2 v& P
  899.   def process_back$ c$ w9 }- m; v
  900.     Sound.play_cancel, J$ `$ B" h5 l% n6 [6 a
  901.     place = 10  (@digits_max - 1 - @old_window_index). }# p2 P: D0 |/ q
  902.     n = (@number  place) % 10# O- m. s/ g  G9 S  `7 |
  903.     @number -= n  place0 T& w) S9 L9 r0 c3 S+ @8 q5 P+ P
  904.     @number_proc.call(@number)
    : N. G+ }1 F7 J" b/ y" }  S$ @
  905.     @old_window_index -= 1 if @old_window_index  0
    - |& a! `% Z3 |( N  S8 K4 c
  906.     @index_proc.call(@old_window_index)
    ! m) G7 J" a5 |$ D4 r% q# m
  907.     @refresh_proc.call+ V: @. ~( i+ M, }# X
  908.   end
    ' V1 j8 _8 J+ j: x) K: ?, ]5 S# T
  909.   #--------------------------------------------------------------------------
    ( u; J( V. M3 u: _
  910.   # ● 按下确定键时的处理8 r. T( I1 q  d6 g  N5 T/ y9 [+ H
  911.   #--------------------------------------------------------------------------- |" q9 ?: ~. ~3 J4 \$ L
  912.   def process_ok9 H' [9 N5 n5 h0 n8 r4 j2 `; M! Q
  913.     if get_number" o/ W  ]. {' W2 J# ]0 `
  914.       Sound.play_cursor! f/ R+ `6 p5 d
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    . t# ^+ H: {* H+ |- c! Y
  916.       n = get_number - (@number  place) % 10
    " G1 x1 I) ~, k/ u+ N8 c8 l
  917.       @number += n  place
    . l8 J4 b$ V( G$ b9 p# }4 k
  918.       @number_proc.call(@number)
    ; T: n' K% N2 q- _* m$ T
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    % J- c. k8 p" [# ~+ e
  920.       @index_proc.call(@old_window_index)2 Q2 S0 _5 S' d$ O5 Y, ]" v& g9 v& M
  921.       @refresh_proc.call! u8 j9 C. D$ F1 O
  922.     elsif is_delete8 m" ]- M0 \! B# U6 E
  923.       process_back
    " t2 h8 R% i( P! D: b0 S
  924.     elsif is_ok( o# X0 L+ V5 X# y" B
  925.       on_input_ok
    1 ]* f4 B9 e# ~; U9 U( K
  926.     end1 C. ?3 w% m1 R- L
  927.   end
      Q+ ?7 A$ N" x; J; L  P: }5 j- c/ C
  928.   #--------------------------------------------------------------------------% }: x5 x4 c: h- I3 p! z. |; Y1 I
  929.   # ● 确定
      j4 h; A; A" P; `' D9 [) m
  930.   #--------------------------------------------------------------------------
    ( A5 B- x, K  K! `- W
  931.   def on_input_ok
    % h1 y/ o" K) p. a
  932.     @index = 0* [: U$ }7 u3 p+ z" O, [5 u4 v; G" N
  933.     @old_window_index = 0
    ( S7 C6 _: @7 D) ~
  934.     $game_variables[@variable_id] = @number: z8 o: ^0 u4 M
  935.     Sound.play_ok9 M) _& W2 q: R' C
  936.     @close_proc.call7 C5 K) f! H' _: k* t0 D2 J- @* b: e
  937.   end( i1 j2 y# t7 ]8 w
  938.   #--------------------------------------------------------------------------
    3 K% D2 v2 ?, J2 }7 W; d
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    $ u" G% s* B7 ~, [: F9 W
  940.   #--------------------------------------------------------------------------
    7 a$ l3 I! I& I
  941.   def set_mouse_pos( k2 h8 }( m/ \
  942.     if viewport.nil # necessary!
    " q' m5 x9 k. i8 y9 m4 Z
  943.       vp_x, vp_y = 0, 0
    6 i9 E/ U3 q' ~( ^$ k- g  T
  944.     else' @) K! n) o! ]& f
  945.       vp_x = viewport.rect.x - viewport.ox$ a! V' E  j1 V7 ^) C% {
  946.       vp_y = viewport.rect.y - viewport.oy3 _+ W# E. g/ Y! t
  947.     end/ G8 v# N4 }+ H0 e4 w: \' N3 T
  948.     item_x1 = vp_x + x + standard_padding * A) f7 ?% y$ i/ v( c/ E
  949.     item_y1 = vp_y + y + standard_padding
    6 P; C+ P6 X) o% j6 ~1 o9 a& l( y. y
  950.     get_index = @index  0  0  @index * V& Y  ^" Y% x
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)! O! z- {, R# Q$ b
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)  L  p2 F& s2 V) d
  953.     Mouse.set_mouse_pos(new_x, new_y)
    3 H. |& F, G! e$ q! a5 G2 |$ m
  954.   end7 [* g6 C8 y3 q
  955. end
    0 j) d- u  c1 }1 H4 H

  956. 2 R8 v& {; d- h$ X4 M+ ^0 k2 F! r, S( U
  957. #==============================================================================0 Z5 |) D2 e" i) ^! `  x
  958. # ■ Window_Message
    - W- E6 t6 y; W" {& z- D8 ]
  959. #------------------------------------------------------------------------------
    $ h) w6 q! H: ^6 q# s2 `
  960. #  显示文字信息的窗口。5 ]: z3 q7 z' @, M: Z
  961. #==============================================================================
    ' g1 Y  E/ O4 m! p+ h
  962. class Window_Message  Window_Base7 }+ T/ X7 `/ Y1 ]+ q/ c
  963.   #--------------------------------------------------------------------------9 v+ u' `! J7 [
  964.   # ● 处理数值的输入(覆盖原方法)1 Z2 j0 M9 n  J: u- P' m7 M( Z! \
  965.   #--------------------------------------------------------------------------
    ' z* j( W6 x, T
  966.   def input_number+ v( T, D) v7 L  t% z/ l6 |
  967.     @number_window.start
    * i' S9 E3 [" e% Q+ U$ {2 h8 e
  968.     Fiber.yield while @number_window.extra_window.active8 U1 w7 F: D1 ?9 U4 n
  969.   end! J3 ?" T" V# Y
  970. end! b) O6 J' k- S; h: }4 h

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

  2145. 8 n6 ~2 Q9 {5 V
  2146. #==============================================================================7 b& v. t$ \' V4 R- h. v& a
  2147. # ■ Game_Map
    ; D& d9 t) }& A3 J
  2148. #------------------------------------------------------------------------------
    2 Z* _5 D% ^7 ^( ]
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    $ T- Q" Z' y) w; K8 n
  2150. #   本类的实例请参考 $game_map 。' c! d8 \$ ~/ b7 M
  2151. #==============================================================================' ~, d, L8 [* O5 n' I
  2152. class Game_Map
    2 E) r- }: }& ^, a) b6 w% s. f' D
  2153.   #--------------------------------------------------------------------------
    / G/ G% A6 {* }! {
  2154.   # ● 定义实例变量
    ) J" R8 n' H9 z! R
  2155.   #--------------------------------------------------------------------------- L! c3 @* |) W% F6 D+ K# s  c  k
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
    9 ]# j+ a$ @* {
  2157.   attr_reader mouse_map_y # 同上. G1 C8 D, C" Y8 \  H
  2158.   #--------------------------------------------------------------------------
    ' g6 H' l: `+ r
  2159.   # ● 初始化对象- I+ x5 O8 `: ^1 P4 }
  2160.   #--------------------------------------------------------------------------
    3 N: Q: s: V/ S0 H- X* D
  2161.   alias sion_mouse_initialize initialize1 M9 n- c' Q) N7 V
  2162.   def initialize
    7 v6 z8 f& V9 d( x0 h& s% G
  2163.     sion_mouse_initialize
    1 j% t0 G+ N9 U0 w5 h/ v+ K  D
  2164.     creat_move_sign  ###
    2 W0 z8 e1 K4 O" g
  2165.     set_constants6 M% o4 p- }7 [6 y
  2166.   end
    1 j. _  Y$ \2 j: i3 Q
  2167.   #--------------------------------------------------------------------------% t. U6 ?4 Q7 B  W. \& y' @4 q
  2168.   # ● 更新画面* B4 x( Q( u! ~3 W$ {
  2169.   #     main  事件解释器更新的标志) h! t& k) Q% m1 `/ O( I: S
  2170.   #--------------------------------------------------------------------------
    # H  |: H; Z+ i6 N9 F8 E1 ?
  2171.   alias sion_mouse_update update
    ( w" h# j4 V5 D8 {  K
  2172.   def update(main = false)9 v. \7 V. D/ B) c* \2 Q6 E
  2173.     sion_mouse_update(main)
    - q) ]" c1 A$ e3 |/ v$ \7 E
  2174.     update_move_sign
    7 H- W' b7 O! x- N9 `: l, A" ^
  2175.   end
    . ~! b/ d1 ?* \
  2176.   #--------------------------------------------------------------------------
    : K  S7 R* j0 T5 W, ^
  2177.   # ● 创建显示路径点的事件' Q' J# x6 F3 b6 f
  2178.   #--------------------------------------------------------------------------* N4 V8 o% r% I9 \
  2179.   def creat_move_sign
    . W* G- w9 P7 w. E
  2180.     $mouse_move_sign = Move_Sign.new
    ) Z9 F) {5 c; b; s, V1 w
  2181.   end
    0 V" w: Y: i6 p3 O( M7 @2 [# I0 T
  2182.   #--------------------------------------------------------------------------
    + Y# h1 a6 G. M. a/ @
  2183.   # ● 更新显示路径点的事件
    $ k- A! b% Y* w' a) F8 u( |
  2184.   #--------------------------------------------------------------------------9 \: e( v; r( R( u. ?" ?: ^
  2185.   def set_constants( B  \3 ?0 K! L# Z9 Q# g/ J
  2186.     @mouse_pos_setted = true
    8 [' W5 r; A& q3 b/ ^1 l1 P
  2187.     @set_pos_prepared = false
    " A) V4 e+ r! I( U$ g! t
  2188.     @mouse_old_x = 0  M5 E+ m, b( e
  2189.     @mouse_old_y = 0
    2 u! w, ]' @  m2 X
  2190.   end
    ! _1 O' d% K6 M
  2191.   #--------------------------------------------------------------------------+ a) k; z2 I! z3 |& a
  2192.   # ● 更新显示路径点的事件
    ! f% J" [2 B% o% P$ l  o' q* }+ A& T
  2193.   #--------------------------------------------------------------------------! ~9 _3 H! q3 `1 A/ y
  2194.   def update_move_sign
    1 n! L- z$ `1 Z5 d) a& U3 _1 j. K
  2195.     $mouse_move_sign.update( G* J: V! b# Q1 z
  2196.   end- S1 w6 v. B0 G; H8 _. i* K
  2197.   #--------------------------------------------------------------------------
    1 e! Y6 e0 C9 f& Z- v0 S3 x) A
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    % m1 w& a7 b5 t7 \* r5 Q) {3 t& z" D
  2199.   #--------------------------------------------------------------------------( Z; ^" n3 H3 ~3 ]4 l6 }
  2200.   def get_mouse_map_xy( c' L2 C% K2 `& M& ~' D4 O6 Y" i2 v/ D
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    / e7 R( M( Z9 t
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)4 T7 n3 n# N! X" |5 \% x) ^
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i); e5 Y3 W  P( N# ?4 h3 x
  2204.   end# G3 O0 }, M! f* L/ e
  2205.   #--------------------------------------------------------------------------
    5 B5 X: A+ S1 K7 b5 ?3 O8 g9 d
  2206.   # ● 返回地图画面时重设鼠标坐标
    % O( M; ^' t, g
  2207.   #--------------------------------------------------------------------------
    8 f  F, w9 X/ P. Y- ^
  2208.   def reset_mouse_pos
    ; f/ u0 P8 N& G6 h% v! M
  2209.     return if @mouse_pos_setted
    - R4 `) \6 m5 X" _. a$ T0 s
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
    1 W: f& ]: ~3 H- ?! B
  2211.     @mouse_pos_setted = true
    % ], u6 ]# l0 A
  2212.     @set_pos_prepared = false* D; m9 B4 Q' Z: \; r) A
  2213.   end1 P1 b! s; Z4 c5 {1 D3 V/ d5 F/ C
  2214.   #--------------------------------------------------------------------------/ u3 ~- ^' h. K- n5 z+ G
  2215.   # ● 重设鼠标的坐标
    , _; d9 f) I0 R( ^, f" n' m
  2216.   #--------------------------------------------------------------------------
    $ h1 r+ h7 j# I
  2217.   def prepare_reset_mouse_pos
    ; H# k! O. |% M( M) o& [) v' Z8 C
  2218.     return if @set_pos_prepared& r$ x( O" ]. |& ]6 Q& I* E
  2219.     @mouse_pos_setted = false! l9 C2 K+ c* p: R/ t! d" [
  2220.     @mouse_old_x = Mouse.mouse_x
    ( B' P' ~) D6 `7 I  D& @$ D  q
  2221.     @mouse_old_y = Mouse.mouse_y; b! P) u0 g! @1 q6 h* O& p; Y
  2222.     @set_pos_prepared = true
    " K$ k; v- Y  H6 l- Q9 [* n
  2223.   end9 s" `+ G! O- ^/ v+ ~9 Q
  2224. end
    5 ?6 k1 n& U3 C  _( J0 @( O

  2225. ; H9 [& c! _/ }4 E# }& x" f/ {
  2226. #==============================================================================
    ) ?+ r5 \1 x; T( Q0 V
  2227. # ■ Spriteset_Map: n7 }2 M# j& r, M8 @$ I
  2228. #------------------------------------------------------------------------------+ m% o+ U6 q% a  z
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。0 t- Z0 v$ c" b0 V+ `
  2230. #==============================================================================
    " Z) w: E7 @! y& q
  2231. class Spriteset_Map
    " T+ M# m3 C" U! a5 @6 ~: |
  2232.   #--------------------------------------------------------------------------
    0 x& W, ?: x. B2 ^1 F/ Q* J
  2233.   # ● 生成路径点精灵8 _& S- p9 i( q8 U* j
  2234.   #--------------------------------------------------------------------------
    # Q7 K  \7 W. U5 t* j- I
  2235.   alias sion_mouse_create_characters create_characters( _9 o- e$ p4 w& B% S' ?% S
  2236.   def create_characters, y/ u/ w* C- V. J# I
  2237.     sion_mouse_create_characters: N( A. _6 i, V9 V6 d1 b
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    & z5 s5 O2 _8 y6 F) e+ P  x
  2239.   end5 A% T+ T% I  g2 q& Q
  2240. end
    ' i( m! W8 b, ]) z7 E
  2241. 1 E5 \2 s1 y" v/ m' B
  2242. #==============================================================================! }* n( e/ u% W3 o
  2243. # ■ Scene_Map
    5 k: P6 b$ N. P2 H& A% k; z) V
  2244. #------------------------------------------------------------------------------
    / t5 J, b0 @4 S4 Y! o. u
  2245. #  地图画面
    1 a" q9 m" p) g3 P% l8 q: D( f
  2246. #==============================================================================
    + L8 [5 t0 R7 ^3 b. P6 U. x( z
  2247. class Scene_Map  Scene_Base. r! m6 A3 c: |5 R
  2248.   #--------------------------------------------------------------------------/ B+ I" I" a1 x3 _
  2249.   # ● 画面更新
    % W$ M- C% y1 n" V
  2250.   #--------------------------------------------------------------------------; E5 c3 L- o# }2 Q/ S9 ^* z/ H
  2251.   alias sion_mouse_update_scene update_scene6 |: G, V& S- B
  2252.   def update_scene
    ( Y% [4 l0 w0 G$ l( r- ]9 _
  2253.     sion_mouse_update_scene( T  A. q% L2 w
  2254.     update_mouse_action unless scene_changing
    $ g  j9 g  C! k7 ]% y
  2255.   end) u7 w& b/ `, p
  2256.   #--------------------------------------------------------------------------. |+ R' Y8 u5 K( Z
  2257.   # ● 场所移动前的处理
    " p  R* J2 U7 B9 y
  2258.   #--------------------------------------------------------------------------0 g7 v" k" [! h
  2259.   alias sion_mouse_pre_transfer pre_transfer, T3 P% V  z# [9 S# t" C3 A4 l
  2260.   def pre_transfer9 E. g) C! Q+ ]+ O: l
  2261.     $game_player.reset_move_path
    $ ?- A! R( ?$ V( i% q: o
  2262.     sion_mouse_pre_transfer
    * l# W3 g& \/ k9 d; e
  2263.   end
    ' \7 q* I1 R# X2 X& C) V! c
  2264.   #--------------------------------------------------------------------------
    " \8 v& V& u- q; ]8 r% Y
  2265.   # ● 监听鼠标左键的按下- D: @0 w4 G! B8 l' ?
  2266.   #--------------------------------------------------------------------------& w! j. r- ?6 s: m
  2267.   def update_mouse_action
    ) v% S. |( m( p/ i
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    & F- e/ D8 K; E* Y1 h! Y
  2269.   end1 i, I7 A9 u6 J0 i5 f
  2270. end6 E, s" g$ C9 C  y

  2271. ) H6 N& l% X/ H
  2272. #==============================================================================1 B, E: Z# R/ S$ l
  2273. # ■ Scene_File
    ! a' \+ `4 T5 @4 M5 l0 @: z
  2274. #------------------------------------------------------------------------------
    $ d% |6 l" `; j3 x. w  G2 ~/ F5 g
  2275. #  存档画面和读档画面共同的父类
    3 Z! n" ?. I3 O" D7 ]4 `
  2276. #==============================================================================
    + u+ ]2 n3 y- H2 v: Q3 t8 W% h+ R
  2277. class Scene_File  Scene_MenuBase% O$ S3 T6 ?( V
  2278.   #--------------------------------------------------------------------------- L8 T! v) E  n. @8 |# c
  2279.   # ● 开始处理6 V- F/ w1 b8 S8 D7 b/ \/ c  f* \4 i+ H
  2280.   #--------------------------------------------------------------------------
    ! P; u7 C6 D, v
  2281.   alias sion_mouse_start start- N$ I$ J; X  u) W+ Y- K
  2282.   def start
    3 }  U, e" I! n3 L, z. q7 {$ E- v7 A
  2283.     sion_mouse_start
    . X3 K$ a4 `) z2 j. O' ?. v$ K
  2284.     @move_state = 0
    ) U5 j: ^7 ]* J/ j& f& U
  2285.     set_mouse_pos" R& ]* S. R3 [; y' s6 C
  2286.   end' p, @5 R/ }) P! w( L: X6 O+ n
  2287.   #--------------------------------------------------------------------------
    / h! B2 X1 i4 S) A
  2288.   # ● 更新画面+ m* d. d$ m. G% Z$ F( b- j
  2289.   #--------------------------------------------------------------------------6 @1 d+ ^% Y& q6 _  t$ B# N* X3 B
  2290.   alias sion_mouse_update update2 ?" w% l$ B. P  r7 O& Q" a. E
  2291.   def update
    , o- T5 ^8 r+ c& K$ S  T
  2292.     sion_mouse_update
      l- e" h1 X9 r
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos9 O  a5 c  s% `
  2294.   end  P% P) n3 h: p7 Y# t& m
  2295.   #--------------------------------------------------------------------------8 S# y0 S# I: @
  2296.   # ● 更新光标1 E( {. A& a5 _3 J; x# R
  2297.   #--------------------------------------------------------------------------
    / Y' \9 B& V* ?& @% N+ N1 M
  2298.   def set_cursor- W1 Z; p7 Z+ I3 {* Q0 X
  2299.     @move_state += 1
    3 r' B6 _9 W  g% |: b0 J
  2300.     last_index = @index  g% M3 p4 `' g0 _6 P0 c0 L! E5 ^
  2301.     if mouse_which_window == -2
    ) L# Y9 V' Y$ W" {5 `4 ^
  2302.       if (@move_state - 1) % 6 == 0
    $ m, N4 `* Z7 G; z7 j
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    . R. w  D: l! m
  2304.       end- N/ w3 M7 P; ~( _
  2305.     elsif mouse_which_window == -1
    # E) M% d9 Y6 F+ |
  2306.       if (@move_state - 1) % 6 == 04 ?6 [0 ^, r2 ?: P& w% }" h9 Y
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0: x4 w) o3 `8 P# I1 W
  2308.       end
    * t- A) v5 x3 W+ v' _
  2309.     else
    1 I$ o7 [8 X; D
  2310.       @move_state = 0
    # |8 O# w# F7 S- U" K
  2311.       @index = top_index + mouse_which_window
    0 [" m6 z0 l" q( {% M, C( H9 Q
  2312.     end- y/ s- d: r( `9 _% H0 L
  2313.     ensure_cursor_visible7 u5 d. R! e6 X7 @, \8 ]! Q
  2314.     if @index != last_index$ A" v6 K" t3 V: ?$ _
  2315.       @savefile_windows[last_index].selected = false
    ; j4 E% }2 u# z; v
  2316.       @savefile_windows[@index].selected = true3 p2 w& ?9 H! Z$ m1 C6 {5 P
  2317.     end  y1 o2 f( L3 r+ r, n9 T
  2318.   end
    # X4 ^( g+ I1 I; Y3 f& [
  2319.   #--------------------------------------------------------------------------
    , _" t4 L  e  W# \; a0 a+ q
  2320.   # ● 判断鼠标位于哪个窗口- H( t2 T8 H& S" G5 l6 Q. c( c
  2321.   #--------------------------------------------------------------------------
    + @# M! O; X3 `
  2322.   def mouse_which_window
    8 n( K# l- S! i1 u
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y& R" @4 k$ E+ R  b/ g
  2324.     if mouse_y  @help_window.height + 140 d% Q, @/ i" [( Y( y8 q
  2325.       mouse_row = -1
    / }- |# u$ ?  J" @  ]/ c
  2326.     elsif mouse_y  Graphics.height - 146 E6 }- P8 u6 o7 W( z% M* G) t
  2327.       mouse_row = -2: X# @: n! d# z# e/ Y9 T
  2328.     else1 J* |) D/ p/ u
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    . w% j. V9 R) ~5 I8 x) l
  2330.         (Graphics.height - @help_window.height)5 E2 D' ]0 C+ [* z
  2331.     end
    ) b* g; E2 P$ j' `) S% U% G
  2332.     return mouse_row, F6 _# [) J7 D& G6 @. V4 `
  2333.   end3 s/ ~0 L3 b& U9 H+ G9 T  C
  2334.   #--------------------------------------------------------------------------
    5 e& |8 w. s+ Y4 K4 V4 s  p
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ( W5 ]; y) |7 y
  2336.   #--------------------------------------------------------------------------
    . ]" ^, ?9 X9 c& X2 T; X9 i  h
  2337.   def set_mouse_pos
    1 }/ z! K- x, T- H7 P+ `
  2338.     new_x = 40
    & g- U$ v" z! r; \5 z
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24+ z( O: ^' {4 S. f: ~6 J
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    ; q% i8 P- L. [2 p3 k
  2341.   end
    , n0 V8 z$ F; i+ R
  2342. end' I7 n, c& j3 b) c  H; Z# X

  2343. ) W0 a* v1 W+ `. Y" L% H/ X/ T
  2344. #==============================================================================& h% b  ?! w+ F5 z6 v( K  c  o
  2345. # ■ Game_Event
    * t- w/ @7 A9 E' A
  2346. #------------------------------------------------------------------------------
    3 g) C# ?% t# Y$ m
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。% O- @8 f: d$ T& f; M7 h
  2348. #   在 Game_Map 类的内部使用。/ V3 K  D6 V. |' `- j5 ^* u
  2349. #==============================================================================
    $ X. p: X+ j- Z! s2 I, i# O) [
  2350. class Game_Event  Game_Character
    # o0 l7 s  K- I- O+ O
  2351.   #--------------------------------------------------------------------------
    / u4 z- @/ U8 Y8 Y% J
  2352.   # ● 事件启动, z! D3 c  j$ D8 Q$ a1 V9 N, i6 m
  2353.   #--------------------------------------------------------------------------
    . g3 S7 c& A+ S+ G: a
  2354.   alias sion_mouse_start start. ?$ R0 w4 f, S% c
  2355.   def start
    : Q" J  ~. I+ Z+ l/ W
  2356.     return if mouse_start && !Mouse.press(0x01). d' [0 P- P$ p  M0 J  o8 t$ R4 H
  2357.     sion_mouse_start3 u+ l# V3 ]% Z- _+ V
  2358.   end8 t& h3 _! n! E" r
  2359.   #--------------------------------------------------------------------------
    2 @5 `6 y7 f3 n
  2360.   # ● 判断事件是否由鼠标启动2 j6 s3 V  K" r# h
  2361.   #--------------------------------------------------------------------------, e6 n9 f& H# m. M# A  }
  2362.   def mouse_start
    ) q8 i  k: W! {8 B
  2363.     return false if empty
    3 I! p% a+ x% v' G9 Q
  2364.     @list.each do index
    ' t/ L0 Q# `  d
  2365.       return true if (index.code == 108  index.code == 408) &&1 J$ b+ {4 q2 D/ f
  2366.         index.parameters[0].include('鼠标启动')# k( u5 x; ^$ G) N
  2367.     end
    6 h2 _- ?  U3 r$ D
  2368.     return false
    + K5 ]5 X& J, l1 `4 a5 m
  2369.   end0 T- m- w4 b- D) v4 }
  2370. end
    9 s* v& {5 m9 t. T' F9 R
  2371. 1 {3 X/ Q( _, I- Y' u
  2372. ####泥煤的height: f- Y2 {/ E6 |: ~
  2373. # @height = height- R/ }2 {+ G( j7 L

  2374. 7 t0 T; x8 [* S* e8 T5 C
  2375. class Area_Response/ y( W9 Q4 r# X# K2 d
  2376.   attr_accessor type
    9 v0 Z# w0 f( n1 n# W
  2377.   attr_reader ox
    + ~  I, Z/ t) ]$ n
  2378.   attr_reader oy
    3 A: Z4 H9 F/ h) ]8 G# D6 P
  2379.   attr_reader width* Y: x: g* i* h6 m9 E5 ^! r7 I6 L
  2380.   attr_reader height& o+ H3 T$ y. f$ y  a
  2381.   attr_reader switch_id. R; L$ `' v6 f
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    0 [1 J6 w  i* o1 @& g1 I- w; a
  2383.     @type = type( W' c3 i8 o7 N
  2384.     @ox = ox% ^" x% s! i. K* J9 Y( O
  2385.     @oy = oy
    3 S( d( ~0 Z; G+ M6 a  C( @
  2386.     @width = width$ y* G# L4 L; E1 B
  2387.     @height = height
    3 c0 B# k1 j6 ]+ {, Y$ p; {
  2388.     @switch_id = switch_id
    9 m# J  H& q/ e4 u) |& O; A
  2389.   end
    - c8 a1 U: j9 `# |
  2390. end
    # G& }# A  w+ [9 U
  2391. : c' E1 Q) D/ X. Q- b$ I" H5 V
  2392. $area_responses = []
    6 @$ q9 W2 ~( J0 ^+ @7 r) b
  2393. 6 J+ Q3 o! G; L0 Z, o  [+ Z
  2394. class Scene_Map6 {" x% b; [7 h2 Y  ]# _
  2395.   alias update_mouse_2013421 update_mouse_action5 _) l& [# O/ m& y( L2 x
  2396.   def update_mouse_action- r7 ?% A  h- D4 ]2 [4 D
  2397.     update_area_response: w2 j! V0 C, u" V) m
  2398.     update_mouse_2013421; B  U9 c: M1 A
  2399.   end
    % g; U& p' \0 u
  2400.   def update_area_response
    0 {% t& P5 s2 l
  2401.     responses = $area_responses3 N3 N4 u9 t+ C, T- k: A  c- `; k
  2402.     responses.each {response
    + L) B  Q9 H# L* o) V& v
  2403.       ox = response.ox
    ) i7 R9 i% R- S7 C* Y2 \$ l" Y3 j
  2404.       oy = response.oy+ J4 ?9 X+ _& h; x, w
  2405.       width = response.width
    7 M! K2 F* H, G! n6 k
  2406.       height = response.height
    9 z! n: |- p# g* A
  2407.       switch_id = response.switch_id
    ) ]0 k2 B/ v+ K) i
  2408.       case response.type/ K9 K- I9 {- M$ @9 r
  2409.       when 0$ Y; B& u& {# C; V/ L- V( ?6 b# ]
  2410.         if mouse_in_area(ox, oy, width, height)$ u, r6 R2 B0 w' F: z; g
  2411.           $game_switches[switch_id] = true
    ; r% N& ?) v( n% _, N* O1 M/ @
  2412.           $area_responses.delete(response)
    4 M# U8 m1 d: X5 I) {, ?1 f
  2413.         end- G+ n% T3 h9 v. k  h& @- p
  2414.       when 11 I; n, t2 ?8 J2 R, g5 z* P
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)2 E$ W5 q, e- _, T8 Q. i
  2416.           $game_switches[switch_id] = true8 m5 y( B3 b* c0 }% i: x
  2417.           $area_responses.delete(response)8 q6 K) F- s! f0 x) z: `
  2418.         end2 }% X" x  [0 E$ h6 j% R4 h
  2419.       when 2/ C. q8 F6 k1 L! Y( x  B+ @6 W
  2420.         if mouse_in_area(ox, oy, width, height)
    ) e; D5 t1 F0 h. \3 ^9 r, M! `0 T8 Q' `
  2421.           $game_switches[switch_id] = true$ j+ K3 K$ ]( O( B  i6 S
  2422.         else
    3 C: O. g* o8 X5 l
  2423.           $game_switches[switch_id] = false' W. j0 L* m$ G( x; M  l  A# O
  2424.         end9 i3 B3 g$ A: v$ R# D) h
  2425.       when 3
    - _4 H- K1 m- N5 ~
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    ' P+ Z& J  E' t$ i  x7 |
  2427.             (oy - $game_map.display_y)  32, width, height)& o* P) p' P. ~6 P0 n
  2428.           $game_map.events_xy(ox, oy).each {event' Y1 f5 N( V. e" ]7 o. C! z( U
  2429.           event.start9 D. E/ g$ V# T
  2430.           $area_responses.delete(response)( o. j) M  `/ `* k$ s* c4 M9 r
  2431.           return
    4 g6 j7 ]9 w4 F/ t& d8 s, k
  2432.           }
    2 U; v  F- g5 _
  2433.         end
    : O6 W5 w2 |* A  S
  2434.       when 4
    ( l5 [: r5 x* t
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,& L) k$ @) R4 \: z8 k- }
  2436.             (oy - $game_map.display_y)  32, width, height)
    2 A2 x' t/ Q$ A. y2 M# v3 f' _
  2437.           $game_map.events_xy(ox, oy).each {event* k5 i+ L' p  \8 S/ d
  2438.             event.start8 _0 T6 B2 `9 _' [
  2439.             return( Q, }& `6 K- O+ m+ x$ P8 P
  2440.           } # L8 f# w6 s  e
  2441.         end. Y/ H" S) f, B; E& l
  2442.       end' i; j$ J, g" K1 m: A- h
  2443.     }3 p# {5 F, f* S! a
  2444.   end
    6 K) i$ h: C: Q1 G- o
  2445.   def mouse_in_area(ox, oy, width, height)+ {4 ]7 w! y1 t6 Y( p6 D
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    . Z9 x' X% i) ^# B) d2 y; ?5 \
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    - Y5 C- q2 S( }+ v
  2448.   end( m7 O) q* U* S5 N4 F8 a4 e* j6 p
  2449. end
    5 r$ F$ N( l: l: c! i
  2450. class Game_Interpreter+ B; `6 d. t8 u9 b7 q
  2451.   def area_response(arg)
    # C# {4 o& _9 ~. P8 n, }4 Y5 M
  2452.     $area_responses.push(Area_Response.new(arg))7 c# e7 c9 w8 w' `% r
  2453.   end1 s& c# d. {& {+ p  H% W
  2454. end5 }/ t9 N7 Q( w+ \. Y7 S3 a' a
复制代码

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

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

GMT+8, 2025-9-12 00:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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