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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================  j) R+ X' a+ S3 ^
  2. - h, J6 ^2 r! c; e6 j: \6 K
  3.   Sion Mouse System v1.3e% U3 X- E% ^6 f. m- T$ t7 h0 p
  4.   
    2 Y: g3 ]/ f) B6 j8 D
  5.   Changlog
    + e7 T6 j* C& d3 [  e! I
  6.   " O3 c  L" Q+ r, \% ?6 f% w0 O
  7.   2013.4.21 v1.3f
    3 k" h8 u4 \2 g. I$ w
  8.    
    ! `) A- ^: f7 N
  9.     1.3f 卷动地图 bug 修正
    2 X3 F2 [0 a- t6 q! m
  10.     % i' X% V$ I" b2 R! k( u  b" n
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    , k  P! ?) |$ s- n9 ~
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内1 d9 @: [8 `/ k% |) ]% V
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    1 C" g' F3 H- F$ `0 r5 B

  14. ' H9 V9 ~- s' E5 A0 @( T2 K" e
  15.     1.3f bug修正
    % j, y( P% S6 t
  16.   ) c! m: C7 w( l& B8 ?5 j6 [; R
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及8 T8 X# v* j5 H9 B. |' a, s
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    * u  ^0 V0 i+ d

  19. " i* g3 A3 D+ w2 L# E
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    5 [  Y' [  i4 k7 G+ q% R
  21. 9 H7 Z3 _3 e: w6 f7 S5 z1 P( V
  22.     1.3b 修正一些罕见的bug;( [  x9 q+ ?$ a( s9 B; T6 o- J$ U

  23. 6 s: L5 g: d. M. U+ @' x
  24.     1.3a 代码小修改;
    . W! J' D7 Z; m/ \+ h6 b) y
  25.           加入了鼠标点击启动事件的功能,
    # H- c  M* D- y4 L5 `' x& @
  26.           在事件中加入“注释”: 鼠标启动  ,7 w( C2 E/ i' q& E' g6 m3 a
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    * `2 W* j: P4 @2 i/ z8 B# N
  28.   ' t8 R$ z6 E: f) Y+ C6 N0 H# F
  29.   2013.2.12 v1.2
    - I* Q/ [) m2 |; _4 l3 p+ Q9 T

  30. ; J# D: ~, ?4 i) E
  31.     寻路逻辑优化;5 J3 ~* C3 P3 r* s4 h, \& v
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    9 C; a1 l7 W. x  S* K/ }
  33.     现在支持用鼠标来操作载具了。
    6 F! f+ F8 k; Q+ n" e

  34. $ }, T$ W, H/ H  x$ n# H
  35.   2013.2.8 v1.1
    ; \6 x( w( |) X) e+ H
  36. ' C( V5 I6 j& q2 D6 P5 c: a
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    % @9 U) ~8 w2 L9 J3 r4 Q
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;1 h* R& Y4 J, M7 n6 U
  39.     移动时,路径指示点的绘制更加稳定;
    5 b- Z% k# R. ^0 _. Z
  40.     现在支持默认存档画面的鼠标操作了。: I0 d3 L9 t6 l! p

  41. ' r$ ~1 y& T* g0 _
  42. & d6 \: `$ v. F' z8 B1 ]: _
  43.   OrigenVersion
    5 A* C; q  L3 R( b5 W0 N$ t
  44.   
    5 s/ s- }5 P2 Y) W  A
  45.     2013.2.7 v1.0
    ! X" ?' j1 N" k5 V/ `
  46. 3 G2 G6 w: y' s- @
  47.   主要功能' Q+ T% ]0 c' [& S- h
  48. $ b9 L  f" ~5 o: e! ]- R, L
  49.       使用鼠标进行各种操作...3 X& v% f- X9 v' u
  50.       将鼠标锁定在游戏窗口内
    $ i2 |0 C4 L/ |) ^9 I$ X( n! i
  51.       自动寻路,按住 D 键可以扩大寻路的范围' m% o2 w4 G* p( b) ^" J
  52.       双击鼠标进行冲刺
    ' J" D6 E+ q! v5 G2 i2 ^# m
  53.       更改地图卷动方式以适应鼠标移动+ p- U7 [4 X7 g! B+ g1 Z  _
  54.       变量输入框改良0 i4 Y! q, X) w4 c- P
  55. 5 b8 X- q1 L9 h, V4 {  m; G% C) F' }
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    1 D# I/ j2 K: H

  57. ! S0 r; O6 M2 |- u: R
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹; m+ ?8 F) i& \2 R( v' ~

  59. 8 `. h9 j! z' Z1 n( J$ y- b
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    2 H6 O. d4 t" E4 j4 ?: _. @

  61. & s( y% X* G# @8 }& y. P
  62. 9 u/ I' F8 s& I1 Z# D
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★4 M5 t& N/ _9 Y- E: N1 {
  64. , @( _+ q0 B  ~# P

  65. 7 q4 i3 c1 w2 ?# J8 U6 x, @
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    + F8 {6 O" [# X% Z1 D0 O# a

  67. - U4 ^& r' C6 S! v
  68. #==============================================================================9 j3 d: v5 d5 `; W9 d/ f
  69. # ■ 常数设置 5 I" v! m( j8 e8 m
  70. #==============================================================================
    . ~2 Q( K( x$ M6 `3 ?7 z, n
  71. module KsOfSion6 N" [( l5 O& E5 w, t+ @; O* W
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false- @( n" b& ^+ G( Q
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑7 f* x/ m! F6 L$ N0 n$ j
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
      O7 `7 `" R7 P
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量7 A5 g& @7 M: l0 J' v) R9 a) x8 U, ]
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处. R4 z1 k  j7 v% T, [# h9 d. z0 G
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧1 G+ f* U* }& ~
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)9 y7 o/ U* e& i3 l8 J4 {" ?/ `; Z
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键: d9 \3 @+ S% W/ H% e
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
      v) T+ z# L% |: F5 l5 t$ P' U% G
  81. end( U1 M7 P- v* q; W7 Z6 Q; I" m  n

  82. ( d( T' n9 x3 r& {( H
  83. #==============================================================================
    + u- z6 b- j$ y
  84. # ■ 用来显示路径点的类( Q" V0 m1 m9 f$ m1 C: a8 e
  85. #==============================================================================# r2 r/ z) Z4 B; W2 w0 N
  86. class Move_Sign  Game_Character
    6 E3 q* \2 k: r, A
  87.   #--------------------------------------------------------------------------3 ^) J" l1 f' O" t3 I8 s, A
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图* h3 |: [6 @" G" f
  89.   #--------------------------------------------------------------------------
    # M- ^, C' D7 m2 q1 E
  90.   def init_public_members- G, R$ x8 S$ ?' \% ]5 _9 p7 }' w
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹0 c* k6 _  {% v, C0 r! H
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    . r$ \7 x/ g0 S( [& v8 a
  93.     @move_speed      = 5        # ★ 踏步速度
    6 ?- P$ y* V% @; t4 ]( U6 a
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    9 }1 }8 B9 z3 x+ C1 ~
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    / a3 h6 `3 k* u1 n. s3 }& D$ v! z- v
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    2 g- G3 ~  L! P" @
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列  Z' m$ f# j/ x3 ~( {
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)5 N+ _2 k$ r4 Z  |( f' b7 `! k" U
  99. & q7 T& e7 j; B

  100. 3 v  M. h" I, ?5 }' z+ E
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★! \9 y6 R7 c' j( N2 y2 ^& F, ]2 }0 l

  102. # T4 l0 j5 r: A. u$ h3 R

  103. 1 x; c$ {" a- P, e* t
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    ; _8 M2 x8 Q" ]5 h' A
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')& R8 M5 `5 w9 w8 ~0 V: Z
  106. ! w  n0 G& ?" V* F8 Z$ O
  107.       if $no_arrowpic_warn, ]5 x; r- C! F1 d) y+ E
  108.         MouseShow_Cursor.call(1)
    ( ?( D) ]# ]9 w; O* O- d/ D
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png- E7 A) Z% n3 R5 e+ A& D
  110. ' V- t# ]5 R5 _$ m
  111. “路径指示点”将使用游戏自带图片* b) W( q+ g  c# d+ S$ M

  112.   h( L, V0 o( n. R& K9 q4 l, A
  113. 该提示可以在脚本内关闭')- x* [9 q1 ]  X
  114.         MouseShow_Cursor.call(0)) O- f7 {6 I9 Y1 B
  115.         $no_arrowpic_warn = false9 v: _' F8 q, p: S& |
  116.       end, L7 G0 [3 J" Y: E9 L" {
  117.       @character_name  = '!Flame'
      P- B* M$ }% }
  118.       @character_index = 6- r7 v( X2 N2 k+ N4 d# {2 q
  119. ! Q5 q' b3 @/ A' I& ^) z
  120.     end+ Q+ V! J5 ~1 z9 ?8 j
  121.     @direction_fix = false  # 固定朝向
    - a/ m) B0 z5 }! D# @. x$ W
  122.     @move_frequency = 6     # 移动频率4 U/ q& G( w& q" |4 o
  123.     @walk_anime = true      # 步行动画
      w/ C  P$ A  X( G
  124.     @pattern = 1            # 图案
    + H8 d/ y/ a( c1 @, o
  125.     @through = true         # 穿透2 p- A0 B8 U5 Z  I4 s) Z$ f
  126.     @bush_depth = 0         # 草木深度
    + R' A+ }3 D* Q* Q- O
  127.     @animation_id = 0       # 动画 ID3 p' o2 {. n) ]
  128.     @balloon_id = 0         # 心情 ID3 @8 V; K: J# w! Z* I$ P
  129.     @transparent = true     # 透明1 S6 d9 P7 R; \: _
  130.     @id = 02 X, K7 X% \+ N$ W/ n* `! O
  131.     @x = 06 X6 f4 n8 A  V6 o" V# F3 P
  132.     @y = 0/ s  f" w* j4 k  P2 b* S# u
  133.     @real_x = 0
    $ L4 U% K$ J4 u7 F
  134.     @real_y = 0
    , R9 ~- {& y' r. k
  135.     @tile_id = 04 y" Q7 Q& |& Z# E$ J  C- I5 d1 ~
  136.   end1 r8 e/ j: t* E) ^8 w. _& [
  137.   #--------------------------------------------------------------------------
    0 z" \9 u+ ]3 ]& l3 y
  138.   # ● 定义实例变量
    $ f% Y3 \! q* [5 Z: U7 s
  139.   #--------------------------------------------------------------------------
    " F9 {( u: @0 d. {% z# N3 g
  140.   attr_accessor direction1 W# x1 X* V3 `; ?
  141. end
    . c. A: {, y6 |" E0 q( e/ Z; r

  142. 3 A9 _' c9 |. Z
  143. #==============================================================================
    - f2 Z0 B' @. C
  144. # ■ Module Mouse2 ~7 w6 q$ T5 X3 O% e
  145. #==============================================================================* s* ?/ e$ u: g# J
  146. module Mouse
    % {7 v4 p" \& b. k+ o
  147.   #--------------------------------------------------------------------------
      b3 k5 p1 B7 A) r0 G4 I' O, b
  148.   # ● API8 I" L" H$ j, q6 ^( n
  149.   #--------------------------------------------------------------------------
    2 z- e+ I$ ?  G8 L5 `1 \1 z" x  g2 v" G
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')* a7 h, P4 H6 @
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    $ L* R4 y0 D( }3 @* b7 N
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l'): U& V8 y1 R$ A5 V' ^
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')) n1 ~" n) [" [3 @8 n! e2 N2 ^+ t
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    ! R6 @: U4 `' z
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    : L7 N5 P- i- x% Y: A8 h
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    % d' X; s* I3 T: w' Q$ @5 S
  157.   Window_Hwnd       = Get_Active_Window.call
    / m8 j3 W4 s0 i% n) o1 T3 ~

  158. ' K/ b7 X9 J1 B, w, D% Q( I$ E
  159. class  self* \# f% j0 W2 Q3 r  j/ e( I
  160.   #--------------------------------------------------------------------------
    6 z4 l* y( h2 p# o6 b/ ?( j
  161.   # ● 初始化& }! y7 C4 y7 i# G
  162.   #--------------------------------------------------------------------------
    2 U! m' \; z' t+ `: B. {9 [
  163.   def init! e2 x& J' [) q9 _' M$ L7 z. z0 w4 {$ J
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor! E  s+ x7 M. d
  165.     @left_state = 0: B/ h* n2 M+ W2 N4 S* B
  166.     @right_state = 0% F6 T2 z& U8 C" C. N
  167.     @ck_count = 0 # 帧数计,单击以后从0开始* [9 X" k4 w. i+ D
  168.     @dk_count = 0 # 用于双击的判定
    $ W( t* @) n. _% x( y4 q
  169.     @clicked = false$ }0 F7 O+ q6 `/ i- k/ i
  170.     creat_mouse_sprite6 f! Y* Q$ @7 v0 y/ i6 ^" _( S
  171.     update
    9 N$ a' n% I5 T1 \' }
  172.   end. \% I  L! l+ x% Z/ }! W( K- v3 s
  173.   #--------------------------------------------------------------------------
    & i- b# u$ h& [/ s0 q( {
  174.   # ● 鼠标指针精灵) P' g  ^4 f, ]. p3 f' c
  175.   #--------------------------------------------------------------------------4 [1 o- S! e4 C! [% \
  176. #~   def creat_mouse_sprite: x8 G! O, R* n5 D% o, J
  177. #~     ) O) l" I- ~, \
  178. #~       @mouse_sprite = Sprite.new6 X) B+ n: \; p" E& l
  179. #~       panda = 2#rand(2)+16 Y  x3 b% \( Q7 Y0 E% g1 i4 J$ O; V
  180. 2 ?; j& M2 c2 S! t) N
  181. #~      if panda = 1
    + S5 `' Q/ f. r2 Q# D9 X5 c/ ]/ X
  182. #~        if File.exist('GraphicsSystemCursor2.png')$ r5 e1 _! P( u! {0 K
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    1 f7 X! O. l) c
  184. #~        end#with if File.exist
    ( a6 n9 e6 _& E# a1 f5 B/ Q& T
  185. #~   
    - r1 Z  w$ [! E6 Z! C
  186. #~     else if panda = 2 #with if panda=1- o9 {* U* s7 x  b5 M8 e6 O
  187. #~      
    4 E& L, `7 E) ?0 n) {0 r8 O
  188. #~      if File.exist('GraphicsSystemCursor2.png')5 t4 S8 ?/ t& B8 \" U8 o* a
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')  P5 u0 }. j. A& O& k
  190. #~      end#with if File.exist: z0 r) G0 o( D( w
  191. #~       ' r* T/ @/ X0 n. D: q8 |
  192. #~     else #with if panda=1
    + b3 j. y. }' l; u1 r
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)" Y7 V# N" [# C& I3 T! {* \" x( `
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    4 g% ]8 J4 ^) Z+ v- |
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    " J7 m1 J+ @8 A2 U0 ?+ z
  196. #~     end#with if panda=1
      |4 {- h% u5 {/ h% n
  197. #~     # c0 ?4 k- D. X, i
  198. #~     #with def% b& Z! T0 Y) U  c. ?1 Q5 W
  199. #~   end
    + Z" A1 r. L! |. i  ~" Q6 [
  200. def creat_mouse_sprite( e" l; p# k' A5 h8 }9 o
  201.     @mouse_sprite = Sprite.new% J( ]) v4 t3 |5 \  M; I
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})+ f& X6 P0 K, C) C9 ?* [
  203.     @mouse_sprite.z = 99991 D8 a* @+ M+ ?
  204.     Show_Cursor.call(0)
    8 e  o- f6 ]0 ^8 D, t
  205. end' I0 w9 [# G# ?0 B

  206. . Q6 \9 w5 I0 r# l
  207.   #--------------------------------------------------------------------------
    ' y/ H; @  X. M0 r4 ]
  208.   # ● 更新
    ) q  Y3 H* @* Q+ W8 m, f$ ], a
  209.   #--------------------------------------------------------------------------7 }: V0 u$ g, \+ n
  210.   def update$ w- H. o* r+ d- F+ J5 X3 B
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    $ w' h( z8 y" z) n/ p
  212.     left_state  = Get_Key_State.call(0x01)
      Y5 A0 w. |5 Y" l$ d' x) \
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    " R$ C; f9 g7 Y
  214.     right_state = Get_Key_State.call(0x02)
    $ j6 ?% p  B) J& I# F9 E4 Z
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0+ K5 }0 P! h5 g
  216.     update_double_click! p) e/ A5 }9 I$ z1 n- U
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1" b8 h0 {, k5 I& e
  218.   end& n/ e! b# M7 h: q' X2 h" E
  219.   #--------------------------------------------------------------------------: C5 o" g+ b5 L  Y4 m4 o  T
  220.   # ● 获取鼠标坐标
    3 h5 \6 H* b4 D! f# p2 k
  221.   #--------------------------------------------------------------------------
    $ _2 l$ c. N1 P$ r5 ]' p& S! a9 d
  222.   def get_mouse_pos
    ! `( H$ F! y! X. O0 \
  223.     arg = [0, 0].pack('ll'): Q" A4 L0 u: p# l' l+ _
  224.     Get_Cursor_Pos.call(arg)
    1 G4 Z2 f- l9 O: V4 m) y  b$ v! k
  225.     Screen_To_Client.call(Window_Hwnd, arg)% P6 z. F0 F5 o! u" ~( ]& U
  226.     x, y = arg.unpack('ll')
    . L% ?; H- z( C
  227.     return x, y2 O. H! q  K4 ]/ X
  228.   end
    * k- S" M! }" A3 M# R
  229.   #--------------------------------------------------------------------------
    1 p# F0 u0 A& x" x
  230.   # ● 将鼠标固定在屏幕内! J& K$ @) M" b8 |' v% p
  231.   #--------------------------------------------------------------------------. F  Q# [8 ?: G( C  P
  232.   def lock_mouse_in_screen
    2 t' I! f6 ?& C! s3 `6 u! N2 c# v* _
  233.     arg = [0, 0].pack('ll')
    % l2 M  r( P7 N, x
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    5 p, L3 |3 q% ~! Z  Y
  235.     x, y  = arg.unpack('ll')
    : g% l' |) o, B/ N. ~: H, M. P( D
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))! e5 |/ ]0 ?; I+ R9 O
  237.   end
    $ n% A7 m6 n6 f3 t8 D
  238.   #--------------------------------------------------------------------------/ j6 O/ Y' Y0 T7 s5 p
  239.   # ● 解除鼠标固定- C- i) {, D& x6 Q% m0 a- d
  240.   #--------------------------------------------------------------------------
    % k- T4 ^& I# {) j" l& ^
  241.   def unlock_mouse_in_screen
    / m7 n, H4 Q! A( g& Z
  242.     Clip_Cursor.call(0)
    3 b! e' z( n( U0 k/ n' Y4 \0 l
  243.   end  D; C7 p. Z! k) x9 J7 L
  244.   #--------------------------------------------------------------------------2 V+ b- H3 u& n4 L0 M2 b
  245.   # ● 鼠标双击判定
    $ p( F5 w% f; z! ~) E" n
  246.   #--------------------------------------------------------------------------
    4 i: @& ~: f- j% @) C
  247.   def update_double_click! [/ W8 m9 m' C9 Z# z
  248.     @clicked = true if @left_state == 1
      k5 `3 m9 P4 v, y, A
  249.     if @dk_count  0 && @left_state == 1
    / P# f9 P- |: L8 S) _+ a7 t, c
  250.       @dk_count = 0; @clicked = false& c) w, Z+ U7 B7 L, y. W
  251.       return @double_click = true
    & E+ {2 ]) X3 g" a& l5 X
  252.     elsif @clicked% B: T" l) P5 U0 P% [
  253.       if @dk_count  KsOfSionDbclick_Frame
    - E- X% |$ D% c" P% b! W
  254.         @dk_count += 13 N! U" Y  j, T$ W8 f0 [
  255.       else! O0 i5 _* z# l5 p
  256.         @dk_count = 0; @clicked = false
    . H. A3 V- k: @1 v
  257.       end
    * |+ J; |  i' _6 ?. ]: B; ~) K( N4 A
  258.     end
    6 ^0 b4 c9 J9 j: o) A7 _6 i
  259.     @double_click = false
    ; n4 C( f5 H3 a& j
  260.   end
    8 K6 }+ z( \8 a: m$ G
  261.   #--------------------------------------------------------------------------2 r$ ?2 M( u# K2 s! m# H7 l3 f8 N2 Q( b
  262.   # ● 按键被按下就返回true
    ; R4 c) q# t: g; ?. ?+ [' \
  263.   #--------------------------------------------------------------------------
    5 N2 |. E8 p0 Y. g
  264.   def press(button)
    2 R2 O1 s0 K2 {8 X5 ^
  265.     case button4 r# \5 r* m. [2 z
  266.       when 0x01; return !@left_state.zero* `7 f1 {  q9 A! i7 p3 `0 X
  267.       when 0x02; return !@right_state.zero
    " B- w; I* v1 t9 i
  268.     end- A: F( n' e/ X% H
  269.     return false
    + p2 _, z) Z# \9 M
  270.   end
    1 |. P/ C6 E5 N. i0 C/ ~
  271.   #--------------------------------------------------------------------------# k; q7 Q! B3 `- o& \
  272.   # ● 按键刚被按下则返回true
    : r; a7 D3 U7 ~4 A0 [7 p
  273.   #--------------------------------------------------------------------------, `4 v: {7 V" w
  274.   def trigger(button)
    0 h9 j) [8 A- T& V6 D8 d
  275.     case button
    0 v4 o# Q. K* X* t! C  R, G
  276.       when 0x01; return @left_state == 1
    ( j& b7 Q  _! i) ^5 M/ ]
  277.       when 0x02; return @right_state == 1) w. a6 Y% K5 s" L$ B2 d9 q* D3 x
  278.     end4 Y6 }! U' q' Y, m& {
  279.     return false
      L/ Y* I' F$ r; |- V- S( K
  280.   end' p0 |9 n% t5 Z8 `: b) k
  281.   #--------------------------------------------------------------------------
    ' N. V( h1 D9 N
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    - ?0 {" R! A: V3 @
  283.   #--------------------------------------------------------------------------
    . _, ?7 S& l3 J7 r( x" D8 b
  284.   def repeat(button)" m  [' k$ ~5 F
  285.     case button
    # x( \1 v& @/ b; g8 Y7 l
  286.       when 0x01; return @left_state == 1
    , r$ B, q0 m, U  X6 H3 P
  287.         (@left_state  22 && (@left_state % 6).zero)7 f2 J1 @8 P, D, {
  288.       when 0x02; return @right_state == 1 # X0 g/ H0 t# _+ S3 G/ \
  289.         (@right_state  22 && (@right_state % 6).zero), ?. Z" W6 K7 k: o6 J$ `
  290.     end5 {" R9 K1 W/ L( c" U
  291.     return false& Q& Y1 Y- B! |. t
  292.   end
    ) q+ h: ~' s& N) j2 q
  293.   #--------------------------------------------------------------------------- ]$ v6 k2 P4 L0 j5 a# N: r% ]
  294.   # ● 判断是否双击鼠标! P9 L9 ^9 S/ @# S4 D, x6 h) J! e& k- G
  295.   #--------------------------------------------------------------------------, S: h. {* A, U( ]* a0 c- n$ {. ~
  296.   def double_click7 [4 |$ x9 C( {" t* {
  297.     @double_click
    ; ~7 V: u1 n! J  u7 \6 {
  298.   end& o, Z( ?& D2 Q6 u7 l( B% y' V# c2 V
  299.   #--------------------------------------------------------------------------4 Q3 R0 @( e- b- T, \4 v% ~0 s
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    ' @; v( D: q9 G6 i) G: r# L! V! t4 F
  301.   #--------------------------------------------------------------------------
    : x( p% I$ v% P$ Q9 Q
  302.   def click_count6 F# b1 e! Y( ]% D' {% L" q8 b( N
  303.     @ck_count! h, w! b" C1 q  }' Y+ j
  304.   end
      p+ \) n8 h" C" V0 g
  305.   #--------------------------------------------------------------------------' L: A5 B1 C6 M1 F! Z  V1 Q  k
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    4 {, L& \) }4 u/ f" H9 P
  307.   #--------------------------------------------------------------------------1 W; g3 j+ C' Y6 P! d. h/ t
  308.   def left_state- h/ U6 ?: G2 {- A' a, T1 I% H
  309.     @left_state
    & \$ Z. [! M% f4 z
  310.   end
    : @$ }: j( P, G; m1 }1 Y% F
  311.   #--------------------------------------------------------------------------
    - q8 S+ l% h+ }7 m! c. r0 A. w
  312.   # ● 获取鼠标的x坐标
    7 j7 S2 ^% ]+ [% m
  313.   #--------------------------------------------------------------------------
    9 z7 y: z& F/ H. N# f
  314.   def mouse_x
    7 _! }3 V# x) S9 F+ n
  315.     @mouse_sprite.x( ~. h. d: O' D1 J  N2 D
  316.   end  v; O. _6 a4 t+ g$ C
  317.   #--------------------------------------------------------------------------8 {! W9 u/ q2 u2 V/ X% C& ~6 V
  318.   # ● 获取鼠标的y坐标6 i& s+ u: h3 Q+ n/ k3 q  O
  319.   #--------------------------------------------------------------------------" D3 t# v4 o, s1 ^
  320.   def mouse_y8 e/ o: m- j2 v
  321.     @mouse_sprite.y! B7 _) c4 E* {3 _  p# H* Q- u% ~/ P
  322.   end  L. g" m$ o3 d$ \' ?6 e
  323.   #--------------------------------------------------------------------------$ T( O' I1 d6 j
  324.   # ● 设置鼠标坐标
    ( z  P' j/ N  J8 J# e* [
  325.   #--------------------------------------------------------------------------- ]* Z2 {: G' s& u; g2 G: T+ L
  326.   def set_mouse_pos(new_x, new_y)
    9 |  E. `8 S5 P2 p' n0 ]6 ]
  327.     arg = [0, 0].pack('ll')
    8 n3 S4 }; z' _1 J# Z3 Y3 N" M
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    * H  |; P7 u3 h# }9 z
  329.     x, y  = arg.unpack('ll')0 Q7 K( |, L! ^5 L0 o7 l- y: k
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)+ x( a6 g3 @% g* |; T, v* a" Z
  331.   end9 v: V) n' o5 C9 e7 F
  332. end #end of class  self , D1 h+ [# ]3 k& S/ ~* u$ A

  333. , u& A, d( g' E: ~- ^2 i
  334. end% L  h; y, K' T% N. Q5 ?
  335. 2 I& s+ b; q$ h8 }8 Q* Q& I
  336. #==============================================================================+ a' s& a( ^$ y6 b5 \$ k: w
  337. # ■ SceneManager
    3 j% L6 T7 j" a
  338. #==============================================================================
    $ M, T7 c% Z- {9 v/ f
  339. class  SceneManager
    7 e! B. Z; S$ ^! c
  340.   #--------------------------------------------------------------------------9 S9 Z1 e6 `5 o: E
  341.   # ● alias
    + K$ |$ y6 F/ m
  342.   #--------------------------------------------------------------------------! q* ]! [, ~- F6 Q+ R
  343.   unless self.method_defined(sion_mouse_run)
    2 g! U! {+ g+ u0 \7 y, X
  344.     alias_method sion_mouse_run, run$ P9 \0 S( u8 o. y
  345.     alias_method sion_mouse_call, call$ ~# f6 U) [. z& u
  346.     alias_method sion_mouse_return, return" n" M' S$ I  _$ A* o
  347.   end
    ; j8 ^  A' Y! n7 o" S3 l
  348.   #--------------------------------------------------------------------------
    , a" C" ^/ O, g. r) l% H
  349.   # ● 运行
    2 T0 n  r) b' ?8 o- e- _" f" K
  350.   #--------------------------------------------------------------------------* Z+ b2 r" R2 a  b& }) d
  351.   def run
    ! j! h: p  d7 X; w7 s, A/ B
  352.     Mouse.init: w: }( Z6 l6 X2 [* t4 c, C) s
  353.     sion_mouse_run6 i! ~9 e& P- R
  354.   end
    1 Q, c% P* M- O5 ?* W& P6 f: D: ]
  355.   #--------------------------------------------------------------------------' t5 \) {( X  I
  356.   # ● 切换$ r0 b- u3 e2 U! j4 B7 L
  357.   #--------------------------------------------------------------------------  z9 U* g7 Y6 X, u
  358.   def call(scene_class)3 a' v8 S- n! P' J
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map), D: C& c6 U5 ]
  360.     sion_mouse_call(scene_class)3 c4 g& z- d& W( Z- U" W" U
  361.   end: ?1 ~/ R3 _, G( D# X7 O
  362.   #--------------------------------------------------------------------------4 g+ L  I: w, {5 C
  363.   # ● 返回到上一个场景
    7 I2 o: l6 b1 v
  364.   #--------------------------------------------------------------------------: ^! [8 t& w. F7 k
  365.   def return
    5 I( h9 G8 x1 v4 g. ]
  366.     sion_mouse_return% o  I! _* e7 F, X$ }' J
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    ! F2 u, j: c6 J; ?: w
  368.       @scene.instance_of(Scene_Map)
    + o; q. Y- r: B4 B: @. ^+ A
  369.   end9 i( e! W. A- _6 n  J
  370. end" T# v6 _& Y- ~0 w2 y0 K% |
  371. 8 F5 K; }% C4 }& d
  372. #==============================================================================( w9 s/ y  z( @, f" N7 i. Z
  373. # ■ Module Input& O" }4 d1 h1 _7 Z- x5 o
  374. #==============================================================================# a; |/ c$ Q" i  {/ Y+ Z
  375. class  Input
    7 l4 w! w* V; D+ N, Q9 ~0 e1 O
  376.   #--------------------------------------------------------------------------' L& V2 Z1 e0 H0 Z9 N
  377.   # ● alias, E3 ~% J, ]% |. z& L! I# V$ a9 [
  378.   #--------------------------------------------------------------------------3 @, H0 `9 p4 g) V, c% X4 X6 q
  379.   unless self.method_defined(sion_mouse_update)) R/ Z9 ^$ r# }) c0 v- s$ |1 I
  380.     alias_method sion_mouse_update,   update
    4 o# o% U+ `1 @0 M, u
  381.     alias_method sion_mouse_press,   press
    + d& X1 b$ v+ {# Y) S9 ^( k
  382.     alias_method sion_mouse_trigger, trigger% b* C0 ^" \& u
  383.     alias_method sion_mouse_repeat,  repeat0 F0 p, P- Q) N- N4 K- _
  384.   end+ D: r2 Z% h- G
  385.   #--------------------------------------------------------------------------
    % D  ~8 j6 [% ]
  386.   # ● 更新鼠标9 c, [0 W  {2 g8 N2 C
  387.   #--------------------------------------------------------------------------
    ) J# A- ~! G3 ]7 i
  388.   def update3 o! ^0 n1 W+ e. g
  389.     Mouse.update5 t, u; q8 d9 R! B
  390.     sion_mouse_update" x4 n) i& {; N, K7 {% ~4 K* r
  391.   end+ h  }* z; i" a" g
  392.   #--------------------------------------------------------------------------
    4 v5 n* K* T, B
  393.   # ● 按键被按下就返回true
    7 u+ w6 F) g7 M/ H9 J& T
  394.   #--------------------------------------------------------------------------1 \2 O+ g" D& \
  395.   def press(key)
    + Z) G8 g' P* `7 t$ k! [+ L
  396.     return true if sion_mouse_press(key)0 W9 Q6 B  _* w5 M7 N: @; M5 ^$ K
  397.     return Mouse.press(0x01) if key == C# l+ a* g& ?- j5 n: t( @7 v
  398.     return Mouse.press(0x02) if key == B
    3 j; ?$ c+ \, P7 t
  399.     return false, J$ ~$ v" o: D9 E
  400.   end3 j' Q! S, l  K1 U8 s
  401.   #--------------------------------------------------------------------------  D/ P! s0 I* R9 b
  402.   # ● 按键刚被按下则返回true
    7 v4 B% ?2 F5 v1 c
  403.   #--------------------------------------------------------------------------' d( ^, b: i, q
  404.   def trigger(key); e6 x0 \2 I1 G* @3 `9 d! C) w
  405.     return true if sion_mouse_trigger(key): b. q. H1 q  t% {" d% C0 d3 y
  406.     return Mouse.trigger(0x01) if key == C9 `8 B, }: K* k- I( u- t) W
  407.     return Mouse.trigger(0x02) if key == B& I8 W( Z% ?. p+ l0 o9 {0 Z  F+ S$ ~
  408.     return false
    " s# M4 R0 j5 T
  409.   end
    . e, t7 l) g4 g
  410.   #--------------------------------------------------------------------------
    $ \+ f+ Y5 Y' @/ E* ]
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true; P3 f1 K' X) E- |
  412.   #--------------------------------------------------------------------------
    - U; p6 q) ^, v6 b7 ~6 |. S) P
  413.   def repeat(key)! R# V3 q" X- J6 @$ z
  414.     return true if sion_mouse_repeat(key)3 O$ S, y. c8 b/ H( J6 H: s
  415.     return Mouse.repeat(0x01) if key == C
    : A% J. S! m5 U; D
  416.     return Mouse.repeat(0x02) if key == B
    , s* o% l3 k1 r6 [7 I% D8 s; f5 f
  417.     return false
      u* Y) v& f: X& O1 o
  418.   end
    + Y) ~2 C7 H+ U+ v
  419. end
    : e0 ?7 O6 z; p& j

  420. ) ^/ X6 ?( b: r; h9 `( k

  421. & v. {& a2 M1 s" f
  422. #==============================================================================
    $ Y- Z7 [7 [9 V5 `
  423. # ■ Window_Selectable( G$ W  b# d* n0 U& o4 e4 Y& W/ T
  424. #------------------------------------------------------------------------------
    9 S) ?9 m4 J$ f) \1 k1 {4 L
  425. #  拥有光标移动、滚动功能的窗口
    : P) g! [( Q, {
  426. #==============================================================================
    # t5 r0 k, a% ?+ b4 m- v5 e  `
  427. class Window_Selectable, x5 m, P+ O2 c/ U0 _
  428.   #--------------------------------------------------------------------------. D) ]* t7 D# a7 j) {4 f
  429.   # ● 初始化
    ( x% \1 `% Z' [% R9 H' N, b8 G; ]
  430.   #--------------------------------------------------------------------------
    9 a5 d5 q* }" L4 k# H* G+ W9 x7 B
  431.   alias sion_mouse_initialize initialize
    7 z* T, }; J% V
  432.   def initialize(x, y, width, height)
    6 y% t1 G, `. \7 M( G6 S+ s/ f
  433.     sion_mouse_initialize(x, y, width, height)
    ' X/ I) B# @2 z
  434.     @move_state = 0# G+ _2 O+ v/ f7 v4 C; l8 M
  435.   end
    # a. ~: Q; R  [. B) B1 u# b
  436.   #--------------------------------------------------------------------------, c" O( `9 j4 m0 h( ]
  437.   # ● 更新
    ) ^  t, S$ K: P1 {
  438.   #--------------------------------------------------------------------------5 N) ~% Q6 k% _& h; m
  439.   alias sion_mouse_update update
    ; E; R7 Y) a, D, A2 X6 f; w9 f/ g
  440.   def update' i  _! z3 n2 e1 Y
  441.     sion_mouse_update
    8 T! h# v# v7 H+ ~
  442.     update_mouse_cursor
    0 G0 r/ g" o+ u2 J
  443.   end0 s9 X' M; g, ~' c7 }' V3 e5 E
  444.   #--------------------------------------------------------------------------
    # Z# v! X! t9 D! O7 A. F8 m" X2 ^2 L
  445.   # ● 启动后设置鼠标到index位置. P( O0 N- f$ r. d
  446.   #--------------------------------------------------------------------------! v) Q; {- [9 m9 K  J" ^% I' H
  447.   def activate$ e- D! y( R$ G% f& J
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    2 `! p: U+ |) }9 c9 w" k4 h% R! u
  449.     super6 }7 d# O3 L; i: n
  450.   end5 r4 q& E! p; t( y; e
  451.   #--------------------------------------------------------------------------% h6 n0 u9 M: _/ V" j- e7 J
  452.   # ● 更新鼠标和光标的位置
    ( {+ K* e# d6 J' \( _
  453.   #--------------------------------------------------------------------------3 P6 ^* a1 z0 o
  454.   def update_mouse_cursor
    9 x: i/ A( f' ?" W6 ?: Q# _. S3 [
  455.     if active
    - c3 @- |& ^. u6 K* T
  456.       if @need_set_pos
    , Y+ E3 b0 F- b) I: T
  457.         @need_set_pos = nil5 X$ y7 o- F/ v6 U8 ~  D( p5 L! S
  458.         set_mouse_pos
    6 Y! J" y3 \+ u8 @. J# J$ V
  459.       elsif cursor_movable
    ) T# L- h# ~7 \/ D
  460.         Input.dir4.zero  set_cursor  set_mouse_pos( f& [* t; d4 w( K
  461.       end+ p4 c; t+ y- E  R8 L! Z
  462.     end
    6 O& x0 {6 Z/ T( P2 O, i; U$ H
  463.   end
    1 a, r3 n' V9 d1 p% Y( K1 Y
  464.   #--------------------------------------------------------------------------! m5 X4 ^7 m. m7 S# `" _
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    3 T/ }8 o0 F+ k- b* g8 `+ B( s6 Y
  466.   #--------------------------------------------------------------------------
    , u1 ~$ K6 W  [
  467.   def set_cursor) L( Z1 `+ J% J( w8 _$ E1 B8 ?
  468.     mouse_row, mouse_col = mouse_window_area0 x. w, |/ F( e/ |. I
  469.     if    mouse_row == -1  R% j! e) h: G0 N3 A
  470.       @move_state += 1 if need_scroll
    ; k2 r- Z- j  w5 U2 @5 }4 v# g
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand* d0 T! |+ \+ L4 L& y
  472.     elsif mouse_row == -2
    7 z1 I) U6 V1 e' u# o9 ~# Y$ A
  473.       @move_state += 1 if need_scroll( ]. r/ Q; d5 |
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ' U; d% c1 R1 b! n
  475.     elsif mouse_col == -1
    3 D: V% k6 O7 q. G2 P" z0 ?% `
  476.       @move_state += 1 if need_scroll9 ]# p( x) X: V4 ~) J
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand/ Y' |% C, Z6 Q7 h$ o* ]; {
  478.     elsif mouse_col == -2
    4 ?5 }: Z  ^7 ^- t
  479.       @move_state += 1 if need_scroll
    / E% f, _/ l5 K( k5 V
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand" K$ B$ m% @% o+ n3 C
  481.     else5 w7 k# ~- Z5 l( W* w, D) H* x: {
  482.       @move_state = 0. ], _9 X$ v- L2 ^2 I9 J2 n4 b- M
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col, A# s& g& ?; Z" B, w3 B
  484.       select(new_index) if new_index  item_max && new_index != @index
    ( u5 g( m0 V3 X6 D
  485.     end$ t7 y/ |% T" l) d4 v8 g( e
  486.   end" ^0 H$ @# b$ n) h; a7 f
  487.   #--------------------------------------------------------------------------- l! M, |& W1 J2 F! k7 ~- @( ~
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    . S1 d- T1 }8 b, l4 e; i& y, }. P
  489.   #--------------------------------------------------------------------------7 s: d. i4 a1 \. H
  490.   def mouse_window_area5 K5 H6 ]. H) E- A. P
  491.     if viewport.nil # necessary!
    9 E; t- A7 E! g
  492.       vp_x, vp_y = 0, 0* s6 s1 @6 O. q: q# o
  493.     else
    8 A/ G) C( o: h
  494.       vp_x = viewport.rect.x - viewport.ox% o$ O# [( u3 g; g. s5 w0 s0 s4 |0 {
  495.       vp_y = viewport.rect.y - viewport.oy
    + ^8 r/ T" p3 M" ^1 u6 y; a( J' \
  496.     end2 o, S) \  V% V( {$ T+ P2 s
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y! {( T1 v( v9 y5 Q9 d8 F4 q
  498.     item_x1 = vp_x + x + standard_padding
    " j' Y5 m/ K/ v9 z0 o, _- z5 B3 M
  499.     item_y1 = vp_y + y + standard_padding' J6 ^: v; [) z: S& g3 \# k3 J
  500.     item_x2 = vp_x + x - standard_padding + width0 A1 x3 q- m0 Y" u& o  [% l
  501.     item_y2 = vp_y + y - standard_padding + height
    6 K0 B2 N3 F- D3 t. h  ~
  502.     if mouse_x  item_x1& F. A  U) x  l  Y
  503.       mouse_col = -10 V8 b# `7 T! A$ n/ _% z' w
  504.     elsif mouse_x  item_x28 E% c7 C$ K. f, B4 ~; @
  505.       mouse_col = -2
    ) r0 M+ y# T' n0 w- ]
  506.     else
    / ~& d, ]& w1 b1 j# v, Q  n5 E
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)" I9 y1 a' T! }7 D. ~8 u" F) q0 {
  508.     end4 K/ c- A' Y4 b  U# ^' V# @
  509.     if mouse_y  item_y1
    ' C- T$ D/ ^6 A6 T  @
  510.       mouse_row = -1
    2 C9 C/ l+ Y% B2 e! X& D* Q
  511.     elsif mouse_y  item_y2
    + Z; M. G  w2 w/ `
  512.       mouse_row = -2
    " e0 j/ a! M- ]8 B) t# w1 E' ?
  513.     else
    4 G9 k/ M' L) L% _$ c4 @
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    9 X4 _& {, ^7 m# V+ F! {/ G9 _7 v
  515.     end0 n/ [; s' z: H
  516.     return mouse_row, mouse_col1 J2 h9 A3 |% I" u
  517.   end
    3 U$ l* ]( q7 ?. ?; w
  518.   #--------------------------------------------------------------------------, S, T! I9 Y& R9 q2 b
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    5 G7 S0 E1 X# o; w3 N4 j4 [
  520.   #--------------------------------------------------------------------------
    # Z8 ^1 J* y/ o# f6 a% u$ s
  521.   def set_mouse_pos
    : \; E, A4 }4 a" \: \. p6 Q
  522.     if viewport.nil # necessary!
    3 B) g3 L4 z/ D, m2 U0 _
  523.       vp_x, vp_y = 0, 02 b2 E: L: A8 _3 Q3 {
  524.     else5 d+ |/ D' |' V4 x  b
  525.       vp_x = viewport.rect.x - viewport.ox
    ' p( k1 p. h; D7 P0 z- X, E
  526.       vp_y = viewport.rect.y - viewport.oy
    & x6 p# z/ ^: M0 S5 U0 A, e
  527.     end
    ' ~- L4 a6 o/ X8 Y  Y/ o7 V
  528.     item_x1 = vp_x + x + standard_padding # j/ R4 B+ o7 H
  529.     item_y1 = vp_y + y + standard_padding1 r' o/ l* v2 g; ?1 ?
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    + F: }* r- \+ S) u5 m8 `$ }
  531.     row = get_index  col_max - top_row* z+ y# a+ {% w5 L
  532.     col = get_index % col_max0 I; y5 S4 S# D5 ]! Y( g9 y; d2 D
  533.     new_x = item_x1 + item_width  (col + 0.5)6 q4 ~' y) ?; |) H9 @  X
  534.     new_y = item_y1 + item_height  (row + 0.5): I, R+ T. F. c; w% a2 S* @
  535.     Mouse.set_mouse_pos(new_x, new_y)
    $ \; |- q6 q6 @) A) n9 s0 M* f
  536.   end
    1 ?5 E: e) H5 P6 i8 x! J5 Y- p; V
  537.   #--------------------------------------------------------------------------
    9 B" K" p0 t$ O/ e& L" J, U# `
  538.   # ● 判断菜单是否需要卷动* H$ U3 s6 a; R" M, z$ D
  539.   #--------------------------------------------------------------------------
    0 f1 B0 m# Z, w. [
  540.   def need_scroll: s* i. Q# e3 a4 A& I
  541.     item_max  col_max  page_row_max
    : e% w+ p/ Y  ^6 m5 O8 z
  542.   end
    . U+ A: j% M' I' T, O0 V# E2 p9 e
  543.   #--------------------------------------------------------------------------( A0 i# v; i, [  p
  544.   # ● 判断是否为水平卷动菜单+ j% l, w/ h, D# u6 B' E- k( ~- @
  545.   #--------------------------------------------------------------------------
    - [' ~% c% U7 w  F/ \
  546.   def is_horzcommand
    1 y: E) }$ v" K% G, T6 ?
  547.     return false& z/ D+ C, [: U( F0 |% y& ?: y
  548.   end
    & a2 x- v: F$ j% b+ @
  549. end+ b8 _/ Z1 F; E0 n9 e* h! g

  550. 1 ^& ^! }9 Y4 i3 l
  551. class Window_HorzCommand) a' C  a% e$ i0 E% J% S: f
  552.   #--------------------------------------------------------------------------
    ; r3 n7 w% U- C( \) w
  553.   # ● 判断是否为水平卷动菜单+ ?$ g0 ?& {4 _4 C! `
  554.   #--------------------------------------------------------------------------
    , C5 q9 ]7 G- q( @* P( f
  555.   def is_horzcommand; t' c' Y$ n2 X8 M. U# x
  556.     return true
    $ o. e2 W3 D5 W2 B
  557.   end2 b: V7 A. J9 ~  {
  558. end
    + r5 n8 p  G. N$ g" P" V4 h

  559. & J7 }& ?0 T6 a+ i. P3 R) h; y
  560. #==============================================================================1 D: E2 d- Y% i: ~7 l3 n/ W) u
  561. # ■ Window_NameInput$ |! s/ s( a  ~+ ]0 z1 h0 q* a9 ?8 N6 f
  562. #------------------------------------------------------------------------------
    " [  n! I" e/ Q. K+ h2 ]+ X
  563. #  名字输入画面中,选择文字的窗口。
    % E1 q# r" D: S2 e" P- W6 B8 G
  564. #==============================================================================
    % L3 v0 O: K/ k
  565. class Window_NameInput
    5 b1 m& }* |( Q: ]7 w* W. U
  566.   #--------------------------------------------------------------------------: ^7 L: a8 i5 v/ A: c
  567.   # ● 设置列数
    $ X  q/ O4 ~' ?, X
  568.   #--------------------------------------------------------------------------
    % D+ L1 K8 q* U# a4 c% z6 u
  569.   def col_max! S* f. r+ p  M. r
  570.     return 10- T/ Y/ _9 r8 R, V; F
  571.   end$ H0 Y" Q. [; `1 ^! J: F
  572.   #--------------------------------------------------------------------------) t1 U4 v' t9 Q! g
  573.   # ● 设置填充的Item个数
    & m: T, r0 V  c9 t  ]/ ]/ g+ F
  574.   #--------------------------------------------------------------------------7 o  n0 A& A% B) n+ P" ^4 y& ~! z
  575.   def item_max5 s7 L0 a5 y3 ]4 Z5 u9 I1 i
  576.     return 90& i2 n$ f0 |$ Y9 \& R/ w
  577.   end
    % d, ~- H2 h# C$ u0 j
  578.   #--------------------------------------------------------------------------
    ' z1 O8 D" v5 |1 n
  579.   # ● 设置填充的Item个数
    - T( ?: I" }  V9 z# G+ r3 G
  580.   #--------------------------------------------------------------------------
    1 w$ e/ S* ~4 h$ L* E7 p2 R
  581.   def item_width
    6 }  B5 \! c4 z$ J2 i* e' s: a: Q( y8 ?
  582.     return 328 m( H8 S! ?- Z. g( g
  583.   end4 O& K# r* X* `) n3 u' p8 ^) i
  584.   #--------------------------------------------------------------------------9 {+ G: L2 N  p/ j$ L7 G6 ^6 M
  585.   # ● 判断鼠标位于菜单的第几行、第几列* Q% h1 ?0 n( x4 V+ Y+ j) x
  586.   #--------------------------------------------------------------------------6 G! [( H/ o# E/ O- c- D$ U/ f
  587.   def mouse_window_area
    ' N3 @" @4 x$ y
  588.     if viewport.nil
    * l) y& H& M! {1 _; t
  589.       vp_x, vp_y = 0, 0
    ; Q& R9 i7 T# ]1 ?) q- R
  590.     else8 a* t# {1 e, a  e7 T' J- f3 S
  591.       vp_x = viewport.rect.x - viewport.ox
    " P, t0 p  M2 R% D
  592.       vp_y = viewport.rect.y - viewport.oy. a/ H" D. e- m! O& L5 H
  593.     end0 z' F4 W- v  m3 y& m
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y: f! h0 ]' b1 ?* E- r
  595.     item_x1 = vp_x + x + standard_padding
    0 \5 v4 P2 U4 j0 z
  596.     item_y1 = vp_y + y + standard_padding
    2 Y9 a# s  C8 F: \
  597.     item_x2 = vp_x + x - standard_padding + width8 ~) A; J0 F# S# ?
  598.     item_y2 = vp_y + y - standard_padding + height& C' D2 L: k  I; `8 y
  599.     if mouse_x  item_x12 K4 A, f& Y" n3 }1 L0 r: O/ s
  600.       mouse_col = -1
    & t. y% f4 Z" s: M
  601.     elsif mouse_x  item_x2
    % t$ S# I; q" o/ m+ B
  602.       mouse_col = -2
    " }( v& p( c' Y
  603.     elsif mouse_x  item_x1 + 1607 X8 I3 y7 o2 Q, ]0 g
  604.       mouse_col = (mouse_x - item_x1)32
    # ^, A: M! ~# y+ `2 {  S4 G! P
  605.     elsif mouse_x  item_x2 - 160
    4 u2 I% r9 }" @% G. I" {; E3 R
  606.       mouse_col = 9 - (item_x2 - mouse_x)320 i2 a0 h  {8 y  w" E7 Y
  607.     else
    * Z/ g4 _" i$ k8 d/ Z# S6 }
  608.       mouse_col = mouse_x  x + width2  5  4
    + f% R. r  `; p; D* h
  609.     end1 |* o: _. Y1 m" N
  610.     if mouse_y  item_y15 M. y5 J7 M8 x- z0 d
  611.       mouse_row = -1
    # R" G. ]* x5 m5 p
  612.     elsif mouse_y  item_y2
    # H  E+ x  T8 S& b6 \
  613.       mouse_row = -2
    + b& A! _5 L" y
  614.     else6 @9 Q  [# W" ^+ D0 J8 N: S: }
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)5 K8 a* g1 w+ T6 n6 Q
  616.     end
    # y8 |+ |' A3 Q6 v$ p' @
  617.     return mouse_row, mouse_col6 M7 d8 N8 Z4 z& r; r2 V5 H; S* ]
  618.   end9 B. F# {+ e; K7 F- C
  619.   #--------------------------------------------------------------------------
    3 A# ~+ d6 S, n; J
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置: Z) }& @) g+ [! J& g: {, \
  621.   #--------------------------------------------------------------------------* U' K; q4 ]0 W) c
  622.   def set_mouse_pos5 B  ^) p7 ?* P) L5 L8 i; x# e
  623.     if viewport.nil # necessary!7 |2 ?6 [# F' f0 J: y# k
  624.       vp_x, vp_y = 0, 03 Q0 V7 a( ?; w3 F* O
  625.     else
    8 q7 D* O! D; I' {2 N0 ?/ {" L
  626.       vp_x = viewport.rect.x - viewport.ox3 d7 i5 z- M0 |0 W
  627.       vp_y = viewport.rect.y - viewport.oy
    ! L. g* G3 g- I0 f! x& l9 w
  628.     end+ M" L  |! ?1 _. J
  629.     item_x1 = vp_x + x + standard_padding
    2 B% @/ y+ a% r& t& o2 K# K  \
  630.     item_y1 = vp_y + y + standard_padding! s+ Q/ P5 J3 G2 ~1 o7 v8 `+ o1 E
  631.     get_index = @index  0  0  @index . q) l+ B" S# F9 N
  632.     row = get_index  col_max - top_row$ S; a8 v1 o5 @3 a( t
  633.     col = get_index % col_max8 [8 }' D& a  @$ |; g
  634.     new_x = item_x1 + item_width  (col + 0.5)- ~1 g8 H7 _' s$ c. j# F. i$ A
  635.     new_y = item_y1 + item_height  (row + 0.5)1 P! G7 z# q9 h) ^" r6 c
  636.     new_x += 14 if col  4$ v/ d  x" w" f; M! p3 y- j0 V
  637.     Mouse.set_mouse_pos(new_x, new_y)
      e; `2 o. I/ p' H! K. m
  638.   end
    4 b4 o; F4 E" W2 D. ^* }6 X
  639. end2 i4 q% t3 B, ]. d1 A. W6 {
  640. " n+ y7 r6 O" _. _9 v4 e! G
  641. #==============================================================================
    6 {1 ^- I4 `5 S3 w
  642. # ■ Window_NumberInput+ `$ J, p! H- A$ G
  643. #------------------------------------------------------------------------------. d5 d1 Q+ z1 i
  644. #  重写了数值输入的方法以适应鼠标
    . f" @: p( L5 \' E5 a/ T# ?
  645. #==============================================================================
    , n# G& E$ |$ ]/ l  _
  646. class Window_NumberInput  Window_Base
    ) J/ T; P/ Z8 x& |5 `
  647.   #--------------------------------------------------------------------------
    5 z6 w( V8 d; h: \8 ~
  648.   # ● 定义实例变量
    * C" A3 Y4 L& Z+ N
  649.   #--------------------------------------------------------------------------, p3 v+ g* q  Y8 X+ j% l
  650.   attr_reader extra_window
    ( g0 X# \, P9 C& [
  651.   #--------------------------------------------------------------------------' S& ?: w# b1 x" p
  652.   # ● 初始化
    : N  `% m7 |7 H/ \  D
  653.   #--------------------------------------------------------------------------
    9 p6 Q. }: k# L8 c9 h- M; S6 B
  654.   alias sion_mouse_initialize initialize
    + ~+ H$ h7 F9 l2 S1 L; n6 ]5 ?) |
  655.   def initialize(arg)
    " j) p% ^* T& P5 z, q
  656.     sion_mouse_initialize(arg)
    / o( M4 m! ]5 x/ v
  657.     create_extra_window
      v5 a. U  e5 X0 W8 m4 j4 u3 }3 c/ H0 p
  658.   end
    8 Y! [/ S, ~/ N  o# S
  659.   #--------------------------------------------------------------------------# l+ w% }. ^! u* {+ V* |" W$ q1 M
  660.   # ● 启动
    ( n/ V+ z7 V: W1 W& @" a0 y' A
  661.   #--------------------------------------------------------------------------# T' }+ p. u2 ~4 }& e
  662.   alias sion_mouse_start start
      C- r2 \8 E0 d+ L
  663.   def start, [/ ]7 j& }) d. H6 Y3 }
  664.     sion_mouse_start
    $ d# ^, }$ x9 c0 R4 H0 B( t
  665.     deactivate
    3 j& X# U' W" ?( Y) I
  666.     extra_start
    # {: R" I- ]  t5 w
  667.   end
    3 `3 ?% H; z: g+ f# U/ F: q1 x
  668.   #--------------------------------------------------------------------------. Q3 o. ?8 Z) o* H7 W. x
  669.   # ● 创建新的数值输入窗口) Z/ c: S3 v" T' N9 N1 g
  670.   #--------------------------------------------------------------------------
    + w! y" D* i' @) k
  671.   def create_extra_window0 ?7 B" m. F( w3 Z
  672.     @extra_window = Window_NumberInput_Ex.new4 ]6 C9 M* F3 s: r# I* m8 {9 z
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
      _. o( w8 P, L5 ~
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }+ e# j$ u1 b) {0 p
  675.     @extra_window.index_proc   = Proc.new {n @index = n }3 q7 g+ W; n1 C/ V" Y1 _  w1 K
  676.     @extra_window.close_proc   = Proc.new { close }. c4 y+ [2 u8 m9 U
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    & u4 e% T* W0 f; L, G3 u
  678.   end
    ) \; D+ z8 b  r: P
  679.   #--------------------------------------------------------------------------; e0 ], |( v7 s" c# c
  680.   # ● 激活新窗口
    ' s! d" c8 {- {! b. x) F3 Q
  681.   #--------------------------------------------------------------------------
    2 H7 O( V& y0 z/ z  E  n$ v. K" z9 E0 }
  682.   def extra_start
    5 W, j7 a. }2 p- B
  683.     case $game_message.position1 e# N8 P: h; j$ F1 M+ o& I6 ^
  684.       when 0; @extra_window.y = y + height + 4
    ' D, w+ l( X- }' T0 v8 y
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8% A! U, P. i+ d. o" K- j
  686.       when 2; @extra_window.y = y - @extra_window.height - 4% Q9 t; k! I( r4 r. d8 Q: v5 R
  687.       else  ; @extra_window.y = 86 l) d* T( ^- m9 ^2 [$ R; q8 E
  688.     end! l1 [) ?- {4 Q. J% e
  689.     @extra_window.variable_id = $game_message.num_input_variable_id+ z0 h# }) I" C8 u* C
  690.     @extra_window.digits_max  = @digits_max$ l* U; x, u% p$ C# Y2 v
  691.     @extra_window.number      = @number7 e( o: Q* N" ]- [
  692.     @extra_window.open8 [) O% d3 k3 W5 X6 m0 M- W
  693.     @extra_window.activate, P7 _0 t; y5 W. [# |6 J- n
  694.   end" v  k% z- ~( S$ c; F, W$ c3 s
  695.   #--------------------------------------------------------------------------0 z0 ~- W( ]6 T' D! H  f& p5 q  |/ T
  696.   # ● 更新0 d9 c* |& B1 |( Y. t
  697.   #--------------------------------------------------------------------------
    2 J% `* I2 l8 H" x9 S/ W4 a
  698.   def update
      j8 e3 |4 G6 s' X9 i8 m
  699.     super9 }- ?3 C  Q8 ^. v
  700.     @extra_window.update, z' `/ c8 b/ a3 d7 B2 R
  701.     update_cursor
      D  m! d' P2 _( j2 I4 P
  702.   end* T" h: b" A& {1 R* `
  703.   #--------------------------------------------------------------------------
    ) y! ?  U2 X% d
  704.   # ● 关闭窗口
    0 l1 |7 E+ n0 v4 j8 E' w6 R
  705.   #--------------------------------------------------------------------------
    , {7 _7 k" W5 i. P5 W: P; l' A
  706.   def close
      j! u0 o% O3 W
  707.     super5 k+ o7 e; d1 O% [, Y! Z3 W3 v
  708.     @extra_window.close# k$ s2 u6 e! P
  709.     @extra_window.deactivate2 S6 U$ R; x/ E$ v( V# |
  710.   end
    3 c3 A  p9 B. A( B
  711. end
    $ g  e% Y2 p+ f3 s

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

  2145. ; N; k0 H+ W: L7 U
  2146. #==============================================================================
      O, Q, `& u; c. I; q3 T2 n: f
  2147. # ■ Game_Map5 c% C" t4 r+ |: x
  2148. #------------------------------------------------------------------------------( R% C3 N6 g4 a+ g
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
    $ L- P3 X, s  P( K% M
  2150. #   本类的实例请参考 $game_map 。7 K# N" N2 ~5 z
  2151. #==============================================================================
    4 Q3 P6 p. F( F" n6 q
  2152. class Game_Map1 K, H& q% d: Y9 \9 h
  2153.   #--------------------------------------------------------------------------1 L" z! h) O3 l0 S: @, X
  2154.   # ● 定义实例变量
    7 h4 k, _; R+ \6 m
  2155.   #--------------------------------------------------------------------------1 ?# w7 F: O1 y: z3 W' h
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据; V1 e7 V% ~4 r0 a5 y8 v* A
  2157.   attr_reader mouse_map_y # 同上9 T0 }# {, s  a0 I9 y
  2158.   #--------------------------------------------------------------------------0 ~+ |# v4 e" Z/ _
  2159.   # ● 初始化对象5 h3 P/ T4 Z  v& d) o0 s6 _
  2160.   #--------------------------------------------------------------------------8 W7 j* A7 a" ]- Y
  2161.   alias sion_mouse_initialize initialize6 n! S* B; m' u1 a* p
  2162.   def initialize( O. C( X* C4 Z3 }3 [
  2163.     sion_mouse_initialize' p& z; ?  E( Q% Q) F
  2164.     creat_move_sign  ###  h" H. }& _$ i: L
  2165.     set_constants+ A) J3 Y6 \' n0 |5 k/ k
  2166.   end
    : Z! Z) s( s7 J2 Q4 C
  2167.   #--------------------------------------------------------------------------9 r) w1 F1 p+ X% b
  2168.   # ● 更新画面
    " H( v1 D2 e/ Z2 D) _! h- F9 K4 x
  2169.   #     main  事件解释器更新的标志
    9 H" l# m, N1 N8 A: Y$ ^; [
  2170.   #--------------------------------------------------------------------------
    ! {! k# `3 M' w
  2171.   alias sion_mouse_update update' }9 e1 D$ \( S9 X9 \  F+ w  i) F
  2172.   def update(main = false)
    + l5 K2 m: H/ M, V8 l5 x+ i
  2173.     sion_mouse_update(main)+ m. h, Z% l: d4 ]' }' a
  2174.     update_move_sign
    / p1 h" k( W% ?* G/ u' h
  2175.   end
    * k, J2 |7 C. W+ w
  2176.   #--------------------------------------------------------------------------
      {! m4 t# {4 x& @0 @
  2177.   # ● 创建显示路径点的事件
    ) T+ F1 r" c$ f! K( ?. a
  2178.   #--------------------------------------------------------------------------$ L4 [( y8 d* B  v3 ~# O
  2179.   def creat_move_sign
    * W  h7 F( ]  _. ]  y5 t
  2180.     $mouse_move_sign = Move_Sign.new# t2 R3 C) N9 \6 i9 n
  2181.   end% G6 [; B7 _  q" l
  2182.   #--------------------------------------------------------------------------
    : l% d9 ^* r& G5 K5 x! `& |+ Z
  2183.   # ● 更新显示路径点的事件" G( ?; m. Y9 X
  2184.   #--------------------------------------------------------------------------4 V/ f" L/ u, V5 F9 I" ]5 ~
  2185.   def set_constants
    * l; M5 E/ s0 q& ~8 ?
  2186.     @mouse_pos_setted = true
    & ~  y; T. O7 A) B: L5 h* l. |. ]- ^
  2187.     @set_pos_prepared = false* b( ~  A' d3 ]7 O- Q- M( j+ c
  2188.     @mouse_old_x = 00 H3 B/ O0 C' D
  2189.     @mouse_old_y = 0$ n1 u; z$ p( q6 \, e
  2190.   end6 V7 |4 }; a$ X
  2191.   #--------------------------------------------------------------------------
      [( ]2 \9 k$ `. J& C
  2192.   # ● 更新显示路径点的事件9 N/ N3 n& Q* V  ?% n# J3 N+ ~( a
  2193.   #--------------------------------------------------------------------------
    ( N6 E. ?+ D& \" F- U3 t
  2194.   def update_move_sign
      d; k% k8 M) R8 Z* Q
  2195.     $mouse_move_sign.update% l) ~3 H% a. z+ `
  2196.   end
    8 E7 y- ]& N! j. ?9 u8 f$ n
  2197.   #--------------------------------------------------------------------------' \) ^0 i) c/ _/ z
  2198.   # ● 获取鼠标位于的地图块的x、y坐标% M- ^6 t; F; W
  2199.   #--------------------------------------------------------------------------
    , v& q5 [+ K, ?% [8 a
  2200.   def get_mouse_map_xy$ U$ Z4 x5 r  P" j
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ; l4 z6 W+ D7 ~& R  T* w9 _" n
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    " A% a0 B; _- `+ J& ?
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    : c" A3 h' J2 B, ~- X6 X
  2204.   end& n7 i) V1 L* [2 d6 ~' z9 _- e
  2205.   #--------------------------------------------------------------------------1 s. a; c/ ^- ^4 w* F" ~: e- l' n
  2206.   # ● 返回地图画面时重设鼠标坐标& X# b: c1 {3 f6 e0 V
  2207.   #--------------------------------------------------------------------------
    ) P; G4 J# R) ?. a! f
  2208.   def reset_mouse_pos
    9 f( _( O9 p. |; S+ n
  2209.     return if @mouse_pos_setted
    4 `, @4 T6 R% U' |. q9 w
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)6 ~/ v* c8 s* \) a/ M6 n
  2211.     @mouse_pos_setted = true& q  a% s% y4 ~
  2212.     @set_pos_prepared = false6 K) a1 g& C$ S7 j$ k0 d
  2213.   end
    . P  E& p, h* n' a* ?
  2214.   #--------------------------------------------------------------------------
    0 X$ a  |1 y* r) c% G
  2215.   # ● 重设鼠标的坐标
    6 q" l5 \. I8 _
  2216.   #--------------------------------------------------------------------------8 O6 ?' m1 b# f+ G( t6 H
  2217.   def prepare_reset_mouse_pos. K7 V( g" N. ~$ k3 N
  2218.     return if @set_pos_prepared# n( G5 ^1 {! R4 d
  2219.     @mouse_pos_setted = false
    2 x% B3 J& ~; T7 H
  2220.     @mouse_old_x = Mouse.mouse_x6 h0 U1 |6 p% j% c. T( e
  2221.     @mouse_old_y = Mouse.mouse_y
    ( d5 f' ^0 r7 |1 `3 [1 T
  2222.     @set_pos_prepared = true
    ; J4 A9 X2 B1 Q" K9 z0 ~
  2223.   end
    * z/ G: e7 B5 |9 b  d* D* I0 g- }
  2224. end( k9 x+ C1 t# `# n
  2225. ' Q3 b' t2 F2 s; w% p
  2226. #==============================================================================
    + R: B/ u. G$ B) V- V3 G) R
  2227. # ■ Spriteset_Map0 N9 f# q! i9 O
  2228. #------------------------------------------------------------------------------
    7 ], V4 N6 \# B$ c
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    , I( z9 ^1 s( A1 l# `! N
  2230. #==============================================================================- `" s  P( d( T
  2231. class Spriteset_Map0 R8 d7 ?$ O9 Q( Z1 {: C7 z
  2232.   #--------------------------------------------------------------------------
    ; E+ q: |. F  [7 S8 g
  2233.   # ● 生成路径点精灵# d" }, ?$ A; P' Z1 t: u/ `
  2234.   #--------------------------------------------------------------------------
    1 W, `) w4 {6 ], Y, @! n, S
  2235.   alias sion_mouse_create_characters create_characters2 q! K2 |  U( P- D  M
  2236.   def create_characters1 `! V, L9 ]5 i* R- _  s9 Q
  2237.     sion_mouse_create_characters- {% p/ w  s$ ?# o; i8 W/ l' @
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    / _$ q1 C5 x4 g* ?2 o, C& i% e
  2239.   end! e7 D5 f! c2 t$ \& W$ X
  2240. end
    : ]. [: Q6 J- o0 e3 v' m! p; ^$ F
  2241. 7 `% @. n2 {) {0 ]
  2242. #==============================================================================/ w+ S  B7 @: M+ T# L: p
  2243. # ■ Scene_Map
      |7 k1 l" H. x7 y' e  L
  2244. #------------------------------------------------------------------------------$ B6 a) f/ k- Y5 d, u8 Y( v
  2245. #  地图画面
    5 K: ~( }; _8 _& d3 k
  2246. #==============================================================================4 g6 ~1 d7 Y% i4 a3 U$ u/ V/ c) B
  2247. class Scene_Map  Scene_Base+ G8 f, [" |8 C/ W
  2248.   #--------------------------------------------------------------------------
    9 t* @2 L4 p# s
  2249.   # ● 画面更新0 k# d! t% v' {2 `
  2250.   #--------------------------------------------------------------------------5 P) B4 l9 ]; s: @6 l  p9 y
  2251.   alias sion_mouse_update_scene update_scene
    9 e) I6 H6 Y, F' I8 G8 L2 f7 e
  2252.   def update_scene3 v3 D, K" d7 f; W
  2253.     sion_mouse_update_scene& N! x0 ^5 H) e/ b
  2254.     update_mouse_action unless scene_changing
    : R/ t2 [: X, `# B; F- c" F3 v
  2255.   end: l+ O5 t! M) B2 ~
  2256.   #--------------------------------------------------------------------------
    8 t+ D+ L+ L  ~" q; T* {
  2257.   # ● 场所移动前的处理
    & u( j0 B+ q+ D) m, c1 h- T
  2258.   #--------------------------------------------------------------------------
    . s) i. g0 J5 h% T7 K9 {
  2259.   alias sion_mouse_pre_transfer pre_transfer  K! m- L8 J- v# X( \# c+ Y3 x7 u
  2260.   def pre_transfer
    : X6 u" H% e) r1 T
  2261.     $game_player.reset_move_path0 ^, p7 Z* w  |! {" a$ R7 C
  2262.     sion_mouse_pre_transfer/ H& Z6 S; n3 I+ Q7 m4 r
  2263.   end
    5 m$ f" t* e4 |3 ~
  2264.   #--------------------------------------------------------------------------/ [; Y) j6 E2 _
  2265.   # ● 监听鼠标左键的按下
    3 [4 l0 K4 ]/ N2 U% c: R
  2266.   #--------------------------------------------------------------------------7 R1 v' ?" p$ R- |" N" O
  2267.   def update_mouse_action
    ! Q/ W' S2 v& b" v" ]+ ]& u1 H
  2268.     $game_player.left_button_action if Mouse.press(0x01)- F: f4 `/ y/ s, C5 b
  2269.   end
    " Y1 H% v2 y- X3 O: D
  2270. end" u6 R+ t9 L) j, n8 |% D; \, ]
  2271. 5 c+ C. A5 [2 M; m2 i3 a
  2272. #==============================================================================
    ! p& J7 y6 X8 v6 R4 P9 W
  2273. # ■ Scene_File3 O; }# {7 Q9 s5 U$ e& K' a$ G
  2274. #------------------------------------------------------------------------------: S1 y: I5 p( p7 T  X2 T3 I
  2275. #  存档画面和读档画面共同的父类
    8 t: o) m3 y! h
  2276. #==============================================================================) i' x2 @& L- Y
  2277. class Scene_File  Scene_MenuBase
    8 J" N, p3 Z5 c# N7 Z0 c( y
  2278.   #--------------------------------------------------------------------------
    " ^6 m; F( A: K; G
  2279.   # ● 开始处理9 W% P0 s& x; P8 |' z
  2280.   #--------------------------------------------------------------------------! _) `9 v- O9 l% k6 a/ Z1 V
  2281.   alias sion_mouse_start start( b# e* m4 h' \
  2282.   def start
    " D  s& E6 G. ?$ ~
  2283.     sion_mouse_start5 J) f' N; x9 @+ F8 ]1 Q7 }& p
  2284.     @move_state = 0" w2 H4 L3 i) _- g# Z0 P
  2285.     set_mouse_pos. z( M. J5 q. U& f3 \4 m. p
  2286.   end! w3 F! B) a2 E1 c' Z, {
  2287.   #--------------------------------------------------------------------------  Y( f! H9 c* O* o) {6 j7 z
  2288.   # ● 更新画面
    ; w" k3 _% [+ h/ {! ?" e
  2289.   #--------------------------------------------------------------------------
    9 {3 \/ g; ~# q2 u
  2290.   alias sion_mouse_update update
    4 _" }  y  M/ x& B& f. W
  2291.   def update+ E! L0 T7 \9 {. o
  2292.     sion_mouse_update& C+ Q: |4 g0 v/ V% L, O4 X
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    # x' p& I' H4 {
  2294.   end6 C6 J5 Y" D+ H5 }4 A$ Q
  2295.   #--------------------------------------------------------------------------
    9 V4 D4 U/ G. \9 C* t# v7 d
  2296.   # ● 更新光标
    ; T8 S( A; |% y& K2 X! u( G
  2297.   #--------------------------------------------------------------------------
    3 Y+ C# p& u7 B) d) L" _  i
  2298.   def set_cursor
    ! n0 I+ w- I- c3 @% l8 e
  2299.     @move_state += 1
      L0 T; x. @' c3 M$ I
  2300.     last_index = @index
    " c4 q) P' W( W6 E* p& Y
  2301.     if mouse_which_window == -2
    ; Z1 v# y4 Q' W8 [( F8 B4 O8 e
  2302.       if (@move_state - 1) % 6 == 0
    # Y( D7 P7 R( S; q3 C
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1* Q6 R7 e- _/ ?7 r: W6 w
  2304.       end
    7 \% B, S$ i  q2 ]
  2305.     elsif mouse_which_window == -1
    9 [: D: g. K& D7 J* X+ Z
  2306.       if (@move_state - 1) % 6 == 0
    0 T/ N  x8 R6 n
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    4 n; }4 O- c! W5 Q: k
  2308.       end
    . Z6 m! n6 P- P7 a
  2309.     else* e7 X: [; P! t5 Y: I# f1 m/ i
  2310.       @move_state = 0
    ; d  N- G1 O, @, Z8 ^
  2311.       @index = top_index + mouse_which_window" s( N9 }9 B/ U0 R6 n. q
  2312.     end
    5 q2 c4 k/ O' G
  2313.     ensure_cursor_visible5 ~0 y5 ?$ m  ^9 O
  2314.     if @index != last_index5 O+ t' m0 P' y4 r0 U1 T! W
  2315.       @savefile_windows[last_index].selected = false
    7 g& ^  P+ T; c% H9 b6 u& P* t
  2316.       @savefile_windows[@index].selected = true8 B- M- B2 D- w7 d* z3 N5 ~! ]
  2317.     end4 t  m* V' [# }( P3 v# b1 }  D
  2318.   end$ Y# H% {- u: S+ e5 P
  2319.   #--------------------------------------------------------------------------
    ! L9 P4 a3 K3 \2 x+ I
  2320.   # ● 判断鼠标位于哪个窗口3 j0 X& C, W. i. c
  2321.   #--------------------------------------------------------------------------
    5 y/ [& w- H' `0 S7 i2 w" V
  2322.   def mouse_which_window& L# e. u) U1 a+ i5 ], V; |/ d* @
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    % p" ?1 P4 }, n8 k8 T
  2324.     if mouse_y  @help_window.height + 14
    + i  w; ^) u  G
  2325.       mouse_row = -1
    + }, H* G  {. Y4 b4 {% ?3 _( {
  2326.     elsif mouse_y  Graphics.height - 148 C  t1 X9 |; A% U1 @3 q
  2327.       mouse_row = -2
    7 M* M9 y! `( I' {9 Z# w7 v
  2328.     else
    : T+ U; N, N- t' g+ ?
  2329.       mouse_row = 4  (mouse_y - @help_window.height) 0 U6 C$ P8 j3 O9 I  Q
  2330.         (Graphics.height - @help_window.height)% ?$ V- _: f+ |7 S) r" \
  2331.     end$ @$ J& \1 y  @
  2332.     return mouse_row
    0 V9 W$ d& i9 o9 b& Z& n% {$ h
  2333.   end
    ; @% i% Q' H  O; D% P0 D. I
  2334.   #--------------------------------------------------------------------------- z0 p/ }, O; b
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    - G* w( H- i4 C$ _7 ?" l
  2336.   #--------------------------------------------------------------------------
      C  [, v, N0 w% d- h1 U7 A/ _
  2337.   def set_mouse_pos. i# B+ c- {  M( [2 t: G& G
  2338.     new_x = 40
    4 ?$ Q# z, V9 x" J0 \
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    - J3 y( ?, q5 n& V3 z& {% J
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    - H2 I5 w" k$ R% P; z* Z* e
  2341.   end$ v; m3 j  O# u7 P
  2342. end
    & t4 B" C* w2 w; }7 l
  2343. , O$ z! G( D8 D) m" ^- y& p
  2344. #==============================================================================9 R. P( J0 ?3 ]9 C# E$ r
  2345. # ■ Game_Event8 e' J% i5 B' p" O! O/ y$ Y
  2346. #------------------------------------------------------------------------------# j# ~& u2 f: }+ j- e5 l' l8 B- A5 r
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    * x1 J0 _; o2 ^- s
  2348. #   在 Game_Map 类的内部使用。' V9 L6 @& d& A, E  }
  2349. #==============================================================================+ Y: ]% E$ n: ^" j
  2350. class Game_Event  Game_Character/ b* u% j& x% X  E' J
  2351.   #--------------------------------------------------------------------------
    . ~% b8 \) ~; R' Y) {* |! r$ Z; \$ t
  2352.   # ● 事件启动
    1 @6 n) Q8 E! `4 p8 D
  2353.   #--------------------------------------------------------------------------
    : H: u5 m3 }) A6 ^$ v& l* @
  2354.   alias sion_mouse_start start- U1 b; r! \+ o$ V3 {0 r, n% D
  2355.   def start+ b! J/ N% ^$ R7 O2 }9 O, d
  2356.     return if mouse_start && !Mouse.press(0x01)
    9 u. p' y* x5 x& C& E
  2357.     sion_mouse_start
    * E/ R, L" K+ w8 p8 V  h8 f# T  X
  2358.   end* @5 h6 Y9 {( M$ k1 w
  2359.   #--------------------------------------------------------------------------
    1 ?* R9 D) W2 A" ?. O! R5 q$ I
  2360.   # ● 判断事件是否由鼠标启动: @; W! e' _& y; @" C
  2361.   #--------------------------------------------------------------------------& B% f& K) o8 `, c- Z! M9 p
  2362.   def mouse_start# {/ T0 s# F* p; d& ^  g* ^
  2363.     return false if empty
    * Y7 c/ E  z% N' T! u# v& [0 s8 v
  2364.     @list.each do index& V) ]" a3 p2 U8 ?3 K# Y+ U" n' C
  2365.       return true if (index.code == 108  index.code == 408) &&
    7 k# w2 X' o# }
  2366.         index.parameters[0].include('鼠标启动')
    $ i, E* L6 Y; L% p2 J
  2367.     end7 s" u  m( P5 m* @3 a/ w# Z+ K
  2368.     return false
    : o6 K. T+ @. x& L/ a6 Z9 B
  2369.   end) s, J! E, t; M# I" M* [
  2370. end
    1 c! ?! k$ _1 o% }

  2371. / [# ]( w/ o8 O& W; }2 \! c; i3 z/ x
  2372. ####泥煤的height
    ' `, S1 t2 D7 V& B5 F% l
  2373. # @height = height( y8 U  Z( L% V, C5 }0 R. ^
  2374. + ~( Q3 A( H  _+ R& b9 X5 {- m/ k; }0 g
  2375. class Area_Response
    ; }5 Y6 x0 D& D3 _2 r* O
  2376.   attr_accessor type: Z9 `, ~7 s6 o7 [4 m* R
  2377.   attr_reader ox
    % l4 p7 d4 ]( J! [  E! l
  2378.   attr_reader oy7 ]% W6 O4 ]  v" _. c" o
  2379.   attr_reader width
    / o5 z$ I' R% X/ j  b
  2380.   attr_reader height6 L$ B% A' M1 N' ]& {
  2381.   attr_reader switch_id. o% ?$ s  k+ }( b
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)! C( c% D. x6 P+ D
  2383.     @type = type6 J: u4 C! I3 w, t6 L  e2 ]! ^
  2384.     @ox = ox6 ^$ S" v: M9 r8 X! g
  2385.     @oy = oy
    9 b% G8 j' g* `9 [% d# H
  2386.     @width = width
    * y0 ^5 }: `, a  Z8 _% |, f+ P
  2387.     @height = height
    $ \) b8 ~8 {4 w
  2388.     @switch_id = switch_id( Z; C2 s* L0 c, d: [# `, K% t
  2389.   end4 o9 l* D/ r; P. G" s" W
  2390. end
    . r5 [6 Y  {4 ]! K, o' t5 v  c4 m, s- @1 u
  2391. * D* ~9 I, T& g& y# `
  2392. $area_responses = []
    % a& G; g% y' \" g  Q

  2393. . e  [) Z0 Y7 H. \# C
  2394. class Scene_Map
    1 O/ @+ C* |8 V" V: j2 h- ~
  2395.   alias update_mouse_2013421 update_mouse_action
    6 h' Y4 }5 h* l3 \8 r& R
  2396.   def update_mouse_action
    4 A/ ?7 s6 D) U# Y6 x/ ~
  2397.     update_area_response" n9 K( l2 D2 j1 O7 T
  2398.     update_mouse_20134212 M" B  T7 z3 L1 {( E
  2399.   end  Y' L# R+ _3 ?- U5 a2 k/ v9 ~4 M3 V
  2400.   def update_area_response
    ' Y) F$ Y8 s$ s7 }3 f% [' J
  2401.     responses = $area_responses- \1 H0 W& ~4 `" d8 i3 {6 T1 z
  2402.     responses.each {response) J# j6 }* G- w
  2403.       ox = response.ox
    $ Y$ i3 T4 [6 O. g7 x
  2404.       oy = response.oy
    6 R' s4 r* w) v
  2405.       width = response.width
    1 M: r9 i! i# a8 ^* y! O" o
  2406.       height = response.height
    $ h0 V1 e$ |) _* F  R5 ?' h
  2407.       switch_id = response.switch_id1 C7 V$ E" x5 m
  2408.       case response.type  M+ Y5 t" M& e  W; x: W8 z$ q
  2409.       when 0. X& ^& `5 O- x' l
  2410.         if mouse_in_area(ox, oy, width, height)) p$ u2 t! \4 ~3 d( _
  2411.           $game_switches[switch_id] = true
    ) \- l  \! i* ^4 f
  2412.           $area_responses.delete(response)$ `6 J4 q: q7 M1 |/ n  h  f2 j  _: l! y
  2413.         end
    + G3 K8 N4 {1 I5 |5 w
  2414.       when 1
    & G9 U4 w+ _; k! B
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)/ B3 w5 v; G' s( R; H
  2416.           $game_switches[switch_id] = true
    ! }& h/ ^7 f/ [$ A# P5 H. S8 s
  2417.           $area_responses.delete(response)! \; L' ?0 U3 Z) ^  z% l
  2418.         end9 `$ n* }8 z: @
  2419.       when 2
    + ]4 C6 @: Y# Q$ E9 p' B
  2420.         if mouse_in_area(ox, oy, width, height)/ H3 @! L5 Z8 I7 J* ~1 Q' y
  2421.           $game_switches[switch_id] = true
    & C0 a% O" I; `
  2422.         else) J4 h  B- I* i' X0 X. |" i
  2423.           $game_switches[switch_id] = false
    4 z: d- t$ y+ R) {$ M# {0 r, |
  2424.         end( R3 U; N- _: f- X" }4 X
  2425.       when 3  t+ B% O9 i3 m/ a/ k
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    & I  m. I# o; O2 Z( I0 b0 m
  2427.             (oy - $game_map.display_y)  32, width, height)$ E- Y* J% y1 M8 Y+ U
  2428.           $game_map.events_xy(ox, oy).each {event
    ) C% P, \1 M2 R9 `' C
  2429.           event.start
    . j. {5 a1 ~$ k" B# U7 p' o) b4 H
  2430.           $area_responses.delete(response)- g2 b; Q' _5 _1 Y" r
  2431.           return- V  i* m- m' D6 r; o  D" d
  2432.           } + _2 Q2 I2 w8 \5 T
  2433.         end" T, J8 H5 H: S3 p
  2434.       when 4
    $ o) E( N) E8 Y% A
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,& c: T) v9 a7 y" x8 w/ A
  2436.             (oy - $game_map.display_y)  32, width, height)
    1 i3 q+ O# }5 g
  2437.           $game_map.events_xy(ox, oy).each {event% b2 e  n) ]9 l! g; e
  2438.             event.start9 p1 m8 x6 ~+ u3 [, K' Z6 Y  h
  2439.             return
    - s2 Y1 C0 t  D5 c2 Q* z& X) p& y
  2440.           } # \0 {! e3 m% \! E
  2441.         end( i9 \' j* [- K8 ^
  2442.       end) V, W: y/ p- O
  2443.     }
    ; D# h, t% [+ x- ?5 y0 U! V
  2444.   end8 R- F$ ?4 [3 Z6 F4 f0 o0 S  e
  2445.   def mouse_in_area(ox, oy, width, height)
      [+ q: Y# R7 ^5 I" Y3 V
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&5 ]5 t1 |1 Z3 L9 [8 k# H
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height  C, ?4 y9 z" F( ?- ]
  2448.   end
    5 {; `1 Z1 P% }, B" d
  2449. end( [- s$ T4 a. j$ G/ f" c
  2450. class Game_Interpreter
    9 M1 \% d7 c: t
  2451.   def area_response(arg)
    % K. I& q. }6 P# d$ {. Y9 `# N2 {$ l7 T
  2452.     $area_responses.push(Area_Response.new(arg))4 U$ {5 B, o$ L* R1 g
  2453.   end$ d2 T7 o6 e+ \4 r% G* P
  2454. end) ~7 ^! e. O$ X
复制代码

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

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

GMT+8, 2025-10-31 09:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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