查看: 1576|回复: 2

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

[复制链接]
梦石
0
星屑
50
在线时间
65 小时
注册时间
2008-5-15
回帖
29
发表于 2013-3-26 17:54:28 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 牲口 于 2013-3-26 18:45 编辑
  1. #===========================================================================#

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

  3. # - Added path finding, now the game player is able to move using the mouse
  4. # - Added compatibility with Victor Animated Battle version 1.x and above
  5. # - Now you are able to change the mouse cursor icon in game
  6. # - Two new notetags added to change the mouse cursor by event comment tags
  7. # - Fixed crash when pointing a notetagged event with a valid condition
  8. #----------------------------------------------------------------------------
  9. # * Version 1.6 change log (Date: November 21 2012)
  10. #
  11. # - Added compatibility for any game screen resolution
  12. # - System optimized to consume less cpu than before
  13. # - Added extra compatibility for Pearl ABS Liquid
  14. # - Removed the font fix
  15. # - Added the imported bolean
  16. #----------------------------------------------------------------------------
  17. # * Version 1.5 change log
  18. #
  19. # - Fixed cursor sound over loading on selectable windows
  20. # - Fixed bug when selecting event graphic tileset that have mouse comment tag
  21. # - FIxed minor bug when transfering (event name now erase completely)
  22. # - Added option to turn on / off arrow selector on save file
  23. # - Important! changes on mouse comment tags!
  24. #   ~ CLICK START change to MOUSE START
  25. #   ~ ANIMATION   change to MOUSE ANIMATION
  26. #   ~ NAME        change to MOUSE NAME
  27. #
  28. #---------------------------------------------------------------------------
  29. # * installation
  30. #
  31. # Copy and paste this script above main done!
  32. #
  33. # * Mouse triggers
  34. #   - Left click:     Action button
  35. #   - Right click:    Cancel button, close windows
  36. #   - Mouse wheel middle button:   DASH
  37. #
  38. #---------------------------------------------------------------------------
  39. # * Main features
  40. #
  41. # - Allow you create buttons and configure them to do something
  42. # - Events can be buttons too, map ground buttons! for some puzzles etc.
  43. # - Allow you display event name
  44. # - Full mouse interaction
  45. # - WASD movement optional
  46. # - Path finding feature, player is able to move using the mouse
  47. # - Mouse cursor changing in-game enabled
  48. #---------------------------------------------------------------------------
  49. # * Event buttons commands
  50. #
  51. # Write this lines on event comments tags
  52. #
  53. # MOUSE START       - Event start when you click the event
  54. # MOUSE ANIMATION x - Show animation when mouse is over event,
  55. #                     ex: MOUSE ANIMATION 1
  56. # MOUSE NAME x      - Display event name when mouse is over event,
  57. #                     ex: MOUSE NAME Falcao
  58. # MOUSE ICON x      - change the mouse cursor icon when it is over the event
  59. #                     change x for the icon index to display
  60. # MOUSE PIC X       - Change the mouse cursor when is over an event but in this
  61. #                     case it display a picture graphic name, change x for the
  62. #                     picture name
  63. #------------------------------------------------------------------------------
  64. # * Script calls
  65. #
  66. # Call this line to turn off/on the mouse cursor within the game true/false
  67. # Mouse.show_cursor(false)
  68. #
  69. # If you want to change the mouse cursor manually use the following script calls
  70. # Mouse.set_cursor(:iconset, x)     - change x for any icon index
  71. #
  72. # if you want to show a picture instead iconset use the next script call
  73. # Mouse.set_cursor(:picture, name)  - change name for picture name
  74. #-----------------------------------------------------------------------------

  75. module Map_Buttons

  76. # You can easily insert as many buttons you want to the map screen
  77. # define here below your buttons parameters
  78.   
  79.   Insert = {
  80. #-----------------------------------------------------------------------------
  81. #  A => [B, C, D, E, F]
  82. #  
  83. #  A = Button number
  84. #
  85. #  B = Name
  86. #  C = X position in screen tile
  87. #  D = Y position in screen tile
  88. #  E = Icon, if you want a picture write picture 'name' otherwise icon index
  89. #  F = What this button gonna do?, you have two options, call scene or call
  90. #  common event, if you want scene put scene name, if you want common event
  91. #  put common event ID
  92.   
  93.   # This button call the menu screen
  94.   1=> ["Menu", 16, 11, 117, Scene_Menu],  
  95.   
  96.   # This button call a common event ID 1
  97.   2=>  ["Bestiary",  16, 12, 121, 1],
  98.   
  99.   

  100.   }

  101. # * General configutration

  102. # Mouse cursor icon, if you want a picture write pic 'name' otherwise icon index
  103.   CursorIcon = 386

  104. # Switch ID to turn off/on the icons on the screen
  105.   Switch = 100
  106.   
  107. # Allow movement with  W A S D keys true/false
  108.   WASD_Movement = true
  109.   
  110. # Display arrow selector on save file? true / false
  111.   DisplaySelector = false
  112.   
  113. # When you click on event, do you want the player to ignore the self movement?
  114.   IgnoreEventPath = true
  115.   
  116. # Switch id to enable or disable the path finding feature
  117.   PathFinderSwitch = 500
  118. #
  119. #----------------------------------------------------------------------------
  120. #
  121. # * License
  122. #
  123. # You can use this script in non comercial games, in you need it for comercial
  124. # games let me know. [email]falmc99@gmail.com[/email]
  125. #-----------------------------------------------------------------------------

  126.   def self.check_value(value)
  127.     return 'numeric' if value.is_a? Fixnum
  128.     return 'string'
  129.   end
  130. end

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

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

  326. # Set buttons sprites
  327. class Spriteset_Map
  328.   alias falcao_insert_buttuns_view create_viewports
  329.   def create_viewports
  330.     @interact_buttoms = Interactive_Buttoms.new
  331.     falcao_insert_buttuns_view
  332.   end
  333.   
  334.   alias falcao_insert_buttuns_dis dispose
  335.   def dispose
  336.     @interact_buttoms.reset_cursor if @interact_buttoms.cursoring != nil
  337.     @interact_buttoms.dispose
  338.     falcao_insert_buttuns_dis
  339.   end
  340.   
  341.   alias falcao_insert_buttuns_up update
  342.   def update
  343.     if $game_player.clear_mousepointers
  344.       @interact_buttoms.dispose
  345.       $game_player.clear_mousepointers = nil
  346.     end
  347.     @interact_buttoms.update
  348.     falcao_insert_buttuns_up
  349.   end
  350. end

  351. # comments definition
  352. class Game_Event < Game_Character
  353.   attr_reader   :mouse_start, :mouse_animation, :mouse_name, :mouse_iconset
  354.   attr_reader   :mouse_picture, :page
  355.   alias falcaomouse_setup setup_page_settings
  356.   def setup_page_settings
  357.     falcaomouse_setup
  358.     @mouse_start     = check_comment("MOUSE START")
  359.     @mouse_animation = check_value("MOUSE ANIMATION")
  360.     @mouse_name      = check_name("MOUSE NAME")
  361.     @mouse_iconset   = check_value("MOUSE ICON")
  362.     @mouse_picture   = check_name("MOUSE PIC")
  363.   end

  364.   def check_comment(comment)
  365.     return false if @list.nil? or @list.size <= 0
  366.     for item in @list
  367.       if item.code == 108 or item.code == 408
  368.         if item.parameters[0].include?(comment)
  369.           return true
  370.         end
  371.       end
  372.     end
  373.     return false
  374.   end
  375.   
  376.   def check_value(comment)
  377.     return 0 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] =~ /#{comment}[ ]?(\d+)?/
  381.           return $1.to_i
  382.         end
  383.       end
  384.     end
  385.     return 0
  386.   end
  387.   
  388.   def check_name(comment)
  389.     return "" if @list.nil? or @list.size <= 0
  390.     for item in @list
  391.       next unless item.code == 108 or item.code == 408
  392.       if item.parameters[0] =~ /#{comment} (.*)/
  393.         return $1.to_s
  394.       end
  395.     end
  396.     return ""
  397.   end
  398. end

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

  468. # Game_character new variable
  469. class Game_CharacterBase
  470.   attr_accessor :ch_oy
  471. end

  472. # Sprite character
  473. class Sprite_Character < Sprite_Base
  474.   alias falcaoadd_oxy_set_character_bitmap set_character_bitmap
  475.   def set_character_bitmap
  476.     falcaoadd_oxy_set_character_bitmap
  477.     @character.ch_oy = self.oy
  478.   end
  479. end

  480. class Game_System
  481.   attr_accessor :current_cursor
  482.   def cursorr
  483.     return Map_Buttons::CursorIcon if @current_cursor.nil?
  484.     return @current_cursor
  485.   end
  486. end

  487. # Mouse module
  488. module Mouse
  489.   
  490.   GetKeyState    = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')
  491.   GetCursorPos   = Win32API.new('user32',    'GetCursorPos',     'p',     'i')
  492.   GetClientRect  = Win32API.new('user32',    'GetClientRect',    %w(l p), 'i')
  493.   ShowCursor     = Win32API.new('user32',    'ShowCursor',       'i',     'l')
  494.   ScreenToClient = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')
  495.   Findwindow     = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
  496.   GetPrivatePro  = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  497.   %w(p p p p l p), 'l')
  498.                               
  499.   ShowCursor.call(0)
  500.   
  501.   @triggers     =   [[0, 1], [0, 2], [0, 4]]
  502.   @old_pos      =   0

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

  567.   def self.screen_to_client(x=0, y=0)
  568.     pos = [x, y].pack('ll')
  569.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  570.   end  

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

  650.   def self.hwnd
  651.     if @hwnd.nil?
  652.       game_name = "\0" * 256
  653.       GetPrivatePro.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  654.       game_name.delete!("\0")
  655.       @hwnd = Findwindow.call('RGSS Player', game_name)
  656.     end
  657.     return @hwnd
  658.   end
  659.   
  660.   def self.client_size
  661.     rect = [0, 0, 0, 0].pack('l4')
  662.     GetClientRect.call(self.hwnd, rect)
  663.     right, bottom = rect.unpack('l4')[2..3]
  664.     return right, bottom
  665.   end
  666. end

  667. # Input module aliased
  668. class << Input
  669.   unless self.method_defined?(:falcao21_mouse_update)
  670.     alias_method :falcao21_mouse_update,   :update
  671.     alias_method :falcao21_mouse_trigger?, :trigger?
  672.     alias_method :falcao21_mouse_repeat?,  :repeat?
  673.     alias_method :fal_mouse_input_press?,  :press?
  674.   end
  675.   
  676.   def update
  677.     if $mouse_cursor.visible
  678.       Mouse.update
  679.       $game_arrows.update
  680.       mx, my = *Mouse.position
  681.       $mouse_cursor.x = mx unless mx.nil?
  682.       $mouse_cursor.y = my unless my.nil?   
  683.     end
  684.     falcao21_mouse_update
  685.   end
  686.   
  687.   # trigger
  688.   def trigger?(constant)
  689.     return true if falcao21_mouse_trigger?(constant)
  690.     unless Mouse.pos.nil?
  691.       if Mouse.input_keys.has_value?(constant)
  692.         mouse_trigger = Mouse.input_keys.index(constant)
  693.         return true if Mouse.trigger?(mouse_trigger)
  694.       end
  695.     end
  696.     return false
  697.   end

  698.   # press
  699.   def press?(constant)
  700.     return true if fal_mouse_input_press?(constant)
  701.     unless Mouse.pos.nil?
  702.       if Mouse.input_keys.has_value?(constant)
  703.         mouse_trigger = Mouse.input_keys.index(constant)
  704.         return true if Mouse.press?(mouse_trigger)      
  705.       end
  706.     end
  707.     return false
  708.   end
  709.   
  710.   # repeat
  711.   def repeat?(constant)
  712.     return true if falcao21_mouse_repeat?(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.repeat?(mouse_trigger)
  717.       end
  718.     end
  719.     return false
  720.   end
  721. end

  722. # Here your best friend, you can call this script within the game, scene etc.
  723. # $game_arrows.create_arrows(x, y), create it, $game_arrows.dispose, delete it
  724. class Game_Arrow_Selector
  725.   attr_accessor :mode_on
  726.   attr_accessor :in_type
  727.   def initialize
  728.     @mode_on = false
  729.   end

  730.   def create_arrows(x, y)
  731.     return unless @arrows_sprites.nil?
  732.     buttons = {1=> 'UP', 2=> 'RIGHT', 3=> 'DOWN',
  733.     4=> 'LEFT', 5=> 'OK', 6=> 'Cancel'}
  734.     @arrows_sprites = []
  735.     for i in buttons.values
  736.       @arrows_sprites.push(Garrows_Sprites.new(i, x, y))
  737.     end
  738.   end
  739.   
  740.   def dispose
  741.     return if @arrows_sprites.nil?
  742.     for arrow in @arrows_sprites
  743.       arrow.dispose
  744.     end
  745.     @arrows_sprites = nil
  746.     @mode_on = false
  747.   end
  748.   
  749.   def update
  750.     return if @arrows_sprites.nil?
  751.     for arrow in @arrows_sprites
  752.       arrow.update
  753.     end
  754.   end
  755. end

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

  841. $game_arrows = Game_Arrow_Selector.new

  842. # Arrow selector is displayed when Input number is on
  843. class Game_Interpreter
  844.   alias falcao_setup_num_input setup_num_input
  845.   def setup_num_input(params)
  846.     falcao_setup_num_input(params)
  847.     $game_arrows.create_arrows(256, 194) if $game_message.position == 0
  848.     $game_arrows.create_arrows(256, 340) if $game_message.position == 1
  849.     $game_arrows.create_arrows(256, 180) if $game_message.position == 2
  850.   end
  851. end

  852. # Arrow selector is disposed when press ok
  853. class Window_NumberInput < Window_Base
  854.   alias falcao_process_ok process_ok
  855.   def process_ok
  856.     falcao_process_ok
  857.     $game_arrows.dispose
  858.   end
  859. end

  860. # Arrow selector is displayed within save and load scene
  861. class Scene_File < Scene_MenuBase
  862.   alias falcao47_start start
  863.   alias falcao47_terminate terminate
  864.   
  865.   def start
  866.     falcao47_start
  867.     $game_arrows.create_arrows(210, 166) if Map_Buttons::DisplaySelector
  868.   end
  869.   
  870.   def terminate
  871.     falcao47_terminate
  872.     $game_arrows.dispose if Map_Buttons::DisplaySelector
  873.   end
  874. end

  875. # WASD Movements
  876. module Input
  877.   class << self
  878.     if !method_defined?('vxe_dir4')
  879.       alias vxace_dir4 dir4
  880.     end
  881.     def dir4
  882.       if Map_Buttons::WASD_Movement
  883.         return 2 if (Input.press?(Input::Y))
  884.         return 4 if (Input.press?(Input::X))
  885.         return 6 if (Input.press?(Input::Z))
  886.         return 8 if (Input.press?(Input::R))
  887.       end
  888.       return vxace_dir4
  889.     end
  890.   end
  891. end

  892. # If event start with mouse
  893. class Game_Player < Game_Character
  894.   alias falcao_start_map_event start_map_event
  895.   def start_map_event(x, y, triggers, normal)
  896.     $game_map.events_xy(x, y).each do |event_click|
  897.       return if event_click.check_comment("MOUSE START")
  898.     end  
  899.     falcao_start_map_event(x, y, triggers, normal)
  900.   end
  901. end

  902. # clear pointers when tranfering
  903. class Game_Player < Game_Character
  904.   attr_accessor :clear_mousepointers
  905.   alias falcaomouse_perform_transfer perform_transfer
  906.   def perform_transfer
  907.     @clear_mousepointers = true if $game_map.map_id !=  @new_map_id
  908.     falcaomouse_perform_transfer
  909.   end
  910. end

  911. # Path find
  912. class Game_Character < Game_CharacterBase
  913.   attr_accessor :map, :runpath
  914.   alias pathfind1_ini initialize
  915.   def initialize
  916.     pathfind1_ini
  917.     @map = nil
  918.     @runpath = false
  919.   end
  920.   
  921.   alias pathfind1_up update
  922.   def update
  923.     run_path if @runpath == true
  924.     pathfind1_up
  925.   end
  926.   
  927.   def run_path
  928.     return if moving?
  929.     step = @map[@x,@y]
  930.     if step == 1
  931.       @map = nil
  932.       @runpath = false
  933.       return
  934.     end
  935.     dir = rand(2)
  936.     case dir
  937.     when 0
  938.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  939.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  940.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  941.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  942.     when 1
  943.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  944.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  945.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  946.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  947.     end
  948.   end

  949.   def find_path(x,y)
  950.     sx, sy = @x, @y
  951.     result = setup_map(sx,sy,x,y)
  952.     @runpath = result[0]
  953.     @map = result[1]
  954.     @map[sx,sy] = result[2] if result[2] != nil
  955.   end

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

  1013. # Window selectable (Thanks wora for some lines here)
  1014. class Window_Selectable < Window_Base
  1015.   alias mouse_selection_ini initialize
  1016.   def initialize(*args)
  1017.     mouse_selection_ini(*args)
  1018.     @scroll_wait = 0
  1019.     @cursor_wait = 0
  1020.     @sdelay = 0
  1021.   end

  1022.   alias mouse_selection_update update
  1023.   def update
  1024.     update_mouse_selection if self.active and self.visible
  1025.     @sdelay -= 1 if @sdelay > 0
  1026.     mouse_selection_update
  1027.   end
  1028.   
  1029.   def update_mouse_selection
  1030.     @cursor_wait -= 1 if @cursor_wait > 0
  1031.     (0..self.item_max - 1).each do |i|
  1032.       irect = item_rect(i)
  1033.       irx = self.x + 16 + irect.x - self.ox
  1034.       iry = self.y + 16 + irect.y - self.oy
  1035.       move_cursor(i) if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1036.       update_cursor
  1037.     end
  1038.   end

  1039.   def move_cursor(index)
  1040.     return if @index == index
  1041.     @scroll_wait -= 1 if @scroll_wait > 0
  1042.     row1 = @index / self.col_max
  1043.     row2 = index / self.col_max
  1044.     bottom = self.top_row + (self.page_row_max - 1)
  1045.     if index != @index and @sdelay == 0
  1046.       Sound.play_cursor
  1047.       @sdelay = 5
  1048.     end
  1049.     if row1 == self.top_row and row2 < self.top_row
  1050.       return if @scroll_wait > 0
  1051.       @index = [@index - self.col_max, 0].max
  1052.       @scroll_wait = 30
  1053.     elsif row1 == bottom and row2 > bottom
  1054.       return if @scroll_wait > 0
  1055.       @index = [@index + self.col_max, self.item_max - 1].min
  1056.       @scroll_wait = 30
  1057.     else
  1058.       @index = index
  1059.     end
  1060.     return if @cursor_wait > 0
  1061.     @cursor_wait += 2
  1062.   end
  1063. end

  1064. # Name imput selectable
  1065. class Window_NameInput
  1066.   alias mouse_name_select update unless $@
  1067.   def update(*args, &block)
  1068.     mouse_name_select(*args, &block)
  1069.     if self.active and self.visible
  1070.       (0..self.table[@page].size - 1).each do |i|
  1071.       irect = item_rect(i)
  1072.       irx = self.x + 16 + irect.x - self.ox
  1073.       iry = self.y + 16 + irect.y - self.oy
  1074.       @index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1075.       end
  1076.     end
  1077.   end
  1078. end

  1079. # Window party command
  1080. class Window_PartyCommand < Window_Command
  1081.   def update_mouse_selection
  1082.     (0..self.item_max - 1).each do |i|
  1083.     irect = item_rect(i)
  1084.     irx = self.viewport.ox + 16 + irect.x - self.ox
  1085.     iry = 288 + 16 + irect.y - self.oy
  1086.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1087.     end
  1088.   end
  1089. end

  1090. # Window actor command
  1091. class Window_ActorCommand < Window_Command
  1092.   def update_mouse_selection
  1093.     (0..self.item_max - 1).each do |i|
  1094.     irect = item_rect(i)
  1095.     add = 288
  1096.     add = 156 if !$imported[:ve_animated_battle].nil? &&  
  1097.     $imported[:ve_animated_battle] > 1
  1098.     irx = self.viewport.ox + add + 16 + irect.x
  1099.     iry = 288 + 16 + irect.y
  1100.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1101.     end
  1102.   end
  1103. end
复制代码


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

和XAS一起用 能做到wasd走路左键攻击 挺带感的
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 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

  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. # * 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]falmc99@gmail.com[/email]
  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 @index == 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
复制代码

点评

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

使用道具 举报

梦石
0
星屑
56
在线时间
342 小时
注册时间
2011-10-29
回帖
327
发表于 2013-3-26 18:46:37 | 显示全部楼层
求用法和来源网站!
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部