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

Project1

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

[已经过期] 图片选项

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
135 小时
注册时间
2012-6-14
帖子
43
跳转到指定楼层
1
发表于 2013-8-27 20:52:26 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
不好意思又来发问了...
这次我想问怎样能达成图片选项的效果?
如图

人物对话的选项跟在某些特定地图我希望能直接用鼠标跟键盘直接点选...
这个是要用脚本还是事件?该怎么做呢?
不好意思麻烦大家了

Lv1.梦旅人

梦石
0
星屑
117
在线时间
552 小时
注册时间
2012-8-18
帖子
1429
2
发表于 2013-8-27 21:32:55 | 只看该作者
用鼠标就意味着用脚本= =

评分

参与人数 1星屑 -10 收起 理由
Mic_洛洛 -10 “废水”,退散!

查看全部评分

我要填坑!我要背单词!我要学日语!我要每天锻炼!
好吧呵呵= =
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
70
在线时间
1083 小时
注册时间
2013-3-29
帖子
2394
3
发表于 2013-8-27 21:40:56 | 只看该作者
其实这样LZ还不如直接用橙光好了……

坑的进度如上                                                                                                        点击↑
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1058
在线时间
878 小时
注册时间
2012-6-28
帖子
1079
4
发表于 2013-8-27 21:50:31 | 只看该作者
试试橙光吧,适合做你需要的这种文字游戏。。。我说这样的话,第一次。。。
不追求华丽的商业素材;不依赖与自己运用能力不符的外挂脚本;不搞华而不实的无用噱头。
                    修改,使用最朴实的素材,融入自己的智慧做最好的游戏!
                                    点这里!暂不设加入门槛
         
                               我觉得我的优点是,会认真的画每一张地图。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
89 小时
注册时间
2009-3-7
帖子
144
5
发表于 2013-8-27 22:37:48 | 只看该作者
本帖最后由 猫猫鱼 于 2013-8-27 22:39 编辑

