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

Project1

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

[已经解决] 一个和XAS不冲突的鼠标脚本 能否去掉它的点击走路功能

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
65 小时
注册时间
2008-5-15
帖子
44
跳转到指定楼层
1
发表于 2013-3-26 17:54:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 牲口 于 2013-3-26 18:45 编辑

RUBY 代码复制
  1. #===========================================================================#
  2.  
  3. # * Version 2.0 change log (Date: January 13 2013)
  4.  
  5. # - Added path finding, now the game player is able to move using the mouse
  6. # - Added compatibility with Victor Animated Battle version 1.x and above
  7. # - Now you are able to change the mouse cursor icon in game
  8. # - Two new notetags added to change the mouse cursor by event comment tags
  9. # - Fixed crash when pointing a notetagged event with a valid condition
  10. #----------------------------------------------------------------------------
  11. # * Version 1.6 change log (Date: November 21 2012)
  12. #
  13. # - Added compatibility for any game screen resolution
  14. # - System optimized to consume less cpu than before
  15. # - Added extra compatibility for Pearl ABS Liquid
  16. # - Removed the font fix
  17. # - Added the imported bolean
  18. #----------------------------------------------------------------------------
  19. # * Version 1.5 change log
  20. #
  21. # - Fixed cursor sound over loading on selectable windows
  22. # - Fixed bug when selecting event graphic tileset that have mouse comment tag
  23. # - FIxed minor bug when transfering (event name now erase completely)
  24. # - Added option to turn on / off arrow selector on save file
  25. # - Important! changes on mouse comment tags!
  26. #   ~ CLICK START change to MOUSE START
  27. #   ~ ANIMATION   change to MOUSE ANIMATION
  28. #   ~ NAME        change to MOUSE NAME
  29. #
  30. #---------------------------------------------------------------------------
  31. # * installation
  32. #
  33. # Copy and paste this script above main done!
  34. #
  35. # * Mouse triggers
  36. #   - Left click:     Action button
  37. #   - Right click:    Cancel button, close windows
  38. #   - Mouse wheel middle button:   DASH
  39. #
  40. #---------------------------------------------------------------------------
  41. # * Main features
  42. #
  43. # - Allow you create buttons and configure them to do something
  44. # - Events can be buttons too, map ground buttons! for some puzzles etc.
  45. # - Allow you display event name
  46. # - Full mouse interaction
  47. # - WASD movement optional
  48. # - Path finding feature, player is able to move using the mouse
  49. # - Mouse cursor changing in-game enabled
  50. #---------------------------------------------------------------------------
  51. # * Event buttons commands
  52. #
  53. # Write this lines on event comments tags
  54. #
  55. # MOUSE START       - Event start when you click the event
  56. # MOUSE ANIMATION x - Show animation when mouse is over event,
  57. #                     ex: MOUSE ANIMATION 1
  58. # MOUSE NAME x      - Display event name when mouse is over event,
  59. #                     ex: MOUSE NAME Falcao
  60. # MOUSE ICON x      - change the mouse cursor icon when it is over the event
  61. #                     change x for the icon index to display
  62. # MOUSE PIC X       - Change the mouse cursor when is over an event but in this
  63. #                     case it display a picture graphic name, change x for the
  64. #                     picture name
  65. #------------------------------------------------------------------------------
  66. # * Script calls
  67. #
  68. # Call this line to turn off/on the mouse cursor within the game true/false
  69. # Mouse.show_cursor(false)
  70. #
  71. # If you want to change the mouse cursor manually use the following script calls
  72. # Mouse.set_cursor(:iconset, x)     - change x for any icon index
  73. #
  74. # if you want to show a picture instead iconset use the next script call
  75. # Mouse.set_cursor(:picture, name)  - change name for picture name
  76. #-----------------------------------------------------------------------------
  77.  
  78. module Map_Buttons
  79.  
  80. # You can easily insert as many buttons you want to the map screen
  81. # define here below your buttons parameters
  82.  
  83.   Insert = {
  84. #-----------------------------------------------------------------------------
  85. #  A => [B, C, D, E, F]
  86. #  
  87. #  A = Button number
  88. #
  89. #  B = Name
  90. #  C = X position in screen tile
  91. #  D = Y position in screen tile
  92. #  E = Icon, if you want a picture write picture 'name' otherwise icon index
  93. #  F = What this button gonna do?, you have two options, call scene or call
  94. #  common event, if you want scene put scene name, if you want common event
  95. #  put common event ID
  96.  
  97.   # This button call the menu screen
  98.   1=> ["Menu", 16, 11, 117, Scene_Menu],  
  99.  
  100.   # This button call a common event ID 1
  101.   2=>  ["Bestiary",  16, 12, 121, 1],
  102.  
  103.  
  104.  
  105.   }
  106.  
  107. # * General configutration
  108.  
  109. # Mouse cursor icon, if you want a picture write pic 'name' otherwise icon index
  110.   CursorIcon = 386
  111.  
  112. # Switch ID to turn off/on the icons on the screen
  113.   Switch = 100
  114.  
  115. # Allow movement with  W A S D keys true/false
  116.   WASD_Movement = true
  117.  
  118. # Display arrow selector on save file? true / false
  119.   DisplaySelector = false
  120.  
  121. # When you click on event, do you want the player to ignore the self movement?
  122.   IgnoreEventPath = true
  123.  
  124. # Switch id to enable or disable the path finding feature
  125.   PathFinderSwitch = 500
  126. #
  127. #----------------------------------------------------------------------------
  128. #
  129. # * License
  130. #
  131. # You can use this script in non comercial games, in you need it for comercial
  132. # games let me know. [email][email protected][/email]
  133. #-----------------------------------------------------------------------------
  134.  
  135.   def self.check_value(value)
  136.     return 'numeric' if value.is_a? Fixnum
  137.     return 'string'
  138.   end
  139. end
  140.  
  141. ($imported ||= {})[:Mouse_System_Buttons] = 2.0
  142.  
  143. # This class create all screen and event buttons on game screen
  144. class Interactive_Buttoms
  145.   attr_reader :cursoring
  146.   def initialize
  147.     create_screen_buttoms
  148.     @ani_delay = 0
  149.   end
  150.  
  151.   def create_screen_buttoms
  152.     if $imported["Falcao Pearl ABS Liquid"]
  153.       if PearlKernel::clean_back?
  154.         @buttons_sprites = []
  155.         return
  156.       end
  157.     end
  158.     @buttons_sprites = []
  159.     for i in Map_Buttons::Insert.values
  160.       @buttons_sprites.push(Sprite_Buttons.new(i[0], i[1], i[2], i[3], i[4]))
  161.     end
  162.   end
  163.  
  164.   def create_button_text
  165.     if @button_text.nil?
  166.       @button_text = Sprite.new
  167.       @button_text.bitmap = Bitmap.new(100, 32)
  168.       @button_text.z = 50
  169.       @button_text.bitmap.font.size = 16
  170.     end
  171.   end
  172.  
  173.   def dispose_screen_buttons
  174.     for button in @buttons_sprites
  175.       button.dispose
  176.     end
  177.     @buttons_sprites = []
  178.   end
  179.  
  180.   def dispose_button_text
  181.     if not @button_text.nil?
  182.       @button_text.dispose
  183.       @button_text.bitmap.dispose
  184.       @button_text = nil
  185.     end
  186.   end
  187.  
  188.   def dispose
  189.     dispose_screen_buttons
  190.     dispose_button_text
  191.   end
  192.  
  193.   def update
  194.     if $game_switches[Map_Buttons::Switch] and not @buttons_sprites.empty?
  195.       dispose_screen_buttons
  196.     elsif not $game_switches[Map_Buttons::Switch] and @buttons_sprites.empty?
  197.       create_screen_buttoms
  198.     end
  199.     update_buttons
  200.     update_event_selection
  201.   end
  202.  
  203.   # path update
  204.   def update_path
  205.     return if $game_switches[Map_Buttons::PathFinderSwitch]
  206.     return if $game_message.busy?
  207.     return unless $game_player.normal_walk?
  208.     mx, my = Mouse.map_grid[0], Mouse.map_grid[1]
  209.     if Map_Buttons::IgnoreEventPath
  210.       $game_map.events.values.each do |event|
  211.         return if event.x == mx and event.y == my
  212.       end
  213.     end
  214.     $game_player.find_path(mx, my)
  215.   end
  216.  
  217.   def update_buttons
  218.     for button in @buttons_sprites
  219.       button.update
  220.       if button.zooming
  221.         @screen_b = true
  222.         create_button_text
  223.         if button.x > 272
  224.           x, y = button.px * 32 - 98, button.py * 32
  225.           draw_button_text(x, y, button.name, 2)
  226.         elsif button.x < 272
  227.           x, y = button.px * 32 + 31, button.py * 32
  228.           draw_button_text(x, y, button.name, 0)
  229.         end
  230.       end
  231.     end
  232.  
  233.     if @screen_b != nil
  234.       unless mouse_over_button?
  235.         dispose_button_text
  236.         @screen_b = nil
  237.       end
  238.     end
  239.   end
  240.  
  241.   def reset_cursor
  242.     if Map_Buttons::check_value(@cursoring[1]) == 'numeric'
  243.       Mouse.set_cursor(:iconset, @cursoring[1], true)
  244.     else
  245.       Mouse.set_cursor(:picture, @cursoring[1], true)
  246.     end
  247.     @cursoring = nil
  248.   end
  249.  
  250.   def apply_iconchanging(sym, operand, event)
  251.     cursor = $game_system.cursorr
  252.     cursor = Map_Buttons::CursorIcon if cursor.nil?
  253.     @cursoring = [event, cursor]
  254.     Mouse.set_cursor(sym, operand, true)
  255.   end
  256.  
  257.   def update_event_selection
  258.     return if @screen_b #disable event buttom if mouse over screen buttom
  259.     update_path if Mouse.trigger?(0)
  260.     for event in $game_map.events.values
  261.       next if event.page.nil?
  262.       if event.x == Mouse.map_grid[0] and event.y == Mouse.map_grid[1]
  263.         if event.mouse_start
  264.           if Mouse.trigger?(0) and !$game_map.interpreter.running?
  265.             event.start
  266.           end
  267.         end
  268.         anime = event.mouse_animation
  269.         if anime != 0
  270.           @ani_delay += 1
  271.           event.animation_id = anime if @ani_delay == 1
  272.           @ani_delay = 0 if @ani_delay > 16
  273.         end
  274.         name = event.mouse_name
  275.         if name != ""
  276.           @eve = [event.x, event.y, event, name]
  277.           create_button_text
  278.         end
  279.         icon = event.mouse_iconset
  280.         picture = event.mouse_picture
  281.         if !icon.nil? and icon != 0 and @cursoring.nil?
  282.           apply_iconchanging(:iconset, icon, event)
  283.         elsif !picture.nil? and picture != "" and @cursoring.nil?
  284.           apply_iconchanging(:picture, picture, event)
  285.         end
  286.       end
  287.     end
  288.  
  289.     if @cursoring != nil
  290.       reset_cursor if not mouse_over_event?(@cursoring[0].x, @cursoring[0].y)
  291.     end
  292.  
  293.     if @eve != nil
  294.       @eve[2].ch_oy.nil? ? event_oy = 32 : event_oy = @eve[2].ch_oy
  295.       if event_oy > 32
  296.         draw_button_text(@eve[2].screen_x - 49,
  297.         @eve[2].screen_y - event_oy / 2 - 50, @eve[3], 1)
  298.       else
  299.         draw_button_text(@eve[2].screen_x - 49,
  300.         @eve[2].screen_y - event_oy / 2 - 36, @eve[3], 1)
  301.       end
  302.       if not mouse_over_event?(@eve[0], @eve[1])
  303.         dispose_button_text
  304.         @eve = nil
  305.       end
  306.     end
  307.   end
  308.  
  309.   def draw_button_text(x, y, text, a=0)
  310.     return if @button_text.nil?
  311.     @button_text.x = x
  312.     @button_text.y = y
  313.     return if @old_name == text
  314.     @button_text.bitmap.clear
  315.     @button_text.bitmap.draw_text(2, 0, @button_text.bitmap.width, 32, text, a)
  316.     @old_name = text
  317.   end
  318.  
  319.   def mouse_over_button?
  320.     for button in @buttons_sprites
  321.       if Mouse.object_area?(button.x, button.y - 6, button.width, button.height)
  322.         return true
  323.       end
  324.     end
  325.     @old_name = nil
  326.     return false
  327.   end
  328.  
  329.   def mouse_over_event?(event_x, event_y)
  330.     if Mouse.map_grid[0] == event_x and Mouse.map_grid[1] == event_y
  331.       return true
  332.     end
  333.     @old_name = nil
  334.     return false
  335.   end
  336. end
  337.  
  338. # Set buttons 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. # comments definition
  365. class Game_Event < Game_Character
  366.   attr_reader   :mouse_start, :mouse_animation, :mouse_name, :mouse_iconset
  367.   attr_reader   :mouse_picture, :page
  368.   alias falcaomouse_setup setup_page_settings
  369.   def setup_page_settings
  370.     falcaomouse_setup
  371.     @mouse_start     = check_comment("MOUSE START")
  372.     @mouse_animation = check_value("MOUSE ANIMATION")
  373.     @mouse_name      = check_name("MOUSE NAME")
  374.     @mouse_iconset   = check_value("MOUSE ICON")
  375.     @mouse_picture   = check_name("MOUSE PIC")
  376.   end
  377.  
  378.   def check_comment(comment)
  379.     return false if @list.nil? or @list.size <= 0
  380.     for item in @list
  381.       if item.code == 108 or item.code == 408
  382.         if item.parameters[0].include?(comment)
  383.           return true
  384.         end
  385.       end
  386.     end
  387.     return false
  388.   end
  389.  
  390.   def check_value(comment)
  391.     return 0 if @list.nil? or @list.size <= 0
  392.     for item in @list
  393.       if item.code == 108 or item.code == 408
  394.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  395.           return $1.to_i
  396.         end
  397.       end
  398.     end
  399.     return 0
  400.   end
  401.  
  402.   def check_name(comment)
  403.     return "" if @list.nil? or @list.size <= 0
  404.     for item in @list
  405.       next unless item.code == 108 or item.code == 408
  406.       if item.parameters[0] =~ /#{comment} (.*)/
  407.         return $1.to_s
  408.       end
  409.     end
  410.     return ""
  411.   end
  412. end
  413.  
  414. # Create screen buttons sprites
  415. class Sprite_Buttons < Sprite
  416.   attr_reader   :px
  417.   attr_reader   :py
  418.   attr_reader   :name
  419.   attr_reader   :zooming
  420.   def initialize(name, px, py, icon_index, action=nil)
  421.     super()
  422.     self.z = 50
  423.     @icon_index = icon_index
  424.     @px = px
  425.     @py = py
  426.     @action = action
  427.     @object_zooming = 0
  428.     @zooming = false
  429.     @name = name
  430.     set_bitmap
  431.     update
  432.   end
  433.  
  434.   def update
  435.     super
  436.     if Mouse.object_area?(self.x, self.y - 4, self.bitmap.width,
  437.       self.bitmap.height)
  438.       @zooming = true
  439.       @object_zooming += 1
  440.       case @object_zooming
  441.       when 1..10  ; self.zoom_x -= 0.02 ;  self.zoom_y -= 0.02
  442.       when 11..20 ; self.zoom_x += 0.02 ;  self.zoom_y += 0.02
  443.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  444.         @object_zooming = 0
  445.       end
  446.       if Mouse.trigger?(0) and @action != nil
  447.         unless $game_map.interpreter.running?
  448.           Sound.play_ok
  449.           if @action == Scene_Menu and not $game_system.menu_disabled
  450.             SceneManager.call(@action)
  451.             Window_MenuCommand::init_command_position
  452.             return
  453.           end
  454.          if Map_Buttons::check_value(@action) == 'numeric'
  455.            $game_temp.reserve_common_event(@action)
  456.          else
  457.            SceneManager.call(@action)
  458.          end
  459.         end
  460.       end
  461.     elsif @object_zooming > 0
  462.       self.zoom_x = 1.0
  463.       self.zoom_y = 1.0
  464.       @object_zooming = 0
  465.     else
  466.       @zooming = false
  467.     end
  468.   end
  469.  
  470.   def set_bitmap
  471.     if Map_Buttons::check_value(@icon_index) == 'numeric'
  472.       self.bitmap = Bitmap.new(24, 24)
  473.       bitmap = Cache.system("Iconset")
  474.       rect = Rect.new(@icon_index % 16 * 24, @icon_index / 16 * 24, 24, 24)
  475.       self.bitmap.blt(0, 0, bitmap, rect)
  476.     else
  477.       self.bitmap = Cache.picture(@icon_index)
  478.     end
  479.     self.x = @px * 32 + 4
  480.     self.y = @py * 32 + 4
  481.   end
  482. end
  483.  
  484. # Game_character new variable
  485. class Game_CharacterBase
  486.   attr_accessor :ch_oy
  487. end
  488.  
  489. # Sprite character
  490. class Sprite_Character < Sprite_Base
  491.   alias falcaoadd_oxy_set_character_bitmap set_character_bitmap
  492.   def set_character_bitmap
  493.     falcaoadd_oxy_set_character_bitmap
  494.     @character.ch_oy = self.oy
  495.   end
  496. end
  497.  
  498. class Game_System
  499.   attr_accessor :current_cursor
  500.   def cursorr
  501.     return Map_Buttons::CursorIcon if @current_cursor.nil?
  502.     return @current_cursor
  503.   end
  504. end
  505.  
  506. # Mouse module
  507. module Mouse
  508.  
  509.   GetKeyState    = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')
  510.   GetCursorPos   = Win32API.new('user32',    'GetCursorPos',     'p',     'i')
  511.   GetClientRect  = Win32API.new('user32',    'GetClientRect',    %w(l p), 'i')
  512.   ShowCursor     = Win32API.new('user32',    'ShowCursor',       'i',     'l')
  513.   ScreenToClient = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')
  514.   Findwindow     = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
  515.   GetPrivatePro  = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  516.   %w(p p p p l p), 'l')
  517.  
  518.   ShowCursor.call(0)
  519.  
  520.   @triggers     =   [[0, 1], [0, 2], [0, 4]]
  521.   @old_pos      =   0
  522.  
  523.   # Mouse Sprite
  524.  
  525.   def self.set_cursor(sym, operand, write=false)
  526.     case sym
  527.     when :iconset
  528.       $mouse_cursor.bitmap = Bitmap.new(24, 24)
  529.       bitmap = Cache.system("Iconset")
  530.       rect = Rect.new(operand % 16 * 24, operand / 16 * 24, 24, 24)
  531.       $mouse_cursor.bitmap.blt(0, 0, bitmap, rect)
  532.     when :picture then $mouse_cursor.bitmap = Cache.picture(operand)
  533.     end
  534.     $game_system.current_cursor = operand if write
  535.   end
  536.  
  537.   $mouse_cursor = Sprite.new
  538.   icon = Map_Buttons::CursorIcon
  539.   if Map_Buttons::check_value(icon) == 'numeric'
  540.     set_cursor(:iconset, icon)
  541.   else
  542.     set_cursor(:picture, icon)
  543.   end
  544.   $mouse_cursor.z = 10001
  545.   $mouse_cursor.x = $mouse_cursor.y = 1000
  546.   $mouse_cursor.ox = 4
  547.  
  548.   def self.show_cursor(value)
  549.     unless value
  550.       @pos[0] = @pos[1] = 600
  551.     end
  552.     $mouse_cursor.visible = value
  553.   end
  554.  
  555.   def self.map_grid
  556.     return nil if @pos == nil
  557.     x = ($game_map.display_x).to_i + (@pos[0] / 32)
  558.     y = ($game_map.display_y).to_i + (@pos[1] / 32)
  559.     return [x, y]
  560.   end
  561.  
  562.   def self.standing?
  563.     return false if @old_px != @pos[0]
  564.     return false if @old_py != @pos[1]
  565.     return true
  566.   end
  567.  
  568.   def self.input_keys
  569.     $game_arrows.mode_on ? type = $game_arrows.in_type : type = Input::C
  570.     keys = {0 => type, 1 => Input::B, 2 => Input::A}
  571.     return keys
  572.   end
  573.  
  574.   def self.object_area?(x, y, width, height)
  575.     return false if @pos.nil?
  576.     return @pos[0].between?(x, width + x) && @pos[1].between?(y, height + y)
  577.   end
  578.  
  579.   def self.position
  580.     return @pos == nil ? [0, 0] : @pos
  581.   end
  582.  
  583.   def self.global_pos
  584.     pos = [0, 0].pack('ll')
  585.     return GetCursorPos.call(pos) == 0 ? nil : pos.unpack('ll')
  586.   end
  587.  
  588.   def self.screen_to_client(x=0, y=0)
  589.     pos = [x, y].pack('ll')
  590.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  591.   end  
  592.  
  593.   def self.pos
  594.     global_pos = [0, 0].pack('ll')   
  595.     gx, gy = GetCursorPos.call(global_pos) == 0 ? nil : global_pos.unpack('ll')
  596.     local_pos = [gx, gy].pack('ll')
  597.     x, y = ScreenToClient.call(self.hwnd,
  598.     local_pos) == 0 ? nil : local_pos.unpack('ll')
  599.     begin
  600.       if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
  601.         @old_px, @old_py = x, y
  602.         return x, y
  603.       else
  604.         return -20, -20
  605.       end
  606.     rescue
  607.       return 0, 0
  608.     end
  609.   end  
  610.  
  611.   def self.update
  612.     old_pos = @pos
  613.     @pos = self.pos
  614.     self.input_keys
  615.     if !$mouse_cursor.visible && old_pos != @pos
  616.       $mouse_cursor.visible = true
  617.     end
  618.     if old_pos != [-20, -20] && @pos == [-20, -20]
  619.       ShowCursor.call(1)
  620.     elsif old_pos == [-20, -20] && @pos != [-20, -20]
  621.        ShowCursor.call(0)
  622.     end
  623.     for i in @triggers
  624.       n = GetKeyState.call(i[1])
  625.       if [0, 1].include?(n)
  626.         i[0] = (i[0] > 0 ? i[0] * -1 : 0)
  627.       else
  628.         i[0] = (i[0] > 0 ? i[0] + 1 : 1)
  629.       end
  630.     end
  631.   end
  632.  
  633.   # trigger definition
  634.   def self.trigger?(id = 0)
  635.     pos = self.pos
  636.     if pos != [-20,-20]
  637.     case id
  638.       when 0  
  639.         return @triggers[id][0] == 1
  640.       when 1  
  641.         if @triggers[1][0] == 1 && !$game_system.menu_disabled
  642.           return @triggers[id][0] == 1
  643.         end
  644.       when 2
  645.         return @triggers[id][0] == 1
  646.       end   
  647.     end
  648.   end
  649.  
  650.   # repeat definition
  651.   def self.repeat?(id = 0)
  652.     if @triggers[id][0] <= 0
  653.       return false
  654.     else
  655.       return @triggers[id][0] % 5 == 1 && @triggers[id][0] % 5 != 2
  656.     end
  657.   end
  658.  
  659.   #press definition
  660.   def self.press?(id = 0)
  661.     if @triggers[id][0] <= 0
  662.       return false
  663.     else
  664.       return true
  665.     end
  666.   end
  667.  
  668.   def self.screen_to_client(x=0, y=0)
  669.     pos = [x, y].pack('ll')
  670.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  671.   end
  672.  
  673.   def self.hwnd
  674.     if @hwnd.nil?
  675.       game_name = "\0" * 256
  676.       GetPrivatePro.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  677.       game_name.delete!("\0")
  678.       @hwnd = Findwindow.call('RGSS Player', game_name)
  679.     end
  680.     return @hwnd
  681.   end
  682.  
  683.   def self.client_size
  684.     rect = [0, 0, 0, 0].pack('l4')
  685.     GetClientRect.call(self.hwnd, rect)
  686.     right, bottom = rect.unpack('l4')[2..3]
  687.     return right, bottom
  688.   end
  689. end
  690.  
  691. # Input module aliased
  692. class << Input
  693.   unless self.method_defined?(:falcao21_mouse_update)
  694.     alias_method :falcao21_mouse_update,   :update
  695.     alias_method :falcao21_mouse_trigger?, :trigger?
  696.     alias_method :falcao21_mouse_repeat?,  :repeat?
  697.     alias_method :fal_mouse_input_press?,  :press?
  698.   end
  699.  
  700.   def update
  701.     if $mouse_cursor.visible
  702.       Mouse.update
  703.       $game_arrows.update
  704.       mx, my = *Mouse.position
  705.       $mouse_cursor.x = mx unless mx.nil?
  706.       $mouse_cursor.y = my unless my.nil?   
  707.     end
  708.     falcao21_mouse_update
  709.   end
  710.  
  711.   # trigger
  712.   def trigger?(constant)
  713.     return true if falcao21_mouse_trigger?(constant)
  714.     unless Mouse.pos.nil?
  715.       if Mouse.input_keys.has_value?(constant)
  716.         mouse_trigger = Mouse.input_keys.index(constant)
  717.         return true if Mouse.trigger?(mouse_trigger)
  718.       end
  719.     end
  720.     return false
  721.   end
  722.  
  723.   # press
  724.   def press?(constant)
  725.     return true if fal_mouse_input_press?(constant)
  726.     unless Mouse.pos.nil?
  727.       if Mouse.input_keys.has_value?(constant)
  728.         mouse_trigger = Mouse.input_keys.index(constant)
  729.         return true if Mouse.press?(mouse_trigger)      
  730.       end
  731.     end
  732.     return false
  733.   end
  734.  
  735.   # repeat
  736.   def repeat?(constant)
  737.     return true if falcao21_mouse_repeat?(constant)
  738.     unless Mouse.pos.nil?
  739.       if Mouse.input_keys.has_value?(constant)
  740.         mouse_trigger = Mouse.input_keys.index(constant)     
  741.         return true if Mouse.repeat?(mouse_trigger)
  742.       end
  743.     end
  744.     return false
  745.   end
  746. end
  747.  
  748. # Here your best friend, you can call this script within the game, scene etc.
  749. # $game_arrows.create_arrows(x, y), create it, $game_arrows.dispose, delete it
  750. class Game_Arrow_Selector
  751.   attr_accessor :mode_on
  752.   attr_accessor :in_type
  753.   def initialize
  754.     @mode_on = false
  755.   end
  756.  
  757.   def create_arrows(x, y)
  758.     return unless @arrows_sprites.nil?
  759.     buttons = {1=> 'UP', 2=> 'RIGHT', 3=> 'DOWN',
  760.     4=> 'LEFT', 5=> 'OK', 6=> 'Cancel'}
  761.     @arrows_sprites = []
  762.     for i in buttons.values
  763.       @arrows_sprites.push(Garrows_Sprites.new(i, x, y))
  764.     end
  765.   end
  766.  
  767.   def dispose
  768.     return if @arrows_sprites.nil?
  769.     for arrow in @arrows_sprites
  770.       arrow.dispose
  771.     end
  772.     @arrows_sprites = nil
  773.     @mode_on = false
  774.   end
  775.  
  776.   def update
  777.     return if @arrows_sprites.nil?
  778.     for arrow in @arrows_sprites
  779.       arrow.update
  780.     end
  781.   end
  782. end
  783.  
  784. class Garrows_Sprites < Sprite
  785.   def initialize(name, x, y)
  786.     super()
  787.     self.z = 1000
  788.     @px, @py = x, y
  789.     @name = name
  790.     @object_zooming = 0
  791.     @zooming = false
  792.     set_bitmap
  793.     update
  794.   end
  795.  
  796.   def update
  797.     super
  798.     if Mouse.object_area?(self.x + @fix[0], self.y + @fix[1],
  799.       self.bitmap.width + @fix[2], self.bitmap.height + @fix[3])
  800.       $game_arrows.mode_on = true
  801.       $game_arrows.in_type = Input::UP    if @name == 'UP'
  802.       $game_arrows.in_type = Input::DOWN  if @name == 'DOWN'
  803.       $game_arrows.in_type = Input::LEFT  if @name == 'LEFT'
  804.       $game_arrows.in_type = Input::RIGHT if @name == 'RIGHT'
  805.       $game_arrows.in_type = Input::C     if @name == 'OK'
  806.       $game_arrows.in_type = Input::B     if @name == 'Cancel'
  807.       @object_zooming += 1
  808.       @zooming = true
  809.       case @object_zooming
  810.       when 1..10  ; self.zoom_x -= 0.01 ;  self.zoom_y -= 0.01
  811.       when 11..20 ; self.zoom_x += 0.01 ;  self.zoom_y += 0.01
  812.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  813.         @object_zooming = 0
  814.       end
  815.     elsif @object_zooming > 0
  816.       self.zoom_x = 1.0
  817.       self.zoom_y = 1.0
  818.       @object_zooming = 0
  819.     elsif @zooming
  820.       @zooming = false
  821.       $game_arrows.mode_on = false
  822.     end
  823.   end
  824.  
  825.   def set_bitmap
  826.     self.bitmap = Bitmap.new(24, 15) if @name != 'Cancel'
  827.     case @name
  828.     when 'UP'
  829.       self.x = @px + 25 ; self.y = @py - 2
  830.       self.angle = 182  ; @fix = [-23, -18, 0,  0]
  831.     when 'DOWN'
  832.       self.x = @px + 1 ; self.y = @py + 26
  833.       @fix = [0, -4, 0,  0]
  834.     when 'LEFT'
  835.       self.x = @px      ; self.y = @py + 1
  836.       self.angle = - 92 ; @fix = [-14, -4, - 9,  9]
  837.     when 'RIGHT'
  838.       self.x = @px + 26  ; self.y = @py + 26
  839.       self.angle = + 92  ; @fix = [0, - 26, - 9,  9]
  840.     when 'OK'
  841.       self.x = @px + 1  ; self.y = @py + 6
  842.       @fix = [0, -4, 0,  0]
  843.       self.bitmap.font.size = 20
  844.       self.bitmap.draw_text(4, -7, self.bitmap.width, 32, @name)
  845.       return
  846.     when 'Cancel'
  847.       self.x = @px - 11  ; self.y = @py + 42
  848.       @fix = [0, -4, 0,  0]
  849.       self.bitmap = Bitmap.new(50, 15)
  850.       self.bitmap.font.size = 20
  851.       self.bitmap.draw_text(2, -7, self.bitmap.width, 32, @name)
  852.       return
  853.     end
  854.     draw_crappy_triangle(0, 0)
  855.   end
  856.  
  857.   # This method create a crappy triangle pointing down
  858.   def draw_crappy_triangle(px, py)
  859.     color = Color.new(192, 224, 255, 255)
  860.     x, y, w, =  0, 4, 24
  861.     self.bitmap.fill_rect(px + 1, py, 22, 1, color)
  862.     self.bitmap.fill_rect(px,     py + 1, 24, 4, color)
  863.     for i in 1..10
  864.       x += 1; y += 1; w -= 2
  865.       self.bitmap.fill_rect(px + x, py + y,       w, 1, color)
  866.     end
  867.   end
  868. end
  869.  
  870. $game_arrows = Game_Arrow_Selector.new
  871.  
  872. # Arrow selector is displayed when Input number is on
  873. class Game_Interpreter
  874.   alias falcao_setup_num_input setup_num_input
  875.   def setup_num_input(params)
  876.     falcao_setup_num_input(params)
  877.     $game_arrows.create_arrows(256, 194) if $game_message.position == 0
  878.     $game_arrows.create_arrows(256, 340) if $game_message.position == 1
  879.     $game_arrows.create_arrows(256, 180) if $game_message.position == 2
  880.   end
  881. end
  882.  
  883. # Arrow selector is disposed when press ok
  884. class Window_NumberInput < Window_Base
  885.   alias falcao_process_ok process_ok
  886.   def process_ok
  887.     falcao_process_ok
  888.     $game_arrows.dispose
  889.   end
  890. end
  891.  
  892. # Arrow selector is displayed within save and load scene
  893. class Scene_File < Scene_MenuBase
  894.   alias falcao47_start start
  895.   alias falcao47_terminate terminate
  896.  
  897.   def start
  898.     falcao47_start
  899.     $game_arrows.create_arrows(210, 166) if Map_Buttons::DisplaySelector
  900.   end
  901.  
  902.   def terminate
  903.     falcao47_terminate
  904.     $game_arrows.dispose if Map_Buttons::DisplaySelector
  905.   end
  906. end
  907.  
  908. # WASD Movements
  909. module Input
  910.   class << self
  911.     if !method_defined?('vxe_dir4')
  912.       alias vxace_dir4 dir4
  913.     end
  914.     def dir4
  915.       if Map_Buttons::WASD_Movement
  916.         return 2 if (Input.press?(Input::Y))
  917.         return 4 if (Input.press?(Input::X))
  918.         return 6 if (Input.press?(Input::Z))
  919.         return 8 if (Input.press?(Input::R))
  920.       end
  921.       return vxace_dir4
  922.     end
  923.   end
  924. end
  925.  
  926. # If event start with mouse
  927. class Game_Player < Game_Character
  928.   alias falcao_start_map_event start_map_event
  929.   def start_map_event(x, y, triggers, normal)
  930.     $game_map.events_xy(x, y).each do |event_click|
  931.       return if event_click.check_comment("MOUSE START")
  932.     end  
  933.     falcao_start_map_event(x, y, triggers, normal)
  934.   end
  935. end
  936.  
  937. # clear pointers when tranfering
  938. class Game_Player < Game_Character
  939.   attr_accessor :clear_mousepointers
  940.   alias falcaomouse_perform_transfer perform_transfer
  941.   def perform_transfer
  942.     @clear_mousepointers = true if $game_map.map_id !=  @new_map_id
  943.     falcaomouse_perform_transfer
  944.   end
  945. end
  946.  
  947. # Path find
  948. class Game_Character < Game_CharacterBase
  949.   attr_accessor :map, :runpath
  950.   alias pathfind1_ini initialize
  951.   def initialize
  952.     pathfind1_ini
  953.     @map = nil
  954.     @runpath = false
  955.   end
  956.  
  957.   alias pathfind1_up update
  958.   def update
  959.     run_path if @runpath == true
  960.     pathfind1_up
  961.   end
  962.  
  963.   def run_path
  964.     return if moving?
  965.     step = @map[@x,@y]
  966.     if step == 1
  967.       @map = nil
  968.       @runpath = false
  969.       return
  970.     end
  971.     dir = rand(2)
  972.     case dir
  973.     when 0
  974.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  975.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  976.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  977.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  978.     when 1
  979.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  980.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  981.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  982.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  983.     end
  984.   end
  985.  
  986.   def find_path(x,y)
  987.     sx, sy = @x, @y
  988.     result = setup_map(sx,sy,x,y)
  989.     @runpath = result[0]
  990.     @map = result[1]
  991.     @map[sx,sy] = result[2] if result[2] != nil
  992.   end
  993.  
  994.   def clear_path
  995.     @map = nil
  996.     @runpath = false
  997.   end
  998.  
  999.   def setup_map(sx,sy,ex,ey)
  1000.     map = Table.new($game_map.width, $game_map.height)
  1001.     map[ex,ey] = 1
  1002.     old_positions = []
  1003.     new_positions = []
  1004.     old_positions.push([ex, ey])
  1005.     depth = 2
  1006.     depth.upto(100){|step|
  1007.       loop do
  1008.         break if old_positions[0] == nil
  1009.         x,y = old_positions.shift
  1010.         return [true, map, step] if x == sx and y+1 == sy
  1011.         if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
  1012.           map[x,y + 1] = step
  1013.           new_positions.push([x,y + 1])
  1014.         end
  1015.         return [true, map, step] if x-1 == sx and y == sy
  1016.         if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
  1017.           map[x - 1,y] = step
  1018.           new_positions.push([x - 1,y])
  1019.         end
  1020.         return [true, map, step] if x+1 == sx and y == sy
  1021.         if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
  1022.           map[x + 1,y] = step
  1023.           new_positions.push([x + 1,y])
  1024.         end
  1025.         return [true, map, step] if x == sx and y-1 == sy
  1026.         if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
  1027.           map[x,y - 1] = step
  1028.           new_positions.push([x,y - 1])
  1029.         end
  1030.       end
  1031.       old_positions = new_positions
  1032.       new_positions = []
  1033.     }
  1034.     return [false, nil, nil]
  1035.   end
  1036. end
  1037.  
  1038. class Game_Player
  1039.   alias pathfind_player_update update
  1040.   def update
  1041.     clear_path if Input.dir4 != 0
  1042.     pathfind_player_update
  1043.   end
  1044.  
  1045.   alias findpath_perform_transfer perform_transfer
  1046.   def perform_transfer
  1047.     clear_path if $game_map.map_id !=  @new_map_id
  1048.     findpath_perform_transfer
  1049.   end
  1050. end
  1051.  
  1052. # Window selectable (Thanks wora for some lines here)
  1053. class Window_Selectable < Window_Base
  1054.   alias mouse_selection_ini initialize
  1055.   def initialize(*args)
  1056.     mouse_selection_ini(*args)
  1057.     @scroll_wait = 0
  1058.     @cursor_wait = 0
  1059.     @sdelay = 0
  1060.   end
  1061.  
  1062.   alias mouse_selection_update update
  1063.   def update
  1064.     update_mouse_selection if self.active and self.visible
  1065.     @sdelay -= 1 if @sdelay > 0
  1066.     mouse_selection_update
  1067.   end
  1068.  
  1069.   def update_mouse_selection
  1070.     @cursor_wait -= 1 if @cursor_wait > 0
  1071.     (0..self.item_max - 1).each do |i|
  1072.       irect = item_rect(i)
  1073.       irx = self.x + 16 + irect.x - self.ox
  1074.       iry = self.y + 16 + irect.y - self.oy
  1075.       move_cursor(i) if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1076.       update_cursor
  1077.     end
  1078.   end
  1079.  
  1080.   def move_cursor(index)
  1081.     return if @index == index
  1082.     @scroll_wait -= 1 if @scroll_wait > 0
  1083.     row1 = @index / self.col_max
  1084.     row2 = index / self.col_max
  1085.     bottom = self.top_row + (self.page_row_max - 1)
  1086.     if index != @index and @sdelay == 0
  1087.       Sound.play_cursor
  1088.       @sdelay = 5
  1089.     end
  1090.     if row1 == self.top_row and row2 < self.top_row
  1091.       return if @scroll_wait > 0
  1092.       @index = [@index - self.col_max, 0].max
  1093.       @scroll_wait = 30
  1094.     elsif row1 == bottom and row2 > bottom
  1095.       return if @scroll_wait > 0
  1096.       @index = [@index + self.col_max, self.item_max - 1].min
  1097.       @scroll_wait = 30
  1098.     else
  1099.       @index = index
  1100.     end
  1101.     return if @cursor_wait > 0
  1102.     @cursor_wait += 2
  1103.   end
  1104. end
  1105.  
  1106. # Name imput selectable
  1107. class Window_NameInput
  1108.   alias mouse_name_select update unless $@
  1109.   def update(*args, &block)
  1110.     mouse_name_select(*args, &block)
  1111.     if self.active and self.visible
  1112.       (0..self.table[@page].size - 1).each do |i|
  1113.       irect = item_rect(i)
  1114.       irx = self.x + 16 + irect.x - self.ox
  1115.       iry = self.y + 16 + irect.y - self.oy
  1116.       @index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1117.       end
  1118.     end
  1119.   end
  1120. end
  1121.  
  1122. # Window party command
  1123. class Window_PartyCommand < Window_Command
  1124.   def update_mouse_selection
  1125.     (0..self.item_max - 1).each do |i|
  1126.     irect = item_rect(i)
  1127.     irx = self.viewport.ox + 16 + irect.x - self.ox
  1128.     iry = 288 + 16 + irect.y - self.oy
  1129.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1130.     end
  1131.   end
  1132. end
  1133.  
  1134. # Window actor command
  1135. class Window_ActorCommand < Window_Command
  1136.   def update_mouse_selection
  1137.     (0..self.item_max - 1).each do |i|
  1138.     irect = item_rect(i)
  1139.     add = 288
  1140.     add = 156 if !$imported[:ve_animated_battle].nil? &&  
  1141.     $imported[:ve_animated_battle] > 1
  1142.     irx = self.viewport.ox + add + 16 + irect.x
  1143.     iry = 288 + 16 + irect.y
  1144.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1145.     end
  1146.   end
  1147. end


