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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    5 ?# ?7 L  U0 J

  2. , P2 W" [* ^8 L& o6 A
  3.   Sion Mouse System v1.3e: i2 b9 W' o: P4 l1 D& N/ f' u
  4.   , G5 n+ D$ {/ \6 E) K
  5.   Changlog
      }) ?! A3 l6 t( \3 S
  6.   
    7 C# m" y2 J1 G3 r
  7.   2013.4.21 v1.3f" Z9 U. ?1 ]# O: M+ g: [
  8.     3 s& w" w) A& v9 O
  9.     1.3f 卷动地图 bug 修正
    " t. ]/ s  K( \3 J- L, ~* P/ h7 j$ K
  10.    
    % G7 ], U  Q+ ^; }# \' |" C
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    9 {2 }# s5 z! D- X! U) \, S
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内7 r; P2 I% c% d2 K9 ^- G: S
  13.                               Mouse.unlock_mouse_in_screen 解除锁定, B4 y- F. r' y& y. u6 X- y

  14. * A' ^: J& u7 m$ v; ^- s
  15.     1.3f bug修正
    ! R# X" @1 k+ R. p5 l
  16.   6 R+ h: j. L1 `) G
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    5 C9 d3 X4 u8 [
  18.           关闭菜单时,鼠标是否移动到原来的位置。& n; b. h# B( T4 l  L7 ~
  19. % z2 V& ^; M, |, Z) v
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    2 z4 T3 O8 y1 Y, N
  21. % @- e4 ?4 ~: j& z
  22.     1.3b 修正一些罕见的bug;
    8 Y. ]- P+ p3 p1 q/ \; H- d4 W

  23. 7 J1 {/ [* S/ k% c- f( Q* h$ _. O
  24.     1.3a 代码小修改;/ T  S4 d# g* P$ M/ C% O$ n4 K: a
  25.           加入了鼠标点击启动事件的功能,2 Q' ]' h7 t" m2 S; u
  26.           在事件中加入“注释”: 鼠标启动  ,  u; H2 z6 r6 c9 T; L7 C
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    & u& `# D( p; D$ O) p1 ]# N
  28.   / `$ q4 B, S  ~2 l
  29.   2013.2.12 v1.2/ }5 J, l3 n# \& W
  30. . b8 @2 J$ C4 y
  31.     寻路逻辑优化;
    / ]% Y( j& v# T, K) J
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;5 c# z! G1 }/ f% m/ N% J$ K; C9 W
  33.     现在支持用鼠标来操作载具了。
    , ?- s' l* d1 `1 h5 m
  34. ) Q6 H  j# P7 k: f; _0 B
  35.   2013.2.8 v1.1
    * Y: N, j% W. O, k; s3 m; @2 y

  36. ( E' u4 [5 ?' p  c. e
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    2 i5 w( d) g5 x
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;9 j1 d7 u# h. t- L& \' {# O5 w2 J9 c
  39.     移动时,路径指示点的绘制更加稳定;/ G! v+ V* B6 _0 n& Z- c- W
  40.     现在支持默认存档画面的鼠标操作了。
    & h; F- L0 Z* c3 [* c

  41.   i. X9 P3 _( {9 n5 i+ l1 w  Q& u

  42. " K( a' z- p3 ]1 i/ @( S
  43.   OrigenVersion
    9 D8 g% H. `) l+ l0 r" W7 a/ V- T
  44.   
    9 [* i7 }5 G% K% s% i
  45.     2013.2.7 v1.0
    4 _# S2 ]2 K5 g# I7 @% d& e
  46. + @& E  v/ p* s. i
  47.   主要功能
    ' N5 P) X8 v9 q. Q! k+ c& Q  ]

  48. 4 _8 i3 H+ F) m3 A
  49.       使用鼠标进行各种操作...
    2 i' S. H& [  {* E
  50.       将鼠标锁定在游戏窗口内4 n0 q& s- X' v1 K. H4 V% w
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    . i5 r) H6 g- @0 A6 U& p( q( C. ^
  52.       双击鼠标进行冲刺2 m9 F; F; p6 c' Z2 i
  53.       更改地图卷动方式以适应鼠标移动
    # R! O0 b: g, Q, e9 }' W$ _: m: ^
  54.       变量输入框改良
    3 F* ?  b  }7 H1 E

  55. ; k* F4 r1 D) x$ H/ z
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹3 W, S3 ]' [! Y% ~
  57. 3 j1 [7 l+ n& O9 j4 q1 B
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹" I3 D9 i5 t- m* m! C, t8 K

  59. / B5 E; g2 R0 d) Z6 q
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    ! K  ~" C* Q- @" S' K

  61. & L) L/ p6 [7 K6 X% E

  62. % a; `3 i  y6 X9 t( F6 [
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★1 E0 U  `4 Z9 d" V& K9 t0 G
  64. 2 ]+ l+ Y5 g6 z) S: W

  65. 8 P- M/ s8 y$ l0 U' }
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    2 g  s/ f$ @) p: Z$ x  x/ }) x! \/ a

  67. % f# b% u' r# q
  68. #==============================================================================
    ) _7 @; B1 r& k- j
  69. # ■ 常数设置
    " x8 A9 v4 a! v; W, k7 _1 Y5 Q
  70. #==============================================================================
    * J) b/ i' w' T% D. F5 U% |" t$ d
  71. module KsOfSion1 X3 k. c$ \! d# J& V$ K
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    " K- c. K; `. k5 Z
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    $ m: \6 k9 |0 r6 l
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    8 k1 C0 }8 w2 f& s- ?/ e0 \
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量! P+ l5 X: s/ ?
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处9 u8 r- I: T0 v/ P! O% m  s: r
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    2 f9 s8 x, i# F. c
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    5 K" {( V5 `' U& i5 W) N$ c
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    & N! D- m) I+ P, l3 d7 P! V+ |
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)8 e/ E' f; O0 s( B
  81. end
    * q% Y9 v* n. v8 z3 f$ K8 I; F. C. R
  82. ( _1 j/ c! w7 t; ]3 k8 ?. P5 m+ w+ H
  83. #==============================================================================
    7 W$ b% m  r+ U" v( d
  84. # ■ 用来显示路径点的类
    1 O  W+ L3 ^9 _1 e( E
  85. #==============================================================================
    $ U2 {0 n3 W* P+ U& p% {- g( _
  86. class Move_Sign  Game_Character
    8 u4 E! g6 b; l# y; `; E
  87.   #--------------------------------------------------------------------------3 f  ?1 E3 [2 `$ n+ Z8 {, |( j1 W. }
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图4 x% H! u; P9 u, {
  89.   #--------------------------------------------------------------------------
    . P+ l$ r: m( b$ A* `
  90.   def init_public_members$ x" p! _) B1 k1 _& y
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹9 g' P2 @$ V7 Q1 c, s% j! @
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0+ V' `* H# K( A; g
  93.     @move_speed      = 5        # ★ 踏步速度* E" I% |3 j. E+ i1 z
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)* T  I6 I6 C1 f% z0 W: a  P+ N
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度9 x/ N; v$ @; [# C: v
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    ; s( m' b, Q5 C/ |
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列$ v: ~' X( u, E/ B; i
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)+ u4 N+ L- ^, }6 b/ m
  99.   z% L, f5 ^) y  W( o3 j

  100. " D: L6 w9 i3 D+ t! @: w! J
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★6 X* k( H/ P, k3 i6 q7 J( x
  102.   `( I% ~- a" I7 Y, W8 R9 G5 x
  103. & ^/ u. @0 S$ Y$ N- M
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    + ?- I) s- {2 C  ]
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')" e' ?8 L% o6 N. ~6 ^* X

  106. / }+ m5 Q) z" |4 N' [
  107.       if $no_arrowpic_warn. j) P$ I1 a6 C2 _( f0 j9 p
  108.         MouseShow_Cursor.call(1)1 L# D' X, O- A5 p  P$ {- ^
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    8 L2 ^1 ^: p. y) p) k! e4 [

  110. ' x# f$ u5 V3 y* C) Q! @
  111. “路径指示点”将使用游戏自带图片& L2 }+ V, B# \- I" e

  112. 2 U4 Z& x) z8 y2 u  {
  113. 该提示可以在脚本内关闭')2 [; ?/ I' H$ l$ r6 a+ T. M1 Q
  114.         MouseShow_Cursor.call(0)
    $ P  E9 I, J* J3 c
  115.         $no_arrowpic_warn = false5 A* s3 A0 p+ B
  116.       end0 V. ]! V4 D7 l" C6 F! I6 m
  117.       @character_name  = '!Flame'
    , A7 I9 [0 {, X- w8 |
  118.       @character_index = 6' @& Y2 j% y; Z2 T# A, b

  119. , y* @0 Q# v1 W3 _) D% }& S
  120.     end
    " G0 v9 b! \% @" P$ D
  121.     @direction_fix = false  # 固定朝向
    # M/ o$ v' Y; y4 ]  }5 m" w$ x! ~" v
  122.     @move_frequency = 6     # 移动频率9 `2 Z, ^3 ]8 @# w" k
  123.     @walk_anime = true      # 步行动画& J* B- Y) ]+ D& t( O# ]8 Q# ]) h
  124.     @pattern = 1            # 图案
    / q" V$ @/ `9 Q, C9 c
  125.     @through = true         # 穿透5 I! R, G8 d9 D% M! e
  126.     @bush_depth = 0         # 草木深度
    1 v; O4 F; H" U3 G# q
  127.     @animation_id = 0       # 动画 ID
    8 e2 t* Z- |8 X$ f* j! g
  128.     @balloon_id = 0         # 心情 ID( g) {* j6 f4 Q7 @% y
  129.     @transparent = true     # 透明
    6 \2 p8 b' k7 W; M: H. ]8 x& R6 g
  130.     @id = 0
    $ u# S: g4 x6 N* j0 L* Y
  131.     @x = 0
    ! L! v" H% o+ K, \1 h( B9 w4 m
  132.     @y = 0
    0 u! T) h% y3 e! A3 F0 U) P% @
  133.     @real_x = 0! v9 s/ @; ?* I9 E+ |4 u
  134.     @real_y = 0% F$ f# C. q6 G, f3 t* h
  135.     @tile_id = 0
    9 D% N: U% \: F
  136.   end6 T, L3 Y0 C5 T% u
  137.   #--------------------------------------------------------------------------
    0 p; ?5 e" `9 L# K
  138.   # ● 定义实例变量
    4 f6 D, \: v! w0 N' s
  139.   #--------------------------------------------------------------------------& K$ l/ _  p( r7 v3 m! J3 l
  140.   attr_accessor direction7 q: p( E3 i$ |4 c
  141. end
    9 ]' B( O7 L" p
  142. 6 N% u! d" W+ M  g- a9 w  S' S2 W; K
  143. #==============================================================================
    $ a. ~- j8 n8 q3 e
  144. # ■ Module Mouse' _: h9 w4 [% o0 q" b6 t
  145. #==============================================================================
    * [. j$ F3 W  X8 Y. F
  146. module Mouse( U* V7 A9 d4 ?* L8 s2 r2 w
  147.   #--------------------------------------------------------------------------) J+ O' o  h# T2 z
  148.   # ● API7 q3 B3 }4 Y' y
  149.   #--------------------------------------------------------------------------
    3 c* j" m8 h! E' ]$ n0 a
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')1 e. a  b# p; z5 Q0 u
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')( G6 ~8 l  V8 Q! G
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    0 J8 S* o: f) U2 c: l" H3 w
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')3 q, t) C' {, o1 j  u
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    . g2 a2 x/ P0 c8 V( B! H& r
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')' F' j5 M7 k) T1 w- }
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')& v8 ^- l2 B0 U
  157.   Window_Hwnd       = Get_Active_Window.call( s! |& [0 M, `2 F' s- G3 I

  158. . [9 l/ }0 k5 R7 q2 y4 h1 ]+ B
  159. class  self/ z* u! ^- O5 R# b9 S  ?$ ?
  160.   #--------------------------------------------------------------------------5 v* m3 q+ C& I( R1 M
  161.   # ● 初始化7 U. [. J6 I- h5 p
  162.   #--------------------------------------------------------------------------4 m+ O; L& n( [
  163.   def init+ ^& d* o; N5 ~. g5 N6 C# ^
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor' G7 `; C! {7 `( l- }0 V1 f2 G
  165.     @left_state = 0
    5 m3 {/ }( u+ V( k
  166.     @right_state = 0* a( t. [: L7 ~) g+ f& E1 F6 o
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    3 _* r( G; \& O/ H4 n4 K$ P+ Q
  168.     @dk_count = 0 # 用于双击的判定
    / B8 C% r( g) m% V+ f
  169.     @clicked = false
    2 Q3 \: [/ z7 f; M4 x) `
  170.     creat_mouse_sprite6 v: }4 F# d7 l: c" j& ~" p6 u, s
  171.     update: f6 x* i/ k$ \; z4 k6 r
  172.   end( b6 G9 O/ P; J$ {  L: c
  173.   #--------------------------------------------------------------------------
    6 L* k& E$ q0 z7 X: W" e# B
  174.   # ● 鼠标指针精灵1 `! x3 Y) e  ?9 `
  175.   #--------------------------------------------------------------------------
    5 t6 G  [: v; U6 [) w* W* r* U! e, ]
  176. #~   def creat_mouse_sprite
    # s% C/ x+ u1 K0 H. l
  177. #~     " j) e: j& X3 P& j# H3 y
  178. #~       @mouse_sprite = Sprite.new
    5 o8 h; ~0 k1 V! I, k2 j0 G. i1 H
  179. #~       panda = 2#rand(2)+18 N, K3 L7 ]2 T) q8 \8 w

  180. . d7 a# Q! c' I1 v1 b5 Z# e* g% d4 v
  181. #~      if panda = 1
    - R: n8 V- D2 r
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    1 Y* }+ A; A$ i- ]  t4 l6 E, S
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')/ s( t+ {& A- P% j; C0 V
  184. #~        end#with if File.exist
    0 h$ x2 H# p* L9 n7 c  o
  185. #~    ! d; Z# M' `" }" S" p/ B
  186. #~     else if panda = 2 #with if panda=1) h/ |$ K- [  P. ^' O8 @3 Y
  187. #~      
    4 v& j# V8 K. S+ p
  188. #~      if File.exist('GraphicsSystemCursor2.png')+ e# y1 @3 b1 y- V4 M  @9 R/ s) C5 @
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    # N9 Z; J4 z' D/ U/ A
  190. #~      end#with if File.exist
    % u" ?, U  ^* e+ Q; h2 q
  191. #~      
    4 z- o' m# b. N7 t
  192. #~     else #with if panda=1- Q# q4 ~9 n  O' x
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    # O. A+ L1 A% i; {
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    2 B0 e3 M# r( e& k
  195. #~       Rect.new(5  24, 24  24, 24, 24))( x3 w3 k# v& R. c1 t6 P" P' J. l
  196. #~     end#with if panda=1
    , `0 {- |0 ?1 S" q) Q
  197. #~       e0 E  l- V: j" x. `
  198. #~     #with def
    / `* W' j& P" z! @5 K7 S3 L
  199. #~   end$ `  H& K# \. q0 K2 c
  200. def creat_mouse_sprite& t! `8 R" K8 n7 S. {: l
  201.     @mouse_sprite = Sprite.new# Q4 V/ l' `* V
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    " l, U, N, m1 i
  203.     @mouse_sprite.z = 9999
      y- b+ h9 Y1 M& Z( c/ R9 U, d
  204.     Show_Cursor.call(0)) B. m( S3 B! {! v4 [
  205. end5 l; q, o% r8 J3 z2 |

  206. # O8 }% b9 Q) T5 i4 J( Q
  207.   #--------------------------------------------------------------------------
    - V, r( I) \* B8 z7 ]
  208.   # ● 更新
    4 o9 L6 t" q4 m! w4 p
  209.   #--------------------------------------------------------------------------
    . @# Z; p! Y) ?
  210.   def update
    / I. Z( e( N0 ]4 S
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    ( F8 w  F5 @. b8 s8 n6 l
  212.     left_state  = Get_Key_State.call(0x01)
    + J# n2 q8 F/ i! C
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    , G; E3 i0 }. E# C+ Q4 w
  214.     right_state = Get_Key_State.call(0x02)2 |% l1 s+ Z/ X1 y: Q
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    6 }9 }! y% a. u- e2 C0 `
  216.     update_double_click
    5 R, F$ F: x/ h. H
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1$ o8 Y: Y+ z0 z2 K0 l0 w
  218.   end1 q. R) S; Z0 t) \# t0 r
  219.   #--------------------------------------------------------------------------
    * L  e5 X) B! p* I
  220.   # ● 获取鼠标坐标; F$ o' N0 s6 w6 I3 i7 _
  221.   #--------------------------------------------------------------------------4 K6 ?" d1 o4 ]/ G/ f: m* j" h5 s/ e7 G
  222.   def get_mouse_pos
    9 Y- _* z: {8 p( ^& k" l+ [3 p
  223.     arg = [0, 0].pack('ll')( |" A# a" K- t" |5 e& t
  224.     Get_Cursor_Pos.call(arg)
    . \1 `$ h( g8 |  K, ~# }7 p" b! S/ C
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    ! B; q8 p8 v6 V8 ]: D, @& N% ^  x
  226.     x, y = arg.unpack('ll')
    ; f& q( x/ S# n& @* F  P$ D
  227.     return x, y
    ; Y& P! R7 T4 }: z4 a7 y2 Y6 u
  228.   end
      t3 G/ K9 h/ S, E; o
  229.   #--------------------------------------------------------------------------
    # S# H+ J) q3 V. w8 B% I% s$ c
  230.   # ● 将鼠标固定在屏幕内6 z6 B1 j1 U0 r/ D
  231.   #--------------------------------------------------------------------------8 x% m7 k0 x- W$ Q* Y
  232.   def lock_mouse_in_screen' U3 f2 h. U' \# K% ?
  233.     arg = [0, 0].pack('ll')2 N8 e1 @. `! v5 T, `8 p- ]( T/ @
  234.     Screen_To_Client.call(Window_Hwnd, arg)" q( E& V% N# q
  235.     x, y  = arg.unpack('ll')
    & \5 x. f; ]' [. Y4 o. |
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))' U$ }7 x9 }, h, k( n) X8 i
  237.   end
    ) |  [* |% f6 f. l
  238.   #--------------------------------------------------------------------------
    $ q2 b$ @# `5 F% h  ]( M2 m
  239.   # ● 解除鼠标固定* s) D! s- K& i7 l1 w
  240.   #--------------------------------------------------------------------------
    9 T1 J: A) _) u2 V$ Z$ z1 l5 x
  241.   def unlock_mouse_in_screen% f" Y6 S+ z4 L2 [+ J. t
  242.     Clip_Cursor.call(0)6 r/ n) N" |; R& K; h* d0 _9 X
  243.   end& w- t" j  [4 A* U& z7 J* L
  244.   #--------------------------------------------------------------------------
    8 G* `2 D9 d* P% H$ f* ^6 u
  245.   # ● 鼠标双击判定( m4 `) r3 V$ L* S) T5 h, u
  246.   #--------------------------------------------------------------------------
    # D: H  [0 z5 Z% B- L8 a3 o( F. ?2 n8 d
  247.   def update_double_click
    8 m7 N0 H; H5 X9 T7 [- C% s
  248.     @clicked = true if @left_state == 1; L  K' g5 K4 q0 i' E
  249.     if @dk_count  0 && @left_state == 1
    6 }% Y4 g% n( {! S4 w$ K2 J
  250.       @dk_count = 0; @clicked = false8 ^) q( x' {. f' d  ~, q
  251.       return @double_click = true6 R5 B4 z. [- f- k
  252.     elsif @clicked3 J1 I1 k0 ]5 m7 A- U2 X; h
  253.       if @dk_count  KsOfSionDbclick_Frame
    # z% O; E- T& \3 N& |0 A
  254.         @dk_count += 1. X' v2 H. I& j! y
  255.       else; `# K6 s) ^, F* D! ~- N
  256.         @dk_count = 0; @clicked = false( n  v: N8 _0 c* U. H& Z0 W6 J
  257.       end
    ; C$ `- f& R- E, ^# _  j
  258.     end$ k/ Y5 q3 r; a+ E& `
  259.     @double_click = false) X0 y' g6 N/ w  ]
  260.   end
    % U8 i3 J& ]0 X
  261.   #--------------------------------------------------------------------------
    / M: o- {3 ]& P2 f
  262.   # ● 按键被按下就返回true
    % E3 `9 }% V: \1 _0 {
  263.   #--------------------------------------------------------------------------3 {9 C) E  R( l* F7 k! j
  264.   def press(button)
    ( L/ z7 I8 |. ?1 G, T  w, u
  265.     case button
    / T8 S: ^( s6 V# E2 D3 t' b3 }8 O
  266.       when 0x01; return !@left_state.zero* d/ y# ]% A$ X) }
  267.       when 0x02; return !@right_state.zero  b$ z" U2 `9 M9 s+ o$ }; e
  268.     end
    - G0 b4 ?+ S. v; m+ b
  269.     return false
    3 y) d6 s7 |& s
  270.   end
    % Z- L+ j4 ~$ h1 W
  271.   #--------------------------------------------------------------------------
    3 J+ W  D7 \( E: |8 @  Q
  272.   # ● 按键刚被按下则返回true
    + ?" z: K$ P1 y: [" p- s3 p
  273.   #--------------------------------------------------------------------------
    - a: B7 m5 F5 d; ]
  274.   def trigger(button)9 ~0 l# @$ l, g! H* b1 ]0 j( _
  275.     case button
    " \8 U$ h( \# C  I* C6 a! P2 u1 F
  276.       when 0x01; return @left_state == 12 u1 l# S" E# d/ [
  277.       when 0x02; return @right_state == 1( N+ }; J8 @  U( t: k/ ]5 {4 Q
  278.     end
    ' w6 ^) P. h2 V7 E+ J
  279.     return false4 {8 e9 _7 s. ]: [  u+ ^
  280.   end" K* m. \7 J9 z6 e
  281.   #--------------------------------------------------------------------------' n1 `( U# T/ K- w: X
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    7 N; w5 U; |  w  N# B* i! ?
  283.   #--------------------------------------------------------------------------
    ' D. C2 H1 }& b2 ~
  284.   def repeat(button)* r  O: h/ E( I. B- m% b
  285.     case button0 B/ \4 U( l( g( J. d* i
  286.       when 0x01; return @left_state == 1
    2 Z% f& g: P, w& g: G( k, j9 A3 K
  287.         (@left_state  22 && (@left_state % 6).zero)
    7 B! V2 [7 ~* ~. P0 W1 ^
  288.       when 0x02; return @right_state == 1
    / A% h* ^. U2 u
  289.         (@right_state  22 && (@right_state % 6).zero)
    ( D4 F6 @9 j2 M2 P1 D  v7 y+ G9 S' o
  290.     end4 J% U  y3 c2 @. c* F: a
  291.     return false+ S* |" S! B( N% `+ i% g* t
  292.   end! V! F& b( g2 g+ D- A" O: I7 B, |
  293.   #--------------------------------------------------------------------------) D. K- @  s" |) M( [
  294.   # ● 判断是否双击鼠标
    " Q. r# f# B* s6 N( v" _* j2 W
  295.   #--------------------------------------------------------------------------
    / U. g$ H3 L( q; {! ?
  296.   def double_click2 W  x+ |# I! t' p( r
  297.     @double_click+ u) |& z; Q8 ~9 J
  298.   end
    7 U  e2 X$ @) H4 }+ s
  299.   #--------------------------------------------------------------------------
    4 T6 z- p3 ^3 b; }/ J
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0), @. V4 H1 b& @
  301.   #--------------------------------------------------------------------------5 f2 q  L) ~. q3 h5 K
  302.   def click_count
    ; \! Y( Q6 W( R. N8 }% [, F6 {
  303.     @ck_count
    3 c% F- a! y/ e
  304.   end
    : z) {; H/ y4 g- H/ A" ?
  305.   #--------------------------------------------------------------------------
    ( Z' J' z; y" E6 ]/ Z& h( t/ o
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    # x; u) _% r  X5 G- F0 d
  307.   #--------------------------------------------------------------------------
    7 @; L9 k1 J- A6 W5 C
  308.   def left_state
    + _  ?0 o! i% K& ]; s, u
  309.     @left_state
    4 X5 N0 m9 M4 l* v0 S/ z
  310.   end& _0 e2 b" r' D5 e( S$ s, a
  311.   #--------------------------------------------------------------------------
    9 R' j/ w  z& `8 b% C3 Y
  312.   # ● 获取鼠标的x坐标9 D' C$ U# `& c" A; H+ l
  313.   #--------------------------------------------------------------------------* ]$ X! j' e- D- n' b
  314.   def mouse_x3 M* a  K/ G- N# v$ u+ H) W
  315.     @mouse_sprite.x
    ! s4 `+ F% K3 e, j9 z3 t5 n! j* P9 f- J
  316.   end1 j' M5 ]% b+ x$ R4 i; y" F
  317.   #--------------------------------------------------------------------------  i% j/ a% Y" X/ k; D
  318.   # ● 获取鼠标的y坐标
    8 I  B9 B) A' u# O+ ?2 D% ]
  319.   #--------------------------------------------------------------------------
    ; b( f: T' Q* B; T1 X2 a# v- R
  320.   def mouse_y
      h3 N& A7 D; }' J
  321.     @mouse_sprite.y
    & U6 E+ T/ Q" ?" s) L9 r
  322.   end
    $ v- v! F  H3 N, l, h) ?4 a6 ~
  323.   #--------------------------------------------------------------------------' E  j. U- D. X- F8 A
  324.   # ● 设置鼠标坐标
    $ L' B1 I4 f1 W/ K/ E" f0 u
  325.   #--------------------------------------------------------------------------
    ; r$ F  ^! i2 A5 L
  326.   def set_mouse_pos(new_x, new_y)" b& S. E+ a. h) R, ?; i0 e. R
  327.     arg = [0, 0].pack('ll')# `" c2 x# j, I; D$ B0 c0 z2 B$ c" d8 s3 t
  328.     Screen_To_Client.call(Window_Hwnd, arg)8 V" V* l9 x6 V9 E
  329.     x, y  = arg.unpack('ll')
    9 C, T! y; d: m+ o$ I: ?* D1 ~2 g
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)* J' x1 N! C5 V5 l8 k% a
  331.   end
    $ X) [/ J9 Y5 k# j, k# B3 e4 \
  332. end #end of class  self ) O# B, k: K9 a4 j' {" c
  333. 8 m$ L7 c" W, z2 |& x3 |* @
  334. end
    $ ], W0 F7 Z, }: f# J

  335. 7 l( e" B9 F; `4 z0 o1 r) C5 @
  336. #==============================================================================
    " e. n" B; l# _7 f0 U; q1 ~
  337. # ■ SceneManager
    , N! K+ c( V8 {: K% J* Z5 ?+ `) _
  338. #==============================================================================
    # T3 b9 K: E0 |! C. j
  339. class  SceneManager! m& ^. @' X$ E6 l4 u% `& k  D
  340.   #--------------------------------------------------------------------------
    & |4 f4 M8 j& \2 t3 d) U- L
  341.   # ● alias( `: g" a, a% U6 R' Y0 h! c; j
  342.   #--------------------------------------------------------------------------& h" q% a4 {2 E% x1 j) Q
  343.   unless self.method_defined(sion_mouse_run)# n8 q6 k  s, l2 m9 T
  344.     alias_method sion_mouse_run, run
    # X$ B, h' |. k; N/ W/ J$ l
  345.     alias_method sion_mouse_call, call& }& G; v4 w1 N2 m. g) K; c
  346.     alias_method sion_mouse_return, return# r) ^5 s$ a' z$ {/ p, n% x/ O
  347.   end
    ) s+ K( O8 d- V; k& y
  348.   #--------------------------------------------------------------------------
    0 @% i% B2 _* J# C/ W( u5 G; N. L1 u
  349.   # ● 运行1 y- z6 R( e0 ?; A2 C- Q
  350.   #--------------------------------------------------------------------------
    2 p, u' v- N" ?6 s& j3 {& T9 l
  351.   def run
    / g5 v5 u9 C% N& m, o
  352.     Mouse.init
    2 i$ ]& h' @+ O0 n. N) z
  353.     sion_mouse_run
    ; e. V( R0 q7 }3 Z8 g' u8 b4 x# D. z
  354.   end
    5 u' y- Q( R( p" {# z% J# o
  355.   #--------------------------------------------------------------------------3 D: s/ _7 m* E+ V/ Q
  356.   # ● 切换5 C' T; ~' i$ _: r4 C
  357.   #--------------------------------------------------------------------------. p) n5 C% c7 R7 q* g& H: \( H
  358.   def call(scene_class)
    - X; X) V0 H6 J; m4 M5 w9 J
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)) y! Y7 Q) \6 \% @0 V* G2 G! D+ L
  360.     sion_mouse_call(scene_class)! \: x+ }7 E2 N! ]
  361.   end
    * M% ]9 Z9 ~# C
  362.   #--------------------------------------------------------------------------; v+ ]+ s' q; @) S7 R1 d
  363.   # ● 返回到上一个场景) P4 N" }7 {" D$ h! q, G+ W! e
  364.   #--------------------------------------------------------------------------0 n; }% D1 J- S- N  l
  365.   def return  J! K# H7 f3 Q" t: B
  366.     sion_mouse_return- C6 a% \2 T! n7 {3 @: i* i
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&$ m2 S4 ^# L+ T& G% _$ m, M) Z
  368.       @scene.instance_of(Scene_Map)
    - x; O( \: y4 j
  369.   end
    0 }. {+ a( @/ u
  370. end
    , `4 q% _3 c7 D% W$ y" c" n5 L) C
  371. / _; k- [; k, ~: l' f" K, ?7 U
  372. #==============================================================================
    3 B0 b. `; C: }! I
  373. # ■ Module Input
    , h$ N/ U9 U- _, Y, [& f
  374. #==============================================================================' ^& W9 A; K/ ^! X$ R2 N: L
  375. class  Input& \: ?, ^, R* j/ O0 L4 t" q3 |& D* |
  376.   #--------------------------------------------------------------------------# P3 R6 {# Z' e* ?  u
  377.   # ● alias
    4 u! l' E- D) P8 E( W3 V
  378.   #--------------------------------------------------------------------------! I+ S" A' l6 a: H8 s0 u
  379.   unless self.method_defined(sion_mouse_update)8 Y8 i. a& K5 C3 y9 ]! Z
  380.     alias_method sion_mouse_update,   update
    2 H; G& H- n7 f8 t9 }
  381.     alias_method sion_mouse_press,   press2 n, h! F+ n8 N: s
  382.     alias_method sion_mouse_trigger, trigger; h4 u6 @/ H5 l" N3 M4 I- K; `
  383.     alias_method sion_mouse_repeat,  repeat
    , y3 q+ t2 z1 n9 ?/ Q) L
  384.   end
    1 Q( u) }5 `; ~. l
  385.   #--------------------------------------------------------------------------
    5 g% G3 U- J" n, G
  386.   # ● 更新鼠标- R; Y) H1 R  w: f! G
  387.   #--------------------------------------------------------------------------; |% k' `: `  F
  388.   def update8 q  D( l. F; p4 P! Y% \* v( t: S" T
  389.     Mouse.update( ]" |8 D& r- I5 C" {$ p9 d
  390.     sion_mouse_update
    2 B+ X4 c5 L5 Y. }. [3 a8 D
  391.   end
    . b; e! W! J7 t# G/ T# M
  392.   #--------------------------------------------------------------------------. N8 J9 ^* k: M5 s0 U
  393.   # ● 按键被按下就返回true. ]% C. R" [0 @, t
  394.   #--------------------------------------------------------------------------+ w$ Q) X4 ~4 q
  395.   def press(key)
    & b  L) a& [# b( }/ e9 \1 X6 O# n
  396.     return true if sion_mouse_press(key)4 i2 Q) E1 i" g# `
  397.     return Mouse.press(0x01) if key == C
    & ~$ g5 W! D$ g1 N% F' r$ s
  398.     return Mouse.press(0x02) if key == B; w% O6 h) ]3 M' W( K
  399.     return false( T0 C/ Z  F; y# Y0 u0 @
  400.   end; N+ `  N, {! g5 T
  401.   #--------------------------------------------------------------------------2 V& l1 x( ^0 E+ m/ ~) a7 S
  402.   # ● 按键刚被按下则返回true+ b9 K: z( G- j1 m, M4 P2 m
  403.   #--------------------------------------------------------------------------
    - L. `* T8 R9 M- z( Q. i
  404.   def trigger(key)
    3 z+ \) C" Y2 K7 a% V5 x1 \7 G; N
  405.     return true if sion_mouse_trigger(key)
    # o/ q/ I! H4 i+ Q9 T& P
  406.     return Mouse.trigger(0x01) if key == C! v: H- J8 y: T0 v. E4 G! B
  407.     return Mouse.trigger(0x02) if key == B% ^. x: \* c2 l
  408.     return false; X$ f# [* K. ~& O
  409.   end  o( M7 o- c  z' K/ z9 e! h
  410.   #--------------------------------------------------------------------------/ U* c$ C# R" Q$ C
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    $ [& T+ ?1 o1 G# |* y
  412.   #--------------------------------------------------------------------------6 E* Z( E3 M( F2 u3 B! w: \+ Y2 S
  413.   def repeat(key)# i1 x( R+ Q8 z6 I. j6 c
  414.     return true if sion_mouse_repeat(key)8 M, Y. R8 w  [6 [( w$ @
  415.     return Mouse.repeat(0x01) if key == C: o% ?, n/ Q3 M  N$ U
  416.     return Mouse.repeat(0x02) if key == B
    - y% d6 o' |; p$ o
  417.     return false+ Q8 T' F! z% g; m5 z
  418.   end4 T9 M  d+ P: u4 A' ?: E1 k- c* A
  419. end
      V/ o/ {# Y+ q  W! }8 F8 R# t

  420. - K' c; a! W8 i2 l
  421. 2 P$ L# f& |# G- M! ~4 P$ p* t+ `
  422. #==============================================================================, H0 R9 K3 R% Z
  423. # ■ Window_Selectable
    2 U" v! g% D7 J/ `
  424. #------------------------------------------------------------------------------
    + V' R/ o: O8 ]2 f5 M
  425. #  拥有光标移动、滚动功能的窗口
    4 p! K6 |9 m; ?% g6 i, z! K) F. v
  426. #==============================================================================
    # Q* p, ]3 x. k
  427. class Window_Selectable
    ( P& `2 q$ Q5 d3 S( e* a
  428.   #--------------------------------------------------------------------------5 y  [. f/ A/ s
  429.   # ● 初始化1 N5 _  U4 w! v! [, q
  430.   #--------------------------------------------------------------------------+ h0 l- b9 {" E* D7 r. j2 V) h
  431.   alias sion_mouse_initialize initialize
    7 D* L; T, v# z3 K2 o
  432.   def initialize(x, y, width, height)4 v7 U' W5 ], z$ l, R
  433.     sion_mouse_initialize(x, y, width, height)
    8 _4 I# @& S. ]# _. W6 O% W) S
  434.     @move_state = 0
    ' O& ]$ a/ s8 @: w8 @$ b
  435.   end
    ) x- v. u" \' h
  436.   #--------------------------------------------------------------------------
    $ o7 i  D* y7 x
  437.   # ● 更新
    : i9 q3 J9 R/ A1 ]" l( y7 J& n
  438.   #--------------------------------------------------------------------------
    , b# X' _; G3 I- I
  439.   alias sion_mouse_update update
    6 J% S% X# b8 D  i3 \1 g2 n
  440.   def update; b. F8 b' n9 I* L
  441.     sion_mouse_update" M; j5 \" d! M0 V: B2 J! G8 w( ?7 n
  442.     update_mouse_cursor  j7 d: R; @) c& o, U$ o
  443.   end1 L0 J6 \: q7 \  D4 C. a
  444.   #--------------------------------------------------------------------------
    / v6 A5 W5 C' U: B4 g. f
  445.   # ● 启动后设置鼠标到index位置/ D, ]5 d0 e0 N# B& q
  446.   #--------------------------------------------------------------------------
    9 T2 E( N  X% C
  447.   def activate0 `% Y5 \; t% \; M" R$ i
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos" b2 a4 x( k2 ?  W  }: t
  449.     super$ V' l$ R0 o2 l; K
  450.   end1 f' Z0 F0 w$ g/ F! p9 [& s- ~
  451.   #--------------------------------------------------------------------------
    6 z  H& ~: `* n% U
  452.   # ● 更新鼠标和光标的位置
    / L+ h0 A+ G3 [- h5 C
  453.   #--------------------------------------------------------------------------
    6 m9 C; |7 R, o- ^2 M( b
  454.   def update_mouse_cursor6 [; f3 [6 p8 ~, c, f  U7 M( L2 v
  455.     if active7 p& N& U: O0 h3 Y; n
  456.       if @need_set_pos1 B' a% _, ]" l3 g, Q! P' s
  457.         @need_set_pos = nil9 R8 g' z+ q" Z+ i7 P/ f, J
  458.         set_mouse_pos
    8 l; C) u$ i- A" W
  459.       elsif cursor_movable6 }! {% c: y% B0 C6 Y/ }, H
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    1 ]) i2 q6 ?5 x- A: G
  461.       end6 ~9 F) V  G' J9 m1 ^8 W  y
  462.     end2 }: \& p! n: W( @/ S
  463.   end! u6 I2 U( W6 b' `1 J8 i' i, |3 E
  464.   #--------------------------------------------------------------------------6 {3 w. l, o! E* m! F1 L/ X
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    6 M4 @! p! p: `9 x' M5 M/ l
  466.   #--------------------------------------------------------------------------
    9 t$ o( d7 F$ O! D2 @+ I! O* x6 W
  467.   def set_cursor; z7 G+ g+ m0 K9 R4 ?8 U' k
  468.     mouse_row, mouse_col = mouse_window_area
    5 r( j. C, u9 d7 s1 J) i" B4 i
  469.     if    mouse_row == -1$ _% h  G5 S! c7 t, N
  470.       @move_state += 1 if need_scroll
    9 ~8 r) o( ^( ]$ `+ X6 H; y$ ~' j
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ) _- [4 l  {5 ]! u: U0 `& |7 I; q
  472.     elsif mouse_row == -21 g9 q) p6 Q% D6 J
  473.       @move_state += 1 if need_scroll# X! p* P  l; A6 d0 Y# ~0 Q8 y
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand2 ?  L: ~9 S' y4 C
  475.     elsif mouse_col == -12 [; @/ J) @3 y- G8 [) A
  476.       @move_state += 1 if need_scroll2 B) T+ V- f7 o
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    1 ^5 Q' P; {' ]; r: z7 S: \1 H# I. G
  478.     elsif mouse_col == -2$ n* z1 }5 j9 m) }
  479.       @move_state += 1 if need_scroll
    ! z! \- n5 l  \% b
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand1 b+ K  t+ a- P$ Z3 s- J, h2 V
  481.     else% c6 O' T5 h& f) V5 s3 b- p
  482.       @move_state = 0* u+ o3 |& I. p& e' t. c
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    1 G+ x2 f, ^7 C1 G2 O2 Z8 s
  484.       select(new_index) if new_index  item_max && new_index != @index+ v6 {* S% h* a' m: n# ]* X
  485.     end& v$ Y7 B& v; I: }; a3 I5 \
  486.   end
    3 ^+ r: S1 q7 l2 y; A- @. o3 M# B: }
  487.   #--------------------------------------------------------------------------
    9 n" Q1 z1 Y! R4 v
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    " Y9 Y* N- Q( Q( D& T* _# M  L/ \% h
  489.   #--------------------------------------------------------------------------& V  c; \) @* M$ \( M  f
  490.   def mouse_window_area
    : B  Y0 X  H5 P/ O% u; }) c  e9 P6 k8 `* v
  491.     if viewport.nil # necessary!
    , C4 z1 e* o2 h1 U3 I
  492.       vp_x, vp_y = 0, 0
    * {' s$ k: ?3 R3 _' @; q% m! H* |
  493.     else2 V* y# g1 c; a$ C) k, e2 c: Y
  494.       vp_x = viewport.rect.x - viewport.ox
    . z* {. {2 L+ S4 a- G  R$ `
  495.       vp_y = viewport.rect.y - viewport.oy
    8 _; c' x" x6 [: ~
  496.     end' g% {+ D) z, W" u0 d3 D
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ; K+ P% O7 E& S( z9 U1 [
  498.     item_x1 = vp_x + x + standard_padding ! L0 P" n, N( w/ B
  499.     item_y1 = vp_y + y + standard_padding) _# O1 X* R5 [0 s
  500.     item_x2 = vp_x + x - standard_padding + width# l1 c+ ?3 t, h4 a1 x! @
  501.     item_y2 = vp_y + y - standard_padding + height
    # L4 q0 |1 }3 A" I
  502.     if mouse_x  item_x1
      ^: M, M& p/ ~, _
  503.       mouse_col = -1
    . z  ]- z7 z7 o% w: [3 |2 Q
  504.     elsif mouse_x  item_x2
    / W2 U0 I) F5 ^( ], P9 X
  505.       mouse_col = -2
    ' s: C+ p0 b* [0 ^! N+ D6 L: c- C
  506.     else
    - M( m+ O7 H$ {
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)- B$ M0 D% t3 L: I
  508.     end
    + S4 O5 n1 `5 i: _+ S5 B
  509.     if mouse_y  item_y19 X' U9 z& g6 }! ~) C
  510.       mouse_row = -1
    8 f- E( b! R) n) H( T' `. f: S) H
  511.     elsif mouse_y  item_y2/ e& d/ k0 j" j8 H
  512.       mouse_row = -2  E) J. G6 M5 d% |2 r
  513.     else
    / Y. h/ J& V1 r0 P/ t" {
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    6 D: q# X7 a5 h) D
  515.     end& f+ _& A/ F! A7 k' r) f
  516.     return mouse_row, mouse_col
    & ]6 b. {7 i5 `: r# U- B4 c+ i
  517.   end# U& W; N! b5 D# y' \) N
  518.   #--------------------------------------------------------------------------1 y& T- G' }7 d+ X$ F) x
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置! x/ b" o7 R/ V, `4 J$ X8 B+ h
  520.   #--------------------------------------------------------------------------! z6 ?& r2 F! H5 F; K- i* Q8 p  _5 z$ [
  521.   def set_mouse_pos
    3 \% Y9 s+ K' c
  522.     if viewport.nil # necessary!
    9 D1 [! b8 v, K0 ^1 `! o+ W" M
  523.       vp_x, vp_y = 0, 0
    0 K; a5 `5 X  S( a, |
  524.     else8 u( G: L" F/ ?1 i2 J7 ^
  525.       vp_x = viewport.rect.x - viewport.ox
    0 E& E3 |; \- O$ L7 u; m5 ^" a
  526.       vp_y = viewport.rect.y - viewport.oy2 H" x3 z8 B( ]$ R2 `  Q7 ]" |
  527.     end, Z* j# S; a7 u! }9 ]# ~- t
  528.     item_x1 = vp_x + x + standard_padding
    " X% u# U: b$ d5 D5 K4 P
  529.     item_y1 = vp_y + y + standard_padding
    & s8 Y& V, w0 d9 c6 j. H
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    : k. `6 s" [, A( D. J
  531.     row = get_index  col_max - top_row' Q/ `* D  [( F5 C; C
  532.     col = get_index % col_max
    ' u! O- @9 _( b
  533.     new_x = item_x1 + item_width  (col + 0.5); F$ Q3 a8 U3 p$ L
  534.     new_y = item_y1 + item_height  (row + 0.5)
    & U% O" ?% J. `( |4 V# a
  535.     Mouse.set_mouse_pos(new_x, new_y)
    4 _' Q  d0 n3 u# t1 A5 L' A' h
  536.   end  Y2 @+ W6 {) k, O0 Y; G" S$ U+ t  W
  537.   #--------------------------------------------------------------------------% q) K5 G- q& K" @3 [3 C
  538.   # ● 判断菜单是否需要卷动7 r! p; _; d6 Q; V+ o$ e
  539.   #--------------------------------------------------------------------------
    * s  t6 m* f! [. F. M+ v- \
  540.   def need_scroll/ C3 w$ ~3 O. L8 F3 L4 d
  541.     item_max  col_max  page_row_max2 c+ z% T; j% V: `$ Q9 z1 N( [- X7 c
  542.   end/ ]9 J3 @5 g- j
  543.   #--------------------------------------------------------------------------
    8 K% ]( S0 x8 `% l2 t
  544.   # ● 判断是否为水平卷动菜单0 ]3 B2 I7 r1 c' w! S
  545.   #--------------------------------------------------------------------------. r- ]. y7 P1 ^4 ^
  546.   def is_horzcommand" L2 H( A. f3 D3 e
  547.     return false
    7 j6 F1 f: v, O- a. Z( A9 W6 J$ _! ~
  548.   end& Q7 ?  q( h0 X& D: v
  549. end9 I" u* K- {+ d; v; Y

  550. 6 w, p# Y/ q2 M4 h, O$ d
  551. class Window_HorzCommand: r. p2 ]& [" S
  552.   #--------------------------------------------------------------------------
    ( Y5 K4 N/ |2 x
  553.   # ● 判断是否为水平卷动菜单
    : ^" V* Z$ ]1 |; `8 U
  554.   #--------------------------------------------------------------------------
    ; I( y0 v8 o, l! ?* G9 a2 }. B
  555.   def is_horzcommand
    9 l/ X4 b. Z* g( m
  556.     return true. `( g* s; A$ R0 ^! X
  557.   end
    " y" q4 Q' ~' s4 ]  F0 j
  558. end9 x; R, M! g: i. o% z
  559. ; z9 }: r1 \& Y$ v- s: {% [
  560. #==============================================================================: _" K. M$ Z# u
  561. # ■ Window_NameInput7 [3 g+ \& f' l! ]
  562. #------------------------------------------------------------------------------. m9 }/ e) E% y% B- Y. Z
  563. #  名字输入画面中,选择文字的窗口。
    & u9 E, n5 n' X, l/ t: G! e3 R
  564. #==============================================================================& a' h1 ~, c9 W  u
  565. class Window_NameInput
    3 n8 Q1 x3 w2 _7 S9 e
  566.   #--------------------------------------------------------------------------
    . t: a! e/ C" C- j4 a: F0 ~. D* s$ ~
  567.   # ● 设置列数" ]7 [2 A- `! ]4 r; Z
  568.   #--------------------------------------------------------------------------( u- |  u/ g5 J1 {
  569.   def col_max
    4 T4 V$ k$ F+ i
  570.     return 103 N5 ^: o0 y; P& ]6 H5 g- C+ m0 w" g- O
  571.   end
    ' j  h2 Y' ?/ W$ h6 z% c& K$ G* U
  572.   #--------------------------------------------------------------------------* Q' _7 _. e) }0 v0 ~' B
  573.   # ● 设置填充的Item个数* B; f5 M5 g7 T2 a
  574.   #--------------------------------------------------------------------------
    ; t7 J( D! g# H  ?" D% Y3 c
  575.   def item_max- @3 A8 D% V! f, M1 x* j: \
  576.     return 90
    5 h; D# N4 g- Z7 X( e8 p- m+ b1 z. D
  577.   end
    5 g# n* V: Q, ]. ]8 l  M
  578.   #--------------------------------------------------------------------------0 X0 Y. I& K8 B; x( E+ X6 o
  579.   # ● 设置填充的Item个数3 k! l1 P: Z7 i- i1 @6 u% d$ Y
  580.   #--------------------------------------------------------------------------
    ; q' _/ \: ], t# b9 a; x5 ]6 |% o
  581.   def item_width
    8 W+ H: W9 D. W$ ~4 ]- f
  582.     return 32) K7 J# |  b) y. d! \6 E, g' Y. p3 q
  583.   end/ K! y" f; ?( s* v$ n0 }
  584.   #--------------------------------------------------------------------------
      |0 N  c0 E" X
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    8 e, }  }! P% e6 y
  586.   #--------------------------------------------------------------------------
    6 i6 H* h- U; `' f) q
  587.   def mouse_window_area9 C" {2 x6 F7 e5 E' F! D9 a
  588.     if viewport.nil
    $ V3 P& c$ B6 B( r( B9 O+ I
  589.       vp_x, vp_y = 0, 0
    5 J/ O* a/ Y" K2 T' c( d$ Q
  590.     else
    & s- [0 Z% K4 O% `0 @1 y) t( r1 ^8 Q
  591.       vp_x = viewport.rect.x - viewport.ox) J" Z* s, C( [' n, U
  592.       vp_y = viewport.rect.y - viewport.oy
    3 m1 ~1 _  h' ^2 k) |
  593.     end2 ^8 K5 |( _# ~' K. B" o
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    / L# }7 l# [8 y4 |) R3 ]
  595.     item_x1 = vp_x + x + standard_padding * {. a  \% k* ~* }
  596.     item_y1 = vp_y + y + standard_padding
    + y* x" y6 r% ^  r; m
  597.     item_x2 = vp_x + x - standard_padding + width
    & ?( j+ ]% u5 B; _$ ?2 n9 V
  598.     item_y2 = vp_y + y - standard_padding + height  Z; R% O9 @2 W6 _; k, |$ C
  599.     if mouse_x  item_x1! @0 c* Y+ Q4 K" \3 @6 V4 _" z
  600.       mouse_col = -11 z9 e6 A9 P1 T* P: @
  601.     elsif mouse_x  item_x2
    ! u# \) m: c, h
  602.       mouse_col = -23 H- Y. R" F) u# U0 ]' z
  603.     elsif mouse_x  item_x1 + 160
    ( s/ G+ J! t$ t9 I2 A7 F, `
  604.       mouse_col = (mouse_x - item_x1)32; w. M* t& h1 C" A2 I; ]( t" i, u7 s
  605.     elsif mouse_x  item_x2 - 160# D& A+ ]! m) [
  606.       mouse_col = 9 - (item_x2 - mouse_x)329 b% D, j* g* x" \( f" w4 F# v
  607.     else
    ) R& d& m% _  Y% _% v
  608.       mouse_col = mouse_x  x + width2  5  4$ J, A9 D- {& M9 Z
  609.     end. u& X2 ]* ?- K7 r% F
  610.     if mouse_y  item_y1. u* h' J: w2 @4 u+ ?- t6 d# V3 L3 ?
  611.       mouse_row = -1" L' V" z3 n- [7 x& j! p! w
  612.     elsif mouse_y  item_y2
    . c; F6 {+ C3 h9 v+ t1 I
  613.       mouse_row = -2
    5 r3 B- B* K# C* A2 f' b
  614.     else2 \4 o; r6 i0 n
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    9 d! E  q) N$ b" k' o
  616.     end
    5 ^! M) }3 I: r- _7 z3 q0 X
  617.     return mouse_row, mouse_col
    8 g/ J& W; `5 J
  618.   end9 [( U2 n/ J# s3 p5 q9 ~1 E& e
  619.   #--------------------------------------------------------------------------# A( B/ l' e# J, e7 m) I% R
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置. @# h* ^  S' d+ r0 `) Y
  621.   #--------------------------------------------------------------------------. Q4 w: p: F7 C2 ~) X2 d
  622.   def set_mouse_pos
    ( Y5 P" E8 g1 w, G' m; h6 M
  623.     if viewport.nil # necessary!' T! l7 Y6 B) X4 }
  624.       vp_x, vp_y = 0, 05 r& R/ ]2 p; e0 c. t
  625.     else( E1 W' D' E3 x( c# \% V
  626.       vp_x = viewport.rect.x - viewport.ox4 ~" S% Y: B' Q9 c/ e
  627.       vp_y = viewport.rect.y - viewport.oy, ^# e+ v; ~& ~0 t4 _
  628.     end
    2 @4 p/ a9 m) _: Q
  629.     item_x1 = vp_x + x + standard_padding * F! a1 Z2 q! r
  630.     item_y1 = vp_y + y + standard_padding7 p0 Q& D+ D5 d
  631.     get_index = @index  0  0  @index
    7 O9 }0 Q1 Q  ^% X
  632.     row = get_index  col_max - top_row
      n$ v: A4 v8 l8 q; w
  633.     col = get_index % col_max
    " U* L$ W/ l& |1 j
  634.     new_x = item_x1 + item_width  (col + 0.5)% Z6 ^  b/ @* ]7 Q1 w# j9 o
  635.     new_y = item_y1 + item_height  (row + 0.5)
    / X8 B% l& {3 {4 M1 J. i
  636.     new_x += 14 if col  4
    & R& y# v( r. `% }$ c% ^, F- F( Z
  637.     Mouse.set_mouse_pos(new_x, new_y)* J6 r4 z/ O7 z' S$ s2 s( h, m& ^
  638.   end
    % A; G8 u( D  k, j+ }3 j1 W% y
  639. end3 Z. m% {/ a; G; W! q$ I9 i

  640. & P! V6 k, T+ I1 |& O6 S5 y
  641. #==============================================================================
    8 ~1 |7 m2 X, v  I+ R( f; ?
  642. # ■ Window_NumberInput
    3 F: ]2 W& f/ M/ k
  643. #------------------------------------------------------------------------------
    2 f9 I1 U, b# h0 ?% X6 y+ w; k
  644. #  重写了数值输入的方法以适应鼠标2 S$ _2 A/ `! D" }5 e( _$ P3 r
  645. #==============================================================================
    0 n4 t1 f8 w0 G3 O0 y4 \# w. {
  646. class Window_NumberInput  Window_Base' j1 p) }/ z9 [( n
  647.   #--------------------------------------------------------------------------
    & b$ ?; h1 S& L7 H5 T
  648.   # ● 定义实例变量' ~0 v* T1 ]1 v. u' ]6 n( J6 B
  649.   #--------------------------------------------------------------------------
    ! {; F9 W' ?* u* k
  650.   attr_reader extra_window5 N, A$ S9 N( x% D& L! p6 t
  651.   #--------------------------------------------------------------------------
    7 ?% b$ e! J( w( H4 T% m, D
  652.   # ● 初始化+ s, S. @8 Q8 \: B; d/ R: i# g
  653.   #--------------------------------------------------------------------------3 d" j4 {6 f8 H2 w! d. t- E3 |- H
  654.   alias sion_mouse_initialize initialize4 L& M# i: v. W" w9 c8 u
  655.   def initialize(arg)
    % L* @' S/ f) g( _5 j9 {4 @
  656.     sion_mouse_initialize(arg)
    / k8 h2 n+ o: ?: J# a& R
  657.     create_extra_window0 h7 N4 \- i! d  C3 l6 x4 r
  658.   end3 O9 w! \( B4 Y& N( b6 m
  659.   #--------------------------------------------------------------------------
    ' G' r/ Y2 p( ^; I3 Q
  660.   # ● 启动& ]( k8 R% F( C
  661.   #--------------------------------------------------------------------------
    ; Y5 ~# ~* d6 }& c% l
  662.   alias sion_mouse_start start
    ; Z2 L7 Z, U1 i4 o; e
  663.   def start
    1 y5 a7 x5 T- p' f* Q9 c
  664.     sion_mouse_start
    9 {( z- Y( X. g& ]+ v/ j  N  L
  665.     deactivate( ^" m& X/ o% k8 g
  666.     extra_start
    2 W4 @9 |) ?4 O! O3 n9 m
  667.   end
    ' c: e2 A, r: D/ a' y" t
  668.   #--------------------------------------------------------------------------
    0 e8 a5 Q% f) {6 {( j
  669.   # ● 创建新的数值输入窗口
    3 l4 o, O& c' E  G( ?( I
  670.   #--------------------------------------------------------------------------
    : T! K6 K, d2 w0 e0 j  j( Y3 q
  671.   def create_extra_window
    " H) Q7 @. @! \& r& U; Y! ^+ D3 Y
  672.     @extra_window = Window_NumberInput_Ex.new8 r# A+ a2 j) \4 E3 L) D% Q$ j
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    $ n- o4 I5 ]8 f6 H: R: ?- Y% ]
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    8 |) T  b2 G+ l0 z* I
  675.     @extra_window.index_proc   = Proc.new {n @index = n }, x* p/ m, M) b; `3 J4 @- Z
  676.     @extra_window.close_proc   = Proc.new { close }. s5 {2 P9 ?: d/ }5 f
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    ! n& W2 ~; c  ]
  678.   end  q! R5 w4 {3 P- M; t% C, |
  679.   #--------------------------------------------------------------------------
    : c8 o  H9 u- S3 L0 A7 A
  680.   # ● 激活新窗口
    $ e5 C% T2 e/ p" H; k3 b  g" \( q
  681.   #--------------------------------------------------------------------------2 \8 Z, Z- W" f  u" D
  682.   def extra_start
    $ O* ~2 b# n# F7 ]) Q
  683.     case $game_message.position
    5 }5 g  B$ h. y1 g" P+ C4 Y
  684.       when 0; @extra_window.y = y + height + 4
    ) \) G8 M) J% D4 R
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    ; h  g# c1 e# ^
  686.       when 2; @extra_window.y = y - @extra_window.height - 48 d9 `& |; {# O: G
  687.       else  ; @extra_window.y = 8
    6 c5 s9 f& e1 w) c$ r
  688.     end
    0 Z/ t7 v" l; }9 q: w; V% v: W0 v
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    2 C; d) p' E3 q  N2 m- x
  690.     @extra_window.digits_max  = @digits_max
    4 |6 O  K+ p! k7 A+ S) P
  691.     @extra_window.number      = @number% T. {2 z% |' v
  692.     @extra_window.open+ M6 d- M3 r) L$ l2 X
  693.     @extra_window.activate
    # [2 y1 L; o7 K4 C( b! _4 S" D; G. I
  694.   end, s! M. p" d" d
  695.   #--------------------------------------------------------------------------* S# @. W) @6 G# a/ }& z
  696.   # ● 更新/ [: t7 v8 J! y* u: ^: G3 m# t
  697.   #--------------------------------------------------------------------------
    : D" N0 x0 g" a) C5 a
  698.   def update0 f$ r" G) w  |. J
  699.     super1 P) o6 ^8 x9 K; H
  700.     @extra_window.update
    # `$ Y5 g: i, Y6 x8 P+ f
  701.     update_cursor+ v0 v8 b0 E. O
  702.   end
    ( f2 V4 l1 h$ }
  703.   #--------------------------------------------------------------------------# d8 Y8 ^' {  \" M  z
  704.   # ● 关闭窗口
    0 d# T, A( x0 e7 F- S
  705.   #--------------------------------------------------------------------------
    2 d5 j5 V2 ?/ L
  706.   def close5 W0 i7 Q  ?5 p+ y/ T- ]
  707.     super
    ) S8 y  g( o  h5 y+ H% g' U
  708.     @extra_window.close6 [* E, t( o; D8 w4 ~! q7 B
  709.     @extra_window.deactivate9 Z* L8 ~1 @, c0 N
  710.   end- E+ G: c0 z, W
  711. end
    ( r# j9 H/ r& z; [' ?, n- V. E8 F

  712. : x  B. o. o# [- \& Y( u
  713. #==============================================================================
    , d3 x6 e' x% u7 I( J* n
  714. # ■ Window_NumberInput_Ex
    ) S; O/ q& ?% Z5 @2 N4 R$ ^3 z
  715. #------------------------------------------------------------------------------7 c) B; }, _* E9 m
  716. #  新的数值输入窗口(NewClass)) ^; {: f4 \+ f, ^
  717. #==============================================================================
    6 {  x5 S  k1 e: m* [
  718. class Window_NumberInput_Ex  Window_Selectable
    6 C7 |( S4 u/ p  @1 d
  719.   #--------------------------------------------------------------------------  v) k; a, s7 O" ~- ]9 v: X$ p3 N
  720.   # ● 定义实例变量9 |4 r0 Y0 m6 c- |/ ]' J
  721.   #--------------------------------------------------------------------------
    ( I7 h& J8 ~2 p
  722.   attr_accessor number_proc
    " G. ~% U* C0 t- Z! M* e7 u/ P
  723.   attr_accessor index_proc4 x  s7 E1 h: K% g3 \# s- R
  724.   attr_accessor close_proc
    . d; A9 x, N5 M4 ^9 c
  725.   attr_accessor refresh_proc
    , K  ^3 P* P% P- L
  726.   attr_accessor number& l; |, O) L3 }( V
  727.   attr_accessor digits_max
    - k6 p# |) O9 Y) G
  728.   attr_accessor variable_id# N- k" y+ ?7 y6 `& x: Y2 J
  729.   #--------------------------------------------------------------------------
    9 s4 i/ r1 G5 {9 g' R" X
  730.   # ● 数字表
    ( P! {# m5 h* `# [$ o
  731.   #--------------------------------------------------------------------------
    5 A/ j6 v, y! S9 i% {  A
  732.   TABLE = [  7,  8,  9,7 e$ u. H- b) x! d. y/ Y
  733.              4,  5,  6,4 J" y; ~% g, [* h1 N
  734.              1,  2,  3,
    2 r# e2 E1 U& u9 w
  735.             '←',0,'确定',]; P& X( r; r* h4 ~( I4 M
  736.   #--------------------------------------------------------------------------  W5 y; b2 o$ q  ~  b" ?" \8 i
  737.   # ● 初始化对象
    . p+ j  G; V3 J5 @6 r9 Q
  738.   #--------------------------------------------------------------------------4 G1 r& D- @( [$ J; a
  739.   def initialize" l5 j( C% N5 w9 ]: Q5 C! O
  740.     super(0, 0, 120, fitting_height(4))
    ; K9 Z$ G0 S' P* b8 @9 K
  741.     self.openness = 0
    . w/ ]3 F# W2 A. B2 v
  742.     @index = 0
    + g# O0 L4 E3 B+ ^% A
  743.     @number = 0
    4 p& M+ J* t$ k+ T& j( @4 o8 V
  744.     @old_window_index = 07 K* E0 x% c; g% V4 g# K- c$ e
  745.     @digits_max = 0: I/ _  ?: K8 l! x
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    " P  N9 \& O% b0 ?7 N" `+ Y1 o
  747.   end8 I# O) s  I7 m5 g# `7 c* y
  748.   #--------------------------------------------------------------------------! Z+ {! ]; l, z1 P8 p; B
  749.   # ● 获取项目的绘制矩形
    ( h9 s& U  b- c0 k7 I3 n; \& K' g8 ~
  750.   #--------------------------------------------------------------------------9 d! {) r( w8 o8 Q. u% q; {  s
  751.   def item_rect(index)8 m7 a  l5 _9 J
  752.     rect = Rect.new9 P! t  W4 d" j# @* g5 x
  753.     rect.x = index % 3  329 O; o; v0 n2 b8 u& ?, l
  754.     rect.y = index  3  line_height9 T9 p9 I6 v# o7 a$ O4 ~9 h
  755.     rect.width = 32
    , n0 ~5 _: i, ]0 D' I, U/ p
  756.     rect.height = line_height% a* g1 L! p: c1 a2 h  }' v
  757.     return rect
    - J$ o' s- C. h
  758.   end$ B1 Q) Z: C1 w1 ]3 H+ Q
  759.   #--------------------------------------------------------------------------9 j  P0 C3 W) G* R/ V5 E7 s
  760.   # ● 将光标设置到鼠标所在的位置) ]& b8 ^3 h& }6 e: `( w& l3 v" U$ G
  761.   #--------------------------------------------------------------------------
    2 F) a; v. {, k! B* Q
  762.   def set_cursor, k5 E8 F. j/ C) n' m
  763.     mouse_row, mouse_col = mouse_window_area8 Q- L# S( @5 {
  764.     if mouse_row = 0 && mouse_col = 0
    8 z4 \# B- r' B7 e
  765.       new_index = mouse_row  3 + mouse_col4 n6 [' a/ t$ p( A* z7 u# f
  766.       select(new_index) if new_index = 112 K: a3 m" u; u% v! S* N
  767.     end
    5 y+ I  d7 m1 X' E
  768.   end8 c2 E& N& F7 s# l9 G% n
  769.   #--------------------------------------------------------------------------
    7 o% Z$ E; U( A' c' }' w( n( p4 ~
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列4 z! V# a6 A- w7 v  `- }, f
  771.   #--------------------------------------------------------------------------
    5 _7 d% [- G5 j  P: n
  772.   def mouse_window_area. S9 y! v) K- T  @
  773.     if viewport.nil
    / I. q4 v8 c" \3 _# `/ S3 D
  774.       vp_x, vp_y = 0, 0
    8 E0 z- A; @  K4 E2 I1 ]/ G
  775.     else# W% w* C) p/ O" T
  776.       vp_x = viewport.rect.x - viewport.ox
    * `$ A/ Z# D2 L" R6 H
  777.       vp_y = viewport.rect.y - viewport.oy
    : W7 V+ r$ @8 |5 J8 z
  778.     end
    - S. e" z; O2 w3 V2 B
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y2 @8 d) Y$ L5 }3 l; ]
  780.     item_x1 = vp_x + x + standard_padding
    . o# I- Q8 M8 _1 s' D( u' J# m
  781.     item_y1 = vp_y + y + standard_padding
    4 {6 g% H, W0 Z3 P" T9 P
  782.     item_x2 = vp_x + x - standard_padding + width
    ' E/ `# t4 Z" G
  783.     item_y2 = vp_y + y - standard_padding + height
    % r! p9 A+ ?3 _. a' m. x
  784.     if mouse_x  item_x1
    3 s; a2 d- ~, w3 |6 {
  785.       mouse_col = -11 P6 M6 h8 v8 t% b! s5 w
  786.     elsif mouse_x  item_x2
    4 T2 M) T/ Y- P7 r+ z% l+ d
  787.       mouse_col = -2
    8 e+ F4 D! L! d# H( q8 ~8 W
  788.     else
    2 n; z. M0 V+ O* Q! W! s% T2 |
  789.       mouse_col = (mouse_x - item_x1)  32# @9 ?9 |" G1 Q9 ^
  790.     end) o$ E" [5 q/ T( [% B( A
  791.     if mouse_y  item_y1
    % e5 g8 P: a& F7 I' `! O% x
  792.       mouse_row = -1
    7 `  L5 Q1 d* G' [. j
  793.     elsif mouse_y  item_y2& K  {9 m! [$ m/ Y8 V
  794.       mouse_row = -2
    - i2 ]# }4 E) C
  795.     else8 u9 g8 T4 k& ?; ^
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)5 @1 X* S; K8 ~' j- X
  797.     end
    ) [! p0 U( `& N& a) q/ z
  798.     return mouse_row, mouse_col
    9 w* W' k0 t- _1 C
  799.   end
    7 t7 U5 C- E/ T- {& M$ n
  800.   #--------------------------------------------------------------------------
    2 Z5 e5 i" M; @- ~/ `' `  W9 U# O
  801.   # ● 获取文字& P# m5 F8 m  N$ B& L1 n( ^1 y7 a, ^2 ?
  802.   #--------------------------------------------------------------------------
    ) f4 l! {2 X4 b, i& e3 t
  803.   def get_number$ [0 }! W7 X& ]: N  o- n
  804.     return false if @index == 9  @index == 11. i& R1 m) Z1 d6 d6 v  l: _) D; i6 q
  805.     return TABLE[@index]
    ! o* }7 u$ G* {7 f6 A9 V
  806.   end
    " K4 k. Q) q+ ]- Q! t6 a! h
  807.   #--------------------------------------------------------------------------/ x/ D) ?, r1 o! @' X( X
  808.   # ● 判定光标位置是否在“退格”上
    / p  Q% P  S5 h" p1 M
  809.   #--------------------------------------------------------------------------; I( m: Z' b7 W) |5 T, j
  810.   def is_delete
    , r; X+ D- s' Y" g2 h1 `
  811.     @index == 9: c' O: O+ b0 Y/ H, T
  812.   end- ~* P7 g9 S4 i& x
  813.   #--------------------------------------------------------------------------6 A2 T8 S  f5 a% ^: @' ]0 @/ Z
  814.   # ● 判定光标位置是否在“确定”上
    / `! j- j' X! p1 I
  815.   #--------------------------------------------------------------------------
    # X8 P0 ^3 c  I
  816.   def is_ok% r$ ?# c/ ?/ S+ W1 _5 h4 x+ u* {
  817.     @index == 116 o3 y7 [- c- M2 \! ]" x
  818.   end
    4 h! o* ^$ e; f6 ^; Z
  819.   #--------------------------------------------------------------------------' }" ]+ G6 S4 G3 h
  820.   # ● 更新光标7 i* a# h4 b* q
  821.   #--------------------------------------------------------------------------+ Y1 p- H: O+ X0 d
  822.   def update_cursor0 h8 X1 d4 {7 d5 v; r. Q. V
  823.     cursor_rect.set(item_rect(@index))  h$ y& u7 M, j; J" F5 h6 G* s
  824.   end
    ' K( B/ ]( r+ V9 d5 R* N' U
  825.   #--------------------------------------------------------------------------
    ' h3 u8 Y. @2 F0 u6 ]9 ~5 Q
  826.   # ● 判定光标是否可以移动
    0 z9 D2 J: M# h$ O2 f% ?
  827.   #--------------------------------------------------------------------------( V! T8 P, L* _  w
  828.   def cursor_movable6 |: U! u" \4 r& c( u5 ^3 u. {
  829.     active
    ; {+ J$ R2 \4 c" \0 V6 J4 y
  830.   end. p* u" i' M" P& `+ V  f; _. F
  831.   #--------------------------------------------------------------------------3 {( S7 T$ ?! o$ h1 |
  832.   # ● 光标向下移动  U' R4 u: N; A# u/ J: {
  833.   #     wrap  允许循环- W# Q8 k  I" c0 I( n
  834.   #--------------------------------------------------------------------------
    5 @. I7 a- S+ l
  835.   def cursor_down(wrap)) c4 l% i6 q5 [& i
  836.     if @index  9 or wrap
    # w. l6 z; X$ n& u: X2 h
  837.       @index = (index + 3) % 12) ]' q3 M9 {, T( U" f
  838.     end) O% k+ [6 L& u: R5 f. P1 ?; w' v9 z0 e
  839.   end5 A# O8 d: m& [. O$ S! K
  840.   #--------------------------------------------------------------------------
    " Q- A: _9 l6 g8 E, z1 ~9 L
  841.   # ● 光标向上移动* X# C0 ], o5 f
  842.   #     wrap  允许循环! X9 e- z9 ?! q
  843.   #--------------------------------------------------------------------------$ d; S7 `* i$ k0 F
  844.   def cursor_up(wrap)
    . h' _  C+ m& H
  845.     if @index = 3 or wrap0 o3 |+ R; Y9 ]' V# b* \. d
  846.       @index = (index + 9) % 127 B; d$ v% I# C) s2 a* B
  847.     end
    / s+ R6 A$ L; Q# E
  848.   end
    8 r! I! e) n, H5 F
  849.   #--------------------------------------------------------------------------
    # k- \2 x" P" b6 |+ U
  850.   # ● 光标向右移动
    ; k( b+ p- y7 ?* `: ~4 {, h% Q7 ^
  851.   #     wrap  允许循环
    5 p; R. G& k( A; H& u1 Q) L
  852.   #--------------------------------------------------------------------------
    , y$ _! t3 r, P& s6 ^3 G
  853.   def cursor_right(wrap)
    . V# G4 F! ]0 N/ I. s( F
  854.     if @index % 3  29 n- N3 w; _9 l3 o% n
  855.       @index += 1
    & z0 A. q1 k2 K
  856.     elsif wrap0 a! i. K# s* _8 b1 |2 }
  857.       @index -= 2) d' |6 X4 a7 o4 F1 V7 s- d$ I
  858.     end1 f: S% z' A  X; C; ?
  859.   end
    ( O( Z" N! F+ L+ C( n6 V% `; s
  860.   #--------------------------------------------------------------------------
    , P4 p) }6 T9 c- U( w
  861.   # ● 光标向左移动
    8 k2 g" L! x0 `& T# S0 ^6 o
  862.   #     wrap  允许循环' H' y! f: n1 D7 a2 n8 z# l: E; P5 p
  863.   #--------------------------------------------------------------------------3 ]  @- B* f0 E6 s0 [; M7 e
  864.   def cursor_left(wrap)
    1 o# [4 i7 v$ m  j. w! A4 L! S0 T
  865.     if @index % 3  01 F. u% E8 |3 }/ E
  866.       @index -= 13 T/ R6 Y% U. q0 E
  867.     elsif wrap" B7 k& k; H2 A/ B( F# S
  868.       @index += 2: T6 K0 A6 R1 A% @4 r$ w2 {3 P7 N
  869.     end
    " w& K4 n) ^! b! j" F* [
  870.   end
    0 f6 c5 t: \' X( w& j. E6 ~
  871.   #--------------------------------------------------------------------------3 q. X. t5 D8 s' ~7 Z
  872.   # ● 处理光标的移动! m7 J! h) f4 n1 g( y- Z9 Q, V
  873.   #--------------------------------------------------------------------------
    ' `* W* A9 X4 S" C4 x' A- \; T
  874.   def process_cursor_move( }. K) H. o8 `. o7 _+ `- X
  875.     super; M  \# D& n3 A5 _; ]7 m: x% Y& N
  876.     update_cursor
    - Z9 {  A3 e) \7 n( }# u
  877.   end, K/ g0 p. p" z2 ?7 Y
  878.   #--------------------------------------------------------------------------
    7 j) e" a" s" Q4 ]! j/ n
  879.   # ● “确定”、“删除字符”和“取消输入”的处理( p9 B) O5 j2 t! l0 t; k
  880.   #--------------------------------------------------------------------------
    # A% z5 y; n" L2 [
  881.   def process_handling
    . g3 h- L8 l  u3 }+ J
  882.     return unless open && active* I$ B; _; b  T) }4 C! K6 P, ?
  883.     process_jump if Input.trigger(A)
    8 i2 E1 C9 [3 C, u, p- _$ T/ Y
  884.     process_back if Input.repeat(B)
    ! q' R/ k: A1 P& [. k
  885.     process_ok   if Input.trigger(C)
    9 H2 U5 u+ K/ q0 F$ q
  886.   end
    2 Z9 \! M- l1 A- p8 Z: A
  887.   #--------------------------------------------------------------------------
    , p4 W7 P6 `* T: H
  888.   # ● 跳转“确定”
    % |) _* j' ^, e+ H, G
  889.   #--------------------------------------------------------------------------
      c2 G2 X) m! r! f
  890.   def process_jump
    , t4 U/ G! |3 E- V! X
  891.     if @index != 11
    & Y' H" A( [  j
  892.       @index = 11
    ; l2 `0 B5 _0 W. _
  893.       Sound.play_cursor3 z1 |6 Q2 C: @6 H
  894.     end
    * _* x, s1 f+ f, E4 U
  895.   end8 V0 \- P3 ?3 u% J2 L$ `. N
  896.   #--------------------------------------------------------------------------
    # ~& @; x) o# N0 M+ [2 D9 `+ {
  897.   # ● 后退一个字符
    ( L) d: O) G) g0 Y
  898.   #--------------------------------------------------------------------------
    ' }- p0 {2 W1 F) m8 J7 I" d. L
  899.   def process_back& o. L3 R& T) L" R% R
  900.     Sound.play_cancel3 c6 u' D! g, M1 ]
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    " N6 `5 x0 F7 G! D6 ?  L: P
  902.     n = (@number  place) % 10
    - A- J" r' D# \3 N
  903.     @number -= n  place
    7 c/ y" V; }  Z" u
  904.     @number_proc.call(@number)
    9 h- i3 a- A* K* T! ~
  905.     @old_window_index -= 1 if @old_window_index  0
    * _2 l9 t  f9 ?
  906.     @index_proc.call(@old_window_index)
    $ a& I4 A# [/ ?) q, G. c: Q/ \, [
  907.     @refresh_proc.call8 \( T3 p% \0 o/ p% K+ S9 |7 ?
  908.   end
      `9 g( H4 ]/ l5 t- L% A5 u" c
  909.   #--------------------------------------------------------------------------# l8 h' W! S8 U$ S/ i: |
  910.   # ● 按下确定键时的处理, `6 N+ ?3 O/ y. \
  911.   #--------------------------------------------------------------------------
    7 {) f# Z$ x4 J7 ~% s5 a, e* R. V
  912.   def process_ok
    ' J# x) u7 i' s
  913.     if get_number
    % S" T' _4 z/ ?$ ?
  914.       Sound.play_cursor. X/ O  S: \' F2 E6 u2 b) L
  915.       place = 10  (@digits_max - 1 - @old_window_index)+ \+ `" ~5 ^; D5 t  F* @5 [; Z
  916.       n = get_number - (@number  place) % 109 b! ^& v2 ]5 z3 v9 \. Y9 ~
  917.       @number += n  place
    0 B  h4 R- U' |: Y. x
  918.       @number_proc.call(@number), P) T& E, @1 g3 a, m' u
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1& e! H4 y% s  [, {$ l  G4 M. G$ e
  920.       @index_proc.call(@old_window_index)
    7 ^& i* F) n! _; w  I
  921.       @refresh_proc.call
    0 N0 d# A; z4 ^7 @$ a* M& J4 P3 r
  922.     elsif is_delete
    * g( {5 t3 {& i5 h
  923.       process_back
    5 u1 ^! i  K) `& s/ O) S8 Y. Y& ~
  924.     elsif is_ok, t' v$ e) M( |8 h" O: [4 l
  925.       on_input_ok# I6 F& P; c' s- s  W. y
  926.     end
    : n: \8 h. Q5 F- h7 y6 c
  927.   end2 M8 ?9 R! b9 M. C
  928.   #--------------------------------------------------------------------------
    % d& q& u  ?: B
  929.   # ● 确定( t3 t0 X0 M1 `/ g6 v$ J
  930.   #--------------------------------------------------------------------------
      [8 X- i* }" R6 j- n6 h8 l
  931.   def on_input_ok4 [1 y: D* c3 {+ l) H3 [  o
  932.     @index = 04 }, G# w" L3 W6 g4 k1 ?
  933.     @old_window_index = 0* ^: J3 h* j" \) D& U4 z
  934.     $game_variables[@variable_id] = @number
    . M! X& T8 O, o5 S2 W
  935.     Sound.play_ok8 t* p3 V2 E% N
  936.     @close_proc.call
    * |, Z) U4 q! [! S' O
  937.   end0 A) i, f( K( ]+ r8 O. b
  938.   #--------------------------------------------------------------------------: b4 z5 _" `- m: F* y  T1 w, W
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    - e+ y/ _3 @- @
  940.   #--------------------------------------------------------------------------0 f5 p3 I; u1 s' B5 _* v4 ?
  941.   def set_mouse_pos" a3 a% S- Z% |
  942.     if viewport.nil # necessary!
    # k- e) e/ U2 d! r6 w, k0 \
  943.       vp_x, vp_y = 0, 0- g4 f2 @1 J$ E2 l. {9 M# i. _4 T! C
  944.     else4 b+ X; f9 }5 ?5 m/ d' Z7 W
  945.       vp_x = viewport.rect.x - viewport.ox
    - N0 y9 \5 l) |3 e  t. g4 N
  946.       vp_y = viewport.rect.y - viewport.oy
    + ^( c$ b  k0 ^! M( l- w1 O
  947.     end
    * A( A5 N! N/ H5 O
  948.     item_x1 = vp_x + x + standard_padding / ^8 w; B" O8 E8 S7 T# @8 o5 |  Z! _
  949.     item_y1 = vp_y + y + standard_padding, y- e" n( Z$ S& n" k/ H
  950.     get_index = @index  0  0  @index ' H! ?2 A* o$ q- k+ l
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)$ J7 Q0 K  }0 \4 v- r+ m
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)) Y3 O3 [9 H+ v$ K% Z% f: j
  953.     Mouse.set_mouse_pos(new_x, new_y)2 i% ?3 X! ]8 e  W( i  U. ^( t5 _
  954.   end2 n0 [8 H7 @* m! m( c. D
  955. end% ^/ |3 q* [6 E7 V5 H. A

  956. . L8 ~4 }# b# b4 j
  957. #==============================================================================
    : |9 f  @) D" K  v6 e4 s) ^
  958. # ■ Window_Message0 X8 q2 ?4 |4 [
  959. #------------------------------------------------------------------------------- Q* B, o- M7 c: T+ V" Y+ w1 ^
  960. #  显示文字信息的窗口。& Y! J1 P" O$ T! E, a- A
  961. #==============================================================================& ]2 V( X5 m. n' G  c4 u0 I8 P
  962. class Window_Message  Window_Base
    , c4 [4 S: T6 Q  u
  963.   #--------------------------------------------------------------------------4 w, u2 e& j+ m5 I7 a& u
  964.   # ● 处理数值的输入(覆盖原方法)
    - ~# g5 P, A$ S! ?' C) k
  965.   #--------------------------------------------------------------------------, J& v6 c8 }& r8 t4 r( m
  966.   def input_number# k' \( x9 j3 R
  967.     @number_window.start
    9 L% j1 K8 f8 ]$ n; C
  968.     Fiber.yield while @number_window.extra_window.active- Z3 m; ]# A0 D6 O- m' h
  969.   end
    9 i- s, q/ x0 F1 c% `! g, a6 k9 ^
  970. end
    4 L* z* a! J: F0 [
  971. , \) ?# g0 w- d% s$ ?/ Q" \0 j6 X
  972. #==============================================================================
    3 k0 S. I* b, F( y! y2 \4 @% k
  973. # ■ Window_PartyCommand
    8 n6 `. V" S1 M6 V$ A0 k1 ?
  974. #------------------------------------------------------------------------------4 r0 \% \( R: @) L
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    . ^* \' O5 k7 N/ l" E4 F4 f
  976. #==============================================================================
    ( i  X7 v: O, P* W  S# {' ?
  977. class Window_PartyCommand  Window_Command
    4 w2 v% ~  m7 e. Y1 N
  978.   #--------------------------------------------------------------------------
    $ s. A* H% d2 M) Z* i
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ( m7 o" b/ K* V! x9 X7 B- d5 ^
  980.   #--------------------------------------------------------------------------5 X4 x% n% {$ ~7 S# `7 ~% J9 b
  981.   def set_mouse_pos+ `* E. J* m0 B+ ^6 x
  982.     if viewport.nil
    ( Z( C2 |6 k1 L, }+ r' @
  983.       vp_x, vp_y = 0, 0- H) S' K/ k$ J* v  u
  984.     else
    , W( T8 n/ h2 a+ d
  985.       #vp_x = viewport.rect.x - viewport.ox
    0 M, Y) S* {/ j4 s  X* Y$ X+ g
  986.       vp_y = viewport.rect.y - viewport.oy
    ( P0 l, v( g8 s
  987.     end
    & y1 a% b- ^4 A& R( |
  988.     item_x1 = x + standard_padding
    4 f1 n% L! k  z7 b/ L: ?2 d, {4 N
  989.     item_y1 = vp_y + y + standard_padding
    # B, p1 p# N4 r3 b1 X4 ?8 {, h! z* z
  990.     get_index = @index  0  0  @index 8 X( c2 t/ A+ v& g& ~( r1 y
  991.     row = get_index  col_max - top_row
    : `, v! K9 O9 s+ _# {8 P
  992.     col = get_index % col_max
    $ D1 k  U3 `$ l- S. ^
  993.     new_x = item_x1 + item_width  (col + 0.5). N: D1 `" F2 p1 h, p( `" e: d) p, q
  994.     new_y = item_y1 + item_height  (row + 0.5)3 u' r/ E, D# k& v/ P# R* T
  995.     Mouse.set_mouse_pos(new_x, new_y)
    % h* \* i- Z7 s9 E
  996.   end
      E8 K3 G7 [! {* ^, W4 f
  997. end( J0 _4 O8 g0 z1 }/ K; i; M$ m+ O2 h
  998. ! Z  b' ]$ `7 k. N3 k
  999. #==============================================================================+ ~% j. R4 t) ]$ @. y  ~5 i! ^+ h
  1000. # ■ Window_ActorCommand
    % ~, P1 O* f$ u5 {- V2 C7 R
  1001. #------------------------------------------------------------------------------
    5 C+ S" r! k' }6 {5 H. N
  1002. #  战斗画面中,选择角色行动的窗口。; f7 J/ j, S% Z( y+ G& q$ W
  1003. #==============================================================================6 _* p" R! ]+ ?8 U# w
  1004. class Window_ActorCommand  Window_Command
    : A2 k4 Z& h. A  p& t$ K
  1005.   #--------------------------------------------------------------------------
    1 l8 `/ V, x  w1 m! O+ d* e% k
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置, N% `2 t# R0 o/ W; N
  1007.   #--------------------------------------------------------------------------/ \/ s' ]- ^7 r7 s
  1008.   def set_mouse_pos1 z' `7 Q  Z" F: `
  1009.     if viewport.nil
    * j" m: S: K: v& ]+ g# L* u' J
  1010.       vp_x, vp_y = 0, 0
    # I6 i0 t  w& b; E  D
  1011.     else
    ; s7 a& ~4 \3 u6 O! ]8 C: V3 L
  1012.       #vp_x = viewport.rect.x - viewport.ox8 A) l3 }" s" h% a
  1013.       vp_y = viewport.rect.y - viewport.oy
    6 `( W7 E$ \  B% H6 H7 ^) d
  1014.     end
    8 S; W9 t! M  F
  1015.     item_x1 = Graphics.width - width + standard_padding7 K- j- M3 B* Q; [/ q5 [* U
  1016.     item_y1 = vp_y + y + standard_padding4 b2 A# ?- d# u
  1017.     get_index = @index  0  0  @index
    7 Q6 h  G6 ]+ T. r; J0 E
  1018.     row = get_index  col_max - top_row
    9 m; ?& q$ R/ F1 o/ C2 f0 p
  1019.     col = get_index % col_max
    # V8 @3 j- o4 e, C# p
  1020.     new_x = item_x1 + item_width  (col + 0.5)3 z" `, F9 Q8 t3 [# B5 X
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    / }, F" Q1 |0 c" _
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    4 p5 S  g* P2 `
  1023.   end
    7 W( I3 S* }+ C0 a
  1024. end/ k% q1 M! K- `: e5 x

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

  2225. / t% ?- u/ Q2 D# }
  2226. #==============================================================================3 U6 \" y$ N3 ]% I+ c
  2227. # ■ Spriteset_Map# c& u8 Q  n4 Q3 [  c
  2228. #------------------------------------------------------------------------------! J9 w6 M, Q  B1 z
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    ; P, |# u/ Z# R$ c2 l
  2230. #==============================================================================
    3 \0 c+ A% T+ k1 V% I
  2231. class Spriteset_Map
    2 d$ D- f# f4 K4 D
  2232.   #--------------------------------------------------------------------------
    2 [! i/ H6 [0 l
  2233.   # ● 生成路径点精灵
    ; C! }7 @7 O2 g' l! L5 M+ r
  2234.   #--------------------------------------------------------------------------
    / q4 @* g, W  O6 N% F. g5 h
  2235.   alias sion_mouse_create_characters create_characters
    7 O/ z2 q/ ?$ J8 B5 ]0 X* S, x
  2236.   def create_characters
    . V8 J5 i8 e- p1 \0 {
  2237.     sion_mouse_create_characters8 _0 V% V. {7 y; @! Y# y7 o
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    % v7 p3 j; `0 k# E) t
  2239.   end
    . A1 p" K( ]2 ]! M; q/ S
  2240. end. y1 s+ O' y4 T' y6 E
  2241. 6 M3 B% Z% c# @/ n# @+ C
  2242. #==============================================================================' z7 M8 _+ |/ V% m2 @0 ]) z/ j. @
  2243. # ■ Scene_Map
    8 |' K% T& \$ }1 x+ V  c! C" F
  2244. #------------------------------------------------------------------------------
    4 }/ ^& R1 v1 P
  2245. #  地图画面9 b" p: k  {; F  a
  2246. #==============================================================================" G+ I. ~3 }' Q5 Q
  2247. class Scene_Map  Scene_Base
    6 O0 I9 S. L5 m- s+ Z6 h
  2248.   #--------------------------------------------------------------------------  p1 Y( S8 ^: t# _2 ]
  2249.   # ● 画面更新1 l" G$ A! h% j5 P9 R" e
  2250.   #--------------------------------------------------------------------------
    / f9 _1 [- N2 M1 e& {
  2251.   alias sion_mouse_update_scene update_scene: d: K) l8 p8 K/ u
  2252.   def update_scene  B. z: A! a/ D+ }. n
  2253.     sion_mouse_update_scene
    # r% [7 [- H% k! `* N3 L
  2254.     update_mouse_action unless scene_changing+ C  M; N7 @/ z( n
  2255.   end
    3 {+ Y! L  ^" O. R
  2256.   #--------------------------------------------------------------------------
    . p- b& W& i! |. ~% ]5 H3 f
  2257.   # ● 场所移动前的处理1 q. W7 w. ~9 I! a
  2258.   #--------------------------------------------------------------------------
    , ?" u1 @, F/ x# l; M$ q
  2259.   alias sion_mouse_pre_transfer pre_transfer
    0 E) D% C8 n! n% x0 n# y7 Y
  2260.   def pre_transfer# Y# R4 U6 ?' W6 r" A; V3 D
  2261.     $game_player.reset_move_path% m" ]" A1 @8 }( _* f
  2262.     sion_mouse_pre_transfer( [4 d( W  B- j5 ]* W8 a
  2263.   end$ x1 y/ ^/ }2 w
  2264.   #--------------------------------------------------------------------------! a* ^  i0 H5 X1 x9 L$ @
  2265.   # ● 监听鼠标左键的按下' P5 A( P/ D! \, b2 Q1 w" N& ^
  2266.   #--------------------------------------------------------------------------
    " n& [0 [1 v7 x" y( K7 Y' e
  2267.   def update_mouse_action: ~3 x+ Y% u# E0 _, d
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    * o$ `0 H5 V7 Q/ y: e
  2269.   end
    " R9 o; s& Z6 |
  2270. end
    ' Q9 f8 B7 g* O

  2271. . N8 o( `& l7 l2 G: }
  2272. #==============================================================================
    8 T+ l6 q0 o. [' R
  2273. # ■ Scene_File; H6 ^$ u& N# d; j2 O8 y4 p
  2274. #------------------------------------------------------------------------------
    5 z/ {0 @9 e5 W7 x
  2275. #  存档画面和读档画面共同的父类
    ) I8 k) q4 M% |; D2 v* K; b5 |- c+ N
  2276. #==============================================================================# p( l: |, ~' E0 Y$ K7 `0 y7 \
  2277. class Scene_File  Scene_MenuBase5 X0 T: u% q  H9 C6 M4 D2 g6 e+ \
  2278.   #--------------------------------------------------------------------------
      Q# m1 }" s/ |
  2279.   # ● 开始处理- ]" q8 e9 x& q$ M( l6 T
  2280.   #--------------------------------------------------------------------------
    9 [. t. N# P8 {  z7 x# b9 A
  2281.   alias sion_mouse_start start
    ( z  S0 e" s/ @% a. l2 @2 O. P
  2282.   def start
    - s# @( ~( r$ C1 ]8 K  K
  2283.     sion_mouse_start
    2 {( F9 [3 P1 Q5 E1 Z, L5 y3 m
  2284.     @move_state = 0
    ' v: M7 R( v) T9 [' ^
  2285.     set_mouse_pos' O7 n) Z) x# H
  2286.   end
    0 A0 y/ n' }  L! s. ?; V2 S% F
  2287.   #--------------------------------------------------------------------------& Q1 {6 r4 O+ {4 `/ K; _, H
  2288.   # ● 更新画面
    3 |8 c0 G6 n, f5 j
  2289.   #--------------------------------------------------------------------------
    & v" ^9 y1 F7 E( Y/ Q1 P
  2290.   alias sion_mouse_update update
    ( V" |. Q# D) r, J4 [
  2291.   def update# l$ E& y8 o+ `0 K+ X
  2292.     sion_mouse_update' Y, ?0 \* j# L: u* B
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    4 ~$ i! Y9 D1 V0 C2 G& R! R3 T  W
  2294.   end6 s; r4 ^. S" ]4 [# ?% K7 q
  2295.   #--------------------------------------------------------------------------: ^4 v+ r$ N. `- u* J1 e
  2296.   # ● 更新光标1 A- |- \% {  `( A9 I
  2297.   #--------------------------------------------------------------------------
    $ g0 g, i5 H0 O* Q7 W& s+ @
  2298.   def set_cursor
    7 q5 k0 H% b! ], M8 ?
  2299.     @move_state += 1) L" I+ Y% }4 h6 ~; x* @5 V
  2300.     last_index = @index% y+ B" x1 z9 |: D& R" v
  2301.     if mouse_which_window == -2# x0 k! t9 A2 F
  2302.       if (@move_state - 1) % 6 == 0) Y6 X" s$ X$ h6 T4 [' j
  2303.         @index = (@index + 1) % item_max if @index  item_max - 13 P: t' t, ]% J9 n
  2304.       end; v: L3 s. X2 t! y# |
  2305.     elsif mouse_which_window == -1
    / T$ W1 h5 G9 j. y
  2306.       if (@move_state - 1) % 6 == 0- x6 M/ f/ p$ V, E$ s
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
      s& f' o: u- T, m" |
  2308.       end8 B9 K3 C4 S! U& G& X0 ~
  2309.     else1 N% B/ A- R/ }! Z6 z6 _
  2310.       @move_state = 02 k2 v9 `+ z# j: L! F* x0 d9 X7 f9 B
  2311.       @index = top_index + mouse_which_window$ l4 w, z1 ^5 b6 [
  2312.     end
    & o3 }, E9 D) j' [- e+ n
  2313.     ensure_cursor_visible
    % E' S3 Q) k  J; U; g7 D" c
  2314.     if @index != last_index
    ' G6 i: H, Q- J! E, h3 |$ Y5 H
  2315.       @savefile_windows[last_index].selected = false
    0 u' d8 A6 H- {& @5 r& c8 J0 T
  2316.       @savefile_windows[@index].selected = true
    5 Q( |2 \, A' ?6 O
  2317.     end; e* r$ O; {7 j. d5 T$ S" N  O
  2318.   end! n8 @  Z( m4 r& |3 V; V5 o
  2319.   #--------------------------------------------------------------------------6 Z% h% w. T' A" Q. B+ k1 X
  2320.   # ● 判断鼠标位于哪个窗口
    ! a+ k# {  m+ O4 U
  2321.   #--------------------------------------------------------------------------
    # g9 V4 {. y  G6 l
  2322.   def mouse_which_window
    8 s; F3 C% y0 I5 e
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ' A6 E/ g" a$ v2 a- i! |! d
  2324.     if mouse_y  @help_window.height + 14
    . ?+ r+ v  |) j) e; y  D) i* V# a
  2325.       mouse_row = -1
    ' Z- y( k  R, \% w( A7 g
  2326.     elsif mouse_y  Graphics.height - 14: v: b# Q/ N% x8 y( A3 f3 M
  2327.       mouse_row = -27 S: y3 P; S, {% y2 W8 z( r
  2328.     else
    - Z! c$ [9 \3 X& [4 E( x, i; _
  2329.       mouse_row = 4  (mouse_y - @help_window.height) ' ~0 t/ R& |+ b: w" B3 e: F
  2330.         (Graphics.height - @help_window.height)
      n1 m& }! s% e4 E7 z
  2331.     end% H, p  y# O  g! y
  2332.     return mouse_row  l3 F! b8 ?+ A+ ~
  2333.   end4 B4 S- N" A2 |8 _0 o
  2334.   #--------------------------------------------------------------------------
    + G  q; i( Z$ \; L; N! N
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置3 V0 O& B: [) R' T9 Q. A2 Y
  2336.   #--------------------------------------------------------------------------
    3 e9 b& U- t. w9 m
  2337.   def set_mouse_pos7 J( t% Q6 O! ]) `# X
  2338.     new_x = 40' |9 z: c7 x8 t2 v" s0 M
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    6 G1 I6 ?/ [7 [7 n; \1 R
  2340.     Mouse.set_mouse_pos(new_x, new_y)2 Y( Z/ C! p0 ?- Q
  2341.   end8 K% j. i( {, p, x# w( H
  2342. end& Y3 s4 X4 y% \( I2 F
  2343. + K. I  {: k  i7 V9 S
  2344. #==============================================================================+ x4 v3 r+ {/ A* @% [
  2345. # ■ Game_Event0 W# w1 Q2 U; Q5 ]5 L
  2346. #------------------------------------------------------------------------------! R; `4 G9 V$ e; Y
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。$ I9 ~. u$ W1 ?, e. M# B- V- M
  2348. #   在 Game_Map 类的内部使用。
    5 a4 O/ L5 U. z' x5 |$ _! K, H
  2349. #==============================================================================
    # e! V7 y) ~0 L
  2350. class Game_Event  Game_Character
      l' w7 s7 M* [* G2 m5 _
  2351.   #--------------------------------------------------------------------------
    9 N3 }( S4 M$ K1 i
  2352.   # ● 事件启动0 @& x' t% ]: i$ h* Q
  2353.   #--------------------------------------------------------------------------$ R1 t" X6 o6 t% j* _
  2354.   alias sion_mouse_start start0 D- O3 [# l, S
  2355.   def start
    + R; ~8 ~; t# M8 H$ W" y
  2356.     return if mouse_start && !Mouse.press(0x01)
    4 ?# u. n: }9 B3 `1 B
  2357.     sion_mouse_start8 }/ Z  D7 _8 P- d3 Z
  2358.   end4 A. U( Q  P0 b
  2359.   #--------------------------------------------------------------------------2 r$ W# \8 D: E+ A' h4 }* d, n/ l
  2360.   # ● 判断事件是否由鼠标启动
    0 G% q, }4 ^; f  n* e1 a7 O4 O
  2361.   #--------------------------------------------------------------------------
    # r, i1 m/ v4 b4 r- G% ~2 B, U
  2362.   def mouse_start, W8 O, D; f9 z3 J# @
  2363.     return false if empty
    1 ]1 E6 G% \  l9 o) |# k2 D
  2364.     @list.each do index- t  u  C% z% X) k7 \( Q
  2365.       return true if (index.code == 108  index.code == 408) &&+ n0 n7 _' g6 O3 C% f) {# ~
  2366.         index.parameters[0].include('鼠标启动')/ u. C$ J# q6 R8 V7 A
  2367.     end' O) M( {: m8 `$ e4 c
  2368.     return false
    . |, |( U1 p8 \9 q1 J
  2369.   end5 r5 T- [% f- T$ K( R; k
  2370. end
    * }& S, G& Q3 `- x9 L6 c- N

  2371. 9 }2 }9 e- @% d& f2 E+ U/ ~3 e
  2372. ####泥煤的height
    - l; j: I+ N, ]- v3 D
  2373. # @height = height0 k3 r& w+ h8 ^- [: x& T
  2374. % \/ q$ r* a9 S$ G: _& v' U
  2375. class Area_Response
    . l8 J3 I( b  J, @/ d1 S0 {7 Y8 U+ s% h
  2376.   attr_accessor type+ e' Q0 g) o! H' z1 {
  2377.   attr_reader ox, m1 X0 u$ u+ g  F8 U3 r6 l
  2378.   attr_reader oy* y- o3 A! @. q6 |
  2379.   attr_reader width
    * Q; V# w7 S0 F7 o7 t
  2380.   attr_reader height( r4 S5 \! D8 s1 Q+ B' B9 J6 Q; ~1 l+ R
  2381.   attr_reader switch_id
    + j  u6 ~% t3 ^; r9 Q+ p* Z
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    1 Q- c: Y- K7 S, V1 g1 R
  2383.     @type = type5 F( S# ~8 M7 W
  2384.     @ox = ox- |3 ~: B3 H& e1 q' ]
  2385.     @oy = oy7 d; ?8 g1 I4 D' q+ G
  2386.     @width = width. b- F3 X7 S  \# a6 [
  2387.     @height = height1 W5 s" p, T1 m/ t- u9 w& v
  2388.     @switch_id = switch_id
    5 c- J8 c4 R' g2 R
  2389.   end
    , f0 \! S! K8 Y1 g
  2390. end+ o- H, R' |0 h6 }. S
  2391. 7 ^/ H& E0 C" e# ^1 F
  2392. $area_responses = []
    8 R5 i! \8 s( l% ]

  2393. 0 J/ o9 a6 e2 M" M- O& t9 \
  2394. class Scene_Map
    + o7 `5 q! m# k' Q" ~. D" |9 T2 b$ f
  2395.   alias update_mouse_2013421 update_mouse_action, K9 @% g" B! r7 u2 t- F' d
  2396.   def update_mouse_action2 C: f& K3 [* A) x# ]+ f3 b
  2397.     update_area_response2 m1 g4 S+ h" L, J+ l
  2398.     update_mouse_2013421/ j" ^3 q4 D- G1 M* ~
  2399.   end  u6 ^: S: g7 S! V5 G
  2400.   def update_area_response/ |  I; G* [+ z' v+ ]1 K* {
  2401.     responses = $area_responses
    0 j% C4 h! v' d5 C
  2402.     responses.each {response6 {& y: F4 c5 Z2 F+ u  \; j
  2403.       ox = response.ox6 `- f3 E- L' q2 S; `
  2404.       oy = response.oy
    : Q* l3 ~4 A. A5 J, j1 v
  2405.       width = response.width
    * R. C: A* w2 M( ^3 w. Y
  2406.       height = response.height
      X/ d: b$ K8 h) N
  2407.       switch_id = response.switch_id2 V1 Q8 I& ?4 m# O1 Z1 Q# \2 k
  2408.       case response.type
    6 U" @% `8 P+ E8 j
  2409.       when 01 G3 `0 V1 W( z
  2410.         if mouse_in_area(ox, oy, width, height)$ z  O  C! V+ {
  2411.           $game_switches[switch_id] = true# o4 A" p' N( P- P9 |
  2412.           $area_responses.delete(response)8 x- x* C8 d: t& X3 ]% y/ Y( l# n
  2413.         end4 n% I: z  K0 l1 i4 ?% v7 X7 g" i
  2414.       when 1) g* j% `$ C/ G& [7 c! ?
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    $ o; B) X- Q7 y2 F/ R' J
  2416.           $game_switches[switch_id] = true
    ) V- a8 l: j7 t# Z, P6 ^
  2417.           $area_responses.delete(response)' B8 W3 j* N/ y# q* @1 _/ R8 y
  2418.         end
    % w% D0 K+ X6 p( c& t. Y
  2419.       when 2
    8 V) o4 R* i* q' O3 m! E
  2420.         if mouse_in_area(ox, oy, width, height)
    $ e1 s- m- ?+ u7 s8 R; D
  2421.           $game_switches[switch_id] = true. ?  a( ^. @* _! q5 z& D) D0 q
  2422.         else
    & H6 v! Y/ T( U1 g% C! b- S
  2423.           $game_switches[switch_id] = false8 W& u- e" t3 Q* n4 T- w
  2424.         end. E+ Z8 ?( B5 Y% v: e5 W0 R2 J' O
  2425.       when 3! p% p& B0 v! G6 C
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    / J5 p4 C6 y2 n6 ?2 n6 D% ?% E
  2427.             (oy - $game_map.display_y)  32, width, height)
    + [/ [. j, |7 a! z; S* t
  2428.           $game_map.events_xy(ox, oy).each {event
    : k' K! S2 i) J
  2429.           event.start
    ' B( J% J/ m& O2 Y2 |) L" A; M
  2430.           $area_responses.delete(response)& f7 ?' g9 X4 j/ e( i6 h
  2431.           return$ O% ]$ G* {# X$ ]0 `
  2432.           }
    % f- M4 G& Y. p, t3 q, U
  2433.         end6 I5 O8 S+ w! u  N4 ?; w8 ]
  2434.       when 4
    / e1 ?0 V0 Z% [: W( A% r4 B& V9 ~
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    6 O3 H- Q8 s; W8 U6 m
  2436.             (oy - $game_map.display_y)  32, width, height)
    . i2 j$ f2 J( Q( s5 @; Q
  2437.           $game_map.events_xy(ox, oy).each {event+ K$ l: D+ O  Z& g/ }
  2438.             event.start
    ( n8 j  _0 P- U/ L  K
  2439.             return
      R- V, j( j$ D( i
  2440.           }
    4 m+ D0 W6 V& O" @
  2441.         end0 e# O1 I, H" X2 Y  a
  2442.       end5 t5 O5 j# \9 O# l/ h  d
  2443.     }
    $ ?, Q7 T5 d! o- e: t2 Q: m
  2444.   end
    : _# Z# d% @) C' D$ n& l4 L
  2445.   def mouse_in_area(ox, oy, width, height)
    / S, _- s: D/ F8 R8 v
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    8 O) r2 ^" J8 J* D+ l9 i1 \
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height8 C% S% A, [5 J+ W; k$ Y. s
  2448.   end
    ) _# B7 k1 M9 d' r+ r
  2449. end1 W* W* h: s- O& R7 Z
  2450. class Game_Interpreter
    . W7 d+ N5 J" I( o; {
  2451.   def area_response(arg)
    ' E2 ]4 U, f% }4 A
  2452.     $area_responses.push(Area_Response.new(arg))8 w) ^: |( V5 f! z9 [; r6 N
  2453.   end
    ! k, V2 ?1 \( ]
  2454. end
    . g* |$ z$ M0 m; Q. R$ K7 ^
复制代码

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

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

GMT+8, 2025-9-11 17:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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