文字游戏的话用橙光吧,很方便,6R也会给专业的技术支持。
当然,如果你一定要RM系列也行,鼠标的功能得靠脚本来实现,如果只是键盘控制,用事件也可以完成,用变量记录指的位置和坐标就行。
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
22152
在线时间
8583 小时
注册时间
2011-12-31
帖子
3362
6
发表于 2013-8-27 23:08:18 | 只看该作者
  1. #===========================================================================#
  2. #  #*****************#                                                      #
  3. #  #*** By Falcao ***#         滑鼠系統按鈕 2.0                     #
  4. #  #*****************#         這是一個基於按鈕滑鼠腳本   #
  5. #                              允許創建地圖螢幕或地圖按鈕  #
  6. #                              在遊戲玩法內提供充分的全滑鼠互動  #
  7. #       RMVXACE                      #
  8. #                                                                           #
  9. #                                                                           #
  10. # Falcao RGSS site:  http://falcaorgss.wordpress.com                        #
  11. # Falcao Forum site: http://makerpalace.com                                 #
  12. #                                                                           #
  13. #===========================================================================#

  14. # * Version 2.0 change log (Date: January 13 2013)

  15. # - Added path finding, now the game player is able to move using the mouse
  16. # - Added compatibility with Victor Animated Battle version 1.x and above
  17. # - Now you are able to change the mouse cursor icon in game
  18. # - Two new notetags added to change the mouse cursor by event comment tags
  19. # - Fixed crash when pointing a notetagged event with a valid condition
  20. #----------------------------------------------------------------------------
  21. # * Version 1.6 change log (Date: November 21 2012)
  22. #
  23. # - Added compatibility for any game screen resolution
  24. # - System optimized to consume less cpu than before
  25. # - Added extra compatibility for Pearl ABS Liquid
  26. # - Removed the font fix
  27. # - Added the imported bolean
  28. #----------------------------------------------------------------------------
  29. # * Version 1.5 change log
  30. #
  31. # - Fixed cursor sound over loading on selectable windows
  32. # - Fixed bug when selecting event graphic tileset that have mouse comment tag
  33. # - FIxed minor bug when transfering (event name now erase completely)
  34. # - Added option to turn on / off arrow selector on save file
  35. # - Important! changes on mouse comment tags!
  36. #   ~ CLICK START change to MOUSE START
  37. #   ~ ANIMATION   change to MOUSE ANIMATION
  38. #   ~ NAME        change to MOUSE NAME
  39. #
  40. #---------------------------------------------------------------------------
  41. # * 安裝
  42. #
  43. # 複製和粘貼此腳本於main前面 !
  44. #
  45. # * 滑鼠按鍵
  46. #   -按下滑鼠左鍵:     動作按鈕
  47. #   -按下滑鼠右鍵:    取消按鈕,關閉視窗
  48. #   - 按下滑鼠滾輪/中間按鈕:   DASH
  49. #按下滑鼠左鍵
  50. #---------------------------------------------------------------------------
  51. # * 主要功能
  52. #
  53. # - 允許創建按鈕,並為它們指定工作
  54. # - Events can be buttons too, map ground buttons! for some puzzles etc.
  55. # -顯示事件的名稱
  56. # - 全滑鼠互動
  57. # - 可選WASD 移動
  58. # - 滑鼠自動尋路功能
  59. # - 可在遊戲中啟用改變鼠標光標
  60. #---------------------------------------------------------------------------
  61. # * 事件按鈕命令
  62. #
  63. # Write this lines on event comments tags
  64. #
  65. # MOUSE START       - 單擊事件時開始事件
  66. # MOUSE ANIMATION x - 鼠標在事件上時顯示動畫效果
  67. #                     例: MOUSE ANIMATION 1
  68. # MOUSE NAME x      - 鼠標在事件上時顯示事件名稱,
  69. #                     例: MOUSE NAME Falcao
  70. # MOUSE ICON x      - 鼠標在事件上時改變鼠標光標的圖標
  71. #                     x : 圖標索引
  72. # MOUSE PIC X       - Change the mouse cursor when is over an event but in this
  73. #                     case it display a picture graphic name, change x for the
  74. #                     picture name
  75. #------------------------------------------------------------------------------
  76. # * Script calls
  77. #
  78. # 調用此行來打開/關閉鼠標光標 true/false
  79. # Mouse.show_cursor(false)
  80. #
  81. # 如果您要手動更改滑鼠游標使用下面的腳本調用
  82. # Mouse.set_cursor(:iconset, x)     - X是圖標的索引
  83. #
  84. #  如果您想要顯示圖片 iconset 使用下面的腳本調用
  85. # Mouse.set_cursor(:picture, name)  -  name 更改成圖片名稱
  86. #-----------------------------------------------------------------------------

  87. module Map_Buttons

  88. # 很容易在地圖畫面上増加許多按鈕
  89. # 下方是按鈕定義的參數
  90.   
  91.   Insert = {
  92. #-----------------------------------------------------------------------------
  93. #  A => [B, C, D, E, F]
  94. #  
  95. #  A = 按鈕號碼
  96. #
  97. #  B = 命名
  98. #  C = X 在屏幕位置(以字符為單位)
  99. #  D = Y 在屏幕位置(以字符為單位)
  100. #  E = 圖標,寫入圖片圖片'名'或圖標索引
  101. #  F = 這按鈕做什麼?有兩個選項, 呼叫場景或呼叫公共事件,
  102. # 如果你想要場景則寫入場景名稱,
  103. # 公共事件 則寫入公共事件ID
  104.   
  105.   # 按鈕調用菜單畫面(場景用法例子)
  106.   1=> ["Menu", 16, 11, 117, Scene_Menu],  
  107.   
  108.   # 按鈕調用事件 ID 1(事件用法例子)
  109.   2=>  ["Bestiary",  16, 12, 121, 1],
  110.   
  111.   

  112.   }

  113. # * General configutration

  114. # 鼠標光標的圖標,圖標索引如果想要圖片寫入圖片的名字
  115.   CursorIcon = 386

  116. # 切換ID:在屏幕上顕示圖標 打開/關閉
  117.   Switch = 100
  118.   
  119. # 允許使用W A S D鍵移動 true/false
  120.   WASD_Movement = true
  121.   
  122. # 顯示箭頭選擇保存文件? true / false
  123.   DisplaySelector = false
  124.   
  125. # 當你點擊事件,讓玩家忽略該自我的的移動嗎?
  126.   IgnoreEventPath = true
  127.   
  128. # 尋路開關ID:啟用或禁用尋路功能
  129.   PathFinderSwitch = 500
  130. #
  131. #----------------------------------------------------------------------------
  132. #
  133. # * License
  134. #
  135. # 可以在非商業遊戲中使用此腳本,
  136. # 商業遊戲則要通知我(作者). [email protected]
  137. #-----------------------------------------------------------------------------

  138.   def self.check_value(value)
  139.     return 'numeric' if value.is_a? Fixnum
  140.     return 'string'
  141.   end
  142. end

  143. ($imported ||= {})[:Mouse_System_Buttons] = 2.0

  144. # 這個類創建的所有屏幕遊戲畫面上的按鈕和事
  145. class Interactive_Buttoms
  146.   attr_reader :cursoring
  147.   def initialize
  148.     create_screen_buttoms
  149.     @ani_delay = 0
  150.   end
  151.   
  152.   def create_screen_buttoms
  153.     if $imported["Falcao Pearl ABS Liquid"]
  154.       if PearlKernel::clean_back?
  155.         @buttons_sprites = []
  156.         return
  157.       end
  158.     end
  159.     @buttons_sprites = []
  160.     for i in Map_Buttons::Insert.values
  161.       @buttons_sprites.push(Sprite_Buttons.new(i[0], i[1], i[2], i[3], i[4]))
  162.     end
  163.   end
  164.   
  165.   def create_button_text
  166.     if @button_text.nil?
  167.       @button_text = Sprite.new
  168.       @button_text.bitmap = Bitmap.new(100, 32)
  169.       @button_text.z = 50
  170.       @button_text.bitmap.font.size = 16
  171.     end
  172.   end
  173.   
  174.   def dispose_screen_buttons
  175.     for button in @buttons_sprites
  176.       button.dispose
  177.     end
  178.     @buttons_sprites = []
  179.   end
  180.   
  181.   def dispose_button_text
  182.     if not @button_text.nil?
  183.       @button_text.dispose
  184.       @button_text.bitmap.dispose
  185.       @button_text = nil
  186.     end
  187.   end
  188.   
  189.   def dispose
  190.     dispose_screen_buttons
  191.     dispose_button_text
  192.   end
  193.   
  194.   def update
  195.     if $game_switches[Map_Buttons::Switch] and not @buttons_sprites.empty?
  196.       dispose_screen_buttons
  197.     elsif not $game_switches[Map_Buttons::Switch] and @buttons_sprites.empty?
  198.       create_screen_buttoms
  199.     end
  200.     update_buttons
  201.     update_event_selection
  202.   end
  203.   
  204.   # 路徑更新
  205.   def update_path
  206.     return if $game_switches[Map_Buttons::PathFinderSwitch]
  207.     return if $game_message.busy?
  208.     return unless $game_player.normal_walk?
  209.     mx, my = Mouse.map_grid[0], Mouse.map_grid[1]
  210.     if Map_Buttons::IgnoreEventPath
  211.       $game_map.events.values.each do |event|
  212.         return if event.x == mx and event.y == my
  213.       end
  214.     end
  215.     $game_player.find_path(mx, my)
  216.   end
  217.   
  218.   def update_buttons
  219.     for button in @buttons_sprites
  220.       button.update
  221.       if button.zooming
  222.         @screen_b = true
  223.         create_button_text
  224.         if button.x > 272
  225.           x, y = button.px * 32 - 98, button.py * 32
  226.           draw_button_text(x, y, button.name, 2)
  227.         elsif button.x < 272
  228.           x, y = button.px * 32 + 31, button.py * 32
  229.           draw_button_text(x, y, button.name, 0)
  230.         end
  231.       end
  232.     end
  233.    
  234.     if @screen_b != nil
  235.       unless mouse_over_button?
  236.         dispose_button_text
  237.         @screen_b = nil
  238.       end
  239.     end
  240.   end
  241.   
  242.   def reset_cursor
  243.     if Map_Buttons::check_value(@cursoring[1]) == 'numeric'
  244.       Mouse.set_cursor(:iconset, @cursoring[1], true)
  245.     else
  246.       Mouse.set_cursor(:picture, @cursoring[1], true)
  247.     end
  248.     @cursoring = nil
  249.   end
  250.   
  251.   def apply_iconchanging(sym, operand, event)
  252.     cursor = $game_system.cursorr
  253.     cursor = Map_Buttons::CursorIcon if cursor.nil?
  254.     @cursoring = [event, cursor]
  255.     Mouse.set_cursor(sym, operand, true)
  256.   end
  257.   
  258.   def update_event_selection
  259.     return if @screen_b #disable event buttom if mouse over screen buttom
  260.     update_path if Mouse.trigger?(0)
  261.     for event in $game_map.events.values
  262.       next if event.page.nil?
  263.       if event.x == Mouse.map_grid[0] and event.y == Mouse.map_grid[1]
  264.         if event.mouse_start
  265.           if Mouse.trigger?(0) and !$game_map.interpreter.running?
  266.             event.start
  267.           end
  268.         end
  269.         anime = event.mouse_animation
  270.         if anime != 0
  271.           @ani_delay += 1
  272.           event.animation_id = anime if @ani_delay == 1
  273.           @ani_delay = 0 if @ani_delay > 16
  274.         end
  275.         name = event.mouse_name
  276.         if name != ""
  277.           [url=home.php?mod=space&uid=94943]@Eve[/url] = [event.x, event.y, event, name]
  278.           create_button_text
  279.         end
  280.         icon = event.mouse_iconset
  281.         picture = event.mouse_picture
  282.         if !icon.nil? and icon != 0 and @cursoring.nil?
  283.           apply_iconchanging(:iconset, icon, event)
  284.         elsif !picture.nil? and picture != "" and @cursoring.nil?
  285.           apply_iconchanging(:picture, picture, event)
  286.         end
  287.       end
  288.     end
  289.    
  290.     if @cursoring != nil
  291.       reset_cursor if not mouse_over_event?(@cursoring[0].x, @cursoring[0].y)
  292.     end
  293.    
  294.     if @eve != nil
  295.       @eve[2].ch_oy.nil? ? event_oy = 32 : event_oy = @eve[2].ch_oy
  296.       if event_oy > 32
  297.         draw_button_text(@eve[2].screen_x - 49,
  298.         @eve[2].screen_y - event_oy / 2 - 50, @eve[3], 1)
  299.       else
  300.         draw_button_text(@eve[2].screen_x - 49,
  301.         @eve[2].screen_y - event_oy / 2 - 36, @eve[3], 1)
  302.       end
  303.       if not mouse_over_event?(@eve[0], @eve[1])
  304.         dispose_button_text
  305.         @eve = nil
  306.       end
  307.     end
  308.   end
  309.   
  310.   def draw_button_text(x, y, text, a=0)
  311.     return if @button_text.nil?
  312.     @button_text.x = x
  313.     @button_text.y = y
  314.     return if @old_name == text
  315.     @button_text.bitmap.clear
  316.     @button_text.bitmap.draw_text(2, 0, @button_text.bitmap.width, 32, text, a)
  317.     @old_name = text
  318.   end
  319.   
  320.   def mouse_over_button?
  321.     for button in @buttons_sprites
  322.       if Mouse.object_area?(button.x, button.y - 6, button.width, button.height)
  323.         return true
  324.       end
  325.     end
  326.     @old_name = nil
  327.     return false
  328.   end
  329.   
  330.   def mouse_over_event?(event_x, event_y)
  331.     if Mouse.map_grid[0] == event_x and Mouse.map_grid[1] == event_y
  332.       return true
  333.     end
  334.     @old_name = nil
  335.     return false
  336.   end
  337. end

  338. # 設置按鍵 sprites
  339. class Spriteset_Map
  340.   alias falcao_insert_buttuns_view create_viewports
  341.   def create_viewports
  342.     @interact_buttoms = Interactive_Buttoms.new
  343.     falcao_insert_buttuns_view
  344.   end
  345.   
  346.   alias falcao_insert_buttuns_dis dispose
  347.   def dispose
  348.     @interact_buttoms.reset_cursor if @interact_buttoms.cursoring != nil
  349.     @interact_buttoms.dispose
  350.     falcao_insert_buttuns_dis
  351.   end
  352.   
  353.   alias falcao_insert_buttuns_up update
  354.   def update
  355.     if $game_player.clear_mousepointers
  356.       @interact_buttoms.dispose
  357.       $game_player.clear_mousepointers = nil
  358.     end
  359.     @interact_buttoms.update
  360.     falcao_insert_buttuns_up
  361.   end
  362. end

  363. # 註釋定義
  364. class Game_Event < Game_Character
  365.   attr_reader   :mouse_start, :mouse_animation, :mouse_name, :mouse_iconset
  366.   attr_reader   :mouse_picture, :page
  367.   alias falcaomouse_setup setup_page_settings
  368.   def setup_page_settings
  369.     falcaomouse_setup
  370.     @mouse_start     = check_comment("MOUSE START")
  371.     @mouse_animation = check_value("MOUSE ANIMATION")
  372.     @mouse_name      = check_name("MOUSE NAME")
  373.     @mouse_iconset   = check_value("MOUSE ICON")
  374.     @mouse_picture   = check_name("MOUSE PIC")
  375.   end

  376.   def check_comment(comment)
  377.     return false if @list.nil? or @list.size <= 0
  378.     for item in @list
  379.       if item.code == 108 or item.code == 408
  380.         if item.parameters[0].include?(comment)
  381.           return true
  382.         end
  383.       end
  384.     end
  385.     return false
  386.   end
  387.   
  388.   def check_value(comment)
  389.     return 0 if @list.nil? or @list.size <= 0
  390.     for item in @list
  391.       if item.code == 108 or item.code == 408
  392.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  393.           return $1.to_i
  394.         end
  395.       end
  396.     end
  397.     return 0
  398.   end
  399.   
  400.   def check_name(comment)
  401.     return "" if @list.nil? or @list.size <= 0
  402.     for item in @list
  403.       next unless item.code == 108 or item.code == 408
  404.       if item.parameters[0] =~ /#{comment} (.*)/
  405.         return $1.to_s
  406.       end
  407.     end
  408.     return ""
  409.   end
  410. end

  411. # 創建屏幕上的按鈕 sprites
  412. class Sprite_Buttons < Sprite
  413.   attr_reader   :px
  414.   attr_reader   :py
  415.   attr_reader   :name
  416.   attr_reader   :zooming
  417.   def initialize(name, px, py, icon_index, action=nil)
  418.     super()
  419.     self.z = 50
  420.     @icon_index = icon_index
  421.     @px = px
  422.     @py = py
  423.     @action = action
  424.     @object_zooming = 0
  425.     @zooming = false
  426.     @name = name
  427.     set_bitmap
  428.     update
  429.   end
  430.   
  431.   def update
  432.     super
  433.     if Mouse.object_area?(self.x, self.y - 4, self.bitmap.width,
  434.       self.bitmap.height)
  435.       @zooming = true
  436.       @object_zooming += 1
  437.       case @object_zooming
  438.       when 1..10  ; self.zoom_x -= 0.02 ;  self.zoom_y -= 0.02
  439.       when 11..20 ; self.zoom_x += 0.02 ;  self.zoom_y += 0.02
  440.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  441.         @object_zooming = 0
  442.       end
  443.       if Mouse.trigger?(0) and @action != nil
  444.         unless $game_map.interpreter.running?
  445.           Sound.play_ok
  446.           if @action == Scene_Menu and not $game_system.menu_disabled
  447.             SceneManager.call(@action)
  448.             Window_MenuCommand::init_command_position
  449.             return
  450.           end
  451.          if Map_Buttons::check_value(@action) == 'numeric'
  452.            $game_temp.reserve_common_event(@action)
  453.          else
  454.            SceneManager.call(@action)
  455.          end
  456.         end
  457.       end
  458.     elsif @object_zooming > 0
  459.       self.zoom_x = 1.0
  460.       self.zoom_y = 1.0
  461.       @object_zooming = 0
  462.     else
  463.       @zooming = false
  464.     end
  465.   end
  466.   
  467.   def set_bitmap
  468.     if Map_Buttons::check_value(@icon_index) == 'numeric'
  469.       self.bitmap = Bitmap.new(24, 24)
  470.       bitmap = Cache.system("Iconset")
  471.       rect = Rect.new(@icon_index % 16 * 24, @icon_index / 16 * 24, 24, 24)
  472.       self.bitmap.blt(0, 0, bitmap, rect)
  473.     else
  474.       self.bitmap = Cache.picture(@icon_index)
  475.     end
  476.     self.x = @px * 32 + 4
  477.     self.y = @py * 32 + 4
  478.   end
  479. end

  480. # Game_character 新的變量
  481. class Game_CharacterBase
  482.   attr_accessor :ch_oy
  483. end

  484. # Sprite character
  485. class Sprite_Character < Sprite_Base
  486.   alias falcaoadd_oxy_set_character_bitmap set_character_bitmap
  487.   def set_character_bitmap
  488.     falcaoadd_oxy_set_character_bitmap
  489.     @character.ch_oy = self.oy
  490.   end
  491. end

  492. class Game_System
  493.   attr_accessor :current_cursor
  494.   def cursorr
  495.     return Map_Buttons::CursorIcon if @current_cursor.nil?
  496.     return @current_cursor
  497.   end
  498. end

  499. # 鼠標模組
  500. module Mouse
  501.   
  502.   GetKeyState    = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')
  503.   GetCursorPos   = Win32API.new('user32',    'GetCursorPos',     'p',     'i')
  504.   GetClientRect  = Win32API.new('user32',    'GetClientRect',    %w(l p), 'i')
  505.   ShowCursor     = Win32API.new('user32',    'ShowCursor',       'i',     'l')
  506.   ScreenToClient = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')
  507.   Findwindow     = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
  508.   GetPrivatePro  = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  509.   %w(p p p p l p), 'l')
  510.                               
  511.   ShowCursor.call(0)
  512.   
  513.   @triggers     =   [[0, 1], [0, 2], [0, 4]]
  514.   @old_pos      =   0

  515.   # 鼠標 Sprite
  516.   
  517.   def self.set_cursor(sym, operand, write=false)
  518.     case sym
  519.     when :iconset
  520.       $mouse_cursor.bitmap = Bitmap.new(24, 24)
  521.       bitmap = Cache.system("Iconset")
  522.       rect = Rect.new(operand % 16 * 24, operand / 16 * 24, 24, 24)
  523.       $mouse_cursor.bitmap.blt(0, 0, bitmap, rect)
  524.     when :picture then $mouse_cursor.bitmap = Cache.picture(operand)
  525.     end
  526.     $game_system.current_cursor = operand if write
  527.   end
  528.   
  529.   $mouse_cursor = Sprite.new
  530.   icon = Map_Buttons::CursorIcon
  531.   if Map_Buttons::check_value(icon) == 'numeric'
  532.     set_cursor(:iconset, icon)
  533.   else
  534.     set_cursor(:picture, icon)
  535.   end
  536.   $mouse_cursor.z = 10001
  537.   $mouse_cursor.x = $mouse_cursor.y = 1000
  538.   $mouse_cursor.ox = 4
  539.   
  540.   def self.show_cursor(value)
  541.     unless value
  542.       @pos[0] = @pos[1] = 600
  543.     end
  544.     $mouse_cursor.visible = value
  545.   end
  546.   
  547.   def self.map_grid
  548.     return nil if @pos == nil
  549.     x = ($game_map.display_x).to_i + (@pos[0] / 32)
  550.     y = ($game_map.display_y).to_i + (@pos[1] / 32)
  551.     return [x, y]
  552.   end
  553.   
  554.   def self.standing?
  555.     return false if @old_px != @pos[0]
  556.     return false if @old_py != @pos[1]
  557.     return true
  558.   end
  559.   
  560.   def self.input_keys
  561.     $game_arrows.mode_on ? type = $game_arrows.in_type : type = Input::C
  562.     keys = {0 => type, 1 => Input::B, 2 => Input::A}
  563.     return keys
  564.   end
  565.   
  566.   def self.object_area?(x, y, width, height)
  567.     return false if @pos.nil?
  568.     return @pos[0].between?(x, width + x) && @pos[1].between?(y, height + y)
  569.   end
  570.   
  571.   def self.position
  572.     return @pos == nil ? [0, 0] : @pos
  573.   end
  574.   
  575.   def self.global_pos
  576.     pos = [0, 0].pack('ll')
  577.     return GetCursorPos.call(pos) == 0 ? nil : pos.unpack('ll')
  578.   end

  579.   def self.screen_to_client(x=0, y=0)
  580.     pos = [x, y].pack('ll')
  581.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  582.   end  

  583.   def self.pos
  584.     global_pos = [0, 0].pack('ll')   
  585.     gx, gy = GetCursorPos.call(global_pos) == 0 ? nil : global_pos.unpack('ll')
  586.     local_pos = [gx, gy].pack('ll')
  587.     x, y = ScreenToClient.call(self.hwnd,
  588.     local_pos) == 0 ? nil : local_pos.unpack('ll')
  589.     begin
  590.       if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
  591.         @old_px, @old_py = x, y
  592.         return x, y
  593.       else
  594.         return -20, -20
  595.       end
  596.     rescue
  597.       return 0, 0
  598.     end
  599.   end  
  600.    
  601.   def self.update
  602.     old_pos = @pos
  603.     @pos = self.pos
  604.     self.input_keys
  605.     if !$mouse_cursor.visible && old_pos != @pos
  606.       $mouse_cursor.visible = true
  607.     end
  608.     if old_pos != [-20, -20] && @pos == [-20, -20]
  609.       ShowCursor.call(1)
  610.     elsif old_pos == [-20, -20] && @pos != [-20, -20]
  611.        ShowCursor.call(0)
  612.     end
  613.     for i in @triggers
  614.       n = GetKeyState.call(i[1])
  615.       if [0, 1].include?(n)
  616.         i[0] = (i[0] > 0 ? i[0] * -1 : 0)
  617.       else
  618.         i[0] = (i[0] > 0 ? i[0] + 1 : 1)
  619.       end
  620.     end
  621.   end
  622.   
  623.   # trigger 定義
  624.   def self.trigger?(id = 0)
  625.     pos = self.pos
  626.     if pos != [-20,-20]
  627.     case id
  628.       when 0  
  629.         return @triggers[id][0] == 1
  630.       when 1  
  631.         if @triggers[1][0] == 1 && !$game_system.menu_disabled
  632.           return @triggers[id][0] == 1
  633.         end
  634.       when 2
  635.         return @triggers[id][0] == 1
  636.       end   
  637.     end
  638.   end
  639.   
  640.   # repeat 定義
  641.   def self.repeat?(id = 0)
  642.     if @triggers[id][0] <= 0
  643.       return false
  644.     else
  645.       return @triggers[id][0] % 5 == 1 && @triggers[id][0] % 5 != 2
  646.     end
  647.   end
  648.   
  649.   #按下定義
  650.   def self.press?(id = 0)
  651.     if @triggers[id][0] <= 0
  652.       return false
  653.     else
  654.       return true
  655.     end
  656.   end
  657.   
  658.   def self.screen_to_client(x=0, y=0)
  659.     pos = [x, y].pack('ll')
  660.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  661.   end

  662.   def self.hwnd
  663.     if @hwnd.nil?
  664.       game_name = "\0" * 256
  665.       GetPrivatePro.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  666.       game_name.delete!("\0")
  667.       @hwnd = Findwindow.call('RGSS Player', game_name)
  668.     end
  669.     return @hwnd
  670.   end
  671.   
  672.   def self.client_size
  673.     rect = [0, 0, 0, 0].pack('l4')
  674.     GetClientRect.call(self.hwnd, rect)
  675.     right, bottom = rect.unpack('l4')[2..3]
  676.     return right, bottom
  677.   end
  678. end

  679. # 輸入模塊混疊
  680. class << Input
  681.   unless self.method_defined?(:falcao21_mouse_update)
  682.     alias_method :falcao21_mouse_update,   :update
  683.     alias_method :falcao21_mouse_trigger?, :trigger?
  684.     alias_method :falcao21_mouse_repeat?,  :repeat?
  685.     alias_method :fal_mouse_input_press?,  :press?
  686.   end
  687.   
  688.   def update
  689.     if $mouse_cursor.visible
  690.       Mouse.update
  691.       $game_arrows.update
  692.       mx, my = *Mouse.position
  693.       $mouse_cursor.x = mx unless mx.nil?
  694.       $mouse_cursor.y = my unless my.nil?   
  695.     end
  696.     falcao21_mouse_update
  697.   end
  698.   
  699.   # trigger
  700.   def trigger?(constant)
  701.     return true if falcao21_mouse_trigger?(constant)
  702.     unless Mouse.pos.nil?
  703.       if Mouse.input_keys.has_value?(constant)
  704.         mouse_trigger = Mouse.input_keys.index(constant)
  705.         return true if Mouse.trigger?(mouse_trigger)
  706.       end
  707.     end
  708.     return false
  709.   end

  710.   # 按下
  711.   def press?(constant)
  712.     return true if fal_mouse_input_press?(constant)
  713.     unless Mouse.pos.nil?
  714.       if Mouse.input_keys.has_value?(constant)
  715.         mouse_trigger = Mouse.input_keys.index(constant)
  716.         return true if Mouse.press?(mouse_trigger)      
  717.       end
  718.     end
  719.     return false
  720.   end
  721.   
  722.   # repeat
  723.   def repeat?(constant)
  724.     return true if falcao21_mouse_repeat?(constant)
  725.     unless Mouse.pos.nil?
  726.       if Mouse.input_keys.has_value?(constant)
  727.         mouse_trigger = Mouse.input_keys.index(constant)     
  728.         return true if Mouse.repeat?(mouse_trigger)
  729.       end
  730.     end
  731.     return false
  732.   end
  733. end

  734. # Here your best friend, 你可以在遊戲中,場景等調用這個腳本.
  735. # $game_arrows.create_arrows(x, y), create it, $game_arrows.dispose, delete it
  736. class Game_Arrow_Selector
  737.   attr_accessor :mode_on
  738.   attr_accessor :in_type
  739.   def initialize
  740.     @mode_on = false
  741.   end

  742.   def create_arrows(x, y)
  743.     return unless @arrows_sprites.nil?
  744.     buttons = {1=> 'UP', 2=> 'RIGHT', 3=> 'DOWN',
  745.     4=> 'LEFT', 5=> 'OK', 6=> 'Cancel'}
  746.     @arrows_sprites = []
  747.     for i in buttons.values
  748.       @arrows_sprites.push(Garrows_Sprites.new(i, x, y))
  749.     end
  750.   end
  751.   
  752.   def dispose
  753.     return if @arrows_sprites.nil?
  754.     for arrow in @arrows_sprites
  755.       arrow.dispose
  756.     end
  757.     @arrows_sprites = nil
  758.     @mode_on = false
  759.   end
  760.   
  761.   def update
  762.     return if @arrows_sprites.nil?
  763.     for arrow in @arrows_sprites
  764.       arrow.update
  765.     end
  766.   end
  767. end

  768. class Garrows_Sprites < Sprite
  769.   def initialize(name, x, y)
  770.     super()
  771.     self.z = 1000
  772.     @px, @py = x, y
  773.     @name = name
  774.     @object_zooming = 0
  775.     @zooming = false
  776.     set_bitmap
  777.     update
  778.   end
  779.   
  780.   def update
  781.     super
  782.     if Mouse.object_area?(self.x + @fix[0], self.y + @fix[1],
  783.       self.bitmap.width + @fix[2], self.bitmap.height + @fix[3])
  784.       $game_arrows.mode_on = true
  785.       $game_arrows.in_type = Input::UP    if @name == 'UP'
  786.       $game_arrows.in_type = Input::DOWN  if @name == 'DOWN'
  787.       $game_arrows.in_type = Input::LEFT  if @name == 'LEFT'
  788.       $game_arrows.in_type = Input::RIGHT if @name == 'RIGHT'
  789.       $game_arrows.in_type = Input::C     if @name == 'OK'
  790.       $game_arrows.in_type = Input::B     if @name == 'Cancel'
  791.       @object_zooming += 1
  792.       @zooming = true
  793.       case @object_zooming
  794.       when 1..10  ; self.zoom_x -= 0.01 ;  self.zoom_y -= 0.01
  795.       when 11..20 ; self.zoom_x += 0.01 ;  self.zoom_y += 0.01
  796.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  797.         @object_zooming = 0
  798.       end
  799.     elsif @object_zooming > 0
  800.       self.zoom_x = 1.0
  801.       self.zoom_y = 1.0
  802.       @object_zooming = 0
  803.     elsif @zooming
  804.       @zooming = false
  805.       $game_arrows.mode_on = false
  806.     end
  807.   end
  808.   
  809.   def set_bitmap
  810.     self.bitmap = Bitmap.new(24, 15) if @name != 'Cancel'
  811.     case @name
  812.     when 'UP'
  813.       self.x = @px + 25 ; self.y = @py - 2
  814.       self.angle = 182  ; @fix = [-23, -18, 0,  0]
  815.     when 'DOWN'
  816.       self.x = @px + 1 ; self.y = @py + 26
  817.       @fix = [0, -4, 0,  0]
  818.     when 'LEFT'
  819.       self.x = @px      ; self.y = @py + 1
  820.       self.angle = - 92 ; @fix = [-14, -4, - 9,  9]
  821.     when 'RIGHT'
  822.       self.x = @px + 26  ; self.y = @py + 26
  823.       self.angle = + 92  ; @fix = [0, - 26, - 9,  9]
  824.     when 'OK'
  825.       self.x = @px + 1  ; self.y = @py + 6
  826.       @fix = [0, -4, 0,  0]
  827.       self.bitmap.font.size = 20
  828.       self.bitmap.draw_text(4, -7, self.bitmap.width, 32, @name)
  829.       return
  830.     when 'Cancel'
  831.       self.x = @px - 11  ; self.y = @py + 42
  832.       @fix = [0, -4, 0,  0]
  833.       self.bitmap = Bitmap.new(50, 15)
  834.       self.bitmap.font.size = 20
  835.       self.bitmap.draw_text(2, -7, self.bitmap.width, 32, @name)
  836.       return
  837.     end
  838.     draw_crappy_triangle(0, 0)
  839.   end
  840.   
  841.   # This method create a crappy triangle pointing down
  842.   def draw_crappy_triangle(px, py)
  843.     color = Color.new(192, 224, 255, 255)
  844.     x, y, w, =  0, 4, 24
  845.     self.bitmap.fill_rect(px + 1, py, 22, 1, color)
  846.     self.bitmap.fill_rect(px,     py + 1, 24, 4, color)
  847.     for i in 1..10
  848.       x += 1; y += 1; w -= 2
  849.       self.bitmap.fill_rect(px + x, py + y,       w, 1, color)
  850.     end
  851.   end
  852. end

  853. $game_arrows = Game_Arrow_Selector.new

  854. # 當輸入的數字
  855. class Game_Interpreter
  856.   alias falcao_setup_num_input setup_num_input
  857.   def setup_num_input(params)
  858.     falcao_setup_num_input(params)
  859.     $game_arrows.create_arrows(256, 194) if $game_message.position == 0
  860.     $game_arrows.create_arrows(256, 340) if $game_message.position == 1
  861.     $game_arrows.create_arrows(256, 180) if $game_message.position == 2
  862.   end
  863. end

  864. # 按OK
  865. class Window_NumberInput < Window_Base
  866.   alias falcao_process_ok process_ok
  867.   def process_ok
  868.     falcao_process_ok
  869.     $game_arrows.dispose
  870.   end
  871. end

  872. # 保存和加載場景
  873. class Scene_File < Scene_MenuBase
  874.   alias falcao47_start start
  875.   alias falcao47_terminate terminate
  876.   
  877.   def start
  878.     falcao47_start
  879.     $game_arrows.create_arrows(210, 166) if Map_Buttons::DisplaySelector
  880.   end
  881.   
  882.   def terminate
  883.     falcao47_terminate
  884.     $game_arrows.dispose if Map_Buttons::DisplaySelector
  885.   end
  886. end

  887. # WASD 移動
  888. module Input
  889.   class << self
  890.     if !method_defined?('vxe_dir4')
  891.       alias vxace_dir4 dir4
  892.     end
  893.     def dir4
  894.       if Map_Buttons::WASD_Movement
  895.         return 2 if (Input.press?(Input::Y))
  896.         return 4 if (Input.press?(Input::X))
  897.         return 6 if (Input.press?(Input::Z))
  898.         return 8 if (Input.press?(Input::R))
  899.       end
  900.       return vxace_dir4
  901.     end
  902.   end
  903. end

  904. # 用鼠標開始事件
  905. class Game_Player < Game_Character
  906.   alias falcao_start_map_event start_map_event
  907.   def start_map_event(x, y, triggers, normal)
  908.     $game_map.events_xy(x, y).each do |event_click|
  909.       return if event_click.check_comment("MOUSE START")
  910.     end  
  911.     falcao_start_map_event(x, y, triggers, normal)
  912.   end
  913. end

  914. # clear pointers when tranfering
  915. class Game_Player < Game_Character
  916.   attr_accessor :clear_mousepointers
  917.   alias falcaomouse_perform_transfer perform_transfer
  918.   def perform_transfer
  919.     @clear_mousepointers = true if $game_map.map_id !=  @new_map_id
  920.     falcaomouse_perform_transfer
  921.   end
  922. end

  923. # Path find
  924. class Game_Character < Game_CharacterBase
  925.   attr_accessor :map, :runpath
  926.   alias pathfind1_ini initialize
  927.   def initialize
  928.     pathfind1_ini
  929.     @map = nil
  930.     @runpath = false
  931.   end
  932.   
  933.   alias pathfind1_up update
  934.   def update
  935.     run_path if @runpath == true
  936.     pathfind1_up
  937.   end
  938.   
  939.   def run_path
  940.     return if moving?
  941.     step = @map[@x,@y]
  942.     if step == 1
  943.       @map = nil
  944.       @runpath = false
  945.       return
  946.     end
  947.     dir = rand(2)
  948.     case dir
  949.     when 0
  950.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  951.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  952.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  953.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  954.     when 1
  955.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  956.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  957.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  958.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  959.     end
  960.   end

  961.   def find_path(x,y)
  962.     sx, sy = @x, @y
  963.     result = setup_map(sx,sy,x,y)
  964.     @runpath = result[0]
  965.     @map = result[1]
  966.     @map[sx,sy] = result[2] if result[2] != nil
  967.   end

  968.   def clear_path
  969.     @map = nil
  970.     @runpath = false
  971.   end
  972.   
  973.   def setup_map(sx,sy,ex,ey)
  974.     map = Table.new($game_map.width, $game_map.height)
  975.     map[ex,ey] = 1
  976.     old_positions = []
  977.     new_positions = []
  978.     old_positions.push([ex, ey])
  979.     depth = 2
  980.     depth.upto(100){|step|
  981.       loop do
  982.         break if old_positions[0] == nil
  983.         x,y = old_positions.shift
  984.         return [true, map, step] if x == sx and y+1 == sy
  985.         if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
  986.           map[x,y + 1] = step
  987.           new_positions.push([x,y + 1])
  988.         end
  989.         return [true, map, step] if x-1 == sx and y == sy
  990.         if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
  991.           map[x - 1,y] = step
  992.           new_positions.push([x - 1,y])
  993.         end
  994.         return [true, map, step] if x+1 == sx and y == sy
  995.         if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
  996.           map[x + 1,y] = step
  997.           new_positions.push([x + 1,y])
  998.         end
  999.         return [true, map, step] if x == sx and y-1 == sy
  1000.         if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
  1001.           map[x,y - 1] = step
  1002.           new_positions.push([x,y - 1])
  1003.         end
  1004.       end
  1005.       old_positions = new_positions
  1006.       new_positions = []
  1007.     }
  1008.     return [false, nil, nil]
  1009.   end
  1010. end
  1011.   
  1012. class Game_Player
  1013.   alias pathfind_player_update update
  1014.   def update
  1015.     clear_path if Input.dir4 != 0
  1016.     pathfind_player_update
  1017.   end
  1018.   
  1019.   alias findpath_perform_transfer perform_transfer
  1020.   def perform_transfer
  1021.     clear_path if $game_map.map_id !=  @new_map_id
  1022.     findpath_perform_transfer
  1023.   end
  1024. end

  1025. # Window selectable (Thanks wora for some lines here)
  1026. class Window_Selectable < Window_Base
  1027.   alias mouse_selection_ini initialize
  1028.   def initialize(*args)
  1029.     mouse_selection_ini(*args)
  1030.     @scroll_wait = 0
  1031.     @cursor_wait = 0
  1032.     @sdelay = 0
  1033.   end

  1034.   alias mouse_selection_update update
  1035.   def update
  1036.     update_mouse_selection if self.active and self.visible
  1037.     @sdelay -= 1 if @sdelay > 0
  1038.     mouse_selection_update
  1039.   end
  1040.   
  1041.   def update_mouse_selection
  1042.     @cursor_wait -= 1 if @cursor_wait > 0
  1043.     (0..self.item_max - 1).each do |i|
  1044.       irect = item_rect(i)
  1045.       irx = self.x + 16 + irect.x - self.ox
  1046.       iry = self.y + 16 + irect.y - self.oy
  1047.       move_cursor(i) if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1048.       update_cursor
  1049.     end
  1050.   end

  1051.   def move_cursor(index)
  1052.     return if [url=home.php?mod=space&uid=370741]@Index[/url] == index
  1053.     @scroll_wait -= 1 if @scroll_wait > 0
  1054.     row1 = @index / self.col_max
  1055.     row2 = index / self.col_max
  1056.     bottom = self.top_row + (self.page_row_max - 1)
  1057.     if index != @index and @sdelay == 0
  1058.       Sound.play_cursor
  1059.       @sdelay = 5
  1060.     end
  1061.     if row1 == self.top_row and row2 < self.top_row
  1062.       return if @scroll_wait > 0
  1063.       @index = [@index - self.col_max, 0].max
  1064.       @scroll_wait = 30
  1065.     elsif row1 == bottom and row2 > bottom
  1066.       return if @scroll_wait > 0
  1067.       @index = [@index + self.col_max, self.item_max - 1].min
  1068.       @scroll_wait = 30
  1069.     else
  1070.       @index = index
  1071.     end
  1072.     return if @cursor_wait > 0
  1073.     @cursor_wait += 2
  1074.   end
  1075. end

  1076. # Name imput selectable
  1077. class Window_NameInput
  1078.   alias mouse_name_select update unless $@
  1079.   def update(*args, &block)
  1080.     mouse_name_select(*args, &block)
  1081.     if self.active and self.visible
  1082.       (0..self.table[@page].size - 1).each do |i|
  1083.       irect = item_rect(i)
  1084.       irx = self.x + 16 + irect.x - self.ox
  1085.       iry = self.y + 16 + irect.y - self.oy
  1086.       @index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1087.       end
  1088.     end
  1089.   end
  1090. end

  1091. # Window party command
  1092. class Window_PartyCommand < Window_Command
  1093.   def update_mouse_selection
  1094.     (0..self.item_max - 1).each do |i|
  1095.     irect = item_rect(i)
  1096.     irx = self.viewport.ox + 16 + irect.x - self.ox
  1097.     iry = 288 + 16 + irect.y - self.oy
  1098.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1099.     end
  1100.   end
  1101. end

  1102. # Window actor command
  1103. class Window_ActorCommand < Window_Command
  1104.   def update_mouse_selection
  1105.     (0..self.item_max - 1).each do |i|
  1106.     irect = item_rect(i)
  1107.     add = 288
  1108.     add = 156 if !$imported[:ve_animated_battle].nil? &&  
  1109.     $imported[:ve_animated_battle] > 1
  1110.     irx = self.viewport.ox + add + 16 + irect.x
  1111.     iry = 288 + 16 + irect.y
  1112.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1113.     end
  1114.   end
  1115. end
