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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    , `9 W# X( S+ _' H% A, ^0 o$ |  v
  2. - Z7 q! ?/ i% v( I8 T6 ?
  3.   Sion Mouse System v1.3e
    " D$ L4 o" f' V& j) Y
  4.   & o8 x; r2 \! l3 a
  5.   Changlog
    ; O3 Q) i$ c1 f6 C
  6.   
    + ^3 v  E6 Q3 J' |- T
  7.   2013.4.21 v1.3f
    ' N8 X, [& p( S' I
  8.     3 n4 P' B! s% m9 D  a$ h! P1 M# g5 |
  9.     1.3f 卷动地图 bug 修正0 Z/ Y+ f0 \: P9 @6 v  B
  10.    
    / b; K: q3 K9 F* R8 S
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    , q8 ~8 x, M7 h* U4 d
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    " v, m6 B) e3 O% v5 ^% x
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    0 o: b* x7 Q7 e

  14. 7 ?* o5 z* W7 V! |
  15.     1.3f bug修正
    + A5 I8 ]! m1 j  j6 o% S
  16.   ! V0 R1 i" z+ }1 e: r6 i
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    # }2 Y$ [- X1 [* O+ T
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    2 @* M2 Q' f5 _4 z- a7 n: X
  19. ( P% f) z. C- L4 G9 P
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    7 L" y# S1 s. s/ L% T0 b; C+ F
  21. 6 }$ a. |4 U/ z7 u- t) z
  22.     1.3b 修正一些罕见的bug;
    5 ~# b/ P: {* W! m1 X3 m3 b
  23. 4 U3 X2 i: t( X# ~) B) o
  24.     1.3a 代码小修改;: O# _# H7 ?# t( u9 D
  25.           加入了鼠标点击启动事件的功能,
    ) m& f. Q( f- p, }5 ?
  26.           在事件中加入“注释”: 鼠标启动  ,, t, p9 v! x/ C" I
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    4 x9 X& r6 h7 C5 K5 J7 x4 P
  28.   
    . E6 M6 _( N' b% Z
  29.   2013.2.12 v1.2- |2 v8 l# _5 W+ p  p0 j) J' I

  30. 0 c7 W$ t8 m9 O/ y% M1 K# c
  31.     寻路逻辑优化;7 Q: n! a) i1 t7 r
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;" y2 l5 s( D1 |7 m- {9 h- r' ^
  33.     现在支持用鼠标来操作载具了。
    1 V% u( w) b2 P) A; i2 [
  34. ( K/ k) j$ }$ I* K6 D6 k
  35.   2013.2.8 v1.1
    2 j, r* u* V3 m  G0 R

  36. 3 W+ F6 G% T) G6 @% Y
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    % W6 m2 p4 ^- H8 g
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    $ i2 `/ i+ y( ]# o
  39.     移动时,路径指示点的绘制更加稳定;
    7 ^  S' o. j+ G9 R# C
  40.     现在支持默认存档画面的鼠标操作了。
    2 N  A1 s0 b9 n8 _8 c
  41. 6 ^* r3 R3 H: S' v# T
  42.   J/ F0 B" g/ o( E
  43.   OrigenVersion& E4 g: Q6 S* r6 U6 G8 S
  44.   
    # M  i5 i$ `  X! d$ Z  n4 d& z* e3 i
  45.     2013.2.7 v1.0
    . o# [/ K2 O, g8 ]' Q9 T

  46. : l& d" z. o( Z  b
  47.   主要功能1 n, B( b! _, G) E" {7 D7 z: U% c

  48. ! }  L* _7 k. M3 v1 B+ Y
  49.       使用鼠标进行各种操作...; J/ a+ c$ b4 a$ d
  50.       将鼠标锁定在游戏窗口内
    5 D: ^- O; k, l$ {
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    % K5 a4 B# @$ O1 v1 Y
  52.       双击鼠标进行冲刺0 t, {" x  o6 @8 W8 ]% F
  53.       更改地图卷动方式以适应鼠标移动
    , R. b" `7 k0 I  K. y
  54.       变量输入框改良6 n! \+ G0 w4 Y: U/ Z
  55. - Y' c7 B9 `) G2 i
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹  a4 N' C. V; b/ I% [; a
  57. 5 Y" }/ X! \' ~/ |
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    % m% [" @6 C9 z1 l/ y* G

  59. ! a9 g4 U5 b  b4 S/ I
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭/ R0 b7 b. B* t
  61. 8 v8 [+ n: v7 l6 E

  62. ! `' Q; M2 R+ c& i7 E
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    ; t, r" O3 S. |* j1 H

  64. / L6 U0 T* C- w" T# C
  65. , U' v0 |* Z" \+ K! `
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示! n- K, p" l; p% @( D  M

  67. . ~6 I8 K2 P4 F/ u. n7 y
  68. #==============================================================================3 n: N6 K, ^: ^  m7 P
  69. # ■ 常数设置 # K8 P) V( o; X$ r
  70. #==============================================================================) X3 O8 r4 Z) B3 }4 u% j& P
  71. module KsOfSion" j! I* A9 i; _; |! B) w$ Y; P
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    + `' r2 Q5 s' D+ I+ H' Z
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑: c$ d7 e4 k( Y! I, b5 a; d8 R- S
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false1 d3 T# `! C; S- M  P, b4 R
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量! ~; r. Q2 e* g+ T
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    $ ^) C9 |6 l% M: s& _1 N
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧1 o+ w1 }  j; ^8 d& h( q
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)8 R) J' s, O7 o" R9 `+ ]
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    - m7 X7 S! m0 h% D& J  [
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    : B/ e9 ?$ t% H& }2 R/ |
  81. end/ n$ M5 Q7 a" z8 k

  82. # X! V. _  g$ C; s4 u( A( V) ]! [
  83. #==============================================================================
    ( L$ L! H  q4 B' ^5 f
  84. # ■ 用来显示路径点的类) U: k5 w- C, g1 g, J' |
  85. #==============================================================================' }; j9 w6 O1 k. l
  86. class Move_Sign  Game_Character) ~/ [& b$ M8 C) b* L- B8 `
  87.   #--------------------------------------------------------------------------. w/ `' w9 w# I* ^' L7 F
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图. z* n5 ^7 M$ _; L( B, H
  89.   #--------------------------------------------------------------------------
    , N4 a% S( {: e+ v8 k# z. h
  90.   def init_public_members
    ) B% v7 b, Y3 N' K# H3 C
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    8 V4 D: P9 T! x0 a' S1 [
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    $ G# b' S4 ^" Y) L% G
  93.     @move_speed      = 5        # ★ 踏步速度
    % I3 B& j6 f4 i" u4 y5 b! I) B
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)2 ~9 ]" A- j# K( S$ d1 o) h  i
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度& m5 F  Y8 i: X3 O, L
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常). w- g: \# q. b) m2 m6 m: M1 l/ B
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列' }& k/ h% O0 @
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    7 U+ b; k; r+ }, h9 {# G
  99. 9 e/ j$ b* n3 I4 R8 R
  100. # {! ~, U) N6 B
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    , I# D% [( z% x* N( y
  102. ; Q3 O; J$ I# U$ j" T8 K9 _. U7 H
  103. 5 a1 @' v: M" B4 r$ H8 S7 S' q- t
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图( p6 ~1 K3 k1 J; M4 a% x$ q2 R
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')" n* v' g( E+ C' k! [" e& ]

  106. # H. `" Q: e; H" w6 B
  107.       if $no_arrowpic_warn% p: T* Q; f6 `) D1 w2 s- Y
  108.         MouseShow_Cursor.call(1)+ I+ s6 V3 V  t7 E) L
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    - ]! P* F" f0 l: C
  110. ) v$ U  X. O1 Z% k
  111. “路径指示点”将使用游戏自带图片
    8 m7 ?3 X+ `' A. z
  112. - e# @  o- P& }0 y/ d, R
  113. 该提示可以在脚本内关闭')
    # M4 L# _0 Z9 _% D8 |" K* e9 N: n
  114.         MouseShow_Cursor.call(0); s6 Z. x7 g3 M5 E, I
  115.         $no_arrowpic_warn = false; Q9 d& i3 t0 a5 c  p4 C
  116.       end
    . G( V# b" w4 D& J+ n1 Z
  117.       @character_name  = '!Flame') Y! d; _# [% B+ }8 t
  118.       @character_index = 64 b0 S& E, G4 J/ D# N

  119. 4 v! ]* d& [* L( I* c# N
  120.     end
    ! \4 m! n0 z: U  k) _
  121.     @direction_fix = false  # 固定朝向
    0 y( m0 _+ `+ D4 y1 D
  122.     @move_frequency = 6     # 移动频率
    8 c- M+ g: `/ B7 u# b
  123.     @walk_anime = true      # 步行动画: B7 V" t& h  T/ j
  124.     @pattern = 1            # 图案' i" w5 Y( D# o: e* U: U
  125.     @through = true         # 穿透
    - P1 f: a- G2 M0 Z/ |( R" ?' a
  126.     @bush_depth = 0         # 草木深度  B$ k5 g9 |( n  Z$ U& ~# ^, @( s
  127.     @animation_id = 0       # 动画 ID; f+ v0 j. ~6 q
  128.     @balloon_id = 0         # 心情 ID
    . v; p1 z* d( j6 C( T
  129.     @transparent = true     # 透明
    ( m+ {$ O: b0 f. x* X9 Z. ^; T
  130.     @id = 0
    2 y$ L2 B2 r$ Z. \' n, Y- R/ I$ ], r
  131.     @x = 0! Z6 c" {3 d& T8 }# T8 J/ X
  132.     @y = 0: F5 |' ]2 D- F$ W( x8 b
  133.     @real_x = 0
    ; k4 D" |/ c* v/ R+ l3 E' x
  134.     @real_y = 0: x; ]3 D- y$ P( K: B0 V. u# |
  135.     @tile_id = 0) h3 c$ n5 x; b) P
  136.   end
    ' D8 A. z5 n9 \3 a/ n5 C& S
  137.   #--------------------------------------------------------------------------$ l% ?  A6 M) T% M4 A6 T
  138.   # ● 定义实例变量
    5 S4 b6 D6 Q: M5 o
  139.   #--------------------------------------------------------------------------8 [* s. d$ e  ]& D' g; e! U
  140.   attr_accessor direction5 E1 [% R, x" E/ S
  141. end
    2 s) M* c4 _. W2 X% C" t
  142. ( E6 Z- f, Q4 L  T' o7 U+ X, L
  143. #==============================================================================; v: j3 B3 x& N0 Z2 K1 _% Z
  144. # ■ Module Mouse; ]0 C1 m: ]4 n
  145. #==============================================================================, s) q! g  D. o: o3 q5 C  K
  146. module Mouse
    5 i/ ?; Y, }( a& x" d4 W5 m6 L
  147.   #--------------------------------------------------------------------------
    , B" T( k8 N7 ~
  148.   # ● API
    5 ?$ x7 b& I7 P) c9 z% _5 a
  149.   #--------------------------------------------------------------------------
    ( {3 }5 u) i9 s5 ~, l2 v
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    % H$ d6 w3 q8 I: m  k$ Y
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')) I# T% W+ R3 b" F
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    ; Q6 [( e8 i: F* |
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    ' P: j, n2 s- u" b4 T$ |8 W
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    * F  y/ }! C4 t  c# j. |1 Y% U
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')8 ?0 H" Y' t6 c7 F$ T2 o
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    ' m0 N8 `3 \9 w" y. m% p
  157.   Window_Hwnd       = Get_Active_Window.call/ A& q) j, L+ d9 }0 B% G
  158. ; K0 M/ E! J& c" g; T
  159. class  self
    1 s" k# S, [  S4 V; k- e
  160.   #--------------------------------------------------------------------------& u  W9 J5 X2 s! a6 V- w
  161.   # ● 初始化
    8 f1 G' u+ j1 v( K6 p+ h
  162.   #--------------------------------------------------------------------------5 H$ S5 y, t: `
  163.   def init/ [4 b# c: Y) V; n2 m$ l
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor, g. `) {7 ~1 `" M: T
  165.     @left_state = 0
    / s5 s' y) S9 Q1 @' e1 ?
  166.     @right_state = 0. k2 U; f& Z( A1 b8 u
  167.     @ck_count = 0 # 帧数计,单击以后从0开始/ M/ [/ ^7 c7 R- ]  ?3 ^1 ], M
  168.     @dk_count = 0 # 用于双击的判定
    " U) K: o7 @; @4 m
  169.     @clicked = false
    ( _1 B/ W9 U* _
  170.     creat_mouse_sprite& U! Q1 {. k6 m! P& l
  171.     update) q+ W& s$ @1 ~7 f
  172.   end
    $ h* C+ b, K* @9 ?6 p' N( _
  173.   #--------------------------------------------------------------------------
    ( \" g- d! q; N8 f* c1 d
  174.   # ● 鼠标指针精灵) K1 S' g; j6 g3 ]8 p, o
  175.   #--------------------------------------------------------------------------& g: h1 s" b$ I! K# W2 g& f: s
  176. #~   def creat_mouse_sprite9 c- f4 x8 h7 I9 j$ e6 _& k' T7 K; }
  177. #~     ' n2 r0 B; ^7 c, h$ r6 `6 o$ p5 B# {
  178. #~       @mouse_sprite = Sprite.new: l  A$ t( n; R1 S& n4 Z# z
  179. #~       panda = 2#rand(2)+1
    & \- ]) X% Z) f# c: _9 m
  180. / p* U4 _& M- V/ x) e
  181. #~      if panda = 1
    8 f" i0 M# t5 O1 Y0 w5 A
  182. #~        if File.exist('GraphicsSystemCursor2.png')' R7 S  z- j+ o5 F) |* V* W; c
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
      S9 T% M0 x4 Y% |
  184. #~        end#with if File.exist
    ' Z6 U8 J8 S+ N9 e
  185. #~   
    $ E: H+ D" o- {3 b8 F7 v
  186. #~     else if panda = 2 #with if panda=1& a7 B1 W9 ?2 b" ?# A+ D
  187. #~      
    0 {3 G3 H" e  [, b9 G
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    $ K1 p: N3 \; b; C/ G* ?- }
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')& g5 G) [" w4 G' `! o
  190. #~      end#with if File.exist
    * B( j8 \; {! [$ d/ l
  191. #~       ( O; w" B9 a3 N; L' @
  192. #~     else #with if panda=14 g' J6 _6 |6 a' r+ J
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
      D! ]6 `% k9 _$ H7 `5 Z) B
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),  w2 K1 g4 U9 {2 H0 h/ D
  195. #~       Rect.new(5  24, 24  24, 24, 24))5 T7 p  S3 d. `, l% u
  196. #~     end#with if panda=1: O. D! t3 {2 P' U0 l
  197. #~     , X8 u6 v- |. w6 k! V
  198. #~     #with def  C5 \4 v3 y4 _* A* ]7 n) e; z- `
  199. #~   end8 r% e. r3 i" O
  200. def creat_mouse_sprite
    / `( b. m/ [8 L: o! ?' a" m
  201.     @mouse_sprite = Sprite.new+ w, |+ ]3 s5 S
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})4 K$ g) p3 @! \' ~2 s: g0 L
  203.     @mouse_sprite.z = 9999
      A/ P/ Z& o! ?9 o+ O' c
  204.     Show_Cursor.call(0)1 U; ~2 f4 F& P, v' v
  205. end
    , w8 F' ?/ N  [- f5 s7 R6 H- T
  206. 4 U) l; h* Y, ]" c8 ^- i
  207.   #--------------------------------------------------------------------------" E3 U- J  I6 _# \
  208.   # ● 更新( d$ A/ J: H& {; [5 Q
  209.   #--------------------------------------------------------------------------: n5 K& {2 k+ |& y3 k3 ]
  210.   def update
    ( e6 u' k8 f5 m6 j, `+ \" r5 Q8 z
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    & q& ~: i0 d- O  Y; G
  212.     left_state  = Get_Key_State.call(0x01)
    - p# q" h) I' x- G" u  p2 ~, G, w
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0" B6 _/ A! ]0 U2 f( v2 y
  214.     right_state = Get_Key_State.call(0x02)
    - e$ K8 L! a4 D& b$ y$ ^
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0' J: M4 r$ M' d8 [
  216.     update_double_click4 s+ q. L& k' s7 D
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    8 K3 ~# }8 b# h9 ]
  218.   end: v# \/ u1 a% \% A, }
  219.   #--------------------------------------------------------------------------
    9 K3 u" O7 s* k1 A7 ^6 Z, u  }" c- V
  220.   # ● 获取鼠标坐标
    ( m0 f  [& Z1 H2 d
  221.   #--------------------------------------------------------------------------
    : w9 P2 Z% \% s( E4 M/ U) w- a
  222.   def get_mouse_pos9 {! x9 s- O. t
  223.     arg = [0, 0].pack('ll')& A* G. H, P& `9 _; V
  224.     Get_Cursor_Pos.call(arg)
    ! v( ^5 k( M" P  ?
  225.     Screen_To_Client.call(Window_Hwnd, arg)5 Y# G1 K! Q4 h* t/ i" c5 {3 e5 n/ G6 A7 J
  226.     x, y = arg.unpack('ll')
    ! h" ?, L6 f6 E7 h
  227.     return x, y
    ) i8 J" a) O* L' v+ C, `. N: I1 `; F+ ~
  228.   end
    9 B" u' l$ o" s) ?
  229.   #--------------------------------------------------------------------------
    - c1 E5 H/ X' `% s/ Y
  230.   # ● 将鼠标固定在屏幕内8 U% P6 k" K" f! G0 \0 @
  231.   #--------------------------------------------------------------------------
    $ B# p5 k0 u, q
  232.   def lock_mouse_in_screen
    6 ~( o( K+ h- H7 z
  233.     arg = [0, 0].pack('ll')
    / p& s' x; c, k  b3 p
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    : y* f2 ^! A2 a' }
  235.     x, y  = arg.unpack('ll')' Q% y# b2 W- m! Y$ B% H
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    ! I; P; s8 T" L2 [' t9 @1 P: Q$ f+ V
  237.   end
    3 G; H, O3 ~- R. O
  238.   #--------------------------------------------------------------------------% G6 [% h( B, t$ c- H9 l
  239.   # ● 解除鼠标固定3 D4 R" w, q& y$ w: d( p% V4 u
  240.   #--------------------------------------------------------------------------
    / U0 B) x* @! f6 t% E9 @
  241.   def unlock_mouse_in_screen& v7 S' i/ E$ _6 ~, U% L
  242.     Clip_Cursor.call(0)
    4 r8 j' [5 E( \) D. |
  243.   end3 \6 ]2 b0 P5 g2 o) v
  244.   #--------------------------------------------------------------------------
    7 [9 o! l4 ^  b
  245.   # ● 鼠标双击判定
    # X6 V' ?- Y* Q
  246.   #--------------------------------------------------------------------------  j4 H% G: Y% f0 l( f
  247.   def update_double_click, \, B! c" T4 E7 h" b# H
  248.     @clicked = true if @left_state == 19 z. {6 Y' u2 \, j0 I( V
  249.     if @dk_count  0 && @left_state == 1
    * x5 X1 G& g( P+ C+ c
  250.       @dk_count = 0; @clicked = false$ ]9 q7 t- p9 \1 o5 Q3 e' u* E( t
  251.       return @double_click = true# ~. m4 A- b( _8 D
  252.     elsif @clicked. J* r8 [( ~! d; k6 S
  253.       if @dk_count  KsOfSionDbclick_Frame
    1 M4 h& S7 b" h) u6 S( ~+ w! q
  254.         @dk_count += 1
    + h4 T2 n' q0 \4 C/ _
  255.       else
    4 k# f1 B& p1 J. X& F9 p
  256.         @dk_count = 0; @clicked = false( t: X$ D! f- [+ N
  257.       end
    - X' o) W$ t  l, j
  258.     end( V4 z1 R0 P9 z) L* \
  259.     @double_click = false
    " |8 Y* ^# Y+ x9 ?7 N3 J! f: v
  260.   end% n8 z7 X1 |% N8 h
  261.   #--------------------------------------------------------------------------6 E' c% @% X6 {9 j, ?: m
  262.   # ● 按键被按下就返回true
    - B& A- @; J/ D. @, @
  263.   #--------------------------------------------------------------------------4 h! ]+ v1 B+ h- G! h: E) Y- g7 M2 s
  264.   def press(button): m; Z! H) A% Z: R* P) g& ]" d. s; v5 ^
  265.     case button8 b6 Y  X3 c( r& _
  266.       when 0x01; return !@left_state.zero9 N. O; G8 _4 m2 E3 v
  267.       when 0x02; return !@right_state.zero5 J+ j. b& ]- T7 v. @" }
  268.     end; l5 ?+ @4 {' n# V% z& X
  269.     return false2 r) X! s+ p" _) g) P% d2 E
  270.   end
    % G2 F: W, y. f5 C7 H, w0 j
  271.   #--------------------------------------------------------------------------4 b( ]! g& O+ }7 b3 A- |. A
  272.   # ● 按键刚被按下则返回true! x: @; f" U! l
  273.   #--------------------------------------------------------------------------
    4 P; u9 \6 A' e3 U0 Z( ]; S1 k
  274.   def trigger(button)
    6 M$ e3 c  e2 R: \- p
  275.     case button
    $ v# i% Z% l% Z8 g; O* k; `
  276.       when 0x01; return @left_state == 1
    + U; X, ^! |) \3 x3 C4 y
  277.       when 0x02; return @right_state == 12 B8 q+ z! C! d9 l4 e' Z# {
  278.     end
    * I" J& I3 _2 I- A: B0 N
  279.     return false2 B) ~' e# b# x' b0 I. o
  280.   end
    9 P& c" C5 M6 V$ |) @3 u" Q
  281.   #--------------------------------------------------------------------------
    - T2 g7 {" i# l' m, i+ G
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    3 l/ d7 E( }) X* L9 H
  283.   #--------------------------------------------------------------------------" p! {: r( C% V& Z
  284.   def repeat(button)
    ( D9 h9 d) n6 `3 O9 }+ w
  285.     case button
    - I0 K% Z) B1 [( i& N9 w
  286.       when 0x01; return @left_state == 1
    6 G0 x7 T  q2 q3 c! }. U: ^
  287.         (@left_state  22 && (@left_state % 6).zero)5 g, ~& @! v2 L6 N; J
  288.       when 0x02; return @right_state == 1 ) b$ ^, }  h2 d
  289.         (@right_state  22 && (@right_state % 6).zero)- Q  h/ p) `5 u6 _, @/ Y6 r
  290.     end  F; T3 H& C# B: b! ]8 \
  291.     return false
    3 d& Z0 J% v. J" l9 L
  292.   end
      Q! m3 z* Q  ~% h: E
  293.   #--------------------------------------------------------------------------
    ) l; H5 h7 [; r+ V# k
  294.   # ● 判断是否双击鼠标/ ~! R( c0 j* @) \
  295.   #--------------------------------------------------------------------------- d7 r: H* a$ O6 ]! r8 Q. ^
  296.   def double_click
    ; N5 r9 \: e0 H
  297.     @double_click
    . n8 h, S& n3 Q# U( e3 S4 v
  298.   end) |- q1 H8 f; L7 f, o
  299.   #--------------------------------------------------------------------------
    1 ]  z7 U9 U; i, ^. S& t6 K
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    ! `5 @7 D, c" ~* ]
  301.   #--------------------------------------------------------------------------8 j4 g9 R8 c. F0 F
  302.   def click_count
    2 R% H$ s. k2 p: ]' W
  303.     @ck_count
    ; Z1 ?) L/ q7 H! G6 v4 y$ Z* A( \% |
  304.   end
    6 C% t6 l6 {8 P8 v
  305.   #--------------------------------------------------------------------------
    ' n$ m# |! s9 l
  306.   # ● 获取@left_state(按住左键每一帧+=1)6 j4 I3 A) n; I8 n3 i4 h
  307.   #--------------------------------------------------------------------------
    3 {: n$ s- \; h6 `2 A- J
  308.   def left_state9 b3 s9 m9 x+ k0 y+ ?) q5 ~
  309.     @left_state
    3 b" L! u. q- e/ g6 n; k& n
  310.   end
    7 u# I0 I4 o6 G7 d. k
  311.   #--------------------------------------------------------------------------$ J1 v, s* X+ \8 K
  312.   # ● 获取鼠标的x坐标0 Q) p6 j. y3 N
  313.   #--------------------------------------------------------------------------7 b; ?3 t  Y( h$ F5 Q+ c
  314.   def mouse_x
    , A% y8 V3 J" H2 _$ ]# e; d
  315.     @mouse_sprite.x7 T( a8 z# l7 |% Y( j7 B' D# C
  316.   end
    4 c' D. E* {$ `% d- j$ O
  317.   #--------------------------------------------------------------------------# _6 n" y" e) |0 B
  318.   # ● 获取鼠标的y坐标
    3 T4 L$ h  h- P  }7 ~* S+ h2 n
  319.   #--------------------------------------------------------------------------+ P1 _( c6 X- C) ]0 s) A" [3 F
  320.   def mouse_y
    + \/ P& B! ?2 C  a1 x
  321.     @mouse_sprite.y
    5 k  R) {+ k1 ^/ b
  322.   end
    * k1 M! H$ S5 ~' h2 L( Z6 f
  323.   #--------------------------------------------------------------------------/ I& [7 s' Q8 s  b
  324.   # ● 设置鼠标坐标
    9 }) L! k: y2 q
  325.   #--------------------------------------------------------------------------
    : r8 O* o/ I$ X  z! E
  326.   def set_mouse_pos(new_x, new_y)  [7 ~" c; c: m! @9 X
  327.     arg = [0, 0].pack('ll')+ J) J7 p  F# j' Z2 l7 S
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    . q/ @% _' _. ?8 w
  329.     x, y  = arg.unpack('ll')
    $ ?7 j. J) u0 D& K- l$ K- g
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    ( `$ y9 s! x3 z+ _1 ]
  331.   end! L6 Z2 A* A0 ^0 k4 ]5 ^9 `
  332. end #end of class  self ; j8 P; T# Z! O$ C- s4 ^0 q
  333. 9 `1 K$ ^; x# r; Q* \
  334. end4 d2 H& E: |* @: M( _& v
  335. 8 \7 g9 Y% m8 |" u/ C+ {- P
  336. #==============================================================================
    0 N' l7 X- c, P& y/ n" d
  337. # ■ SceneManager4 A; z! {0 A5 U+ o* a2 U5 G
  338. #==============================================================================! M$ s) u0 J& {% K+ S/ `, ^
  339. class  SceneManager
    : ]1 e* b* I2 u( @: ?
  340.   #--------------------------------------------------------------------------
    # }" R  x. {$ z, p  r, U
  341.   # ● alias( o8 ^( v7 A9 X$ k  _0 r0 I; w
  342.   #--------------------------------------------------------------------------* m: X$ S9 }8 Q# T" ~
  343.   unless self.method_defined(sion_mouse_run); F* {* ^$ F( X+ H9 j
  344.     alias_method sion_mouse_run, run0 m4 ^- P# c  A6 u: ~) e0 I
  345.     alias_method sion_mouse_call, call; E2 Z" [/ u* |: @
  346.     alias_method sion_mouse_return, return# p$ P" ?  y6 r, j7 t
  347.   end/ O' a* Y! Z2 {0 c/ L& v4 y
  348.   #--------------------------------------------------------------------------
    " X8 K$ X- R9 K# O- n) U
  349.   # ● 运行
    1 z7 C, H$ [, A* t) x( i
  350.   #--------------------------------------------------------------------------
    0 S! k8 _9 C1 s2 f/ e
  351.   def run
    5 E; A+ a8 W0 U' s) v6 l
  352.     Mouse.init
    3 L& ?/ T' T/ B5 _
  353.     sion_mouse_run
    + h/ p7 v+ I% \6 Q
  354.   end
      N( @' s4 f1 Q( j( @. a
  355.   #--------------------------------------------------------------------------
    3 ^3 [# i- e; h' w8 H4 u. K% k
  356.   # ● 切换
    7 F8 n% a- A) e1 U% |+ g/ w
  357.   #--------------------------------------------------------------------------
    & h4 i+ y& o' e- c" t
  358.   def call(scene_class)* P( B* E  `4 A, C. I. S6 q9 }% v
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    5 L( d' a, I0 R2 v  P
  360.     sion_mouse_call(scene_class)- b4 j5 t# q' `0 r. i8 t
  361.   end
    ) `$ r- F( A2 o5 r
  362.   #--------------------------------------------------------------------------
    % K; R/ N* }- g2 Z! D2 S& Z5 m
  363.   # ● 返回到上一个场景. Y4 T9 [; [0 R
  364.   #--------------------------------------------------------------------------( R3 d  z  k: K$ H5 ?% T& G( Y& l
  365.   def return
    2 z8 V; O% }7 P4 T( @) |
  366.     sion_mouse_return" @" i6 I" S6 q) \" D
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    6 ]. G; _  S" w* f6 @
  368.       @scene.instance_of(Scene_Map)
    3 l8 t( {4 q# _+ P
  369.   end
    ' f( @0 D0 Z0 u5 A
  370. end
    ( @# Q: k0 s3 y# y- }% M) b
  371. ( X6 C- L, b- r" Q. x5 ?
  372. #==============================================================================
    ; u9 s) r# Q/ s( D' o6 F
  373. # ■ Module Input
    % b4 b2 A( n3 K. P! y- C
  374. #==============================================================================. k/ M0 [/ G( g: t; A
  375. class  Input4 p; I) T5 l1 F: P, j' Z
  376.   #--------------------------------------------------------------------------: ^" ~7 Y7 W% t- `; k* v
  377.   # ● alias" o( I; i3 t. }; g9 p
  378.   #--------------------------------------------------------------------------: m) U: U; ~% g
  379.   unless self.method_defined(sion_mouse_update)' G: C& u; g; V/ X6 T
  380.     alias_method sion_mouse_update,   update! v+ a( J' M$ ]+ d
  381.     alias_method sion_mouse_press,   press
    1 V6 M6 e# H* i' \4 }. D
  382.     alias_method sion_mouse_trigger, trigger; \5 G. L) T- k* o
  383.     alias_method sion_mouse_repeat,  repeat! y6 A+ I+ I) U( Z1 j, G6 O
  384.   end" w. n' `6 u; f, _
  385.   #--------------------------------------------------------------------------
    ' Q5 p2 ~+ G! b' I% h( L) e* A4 I
  386.   # ● 更新鼠标8 f. |0 G) l, d* i$ n) R' P
  387.   #--------------------------------------------------------------------------- A9 a+ ?" x3 B2 c+ e
  388.   def update) T/ r+ U8 x- i. ^0 C/ O
  389.     Mouse.update/ U* k+ o, T; d& s; ]: |7 g
  390.     sion_mouse_update  I9 c6 k4 e0 m1 [, U( W' G: n
  391.   end; r8 d3 q! ?7 E8 v1 o
  392.   #--------------------------------------------------------------------------
    + u; j9 j" y( e; W/ O" Z" z0 j
  393.   # ● 按键被按下就返回true9 y+ J$ F% w+ [8 X. ?+ D
  394.   #--------------------------------------------------------------------------
    ( Q1 T7 t3 c2 p: m( x. U# w5 W
  395.   def press(key)
    9 ^" S% ?/ X1 a3 @& B
  396.     return true if sion_mouse_press(key)
    9 N) r, T3 B- a/ A' R# {
  397.     return Mouse.press(0x01) if key == C
    : f, I- |) y, G8 F
  398.     return Mouse.press(0x02) if key == B; H5 B# L" ]% H3 ^+ k
  399.     return false
    7 ]9 |0 e! M1 T4 S) `
  400.   end
    3 @/ q" `0 l, [+ r3 L/ R& W
  401.   #--------------------------------------------------------------------------
    9 g2 A0 X$ W5 u) Y$ U" R
  402.   # ● 按键刚被按下则返回true
    8 k2 `4 ]) L7 ~% x9 O. e6 ]
  403.   #--------------------------------------------------------------------------; T; e( j1 c, ^4 `
  404.   def trigger(key)
    # G/ d6 c. r* P- X
  405.     return true if sion_mouse_trigger(key)! C+ x$ ~8 C3 ~, }! s! Q% R+ K
  406.     return Mouse.trigger(0x01) if key == C
    - K2 Z; B; ~% F5 P
  407.     return Mouse.trigger(0x02) if key == B
    ) s; g" l. Y) V9 V+ l
  408.     return false0 Q5 q5 O" Y  n  R4 F3 k
  409.   end
    & D9 p. T* d( o: g0 F; w! p
  410.   #--------------------------------------------------------------------------
    ! B' Q) q5 }2 B
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    $ ?/ `" [8 r1 w' f7 G& J
  412.   #--------------------------------------------------------------------------# G. A" @% X+ _1 ~
  413.   def repeat(key)
    . Z) J+ Z5 o: C! N0 V% F' r' P
  414.     return true if sion_mouse_repeat(key)
    7 a% G% i  M, l8 H
  415.     return Mouse.repeat(0x01) if key == C* I) a2 y7 [& K
  416.     return Mouse.repeat(0x02) if key == B( n( U% M. }2 K5 }
  417.     return false
    3 Y, f5 j2 Z3 Z; h. p2 w' d
  418.   end) l# b& C: T/ G) j$ C2 S
  419. end
    7 ~4 z. ^* h6 g6 p/ Q8 N
  420. 5 f1 f7 d: u) i- p; x( N4 [( ^3 u

  421. 6 h! A/ t2 |, A
  422. #==============================================================================( Q/ y2 [& L/ T
  423. # ■ Window_Selectable
    1 D8 W$ S- \. Y
  424. #------------------------------------------------------------------------------& L& V( w2 u8 S1 L5 U2 ^: U0 d
  425. #  拥有光标移动、滚动功能的窗口
    8 |# O6 m$ h) a
  426. #==============================================================================
    " s2 ?/ S0 K2 B
  427. class Window_Selectable0 F+ o" m- `( g, T8 m: U
  428.   #--------------------------------------------------------------------------
    $ n) D, v3 P* l" C8 r: [( r6 Y4 D
  429.   # ● 初始化
    0 u7 }' B& I( t, B' r+ I# J
  430.   #--------------------------------------------------------------------------
    " B/ j! C8 L6 Y7 z+ C
  431.   alias sion_mouse_initialize initialize  {& ^& `. ^% s$ T+ ~! I0 a0 j" L7 y
  432.   def initialize(x, y, width, height)
    . A5 c* a9 c$ t& Z: ]% V/ b
  433.     sion_mouse_initialize(x, y, width, height)$ j! M6 X" |6 c7 G8 C/ a
  434.     @move_state = 03 G& V% p0 K7 u6 h* j" L
  435.   end
    / `4 D3 V2 ^0 d
  436.   #--------------------------------------------------------------------------, @" z/ j3 e! \0 _. R/ O6 l
  437.   # ● 更新
    / z4 o& @! d# N# M
  438.   #--------------------------------------------------------------------------1 e( S! x8 j2 G% Q% ?: V5 C
  439.   alias sion_mouse_update update( x' t- N0 G  X0 ~
  440.   def update
    3 `6 \2 W4 J. U) s+ J
  441.     sion_mouse_update& m: _! F, Y3 u& M
  442.     update_mouse_cursor
    * {3 q6 H4 f" Z, ?
  443.   end' s, @) v8 J! q) J) {# b7 p
  444.   #--------------------------------------------------------------------------3 }2 c6 C3 o9 }; V  l0 p! x- i/ P
  445.   # ● 启动后设置鼠标到index位置+ ?% L) R! @  N5 T6 w
  446.   #--------------------------------------------------------------------------
    " D! t: @8 T" T9 }) X. y# O' O
  447.   def activate% E9 m* }+ C4 k& N' p9 P' v( M% v5 J
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos6 `7 n1 ^# O- w/ U
  449.     super
    ' X" w# c2 r; |
  450.   end* y! d/ i6 [: s9 o& J
  451.   #--------------------------------------------------------------------------8 o. f  l; B; S
  452.   # ● 更新鼠标和光标的位置
    8 c2 a* n+ h' ?9 s2 a
  453.   #--------------------------------------------------------------------------; z! p! N* Q: T1 m; M4 R
  454.   def update_mouse_cursor# a9 e6 h) F4 C+ N
  455.     if active
    9 G# {, X' i3 K7 m3 a; E$ b
  456.       if @need_set_pos
      m% N  j! l9 s8 {& ?+ |
  457.         @need_set_pos = nil
    9 U- ]& l% g. P  Q4 u" I
  458.         set_mouse_pos% p% e) k1 Z% w6 v6 K/ |
  459.       elsif cursor_movable
    3 l+ j9 W$ J3 l/ q2 h- {
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    ) @3 |. i6 a" p+ I$ x# _) k
  461.       end; e& X/ i2 R* K
  462.     end5 s8 z9 {8 G5 l* g5 D: D
  463.   end
    - r3 T/ p& G' |* Q! X$ y5 ?1 g+ i* p
  464.   #--------------------------------------------------------------------------
    3 J, J9 ?+ A6 M3 z! Y9 ]
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    ' m& X4 T/ Z. H/ C- t1 p9 I
  466.   #--------------------------------------------------------------------------$ H3 ?7 N6 Z8 b
  467.   def set_cursor
    5 ]9 D0 l+ y6 A" f- ]' x
  468.     mouse_row, mouse_col = mouse_window_area1 D8 ?$ A- p' @) d% A! ^) K
  469.     if    mouse_row == -1
    9 A" n" o, F1 z0 N7 s
  470.       @move_state += 1 if need_scroll  h/ L( X: ?& m" E% c0 `* s7 B8 _
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ! k+ f& K2 m; \) F, i6 v; N7 T2 f
  472.     elsif mouse_row == -2
    / j) N9 [: c9 h$ h5 S* Y
  473.       @move_state += 1 if need_scroll" z" l* n. w7 _" v, n
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    * S! X# M# [8 v* J2 c
  475.     elsif mouse_col == -19 G. G6 F% q4 @4 ]* L
  476.       @move_state += 1 if need_scroll9 K9 A- k3 C. {7 w. q( m2 p; m# ?: y
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand, F6 E7 J% X* g! }( }4 e
  478.     elsif mouse_col == -2" @6 C" H; ^# K' B) k
  479.       @move_state += 1 if need_scroll
    5 O7 G6 P/ M$ X; g5 A; I, z
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand4 R. @2 F4 N" K- M0 r: |
  481.     else" ?+ b3 v5 }+ I& \5 ~) X1 x
  482.       @move_state = 05 R5 q- D3 h; a7 r: ?
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    # a3 x6 p+ S2 @1 N
  484.       select(new_index) if new_index  item_max && new_index != @index) ?) d& [1 W% R$ m3 `. A
  485.     end- z6 k0 F+ K. j. ~1 t0 E
  486.   end
    2 Z3 B$ c+ ^, j- i
  487.   #--------------------------------------------------------------------------
    : e  L, \. |  L/ ?9 F; Z! S
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    # e  {  t5 g2 ?/ _
  489.   #--------------------------------------------------------------------------9 p0 X4 m1 {" A8 Y- r
  490.   def mouse_window_area
    ( p0 d7 j9 V3 P8 n
  491.     if viewport.nil # necessary!
    5 A& T" V' G  `% B7 ?
  492.       vp_x, vp_y = 0, 0
    ; f4 A( p1 l# M0 _) }
  493.     else' T/ y) Q  S/ ^' B
  494.       vp_x = viewport.rect.x - viewport.ox
    * `9 M/ @6 R3 P# D  c
  495.       vp_y = viewport.rect.y - viewport.oy
    # S8 g: f- c  Z2 Y  a
  496.     end9 U# ?1 f- z$ L& C2 D: D+ s
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    - x) J* I9 u" F1 Z# j
  498.     item_x1 = vp_x + x + standard_padding 6 F/ k# T  {8 {2 |0 K3 Y
  499.     item_y1 = vp_y + y + standard_padding( P* D/ {! X, w7 h/ P
  500.     item_x2 = vp_x + x - standard_padding + width
    9 @4 ]* Q: F+ S( [+ k5 Q- W3 y
  501.     item_y2 = vp_y + y - standard_padding + height
    , C+ O: i6 d' {) }$ F* ~0 r* I
  502.     if mouse_x  item_x1& u' z: A/ q/ s3 c
  503.       mouse_col = -1
    6 B6 w# X/ A; y2 ~+ _
  504.     elsif mouse_x  item_x2
    ( Y* A  `1 c2 l
  505.       mouse_col = -2
    8 f  t! V' g9 e: N) P$ ?
  506.     else
    2 P/ j, p+ F" d6 b
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    . Y4 T( |5 m4 f: K+ K0 O9 C
  508.     end
    3 l/ @2 f' t( h( }
  509.     if mouse_y  item_y16 C- |" E% R9 K6 _% p3 V
  510.       mouse_row = -1
    , ]" }- w# n- b5 S2 F8 j
  511.     elsif mouse_y  item_y24 e* v4 b$ l$ e7 E, x
  512.       mouse_row = -2$ O: |- J; y; P/ W
  513.     else
    6 I! ?5 F# J# |6 M' Z, S* r& o
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)% {$ T4 L$ q5 k8 `6 G
  515.     end
    5 S3 [! S; t2 j
  516.     return mouse_row, mouse_col. b+ I5 b* S7 @% m1 c
  517.   end2 d/ ?' A- {* ^( e! f
  518.   #--------------------------------------------------------------------------
    1 N; N0 X  `1 ~
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ) G1 N; |) @: v0 l8 S
  520.   #--------------------------------------------------------------------------
    % p7 m2 [2 j- J3 I# r( D
  521.   def set_mouse_pos
    0 o7 `0 R" d1 X  o) J/ ^
  522.     if viewport.nil # necessary!/ y3 y& i9 |  ]7 ~! O
  523.       vp_x, vp_y = 0, 0
    : g. v0 w6 J8 R; O7 X
  524.     else
    # ?+ K0 {. O5 v2 r
  525.       vp_x = viewport.rect.x - viewport.ox
    9 d; b. Y0 p2 ~1 y' X1 e9 v
  526.       vp_y = viewport.rect.y - viewport.oy# x, z7 {! Q# ?, G* y
  527.     end- Q0 ^* g" E" z$ M, S
  528.     item_x1 = vp_x + x + standard_padding
    + n6 e8 e% }- i. X8 s5 Y
  529.     item_y1 = vp_y + y + standard_padding
    2 U" {8 F5 M" U, d
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
      q* E8 ?7 j5 k/ U
  531.     row = get_index  col_max - top_row
    1 D3 i( @7 S: B
  532.     col = get_index % col_max" k8 Z3 L& x' d
  533.     new_x = item_x1 + item_width  (col + 0.5)/ H: r, d4 M/ d3 x7 |
  534.     new_y = item_y1 + item_height  (row + 0.5)
    # N8 i9 ]2 T- ~4 C& A
  535.     Mouse.set_mouse_pos(new_x, new_y)5 Z' f* P$ a6 G4 G/ ]4 ?1 N, P# i
  536.   end
    ; r6 r/ q) P- K5 D
  537.   #--------------------------------------------------------------------------6 W- w) ?  v" U$ v, q
  538.   # ● 判断菜单是否需要卷动7 ]- J( q. a: p& ]  S5 L2 X9 d
  539.   #--------------------------------------------------------------------------
    ; o1 T# e) }0 m
  540.   def need_scroll
    1 k# ~* P0 ]" {6 o& S0 o4 @
  541.     item_max  col_max  page_row_max
    ; y' h7 h9 a# r' ~6 e
  542.   end5 ^* x4 B) o# h* \# L
  543.   #--------------------------------------------------------------------------5 r! S5 l7 p+ g- o3 n) S2 g/ Q
  544.   # ● 判断是否为水平卷动菜单& l& B7 W9 V- @
  545.   #--------------------------------------------------------------------------4 u; w1 E# A& s' G1 b) T
  546.   def is_horzcommand
    8 i) E) G) `: y5 x1 i
  547.     return false
    & L" y0 |0 D2 J0 N" l/ `
  548.   end
    ( y4 t9 o: ^) f
  549. end
    1 T- R9 Q' S2 [6 u  L
  550. " s. m9 W5 c6 V1 q3 Y
  551. class Window_HorzCommand
    : w, z4 b4 K/ p1 M: V7 n# p+ K
  552.   #--------------------------------------------------------------------------/ X) p5 }+ @! o( I" W8 y1 ^
  553.   # ● 判断是否为水平卷动菜单+ ?! ]: g! ]/ C0 M& V1 J: E( {
  554.   #--------------------------------------------------------------------------
      V: u0 c# p( o$ ?
  555.   def is_horzcommand
    , e' b4 i+ s% A3 z& ~  f) j4 p
  556.     return true
    0 D0 |: l5 h+ g# H; N# w
  557.   end7 X& `) h: Z* Y
  558. end7 |* r. Z7 {  s0 B. y3 C& V: b

  559. , F; {) g& _) ?
  560. #==============================================================================
    ( z, n+ j( j3 ]3 |
  561. # ■ Window_NameInput- ^! v* G8 g; c2 |/ s
  562. #------------------------------------------------------------------------------7 n+ E3 W1 v: M* U0 g
  563. #  名字输入画面中,选择文字的窗口。! {; t( z: e9 B# z9 J9 V& j
  564. #==============================================================================
    , [% [1 B  r% @% f& u
  565. class Window_NameInput$ a. ~$ V$ G( ]8 `: M3 O
  566.   #--------------------------------------------------------------------------
    0 p2 p$ @, o5 G1 ~; \
  567.   # ● 设置列数
    2 r4 q7 S9 ^& O2 t5 I! y+ O8 z$ W
  568.   #--------------------------------------------------------------------------' t( A% Q( n# `- g5 n
  569.   def col_max
    2 J/ V' d9 V+ h. [
  570.     return 10, C$ M  c( M3 c
  571.   end2 U( J/ b( }! ~2 f3 |
  572.   #--------------------------------------------------------------------------
    ) U' [0 u; G9 O. T; k) [
  573.   # ● 设置填充的Item个数2 R; A$ }. P' b* [: ?
  574.   #--------------------------------------------------------------------------
    4 ?) w% s4 a7 v' ~  {
  575.   def item_max
    6 u+ ]( w/ w0 c0 _+ [; Y* |
  576.     return 90% T4 `' ]. v+ _# x2 ]/ |- |8 W
  577.   end
    ( `: t* w) I7 X. h
  578.   #--------------------------------------------------------------------------
    ) D. ]. O5 o# z5 S
  579.   # ● 设置填充的Item个数
    2 ]) C4 Q+ M3 a
  580.   #--------------------------------------------------------------------------
    1 {9 |, h5 ]: r- E* e
  581.   def item_width) r- v8 m! p) h4 V
  582.     return 32
    3 r1 u+ U) L2 q  d2 j1 `0 K) G
  583.   end
    # O2 r6 i$ R9 b6 _
  584.   #--------------------------------------------------------------------------
    7 M, e2 O' b$ T; }
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    % q7 B1 B: r1 e8 T0 J
  586.   #--------------------------------------------------------------------------
    ! }0 ?8 Z4 N' }; [7 k9 U' R
  587.   def mouse_window_area
    * `, R6 M5 e* n( A3 l
  588.     if viewport.nil
    ) }( _% P9 p, E) t
  589.       vp_x, vp_y = 0, 0
    ; ]' p& q: H, o7 u' b* ]+ J
  590.     else; z9 s- C+ ?, s, D( k/ E! N1 t( r
  591.       vp_x = viewport.rect.x - viewport.ox0 X. @% r4 y1 c
  592.       vp_y = viewport.rect.y - viewport.oy* h6 o- j1 l; L  b8 j6 i) y
  593.     end
    ! v2 `/ l  E' ^" {1 K
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y' x- I6 G; q# R+ [- ]! ^$ J
  595.     item_x1 = vp_x + x + standard_padding ; o! y6 p- A# P9 B
  596.     item_y1 = vp_y + y + standard_padding( c! x* ?$ ^# m4 D: _
  597.     item_x2 = vp_x + x - standard_padding + width
    $ _3 t" v+ f8 D7 G
  598.     item_y2 = vp_y + y - standard_padding + height
    4 R* x; D/ A4 @  ~3 L& E/ X, l
  599.     if mouse_x  item_x1; w; ?& v/ R- g$ A3 Y
  600.       mouse_col = -19 {* B( t" h& i( U/ _
  601.     elsif mouse_x  item_x24 p- E0 |" n2 y* n+ g
  602.       mouse_col = -2
    " b5 |+ e* u5 x
  603.     elsif mouse_x  item_x1 + 160  @; k4 v1 g( }2 W
  604.       mouse_col = (mouse_x - item_x1)32/ t& c5 J# `& c+ D- k$ l
  605.     elsif mouse_x  item_x2 - 160* e7 K' Q% I1 x* r/ L1 p
  606.       mouse_col = 9 - (item_x2 - mouse_x)322 C$ c1 Z# Q9 O* ?  P# q! |( \, w
  607.     else
    1 D/ U  P8 j5 w6 o" ?$ o1 j6 I' @
  608.       mouse_col = mouse_x  x + width2  5  4
    ) x/ \# T$ f9 s% A( `
  609.     end
    % s& q( c- I0 A! b! f- S& }
  610.     if mouse_y  item_y1
    ) z+ m* A, r! D5 |! J# [; `' C: m
  611.       mouse_row = -1
    5 y1 K/ P# Y9 q( J+ G
  612.     elsif mouse_y  item_y2% f2 y, Q) A5 D( r
  613.       mouse_row = -24 ^/ u1 K# X' \6 R9 ^
  614.     else/ c* A0 ~# W( ^
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    ; L" d$ V6 v2 X' u4 |, o
  616.     end
    / J% q  Y- @  x) l3 |7 g
  617.     return mouse_row, mouse_col
    0 E; i+ E& L& R, ]; y
  618.   end" B1 O, k+ C& C* f1 ^: ^2 s
  619.   #--------------------------------------------------------------------------3 m* z+ O: H1 l6 R! S6 H- o
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    , n4 m; X8 P+ a3 b2 D1 F! ~' T7 o, B
  621.   #--------------------------------------------------------------------------. J$ f3 X( k  o& ]5 ?( S0 I* |6 Q
  622.   def set_mouse_pos
    & b9 k: l+ ?* n
  623.     if viewport.nil # necessary!
    * x3 J, u, K& W" O) e
  624.       vp_x, vp_y = 0, 0
    1 ?% I8 J1 n/ @0 x7 W
  625.     else0 ^. Q. t1 y& K- ]' X
  626.       vp_x = viewport.rect.x - viewport.ox  U2 R4 \7 o+ w% _$ o: C
  627.       vp_y = viewport.rect.y - viewport.oy4 m  S. Z: p3 J6 i3 y' h: a' Q$ j
  628.     end. D) A4 c+ @- W, ^& N
  629.     item_x1 = vp_x + x + standard_padding
    # {# C5 \) ^5 ^, f
  630.     item_y1 = vp_y + y + standard_padding6 I" I: C; m" U/ C9 Y
  631.     get_index = @index  0  0  @index   ?  @4 r+ ~" w! A) y. @( B
  632.     row = get_index  col_max - top_row, B9 b' R* U4 t) k4 r5 F4 F% S; \( p
  633.     col = get_index % col_max) Q$ x8 z7 n1 E- j3 x8 r4 k9 g
  634.     new_x = item_x1 + item_width  (col + 0.5)
      J) o. j$ o/ N, B
  635.     new_y = item_y1 + item_height  (row + 0.5)  Z( L: M! s7 q8 R  G+ b8 A$ g* G
  636.     new_x += 14 if col  4
    4 X1 c. _5 |2 \0 T3 K7 W9 J/ c
  637.     Mouse.set_mouse_pos(new_x, new_y)
    ! k; M0 m7 H+ }# V
  638.   end, I* h3 h0 Y  c3 `5 N
  639. end" k1 a0 w/ E6 V' c

  640. 7 n1 S& q  E4 x$ ^: j8 U
  641. #==============================================================================3 W, b1 H% S) D9 R. B
  642. # ■ Window_NumberInput
    5 @; K) m) R% g% L5 _
  643. #------------------------------------------------------------------------------
    & [2 X  x: v( {( s2 r
  644. #  重写了数值输入的方法以适应鼠标: O% B. j/ U/ S5 e9 Y" t9 i9 B" j; x
  645. #==============================================================================" q" L9 ~6 c2 U6 C  ^7 }
  646. class Window_NumberInput  Window_Base4 E" T% v# q  y( m& u" |& `$ H
  647.   #--------------------------------------------------------------------------
    ) T$ Y: S9 F# N3 B# i1 j
  648.   # ● 定义实例变量
    ! Y; B# `' s; F
  649.   #--------------------------------------------------------------------------
    - i/ `8 V3 L) A% p' p3 ~
  650.   attr_reader extra_window
    ( q; |/ E1 B- M7 g& T
  651.   #--------------------------------------------------------------------------- Q6 w. c) R! y: R
  652.   # ● 初始化
    + S/ H9 X% J: K& j8 o3 x0 \% J9 C
  653.   #--------------------------------------------------------------------------/ G+ d% I8 ~7 ]
  654.   alias sion_mouse_initialize initialize# O! q& R4 Z  D( d9 w5 U! B9 ]/ b
  655.   def initialize(arg)! U2 [9 z& X$ |/ W
  656.     sion_mouse_initialize(arg)
    2 X# }% |( A; g
  657.     create_extra_window: t2 ?( a; i4 Z1 ]" y6 u
  658.   end6 A0 G/ i1 P6 l: p: e, L
  659.   #--------------------------------------------------------------------------) Q- W5 n5 F! U# R9 B0 L1 m: |
  660.   # ● 启动
    ; h7 ~1 Q( ^" _1 e, r4 A
  661.   #--------------------------------------------------------------------------
    5 l1 k+ I+ o& x. a9 A- |
  662.   alias sion_mouse_start start
    ! Q( ?6 v  K  l0 u, q; Q
  663.   def start
    # c" v! }1 B4 m; L
  664.     sion_mouse_start
    5 A* ]3 y6 u3 h! S" U1 G4 K
  665.     deactivate
    & c# x' Z4 H# ~
  666.     extra_start. {1 m. ~) c$ k$ o- K! t
  667.   end
    : c% D- ^, S9 n. _2 ?
  668.   #--------------------------------------------------------------------------% Y7 r: M6 a8 ~2 C8 z% u1 F
  669.   # ● 创建新的数值输入窗口( l# b& \: j8 z; A; n$ ]8 [/ m
  670.   #--------------------------------------------------------------------------
    / i; h. O; \; T) _, c
  671.   def create_extra_window3 M) ^1 z+ o$ N6 B4 x2 l
  672.     @extra_window = Window_NumberInput_Ex.new6 O7 R/ c6 G! X* R5 x& ]# W" _
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2' P+ I; ^1 f" P9 d% a" v1 D
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }- r! ]% D0 y0 ~, Z) }0 K6 u8 M3 b
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    " d. |5 r4 P3 J$ O. q
  676.     @extra_window.close_proc   = Proc.new { close }( w2 Q" t8 N; f
  677.     @extra_window.refresh_proc = Proc.new { refresh }/ G& R3 _& Z- e  E8 ~" _2 [9 c
  678.   end
    4 g( Q6 Z- A8 k, g: [! X$ c5 Z
  679.   #--------------------------------------------------------------------------+ Z# |* ]! ?9 o
  680.   # ● 激活新窗口* x( Q' H4 t$ P8 ]# {9 q9 M! O
  681.   #--------------------------------------------------------------------------' d6 c- B5 h/ A+ W
  682.   def extra_start
    ! E8 ^3 C9 o3 a# A
  683.     case $game_message.position
    : y) J1 R. p9 y; {" x. o0 g& o! C
  684.       when 0; @extra_window.y = y + height + 4
    ; {4 p9 L* A+ M& D  r; c* U
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8( k# i# c4 m) G& O( i, u
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    : [3 R+ {+ R& J6 S
  687.       else  ; @extra_window.y = 8
    * c; m' }! S: ]3 e1 n4 x% H
  688.     end
    ) E" q: J. r" f; c+ k4 z
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    6 p& [! I& N3 D0 ^. u
  690.     @extra_window.digits_max  = @digits_max
    + I, b: {7 V+ e! r/ ^% B& z
  691.     @extra_window.number      = @number, l( H# \- f7 f" r% T+ W
  692.     @extra_window.open
    . c" e- U. M1 k7 y  A
  693.     @extra_window.activate0 A" f2 g; b1 x- i/ y! r9 c7 E9 K
  694.   end7 |# J: j* p( e7 L
  695.   #--------------------------------------------------------------------------7 P' e: U1 t# {) q9 {% b! Z* s" S
  696.   # ● 更新7 c% ~; s7 Z2 z# ^0 e4 Y
  697.   #--------------------------------------------------------------------------: |% u% p- _& Z* m
  698.   def update" U( A( k4 e" J. K) }
  699.     super
    + F. }( n" c5 D7 g* u, v
  700.     @extra_window.update
    4 |/ V" I5 h4 a& E8 a( [5 N. B
  701.     update_cursor2 ~4 F- O: y5 f) q( t; E
  702.   end
    4 k  [" z1 u; c* n& c- Z
  703.   #--------------------------------------------------------------------------
    # |9 ]# {( P) Z9 ^5 j, D4 |' Y- r
  704.   # ● 关闭窗口
    ! Z) W% b, N; _6 l2 Q
  705.   #--------------------------------------------------------------------------& w* p* [' p6 g/ D+ c# ?% l: o
  706.   def close% H8 E9 X' o3 l/ s3 X# H; ]
  707.     super
    : ~# n6 H) f8 W/ ~3 t4 l
  708.     @extra_window.close6 Z7 o  v% ]. F1 S
  709.     @extra_window.deactivate
    8 E$ s! }0 X2 D2 ^+ p) e0 S& t. g) Z
  710.   end# I! J* F5 ~! F1 i: T' d1 J$ q
  711. end/ h( \9 ?6 d7 p
  712. 0 Y  v* g- D9 y5 l6 S
  713. #==============================================================================& q4 P  y% m$ q3 I
  714. # ■ Window_NumberInput_Ex
    & c- U. M! o1 _  j, g( A
  715. #------------------------------------------------------------------------------
    $ v0 C# Z& ^; O1 @
  716. #  新的数值输入窗口(NewClass)
    " o! C: M: v! q: y% x6 K, y4 ?
  717. #==============================================================================: S4 H) c, o, Z0 n% W' N
  718. class Window_NumberInput_Ex  Window_Selectable
    / H2 `% s6 W6 ^$ r! `4 |4 I" H
  719.   #--------------------------------------------------------------------------* T# g) i9 ]* i6 ~
  720.   # ● 定义实例变量* R: W0 k4 j6 e) z
  721.   #--------------------------------------------------------------------------
    9 z; F' O( j4 E' ^8 ?( X7 b
  722.   attr_accessor number_proc
    7 z. W0 k) L! B' m
  723.   attr_accessor index_proc
    : i6 e. ]0 {" u- \: x3 u& `& R+ N
  724.   attr_accessor close_proc# h7 P/ X( h: T2 F4 J
  725.   attr_accessor refresh_proc
    % x5 `- p1 E7 n( N
  726.   attr_accessor number
    % i  Q  G! u2 z' C$ w( h( i
  727.   attr_accessor digits_max
    0 j. p% T, y2 |+ o2 t
  728.   attr_accessor variable_id
    2 V! a( p0 w' g7 }# s6 C
  729.   #--------------------------------------------------------------------------( }3 n" v2 f5 ?
  730.   # ● 数字表
    ' Q  I9 n1 J, u$ S; e4 x  f
  731.   #--------------------------------------------------------------------------
    6 _2 K8 a( g2 e, y' A) I8 c& i
  732.   TABLE = [  7,  8,  9,
    6 N8 w3 Z( |$ r
  733.              4,  5,  6,
    4 z: H, d+ Y7 }" ~' B2 @1 E1 l, m
  734.              1,  2,  3,& K* L" I0 A5 Q
  735.             '←',0,'确定',]; c* d/ g6 D3 k5 z) g  o- I7 `
  736.   #--------------------------------------------------------------------------
    ' r/ t; b# ]1 N5 Q; Y
  737.   # ● 初始化对象
    - \, \4 H; T' H% I9 Y
  738.   #--------------------------------------------------------------------------6 ?+ L% n( d( G9 L# g0 ]. ]
  739.   def initialize
    5 }2 k) T8 {8 b$ \
  740.     super(0, 0, 120, fitting_height(4))
    ; k' n, i3 u  j% r' F
  741.     self.openness = 0
    $ v' B+ c# l# K. L
  742.     @index = 0
    1 a5 E0 G" a5 s/ \( g1 r- `
  743.     @number = 0
    0 c+ b0 D9 P  F3 @9 O! B) I
  744.     @old_window_index = 0
    5 V8 f0 Y7 f' |8 y
  745.     @digits_max = 0
    : {* U8 D: W0 t5 Z& H9 Q: P
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }* r/ g4 l, }# b
  747.   end
    : ~, H) ^. B; J
  748.   #--------------------------------------------------------------------------
    + \- S( b! _) a  T. p1 q
  749.   # ● 获取项目的绘制矩形& ^5 J3 S  r1 e! p  X7 T
  750.   #--------------------------------------------------------------------------
    " Z% l0 c0 m" S/ q& R
  751.   def item_rect(index)/ z4 S& ]/ }, |" C% m4 _% o  I( n. K
  752.     rect = Rect.new+ z9 M3 Z% a; \7 z9 i/ t5 O7 ?9 P
  753.     rect.x = index % 3  32! j  y0 S: k' o0 `+ _; S
  754.     rect.y = index  3  line_height
    $ B+ C% z0 d, Q; A" E+ k
  755.     rect.width = 32
    & {! O5 i; D+ H
  756.     rect.height = line_height" m2 Y4 g  \$ \; w0 {' ?
  757.     return rect9 l2 m; O& l: d, D& F" D% j
  758.   end* X) N9 D( o9 ]9 B" M& ]0 g
  759.   #--------------------------------------------------------------------------% x9 g$ w0 c6 T! N: U, b
  760.   # ● 将光标设置到鼠标所在的位置
    % N3 F+ g  _! v* v
  761.   #--------------------------------------------------------------------------
    - a( @9 K* t# [' \" N6 u4 B0 l2 N
  762.   def set_cursor7 A: w# S5 S2 S# e8 l
  763.     mouse_row, mouse_col = mouse_window_area
    * F2 s3 `! V5 r. T2 p$ M. H
  764.     if mouse_row = 0 && mouse_col = 0
    8 `+ j3 E* m! ~: s3 s
  765.       new_index = mouse_row  3 + mouse_col3 z; }; d' `# g
  766.       select(new_index) if new_index = 11
    7 x+ ^" ~1 [( M) l5 G; [- C" K; S4 ~
  767.     end
    6 D3 E- C; [% L9 e* {+ }* Z2 y' ?
  768.   end
    9 C8 k" O2 s* x" d. |8 b9 i/ H5 P
  769.   #--------------------------------------------------------------------------
    ; k: Z- _7 ?6 x7 H" T# w
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列+ L+ h2 r& I. R
  771.   #--------------------------------------------------------------------------  ~2 X8 |( r/ {/ G9 Z' B) ?  N+ i% d
  772.   def mouse_window_area
      A+ c0 S' q. j6 ?; N8 j8 L% H; q
  773.     if viewport.nil
    # y0 F* ?3 }6 p% C+ g
  774.       vp_x, vp_y = 0, 0
    / f! v% f/ c- i/ y
  775.     else: |6 D# A. g. U+ g% _: c, X6 S
  776.       vp_x = viewport.rect.x - viewport.ox
    0 i9 J5 O6 j6 [
  777.       vp_y = viewport.rect.y - viewport.oy3 O+ Z8 ^7 m0 h6 N3 P
  778.     end1 J8 O. Z% Q0 O# X* k
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    4 L, ]0 x+ l! a+ m) K5 D1 N5 N4 `
  780.     item_x1 = vp_x + x + standard_padding
    8 q, Z5 t* O# f9 I* o
  781.     item_y1 = vp_y + y + standard_padding
    0 O  t, h6 X7 X) j3 |' x' P4 U" E* D
  782.     item_x2 = vp_x + x - standard_padding + width
    4 v$ O7 N/ }! {; s
  783.     item_y2 = vp_y + y - standard_padding + height$ c: [' _9 B  ]" G3 e" s9 t
  784.     if mouse_x  item_x17 z6 J* Z1 h- {& N! Y
  785.       mouse_col = -10 o, ^. d) ~) Z: e& y4 b2 }' L
  786.     elsif mouse_x  item_x2& d0 m7 I5 ^3 L; z. o: N
  787.       mouse_col = -22 b1 N8 `$ W7 u$ P$ [
  788.     else! e1 p  w8 F) v" ?% O
  789.       mouse_col = (mouse_x - item_x1)  32
    3 s- A. H( s2 \
  790.     end
    6 T$ w" r7 @0 k4 p0 Q6 I1 @
  791.     if mouse_y  item_y1: U3 y! K* [5 W
  792.       mouse_row = -13 P/ C" E, A8 O  r& o1 i* o
  793.     elsif mouse_y  item_y2' ]% r$ b& i% u9 O1 z2 u$ n' Q
  794.       mouse_row = -2
    & c, }" g) A4 w
  795.     else. j: H0 B3 A( ^( c* }( [
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
      J6 s0 |9 d9 _1 r  {3 p
  797.     end
    , M" m: `7 o# u) t) u
  798.     return mouse_row, mouse_col
    ' H1 l6 a' ]) v) t, g, e" ~: m
  799.   end! ?1 A$ M' Q# [
  800.   #--------------------------------------------------------------------------0 V3 b# G- k. D6 _0 }% N+ ^+ D7 ^
  801.   # ● 获取文字
    6 y1 Q7 _4 e6 e5 G
  802.   #--------------------------------------------------------------------------
    6 N' ^* H2 t* g% P# H2 ?7 B
  803.   def get_number
    7 \! D& `1 W6 U% \
  804.     return false if @index == 9  @index == 11
    ' H# f! ?. ^/ t6 D! N4 o
  805.     return TABLE[@index]
    , e/ j- A+ }9 H6 `8 Y
  806.   end4 D' M4 P6 p8 w9 k3 |) b! s
  807.   #--------------------------------------------------------------------------/ ~. x. p+ E8 ~! }) @
  808.   # ● 判定光标位置是否在“退格”上% C* j) W3 Z9 i2 G+ a) s
  809.   #--------------------------------------------------------------------------8 }* ]- Q/ ?+ r6 x, w
  810.   def is_delete
    4 D/ j' k) M2 G6 K: U6 p6 \
  811.     @index == 9! H1 {4 w, Q& z- f
  812.   end, o0 l& O% |: O: ]/ B4 l. Z. c8 s0 |
  813.   #--------------------------------------------------------------------------7 |" r+ }" O3 I5 l+ @* @6 _
  814.   # ● 判定光标位置是否在“确定”上
    $ X: H7 W* G6 Z1 `( P  v
  815.   #--------------------------------------------------------------------------
    3 z0 D7 P$ F+ F
  816.   def is_ok# s  t% F6 G. o2 Z7 E
  817.     @index == 11: z- J# G8 C% b1 [6 T
  818.   end7 f( i6 `$ z, w6 ^1 V- ^+ T- W  ~
  819.   #--------------------------------------------------------------------------
    5 S3 j9 }5 A) j5 s: I# j) D8 b0 [
  820.   # ● 更新光标
    , i% I/ u. e" ?/ E0 @: S
  821.   #--------------------------------------------------------------------------1 F0 q9 [$ z- a2 h0 W1 `  _
  822.   def update_cursor
    4 Z- T- D8 O+ C
  823.     cursor_rect.set(item_rect(@index))" X5 \5 q8 P* O$ w  ]' E% Y8 i5 {) X. a: Y
  824.   end! W! H% D9 ~$ Z$ V6 Z
  825.   #--------------------------------------------------------------------------7 n& t. O+ Q* r* ]! H
  826.   # ● 判定光标是否可以移动* \& U7 y( U8 k  C+ A+ l
  827.   #--------------------------------------------------------------------------. t5 T! S& _- k- @1 W
  828.   def cursor_movable
    1 L" J$ {' f; ]' R
  829.     active
    $ d: d1 s( T' _2 p
  830.   end
    0 M) K, _6 y5 Y) o0 N
  831.   #--------------------------------------------------------------------------- a0 B% P, v; j* x% j0 n2 V, X3 a
  832.   # ● 光标向下移动
    7 P7 @( [) ~- Z
  833.   #     wrap  允许循环
    * `* H8 E* ~+ M$ _' K( I! w6 |$ P/ I
  834.   #--------------------------------------------------------------------------6 U8 F$ x, C7 o6 M. J7 [- a+ k
  835.   def cursor_down(wrap)# K3 J8 P, }) j
  836.     if @index  9 or wrap
    , P8 \/ {7 }1 @) Y  m; x5 S4 u
  837.       @index = (index + 3) % 122 [6 J. K9 K- f" z( P7 I% W* T
  838.     end
    . m5 J! X- l9 E
  839.   end
    - n+ N( X- y8 o. J, a- q
  840.   #--------------------------------------------------------------------------& d: A0 ?$ j+ H3 Z3 E; v$ n! [
  841.   # ● 光标向上移动
    ( l7 }7 {( b% \, ]4 ?
  842.   #     wrap  允许循环( V0 h' Y/ c4 [1 n1 Q* p- Z
  843.   #--------------------------------------------------------------------------
    ( d4 v' v* {$ Z4 B' m' G
  844.   def cursor_up(wrap)
    8 x6 r+ Y8 d  ]$ \1 V
  845.     if @index = 3 or wrap, s. v. g% W! Z3 ^
  846.       @index = (index + 9) % 125 \. C- }( \; t
  847.     end
    + {  m8 \. b) R! j$ o( M6 m4 q
  848.   end, Q5 q, _' _4 T$ ^: X6 [9 r
  849.   #--------------------------------------------------------------------------
    7 N+ u$ t* r8 Q, l; ^0 A  n) k3 H
  850.   # ● 光标向右移动. W' I* s4 B6 V; i1 _2 E4 K
  851.   #     wrap  允许循环
    5 x& j% B% E! Y) y+ r  q
  852.   #--------------------------------------------------------------------------( |- r6 n- n" S* G
  853.   def cursor_right(wrap)
    9 V9 b7 {$ K' k
  854.     if @index % 3  21 S, t1 h0 G. W9 n+ h
  855.       @index += 1
    3 f) t" y% ^. B; _" ~0 y
  856.     elsif wrap3 U, I- Y& X9 j$ H
  857.       @index -= 2. ?- ?8 {4 e) k: C
  858.     end
    % [# W/ W# x. G
  859.   end( }0 {( D0 ~/ y' L; ~5 c5 b
  860.   #--------------------------------------------------------------------------
    & Y5 R' j/ t) Y) _  ?8 ?
  861.   # ● 光标向左移动) i. x# U& |7 F: P
  862.   #     wrap  允许循环
    : H* s' D$ u7 X3 m; {/ g2 x  C
  863.   #--------------------------------------------------------------------------% j* t* D; q* H: T
  864.   def cursor_left(wrap)% S2 \; `; s; ^& t" H- b/ ?
  865.     if @index % 3  0
    0 P0 F0 F& W/ W2 e1 C9 z) j
  866.       @index -= 1
    ' M# Y$ v. W2 k
  867.     elsif wrap
    5 J7 B$ P7 y+ e
  868.       @index += 2' e$ X0 s" `8 x& @4 v0 u
  869.     end
    7 U0 H6 M+ K; _" u/ m* T
  870.   end' c( e/ H2 @! C" {5 D( D
  871.   #--------------------------------------------------------------------------, A* [% E; p9 L: C! e
  872.   # ● 处理光标的移动$ ^. Z0 o) @8 i0 J% z+ U
  873.   #--------------------------------------------------------------------------) b0 ]) O! J1 s: S
  874.   def process_cursor_move
    ( J8 w0 |7 `3 S5 @
  875.     super
    6 Z- b$ N7 S+ o  ?; A
  876.     update_cursor
    0 X# k' e5 g2 c
  877.   end
    ( O9 ~2 v9 [; ^% K; d, _$ e& f
  878.   #--------------------------------------------------------------------------
    7 ?* H3 G4 ~/ ]6 S7 s
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    % i, A& ~+ M/ }
  880.   #--------------------------------------------------------------------------
    . s  ?  L. t1 X* B/ P2 Z5 l! U7 n
  881.   def process_handling
    : k- u: B6 `! u2 ]1 v
  882.     return unless open && active
    & H  G4 |# [; B' l, k6 ?
  883.     process_jump if Input.trigger(A)' b* o9 s; z0 X7 ^
  884.     process_back if Input.repeat(B)
    7 M8 `; w! a9 L
  885.     process_ok   if Input.trigger(C)
    - K: {: w9 q- ?! |0 \. ~1 Z0 E/ p6 {
  886.   end2 z! p2 f) |7 t# X- X
  887.   #--------------------------------------------------------------------------! m# k( E6 i6 y6 ^% Z' \; p
  888.   # ● 跳转“确定”
    2 ]! `8 o9 E5 _
  889.   #--------------------------------------------------------------------------* K' d1 l& U/ b; ~6 J, o
  890.   def process_jump9 n# L$ W: w3 m6 P
  891.     if @index != 111 C5 d* A7 o& |( o" |) z
  892.       @index = 11$ t6 S5 |& R" ]2 M' X4 G4 k3 A
  893.       Sound.play_cursor& p5 i+ e: U( S1 o' L. O
  894.     end
    6 K; v$ y) y% k2 V2 e% [
  895.   end
    / q% v/ d; p- G  H: q# p
  896.   #--------------------------------------------------------------------------
    6 a) B0 K! U" h6 s" p7 d
  897.   # ● 后退一个字符! g) d* i# X& Y/ P
  898.   #--------------------------------------------------------------------------' P. g/ j' ^0 c2 T5 b+ [
  899.   def process_back: [& ~3 V8 h4 C' r) M; C3 h+ M
  900.     Sound.play_cancel* V. n' c* E! Z- d' ]  W
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    ( h- u9 t' P: i2 `9 j; H, K
  902.     n = (@number  place) % 106 K# l9 \6 h5 D1 j+ g
  903.     @number -= n  place+ c. e: }+ a1 u/ V# b2 \4 Q, z
  904.     @number_proc.call(@number)' X; V# n- z* H7 ~2 R# H3 c  U
  905.     @old_window_index -= 1 if @old_window_index  0) H0 i7 {+ l0 Z$ u+ ?4 p# Y" h9 {' w
  906.     @index_proc.call(@old_window_index)& Q% [; i8 {0 v2 B/ j
  907.     @refresh_proc.call
    $ K3 ]+ c7 p% a! |  }
  908.   end  @* c3 T5 C& R$ b5 }
  909.   #--------------------------------------------------------------------------! i4 F% r: f( R
  910.   # ● 按下确定键时的处理
    . G/ u' \2 o, G) N% g! @
  911.   #--------------------------------------------------------------------------+ d/ }( {/ V( B# @' P& ?
  912.   def process_ok
    ) ~8 `; {2 D" b5 c! Z0 ~# p
  913.     if get_number
    6 C! |2 f/ D7 D0 e7 z0 x% ?
  914.       Sound.play_cursor7 C$ v/ u- C# L# B8 e0 D
  915.       place = 10  (@digits_max - 1 - @old_window_index)5 c1 @9 U8 E' Q- ^/ R" s
  916.       n = get_number - (@number  place) % 101 E. o# ~/ \$ n# Z3 k1 I8 u
  917.       @number += n  place
    ' f$ K1 s) B' [% f, n4 m& l4 m" x
  918.       @number_proc.call(@number)
    6 [' I" v4 X5 q- ^+ d
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    5 o: ]; P& E' f# b: f. Z, T2 o
  920.       @index_proc.call(@old_window_index); |" O1 @' `, L  [1 c( c
  921.       @refresh_proc.call& T9 m2 I$ D! @8 G% ?
  922.     elsif is_delete
    1 w4 y9 c  o3 Z3 ?) y) o
  923.       process_back( S* E5 p2 C4 m7 f; z$ O) A2 n
  924.     elsif is_ok
    1 \0 ~& X/ B9 x8 O
  925.       on_input_ok
    # S! K  G' f: C5 d/ ]" s8 r
  926.     end* q* v- e% T/ z$ p4 @2 s/ t6 _
  927.   end
    ( o5 {& y. y2 P' R. t5 r
  928.   #--------------------------------------------------------------------------
    9 d& @1 q7 {9 Q& {
  929.   # ● 确定  y- w+ _$ J* H8 T8 V6 z3 R; r
  930.   #--------------------------------------------------------------------------
    ( N1 k) b! ~4 y
  931.   def on_input_ok' V; v+ e6 r% ], D0 H
  932.     @index = 0
    ; `" g4 R' ~; \/ t
  933.     @old_window_index = 0
    # D5 P" `" D5 I% s
  934.     $game_variables[@variable_id] = @number
    , k( C, U4 M! U1 I, @; Z$ G
  935.     Sound.play_ok
    " w. ]4 t0 z4 J; H8 ]1 ^! z0 k1 K
  936.     @close_proc.call9 t) n6 F5 N2 w+ }& `; s
  937.   end
    / @4 ~& G6 O0 r2 H
  938.   #--------------------------------------------------------------------------
    9 e& M+ I3 J7 Q  w: n; D; m1 a; b4 b. _
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    + o  r% r3 a8 ^4 j
  940.   #--------------------------------------------------------------------------
    # r' D5 r" Q( b
  941.   def set_mouse_pos; u0 f0 M3 A) y* x* u1 }9 }" E* k+ n
  942.     if viewport.nil # necessary!; w3 v- y+ T1 u6 g' |
  943.       vp_x, vp_y = 0, 0
    . E5 ?; e9 k1 r0 [1 K
  944.     else
      Y5 {6 {5 M" P
  945.       vp_x = viewport.rect.x - viewport.ox: T! i' Y" \$ \6 b" S- f
  946.       vp_y = viewport.rect.y - viewport.oy
    / s9 c. F( y, W% s0 b& o% U2 ?# {
  947.     end" w3 G: I- {9 q. c( E0 W- e( |
  948.     item_x1 = vp_x + x + standard_padding + ]0 a% R8 ?. F1 c5 j) [8 r' \5 [" s
  949.     item_y1 = vp_y + y + standard_padding& z( W' T) ~& ?3 i
  950.     get_index = @index  0  0  @index 4 z8 \% J- x! ]$ j# T4 A5 C6 L
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)1 L! |" K( V/ R3 K' A0 W  d2 R
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    3 U3 g' Y$ Z. l( x
  953.     Mouse.set_mouse_pos(new_x, new_y): ?' x! a& G7 G
  954.   end
    6 x8 W1 e# b0 X6 v
  955. end7 _3 P4 f# e* z' Y2 a4 ]+ M+ }
  956. 5 x& N0 j2 W1 w' }0 ^' M- f9 n
  957. #==============================================================================1 V2 B( A& t: `+ y2 p
  958. # ■ Window_Message* h2 \1 i. L4 z: ]8 T, I
  959. #------------------------------------------------------------------------------
    # ]- c1 N! P( M6 U) c
  960. #  显示文字信息的窗口。: y! G7 _" C0 v2 P" V
  961. #==============================================================================  \- h# X+ ]6 P- M5 Q
  962. class Window_Message  Window_Base" S! A" _! D' J: C6 |3 B" j
  963.   #--------------------------------------------------------------------------' ?! c# m0 ]- H3 i
  964.   # ● 处理数值的输入(覆盖原方法)
    6 x/ H9 M2 V$ m6 f) S$ d; ^. N
  965.   #--------------------------------------------------------------------------
    / Y& _" @4 `/ M$ {( E3 I) X2 m
  966.   def input_number4 L% g7 k+ {/ S; Q% C6 g7 M
  967.     @number_window.start& }' }3 x5 e) [5 K1 x
  968.     Fiber.yield while @number_window.extra_window.active' Z0 ~) `3 m! Y3 H4 q1 S
  969.   end
    " Q; A& S9 l- r/ |8 ]2 E# l; n
  970. end
    , C- @0 E! _1 @! o( ]6 z% L6 S
  971. . V6 S$ `9 N( h6 {/ Y
  972. #==============================================================================. S8 S% _3 g0 L, ~8 L" U3 e7 z
  973. # ■ Window_PartyCommand$ Z% }' V; j" Y+ v
  974. #------------------------------------------------------------------------------% l& H8 ?" A- Y/ Z! u
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    1 X& N( t1 Z! H- t; |3 [" u
  976. #==============================================================================
    & F' G/ [. D5 `4 q- V! D
  977. class Window_PartyCommand  Window_Command. [0 l8 ~3 N5 H; f
  978.   #--------------------------------------------------------------------------
    7 N. U( h7 Q) ^* [
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置: O. v+ e  t& ?( Q/ w: W
  980.   #--------------------------------------------------------------------------. N; p+ m+ S1 A8 h1 F
  981.   def set_mouse_pos
    + {9 V" i1 \+ F3 z
  982.     if viewport.nil% R$ l- s" ~5 P9 _
  983.       vp_x, vp_y = 0, 0
    . V% W- A1 b0 M
  984.     else
    , Q/ x) k0 u4 Z$ `  I9 A' v
  985.       #vp_x = viewport.rect.x - viewport.ox0 H' v# E# V+ q) B# X$ d
  986.       vp_y = viewport.rect.y - viewport.oy  ^' s6 Y. N" R% R2 f6 j
  987.     end
    / C' n5 O+ H9 w3 t9 C9 E7 X
  988.     item_x1 = x + standard_padding
    6 z' v$ O2 K% V! b- `2 ]6 \
  989.     item_y1 = vp_y + y + standard_padding" B% y: w9 i! \) ^- e  R0 _
  990.     get_index = @index  0  0  @index
    % e; E( g" a4 W7 v$ e( H
  991.     row = get_index  col_max - top_row. U# G5 U0 Q+ v" J( j! \7 Y
  992.     col = get_index % col_max3 S- e2 H; _" l0 {' O" c
  993.     new_x = item_x1 + item_width  (col + 0.5)
    : n3 ?: n1 h* j
  994.     new_y = item_y1 + item_height  (row + 0.5)
    $ \: a0 Q! C) X; A3 X# E9 I0 }
  995.     Mouse.set_mouse_pos(new_x, new_y)
    0 i" n- x+ ~: e1 D
  996.   end) X% R$ [7 ^1 D2 J) I2 @0 e
  997. end
    6 J, Y0 s3 K4 f6 o; v; i) p) @
  998. 9 t# j4 w: s0 k
  999. #==============================================================================
    $ y. c6 X% V) L8 B6 f/ p
  1000. # ■ Window_ActorCommand* Q  ]! J/ S, N  u+ c% _3 q7 ^
  1001. #------------------------------------------------------------------------------6 {/ J" }, z* j3 q1 s1 z8 H
  1002. #  战斗画面中,选择角色行动的窗口。$ w4 J' D7 p8 {) r- q( Q, l3 Y
  1003. #==============================================================================) S1 _7 y& _; r3 p6 R% a8 a, P/ g
  1004. class Window_ActorCommand  Window_Command
    : }+ M5 C& k' q3 }/ d- n3 O8 ?
  1005.   #--------------------------------------------------------------------------  }8 W1 y5 v+ w% C% h$ G
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置: {/ p- c2 m$ `4 A1 V- _) K
  1007.   #--------------------------------------------------------------------------
    7 J* Z9 v* u6 V0 v0 R5 j
  1008.   def set_mouse_pos8 P9 P* ~) ~; M/ u2 \
  1009.     if viewport.nil
    4 ?9 c! G# }+ \9 ~. r- t
  1010.       vp_x, vp_y = 0, 0% `1 k) J9 a5 v$ I
  1011.     else. F9 c5 o, H: l) h, T8 p
  1012.       #vp_x = viewport.rect.x - viewport.ox5 k3 n0 \9 M7 B/ `% \
  1013.       vp_y = viewport.rect.y - viewport.oy
    & u) m2 H/ P; B
  1014.     end
    $ @) T% g' i( U; k8 Q
  1015.     item_x1 = Graphics.width - width + standard_padding
    3 @7 h/ G: u, V  p( [) P
  1016.     item_y1 = vp_y + y + standard_padding& M  L& W' ^6 N9 W6 ]
  1017.     get_index = @index  0  0  @index
    9 j  @: Q5 Z: K) v3 R+ Y* k2 n
  1018.     row = get_index  col_max - top_row. [6 m4 _8 l2 i/ X
  1019.     col = get_index % col_max9 X0 i* O. a% T: X
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    4 q+ l% l, T. X4 E; ?
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    & _+ P2 v) D/ W$ {+ a8 h& {/ r- V
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    % _2 o0 Y' ?+ W+ c
  1023.   end8 b# c8 T" J- v1 G% P* T
  1024. end
    . n$ r9 t7 {+ I) r
  1025. ; y( l' t/ |' K8 v
  1026. #==============================================================================
    ) J5 @3 F7 l) g  W+ k
  1027. # ■ Game_Player, H. u; ^8 \) u0 Q
  1028. #------------------------------------------------------------------------------
    7 E; ~/ }# G$ R7 C3 l* i0 z
  1029. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
    5 R2 o- V* P+ S" r2 P& ?8 ~
  1030. #   本类的实例请参考 $game_player 。
    - |% r6 M( x0 ]
  1031. #==============================================================================
    9 d- L% U& Z+ I
  1032. class Game_Player  Game_Character
    2 ]) N6 B1 t1 Y: |4 Q9 C$ Y9 @
  1033.   #--------------------------------------------------------------------------
    ; ~7 L' _4 ?, v/ M* D
  1034.   # ● 由方向移动(覆盖原方法). Z- a, Y( V- f) l$ m+ X* g
  1035.   #--------------------------------------------------------------------------
    3 @: b" w- T3 g4 l: s. R% `, Q+ r
  1036.   def move_by_input
    , l" x/ r9 f$ f! i
  1037.     return if !movable  $game_map.interpreter.running4 o7 @( q' L, d9 T, c
  1038.     if Input.dir4  0
    5 l/ q2 }( ?% d+ ?. i& k6 f+ A: }
  1039.       move_straight(Input.dir4) 4 a. B" M" h- J( Y! w7 w
  1040.       reset_move_path
    ) E8 [# u" ~* Z2 L5 Q
  1041.     else9 w8 S8 C/ N5 _. m
  1042.       move_by_mouse
    3 E  H% {! k, \
  1043.     end
      o0 E) C. x; a* q/ t2 G, J
  1044.   end1 I% b# w$ \& f7 [& V
  1045.   #--------------------------------------------------------------------------
    4 o" L$ e7 b- u0 Z- P
  1046.   # ● 非移动中的处理(覆盖原方法)' h; F" o. s, m/ c' H
  1047.   #     last_moving  此前是否正在移动
    $ _" e' e$ e7 r" q4 [8 @2 X% L
  1048.   #--------------------------------------------------------------------------
    8 Z, V8 I4 `- `2 T/ V1 Y$ i
  1049.   def update_nonmoving(last_moving)
    5 D4 Q; E2 j+ {( ?1 t
  1050.     return if $game_map.interpreter.running
    ) J* B  e7 C3 ?* \: i
  1051.     if last_moving, P' i3 _% Z2 u* s3 s
  1052.       $game_party.on_player_walk
    $ L0 i0 b& c$ l$ B+ ~; X2 Y  @
  1053.       return if check_touch_event' |" Q4 }. b: I: n% {( T
  1054.     end
    * J3 g" T$ Z  j& `! ]2 Y' W
  1055.     if movable && Input.trigger(C)+ i4 B' }4 R, W
  1056.       return if Mouse.press(0x01) # 防止按下鼠标左键绘制路径时触发事件或载具切换6 A) q) A( s, E; w: G$ ?. _
  1057.       return if get_on_off_vehicle
    3 Y9 c9 U) u* Z
  1058.       return if check_action_event
    / b5 c7 G; S4 k3 b7 f1 P
  1059.     end
    5 X( u1 h2 y/ P6 U1 w9 O
  1060.     update_encounter if last_moving6 m$ q$ G2 j7 z; B
  1061.   end
    + w# Z: b' P+ C( }+ w+ g* m, l" l
  1062.   #--------------------------------------------------------------------------8 F* F- G  G0 O2 D9 _/ k+ X- p
  1063.   # ● 判定是否跑步状态(覆盖原方法), t2 g, }6 @# m* y- U# s
  1064.   #--------------------------------------------------------------------------
    9 x) e3 G0 ]2 a* r
  1065.   def dash
    ! O0 X& g1 ~2 W" P
  1066.     return false if @move_route_forcing, G" D4 I$ I6 ]0 [3 i: C: ~
  1067.     return false if $game_map.disable_dash
    % {. A8 H: g2 d: X. W2 C
  1068.     return false if vehicle; ~: R( O9 c& h; L
  1069.     return Input.press(A)  @mouse_dash4 S, c1 s' o  q; j+ o# q) M
  1070.   end' V6 _) u7 x' I$ a
  1071.   #--------------------------------------------------------------------------
    9 r4 l) O: _8 q' G7 k" i
  1072.   # ● 初始化1 s( z( g; Q7 k/ x' P) ]
  1073.   #--------------------------------------------------------------------------
    , j$ Z+ [4 d4 h, l* Y& s
  1074.   alias sion_mouse_initialize initialize/ l+ U+ J4 i8 S9 H! ^5 y2 I
  1075.   def initialize
    3 L0 k1 Z2 F# x- c
  1076.     sion_mouse_initialize8 _) d3 m( u5 \. u
  1077.     reset_move_path  c$ L  D) v# N3 @5 s7 ]1 |: R% H8 _
  1078.     @moveto_x = 02 h) e. |0 D; c. g5 b
  1079.     @moveto_y = 02 Y$ F1 ?* V/ U
  1080.   end
    * E' f- Y) X$ E0 s/ l* a0 U) b
  1081.   #--------------------------------------------------------------------------
    ( E2 q: u- F5 V- T1 j% u/ G3 H& l
  1082.   # ● 更新
    ; d/ z. Z1 R; p. P: s5 `( w3 j' J5 \
  1083.   #--------------------------------------------------------------------------
    . o; ~8 }8 k4 {/ x( Y. v- }
  1084.   alias sion_mouse_update update
    / W3 u$ ~% L8 h) l3 E3 i
  1085.   def update
    + A# F$ b+ z; y2 z$ u1 }5 X
  1086.     sion_mouse_update, f4 {; E% W6 i- y
  1087.     clear_unreachable_sign
    * L! T* w4 f3 y- s: u
  1088.   end% [9 }9 ?8 m3 ]- s9 I1 y
  1089.   #--------------------------------------------------------------------------; Q" T* z2 j( r" {. t% b8 l
  1090.   # ● 处理卷动$ V, @& p8 ]2 C) K! c$ f
  1091.   #--------------------------------------------------------------------------+ R" Q# S) ~2 R- F4 T$ A
  1092.   alias sion_mouse_update_scroll update_scroll9 t! R" F( f' _, |8 j; e
  1093.   def update_scroll(last_real_x, last_real_y)
    ! O8 c0 G2 r& q/ y- ^. ?
  1094.     return if $game_map.scrolling* P0 L1 R* V# s* E
  1095.     KsOfSionNew_Scroll  new_update_scroll
    ! o, F, p0 Y5 t' s: G& H
  1096.       sion_mouse_update_scroll(last_real_x, last_real_y)
    % {0 G& }: B# h& n7 B1 {
  1097.   end
    5 C" M" O* Z% X1 W5 I* g' V! v
  1098.   #--------------------------------------------------------------------------
    0 Q+ `. S8 Y# A0 r
  1099.   # ● 重置移动路径相关信息
    4 N+ \  }7 A% Q- ]
  1100.   #--------------------------------------------------------------------------
    / {* v) }+ q1 C2 [* r
  1101.   def reset_move_path) o* I9 b5 `1 G# {0 f* ?- z
  1102.     @mouse_dash = false
    9 u  A* E( ^- Z% ~8 X6 p6 j+ o9 \
  1103.     @mouse_move_path = []
    % a) N+ f$ B7 T( ^% ~
  1104.     $mouse_move_sign.transparent = true
    1 m% ^' v, p2 Z5 |
  1105.   end
    9 ]$ ]$ }! l. ]/ z! g, w8 N8 |6 V8 }
  1106.   #--------------------------------------------------------------------------
    # A/ f6 p5 e: w
  1107.   # ● 新的卷动地图方法
    7 y. N% g+ m  T! r$ @& H2 `" W
  1108.   #--------------------------------------------------------------------------3 V: {4 O8 N, Y9 p" c- b* B
  1109.   def new_update_scroll( r3 z5 V" |$ b! B
  1110.     horz_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.width' n9 D$ e9 t  K. }5 K+ t1 c" {
  1111.     vert_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.height
    9 P5 n# Y' I3 g4 P: _
  1112.     ax = $game_map.adjust_x(@real_x)
    + G, X" q" h- h( d
  1113.     ay = $game_map.adjust_y(@real_y)
    8 I& N0 X! H1 k3 d
  1114.     $game_map.scroll_down (vert_speed  (ay - center_y)) if ay  center_y
    9 \6 f/ N' P* f- h6 `$ E* i
  1115.     $game_map.scroll_left (horz_speed  (center_x - ax)) if ax  center_x
    4 g: o1 \8 ?  N' F
  1116.     $game_map.scroll_right(horz_speed  (ax - center_x)) if ax  center_x
    3 H, S, U4 t5 }  K6 X
  1117.     $game_map.scroll_up   (vert_speed  (center_y - ay)) if ay  center_y4 a6 C) G; z6 @9 W9 s
  1118.   end# x5 g# T- X/ d7 O- Z
  1119.   #--------------------------------------------------------------------------- R% O( K! L6 c
  1120.   # ● 消除不能抵达图标
    7 f4 u$ `0 L) o6 j
  1121.   #--------------------------------------------------------------------------3 a3 z6 e( I/ l
  1122.   def clear_unreachable_sign
    . H% @2 n3 R/ V1 Z* U% L0 a* K6 s# T8 r
  1123.     return if Mouse.press(0x01)
    ) T5 h  T: U! W/ A4 j
  1124.     if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 0+ y2 P! I) {9 Y8 ]
  1125.       $mouse_move_sign.transparent = true! ^, C% H/ g, N0 \: Y; b1 I' c1 m6 ]
  1126.       $mouse_move_sign.direction = 2' Y: ?& x6 u$ y
  1127.     end
    3 \: U: L. K) ~0 T
  1128.   end$ }& M" D5 S* t8 E& B$ Y& i7 m
  1129.   #--------------------------------------------------------------------------2 ~/ Q, D+ ^! {- n
  1130.   # ● 由鼠标移动3 E# ]4 T. f( v9 d* a! D5 `! _
  1131.   #--------------------------------------------------------------------------
    1 K9 H6 W  t  F" ^7 {' Q
  1132.   def move_by_mouse
    % g( u6 L5 [) \$ q. i7 g! Y" z
  1133.     unless @mouse_move_path.empty # 移动路线数组不为空则执行移动
    : k- T- s7 k; L# b/ w
  1134.       dir = @mouse_move_path.shift1 U+ l8 w. _9 o$ u
  1135.       if passable(x, y, dir) && !@mouse_move_path.empty* t- x+ Q/ O" D9 r; i1 V* Q$ S
  1136.         move_straight(dir)8 ^% K# k6 ?# E: w
  1137.       elsif @mouse_move_path.empty # 判断是否是最后一步7 q' A/ [4 b& w- P) o
  1138.         x2 = $game_map.round_x_with_direction(x, dir)+ b/ ^# ~/ Z  s
  1139.         y2 = $game_map.round_y_with_direction(y, dir)6 M' V, h! u& i- n" Y
  1140.         move_straight(dir) unless dir.zero$ L# t+ E( F2 t0 t
  1141.         unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具; r6 D& s2 N4 y! ^
  1142.           check_event_trigger_there([0,1,2])
    8 A4 R* j) i) }- L) h' J
  1143.           get_on_off_vehicle unless $game_map.setup_starting_event
    0 w9 R( V3 w# A% @( w7 _
  1144.         end
    0 M7 d3 `$ `$ K7 N+ z
  1145.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 26 P2 k3 Z+ m3 H* }, ?; z- R
  1146.         @mouse_dash = false
    $ @6 A/ M6 X3 @4 d# e
  1147.       elsif @mouse_move_path[0].zero # 目标点无法抵达,调整朝向→目标点9 L& i8 D. T( A$ ^& \! Q$ R( u
  1148.         @mouse_move_path.shift
    ; L) ~, C/ H1 {% V. V
  1149.         @direction = dir3 p" ?) B4 g" T4 s
  1150.         @mouse_dash = false
    # f. l( c2 K4 ]. J. F6 A% y
  1151.       else
    0 u& Q5 ]' e0 v, N' D, v; h
  1152.         draw_move_path
    $ D  D7 O; ^' F2 E: L* z0 {+ @
  1153.       end
    : t; k3 X4 _3 {: N; c% E/ L" A; g
  1154.     end& d: Y1 p5 p# m
  1155.   end
    # ~8 D0 |6 i/ c- }1 M- d+ h9 ~0 G
  1156.   #--------------------------------------------------------------------------7 k- }! V8 @% a  c6 H, s4 `
  1157.   # ● 地图界面按下鼠标左键的处理
    . y( v/ ^8 Y' U& }
  1158.   #--------------------------------------------------------------------------* _$ K6 t  Y* o7 y& ]
  1159.   def left_button_action
    1 o% z  T: j6 I0 a
  1160.     return if !drawable  $game_map.interpreter.running* x9 b+ l# F0 }- S) F* W7 `1 }
  1161.     get_mouse_pos+ B8 P: g% j# a; X& z8 q8 t6 K
  1162.     $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图
    : x, U! ^( N; g5 G! N+ Q
  1163.     if @shift_event
    2 x( E8 j+ f4 u( p: u: W7 Q
  1164.       if Mouse.trigger(0x01). t/ o% g4 g+ ]% k
  1165.         @shift_event.jump(@moveto_x - @shift_event.x,. y$ Y8 B% b: b+ a
  1166.           @moveto_y - @shift_event.y)
    + e* z5 D2 F$ G
  1167.         @shift_event = nil
    * ~7 b; S6 r! ?' v3 ^
  1168.       end
    % C0 [8 T3 ~0 f' x$ s& r; B
  1169.       return$ r  g1 p- c2 C- \& W- Z: k
  1170.     end
    ( q0 q/ n: ^4 U. ~* Q
  1171.     if @moveto_x == x && @moveto_y == y # 判断目标点是否与角色重合
    " [$ }/ T6 |4 g( r7 m# b- R
  1172.       return if moving  (vehicle && !vehicle.movable)& S! f) x5 D9 I
  1173.       check_event_trigger_here([0]) # 判断是否触发重合点事件
    " C: h9 K& n5 j
  1174.       get_on_off_vehicle if !$game_map.setup_starting_event &&
    " b& ]3 [& L- L. D) f; w
  1175.         $game_map.airship.pos(x, y)  # 判断是否要上、下飞艇# B5 y6 b8 }. z. n* W2 P
  1176.       return
    . F6 w+ M' J, I$ z7 r: P! W4 H9 s( a
  1177.     end
    ( E- v" T7 W& f- c) J/ y/ R- f; u* X
  1178.     # 判断是否用鼠标启动事件
      Z  d1 A% ~! P1 |
  1179.     $game_map.events_xy(@moveto_x, @moveto_y).each do event
    ' V# ]' M9 t8 e4 J  k) [, ^  I3 ]
  1180.       if event.mouse_start: j/ p5 ~# H1 Y  x" V
  1181.         reset_move_path; [( z5 T, T' d. r
  1182.         event.start if Mouse.trigger(0x01)
    / g( y5 I1 y0 ~
  1183.         return
    6 u: j1 K7 Z5 G: b$ e
  1184.       end
    ! S) R9 T$ x* Q; H
  1185.     end% I' F5 j7 L; c: m1 ]
  1186.     @mouse_dash = true if Mouse.double_click # 双击冲刺
    5 y, V/ ~- u& E  G
  1187.     return if Mouse.left_state % 10 != 1 # 按住鼠标左键10帧绘制1次路径# }8 A8 @# v. d5 \
  1188.     for i in 1..4 # 判断目标点是否为角色周围四点
    . F( Y# k$ f3 C7 R' K4 y
  1189.       if x == $game_map.round_x_with_direction(@moveto_x, i  2) &&) i  j$ o, L8 N" Z  s
  1190.          y == $game_map.round_y_with_direction(@moveto_y, i  2)
      b1 j% U0 X3 b1 p
  1191.       $mouse_move_sign.transparent = true
    ; |- _4 W: \2 F" [
  1192.       @mouse_move_path = [10 - i  2] if Mouse.trigger(0x01)0 ~& t$ d. q2 h; P. H
  1193.       return; end
    / r2 e* G: |. F" J4 t, \
  1194.     end, z& m" p" E. z: h: [- F2 Q6 H
  1195.     draw_move_path  e  _# M1 N, l- d% O
  1196.   end1 _5 v6 j/ J, i. h+ l" G9 n
  1197.   #--------------------------------------------------------------------------! w; r: l& ~& }) |
  1198.   # ● 取得鼠标处对应地图坐标点
    2 E! [3 n: x0 s5 i/ |) k
  1199.   #--------------------------------------------------------------------------
    * j1 @$ A$ b8 R6 k
  1200.   def get_mouse_pos" ~: J' {( }& A5 @0 s, K
  1201.     $game_map.get_mouse_map_xy& T# Z! \% A, a1 P4 a
  1202.     @moveto_x = $game_map.mouse_map_x) l5 y0 W. w( U8 x
  1203.     @moveto_y = $game_map.mouse_map_y
    9 ?4 |, j% I" E( x+ t5 |4 j7 c
  1204.     #mouse_x, mouse_y = Mouse.get_mouse_pos
    % c/ h( P* Q" G# _0 ~
  1205.     #@moveto_x = $game_map.round_x(x + (mouse_x - ' @0 Z: g& ?( k8 Z% L, N
  1206.     #  ($game_map.adjust_x(x)  32 + 16).to_i + 16)  32)7 E# Z# m! N7 |1 l
  1207.     #@moveto_y = $game_map.round_y(y + 1 + (mouse_y -
    . k1 \1 x0 F& t% E0 y6 p
  1208.     #  ($game_map.adjust_y(y)  32 + 16).to_i - 16)  32)* S/ K- l- ?3 c( Z; S. d
  1209.   end0 s8 p0 q7 s) ^3 L
  1210.   #--------------------------------------------------------------------------
    : D3 z6 r% Y( y2 L$ l0 x$ H# l
  1211.   # ● 绘制移动路径 @array[move_directions...]2 n/ e  P4 j7 b
  1212.   #--------------------------------------------------------------------------
    " }7 U5 c' }* E
  1213.   def draw_move_path
    $ |9 k) Q( K' `7 `  L
  1214.     #temp = Time.now$ X/ |. ~+ e0 g- {
  1215.     case @vehicle_type* j, L4 f) B$ o
  1216.     when walk3 F7 N! ?3 B# L8 T$ c
  1217.       draw_walk_path
    9 c; j9 K4 \" H. `# }6 b( I
  1218.     when boat
    " [" R- P; w- q. g
  1219.       draw_boat_path) @5 w+ P8 g9 B$ ~
  1220.     when ship* m2 s' z+ K( ^7 o4 Z
  1221.       draw_ship_path8 X. K7 g& S% P
  1222.     when airship
    $ D3 V+ {1 v- V) N- v
  1223.       draw_air_path- c! _' b4 N4 |
  1224.     end$ r$ g9 J9 m* P+ G# a) f6 d
  1225.     #p (Time.now.to_f - temp.to_f) # 测试效率# ~/ q- w/ K2 f* R
  1226.   end" i# q, _, V0 n+ t# f2 q
  1227.   #--------------------------------------------------------------------------! ]! T7 M# ^: j- O3 N0 t
  1228.   # ● 判定是否可以绘制移动路径6 |$ l' r4 R% h& p7 I
  1229.   #--------------------------------------------------------------------------+ l/ D0 b1 Z! t
  1230.   def drawable! e: j) X2 a' p# ~+ f5 O
  1231.     return false if @move_route_forcing  @followers.gathering
    ; A+ j' {% [3 Z5 r) t( V2 z8 Z+ z  i! C
  1232.     return false if @vehicle_getting_on  @vehicle_getting_off4 l8 I  @+ h# s- l) w) p, E$ c
  1233.     return false if $game_message.busy  $game_message.visible
    6 e1 b3 }; \) p+ |
  1234.     return true7 t  @! x# y4 ?% d
  1235.   end
    6 M' V" r5 ^0 |6 ?+ I3 O
  1236.   #--------------------------------------------------------------------------
    % b( u& ?0 A. \
  1237.   # ● 绘制walk移动路径 @array[move_directions...]+ j, F4 n6 {4 g# I. P8 p% Z0 ?+ @! p
  1238.   #--------------------------------------------------------------------------  _9 f8 c9 f3 C, D, [$ @8 a
  1239.   def draw_walk_path; n: n( ^1 U! B% x
  1240.     # 准备绘制路径表格
    3 ~* P" E9 n- @  Z
  1241.     sheet = Table.new($game_map.width, $game_map.height)  c9 M* t" d1 `4 \& c
  1242.     reversed_chase_path  = []; chase_path  = []: ^2 I2 m- F. M6 G
  1243.     reversed_chase_point = []; chase_point = []* C( b; T) Z4 U( ^# G% |) J5 H
  1244.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
    $ E  \7 L+ l1 E& T5 x& L3 U! b" n
  1245.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
    * N( I+ @9 g+ a) h  x) [
  1246.     reach_point = false
    ; s7 s! q# z% m6 i! P
  1247.     step = 3
    9 q% x. X4 s# W4 c+ x: l
  1248.     loop do #loop1 开始填充表格
    2 g3 n' r" w1 I9 }& j# t% D
  1249.      draw_path = false
    % g5 r$ ^( A% a6 \7 w% K5 y
  1250.      check_points = new_start_points
    ! O: {" F6 j, J
  1251.      new_start_points = []  r8 j: K# F& z. Q) j. X
  1252.       loop do #loop2 从起点开始正向填充* Q# t4 U! r0 |% J1 w) T4 I
  1253.         point_x = check_points.shift
    * \# m. C3 @3 \/ Y
  1254.         break if point_x == nil
    ! p/ }$ j" q* u0 U0 `/ E
  1255.         point_y = check_points.shift
    ' k8 F( [! C  Y
  1256.         left_x  = $game_map.round_x(point_x - 1)  Q' O+ ^% m; E7 n3 z# {
  1257.         right_x = $game_map.round_x(point_x + 1)7 }1 b' ~4 v+ D2 N
  1258.         up_y    = $game_map.round_y(point_y - 1)  Y' F- W& v; h: p" w5 Q% z
  1259.         down_y  = $game_map.round_y(point_y + 1)
    8 d# }0 l% \, q, I' N
  1260.                     # 判断路径是否连通$ ~% W! a& y& I% A
  1261.         path_step = step - 1' T1 B' I  y" q8 m3 E
  1262.         if sheet[left_x, point_y] == path_step     &&
    4 w' s* j# `, ~$ F9 p
  1263.            $game_map.passable(left_x, point_y, 6) &&
    1 x" B) _7 s+ Z- T" R& |
  1264.            $game_map.passable(point_x, point_y, 4)
    8 Z7 m" T- I0 J2 A+ w
  1265.           chase_path.push(4)
    ' t8 j3 J: o$ l
  1266.           chase_point = [left_x, point_y]
    ; J$ b% s, J" d0 |8 W# r4 v6 ~
  1267.           reversed_chase_point = [point_x, point_y]4 A5 |  r( }9 P; r
  1268.           reach_point = true; break
    ! r! E, B/ u5 Q( a
  1269.         elsif sheet[right_x, point_y] == path_step     &&
    2 m3 M$ h- R* J7 B! Z4 n- E' r: R* B
  1270.               $game_map.passable(right_x, point_y, 4) &&
    6 C' o" F* N; p$ L7 k
  1271.               $game_map.passable(point_x, point_y, 6)
    + M3 A9 ~4 L& w" w8 @+ x8 s
  1272.             chase_path.push(6)* c/ W% n( z: q% V! U6 L* X' l
  1273.             chase_point = [right_x, point_y], y; x' m  R8 w* ^7 X
  1274.             reversed_chase_point = [point_x, point_y]
    ; v; L3 l  e- O, p
  1275.             reach_point = true; break
    ! X  T# t' p: F
  1276.         elsif sheet[point_x, up_y] == path_step     &&
    - Z8 m2 D2 ]  B4 H
  1277.               $game_map.passable(point_x, up_y, 2) &&  e8 a2 e' g5 [) C
  1278.               $game_map.passable(point_x, point_y, 8)
    5 k$ e( D4 J* N0 Q+ w4 n& C
  1279.             chase_path.push(8)
    " m% `5 L" \9 J9 C( D2 L, g
  1280.             chase_point = [point_x, up_y]4 @5 B* O' O- e
  1281.             reversed_chase_point = [point_x, point_y]
    7 E+ Z* Q. _6 G- |4 b
  1282.             reach_point = true; break
    + F2 f& x$ P$ \) h' j
  1283.         elsif sheet[point_x, down_y] == path_step     &&4 o3 ]- D, C& Y; G2 o* m
  1284.               $game_map.passable(point_x, down_y, 8) &&  i" v' h+ a2 G( p' p% F2 G
  1285.               $game_map.passable(point_x, point_y, 2)
    ) e3 `* P- D: z( u# W
  1286.             chase_path.push(2)
      d7 e. ~- x8 Y' t  ~
  1287.             chase_point = [point_x, down_y]( Q; V& y& z7 e) d- _
  1288.             reversed_chase_point = [point_x, point_y]2 N, Q! c% O5 M, p( X3 B5 C
  1289.             reach_point = true; break
    , Z4 E/ N  G% q! t1 Q, }
  1290.         end+ E) c/ y' ?. ~
  1291.         # 以需要抵达该点的步数填充路径表格 #
    , u9 I9 r2 I/ J$ U0 X6 b# w  T
  1292.         if sheet[left_x, point_y] == 0              &&
    3 v& X( f; d' U8 o+ X8 I1 L
  1293.            $game_map.passable(left_x, point_y, 6)  &&
    ! K) E% S4 `. P5 j4 [
  1294.            !collide_with_events(left_x, point_y)   &&
    , j5 H: l$ ^# T6 \/ J( x! n
  1295.            $game_map.passable(point_x, point_y, 4) &&
    ' C5 A4 F0 e; b, [$ H. Z0 G4 G
  1296.            !collide_with_vehicles(left_x, point_y) #judge_end7 k  j" V* _4 ?; ^/ L1 R
  1297.           sheet[left_x, point_y] = step: l" r- K: f8 y
  1298.           draw_path = true
    & s) `7 a# e& v7 d# T& L
  1299.           new_start_points.push(left_x, point_y)
    ( j) B) _' d( X! ^" J
  1300.         end
    % a, S9 h# j( Q& j" `  y' a
  1301.         if sheet[right_x, point_y] == 0             &&
    8 T# Z$ k) D% l8 k  z2 w
  1302.            $game_map.passable(right_x, point_y, 4) &&, {. \% @9 b8 w6 h6 h, }
  1303.            !collide_with_events(right_x, point_y)  &&
    & Y3 o! M2 B. s/ d
  1304.            $game_map.passable(point_x, point_y, 6) &&* s/ N! H/ y9 [+ G
  1305.            !collide_with_vehicles(right_x, point_y)#judge_end; r, s; j$ b& D/ E. P0 T1 V
  1306.           sheet[right_x, point_y] = step% N8 D* V: {  j1 t$ W( ^5 `
  1307.           draw_path = true" g% A5 {; {) [5 c
  1308.           new_start_points.push(right_x, point_y)
    4 f, r' A9 B, j5 x7 j2 O+ R
  1309.         end, o' h6 j+ }+ U- N. |  @/ z$ ^6 M& |+ P
  1310.         if sheet[point_x, up_y] == 0                &&6 N: i4 U! M' h! S% C
  1311.            $game_map.passable(point_x, up_y, 2)    &&4 p: f9 P  M* n
  1312.            !collide_with_events(point_x, up_y)     &&* F/ t! Q& p4 ?( R* V
  1313.            $game_map.passable(point_x, point_y, 8) &&
    % k& m% V! r5 b, q7 s
  1314.            !collide_with_vehicles(point_x, up_y)   #judge_end7 p$ E" E. N7 u  n( a& W
  1315.           sheet[point_x, up_y] = step
    / N) _& t% A  S& L1 k. {( V5 G
  1316.           draw_path = true$ c" b& J8 ~7 y  P8 s* @
  1317.           new_start_points.push(point_x, up_y)
    + z' N: Y$ [& A* |' ]# F
  1318.         end
    - C' G# I+ ~7 `$ W" N
  1319.         if sheet[point_x, down_y] == 0              &&5 {8 g$ h( Q; c) H
  1320.            $game_map.passable(point_x, down_y, 8)  &&
    : E: o# s: p! n7 L% v- V5 @
  1321.            !collide_with_events(point_x, down_y)   &&
    $ J3 I- T1 i* c2 f" k' e7 b
  1322.            $game_map.passable(point_x, point_y, 2) &&
    , X1 V0 L% @2 v% q8 _% x$ n. f! v
  1323.            !collide_with_vehicles(point_x, down_y) #judge_end- a! n4 U% k3 q0 a" O" i2 d. E* K$ K
  1324.           sheet[point_x, down_y] = step
    9 n1 F  o: S1 g8 g
  1325.           draw_path = true
    6 p3 Z% p0 \& P& }0 v5 y, |) u+ Y( F
  1326.           new_start_points.push(point_x, down_y)
    7 T5 a. x9 x5 G) @" d
  1327.         end
    * h: i& b! G; D6 Q' e6 ]
  1328.       end#endOfLoop2
    " @8 }& y+ I, J+ N& B' j" ^1 h
  1329.       break if !draw_path  reach_point- W+ @2 E( X2 J$ Z0 C" |! M
  1330.       draw_path = false
    * N* Q* u# L/ ^; A& ~' j6 {* s
  1331.       check_points = new_end_points
    ( T# {' E" f" \  t* ~6 M% P
  1332.       new_end_points = []
    ; C* s% b6 @& T0 V
  1333.       step += 1
    $ v. _& }5 I7 H- _8 S
  1334.       break if step  KsOfSionBreak_Steps &&. \0 g- M8 S3 ]6 n
  1335.                !Input.press(KsOfSionFind_Path_Key)
    3 k/ o0 c8 m: M8 e2 e% u& P( j
  1336.       loop do #loop3 从终点开始反向填充5 a) t. T8 S) J1 P
  1337.         point_x = check_points.shift
    " D* v' c1 _+ h$ L! W) T
  1338.         break if point_x == nil
    & v0 h5 R- V; B- T$ g/ `
  1339.         point_y = check_points.shift
    0 P& P* e4 C# x  g# b* _; v
  1340.         left_x  = $game_map.round_x(point_x - 1)
    $ a6 V# L  O5 E: V) r' h8 m' E
  1341.         right_x = $game_map.round_x(point_x + 1)
      P# V; E* p" ~
  1342.         up_y    = $game_map.round_y(point_y - 1)
    , h( n, ~; F! Y4 p# r. y
  1343.         down_y  = $game_map.round_y(point_y + 1)3 O# S  y: h  u" o
  1344.         # 判断路径是否连通0 @, p* s% O' |
  1345.         path_step = step - 1
    ( m3 _# k8 H$ D' Q
  1346.         if sheet[left_x, point_y] == path_step     &&8 n5 V' Y* z7 a( S: Z
  1347.            $game_map.passable(left_x, point_y, 6) &&$ \# J' T% }- p; a
  1348.            $game_map.passable(point_x, point_y, 4)
    % ?$ w9 |* f, \7 K9 }
  1349.           chase_path.push(6)
    4 y" M7 k7 Q$ G
  1350.           chase_point = [point_x, point_y]
    0 o, c( c( _( m; t
  1351.           reversed_chase_point = [left_x, point_y]
    , I5 Q* {7 v6 ]5 T( F
  1352.           reach_point = true; break
    " X0 V8 u  |; T0 Z
  1353.         elsif sheet[right_x, point_y] == path_step     &&! |$ d1 |$ r0 [0 v
  1354.               $game_map.passable(right_x, point_y, 4) &&7 P7 s* E& t) c1 t
  1355.               $game_map.passable(point_x, point_y, 6)
    ! r  N/ c$ W- z" o1 g
  1356.             chase_path.push(4)" S' |8 v7 b) A  p5 b/ d) E- H
  1357.             chase_point = [point_x, point_y]6 P( B( q7 h; @$ F4 Z
  1358.             reversed_chase_point = [right_x, point_y]
    ) z& z7 ~# p! Q; X
  1359.             reach_point = true; break
    8 h# ?% {3 Q- ?
  1360.         elsif sheet[point_x, up_y] == path_step     &&
    4 X5 n* o# c2 F- ^" E
  1361.               $game_map.passable(point_x, up_y, 2) &&2 u6 B: V, h2 a4 \0 f; a
  1362.               $game_map.passable(point_x, point_y, 8)
    & h! Q, U) d% l7 l. M4 q
  1363.             chase_path.push(2)" X% ]. E6 |2 O! [7 E
  1364.             chase_point = [point_x, point_y]
    + E6 i# i- [- p# D/ `& f* |
  1365.             reversed_chase_point = [point_x, up_y]
    ; `, R4 m8 _7 L( T
  1366.             reach_point = true; break  |3 S0 l5 L! C
  1367.         elsif sheet[point_x, down_y] == path_step     &&4 L) f% x# U& Z8 K; _1 s
  1368.               $game_map.passable(point_x, down_y, 8) &&
    " `3 A9 O' l3 n) W" j: |& E
  1369.               $game_map.passable(point_x, point_y, 2)
    7 b. f2 W' f+ o0 t, d2 Z
  1370.             chase_path.push(8)
    6 u; G9 q7 L' b6 X. o2 L( Y! ^
  1371.             chase_point = [point_x, point_y]- o+ l' N; C; a- k8 c' n' B% v
  1372.             reversed_chase_point = [point_x, down_y]
      B: }& P$ a4 A( F4 S5 D* K# Y
  1373.             reach_point = true; break
    1 z- k3 g8 G& F
  1374.         end/ P) p; R, Q' R
  1375.         # 以需要抵达该点的步数填充路径表格 #4 j! w0 q1 \2 k& i
  1376.         if sheet[left_x, point_y] == 0              &&
    5 v9 B" c) z/ q7 Z  H5 h
  1377.            $game_map.passable(left_x, point_y, 6)  &&
    - ]9 p$ U* o- @1 h# {& n
  1378.            !collide_with_events(left_x, point_y)   &&9 u( E, x6 |& }* p$ x+ G, c5 l
  1379.            $game_map.passable(point_x, point_y, 4) &&
    ( r8 ]" I+ T* n* d3 P
  1380.            !collide_with_vehicles(left_x, point_y) #judge_end% F' \" P6 J" j$ Y3 g1 O% B
  1381.           sheet[left_x, point_y] = step1 v- ?  s( z& D' t6 G4 i9 [
  1382.           draw_path = true
    " W8 q) G) u+ F
  1383.           new_end_points.push(left_x, point_y), l4 w4 ?& B1 T& h2 ~
  1384.         end
    # T9 ~, T! b- i) K3 E
  1385.         if sheet[right_x, point_y] == 0             &&
    . v. ?5 D" t! U$ G3 K
  1386.            $game_map.passable(right_x, point_y, 4) &&
    ) i6 i$ ?0 W' R4 A
  1387.            !collide_with_events(right_x, point_y)  &&( y! Y8 Z1 L+ D+ B- J
  1388.            $game_map.passable(point_x, point_y, 6) &&4 k4 u3 F# Y) b2 ~: A' F
  1389.            !collide_with_vehicles(right_x, point_y)#judge_end
    1 Z. q3 h' ^- `5 ]; X. }! I, Z
  1390.           sheet[right_x, point_y] = step" p! t2 _5 R% F, U% T
  1391.           draw_path = true  t. G( B# K  ?  u' ]* q
  1392.           new_end_points.push(right_x, point_y)
      D' q) w: B9 l' d7 W
  1393.         end
    4 d0 F2 ^# G) C
  1394.         if sheet[point_x, up_y] == 0                &&
    ' V# j: _" ?" m
  1395.            $game_map.passable(point_x, up_y, 2)    &&
    - n7 m% D- l, J& T- g7 D
  1396.            !collide_with_events(point_x, up_y)     &&( o9 y. q0 ?" O4 C' M2 S
  1397.            $game_map.passable(point_x, point_y, 8) &&
    & y0 K. I# P8 O" I, e/ T
  1398.            !collide_with_vehicles(point_x, up_y)   #judge_end
    6 Z$ j& M  N4 T5 L. P5 O3 x
  1399.           sheet[point_x, up_y] = step& W- k# @3 O* L/ W9 I
  1400.           draw_path = true8 `+ q- D2 I: H) h0 f
  1401.           new_end_points.push(point_x, up_y)
    + G+ [" A' C' L" _3 z# k
  1402.         end; z" r3 {! F5 u/ E- i# y- h4 b, P
  1403.         if sheet[point_x, down_y] == 0              &&0 t+ l& ~4 f0 h! L3 z
  1404.            $game_map.passable(point_x, down_y, 8)  &&& n  }( D: Y; V* i, L- K
  1405.            !collide_with_events(point_x, down_y)   &&
      U4 P+ N2 U7 d) z
  1406.            $game_map.passable(point_x, point_y, 2) &&. c9 ]/ c  W, G" r' P! ^5 C
  1407.            !collide_with_vehicles(point_x, down_y) #judge_end0 f1 z9 o+ {8 O9 y/ k
  1408.           sheet[point_x, down_y] = step
      [. y4 V3 |5 N4 `& ~
  1409.           draw_path = true. F6 X+ {; @+ [  [( U) f3 b
  1410.           new_end_points.push(point_x, down_y)' U, B' q9 ^3 _9 _& U8 I
  1411.         end
    " Z- Q: T, u$ e+ u
  1412.       end#endOfLoop3& k  X0 l* W& @2 D8 b8 U7 G' f
  1413.       break if !draw_path  reach_point' C$ K  H1 N' z% ^
  1414.       step += 1. k/ ~- Q& m# N2 `# \
  1415.     end #endOfLoop1 路径表格填充完毕8 a. R6 Z3 n. }! y
  1416.     $mouse_move_sign.transparent = false
    8 l5 }, o+ b5 o" t5 l. m* b8 v
  1417.     # 判断指定地点能否抵达
    5 n- F5 `, @2 c+ g& H( U
  1418.     if reach_point
    7 j$ q5 t% L' E8 O  p' p& d/ J0 u
  1419.       $mouse_move_sign.direction = 2
    5 {6 P5 t. Y0 J( O3 k, t5 ]6 |
  1420.     else
      y% e; k! h; O& f. R( a, p
  1421.       not_reach_point  z+ }4 m! n7 c5 ~& k4 R
  1422.       return& c. K3 d: t0 Z0 A' ]
  1423.     end
    ) \$ h( }5 Q: u8 o; U; t
  1424.     # 根据路径表格绘制最短移动路径(反向)6 G; a' l( N! p! V
  1425.     steps = step  2  2 + 16 A* P9 v3 \0 F: R
  1426.     loop_times = step  23 r7 r) V2 Y8 q& I. x
  1427.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1], i3 G9 M, j% k" l- g5 z
  1428.     for i in 1..loop_times # forLoop
    6 t/ x# O; m8 t: ^/ g) h
  1429.     steps -= 2; F1 k5 t' a: A3 L- a" L0 v: H6 T5 V8 g
  1430.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs #反过来?蛋疼了……
    3 D0 I' w9 D# O" e
  1431.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    9 {+ o: s# `# J1 y
  1432.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
    + M/ P- e% `2 F' |& ^4 n4 @! a
  1433.             $game_map.passable(point_x, point_y, 4)                #judge_end
    ! E1 U' ~/ v: b+ I# U
  1434.         reversed_chase_path.push(6)
    4 M4 t3 A* d. d3 z1 r. O
  1435.         point_x = $game_map.round_x(point_x - 1); `( q; g( z3 _1 w1 S7 g/ r
  1436.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    ' L$ Z: f, K6 R& d6 L+ J/ ?, B
  1437.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&1 [( v" s/ ^( s0 |* @' t
  1438.             $game_map.passable(point_x, point_y, 6)                #judge_end
    . ?0 f+ X# |3 _2 p9 u, D# `
  1439.         reversed_chase_path.push(4)
      C# x5 w! u4 J' e$ ?( A
  1440.         point_x = $game_map.round_x(point_x + 1)
    ' Z! z# {. I1 I. p8 T' l6 r
  1441.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&; x8 i$ |$ E; T$ X+ w2 t
  1442.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    + @! D2 v$ b2 m
  1443.             $game_map.passable(point_x, point_y, 2)                #judge_end% [  C' }# A* s: J  R& s7 A
  1444.         reversed_chase_path.push(8)( w) w" L! x$ B" a9 U2 P
  1445.         point_y = $game_map.round_y(point_y + 1)
    4 w; g: Z! ^# o3 J2 @. E
  1446.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    # u1 `* f" r, m- M: H9 Y
  1447.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    5 Q1 S; W1 A/ }/ ^  l" z% B& `
  1448.             $game_map.passable(point_x, point_y, 8)                #judge_end) r  P7 p8 Q0 g1 t% a
  1449.         reversed_chase_path.push(2)
    / f- ?6 N( h7 y! B' _
  1450.         point_y = $game_map.round_y(point_y - 1)) C+ O5 ]  a2 y& U7 W/ ]
  1451.       end2 M$ [8 h' \9 Y# i8 T
  1452.     else+ b  ?1 L; b3 `6 p% O
  1453.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&( ]: W/ p8 j3 P# }. X
  1454.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    $ k- c8 [5 M2 x' N
  1455.             $game_map.passable(point_x, point_y, 2)                #judge_end2 h+ ^5 M& e) O) T
  1456.         reversed_chase_path.push(8)
    9 F6 f8 b6 a5 ?) y/ m% N, E3 S9 z4 n
  1457.         point_y = $game_map.round_y(point_y + 1)& m9 s1 K. ^  q# b) e
  1458.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&4 n! a, J( b7 ^( Z
  1459.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    , \7 A+ k- e1 K1 B. L9 r4 G
  1460.             $game_map.passable(point_x, point_y, 8)                #judge_end
    ! X$ x7 s; {" @% [# z9 o+ ~
  1461.         reversed_chase_path.push(2); L0 R7 \" Z) f/ o# I$ s  H) E
  1462.         point_y = $game_map.round_y(point_y - 1)
    ( q8 G8 W0 J) j( i4 K# f. K
  1463.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    7 b2 h8 N: Y" ^# Y
  1464.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&' r0 S, h& {# d8 l
  1465.             $game_map.passable(point_x, point_y, 4)                #judge_end) W3 Y' [1 G4 J  L  t' j
  1466.         reversed_chase_path.push(6)
    - G. X# ?- R5 C  n8 @
  1467.         point_x = $game_map.round_x(point_x - 1): C" W. a5 [8 O: t
  1468.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    0 M# u3 T$ F0 N( I' i1 T6 [  d
  1469.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&- `6 z* N( n1 T8 T& f
  1470.             $game_map.passable(point_x, point_y, 6)                #judge_end
    & a9 d6 N7 @% R
  1471.         reversed_chase_path.push(4)
    ; D, ?9 l) n' L+ X4 y( ~0 }3 o
  1472.         point_x = $game_map.round_x(point_x + 1)# o# I$ Y9 S" N/ L! m% c
  1473.       end
    6 G* w5 p* {' s0 m( v! u
  1474.     end
    9 p- Q! F' y0 B( G6 Q5 z
  1475.     end #endOfForLoop) h4 [! G8 P* X1 e4 E1 t
  1476.     # 根据路径表格绘制最短移动路径(正向)
    - U; q2 }/ E6 H- n  U- R
  1477.     steps = step  2  29 i. _! s: H; L/ h* h
  1478.     loop_times = step  26 q3 W" @; ^" A2 M8 K% D
  1479.     point_x, point_y = chase_point[0], chase_point[1]6 O% {: d$ G1 X+ N) o( B
  1480.     for i in 2..loop_times # forLoop
    0 O; R5 R; z2 ?: z. D% b/ ~+ _
  1481.     steps -= 2. T8 X$ v( F. ^: b  e
  1482.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    / g& i1 s4 e4 T
  1483.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&( u7 |% c) s  l! h
  1484.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    & G6 f; J& p# |4 r- T
  1485.             $game_map.passable(point_x, point_y, 2)                #judge_end
    ) ]; W5 X0 e- s" }
  1486.         chase_path.push(2)8 o: o. X+ I/ k' j! W
  1487.         point_y = $game_map.round_y(point_y + 1)4 ^) k* _/ N9 I1 i4 F3 F
  1488.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&1 D# S' \) v1 d! E8 q
  1489.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&& D! P& w2 ?- e
  1490.             $game_map.passable(point_x, point_y, 8)                #judge_end
    - s, s$ s% M: u
  1491.         chase_path.push(8)
    # b" ]) |& c2 w) s" a6 Y
  1492.         point_y = $game_map.round_y(point_y - 1)' L& L; M% Q" y4 {1 k
  1493.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&% M3 j0 H( e- \+ [5 Q' L6 m; O
  1494.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
    0 N! b$ i/ w% m! b4 C8 `& F
  1495.             $game_map.passable(point_x, point_y, 4)                #judge_end
    $ j& s" o- n! c, d8 _5 J; s
  1496.         chase_path.push(4)$ B2 j' C9 j3 Z; K$ d
  1497.         point_x = $game_map.round_x(point_x - 1)0 p1 O9 N! u) d8 r; f0 C
  1498.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    * L4 _6 f& S  M
  1499.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    ! L7 [( q6 S: M' M1 S2 a. \+ @
  1500.             $game_map.passable(point_x, point_y, 6)                #judge_end
    9 p% i/ D1 E; S" e$ P8 w4 H: K
  1501.         chase_path.push(6)
    - }3 _, O4 u  W' }3 c( m
  1502.         point_x = $game_map.round_x(point_x + 1)
    : l( w5 R9 V, N( _% I/ K
  1503.       end1 r' y1 w7 A* k% z
  1504.     else) |! A* c/ g7 e2 q" f3 @3 x
  1505.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    ; W( m5 [, M4 U" x% W
  1506.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&5 D; ]( D3 Q1 G! W1 F
  1507.             $game_map.passable(point_x, point_y, 4)                #judge_end
    / \9 y' ^% q7 M5 R( B- M% g2 {
  1508.         chase_path.push(4)
    9 q+ Y' W/ Q! Y2 E( {/ l; V' N( {
  1509.         point_x = $game_map.round_x(point_x - 1)* y9 {- Z3 D# h& h6 u, X
  1510.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&# g$ P  [. p, P( u; W& O5 `
  1511.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&( r, n8 }; g  e
  1512.             $game_map.passable(point_x, point_y, 6)                #judge_end. y. o, A: s7 N$ e" n: j0 g: r+ k
  1513.         chase_path.push(6)3 U$ e# m) E; ?& [
  1514.         point_x = $game_map.round_x(point_x + 1)8 ~- T2 d& B5 k% ?
  1515.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
    6 U  m" d1 ~, l+ g- V
  1516.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    : K8 F4 ?% t# \" t/ K" t
  1517.             $game_map.passable(point_x, point_y, 2)                #judge_end
    + l+ G" L' H( Y8 B
  1518.         chase_path.push(2)
    + c; v9 O9 D1 O7 F
  1519.         point_y = $game_map.round_y(point_y + 1)
    $ X7 v) W! L, }3 E" D. y
  1520.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    6 ]  n- ]2 n- X5 V" P* `
  1521.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    $ N8 x2 L. L; U0 O
  1522.             $game_map.passable(point_x, point_y, 8)                #judge_end
    ! l; ]$ n, j. s7 ]: e1 V
  1523.         chase_path.push(8)! A" L* F: x: z' i3 j: Q
  1524.         point_y = $game_map.round_y(point_y - 1)
    0 T, @4 u# L3 |9 r' m
  1525.       end
    ! x) z4 V, N9 c
  1526.     end4 ^- t5 c, G; X. k& F
  1527.     end #endOfForLoop
    ( a3 u5 @# w! ]( [& E
  1528.     @mouse_move_path = reversed_chase_path.reverse + chase_path5 R6 G5 z" o# E, Y8 k% ?! ]- L8 b$ q
  1529.   end#walk
      p& h1 \, Z5 z, i7 [9 I
  1530.   #--------------------------------------------------------------------------9 B" J; f6 d, |- ]& C+ ^- T# \
  1531.   # ● 绘制boat的移动路径 @array[move_directions...]
    $ z7 n! y$ u5 t) R3 s
  1532.   #--------------------------------------------------------------------------
    . [; v4 C( H) J; c: B+ g
  1533.   def draw_boat_path
    : T2 D8 ^3 k& s
  1534.     # 准备绘制路径表格, q' e! m  h* E; |3 X) v. V
  1535.     sheet = Table.new($game_map.width, $game_map.height)/ {4 [$ [" Z1 P, A% `* w- H
  1536.     reversed_chase_path  = []; chase_path  = []* D, x0 K* f. E8 S( S0 y4 o* r
  1537.     reversed_chase_point = []; chase_point = []
    4 u, |" ?  ], D) a9 ^' l) Z1 K
  1538.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]. V) d# Q( s8 U% G( ]) ~: w* |2 Q: l
  1539.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
    9 U) J$ A. ?2 J
  1540.     reach_point = false
    2 S/ Q/ }9 B( g1 L+ ^/ N: g) c
  1541.     step = 32 {6 F) ], z3 B; d1 b
  1542.     loop do #loop1 开始填充表格! t' }* Q5 }8 Y4 h# l* o
  1543.      draw_path = false9 x3 S6 f* Z( `4 n: d
  1544.      check_points = new_start_points
    ( b# O" @/ T& A; f# Y
  1545.      new_start_points = []
    / f" u1 l$ z7 b2 u& y
  1546.       loop do #loop2 从起点开始正向填充$ V" T/ Y4 z0 W1 |% j- ]
  1547.         point_x = check_points.shift) V6 I+ a9 G" s. e0 W
  1548.         break if point_x == nil- b3 g' ~/ n4 N& ]6 s* `2 `
  1549.         point_y = check_points.shift; m% J& s7 z7 E# s( v
  1550.         left_x  = $game_map.round_x(point_x - 1)- r0 r; P# [' q4 L" B1 g, P( ~5 B  d
  1551.         right_x = $game_map.round_x(point_x + 1)
    : E% |' G( s+ d* G0 H
  1552.         up_y    = $game_map.round_y(point_y - 1); R" h$ j; c2 x- w' M$ {% |% H
  1553.         down_y  = $game_map.round_y(point_y + 1)
    ' V, g8 @0 I7 L+ o
  1554.                     # 判断路径是否连通0 Y  q8 D: D0 V8 v1 m
  1555.         path_step = step - 1
    & x, ~. c! l6 h" M  V/ H
  1556.         if sheet[left_x, point_y] == path_step$ M7 N8 f, z1 W: K1 u# M$ n9 ^
  1557.           chase_path.push(4)! E% u' J0 I6 t2 \% e6 V2 e
  1558.           chase_point = [left_x, point_y]( k# R4 T$ v6 w, I/ F' X
  1559.           reversed_chase_point = [point_x, point_y]: H% |' a, l7 p
  1560.           reach_point = true; break6 D& q  r" Z/ F- K
  1561.         elsif sheet[right_x, point_y] == path_step! L5 k) b8 p! O& p1 |
  1562.             chase_path.push(6)0 r( d6 [( I4 w9 r, E: a  f
  1563.             chase_point = [right_x, point_y]" h% F& a1 r' P- b/ g5 M9 d
  1564.             reversed_chase_point = [point_x, point_y]
    ; g6 t' b  V% n. j3 v
  1565.             reach_point = true; break
    & o) I2 [  `5 Y& u8 ^5 O. a$ B7 o
  1566.         elsif sheet[point_x, up_y] == path_step
    " J& ~1 C3 O7 p' t) L) [( p
  1567.             chase_path.push(8)4 X8 `8 g8 T* R: Y% [0 x
  1568.             chase_point = [point_x, up_y]
    3 U; S, p, g7 Q! V" _, ?
  1569.             reversed_chase_point = [point_x, point_y]7 d' K0 c2 q5 R+ e
  1570.             reach_point = true; break1 m' Q/ i5 ]' T& ^! P
  1571.         elsif sheet[point_x, down_y] == path_step
    1 H1 P- w( \8 ^- F6 \4 o
  1572.             chase_path.push(2)1 w* [# }( }  r$ w3 G8 i
  1573.             chase_point = [point_x, down_y]! ~; K2 z; [  A
  1574.             reversed_chase_point = [point_x, point_y]
    8 C" C; j2 \# k8 k+ R
  1575.             reach_point = true; break% O' |6 U/ a- f( H. Z
  1576.         end
    + }9 l3 d% e( ]; E7 ^0 }' {
  1577.         # 以需要抵达该点的步数填充路径表格 #5 M; b0 O7 l2 e6 I$ r0 S! ?
  1578.         if sheet[left_x, point_y] == 0                &&
    8 u* H  I$ S+ K, r
  1579.            $game_map.boat_passable(left_x, point_y)  &&! B' J' F. S( P  @. j; v: j
  1580.            !collide_with_events(left_x, point_y)     &&. y$ U2 y6 [& F* Q! X  Z
  1581.            !collide_with_vehicles(left_x, point_y)   #judge_end
    * J3 O5 m: ]9 J( g
  1582.           sheet[left_x, point_y] = step
    9 G9 c" H, A' V
  1583.           draw_path = true
    - f2 W% @& L4 ~2 ^4 k$ I7 f# b. G; z
  1584.           new_start_points.push(left_x, point_y)0 b- G3 m2 r1 Y" B: t- V: m* T
  1585.         end' j' A* i& Z- F! g
  1586.         if sheet[right_x, point_y] == 0               &&
    6 q3 S, P& i8 ~' A- \. y. @
  1587.            $game_map.boat_passable(right_x, point_y) &&+ W8 x# B( L% q5 ]$ E3 F; P
  1588.            !collide_with_events(right_x, point_y)    &&+ B" C9 f" x0 h7 @+ r
  1589.            !collide_with_vehicles(right_x, point_y)  #judge_end& J6 Q9 ~7 q" F: `, W
  1590.           sheet[right_x, point_y] = step
    3 y" x, I. q, g
  1591.           draw_path = true
    + M4 ~1 ^$ H/ X: {# S7 Y
  1592.           new_start_points.push(right_x, point_y)& E2 R9 i. K  r6 Z  U& Y
  1593.         end
    ( }6 e5 ~2 w# S& s+ j
  1594.         if sheet[point_x, up_y] == 0                  &&
    3 i% J! w  _1 A% T+ c; Y4 e
  1595.            $game_map.boat_passable(point_x, up_y)    &&
    * c( w! F& Q8 s- c: l8 n) C
  1596.            !collide_with_events(point_x, up_y)       &&+ o( q" c9 v% b! ]  `
  1597.            !collide_with_vehicles(point_x, up_y)     #judge_end& ~2 r$ G! t# q' r/ ~4 S
  1598.           sheet[point_x, up_y] = step* [1 M/ Z# e8 A
  1599.           draw_path = true4 M) u  j0 \8 ^' j5 M" Q
  1600.           new_start_points.push(point_x, up_y)
    ; @1 h! m) J- @
  1601.         end
    " y0 S( p2 h- |: Q4 |8 J$ R: r' Z" E
  1602.         if sheet[point_x, down_y] == 0                &&7 l/ {' k" p4 t0 f. ^6 w8 h6 g. W
  1603.            $game_map.boat_passable(point_x, down_y)  &&
    1 X# k8 O  K* q' L3 i9 u) H
  1604.            !collide_with_events(point_x, down_y)     &&/ `; p% x! H0 E6 o& \1 b
  1605.            !collide_with_vehicles(point_x, down_y)   #judge_end
    6 o/ `* ^; ^1 c' E* _9 }' K
  1606.           sheet[point_x, down_y] = step
    9 k" J$ ]8 |* r4 Z; N( R2 \3 R; C* q
  1607.           draw_path = true- B1 @$ I: K' Q; S( R
  1608.           new_start_points.push(point_x, down_y)
    ! i9 k" E) Q( b) o/ o! G, }$ Z
  1609.         end3 n. M. j5 w8 B0 c: ^
  1610.       end#endOfLoop2
    : ^  Y  f! a: T! Y# v
  1611.       break if !draw_path  reach_point
    6 B* S, `0 R5 A) Z4 I. q) P
  1612.       draw_path = false
      ?* h- G# f9 g8 ?
  1613.       check_points = new_end_points' ~2 a) X0 I6 O: G6 y% X( B
  1614.       new_end_points = []
    # b, Y5 V! \3 {7 K! [' `
  1615.       step += 1
    & T: k6 N6 b4 P# P
  1616.       break if step  KsOfSionBreak_Steps &&
    2 l9 V& `+ @3 V
  1617.                !Input.press(KsOfSionFind_Path_Key)
    - X& S* {% d* O) ]/ Y4 ~( d' a3 e7 b
  1618.       loop do #loop3 从终点开始反向填充
    0 r8 C. I, L1 U0 X  Z! ]
  1619.         point_x = check_points.shift6 @2 ~; C' @% Q5 D' _# x% o  ^
  1620.         break if point_x == nil
    : S" j7 {' \, A
  1621.         point_y = check_points.shift
    1 j/ a0 A7 T, T5 K. M! D
  1622.         left_x  = $game_map.round_x(point_x - 1)- I- j6 \' Z: A. p7 D- b
  1623.         right_x = $game_map.round_x(point_x + 1)! ~6 s9 a; O) [0 [9 O, i
  1624.         up_y    = $game_map.round_y(point_y - 1)
    ( h8 {0 s; A9 k
  1625.         down_y  = $game_map.round_y(point_y + 1)5 I" q5 Z; j% V
  1626.         # 判断路径是否连通
    ' M+ c' I( U3 c
  1627.         path_step = step - 1
    ) x+ J2 j5 @& ]2 {; }
  1628.         if sheet[left_x, point_y] == path_step' @, K+ @( a7 K( `0 M5 i, l
  1629.           chase_path.push(6)
    9 q3 u% I4 e, ]( I6 x
  1630.           chase_point = [point_x, point_y]& `0 U& y# t9 f# i
  1631.           reversed_chase_point = [left_x, point_y]
    % {3 i6 {! q( U# u: q
  1632.           reach_point = true; break* K+ Z' P3 L  m3 ?: o' o" k
  1633.         elsif sheet[right_x, point_y] == path_step
    0 h! j& _: l/ R: d  r
  1634.             chase_path.push(4)
    4 h& t4 }+ Y9 o! [* B8 L
  1635.             chase_point = [point_x, point_y]3 _" t; ]( o' P' l6 K
  1636.             reversed_chase_point = [right_x, point_y]5 \( c4 |3 I4 h& B7 z9 s) ]
  1637.             reach_point = true; break
    % k5 c* l! D$ ^* z
  1638.         elsif sheet[point_x, up_y] == path_step" Y& g4 I/ g6 X/ f2 q  h0 I
  1639.             chase_path.push(2)2 w4 l& Y+ `# ]6 \& m# L
  1640.             chase_point = [point_x, point_y]
    7 U+ `$ y. @( t5 T
  1641.             reversed_chase_point = [point_x, up_y]! n* R+ ?! R; p- j# I& i8 k4 c) e" G
  1642.             reach_point = true; break) Y, {+ ^# V/ R
  1643.         elsif sheet[point_x, down_y] == path_step5 k2 X! T" L) k" s9 E
  1644.             chase_path.push(8)
      k) t0 q! l1 G1 G, J
  1645.             chase_point = [point_x, point_y]3 N, N3 Z% J4 p' X
  1646.             reversed_chase_point = [point_x, down_y]3 V6 P+ [( a( g( B
  1647.             reach_point = true; break
    " W) B% Z% j" r* V
  1648.         end
    " X( k; p" m) V- Z3 X+ I- _
  1649.         # 以需要抵达该点的步数填充路径表格 #" @& x2 t8 m: |, a* x
  1650.         if sheet[left_x, point_y] == 0                &&
    9 y9 W0 N  }9 @9 g
  1651.            $game_map.boat_passable(left_x, point_y)  &&
    ( v" j$ e: P1 t4 s/ n( E: R
  1652.            !collide_with_events(left_x, point_y)     &&) K4 j+ w' V7 c% u  h+ }
  1653.            !collide_with_vehicles(left_x, point_y)   #judge_end
    ! \( J& y' }4 d3 v# M( _
  1654.           sheet[left_x, point_y] = step+ m2 c- q" P& R5 f9 X; g' C/ T
  1655.           draw_path = true9 T3 j3 V6 t( C9 i9 b' b
  1656.           new_end_points.push(left_x, point_y), ]5 Y7 _: h. k' ~. w0 }! ?+ i
  1657.         end
    3 O# M7 E, X, h
  1658.         if sheet[right_x, point_y] == 0               &&+ m0 @% S- S# b1 A; _
  1659.            $game_map.boat_passable(right_x, point_y) &&
    ( k5 l  L/ V9 V
  1660.            !collide_with_events(right_x, point_y)    &&
    . V( `+ x8 I/ n- c9 B/ ?" R
  1661.            !collide_with_vehicles(right_x, point_y)  #judge_end* U/ w. ~6 c0 Y, e1 B! [4 o
  1662.           sheet[right_x, point_y] = step, e. |0 ~  w9 G  X, F
  1663.           draw_path = true8 p; Y3 J6 \; B7 m( V! B$ o
  1664.           new_end_points.push(right_x, point_y)) e7 d% ~& m6 B( B' S
  1665.         end
    ! Y, {+ }" ?* c
  1666.         if sheet[point_x, up_y] == 0                  &&1 C/ z8 s+ ?( l6 E$ U0 }4 ~
  1667.            $game_map.boat_passable(point_x, up_y)    &&
    8 M* f3 T" c3 o; L- J' v: t# ]. i" G
  1668.            !collide_with_events(point_x, up_y)       &&
    : X/ x' d* K/ }! @* Z. t  C
  1669.            !collide_with_vehicles(point_x, up_y)     #judge_end, K4 l" R+ A4 g1 ^! \
  1670.           sheet[point_x, up_y] = step
    3 i1 y' P, X' G% x
  1671.           draw_path = true
    2 V8 y+ y6 `2 n! S$ U" _( G% L
  1672.           new_end_points.push(point_x, up_y)8 u% L0 u- ]! B. c
  1673.         end) b% t% m3 \" ?: b( h( ^$ Q  X
  1674.         if sheet[point_x, down_y] == 0                &&
    ! O* ^) X+ ~! X% A( U
  1675.            $game_map.boat_passable(point_x, down_y)  &&6 {& O' R! F* y: k- J
  1676.            !collide_with_events(point_x, down_y)     &&6 r" V6 C. `% n6 x
  1677.            !collide_with_vehicles(point_x, down_y)   #judge_end
    / M& d# i: ^7 i# j7 g
  1678.           sheet[point_x, down_y] = step, P5 l9 y( }3 u3 `  i
  1679.           draw_path = true
    # H7 n. L  q/ |, U& l4 ]  ]
  1680.           new_end_points.push(point_x, down_y)7 n5 u4 l: G  F' ]
  1681.         end
      p( W: m& u, e# r7 g
  1682.       end#endOfLoop31 j3 h. h$ S2 h
  1683.       break if !draw_path  reach_point
    8 X! ~, S" H: V+ m, Y4 K
  1684.       step += 1' p1 a" ~8 \3 [1 H
  1685.     end #endOfLoop1 路径表格填充完毕
    6 I2 y8 R' @) W" h% l
  1686.     $mouse_move_sign.transparent = false
    " b5 k* {; {$ {8 r* A
  1687.     # 判断指定地点能否抵达
    8 V7 a6 K# b6 ]; U
  1688.     if reach_point' \! b$ @: b; H1 l' f1 w' W
  1689.       $mouse_move_sign.direction = 2
    7 O8 e6 p9 F& n; c3 L0 D
  1690.     else
    - b3 _% o6 Q4 U" O7 u3 H7 H
  1691.       not_reach_point
    ! C* J6 T4 [' ?7 }8 @0 g( k/ ]. L
  1692.       return' O. g4 q6 y3 R% W" Q# F
  1693.     end; b+ `, o8 v4 K
  1694.     # 根据路径表格绘制最短移动路径(正向)& y4 _6 [9 s7 u/ J* |1 ~
  1695.     steps = step  2  2
    ) h; Q! u! M  ^! A2 j/ B
  1696.     loop_times = step  2
    * F  ~( h: W9 \
  1697.     point_x, point_y = chase_point[0], chase_point[1]% e9 q$ H/ |% ~* R' X
  1698.     for i in 2..loop_times # forLoop
    * W& g  c. e: k) p% l( W: z
  1699.     steps -= 2& P( }1 ~7 m0 A6 S1 k/ W  g
  1700.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    7 m0 k7 ~% n4 C- S- M
  1701.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    ! E; s' d3 d- [( i* m
  1702.         chase_path.push(2)! v% k- W& z3 N8 c& w# @& L
  1703.         point_y = $game_map.round_y(point_y + 1)2 T  U6 o; n. }$ @9 L1 \2 |3 x6 O
  1704.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps( Q) {5 ~5 x; s( F0 B/ G1 e  Y
  1705.         chase_path.push(8)
    : Y0 A! X! v9 W, m( W
  1706.         point_y = $game_map.round_y(point_y - 1)& M% T# p& s2 W; x: a) A
  1707.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    ( x8 p4 f& T3 Z: g- Q& q) N
  1708.         chase_path.push(4): J4 u7 J) D- d0 h4 ]1 f
  1709.         point_x = $game_map.round_x(point_x - 1)
    & h3 a5 g: m& S; X1 D) ~$ k* B
  1710.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    3 A/ |0 U' P! ]2 e  U
  1711.         chase_path.push(6)
    " S8 ]" ^. R3 _# q/ ], O9 r
  1712.         point_x = $game_map.round_x(point_x + 1)
    % |! G3 e8 a# ~4 Y$ F* o
  1713.       end4 T% N( L! W9 L
  1714.     else7 e4 j. T4 ]* c( s
  1715.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps% ~. u5 @) o7 _, I8 D
  1716.         chase_path.push(4), N/ d$ G( Y& I) @
  1717.         point_x = $game_map.round_x(point_x - 1)! n- D  u: _4 g$ T
  1718.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    5 i) x8 D8 W! J4 P$ w9 s
  1719.         chase_path.push(6)
    ! c) ^. Y! t  r0 @
  1720.         point_x = $game_map.round_x(point_x + 1)7 V/ l4 R! P7 i" r$ k/ D! m
  1721.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    0 {. g' {! R2 n5 n! R
  1722.         chase_path.push(2)
    1 B! \6 t: p' q" B) A
  1723.         point_y = $game_map.round_y(point_y + 1)$ s" o- Q0 y, B$ q
  1724.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps" I" v( d/ `1 M
  1725.         chase_path.push(8)7 n# ?: L) i" Y9 L0 N+ M2 R  {
  1726.         point_y = $game_map.round_y(point_y - 1)9 S5 B9 ~/ g/ c: r4 K4 Z6 _/ G
  1727.       end
    1 @+ S% N5 v* V* Y9 d. j# G. n
  1728.     end
    / |; O- U5 D+ S6 y. l# _4 e
  1729.     end #endOfForLoop- w! H7 r4 `" y9 h
  1730.     # 如果指定点无法抵达或者登陆, f6 h1 o: s& |1 D1 d
  1731.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)
    # t; F7 z+ \9 N( e0 h! T
  1732.     # 根据路径表格绘制最短移动路径(反向)
    . d2 \7 r+ w% ?( B3 m
  1733.     steps = step  2  2 + 1
    ! ^* U3 d$ B' ~# z7 F" T
  1734.     loop_times = step  2$ F, z2 B6 `- P, i! q/ _, l% i
  1735.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]8 S' X) j6 Z9 U2 _8 s3 [
  1736.     for i in 1..loop_times # forLoop$ c" e( @- {' O% R7 `3 Z& \/ K
  1737.     steps -= 2- F) @0 Y; p( d" d. `, ~9 E
  1738.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
      n8 p( D) s0 ~. s3 U% B2 v9 l
  1739.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps! b" }' b  m! U
  1740.         reversed_chase_path.push(6)
    " K3 h) a1 p$ u: w6 C- _& m3 b- \
  1741.         point_x = $game_map.round_x(point_x - 1)
    # n# Z8 q& r( v# S
  1742.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    " @0 a' W8 S( `4 B
  1743.         reversed_chase_path.push(4)8 R  |! P8 e& E
  1744.         point_x = $game_map.round_x(point_x + 1)
    7 _3 _, l4 b$ j
  1745.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    0 ^' G: P1 l& [5 W/ \0 S$ k6 B
  1746.         reversed_chase_path.push(8)0 G" l$ u( P7 \5 A. V: h
  1747.         point_y = $game_map.round_y(point_y + 1)% G  a! K6 I% x
  1748.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps5 F' W. s" h7 Z
  1749.         reversed_chase_path.push(2): E1 e" d; B# H7 v1 g- C$ M) L7 p
  1750.         point_y = $game_map.round_y(point_y - 1)
    + b0 T0 K# C6 y. y$ Z
  1751.       end4 u' n. d% b: l9 W5 q( [3 ?
  1752.     else; f8 V4 X& g/ Y: A3 @; x
  1753.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps0 d1 g* G, w: P' g, a) Q; @$ B
  1754.         reversed_chase_path.push(8)
    ; ^! r- a/ d% G' Z
  1755.         point_y = $game_map.round_y(point_y + 1)
    + v- D" X" m( w3 Y7 w
  1756.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps: Z0 d+ }0 D0 A- }. I% T
  1757.         reversed_chase_path.push(2)* ^9 X  M0 P8 |1 J7 o# v/ l
  1758.         point_y = $game_map.round_y(point_y - 1), D0 Q- p: _" M4 X" S' |
  1759.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    : Z3 l% W! {+ @) }) c
  1760.         reversed_chase_path.push(6)
    4 Y+ ~8 V+ M9 b# T* W
  1761.         point_x = $game_map.round_x(point_x - 1)  P" |! x0 p( u; U. k" z
  1762.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    8 ^* ~9 w8 y; S6 ^7 {
  1763.         reversed_chase_path.push(4)
    ) l: E* l4 u6 O, `
  1764.         point_x = $game_map.round_x(point_x + 1)
    + r, S# W+ a, _1 G
  1765.       end
    ) p) a, _" b1 O/ o: t; `3 f' z
  1766.     end
    . X. @# ]6 k0 z0 P, x8 A8 J8 h
  1767.     end #endOfForLoop
    % J' Q6 h, {. O8 U3 V
  1768.     @mouse_move_path = reversed_chase_path.reverse + chase_path6 E( u  B" x& z7 F2 M
  1769.   end#boat" t( y# v8 ]0 n( h# U4 V
  1770.   #--------------------------------------------------------------------------& S9 X1 \. w- o& }" R2 ^' `
  1771.   # ● 绘制ship的移动路径 @array[move_directions...]. t  d% k& F% {) E) a
  1772.   #--------------------------------------------------------------------------- m$ F' e: @" V+ m* J6 {' T
  1773.   def draw_ship_path6 b1 c" d1 Q- t$ D' n: ~) w
  1774.     # 准备绘制路径表格. K" E9 j+ ~1 ~2 V) N
  1775.     sheet = Table.new($game_map.width, $game_map.height)
    0 [) T' |5 x' e/ B/ p9 ?; s9 }  @
  1776.     reversed_chase_path  = []; chase_path  = []5 F. F: ]5 i  I* v( h, D' l5 ?
  1777.     reversed_chase_point = []; chase_point = []
    0 s" v9 K2 n2 {9 i  `& ]
  1778.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]# r7 }+ c! s/ K# v  r
  1779.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 28 \% P' L) H. Y0 g& O
  1780.     reach_point = false
    - ^  S6 Y8 T/ X: y
  1781.     step = 3
    + a5 H- r6 q/ L6 X2 E; i( b
  1782.     loop do #loop1 开始填充表格
    + M: m! x4 h, Q0 ?: a
  1783.      draw_path = false7 d! E+ `# c9 t6 x% z
  1784.      check_points = new_start_points
    4 U/ l* P, X' M2 }9 [' d% |
  1785.      new_start_points = []* q8 @/ b9 j! w. m$ z
  1786.       loop do #loop2 从起点开始正向填充
    . f; k0 C! T1 ~! d- y( P; M. |
  1787.         point_x = check_points.shift
    ! [. ^  W8 z* m8 M" c& u, W
  1788.         break if point_x == nil
    / z2 N7 P4 e/ L6 Y% D
  1789.         point_y = check_points.shift
    " h2 x/ _7 H' R4 @1 p3 N
  1790.         left_x  = $game_map.round_x(point_x - 1)% b4 \5 f, I1 f0 B- ?# M+ g7 X1 M4 z
  1791.         right_x = $game_map.round_x(point_x + 1)9 q: \8 d0 u, r/ f) q6 Y. Y0 k/ y* F
  1792.         up_y    = $game_map.round_y(point_y - 1)
    " P9 _; t0 p3 ~" v
  1793.         down_y  = $game_map.round_y(point_y + 1)& a$ e5 a. e' k& T, x0 u7 L0 L
  1794.                     # 判断路径是否连通
    + O2 D, D: N8 n, l5 W' g
  1795.         path_step = step - 1: c& F# R4 h) W1 g
  1796.         if sheet[left_x, point_y] == path_step
    , z. f& N7 X. Y' m. j
  1797.           chase_path.push(4)/ r! k% _- B8 g
  1798.           chase_point = [left_x, point_y]( w; H& K0 M# D; g3 I# Q6 L
  1799.           reversed_chase_point = [point_x, point_y], p. X% V( T# o4 F; k2 s% E9 c& n
  1800.           reach_point = true; break1 s* Z4 X$ s+ a7 P6 X
  1801.         elsif sheet[right_x, point_y] == path_step$ U$ I) W% W# m! u2 S  c% R
  1802.             chase_path.push(6)6 c* t7 H* {* C; ]2 i5 |
  1803.             chase_point = [right_x, point_y]
    4 C4 m% T5 H9 y; v- G3 S! C3 c: H
  1804.             reversed_chase_point = [point_x, point_y]- I: x( ]! v: Z
  1805.             reach_point = true; break
    - q" ^4 G" R7 K2 v. `6 l
  1806.         elsif sheet[point_x, up_y] == path_step8 S" E8 K8 V. ]% Q
  1807.             chase_path.push(8)+ W9 D/ n. M) X; A7 b$ j, L4 J
  1808.             chase_point = [point_x, up_y]2 T% g# ^, F  u+ j2 H
  1809.             reversed_chase_point = [point_x, point_y]
    7 R* L0 U- X, o) D8 a" J* e# q! v
  1810.             reach_point = true; break; F/ q8 I/ S( X* k& Q& \4 Y) @
  1811.         elsif sheet[point_x, down_y] == path_step
    : P5 u' z2 I1 H. U4 S6 g+ q! \
  1812.             chase_path.push(2)
    # H- ~6 k8 {5 _. l, X) j+ S
  1813.             chase_point = [point_x, down_y]/ C( ^+ {. d8 ^5 d
  1814.             reversed_chase_point = [point_x, point_y]
    ) n1 C4 n3 l* D; S
  1815.             reach_point = true; break
    1 K# P* f( m5 L: C
  1816.         end$ _3 ~  [% X. p- s" B! y7 k$ c
  1817.         # 以需要抵达该点的步数填充路径表格 #, a" i0 d3 v9 q: O3 Q
  1818.         if sheet[left_x, point_y] == 0                &&4 l3 r  n! P7 T
  1819.            $game_map.ship_passable(left_x, point_y)  &&* U4 Z4 B' f; j0 P* f3 R
  1820.            !collide_with_events(left_x, point_y)     &&$ g0 k1 W, W( h  e4 Z
  1821.            !collide_with_vehicles(left_x, point_y)   #judge_end
    1 h. E! M  |7 H! K8 v# L* S
  1822.           sheet[left_x, point_y] = step
    3 T+ E8 o6 \: W. l- D3 H% W
  1823.           draw_path = true
    5 j9 M2 M0 ]! p2 S! \; w6 n3 T% f
  1824.           new_start_points.push(left_x, point_y); f, D# ?! o- g$ R7 C) p0 O5 R
  1825.         end
    7 D( X: U9 s9 P0 F4 {
  1826.         if sheet[right_x, point_y] == 0               &&& {- j* D- S( B2 Q# f' E
  1827.            $game_map.ship_passable(right_x, point_y) &&
    , f5 {, F0 ]( j) I* ^- m- G
  1828.            !collide_with_events(right_x, point_y)    &&5 s; n$ a; \' p" }
  1829.            !collide_with_vehicles(right_x, point_y)  #judge_end% n# @# D# g. S; h
  1830.           sheet[right_x, point_y] = step2 A' T9 V: ]( d$ J: h8 x
  1831.           draw_path = true
    ; s! R, v& `% L
  1832.           new_start_points.push(right_x, point_y)
    $ X' L  q5 B2 |  D4 f: K- @  k
  1833.         end. \, q* `" `+ X7 Z
  1834.         if sheet[point_x, up_y] == 0                  &&
    9 @& O3 a; U. T# k
  1835.            $game_map.ship_passable(point_x, up_y)    &&4 M: t/ O2 n) s! z8 ~5 J& w$ u
  1836.            !collide_with_events(point_x, up_y)       &&1 Y7 g7 U" u3 U8 M9 N# y  z; c
  1837.            !collide_with_vehicles(point_x, up_y)     #judge_end5 c# N7 D) T4 M- |' S  t
  1838.           sheet[point_x, up_y] = step
    ) U2 }  w& w+ i* _3 p
  1839.           draw_path = true
    6 ^6 P, V; Q- e
  1840.           new_start_points.push(point_x, up_y)
    " e! i+ W9 J, R* u" |
  1841.         end8 K: H1 J2 @9 d4 `
  1842.         if sheet[point_x, down_y] == 0                &&& d  L7 M8 h" g
  1843.            $game_map.ship_passable(point_x, down_y)  &&( v& c1 i; f+ z' Y# o
  1844.            !collide_with_events(point_x, down_y)     &&
    ! \' Z1 j- `- ?. z
  1845.            !collide_with_vehicles(point_x, down_y)   #judge_end% _- T& |8 @8 _
  1846.           sheet[point_x, down_y] = step
    1 u2 v- L, l4 c4 {" @" l; \
  1847.           draw_path = true
    * R/ y1 N3 {7 M+ @
  1848.           new_start_points.push(point_x, down_y)$ x6 \7 i" Q; T
  1849.         end6 ~/ c, ^: N4 d7 u! v# e/ M2 y* Y
  1850.       end#endOfLoop28 q0 N  s' i; ]0 u
  1851.       break if !draw_path  reach_point
    & w. W/ ]0 Z$ }& W  ]4 X8 B
  1852.       draw_path = false+ A0 q1 j; h% E2 T0 K0 t
  1853.       check_points = new_end_points7 g! A1 Z" R, S  V* @& ~( i, i3 ~; m+ Y9 _
  1854.       new_end_points = []( @) d% U% j& Q6 G8 [5 Z
  1855.       step += 1
    6 e/ u, I4 |+ y
  1856.       break if step  KsOfSionBreak_Steps &&
    8 L8 ^8 a& ]! T5 f3 P& p
  1857.                !Input.press(KsOfSionFind_Path_Key)
    " n/ k) |) o) R  a+ P% ~6 B* ~
  1858.       loop do #loop3 从终点开始反向填充0 s& u0 }% U: Y$ ^
  1859.         point_x = check_points.shift
    " ]4 g- S8 F4 C( v! X+ W
  1860.         break if point_x == nil
    1 \4 j3 V3 L: k+ P) D' y$ r
  1861.         point_y = check_points.shift5 Y. k2 K1 X( T( o2 m% t/ }
  1862.         left_x  = $game_map.round_x(point_x - 1)
    ' Q1 x0 Q5 r/ l% \3 t$ H2 o
  1863.         right_x = $game_map.round_x(point_x + 1)
    : Y- |- J/ e/ l+ k/ Q/ h( ^9 P# r) k
  1864.         up_y    = $game_map.round_y(point_y - 1)
    ) L  r' p: r1 C
  1865.         down_y  = $game_map.round_y(point_y + 1)
    6 N3 p7 L' X1 a" ~9 ~
  1866.         # 判断路径是否连通
    + \7 B( p5 e8 O7 X/ T# m
  1867.         path_step = step - 1
    $ J3 I' D% ?2 x5 n$ M  V& J
  1868.         if sheet[left_x, point_y] == path_step  D# b; j9 i1 L
  1869.           chase_path.push(6)' p( t+ }% |2 C' ^# m
  1870.           chase_point = [point_x, point_y]' I( }) _( M4 a9 X  X$ j/ s
  1871.           reversed_chase_point = [left_x, point_y]
    ! S; q4 R9 O+ j: G: h
  1872.           reach_point = true; break/ x4 M" x8 G: T# b- Z7 L1 E6 q7 |
  1873.         elsif sheet[right_x, point_y] == path_step( O5 x+ h+ P, H$ F. x2 T- D" S- u
  1874.             chase_path.push(4)
    2 x9 T; N3 N; D8 Y
  1875.             chase_point = [point_x, point_y]9 q* L/ X# z) r, H5 l0 Y
  1876.             reversed_chase_point = [right_x, point_y]2 i" J, d# W0 A8 w# H3 t7 \0 T# M2 g
  1877.             reach_point = true; break
    ; p6 }1 e; V- g/ W+ @/ p
  1878.         elsif sheet[point_x, up_y] == path_step1 i& m2 N+ |) q4 t5 f% F4 F* z) F/ D
  1879.             chase_path.push(2)8 Q% J7 n( G1 m0 i
  1880.             chase_point = [point_x, point_y]3 C& D! L: g5 G. w! X* Q( t1 |! V  X$ Y
  1881.             reversed_chase_point = [point_x, up_y]
    / m9 W8 H) F3 H0 f9 }; G; A2 X
  1882.             reach_point = true; break
    . k) c# Z' T9 f% `* b
  1883.         elsif sheet[point_x, down_y] == path_step
    7 u: p6 g8 h4 u6 b
  1884.             chase_path.push(8)
    0 y& F& x' t3 w$ N& h! i# r1 x
  1885.             chase_point = [point_x, point_y]# f9 k# X5 }/ ]) q% a
  1886.             reversed_chase_point = [point_x, down_y]
    $ ]  j8 Y5 h% c# a! v& n$ ^
  1887.             reach_point = true; break
    ' v" l# n% o7 _$ _& j
  1888.         end
    / B2 {/ d7 _3 F8 w3 P
  1889.         # 以需要抵达该点的步数填充路径表格 #- Y; Z+ F' u6 `+ ]' O
  1890.         if sheet[left_x, point_y] == 0                &&
    $ {# `5 F' p2 O4 F7 S- q
  1891.            $game_map.ship_passable(left_x, point_y)  &&
    + t/ Z- I2 G  F- s' x
  1892.            !collide_with_events(left_x, point_y)     &&
    . ]! w; K  u" r' N1 n; v/ I
  1893.            !collide_with_vehicles(left_x, point_y)   #judge_end+ D% m" ]! L! |" G) G% x* A& {. g4 b
  1894.           sheet[left_x, point_y] = step
    . G  F, C5 F: q; I
  1895.           draw_path = true
    % @& L2 g- k. e8 {
  1896.           new_end_points.push(left_x, point_y)3 i; I! j7 D/ S+ d; z) s
  1897.         end
    : G$ E6 n. @3 A3 y8 _" u
  1898.         if sheet[right_x, point_y] == 0               &&
    8 C: O* J# V" J/ F" J: j8 D' X
  1899.            $game_map.ship_passable(right_x, point_y) &&
    1 B& @5 M1 f' Y. t, D, N
  1900.            !collide_with_events(right_x, point_y)    &&
    % U* z0 F, z. S0 K, L% U. u
  1901.            !collide_with_vehicles(right_x, point_y)  #judge_end
    9 t; ]2 K6 q+ U- i
  1902.           sheet[right_x, point_y] = step
    * a! P( S/ a: G5 @4 @
  1903.           draw_path = true
    6 `6 B: B6 ]. d' F
  1904.           new_end_points.push(right_x, point_y)
    & X5 q* L& ~! ]
  1905.         end1 g& P7 B! o0 J7 m* h
  1906.         if sheet[point_x, up_y] == 0                  &&7 A3 c+ d* e9 r: B
  1907.            $game_map.ship_passable(point_x, up_y)    &&" q9 z( T2 P0 n- q, _+ M
  1908.            !collide_with_events(point_x, up_y)       &&  S( R; f. D% C
  1909.            !collide_with_vehicles(point_x, up_y)     #judge_end( R7 F5 L+ l7 i) \% H  y
  1910.           sheet[point_x, up_y] = step
    - t' {9 z3 x) C2 P4 J
  1911.           draw_path = true
    4 |3 u$ i: S" C/ K! [- _) ?. U: Q
  1912.           new_end_points.push(point_x, up_y)6 @% O$ _. L; X/ F
  1913.         end
    $ R8 M& m6 j) }2 {
  1914.         if sheet[point_x, down_y] == 0                &&
    ( d6 l7 V" `1 }0 D$ H7 a
  1915.            $game_map.ship_passable(point_x, down_y)  &&4 o. z) A+ [, P
  1916.            !collide_with_events(point_x, down_y)     &&
      s0 Z- c& j1 B* q) w5 z+ }
  1917.            !collide_with_vehicles(point_x, down_y)   #judge_end6 y: G% d) [1 m. c: N
  1918.           sheet[point_x, down_y] = step
    8 J8 h- Y! Y) t2 c( W
  1919.           draw_path = true% w- N- m2 a' q
  1920.           new_end_points.push(point_x, down_y)& T# C! I; `2 h' P6 D
  1921.         end6 R8 a) z* j0 [' A. j
  1922.       end#endOfLoop34 n$ C- B4 G; ~( [0 {0 f) g
  1923.       break if !draw_path  reach_point5 M3 J; M; C3 N: |
  1924.       step += 1
    7 l+ B4 z  T6 X7 t
  1925.     end #endOfLoop1 路径表格填充完毕
    0 d1 B2 y+ W+ P, V, @; x! v5 N
  1926.     $mouse_move_sign.transparent = false2 I6 z( x! g7 f' P. w; _8 t5 b
  1927.     # 判断指定地点能否抵达
    / W2 a. v9 t# M
  1928.     if reach_point
    / {% v9 c1 M4 H1 h4 t
  1929.       $mouse_move_sign.direction = 29 n( A/ T! b! B6 ^2 \0 U
  1930.     else
    $ H" v- m3 [: x. M* E4 X
  1931.       not_reach_point
      p6 G1 c; T* x  Z5 v
  1932.       return
    ! k) |7 w. @. ]" e- I$ B& s9 z
  1933.     end
    / ~" |$ C* f, C. z& R
  1934.     # 根据路径表格绘制最短移动路径(正向)5 B" @: n+ V' q& m5 N
  1935.     steps = step  2  2" W9 `' k4 W0 F1 g' [/ k
  1936.     loop_times = step  2
    9 l' t% F3 ~8 _
  1937.     point_x, point_y = chase_point[0], chase_point[1]
    ( w' `, c7 ^) Z. w3 y
  1938.     for i in 2..loop_times # forLoop9 g5 c0 N( J- u
  1939.     steps -= 2
    4 r( F  P+ ^! M( G) Q7 [
  1940.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    - H$ @4 R. g$ I; S
  1941.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps3 f& w5 r3 \. T
  1942.         chase_path.push(2)# N" {# Q9 ^" e- [7 ?% \' e
  1943.         point_y = $game_map.round_y(point_y + 1)4 l" p3 M- e% `2 {4 `" H" f  A
  1944.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    % U9 [5 m5 C" f% Z+ F( E
  1945.         chase_path.push(8)5 Y6 X, r# K+ g. K" U( J+ [( l
  1946.         point_y = $game_map.round_y(point_y - 1)  X' ~- N# |7 r, G* @* h
  1947.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    % e( i) s  H' b
  1948.         chase_path.push(4)
    * {0 g3 Q. F" d, B
  1949.         point_x = $game_map.round_x(point_x - 1)' ^7 \2 [7 ?8 F
  1950.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    # A6 G  @. S' W" _4 u
  1951.         chase_path.push(6)
    9 ~2 e) v; L& q# l( m! t, g; v
  1952.         point_x = $game_map.round_x(point_x + 1)$ [' k$ i( U' T; h* x  s
  1953.       end
    , t$ b( `  p* [  `& K5 B/ O7 N
  1954.     else
    ' s1 a; W" K5 `9 D
  1955.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    5 u; d: ~1 k& ~+ I9 w
  1956.         chase_path.push(4)
    : P' I9 E  P% E2 L% C" Z
  1957.         point_x = $game_map.round_x(point_x - 1)
    : o3 Z" Z6 Z/ V0 q7 R9 j
  1958.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    / D( S0 ^  f! z" V
  1959.         chase_path.push(6)
    3 Q) e( L  s- @: a0 K
  1960.         point_x = $game_map.round_x(point_x + 1)
    " N+ J2 s1 U) `. R
  1961.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    # ?' o7 A+ K* g' r
  1962.         chase_path.push(2)8 L. J  Z* B, m0 {9 r1 T( Y
  1963.         point_y = $game_map.round_y(point_y + 1)
    + I( @  f, s: F" Q: S* K
  1964.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps- g' k3 O  a5 J+ F
  1965.         chase_path.push(8)% ~4 t* [, o# c! \$ I% |/ |
  1966.         point_y = $game_map.round_y(point_y - 1)/ \. C4 p+ J9 y9 e- L
  1967.       end
      U4 ]0 z/ H1 W+ a$ x4 ]  v
  1968.     end* Z, i/ c  f0 |" y% K8 @
  1969.     end #endOfForLoop- z2 n) b$ c% v  H: w+ Y! `; u
  1970.     # 如果指定点无法抵达或者登陆: b4 P, G- K- U$ M3 p0 ]! y- z
  1971.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)
    7 D# A% y2 O; H6 P
  1972.     # 根据路径表格绘制最短移动路径(反向)
    7 S" B6 i1 J/ O* p, o. w0 y1 a" f
  1973.     steps = step  2  2 + 18 q$ i# |* S4 P6 b. V$ ~. j
  1974.     loop_times = step  26 ^, u% {; J" J& B
  1975.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]) f9 {) @7 N& F& s) Z
  1976.     for i in 1..loop_times # forLoop
    8 s, g% u: Q3 p2 _+ \2 i. O
  1977.     steps -= 23 w! \- g# {( Y- m- Y+ q% b2 \
  1978.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    0 q1 F" e$ K' d% F  s
  1979.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    3 I. s- o* W7 m6 g; }" ^  |
  1980.         reversed_chase_path.push(6)3 S6 g% G! [+ V2 H4 a8 @
  1981.         point_x = $game_map.round_x(point_x - 1)% L1 Y8 W, A! y8 y4 B' m
  1982.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps1 V& ^; E8 ]1 l" K8 X5 M
  1983.         reversed_chase_path.push(4)3 L, ]2 q5 I# R" ~
  1984.         point_x = $game_map.round_x(point_x + 1), V  O9 C2 ~4 W+ ^8 Q  C4 ]1 ?
  1985.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    9 D+ A1 g2 r9 n. a9 Q- v
  1986.         reversed_chase_path.push(8)% Z4 F. I2 N" e" q( X
  1987.         point_y = $game_map.round_y(point_y + 1)6 R2 E9 p% `8 ~
  1988.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    2 n9 a; R5 ^% k8 q7 d* o
  1989.         reversed_chase_path.push(2)
      t8 Z1 q5 d9 I- m! |
  1990.         point_y = $game_map.round_y(point_y - 1)) K9 ]9 P& Q- @, v( _& d
  1991.       end: k0 ?* n% H. I  ~2 m
  1992.     else' y) H  n$ O! R6 y  F. B6 R0 R6 ?
  1993.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps) Q8 l$ ]8 z/ t: `3 \. k  _# a
  1994.         reversed_chase_path.push(8)
    % Y6 Z+ e* a0 I& g; c; b
  1995.         point_y = $game_map.round_y(point_y + 1): h. @! X' {! |- q
  1996.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps! ~7 o# ~0 B4 P, w4 E, c( y
  1997.         reversed_chase_path.push(2)
    / ^' V, H( e$ g( H
  1998.         point_y = $game_map.round_y(point_y - 1)$ ]8 D; P2 O# E
  1999.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps( b& k) C5 |. K
  2000.         reversed_chase_path.push(6)
    ' Y3 N$ V7 l7 P
  2001.         point_x = $game_map.round_x(point_x - 1)1 G9 \% d4 y' f. x- ~
  2002.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps( D1 ~0 v8 I4 i+ r! J4 F3 f) N) z0 _
  2003.         reversed_chase_path.push(4)0 r/ R$ o' u1 F5 S
  2004.         point_x = $game_map.round_x(point_x + 1): M. V9 s  e/ r6 w* f6 h
  2005.       end8 J: J! @# q2 b' \) j
  2006.     end6 Q0 g$ }2 n1 g/ |' p
  2007.     end #endOfForLoop' [/ e2 f- |' b3 P& a3 a) ~) Y
  2008.     @mouse_move_path = reversed_chase_path.reverse + chase_path
    ( S6 N4 F' X0 n8 t/ o; F  I/ ~
  2009.   end#ship
    . _0 x' r3 }) C) t
  2010.   #--------------------------------------------------------------------------5 e2 \; I; U+ r1 U, f
  2011.   # ● 绘制airship的移动路径 @array[move_directions...], D" z  v  a8 |6 Y
  2012.   #--------------------------------------------------------------------------
    ) ?) ]2 H3 `" [4 Y: r  N2 \
  2013.   def draw_air_path  h2 W; ]2 U) U) g0 Z* L
  2014.     $mouse_move_sign.transparent = false
    # n# l/ t2 f) P( Y1 {
  2015.     # 准备绘制路径表格9 n9 V" t4 ]; N( h% [8 d
  2016.     sheet = Table.new($game_map.width, $game_map.height)& m" N. d8 X6 X  z$ H
  2017.     new_check_point = [x, y]; sheet[x, y] = 1; [9 f& q; G. E; [5 m& \
  2018.     reach_point = false;      step = 2
    / J9 |+ h3 }& O3 z  [9 j
  2019.     loop do #loop1
    + j; g3 Z2 Q) ~' x/ x2 g
  2020.      check_point = new_check_point
    2 G; S, |) ^. d0 e" }
  2021.      new_check_point = []
    : }: u0 `( u4 @' P2 R
  2022.       loop do #loop2
    : D; o( O, d3 E' C
  2023.         point_x = check_point.shift
    6 p4 \) |- m6 g1 N
  2024.         break if point_x == nil
    ' \2 }0 C* Z5 k8 S! R* b5 _
  2025.         point_y = check_point.shift4 b6 j2 q1 Z% q1 X" c
  2026.         if point_x == @moveto_x && point_y == @moveto_y
    ! ^# u' u( ^- n7 V: x+ E, b+ C0 C
  2027.           reach_point = true; break2 J' }, W7 l3 D5 p0 `
  2028.         end
    / x; L' F' j6 u( a' z
  2029.         left_x  = $game_map.round_x(point_x - 1)9 ]$ v5 v5 ]$ Z. e3 {. e) C
  2030.         right_x = $game_map.round_x(point_x + 1)
    9 Z0 Y; S1 L3 ^  Z9 W1 X) }% U& g
  2031.         up_y    = $game_map.round_y(point_y - 1)# d1 v3 c$ J" f
  2032.         down_y  = $game_map.round_y(point_y + 1) 6 G! x4 r6 H6 f" x) f' B
  2033.         # 以需要抵达该点的步数填充路径表格 #8 {$ p; W- c, W6 S
  2034.         if sheet[left_x, point_y] == 0
    5 O8 j; r% o' f  \: O
  2035.           sheet[left_x, point_y] = step0 v# C0 @% `; z2 m
  2036.           new_check_point.push(left_x, point_y)2 H) j# G6 h9 H$ @) g  F, @: o% k
  2037.         end6 c0 f' z; q8 C! H  y
  2038.         if sheet[right_x, point_y] == 0
    $ }- I8 `6 T# l- X4 O+ g
  2039.           sheet[right_x, point_y] = step: m7 A3 x6 X! K+ B
  2040.           new_check_point.push(right_x, point_y)
    6 m& r+ M1 A' T1 V$ Z5 u1 b$ Q
  2041.         end! `/ D6 I' K0 u
  2042.         if sheet[point_x, up_y] == 0
    9 W, _% X) L4 k* R! S. E
  2043.           sheet[point_x, up_y] = step
    1 l, X# `7 @* C) k$ U
  2044.           new_check_point.push(point_x, up_y)
    0 g  a5 _7 o3 S2 o
  2045.         end
    & |/ [# M( P2 p" }+ V. u
  2046.         if sheet[point_x, down_y] == 0; x% I' ?' D* h9 a* F0 e
  2047.           sheet[point_x, down_y] = step
    ( M/ @0 Q4 x: f6 t, T
  2048.           new_check_point.push(point_x, down_y)
    3 }0 x* P8 X1 _
  2049.         end& B* e0 N9 w6 z, Y7 `8 t; L
  2050.       end#endOfLoop2
    , j' U# o3 U8 l+ a( @4 s% G
  2051.       break if reach_point+ u' p8 ]/ X+ R% F3 ^
  2052.       step += 1
    7 u) `* }; l( s- x* }$ q/ ^" W3 H
  2053.     end #endOfLoop1
    6 p3 u. ?" p/ e4 ^/ {+ R
  2054.     # 根据路径表格绘制最短移动路径 #
    , i, H" y* w( u6 p. q* O6 D
  2055.     reversed_chase_path = []; step -= 1
    1 o/ F1 e9 M2 f/ m
  2056.     point_x, point_y = @moveto_x, @moveto_y+ g, N1 C2 r- e# j1 u% J8 U
  2057.     for i in 2..step$ |' L- t! i3 L3 n, x
  2058.     step -= 1
    ( \/ I1 v+ \  ]
  2059.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs* [. k' q: G  Z1 H5 ~* p- M0 Q
  2060.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step0 A7 W) f4 g: ^" X
  2061.         reversed_chase_path.push(6)
    - J9 e$ |1 C9 S9 s* D
  2062.         point_x = $game_map.round_x(point_x - 1)
    7 ~! v4 |: Q* [* z# M
  2063.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
    7 c0 j- I- @2 T3 C, i! x1 v
  2064.         reversed_chase_path.push(4)2 {1 W* |, ?+ M- M
  2065.         point_x = $game_map.round_x(point_x + 1)
    : r) p1 L4 o0 N: W% C
  2066.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
    7 v6 ~- s  F' m. V( [2 r9 B
  2067.         reversed_chase_path.push(8)( E% j9 ?) F* I9 C; @0 e+ S
  2068.         point_y = $game_map.round_y(point_y + 1)
    ) Q. E6 W2 v$ @$ _* P, ~, X6 k
  2069.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
    4 J, _6 u$ w, }9 @% Y6 v+ G
  2070.         reversed_chase_path.push(2)( Q. v% ?& b* ~' L1 E+ K
  2071.         point_y = $game_map.round_y(point_y - 1)# A* [) d& t" Y5 \
  2072.       end/ _2 V5 ~, t  V
  2073.     else3 K0 W) d( Z# P1 x
  2074.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step  x2 n- u, ~6 n. {6 k
  2075.         reversed_chase_path.push(8)
    ' p% h1 d& P* ~' [/ p
  2076.         point_y = $game_map.round_y(point_y + 1)9 S1 z0 q) B( ~  {0 N/ s3 N' A
  2077.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step* b# e3 e/ u; k, m! R$ C  i
  2078.         reversed_chase_path.push(2)
    $ _7 ~) j; p  k- O
  2079.         point_y = $game_map.round_y(point_y - 1)4 H( O$ t& k" _+ \( c
  2080.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step7 Y4 O& T5 U6 o( {3 B* i( H
  2081.         reversed_chase_path.push(6)
    ; Y. Q& T0 E, Y  l% ]: n3 N2 f
  2082.         point_x = $game_map.round_x(point_x - 1), M0 b6 q- n+ b3 R
  2083.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step0 T$ \! ~( M. h0 B( |
  2084.         reversed_chase_path.push(4)4 W* z  c, F5 \- A7 U7 e
  2085.         point_x = $game_map.round_x(point_x + 1)
    " ?  \* I3 a2 _" O* f
  2086.       end
    # T) W7 G& N0 ?! }6 c& j
  2087.     end" U8 b% `  ?3 b% g/ f0 H! k4 K) B! G8 ^
  2088.     end #endOfForLoop
    - Z% b5 n% G5 ], ^( c. ^
  2089.     @mouse_move_path = reversed_chase_path.reverse
    / g9 X0 G4 e3 l, d
  2090.   end#airship4 e% ~6 M* q* K4 P5 W$ B- U
  2091.   #--------------------------------------------------------------------------
    # h4 t2 q0 i! e! ~
  2092.   # ● 目标点无法抵达时的处理,用于各路径绘制方法内部3 }' p  E, n6 K; `7 t
  2093.   #--------------------------------------------------------------------------
    & M8 f' X7 W) Z2 W0 F) o
  2094.   def not_reach_point
    : m8 M! `$ O* w1 p5 u( y
  2095.     $mouse_move_sign.direction = 41 ]6 h3 t' r& V  F
  2096.     dx = 0; dy = 0; dir = 07 x' W2 R% E+ L- t5 F) e
  2097.     if @moveto_x - x  0( O& _# B% C2 V, {! `
  2098.       if @moveto_x - x  $game_map.width - @moveto_x + x &&
    * W! \0 D+ H) i- n5 `
  2099.           $game_map.loop_vertical
    + {8 j: }9 O* A! c, g& v, w
  2100.         dx = $game_map.width - @moveto_x + x; dir = 4
      t  n9 M5 K2 H5 h; E+ K4 ^9 t* c
  2101.       else$ I4 S$ [) m. H& A
  2102.         dx = @moveto_x - x; dir = 6
    " F# j7 I. n) Y, C+ f' H# V, Y
  2103.       end# O' m, A# ?8 r5 K0 d6 ^- R
  2104.     else; _8 ]" O' J, K8 T
  2105.       if x - @moveto_x  $game_map.width - x + @moveto_x &&
    5 s6 X5 U  D' V- A+ J( V; i
  2106.           $game_map.loop_vertical7 Z4 h3 |3 ~) D6 o
  2107.         dx = $game_map.width - x + @moveto_x; dir = 67 T" _' D7 k1 t+ a9 r; A
  2108.       else7 \" I$ ]; v+ q
  2109.         dx = x - @moveto_x; dir = 4
    0 r0 L" y, G% V6 Y+ q4 v" h
  2110.       end
    5 J* r! l' R, ~0 o" k
  2111.     end; C" C( X$ Y/ U0 b+ T
  2112.     if @moveto_y - y  00 {7 `3 X  |1 C
  2113.       if @moveto_y - y  $game_map.height - @moveto_y + y &&
    6 C6 \( r8 a  f7 U/ v" x
  2114.           $game_map.loop_horizontal7 Q8 M  g$ A) m' X0 T1 ?
  2115.         dy = $game_map.height - @moveto_y + y
    " I" g- {' k" W4 y
  2116.         dir = 8 if dy  dx3 e# d8 w: z* G$ [
  2117.       else
    & i6 y: f* O0 |; e. K% f! g% a
  2118.         dy = @moveto_y - y
      }+ H5 ^# ~5 X% `* y, J' Y% V
  2119.         dir = 2 if dy  dx. @8 x& V% W; _/ W: P) I
  2120.       end
    ' j2 P+ e9 j' D+ f/ }
  2121.     else
    6 A7 ^: N, }; Q; f9 V0 c
  2122.       if y - @moveto_y  $game_map.height - y + @moveto_y &&
    4 y2 A# G% O+ P- N) s
  2123.           $game_map.loop_horizontal
    0 {# a& W5 I/ f( a
  2124.         dy = $game_map.height - y + @moveto_y- G) F2 T: r; S7 U2 ]; N* U
  2125.         dir = 2 if dy  dx 3 {7 W7 {6 F( ~: u  X, T
  2126.       else
    ! S+ H9 d# j9 S0 J$ O3 ]- u
  2127.         dy = y - @moveto_y
      O  t& i9 @$ X! @3 \& s+ l; D4 u
  2128.         dir = 8 if dy  dx' V* @# \4 E' q& q7 X( F
  2129.       end4 A$ w- t1 z1 ~) N* n- T* q0 y
  2130.     end
    , B6 ~! G) k7 t! r
  2131.     @mouse_move_path = [dir, 0] # 0方向用于防止移动过程中触发事件  k# R0 ^  w! @) ?. p
  2132.   end
    6 w) ]" Q& _" Z1 _
  2133.   #--------------------------------------------------------------------------
    ) z9 z" A8 Y4 `, f: u$ J/ M* U
  2134.   # ● 判断目标点是否能抵达、登陆,用于船只路径绘制. _; M9 ~9 Y2 \1 h& C
  2135.   #--------------------------------------------------------------------------6 n  z/ @" W. u! P8 c
  2136.   def landable(x, y, path)- c) n+ J8 V- f) j
  2137.     case @vehicle_type
      i, e1 Y3 ^& e4 u
  2138.       when ship; return $game_map.ship_passable(x, y) , N5 V. _% T" n: q0 U. q  g& m
  2139.         $game_map.passable(x, y, 10 - path[-1])
    ; V0 ]0 A4 g+ Q. M) ^+ T/ u
  2140.       when boat; return $game_map.boat_passable(x, y)
    , x: L3 i' w" Z$ ]1 z
  2141.         $game_map.passable(x, y, 10 - path[-1])
    ! \& p, _8 A% Y% T- \
  2142.     end+ N. ~" p& f4 j# Q0 b" p% I
  2143.   end1 o& R) B/ T$ l4 c, ?
  2144. end
    4 o/ j! j* g& [* B9 T
  2145. : P0 c2 }; V8 W: o: H
  2146. #==============================================================================
    " [9 q) T; ^9 L( `4 O
  2147. # ■ Game_Map4 m# n- s/ M3 a& i6 o& _) w
  2148. #------------------------------------------------------------------------------
      c' Z2 @/ [( I* J
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    ' n! \; o4 t6 h
  2150. #   本类的实例请参考 $game_map 。
    8 Y3 s/ @3 Q3 N4 k; Y
  2151. #==============================================================================
    / c# ~+ n7 j8 J9 `
  2152. class Game_Map
    . n. `9 k& ]  t. m  E, C
  2153.   #--------------------------------------------------------------------------
    " \0 n+ e) ?: ~# o8 z: l
  2154.   # ● 定义实例变量7 S' t! `  ]: _7 U
  2155.   #--------------------------------------------------------------------------
    9 B( B" U' w* n; [: f
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据7 d6 V' D# e) M& `( u* v
  2157.   attr_reader mouse_map_y # 同上
    8 Y) o. ^: t2 f" V
  2158.   #--------------------------------------------------------------------------
    : a5 p# z+ J3 M1 A8 _! G
  2159.   # ● 初始化对象# f4 a0 v) S" ^% d: h
  2160.   #--------------------------------------------------------------------------
    1 {( Y7 E! G3 _. y1 w
  2161.   alias sion_mouse_initialize initialize
    8 d# s  \/ h' r4 Z* v" F
  2162.   def initialize# R9 O1 i$ X, `, v; }; B
  2163.     sion_mouse_initialize
    / w3 w$ S" `6 m9 L& Y
  2164.     creat_move_sign  ###
    , C! h/ V8 d4 p0 k; s# t
  2165.     set_constants
    2 }* M5 @) f; X: G
  2166.   end
    ! I7 L* p) Y2 c( h4 e
  2167.   #--------------------------------------------------------------------------
    . B0 [0 d, Q0 b- S1 j, o2 I% w
  2168.   # ● 更新画面* K1 y7 c) T& |* X
  2169.   #     main  事件解释器更新的标志
    1 N' y6 m' w, Z; Y
  2170.   #--------------------------------------------------------------------------8 c& \: E/ L5 Y4 L; H+ v3 ?
  2171.   alias sion_mouse_update update
    / s. \& |2 E' y! R8 @
  2172.   def update(main = false)
    ( Z% M8 S# }1 T) P: I
  2173.     sion_mouse_update(main)0 L' [4 b! I" _' j+ C
  2174.     update_move_sign
    . e$ _( r; u6 N2 s5 v
  2175.   end
    3 a* @. ^' K$ c$ n
  2176.   #--------------------------------------------------------------------------, B0 H* w3 e6 M% i" \2 Z
  2177.   # ● 创建显示路径点的事件
    5 y- O3 x6 m) u  s
  2178.   #--------------------------------------------------------------------------1 o* t2 p9 x) T+ A
  2179.   def creat_move_sign
    ; \" D* i1 n5 L2 {
  2180.     $mouse_move_sign = Move_Sign.new+ c: y' \; v" l7 C
  2181.   end' b, q, A# |" ~* ^1 R8 n" L
  2182.   #--------------------------------------------------------------------------- U' h, f2 o1 D+ N
  2183.   # ● 更新显示路径点的事件; j, [8 n( R: K% K( C
  2184.   #--------------------------------------------------------------------------6 z% \! U! S( s5 a' x! d; S2 @
  2185.   def set_constants
    ; B* U5 K7 `0 I4 J8 [( w( `
  2186.     @mouse_pos_setted = true
    5 U6 H. z, f$ C# c
  2187.     @set_pos_prepared = false
    * c" w: `9 |: t$ b$ u
  2188.     @mouse_old_x = 0  C3 \; `  o) W) n  _% k# V9 u
  2189.     @mouse_old_y = 0
    & ^( M" X7 }+ U$ Q
  2190.   end* l' Y9 |! O8 W0 ?* I8 F
  2191.   #--------------------------------------------------------------------------: K( @& R* K0 O% r' }3 @* t. A
  2192.   # ● 更新显示路径点的事件+ Y1 A) e; }& \
  2193.   #--------------------------------------------------------------------------
    8 l( V, R  N5 r1 a1 R0 y
  2194.   def update_move_sign# ~# X3 _( E: l' Z
  2195.     $mouse_move_sign.update
    3 ]+ F1 f' X# w7 f: y
  2196.   end- s4 D* O9 c6 |( A- k
  2197.   #--------------------------------------------------------------------------# Y8 M  D/ o1 X" s
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    5 g: D2 ?( b! C! Y8 Q2 P
  2199.   #--------------------------------------------------------------------------
    $ G5 o1 ]5 t5 }0 m8 H1 D* I0 m* q# d
  2200.   def get_mouse_map_xy
    , q: S5 O- i3 {9 J
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    . ?% s+ h* I$ L0 `4 B5 r
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    & E! F- G, d  }& L& I# V
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    ' |, s2 c% g  P( E4 @# ^" N$ @
  2204.   end. Q( }5 g0 `% D2 S+ }; _2 v& c
  2205.   #--------------------------------------------------------------------------! Y  M1 j2 _. X6 x
  2206.   # ● 返回地图画面时重设鼠标坐标
    6 _! E) n( t. I: ?, N5 E/ Z  p/ g) \
  2207.   #--------------------------------------------------------------------------1 P7 z0 ?0 ^3 |2 B; r
  2208.   def reset_mouse_pos/ [* h7 M2 j, W5 H4 O" l7 a
  2209.     return if @mouse_pos_setted3 s8 q9 m9 Q: s  X1 ^* [! w
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)7 k6 D  ]! v+ F7 R
  2211.     @mouse_pos_setted = true' d4 R- m4 z3 u2 r1 |! W
  2212.     @set_pos_prepared = false9 B# u5 p% q0 O& X) u" k2 b" Z7 Q
  2213.   end( k6 z" ^: H3 n1 m' V% m
  2214.   #--------------------------------------------------------------------------
    7 S) @6 ?& K# N* O
  2215.   # ● 重设鼠标的坐标
    & ^$ u9 N8 O) t2 u; O9 T
  2216.   #--------------------------------------------------------------------------; W0 ~0 b! E/ e$ y0 P- C
  2217.   def prepare_reset_mouse_pos
    - Y1 B' N4 `0 ?- C
  2218.     return if @set_pos_prepared
    * x6 E* Q, N  W' G
  2219.     @mouse_pos_setted = false
    . ?. `1 L3 o& L3 A6 V% m  `: Q
  2220.     @mouse_old_x = Mouse.mouse_x
    , S* J, _+ V5 c+ Y, h$ `7 G2 }
  2221.     @mouse_old_y = Mouse.mouse_y8 R: }# _3 Z/ w5 ~8 S/ M
  2222.     @set_pos_prepared = true. ~" ]6 ]3 K8 P. @
  2223.   end
    . ^9 C) ]/ v' \( m9 e- g
  2224. end1 b6 Z  Z5 S! W, A8 E8 @! u. E
  2225. 9 |0 y6 Z* ~' X+ m+ \: u4 }
  2226. #==============================================================================9 E7 K- G! Z$ J% C
  2227. # ■ Spriteset_Map
    1 p8 t3 Q! X# A, g
  2228. #------------------------------------------------------------------------------9 O" h* A. ]' v4 w* Q6 \
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    0 o" E. g1 O3 p! e8 c0 l
  2230. #==============================================================================' Z  Z& L% {# a0 `; S/ D0 |$ E
  2231. class Spriteset_Map
    * ^6 \. u& q) F3 g3 c7 |8 b
  2232.   #--------------------------------------------------------------------------
    5 g2 c; E6 C3 u. u
  2233.   # ● 生成路径点精灵
    : w0 z4 V4 [5 `
  2234.   #--------------------------------------------------------------------------! d" L, e2 l" e4 j+ J6 S8 @! @) {) L
  2235.   alias sion_mouse_create_characters create_characters  q* F& E- K8 l; D; U+ P, n2 P
  2236.   def create_characters
    2 @" u# Z& X% F9 ]& _6 ]& f! I6 _
  2237.     sion_mouse_create_characters. P% T' M( i5 b) Q0 S
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    8 B5 Q/ O6 r+ |2 U7 L& t
  2239.   end4 u% V( [4 k$ L) r7 ^+ d/ C
  2240. end
    $ P) y! H, u% }* o

  2241. # C+ _1 k, F! O( _7 y
  2242. #==============================================================================
    ! k+ p8 U( @! G  n) D5 E
  2243. # ■ Scene_Map
    ! c% ]) ~+ Q! H# Y2 u
  2244. #------------------------------------------------------------------------------2 ]; ~9 G  P1 x
  2245. #  地图画面
    " ?  Z$ D- U$ A) ^% Y5 t4 s
  2246. #==============================================================================1 i0 D& y: ]$ y* X! d
  2247. class Scene_Map  Scene_Base
    % F9 h9 W0 P: ?8 \0 @' `, ?
  2248.   #--------------------------------------------------------------------------
    # A0 K. A' j& t7 ~' l/ y/ c
  2249.   # ● 画面更新
    ' g$ i- s; u) Q& @3 N+ _
  2250.   #--------------------------------------------------------------------------
    4 o2 _; b5 f# M% u1 D: H( O! x
  2251.   alias sion_mouse_update_scene update_scene
    8 |* E. r4 K, v  O8 ?5 |
  2252.   def update_scene% L% ~1 F/ Q4 R+ C6 E3 i8 l# a, m
  2253.     sion_mouse_update_scene
    * Q) _5 ~* `4 u& }
  2254.     update_mouse_action unless scene_changing
    9 M  q0 b2 n6 {
  2255.   end
    , i3 c; ^; F3 N8 W4 l+ B' S5 W
  2256.   #--------------------------------------------------------------------------
    + E! u. O+ W" S
  2257.   # ● 场所移动前的处理' s* g% S. O. b+ P; A+ ~4 I5 F6 y
  2258.   #--------------------------------------------------------------------------* o0 W( p/ j. w+ d( z( i" V) K) L
  2259.   alias sion_mouse_pre_transfer pre_transfer
    * K+ D8 Y* P0 G: p
  2260.   def pre_transfer
    4 C& D  y1 F) U6 w0 q3 I; @
  2261.     $game_player.reset_move_path+ ?# [$ V5 W4 i& k: q
  2262.     sion_mouse_pre_transfer
    . D* _  I8 V; g& U
  2263.   end  a4 }" E& q( y2 Y/ x) a
  2264.   #--------------------------------------------------------------------------9 k# f8 G; T9 U& n" |8 y9 H: `
  2265.   # ● 监听鼠标左键的按下
    / E3 u, M  @6 j  ?. ]7 K
  2266.   #--------------------------------------------------------------------------
    7 z& c2 Y9 a+ a( G
  2267.   def update_mouse_action; O+ }! p* {% W
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    & G5 E# f0 i& ^6 \# O/ b) \
  2269.   end
    1 c+ D3 m9 o9 I$ Z
  2270. end& |2 ?% X' r: M* x

  2271. - s, Q/ s( V# @! Q! e  O$ a! G3 r  g
  2272. #==============================================================================
    5 ^$ M2 x3 C" {
  2273. # ■ Scene_File' t5 i4 T4 O: Z$ t
  2274. #------------------------------------------------------------------------------- m, x1 k3 g& T
  2275. #  存档画面和读档画面共同的父类
    5 Q$ N/ g  `1 I! p
  2276. #==============================================================================
    , t7 p$ E: \. ?2 U+ q0 ?
  2277. class Scene_File  Scene_MenuBase( S: S- \$ \$ w0 D' P
  2278.   #--------------------------------------------------------------------------& h( b! T, `  V
  2279.   # ● 开始处理
    7 E0 X' _# p/ E- Z0 p! R  P
  2280.   #--------------------------------------------------------------------------
    0 u( g) G9 q, P
  2281.   alias sion_mouse_start start
    ' C( I' ?6 x8 V7 Q& j0 S% g
  2282.   def start
    % N  s, c7 F% B1 a" Y! s+ a2 C
  2283.     sion_mouse_start8 {4 `, ]) `" O3 H4 C! K, K8 ]/ l
  2284.     @move_state = 0
    + `2 a. X$ z4 Z& p0 B
  2285.     set_mouse_pos3 y9 S- V8 c; a+ @) _
  2286.   end9 R) @4 J3 k  O% ~' G# l
  2287.   #--------------------------------------------------------------------------
    2 Z0 F8 b3 E6 I
  2288.   # ● 更新画面
    + `& C5 {, X" f6 I  v& Q
  2289.   #--------------------------------------------------------------------------2 y( Z( p0 G0 }3 p$ h6 r
  2290.   alias sion_mouse_update update6 D* E& Q. z% B
  2291.   def update
    3 J# ?( j# h( N; w+ y! m% o( o
  2292.     sion_mouse_update
    4 a, A* |" s" G7 e& A" W0 M6 |# Z# f$ w
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    6 k1 ~' y' m. X  I/ Z8 |
  2294.   end- o! g& c. A  o) k& c3 Y! |! f  I  g$ i
  2295.   #--------------------------------------------------------------------------! F9 p5 Z1 H$ i2 _$ x
  2296.   # ● 更新光标
    4 F! i; j  U  F+ x0 R3 x
  2297.   #--------------------------------------------------------------------------6 {) E# G( _1 f2 i+ X! h
  2298.   def set_cursor
    ; Q0 |2 t1 o$ F5 x+ `: k
  2299.     @move_state += 1, J* p0 n* {) t* K: I7 @
  2300.     last_index = @index+ o  Z/ ?3 j% w' f
  2301.     if mouse_which_window == -2( ?+ u' w' J  k7 t/ }: V
  2302.       if (@move_state - 1) % 6 == 08 @: H2 M% _6 P8 e1 d, G  G
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1$ V1 x# l: {; B' N
  2304.       end7 Z$ K% j5 q! k+ L. @; P( K
  2305.     elsif mouse_which_window == -1
    : j" B# E. z4 ~; a9 w
  2306.       if (@move_state - 1) % 6 == 03 K$ R* q3 W: Z% c; B8 N
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    $ A4 f" l/ i% e
  2308.       end3 E4 f+ H) S! D3 S" m: f
  2309.     else
    / z! A" k5 |. K& K$ ?2 j
  2310.       @move_state = 0
    8 j# G- R0 c4 T0 }7 G9 b
  2311.       @index = top_index + mouse_which_window' N" O, A7 k& U9 ~$ V
  2312.     end
      Z" G& [: E8 m9 g
  2313.     ensure_cursor_visible1 b0 n( O( p% j" p0 q6 I; j3 T
  2314.     if @index != last_index
    ! O5 Q2 O9 ~% `6 O. l0 B
  2315.       @savefile_windows[last_index].selected = false
    6 F5 l7 D( z9 X* l' L7 C- D% M
  2316.       @savefile_windows[@index].selected = true/ P0 i" z7 O/ s. K6 x4 A  b& q9 S
  2317.     end
    , r) z% o' f; d! H- m6 i: F$ W6 a
  2318.   end
    % H0 }/ l9 T7 u
  2319.   #--------------------------------------------------------------------------
    9 i9 C9 r9 Z. `3 X) R) h( w4 p
  2320.   # ● 判断鼠标位于哪个窗口
    : w7 T! E; o# L; v
  2321.   #--------------------------------------------------------------------------: Y; ]: r/ }; Y* s
  2322.   def mouse_which_window
    / r7 G) D- ]  W* H8 ?
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y' I( `/ c" I, ~. X0 w  G+ z
  2324.     if mouse_y  @help_window.height + 14
    6 z3 f, J% V. \0 B8 ^- ^, E, A
  2325.       mouse_row = -1) f" h* C% ^9 V/ k' c
  2326.     elsif mouse_y  Graphics.height - 14
    / K& Z8 y" Y& ~" F
  2327.       mouse_row = -26 Q' i0 J. S. t  ]+ L
  2328.     else
    * O; [  g7 y' F0 B1 h0 Y
  2329.       mouse_row = 4  (mouse_y - @help_window.height) - ?9 A7 x/ M. L" b: n3 N
  2330.         (Graphics.height - @help_window.height)
    0 Q9 y+ r, f$ h6 V* ~
  2331.     end
    ' r2 h( }! J, W3 r' f7 w
  2332.     return mouse_row4 G" y. _. j$ g5 \# g
  2333.   end
    + H9 Q* j1 Y  _2 @+ Y4 }. |: P9 [
  2334.   #--------------------------------------------------------------------------
    ' _3 p+ I5 b# `1 E
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    - b" C, t: n; N) ~
  2336.   #--------------------------------------------------------------------------
    : b. V% [" E: R" \% i
  2337.   def set_mouse_pos
    2 L) y9 P' H& O# B. C3 F
  2338.     new_x = 40
    % E4 P) R% ?6 A4 w# m
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24, q( c& p  S4 X( b( r. J5 s# Q
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    * ]0 J0 n5 e) i8 Y& e2 |4 V7 \; Q
  2341.   end0 k! d  A6 j  C* ?$ a3 y; ^
  2342. end. T: I) b6 y0 ^4 i) k+ R% b
  2343. 6 b% ]6 T' u/ R+ s5 S2 o4 I; U
  2344. #==============================================================================& x# h$ K9 G! B% u9 ~" O  y+ n
  2345. # ■ Game_Event
    - `$ u! ^. N( q. ^" w0 L2 F- d! m
  2346. #------------------------------------------------------------------------------
    6 y5 Z: r( U3 O. S1 j
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。% d; j: s# [* {8 T
  2348. #   在 Game_Map 类的内部使用。
    8 C5 N* B0 ?4 |5 y5 P& q
  2349. #==============================================================================
      c" z6 `9 E: O$ h) R& s2 X
  2350. class Game_Event  Game_Character
    6 p9 q6 w- a  ]8 v. K: o
  2351.   #--------------------------------------------------------------------------
    / U8 ~- g" z, G' s& Z  L& j
  2352.   # ● 事件启动2 O! Q5 |% S  u; Y
  2353.   #--------------------------------------------------------------------------
    7 }: I, A' a2 l1 \4 G6 b7 _1 {
  2354.   alias sion_mouse_start start
    & ~! }1 e# W, Z9 y9 B0 ^# O! t
  2355.   def start; h" y& f* ^8 W$ ?. I6 T
  2356.     return if mouse_start && !Mouse.press(0x01)) y) j$ R: B) `
  2357.     sion_mouse_start- M% \, _4 Z( x) R7 @
  2358.   end
      S9 d8 d' [& o: g
  2359.   #--------------------------------------------------------------------------( k& _- C6 f0 x3 m# d/ X$ E
  2360.   # ● 判断事件是否由鼠标启动
    ; `& u0 y, {, q; k( p0 [
  2361.   #--------------------------------------------------------------------------. b) Q) ]& g8 v0 R8 i1 ?3 T
  2362.   def mouse_start( `- G. G9 s$ F! u: Y& T" {
  2363.     return false if empty! `6 A" _/ L2 ?4 Q( g
  2364.     @list.each do index! V2 w( {; l) [2 |3 ?
  2365.       return true if (index.code == 108  index.code == 408) &&
    + t9 M+ T1 _4 L" ~1 A
  2366.         index.parameters[0].include('鼠标启动')
      A; f: R, ^; p. H! R
  2367.     end
    9 @; c  |/ A9 H, t, d$ l
  2368.     return false
    ) ~* w4 l( p8 B# K' r, N
  2369.   end" \4 B7 n; x9 U! J0 Q6 k
  2370. end1 V3 p3 `4 p1 Q* s. O& F
  2371. & @6 u: A# A% d3 ?
  2372. ####泥煤的height7 F$ |* B! A; U: S; s" a5 `" d
  2373. # @height = height4 Z1 h+ ?$ m8 Y& [7 ^* m3 o, F

  2374. # o( W; Q! b, {8 H1 u
  2375. class Area_Response
    2 d8 U; X$ D9 x0 L5 w5 d
  2376.   attr_accessor type
    % m8 w7 K2 }2 c+ t* g' \
  2377.   attr_reader ox
    # o" i6 a& O  ]' V" i' l
  2378.   attr_reader oy
    $ b/ ?* ^- [! y! @
  2379.   attr_reader width/ d2 S3 T* V" d" ]
  2380.   attr_reader height. l  y) O  t7 [6 k9 m
  2381.   attr_reader switch_id
    ; k" T3 ]% [1 a0 E. O0 I7 o9 `8 N
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    2 U  V3 M( B' n' F7 e! m
  2383.     @type = type
    5 b& f+ e& B9 ?/ y
  2384.     @ox = ox
    : `3 V5 v$ H9 D1 @+ S
  2385.     @oy = oy
    ' f2 i2 ]2 t% L5 j6 }8 p
  2386.     @width = width% d( S# D" e9 _1 O: s9 l
  2387.     @height = height
    2 j- Q2 @$ c& G0 g' a3 ~. J
  2388.     @switch_id = switch_id. l6 P  c. K5 }, z
  2389.   end( z3 |: T6 i; v" y& ^; q
  2390. end
    7 \0 e, j$ H2 I! _) T2 q  l4 [' X
  2391. 3 v0 @% a* q/ q9 Y5 i
  2392. $area_responses = []0 p9 \3 j& f* _* ]+ s4 U5 s/ V

  2393. " |, M8 u3 H& b; k. X7 p' o7 [
  2394. class Scene_Map
      z3 A1 }& Z. u3 [
  2395.   alias update_mouse_2013421 update_mouse_action4 F+ O9 K) q0 d3 v
  2396.   def update_mouse_action" V2 b# X# {: d: v) m
  2397.     update_area_response
    " \& `9 o0 L8 c4 h
  2398.     update_mouse_2013421
    3 _( i0 |5 r4 z+ i) }. x1 z8 K
  2399.   end# a; c; Q8 T" W% }$ ]5 Y$ ]
  2400.   def update_area_response$ m# m: ]% Z. t6 ^' q& Y1 h
  2401.     responses = $area_responses' g  K9 ^' y& m5 f. ?5 n! D6 o( O
  2402.     responses.each {response
    9 G. O  ^/ I7 O
  2403.       ox = response.ox" n% t  F9 k2 `
  2404.       oy = response.oy3 s2 M% x6 [/ \8 J+ g& ~4 @; w
  2405.       width = response.width, R- }, z& v8 m5 R: W0 |
  2406.       height = response.height
    $ M- L/ d/ H6 O2 a% ~
  2407.       switch_id = response.switch_id
    1 X3 N, d8 k: y1 L2 `
  2408.       case response.type3 u1 X' ^" v% v, b+ o; y
  2409.       when 0. d" B3 R/ |# a
  2410.         if mouse_in_area(ox, oy, width, height). _: N) g2 k6 n5 T
  2411.           $game_switches[switch_id] = true: @: D% w" R- [! w' D7 ^
  2412.           $area_responses.delete(response)1 P+ t9 ~% p- `- D) }$ r0 L  [
  2413.         end# n% ?" e% m) y0 s3 f, l
  2414.       when 1, o# h% \2 F+ I% L8 U) W8 s
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)9 M8 b: S) _4 t! Z/ i! f' Q
  2416.           $game_switches[switch_id] = true
    4 @3 I- z: v; d- X9 t
  2417.           $area_responses.delete(response)& F1 G& x5 [5 L6 \. @3 ^2 S
  2418.         end2 p0 X6 f+ ~& r7 P4 k/ G7 }
  2419.       when 2! m2 r1 F' ^& t/ ~  l( V
  2420.         if mouse_in_area(ox, oy, width, height)
      e1 C+ t8 i# x7 e! w- j- X
  2421.           $game_switches[switch_id] = true# ?" N6 y' l3 R
  2422.         else
    3 a$ }! I6 a) p
  2423.           $game_switches[switch_id] = false1 W9 [, |$ X1 I% X( A9 F5 \: K0 X
  2424.         end6 h; X4 D* m% U; C' V5 Q: U
  2425.       when 3( F8 O1 }- W7 U# @+ f: P
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,0 z, M5 [* f: X) G! T. w! A7 Q
  2427.             (oy - $game_map.display_y)  32, width, height); A, s* M1 E7 O3 L2 Z
  2428.           $game_map.events_xy(ox, oy).each {event
    / Q7 @6 |! N- }6 W- p
  2429.           event.start) e' o" G$ z* u$ t8 H( U
  2430.           $area_responses.delete(response)
    2 Y8 ^- @  b! j  A; H
  2431.           return
    6 c/ x" d: [" E  l2 [' ^8 w
  2432.           }
    * P0 E( l& }. o8 D3 v
  2433.         end
    ! g0 X6 t/ ~( i  U" b+ O+ ^
  2434.       when 4
    : j* q. K7 G1 c- k2 q
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    # A" G9 D) h3 k' {
  2436.             (oy - $game_map.display_y)  32, width, height)
    : C, Z  C0 Y2 U$ _) [& d8 F. s
  2437.           $game_map.events_xy(ox, oy).each {event" m# y! @/ ]7 }/ e/ T
  2438.             event.start
    8 I  j) ]. n; e. V( ?: C0 A
  2439.             return2 h& r4 k: Y# ]6 r7 A
  2440.           }
    0 J8 |0 }* \, }4 I. c  w
  2441.         end
    ( J; v' B& X; {8 O8 E, [
  2442.       end
    ; r% g  u+ r  c- |4 f* f2 y
  2443.     }
    5 ]- Y' O3 x3 ~, l* H9 m. f
  2444.   end% A" L$ l# p# }9 H: R- s
  2445.   def mouse_in_area(ox, oy, width, height)
    4 P. k' f9 K0 W$ H! Y0 K
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&' g5 Q% F  w4 v/ ?4 U' T6 `# }
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    . R4 [6 M, K! M' ]
  2448.   end
    ( \7 s" {) I, P8 |( n5 N
  2449. end
    , i+ ?: R4 l9 ^9 i, s* ~. C) J
  2450. class Game_Interpreter
    , Z3 e+ v, g; n$ z% I2 }% e. v
  2451.   def area_response(arg)
    ) F; D% {/ g- i' r( `
  2452.     $area_responses.push(Area_Response.new(arg))6 g; J5 c! r* N4 O: y7 L
  2453.   end; ~$ o& w. Z9 j# H
  2454. end
    $ l* O& S  U8 l7 q4 B/ V6 D) x" n/ I. ?
复制代码

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

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

GMT+8, 2025-7-21 15:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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