我想去掉这个脚本的鼠标点击移动功能
保留WASD走路还有其他的功能

和XAS一起用 能做到wasd走路左键攻击 挺带感的

Lv5.捕梦者

梦石
0
星屑
22943
在线时间
8638 小时
注册时间
2011-12-31
帖子
3367
2
发表于 2013-3-26 18:23:12 | 只看该作者
本帖最后由 tseyik 于 2013-3-26 18:25 编辑

# Switch id to enable or disable the path finding feature
  PathFinderSwitch = 500

# 尋路開關ID:啟用或禁用尋路功能
  PathFinderSwitch = 500

RUBY 代码复制
  1. #===========================================================================#
  2. #  #*****************#                                                      #
  3. #  #*** By Falcao ***#         滑鼠系統按鈕 2.0                     #
  4. #  #*****************#         這是一個基於按鈕滑鼠腳本   #
  5. #                              允許創建地圖螢幕或地圖按鈕  #
  6. #                              在遊戲玩法內提供充分的全滑鼠互動  #
  7. #       RMVXACE                      #
  8. #                                                                           #
  9. #                                                                           #
  10. # Falcao RGSS site:  [url]http://falcaorgss.wordpress.com[/url]                        #
  11. # Falcao Forum site: [url]http://makerpalace.com[/url]                                 #
  12. #                                                                           #
  13. #===========================================================================#
  14.  
  15. # * Version 2.0 change log (Date: January 13 2013)
  16.  
  17. # - Added path finding, now the game player is able to move using the mouse
  18. # - Added compatibility with Victor Animated Battle version 1.x and above
  19. # - Now you are able to change the mouse cursor icon in game
  20. # - Two new notetags added to change the mouse cursor by event comment tags
  21. # - Fixed crash when pointing a notetagged event with a valid condition
  22. #----------------------------------------------------------------------------
  23. # * Version 1.6 change log (Date: November 21 2012)
  24. #
  25. # - Added compatibility for any game screen resolution
  26. # - System optimized to consume less cpu than before
  27. # - Added extra compatibility for Pearl ABS Liquid
  28. # - Removed the font fix
  29. # - Added the imported bolean
  30. #----------------------------------------------------------------------------
  31. # * Version 1.5 change log
  32. #
  33. # - Fixed cursor sound over loading on selectable windows
  34. # - Fixed bug when selecting event graphic tileset that have mouse comment tag
  35. # - FIxed minor bug when transfering (event name now erase completely)
  36. # - Added option to turn on / off arrow selector on save file
  37. # - Important! changes on mouse comment tags!
  38. #   ~ CLICK START change to MOUSE START
  39. #   ~ ANIMATION   change to MOUSE ANIMATION
  40. #   ~ NAME        change to MOUSE NAME
  41. #
  42. #---------------------------------------------------------------------------
  43. # * 安裝
  44. #
  45. # 複製和粘貼此腳本於main前面 !
  46. #
  47. # * 滑鼠按鍵
  48. #   -按下滑鼠左鍵:     動作按鈕
  49. #   -按下滑鼠右鍵:    取消按鈕,關閉視窗
  50. #   - 按下滑鼠滾輪/中間按鈕:   DASH
  51. #按下滑鼠左鍵
  52. #---------------------------------------------------------------------------
  53. # * 主要功能
  54. #
  55. # - 允許創建按鈕,並為它們指定工作
  56. # - Events can be buttons too, map ground buttons! for some puzzles etc.
  57. # -顯示事件的名稱
  58. # - 全滑鼠互動
  59. # - 可選WASD 移動
  60. # - 滑鼠自動尋路功能
  61. # - 可在遊戲中啟用改變鼠標光標
  62. #---------------------------------------------------------------------------
  63. # * 事件按鈕命令
  64. #
  65. # Write this lines on event comments tags
  66. #
  67. # MOUSE START       - 單擊事件時開始事件
  68. # MOUSE ANIMATION x - 鼠標在事件上時顯示動畫效果
  69. #                     例: MOUSE ANIMATION 1
  70. # MOUSE NAME x      - 鼠標在事件上時顯示事件名稱,
  71. #                     例: MOUSE NAME Falcao
  72. # MOUSE ICON x      - 鼠標在事件上時改變鼠標光標的圖標
  73. #                     x : 圖標索引
  74. # MOUSE PIC X       - Change the mouse cursor when is over an event but in this
  75. #                     case it display a picture graphic name, change x for the
  76. #                     picture name
  77. #------------------------------------------------------------------------------
  78. # * Script calls
  79. #
  80. # 調用此行來打開/關閉鼠標光標 true/false
  81. # Mouse.show_cursor(false)
  82. #
  83. # 如果您要手動更改滑鼠游標使用下面的腳本調用
  84. # Mouse.set_cursor(:iconset, x)     - X是圖標的索引
  85. #
  86. #  如果您想要顯示圖片 iconset 使用下面的腳本調用
  87. # Mouse.set_cursor(:picture, name)  -  name 更改成圖片名稱
  88. #-----------------------------------------------------------------------------
  89.  
  90. module Map_Buttons
  91.  
  92. # 很容易在地圖畫面上増加許多按鈕
  93. # 下方是按鈕定義的參數
  94.  
  95.   Insert = {
  96. #-----------------------------------------------------------------------------
  97. #  A => [B, C, D, E, F]
  98. #  
  99. #  A = 按鈕號碼
  100. #
  101. #  B = 命名
  102. #  C = X 在屏幕位置(以字符為單位)
  103. #  D = Y 在屏幕位置(以字符為單位)
  104. #  E = 圖標,寫入圖片圖片'名'或圖標索引
  105. #  F = 這按鈕做什麼?有兩個選項, 呼叫場景或呼叫公共事件,
  106. # 如果你想要場景則寫入場景名稱,
  107. # 公共事件 則寫入公共事件ID
  108.  
  109.   # 按鈕調用菜單畫面(場景用法例子)
  110.   1=> ["Menu", 16, 11, 117, Scene_Menu],  
  111.  
  112.   # 按鈕調用事件 ID 1(事件用法例子)
  113.   2=>  ["Bestiary",  16, 12, 121, 1],
  114.  
  115.  
  116.  
  117.   }
  118.  
  119. # * General configutration
  120.  
  121. # 鼠標光標的圖標,圖標索引如果想要圖片寫入圖片的名字
  122.   CursorIcon = 386
  123.  
  124. # 切換ID:在屏幕上顕示圖標 打開/關閉
  125.   Switch = 100
  126.  
  127. # 允許使用W A S D鍵移動 true/false
  128.   WASD_Movement = true
  129.  
  130. # 顯示箭頭選擇保存文件? true / false
  131.   DisplaySelector = false
  132.  
  133. # 當你點擊事件,讓玩家忽略該自我的的移動嗎?
  134.   IgnoreEventPath = true
  135.  
  136. # 尋路開關ID:啟用或禁用尋路功能
  137.   PathFinderSwitch = 500
  138. #
  139. #----------------------------------------------------------------------------
  140. #
  141. # * License
  142. #
  143. # 可以在非商業遊戲中使用此腳本,
  144. # 商業遊戲則要通知我(作者). [email][email protected][/email]
  145. #-----------------------------------------------------------------------------
  146.  
  147.   def self.check_value(value)
  148.     return 'numeric' if value.is_a? Fixnum
  149.     return 'string'
  150.   end
  151. end
  152.  
  153. ($imported ||= {})[:Mouse_System_Buttons] = 2.0
  154.  
  155. # 這個類創建的所有屏幕遊戲畫面上的按鈕和事
  156. class Interactive_Buttoms
  157.   attr_reader :cursoring
  158.   def initialize
  159.     create_screen_buttoms
  160.     @ani_delay = 0
  161.   end
  162.  
  163.   def create_screen_buttoms
  164.     if $imported["Falcao Pearl ABS Liquid"]
  165.       if PearlKernel::clean_back?
  166.         @buttons_sprites = []
  167.         return
  168.       end
  169.     end
  170.     @buttons_sprites = []
  171.     for i in Map_Buttons::Insert.values
  172.       @buttons_sprites.push(Sprite_Buttons.new(i[0], i[1], i[2], i[3], i[4]))
  173.     end
  174.   end
  175.  
  176.   def create_button_text
  177.     if @button_text.nil?
  178.       @button_text = Sprite.new
  179.       @button_text.bitmap = Bitmap.new(100, 32)
  180.       @button_text.z = 50
  181.       @button_text.bitmap.font.size = 16
  182.     end
  183.   end
  184.  
  185.   def dispose_screen_buttons
  186.     for button in @buttons_sprites
  187.       button.dispose
  188.     end
  189.     @buttons_sprites = []
  190.   end
  191.  
  192.   def dispose_button_text
  193.     if not @button_text.nil?
  194.       @button_text.dispose
  195.       @button_text.bitmap.dispose
  196.       @button_text = nil
  197.     end
  198.   end
  199.  
  200.   def dispose
  201.     dispose_screen_buttons
  202.     dispose_button_text
  203.   end
  204.  
  205.   def update
  206.     if $game_switches[Map_Buttons::Switch] and not @buttons_sprites.empty?
  207.       dispose_screen_buttons
  208.     elsif not $game_switches[Map_Buttons::Switch] and @buttons_sprites.empty?
  209.       create_screen_buttoms
  210.     end
  211.     update_buttons
  212.     update_event_selection
  213.   end
  214.  
  215.   # 路徑更新
  216.   def update_path
  217.     return if $game_switches[Map_Buttons::PathFinderSwitch]
  218.     return if $game_message.busy?
  219.     return unless $game_player.normal_walk?
  220.     mx, my = Mouse.map_grid[0], Mouse.map_grid[1]
  221.     if Map_Buttons::IgnoreEventPath
  222.       $game_map.events.values.each do |event|
  223.         return if event.x == mx and event.y == my
  224.       end
  225.     end
  226.     $game_player.find_path(mx, my)
  227.   end
  228.  
  229.   def update_buttons
  230.     for button in @buttons_sprites
  231.       button.update
  232.       if button.zooming
  233.         @screen_b = true
  234.         create_button_text
  235.         if button.x > 272
  236.           x, y = button.px * 32 - 98, button.py * 32
  237.           draw_button_text(x, y, button.name, 2)
  238.         elsif button.x < 272
  239.           x, y = button.px * 32 + 31, button.py * 32
  240.           draw_button_text(x, y, button.name, 0)
  241.         end
  242.       end
  243.     end
  244.  
  245.     if @screen_b != nil
  246.       unless mouse_over_button?
  247.         dispose_button_text
  248.         @screen_b = nil
  249.       end
  250.     end
  251.   end
  252.  
  253.   def reset_cursor
  254.     if Map_Buttons::check_value(@cursoring[1]) == 'numeric'
  255.       Mouse.set_cursor(:iconset, @cursoring[1], true)
  256.     else
  257.       Mouse.set_cursor(:picture, @cursoring[1], true)
  258.     end
  259.     @cursoring = nil
  260.   end
  261.  
  262.   def apply_iconchanging(sym, operand, event)
  263.     cursor = $game_system.cursorr
  264.     cursor = Map_Buttons::CursorIcon if cursor.nil?
  265.     @cursoring = [event, cursor]
  266.     Mouse.set_cursor(sym, operand, true)
  267.   end
  268.  
  269.   def update_event_selection
  270.     return if @screen_b #disable event buttom if mouse over screen buttom
  271.     update_path if Mouse.trigger?(0)
  272.     for event in $game_map.events.values
  273.       next if event.page.nil?
  274.       if event.x == Mouse.map_grid[0] and event.y == Mouse.map_grid[1]
  275.         if event.mouse_start
  276.           if Mouse.trigger?(0) and !$game_map.interpreter.running?
  277.             event.start
  278.           end
  279.         end
  280.         anime = event.mouse_animation
  281.         if anime != 0
  282.           @ani_delay += 1
  283.           event.animation_id = anime if @ani_delay == 1
  284.           @ani_delay = 0 if @ani_delay > 16
  285.         end
  286.         name = event.mouse_name
  287.         if name != ""
  288.           [url=home.php?mod=space&uid=94943]@Eve[/url] = [event.x, event.y, event, name]
  289.           create_button_text
  290.         end
  291.         icon = event.mouse_iconset
  292.         picture = event.mouse_picture
  293.         if !icon.nil? and icon != 0 and @cursoring.nil?
  294.           apply_iconchanging(:iconset, icon, event)
  295.         elsif !picture.nil? and picture != "" and @cursoring.nil?
  296.           apply_iconchanging(:picture, picture, event)
  297.         end
  298.       end
  299.     end
  300.  
  301.     if @cursoring != nil
  302.       reset_cursor if not mouse_over_event?(@cursoring[0].x, @cursoring[0].y)
  303.     end
  304.  
  305.     if @eve != nil
  306.       @eve[2].ch_oy.nil? ? event_oy = 32 : event_oy = @eve[2].ch_oy
  307.       if event_oy > 32
  308.         draw_button_text(@eve[2].screen_x - 49,
  309.         @eve[2].screen_y - event_oy / 2 - 50, @eve[3], 1)
  310.       else
  311.         draw_button_text(@eve[2].screen_x - 49,
  312.         @eve[2].screen_y - event_oy / 2 - 36, @eve[3], 1)
  313.       end
  314.       if not mouse_over_event?(@eve[0], @eve[1])
  315.         dispose_button_text
  316.         @eve = nil
  317.       end
  318.     end
  319.   end
  320.  
  321.   def draw_button_text(x, y, text, a=0)
  322.     return if @button_text.nil?
  323.     @button_text.x = x
  324.     @button_text.y = y
  325.     return if @old_name == text
  326.     @button_text.bitmap.clear
  327.     @button_text.bitmap.draw_text(2, 0, @button_text.bitmap.width, 32, text, a)
  328.     @old_name = text
  329.   end
  330.  
  331.   def mouse_over_button?
  332.     for button in @buttons_sprites
  333.       if Mouse.object_area?(button.x, button.y - 6, button.width, button.height)
  334.         return true
  335.       end
  336.     end
  337.     @old_name = nil
  338.     return false
  339.   end
  340.  
  341.   def mouse_over_event?(event_x, event_y)
  342.     if Mouse.map_grid[0] == event_x and Mouse.map_grid[1] == event_y
  343.       return true
  344.     end
  345.     @old_name = nil
  346.     return false
  347.   end
  348. end
  349.  
  350. # 設置按鍵 sprites
  351. class Spriteset_Map
  352.   alias falcao_insert_buttuns_view create_viewports
  353.   def create_viewports
  354.     @interact_buttoms = Interactive_Buttoms.new
  355.     falcao_insert_buttuns_view
  356.   end
  357.  
  358.   alias falcao_insert_buttuns_dis dispose
  359.   def dispose
  360.     @interact_buttoms.reset_cursor if @interact_buttoms.cursoring != nil
  361.     @interact_buttoms.dispose
  362.     falcao_insert_buttuns_dis
  363.   end
  364.  
  365.   alias falcao_insert_buttuns_up update
  366.   def update
  367.     if $game_player.clear_mousepointers
  368.       @interact_buttoms.dispose
  369.       $game_player.clear_mousepointers = nil
  370.     end
  371.     @interact_buttoms.update
  372.     falcao_insert_buttuns_up
  373.   end
  374. end
  375.  
  376. # 註釋定義
  377. class Game_Event < Game_Character
  378.   attr_reader   :mouse_start, :mouse_animation, :mouse_name, :mouse_iconset
  379.   attr_reader   :mouse_picture, :page
  380.   alias falcaomouse_setup setup_page_settings
  381.   def setup_page_settings
  382.     falcaomouse_setup
  383.     @mouse_start     = check_comment("MOUSE START")
  384.     @mouse_animation = check_value("MOUSE ANIMATION")
  385.     @mouse_name      = check_name("MOUSE NAME")
  386.     @mouse_iconset   = check_value("MOUSE ICON")
  387.     @mouse_picture   = check_name("MOUSE PIC")
  388.   end
  389.  
  390.   def check_comment(comment)
  391.     return false if @list.nil? or @list.size <= 0
  392.     for item in @list
  393.       if item.code == 108 or item.code == 408
  394.         if item.parameters[0].include?(comment)
  395.           return true
  396.         end
  397.       end
  398.     end
  399.     return false
  400.   end
  401.  
  402.   def check_value(comment)
  403.     return 0 if @list.nil? or @list.size <= 0
  404.     for item in @list
  405.       if item.code == 108 or item.code == 408
  406.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  407.           return $1.to_i
  408.         end
  409.       end
  410.     end
  411.     return 0
  412.   end
  413.  
  414.   def check_name(comment)
  415.     return "" if @list.nil? or @list.size <= 0
  416.     for item in @list
  417.       next unless item.code == 108 or item.code == 408
  418.       if item.parameters[0] =~ /#{comment} (.*)/
  419.         return $1.to_s
  420.       end
  421.     end
  422.     return ""
  423.   end
  424. end
  425.  
  426. # 創建屏幕上的按鈕 sprites
  427. class Sprite_Buttons < Sprite
  428.   attr_reader   :px
  429.   attr_reader   :py
  430.   attr_reader   :name
  431.   attr_reader   :zooming
  432.   def initialize(name, px, py, icon_index, action=nil)
  433.     super()
  434.     self.z = 50
  435.     @icon_index = icon_index
  436.     @px = px
  437.     @py = py
  438.     @action = action
  439.     @object_zooming = 0
  440.     @zooming = false
  441.     @name = name
  442.     set_bitmap
  443.     update
  444.   end
  445.  
  446.   def update
  447.     super
  448.     if Mouse.object_area?(self.x, self.y - 4, self.bitmap.width,
  449.       self.bitmap.height)
  450.       @zooming = true
  451.       @object_zooming += 1
  452.       case @object_zooming
  453.       when 1..10  ; self.zoom_x -= 0.02 ;  self.zoom_y -= 0.02
  454.       when 11..20 ; self.zoom_x += 0.02 ;  self.zoom_y += 0.02
  455.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  456.         @object_zooming = 0
  457.       end
  458.       if Mouse.trigger?(0) and @action != nil
  459.         unless $game_map.interpreter.running?
  460.           Sound.play_ok
  461.           if @action == Scene_Menu and not $game_system.menu_disabled
  462.             SceneManager.call(@action)
  463.             Window_MenuCommand::init_command_position
  464.             return
  465.           end
  466.          if Map_Buttons::check_value(@action) == 'numeric'
  467.            $game_temp.reserve_common_event(@action)
  468.          else
  469.            SceneManager.call(@action)
  470.          end
  471.         end
  472.       end
  473.     elsif @object_zooming > 0
  474.       self.zoom_x = 1.0
  475.       self.zoom_y = 1.0
  476.       @object_zooming = 0
  477.     else
  478.       @zooming = false
  479.     end
  480.   end
  481.  
  482.   def set_bitmap
  483.     if Map_Buttons::check_value(@icon_index) == 'numeric'
  484.       self.bitmap = Bitmap.new(24, 24)
  485.       bitmap = Cache.system("Iconset")
  486.       rect = Rect.new(@icon_index % 16 * 24, @icon_index / 16 * 24, 24, 24)
  487.       self.bitmap.blt(0, 0, bitmap, rect)
  488.     else
  489.       self.bitmap = Cache.picture(@icon_index)
  490.     end
  491.     self.x = @px * 32 + 4
  492.     self.y = @py * 32 + 4
  493.   end
  494. end
  495.  
  496. # Game_character 新的變量
  497. class Game_CharacterBase
  498.   attr_accessor :ch_oy
  499. end
  500.  
  501. # Sprite character
  502. class Sprite_Character < Sprite_Base
  503.   alias falcaoadd_oxy_set_character_bitmap set_character_bitmap
  504.   def set_character_bitmap
  505.     falcaoadd_oxy_set_character_bitmap
  506.     @character.ch_oy = self.oy
  507.   end
  508. end
  509.  
  510. class Game_System
  511.   attr_accessor :current_cursor
  512.   def cursorr
  513.     return Map_Buttons::CursorIcon if @current_cursor.nil?
  514.     return @current_cursor
  515.   end
  516. end
  517.  
  518. # 鼠標模組
  519. module Mouse
  520.  
  521.   GetKeyState    = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')
  522.   GetCursorPos   = Win32API.new('user32',    'GetCursorPos',     'p',     'i')
  523.   GetClientRect  = Win32API.new('user32',    'GetClientRect',    %w(l p), 'i')
  524.   ShowCursor     = Win32API.new('user32',    'ShowCursor',       'i',     'l')
  525.   ScreenToClient = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')
  526.   Findwindow     = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
  527.   GetPrivatePro  = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  528.   %w(p p p p l p), 'l')
  529.  
  530.   ShowCursor.call(0)
  531.  
  532.   @triggers     =   [[0, 1], [0, 2], [0, 4]]
  533.   @old_pos      =   0
  534.  
  535.   # 鼠標 Sprite
  536.  
  537.   def self.set_cursor(sym, operand, write=false)
  538.     case sym
  539.     when :iconset
  540.       $mouse_cursor.bitmap = Bitmap.new(24, 24)
  541.       bitmap = Cache.system("Iconset")
  542.       rect = Rect.new(operand % 16 * 24, operand / 16 * 24, 24, 24)
  543.       $mouse_cursor.bitmap.blt(0, 0, bitmap, rect)
  544.     when :picture then $mouse_cursor.bitmap = Cache.picture(operand)
  545.     end
  546.     $game_system.current_cursor = operand if write
  547.   end
  548.  
  549.   $mouse_cursor = Sprite.new
  550.   icon = Map_Buttons::CursorIcon
  551.   if Map_Buttons::check_value(icon) == 'numeric'
  552.     set_cursor(:iconset, icon)
  553.   else
  554.     set_cursor(:picture, icon)
  555.   end
  556.   $mouse_cursor.z = 10001
  557.   $mouse_cursor.x = $mouse_cursor.y = 1000
  558.   $mouse_cursor.ox = 4
  559.  
  560.   def self.show_cursor(value)
  561.     unless value
  562.       @pos[0] = @pos[1] = 600
  563.     end
  564.     $mouse_cursor.visible = value
  565.   end
  566.  
  567.   def self.map_grid
  568.     return nil if @pos == nil
  569.     x = ($game_map.display_x).to_i + (@pos[0] / 32)
  570.     y = ($game_map.display_y).to_i + (@pos[1] / 32)
  571.     return [x, y]
  572.   end
  573.  
  574.   def self.standing?
  575.     return false if @old_px != @pos[0]
  576.     return false if @old_py != @pos[1]
  577.     return true
  578.   end
  579.  
  580.   def self.input_keys
  581.     $game_arrows.mode_on ? type = $game_arrows.in_type : type = Input::C
  582.     keys = {0 => type, 1 => Input::B, 2 => Input::A}
  583.     return keys
  584.   end
  585.  
  586.   def self.object_area?(x, y, width, height)
  587.     return false if @pos.nil?
  588.     return @pos[0].between?(x, width + x) && @pos[1].between?(y, height + y)
  589.   end
  590.  
  591.   def self.position
  592.     return @pos == nil ? [0, 0] : @pos
  593.   end
  594.  
  595.   def self.global_pos
  596.     pos = [0, 0].pack('ll')
  597.     return GetCursorPos.call(pos) == 0 ? nil : pos.unpack('ll')
  598.   end
  599.  
  600.   def self.screen_to_client(x=0, y=0)
  601.     pos = [x, y].pack('ll')
  602.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  603.   end  
  604.  
  605.   def self.pos
  606.     global_pos = [0, 0].pack('ll')   
  607.     gx, gy = GetCursorPos.call(global_pos) == 0 ? nil : global_pos.unpack('ll')
  608.     local_pos = [gx, gy].pack('ll')
  609.     x, y = ScreenToClient.call(self.hwnd,
  610.     local_pos) == 0 ? nil : local_pos.unpack('ll')
  611.     begin
  612.       if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
  613.         @old_px, @old_py = x, y
  614.         return x, y
  615.       else
  616.         return -20, -20
  617.       end
  618.     rescue
  619.       return 0, 0
  620.     end
  621.   end  
  622.  
  623.   def self.update
  624.     old_pos = @pos
  625.     @pos = self.pos
  626.     self.input_keys
  627.     if !$mouse_cursor.visible && old_pos != @pos
  628.       $mouse_cursor.visible = true
  629.     end
  630.     if old_pos != [-20, -20] && @pos == [-20, -20]
  631.       ShowCursor.call(1)
  632.     elsif old_pos == [-20, -20] && @pos != [-20, -20]
  633.        ShowCursor.call(0)
  634.     end
  635.     for i in @triggers
  636.       n = GetKeyState.call(i[1])
  637.       if [0, 1].include?(n)
  638.         i[0] = (i[0] > 0 ? i[0] * -1 : 0)
  639.       else
  640.         i[0] = (i[0] > 0 ? i[0] + 1 : 1)
  641.       end
  642.     end
  643.   end
  644.  
  645.   # trigger 定義
  646.   def self.trigger?(id = 0)
  647.     pos = self.pos
  648.     if pos != [-20,-20]
  649.     case id
  650.       when 0  
  651.         return @triggers[id][0] == 1
  652.       when 1  
  653.         if @triggers[1][0] == 1 && !$game_system.menu_disabled
  654.           return @triggers[id][0] == 1
  655.         end
  656.       when 2
  657.         return @triggers[id][0] == 1
  658.       end   
  659.     end
  660.   end
  661.  
  662.   # repeat 定義
  663.   def self.repeat?(id = 0)
  664.     if @triggers[id][0] <= 0
  665.       return false
  666.     else
  667.       return @triggers[id][0] % 5 == 1 && @triggers[id][0] % 5 != 2
  668.     end
  669.   end
  670.  
  671.   #按下定義
  672.   def self.press?(id = 0)
  673.     if @triggers[id][0] <= 0
  674.       return false
  675.     else
  676.       return true
  677.     end
  678.   end
  679.  
  680.   def self.screen_to_client(x=0, y=0)
  681.     pos = [x, y].pack('ll')
  682.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  683.   end
  684.  
  685.   def self.hwnd
  686.     if @hwnd.nil?
  687.       game_name = "\0" * 256
  688.       GetPrivatePro.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  689.       game_name.delete!("\0")
  690.       @hwnd = Findwindow.call('RGSS Player', game_name)
  691.     end
  692.     return @hwnd
  693.   end
  694.  
  695.   def self.client_size
  696.     rect = [0, 0, 0, 0].pack('l4')
  697.     GetClientRect.call(self.hwnd, rect)
  698.     right, bottom = rect.unpack('l4')[2..3]
  699.     return right, bottom
  700.   end
  701. end
  702.  
  703. # 輸入模塊混疊
  704. class << Input
  705.   unless self.method_defined?(:falcao21_mouse_update)
  706.     alias_method :falcao21_mouse_update,   :update
  707.     alias_method :falcao21_mouse_trigger?, :trigger?
  708.     alias_method :falcao21_mouse_repeat?,  :repeat?
  709.     alias_method :fal_mouse_input_press?,  :press?
  710.   end
  711.  
  712.   def update
  713.     if $mouse_cursor.visible
  714.       Mouse.update
  715.       $game_arrows.update
  716.       mx, my = *Mouse.position
  717.       $mouse_cursor.x = mx unless mx.nil?
  718.       $mouse_cursor.y = my unless my.nil?   
  719.     end
  720.     falcao21_mouse_update
  721.   end
  722.  
  723.   # trigger
  724.   def trigger?(constant)
  725.     return true if falcao21_mouse_trigger?(constant)
  726.     unless Mouse.pos.nil?
  727.       if Mouse.input_keys.has_value?(constant)
  728.         mouse_trigger = Mouse.input_keys.index(constant)
  729.         return true if Mouse.trigger?(mouse_trigger)
  730.       end
  731.     end
  732.     return false
  733.   end
  734.  
  735.   # 按下
  736.   def press?(constant)
  737.     return true if fal_mouse_input_press?(constant)
  738.     unless Mouse.pos.nil?
  739.       if Mouse.input_keys.has_value?(constant)
  740.         mouse_trigger = Mouse.input_keys.index(constant)
  741.         return true if Mouse.press?(mouse_trigger)      
  742.       end
  743.     end
  744.     return false
  745.   end
  746.  
  747.   # repeat
  748.   def repeat?(constant)
  749.     return true if falcao21_mouse_repeat?(constant)
  750.     unless Mouse.pos.nil?
  751.       if Mouse.input_keys.has_value?(constant)
  752.         mouse_trigger = Mouse.input_keys.index(constant)     
  753.         return true if Mouse.repeat?(mouse_trigger)
  754.       end
  755.     end
  756.     return false
  757.   end
  758. end
  759.  
  760. # Here your best friend, 你可以在遊戲中,場景等調用這個腳本.
  761. # $game_arrows.create_arrows(x, y), create it, $game_arrows.dispose, delete it
  762. class Game_Arrow_Selector
  763.   attr_accessor :mode_on
  764.   attr_accessor :in_type
  765.   def initialize
  766.     @mode_on = false
  767.   end
  768.  
  769.   def create_arrows(x, y)
  770.     return unless @arrows_sprites.nil?
  771.     buttons = {1=> 'UP', 2=> 'RIGHT', 3=> 'DOWN',
  772.     4=> 'LEFT', 5=> 'OK', 6=> 'Cancel'}
  773.     @arrows_sprites = []
  774.     for i in buttons.values
  775.       @arrows_sprites.push(Garrows_Sprites.new(i, x, y))
  776.     end
  777.   end
  778.  
  779.   def dispose
  780.     return if @arrows_sprites.nil?
  781.     for arrow in @arrows_sprites
  782.       arrow.dispose
  783.     end
  784.     @arrows_sprites = nil
  785.     @mode_on = false
  786.   end
  787.  
  788.   def update
  789.     return if @arrows_sprites.nil?
  790.     for arrow in @arrows_sprites
  791.       arrow.update
  792.     end
  793.   end
  794. end
  795.  
  796. class Garrows_Sprites < Sprite
  797.   def initialize(name, x, y)
  798.     super()
  799.     self.z = 1000
  800.     @px, @py = x, y
  801.     @name = name
  802.     @object_zooming = 0
  803.     @zooming = false
  804.     set_bitmap
  805.     update
  806.   end
  807.  
  808.   def update
  809.     super
  810.     if Mouse.object_area?(self.x + @fix[0], self.y + @fix[1],
  811.       self.bitmap.width + @fix[2], self.bitmap.height + @fix[3])
  812.       $game_arrows.mode_on = true
  813.       $game_arrows.in_type = Input::UP    if @name == 'UP'
  814.       $game_arrows.in_type = Input::DOWN  if @name == 'DOWN'
  815.       $game_arrows.in_type = Input::LEFT  if @name == 'LEFT'
  816.       $game_arrows.in_type = Input::RIGHT if @name == 'RIGHT'
  817.       $game_arrows.in_type = Input::C     if @name == 'OK'
  818.       $game_arrows.in_type = Input::B     if @name == 'Cancel'
  819.       @object_zooming += 1
  820.       @zooming = true
  821.       case @object_zooming
  822.       when 1..10  ; self.zoom_x -= 0.01 ;  self.zoom_y -= 0.01
  823.       when 11..20 ; self.zoom_x += 0.01 ;  self.zoom_y += 0.01
  824.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  825.         @object_zooming = 0
  826.       end
  827.     elsif @object_zooming > 0
  828.       self.zoom_x = 1.0
  829.       self.zoom_y = 1.0
  830.       @object_zooming = 0
  831.     elsif @zooming
  832.       @zooming = false
  833.       $game_arrows.mode_on = false
  834.     end
  835.   end
  836.  
  837.   def set_bitmap
  838.     self.bitmap = Bitmap.new(24, 15) if @name != 'Cancel'
  839.     case @name
  840.     when 'UP'
  841.       self.x = @px + 25 ; self.y = @py - 2
  842.       self.angle = 182  ; @fix = [-23, -18, 0,  0]
  843.     when 'DOWN'
  844.       self.x = @px + 1 ; self.y = @py + 26
  845.       @fix = [0, -4, 0,  0]
  846.     when 'LEFT'
  847.       self.x = @px      ; self.y = @py + 1
  848.       self.angle = - 92 ; @fix = [-14, -4, - 9,  9]
  849.     when 'RIGHT'
  850.       self.x = @px + 26  ; self.y = @py + 26
  851.       self.angle = + 92  ; @fix = [0, - 26, - 9,  9]
  852.     when 'OK'
  853.       self.x = @px + 1  ; self.y = @py + 6
  854.       @fix = [0, -4, 0,  0]
  855.       self.bitmap.font.size = 20
  856.       self.bitmap.draw_text(4, -7, self.bitmap.width, 32, @name)
  857.       return
  858.     when 'Cancel'
  859.       self.x = @px - 11  ; self.y = @py + 42
  860.       @fix = [0, -4, 0,  0]
  861.       self.bitmap = Bitmap.new(50, 15)
  862.       self.bitmap.font.size = 20
  863.       self.bitmap.draw_text(2, -7, self.bitmap.width, 32, @name)
  864.       return
  865.     end
  866.     draw_crappy_triangle(0, 0)
  867.   end
  868.  
  869.   # This method create a crappy triangle pointing down
  870.   def draw_crappy_triangle(px, py)
  871.     color = Color.new(192, 224, 255, 255)
  872.     x, y, w, =  0, 4, 24
  873.     self.bitmap.fill_rect(px + 1, py, 22, 1, color)
  874.     self.bitmap.fill_rect(px,     py + 1, 24, 4, color)
  875.     for i in 1..10
  876.       x += 1; y += 1; w -= 2
  877.       self.bitmap.fill_rect(px + x, py + y,       w, 1, color)
  878.     end
  879.   end
  880. end
  881.  
  882. $game_arrows = Game_Arrow_Selector.new
  883.  
  884. # 當輸入的數字
  885. class Game_Interpreter
  886.   alias falcao_setup_num_input setup_num_input
  887.   def setup_num_input(params)
  888.     falcao_setup_num_input(params)
  889.     $game_arrows.create_arrows(256, 194) if $game_message.position == 0
  890.     $game_arrows.create_arrows(256, 340) if $game_message.position == 1
  891.     $game_arrows.create_arrows(256, 180) if $game_message.position == 2
  892.   end
  893. end
  894.  
  895. # 按OK
  896. class Window_NumberInput < Window_Base
  897.   alias falcao_process_ok process_ok
  898.   def process_ok
  899.     falcao_process_ok
  900.     $game_arrows.dispose
  901.   end
  902. end
  903.  
  904. # 保存和加載場景
  905. class Scene_File < Scene_MenuBase
  906.   alias falcao47_start start
  907.   alias falcao47_terminate terminate
  908.  
  909.   def start
  910.     falcao47_start
  911.     $game_arrows.create_arrows(210, 166) if Map_Buttons::DisplaySelector
  912.   end
  913.  
  914.   def terminate
  915.     falcao47_terminate
  916.     $game_arrows.dispose if Map_Buttons::DisplaySelector
  917.   end
  918. end
  919.  
  920. # WASD 移動
  921. module Input
  922.   class << self
  923.     if !method_defined?('vxe_dir4')
  924.       alias vxace_dir4 dir4
  925.     end
  926.     def dir4
  927.       if Map_Buttons::WASD_Movement
  928.         return 2 if (Input.press?(Input::Y))
  929.         return 4 if (Input.press?(Input::X))
  930.         return 6 if (Input.press?(Input::Z))
  931.         return 8 if (Input.press?(Input::R))
  932.       end
  933.       return vxace_dir4
  934.     end
  935.   end
  936. end
  937.  
  938. # 用鼠標開始事件
  939. class Game_Player < Game_Character
  940.   alias falcao_start_map_event start_map_event
  941.   def start_map_event(x, y, triggers, normal)
  942.     $game_map.events_xy(x, y).each do |event_click|
  943.       return if event_click.check_comment("MOUSE START")
  944.     end  
  945.     falcao_start_map_event(x, y, triggers, normal)
  946.   end
  947. end
  948.  
  949. # clear pointers when tranfering
  950. class Game_Player < Game_Character
  951.   attr_accessor :clear_mousepointers
  952.   alias falcaomouse_perform_transfer perform_transfer
  953.   def perform_transfer
  954.     @clear_mousepointers = true if $game_map.map_id !=  @new_map_id
  955.     falcaomouse_perform_transfer
  956.   end
  957. end
  958.  
  959. # Path find
  960. class Game_Character < Game_CharacterBase
  961.   attr_accessor :map, :runpath
  962.   alias pathfind1_ini initialize
  963.   def initialize
  964.     pathfind1_ini
  965.     @map = nil
  966.     @runpath = false
  967.   end
  968.  
  969.   alias pathfind1_up update
  970.   def update
  971.     run_path if @runpath == true
  972.     pathfind1_up
  973.   end
  974.  
  975.   def run_path
  976.     return if moving?
  977.     step = @map[@x,@y]
  978.     if step == 1
  979.       @map = nil
  980.       @runpath = false
  981.       return
  982.     end
  983.     dir = rand(2)
  984.     case dir
  985.     when 0
  986.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  987.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  988.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  989.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  990.     when 1
  991.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  992.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  993.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  994.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  995.     end
  996.   end
  997.  
  998.   def find_path(x,y)
  999.     sx, sy = @x, @y
  1000.     result = setup_map(sx,sy,x,y)
  1001.     @runpath = result[0]
  1002.     @map = result[1]
  1003.     @map[sx,sy] = result[2] if result[2] != nil
  1004.   end
  1005.  
  1006.   def clear_path
  1007.     @map = nil
  1008.     @runpath = false
  1009.   end
  1010.  
  1011.   def setup_map(sx,sy,ex,ey)
  1012.     map = Table.new($game_map.width, $game_map.height)
  1013.     map[ex,ey] = 1
  1014.     old_positions = []
  1015.     new_positions = []
  1016.     old_positions.push([ex, ey])
  1017.     depth = 2
  1018.     depth.upto(100){|step|
  1019.       loop do
  1020.         break if old_positions[0] == nil
  1021.         x,y = old_positions.shift
  1022.         return [true, map, step] if x == sx and y+1 == sy
  1023.         if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
  1024.           map[x,y + 1] = step
  1025.           new_positions.push([x,y + 1])
  1026.         end
  1027.         return [true, map, step] if x-1 == sx and y == sy
  1028.         if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
  1029.           map[x - 1,y] = step
  1030.           new_positions.push([x - 1,y])
  1031.         end
  1032.         return [true, map, step] if x+1 == sx and y == sy
  1033.         if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
  1034.           map[x + 1,y] = step
  1035.           new_positions.push([x + 1,y])
  1036.         end
  1037.         return [true, map, step] if x == sx and y-1 == sy
  1038.         if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
  1039.           map[x,y - 1] = step
  1040.           new_positions.push([x,y - 1])
  1041.         end
  1042.       end
  1043.       old_positions = new_positions
  1044.       new_positions = []
  1045.     }
  1046.     return [false, nil, nil]
  1047.   end
  1048. end
  1049.  
  1050. class Game_Player
  1051.   alias pathfind_player_update update
  1052.   def update
  1053.     clear_path if Input.dir4 != 0
  1054.     pathfind_player_update
  1055.   end
  1056.  
  1057.   alias findpath_perform_transfer perform_transfer
  1058.   def perform_transfer
  1059.     clear_path if $game_map.map_id !=  @new_map_id
  1060.     findpath_perform_transfer
  1061.   end
  1062. end
  1063.  
  1064. # Window selectable (Thanks wora for some lines here)
  1065. class Window_Selectable < Window_Base
  1066.   alias mouse_selection_ini initialize
  1067.   def initialize(*args)
  1068.     mouse_selection_ini(*args)
  1069.     @scroll_wait = 0
  1070.     @cursor_wait = 0
  1071.     @sdelay = 0
  1072.   end
  1073.  
  1074.   alias mouse_selection_update update
  1075.   def update
  1076.     update_mouse_selection if self.active and self.visible
  1077.     @sdelay -= 1 if @sdelay > 0
  1078.     mouse_selection_update
  1079.   end
  1080.  
  1081.   def update_mouse_selection
  1082.     @cursor_wait -= 1 if @cursor_wait > 0
  1083.     (0..self.item_max - 1).each do |i|
  1084.       irect = item_rect(i)
  1085.       irx = self.x + 16 + irect.x - self.ox
  1086.       iry = self.y + 16 + irect.y - self.oy
  1087.       move_cursor(i) if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1088.       update_cursor
  1089.     end
  1090.   end
  1091.  
  1092.   def move_cursor(index)
  1093.     return if @index == index
  1094.     @scroll_wait -= 1 if @scroll_wait > 0
  1095.     row1 = @index / self.col_max
  1096.     row2 = index / self.col_max
  1097.     bottom = self.top_row + (self.page_row_max - 1)
  1098.     if index != @index and @sdelay == 0
  1099.       Sound.play_cursor
  1100.       @sdelay = 5
  1101.     end
  1102.     if row1 == self.top_row and row2 < self.top_row
  1103.       return if @scroll_wait > 0
  1104.       @index = [@index - self.col_max, 0].max
  1105.       @scroll_wait = 30
  1106.     elsif row1 == bottom and row2 > bottom
  1107.       return if @scroll_wait > 0
  1108.       @index = [@index + self.col_max, self.item_max - 1].min
  1109.       @scroll_wait = 30
  1110.     else
  1111.       @index = index
  1112.     end
  1113.     return if @cursor_wait > 0
  1114.     @cursor_wait += 2
  1115.   end
  1116. end
  1117.  
  1118. # Name imput selectable
  1119. class Window_NameInput
  1120.   alias mouse_name_select update unless $@
  1121.   def update(*args, &block)
  1122.     mouse_name_select(*args, &block)
  1123.     if self.active and self.visible
  1124.       (0..self.table[@page].size - 1).each do |i|
  1125.       irect = item_rect(i)
  1126.       irx = self.x + 16 + irect.x - self.ox
  1127.       iry = self.y + 16 + irect.y - self.oy
  1128.       @index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1129.       end
  1130.     end
  1131.   end
  1132. end
  1133.  
  1134. # Window party command
  1135. class Window_PartyCommand < Window_Command
  1136.   def update_mouse_selection
  1137.     (0..self.item_max - 1).each do |i|
  1138.     irect = item_rect(i)
  1139.     irx = self.viewport.ox + 16 + irect.x - self.ox
  1140.     iry = 288 + 16 + irect.y - self.oy
  1141.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1142.     end
  1143.   end
  1144. end
  1145.  
  1146. # Window actor command
  1147. class Window_ActorCommand < Window_Command
  1148.   def update_mouse_selection
  1149.     (0..self.item_max - 1).each do |i|
  1150.     irect = item_rect(i)
  1151.     add = 288
  1152.     add = 156 if !$imported[:ve_animated_battle].nil? &&  
  1153.     $imported[:ve_animated_battle] > 1
  1154.     irx = self.viewport.ox + add + 16 + irect.x
  1155.     iry = 288 + 16 + irect.y
  1156.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1157.     end
  1158.   end
  1159. end

点评

这是ace...?  发表于 2013-3-26 18:47
好评  发表于 2013-3-26 18:38
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
56
在线时间
342 小时
注册时间
2011-10-29
帖子
368
3
发表于 2013-3-26 18:46:37 | 只看该作者
求用法和来源网站!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-14 16:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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