复制代码

点评

這個可輕易達到你的要求  发表于 2013-8-27 23:09
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
135 小时
注册时间
2012-6-14
帖子
43
7
 楼主| 发表于 2013-8-28 09:21:53 | 只看该作者
感谢上面的热情回复

对话选项要求只是我比较习惯这样的...

地图选项是希望能加快游戏进程...

实际上这两个功能并非主要功能...我主要还是要做RPG游戏阿XD
@tseyik
这个鼠标脚本跟我的标题脚本相冲...
而且常常按了没反应OTZ
其实我本来就有一个鼠标脚本了...
能不能就单独把那个判断地图按钮的功能独立出来呢?

又或者可以麻烦帮我看看我在用的鼠标脚本有没有类似的功能吗?
因为看到您提供的脚本我才知道脚本有可能有这功能...
可是我看不懂...找不出来
  1. =begin #=======================================================================

  2.   Sion Mouse System v1.3e
  3.   
  4.   Changlog
  5.   
  6.   2013.4.21 v1.3f
  7.    
  8.     1.3f 捲動地圖 bug 修正
  9.    
  10.     1.3e: 邏輯優化;提供解除滑鼠固定的介面
  11.              在事件中執行腳本 Mouse.lock_mouse_in_screen 將滑鼠鎖定在螢幕內
  12.                               Mouse.unlock_mouse_in_screen 解除鎖定

  13.     1.3f: bug修正
  14.   
  15.     1.3d: 常數設置增加:Menu_Set_Pos,用來設置打開功能表時滑鼠是否移動到游標處以及
  16.           關閉功能表時,滑鼠是否移動到原來的位置。

  17.     1.3c: 打開功能表、游標移動時滑鼠會移動到游標位置處

  18.     1.3b: 修正一些罕見的bug;

  19.     1.3a: 代碼小修改;
  20.           加入了滑鼠點擊啟動事件的功能,
  21.           在事件中加入“注釋”: 滑鼠啟動  ,
  22.           該事件將無法用其他方式啟動,只能用滑鼠左鍵點擊啟動。
  23.   
  24.   2013.2.12 v1.2

  25.     尋路邏輯優化;
  26.     優化了事件判斷,現在點擊事件附近的格子,移動到指定點後不會觸發該事件了;
  27.     現在支援用滑鼠來操作載具了。

  28.   2013.2.8 v1.1

  29.     優化了事件判斷,現在可以方便地啟動櫃檯後面的事件;
  30.     修復了某些功能表(例如更換裝備的功能表)掉幀的問題;
  31.     移動時,路徑指示點的繪製更加穩定;
  32.     現在支援默認存檔畫面的滑鼠操作了。


  33.   OrigenVersion
  34.   
  35.     2013.2.7 v1.0

  36.   主要功能

  37.       使用滑鼠進行各種操作...
  38.       將滑鼠鎖定在遊戲視窗內
  39.       自動尋路,按住 D 鍵可以擴大尋路的範圍
  40.       雙擊滑鼠進行衝刺
  41.       更改地圖捲動方式以適應滑鼠移動
  42.       變數輸入框改良

  43.   ★ 滑鼠指標圖片 Cursor.png 放入 Graphics\System 文件夾

  44.   ★ 路徑點指示圖片 $Arrow.png 放入 Graphics\Characters 文件夾

  45.   ★ 如果未放入會彈出提示,並使用RM自帶圖片代替缺失檔;該提示可以在下面關閉


  46. =end #★★★★★★★★ 可能需要設置的參數都在下面用“★”標出了 ★★★★★★★★★★


  47. $no_arrowpic_warn = true   # ★ 設置為false不彈出圖片缺失提示

  48. #==============================================================================
  49. # ■ 常數設置
  50. #==============================================================================
  51. module KsOfSion
  52.   Clip_Cursor    = true    # ★ 滑鼠鎖定在遊戲視窗內,需要關閉設置為false
  53.   Dbclick_Frame  = 15      # ★ 雙擊的最大間隔幀數。在地圖畫面雙擊進行奔跑
  54.   New_Scroll     = true    # ★ 更改地圖捲動方式,需要關閉設置為false
  55.   Map_Scroll_Spd = 1.0     # ★ 更改地圖捲動速率,請確保此值為大於0的float變數
  56.   Menu_Set_Pos   = true    # ★ 打開功能表時將滑鼠移動到游標處
  57.   Break_Steps    = 30      # ★ 滑鼠尋路最大步數,防止路徑太長導致卡幀
  58. #                             “30” 是默認顯示格子數 長(17) + 寬(13)
  59.   Find_Path_Key  = :Z      # ★ 擴大尋路範圍至全地圖按鍵 :Z 對應 D鍵
  60. #                               RM幾個內置的空鍵位 (:X = A)(:Y = S)(:Z = D)
  61. end

  62. #==============================================================================
  63. # ■ 用來顯示路徑點的類
  64. #==============================================================================
  65. class Move_Sign < Game_Character
  66.   #--------------------------------------------------------------------------
  67.   # ● 設置目標點指示圖的各種參數,請注意要使用的圖片是行走圖
  68.   #--------------------------------------------------------------------------
  69.   def init_public_members
  70.     @character_name  = '!$Arrow'# ★ 路徑點箭頭,置於.\Graphics\Characters文件夾
  71.     @character_index = 0        # ★ 圖片索引。$開頭的行走圖設為0
  72.     @move_speed      = 8        # ★ 踏步速度
  73.     @step_anime      = true     # ★ 踏步動畫(如果想使用靜態圖示就關閉這個)
  74.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
  75.     @blend_type      = 0        # ★ 圖片合成方式,默認為0(正常)
  76.     @direction       = 2        # ★ 朝向,2 4 6 8 分別對應行走圖第1 2 3 4 列
  77.     @priority_type   = 1        # ★ 優先順序(默認與人物同級:1)


  78. # ★★★★★★★★★★★★★★★ 參數設置完畢 ★★★★★★★★★★★★★★★★★★★


  79.     # 如果 $Arrow.png 不在對應的檔夾內,彈出提示,並使用遊戲一張內置的行走圖
  80.     unless File.exist?('Graphics/Characters/' + @character_name + '.png')

  81.       if $no_arrowpic_warn
  82.         Mouse::Show_Cursor.call(1)
  83.         msgbox('未找到文件:Graphics\Characters\\' + @character_name + '.png

  84. “路徑指示點”將使用遊戲自帶圖片

  85. 該提示可以在腳本內關閉')
  86.         Mouse::Show_Cursor.call(0)
  87.         $no_arrowpic_warn = false
  88.       end
  89.       @character_name  = '!Flame'
  90.       @character_index = 6

  91.     end
  92.     @direction_fix = false  # 固定朝向
  93.     @move_frequency = 6     # 移動頻率
  94.     @walk_anime = true      # 步行動畫
  95.     @pattern = 1            # 圖案
  96.     @through = true         # 穿透
  97.     @bush_depth = 0         # 草木深度
  98.     @animation_id = 0       # 動畫 ID
  99.     @balloon_id = 0         # 心情 ID
  100.     @transparent = true     # 透明
  101.     @id = 0
  102.     @x = 0
  103.     @y = 0
  104.     @real_x = 0
  105.     @real_y = 0
  106.     @tile_id = 0
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● 定義實例變數
  110.   #--------------------------------------------------------------------------
  111.   attr_accessor :direction
  112. end

  113. #==============================================================================
  114. # ■ Module Mouse
  115. #==============================================================================
  116. module Mouse
  117.   #--------------------------------------------------------------------------
  118.   # ● API
  119.   #--------------------------------------------------------------------------
  120.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
  121.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  122.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
  123.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
  124.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
  125.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
  126.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
  127.   Window_Hwnd       = Get_Active_Window.call

  128. class << self
  129.   #--------------------------------------------------------------------------
  130.   # ● 初始化
  131.   #--------------------------------------------------------------------------
  132.   def init
  133.     lock_mouse_in_screen if KsOfSion::Clip_Cursor
  134.     @left_state = 0
  135.     @right_state = 0
  136.     @ck_count = 0 # 幀數計,單擊以後從0開始
  137.     @dk_count = 0 # 用於雙擊的判定
  138.     @clicked = false
  139.     creat_mouse_sprite
  140.     update
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 滑鼠指標精靈
  144.   #--------------------------------------------------------------------------
  145.   def creat_mouse_sprite
  146.     @mouse_sprite = Sprite.new
  147.     if File.exist?('Graphics/System/Cursor.png')
  148.       @mouse_sprite.bitmap = Bitmap.new('Graphics/System/Cursor')
  149.     else

  150.       if $no_arrowpic_warn
  151.         msgbox('未找到文件:Graphics\System\Cursor.png

  152. “滑鼠指標”將使用遊戲自帶圖片

  153. 該提示可以在腳本內關閉')
  154.       end

  155.       @mouse_sprite.bitmap = Bitmap.new(24, 24)
  156.       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
  157.         Rect.new(5 * 24, 24 * 24, 24, 24))
  158.     end
  159.     @mouse_sprite.z = 9999
  160.     Show_Cursor.call(0)
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● 更新
  164.   #--------------------------------------------------------------------------
  165.   def update
  166.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
  167.     left_state  = Get_Key_State.call(0x01)
  168.     left_state[7] == 1 ? @left_state +=1 : @left_state = 0
  169.     right_state = Get_Key_State.call(0x02)
  170.     right_state[7] == 1 ? @right_state +=1 : @right_state = 0
  171.     update_double_click
  172.     @left_state == 1 ? @ck_count = 0 : @ck_count += 1
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ● 獲取滑鼠座標
  176.   #--------------------------------------------------------------------------
  177.   def get_mouse_pos
  178.     arg = [0, 0].pack('ll')
  179.     Get_Cursor_Pos.call(arg)
  180.     Screen_To_Client.call(Window_Hwnd, arg)
  181.     x, y = arg.unpack('ll')
  182.     return x, y
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 將滑鼠固定在螢幕內
  186.   #--------------------------------------------------------------------------
  187.   def lock_mouse_in_screen
  188.     arg = [0, 0].pack('ll')
  189.     Screen_To_Client.call(Window_Hwnd, arg)
  190.     x, y  = arg.unpack('ll')
  191.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 解除滑鼠固定
  195.   #--------------------------------------------------------------------------
  196.   def unlock_mouse_in_screen
  197.     Clip_Cursor.call(0)
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ● 滑鼠雙擊判定
  201.   #--------------------------------------------------------------------------
  202.   def update_double_click
  203.     @clicked = true if @left_state == 1
  204.     if @dk_count > 0 && @left_state == 1
  205.       @dk_count = 0; @clicked = false
  206.       return @double_click = true
  207.     elsif @clicked
  208.       if @dk_count < KsOfSion::Dbclick_Frame
  209.         @dk_count += 1
  210.       else
  211.         @dk_count = 0; @clicked = false
  212.       end
  213.     end
  214.     @double_click = false
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● 按鍵被按下就返回true
  218.   #--------------------------------------------------------------------------
  219.   def press?(button)
  220.     case button
  221.       when 0x01; return !@left_state.zero?
  222.       when 0x02; return !@right_state.zero?
  223.     end
  224.     return false
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ● 按鍵剛被按下則返回true
  228.   #--------------------------------------------------------------------------
  229.   def trigger?(button)
  230.     case button
  231.       when 0x01; return @left_state == 1
  232.       when 0x02; return @right_state == 1
  233.     end
  234.     return false
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 持續按住鍵一段時間的話,每隔5幀返回一次true
  238.   #--------------------------------------------------------------------------
  239.   def repeat?(button)
  240.     case button
  241.       when 0x01; return @left_state == 1 ||
  242.         (@left_state > 22 && (@left_state % 6).zero?)
  243.       when 0x02; return @right_state == 1 ||
  244.         (@right_state > 22 && (@right_state % 6).zero?)
  245.     end
  246.     return false
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● 判斷是否雙擊滑鼠
  250.   #--------------------------------------------------------------------------
  251.   def double_click?
  252.     @double_click
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 獲取@ck_count(每一幀+=1,單擊後重置為0)
  256.   #--------------------------------------------------------------------------
  257.   def click_count
  258.     @ck_count
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ● 獲取@left_state(按住左鍵每一幀+=1)
  262.   #--------------------------------------------------------------------------
  263.   def left_state
  264.     @left_state
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● 獲取滑鼠的x座標
  268.   #--------------------------------------------------------------------------
  269.   def mouse_x
  270.     @mouse_sprite.x
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ● 獲取滑鼠的y座標
  274.   #--------------------------------------------------------------------------
  275.   def mouse_y
  276.     @mouse_sprite.y
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● 設置滑鼠座標
  280.   #--------------------------------------------------------------------------
  281.   def set_mouse_pos(new_x, new_y)
  282.     arg = [0, 0].pack('ll')
  283.     Screen_To_Client.call(Window_Hwnd, arg)
  284.     x, y  = arg.unpack('ll')
  285.     Set_Cursor_Pos.call(new_x - x, new_y - y)
  286.   end
  287. end #end of: class << self

  288. end

  289. #==============================================================================
  290. # ■ SceneManager
  291. #==============================================================================
  292. class << SceneManager
  293.   #--------------------------------------------------------------------------
  294.   # ● alias
  295.   #--------------------------------------------------------------------------
  296.   unless self.method_defined?(:sion_mouse_run)
  297.     alias_method :sion_mouse_run, :run
  298.     alias_method :sion_mouse_call, :call
  299.     alias_method :sion_mouse_return, :return
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● 運行
  303.   #--------------------------------------------------------------------------
  304.   def run
  305.     Mouse.init
  306.     sion_mouse_run
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   # ● 切換
  310.   #--------------------------------------------------------------------------
  311.   def call(scene_class)
  312.     $game_map.prepare_reset_mouse_pos if @scene.instance_of?(Scene_Map)
  313.     sion_mouse_call(scene_class)
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 返回到上一個場景
  317.   #--------------------------------------------------------------------------
  318.   def return
  319.     sion_mouse_return
  320.     $game_map.reset_mouse_pos if KsOfSion::Menu_Set_Pos &&
  321.       @scene.instance_of?(Scene_Map)
  322.   end
  323. end

  324. #==============================================================================
  325. # ■ Module Input
  326. #==============================================================================
  327. class << Input
  328.   #--------------------------------------------------------------------------
  329.   # ● alias
  330.   #--------------------------------------------------------------------------
  331.   unless self.method_defined?(:sion_mouse_update)
  332.     alias_method :sion_mouse_update,   :update
  333.     alias_method :sion_mouse_press?,   :press?
  334.     alias_method :sion_mouse_trigger?, :trigger?
  335.     alias_method :sion_mouse_repeat?,  :repeat?
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 更新滑鼠
  339.   #--------------------------------------------------------------------------
  340.   def update
  341.     Mouse.update
  342.     sion_mouse_update
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # ● 按鍵被按下就返回true
  346.   #--------------------------------------------------------------------------
  347.   def press?(key)
  348.     return true if sion_mouse_press?(key)
  349.     return Mouse.press?(0x01) if key == :C
  350.     return Mouse.press?(0x02) if key == :B
  351.     return false
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ● 按鍵剛被按下則返回true
  355.   #--------------------------------------------------------------------------
  356.   def trigger?(key)
  357.     return true if sion_mouse_trigger?(key)
  358.     return Mouse.trigger?(0x01) if key == :C
  359.     return Mouse.trigger?(0x02) if key == :B
  360.     return false
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 持續按住鍵一段時間的話,每隔5幀返回一次true
  364.   #--------------------------------------------------------------------------
  365.   def repeat?(key)
  366.     return true if sion_mouse_repeat?(key)
  367.     return Mouse.repeat?(0x01) if key == :C
  368.     return Mouse.repeat?(0x02) if key == :B
  369.     return false
  370.   end
  371. end


  372. #==============================================================================
  373. # ■ Window_Selectable
  374. #------------------------------------------------------------------------------
  375. #  擁有游標移動、滾動功能的視窗
  376. #==============================================================================
  377. class Window_Selectable
  378.   #--------------------------------------------------------------------------
  379.   # ● 初始化
  380.   #--------------------------------------------------------------------------
  381.   alias sion_mouse_initialize initialize
  382.   def initialize(x, y, width, height)
  383.     sion_mouse_initialize(x, y, width, height)
  384.     @move_state = 0
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 更新
  388.   #--------------------------------------------------------------------------
  389.   alias sion_mouse_update update
  390.   def update
  391.     sion_mouse_update
  392.     update_mouse_cursor
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # ● 啟動後設置滑鼠到index位置
  396.   #--------------------------------------------------------------------------
  397.   def activate
  398.     @need_set_pos = true if KsOfSion::Menu_Set_Pos
  399.     super
  400.   end
  401.   #--------------------------------------------------------------------------
  402.   # ● 更新滑鼠和游標的位置
  403.   #--------------------------------------------------------------------------
  404.   def update_mouse_cursor
  405.     if active
  406.       if @need_set_pos
  407.         @need_set_pos = nil
  408.         set_mouse_pos
  409.       elsif cursor_movable?
  410.         Input.dir4.zero? ? set_cursor : set_mouse_pos
  411.       end
  412.     end
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 將游標設置到滑鼠所在的位置,附帶捲動功能表的功能
  416.   #--------------------------------------------------------------------------
  417.   def set_cursor
  418.     mouse_row, mouse_col = mouse_window_area
  419.     if    mouse_row == -1
  420.       @move_state += 1 if need_scroll?
  421.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand?
  422.     elsif mouse_row == -2
  423.       @move_state += 1 if need_scroll?
  424.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand?
  425.     elsif mouse_col == -1
  426.       @move_state += 1 if need_scroll?
  427.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand?
  428.     elsif mouse_col == -2
  429.       @move_state += 1 if need_scroll?
  430.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand?
  431.     else
  432.       @move_state = 0
  433.       new_index = (top_row + mouse_row) * col_max + mouse_col
  434.       select(new_index) if new_index < item_max && new_index != @index
  435.     end
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● 判斷滑鼠位於功能表的第幾行、第幾列
  439.   #--------------------------------------------------------------------------
  440.   def mouse_window_area
  441.     if viewport.nil? # necessary!
  442.       vp_x, vp_y = 0, 0
  443.     else
  444.       vp_x = viewport.rect.x - viewport.ox
  445.       vp_y = viewport.rect.y - viewport.oy
  446.     end
  447.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  448.     item_x1 = vp_x + x + standard_padding
  449.     item_y1 = vp_y + y + standard_padding
  450.     item_x2 = vp_x + x - standard_padding + width
  451.     item_y2 = vp_y + y - standard_padding + height
  452.     if mouse_x < item_x1
  453.       mouse_col = -1
  454.     elsif mouse_x > item_x2
  455.       mouse_col = -2
  456.     else
  457.       mouse_col = col_max * (mouse_x - item_x1) / (item_x2 - item_x1)
  458.     end
  459.     if mouse_y < item_y1
  460.       mouse_row = -1
  461.     elsif mouse_y > item_y2
  462.       mouse_row = -2
  463.     else
  464.       mouse_row = page_row_max * (mouse_y - item_y1 - 1) / (item_y2 - item_y1)
  465.     end
  466.     return mouse_row, mouse_col
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # ● 方向鍵移動游標時將滑鼠移動到對應的游標位置
  470.   #--------------------------------------------------------------------------
  471.   def set_mouse_pos
  472.     if viewport.nil? # necessary!
  473.       vp_x, vp_y = 0, 0
  474.     else
  475.       vp_x = viewport.rect.x - viewport.ox
  476.       vp_y = viewport.rect.y - viewport.oy
  477.     end
  478.     item_x1 = vp_x + x + standard_padding
  479.     item_y1 = vp_y + y + standard_padding
  480.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url] < 0 ? 0 : @index
  481.     row = get_index / col_max - top_row
  482.     col = get_index % col_max
  483.     new_x = item_x1 + item_width * (col + 0.5)
  484.     new_y = item_y1 + item_height * (row + 0.5)
  485.     Mouse.set_mouse_pos(new_x, new_y)
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # ● 判斷功能表是否需要捲動
  489.   #--------------------------------------------------------------------------
  490.   def need_scroll?
  491.     item_max > col_max * page_row_max
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 判斷是否為水準捲動菜單
  495.   #--------------------------------------------------------------------------
  496.   def is_horzcommand?
  497.     return false
  498.   end
  499. end

  500. class Window_HorzCommand
  501.   #--------------------------------------------------------------------------
  502.   # ● 判斷是否為水準捲動菜單
  503.   #--------------------------------------------------------------------------
  504.   def is_horzcommand?
  505.     return true
  506.   end
  507. end

  508. #==============================================================================
  509. # ■ Window_NameInput
  510. #------------------------------------------------------------------------------
  511. #  名字輸入畫面中,選擇文字的視窗。
  512. #==============================================================================
  513. class Window_NameInput
  514.   #--------------------------------------------------------------------------
  515.   # ● 設置列數
  516.   #--------------------------------------------------------------------------
  517.   def col_max
  518.     return 10
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ● 設置填充的Item個數
  522.   #--------------------------------------------------------------------------
  523.   def item_max
  524.     return 90
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 設置填充的Item個數
  528.   #--------------------------------------------------------------------------
  529.   def item_width
  530.     return 32
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ● 判斷滑鼠位於功能表的第幾行、第幾列
  534.   #--------------------------------------------------------------------------
  535.   def mouse_window_area
  536.     if viewport.nil?
  537.       vp_x, vp_y = 0, 0
  538.     else
  539.       vp_x = viewport.rect.x - viewport.ox
  540.       vp_y = viewport.rect.y - viewport.oy
  541.     end
  542.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  543.     item_x1 = vp_x + x + standard_padding
  544.     item_y1 = vp_y + y + standard_padding
  545.     item_x2 = vp_x + x - standard_padding + width
  546.     item_y2 = vp_y + y - standard_padding + height
  547.     if mouse_x < item_x1
  548.       mouse_col = -1
  549.     elsif mouse_x > item_x2
  550.       mouse_col = -2
  551.     elsif mouse_x < item_x1 + 160
  552.       mouse_col = (mouse_x - item_x1)/32
  553.     elsif mouse_x > item_x2 - 160
  554.       mouse_col = 9 - (item_x2 - mouse_x)/32
  555.     else
  556.       mouse_col = mouse_x > x + width/2 ? 5 : 4
  557.     end
  558.     if mouse_y < item_y1
  559.       mouse_row = -1
  560.     elsif mouse_y > item_y2
  561.       mouse_row = -2
  562.     else
  563.       mouse_row = page_row_max * (mouse_y - item_y1 - 1)/(item_y2 - item_y1)
  564.     end
  565.     return mouse_row, mouse_col
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ● 方向鍵移動游標時將滑鼠移動到對應的游標位置
  569.   #--------------------------------------------------------------------------
  570.   def set_mouse_pos
  571.     if viewport.nil? # necessary!
  572.       vp_x, vp_y = 0, 0
  573.     else
  574.       vp_x = viewport.rect.x - viewport.ox
  575.       vp_y = viewport.rect.y - viewport.oy
  576.     end
  577.     item_x1 = vp_x + x + standard_padding
  578.     item_y1 = vp_y + y + standard_padding
  579.     get_index = @index < 0 ? 0 : @index
  580.     row = get_index / col_max - top_row
  581.     col = get_index % col_max
  582.     new_x = item_x1 + item_width * (col + 0.5)
  583.     new_y = item_y1 + item_height * (row + 0.5)
  584.     new_x += 14 if col > 4
  585.     Mouse.set_mouse_pos(new_x, new_y)
  586.   end
  587. end

  588. #==============================================================================
  589. # ■ Window_NumberInput
  590. #------------------------------------------------------------------------------
  591. #  重寫了數值輸入的方法以適應滑鼠
  592. #==============================================================================
  593. class Window_NumberInput < Window_Base
  594.   #--------------------------------------------------------------------------
  595.   # ● 定義實例變數
  596.   #--------------------------------------------------------------------------
  597.   attr_reader :extra_window
  598.   #--------------------------------------------------------------------------
  599.   # ● 初始化
  600.   #--------------------------------------------------------------------------
  601.   alias sion_mouse_initialize initialize
  602.   def initialize(arg)
  603.     sion_mouse_initialize(arg)
  604.     create_extra_window
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ● 啟動
  608.   #--------------------------------------------------------------------------
  609.   alias sion_mouse_start start
  610.   def start
  611.     sion_mouse_start
  612.     deactivate
  613.     extra_start
  614.   end
  615.   #--------------------------------------------------------------------------
  616.   # ● 創建新的數值輸入視窗
  617.   #--------------------------------------------------------------------------
  618.   def create_extra_window
  619.     @extra_window = Window_NumberInput_Ex.new
  620.     @extra_window.x = (Graphics.width - @extra_window.width) / 2
  621.     @extra_window.number_proc  = Proc.new {|n| [url=home.php?mod=space&uid=27178]@Number[/url] = n }
  622.     @extra_window.index_proc   = Proc.new {|n| @index = n }
  623.     @extra_window.close_proc   = Proc.new { close }
  624.     @extra_window.refresh_proc = Proc.new { refresh }
  625.   end
  626.   #--------------------------------------------------------------------------
  627.   # ● 啟動新窗口
  628.   #--------------------------------------------------------------------------
  629.   def extra_start
  630.     case $game_message.position
  631.       when 0; @extra_window.y = y + height + 4
  632.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
  633.       when 2; @extra_window.y = y - @extra_window.height - 4
  634.       else  ; @extra_window.y = 8
  635.     end
  636.     @extra_window.variable_id = $game_message.num_input_variable_id
  637.     @extra_window.digits_max  = @digits_max
  638.     @extra_window.number      = @number
  639.     @extra_window.open
  640.     @extra_window.activate
  641.   end
  642.   #--------------------------------------------------------------------------
  643.   # ● 更新
  644.   #--------------------------------------------------------------------------
  645.   def update
  646.     super
  647.     @extra_window.update
  648.     update_cursor
  649.   end
  650.   #--------------------------------------------------------------------------
  651.   # ● 關閉窗口
  652.   #--------------------------------------------------------------------------
  653.   def close
  654.     super
  655.     @extra_window.close
  656.     @extra_window.deactivate
  657.   end
  658. end

  659. #==============================================================================
  660. # ■ Window_NumberInput_Ex
  661. #------------------------------------------------------------------------------
  662. #  新的數值輸入視窗(NewClass)
  663. #==============================================================================
  664. class Window_NumberInput_Ex < Window_Selectable
  665.   #--------------------------------------------------------------------------
  666.   # ● 定義實例變數
  667.   #--------------------------------------------------------------------------
  668.   attr_accessor :number_proc
  669.   attr_accessor :index_proc
  670.   attr_accessor :close_proc
  671.   attr_accessor :refresh_proc
  672.   attr_accessor :number
  673.   attr_accessor :digits_max
  674.   attr_accessor :variable_id
  675.   #--------------------------------------------------------------------------
  676.   # ● 數字表
  677.   #--------------------------------------------------------------------------
  678.   TABLE = [  7,  8,  9,
  679.              4,  5,  6,
  680.              1,  2,  3,
  681.             '←',0,'確定',]
  682.   #--------------------------------------------------------------------------
  683.   # ● 初始化對象
  684.   #--------------------------------------------------------------------------
  685.   def initialize
  686.     super(0, 0, 120, fitting_height(4))
  687.     self.openness = 0
  688.     @index = 0
  689.     @number = 0
  690.     @old_window_index = 0
  691.     @digits_max = 0
  692.     12.times {|i| draw_text(item_rect(i), TABLE[i], 1) }
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # ● 獲取項目的繪製矩形
  696.   #--------------------------------------------------------------------------
  697.   def item_rect(index)
  698.     rect = Rect.new
  699.     rect.x = index % 3 * 32
  700.     rect.y = index / 3 * line_height
  701.     rect.width = 32
  702.     rect.height = line_height
  703.     return rect
  704.   end
  705.   #--------------------------------------------------------------------------
  706.   # ● 將游標設置到滑鼠所在的位置
  707.   #--------------------------------------------------------------------------
  708.   def set_cursor
  709.     mouse_row, mouse_col = mouse_window_area
  710.     if mouse_row >= 0 && mouse_col >= 0
  711.       new_index = mouse_row * 3 + mouse_col
  712.       select(new_index) if new_index <= 11
  713.     end
  714.   end
  715.   #--------------------------------------------------------------------------
  716.   # ● 判斷滑鼠位於新數值輸入視窗的第幾行、第幾列
  717.   #--------------------------------------------------------------------------
  718.   def mouse_window_area
  719.     if viewport.nil?
  720.       vp_x, vp_y = 0, 0
  721.     else
  722.       vp_x = viewport.rect.x - viewport.ox
  723.       vp_y = viewport.rect.y - viewport.oy
  724.     end
  725.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  726.     item_x1 = vp_x + x + standard_padding
  727.     item_y1 = vp_y + y + standard_padding
  728.     item_x2 = vp_x + x - standard_padding + width
  729.     item_y2 = vp_y + y - standard_padding + height
  730.     if mouse_x < item_x1
  731.       mouse_col = -1
  732.     elsif mouse_x > item_x2
  733.       mouse_col = -2
  734.     else
  735.       mouse_col = (mouse_x - item_x1) / 32
  736.     end
  737.     if mouse_y < item_y1
  738.       mouse_row = -1
  739.     elsif mouse_y > item_y2
  740.       mouse_row = -2
  741.     else
  742.       mouse_row = 4 * (mouse_y - item_y1 - 1) / (item_y2 - item_y1)
  743.     end
  744.     return mouse_row, mouse_col
  745.   end
  746.   #--------------------------------------------------------------------------
  747.   # ● 獲取文字
  748.   #--------------------------------------------------------------------------
  749.   def get_number
  750.     return false if @index == 9 || @index == 11
  751.     return TABLE[@index]
  752.   end
  753.   #--------------------------------------------------------------------------
  754.   # ● 判定游標位置是否在“退格”上
  755.   #--------------------------------------------------------------------------
  756.   def is_delete?
  757.     @index == 9
  758.   end
  759.   #--------------------------------------------------------------------------
  760.   # ● 判定游標位置是否在“確定”上
  761.   #--------------------------------------------------------------------------
  762.   def is_ok?
  763.     @index == 11
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● 更新游標
  767.   #--------------------------------------------------------------------------
  768.   def update_cursor
  769.     cursor_rect.set(item_rect(@index))
  770.   end
  771.   #--------------------------------------------------------------------------
  772.   # ● 判定游標是否可以移動
  773.   #--------------------------------------------------------------------------
  774.   def cursor_movable?
  775.     active
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # ● 游標向下移動
  779.   #     wrap : 允許迴圈
  780.   #--------------------------------------------------------------------------
  781.   def cursor_down(wrap)
  782.     if @index < 9 or wrap
  783.       @index = (index + 3) % 12
  784.     end
  785.   end
  786.   #--------------------------------------------------------------------------
  787.   # ● 游標向上移動
  788.   #     wrap : 允許迴圈
  789.   #--------------------------------------------------------------------------
  790.   def cursor_up(wrap)
  791.     if @index >= 3 or wrap
  792.       @index = (index + 9) % 12
  793.     end
  794.   end
  795.   #--------------------------------------------------------------------------
  796.   # ● 游標向右移動
  797.   #     wrap : 允許迴圈
  798.   #--------------------------------------------------------------------------
  799.   def cursor_right(wrap)
  800.     if @index % 3 < 2
  801.       @index += 1
  802.     elsif wrap
  803.       @index -= 2
  804.     end
  805.   end
  806.   #--------------------------------------------------------------------------
  807.   # ● 游標向左移動
  808.   #     wrap : 允許迴圈
  809.   #--------------------------------------------------------------------------
  810.   def cursor_left(wrap)
  811.     if @index % 3 > 0
  812.       @index -= 1
  813.     elsif wrap
  814.       @index += 2
  815.     end
  816.   end
  817.   #--------------------------------------------------------------------------
  818.   # ● 處理游標的移動
  819.   #--------------------------------------------------------------------------
  820.   def process_cursor_move
  821.     super
  822.     update_cursor
  823.   end
  824.   #--------------------------------------------------------------------------
  825.   # ● “確定”、“刪除字元”和“取消輸入”的處理
  826.   #--------------------------------------------------------------------------
  827.   def process_handling
  828.     return unless open? && active
  829.     process_jump if Input.trigger?(:A)
  830.     process_back if Input.repeat?(:B)
  831.     process_ok   if Input.trigger?(:C)
  832.   end
  833.   #--------------------------------------------------------------------------
  834.   # ● 跳轉“確定”
  835.   #--------------------------------------------------------------------------
  836.   def process_jump
  837.     if @index != 11
  838.       @index = 11
  839.       Sound.play_cursor
  840.     end
  841.   end
  842.   #--------------------------------------------------------------------------
  843.   # ● 後退一個字元
  844.   #--------------------------------------------------------------------------
  845.   def process_back
  846.     Sound.play_cancel
  847.     place = 10 ** (@digits_max - 1 - @old_window_index)
  848.     n = (@number / place) % 10
  849.     @number -= n * place
  850.     @number_proc.call(@number)
  851.     @old_window_index -= 1 if @old_window_index > 0
  852.     @index_proc.call(@old_window_index)
  853.     @refresh_proc.call
  854.   end
  855.   #--------------------------------------------------------------------------
  856.   # ● 按下確定鍵時的處理
  857.   #--------------------------------------------------------------------------
  858.   def process_ok
  859.     if get_number
  860.       Sound.play_cursor
  861.       place = 10 ** (@digits_max - 1 - @old_window_index)
  862.       n = get_number - (@number / place) % 10
  863.       @number += n * place
  864.       @number_proc.call(@number)
  865.       @old_window_index += 1 if @old_window_index < @digits_max - 1
  866.       @index_proc.call(@old_window_index)
  867.       @refresh_proc.call
  868.     elsif is_delete?
  869.       process_back
  870.     elsif is_ok?
  871.       on_input_ok
  872.     end
  873.   end
  874.   #--------------------------------------------------------------------------
  875.   # ● 確定
  876.   #--------------------------------------------------------------------------
  877.   def on_input_ok
  878.     @index = 0
  879.     @old_window_index = 0
  880.     $game_variables[@variable_id] = @number
  881.     Sound.play_ok
  882.     @close_proc.call
  883.   end
  884.   #--------------------------------------------------------------------------
  885.   # ● 方向鍵移動游標時將滑鼠移動到對應的游標位置
  886.   #--------------------------------------------------------------------------
  887.   def set_mouse_pos
  888.     if viewport.nil? # necessary!
  889.       vp_x, vp_y = 0, 0
  890.     else
  891.       vp_x = viewport.rect.x - viewport.ox
  892.       vp_y = viewport.rect.y - viewport.oy
  893.     end
  894.     item_x1 = vp_x + x + standard_padding
  895.     item_y1 = vp_y + y + standard_padding
  896.     get_index = @index < 0 ? 0 : @index
  897.     new_x = item_x1 + 32 * (get_index % 3 + 0.5)
  898.     new_y = item_y1 + 24 * (get_index / 3 + 0.5)
  899.     Mouse.set_mouse_pos(new_x, new_y)
  900.   end
  901. end

  902. #==============================================================================
  903. # ■ Window_Message
  904. #------------------------------------------------------------------------------
  905. #  顯示文字資訊的視窗。
  906. #==============================================================================
  907. class Window_Message < Window_Base
  908.   #--------------------------------------------------------------------------
  909.   # ● 處理數值的輸入(覆蓋原方法)
  910.   #--------------------------------------------------------------------------
  911.   def input_number
  912.     @number_window.start
  913.     Fiber.yield while @number_window.extra_window.active
  914.   end
  915. end

  916. #==============================================================================
  917. # ■ Window_PartyCommand
  918. #------------------------------------------------------------------------------
  919. #  戰鬥畫面中,選擇“戰鬥/撤退”的視窗。
  920. #==============================================================================
  921. class Window_PartyCommand < Window_Command
  922.   #--------------------------------------------------------------------------
  923.   # ● 方向鍵移動游標時將滑鼠移動到對應的游標位置
  924.   #--------------------------------------------------------------------------
  925.   def set_mouse_pos
  926.     if viewport.nil?
  927.       vp_x, vp_y = 0, 0
  928.     else
  929.       #vp_x = viewport.rect.x - viewport.ox
  930.       vp_y = viewport.rect.y - viewport.oy
  931.     end
  932.     item_x1 = x + standard_padding
  933.     item_y1 = vp_y + y + standard_padding
  934.     get_index = @index < 0 ? 0 : @index
  935.     row = get_index / col_max - top_row
  936.     col = get_index % col_max
  937.     new_x = item_x1 + item_width * (col + 0.5)
  938.     new_y = item_y1 + item_height * (row + 0.5)
  939.     Mouse.set_mouse_pos(new_x, new_y)
  940.   end
  941. end

  942. #==============================================================================
  943. # ■ Window_ActorCommand
  944. #------------------------------------------------------------------------------
  945. #  戰鬥畫面中,選擇角色行動的視窗。
  946. #==============================================================================
  947. class Window_ActorCommand < Window_Command
  948.   #--------------------------------------------------------------------------
  949.   # ● 方向鍵移動游標時將滑鼠移動到對應的游標位置
  950.   #--------------------------------------------------------------------------
  951.   def set_mouse_pos
  952.     if viewport.nil?
  953.       vp_x, vp_y = 0, 0
  954.     else
  955.       #vp_x = viewport.rect.x - viewport.ox
  956.       vp_y = viewport.rect.y - viewport.oy
  957.     end
  958.     item_x1 = Graphics.width - width + standard_padding
  959.     item_y1 = vp_y + y + standard_padding
  960.     get_index = @index < 0 ? 0 : @index
  961.     row = get_index / col_max - top_row
  962.     col = get_index % col_max
  963.     new_x = item_x1 + item_width * (col + 0.5)
  964.     new_y = item_y1 + item_height * (row + 0.5)
  965.     Mouse.set_mouse_pos(new_x, new_y)
  966.   end
  967. end

  968. #==============================================================================
  969. # ■ Game_Player
  970. #------------------------------------------------------------------------------
  971. #  處理玩家人物的類。擁有事件啟動的判定、地圖的捲動等功能。
  972. #   本類的實例請參考 $game_player 。
  973. #==============================================================================
  974. class Game_Player < Game_Character
  975.   #--------------------------------------------------------------------------
  976.   # ● 由方向移動(覆蓋原方法)
  977.   #--------------------------------------------------------------------------
  978.   def move_by_input
  979.     return if !movable? || $game_map.interpreter.running?
  980.     if Input.dir4 > 0
  981.       move_straight(Input.dir4)
  982.       reset_move_path
  983.     else
  984.       move_by_mouse
  985.     end
  986.   end
  987.   #--------------------------------------------------------------------------
  988.   # ● 非移動中的處理(覆蓋原方法)
  989.   #     last_moving : 此前是否正在移動
  990.   #--------------------------------------------------------------------------
  991.   def update_nonmoving(last_moving)
  992.     return if $game_map.interpreter.running?
  993.     if last_moving
  994.       $game_party.on_player_walk
  995.       return if check_touch_event
  996.     end
  997.     if movable? && Input.trigger?(:C)
  998.       return if Mouse.press?(0x01) # 防止按下滑鼠左鍵繪製路徑時觸發事件或載具切換
  999.       return if get_on_off_vehicle
  1000.       return if check_action_event
  1001.     end
  1002.     update_encounter if last_moving
  1003.   end
  1004.   #--------------------------------------------------------------------------
  1005.   # ● 判定是否跑步狀態(覆蓋原方法)
  1006.   #--------------------------------------------------------------------------
  1007.   def dash?
  1008.     return false if @move_route_forcing
  1009.     return false if $game_map.disable_dash?
  1010.     return false if vehicle
  1011.     return Input.press?(:A) || @mouse_dash
  1012.   end
  1013.   #--------------------------------------------------------------------------
  1014.   # ● 初始化
  1015.   #--------------------------------------------------------------------------
  1016.   alias sion_mouse_initialize initialize
  1017.   def initialize
  1018.     sion_mouse_initialize
  1019.     reset_move_path
  1020.     @moveto_x = 0
  1021.     @moveto_y = 0
  1022.   end
  1023.   #--------------------------------------------------------------------------
  1024.   # ● 更新
  1025.   #--------------------------------------------------------------------------
  1026.   alias sion_mouse_update update
  1027.   def update
  1028.     sion_mouse_update
  1029.     clear_unreachable_sign
  1030.   end
  1031.   #--------------------------------------------------------------------------
  1032.   # ● 處理捲動
  1033.   #--------------------------------------------------------------------------
  1034.   alias sion_mouse_update_scroll update_scroll
  1035.   def update_scroll(last_real_x, last_real_y)
  1036.     return if $game_map.scrolling?
  1037.     KsOfSion::New_Scroll ? new_update_scroll :
  1038.       sion_mouse_update_scroll(last_real_x, last_real_y)
  1039.   end
  1040.   #--------------------------------------------------------------------------
  1041.   # ● 重置移動路徑相關資訊
  1042.   #--------------------------------------------------------------------------
  1043.   def reset_move_path
  1044.     @mouse_dash = false
  1045.     @mouse_move_path = []
  1046.     $mouse_move_sign.transparent = true
  1047.   end
  1048.   #--------------------------------------------------------------------------
  1049.   # ● 新的捲動地圖方法
  1050.   #--------------------------------------------------------------------------
  1051.   def new_update_scroll
  1052.     horz_speed = 2 ** @move_speed * KsOfSion::Map_Scroll_Spd / Graphics.width
  1053.     vert_speed = 2 ** @move_speed * KsOfSion::Map_Scroll_Spd / Graphics.height
  1054.     ax = $game_map.adjust_x(@real_x)
  1055.     ay = $game_map.adjust_y(@real_y)
  1056.     $game_map.scroll_down (vert_speed * (ay - center_y)) if ay > center_y
  1057.     $game_map.scroll_left (horz_speed * (center_x - ax)) if ax < center_x
  1058.     $game_map.scroll_right(horz_speed * (ax - center_x)) if ax > center_x
  1059.     $game_map.scroll_up   (vert_speed * (center_y - ay)) if ay < center_y
  1060.   end
  1061.   #--------------------------------------------------------------------------
  1062.   # ● 消除不能抵達圖示
  1063.   #--------------------------------------------------------------------------
  1064.   def clear_unreachable_sign
  1065.     return if Mouse.press?(0x01)
  1066.     if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 0
  1067.       $mouse_move_sign.transparent = true
  1068.       $mouse_move_sign.direction = 2
  1069.     end
  1070.   end
  1071.   #--------------------------------------------------------------------------
  1072.   # ● 由滑鼠移動
  1073.   #--------------------------------------------------------------------------
  1074.   def move_by_mouse
  1075.     unless @mouse_move_path.empty? # 移動路線陣列不為空則執行移動
  1076.       dir = @mouse_move_path.shift
  1077.       if passable?(x, y, dir) && !@mouse_move_path.empty?
  1078.         move_straight(dir)
  1079.       elsif @mouse_move_path.empty? # 判斷是否是最後一步
  1080.         x2 = $game_map.round_x_with_direction(x, dir)
  1081.         y2 = $game_map.round_y_with_direction(y, dir)
  1082.         move_straight(dir) unless dir.zero?
  1083.         unless x == x2 && y == y2 # 如果移動失敗,檢查是否啟動前方事件、上下載具
  1084.           check_event_trigger_there([0,1,2])
  1085.           get_on_off_vehicle unless $game_map.setup_starting_event
  1086.         end
  1087.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2
  1088.         @mouse_dash = false
  1089.       elsif @mouse_move_path[0].zero? # 目標點無法抵達,調整朝向→目標點
  1090.         @mouse_move_path.shift
  1091.         @direction = dir
  1092.         @mouse_dash = false
  1093.       else
  1094.         draw_move_path
  1095.       end
  1096.     end
  1097.   end
  1098.   #--------------------------------------------------------------------------
  1099.   # ● 地圖介面按下滑鼠左鍵的處理
  1100.   #--------------------------------------------------------------------------
  1101.   def left_button_action
  1102.     return if !drawable? || $game_map.interpreter.running?
  1103.     get_mouse_pos
  1104.     $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移動路徑點指示圖
  1105.     if @shift_event
  1106.       if Mouse.trigger?(0x01)
  1107.         @shift_event.jump(@moveto_x - @shift_event.x,
  1108.           @moveto_y - @shift_event.y)
  1109.         @shift_event = nil
  1110.       end
  1111.       return
  1112.     end
  1113.     if @moveto_x == x && @moveto_y == y # 判斷目標點是否與角色重合
  1114.       return if moving? || (vehicle && !vehicle.movable?)
  1115.       check_event_trigger_here([0]) # 判斷是否觸發重合點事件
  1116.       get_on_off_vehicle if !$game_map.setup_starting_event &&
  1117.         $game_map.airship.pos?(x, y)  # 判斷是否要上、下飛艇
  1118.       return
  1119.     end
  1120.     # 判斷是否用滑鼠啟動事件
  1121.     $game_map.events_xy(@moveto_x, @moveto_y).each do |event|
  1122.       if event.mouse_start?
  1123.         reset_move_path
  1124.         event.start if Mouse.trigger?(0x01)
  1125.         return
  1126.       end
  1127.     end
  1128.     @mouse_dash = true if Mouse.double_click? # 雙擊衝刺
  1129.     return if Mouse.left_state % 10 != 1 # 按住滑鼠左鍵10幀繪製1次路徑
  1130.     for i in 1..4 # 判斷目標點是否為角色周圍四點
  1131.       if x == $game_map.round_x_with_direction(@moveto_x, i * 2) &&
  1132.          y == $game_map.round_y_with_direction(@moveto_y, i * 2)
  1133.       $mouse_move_sign.transparent = true
  1134.       @mouse_move_path = [10 - i * 2] if Mouse.trigger?(0x01)
  1135.       return; end
  1136.     end
  1137.     draw_move_path
  1138.   end
  1139.   #--------------------------------------------------------------------------
  1140.   # ● 取得滑鼠處對應地圖座標點
  1141.   #--------------------------------------------------------------------------
  1142.   def get_mouse_pos
  1143.     $game_map.get_mouse_map_xy
  1144.     @moveto_x = $game_map.mouse_map_x
  1145.     @moveto_y = $game_map.mouse_map_y
  1146.     #mouse_x, mouse_y = Mouse.get_mouse_pos
  1147.     #@moveto_x = $game_map.round_x(x + (mouse_x -
  1148.     #  ($game_map.adjust_x(x) * 32 + 16).to_i + 16) / 32)
  1149.     #@moveto_y = $game_map.round_y(y + 1 + (mouse_y -
  1150.     #  ($game_map.adjust_y(y) * 32 + 16).to_i - 16) / 32)
  1151.   end
  1152.   #--------------------------------------------------------------------------
  1153.   # ● 繪製移動路徑 @array[move_directions...]
  1154.   #--------------------------------------------------------------------------
  1155.   def draw_move_path
  1156.     #temp = Time.now
  1157.     case @vehicle_type
  1158.     when :walk
  1159.       draw_walk_path
  1160.     when :boat
  1161.       draw_boat_path
  1162.     when :ship
  1163.       draw_ship_path
  1164.     when :airship
  1165.       draw_air_path
  1166.     end
  1167.     #p (Time.now.to_f - temp.to_f) # 測試效率
  1168.   end
  1169.   #--------------------------------------------------------------------------
  1170.   # ● 判定是否可以繪製移動路徑
  1171.   #--------------------------------------------------------------------------
  1172.   def drawable?
  1173.     return false if @move_route_forcing || @followers.gathering?
  1174.     return false if @vehicle_getting_on || @vehicle_getting_off
  1175.     return false if $game_message.busy? || $game_message.visible
  1176.     return true
  1177.   end
  1178.   #--------------------------------------------------------------------------
  1179.   # ● 繪製walk移動路徑 @array[move_directions...]
  1180.   #--------------------------------------------------------------------------
  1181.   def draw_walk_path
  1182.     # 準備繪製路徑表格
  1183.     sheet = Table.new($game_map.width, $game_map.height)
  1184.     reversed_chase_path  = []; chase_path  = []
  1185.     reversed_chase_point = []; chase_point = []
  1186.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1187.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1188.     reach_point = false
  1189.     step = 3
  1190.     loop do #loop1 開始填充表格
  1191.      draw_path = false
  1192.      check_points = new_start_points
  1193.      new_start_points = []
  1194.       loop do #loop2 從起點開始正向填充
  1195.         point_x = check_points.shift
  1196.         break if point_x == nil
  1197.         point_y = check_points.shift
  1198.         left_x  = $game_map.round_x(point_x - 1)
  1199.         right_x = $game_map.round_x(point_x + 1)
  1200.         up_y    = $game_map.round_y(point_y - 1)
  1201.         down_y  = $game_map.round_y(point_y + 1)
  1202.                     # 判斷路徑是否連通
  1203.         path_step = step - 1
  1204.         if sheet[left_x, point_y] == path_step     &&
  1205.            $game_map.passable?(left_x, point_y, 6) &&
  1206.            $game_map.passable?(point_x, point_y, 4)
  1207.           chase_path.push(4)
  1208.           chase_point = [left_x, point_y]
  1209.           reversed_chase_point = [point_x, point_y]
  1210.           reach_point = true; break
  1211.         elsif sheet[right_x, point_y] == path_step     &&
  1212.               $game_map.passable?(right_x, point_y, 4) &&
  1213.               $game_map.passable?(point_x, point_y, 6)
  1214.             chase_path.push(6)
  1215.             chase_point = [right_x, point_y]
  1216.             reversed_chase_point = [point_x, point_y]
  1217.             reach_point = true; break
  1218.         elsif sheet[point_x, up_y] == path_step     &&
  1219.               $game_map.passable?(point_x, up_y, 2) &&
  1220.               $game_map.passable?(point_x, point_y, 8)
  1221.             chase_path.push(8)
  1222.             chase_point = [point_x, up_y]
  1223.             reversed_chase_point = [point_x, point_y]
  1224.             reach_point = true; break
  1225.         elsif sheet[point_x, down_y] == path_step     &&
  1226.               $game_map.passable?(point_x, down_y, 8) &&
  1227.               $game_map.passable?(point_x, point_y, 2)
  1228.             chase_path.push(2)
  1229.             chase_point = [point_x, down_y]
  1230.             reversed_chase_point = [point_x, point_y]
  1231.             reach_point = true; break
  1232.         end
  1233.         # 以需要抵達該點的步數填充路徑表格 #
  1234.         if sheet[left_x, point_y] == 0              &&
  1235.            $game_map.passable?(left_x, point_y, 6)  &&
  1236.            !collide_with_events?(left_x, point_y)   &&
  1237.            $game_map.passable?(point_x, point_y, 4) &&
  1238.            !collide_with_vehicles?(left_x, point_y) #judge_end
  1239.           sheet[left_x, point_y] = step
  1240.           draw_path = true
  1241.           new_start_points.push(left_x, point_y)
  1242.         end
  1243.         if sheet[right_x, point_y] == 0             &&
  1244.            $game_map.passable?(right_x, point_y, 4) &&
  1245.            !collide_with_events?(right_x, point_y)  &&
  1246.            $game_map.passable?(point_x, point_y, 6) &&
  1247.            !collide_with_vehicles?(right_x, point_y)#judge_end
  1248.           sheet[right_x, point_y] = step
  1249.           draw_path = true
  1250.           new_start_points.push(right_x, point_y)
  1251.         end
  1252.         if sheet[point_x, up_y] == 0                &&
  1253.            $game_map.passable?(point_x, up_y, 2)    &&
  1254.            !collide_with_events?(point_x, up_y)     &&
  1255.            $game_map.passable?(point_x, point_y, 8) &&
  1256.            !collide_with_vehicles?(point_x, up_y)   #judge_end
  1257.           sheet[point_x, up_y] = step
  1258.           draw_path = true
  1259.           new_start_points.push(point_x, up_y)
  1260.         end
  1261.         if sheet[point_x, down_y] == 0              &&
  1262.            $game_map.passable?(point_x, down_y, 8)  &&
  1263.            !collide_with_events?(point_x, down_y)   &&
  1264.            $game_map.passable?(point_x, point_y, 2) &&
  1265.            !collide_with_vehicles?(point_x, down_y) #judge_end
  1266.           sheet[point_x, down_y] = step
  1267.           draw_path = true
  1268.           new_start_points.push(point_x, down_y)
  1269.         end
  1270.       end#endOfLoop2
  1271.       break if !draw_path || reach_point
  1272.       draw_path = false
  1273.       check_points = new_end_points
  1274.       new_end_points = []
  1275.       step += 1
  1276.       break if step > KsOfSion::Break_Steps &&
  1277.                !Input.press?(KsOfSion::Find_Path_Key)
  1278.       loop do #loop3 從終點開始反向填充
  1279.         point_x = check_points.shift
  1280.         break if point_x == nil
  1281.         point_y = check_points.shift
  1282.         left_x  = $game_map.round_x(point_x - 1)
  1283.         right_x = $game_map.round_x(point_x + 1)
  1284.         up_y    = $game_map.round_y(point_y - 1)
  1285.         down_y  = $game_map.round_y(point_y + 1)
  1286.         # 判斷路徑是否連通
  1287.         path_step = step - 1
  1288.         if sheet[left_x, point_y] == path_step     &&
  1289.            $game_map.passable?(left_x, point_y, 6) &&
  1290.            $game_map.passable?(point_x, point_y, 4)
  1291.           chase_path.push(6)
  1292.           chase_point = [point_x, point_y]
  1293.           reversed_chase_point = [left_x, point_y]
  1294.           reach_point = true; break
  1295.         elsif sheet[right_x, point_y] == path_step     &&
  1296.               $game_map.passable?(right_x, point_y, 4) &&
  1297.               $game_map.passable?(point_x, point_y, 6)
  1298.             chase_path.push(4)
  1299.             chase_point = [point_x, point_y]
  1300.             reversed_chase_point = [right_x, point_y]
  1301.             reach_point = true; break
  1302.         elsif sheet[point_x, up_y] == path_step     &&
  1303.               $game_map.passable?(point_x, up_y, 2) &&
  1304.               $game_map.passable?(point_x, point_y, 8)
  1305.             chase_path.push(2)
  1306.             chase_point = [point_x, point_y]
  1307.             reversed_chase_point = [point_x, up_y]
  1308.             reach_point = true; break
  1309.         elsif sheet[point_x, down_y] == path_step     &&
  1310.               $game_map.passable?(point_x, down_y, 8) &&
  1311.               $game_map.passable?(point_x, point_y, 2)
  1312.             chase_path.push(8)
  1313.             chase_point = [point_x, point_y]
  1314.             reversed_chase_point = [point_x, down_y]
  1315.             reach_point = true; break
  1316.         end
  1317.         # 以需要抵達該點的步數填充路徑表格 #
  1318.         if sheet[left_x, point_y] == 0              &&
  1319.            $game_map.passable?(left_x, point_y, 6)  &&
  1320.            !collide_with_events?(left_x, point_y)   &&
  1321.            $game_map.passable?(point_x, point_y, 4) &&
  1322.            !collide_with_vehicles?(left_x, point_y) #judge_end
  1323.           sheet[left_x, point_y] = step
  1324.           draw_path = true
  1325.           new_end_points.push(left_x, point_y)
  1326.         end
  1327.         if sheet[right_x, point_y] == 0             &&
  1328.            $game_map.passable?(right_x, point_y, 4) &&
  1329.            !collide_with_events?(right_x, point_y)  &&
  1330.            $game_map.passable?(point_x, point_y, 6) &&
  1331.            !collide_with_vehicles?(right_x, point_y)#judge_end
  1332.           sheet[right_x, point_y] = step
  1333.           draw_path = true
  1334.           new_end_points.push(right_x, point_y)
  1335.         end
  1336.         if sheet[point_x, up_y] == 0                &&
  1337.            $game_map.passable?(point_x, up_y, 2)    &&
  1338.            !collide_with_events?(point_x, up_y)     &&
  1339.            $game_map.passable?(point_x, point_y, 8) &&
  1340.            !collide_with_vehicles?(point_x, up_y)   #judge_end
  1341.           sheet[point_x, up_y] = step
  1342.           draw_path = true
  1343.           new_end_points.push(point_x, up_y)
  1344.         end
  1345.         if sheet[point_x, down_y] == 0              &&
  1346.            $game_map.passable?(point_x, down_y, 8)  &&
  1347.            !collide_with_events?(point_x, down_y)   &&
  1348.            $game_map.passable?(point_x, point_y, 2) &&
  1349.            !collide_with_vehicles?(point_x, down_y) #judge_end
  1350.           sheet[point_x, down_y] = step
  1351.           draw_path = true
  1352.           new_end_points.push(point_x, down_y)
  1353.         end
  1354.       end#endOfLoop3
  1355.       break if !draw_path || reach_point
  1356.       step += 1
  1357.     end #endOfLoop1 路徑表格填充完畢
  1358.     $mouse_move_sign.transparent = false
  1359.     # 判斷指定地點能否抵達
  1360.     if reach_point
  1361.       $mouse_move_sign.direction = 2
  1362.     else
  1363.       not_reach_point
  1364.       return
  1365.     end
  1366.     # 根據路徑表格繪製最短移動路徑(反向)
  1367.     steps = step / 2 * 2 + 1
  1368.     loop_times = step / 2
  1369.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1370.     for i in 1..loop_times # forLoop
  1371.     steps -= 2
  1372.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs #反過來?蛋疼了……
  1373.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1374.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1375.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1376.         reversed_chase_path.push(6)
  1377.         point_x = $game_map.round_x(point_x - 1)
  1378.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1379.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1380.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1381.         reversed_chase_path.push(4)
  1382.         point_x = $game_map.round_x(point_x + 1)
  1383.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1384.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1385.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1386.         reversed_chase_path.push(8)
  1387.         point_y = $game_map.round_y(point_y + 1)
  1388.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1389.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1390.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1391.         reversed_chase_path.push(2)
  1392.         point_y = $game_map.round_y(point_y - 1)
  1393.       end
  1394.     else
  1395.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1396.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1397.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1398.         reversed_chase_path.push(8)
  1399.         point_y = $game_map.round_y(point_y + 1)
  1400.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1401.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1402.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1403.         reversed_chase_path.push(2)
  1404.         point_y = $game_map.round_y(point_y - 1)
  1405.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1406.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1407.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1408.         reversed_chase_path.push(6)
  1409.         point_x = $game_map.round_x(point_x - 1)
  1410.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1411.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1412.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1413.         reversed_chase_path.push(4)
  1414.         point_x = $game_map.round_x(point_x + 1)
  1415.       end
  1416.     end
  1417.     end #endOfForLoop
  1418.     # 根據路徑表格繪製最短移動路徑(正向)
  1419.     steps = step / 2 * 2
  1420.     loop_times = step / 2
  1421.     point_x, point_y = chase_point[0], chase_point[1]
  1422.     for i in 2..loop_times # forLoop
  1423.     steps -= 2
  1424.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1425.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1426.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1427.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1428.         chase_path.push(2)
  1429.         point_y = $game_map.round_y(point_y + 1)
  1430.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1431.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1432.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1433.         chase_path.push(8)
  1434.         point_y = $game_map.round_y(point_y - 1)
  1435.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1436.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1437.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1438.         chase_path.push(4)
  1439.         point_x = $game_map.round_x(point_x - 1)
  1440.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1441.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1442.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1443.         chase_path.push(6)
  1444.         point_x = $game_map.round_x(point_x + 1)
  1445.       end
  1446.     else
  1447.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
  1448.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  1449.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  1450.         chase_path.push(4)
  1451.         point_x = $game_map.round_x(point_x - 1)
  1452.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
  1453.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  1454.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  1455.         chase_path.push(6)
  1456.         point_x = $game_map.round_x(point_x + 1)
  1457.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
  1458.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  1459.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  1460.         chase_path.push(2)
  1461.         point_y = $game_map.round_y(point_y + 1)
  1462.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
  1463.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  1464.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  1465.         chase_path.push(8)
  1466.         point_y = $game_map.round_y(point_y - 1)
  1467.       end
  1468.     end
  1469.     end #endOfForLoop
  1470.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1471.   end#walk
  1472.   #--------------------------------------------------------------------------
  1473.   # ● 繪製boat的移動路徑 @array[move_directions...]
  1474.   #--------------------------------------------------------------------------
  1475.   def draw_boat_path
  1476.     # 準備繪製路徑表格
  1477.     sheet = Table.new($game_map.width, $game_map.height)
  1478.     reversed_chase_path  = []; chase_path  = []
  1479.     reversed_chase_point = []; chase_point = []
  1480.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1481.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1482.     reach_point = false
  1483.     step = 3
  1484.     loop do #loop1 開始填充表格
  1485.      draw_path = false
  1486.      check_points = new_start_points
  1487.      new_start_points = []
  1488.       loop do #loop2 從起點開始正向填充
  1489.         point_x = check_points.shift
  1490.         break if point_x == nil
  1491.         point_y = check_points.shift
  1492.         left_x  = $game_map.round_x(point_x - 1)
  1493.         right_x = $game_map.round_x(point_x + 1)
  1494.         up_y    = $game_map.round_y(point_y - 1)
  1495.         down_y  = $game_map.round_y(point_y + 1)
  1496.                     # 判斷路徑是否連通
  1497.         path_step = step - 1
  1498.         if sheet[left_x, point_y] == path_step
  1499.           chase_path.push(4)
  1500.           chase_point = [left_x, point_y]
  1501.           reversed_chase_point = [point_x, point_y]
  1502.           reach_point = true; break
  1503.         elsif sheet[right_x, point_y] == path_step
  1504.             chase_path.push(6)
  1505.             chase_point = [right_x, point_y]
  1506.             reversed_chase_point = [point_x, point_y]
  1507.             reach_point = true; break
  1508.         elsif sheet[point_x, up_y] == path_step
  1509.             chase_path.push(8)
  1510.             chase_point = [point_x, up_y]
  1511.             reversed_chase_point = [point_x, point_y]
  1512.             reach_point = true; break
  1513.         elsif sheet[point_x, down_y] == path_step
  1514.             chase_path.push(2)
  1515.             chase_point = [point_x, down_y]
  1516.             reversed_chase_point = [point_x, point_y]
  1517.             reach_point = true; break
  1518.         end
  1519.         # 以需要抵達該點的步數填充路徑表格 #
  1520.         if sheet[left_x, point_y] == 0                &&
  1521.            $game_map.boat_passable?(left_x, point_y)  &&
  1522.            !collide_with_events?(left_x, point_y)     &&
  1523.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1524.           sheet[left_x, point_y] = step
  1525.           draw_path = true
  1526.           new_start_points.push(left_x, point_y)
  1527.         end
  1528.         if sheet[right_x, point_y] == 0               &&
  1529.            $game_map.boat_passable?(right_x, point_y) &&
  1530.            !collide_with_events?(right_x, point_y)    &&
  1531.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1532.           sheet[right_x, point_y] = step
  1533.           draw_path = true
  1534.           new_start_points.push(right_x, point_y)
  1535.         end
  1536.         if sheet[point_x, up_y] == 0                  &&
  1537.            $game_map.boat_passable?(point_x, up_y)    &&
  1538.            !collide_with_events?(point_x, up_y)       &&
  1539.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1540.           sheet[point_x, up_y] = step
  1541.           draw_path = true
  1542.           new_start_points.push(point_x, up_y)
  1543.         end
  1544.         if sheet[point_x, down_y] == 0                &&
  1545.            $game_map.boat_passable?(point_x, down_y)  &&
  1546.            !collide_with_events?(point_x, down_y)     &&
  1547.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1548.           sheet[point_x, down_y] = step
  1549.           draw_path = true
  1550.           new_start_points.push(point_x, down_y)
  1551.         end
  1552.       end#endOfLoop2
  1553.       break if !draw_path || reach_point
  1554.       draw_path = false
  1555.       check_points = new_end_points
  1556.       new_end_points = []
  1557.       step += 1
  1558.       break if step > KsOfSion::Break_Steps &&
  1559.                !Input.press?(KsOfSion::Find_Path_Key)
  1560.       loop do #loop3 從終點開始反向填充
  1561.         point_x = check_points.shift
  1562.         break if point_x == nil
  1563.         point_y = check_points.shift
  1564.         left_x  = $game_map.round_x(point_x - 1)
  1565.         right_x = $game_map.round_x(point_x + 1)
  1566.         up_y    = $game_map.round_y(point_y - 1)
  1567.         down_y  = $game_map.round_y(point_y + 1)
  1568.         # 判斷路徑是否連通
  1569.         path_step = step - 1
  1570.         if sheet[left_x, point_y] == path_step
  1571.           chase_path.push(6)
  1572.           chase_point = [point_x, point_y]
  1573.           reversed_chase_point = [left_x, point_y]
  1574.           reach_point = true; break
  1575.         elsif sheet[right_x, point_y] == path_step
  1576.             chase_path.push(4)
  1577.             chase_point = [point_x, point_y]
  1578.             reversed_chase_point = [right_x, point_y]
  1579.             reach_point = true; break
  1580.         elsif sheet[point_x, up_y] == path_step
  1581.             chase_path.push(2)
  1582.             chase_point = [point_x, point_y]
  1583.             reversed_chase_point = [point_x, up_y]
  1584.             reach_point = true; break
  1585.         elsif sheet[point_x, down_y] == path_step
  1586.             chase_path.push(8)
  1587.             chase_point = [point_x, point_y]
  1588.             reversed_chase_point = [point_x, down_y]
  1589.             reach_point = true; break
  1590.         end
  1591.         # 以需要抵達該點的步數填充路徑表格 #
  1592.         if sheet[left_x, point_y] == 0                &&
  1593.            $game_map.boat_passable?(left_x, point_y)  &&
  1594.            !collide_with_events?(left_x, point_y)     &&
  1595.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1596.           sheet[left_x, point_y] = step
  1597.           draw_path = true
  1598.           new_end_points.push(left_x, point_y)
  1599.         end
  1600.         if sheet[right_x, point_y] == 0               &&
  1601.            $game_map.boat_passable?(right_x, point_y) &&
  1602.            !collide_with_events?(right_x, point_y)    &&
  1603.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1604.           sheet[right_x, point_y] = step
  1605.           draw_path = true
  1606.           new_end_points.push(right_x, point_y)
  1607.         end
  1608.         if sheet[point_x, up_y] == 0                  &&
  1609.            $game_map.boat_passable?(point_x, up_y)    &&
  1610.            !collide_with_events?(point_x, up_y)       &&
  1611.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1612.           sheet[point_x, up_y] = step
  1613.           draw_path = true
  1614.           new_end_points.push(point_x, up_y)
  1615.         end
  1616.         if sheet[point_x, down_y] == 0                &&
  1617.            $game_map.boat_passable?(point_x, down_y)  &&
  1618.            !collide_with_events?(point_x, down_y)     &&
  1619.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1620.           sheet[point_x, down_y] = step
  1621.           draw_path = true
  1622.           new_end_points.push(point_x, down_y)
  1623.         end
  1624.       end#endOfLoop3
  1625.       break if !draw_path || reach_point
  1626.       step += 1
  1627.     end #endOfLoop1 路徑表格填充完畢
  1628.     $mouse_move_sign.transparent = false
  1629.     # 判斷指定地點能否抵達
  1630.     if reach_point
  1631.       $mouse_move_sign.direction = 2
  1632.     else
  1633.       not_reach_point
  1634.       return
  1635.     end
  1636.     # 根據路徑表格繪製最短移動路徑(正向)
  1637.     steps = step / 2 * 2
  1638.     loop_times = step / 2
  1639.     point_x, point_y = chase_point[0], chase_point[1]
  1640.     for i in 2..loop_times # forLoop
  1641.     steps -= 2
  1642.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1643.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1644.         chase_path.push(2)
  1645.         point_y = $game_map.round_y(point_y + 1)
  1646.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1647.         chase_path.push(8)
  1648.         point_y = $game_map.round_y(point_y - 1)
  1649.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1650.         chase_path.push(4)
  1651.         point_x = $game_map.round_x(point_x - 1)
  1652.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1653.         chase_path.push(6)
  1654.         point_x = $game_map.round_x(point_x + 1)
  1655.       end
  1656.     else
  1657.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1658.         chase_path.push(4)
  1659.         point_x = $game_map.round_x(point_x - 1)
  1660.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1661.         chase_path.push(6)
  1662.         point_x = $game_map.round_x(point_x + 1)
  1663.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1664.         chase_path.push(2)
  1665.         point_y = $game_map.round_y(point_y + 1)
  1666.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1667.         chase_path.push(8)
  1668.         point_y = $game_map.round_y(point_y - 1)
  1669.       end
  1670.     end
  1671.     end #endOfForLoop
  1672.     # 如果指定點無法抵達或者登陸
  1673.     return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path)
  1674.     # 根據路徑表格繪製最短移動路徑(反向)
  1675.     steps = step / 2 * 2 + 1
  1676.     loop_times = step / 2
  1677.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1678.     for i in 1..loop_times # forLoop
  1679.     steps -= 2
  1680.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1681.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1682.         reversed_chase_path.push(6)
  1683.         point_x = $game_map.round_x(point_x - 1)
  1684.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1685.         reversed_chase_path.push(4)
  1686.         point_x = $game_map.round_x(point_x + 1)
  1687.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1688.         reversed_chase_path.push(8)
  1689.         point_y = $game_map.round_y(point_y + 1)
  1690.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1691.         reversed_chase_path.push(2)
  1692.         point_y = $game_map.round_y(point_y - 1)
  1693.       end
  1694.     else
  1695.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1696.         reversed_chase_path.push(8)
  1697.         point_y = $game_map.round_y(point_y + 1)
  1698.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1699.         reversed_chase_path.push(2)
  1700.         point_y = $game_map.round_y(point_y - 1)
  1701.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1702.         reversed_chase_path.push(6)
  1703.         point_x = $game_map.round_x(point_x - 1)
  1704.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1705.         reversed_chase_path.push(4)
  1706.         point_x = $game_map.round_x(point_x + 1)
  1707.       end
  1708.     end
  1709.     end #endOfForLoop
  1710.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1711.   end#boat
  1712.   #--------------------------------------------------------------------------
  1713.   # ● 繪製ship的移動路徑 @array[move_directions...]
  1714.   #--------------------------------------------------------------------------
  1715.   def draw_ship_path
  1716.     # 準備繪製路徑表格
  1717.     sheet = Table.new($game_map.width, $game_map.height)
  1718.     reversed_chase_path  = []; chase_path  = []
  1719.     reversed_chase_point = []; chase_point = []
  1720.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
  1721.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2
  1722.     reach_point = false
  1723.     step = 3
  1724.     loop do #loop1 開始填充表格
  1725.      draw_path = false
  1726.      check_points = new_start_points
  1727.      new_start_points = []
  1728.       loop do #loop2 從起點開始正向填充
  1729.         point_x = check_points.shift
  1730.         break if point_x == nil
  1731.         point_y = check_points.shift
  1732.         left_x  = $game_map.round_x(point_x - 1)
  1733.         right_x = $game_map.round_x(point_x + 1)
  1734.         up_y    = $game_map.round_y(point_y - 1)
  1735.         down_y  = $game_map.round_y(point_y + 1)
  1736.                     # 判斷路徑是否連通
  1737.         path_step = step - 1
  1738.         if sheet[left_x, point_y] == path_step
  1739.           chase_path.push(4)
  1740.           chase_point = [left_x, point_y]
  1741.           reversed_chase_point = [point_x, point_y]
  1742.           reach_point = true; break
  1743.         elsif sheet[right_x, point_y] == path_step
  1744.             chase_path.push(6)
  1745.             chase_point = [right_x, point_y]
  1746.             reversed_chase_point = [point_x, point_y]
  1747.             reach_point = true; break
  1748.         elsif sheet[point_x, up_y] == path_step
  1749.             chase_path.push(8)
  1750.             chase_point = [point_x, up_y]
  1751.             reversed_chase_point = [point_x, point_y]
  1752.             reach_point = true; break
  1753.         elsif sheet[point_x, down_y] == path_step
  1754.             chase_path.push(2)
  1755.             chase_point = [point_x, down_y]
  1756.             reversed_chase_point = [point_x, point_y]
  1757.             reach_point = true; break
  1758.         end
  1759.         # 以需要抵達該點的步數填充路徑表格 #
  1760.         if sheet[left_x, point_y] == 0                &&
  1761.            $game_map.ship_passable?(left_x, point_y)  &&
  1762.            !collide_with_events?(left_x, point_y)     &&
  1763.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1764.           sheet[left_x, point_y] = step
  1765.           draw_path = true
  1766.           new_start_points.push(left_x, point_y)
  1767.         end
  1768.         if sheet[right_x, point_y] == 0               &&
  1769.            $game_map.ship_passable?(right_x, point_y) &&
  1770.            !collide_with_events?(right_x, point_y)    &&
  1771.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1772.           sheet[right_x, point_y] = step
  1773.           draw_path = true
  1774.           new_start_points.push(right_x, point_y)
  1775.         end
  1776.         if sheet[point_x, up_y] == 0                  &&
  1777.            $game_map.ship_passable?(point_x, up_y)    &&
  1778.            !collide_with_events?(point_x, up_y)       &&
  1779.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1780.           sheet[point_x, up_y] = step
  1781.           draw_path = true
  1782.           new_start_points.push(point_x, up_y)
  1783.         end
  1784.         if sheet[point_x, down_y] == 0                &&
  1785.            $game_map.ship_passable?(point_x, down_y)  &&
  1786.            !collide_with_events?(point_x, down_y)     &&
  1787.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1788.           sheet[point_x, down_y] = step
  1789.           draw_path = true
  1790.           new_start_points.push(point_x, down_y)
  1791.         end
  1792.       end#endOfLoop2
  1793.       break if !draw_path || reach_point
  1794.       draw_path = false
  1795.       check_points = new_end_points
  1796.       new_end_points = []
  1797.       step += 1
  1798.       break if step > KsOfSion::Break_Steps &&
  1799.                !Input.press?(KsOfSion::Find_Path_Key)
  1800.       loop do #loop3 從終點開始反向填充
  1801.         point_x = check_points.shift
  1802.         break if point_x == nil
  1803.         point_y = check_points.shift
  1804.         left_x  = $game_map.round_x(point_x - 1)
  1805.         right_x = $game_map.round_x(point_x + 1)
  1806.         up_y    = $game_map.round_y(point_y - 1)
  1807.         down_y  = $game_map.round_y(point_y + 1)
  1808.         # 判斷路徑是否連通
  1809.         path_step = step - 1
  1810.         if sheet[left_x, point_y] == path_step
  1811.           chase_path.push(6)
  1812.           chase_point = [point_x, point_y]
  1813.           reversed_chase_point = [left_x, point_y]
  1814.           reach_point = true; break
  1815.         elsif sheet[right_x, point_y] == path_step
  1816.             chase_path.push(4)
  1817.             chase_point = [point_x, point_y]
  1818.             reversed_chase_point = [right_x, point_y]
  1819.             reach_point = true; break
  1820.         elsif sheet[point_x, up_y] == path_step
  1821.             chase_path.push(2)
  1822.             chase_point = [point_x, point_y]
  1823.             reversed_chase_point = [point_x, up_y]
  1824.             reach_point = true; break
  1825.         elsif sheet[point_x, down_y] == path_step
  1826.             chase_path.push(8)
  1827.             chase_point = [point_x, point_y]
  1828.             reversed_chase_point = [point_x, down_y]
  1829.             reach_point = true; break
  1830.         end
  1831.         # 以需要抵達該點的步數填充路徑表格 #
  1832.         if sheet[left_x, point_y] == 0                &&
  1833.            $game_map.ship_passable?(left_x, point_y)  &&
  1834.            !collide_with_events?(left_x, point_y)     &&
  1835.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  1836.           sheet[left_x, point_y] = step
  1837.           draw_path = true
  1838.           new_end_points.push(left_x, point_y)
  1839.         end
  1840.         if sheet[right_x, point_y] == 0               &&
  1841.            $game_map.ship_passable?(right_x, point_y) &&
  1842.            !collide_with_events?(right_x, point_y)    &&
  1843.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  1844.           sheet[right_x, point_y] = step
  1845.           draw_path = true
  1846.           new_end_points.push(right_x, point_y)
  1847.         end
  1848.         if sheet[point_x, up_y] == 0                  &&
  1849.            $game_map.ship_passable?(point_x, up_y)    &&
  1850.            !collide_with_events?(point_x, up_y)       &&
  1851.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  1852.           sheet[point_x, up_y] = step
  1853.           draw_path = true
  1854.           new_end_points.push(point_x, up_y)
  1855.         end
  1856.         if sheet[point_x, down_y] == 0                &&
  1857.            $game_map.ship_passable?(point_x, down_y)  &&
  1858.            !collide_with_events?(point_x, down_y)     &&
  1859.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  1860.           sheet[point_x, down_y] = step
  1861.           draw_path = true
  1862.           new_end_points.push(point_x, down_y)
  1863.         end
  1864.       end#endOfLoop3
  1865.       break if !draw_path || reach_point
  1866.       step += 1
  1867.     end #endOfLoop1 路徑表格填充完畢
  1868.     $mouse_move_sign.transparent = false
  1869.     # 判斷指定地點能否抵達
  1870.     if reach_point
  1871.       $mouse_move_sign.direction = 2
  1872.     else
  1873.       not_reach_point
  1874.       return
  1875.     end
  1876.     # 根據路徑表格繪製最短移動路徑(正向)
  1877.     steps = step / 2 * 2
  1878.     loop_times = step / 2
  1879.     point_x, point_y = chase_point[0], chase_point[1]
  1880.     for i in 2..loop_times # forLoop
  1881.     steps -= 2
  1882.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1883.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1884.         chase_path.push(2)
  1885.         point_y = $game_map.round_y(point_y + 1)
  1886.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1887.         chase_path.push(8)
  1888.         point_y = $game_map.round_y(point_y - 1)
  1889.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1890.         chase_path.push(4)
  1891.         point_x = $game_map.round_x(point_x - 1)
  1892.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1893.         chase_path.push(6)
  1894.         point_x = $game_map.round_x(point_x + 1)
  1895.       end
  1896.     else
  1897.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1898.         chase_path.push(4)
  1899.         point_x = $game_map.round_x(point_x - 1)
  1900.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1901.         chase_path.push(6)
  1902.         point_x = $game_map.round_x(point_x + 1)
  1903.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1904.         chase_path.push(2)
  1905.         point_y = $game_map.round_y(point_y + 1)
  1906.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1907.         chase_path.push(8)
  1908.         point_y = $game_map.round_y(point_y - 1)
  1909.       end
  1910.     end
  1911.     end #endOfForLoop
  1912.     # 如果指定點無法抵達或者登陸
  1913.     return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path)
  1914.     # 根據路徑表格繪製最短移動路徑(反向)
  1915.     steps = step / 2 * 2 + 1
  1916.     loop_times = step / 2
  1917.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
  1918.     for i in 1..loop_times # forLoop
  1919.     steps -= 2
  1920.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  1921.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1922.         reversed_chase_path.push(6)
  1923.         point_x = $game_map.round_x(point_x - 1)
  1924.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1925.         reversed_chase_path.push(4)
  1926.         point_x = $game_map.round_x(point_x + 1)
  1927.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1928.         reversed_chase_path.push(8)
  1929.         point_y = $game_map.round_y(point_y + 1)
  1930.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1931.         reversed_chase_path.push(2)
  1932.         point_y = $game_map.round_y(point_y - 1)
  1933.       end
  1934.     else
  1935.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
  1936.         reversed_chase_path.push(8)
  1937.         point_y = $game_map.round_y(point_y + 1)
  1938.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
  1939.         reversed_chase_path.push(2)
  1940.         point_y = $game_map.round_y(point_y - 1)
  1941.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
  1942.         reversed_chase_path.push(6)
  1943.         point_x = $game_map.round_x(point_x - 1)
  1944.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
  1945.         reversed_chase_path.push(4)
  1946.         point_x = $game_map.round_x(point_x + 1)
  1947.       end
  1948.     end
  1949.     end #endOfForLoop
  1950.     @mouse_move_path = reversed_chase_path.reverse + chase_path
  1951.   end#ship
  1952.   #--------------------------------------------------------------------------
  1953.   # ● 繪製airship的移動路徑 @array[move_directions...]
  1954.   #--------------------------------------------------------------------------
  1955.   def draw_air_path
  1956.     $mouse_move_sign.transparent = false
  1957.     # 準備繪製路徑表格
  1958.     sheet = Table.new($game_map.width, $game_map.height)
  1959.     new_check_point = [x, y]; sheet[x, y] = 1
  1960.     reach_point = false;      step = 2
  1961.     loop do #loop1
  1962.      check_point = new_check_point
  1963.      new_check_point = []
  1964.       loop do #loop2
  1965.         point_x = check_point.shift
  1966.         break if point_x == nil
  1967.         point_y = check_point.shift
  1968.         if point_x == @moveto_x && point_y == @moveto_y
  1969.           reach_point = true; break
  1970.         end
  1971.         left_x  = $game_map.round_x(point_x - 1)
  1972.         right_x = $game_map.round_x(point_x + 1)
  1973.         up_y    = $game_map.round_y(point_y - 1)
  1974.         down_y  = $game_map.round_y(point_y + 1)
  1975.         # 以需要抵達該點的步數填充路徑表格 #
  1976.         if sheet[left_x, point_y] == 0
  1977.           sheet[left_x, point_y] = step
  1978.           new_check_point.push(left_x, point_y)
  1979.         end
  1980.         if sheet[right_x, point_y] == 0
  1981.           sheet[right_x, point_y] = step
  1982.           new_check_point.push(right_x, point_y)
  1983.         end
  1984.         if sheet[point_x, up_y] == 0
  1985.           sheet[point_x, up_y] = step
  1986.           new_check_point.push(point_x, up_y)
  1987.         end
  1988.         if sheet[point_x, down_y] == 0
  1989.           sheet[point_x, down_y] = step
  1990.           new_check_point.push(point_x, down_y)
  1991.         end
  1992.       end#endOfLoop2
  1993.       break if reach_point
  1994.       step += 1
  1995.     end #endOfLoop1
  1996.     # 根據路徑表格繪製最短移動路徑 #
  1997.     reversed_chase_path = []; step -= 1
  1998.     point_x, point_y = @moveto_x, @moveto_y
  1999.     for i in 2..step
  2000.     step -= 1
  2001.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  2002.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
  2003.         reversed_chase_path.push(6)
  2004.         point_x = $game_map.round_x(point_x - 1)
  2005.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  2006.         reversed_chase_path.push(4)
  2007.         point_x = $game_map.round_x(point_x + 1)
  2008.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
  2009.         reversed_chase_path.push(8)
  2010.         point_y = $game_map.round_y(point_y + 1)
  2011.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  2012.         reversed_chase_path.push(2)
  2013.         point_y = $game_map.round_y(point_y - 1)
  2014.       end
  2015.     else
  2016.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step
  2017.         reversed_chase_path.push(8)
  2018.         point_y = $game_map.round_y(point_y + 1)
  2019.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  2020.         reversed_chase_path.push(2)
  2021.         point_y = $game_map.round_y(point_y - 1)
  2022.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step
  2023.         reversed_chase_path.push(6)
  2024.         point_x = $game_map.round_x(point_x - 1)
  2025.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  2026.         reversed_chase_path.push(4)
  2027.         point_x = $game_map.round_x(point_x + 1)
  2028.       end
  2029.     end
  2030.     end #endOfForLoop
  2031.     @mouse_move_path = reversed_chase_path.reverse
  2032.   end#airship
  2033.   #--------------------------------------------------------------------------
  2034.   # ● 目標點無法抵達時的處理,用於各路徑繪製方法內部
  2035.   #--------------------------------------------------------------------------
  2036.   def not_reach_point
  2037.     $mouse_move_sign.direction = 4
  2038.     dx = 0; dy = 0; dir = 0
  2039.     if @moveto_x - x > 0
  2040.       if @moveto_x - x > $game_map.width - @moveto_x + x &&
  2041.           $game_map.loop_vertical?
  2042.         dx = $game_map.width - @moveto_x + x; dir = 4
  2043.       else
  2044.         dx = @moveto_x - x; dir = 6
  2045.       end
  2046.     else
  2047.       if x - @moveto_x > $game_map.width - x + @moveto_x &&
  2048.           $game_map.loop_vertical?
  2049.         dx = $game_map.width - x + @moveto_x; dir = 6
  2050.       else
  2051.         dx = x - @moveto_x; dir = 4
  2052.       end
  2053.     end
  2054.     if @moveto_y - y > 0
  2055.       if @moveto_y - y > $game_map.height - @moveto_y + y &&
  2056.           $game_map.loop_horizontal?
  2057.         dy = $game_map.height - @moveto_y + y
  2058.         dir = 8 if dy > dx
  2059.       else
  2060.         dy = @moveto_y - y
  2061.         dir = 2 if dy > dx
  2062.       end
  2063.     else
  2064.       if y - @moveto_y > $game_map.height - y + @moveto_y &&
  2065.           $game_map.loop_horizontal?
  2066.         dy = $game_map.height - y + @moveto_y
  2067.         dir = 2 if dy > dx
  2068.       else
  2069.         dy = y - @moveto_y
  2070.         dir = 8 if dy > dx
  2071.       end
  2072.     end
  2073.     @mouse_move_path = [dir, 0] # 0方向用於防止移動過程中觸發事件
  2074.   end
  2075.   #--------------------------------------------------------------------------
  2076.   # ● 判斷目標點是否能抵達、登陸,用於船隻路徑繪製
  2077.   #--------------------------------------------------------------------------
  2078.   def landable?(x, y, path)
  2079.     case @vehicle_type
  2080.       when :ship; return $game_map.ship_passable?(x, y) ||
  2081.         $game_map.passable?(x, y, 10 - path[-1])
  2082.       when :boat; return $game_map.boat_passable?(x, y) ||
  2083.         $game_map.passable?(x, y, 10 - path[-1])
  2084.     end
  2085.   end
  2086. end

  2087. #==============================================================================
  2088. # ■ Game_Map
  2089. #------------------------------------------------------------------------------
  2090. #  管理地圖的類。擁有捲動地圖以及判斷通行度的功能。
  2091. #   本類的實例請參考 $game_map 。
  2092. #==============================================================================
  2093. class Game_Map
  2094.   #--------------------------------------------------------------------------
  2095.   # ● 定義實例變數
  2096.   #--------------------------------------------------------------------------
  2097.   attr_reader :mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法來更新資料
  2098.   attr_reader :mouse_map_y # 同上
  2099.   #--------------------------------------------------------------------------
  2100.   # ● 初始化對象
  2101.   #--------------------------------------------------------------------------
  2102.   alias sion_mouse_initialize initialize
  2103.   def initialize
  2104.     sion_mouse_initialize
  2105.     creat_move_sign  ###
  2106.     set_constants
  2107.   end
  2108.   #--------------------------------------------------------------------------
  2109.   # ● 更新畫面
  2110.   #     main : 事件解釋器更新的標誌
  2111.   #--------------------------------------------------------------------------
  2112.   alias sion_mouse_update update
  2113.   def update(main = false)
  2114.     sion_mouse_update(main)
  2115.     update_move_sign
  2116.   end
  2117.   #--------------------------------------------------------------------------
  2118.   # ● 創建顯示路徑點的事件
  2119.   #--------------------------------------------------------------------------
  2120.   def creat_move_sign
  2121.     $mouse_move_sign = Move_Sign.new
  2122.   end
  2123.   #--------------------------------------------------------------------------
  2124.   # ● 更新顯示路徑點的事件
  2125.   #--------------------------------------------------------------------------
  2126.   def set_constants
  2127.     @mouse_pos_setted = true
  2128.     @set_pos_prepared = false
  2129.     @mouse_old_x = 0
  2130.     @mouse_old_y = 0
  2131.   end
  2132.   #--------------------------------------------------------------------------
  2133.   # ● 更新顯示路徑點的事件
  2134.   #--------------------------------------------------------------------------
  2135.   def update_move_sign
  2136.     $mouse_move_sign.update
  2137.   end
  2138.   #--------------------------------------------------------------------------
  2139.   # ● 獲取滑鼠位於的地圖塊的x、y座標
  2140.   #--------------------------------------------------------------------------
  2141.   def get_mouse_map_xy
  2142.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  2143.     @mouse_map_x = round_x((@display_x + mouse_x / 32.0).to_i)
  2144.     @mouse_map_y = round_y((@display_y + mouse_y / 32.0).to_i)
  2145.   end
  2146.   #--------------------------------------------------------------------------
  2147.   # ● 返回地圖畫面時重設滑鼠座標
  2148.   #--------------------------------------------------------------------------
  2149.   def reset_mouse_pos
  2150.     return if @mouse_pos_setted
  2151.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
  2152.     @mouse_pos_setted = true
  2153.     @set_pos_prepared = false
  2154.   end
  2155.   #--------------------------------------------------------------------------
  2156.   # ● 重設滑鼠的座標
  2157.   #--------------------------------------------------------------------------
  2158.   def prepare_reset_mouse_pos
  2159.     return if @set_pos_prepared
  2160.     @mouse_pos_setted = false
  2161.     @mouse_old_x = Mouse.mouse_x
  2162.     @mouse_old_y = Mouse.mouse_y
  2163.     @set_pos_prepared = true
  2164.   end
  2165. end

  2166. #==============================================================================
  2167. # ■ Spriteset_Map
  2168. #------------------------------------------------------------------------------
  2169. #  處理地圖畫面精靈和圖塊的類。本類在 Scene_Map 類的內部使用。
  2170. #==============================================================================
  2171. class Spriteset_Map
  2172.   #--------------------------------------------------------------------------
  2173.   # ● 生成路徑點精靈
  2174.   #--------------------------------------------------------------------------
  2175.   alias sion_mouse_create_characters create_characters
  2176.   def create_characters
  2177.     sion_mouse_create_characters
  2178.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
  2179.   end
  2180. end

  2181. #==============================================================================
  2182. # ■ Scene_Map
  2183. #------------------------------------------------------------------------------
  2184. #  地圖畫面
  2185. #==============================================================================
  2186. class Scene_Map < Scene_Base
  2187.   #--------------------------------------------------------------------------
  2188.   # ● 畫面更新
  2189.   #--------------------------------------------------------------------------
  2190.   alias sion_mouse_update_scene update_scene
  2191.   def update_scene
  2192.     sion_mouse_update_scene
  2193.     update_mouse_action unless scene_changing?
  2194.   end
  2195.   #--------------------------------------------------------------------------
  2196.   # ● 場所移動前的處理
  2197.   #--------------------------------------------------------------------------
  2198.   alias sion_mouse_pre_transfer pre_transfer
  2199.   def pre_transfer
  2200.     $game_player.reset_move_path
  2201.     sion_mouse_pre_transfer
  2202.   end
  2203.   #--------------------------------------------------------------------------
  2204.   # ● 監聽滑鼠左鍵的按下
  2205.   #--------------------------------------------------------------------------
  2206.   def update_mouse_action
  2207.     $game_player.left_button_action if Mouse.press?(0x01)
  2208.   end
  2209. end

  2210. #==============================================================================
  2211. # ■ Scene_File
  2212. #------------------------------------------------------------------------------
  2213. #  存檔畫面和讀檔畫面共同的父類
  2214. #==============================================================================
  2215. class Scene_File < Scene_MenuBase
  2216.   #--------------------------------------------------------------------------
  2217.   # ● 開始處理
  2218.   #--------------------------------------------------------------------------
  2219.   alias sion_mouse_start start
  2220.   def start
  2221.     sion_mouse_start
  2222.     @move_state = 0
  2223.     set_mouse_pos
  2224.   end
  2225.   #--------------------------------------------------------------------------
  2226.   # ● 更新畫面
  2227.   #--------------------------------------------------------------------------
  2228.   alias sion_mouse_update update
  2229.   def update
  2230.     sion_mouse_update
  2231.     Input.dir4.zero? ? set_cursor : set_mouse_pos
  2232.   end
  2233.   #--------------------------------------------------------------------------
  2234.   # ● 更新游標
  2235.   #--------------------------------------------------------------------------
  2236.   def set_cursor
  2237.     @move_state += 1
  2238.     last_index = @index
  2239.     if mouse_which_window == -2
  2240.       if (@move_state - 1) % 6 == 0
  2241.         @index = (@index + 1) % item_max if @index < item_max - 1
  2242.       end
  2243.     elsif mouse_which_window == -1
  2244.       if (@move_state - 1) % 6 == 0
  2245.         @index = (@index - 1 + item_max) % item_max if @index > 0
  2246.       end
  2247.     else
  2248.       @move_state = 0
  2249.       @index = top_index + mouse_which_window
  2250.     end
  2251.     ensure_cursor_visible
  2252.     if @index != last_index
  2253.       @savefile_windows[last_index].selected = false
  2254.       @savefile_windows[@index].selected = true
  2255.     end
  2256.   end
  2257.   #--------------------------------------------------------------------------
  2258.   # ● 判斷滑鼠位於哪個視窗
  2259.   #--------------------------------------------------------------------------
  2260.   def mouse_which_window
  2261.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
  2262.     if mouse_y < @help_window.height + 14
  2263.       mouse_row = -1
  2264.     elsif mouse_y > Graphics.height - 14
  2265.       mouse_row = -2
  2266.     else
  2267.       mouse_row = 4 * (mouse_y - @help_window.height) /
  2268.         (Graphics.height - @help_window.height)
  2269.     end
  2270.     return mouse_row
  2271.   end
  2272.   #--------------------------------------------------------------------------
  2273.   # ● 方向鍵移動游標時將滑鼠移動到對應的游標位置
  2274.   #--------------------------------------------------------------------------
  2275.   def set_mouse_pos
  2276.     new_x = 40
  2277.     new_y = @help_window.height + savefile_height * (@index - top_index) + 24
  2278.     Mouse.set_mouse_pos(new_x, new_y)
  2279.   end
  2280. end

  2281. #==============================================================================
  2282. # ■ Game_Event
  2283. #------------------------------------------------------------------------------
  2284. #  處理事件的類。擁有條件判斷、事件頁的切換、並行處理、執行事件等功能。
  2285. #   在 Game_Map 類的內部使用。
  2286. #==============================================================================
  2287. class Game_Event < Game_Character
  2288.   #--------------------------------------------------------------------------
  2289.   # ● 事件啟動
  2290.   #--------------------------------------------------------------------------
  2291.   alias sion_mouse_start start
  2292.   def start
  2293.     return if mouse_start? && !Mouse.press?(0x01)
  2294.     sion_mouse_start
  2295.   end
  2296.   #--------------------------------------------------------------------------
  2297.   # ● 判斷事件是否由滑鼠啟動
  2298.   #--------------------------------------------------------------------------
  2299.   def mouse_start?
  2300.     return false if empty?
  2301.     @list.each do |index|
  2302.       return true if (index.code == 108 || index.code == 408) &&
  2303.         index.parameters[0].include?('滑鼠啟動')
  2304.     end
  2305.     return false
  2306.   end
  2307. end

  2308. ####泥煤的height
  2309. # @height = height

  2310. class Area_Response
  2311.   attr_accessor :type
  2312.   attr_reader :ox
  2313.   attr_reader :oy
  2314.   attr_reader :width
  2315.   attr_reader :height
  2316.   attr_reader :switch_id
  2317.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
  2318.     @type = type
  2319.     @ox = ox
  2320.     @oy = oy
  2321.     @width = width
  2322.     @height = height
  2323.     @switch_id = switch_id
  2324.   end
  2325. end

  2326. $area_responses = []

  2327. class Scene_Map
  2328.   alias update_mouse_2013421 update_mouse_action
  2329.   def update_mouse_action
  2330.     update_area_response
  2331.     update_mouse_2013421
  2332.   end
  2333.   def update_area_response
  2334.     responses = $area_responses
  2335.     responses.each {|response|
  2336.       ox = response.ox
  2337.       oy = response.oy
  2338.       width = response.width
  2339.       height = response.height
  2340.       switch_id = response.switch_id
  2341.       case response.type
  2342.       when 0
  2343.         if mouse_in_area?(ox, oy, width, height)
  2344.           $game_switches[switch_id] = true
  2345.           $area_responses.delete(response)
  2346.         end
  2347.       when 1
  2348.         if mouse_in_area?(ox, oy, width, height) && Mouse.trigger?(0x01)
  2349.           $game_switches[switch_id] = true
  2350.           $area_responses.delete(response)
  2351.         end
  2352.       when 2
  2353.         if mouse_in_area?(ox, oy, width, height)
  2354.           $game_switches[switch_id] = true
  2355.         else
  2356.           $game_switches[switch_id] = false
  2357.         end
  2358.       when 3
  2359.         if mouse_in_area?((ox - $game_map.display_x) * 32 ,
  2360.             (oy - $game_map.display_y) * 32, width, height)
  2361.           $game_map.events_xy(ox, oy).each {|event|
  2362.           event.start
  2363.           $area_responses.delete(response)
  2364.           return
  2365.           }
  2366.         end
  2367.       when 4
  2368.         if mouse_in_area?((ox - $game_map.display_x) * 32,
  2369.             (oy - $game_map.display_y) * 32, width, height)
  2370.           $game_map.events_xy(ox, oy).each {|event|
  2371.             event.start
  2372.             return
  2373.           }
  2374.         end
  2375.       end
  2376.     }
  2377.   end
  2378.   def mouse_in_area?(ox, oy, width, height)
  2379.     Mouse.mouse_x >= ox && Mouse.mouse_x <= ox + width &&
  2380.     Mouse.mouse_y >= oy && Mouse.mouse_y <= oy + height
  2381.   end
  2382. end
  2383. class Game_Interpreter
  2384.   def area_response(*arg)
  2385.     $area_responses.push(Area_Response.new(*arg))
  2386.   end
  2387. end
