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

Project1

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

[已经解决] 鼠标系统能不能添加个开关

[复制链接]

Lv1.梦旅人

梦石
0
星屑
165
在线时间
479 小时
注册时间
2011-3-5
帖子
291
跳转到指定楼层
1
发表于 2014-7-24 11:15:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 love9880 于 2014-7-24 11:16 编辑

脚本在下面。
求大神增加个自动寻路的开关,
即当x号开关开启时,自动寻路开启;x号开关关闭时,则反之。
最好有教程辣蟹蟹www
变量 IgnoreEventPath 是脚本里自动寻路的开关

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

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2014-7-24 11:22:35 | 只看该作者
本帖最后由 taroxd 于 2014-7-24 11:24 编辑

208行改为:
unless $game_switches[Map_Buttons::IgnoreEventPath]

然后把 IgnoreEventPath 设为对应的开关ID

评分

参与人数 1梦石 +1 收起 理由
VIPArcher + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
165
在线时间
479 小时
注册时间
2011-3-5
帖子
291
3
 楼主| 发表于 2014-7-24 11:33:54 | 只看该作者
taroxd 发表于 2014-7-24 11:22
208行改为:
unless $game_switches[Map_Buttons::IgnoreEventPath]

好的。对惹版主大人主题前缀怎么改成已经解决的。

点评

咱会改的不用担心。想要主动结贴可以使用“举报”或者@版主-。- 反正我看到了你就不用操心了  发表于 2014-7-24 11:36
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-14 09:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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