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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    # s4 U8 Q! P4 H1 `
  2. . b* S3 c7 @( @" c% l4 r
  3.   Sion Mouse System v1.3e
    : w+ A4 J% f8 A" x5 ]
  4.   : g2 M" y" l& S8 n$ i
  5.   Changlog
    ! ~- ~/ }6 k) }) ~4 {
  6.   
    + X" C, }8 j& H7 q( z. J% t
  7.   2013.4.21 v1.3f
    : _, [- j' d% I. Q% r* |  m7 G/ i
  8.     8 z3 z1 c( R& Q3 c. v, x9 v
  9.     1.3f 卷动地图 bug 修正- U& U, @% ~8 d5 {: Z
  10.     $ E8 X$ s. ~+ b1 `* H# u  u
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口+ I% Y% E) c; B
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    . i" R! x0 q4 T9 u( }7 f2 t' x
  13.                               Mouse.unlock_mouse_in_screen 解除锁定9 U; F4 \0 I- Q" i4 |

  14. 0 H! r  V- J& `) H1 W7 G+ h/ G# o
  15.     1.3f bug修正
    . u' s! ?% ]& w9 `; h
  16.   
    $ @3 S3 [+ X1 k# m& m0 E, }% f
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    4 c, M5 b( ]+ [: j3 u# C+ }
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    / D5 g# ]% A+ @3 x7 X9 I& {
  19. ( s$ g" U5 {. \' P3 g( k+ S9 D
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    ) |' q* W; d  J

  21. 8 a* P% z- J. g  ?' J8 i- W
  22.     1.3b 修正一些罕见的bug;/ V! R1 i/ }) `7 A
  23. $ L/ \& Y' O8 m' N. P, [6 ^
  24.     1.3a 代码小修改;
    8 r) q& C6 ^" n- C! H$ |; ?  D  V
  25.           加入了鼠标点击启动事件的功能,
    : r+ A& ^+ e" n
  26.           在事件中加入“注释”: 鼠标启动  ,( B! B6 S' G. c( J
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。6 [! j; q. F2 l
  28.   
    7 c* R5 ]- v- v" M* M) K
  29.   2013.2.12 v1.2- u$ }+ v- e$ O& o; g# w

  30. , g5 c2 H; j! y2 b; a; H
  31.     寻路逻辑优化;
    4 ]7 {0 u  i* `, U9 e
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    6 i) B, l& v5 k0 z' }
  33.     现在支持用鼠标来操作载具了。+ g8 L$ q4 G4 t0 C% J/ N  Q
  34. $ F$ T9 J( a+ Y$ {4 c* H; F
  35.   2013.2.8 v1.1. C: q2 U0 `) X  |3 c
  36. 6 Y2 a" m/ J1 s4 C& q! M2 F
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    - _  Y9 P4 C7 w+ Z/ F
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    : k' I4 J( q( T
  39.     移动时,路径指示点的绘制更加稳定;
    ! n. w- \8 ^& t: {' e- a& a
  40.     现在支持默认存档画面的鼠标操作了。
    ' \1 ~& Y) J' ^3 w0 G0 H$ ~2 c

  41. - T  @- G. F8 G$ I, y

  42. 6 w# \& e3 l2 ?; r; _
  43.   OrigenVersion
    6 _- ]7 i, e9 a" _( x
  44.   
    " y% x% X8 z' a' c3 m, t- i
  45.     2013.2.7 v1.0
    0 r9 K0 `- b  |! o7 P. J0 C! g

  46. 8 N- _: n) g) n' K7 R
  47.   主要功能( O5 ]8 n8 w, u$ f' H
  48. $ p+ y. f- E' \. g* q
  49.       使用鼠标进行各种操作...
    * _2 Q5 u# x4 {3 K) b
  50.       将鼠标锁定在游戏窗口内
    " V" W+ d/ }4 Q. V- R$ j8 Y" j
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    4 \' m4 Z$ ^  l
  52.       双击鼠标进行冲刺
    7 o: u; u( U  A2 [- j: U  H3 q/ A
  53.       更改地图卷动方式以适应鼠标移动
    1 k( ~, ~$ T# u$ \4 s0 J
  54.       变量输入框改良: i; D/ }; A5 x8 ?3 s, h

  55. * l* }3 S4 k6 g! V* y+ r3 k6 _; S
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹0 B7 O2 \, ~6 K; ^1 k
  57. . X1 f  G2 ]! Z
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    : {8 a' o& v, r) W4 i4 S

  59. 1 |! W7 C* p7 h' m: Y, @! D% P
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭* I. n7 T, \& p" n" Q  M0 m. m

  61. : J0 c. v* V: K" j+ I( S
  62. # L7 d0 o8 O) L; K4 C
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★8 m$ r: R( H, J% ~7 a+ q+ D1 e, z
  64. 2 y* D1 R! I+ c9 D0 I. C) s

  65. , O% n" i8 l1 u+ W2 s# q  @$ I
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示8 o6 }: Y9 d2 T

  67. 2 R8 w% M* s4 G# s* z. J: W
  68. #==============================================================================1 L1 @9 L1 K9 `; Q4 q) Q7 H! u
  69. # ■ 常数设置 + R% m" D' Q% p7 G0 t, ~" x
  70. #==============================================================================
    " v' }6 G+ \& n; Y3 [9 l& r
  71. module KsOfSion
    5 S6 j: U& B( a2 K2 J1 M# `
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    1 \9 f4 p/ B: e# i5 m5 y$ N
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑7 m5 p5 V6 y6 {. o  D
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    $ s5 B! R. s* y) I$ j1 ?2 E7 u' S
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    1 C9 z" H, z8 e- g9 h
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    ! e9 |' C- t9 j6 w
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
    7 O1 P# q. k$ L+ k0 N' q) j+ i
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)8 o8 {; ^& c# O
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
      W' |$ M8 U! u1 o$ ~
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    1 X) {/ X$ `# D/ T' Z0 t& Y8 ~
  81. end
    # t  i+ g; K5 _+ m% D

  82. & u3 B5 \; p- j$ d! @8 r
  83. #==============================================================================
    8 N; Q/ ^3 @- C4 H0 {
  84. # ■ 用来显示路径点的类& S- S  e% h5 |5 f9 g/ Z
  85. #==============================================================================
    8 X6 k- d* A+ B2 f4 \! }6 z# l; t' s( X
  86. class Move_Sign  Game_Character( H( Y5 q( a% y8 V: f3 Y$ K
  87.   #--------------------------------------------------------------------------: ~8 s& a7 ?8 k0 u6 o
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    ) E; P: E5 ]/ R- f+ L% q# R
  89.   #--------------------------------------------------------------------------5 j: K( g3 ?2 u
  90.   def init_public_members' b8 I/ L8 S: E' a" f' {: l
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹9 S/ E3 g0 s9 u
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
      C# @5 K, k, o: s* G* `
  93.     @move_speed      = 5        # ★ 踏步速度
    5 h& I. P4 J5 ?6 z& \
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    # U  W# M7 _+ ]* G9 y2 h) C
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度& V4 `$ x# L2 l. h. f
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    # C: H7 v# u& [
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    & i3 L) }7 R' N/ _6 c
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    ' i) b5 J5 Y( v* ~) {2 T* o

  99. ; E# Q) {; g1 X; `' i5 G

  100. - m* f7 O. p( B( _2 u
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★, q2 i/ S4 R5 W' s
  102. 6 e% j+ P: N4 g. V; O" z7 }3 I

  103. 9 f: N4 z/ W7 U/ _
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    4 K$ Z+ N! r7 ~) E3 r+ }
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
      D+ @+ W! `+ J/ `7 y
  106. 1 n; f! L# B1 V4 X; M. c
  107.       if $no_arrowpic_warn; L/ i& n) ?, o2 t; ]: j3 _
  108.         MouseShow_Cursor.call(1)
    4 ^4 T$ ^6 q0 T# F
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    ) P5 x4 o6 y7 N9 X; G! ~0 Z" `

  110. * @# S9 k1 u5 U7 H# Y
  111. “路径指示点”将使用游戏自带图片
    - ~& c3 m3 ?. H. R5 {9 {2 M
  112. ! H' S1 o5 h6 l: N5 _
  113. 该提示可以在脚本内关闭')0 y3 v- J6 X3 y; j# f; U
  114.         MouseShow_Cursor.call(0)6 t* a! M% L5 F  c  ?- x
  115.         $no_arrowpic_warn = false
    & b- R5 E6 G2 q. I4 C  e
  116.       end
    ! ?8 t* F- V/ Y7 x& x
  117.       @character_name  = '!Flame'2 I3 J* R3 [7 M/ M+ a
  118.       @character_index = 62 I; |. l- p2 Q4 x0 r8 y
  119. 0 O1 f/ p" O, |1 }7 j( J% ~
  120.     end* e8 \8 ^9 P+ S- V- j, P& Z, m
  121.     @direction_fix = false  # 固定朝向  p+ r: F7 k$ f* U6 N
  122.     @move_frequency = 6     # 移动频率
    2 N3 g7 U5 _3 P6 o
  123.     @walk_anime = true      # 步行动画
    $ x5 B  ~5 C; d( V: i
  124.     @pattern = 1            # 图案
      v9 k% L* [* T( N' Y; z9 [! h2 X
  125.     @through = true         # 穿透
    ! q! y' c( Q9 Q, Y4 n
  126.     @bush_depth = 0         # 草木深度8 W6 |9 A' q+ m/ Z' \' n- ]
  127.     @animation_id = 0       # 动画 ID
    & s9 h" _8 t0 ?6 ^  v
  128.     @balloon_id = 0         # 心情 ID
    6 P& F+ Q. E! R( r# I  n! d3 _
  129.     @transparent = true     # 透明
    ' j( m0 L/ B& d& M: Z/ c
  130.     @id = 02 T% ~( }1 X5 j% X7 N% r4 x
  131.     @x = 0' y; a1 c! h  `4 K2 Q3 _8 o/ ]
  132.     @y = 0
    0 h& C' k3 r' m. v% f2 P7 i- j; G6 l
  133.     @real_x = 0
    2 x9 r9 p# T# s* t3 @" d
  134.     @real_y = 0% Z  H) L1 U# u4 h* A; g7 b/ h" }8 r
  135.     @tile_id = 0
    $ ~- B6 Z& n! b3 \4 k5 a$ X
  136.   end. }& J3 h! R0 [) W7 n# J
  137.   #--------------------------------------------------------------------------, @& N. t) B+ ^, n* @
  138.   # ● 定义实例变量6 x- J" p" O+ m
  139.   #--------------------------------------------------------------------------
    * g( H4 v. `7 P& m% g* `
  140.   attr_accessor direction
    ' R3 A) v( _4 F& M
  141. end1 j, g% L2 w( d8 J# }5 Q) p6 Q
  142. # x0 l; H6 r; Q$ T3 Z2 f
  143. #==============================================================================/ W/ P5 e/ {& o
  144. # ■ Module Mouse
    + @7 R$ W$ B- N( m% i6 X
  145. #==============================================================================4 j+ m( F8 L; c  F
  146. module Mouse% l/ E' Z$ s, Y  p+ f; M7 S* K
  147.   #--------------------------------------------------------------------------
    ; D/ H4 e3 g; ~/ G( S0 y1 W- U
  148.   # ● API
    ; f0 B0 K: t; x, ~" R. ]
  149.   #--------------------------------------------------------------------------9 [  h. Y7 q; @& d" }
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    # c# @1 G; m6 E+ T  R0 t0 Q
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')$ A, [6 D6 u& h+ @. e5 {1 y
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')% `" l) c' j  ?
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')2 G( T/ e# }6 T  A2 ?
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    3 L" `9 A3 P$ |  |  h, B. o
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    : I+ C9 d! m, w
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    / Q; d# Q$ \4 x8 [, U7 A- g
  157.   Window_Hwnd       = Get_Active_Window.call
    . n8 D4 ]' M) I7 a5 q4 X

  158. " G# t4 ?* J6 z) x" ~9 _! Y
  159. class  self; ~9 g( e8 i( B; a& X
  160.   #--------------------------------------------------------------------------
    8 f$ ~. J, d7 M$ r
  161.   # ● 初始化) Y" R9 o( K+ }2 I2 m8 F; p1 k
  162.   #--------------------------------------------------------------------------
    & I9 F1 T2 k2 e
  163.   def init
    # f0 j4 I' L( d. N1 G
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor# m" A. P5 U4 }% j
  165.     @left_state = 0
    % I, ?' J& d2 I/ R8 }
  166.     @right_state = 0
    / a  G) T: K$ \2 f. R- ~5 z
  167.     @ck_count = 0 # 帧数计,单击以后从0开始; K* F* C4 U6 o
  168.     @dk_count = 0 # 用于双击的判定
      r( e% n; ]+ a+ l3 P; e, o( T
  169.     @clicked = false
    2 ^7 V0 [5 ?4 Y5 y, l8 j
  170.     creat_mouse_sprite& V( g# J% ^, [/ H" e8 Z- D
  171.     update3 k  I5 w8 {- N- @8 O$ z
  172.   end, q9 _! J" \, O0 |
  173.   #--------------------------------------------------------------------------
    * ?2 S5 c, M- {  p; i1 ~
  174.   # ● 鼠标指针精灵
    8 z5 y7 C3 E* D& V8 P( U5 L& J, x
  175.   #--------------------------------------------------------------------------5 `7 ?. f5 |8 k$ b% U8 ?
  176. #~   def creat_mouse_sprite
    2 t, h0 R: d* o, q# K
  177. #~     
    / B; [( g( E) d/ k- U6 V$ G8 B
  178. #~       @mouse_sprite = Sprite.new0 H7 V8 a" C6 d, e# ]
  179. #~       panda = 2#rand(2)+1
    8 j% _( U8 m8 v4 u5 P/ D1 U! i
  180. ) d% v4 W4 x5 a; C( R/ U7 q
  181. #~      if panda = 16 p5 {. a  R' Q7 c: `4 |! B
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    / o0 z- s/ F! G9 u1 |
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    * d# `# O9 d# m8 E
  184. #~        end#with if File.exist
      ]. v& b4 f! Z3 q5 l7 F
  185. #~   
    - T! c+ F4 p* [5 f% x0 K% |' O
  186. #~     else if panda = 2 #with if panda=19 |4 E% c+ t* q8 q& J, {! }
  187. #~      
    4 p" f  |; L' \  f' i' T& |$ l1 J: g
  188. #~      if File.exist('GraphicsSystemCursor2.png')9 }2 g6 K! P  l: d* Z, K
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    ; r. ^# U. `' ?4 E0 F. u
  190. #~      end#with if File.exist
    4 R5 C/ {2 A0 r: z
  191. #~      
    8 j" S1 ^$ H; K6 ^) L# w9 H; g, c
  192. #~     else #with if panda=15 O1 h; z! E. u" t
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
      z6 r0 ^9 v( S' I' V) `
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    * A: }1 P, e. x; h# J5 g, e. K4 R7 _
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    1 s$ l( i: I; V' G- a3 T' `! l
  196. #~     end#with if panda=16 \3 j9 m7 h6 e: X
  197. #~     
    $ L+ K: i5 B9 i/ H5 X
  198. #~     #with def5 I; G# E  Q, R/ G
  199. #~   end- I8 I; v( _" @0 U, \, Q2 ?& @
  200. def creat_mouse_sprite
    " @* ]7 T( r; f' r0 I9 a% A
  201.     @mouse_sprite = Sprite.new3 R# `$ D" ~  V/ F! e
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})' k+ K- n4 a. t+ L7 u' m; Q6 a
  203.     @mouse_sprite.z = 9999; q# d0 q1 {9 F' W! h: O/ _
  204.     Show_Cursor.call(0)
    ) b; [: `% Z; X' ]% p6 w& H" U) T: W
  205. end0 m. F- X/ Y2 V' ~

  206. ( o  Z' B. }3 J$ ~
  207.   #--------------------------------------------------------------------------
    2 J; N3 P3 D: B2 U
  208.   # ● 更新. w0 d4 |$ u( h
  209.   #--------------------------------------------------------------------------
    . E/ d5 K4 G' I7 a0 `+ E, e
  210.   def update
    . N8 P' Z+ Z0 ~
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos* M: t6 t$ p  z6 f3 d
  212.     left_state  = Get_Key_State.call(0x01)& y0 N1 P$ i) z; B& K
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0& q, [% E2 ^% ?0 @& t8 {
  214.     right_state = Get_Key_State.call(0x02)
    7 t4 ?) V4 z+ l
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    7 r' v6 y: Y: G5 j5 h( h/ h
  216.     update_double_click
    6 l$ L9 {5 w/ a& P! H! m: b4 Y
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    : F8 C0 _3 _3 o( m
  218.   end
    " J4 L' I, N) @' G1 o8 O3 s0 q9 ], h7 [
  219.   #--------------------------------------------------------------------------* J* ?7 v( G+ r' l+ ~
  220.   # ● 获取鼠标坐标
    3 t: m/ Q! E4 Z5 T
  221.   #--------------------------------------------------------------------------
    ) h" \' s1 ~5 Q8 o1 B, L4 `
  222.   def get_mouse_pos
    : L: b0 }  \0 R# @% V& |
  223.     arg = [0, 0].pack('ll')+ |: U4 A8 n! M. o0 F7 [, `  ^/ u
  224.     Get_Cursor_Pos.call(arg)! l$ z5 o7 G" h) z: Q& F
  225.     Screen_To_Client.call(Window_Hwnd, arg)$ q; v- ?6 y3 Z2 Q
  226.     x, y = arg.unpack('ll')& n" }' J5 F) p4 E- l
  227.     return x, y
    1 w' A2 L  C/ ~
  228.   end
    ! z; Z7 p0 s/ ^) F4 G
  229.   #--------------------------------------------------------------------------
    + [& d( Q4 V8 t3 G, r3 I4 P
  230.   # ● 将鼠标固定在屏幕内
    ; f" _; a, E: I
  231.   #--------------------------------------------------------------------------
    * d0 D" i1 y/ U+ [
  232.   def lock_mouse_in_screen
    + v  ]6 v* V, N# w$ I. E$ R2 u
  233.     arg = [0, 0].pack('ll'), Q9 ]* y5 Q7 N- T2 v4 a
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    - w- e0 [5 I) C, `2 ~6 F
  235.     x, y  = arg.unpack('ll'). {1 v. `. F' g
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    3 ^3 X5 H2 K0 ~& ~" n
  237.   end& U% `9 U" ?6 O1 D
  238.   #--------------------------------------------------------------------------  l! c6 |) V( u. @
  239.   # ● 解除鼠标固定
    1 M% R" Z! ]# U8 |
  240.   #--------------------------------------------------------------------------7 b' r0 C/ g4 p0 \
  241.   def unlock_mouse_in_screen
    ( Y6 g' I' ~" z/ C& X
  242.     Clip_Cursor.call(0). i: A" I& u! h+ Z
  243.   end
    3 h1 M+ u1 K4 T" o$ B
  244.   #--------------------------------------------------------------------------
    7 V; O' ]  A/ R/ o
  245.   # ● 鼠标双击判定- B9 M3 s( ?3 o# \6 c9 z3 |
  246.   #--------------------------------------------------------------------------
    4 p* A$ m; _. a: [% x2 P
  247.   def update_double_click8 K6 d5 e' H; n
  248.     @clicked = true if @left_state == 14 V, P6 S6 q+ l( C9 e. j
  249.     if @dk_count  0 && @left_state == 1& {1 I( ~* B3 J% M; L: p! r
  250.       @dk_count = 0; @clicked = false
    * x, D0 g  q$ J9 Y1 B
  251.       return @double_click = true& |/ |; J; O* ^. r
  252.     elsif @clicked
    8 d$ E1 S9 R) C
  253.       if @dk_count  KsOfSionDbclick_Frame2 g3 S( s6 V+ @/ u% Q
  254.         @dk_count += 1
    - z& N7 L; X! G0 J0 k7 d
  255.       else8 o3 l8 t9 s3 e, u  k( x! a
  256.         @dk_count = 0; @clicked = false
    + ?# C0 |2 `8 E
  257.       end2 q9 L7 j6 T0 ~! ]
  258.     end1 w$ p" S7 T% P! z  i$ l
  259.     @double_click = false% d' ~8 I, J( ?- k: R' t$ [
  260.   end
    3 T% c) P* ~+ r! H' T+ W
  261.   #--------------------------------------------------------------------------
    ( \9 K1 K: w" {5 J% T. i
  262.   # ● 按键被按下就返回true
    $ o! R. Q0 I' O( k) h: C
  263.   #--------------------------------------------------------------------------( G0 ]# Q* g! I6 w: |5 y2 A
  264.   def press(button)
      ^+ c! w( }( w) e! \5 J4 v+ F
  265.     case button' J( s7 \' j  c  _) e1 b
  266.       when 0x01; return !@left_state.zero4 ^- ]3 D, a4 v% w; r: |1 ^7 \
  267.       when 0x02; return !@right_state.zero
    / {; h% b# G* R( a9 J" f
  268.     end
    ) a4 I+ }1 g" B& ]' K4 W( E
  269.     return false
    4 ]4 o. `( Q# n' @* H
  270.   end# e2 ]+ C8 P$ t8 y4 I; n/ j
  271.   #--------------------------------------------------------------------------
    8 l6 B6 N  P$ b# H
  272.   # ● 按键刚被按下则返回true
    7 L2 a' }' `* A1 v+ A
  273.   #--------------------------------------------------------------------------- N( u2 h% v* @/ s# D/ W
  274.   def trigger(button)
    3 k0 m$ z/ ?6 V) v. ]3 s5 }$ B
  275.     case button
    4 Z; t( G% E5 u+ G+ G+ t/ P' s
  276.       when 0x01; return @left_state == 18 e& |' n5 U5 B4 j
  277.       when 0x02; return @right_state == 1
    + {3 h& K' j8 @
  278.     end, x5 s2 {; v9 d. C& K
  279.     return false
    8 h* R7 }+ N; S; b) B9 ~
  280.   end: W* `7 D- T) c5 ]! G' E) c
  281.   #--------------------------------------------------------------------------+ k: z6 a$ |% i0 Y" v7 }
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true" R( s* ?2 O5 S9 m" u! J5 [3 F# [4 ~
  283.   #--------------------------------------------------------------------------
      d, e' b) g4 Z  I- B5 n& W
  284.   def repeat(button): {4 i" C) ]1 G# E) o6 \$ U# Z$ v
  285.     case button
    - p8 E: n* A4 Z) k8 d0 h9 b
  286.       when 0x01; return @left_state == 1 6 a" [: h% F. D" G# Z2 k0 ^
  287.         (@left_state  22 && (@left_state % 6).zero)
    ; C$ g+ b9 O6 x: C' {5 k
  288.       when 0x02; return @right_state == 1 ) t# H4 W3 B) o( E1 O  W0 \
  289.         (@right_state  22 && (@right_state % 6).zero)" t; n4 j6 q0 K2 j7 ?6 v
  290.     end" j% L% t" @' o) o1 O/ D
  291.     return false: _) f; l( d- [) i9 f# m6 Y
  292.   end
    - I# M' s, @  n8 i) P; q
  293.   #--------------------------------------------------------------------------! h" p" A9 B; Z9 M6 F9 O
  294.   # ● 判断是否双击鼠标
    $ c6 q5 F' [  l- d
  295.   #--------------------------------------------------------------------------
    % W! Q% r+ H; I2 L
  296.   def double_click
    / B! Q5 x! A4 n. S, O
  297.     @double_click
    2 g$ ?: T4 f& L3 H" E" v
  298.   end* n# J) I/ g3 u
  299.   #--------------------------------------------------------------------------
    . t  C1 f- A  ~, P/ f  g) [; X3 \
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    + T- ?' w6 }8 \
  301.   #--------------------------------------------------------------------------7 Q7 J* k; M" [0 Y3 B& }6 _  n0 X
  302.   def click_count( Y- l/ i$ D$ G' b0 k
  303.     @ck_count
    0 A( i* ]* j  M
  304.   end
    7 Z- H7 t/ S/ I8 n" d, k
  305.   #--------------------------------------------------------------------------
    + H( J2 `6 I' z' I5 _
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    5 y$ n' e, N. |8 A7 e. E* a
  307.   #--------------------------------------------------------------------------
    ; o% P! }" ?2 X" y7 p
  308.   def left_state0 K( |! z" {) s, e1 p) W$ T4 d% H' a
  309.     @left_state% f* Q& d9 d5 a- ~! I
  310.   end
      }" O% Z1 G2 p! `* E: s( [
  311.   #--------------------------------------------------------------------------: j% U8 F7 e" e! V; D( H& Y5 t/ U
  312.   # ● 获取鼠标的x坐标! S- e9 n8 q" _
  313.   #--------------------------------------------------------------------------$ Q! p1 A9 w" f" B. k6 `
  314.   def mouse_x1 R/ z5 ?" d& N5 N6 h& A) c
  315.     @mouse_sprite.x9 K/ J& a0 d: O+ f$ g- r
  316.   end( c, M1 w) l$ y9 I
  317.   #--------------------------------------------------------------------------% G/ m# F. q3 ?
  318.   # ● 获取鼠标的y坐标# e2 L9 X3 V1 J/ d4 U( K
  319.   #--------------------------------------------------------------------------% a& M8 t# ~0 |& ~2 z
  320.   def mouse_y4 T! R- Y7 s+ E* ~
  321.     @mouse_sprite.y
    - {, x8 ~' i' H4 w
  322.   end3 t/ ^9 Q: J  e$ q' A
  323.   #--------------------------------------------------------------------------3 F: L1 D! N" k3 C" o+ {+ C
  324.   # ● 设置鼠标坐标/ n  p) w; |# s: }  a1 m9 l
  325.   #--------------------------------------------------------------------------
    2 z% a+ H# ~# D  w& T
  326.   def set_mouse_pos(new_x, new_y)
    % e# d3 E1 v. b  j! z
  327.     arg = [0, 0].pack('ll')% j$ H* a; |/ |4 Q; Q* j
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    + i5 E/ V0 U0 r' I* G  }4 K8 i
  329.     x, y  = arg.unpack('ll')
    " H- W9 q4 P+ ]9 n5 F
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)) k, {. b- t: i* Q$ r* A, i/ f3 k; B
  331.   end5 |; U) h1 U  P/ \! ^7 f8 d0 M
  332. end #end of class  self
    8 K) X0 f0 }& R/ H( [/ s3 k
  333. 6 `3 C. u+ H; |' p5 O' A! h
  334. end
    / V* K8 T; o) X

  335. * a( @' w: `. O& J' V
  336. #==============================================================================
    5 A7 k5 v; g4 G7 R+ ], c9 b
  337. # ■ SceneManager- q9 p. m4 b2 c; s+ K" ]: @* s
  338. #==============================================================================
    $ G$ F$ F8 M( W9 Z
  339. class  SceneManager6 n7 s9 L! m- x' d8 @- ^0 V
  340.   #--------------------------------------------------------------------------2 _* N6 l4 a7 V5 U5 v; ~- l
  341.   # ● alias- w; A# D* D) w: r: {3 _3 v2 S8 b$ ]
  342.   #--------------------------------------------------------------------------) t1 k3 J/ n# \% f
  343.   unless self.method_defined(sion_mouse_run)
    . [/ ?/ W* N3 Q5 x( y
  344.     alias_method sion_mouse_run, run
    8 a$ ^1 x- K4 V! X7 I8 w
  345.     alias_method sion_mouse_call, call* o4 {. {7 `2 {* O! U
  346.     alias_method sion_mouse_return, return
    . M) ^7 _0 z, i/ B3 n) e8 k4 t
  347.   end: t4 w, H! P' G# \* n5 F' s
  348.   #--------------------------------------------------------------------------
    ! f. A$ Y. r- C( u2 d
  349.   # ● 运行
    / J# ^+ A' W& M" P2 I
  350.   #--------------------------------------------------------------------------
    / B; b6 k: {! D9 r( v% y
  351.   def run
    / N9 [( {3 J: i8 z5 i" S$ y
  352.     Mouse.init
      T* t( a& G; l" l; G
  353.     sion_mouse_run
      |9 Y$ L- l. L- Y& z' W( q
  354.   end
    " `3 M5 m* @6 @$ E
  355.   #--------------------------------------------------------------------------
    2 E6 Z( d; y% D+ u! N/ j6 M
  356.   # ● 切换% y1 L. K6 T8 X; ~
  357.   #--------------------------------------------------------------------------
    ( m% c8 j  z) C& T7 d2 S
  358.   def call(scene_class)
    2 i- S; \$ `; F" L" e; P+ z
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    " s+ X( H( ^% [  E
  360.     sion_mouse_call(scene_class)
    7 ~8 ^- G3 L5 L. ?2 \! D
  361.   end2 p+ F2 n, D- x
  362.   #--------------------------------------------------------------------------
      k  X4 S1 Z; L, s+ I
  363.   # ● 返回到上一个场景
      [" x  p; S6 q0 T2 U3 k/ e5 Z
  364.   #--------------------------------------------------------------------------: ~! N  W' s3 L* M4 X
  365.   def return
    * e+ P: r8 q4 g
  366.     sion_mouse_return
    ; z- T" D- Y1 U7 P4 i) O
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    . D" X" t7 v" ~
  368.       @scene.instance_of(Scene_Map)5 h4 _9 V1 `0 Z. A8 a
  369.   end
    0 z. K" L4 W3 s! `, x5 l& m, A- R
  370. end% d" |% K% [1 J5 I

  371. ! b0 Y. ?; Z$ L) @) U: z! J$ x
  372. #==============================================================================
    9 h  q: B/ e& `# l# L  y1 o% |
  373. # ■ Module Input6 j$ @2 i: h+ Z8 u6 v
  374. #==============================================================================
    . L% Z4 u1 u3 l2 ?* q8 j: W- d$ w) Q5 p8 ]
  375. class  Input
    9 ^7 p3 j1 V8 j7 Z2 p' |# L; J
  376.   #--------------------------------------------------------------------------
    + F1 |1 B# q) ]" b$ G/ J; C$ C
  377.   # ● alias
      f3 R/ \2 ]2 o: b& K8 C1 P; B2 ?
  378.   #--------------------------------------------------------------------------; [1 d' B4 h# r) Z
  379.   unless self.method_defined(sion_mouse_update)- I1 e* n9 u9 }$ C5 e8 _
  380.     alias_method sion_mouse_update,   update
    " P4 v  j# s5 {
  381.     alias_method sion_mouse_press,   press) I$ w9 y9 i- Q, B
  382.     alias_method sion_mouse_trigger, trigger
    # v# b; r2 X$ L& B/ p
  383.     alias_method sion_mouse_repeat,  repeat
    # {$ _$ w* m/ @8 h3 W; M
  384.   end
    ! `, N7 k: G, T
  385.   #--------------------------------------------------------------------------1 \1 _4 W1 u0 [; z# V3 v7 ^) H1 h
  386.   # ● 更新鼠标
    , S8 ^. T( C& e8 P+ b7 O) F
  387.   #--------------------------------------------------------------------------
    % v4 U+ j* B2 z8 T& g+ Y9 P9 {
  388.   def update& k8 N0 q. g; y; ]9 y# c' u
  389.     Mouse.update
    - I+ E0 ~7 f/ L$ p
  390.     sion_mouse_update
    ( W! O* G% N5 W7 q* H& I
  391.   end
    1 b5 `: i. F- }
  392.   #--------------------------------------------------------------------------# d3 D, m- @" [, d
  393.   # ● 按键被按下就返回true1 y, J9 a$ I3 e; W/ l4 @! ~& }: @9 n: Q
  394.   #--------------------------------------------------------------------------
    ( y: I1 c% L/ J% R5 O2 o% V# b! f
  395.   def press(key)6 K- A0 F1 D! x  @- k: C
  396.     return true if sion_mouse_press(key)0 ?% J+ i9 M7 A# r( X3 r
  397.     return Mouse.press(0x01) if key == C3 }. B4 G% ?5 l1 _
  398.     return Mouse.press(0x02) if key == B
    , l8 B: ?7 `) t6 J5 w
  399.     return false8 I2 Y5 [. M( L5 N. g
  400.   end
    ' o# q- T! j2 J
  401.   #--------------------------------------------------------------------------
    - n) l* S. w9 C+ a
  402.   # ● 按键刚被按下则返回true
    - @$ G, ?) a1 t2 x8 x
  403.   #--------------------------------------------------------------------------
    . y/ N7 t  P: B" W& }4 c% |  g8 S2 _
  404.   def trigger(key)
    : f: W0 g& l$ a  h. v# \
  405.     return true if sion_mouse_trigger(key)! u/ f; x% v5 C: v
  406.     return Mouse.trigger(0x01) if key == C3 `' I7 R! N& X3 i4 _3 ?! k
  407.     return Mouse.trigger(0x02) if key == B: P; T2 W" u6 A  G/ _' R
  408.     return false8 e( A5 m' H$ C! o; L# c
  409.   end6 t* L- S( ?8 P* u% y6 b
  410.   #--------------------------------------------------------------------------
    0 v. Q" G* p. E5 F% @6 V
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true- p" E8 f# p5 `! \" K6 q( e
  412.   #--------------------------------------------------------------------------
    6 C  J. h4 \. R1 ^# y: F
  413.   def repeat(key)
    " n& q- A4 f8 q' M1 i
  414.     return true if sion_mouse_repeat(key)
    7 ~% W0 b( V* D
  415.     return Mouse.repeat(0x01) if key == C, k0 Z% K: P8 M% r/ O# \* ?
  416.     return Mouse.repeat(0x02) if key == B
    $ F( u3 m9 M; t+ y
  417.     return false3 G' Y+ e+ X$ V  l2 `
  418.   end
    " C5 N& S9 z  s/ D( T; @
  419. end
    ( R) v6 {5 H9 B, r& g3 H* }
  420. , d( r  Q9 ^% P% a/ u

  421. 9 }# D! T( H4 _5 q
  422. #==============================================================================
    & u- F' }/ r  S8 ?
  423. # ■ Window_Selectable* g7 c+ {/ t4 P2 n) x8 L
  424. #------------------------------------------------------------------------------6 D/ S) L( r* ]
  425. #  拥有光标移动、滚动功能的窗口
    ! e* a: a$ q, Q! l3 q5 m3 p
  426. #==============================================================================
    # p! [3 h+ M, C
  427. class Window_Selectable
    8 T0 l$ R9 Y4 O  M
  428.   #--------------------------------------------------------------------------: ~& A- C3 r* l" g1 g
  429.   # ● 初始化
    2 A5 w: H4 n2 `* ^7 g
  430.   #--------------------------------------------------------------------------/ ~4 y  N1 c, P8 |3 S
  431.   alias sion_mouse_initialize initialize
    * q, u2 N/ Z, B  G) r
  432.   def initialize(x, y, width, height)' w7 P- N. ~6 K
  433.     sion_mouse_initialize(x, y, width, height)
    $ i6 w" N; p6 @$ j( y
  434.     @move_state = 0$ ?$ n& v, K  B% @1 Y' o9 v) x
  435.   end
    ' _1 u/ G) z- p% d
  436.   #--------------------------------------------------------------------------3 x. R6 g. P2 ~2 S% G
  437.   # ● 更新
    % J* W; L: H- l# D5 g
  438.   #--------------------------------------------------------------------------- l8 K1 ~+ R/ _- a  T
  439.   alias sion_mouse_update update" Z! ]& D$ S. v4 b
  440.   def update3 T& I+ U. P5 @
  441.     sion_mouse_update
    - ?1 g% ^0 V$ R$ f; v: z+ c
  442.     update_mouse_cursor1 \4 r) p( a. s) s2 J$ p7 K7 E7 W" x) |
  443.   end
    % k& }% B) J. f7 o+ t: a
  444.   #--------------------------------------------------------------------------
    - L, `* X& F$ J$ f
  445.   # ● 启动后设置鼠标到index位置
    3 ?/ I! s  ?: C7 ?. m/ k. U
  446.   #--------------------------------------------------------------------------2 F$ T" W* Q" U) }' \9 y& d
  447.   def activate
    ( i% s! Z& n1 `$ r8 }# T% T: k
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos% H, o9 W" g/ A9 i6 x
  449.     super0 G! P/ ^7 D0 ?% b3 s# N! x" \
  450.   end
    % w" G% k5 @# |% Y
  451.   #--------------------------------------------------------------------------
    & k9 X4 O) |- H$ o: o( J
  452.   # ● 更新鼠标和光标的位置8 L: C' V; o0 }$ H2 H9 |
  453.   #--------------------------------------------------------------------------& z: o8 A( j8 K" b5 \; G
  454.   def update_mouse_cursor
    ' t% t+ o  X' i8 T; D# g# Q
  455.     if active
    ( R1 z/ r( `# e  c5 G9 l  d  b
  456.       if @need_set_pos
    : {1 R/ _7 G" ]# A1 L5 H% W" k
  457.         @need_set_pos = nil
    + E% s* `5 I" _8 r- p! \8 ?
  458.         set_mouse_pos- h8 ^9 [2 P0 s$ X* g
  459.       elsif cursor_movable, X3 g0 B- k5 ?: D
  460.         Input.dir4.zero  set_cursor  set_mouse_pos- ~8 [$ N0 r0 ~' d+ }9 Z* b+ `
  461.       end
    - W* H) ~' @+ Z. I( o$ n0 v' I) |5 D
  462.     end
    0 m$ _& \7 z, }5 F, V0 \
  463.   end
    ) L0 R! i7 w3 d" P: B$ \
  464.   #--------------------------------------------------------------------------0 ]/ u0 T9 e  f+ t/ A
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能  o8 n! k5 o* }
  466.   #--------------------------------------------------------------------------; T' Z6 U4 J" ]$ f! d6 C. e8 U
  467.   def set_cursor
    . _/ I6 p% q, Y: W, U6 @
  468.     mouse_row, mouse_col = mouse_window_area
    ) Z* V- \+ N( G0 J, R$ T7 O1 c
  469.     if    mouse_row == -1. s5 T0 V- S7 Q* [3 W: U* Y
  470.       @move_state += 1 if need_scroll: U% t, [7 u' o: O
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ( L2 j8 z+ V) a1 y4 l8 I
  472.     elsif mouse_row == -2
    . W9 A) c% A1 x3 m
  473.       @move_state += 1 if need_scroll
    5 f% Q' E% C8 U9 n! i
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand1 ]4 L6 ]  L8 \, W4 K
  475.     elsif mouse_col == -1" S, p( H7 _1 O
  476.       @move_state += 1 if need_scroll
    ; P* R  ~! i+ E% y' Y+ P& [
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    1 y3 ~4 P' Z- S# Q( F8 Q
  478.     elsif mouse_col == -22 y, L( h$ f- B7 n% P: o* m
  479.       @move_state += 1 if need_scroll
    " c3 t) n: X# G7 U6 ~# x. W
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    : s& v# e5 l, k: ~
  481.     else: ?, C% D- R) Z7 R( S& P5 s3 |
  482.       @move_state = 0
    2 L( s- b- n: m4 u2 G* N! ~
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col5 V  w* q, _& d# R! I
  484.       select(new_index) if new_index  item_max && new_index != @index
    7 }4 v1 b% f# B" L( R' i( \
  485.     end2 O& I9 c2 |9 m
  486.   end# W. ?. f' J) [; S! F9 U. c
  487.   #--------------------------------------------------------------------------7 f6 }2 G( W: L8 I* Q6 w- ?; X- v6 B
  488.   # ● 判断鼠标位于菜单的第几行、第几列8 P  \# X* L/ y5 h
  489.   #--------------------------------------------------------------------------$ J% M  P7 w! m! M3 Z* j. |$ p: A* U( R
  490.   def mouse_window_area
    . X* D3 U! [! F- I6 z/ j. j# ~/ j! I
  491.     if viewport.nil # necessary!$ Z# ~+ J$ U+ {+ a4 k& q# B
  492.       vp_x, vp_y = 0, 0
    + U2 S- b2 u2 g5 X9 s. {" |
  493.     else( [" p1 x. }' G" ^
  494.       vp_x = viewport.rect.x - viewport.ox0 F( b3 m+ X0 D0 x
  495.       vp_y = viewport.rect.y - viewport.oy7 K% m% y) k- h3 L/ I
  496.     end
    # H$ D# G; |/ v; B: I8 {- H' f9 ]2 V
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ; l7 K- g( R9 v4 F
  498.     item_x1 = vp_x + x + standard_padding
    ; J( y# v8 f4 I( u, d2 C
  499.     item_y1 = vp_y + y + standard_padding
    . L2 k9 x  _; B
  500.     item_x2 = vp_x + x - standard_padding + width5 o, G6 F: u% q3 V1 d* |) R3 c8 K9 h) q
  501.     item_y2 = vp_y + y - standard_padding + height
    ' f! z7 b8 h5 {7 C3 G
  502.     if mouse_x  item_x1
    8 Y0 ~$ ]% |6 G9 i* E. ?
  503.       mouse_col = -1. u9 N+ L% X0 f0 Z2 ^7 r: o2 i3 W
  504.     elsif mouse_x  item_x2
    ( M9 g  ]! q( x9 N/ L* B$ ^4 Q
  505.       mouse_col = -2
    ! H7 h! y/ ?, G: }& r+ r
  506.     else
    ; |: X" V2 s2 {5 z1 ~8 p
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)) n( k9 \1 A- c4 q
  508.     end+ Z) v3 N, H' F. e" \; Y+ L
  509.     if mouse_y  item_y1" a  \; i" Z, s5 s
  510.       mouse_row = -1
    8 |! V2 b$ }/ P$ m% U, G
  511.     elsif mouse_y  item_y2
    $ C# ]" j0 W( F" e5 b
  512.       mouse_row = -2/ V! d7 {2 T  O3 L2 I
  513.     else9 ?; I5 H* I$ [% H
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)) Q+ O2 y& N* C: ?) t
  515.     end
    5 Y( t# \* W' _- o7 ^6 p
  516.     return mouse_row, mouse_col
    9 |8 k7 [, P! D' g6 Y3 P3 H1 ~% }9 ~
  517.   end
    3 A2 K% d. U# U( B& i# |* M4 s
  518.   #--------------------------------------------------------------------------
    0 }; a3 U. s( I
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    4 j1 F) u1 s; H) m$ E& |
  520.   #--------------------------------------------------------------------------
      U* v) p# d' \' Y/ o) T, q' m
  521.   def set_mouse_pos* _) [! O" ~* U8 o9 ^" W
  522.     if viewport.nil # necessary!
    7 J8 F9 u1 S' `! {' s* a) ?
  523.       vp_x, vp_y = 0, 08 U4 q6 B/ T* W
  524.     else6 h, {5 B3 Y# k& o
  525.       vp_x = viewport.rect.x - viewport.ox
    3 b0 X9 D2 Q8 y2 R4 t
  526.       vp_y = viewport.rect.y - viewport.oy! {  Y+ i+ A( b- \
  527.     end  n: b" V) `, }% d: @' N' w
  528.     item_x1 = vp_x + x + standard_padding
    / ^7 X/ H& P2 D; v8 Z4 w0 @: k
  529.     item_y1 = vp_y + y + standard_padding* A& R1 B# c% ^9 I
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    ' k3 d' Z( E) H; n/ `/ |
  531.     row = get_index  col_max - top_row
    3 L/ w) \$ S0 ?" u5 }* P; K' v
  532.     col = get_index % col_max
    / @7 m2 B( R0 l+ L5 J+ m. @
  533.     new_x = item_x1 + item_width  (col + 0.5)! C7 v$ r& Z. D7 F" W) S9 C
  534.     new_y = item_y1 + item_height  (row + 0.5)( i0 Q4 U3 _6 a/ \* a
  535.     Mouse.set_mouse_pos(new_x, new_y)6 o8 k0 z! O8 B, F, @6 q
  536.   end# e: T1 T6 z2 c
  537.   #--------------------------------------------------------------------------( o# `; A9 @; A3 {& f
  538.   # ● 判断菜单是否需要卷动$ u) a# M. n! ?$ Y
  539.   #--------------------------------------------------------------------------
    & l% t7 [5 ^" V' D( ?  U
  540.   def need_scroll. h: P) C! A7 t
  541.     item_max  col_max  page_row_max
    3 A7 p: X6 O% L
  542.   end! U+ Z; ?8 M- ~- D
  543.   #--------------------------------------------------------------------------
    & t5 q( \' I; w" M2 f) A3 r
  544.   # ● 判断是否为水平卷动菜单
    6 m8 P8 ?; j6 h6 m* O
  545.   #--------------------------------------------------------------------------4 d& j' |3 J' y7 A6 F
  546.   def is_horzcommand! W" M' z* K6 ?0 j8 q; O
  547.     return false' R: _9 q4 W2 N6 s# T1 t
  548.   end6 W4 \5 m) c- V! w' r: p' ?1 _
  549. end0 \1 |7 s$ F0 M, u# ]8 _/ d" C
  550. ; R0 X* A+ `# f
  551. class Window_HorzCommand
    2 h0 o* t9 X9 n' F$ [
  552.   #--------------------------------------------------------------------------
    5 Z  @8 v4 F7 b" @
  553.   # ● 判断是否为水平卷动菜单
    $ G5 g+ Q! @' q5 p
  554.   #--------------------------------------------------------------------------
    & o: K4 X/ o2 C- t
  555.   def is_horzcommand* f5 C7 [0 W; L
  556.     return true. x5 U9 b" r; f- Y9 p
  557.   end5 r5 Q# O* M$ d4 y9 d& j! m
  558. end
    7 p1 a$ \/ r( R" O: S  e7 j/ e
  559. 5 l2 U, X! Q# P2 B& }4 p
  560. #==============================================================================* E4 j2 t+ R0 M2 H! \+ e
  561. # ■ Window_NameInput
      \: ~. H9 G: c
  562. #------------------------------------------------------------------------------3 I7 _3 F' z$ I) C& g$ L! ~
  563. #  名字输入画面中,选择文字的窗口。1 p9 H* w% W1 M1 h7 f6 R
  564. #==============================================================================) }0 x/ R" R8 V* k# a
  565. class Window_NameInput6 T9 {" x1 ]. k9 [
  566.   #--------------------------------------------------------------------------
    & g  }! ]7 ^' _
  567.   # ● 设置列数
    , J2 N$ ?# v7 z9 R; j
  568.   #--------------------------------------------------------------------------8 F; t2 X! \8 m4 s3 |6 H5 Q" Q
  569.   def col_max7 ?/ x/ u! s3 d  Z% B, b. ?) o
  570.     return 10- L# G" k" K4 N/ `9 {
  571.   end7 z2 `* [5 \$ ~9 ]8 s$ Y; C' h' v: C
  572.   #--------------------------------------------------------------------------
    " i/ ]# s' u% m5 B- G. V8 Z) ]
  573.   # ● 设置填充的Item个数
    9 i  S$ T0 B3 m  X* N/ N
  574.   #--------------------------------------------------------------------------6 p& ]3 `. J* U- W+ E
  575.   def item_max
      s& E: v- @) c5 D
  576.     return 90. z5 \" |8 J2 `: }; ]# I- `. k% M) s
  577.   end
    ( ]( M2 l  W4 I# q7 Q& F
  578.   #--------------------------------------------------------------------------
    5 F: x+ Y5 _$ V) V4 O) m' C* @; t
  579.   # ● 设置填充的Item个数. V4 Q: Y+ B- s6 @: z
  580.   #--------------------------------------------------------------------------
    8 P9 L$ d& ?) U# n) `& j- B
  581.   def item_width
    ; Q( z- G$ q( d3 g  ]
  582.     return 32! @+ C+ w7 l' Z) W; a
  583.   end. m$ {+ M5 s9 \' }
  584.   #--------------------------------------------------------------------------
    ) i( z+ F, A7 \( \  h3 l
  585.   # ● 判断鼠标位于菜单的第几行、第几列2 u4 ]6 E9 L& u( c6 {2 u" [
  586.   #--------------------------------------------------------------------------" T# R& A$ r- f& M/ `
  587.   def mouse_window_area
    ; h* H7 S3 b: k  c0 d
  588.     if viewport.nil
    & f9 [6 Z. C5 R' l
  589.       vp_x, vp_y = 0, 09 V$ j1 n/ ^  ?1 U* t
  590.     else
    - N' D3 }) y* o3 h; j1 N
  591.       vp_x = viewport.rect.x - viewport.ox( ^( P3 o6 r8 a7 N3 }/ f. U
  592.       vp_y = viewport.rect.y - viewport.oy
    $ Z3 E! V  x* a3 A5 g: C
  593.     end# U9 u* M" K7 y7 O' U
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y! `3 o% X; P5 f% j
  595.     item_x1 = vp_x + x + standard_padding " h' a( T: F+ p9 p- z: K6 e
  596.     item_y1 = vp_y + y + standard_padding5 Q/ M+ @$ N; w# z
  597.     item_x2 = vp_x + x - standard_padding + width
    1 N; z+ a" S- k2 m% C
  598.     item_y2 = vp_y + y - standard_padding + height. ~+ n- D9 q3 o# Q, q: q/ E, I3 O
  599.     if mouse_x  item_x10 E" k! |1 u) Z+ w! N
  600.       mouse_col = -15 O$ {$ ]- J0 G. d) ?$ A
  601.     elsif mouse_x  item_x2
    4 n3 `9 B4 n% T1 s
  602.       mouse_col = -2
    ) d' Q$ y! p9 B0 c+ t
  603.     elsif mouse_x  item_x1 + 160
    9 q* A7 n; G; N& M
  604.       mouse_col = (mouse_x - item_x1)32
    / c) ~9 a" K" l
  605.     elsif mouse_x  item_x2 - 160
    8 c5 T! J9 _5 y% Q) {
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    / q5 t. b' Y9 h( j; N3 ^! ]
  607.     else1 c% m3 i' M2 ]% [/ X* o  n
  608.       mouse_col = mouse_x  x + width2  5  4
    6 y9 C& b$ g7 H
  609.     end
    / w9 j: f3 k5 f! y0 M
  610.     if mouse_y  item_y17 t; l5 B) q! N: K9 b! K7 F# L
  611.       mouse_row = -1* y0 b0 {( @# g% T* W2 Y& V
  612.     elsif mouse_y  item_y2+ p+ W% C4 U3 ~" y4 F  S, {
  613.       mouse_row = -29 k7 j- [! d6 P6 c, l( T, ^
  614.     else$ X# I& D6 a; J! _- Y
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    - |" d( M: d7 Z6 t6 L- K8 _4 A
  616.     end
    / m2 w' O8 w" b! v8 M2 A
  617.     return mouse_row, mouse_col
    $ g+ \1 A4 ~3 h4 F9 e) c
  618.   end
    0 ^, O6 S, [+ J( \3 E! J
  619.   #--------------------------------------------------------------------------
    , M9 C4 u* N1 \, ~: n1 o- f
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置3 w: m9 H- C$ a% X  Z0 Z0 d  W  _
  621.   #--------------------------------------------------------------------------) h/ R, j5 o+ K3 e
  622.   def set_mouse_pos/ n6 g1 V! f. K+ q+ m5 H! _0 V7 U
  623.     if viewport.nil # necessary!( W8 l: x/ @6 i  Z* c/ Q
  624.       vp_x, vp_y = 0, 0
    6 l) t6 ?8 d* d# S
  625.     else
    1 i: V5 k* O$ Y5 l' }4 I
  626.       vp_x = viewport.rect.x - viewport.ox
    * [+ B* D* g. b0 e3 U& N# I6 O( k
  627.       vp_y = viewport.rect.y - viewport.oy
    & i0 |7 [6 a- a4 a4 U
  628.     end
    4 ~; |# ~6 [. B* U* I& K
  629.     item_x1 = vp_x + x + standard_padding 9 |% c1 d( ~5 c
  630.     item_y1 = vp_y + y + standard_padding3 C6 }; W& B. P; k0 G
  631.     get_index = @index  0  0  @index
    8 x5 K5 p3 Y! o. b* e) p
  632.     row = get_index  col_max - top_row
    5 V1 f7 P0 T( l& J
  633.     col = get_index % col_max& g$ V- M! M* Q6 j/ j: q
  634.     new_x = item_x1 + item_width  (col + 0.5)
    $ w9 g$ u( u5 P% j% h$ G+ H
  635.     new_y = item_y1 + item_height  (row + 0.5)
    / a  ]- i6 T0 C% a
  636.     new_x += 14 if col  4( U  J3 ~% }+ r7 R; `4 t& P* X
  637.     Mouse.set_mouse_pos(new_x, new_y); v& ]- g, @. R2 l/ M( d# N
  638.   end
    ) X6 x0 d* E. D* F* U) x; r
  639. end
    " h: H5 f& Q! d2 ]. `
  640. : W6 [7 y/ j5 v3 h7 ]
  641. #==============================================================================1 O, G+ j  H- t7 f, C' x8 k
  642. # ■ Window_NumberInput( y2 X$ h7 v; x
  643. #------------------------------------------------------------------------------8 B; t2 y+ b) q3 i+ g: h
  644. #  重写了数值输入的方法以适应鼠标' J) W5 X7 I& v' L
  645. #==============================================================================6 f# b# y9 @! A) W
  646. class Window_NumberInput  Window_Base
    ! ?- S" Q1 s) H) x, r
  647.   #--------------------------------------------------------------------------# o2 w" h; b6 y) k* B; S
  648.   # ● 定义实例变量
    6 k! n, o+ W6 B+ i. Y
  649.   #--------------------------------------------------------------------------
    , u2 [- U& ?' E8 ?" B9 G4 p7 E
  650.   attr_reader extra_window
    & p8 v7 k! e: G" }4 K$ w$ f
  651.   #--------------------------------------------------------------------------% T" s0 L/ C$ @2 ], y
  652.   # ● 初始化
    5 Y8 O) x' K, \& P$ ^
  653.   #--------------------------------------------------------------------------" z. N6 b3 A3 c5 c" Z: ?. P6 v
  654.   alias sion_mouse_initialize initialize
    3 S5 @5 u9 I6 i* V( O; V
  655.   def initialize(arg)" @, m) p/ p3 ~" }" ~
  656.     sion_mouse_initialize(arg)
    6 S3 L$ N( M6 \3 s1 r2 W
  657.     create_extra_window
    % g8 L! o1 G/ E4 [2 k- B
  658.   end3 y9 d) Q; Y+ t4 a1 @/ H
  659.   #--------------------------------------------------------------------------
    ' S8 W# Z& a: W& {0 Y8 M# ~
  660.   # ● 启动" h2 a8 a' }" j( G& {3 I
  661.   #--------------------------------------------------------------------------
    3 l7 b/ u, E5 J! D5 }+ h* v* d
  662.   alias sion_mouse_start start/ P5 M$ C+ D% u; Y  f. v& B0 d; S+ R
  663.   def start6 D& V" y: K8 B, h# c) X# r
  664.     sion_mouse_start$ Q8 n) Y. f7 D0 Y: Q( g
  665.     deactivate
    5 M: H# k& x1 a) D% Q- |; E
  666.     extra_start
    + G( E5 H3 l0 a* M
  667.   end
    , o% }! @7 |- |  f: S3 s4 t
  668.   #--------------------------------------------------------------------------4 X9 v7 N+ y# u
  669.   # ● 创建新的数值输入窗口
    3 t8 m# d0 R# \$ D- }
  670.   #--------------------------------------------------------------------------
    1 r# L+ y) g9 C' \
  671.   def create_extra_window
    0 A5 O7 Q  B- ]$ G2 S. G4 G
  672.     @extra_window = Window_NumberInput_Ex.new1 _% N: P% B+ H/ J5 s
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2$ v7 v3 o! Y+ ]# Z6 N
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }( m6 f+ E* L' F2 U) X
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    3 O/ x3 K' ~4 X2 k$ n
  676.     @extra_window.close_proc   = Proc.new { close }9 F5 O( s7 [' X5 g0 \% G
  677.     @extra_window.refresh_proc = Proc.new { refresh }% J. x' D) r5 |' t8 k
  678.   end
    ! j3 @4 Q/ }  c: h% ?0 g  ?8 h
  679.   #--------------------------------------------------------------------------
    2 N6 a8 j" M$ Y( L9 x4 K
  680.   # ● 激活新窗口6 U$ x2 z/ Y0 |$ X8 p
  681.   #--------------------------------------------------------------------------8 T( C6 C! |, z! x2 R9 W& [
  682.   def extra_start' ?3 a5 B: [4 G
  683.     case $game_message.position
    / i' X5 J% _. l# @5 E" d4 V
  684.       when 0; @extra_window.y = y + height + 4
    $ d' E+ v5 D0 r1 m2 n
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    $ g; z8 f9 b4 {. p: M! r& Y
  686.       when 2; @extra_window.y = y - @extra_window.height - 41 N% _& M* h) q- T' f& _
  687.       else  ; @extra_window.y = 8$ E1 f! |( s1 E+ d
  688.     end/ `* a: R1 [! X" v4 a
  689.     @extra_window.variable_id = $game_message.num_input_variable_id; ~6 Q* S; l5 P3 W2 l+ K1 [
  690.     @extra_window.digits_max  = @digits_max
    ) `+ {2 x: ^" s! Q  T" S4 N
  691.     @extra_window.number      = @number" X5 b. M  }/ `3 a- D. Z8 I4 C
  692.     @extra_window.open* y0 M3 ^4 c! C" I; E( Z
  693.     @extra_window.activate# `8 q  K# M9 d5 Q/ m2 N
  694.   end# |' M1 I% n6 @
  695.   #--------------------------------------------------------------------------9 ~& m4 A% x7 A) e" C1 k0 p( W
  696.   # ● 更新. ]4 d5 E, i+ v) e( k# ?) @4 x
  697.   #--------------------------------------------------------------------------) E9 e7 K/ `7 q( R+ |: k6 b
  698.   def update
    % W$ c$ n$ n" ?# x2 A' ]
  699.     super& `: @- D% @% s' e
  700.     @extra_window.update
    3 [: K) K( T, S4 O7 Z& _. U
  701.     update_cursor& p0 c; Y( J9 {" M
  702.   end9 `# v7 f5 K0 h* F% k
  703.   #--------------------------------------------------------------------------. D! r5 `: ]2 ?3 `9 e
  704.   # ● 关闭窗口) Q/ X4 ~5 ~. F- x
  705.   #--------------------------------------------------------------------------! I6 V% c4 v! M$ ^# i9 @* J% E% Y
  706.   def close
    3 u* H! s+ s" ^+ }  t* r
  707.     super  i; j0 H2 `" v' Y! O
  708.     @extra_window.close
    ; |( p9 J) _% t; @  S
  709.     @extra_window.deactivate" L9 \2 N+ |4 \4 L8 r) y' Q% p  P# `
  710.   end
    + V9 G# b7 E3 C9 I5 T3 l+ u" z
  711. end
    " G) b" j. d1 i7 L( [: h. i
  712. + s/ }$ N: ]' }, I3 e- H) w! w
  713. #==============================================================================, j) G0 G( }) k# G
  714. # ■ Window_NumberInput_Ex9 J3 d2 N# s# V$ W+ L
  715. #------------------------------------------------------------------------------
    $ p) n1 S* g" f+ b- e; B. g* i8 {6 W) K
  716. #  新的数值输入窗口(NewClass)6 f1 ]* o4 }% P% s( _+ m4 p' y/ k) j  B
  717. #==============================================================================
    ( @) B$ [5 x$ e
  718. class Window_NumberInput_Ex  Window_Selectable
      [3 b# n% p& l4 q
  719.   #--------------------------------------------------------------------------' o" S$ m: o( |& x9 A5 w
  720.   # ● 定义实例变量
    % Y3 e( |# W' t  H
  721.   #--------------------------------------------------------------------------
    0 u) ^6 f5 X  m  l! l
  722.   attr_accessor number_proc2 L% a2 M4 m$ N0 H
  723.   attr_accessor index_proc
    ; s6 W* q3 Y7 u1 g. I4 O6 B6 ~
  724.   attr_accessor close_proc
    - A) u5 F/ }4 v
  725.   attr_accessor refresh_proc; `2 e( A7 Y: }9 g9 O) J
  726.   attr_accessor number1 S6 x; y+ l% z2 _. `; Q
  727.   attr_accessor digits_max( x$ C2 \  }. F( I2 J( O1 K
  728.   attr_accessor variable_id* b5 j3 a" G! `/ {2 l+ @$ r1 U( U; U- s
  729.   #--------------------------------------------------------------------------
    , K) P3 g0 V# G4 H* k: S* S
  730.   # ● 数字表
    1 B2 F$ E: Z9 y3 h6 J0 E) N
  731.   #--------------------------------------------------------------------------
    - o/ f( ?0 v5 R" n1 a2 U7 e0 L
  732.   TABLE = [  7,  8,  9,- o0 h5 d! x) f
  733.              4,  5,  6,$ q& x# z' v+ E2 F# v
  734.              1,  2,  3,
    ; E# y, p& a  J+ b# Z
  735.             '←',0,'确定',]. |8 b* m2 B" E5 ^/ L
  736.   #--------------------------------------------------------------------------
    - l; Z& K* G% |6 W+ K
  737.   # ● 初始化对象4 E5 L6 T3 v2 r7 q, u& J
  738.   #--------------------------------------------------------------------------
    8 S6 Z) r* k4 T" s1 Z' ?
  739.   def initialize: B6 }* i1 v( c; G0 q4 [" e# p
  740.     super(0, 0, 120, fitting_height(4))+ C5 S( P8 [' Y3 V, |' k
  741.     self.openness = 05 ?  v- [( A* z
  742.     @index = 0( A6 ]4 M& z+ c( Z' Z1 r" D1 F
  743.     @number = 0% X3 J  ~! W& N$ \8 f
  744.     @old_window_index = 01 }0 \0 S9 [, c) S$ |: a. e
  745.     @digits_max = 0
    ; v, q0 J/ [1 U& O7 L# k
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }$ E  ]7 I! F0 s5 ]
  747.   end9 T, w+ w: a9 S  r8 n
  748.   #--------------------------------------------------------------------------
    6 u+ d& ~# N, e: p' F: \$ F
  749.   # ● 获取项目的绘制矩形0 J3 Z1 f/ f! m5 _8 P" Z4 S
  750.   #--------------------------------------------------------------------------5 F7 K0 R2 p5 G: U1 d% R% I
  751.   def item_rect(index)
    5 O  s- {5 [0 _$ W: U
  752.     rect = Rect.new8 G* p' h; g! G4 Q8 P* d
  753.     rect.x = index % 3  32
    4 t, J4 N9 c) J" v2 e
  754.     rect.y = index  3  line_height. Q! v# u! [* X$ C
  755.     rect.width = 32- Q/ F2 Y) Y; M8 w, s
  756.     rect.height = line_height' B. W# j6 L: T9 a3 T
  757.     return rect6 m/ ]$ [3 ]( c6 j3 q6 \
  758.   end
    - U  k) O2 _* F9 K
  759.   #--------------------------------------------------------------------------/ L! v- g* f" v# s5 R/ l% k5 l
  760.   # ● 将光标设置到鼠标所在的位置9 v* N6 y1 K$ ?* }4 E
  761.   #--------------------------------------------------------------------------" [3 n1 e& E, l7 h0 a
  762.   def set_cursor$ ]) r" K  C4 A+ Y
  763.     mouse_row, mouse_col = mouse_window_area
    $ k# M, @: {: I7 M# F) \" e! L+ x6 ~
  764.     if mouse_row = 0 && mouse_col = 0
    ; j* X( G* I# y9 ]
  765.       new_index = mouse_row  3 + mouse_col7 \! K9 s9 E+ w  ]2 x  ?
  766.       select(new_index) if new_index = 119 _7 `& O1 a' g/ [- O
  767.     end
    1 b1 o2 b9 k) Z# L% a: F9 W! ^
  768.   end
    7 U# G6 U* a% ~0 q7 S, Z
  769.   #--------------------------------------------------------------------------
    5 z: p' W2 X* a
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    / M1 g8 [3 u, a# t+ [" \
  771.   #--------------------------------------------------------------------------: \, y$ p+ A: t7 c+ X% N" J( a! I
  772.   def mouse_window_area' ^  _) Z; S# n  w- b9 g
  773.     if viewport.nil; M+ u3 V; u, `/ C' t
  774.       vp_x, vp_y = 0, 0
    8 ~4 G& ~6 v. ~: p) R" n8 a: x
  775.     else
    , \: j8 A" ?' ~/ h
  776.       vp_x = viewport.rect.x - viewport.ox
    1 b$ k6 m( Z9 W' Q; k  j3 p* K
  777.       vp_y = viewport.rect.y - viewport.oy
    ' j8 \0 q) l( U5 R
  778.     end, v4 L; p8 z5 C- x* x! Q' N1 O
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y% z" |. q5 L) j% U+ o9 @% b
  780.     item_x1 = vp_x + x + standard_padding * i  v( Z$ A- {1 U
  781.     item_y1 = vp_y + y + standard_padding. m8 B3 H" @6 N# ]0 E5 k" w2 @
  782.     item_x2 = vp_x + x - standard_padding + width( D" P. d3 D! }( I6 F* q
  783.     item_y2 = vp_y + y - standard_padding + height
    ( `7 I! D8 u4 I8 o2 k
  784.     if mouse_x  item_x1, g/ w8 s" {4 z& \& r" y
  785.       mouse_col = -1
    2 f; K5 Q7 G# D6 S6 S. f2 a. O
  786.     elsif mouse_x  item_x2
    * c7 {7 v& k6 x! K1 ?
  787.       mouse_col = -2* Z' Q1 P. ]; |
  788.     else
    ( f, o0 u& y2 f: X  @
  789.       mouse_col = (mouse_x - item_x1)  32
    " P$ j4 Q& ~3 l( m3 x
  790.     end% ]8 g: [8 j9 E% \5 L6 F4 {
  791.     if mouse_y  item_y12 J+ X+ g0 ?$ P; ?: E0 Z1 L3 ~8 y
  792.       mouse_row = -14 T) ^) A1 w( J7 d6 G
  793.     elsif mouse_y  item_y2
    2 B4 W; @7 h3 L/ a/ F1 f0 J! c0 O: |
  794.       mouse_row = -2
    2 p+ ~0 d" u' [% U
  795.     else
    . J) [$ T' o( x& D+ f. [% M. ]- E3 w
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    & [& i$ V/ o" B4 h
  797.     end: Z- @# ~/ j1 X) J. y/ _! v( d
  798.     return mouse_row, mouse_col0 S, y8 R1 {* z' ], J
  799.   end
    . F/ ~: f" H% |8 \
  800.   #--------------------------------------------------------------------------
    / c2 g2 p, E% |3 }! P2 W9 Z$ D( F( X
  801.   # ● 获取文字0 S- u- m( |0 n# ?8 y, c
  802.   #--------------------------------------------------------------------------3 x0 F% k) d) ?) D% B
  803.   def get_number
    ! i) H% M; I" ]7 C6 J* Q! S
  804.     return false if @index == 9  @index == 11
    - ^& C9 l* ~2 g- d2 w# C- b4 ^
  805.     return TABLE[@index]
    ( W& g# e) L+ C
  806.   end
    + E) L! d" Q) c
  807.   #--------------------------------------------------------------------------/ W' O% t6 g! Z  K/ q2 p  s
  808.   # ● 判定光标位置是否在“退格”上
    / K% }) D5 D+ E3 e% W0 X! w2 C) E
  809.   #--------------------------------------------------------------------------9 ]+ s( u; Z$ F5 L, c) P
  810.   def is_delete
    7 X% H3 \' r- x( @+ f
  811.     @index == 9; n# r6 n$ m3 F$ K) F" u
  812.   end
    & D. v( G+ N  P) w
  813.   #--------------------------------------------------------------------------
    0 C+ f' p% X) U, B# S/ d) v
  814.   # ● 判定光标位置是否在“确定”上
    / W8 U1 U! q* W. p8 e4 G+ c
  815.   #--------------------------------------------------------------------------
    ( e* A" i6 V9 |7 U4 e
  816.   def is_ok
    3 @- u" B9 g( D% @; @
  817.     @index == 119 u# s$ z8 d  p
  818.   end
    / n, m! @. I2 {4 S8 ?: v$ u
  819.   #--------------------------------------------------------------------------
    & r3 `, p( ~7 k$ z2 p0 P
  820.   # ● 更新光标
    " N0 M  A9 Z2 }5 X$ V# j3 z" k
  821.   #--------------------------------------------------------------------------% W: ~/ Y) r, H  f
  822.   def update_cursor
    0 d7 [( [9 J( q& v, p
  823.     cursor_rect.set(item_rect(@index))
    1 w: {: ], P9 o9 q6 {
  824.   end
    . d& w$ b" d9 l
  825.   #--------------------------------------------------------------------------1 U2 Z  D  e% t6 g) D) J1 E
  826.   # ● 判定光标是否可以移动+ z' p/ [5 S# f0 \% j) \
  827.   #--------------------------------------------------------------------------
    6 v- l! o; D* c  z
  828.   def cursor_movable
    * k% h9 S" B6 G9 A. O
  829.     active1 W) D8 ^+ L' I0 d; F) v5 v
  830.   end
    : E: W5 i3 f  C
  831.   #--------------------------------------------------------------------------
    2 u* S- B2 Q/ u  n
  832.   # ● 光标向下移动+ S9 U2 h: |- _) G
  833.   #     wrap  允许循环
    ; L. m# `/ L2 L& e
  834.   #--------------------------------------------------------------------------* P% y- n# [) Y+ v6 i
  835.   def cursor_down(wrap)
    ) h3 a/ A$ I* ]* P' I; V
  836.     if @index  9 or wrap: a2 ^. ]0 N1 ~! g, j
  837.       @index = (index + 3) % 12
    % m% E# ?+ U1 D$ C8 ~3 \
  838.     end; }) c; m+ ~; z2 n( r. S% |
  839.   end! {, ^: f+ Y5 W. w* l
  840.   #--------------------------------------------------------------------------  D$ o- Y' O- H! D
  841.   # ● 光标向上移动
    9 ^' V7 N; i0 y1 _7 v
  842.   #     wrap  允许循环9 ?& R" V1 u/ D6 [; @
  843.   #--------------------------------------------------------------------------
    * B5 N* m. M9 j" o6 H: t
  844.   def cursor_up(wrap)
    & X2 ~2 P. f7 B' V. n# w
  845.     if @index = 3 or wrap
    6 ^. F4 q7 q, a2 j3 ]" \* Z
  846.       @index = (index + 9) % 12
    5 [' k3 I, @2 L, S
  847.     end& p% }' E7 q" U4 Q: T7 C& x
  848.   end5 a/ [' A; a6 d
  849.   #--------------------------------------------------------------------------
    ( F* d( E4 y7 q" c0 J( O
  850.   # ● 光标向右移动- o2 p1 Y* L/ i1 i/ c
  851.   #     wrap  允许循环
    : q2 Q/ M9 ^7 K* n4 z+ [( w  O% X
  852.   #--------------------------------------------------------------------------
      ]& w: G3 @2 V
  853.   def cursor_right(wrap); o/ @( g4 D  [2 {$ Y, g/ Y
  854.     if @index % 3  2. l' G6 c, ?. R
  855.       @index += 1, z1 t5 C, Y4 p/ J1 k
  856.     elsif wrap
    " \' b" ^. |# G$ @9 p) k7 ^
  857.       @index -= 2
    9 _' j/ F8 _) o; s0 H+ w
  858.     end2 D, M/ M% t  k, {  A
  859.   end3 j" o2 U( k2 a; B  m: y
  860.   #--------------------------------------------------------------------------
    9 _9 E! H- W6 f% O$ N$ r+ b
  861.   # ● 光标向左移动/ u- G0 D, e; Q; o6 B4 j8 w3 P
  862.   #     wrap  允许循环* i  H6 E# f2 d4 Z, h6 Z
  863.   #--------------------------------------------------------------------------% b7 h1 k* v4 J/ U& F
  864.   def cursor_left(wrap); y  n" z1 s! y
  865.     if @index % 3  02 f) p" {: m: w, d! K
  866.       @index -= 1  }) B. u8 H: t' I
  867.     elsif wrap
    . N. n8 K% H) [% I5 E- u
  868.       @index += 2
    " y5 p% W8 v+ k% Q
  869.     end/ Q4 i) j( ~, c/ U% v
  870.   end
    + L4 d+ V  C7 K3 {6 w
  871.   #--------------------------------------------------------------------------# O( g  n1 }( G5 [  }) H1 I
  872.   # ● 处理光标的移动5 i+ f) i: Y. A# N0 W9 l" f* [
  873.   #--------------------------------------------------------------------------
    3 [6 x9 i- J3 x% s6 }3 v* D3 A
  874.   def process_cursor_move
    7 }" l3 k- X% w* {! M5 C
  875.     super
    - d+ `* _  B$ u" m% i
  876.     update_cursor
    * A" S& e! H& u: d8 o( E' a- ^
  877.   end
    * ^' G$ @9 X4 A* v6 M
  878.   #--------------------------------------------------------------------------  ^- P9 }- o* Z) T
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    8 n6 _; T! `7 R4 {/ i- m
  880.   #--------------------------------------------------------------------------
    7 S7 [0 V# Z( w. S
  881.   def process_handling
    ! S& S) R+ E; a
  882.     return unless open && active
    ' a: I6 _9 x0 I0 j
  883.     process_jump if Input.trigger(A)
    " S6 a* z2 E! e/ T# p/ n, [$ b
  884.     process_back if Input.repeat(B). N$ o0 @3 p0 M7 v9 S: G- L
  885.     process_ok   if Input.trigger(C), `  K- V9 I) z8 U$ E$ n' n4 f" r
  886.   end
    % B; z# c2 u& _
  887.   #--------------------------------------------------------------------------
    ) N8 q( m' B  t& n
  888.   # ● 跳转“确定”
    & C4 T0 K1 V- ~
  889.   #--------------------------------------------------------------------------% @$ Z/ Z8 V! _- d7 O
  890.   def process_jump
    $ X) y+ q& s1 }/ {
  891.     if @index != 11
    * Y  [1 K9 q2 l: N0 G) v% S
  892.       @index = 11; u( f; d# q) R
  893.       Sound.play_cursor
    3 f- I+ i& L3 t! @
  894.     end0 G0 }2 l$ z& T/ n9 N
  895.   end) Y+ {8 Q- e$ _6 Q
  896.   #--------------------------------------------------------------------------
    9 u! C2 Y! l9 ?
  897.   # ● 后退一个字符6 e! Z5 B1 a, L7 `; c
  898.   #--------------------------------------------------------------------------) u" C+ `' t9 z' [: E* P
  899.   def process_back7 ~  E( n: l( V2 n; U/ F# u
  900.     Sound.play_cancel
    5 I8 I- `5 F8 `6 p. g+ Q
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    ( v% {5 X+ F, ]1 ?- n% T
  902.     n = (@number  place) % 105 t+ Z- I$ l5 u) M$ |& P
  903.     @number -= n  place7 f/ z1 }+ S9 A, N- V- {
  904.     @number_proc.call(@number)
    4 `/ k- @2 G' z1 I6 l5 \3 W* g  b
  905.     @old_window_index -= 1 if @old_window_index  0$ b8 z2 R5 k, B0 D. O
  906.     @index_proc.call(@old_window_index)5 b( c/ d0 d( ~; [) y5 w) U
  907.     @refresh_proc.call- Q( l3 h2 k7 L4 s
  908.   end
    ( `  o5 d5 P6 d0 I. [$ L& X6 f
  909.   #--------------------------------------------------------------------------& q! ?  p! X; p* b4 Y) w; J
  910.   # ● 按下确定键时的处理: a" F3 O& {% f: \+ [% p# l
  911.   #--------------------------------------------------------------------------7 l# K2 \/ v/ z7 y$ l2 |
  912.   def process_ok
    / y4 o+ F5 p3 _7 J
  913.     if get_number
    ' |& G% p9 ?# E( {3 P. e; {
  914.       Sound.play_cursor/ t' I5 U; B1 V
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    / [7 a, ?4 B& E! j
  916.       n = get_number - (@number  place) % 103 V* E* X1 u3 B( x
  917.       @number += n  place" |, w5 C! c8 [) c6 O+ S
  918.       @number_proc.call(@number)
    : J# k: i" {8 I% _- N) p. X9 {
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1; a) I3 I- K; y. D" C) C
  920.       @index_proc.call(@old_window_index)0 @* X  L$ \" S6 S. `1 s
  921.       @refresh_proc.call
    5 T9 d; o% y& L- w% {
  922.     elsif is_delete* E8 P& s1 H; L* m6 G
  923.       process_back' K9 v6 ]' L; k5 {
  924.     elsif is_ok" K" |5 O8 |" T
  925.       on_input_ok
    ! h% {. ~8 S/ n! J& c0 k9 ~
  926.     end5 A0 q7 ~! u6 v; A( E5 Q3 p
  927.   end
    : F/ s+ G4 P" w  W2 J
  928.   #--------------------------------------------------------------------------
    ' C8 l8 }& ^: p5 ?/ K
  929.   # ● 确定
    , W, a0 I# W6 ~3 |
  930.   #--------------------------------------------------------------------------* [- g- x& P. B3 ]1 O0 r
  931.   def on_input_ok
    ( `% }! ~. T. X' p2 W& {
  932.     @index = 0
    ' E. }9 n( n" `
  933.     @old_window_index = 0
    8 A7 t4 D. y7 d  l* Z2 {
  934.     $game_variables[@variable_id] = @number
    / ~! S, t" A- n, m1 J; g4 O* O1 U
  935.     Sound.play_ok
    2 n* r" X4 X2 a7 z+ n! r
  936.     @close_proc.call
    3 |0 A; {* o$ |5 Y3 p
  937.   end4 r' S5 \" j4 p- p5 [
  938.   #--------------------------------------------------------------------------
    3 o& {" H. w' _
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置9 N8 g7 T, o( A- i
  940.   #--------------------------------------------------------------------------1 u: A! U4 n+ O/ d0 O
  941.   def set_mouse_pos
    5 ^( h/ L# R% |* `3 l' `8 e
  942.     if viewport.nil # necessary!
    7 R/ |; d5 P2 F
  943.       vp_x, vp_y = 0, 0% y! m; e; L- A# i. T
  944.     else4 ?7 @8 F6 ~/ S$ R: w7 F
  945.       vp_x = viewport.rect.x - viewport.ox% z$ {: T4 b8 [- t
  946.       vp_y = viewport.rect.y - viewport.oy7 E* o% A  @* k: i  Q/ x
  947.     end  c) K6 W& Z5 R
  948.     item_x1 = vp_x + x + standard_padding
    " {& r& C' M  u) F
  949.     item_y1 = vp_y + y + standard_padding4 _/ l* R; a# Q2 n" {4 p, A/ I" P& a0 ?
  950.     get_index = @index  0  0  @index
    9 ]" Z$ b% R8 G1 S' e& K
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)* P& ]/ z( S9 S9 k. p/ d
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    $ X; R  A( J4 U/ q: O+ i
  953.     Mouse.set_mouse_pos(new_x, new_y); [* x  Q+ a- K! E; Z2 V) Z2 |
  954.   end* k# [4 N7 l0 @6 q( a2 V1 \5 p
  955. end9 z4 o; s5 Y, D" b

  956. ; m( c- O  H+ G$ U1 C) V$ r$ l  P8 U( i
  957. #==============================================================================
    6 B3 }5 h: D) V' E' ]
  958. # ■ Window_Message
    0 r' ^, w" |4 S& j* b
  959. #------------------------------------------------------------------------------
    - J! J. {4 A. Y
  960. #  显示文字信息的窗口。' N3 S/ M* T/ {3 H8 u' m
  961. #==============================================================================, c+ k5 p5 N; \, U5 F; I
  962. class Window_Message  Window_Base
      V( e# [2 q, i) h+ G
  963.   #--------------------------------------------------------------------------
    6 N: w$ X1 X7 Q& {3 F
  964.   # ● 处理数值的输入(覆盖原方法)
    * B  c. t; T0 ~# R% {# l9 b, {
  965.   #--------------------------------------------------------------------------" p; w* S1 [0 L/ i. L
  966.   def input_number* X% O2 q. L$ V! Q
  967.     @number_window.start! p- c  _7 W6 a. c9 P7 }0 s
  968.     Fiber.yield while @number_window.extra_window.active% q' s8 ~' @: A" Z% ~- m& z
  969.   end) _" |' x" |+ `
  970. end
    & n+ P3 e" E1 \4 w3 c3 y: g
  971. % i6 m* T  g; x0 A* f1 b3 C" y
  972. #==============================================================================
    - D; g, m/ g" }' W( U  x2 b
  973. # ■ Window_PartyCommand1 z. Q, U* L: R# n
  974. #------------------------------------------------------------------------------- I+ K+ ^: a( `2 r7 F! q" X
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    " G$ ]4 w8 [( M' V( Y* u
  976. #==============================================================================: _( l( s6 f  z( b( e5 C2 e
  977. class Window_PartyCommand  Window_Command7 s8 f2 S2 M' H: E
  978.   #--------------------------------------------------------------------------
    7 @" Z3 c+ y0 h; ~, d% T* q" r
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置+ l- x# Z7 Y6 h( C2 I, x3 Y
  980.   #--------------------------------------------------------------------------/ F, X' q# R: `  O+ ?+ w, O
  981.   def set_mouse_pos! L- }/ c$ B* F3 ]
  982.     if viewport.nil3 i. c: z1 {. h. {7 t; O
  983.       vp_x, vp_y = 0, 0
    & d1 w4 h) b$ L9 }
  984.     else& T# ~, |$ [  L0 n# m# \* ^
  985.       #vp_x = viewport.rect.x - viewport.ox/ `7 m. p" B/ A0 M
  986.       vp_y = viewport.rect.y - viewport.oy
    5 \+ _$ u% I" G0 g3 A! E
  987.     end
    4 i( I+ {- p  `
  988.     item_x1 = x + standard_padding ( R9 y% k8 N& h. u4 B
  989.     item_y1 = vp_y + y + standard_padding
    % E! s3 B2 h6 e
  990.     get_index = @index  0  0  @index # P% ^4 @6 G4 d* |" J2 ~
  991.     row = get_index  col_max - top_row; q7 T: u4 {7 G. @# f/ a6 @
  992.     col = get_index % col_max" N, M* B; ]4 j0 j# ?+ \& c
  993.     new_x = item_x1 + item_width  (col + 0.5)1 K: w! t" u0 x! c$ C/ a# f
  994.     new_y = item_y1 + item_height  (row + 0.5)2 R+ j. }, [9 u4 [' _' W
  995.     Mouse.set_mouse_pos(new_x, new_y); {2 g+ g! s: `0 ~! x) `
  996.   end( P8 R5 ?. ^) Y, w+ A
  997. end
    * D2 q: G) A( Y# T4 @6 U4 k, z
  998. $ v, {/ I: I2 p0 n9 v2 v
  999. #==============================================================================, e, f  f. q! W
  1000. # ■ Window_ActorCommand0 @  ?% e0 j8 T6 {2 O, v& v1 a
  1001. #------------------------------------------------------------------------------
    ( c0 g+ t! A& g- e: h5 U
  1002. #  战斗画面中,选择角色行动的窗口。* Y4 B% r4 A+ I+ M8 k, V
  1003. #==============================================================================
    / B$ J5 I; N) \* x; ?8 S$ k
  1004. class Window_ActorCommand  Window_Command
    6 F$ o- @) `: `+ _2 W, n
  1005.   #--------------------------------------------------------------------------! K3 @% m$ b6 w+ U, E" [, r" h
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ) `& K! M1 O* d$ ^, h* d; t
  1007.   #--------------------------------------------------------------------------' [. z3 v" ~5 a( c2 ?
  1008.   def set_mouse_pos
    . p, E- d; C* E1 g) u
  1009.     if viewport.nil$ h9 M9 ^/ o  ?# {9 L+ L
  1010.       vp_x, vp_y = 0, 0
    0 p$ M+ V/ t6 g  v1 ~7 H
  1011.     else$ D) q; N! {+ x) B
  1012.       #vp_x = viewport.rect.x - viewport.ox
    . n' b& r/ `$ C
  1013.       vp_y = viewport.rect.y - viewport.oy
    $ r4 v3 u8 p. ~4 _$ G5 t
  1014.     end
    , V8 a" `: \, ?, A7 R. Z
  1015.     item_x1 = Graphics.width - width + standard_padding1 r6 g6 ~/ _2 x6 E, b! T6 g; r7 g
  1016.     item_y1 = vp_y + y + standard_padding' u/ f, x$ {5 q+ P/ }+ s& x
  1017.     get_index = @index  0  0  @index
    0 ^8 q9 H( z4 C6 D' [9 q! j% d
  1018.     row = get_index  col_max - top_row! z% Y5 i1 Q; S' s) s- d8 s5 T. b1 l
  1019.     col = get_index % col_max9 [+ `$ I5 _, ?% D7 G
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    5 x- e7 d! T' y; j6 V8 T. o, q
  1021.     new_y = item_y1 + item_height  (row + 0.5)  y0 ^, m0 v, D) I( v/ q  O6 A+ M
  1022.     Mouse.set_mouse_pos(new_x, new_y)! q9 ]; p5 p! K  ~& N$ F
  1023.   end1 E  c* j* r/ P; l7 K, K2 I& B
  1024. end4 t6 S4 M# h4 l5 N

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

  2145. . M) }! }  m2 G9 }
  2146. #==============================================================================
    & i! P- e- r: o
  2147. # ■ Game_Map% n0 \4 r9 W9 V- L/ w: @
  2148. #------------------------------------------------------------------------------
    1 a: Z4 ^/ O6 T# a0 G; R- W
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。% x# V3 W' ^0 o0 t/ N3 a) Q* b
  2150. #   本类的实例请参考 $game_map 。
    2 Z7 t/ s2 ?8 Z* K
  2151. #==============================================================================, P, g3 \7 x8 |# _7 z/ i
  2152. class Game_Map* i0 |# Y0 k; r# L* y3 B
  2153.   #--------------------------------------------------------------------------
    8 S" ]) S! y" B0 N
  2154.   # ● 定义实例变量
    6 g& {9 Y4 q$ ]& p
  2155.   #--------------------------------------------------------------------------
    7 x  ?) W  b" {1 ^
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据: ^9 |4 \1 t* k
  2157.   attr_reader mouse_map_y # 同上' p9 `; X/ L8 _1 N, u% f# F0 Q
  2158.   #--------------------------------------------------------------------------' b9 a: ^, h* _5 l& t; K4 ]( ~2 T
  2159.   # ● 初始化对象
    ! ]: g$ [- [3 k' R4 {% M
  2160.   #--------------------------------------------------------------------------
    7 W8 x% G4 C, |* x; M5 q' I. i
  2161.   alias sion_mouse_initialize initialize
    % c% `* `% t+ q8 `0 B. g
  2162.   def initialize
    ! G4 w8 X' y! s, K
  2163.     sion_mouse_initialize8 h' a5 j8 u' P3 U3 I* c2 f& {8 a
  2164.     creat_move_sign  ###
    9 j0 w6 R4 i4 l% s& g+ o3 n! m7 z: F
  2165.     set_constants- T$ ^, l$ j/ s4 g7 E5 y
  2166.   end
    + s! W) u4 R* ]4 ~: O- A) f
  2167.   #--------------------------------------------------------------------------9 P, v6 {$ K6 p' X2 o. T
  2168.   # ● 更新画面$ x. t6 B1 @# N. x" |; ]" {
  2169.   #     main  事件解释器更新的标志
    / \" N6 h! ^# `5 H" ?/ k1 i
  2170.   #--------------------------------------------------------------------------
    . [  p, W4 S: q( l  S8 G
  2171.   alias sion_mouse_update update
    7 `$ A" H" r  r) H5 W. f& K
  2172.   def update(main = false)$ y0 b9 \$ a+ y! W) }0 e8 L6 d
  2173.     sion_mouse_update(main)3 Z- a  [7 ^* p$ X! p( L6 b
  2174.     update_move_sign
    . @, q9 t* g9 q" z; b) z9 N
  2175.   end
    & H8 E& s4 t- E- e+ S9 E
  2176.   #--------------------------------------------------------------------------& K' j6 q/ m; K* r  H* d
  2177.   # ● 创建显示路径点的事件6 m# A; z8 _2 D8 v  v9 f5 y* l
  2178.   #--------------------------------------------------------------------------$ O' z5 c5 c' f3 x
  2179.   def creat_move_sign+ G" ~, _2 ]7 ?6 K# B
  2180.     $mouse_move_sign = Move_Sign.new
    ( p. H# O0 F* K) A
  2181.   end+ C4 B0 h8 Y/ G8 Z
  2182.   #--------------------------------------------------------------------------
    # k  \) v4 ~  l6 v
  2183.   # ● 更新显示路径点的事件3 T4 K3 K9 J4 H9 q" \% X3 c
  2184.   #--------------------------------------------------------------------------
    ' X  Y! e) K/ M4 Q8 |2 t- Y
  2185.   def set_constants
    8 C) v# R, X( ]! b# p" K
  2186.     @mouse_pos_setted = true
    : i) H( S) u% K4 I
  2187.     @set_pos_prepared = false
    # w, a5 b* G- d9 [) p
  2188.     @mouse_old_x = 0
    , }/ F2 r2 }; @& U5 ^1 ?' ^5 x
  2189.     @mouse_old_y = 00 V' {: T9 @/ f5 f
  2190.   end
    ' K" f# ~1 h5 J2 C. a+ O' D
  2191.   #--------------------------------------------------------------------------
    9 T) d) n8 w, `6 [/ Y3 ?% `; Z/ i
  2192.   # ● 更新显示路径点的事件/ `) o. g% Y! [8 h  e
  2193.   #--------------------------------------------------------------------------5 v& K; ]" O; Q* z% g( u
  2194.   def update_move_sign7 P" j/ B5 ]% }3 r" x
  2195.     $mouse_move_sign.update
    ' J2 b) N* h# m, r! O
  2196.   end
      _# @$ E9 D8 P$ s3 H
  2197.   #--------------------------------------------------------------------------9 S! S5 ]1 x2 J' K  J
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    , C' |& y  z+ R7 Z
  2199.   #--------------------------------------------------------------------------8 `% a5 q4 a7 a% d& S( R$ T
  2200.   def get_mouse_map_xy( \6 r8 a- ~6 r8 X1 J2 c  x
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y) w& G, @' X4 A
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)- `  x; Y7 T1 ?
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    ! Y" B6 T. x6 v9 L. W2 t
  2204.   end" V4 ~/ y3 v6 m9 G5 G
  2205.   #--------------------------------------------------------------------------: {% W: x  l% ]' s6 ]5 {9 [0 z. b
  2206.   # ● 返回地图画面时重设鼠标坐标: c( p" n3 t! j$ z: @1 D3 h
  2207.   #--------------------------------------------------------------------------
    ' x0 P( s! q7 {% S( [4 i' a: x9 c
  2208.   def reset_mouse_pos) |0 Y6 M0 D" n3 q
  2209.     return if @mouse_pos_setted
    8 H) M% }% h" V- {8 [8 B4 H5 v
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
    ) D9 i0 ]3 w7 U$ g
  2211.     @mouse_pos_setted = true& \! `3 V; g) C: y9 C# c( p' U* J
  2212.     @set_pos_prepared = false
    ' j; W1 c+ h2 C; B; A
  2213.   end8 w$ ~' c2 o, A. a
  2214.   #--------------------------------------------------------------------------5 q' [7 V/ K4 Y& {! C, k0 ~
  2215.   # ● 重设鼠标的坐标
    * I8 S) O  ~  T: c& w; n
  2216.   #--------------------------------------------------------------------------. ~4 A, y1 k' ]( B, v
  2217.   def prepare_reset_mouse_pos
    / E% Q3 @, d5 h" h  |, ]/ y
  2218.     return if @set_pos_prepared" |: X4 y2 j  b9 }4 D0 K
  2219.     @mouse_pos_setted = false3 o6 H- h9 F, E4 Q; ?
  2220.     @mouse_old_x = Mouse.mouse_x
    + m, z* w* s  V- ?% G$ V
  2221.     @mouse_old_y = Mouse.mouse_y: Z% n/ F8 |4 k1 p2 m( r# M, B* [
  2222.     @set_pos_prepared = true, ~# u) F% k# {6 H+ }1 t
  2223.   end
    % t% w+ s; Q" x( y8 @
  2224. end- g9 r$ h" }7 s3 I

  2225. % D/ E3 H/ h. j
  2226. #==============================================================================
    5 o9 L, ^$ w4 q' X9 Y4 q" {
  2227. # ■ Spriteset_Map1 H! H) I2 x) \, y7 A
  2228. #------------------------------------------------------------------------------
    % ?* N. l! m( K8 r  f3 @
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    % X, P  ^7 ^! h3 N& D
  2230. #==============================================================================9 P. ~3 o2 E7 G7 y' B+ }
  2231. class Spriteset_Map
    1 r/ |+ O3 ?! d$ I1 E, q
  2232.   #--------------------------------------------------------------------------0 R. @. z5 r  G
  2233.   # ● 生成路径点精灵7 C$ E8 Q, d: R! g
  2234.   #--------------------------------------------------------------------------1 s  J9 n6 Y5 A! n
  2235.   alias sion_mouse_create_characters create_characters, ^3 @& V1 q/ ?1 c! K
  2236.   def create_characters; k* e! i) h5 c3 v6 H
  2237.     sion_mouse_create_characters
    . Y& E7 D- g+ {; B. E( K
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))4 M2 i% G: a2 L) S2 o4 i. B  h2 j
  2239.   end
    ) C+ V1 M' ?; D
  2240. end
    6 w) ?9 O4 n7 V  Y6 ]3 [2 n

  2241. % X, ~  D( i' B6 k5 }( L7 g' s
  2242. #==============================================================================
    0 y$ R4 [- j  X, J& I
  2243. # ■ Scene_Map$ m3 o, I, ^+ L' V  i
  2244. #------------------------------------------------------------------------------
    # V2 a8 y$ Z+ q9 ?7 V1 g
  2245. #  地图画面
    1 x% L2 T3 z+ J" O2 _; \( d% a3 d
  2246. #==============================================================================
    4 W- D8 \# x) _- B% i+ X
  2247. class Scene_Map  Scene_Base
    0 H# s$ o4 J  m* D3 _4 |5 L
  2248.   #--------------------------------------------------------------------------1 B, p2 `3 m( ~" B; z: z8 _# A( R+ _# k
  2249.   # ● 画面更新
    - r: `* S$ t  t/ B: s: K/ N
  2250.   #--------------------------------------------------------------------------9 x# I. E( i4 t: ^/ ^( f2 p) M
  2251.   alias sion_mouse_update_scene update_scene# C& f" r+ J+ N* _% D4 z8 }" _
  2252.   def update_scene
    0 \% o3 l4 o7 ]  H: X- ]3 a1 l) ^& c
  2253.     sion_mouse_update_scene: C7 B& e8 i+ ]& d( I" W
  2254.     update_mouse_action unless scene_changing
    - z! t1 h# `/ L* S* U4 B3 G
  2255.   end
    $ C3 J: p# W% d, v, M  x# O6 k
  2256.   #--------------------------------------------------------------------------9 H. J( N5 m1 Z1 H1 I! E3 Q
  2257.   # ● 场所移动前的处理
    2 n* `2 a3 s, @( M# i7 W# d, h
  2258.   #--------------------------------------------------------------------------
    6 M" y7 c& \! w$ v  O; `
  2259.   alias sion_mouse_pre_transfer pre_transfer
    # V9 i8 Z- [# @5 R+ `
  2260.   def pre_transfer
    9 O& i7 e+ e$ N9 [; l; R
  2261.     $game_player.reset_move_path
    3 v; U  W. \' F, M0 D
  2262.     sion_mouse_pre_transfer
    + g+ l1 l2 ?: w/ q" ?' @( c5 ^
  2263.   end
    6 t$ {2 A, d7 c; c4 _
  2264.   #--------------------------------------------------------------------------& e; }% E* `5 a  V, O' G
  2265.   # ● 监听鼠标左键的按下
    . K2 t1 R7 C! ~9 A$ t
  2266.   #--------------------------------------------------------------------------
    ; h  V* {+ J( p$ z* v; e. u" G
  2267.   def update_mouse_action$ X/ J8 d1 h9 R' p
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    6 x# ~) g7 m$ l# L  I  [
  2269.   end* m4 q2 R  L0 B( F% b3 F9 |
  2270. end
    ! A. z2 |/ x, l3 ?% P4 ^
  2271. , U& j& }% q9 |3 L& G+ s- N
  2272. #==============================================================================3 D/ p/ q/ B, W! ?
  2273. # ■ Scene_File# J. x* ]! C3 _: k3 `+ B5 e8 Y6 g
  2274. #------------------------------------------------------------------------------; t/ x% i+ M' B) A4 V, c
  2275. #  存档画面和读档画面共同的父类
    4 H8 D% l* h/ B1 j1 p) `
  2276. #==============================================================================/ T3 m7 A9 Y9 {; z* |9 W- K
  2277. class Scene_File  Scene_MenuBase
    - t8 Q( W# Y; x  M
  2278.   #--------------------------------------------------------------------------
    : }& ?) l: }6 \4 h" v  a
  2279.   # ● 开始处理
    - [1 M$ V% e4 {0 b
  2280.   #--------------------------------------------------------------------------
    7 I5 ?$ n8 W1 m3 ^
  2281.   alias sion_mouse_start start5 f* J# Y1 n$ C% H* w3 U
  2282.   def start% E0 s) K7 s: l
  2283.     sion_mouse_start
    8 r+ w. l% M0 o
  2284.     @move_state = 01 z6 O& \3 Z8 M; G
  2285.     set_mouse_pos' p, y/ I2 ?& K  K& F/ M
  2286.   end7 G0 q$ ]1 _, i9 k" v* H; C( Y
  2287.   #--------------------------------------------------------------------------
    + p5 d# q5 R5 Z! d  ]) q5 W! u
  2288.   # ● 更新画面
    5 {8 N0 B  T- q
  2289.   #--------------------------------------------------------------------------- P% W4 i$ p+ _8 v2 F
  2290.   alias sion_mouse_update update+ g6 F! ~- c5 i' ~
  2291.   def update
    . e1 u% h% p" I/ U4 `% X
  2292.     sion_mouse_update$ t! E4 h* L9 z; @. l& a9 |) i1 `
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos: R3 Q+ B4 F1 l9 M% Z
  2294.   end# g% X: J8 z2 W  N1 {6 E% n
  2295.   #--------------------------------------------------------------------------
    ' U7 z5 k) S& n: O$ r' a) O+ h- |
  2296.   # ● 更新光标
    8 ?8 g+ T4 M) i" g
  2297.   #--------------------------------------------------------------------------
    ' B/ p! t9 a6 v; j/ o. q5 Q$ X
  2298.   def set_cursor" k; B) u8 `0 J8 ~
  2299.     @move_state += 1
    1 V- d4 x, r4 V
  2300.     last_index = @index$ ^  _3 G$ u7 n, R) @5 R
  2301.     if mouse_which_window == -2- Q/ p  ~& a: G# y  h
  2302.       if (@move_state - 1) % 6 == 0( }! N0 }% Y; c) P! ]1 z4 Y/ _, z
  2303.         @index = (@index + 1) % item_max if @index  item_max - 18 ~& Z4 ]3 k* a8 A
  2304.       end
    * x! i/ h5 N3 J8 A- B7 W; m+ j# A
  2305.     elsif mouse_which_window == -1- {2 F6 g" {  j. I/ @1 q
  2306.       if (@move_state - 1) % 6 == 0
    ( q  u6 h  T1 f% @4 f5 t
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    ) U2 H) i0 K0 i
  2308.       end/ r1 S8 s7 H6 h) w5 {) s  g
  2309.     else: r2 J% B& F% Q5 _. }9 \
  2310.       @move_state = 0
    7 p, v* k' K% U6 n, T, ~
  2311.       @index = top_index + mouse_which_window
    $ K' l( G. L: J4 \0 V, a! W& k! ~
  2312.     end
    . k1 B- \9 W, z1 d* s2 r
  2313.     ensure_cursor_visible, H7 `. j! B6 _* d
  2314.     if @index != last_index& K; W6 g+ q# z
  2315.       @savefile_windows[last_index].selected = false
    1 f& [7 M6 w- `  \& C0 E  f1 i
  2316.       @savefile_windows[@index].selected = true' W$ W- j# ~( b: a5 F! |/ a/ q
  2317.     end6 C. B8 a2 M7 ^, R
  2318.   end
      s4 U5 ]7 G8 X! p2 s+ f6 u
  2319.   #--------------------------------------------------------------------------: o! E" S- U! C; F$ Y3 R
  2320.   # ● 判断鼠标位于哪个窗口
    8 I7 r  J5 w4 Y7 t
  2321.   #--------------------------------------------------------------------------
    8 [0 U$ \- V& \& U, ~
  2322.   def mouse_which_window  C. F( v1 X. d8 ?# X8 W$ Z
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y5 k# x$ c: I: P  l/ N
  2324.     if mouse_y  @help_window.height + 14
    # v' P3 [! @9 \
  2325.       mouse_row = -10 i2 R- O; e9 @  q; M8 G
  2326.     elsif mouse_y  Graphics.height - 14
    ' H; t, m2 j% b1 C9 Z) ^
  2327.       mouse_row = -2' f) F) N1 _" r" h
  2328.     else8 o- c6 M3 k& C4 |
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    3 f2 a3 b) q# E# x" x8 s9 O
  2330.         (Graphics.height - @help_window.height)2 F& }) f3 ~# D* K0 J# R4 Q
  2331.     end
    , K$ D* {, a) r; y6 }) _6 y
  2332.     return mouse_row
    ' o; Z' C+ t& r0 e
  2333.   end
    ! P" Q  f+ T0 g9 c" ]
  2334.   #--------------------------------------------------------------------------1 z8 t  u* n9 k( y
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置6 S7 d8 I* {1 ^$ Q" T8 d/ F
  2336.   #--------------------------------------------------------------------------1 b, Z( g5 L: ]& f0 Q6 ~6 y' L
  2337.   def set_mouse_pos, Z, w% c2 h: e: F' j
  2338.     new_x = 40, X" k" e1 z9 n+ k: T: \/ g( K! i
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    8 E% F# Q, {* w
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    8 U: u  b$ d+ {; x
  2341.   end
    8 J& D3 D$ X  s% O. t" N* m
  2342. end3 L  [# `" z" _

  2343. - G' B1 Z  Q/ l, S3 D
  2344. #==============================================================================
    * |9 N9 Z6 |, O0 Y: P9 z
  2345. # ■ Game_Event' P/ _: a6 T1 H' u
  2346. #------------------------------------------------------------------------------0 Q, \& D$ T8 L: G9 X
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    2 o9 z9 x. }4 e
  2348. #   在 Game_Map 类的内部使用。% K8 g2 }/ h1 X1 o4 Q2 N  {8 N& G
  2349. #==============================================================================8 }8 a) B  V1 q5 j3 H
  2350. class Game_Event  Game_Character& |( P, p% S! v* u& \
  2351.   #--------------------------------------------------------------------------
    + c2 B  C. i/ q5 O+ L
  2352.   # ● 事件启动: m8 A* G: |0 i$ \7 ]
  2353.   #--------------------------------------------------------------------------  w, O) F; f2 p, Z: j: {7 u$ X6 H
  2354.   alias sion_mouse_start start( g: [& o0 Y8 o8 f+ L8 K6 \
  2355.   def start
    / i: ]. G1 w+ n- B
  2356.     return if mouse_start && !Mouse.press(0x01)
    ' j8 D, F* H- a: }% Q7 F
  2357.     sion_mouse_start0 ]: A9 K* G% b: S1 C7 v  r# Q$ B
  2358.   end% d$ z+ |' \! @6 ~+ G
  2359.   #--------------------------------------------------------------------------9 W6 Q- ~2 o; A" v. u( ^. [2 I
  2360.   # ● 判断事件是否由鼠标启动( c# S( e& J7 i5 q, N: p! b$ E
  2361.   #--------------------------------------------------------------------------8 L7 h" V& A+ ^& e! i+ x$ x+ l
  2362.   def mouse_start
    . V3 O) ]/ l0 M( `2 ^3 X) C
  2363.     return false if empty
    : c( i5 x! x) d$ o9 ^1 ]7 j
  2364.     @list.each do index! _+ K! S  b. ?
  2365.       return true if (index.code == 108  index.code == 408) &&
    9 A" V! {  S# T9 [! k
  2366.         index.parameters[0].include('鼠标启动')! p- F/ H: k5 A" C; i
  2367.     end
    / b( _% K/ E7 |6 N. \
  2368.     return false6 E$ w8 I2 e) m- B
  2369.   end
    3 L% q" L" R' i" [# g
  2370. end4 `9 U, w: O/ _' _& N3 e
  2371.   m# _5 B; x9 Z; S8 Z8 b6 R
  2372. ####泥煤的height' G- V$ b1 n, I( `6 @
  2373. # @height = height. S1 p+ D) R, m  s: M0 X" z

  2374. 3 n: ~2 l! j" s2 F3 s
  2375. class Area_Response7 K/ k9 a7 G5 l' p
  2376.   attr_accessor type
    $ M5 {- R( [4 H& J; Q
  2377.   attr_reader ox2 n6 v6 s' |/ z* M3 h" c" I
  2378.   attr_reader oy& l9 A4 k) }' r6 q) Z  L
  2379.   attr_reader width
    % N, i. P4 b) @* ?6 c
  2380.   attr_reader height
    % R+ m0 l+ V6 k( l
  2381.   attr_reader switch_id* c. {, N6 y8 {
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)" U: z7 I8 x# s+ ?! @0 I
  2383.     @type = type" S1 C1 w$ ]( a: H. r+ \- K
  2384.     @ox = ox) A1 ?9 j4 A$ O% y: K* f
  2385.     @oy = oy
    0 n: o# L! g' Z
  2386.     @width = width3 I: @  f* p  F& m+ o/ t
  2387.     @height = height; L( y+ G+ d8 q6 x( I/ G
  2388.     @switch_id = switch_id
    * o! y" t  A( b% u8 G" X
  2389.   end# L  j% }( M! [. [6 e2 S
  2390. end1 J+ r: ]! q- u3 ?5 A. c
  2391. 3 Y' S; d) R* y9 A( @: r
  2392. $area_responses = []
    8 |% h, y% {6 T( u

  2393. * e3 R' n1 V9 ?) u1 w3 A
  2394. class Scene_Map
    & E  L' }* V) ?3 c2 U% u! x
  2395.   alias update_mouse_2013421 update_mouse_action
    % H1 b' i( @% O  P! [2 @' m) }
  2396.   def update_mouse_action
    % S. ?, S4 [4 b8 q1 w
  2397.     update_area_response
    - i" O$ J/ [, W$ n, v. Y
  2398.     update_mouse_2013421# |% d7 v" |9 L) Q% z( {9 b
  2399.   end
    5 V. m3 _: ?8 e( L
  2400.   def update_area_response9 C( j- Y# V9 ^
  2401.     responses = $area_responses
    + H- y/ V$ q; p. S$ G. s0 M$ x
  2402.     responses.each {response+ z1 @$ B# b- W
  2403.       ox = response.ox& h6 B, r2 d2 o
  2404.       oy = response.oy8 F* j$ ]% f4 I! m
  2405.       width = response.width
    ' I6 x& A/ D; t6 Y1 v
  2406.       height = response.height+ G6 @' q5 u1 K* l- T
  2407.       switch_id = response.switch_id$ F* t3 k0 L2 Z& W9 d
  2408.       case response.type
    / F* {) b5 Z3 X( F( n( L5 i  k+ Z
  2409.       when 07 c' H# _2 N6 B1 V; W
  2410.         if mouse_in_area(ox, oy, width, height)4 P( f3 I$ b3 z  H: q  t
  2411.           $game_switches[switch_id] = true; @% W8 I: \7 x
  2412.           $area_responses.delete(response)1 B% T- r; C2 J" S- A  z7 F3 M
  2413.         end
    ' j7 q7 F# A9 o$ o! L
  2414.       when 1/ i* \1 k+ I& c( \+ Q2 d" _' ?1 T
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)5 P# ?, Y; h0 N# o
  2416.           $game_switches[switch_id] = true. r( q/ j. }4 p" v  u( T
  2417.           $area_responses.delete(response)
    ) z+ n" _! j) c
  2418.         end- U( q1 ^, C) p0 g8 N, l* ?: Y
  2419.       when 2+ W5 U' \& v, F$ D; F- x) H
  2420.         if mouse_in_area(ox, oy, width, height)6 j+ K9 Q' P0 [, N/ U; w$ s1 [
  2421.           $game_switches[switch_id] = true! f" A, p0 D) S' [
  2422.         else; O* Z$ R; _8 g! e& [) h% ]
  2423.           $game_switches[switch_id] = false
    7 I+ `# B0 a" s) ^4 C) u7 V
  2424.         end6 t: f; U0 u' M6 Y
  2425.       when 3
    + Z( E: O6 ~2 u2 O7 }
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    * p' p. ~& z, ?9 M6 x2 e
  2427.             (oy - $game_map.display_y)  32, width, height)+ o8 m9 J& Z& j
  2428.           $game_map.events_xy(ox, oy).each {event
    3 q7 v. E9 v$ u( z
  2429.           event.start
    * t# s# L( \/ G1 x: i4 s0 \, n
  2430.           $area_responses.delete(response)) g6 e! N. z: U1 I
  2431.           return
    , H) d, P- X5 d; L9 j0 q/ W
  2432.           }
    0 L. ?) e8 Y: e
  2433.         end( g( a0 j8 ]! w  f
  2434.       when 4
    ; S5 |9 T  c7 Q# j6 T
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,/ x8 o' }& X  l+ S
  2436.             (oy - $game_map.display_y)  32, width, height)- j4 A5 P4 p% F9 n8 W7 g  t
  2437.           $game_map.events_xy(ox, oy).each {event0 R5 n& T( w) f3 W
  2438.             event.start6 a& L' g. P7 `$ t4 j, P1 H
  2439.             return
    6 p9 P( h* I4 i5 ?1 p
  2440.           } 2 w1 U. W4 [% v. b
  2441.         end
    9 t& ]1 O: y3 A5 b  k
  2442.       end
    . R9 t/ u: c1 t7 E' R
  2443.     }; |2 a# @5 }+ A" H  V- Y4 E0 y7 ~5 {
  2444.   end
    ! d. \/ X+ o8 D" m& C4 @3 Y) \) S
  2445.   def mouse_in_area(ox, oy, width, height)8 E' c* I6 S. {: M
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&! N5 |( a: d4 j# O$ D, c/ w+ E
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    9 Z$ V0 ?4 V( K# d' V
  2448.   end' z- \9 ]3 [4 W
  2449. end
    1 ]. I4 H# P8 n  T- I
  2450. class Game_Interpreter
    , _" _0 _3 R0 G6 P
  2451.   def area_response(arg)
    % Z. g; v" M8 i3 t7 e6 U- H8 Q# [
  2452.     $area_responses.push(Area_Response.new(arg))
    1 S. _9 W. n( U2 l1 d7 `
  2453.   end1 g% x7 H7 f0 `' S
  2454. end
    4 h. L* R* A' A
复制代码

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

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

GMT+8, 2025-10-31 02:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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