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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    7 i, m8 y9 z$ x6 k6 F

  2. % s9 d/ w0 G0 w8 r/ l* K* k
  3.   Sion Mouse System v1.3e- f8 a* O2 B) K# S+ B! k
  4.   
    $ i) c8 y, L' q9 A. z
  5.   Changlog2 M* g4 J- c6 T  V' A1 y
  6.   * \1 ^7 Z0 |0 a; A" k' C- r
  7.   2013.4.21 v1.3f
    + r6 Y7 J4 ~; H
  8.    
    - M5 I+ T1 [3 m, g$ Z2 s
  9.     1.3f 卷动地图 bug 修正- R; |' n) x7 |5 r$ k
  10.     ( g- |2 z! Q1 }+ F6 i7 c8 R: k2 w5 I
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口% K/ L$ v; u( ]1 A0 L) R
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    # E: I* V) Y/ k+ ^+ j
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    1 `( E; p; k4 F

  14. - p3 q8 X: f) ^* G3 x
  15.     1.3f bug修正. r8 G* g0 d; o; V
  16.   5 ~. {8 {1 y$ o1 V8 @$ c  Z7 _
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    - e1 w, @5 Y8 }" G# Q
  18.           关闭菜单时,鼠标是否移动到原来的位置。5 ^) B! {$ `- B7 D1 \) o
  19. ! u: j( ^+ ?& e: k; p* a( E
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处) `1 z1 X  @  `& u: o0 ~# W) r3 v6 T: e

  21. * I) G/ r; X7 N) Z
  22.     1.3b 修正一些罕见的bug;
    ' k  \& J% I2 D6 d/ `, Y9 L
  23. 4 j6 x& C( Y% z5 u! Q
  24.     1.3a 代码小修改;
    * E! O9 ]* a- Z3 m0 e, o
  25.           加入了鼠标点击启动事件的功能,, Z9 t0 T" i# o! _& Y
  26.           在事件中加入“注释”: 鼠标启动  ,
    + `3 R/ @# _5 R; D
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    7 n) s. m2 X, j; j  M
  28.     q6 ]$ A! O1 s4 J, s% N* F- x' t
  29.   2013.2.12 v1.2
    : b6 g! j* @) x/ `. c" k5 I

  30. + Z; w# {* z4 B( I0 x% T
  31.     寻路逻辑优化;
    & l  K& n# {# ^3 e
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;1 o, U: E* Q$ s6 i1 g6 `: m; |
  33.     现在支持用鼠标来操作载具了。0 T7 {8 S. L" L; r- Q5 U' P2 [
  34. 0 {8 a2 D0 |0 s. T) [9 {
  35.   2013.2.8 v1.1
    & C9 ^3 h+ L; }& d# ~
  36. 3 J$ C- E; V) u$ `5 |8 ~
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;7 n* P. E/ O' J/ P! a" F" D3 i
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    ; O  ]2 A5 d4 M* j
  39.     移动时,路径指示点的绘制更加稳定;! |5 y* v$ d' `$ L# S
  40.     现在支持默认存档画面的鼠标操作了。( d! b  _! ]4 [

  41. . G$ ]' C8 ]' v( ^% }

  42. ) W; ^7 L3 ?' J* d' E2 i3 u
  43.   OrigenVersion
    ' U& ?/ S3 i; U2 Z; N. f5 ^
  44.   2 j4 j% ]3 r4 j1 {; X
  45.     2013.2.7 v1.0 ) M( s4 ~& D/ H) b
  46. # k" s. V" n/ B3 O" q
  47.   主要功能
    * v; u# U( ^0 _# H
  48. ( P! v! o- k5 f- h- T4 w
  49.       使用鼠标进行各种操作...! r7 u& d1 l; W) O% v/ N) B* J! i
  50.       将鼠标锁定在游戏窗口内
    / S( k, \( F: K3 ~& @9 j/ S
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    . P, k3 U( h( n# k/ D" g
  52.       双击鼠标进行冲刺
    1 X: H  d; R' M/ f
  53.       更改地图卷动方式以适应鼠标移动4 q6 g4 L9 l* y" Z: a# o& \, k( E/ N
  54.       变量输入框改良' y' T8 }/ e2 k
  55. , W6 t* G2 S; C
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    4 |$ R) F% C( G3 Y  K$ f/ ^0 J% I. w
  57. + B  C. |6 `$ a6 R* w0 p0 o
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    " I4 H( \* z+ j, P5 M
  59. / |3 k1 t  m/ u% J9 @( H* e( L& ]
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭, L* @4 V! k' X! w+ t- Q. k1 G
  61. ) B  F/ E8 i5 Y4 f9 Y8 V

  62. 5 m& B) U+ ]8 D  c5 G# i
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
      |) @. G) G% z# B
  64. ; g+ v8 M. P, x8 H  y$ L

  65. 3 h! y5 y/ l# j! G$ Q3 x2 C
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    8 V6 K* Q8 W3 h: Q& r7 h+ {
  67. . h2 U: C0 \  ]4 L9 l& @- C
  68. #==============================================================================: E) H* [) Y4 R! C' V2 h
  69. # ■ 常数设置 / O  D$ ^% q+ \
  70. #==============================================================================
    ! f& J/ {4 N9 D" A. K
  71. module KsOfSion
    9 q4 ]' t" t  {; P
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false& a. L; z* H7 t) I5 i4 Z+ i
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑0 v+ z' @8 H) o3 l/ {' k0 z
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false" D$ O4 G* M; m, I8 W7 f
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量- v. A, U5 ?! Y0 u8 i
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处0 @# @7 N! T5 |( A8 [: Z
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    & B5 I1 S/ `) j
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    2 `5 F& j. p3 h' r
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键7 }7 l& B* f* L/ e7 Q9 U
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    - u0 j. b8 s5 W$ q+ M. B8 j5 ^
  81. end1 A( e3 g/ c8 T7 w+ W$ R3 F! @

  82. 1 J) Q1 }) [  J. \  m3 Y, A0 p
  83. #==============================================================================( `0 a8 L! M7 c" g/ W' }
  84. # ■ 用来显示路径点的类* ?' f0 d7 E- A3 c: g* {7 f
  85. #==============================================================================& q2 ^- ]# ~" a8 }' Z& ]8 L: T
  86. class Move_Sign  Game_Character
    4 O1 v$ n; a) P$ e+ n/ m5 J- Q5 P
  87.   #--------------------------------------------------------------------------
    , E! y' ^* ^' y7 a/ q# f9 L( T
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    , T0 K+ L7 r6 Y
  89.   #--------------------------------------------------------------------------
    / a! M3 V& M* J% e  J
  90.   def init_public_members& K6 j. Z% b/ f
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹7 \$ e% d4 ?* D( Q! B. Z( j
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0! h& e8 ^; z3 ~7 i; m. ~( t  J
  93.     @move_speed      = 5        # ★ 踏步速度4 r5 R6 l6 D' k$ v# T0 B  y
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)* x4 S/ ?4 [0 ]  S+ F( n4 d
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    ( a) y  L( u: U5 _! b2 f" E% E
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    % I  y* W! r: V  [; I. X
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列. K+ E/ C' H& Q8 B7 Z1 R1 m
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)' G: n# c& _7 N" ?& p  s
  99. ' P+ q/ U* v2 p$ }; q
  100. ( f  y( P( f% R2 m7 g
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    9 a% t! h% G5 t+ L& R

  102. # g  d4 x' y8 C

  103. 0 A( s  x8 z% M9 ~7 s! h1 V/ [. `) o
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图+ ]* W' N- P3 k+ @5 d
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    9 T3 N# P$ l: f. \: A

  106. ) z" J( X: c0 }  z' s& x! B
  107.       if $no_arrowpic_warn
    $ B& y( h$ Z: C0 b9 }
  108.         MouseShow_Cursor.call(1)
    0 g/ F" F& X' z( T0 x
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    $ t9 l: l: r% o

  110. " C" p! i( o$ e9 D+ w) N" w
  111. “路径指示点”将使用游戏自带图片' @0 P8 q' q/ ~6 f; g5 }
  112. ' ?4 E* w( g5 g5 N6 g0 h3 L( ~) m$ h
  113. 该提示可以在脚本内关闭')) `  W0 M: _: v2 |1 K
  114.         MouseShow_Cursor.call(0): v" r3 Q- f% o# F9 h
  115.         $no_arrowpic_warn = false
    7 I0 U9 I; H* n- ?, D7 X. h
  116.       end
    * Q$ O6 O' g( f4 v# l& @, C2 w% X
  117.       @character_name  = '!Flame'
    . d9 Y# ?$ ~& b. Q) J
  118.       @character_index = 6
    % C% B1 D% d; q" q# w7 d0 H
  119. 4 o( ^; a$ J5 V  y: |' R2 {: @$ [
  120.     end
    , P, d# X! p5 u1 z' Q4 A) M
  121.     @direction_fix = false  # 固定朝向& a9 G0 H/ I; f' @
  122.     @move_frequency = 6     # 移动频率
    ( i( Z4 P$ S; B
  123.     @walk_anime = true      # 步行动画
    $ d) _: \# t2 X7 b; O" C9 ?
  124.     @pattern = 1            # 图案2 [4 v3 ~, v( F8 _& c. F
  125.     @through = true         # 穿透
    $ c1 O- T$ _. z* a, k
  126.     @bush_depth = 0         # 草木深度( d: r" F( k3 w- K/ E6 }; N. q
  127.     @animation_id = 0       # 动画 ID3 n7 O/ C3 a# b4 @1 A. ~1 R
  128.     @balloon_id = 0         # 心情 ID5 J; D6 ]+ f$ I9 h
  129.     @transparent = true     # 透明
    - F* }& x( Z- d( F7 {
  130.     @id = 0" e; e9 J8 v- d* A) E- z
  131.     @x = 0
    3 z" T3 }0 a9 L9 V
  132.     @y = 0, c! |) h3 h5 p4 H7 D' V" g
  133.     @real_x = 0
    5 E& a3 y# w8 I2 F+ |7 O" l
  134.     @real_y = 0
    ! G6 {5 O, J, l7 t! e3 T2 G/ R8 G
  135.     @tile_id = 0
    0 |2 g: f6 k! q" y) b2 w0 N" Q8 [8 ?( a
  136.   end# l8 T* }- J, h7 @8 \% |2 H
  137.   #--------------------------------------------------------------------------& r+ i$ {# O( k$ a2 y
  138.   # ● 定义实例变量
    ; v2 b+ W7 t9 _. T- t# H1 x
  139.   #--------------------------------------------------------------------------6 w% m: c. z0 f- ]2 b2 c
  140.   attr_accessor direction
    . _" _4 z' O2 {+ j$ Z0 X) x
  141. end
    / b2 ?6 S6 V/ X# ^" P

  142. " M3 p- W2 Q" x7 D6 D! m  r
  143. #==============================================================================
    ' v2 _, h8 s( o: `2 u
  144. # ■ Module Mouse
    1 Z$ O0 m3 x9 k- F7 G/ P
  145. #==============================================================================! I: ?6 ~' ?- b6 L  R( o% x
  146. module Mouse
    9 D0 s+ }6 r4 K- W. b
  147.   #--------------------------------------------------------------------------
    1 y& y" V8 d7 X
  148.   # ● API
    + ~1 _: I, d3 f& m
  149.   #--------------------------------------------------------------------------8 |! r. ~  ]4 X- R  K
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')2 v2 a: D; P: E6 W1 l. K7 z/ M
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    , Q/ z! n; _0 y% Q; p. Y
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    7 Z. S5 i  C+ H5 U7 k
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')8 T) z8 a7 J* m+ E9 K# w0 i8 I
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')$ C6 ?% S9 W4 b2 K3 h1 ?. K3 R3 i
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')+ i1 \/ S. \( F6 U2 D9 Q/ Z8 O) f# B
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')8 b1 A4 v+ I% h( j1 W
  157.   Window_Hwnd       = Get_Active_Window.call
    9 _( H0 W. k5 U  ~5 ~. x) N- X$ w
  158. " N, ]$ [/ p; N4 [% {) h- w
  159. class  self
    / j. n1 j: S. n! \
  160.   #--------------------------------------------------------------------------* E  }! s, Q1 q! O
  161.   # ● 初始化
    + u, N" i# |; j& {  I5 R
  162.   #--------------------------------------------------------------------------8 Q* g% x- L# d* [5 j5 N7 J1 j: b
  163.   def init
    * {# l# m; N; [
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    4 E, X5 H4 T! _9 X1 {
  165.     @left_state = 0
    ( M- V& i6 X8 A% e! R& O$ r
  166.     @right_state = 0
    $ c2 F# w* t7 X8 s
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    ( d& N; h3 j+ Z. T
  168.     @dk_count = 0 # 用于双击的判定6 d! G- O9 m% k' V
  169.     @clicked = false
    3 U; k, A" q2 @& Z
  170.     creat_mouse_sprite
    , z( ]  g0 G, V8 |5 E' L$ f
  171.     update
    0 l  S/ Q4 d  p3 {/ E
  172.   end  {' ^2 k  q1 M: Y* O  q) t
  173.   #--------------------------------------------------------------------------( ]$ s' _4 o$ R& y; z5 }
  174.   # ● 鼠标指针精灵
    - q& Q4 _2 }" U. e
  175.   #--------------------------------------------------------------------------0 e( y3 A/ \1 k7 t1 j  G& O
  176. #~   def creat_mouse_sprite3 I% y- {, d) K2 S' Q
  177. #~     + `0 W. Z( a6 W/ {- s# t' m& G
  178. #~       @mouse_sprite = Sprite.new
    9 p8 Q6 }4 X+ K$ @! H# J# ^! }5 x
  179. #~       panda = 2#rand(2)+1' _9 b  I2 D1 z) U
  180. # g( t9 C) q- O: R
  181. #~      if panda = 1
    ; I6 I7 x( \& g4 v
  182. #~        if File.exist('GraphicsSystemCursor2.png')/ @0 Y, W, J7 P2 K- [
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')- J6 I2 z; V( l7 `
  184. #~        end#with if File.exist4 i2 l/ |; O  r- y0 `% H5 ?, b& N
  185. #~    " d1 D# O' c( b: m- ]
  186. #~     else if panda = 2 #with if panda=1" Z2 A6 R% [% l1 I& d
  187. #~      
    & X9 @6 k: x" y! B3 G' [+ A) E
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    - ~6 ^9 j# P+ T# [& s6 y- |' f
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
      w9 p9 w2 v# `6 c
  190. #~      end#with if File.exist
    - a8 ]0 N* _3 C. s- x0 l4 h2 W* _, i
  191. #~       , _5 F' c" q# t- `- ~2 m; z& }
  192. #~     else #with if panda=1: |2 M7 V5 |1 F4 ]4 X; ?
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)" t! H- C4 r. ]# S
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),' V2 ]4 J' w& c
  195. #~       Rect.new(5  24, 24  24, 24, 24))2 v3 v! J! z: D& k
  196. #~     end#with if panda=1
    7 A! O$ s7 o' q2 S: G: O
  197. #~     % Q/ _9 W, z- W. d0 B+ Z: T
  198. #~     #with def
    % l+ a* g5 S' G, W) h2 Y
  199. #~   end
    8 ?0 D9 R, C6 Q9 b4 j) Z: o; D
  200. def creat_mouse_sprite* K7 h5 w  V+ G8 [4 u$ I2 Z5 D& ~
  201.     @mouse_sprite = Sprite.new6 r9 `% ?6 F. j( F, r* R- j
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})8 j; T: W5 r% A& W5 m6 _" N
  203.     @mouse_sprite.z = 9999
    ( d( F4 Q  ]- d- `0 m# E
  204.     Show_Cursor.call(0)1 k& Z' ~' ?( F) m/ `
  205. end" b4 K$ s# n# x) @. ^% Y% X  z

  206. % ^1 ^' W! I0 G/ P" N
  207.   #--------------------------------------------------------------------------
    4 @: a+ Q$ t" U2 D0 |, g
  208.   # ● 更新
    # C4 K, [, ^1 b# e% `" w
  209.   #--------------------------------------------------------------------------) Z# }9 I- T5 Y
  210.   def update
    0 x" v* |, X+ V* q, M* y# y# P
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    & G: d# d( H( y  s: {( i
  212.     left_state  = Get_Key_State.call(0x01)7 g+ E9 |5 d% f/ Q9 O8 ?
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    % x# p, r* Z/ {6 L- U8 u8 {
  214.     right_state = Get_Key_State.call(0x02)
    # b& T. `& T5 _3 t
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0- |, j+ i2 M4 M7 N
  216.     update_double_click
    ' F+ l0 f+ f5 S: f$ ]" e. [
  217.     @left_state == 1  @ck_count = 0  @ck_count += 14 W7 n5 U0 k# _; k
  218.   end8 @2 @" f) M) h: Z
  219.   #--------------------------------------------------------------------------
    # p$ c% H0 E' s! q
  220.   # ● 获取鼠标坐标$ O/ U5 ]$ e' v# E9 I- u
  221.   #--------------------------------------------------------------------------) `5 c+ J9 Z7 _% L: M
  222.   def get_mouse_pos
    9 j; ?9 i5 `4 h0 Q5 w) Z0 ]
  223.     arg = [0, 0].pack('ll')
    $ Y! x$ f+ m2 o+ g* V. Q5 a
  224.     Get_Cursor_Pos.call(arg)' o3 M2 h" }$ G7 @
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    8 P. s; N7 \3 u* j/ ]2 G3 u* G
  226.     x, y = arg.unpack('ll'). X" ^3 s6 g' q( ?7 O
  227.     return x, y' n. R  `$ J2 \8 F3 N9 x; n% M7 u
  228.   end% D; G, [2 y7 S2 W/ o
  229.   #--------------------------------------------------------------------------2 X, D/ y, G( E/ e- W4 H
  230.   # ● 将鼠标固定在屏幕内# \$ t9 P! P2 ]. W
  231.   #--------------------------------------------------------------------------
    % s$ Y5 E+ F4 J0 N0 u. i
  232.   def lock_mouse_in_screen0 x* _7 w1 i2 i& I
  233.     arg = [0, 0].pack('ll')
    ; f9 J, ~' b6 B" M
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    4 }& c  q; U0 s% ?% N9 l  L
  235.     x, y  = arg.unpack('ll')+ G2 ]6 e  _( D' S
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    4 d+ I  `7 v- o' z6 X
  237.   end- z3 ~' J5 j9 A; t+ q
  238.   #--------------------------------------------------------------------------
      Q) F  C4 \9 p: P4 I6 u  ^0 H
  239.   # ● 解除鼠标固定+ H- h9 _1 {0 }' E  w
  240.   #--------------------------------------------------------------------------* k: v* m4 g& @( Y
  241.   def unlock_mouse_in_screen
    & D6 c  S2 V2 M* I; |; z
  242.     Clip_Cursor.call(0)! m" ?9 E3 c; M. u& l9 ]5 P* w
  243.   end+ N2 x/ |5 T" K
  244.   #--------------------------------------------------------------------------! v+ T1 F: f6 @7 W6 |/ `
  245.   # ● 鼠标双击判定
    + J4 d2 s% f7 }4 `8 u: k
  246.   #--------------------------------------------------------------------------& D# J9 X  l/ h6 O: O$ N
  247.   def update_double_click
    . Y1 D# C- x+ U, n6 a$ r3 W. a" Z
  248.     @clicked = true if @left_state == 15 v* S3 Z6 ?6 w) ]' q" M: H
  249.     if @dk_count  0 && @left_state == 1% a; j9 S2 M" Q$ T- _' E5 I
  250.       @dk_count = 0; @clicked = false
    3 i/ U" ]- q: t' W2 F% D
  251.       return @double_click = true
    % ?! x4 R' h; C) p+ G
  252.     elsif @clicked: w$ N1 d2 w( O# V  q5 O
  253.       if @dk_count  KsOfSionDbclick_Frame9 ?: c# O6 x) s8 M
  254.         @dk_count += 1$ C% h* ^, q* m* J
  255.       else5 l* ?& e, F$ ]) Y: {# h
  256.         @dk_count = 0; @clicked = false3 K- s1 ?- M* E4 d) ]7 U% l
  257.       end
    , V+ S- A2 a8 t" \1 U
  258.     end" M, Q2 }: D) n1 l2 |! Z
  259.     @double_click = false5 N% R/ X7 K, h8 ?' x
  260.   end3 c& M! _$ b. S
  261.   #--------------------------------------------------------------------------
    5 m" j" i) y, A
  262.   # ● 按键被按下就返回true
    & V, h, Q" I8 q, p+ M
  263.   #--------------------------------------------------------------------------# D( m9 @7 `  E: {9 c  j
  264.   def press(button)- H% ]9 u/ ]' f
  265.     case button, ^2 k5 x1 n; _, K! g
  266.       when 0x01; return !@left_state.zero% X* p. U* v9 P
  267.       when 0x02; return !@right_state.zero
    . G, r" k& t/ K. H$ n
  268.     end
    / Q7 K, n$ v6 e8 i. F5 D
  269.     return false: U* O4 P! I2 C* D( k
  270.   end
    . O" W* K7 x9 f
  271.   #--------------------------------------------------------------------------
    ) X0 D$ B9 w* b5 b( _$ n3 Y
  272.   # ● 按键刚被按下则返回true
    + |# e+ I) h3 a' Q8 A8 G  K5 p
  273.   #--------------------------------------------------------------------------1 r' m/ Y. x5 Z0 C7 q) h$ R0 M# r
  274.   def trigger(button): Z& n- g1 v8 l7 ~* c# `. F
  275.     case button
    * {+ w* M8 H, `8 f% }) w2 P8 B# H
  276.       when 0x01; return @left_state == 1
    9 @/ A( Q9 J+ U- l
  277.       when 0x02; return @right_state == 1, x/ m* R8 X% N' S: w
  278.     end
    9 d" D9 S9 x, j% e% N- w. e
  279.     return false
    . H& p0 C, \: x1 U
  280.   end1 K( u' a2 V" D3 G
  281.   #--------------------------------------------------------------------------
    0 W9 k: _: L# h0 \! a
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true7 q: u0 P* O3 L. l$ H$ |0 e, U
  283.   #--------------------------------------------------------------------------4 \6 \" B, L$ O8 f4 u) F' Z
  284.   def repeat(button)/ v( e" V" X1 c) B1 W( k
  285.     case button
    % \, F, X7 M5 `* r% ~- E0 P
  286.       when 0x01; return @left_state == 1 - i! ?0 V' b! c6 |' n3 }' @  J
  287.         (@left_state  22 && (@left_state % 6).zero)* y3 a: O4 ~0 i# {, c, E
  288.       when 0x02; return @right_state == 1 / d$ I0 i$ l& ]2 ~
  289.         (@right_state  22 && (@right_state % 6).zero)  @: m( y9 l$ S  B- q: R; h, f! r
  290.     end5 N% \! R7 S5 C$ ?' n. d9 H2 A
  291.     return false7 r, c3 L1 W3 R
  292.   end) Z/ ~& P# M9 Z2 F/ X8 k
  293.   #--------------------------------------------------------------------------
    ; @2 H: z; _4 d
  294.   # ● 判断是否双击鼠标! u+ H" j6 A1 D3 j, n9 S9 l
  295.   #--------------------------------------------------------------------------' W" m% x3 ~: _* S3 |$ ?" L
  296.   def double_click
    1 v; d/ p3 r5 F6 b. ^+ j0 ~" t
  297.     @double_click: Q5 d* E# d6 ]- s2 {: N; z0 v
  298.   end
    ' L9 f( J& O8 b. Q+ ^% L4 W
  299.   #--------------------------------------------------------------------------
    2 i! I' H7 v8 J! [
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    ; ~  l: O# h* J3 o" f
  301.   #--------------------------------------------------------------------------
    : B% x6 c/ i# i! j% j* ]7 k
  302.   def click_count
    ! E: v/ C/ \) X& W  G; @5 O0 m
  303.     @ck_count
    ) O: b! I9 m8 s; e
  304.   end: X6 t) ^0 W% g, H
  305.   #--------------------------------------------------------------------------
    ' a  [# a, O# a2 S
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    " g: Z3 ?  B6 o( g! X; y
  307.   #--------------------------------------------------------------------------
    7 v; D3 z2 v0 a/ `# i
  308.   def left_state; ^9 T3 P8 N  w# C9 O2 ~
  309.     @left_state
    & H' M& ]  n" D0 n7 ]1 E9 i4 V: h
  310.   end
    % D& `; T5 q& |( q
  311.   #--------------------------------------------------------------------------
    ; }8 j$ J& P4 }; _& @) P2 S
  312.   # ● 获取鼠标的x坐标% p- A/ z& l9 r' z
  313.   #--------------------------------------------------------------------------2 \- b1 Y* F. ~$ c6 P! z
  314.   def mouse_x) l& C; k$ i2 G+ v6 K- o9 y
  315.     @mouse_sprite.x
    5 b. [) s. l" O: k% c
  316.   end/ h( F6 e; s9 I' H/ v
  317.   #--------------------------------------------------------------------------& ^: \8 H. ~' Y) F9 r5 W  o/ {
  318.   # ● 获取鼠标的y坐标3 `' v8 _6 f" i, R
  319.   #--------------------------------------------------------------------------$ x$ F7 e+ M2 W8 S7 L4 Y7 z
  320.   def mouse_y
    5 O: E3 X' d% o+ z2 L
  321.     @mouse_sprite.y4 x4 H2 q8 D: r
  322.   end4 L$ e/ ^" ?1 [. x8 j' @
  323.   #--------------------------------------------------------------------------" i+ b4 j' b. n# p! U" j, W- ^6 M
  324.   # ● 设置鼠标坐标& ?: D6 S% N& p6 j# C* L# i
  325.   #--------------------------------------------------------------------------" V1 J5 ^8 Y% a9 J
  326.   def set_mouse_pos(new_x, new_y)& x; N. F/ ^9 G# O* i/ _$ _( m
  327.     arg = [0, 0].pack('ll')
    0 U" T& y; j1 [, n  n* l7 X
  328.     Screen_To_Client.call(Window_Hwnd, arg)$ i$ w1 b$ X# A' y, z& s0 @# O& g
  329.     x, y  = arg.unpack('ll')& b9 C$ R' Z* E. ]; _3 F
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    4 H/ a8 H* h" c' R
  331.   end
      l0 [7 ^. Q4 o8 |" Y* t
  332. end #end of class  self
    * S# z) z5 K$ e7 Q+ y/ B
  333. ' E3 w$ D3 M6 {! h( o
  334. end8 A, O7 {" \% \, ?

  335. + l: E" |8 h" W
  336. #==============================================================================
    / e. a) J9 s" ]# ^
  337. # ■ SceneManager; B! t- q, p8 _( y; x; ?0 A
  338. #==============================================================================# P' W$ l, Q( Y" q$ O
  339. class  SceneManager
    : [0 }0 t- {* ]  ~0 K' f6 m
  340.   #--------------------------------------------------------------------------
    1 P5 n. I0 \5 w% Q! t% c
  341.   # ● alias. m7 K3 Y6 W& e3 z
  342.   #--------------------------------------------------------------------------
    ! ~. h, @& F' f' c9 x9 E
  343.   unless self.method_defined(sion_mouse_run)! ]1 `" Y. \" x8 ?; t
  344.     alias_method sion_mouse_run, run1 e1 G" t% a+ ?! h
  345.     alias_method sion_mouse_call, call6 a+ S% u0 q3 D, e
  346.     alias_method sion_mouse_return, return
    3 m( K& ~$ n! M" V% ^
  347.   end
    ' c( t. N% E; B5 a5 P8 o# w4 z
  348.   #--------------------------------------------------------------------------
    6 M8 M3 G2 a9 \/ X5 h- g: l3 C( q
  349.   # ● 运行
    * u3 I$ [+ I: c) D
  350.   #--------------------------------------------------------------------------: m3 x' X7 q" p- g2 ]8 j
  351.   def run3 b; l% [$ R1 p# m6 q
  352.     Mouse.init
    / N" J3 E. X5 `; m
  353.     sion_mouse_run  {9 f8 c) ^$ y3 G  O- m' }
  354.   end% h  Z$ F9 x/ h& ~4 N1 ]
  355.   #--------------------------------------------------------------------------3 L9 ]. e7 o4 M- {& d
  356.   # ● 切换+ o) D- G( C' _$ _& U/ S* M$ U% t
  357.   #--------------------------------------------------------------------------
    . T! S" k% p( V* \& A+ D4 a
  358.   def call(scene_class)
    ; X8 v5 j. h! J4 _7 J
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    # W; i; G* k0 F0 b
  360.     sion_mouse_call(scene_class)
    6 V* v2 q, Y& p& R0 i5 J8 g2 _
  361.   end
    4 s4 Z' p. e% {3 v, U0 a0 h6 Z
  362.   #--------------------------------------------------------------------------& a. ?. n! l# X. `
  363.   # ● 返回到上一个场景+ y3 P% V* u5 |1 y7 |
  364.   #--------------------------------------------------------------------------
    1 y9 y, Q3 R  |/ n2 J5 o- I4 w$ T/ F
  365.   def return
    & `% s* z4 @8 n* s4 n
  366.     sion_mouse_return. ^  N1 R/ C5 Q/ }
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    " m( {2 w8 g9 e
  368.       @scene.instance_of(Scene_Map)
    % F( [3 `9 s9 e  N( p8 [' W2 C
  369.   end
    3 d+ s( z7 d; j% [7 U6 W
  370. end
    * H- C+ R9 D+ v7 }( {
  371. - S& G2 j7 V& w( ?. L+ i
  372. #==============================================================================4 N: `8 E* Z5 E$ a4 L  S# j
  373. # ■ Module Input
    4 R. ~# C3 `) C& r& n6 H. C8 U
  374. #==============================================================================5 U. L' O# P; Q. \$ `  M
  375. class  Input: O: h" b. i) y3 w
  376.   #--------------------------------------------------------------------------4 B  f& J1 J4 @+ Y5 v, @
  377.   # ● alias
    7 }( ~5 k: m7 Y8 J5 ~! T4 M
  378.   #--------------------------------------------------------------------------5 q% {, K. b7 _8 O
  379.   unless self.method_defined(sion_mouse_update)
    ! U- @, z! p; L* W1 h. U* D
  380.     alias_method sion_mouse_update,   update
    / A* X; |" E3 G3 m1 v
  381.     alias_method sion_mouse_press,   press
    ' v' t5 }- z' M+ U9 H( U7 Y. ^
  382.     alias_method sion_mouse_trigger, trigger! o4 w0 X9 M7 R& ~4 E
  383.     alias_method sion_mouse_repeat,  repeat
    ) O- Y$ }7 G  c
  384.   end
    4 _  n. p* I# e- K
  385.   #--------------------------------------------------------------------------
    1 n1 V5 W% c% `
  386.   # ● 更新鼠标
    ! q, _- Y3 K  y4 V+ b
  387.   #--------------------------------------------------------------------------9 I; m( q& ~. w* \
  388.   def update: [- T# ^8 o7 y5 s% x7 q
  389.     Mouse.update
    . B9 i) k0 T' z0 u2 [% `
  390.     sion_mouse_update9 v5 k: B9 J# ?; W0 ?
  391.   end
    / c' d* W2 d' t  a" A% T2 d
  392.   #--------------------------------------------------------------------------
    " y. h1 B) O8 _: a3 e: _2 A% i
  393.   # ● 按键被按下就返回true
    1 N, T, E0 ]) @  N! y( X
  394.   #--------------------------------------------------------------------------9 H' s" Q- g! N
  395.   def press(key)
    + w' T; }" [" r+ c% t* V
  396.     return true if sion_mouse_press(key); N0 f" n* Y3 {( l1 g
  397.     return Mouse.press(0x01) if key == C! j% S3 B6 H' G2 R; i
  398.     return Mouse.press(0x02) if key == B
    / V6 x4 }6 S" B
  399.     return false9 L. Q+ z& @3 ?- h7 C9 W. K' i
  400.   end
    8 _4 S. d1 W$ Z4 I$ q  Q
  401.   #--------------------------------------------------------------------------
    3 p' Q5 Y; Q5 u; n& A
  402.   # ● 按键刚被按下则返回true0 r, M6 a; d: t# p3 p& v; u
  403.   #--------------------------------------------------------------------------
    # z# i, W5 v$ B; |& m5 Q
  404.   def trigger(key)" {. x7 O8 H8 Q9 R
  405.     return true if sion_mouse_trigger(key)  O0 B- ~& _" a; [' V, j" o" j
  406.     return Mouse.trigger(0x01) if key == C
    7 y5 g0 [7 T* Y4 A0 ~' \" R
  407.     return Mouse.trigger(0x02) if key == B
    7 a+ `3 s' P" q/ e  ^( e: Q$ R
  408.     return false
    ! U8 r  Z: X. k# w
  409.   end+ g# J8 U& F$ k' H* v3 P
  410.   #--------------------------------------------------------------------------8 o# {) f5 x  j
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true* x1 M  P, M& _& b# P
  412.   #--------------------------------------------------------------------------
    . s2 i# S1 j* H, B1 ~+ u- V; x
  413.   def repeat(key)
    0 m6 q5 \' T7 Y5 Z1 X% g
  414.     return true if sion_mouse_repeat(key)2 M2 {' J& i) _1 X! q# g
  415.     return Mouse.repeat(0x01) if key == C5 b$ i+ G6 Q+ q' W+ P) u
  416.     return Mouse.repeat(0x02) if key == B
    2 w1 _: B9 a+ M# p" D# ^  b
  417.     return false% j* O  a' v2 [- _
  418.   end$ K( d7 o7 r/ ?7 x: M4 [1 Q$ h! N) d
  419. end
    . L: c$ s7 P7 Z. m, a; q

  420. 6 \, s" w3 a# n4 @- |6 k
  421. ) R+ j- w) \6 m3 L
  422. #==============================================================================/ Q" m3 H7 R- K- N# q! h
  423. # ■ Window_Selectable
    3 \3 ]" T0 }4 B9 ^( f
  424. #------------------------------------------------------------------------------
    3 c3 |, R# Q9 W% I  {0 t8 `7 f& M
  425. #  拥有光标移动、滚动功能的窗口! g. R. S2 \' g2 ^
  426. #==============================================================================; s7 v5 z9 k, I1 C
  427. class Window_Selectable
    $ x' M4 |! }  M7 G: L
  428.   #--------------------------------------------------------------------------2 c  J' i% T* N+ q" Y+ S
  429.   # ● 初始化
    4 {- A6 l* d- B" L" `7 R/ T
  430.   #--------------------------------------------------------------------------
    ! F0 ?2 @% N! ~; X7 }1 H! }" t% E* z
  431.   alias sion_mouse_initialize initialize' ~, K6 _8 V- m2 \: Q- {  k
  432.   def initialize(x, y, width, height)" \$ b. e, m& ?% W0 ~
  433.     sion_mouse_initialize(x, y, width, height), K) o' B! `1 e* e! y. ]
  434.     @move_state = 0
    / \2 K/ }, R4 R3 s6 t) Z; C
  435.   end
    $ }5 V. g  w- T; L
  436.   #--------------------------------------------------------------------------
    ; ~1 C9 P+ V6 E% I
  437.   # ● 更新5 `( V- z6 J( H  }- X
  438.   #--------------------------------------------------------------------------. @/ V% w+ z% Q' X) J
  439.   alias sion_mouse_update update
    0 P+ ~# T  o# {7 D$ a
  440.   def update
    7 \! S% h: q0 y6 ?$ ^/ G; T
  441.     sion_mouse_update( c8 k8 \+ r0 m# c
  442.     update_mouse_cursor
    2 k, k! O5 D" g; i( J" V  n( S1 Q/ x
  443.   end: d$ v. \! E  |8 Q
  444.   #--------------------------------------------------------------------------
    3 Z4 B5 ?+ o( Q! G& y" d3 Q
  445.   # ● 启动后设置鼠标到index位置) r, N7 L% d" J" l9 ^
  446.   #--------------------------------------------------------------------------
    0 S& U6 l  K8 ^0 u5 L  L
  447.   def activate) D  \4 N# H2 m; N1 y9 l. Q
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    ( l5 j. l# w# _" C, l
  449.     super
    , S$ e/ h, j: j+ f6 o8 W6 I
  450.   end) |/ R5 _; l* b
  451.   #--------------------------------------------------------------------------
    . W" N# Q4 Z7 q4 A4 p
  452.   # ● 更新鼠标和光标的位置- M3 y4 }. F2 [3 ~( i7 X
  453.   #--------------------------------------------------------------------------
    5 t6 I/ E9 z- l% E9 }
  454.   def update_mouse_cursor
    5 V% a" _$ o, ?5 w
  455.     if active  ?: i( ~  \$ ]* e3 a2 e0 W9 o" J
  456.       if @need_set_pos
    ) c3 y, \1 J: K/ Y6 G% f
  457.         @need_set_pos = nil
    . Y* Q% m0 `. Z1 x( c7 q$ i
  458.         set_mouse_pos
    . T" R# i4 ^$ `% I7 B- ?
  459.       elsif cursor_movable
    3 Q+ Z- O3 Z9 t# x9 X4 u/ k
  460.         Input.dir4.zero  set_cursor  set_mouse_pos$ S* C; @" C$ g7 ^$ ]
  461.       end9 |2 y4 H7 l; q7 a& P- A
  462.     end" B# \% D* |7 @& Q6 A
  463.   end% U7 @9 T1 \; _6 D
  464.   #--------------------------------------------------------------------------7 Q0 z2 t+ d8 B
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能6 Z1 F; Y  C0 r' d) w
  466.   #--------------------------------------------------------------------------% ]1 y% S8 i& C5 D- V8 Z5 P1 r$ X
  467.   def set_cursor
    ; j1 E$ m* p( e/ \5 W
  468.     mouse_row, mouse_col = mouse_window_area
    & u1 T5 ~8 z0 V6 e# w; f" C
  469.     if    mouse_row == -1# ]* D$ z! q/ @, _. K# {
  470.       @move_state += 1 if need_scroll; h; g" \) y5 R+ r9 f
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand4 |$ Z" d4 C& P% ]  j9 l
  472.     elsif mouse_row == -2
    7 G2 a0 ?2 M7 R% Y0 [" P
  473.       @move_state += 1 if need_scroll  P! v/ \; p( Z: s. M8 R$ M
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand. m  d- Q/ {1 q1 |: Q7 N
  475.     elsif mouse_col == -1
    : _5 Z0 Z% B) h; L9 m. L* E
  476.       @move_state += 1 if need_scroll
    $ J3 e" ~6 d8 F
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand' u8 c7 u6 G4 j3 i: x
  478.     elsif mouse_col == -2
    " O% Z. c4 f7 b1 L  P- L5 E5 t
  479.       @move_state += 1 if need_scroll
    5 ?5 n, m+ V" H( |/ @0 R; L
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand. M: y* x8 p6 r9 P$ s' b/ \7 N4 K
  481.     else
    * z% o7 r7 }1 N5 r# j( j2 E
  482.       @move_state = 0
    7 k2 t) \$ e4 A: g
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    % d' ?( ^. U0 N& A3 l; K2 Q! c
  484.       select(new_index) if new_index  item_max && new_index != @index$ Q" \' W% Z6 Y2 V& J
  485.     end
    ; i) M3 Y' u5 x) C! P: J6 }
  486.   end
    - |! C- P6 O- [' ^) M% ]
  487.   #--------------------------------------------------------------------------
    7 \$ X5 {( F" b' r! s9 c
  488.   # ● 判断鼠标位于菜单的第几行、第几列; J1 P+ d" c& a* O( t
  489.   #--------------------------------------------------------------------------0 I: T1 V( e$ o- ?# K
  490.   def mouse_window_area
    ! @4 [# |( i4 G8 Y& B) x; f
  491.     if viewport.nil # necessary!
      t* r2 ]: g$ K4 n8 @
  492.       vp_x, vp_y = 0, 0. O" q: J7 g' Q" J8 t: v
  493.     else8 N% ~4 t& |. c
  494.       vp_x = viewport.rect.x - viewport.ox
    / D8 K) p) w% S% Y
  495.       vp_y = viewport.rect.y - viewport.oy
    , f- l7 w5 Z1 A6 I. t
  496.     end
    9 a) Q" s9 v0 J, W/ R' O
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ; `4 p* B, m3 d$ C3 b# j
  498.     item_x1 = vp_x + x + standard_padding
    8 |2 ?$ |) L8 j5 L3 M" n, K! L  g
  499.     item_y1 = vp_y + y + standard_padding1 S  b1 G& _1 G$ V9 w1 o) F
  500.     item_x2 = vp_x + x - standard_padding + width) i) y. T/ a9 p0 ^# w" Z0 l
  501.     item_y2 = vp_y + y - standard_padding + height
    ) z' v. c) k! V, \) L% R0 m
  502.     if mouse_x  item_x1* d0 T- d0 ^3 _! I: k5 k
  503.       mouse_col = -1
    , d- D' r! @# @0 \" ?: ?
  504.     elsif mouse_x  item_x2
    . a% _9 K8 k8 L' q
  505.       mouse_col = -2) B3 H! b$ z3 X, D# c: M  N& x/ g
  506.     else. i2 [1 I! y9 t# l) X, w2 h8 [; `7 @
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1), m. X  _9 {* Y& I! m3 q
  508.     end
    / H1 Z3 N9 o. z3 r2 ^1 d
  509.     if mouse_y  item_y1
    , F$ c3 b7 W% Y; Y4 Y$ _: \
  510.       mouse_row = -1
    ) R- K( X% w3 g* A+ v* P+ ^% q( n% l
  511.     elsif mouse_y  item_y2- h8 N1 A, ^* N1 P) J
  512.       mouse_row = -2
    $ L8 [( c! j. J. x! Q" m
  513.     else( o& Z/ ~' l' ?
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    5 z' g0 D: W9 T! P& R0 K) p
  515.     end
    : E% S# C; D4 R, a- x
  516.     return mouse_row, mouse_col) c# N6 `- P' s, i1 n
  517.   end, l+ C% D9 S2 @; d. f
  518.   #--------------------------------------------------------------------------* B0 ], |9 \% @$ P: b
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    + Y. r. [. F4 @! Z. ?/ e, F8 O; |# O
  520.   #--------------------------------------------------------------------------. x# Q# n9 |! ^  z7 _
  521.   def set_mouse_pos9 k7 E3 f3 J8 e# l3 N  X9 d
  522.     if viewport.nil # necessary!5 F- X+ D% p9 L5 s+ Q) k& d
  523.       vp_x, vp_y = 0, 0
    # l# y& L0 g" W0 d  F
  524.     else& k2 V; L: K; j' }$ T
  525.       vp_x = viewport.rect.x - viewport.ox
    . p' z+ D0 E7 ^/ Y. B) G
  526.       vp_y = viewport.rect.y - viewport.oy+ p4 ]5 r4 X+ n) L# m4 k
  527.     end0 n% K: U* Y7 W3 `
  528.     item_x1 = vp_x + x + standard_padding
    0 D/ z$ Q9 R; d3 n
  529.     item_y1 = vp_y + y + standard_padding, }1 h: o% i1 Z; d
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
      p' E1 Q! }& R9 n! w" g+ P3 |. r
  531.     row = get_index  col_max - top_row
    % M# |5 L- k* h9 N; h3 x
  532.     col = get_index % col_max
    3 T: f& ?" m2 n" ^, V
  533.     new_x = item_x1 + item_width  (col + 0.5)0 \/ O6 w/ ~: O
  534.     new_y = item_y1 + item_height  (row + 0.5)
    ! l$ N6 D) X# Y6 i8 K6 ^/ u% a7 g6 w
  535.     Mouse.set_mouse_pos(new_x, new_y)1 m; c3 X" V2 Z' P3 J
  536.   end
    + j( A( S4 L% E" _; b
  537.   #--------------------------------------------------------------------------% E0 `9 c: q9 k- Q9 S; s6 n; h
  538.   # ● 判断菜单是否需要卷动
    # h+ s. r1 R" `8 q4 l; r
  539.   #--------------------------------------------------------------------------8 ]) L- r' V2 D; s' Q' n7 l
  540.   def need_scroll
    ! F5 w( c+ q0 n" p" p$ ^. M
  541.     item_max  col_max  page_row_max! k7 G6 i0 D( @0 q% w) P
  542.   end
    % `5 l5 B' K- n( t
  543.   #--------------------------------------------------------------------------
    # T+ |* c; F# Z, p  N
  544.   # ● 判断是否为水平卷动菜单% l( l8 `3 _3 I# a: E# M
  545.   #--------------------------------------------------------------------------
    ) w, {$ a1 E0 c5 }0 O% D9 P$ f/ t
  546.   def is_horzcommand
    ( i8 k. b! y" L2 Y
  547.     return false
    6 {; x6 i2 U! V" b% j. e" s% f
  548.   end
    . b7 j. c: j- \& B8 R/ a6 {# t
  549. end; D: r" d3 K  V& m. k2 y/ K

  550. . p1 m. \2 [; O' n& V) v
  551. class Window_HorzCommand* a: O; X5 `' l
  552.   #--------------------------------------------------------------------------2 l& ?1 `" l' ~# U$ v5 Y
  553.   # ● 判断是否为水平卷动菜单
    % U; C7 a) G- @( h- T3 a& |. |
  554.   #--------------------------------------------------------------------------; X/ |" z# r. n5 U! F* K
  555.   def is_horzcommand
    6 W6 ?$ }4 W* p4 Y" Y
  556.     return true# ^* W2 c; ^2 @9 W. e" t( Z
  557.   end/ f& A3 h# D! N/ J) e
  558. end# h, f* ^+ f4 O( c, C% Q* u" K

  559. 9 n$ n) N, E4 g. n! u. |' H
  560. #==============================================================================
    % v1 y- w* Y# l
  561. # ■ Window_NameInput0 k! [. ?. r" }& s, m4 x  |
  562. #------------------------------------------------------------------------------
    # |) U3 S1 M! a: d
  563. #  名字输入画面中,选择文字的窗口。
    ) K" a1 ~6 ^  P4 V9 ?
  564. #==============================================================================
    1 ^6 o) I4 c7 M3 u3 ^; f
  565. class Window_NameInput
    / f: H5 G' `1 E% O. e1 j$ F1 L: @
  566.   #--------------------------------------------------------------------------
    ; Z& p$ h( n8 Q8 ~- t
  567.   # ● 设置列数
    5 d! Z. ]8 S  t3 n6 `% M; ~6 G% Q
  568.   #--------------------------------------------------------------------------
    1 ]2 G$ o' {7 {* r
  569.   def col_max) w5 |( @2 y1 u! f7 C- V+ k
  570.     return 10
    % {  l; {+ Q8 ~, j% x( \
  571.   end
    5 u5 s0 W6 Z' e& |+ X# a
  572.   #--------------------------------------------------------------------------
    % W2 e9 n2 F8 `8 @8 l9 H
  573.   # ● 设置填充的Item个数( {* a0 @; f4 `8 {8 m1 w! T
  574.   #--------------------------------------------------------------------------. x0 Z. j: ?3 ?
  575.   def item_max
    7 K, s. m* D8 M) N
  576.     return 90
    9 p; x. G1 u0 `* }
  577.   end
    0 b& h, q/ M6 C
  578.   #--------------------------------------------------------------------------8 s, {5 [, A% ?" U
  579.   # ● 设置填充的Item个数
    1 ^. r+ K! i- f. n+ P
  580.   #--------------------------------------------------------------------------
    5 @4 L7 @$ Q: F7 t8 Q/ h
  581.   def item_width
    6 C5 W' E7 E: Q  u/ v5 C' G; i
  582.     return 329 d* S7 R" }7 k4 F4 E% J- p
  583.   end8 x/ e6 e4 g$ N9 V% _+ I4 |  ~6 V- l
  584.   #--------------------------------------------------------------------------6 O) l- y7 _/ @8 w" G8 t
  585.   # ● 判断鼠标位于菜单的第几行、第几列% h1 ^! L: _0 `+ x* l
  586.   #--------------------------------------------------------------------------2 f: R: M. @- ^# e/ P+ P/ q
  587.   def mouse_window_area4 h. R' z$ M9 f% N' e7 |
  588.     if viewport.nil8 o, }3 I# |) J3 ]
  589.       vp_x, vp_y = 0, 0; Y; {# i) R' C1 T, e
  590.     else
    6 B( C+ w: b/ l
  591.       vp_x = viewport.rect.x - viewport.ox
    4 A, I4 g, Z  f- y7 t9 ]4 N
  592.       vp_y = viewport.rect.y - viewport.oy' \" k4 \: f( ^  H& G+ }' E
  593.     end, R+ |7 O' x1 f* w/ u4 Y0 c. l4 i
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ! r6 Z* @% i$ R2 C% l3 C
  595.     item_x1 = vp_x + x + standard_padding 6 n) n# u, z5 E( h% O% O
  596.     item_y1 = vp_y + y + standard_padding! F& N0 G9 h  A- I8 p, t
  597.     item_x2 = vp_x + x - standard_padding + width
    7 s$ c, o6 Y+ p$ G: F# W
  598.     item_y2 = vp_y + y - standard_padding + height/ ~. U5 U+ r) ]5 `1 x
  599.     if mouse_x  item_x1+ x; y# _/ r. S( b6 a  r% n
  600.       mouse_col = -1
    ) p: L  h& z" g4 q; d
  601.     elsif mouse_x  item_x2+ c* N9 H7 B% v2 \
  602.       mouse_col = -2
    9 w; l4 N6 \5 d5 n* O! A) s) i
  603.     elsif mouse_x  item_x1 + 1609 h7 A' U+ N& G3 X
  604.       mouse_col = (mouse_x - item_x1)32! d: C+ G* }% e' Q" r" n+ m
  605.     elsif mouse_x  item_x2 - 160$ I7 L: X. `4 [/ ^
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    8 o% e0 ^; k4 B3 F
  607.     else
    ' K2 c# }! S  j8 h8 ?8 u
  608.       mouse_col = mouse_x  x + width2  5  4
    - p" b/ o/ I' J/ a7 d. P9 K
  609.     end& W/ n5 O3 n# H8 I& a8 w
  610.     if mouse_y  item_y1$ @. ]! }1 s+ P: I: x: V
  611.       mouse_row = -19 D7 U* Z$ x, m1 s2 e
  612.     elsif mouse_y  item_y2
    " {3 a- t. |) Q
  613.       mouse_row = -2# [9 k  e' Y9 h5 _' A4 l" o4 X
  614.     else
    1 f! u! ]/ T% m2 a% X
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)/ I+ e; _; a0 R! B  J% k
  616.     end% A' y, D9 _9 \. L: W3 z
  617.     return mouse_row, mouse_col$ Y( N9 t7 {1 q1 ~( Q: ^
  618.   end
    " _! B' k0 s8 }) l5 A
  619.   #--------------------------------------------------------------------------
    # f4 \" l' ?1 M) v9 a
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    * Z& V& a9 U7 F. B" @& V% D) A6 t9 C
  621.   #--------------------------------------------------------------------------6 N8 ]8 h% Z% {
  622.   def set_mouse_pos4 E1 W8 t/ O7 a1 e' n
  623.     if viewport.nil # necessary!
    , B5 `  X7 d9 U: P! M! {
  624.       vp_x, vp_y = 0, 0
    , r7 G; w* r2 _7 i- x/ E
  625.     else9 ^! e1 ~$ ~0 l7 h# I
  626.       vp_x = viewport.rect.x - viewport.ox2 d( ^: L; n. \% U. K1 u7 ^
  627.       vp_y = viewport.rect.y - viewport.oy% m* j6 e- ^, D, @7 [$ p& V2 D  X9 x" {
  628.     end
    ) n( \3 u/ k6 t- W
  629.     item_x1 = vp_x + x + standard_padding
    $ l! G1 @) T  s4 _9 O
  630.     item_y1 = vp_y + y + standard_padding
    4 y8 s+ z( d7 o' [8 c
  631.     get_index = @index  0  0  @index ! |' [2 g5 L7 b' q
  632.     row = get_index  col_max - top_row) R9 d/ i, \4 i# R, x3 H
  633.     col = get_index % col_max
    5 y9 o5 n4 P3 Q
  634.     new_x = item_x1 + item_width  (col + 0.5)
    / b1 Y$ u6 K( g8 p3 O0 e2 G
  635.     new_y = item_y1 + item_height  (row + 0.5)
    + w5 d$ _- l: e4 u* R/ J
  636.     new_x += 14 if col  4
    ' o' G. L! q* g' L
  637.     Mouse.set_mouse_pos(new_x, new_y)# [" N! ?1 U, O, K/ b
  638.   end
    4 \7 D. C: [+ Z! n1 b3 }6 A
  639. end& f; o0 f$ z/ N7 X5 X* C1 k
  640. # n% A' {, \. R9 P7 N: u) x
  641. #==============================================================================
    ! L0 H) X' S: G
  642. # ■ Window_NumberInput0 j% T+ i+ G; A8 \; q
  643. #------------------------------------------------------------------------------& [2 U) @6 o; O1 o8 u% H% l
  644. #  重写了数值输入的方法以适应鼠标
    - \" F8 E8 q; G2 V1 c
  645. #==============================================================================9 i9 Q. S) T$ k7 h
  646. class Window_NumberInput  Window_Base
    ; d) f1 U2 X: p+ S) ~, N
  647.   #--------------------------------------------------------------------------
    % C/ z: W8 M0 U7 e# S
  648.   # ● 定义实例变量. x2 P9 i0 T$ l- D
  649.   #--------------------------------------------------------------------------
    5 r. g3 d/ |/ |. k" n; O
  650.   attr_reader extra_window$ d, X  W  F8 P8 y3 l- W
  651.   #--------------------------------------------------------------------------  v9 W6 i  K9 H- w4 c3 V
  652.   # ● 初始化2 q/ E$ k2 x1 p& L( o9 h9 w
  653.   #--------------------------------------------------------------------------
      ~7 m( w0 W8 v8 z2 a9 U$ n" j+ ^
  654.   alias sion_mouse_initialize initialize
      `5 A! ?0 s* h8 k. g
  655.   def initialize(arg)& k5 E6 Z  i% l) x% Y  ^: {
  656.     sion_mouse_initialize(arg)
    1 e+ `& M8 J1 N; ~# W
  657.     create_extra_window
    3 Y8 e+ N) h8 D6 U( L, ~
  658.   end
    9 x# b3 Y$ K& m3 g
  659.   #--------------------------------------------------------------------------! @) M; u9 d# Y7 q- y7 n1 @2 m; q
  660.   # ● 启动
    / a, |- `& y3 R7 n
  661.   #--------------------------------------------------------------------------
    ) F& C& o; h- @4 W, L5 F
  662.   alias sion_mouse_start start
    6 X1 |6 S! S: y+ a2 o# L
  663.   def start
    : h, r& V. t7 {+ e8 B7 b
  664.     sion_mouse_start
    2 o; V$ e: @: u* D+ ]
  665.     deactivate5 H* t2 [/ a* W8 _1 Y. Y0 v
  666.     extra_start% e- A  q2 p+ ~: f. m! G
  667.   end
    + I% G6 R! \& N  _" ^
  668.   #--------------------------------------------------------------------------+ S! i+ T9 [$ L2 l  ^. Y1 r
  669.   # ● 创建新的数值输入窗口
      ^' ~. `3 l! v: z
  670.   #--------------------------------------------------------------------------" R" @' S* j2 Q. J/ M6 U
  671.   def create_extra_window3 }3 C- A" v$ d/ e! ^+ x* ^# H
  672.     @extra_window = Window_NumberInput_Ex.new
      D! v! j$ a) H
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    + u6 S. Y( k4 |' L# v6 K6 j
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    ' p" M0 l; r5 r) P! S
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    , r% D2 Z5 F# Z' s: q: x) D
  676.     @extra_window.close_proc   = Proc.new { close }
    9 s; K2 P5 }  U: \1 M% X
  677.     @extra_window.refresh_proc = Proc.new { refresh }( P- u3 x- Y& D
  678.   end0 f( F8 ?- ^0 A. |/ y( ]/ P+ q
  679.   #--------------------------------------------------------------------------* n& x3 D* j! Y8 q
  680.   # ● 激活新窗口
    - W: H' \! n0 |4 y; `! x( u" ^
  681.   #--------------------------------------------------------------------------
    / I9 D4 X6 U  S  L4 ?3 }
  682.   def extra_start- O8 I' j$ c7 c3 ~% v
  683.     case $game_message.position9 ]5 d) M6 p: B7 K9 L$ {3 V) g
  684.       when 0; @extra_window.y = y + height + 4" g/ Y8 S2 x3 I3 z+ e$ `  [
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8  k& E5 z" U' j" L* \! k" P
  686.       when 2; @extra_window.y = y - @extra_window.height - 4: e, t5 }' X7 \' W% R
  687.       else  ; @extra_window.y = 86 W0 A0 Q4 y' H: v1 L# p  l
  688.     end2 R% Q* c, h# `
  689.     @extra_window.variable_id = $game_message.num_input_variable_id4 v- W/ w" q! a$ o: g! v
  690.     @extra_window.digits_max  = @digits_max) R# y1 w# B' B$ @2 t
  691.     @extra_window.number      = @number5 ]1 T9 n$ z1 ^& |! }6 J! d
  692.     @extra_window.open: j: A8 b" L5 s
  693.     @extra_window.activate
    , q$ f6 P2 l3 K; l
  694.   end4 M7 ~/ |% g$ {, O
  695.   #--------------------------------------------------------------------------
    - i* A) }" r" D+ F* E
  696.   # ● 更新0 ]0 x7 }' o; ~
  697.   #--------------------------------------------------------------------------+ w. g3 q5 ^9 I
  698.   def update+ d. V' z7 ?8 O: J5 A
  699.     super1 j/ G* Y' D9 ^
  700.     @extra_window.update
    - u- D' V% I$ X4 ?3 ]. f
  701.     update_cursor
    9 i7 b- d  q+ O3 R
  702.   end
    9 V  l. e1 ]5 W' U% h4 h
  703.   #--------------------------------------------------------------------------
    % E! r) u  }* O+ O
  704.   # ● 关闭窗口" W/ f: I" s7 ^/ O& Q# i4 z
  705.   #--------------------------------------------------------------------------( j) G$ M0 E) B$ q# A1 X6 z4 ]8 {6 ?
  706.   def close
    5 i' t9 j5 R" c% x1 f. `; d0 p; A
  707.     super
    0 O" s0 C/ n& b5 a. F
  708.     @extra_window.close* N( z2 K1 F8 T. y8 ^2 d
  709.     @extra_window.deactivate
    7 {% i3 j) ^/ h& r, G5 o, v8 w0 D
  710.   end) W* k3 E( p4 Z& I" h
  711. end
    ' l. r5 t; V% v2 E# t2 M

  712. $ `9 e7 @7 P) D- Q
  713. #==============================================================================; y7 z$ z4 p( p$ Q) [/ R+ \
  714. # ■ Window_NumberInput_Ex
    * \' [# `0 }/ D
  715. #------------------------------------------------------------------------------
    1 }# H. J" N9 `2 P, j0 c' d1 z
  716. #  新的数值输入窗口(NewClass). `3 j% _0 J) _) M3 f" z& g
  717. #==============================================================================
    : Y, h- F: s, q" z% L
  718. class Window_NumberInput_Ex  Window_Selectable
    . B! w* W. G+ }1 b
  719.   #--------------------------------------------------------------------------
    5 P) Q: }# Q8 |8 D
  720.   # ● 定义实例变量" r$ k" n* s3 j& b
  721.   #--------------------------------------------------------------------------) |7 r, V; `5 S. u
  722.   attr_accessor number_proc
    ( {% c0 A5 x; Y) F; j
  723.   attr_accessor index_proc
    & G0 ~# U# r; x$ {$ `! j
  724.   attr_accessor close_proc* t9 o$ A8 j* k/ o* a3 w7 }3 g, y
  725.   attr_accessor refresh_proc" s1 G, }( G, r( f6 f+ G. f
  726.   attr_accessor number- T5 r: J! m5 y: q
  727.   attr_accessor digits_max+ W2 x0 e" O; I" P2 m" o3 y
  728.   attr_accessor variable_id
    # }. O- q/ N/ ?( l/ K& h3 C4 ~: Z% A7 q7 _
  729.   #--------------------------------------------------------------------------4 P+ ^- V7 ~6 ~( O
  730.   # ● 数字表
    , w  J" _+ o8 L3 Q+ C
  731.   #--------------------------------------------------------------------------
    $ \1 [! D  d. H) k1 b7 F& |
  732.   TABLE = [  7,  8,  9,5 |# I' ^7 j9 `0 [/ D" w7 x
  733.              4,  5,  6,; K% {! N; o) J) }( W* V7 E  E
  734.              1,  2,  3,3 B- W8 i! u* X# ?4 l. ^# N
  735.             '←',0,'确定',]  p' J; S! @7 n% R0 a6 u
  736.   #--------------------------------------------------------------------------
    % g; Y; a- C( W6 d2 u; [! b
  737.   # ● 初始化对象3 ]% I9 H  ~$ x2 a! s# q
  738.   #--------------------------------------------------------------------------
    $ j5 O- ^3 {+ S1 ^" x. U: C! u2 `
  739.   def initialize# l0 G9 d7 S3 w1 H0 x/ m
  740.     super(0, 0, 120, fitting_height(4))
    ) I5 k6 u9 O& V; }
  741.     self.openness = 0& q/ {6 j4 t% ^2 w% P
  742.     @index = 08 z" |( ]3 @# e
  743.     @number = 02 \- ~. d+ d5 w( b, c
  744.     @old_window_index = 0) d) H1 e% P) T5 z
  745.     @digits_max = 0
    + ?7 x& h/ f2 d' E' I( j4 o
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }' y9 s, i, R; S: e0 J
  747.   end
    & Q3 _! @5 A/ s4 `- x5 k$ i1 H
  748.   #--------------------------------------------------------------------------
    2 R" e1 T! A2 [: n0 P* X$ O
  749.   # ● 获取项目的绘制矩形
    # l4 z5 Q) ^( _! Q) ?1 Q7 l
  750.   #--------------------------------------------------------------------------0 J- M! n' z8 h# q$ Q
  751.   def item_rect(index)
    7 h7 O! G& i( R# X9 N7 L! a
  752.     rect = Rect.new' b5 f% U; R# ^7 w
  753.     rect.x = index % 3  32: v. z! b* Y! d$ B
  754.     rect.y = index  3  line_height6 r* d3 P/ S3 i8 {! K1 n8 I6 \$ r1 \
  755.     rect.width = 320 o' W' r3 j4 s
  756.     rect.height = line_height
    : b0 w( R* L, g3 H0 f3 V
  757.     return rect3 d4 ]0 J% W7 M3 ]% n& p1 Z7 B
  758.   end
    5 N3 H/ X. ?  C0 e3 z2 Q
  759.   #--------------------------------------------------------------------------
    + J" l( r! P; W- d9 K
  760.   # ● 将光标设置到鼠标所在的位置) \: Q4 G- _. v: U& w7 ]+ K2 t0 Y
  761.   #--------------------------------------------------------------------------
    0 `- {1 G$ Z8 a7 b5 K, m
  762.   def set_cursor) a0 I  v. M3 w2 J+ }7 B- o
  763.     mouse_row, mouse_col = mouse_window_area
    ) u" }4 |1 K. R8 J$ {' p
  764.     if mouse_row = 0 && mouse_col = 0
    , H# K5 {6 `* E/ r* T7 _1 B9 E
  765.       new_index = mouse_row  3 + mouse_col; I& v" s, i/ y2 `  X$ l
  766.       select(new_index) if new_index = 111 h3 O$ k) h( ]. {+ r$ X
  767.     end) q5 m8 U2 s' r9 k' T3 t9 t( \) {
  768.   end: j. z: m& u% Y% j, P! N) S
  769.   #--------------------------------------------------------------------------
    $ ^* N6 z# N% S7 a
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    / N: }& \" e8 N4 ?" X
  771.   #--------------------------------------------------------------------------- k4 Y, r# |) \1 A- C
  772.   def mouse_window_area* O* i; @2 @; R" [5 C" I
  773.     if viewport.nil
    + w0 Q7 E9 a& F
  774.       vp_x, vp_y = 0, 0
    1 y( I( ^# \$ ?
  775.     else2 [0 i  f0 X. K0 q
  776.       vp_x = viewport.rect.x - viewport.ox0 U, r" Y: e& ^" Q& u
  777.       vp_y = viewport.rect.y - viewport.oy0 A  l& G7 G4 X  Z9 X+ h; W
  778.     end
    4 @+ Q, V% \1 D( z$ g- @( l$ ~( v
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y( _& [! [' X! Z% F: u
  780.     item_x1 = vp_x + x + standard_padding
    6 @3 `7 [* [5 w9 m1 T5 e
  781.     item_y1 = vp_y + y + standard_padding
    % T( e; D$ C/ n( ^5 l
  782.     item_x2 = vp_x + x - standard_padding + width6 n2 K. j  ~+ D+ k% T7 c
  783.     item_y2 = vp_y + y - standard_padding + height
    - w$ b' l. K  {4 C4 x3 b9 y! H6 w* V
  784.     if mouse_x  item_x1
    $ N( @- `: ?& @4 ?! M8 b- m2 z6 N1 U
  785.       mouse_col = -1
    2 M* L, A$ L& ?7 s
  786.     elsif mouse_x  item_x22 J9 H8 m- d  u! ^8 B0 W* i
  787.       mouse_col = -2
    ( `6 w1 O& ]3 n$ J/ r' F: u/ B; Y$ j
  788.     else: r5 K) b* x& z' e3 `% Q& Z3 `" k# _
  789.       mouse_col = (mouse_x - item_x1)  32
    1 H' J7 I+ M( p9 Q7 y0 G3 z
  790.     end
    ; @& @; G- x2 D* u5 u) T
  791.     if mouse_y  item_y1
    # G4 w# C$ F4 B, K4 m# ~
  792.       mouse_row = -1
    & t% m$ y4 M5 ?2 ?
  793.     elsif mouse_y  item_y2
    0 Z. Z) x* {2 D) w
  794.       mouse_row = -26 X0 \" v. P  ^  F3 D5 Z
  795.     else
    $ f7 w  E% K5 O) D/ Q: S0 U
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    : k7 J% c- K2 {- W& C2 i3 @; E. z/ n
  797.     end
    6 E( L- ^  k. X$ v( M& z1 o8 c) v
  798.     return mouse_row, mouse_col
    ) f) l/ C& F: {
  799.   end
      }* w4 h" ?! t+ }6 t4 m" x0 I/ j" O& h7 _
  800.   #--------------------------------------------------------------------------$ u) R3 r" }# p1 r# q9 g3 |
  801.   # ● 获取文字# Z5 S* g) v. N- W% n. c% u
  802.   #--------------------------------------------------------------------------
    6 ?0 ~+ L6 R7 R9 O9 t
  803.   def get_number
    . l8 j- h, K& G1 N+ X7 w+ o2 G
  804.     return false if @index == 9  @index == 11' d/ H9 a/ F, K1 n3 L2 ?
  805.     return TABLE[@index], N  e' x: R& V6 h% z
  806.   end
    ' l  w; f! s" e$ k1 T
  807.   #--------------------------------------------------------------------------# l: d, @0 E/ h) `' n1 X+ M2 z% s
  808.   # ● 判定光标位置是否在“退格”上$ D: W& X3 t( w7 c
  809.   #--------------------------------------------------------------------------
    , ~/ h+ @9 a% o
  810.   def is_delete
      h" o6 f5 z1 L( J+ V) J- O
  811.     @index == 99 U: G% x9 @! b) [0 u
  812.   end
    ; Y. i& f9 m( U* u
  813.   #--------------------------------------------------------------------------2 g* _6 ^0 i1 K% ]5 M' Q9 `) n
  814.   # ● 判定光标位置是否在“确定”上" u- ]3 ?7 M: `$ D# H. t7 V
  815.   #--------------------------------------------------------------------------
    - M) w9 f9 u  O# j8 z
  816.   def is_ok
    : |# r' d' \7 p2 o, w! D
  817.     @index == 11. M0 k) y' e" x" o2 u
  818.   end
    % w% B% ]8 V" a6 s
  819.   #--------------------------------------------------------------------------
    ! v, D6 P- }3 P& W' }/ N
  820.   # ● 更新光标$ u# B' v8 O* L6 Z' T
  821.   #--------------------------------------------------------------------------& Y# i, q6 D/ W  z1 v
  822.   def update_cursor
    5 \" [6 l& v8 [( z- i
  823.     cursor_rect.set(item_rect(@index))
    # G6 ]% G* @5 p
  824.   end
    , \( D4 K' i3 ]" s$ ~
  825.   #--------------------------------------------------------------------------5 O/ n6 g' X) @# X9 O7 x
  826.   # ● 判定光标是否可以移动
    5 B$ w- Z. Y+ u3 _6 j
  827.   #--------------------------------------------------------------------------% }. j9 q! m7 O. z, S3 g0 P
  828.   def cursor_movable
    8 ?: t) k, V' n  y8 T2 |
  829.     active
    # p0 O: ~2 |+ O0 V
  830.   end
    . _3 F7 y: p% u! C4 Y
  831.   #--------------------------------------------------------------------------. d/ u& Z5 |0 n$ k/ t1 F3 T
  832.   # ● 光标向下移动
    $ n4 V9 S5 C' e& W
  833.   #     wrap  允许循环5 j3 r# q6 T( f% U* }
  834.   #--------------------------------------------------------------------------
      }9 z  T0 U; _. \( V
  835.   def cursor_down(wrap)# N, M! _3 c/ B/ d: b3 I
  836.     if @index  9 or wrap
    . k& @- f% H  _3 a( e5 {" h
  837.       @index = (index + 3) % 12
    5 }" h' e) ~2 y  B% ~
  838.     end
    ! ~4 f9 w2 n2 }5 n$ X
  839.   end
    . J5 y' f& S) n3 r  s
  840.   #--------------------------------------------------------------------------+ @6 M! K1 G9 u, k7 f
  841.   # ● 光标向上移动
    . h$ d& U. r0 }0 D) l1 {
  842.   #     wrap  允许循环6 i6 Y: P; R' r
  843.   #--------------------------------------------------------------------------- R# N, x+ E+ r' `4 E- ^
  844.   def cursor_up(wrap)
    & Z3 I- U3 B. x
  845.     if @index = 3 or wrap: u2 e8 r8 ~. t1 U' a/ Z5 x+ o
  846.       @index = (index + 9) % 122 P; s) H% Y) |% n0 m8 k. W
  847.     end6 N6 e/ M' t( ~& m3 m1 E
  848.   end& D6 C1 S5 K& P; x" t- F
  849.   #--------------------------------------------------------------------------! S6 o1 l8 U+ Y3 h. f
  850.   # ● 光标向右移动+ d% f. v/ R$ `. c" ?9 o9 {2 w$ U
  851.   #     wrap  允许循环5 k- b8 _+ \, f" e' M
  852.   #--------------------------------------------------------------------------9 T  V5 o) e; j: \* t4 R) ^7 }
  853.   def cursor_right(wrap)
    ; H3 c0 K8 E; g9 j: j& X  r
  854.     if @index % 3  2
    $ f0 s6 t  n; W( \: `4 [7 v5 A
  855.       @index += 1- h: y9 }3 J: w% L' v, b" Z6 f* d
  856.     elsif wrap9 m! k- Z& l5 q! h  K: T/ q
  857.       @index -= 29 k. _1 z7 x9 e; k: `: `
  858.     end
    2 e7 C" t! O  P3 i
  859.   end' t, B' h- }0 A: |3 K" ]
  860.   #--------------------------------------------------------------------------2 u+ E; b* {' @! I
  861.   # ● 光标向左移动* C/ Q+ M) ^4 N/ O
  862.   #     wrap  允许循环
    # @8 e7 W! S( D- q! F: H. l
  863.   #--------------------------------------------------------------------------
    : M. B! {& _# }9 |& |7 @4 }: q  w
  864.   def cursor_left(wrap)
    3 f9 W7 I: T- w
  865.     if @index % 3  0
    , A% B0 Y; D  _! z+ i) n% \$ e
  866.       @index -= 1
    ; B' {6 t# _' N5 S% _% y) |
  867.     elsif wrap& S, W" b3 h0 N+ H! c) _9 n9 \
  868.       @index += 2
    ' N% X$ F6 k2 s5 H  R$ g4 k6 C
  869.     end
    5 I" d( G" d. y! j4 \
  870.   end& M2 V' ~# A' R4 `5 k2 g- E
  871.   #--------------------------------------------------------------------------
    * k8 B2 n8 c8 N, I1 p
  872.   # ● 处理光标的移动
    1 `6 _' `: @+ H9 T; U; x4 W5 q2 L) _
  873.   #--------------------------------------------------------------------------0 N$ H# c8 d- O+ S
  874.   def process_cursor_move
    & b: f& F; s5 h) \# |
  875.     super
    + g9 T. Y8 D* L% }6 E, u
  876.     update_cursor) t, {3 T! z6 b- I
  877.   end
    ; S; t3 N2 \, s6 [
  878.   #--------------------------------------------------------------------------& D5 q0 l2 {& @1 M0 n0 G9 R
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    : g; i! S& R" Y, t' D& v
  880.   #--------------------------------------------------------------------------
    ( J6 q' H* p7 Q! V7 a" [$ y2 B
  881.   def process_handling
    " B& V1 u. X# t' S! n2 t6 K
  882.     return unless open && active
    / q2 p0 R$ o9 L7 U6 z
  883.     process_jump if Input.trigger(A)  Y/ \$ `+ U% w1 l: b
  884.     process_back if Input.repeat(B)
    & o( _, M' Z( w. Z
  885.     process_ok   if Input.trigger(C): w4 I) b$ R, S
  886.   end! x" s% q& r' y# X4 E+ q
  887.   #--------------------------------------------------------------------------6 D5 k  r. U) j; S6 a6 P
  888.   # ● 跳转“确定”
    9 O$ B. x8 t/ |1 |; ^& ]6 L  H
  889.   #--------------------------------------------------------------------------
    - J  ]' [' J, i- [3 e- d
  890.   def process_jump
    " I- |2 X( h9 @  m1 h* l
  891.     if @index != 11  W3 k' S  b0 ^9 I
  892.       @index = 11! c+ Y! O# ?; S- ^7 \: V
  893.       Sound.play_cursor
    $ g' m3 e4 N* K
  894.     end
      E/ W5 q* u; o$ r
  895.   end
    * t. l3 E# I* {! C2 V
  896.   #--------------------------------------------------------------------------
    - ]3 M( w$ \1 Z+ \% u8 F
  897.   # ● 后退一个字符
    . V' p. j& G2 d
  898.   #--------------------------------------------------------------------------
    ; h* E+ H+ C& T/ B" h  b
  899.   def process_back1 `. j7 k0 K; c: \; z' z
  900.     Sound.play_cancel/ z, z0 k: d; h8 g3 N5 y" ]
  901.     place = 10  (@digits_max - 1 - @old_window_index)% y+ M7 P4 J, N; Y
  902.     n = (@number  place) % 10
    ) J  D( P6 _8 S2 Q& o
  903.     @number -= n  place
    : x3 L' E. D# W/ K* r
  904.     @number_proc.call(@number)1 ?6 v1 K& F$ o# H/ E
  905.     @old_window_index -= 1 if @old_window_index  0- O6 S( Y+ l+ R( t! o! L, P3 o9 Z
  906.     @index_proc.call(@old_window_index)
    $ p! v# p2 i2 b
  907.     @refresh_proc.call1 D; P" w2 @1 U& ?- }
  908.   end, l9 S- s( n: u( \- D% ^0 g2 ^
  909.   #--------------------------------------------------------------------------" I: m1 w; H; Z) A2 ?
  910.   # ● 按下确定键时的处理& E6 ^* o+ V" C6 ?
  911.   #--------------------------------------------------------------------------7 H% h: P8 Q0 A3 H" K4 p
  912.   def process_ok
    & X: Q& z( X$ s7 H9 }9 G9 N
  913.     if get_number9 ~! e2 M8 m$ H. l2 Q
  914.       Sound.play_cursor" Z& L% {4 k# W6 W6 T) I6 Y& D
  915.       place = 10  (@digits_max - 1 - @old_window_index)5 P& |2 O3 X6 V6 t# H$ f" W
  916.       n = get_number - (@number  place) % 10
    / ~  c. t/ V- W) p7 L, Q: a9 v
  917.       @number += n  place
      G* j4 w0 i5 ~/ P
  918.       @number_proc.call(@number)
    ( c, @, l; V0 `: I' v' P0 D! ^
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1: S! Q7 R5 ]1 b% g, l
  920.       @index_proc.call(@old_window_index)$ u# x5 v4 M/ d% h
  921.       @refresh_proc.call) \" T. N1 P4 V) \/ I) \, G
  922.     elsif is_delete
    * V) v( l6 b6 ~, _! W) s
  923.       process_back3 H8 y, p, f  |3 y& i4 w
  924.     elsif is_ok
    3 x' q5 C" j* s; @0 R
  925.       on_input_ok
    % ]& a6 n3 A% u5 T' ?
  926.     end* y* V4 P# N/ B8 L
  927.   end
    & a% ?: x$ c- M: a" [/ x. H
  928.   #--------------------------------------------------------------------------
      m: j) J' |, j0 q: f) b' ]
  929.   # ● 确定
    " f, }& \  u) f6 c( x
  930.   #--------------------------------------------------------------------------6 e8 m, W7 u0 H( ]
  931.   def on_input_ok
    7 \) @: u' a9 `8 k" I) H/ |
  932.     @index = 0: C9 Z% ?$ |6 Z
  933.     @old_window_index = 0
    1 z0 U( b9 M1 t+ n+ A
  934.     $game_variables[@variable_id] = @number4 f; s  R% L- N% w% X7 W
  935.     Sound.play_ok
    # t; j5 L! y/ D, r9 l2 n+ b
  936.     @close_proc.call7 e9 M1 i+ N1 z9 X" E) T! P" Q; v
  937.   end$ C' \- J" t. m% L9 P$ q3 h
  938.   #--------------------------------------------------------------------------8 x! e; j# g" t) d
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置  g5 ?( X  {$ G4 V% m. h  Z
  940.   #--------------------------------------------------------------------------
    : A6 k* L- c& x! r* l! g* b
  941.   def set_mouse_pos# |  C7 J- A0 j# x% E0 i8 ^
  942.     if viewport.nil # necessary!
    : U+ A6 j: m& g+ `3 i
  943.       vp_x, vp_y = 0, 0
    6 k" t: u, i" J' a: a, b
  944.     else) V, k( q) L. J, ?" j/ }4 R+ x/ ~. B
  945.       vp_x = viewport.rect.x - viewport.ox2 }- K4 v& }4 m! _; H
  946.       vp_y = viewport.rect.y - viewport.oy
    2 U7 z0 }. W3 R  X5 \) o6 ?1 g' ?
  947.     end
    9 h* j; Q$ [, z) b& V  p" @
  948.     item_x1 = vp_x + x + standard_padding
    " o7 V& R5 i# J
  949.     item_y1 = vp_y + y + standard_padding
    3 W; t7 d* F; |- J. O' b
  950.     get_index = @index  0  0  @index
    9 }6 [1 f4 [/ \" j% U
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)' l/ U6 m9 @% M) D% f" e9 {6 S
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)$ ]; J! C( a( h/ B0 n% U4 f
  953.     Mouse.set_mouse_pos(new_x, new_y)
    7 Q: M! b4 ^$ S# r% Y
  954.   end
    ' J$ ~! `$ ]/ G7 s! c" R
  955. end5 T- a1 i  X# L6 Z3 u& f

  956. ! u2 r4 Q" ^' d7 c
  957. #==============================================================================
      V* a+ U2 j3 }! M) P
  958. # ■ Window_Message- d; ?) e7 H; L, L2 ^: ?
  959. #------------------------------------------------------------------------------/ U! e" U% O8 c9 A! o% A! G/ d
  960. #  显示文字信息的窗口。
    ' V8 _/ d: B  \) s4 G: U# U
  961. #==============================================================================
    ! p) \  H  p0 }+ J& m7 e
  962. class Window_Message  Window_Base
    # b) J4 |+ G! D! f* h7 i% _
  963.   #--------------------------------------------------------------------------
    0 f, ^& i- G9 M
  964.   # ● 处理数值的输入(覆盖原方法)
    ( Q$ _3 S! D' c. l1 i# D( T
  965.   #--------------------------------------------------------------------------6 W' w: }( J( b' ^" o7 l
  966.   def input_number
    / v: r7 {! H% Q- w/ T* g
  967.     @number_window.start2 Z) j: }3 M! E  w7 i
  968.     Fiber.yield while @number_window.extra_window.active
    3 @( O2 i1 L* p7 W
  969.   end
    ; K0 x! p0 X# e, o
  970. end# c9 c: g; M3 K4 h& B5 c6 m  V

  971. * \- J6 W6 O8 S, S4 J4 L: w( x
  972. #==============================================================================- R5 X& \- H1 w- L- P
  973. # ■ Window_PartyCommand5 ~3 C0 a/ n! G+ v6 {
  974. #------------------------------------------------------------------------------
    - Y! |$ y2 K+ R6 ~
  975. #  战斗画面中,选择“战斗/撤退”的窗口。1 A6 D1 Q" Q0 e8 y; }" F
  976. #==============================================================================
    8 K/ G' o, S- M: F$ k
  977. class Window_PartyCommand  Window_Command; I$ p) f* {$ W$ Z
  978.   #--------------------------------------------------------------------------
    3 h: U" a( k3 ^3 O9 [& l
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置: m: x8 v1 g" C6 @" r7 V
  980.   #--------------------------------------------------------------------------
    8 ]% k& _1 z8 d4 e( E
  981.   def set_mouse_pos! B+ Z( i+ T- \. z7 ]$ O6 o
  982.     if viewport.nil
    9 W+ @% {( }" L3 _
  983.       vp_x, vp_y = 0, 0
    6 V, @  H6 A# {7 f$ e+ Z/ e9 L
  984.     else9 I! \# r7 c( [! [
  985.       #vp_x = viewport.rect.x - viewport.ox6 e" n2 v2 `2 s8 w  Z/ W* i
  986.       vp_y = viewport.rect.y - viewport.oy
    9 ?* d  y' b& ?) z, w9 q2 v' t% t
  987.     end! ]2 C7 B3 ^# ~4 _# k
  988.     item_x1 = x + standard_padding ' H) s% h- q& o; S+ ^* Z( ~
  989.     item_y1 = vp_y + y + standard_padding5 p! S) u7 ^: |
  990.     get_index = @index  0  0  @index
    8 y9 H% A9 Y/ A( }0 M: ^
  991.     row = get_index  col_max - top_row* z% A5 y6 u7 Z2 Q
  992.     col = get_index % col_max8 E# j7 F9 H2 ?- A7 U, g% {( ?$ O
  993.     new_x = item_x1 + item_width  (col + 0.5)" P9 j' g) l7 v( |* x$ X
  994.     new_y = item_y1 + item_height  (row + 0.5)
    * f, K* P$ d# I
  995.     Mouse.set_mouse_pos(new_x, new_y)
    9 a2 w7 k( i# Q
  996.   end+ J5 r8 U6 W2 T- t% i* ^% w" X
  997. end6 T4 h  U8 W% [/ y0 }5 Z& i3 d

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

  2145. , C* P  j, b# ~4 \* H, P
  2146. #==============================================================================1 W0 g! |" x3 ^- E$ `3 V$ `2 A
  2147. # ■ Game_Map6 U! }& V4 W$ u; B
  2148. #------------------------------------------------------------------------------8 }9 ?+ p9 G) Y8 h
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。: u" m9 v) h) |+ K0 }: \
  2150. #   本类的实例请参考 $game_map 。
    $ k: b; e1 y1 K( Q0 g8 U
  2151. #==============================================================================0 B% m/ ^' Y0 w! ^$ s$ W* U
  2152. class Game_Map2 i* V9 S* G: o+ t
  2153.   #--------------------------------------------------------------------------
    ; A5 U$ a  s, l: K* P
  2154.   # ● 定义实例变量. u/ a) h! o  N7 `  f
  2155.   #--------------------------------------------------------------------------
    7 r" [6 D1 J/ |0 I# u: ~' T+ {$ f
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
    * K9 J( D# w4 L9 |
  2157.   attr_reader mouse_map_y # 同上, \6 a4 G8 e+ S0 T, \
  2158.   #--------------------------------------------------------------------------) ^' r  q5 a, m1 @( x9 [
  2159.   # ● 初始化对象8 E: \% r' {1 _5 \* @. Q& R
  2160.   #--------------------------------------------------------------------------; O( X8 `" c/ L) l5 s2 g3 g
  2161.   alias sion_mouse_initialize initialize: B1 R6 n: b' J) u. a- U2 _( x% q
  2162.   def initialize
    * Z& J5 t9 t% ?! }/ w
  2163.     sion_mouse_initialize9 I6 w; `/ _4 b5 M- \/ _4 i/ R
  2164.     creat_move_sign  ###
    + E9 ]( b4 Q, O( S/ Y
  2165.     set_constants! j0 Z/ C7 |' l1 n$ x, X( S+ v0 c
  2166.   end
    ! @! T, w6 W( c/ R
  2167.   #--------------------------------------------------------------------------# |: @- B2 [% G& d# W
  2168.   # ● 更新画面- N. Z! j6 e; t( m' |! _! P6 L
  2169.   #     main  事件解释器更新的标志
    ' x5 @6 |2 S3 i2 S8 a/ {  Q  q2 g! J
  2170.   #--------------------------------------------------------------------------
    & ]/ b0 _: G' U, c7 Z
  2171.   alias sion_mouse_update update
    ; @8 W6 s  \% I- B
  2172.   def update(main = false)$ z2 K. {* }  V1 r
  2173.     sion_mouse_update(main)2 S! n1 n+ K& i% e
  2174.     update_move_sign
    " J6 g+ l- C) e# v
  2175.   end( H% v' h, P) D
  2176.   #--------------------------------------------------------------------------/ e( Q/ ?1 V" O
  2177.   # ● 创建显示路径点的事件; E- _2 C, |8 p
  2178.   #--------------------------------------------------------------------------5 v6 q8 d) f1 h" V
  2179.   def creat_move_sign, ]* Q7 z1 ~: ~% o; w) K8 [
  2180.     $mouse_move_sign = Move_Sign.new
    ' C* ~. e0 S' r( z( ?7 _
  2181.   end) n/ x* I( r8 D9 h" a0 E% e8 O
  2182.   #--------------------------------------------------------------------------
    % |8 p' A1 H5 f6 ?2 y) a- L  U1 N& ~5 `
  2183.   # ● 更新显示路径点的事件
    " l3 n9 f& f3 D9 Y) k( i
  2184.   #--------------------------------------------------------------------------: D# T6 m! h0 X$ b" L" y6 V
  2185.   def set_constants0 z: i" S2 k. y, n& b8 ]3 n0 g
  2186.     @mouse_pos_setted = true
    " x: {' R" K* ?9 H% w
  2187.     @set_pos_prepared = false6 A: X, O  o; {( \% N
  2188.     @mouse_old_x = 0
    ' p4 j7 T& X* v( X9 G% [
  2189.     @mouse_old_y = 0
    % ~) n5 {" _3 P8 h
  2190.   end2 O2 N; b  U& r: w+ N) c. x" \
  2191.   #--------------------------------------------------------------------------! f3 n! H* u* t! D1 x$ ^
  2192.   # ● 更新显示路径点的事件$ K% b$ q: ^3 k" h( n
  2193.   #--------------------------------------------------------------------------
    & u. e1 L9 T5 l( R, E
  2194.   def update_move_sign' O+ E- ]7 ]* ~
  2195.     $mouse_move_sign.update
    + o3 z; C, ?+ j; m2 _+ D
  2196.   end
    3 Y+ a0 X8 X! D# \4 |$ G
  2197.   #--------------------------------------------------------------------------
    % b0 c& {* e, ?) E3 \
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    % D- p" m' X9 I, O! Q; K
  2199.   #--------------------------------------------------------------------------1 [( m9 F5 t0 W' u
  2200.   def get_mouse_map_xy* ^. y3 D* W2 q  A6 G
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y. q9 U8 \5 I& Q: f- p# g# J$ \
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    # @( W4 Y' ~6 q8 Z$ Q2 q" M" r
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)/ G1 s  f' L- ?9 t6 r2 i
  2204.   end
    8 u, A0 j; {/ _  a+ T' {
  2205.   #--------------------------------------------------------------------------+ l& P0 d! T% L) Y
  2206.   # ● 返回地图画面时重设鼠标坐标
    ; p. X9 D2 ~4 P, x  g. ~9 {: K$ k
  2207.   #--------------------------------------------------------------------------
    $ d, l; s& w* Z  d1 V' g' z
  2208.   def reset_mouse_pos& Z# `. h- E0 L! z
  2209.     return if @mouse_pos_setted
    2 @: K* r- w; E5 u
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
    0 h1 I  @" `; _& V+ b
  2211.     @mouse_pos_setted = true
    : d( B; i2 e. d; ^. j4 N  H, O
  2212.     @set_pos_prepared = false4 {) I3 ~: A/ \5 d. W
  2213.   end! @# x4 b7 I/ K0 q
  2214.   #--------------------------------------------------------------------------8 {) d! ?( J, _' X; |2 |5 N
  2215.   # ● 重设鼠标的坐标
    + l6 d9 x4 u3 m- r  _
  2216.   #--------------------------------------------------------------------------
    ! F6 c& T9 ]# a- b
  2217.   def prepare_reset_mouse_pos
    5 k* u  P( {, ~- _: z9 w/ Y  A
  2218.     return if @set_pos_prepared, L$ u' K# H- ]) i* x) S6 P
  2219.     @mouse_pos_setted = false
    # b" \( p, R2 B& N2 h  S. J
  2220.     @mouse_old_x = Mouse.mouse_x3 {( k/ \  v( E# b9 R# N7 w3 D
  2221.     @mouse_old_y = Mouse.mouse_y
    0 J& e( ^5 O; ?
  2222.     @set_pos_prepared = true, S; w2 P+ T/ A. @$ t
  2223.   end0 B+ r0 l: n7 E
  2224. end! R, x, r: x) j. b0 p
  2225. & [: `% Y* j' ~0 B' c
  2226. #==============================================================================! d! |& y, f9 p) t% W0 N
  2227. # ■ Spriteset_Map
    3 L. ^- b/ e3 U! f* `* p& g
  2228. #------------------------------------------------------------------------------
    9 w% u8 D0 i$ D( P# O: V
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    ; j" v% Z7 X' i; H1 Y6 M
  2230. #==============================================================================
    % F! ]6 I8 N( P/ D' B/ Y' L
  2231. class Spriteset_Map1 t6 R- x- z5 ~  w
  2232.   #--------------------------------------------------------------------------8 x+ t7 q# _( K6 W+ A
  2233.   # ● 生成路径点精灵
    : q$ f' a6 k2 b0 \  S# r4 f8 ?, \
  2234.   #--------------------------------------------------------------------------
    ! D7 J* l$ \5 p- ?7 O
  2235.   alias sion_mouse_create_characters create_characters5 Q% r. j; a+ w! \5 \2 \  p  f
  2236.   def create_characters- y4 Y- \" J% V0 a* {
  2237.     sion_mouse_create_characters* ~; N! L' `9 F; ~
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    # a/ E* o$ n. N% x/ @8 `. W) `3 I6 ]
  2239.   end: ^2 K& C& v/ P. E
  2240. end
    : y: n/ T  F9 X
  2241. % ?4 t1 H( @! X! {
  2242. #==============================================================================% F( b/ g  w9 \4 f# N9 N( R
  2243. # ■ Scene_Map" e9 l* ~- u3 M
  2244. #------------------------------------------------------------------------------2 z: B& f4 C. V1 K
  2245. #  地图画面
    9 B/ T) c6 E7 L  e/ q
  2246. #==============================================================================
    % V2 r# t, j" _5 j/ n
  2247. class Scene_Map  Scene_Base
    + J* w0 u* n7 A% y- c7 T* @
  2248.   #--------------------------------------------------------------------------
    ' J, x! l8 z1 V& H
  2249.   # ● 画面更新) g( }7 B# i6 ?
  2250.   #--------------------------------------------------------------------------# y" v7 A6 H0 T6 ~, ^+ w9 A
  2251.   alias sion_mouse_update_scene update_scene+ u& u) t- j: g" N
  2252.   def update_scene$ I2 U" ]1 B8 ?! _4 Z/ A
  2253.     sion_mouse_update_scene0 o3 l0 g$ c/ r$ ~7 b6 q5 B
  2254.     update_mouse_action unless scene_changing
    ' H. y& r. q4 u! u
  2255.   end# w/ D5 q* ]4 J8 H" `
  2256.   #--------------------------------------------------------------------------
    ' ^3 E" w" G% `* i) V- c; Y
  2257.   # ● 场所移动前的处理
    8 `, L" y- A' |+ i6 a  L! z
  2258.   #--------------------------------------------------------------------------; ]# j2 X" q: Y) s
  2259.   alias sion_mouse_pre_transfer pre_transfer
    0 `' i% R. r3 v$ @
  2260.   def pre_transfer
    , R2 {8 t* n& v% Y4 S+ f: P/ }/ x
  2261.     $game_player.reset_move_path) K9 }6 V2 w# C; a1 A, c
  2262.     sion_mouse_pre_transfer0 D" c* x8 Q& y- q  h& K
  2263.   end
    : E# A( W2 M& ^- S4 v8 h
  2264.   #--------------------------------------------------------------------------! Y! y1 `( W* K5 V3 l7 x  f
  2265.   # ● 监听鼠标左键的按下* f# n1 c- x( C7 \6 K
  2266.   #--------------------------------------------------------------------------
    8 r. Y* u# Q7 V& w. |
  2267.   def update_mouse_action
    " N; S+ B5 m4 b. k& Y
  2268.     $game_player.left_button_action if Mouse.press(0x01)0 ]  H$ w7 W; p
  2269.   end
    " N! d, S( Y6 Z
  2270. end  l" `7 k4 K* p# |

  2271. ' Z+ t% e2 V0 K' V+ u1 ]: K
  2272. #==============================================================================7 `/ `% F! f; }9 c+ R, s
  2273. # ■ Scene_File! |4 s' d/ A" J6 L- x
  2274. #------------------------------------------------------------------------------
    % V6 ^! r" ~6 G, W( M2 Z, J
  2275. #  存档画面和读档画面共同的父类
    9 k% o" K7 ?" z. R( s
  2276. #==============================================================================
    1 ]- l9 {5 N' I/ [# j' W
  2277. class Scene_File  Scene_MenuBase& v8 q5 [# b' t; X0 q
  2278.   #--------------------------------------------------------------------------
    8 W  w8 Z4 H4 e' y9 p3 E+ r
  2279.   # ● 开始处理
    ' D3 \8 p: w- j# L# R$ }
  2280.   #--------------------------------------------------------------------------8 ~6 E# Y( \# g/ |, g3 Q( v
  2281.   alias sion_mouse_start start* V7 g) U9 E0 e6 v* N
  2282.   def start  @( M4 Q7 U0 T/ A) v
  2283.     sion_mouse_start. q7 n: @3 ?3 r4 C
  2284.     @move_state = 0- G" T0 R3 T& }- O. H
  2285.     set_mouse_pos8 C2 `' h3 d* w: X
  2286.   end2 B- S3 s0 V$ I% ~" {
  2287.   #--------------------------------------------------------------------------1 j2 q" A( n1 W
  2288.   # ● 更新画面
    4 ?7 i" q3 M" @
  2289.   #--------------------------------------------------------------------------" j* I) l4 ~: U+ @" Y2 P2 ?
  2290.   alias sion_mouse_update update
    & W' i: b! a) O+ n3 n
  2291.   def update! [1 z/ h. f% B& X: t0 I. C
  2292.     sion_mouse_update& u) g1 ~/ e  U
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos+ s. [) ?6 }- A/ N/ k2 g
  2294.   end
    ( R7 e4 _# A: p' A- t& A/ b9 b
  2295.   #--------------------------------------------------------------------------
    9 [5 q2 D0 c' e) v- N
  2296.   # ● 更新光标
    / A' u! B& V7 ^, j: H: V
  2297.   #--------------------------------------------------------------------------
    8 I' E- l3 X# @0 L1 ~3 z
  2298.   def set_cursor/ u' U; f6 F) k* r1 k0 P
  2299.     @move_state += 17 z$ U  p) b& a" [. g. ?
  2300.     last_index = @index
    9 ]8 J  m3 f+ Y2 A- h) z2 z
  2301.     if mouse_which_window == -2- e6 @7 y3 C* S3 L& `
  2302.       if (@move_state - 1) % 6 == 0  o- I6 g3 I3 E3 g0 ?: H' D
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1  h1 l( q% F/ l" E! m5 V
  2304.       end
    ( l/ D9 C( V* u! K" b; {* G
  2305.     elsif mouse_which_window == -1
    ( [) k) T! W1 {; u- z
  2306.       if (@move_state - 1) % 6 == 06 T( }3 S" }( y4 T, M4 N" N
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0/ u( x2 ~8 \3 a1 j; i$ j/ \
  2308.       end
    ' ~; a* Y8 s1 O) N
  2309.     else
      l% d( w+ t9 ^' a# X5 u* p5 W
  2310.       @move_state = 06 D/ \* N9 d2 c: R# a. L1 g
  2311.       @index = top_index + mouse_which_window
    9 s0 z  h" w& P$ O+ M  ?% I
  2312.     end; d1 O3 N% u6 g7 n( H( }9 i: s" t
  2313.     ensure_cursor_visible
    . }# i4 i2 Q+ b  P' l
  2314.     if @index != last_index  Y( W5 ]# G8 J$ Y% |/ E
  2315.       @savefile_windows[last_index].selected = false
    , b. y% C4 p. Y- z2 y/ H$ J
  2316.       @savefile_windows[@index].selected = true
    4 Q: L# J/ ^8 @7 ^6 i
  2317.     end
    6 ^/ H% i! d0 I8 o& H3 O
  2318.   end
    1 C' X  _' H" E; n7 m+ q9 ]
  2319.   #--------------------------------------------------------------------------" K( x: w" E9 {. v$ N2 w5 R( ?# W2 S
  2320.   # ● 判断鼠标位于哪个窗口" q. E0 J) ~0 t2 X7 ^: P
  2321.   #--------------------------------------------------------------------------
    ' Y$ v, {6 m5 ~
  2322.   def mouse_which_window
    + |) P5 y% J% T5 @& r. Y; C( {, O, W
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    # v# j3 d* O6 V+ f7 l3 v$ N! b5 S7 `
  2324.     if mouse_y  @help_window.height + 14
    - W1 B- _1 o1 E
  2325.       mouse_row = -1/ T. n9 Q3 N7 S: |4 d2 W" U
  2326.     elsif mouse_y  Graphics.height - 14
    ( x; O2 ^( n* S3 a# E  V
  2327.       mouse_row = -2" z/ O; `( h, c! A. r4 D
  2328.     else
    ) M* x+ g" I9 q
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    / V# F3 Z; j3 y  W
  2330.         (Graphics.height - @help_window.height)3 a4 H/ l0 T# M5 U9 E9 `9 Z
  2331.     end
    " }) r) I. ^. Y, F$ L2 I. o) e- l
  2332.     return mouse_row+ K6 k+ |: ~0 D
  2333.   end
    : j' X. t8 `8 Y/ q3 z
  2334.   #--------------------------------------------------------------------------
    0 l) J6 k: ]# @3 ^  }2 s
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    6 m5 n2 \  j# m  X- Q* I# B+ T
  2336.   #--------------------------------------------------------------------------% L0 t8 ~& I5 s, N
  2337.   def set_mouse_pos9 C" l# |2 e, R6 L
  2338.     new_x = 401 G3 f9 v/ i! A8 f
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    . n- w9 ]( w9 X) |. m5 \) _
  2340.     Mouse.set_mouse_pos(new_x, new_y)" M3 C7 _3 L4 |5 i$ H8 {
  2341.   end; e1 b: E  i7 o# }$ j8 [
  2342. end
    ( c% T) G9 J" d2 D: @6 q& `

  2343. " O# o  W! c* I3 X1 w0 C! J7 f, t! i, G' W
  2344. #==============================================================================
    * A4 y7 U! ]$ C5 E, `7 O
  2345. # ■ Game_Event
    , J! o1 V, r  x" k
  2346. #------------------------------------------------------------------------------
    . d% }& \, \) E+ {) ~0 f4 E6 _
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。& u1 [% V* t5 _& p8 O. O
  2348. #   在 Game_Map 类的内部使用。
    % M. K; W* J  W+ H  x3 T( @+ I& F
  2349. #==============================================================================
    : Z# D1 _' ^5 U) m' {
  2350. class Game_Event  Game_Character& F; M: J/ @% S  E, U  a8 d  K
  2351.   #--------------------------------------------------------------------------4 d- f5 g4 s3 s3 O# i6 B( ^
  2352.   # ● 事件启动
    + U( k$ {$ H; `- W% m% y( L4 R$ T
  2353.   #--------------------------------------------------------------------------+ T$ ~9 O& C) \7 l- f* _! x
  2354.   alias sion_mouse_start start
    7 G3 f2 P, m- k7 p" h3 e# w& T0 _
  2355.   def start4 c0 i4 q( Y) G
  2356.     return if mouse_start && !Mouse.press(0x01); _3 `! c: X9 W0 D  n) e
  2357.     sion_mouse_start
    - @, p) f7 q) E9 {* D" ?
  2358.   end+ l9 h3 L0 ~4 d/ C) y) T  {! h8 ?' q
  2359.   #--------------------------------------------------------------------------6 G3 h' n6 M: ?4 d9 H* Z6 n
  2360.   # ● 判断事件是否由鼠标启动
    # c9 V9 `7 N1 `$ w+ o4 B8 w4 A9 f
  2361.   #--------------------------------------------------------------------------
    5 ]$ U) k4 v, l/ h% k2 V# w- ]9 V1 |
  2362.   def mouse_start- H" K2 ]+ c- r5 W* X. v) k
  2363.     return false if empty
    % }: s, E) @2 E2 M8 i. l! _, G! v: F
  2364.     @list.each do index. V: S& z2 i# G- a
  2365.       return true if (index.code == 108  index.code == 408) &&
    * l$ \9 [3 u5 c4 i( W5 P# P: V
  2366.         index.parameters[0].include('鼠标启动')) H& z$ A  l# m
  2367.     end9 k; z8 r/ K1 u: D0 _6 k1 d
  2368.     return false
    ! ^  }8 O3 M' J9 Z8 U. r2 t" _
  2369.   end
    , w* P: y$ A" T! y+ z2 v' v5 f
  2370. end' R5 [$ A9 E& k+ T- P/ [8 A! E
  2371. & `* R* \$ N/ V' m
  2372. ####泥煤的height7 o: ^6 e+ @( o: \/ x3 q
  2373. # @height = height! c, f& }) Y$ H$ G9 R. @
  2374. ; L. g) V  g7 B, P7 v2 _
  2375. class Area_Response
    - u4 J" Z$ M& _( l9 f* B2 @
  2376.   attr_accessor type; Q' v2 o: ~' j5 D3 g1 F
  2377.   attr_reader ox, H5 D; p( B; w4 k1 j. t3 @
  2378.   attr_reader oy0 i$ C, U( T$ Z' F- b( T
  2379.   attr_reader width1 Z1 d1 ?6 a) D9 n
  2380.   attr_reader height3 A5 R6 g5 Y4 b' J2 _/ a2 ~
  2381.   attr_reader switch_id
    $ [8 y# x8 Z5 |; g
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)/ |( m0 J" ^3 O# a+ T  E5 p2 k
  2383.     @type = type8 G$ I  {1 M8 t- i+ q! T! Y
  2384.     @ox = ox  G' n- }$ Z  Z0 w
  2385.     @oy = oy0 E9 H: r# h, @; ?# q7 b7 V
  2386.     @width = width
    ; Q% O+ l7 Y% F* F, h0 q; E- U/ p
  2387.     @height = height: ?2 B/ K: {, e
  2388.     @switch_id = switch_id
    / V7 [% Y* x( e# I5 I1 j
  2389.   end! k( u! Y- w7 V0 O9 j) F
  2390. end  |1 \; ^3 {! Q

  2391. ! r( S# f$ r: i0 e2 |, I
  2392. $area_responses = []0 t& B' Q( v( c
  2393. 8 \% d  Y2 w! b
  2394. class Scene_Map
    4 ?+ B) J8 S5 ^1 s9 y8 s
  2395.   alias update_mouse_2013421 update_mouse_action; x* q3 p/ }  ^4 G
  2396.   def update_mouse_action/ X! O7 ~6 j5 u) N, ^! G" r6 h
  2397.     update_area_response# e( p* m* k- I: v
  2398.     update_mouse_2013421
    $ K# v3 T" \* p! j4 \3 a; E2 Y
  2399.   end- `  @+ J3 c4 N- E4 S
  2400.   def update_area_response
    # T8 q4 P( `! A
  2401.     responses = $area_responses1 |7 B; k9 P- k6 V$ [
  2402.     responses.each {response* L7 B" z  Q" \$ p0 B
  2403.       ox = response.ox! F" V* \/ i$ c5 |
  2404.       oy = response.oy
    , H. r$ N5 `$ T# \0 K5 T
  2405.       width = response.width: F" D% C' R5 \. x: U
  2406.       height = response.height
    5 ^$ q$ r% H! v3 D: Q% u, [6 l
  2407.       switch_id = response.switch_id% d, {, T. I7 D! [: {
  2408.       case response.type7 a2 ^+ v# e8 m* H2 W
  2409.       when 0
    ) G6 E7 e1 B* H# |. d8 Z3 C
  2410.         if mouse_in_area(ox, oy, width, height)
    # t, Y6 c" z, Y# x- T4 e
  2411.           $game_switches[switch_id] = true+ J. R  ]! Q8 R2 f$ b
  2412.           $area_responses.delete(response)
    " V* _3 _. M- m* `* w9 w
  2413.         end7 I% X/ ~* }4 Q$ a- P- l& c
  2414.       when 1
    , U! r% y% V, B2 z$ O' @2 W; a
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
    $ }0 p6 y" x5 D) K
  2416.           $game_switches[switch_id] = true
    6 C$ O0 i/ X0 @# u
  2417.           $area_responses.delete(response)% e; [, e2 Z2 w3 d" L% e* c
  2418.         end
    0 \8 R1 S# z+ g$ A
  2419.       when 2
    7 w) T) ^# q. s: ?* S
  2420.         if mouse_in_area(ox, oy, width, height)
    6 l4 n. h4 r+ s5 `" n' s
  2421.           $game_switches[switch_id] = true
    7 Z  h% w7 `3 T: W3 i2 @! w3 Q
  2422.         else
    3 M# h' E9 n  `. A
  2423.           $game_switches[switch_id] = false4 V" l( _9 s# ^* h) }, ~/ a: ?
  2424.         end) _2 \5 {, ~  j
  2425.       when 3" y+ M& `" w& D, m/ r4 l
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,. Q! |1 b4 k. Q; |6 j; q
  2427.             (oy - $game_map.display_y)  32, width, height)
    ! ^# X$ e; d* }, r6 e2 O
  2428.           $game_map.events_xy(ox, oy).each {event( g3 @1 c0 \  `' l
  2429.           event.start
    & f; M$ A% Q' S( y
  2430.           $area_responses.delete(response), i9 ~% z+ ~3 D8 r/ h* n4 u6 p4 f
  2431.           return% ?) Q2 ?7 y* W! {, L$ Z* l
  2432.           } # _1 A3 m2 ]2 Z6 w/ F5 K) t2 _( M: K( C
  2433.         end' e& }, h; w- W' L" i! m. A
  2434.       when 43 l* [+ ~( z! N1 r9 A* W8 W! y: T
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,! v) o) l. B$ o9 u$ j9 N
  2436.             (oy - $game_map.display_y)  32, width, height)8 N' H% A/ y0 u+ N
  2437.           $game_map.events_xy(ox, oy).each {event
    : b+ h' |7 [& `0 d* L( e- v
  2438.             event.start  x; \2 {& d( l: V# @7 ?/ E
  2439.             return
    ! [) l% {1 F1 Z: M& _, M9 w$ v
  2440.           }
    5 g# Q+ i5 C+ P# w( E1 a
  2441.         end
    / U* B' i% a/ j6 v$ _4 B( G1 P$ ~) C
  2442.       end. U- n% }$ B9 D% g: q  H5 e( v
  2443.     }" g! s8 X! C9 ]9 Z7 X7 K9 R
  2444.   end
    ! R& j- O; \# h' p) [* a
  2445.   def mouse_in_area(ox, oy, width, height)
    1 L' z2 [4 R* M4 [( N  Z
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    3 _0 o: m  L+ Y% k3 Z% Q: d
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height" I8 T2 ?: E( N) m& C: G5 }
  2448.   end
    6 f% u; Y. p; c$ ^2 ^
  2449. end% U, f: t3 a$ ~/ P4 O% a
  2450. class Game_Interpreter7 C- o3 {. J! R* x, j0 B
  2451.   def area_response(arg); E& Q8 V8 L# L# Z, ]2 ]/ w& u
  2452.     $area_responses.push(Area_Response.new(arg)). s4 @9 A% h' G" ~* |  g! ^
  2453.   end
    - e& n4 a1 u, r( U* `7 g
  2454. end
    3 E5 X& M0 {2 c$ {
复制代码

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

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

GMT+8, 2025-7-20 06:03

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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