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

Project1

 找回密码
 注册会员
搜索

【转载】鼠标插件

查看数: 1419 | 评论数: 2 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2020-9-9 12:48

正文摘要:

本帖最后由 学霸小凯 于 2020-9-9 18:32 编辑 鼠标的话在游戏文件/Graphics目录新建一个叫做Mouse的文件夹,文件夹里放入一个叫做Mouse的图片, 图片: $敌人选框扩大 = 20 $角色选框扩大 = 30 #============== ...

回复

alexncf125 发表于 2020-9-9 13:47:33
本帖最后由 alexncf125 于 2020-9-9 13:49 编辑

「原创发布」!!?

https://rpg.blue/thread-167574-1-1.html
https://rpg.blue/thread-277287-1-1.html

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
学霸小凯 发表于 2020-9-9 12:50:09
脚本重发:
RUBY 代码复制
  1. $敌人选框扩大 = 20
  2. $角色选框扩大 = 30
  3.  
  4. #==============================================================================
  5. # API调用
  6. #==============================================================================
  7. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  8. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  9. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  10. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  11. $Window_HWND = $GetActiveWindow.call
  12. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  13. #$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
  14. #$HookStart  = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
  15. #$HookEnd  = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
  16. #$GetMouseStatus  = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
  17. #$Window_HWND = $FindWindow.call(nil, 'mousetry')
  18.  
  19. module Mouse  
  20.   LEFT = 0x01
  21.   RIGHT = 0x02
  22.  
  23.   def self.init(sprite = nil)
  24. #   $HookStart.call($Window_HWND)
  25.     $ShowCursor.call(0)
  26.  
  27.     @show_cursor = false
  28.  
  29.     @mouse_sprite = Sprite.new
  30.     @mouse_sprite.z = 99999
  31.     @mouse_sprite.bitmap = Bitmap.new('Graphics/Mouse/Mouse.png')
  32.     #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))
  33.  
  34.     @left_press = false
  35.     @right_press = false
  36.     @left_trigger = false
  37.     @right_trigger = false
  38.     @left_repeat = false
  39.     @right_repeat = false
  40.     @click_lock = false
  41.  
  42.     update
  43.   end
  44.   def self.exit
  45.     @mouse_sprite.bitmap.dispose
  46.     @mouse_sprite.dispose
  47.     @show_cursor = true
  48. #    $HookEnd.call
  49.     $ShowCursor.call(1)
  50.   end
  51.   def self.mouse_debug
  52.     return @mouse_debug.bitmap
  53.   end
  54.   def self.update
  55.     left_down = $GetKeyState.call(0x01)
  56.     right_down = $GetKeyState.call(0x02)
  57.  
  58.     @click_lock = false
  59.     mouse_x, mouse_y = self.get_mouse_pos
  60.     if @mouse_sprite != nil
  61.       @mouse_sprite.x = mouse_x
  62.       @mouse_sprite.y = mouse_y
  63.     end
  64.     if left_down[7] == 1
  65.       @left_repeat = (not @left_repeat)
  66.       @left_trigger = (not @left_press)
  67.       @left_press = true
  68.     else
  69.       @left_press = false
  70.       @left_trigger = false
  71.       @left_repeat = false
  72.     end
  73.     if right_down[7] == 1
  74.       @right_repeat = (not @right_repeat)
  75.       @right_trigger = (not @right_press)
  76.       @right_press = true
  77.     else
  78.       @right_press = false
  79.       @right_trigger = false
  80.       @right_repeat = false
  81.     end
  82.   end
  83.   def self.get_mouse_pos
  84.     point_var = [0, 0].pack('ll')
  85.     if $GetCursorPos.call(point_var) != 0
  86.       if $ScreenToClient.call($Window_HWND, point_var) != 0
  87.         x, y = point_var.unpack('ll')
  88.         if (x < 0) or (x > 10000) then x = 0 end
  89.         if (y < 0) or (y > 10000) then y = 0 end
  90.         if x > 640 then x = 640 end
  91.         if y > 480 then y = 480 end
  92.         return x, y
  93.       else
  94.         return 0, 0
  95.       end
  96.     else
  97.       return 0, 0
  98.     end
  99.   end
  100.   def self.press?(mouse_code)
  101.     if mouse_code == LEFT
  102.       if @click_lock
  103.         return false
  104.       else
  105.         return @left_press
  106.       end
  107.     elsif mouse_code == RIGHT
  108.       return @right_press
  109.     else
  110.       return false
  111.     end
  112.   end
  113.   def self.trigger?(mouse_code)
  114.     if mouse_code == LEFT
  115.       if @click_lock
  116.         return false
  117.       else
  118.         return @left_trigger
  119.       end
  120.     elsif mouse_code == RIGHT
  121.       return @right_trigger
  122.     else
  123.       return false
  124.     end
  125.   end
  126.   def self.repeat?(mouse_code)
  127.     if mouse_code == LEFT
  128.       if @click_lock
  129.         return false
  130.       else
  131.         return @left_repeat
  132.       end
  133.     elsif mouse_code == RIGHT
  134.       return @right_repeat
  135.     else
  136.       return false
  137.     end
  138.   end
  139.   def self.click_lock?
  140.     return @click_lock
  141.   end
  142.   def self.click_lock
  143.     @click_lock = true
  144.   end
  145.   def self.click_unlock
  146.     @click_lock = false
  147.   end
  148. end
  149. module Input
  150.   if @self_update == nil
  151.     @self_update = method('update')
  152.     @self_press = method('press?')
  153.     @self_trigger = method('trigger?')
  154.     @self_repeat = method('repeat?')
  155.   end
  156.   def self.update
  157.     @self_update.call
  158.     Mouse.update
  159.   end
  160.   def self.press?(key_code)
  161.     if @self_press.call(key_code)
  162.       return true
  163.     end
  164.     if key_code == C
  165.       return Mouse.press?(Mouse::LEFT)
  166.     elsif key_code == B
  167.       return Mouse.press?(Mouse::RIGHT)
  168.     else
  169.       return @self_press.call(key_code)
  170.     end
  171.   end
  172.   def self.trigger?(key_code)
  173.     if @self_trigger.call(key_code)
  174.       return true
  175.     end
  176.     if key_code == C
  177.       return Mouse.trigger?(Mouse::LEFT)
  178.     elsif key_code == B
  179.       return Mouse.trigger?(Mouse::RIGHT)
  180.     else
  181.       return @self_trigger.call(key_code)
  182.     end
  183.   end
  184.   def self.repeat?(key_code)
  185.     if @self_repeat.call(key_code)
  186.       return true
  187.     end
  188.     if key_code == C
  189.       return Mouse.repeat?(Mouse::LEFT)
  190.     elsif key_code == B
  191.       return Mouse.repeat?(Mouse::RIGHT)
  192.     else
  193.       return @self_repeat.call(key_code)
  194.     end
  195.   end
  196. end
  197.  
  198. class Window_Selectable
  199.   if @self_alias == nil
  200.     alias self_update update
  201.     @self_alias = true
  202.   end
  203.   def update
  204.     #self.cursor_rect.empty
  205.     self_update
  206.     if self.active and @item_max > 0
  207.       index_var = @index
  208.       tp_index = @index
  209.       mouse_x, mouse_y = Mouse.get_mouse_pos
  210.       mouse_not_in_rect = true
  211.       for i in 0...@item_max
  212.         @index = i
  213.         update_cursor
  214.         top_x = self.cursor_rect.x + self.x + 16
  215.         top_y = self.cursor_rect.y + self.y + 16
  216.         bottom_x = top_x + self.cursor_rect.width
  217.         bottom_y = top_y + self.cursor_rect.height
  218.  
  219.           top_x += self.x_mod
  220.           top_y += self.y_mod
  221.           bottom_x += self.x_mod
  222.           bottom_y += self.y_mod
  223.  
  224.         if (mouse_x > top_x) and (mouse_y > top_y) and
  225.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  226.           mouse_not_in_rect = false
  227.           if tp_index != @index
  228.             tp_index = @index
  229.             $data_system.sounds[0].play
  230.           end
  231.           break
  232.         end
  233.       end
  234.     if Input.trigger?(Input::F9)
  235.     p top_x,top_y,Mouse.get_mouse_pos
  236.     end
  237.       if mouse_not_in_rect
  238.         @index = index_var
  239.         update_cursor
  240.         Mouse.click_lock
  241.       else
  242.         Mouse.click_unlock               
  243.       end
  244.     end
  245.   end
  246. end
  247.  
  248.  
  249.  
  250.  
  251. class Window_NameInput
  252.   if @self_alias == nil
  253.     alias self_update update
  254.     @self_alias = true
  255.   end
  256.   def update
  257.     #self.cursor_rect.empty
  258.     self_update
  259.     if self.active
  260.       index_var = @index
  261.       mouse_x, mouse_y = Mouse.get_mouse_pos
  262.       mouse_not_in_rect = true
  263.       for i in (0...HIRAGANA.size).to_a.push(180)
  264.         @index = i
  265.         update_cursor
  266.         top_x = self.cursor_rect.x + self.x + 16
  267.         top_y = self.cursor_rect.y + self.y + 16
  268.         bottom_x = top_x + self.cursor_rect.width
  269.         bottom_y = top_y + self.cursor_rect.height
  270.         #
  271.         if (mouse_x > top_x) and (mouse_y > top_y) and
  272.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  273.           mouse_not_in_rect = false
  274.           break
  275.         end
  276.       end
  277.       if mouse_not_in_rect
  278.         @index = index_var
  279.         update_cursor
  280.         Mouse.click_lock
  281.       else
  282.         Mouse.click_unlock
  283.       end
  284.     end
  285.   end
  286. end
  287. =begin
  288.  
  289. class Window_InputNumber
  290.   if @self_alias == nil
  291.     alias self_update update
  292.     @self_alias = true
  293.   end
  294.   def update
  295.     #self.cursor_rect.empty
  296.     self_update
  297.     mouse_x, mouse_y = Mouse.get_mouse_pos
  298.     if self.active and @digits_max > 0
  299.       index_var = @index
  300.       mouse_not_in_rect = true
  301.       for i in 0...@digits_max
  302.         @index = i
  303.         #update_cursor
  304.         top_x = self.cursor_rect.x + self.x + 16
  305.         bottom_x = top_x + self.cursor_rect.width
  306.         #
  307.         if (mouse_x > top_x) and (mouse_x < bottom_x)
  308.           mouse_not_in_rect = false
  309.           break
  310.         end
  311.       end
  312.       if mouse_not_in_rect
  313.         @index = index_var
  314.         #update_cursor
  315.         Mouse.click_lock
  316.       else
  317.         Mouse.click_unlock
  318.       end
  319.     end
  320.     if @last_mouse_y == nil
  321.       @last_mouse_y = mouse_y
  322.     end
  323.     check_pos = (@last_mouse_y - mouse_y).abs
  324.     if check_pos > 10
  325.       #$game_system.se_play($data_system.cursor_se)
  326.       place = 10 ** (@digits_max - 1 - @index)
  327.       n = @Number / place % 10
  328.       @number -= n * place
  329.       n = (n + 1) % 10 if mouse_y < @last_mouse_y
  330.       n = (n + 9) % 10 if mouse_y > @last_mouse_y
  331.       @number += n * place
  332.       refresh
  333.       @last_mouse_y = mouse_y
  334.     end
  335.   end
  336. end
  337. =end
  338.  
  339. class Scene_File
  340.   if @self_alias == nil
  341.     alias self_update update
  342.     @self_alias = true
  343.   end
  344.   def update
  345.     mouse_x, mouse_y = Mouse.get_mouse_pos
  346.     Mouse.click_lock
  347.     idx = 0
  348.     for i in @savefile_windows
  349.       top_x = i.x + 16
  350.       top_y = i.y + 16
  351.       bottom_x = top_x + i.width
  352.       bottom_y = top_y + i.height
  353.       if (mouse_x > top_x) and (mouse_y > top_y) and
  354.          (mouse_x < bottom_x) and (mouse_y < bottom_y)
  355.         i.selected = true
  356.         if @file_index != idx
  357.           @file_index = idx
  358.           $data_system.sounds[0].play
  359.         end            
  360.         Mouse.click_unlock
  361.       else
  362.         i.selected = false
  363.       end
  364.       idx += 1
  365.     end
  366.     self_update
  367.   end
  368. end
  369.  
  370. class Game_Player
  371.   if @self_alias == nil
  372.     alias self_update update
  373.     @self_alias = true
  374.   end
  375.   def update
  376.     mouse_x, mouse_y = Mouse.get_mouse_pos
  377.     if @last_move_x == nil
  378.       @last_move_x = false
  379.     end
  380.     if $game_switches[123]
  381.      if Mouse.press?(Mouse::LEFT)
  382.        for event in $game_map.events.values
  383.          if event.screen_x/32 == mouse_x/32 and event.screen_y/32-1 == mouse_y/32
  384.            event.start
  385.          end
  386.        end
  387.      end
  388.      self_update
  389.      return
  390.    end
  391.     if Mouse.press?(Mouse::LEFT)
  392.    #for event in $game_map.events.values
  393.    #if event.screen_x/32 == mouse_x/32 and event.screen_y/32-1 == mouse_y/32
  394.    #event.start
  395.    #end
  396.    #end
  397.       last_moving = moving?
  398.       last_direction = @direction
  399.     #  return unless movable?
  400.     #  return if $game_map.interpreter.running?
  401.       unless moving? or $game_map.interpreter.running?
  402.       last_x = @x
  403.         if @last_move_x
  404.           @last_move_x = false
  405.         elsif mouse_x > screen_x + 16
  406.           move_right
  407.         elsif mouse_x < screen_x - 16
  408.           move_left
  409.         end
  410.         last_y = @y
  411.         if last_x != @x
  412.           @last_move_x = true
  413.         elsif mouse_y > screen_y
  414.           move_down
  415.         elsif mouse_y < screen_y - 32
  416.           move_up
  417.         end
  418. =begin        
  419.         if last_y != @y
  420.           @last_move_x = false
  421.         elsif not @last_move_x
  422.           case last_direction
  423.           when 2
  424.             turn_down
  425.           when 4
  426.             turn_left
  427.           when 6
  428.             turn_right
  429.           when 8
  430.             turn_up
  431.           end        
  432.         end
  433. =end         
  434.       end
  435.     end
  436.     self_update
  437.   end
  438. end
  439. Mouse.init
  440. END { Mouse.exit }
  441.  
  442.  
  443. class Window_Base < Window
  444.   attr_accessor :x_mod
  445.   attr_accessor :y_mod
  446.   alias ka_initialize initialize
  447.   def initialize(x, y, width, height)
  448.     ka_initialize(x, y, width, height)
  449.     self.x_mod = 0
  450.     self.y_mod = 0
  451.   end
  452. end
  453. class Window_PartyCommand < Window_Command
  454.   alias ka1_initialize initialize
  455.   def initialize
  456.     ka1_initialize
  457.     self.y_mod = 288
  458.   end
  459. end
  460. class Window_ActorCommand < Window_Command
  461.   alias ka2_initialize initialize
  462.   def initialize
  463.     ka2_initialize
  464.     self.x_mod = -128
  465.     self.y_mod = 288
  466.   end
  467. end
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-5-9 01:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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