复制代码
我看不懂脚本...也只能拜托各位了

点评

你打击了我学编程的信心QAQ  发表于 2013-9-26 17:29
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
135 小时
注册时间
2012-6-14
帖子
43
8
 楼主| 发表于 2013-8-28 10:01:13 | 只看该作者
不好意思...
我找到了...
地圖這方面...呃就是事件添加註釋滑鼠啟動就行了...(太簡單了一直沒看到OTZ
不過這樣人物對話時分歧選項要弄成這樣就沒辦法耶...

是這一個要另外修改什麼嗎?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
48
在线时间
95 小时
注册时间
2013-3-8
帖子
268
9
发表于 2013-8-28 10:14:31 | 只看该作者
本帖最后由 蓝焰。 于 2013-8-28 10:16 编辑

厉害的脚本渣表示:
用一些简单的东西就可以:
  1. varaable = Window_A.new(x,y,w,h)
  2. varaable = Window_B.new(x,y,w,h)
  3. varaable = Window_C.new(x,y,w,h)
  4. varaable = Window_D.new(x,y,w,h)
复制代码
然后用你的脚本什么的什么什么去吧!(因为后面的我还没学到)
我是厉害的脚本渣XD
不看最后的XD你一定觉得我是来捣乱的,事实上我是来灌水的XD

评分

参与人数 1星屑 -10 收起 理由
Mic_洛洛 -10 不带你这样卖萌的,请自重!

查看全部评分

我也要给自己的群宣传~> <

RUBY-技术讨论群:126393968

欢迎新人或是触前来支持


阿里阿多~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
135 小时
注册时间
2012-6-14
帖子
43
10
 楼主| 发表于 2013-8-28 11:16:07 | 只看该作者
蓝焰。 发表于 2013-8-28 10:14
厉害的脚本渣表示:
用一些简单的东西就可以:然后用你的脚本什么的什么什么去吧!(因为后面的我还没学到 ...

......??
所以這是??
我看不懂腳本的...這是要怎麼用?

点评

喔...所以我不用管這個...... 因為這個也不一定適用? 等下看別人的回答就成?  发表于 2013-8-28 13:06
几十个小时前我也看不懂...我说的是在线时间..事实上我也不会用..  发表于 2013-8-28 11:30
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-6-6 11:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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