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

Project1

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

[已经过期] 在一XV工程上加上鼠标脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
96
在线时间
81 小时
注册时间
2015-6-30
帖子
48
跳转到指定楼层
1
发表于 2015-7-26 09:27:49 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
之前游戏是正常运行的。现在加入了脚本就报错,请大神指导。
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  5. $敌人选框扩大 = 30
  6. $角色选框扩大 = 20


  7. #==============================================================================
  8. # API调用
  9. #==============================================================================
  10. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  11. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  12. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  13. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  14. $Window_HWND = $GetActiveWindow.call
  15. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  16. #$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
  17. #$HookStart  = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
  18. #$HookEnd  = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
  19. #$GetMouseStatus  = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
  20. #$Window_HWND = $FindWindow.call(nil, 'mousetry')

  21. module Mouse  
  22.   LEFT = 0x01
  23.   RIGHT = 0x02

  24.   def self.init(sprite = nil)
  25. #   $HookStart.call($Window_HWND)
  26.     $ShowCursor.call(0)
  27.    
  28.     @show_cursor = false
  29.    
  30.     @mouse_sprite = Sprite.new
  31.     @mouse_sprite.z = 99999
  32.     @mouse_sprite.bitmap = Bitmap.new('Graphics/Mouse/1')
  33.     #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))

  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.     @mouse_x, @mouse_y = self.get_mouse_pos
  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_x != mouse_x or @mouse_y != mouse_y
  61.       moving(@mouse_x, @mouse_y)
  62.       @mouse_x, @mouse_y = mouse_x,mouse_y
  63.     end
  64.     if @mouse_sprite != nil
  65.       @mouse_sprite.x = mouse_x
  66.       @mouse_sprite.y = mouse_y
  67.     end
  68.     if @anima == true
  69.     if @npc == true
  70.       if @count == 80
  71.         @count = 0
  72.         @npc = false
  73.       else
  74.         @count += 1
  75.         end
  76.       if FileTest.exist?("Graphics/Mouse/npc_#{@count/10}.png")
  77.         @mouse_sprite.bitmap = Bitmap.new("Graphics/Mouse/npc_#{@count/10}.png")
  78.       end
  79.     elsif @coach == true
  80.       if @count == 60
  81.         @count = 0
  82.         @coach = false
  83.       else
  84.         @count += 1
  85.         end
  86.       if FileTest.exist?("Graphics/Mouse/coach_#{@count/10}.png")
  87.         @mouse_sprite.bitmap = Bitmap.new("Graphics/Mouse/coach_#{@count/10}.png")
  88.       end
  89.     elsif @enemy == true
  90.       if @count == 60
  91.         @count = 0
  92.         @enemy= false
  93.       else
  94.         @count += 1
  95.         end
  96.         if FileTest.exist?("Graphics/Mouse/#{@count/10 + 4}.png")
  97.         @mouse_sprite.bitmap = Bitmap.new("Graphics/Mouse/#{@count/10 + 4}.png")
  98.       end
  99.       elsif @wait == true
  100.       if @count == 60
  101.         @count = 0
  102.         @wait = false
  103.       else
  104.         @count += 1
  105.         end
  106.         if FileTest.exist?("Graphics/Mouse/wait_#{@count/10}.png")
  107.         @mouse_sprite.bitmap = Bitmap.new("Graphics/Mouse/wait_#{@count/10}.png")
  108.       end
  109.   
  110.       else
  111.       @count == 40 ? @count = 0 : @count += 1
  112.     if FileTest.exist?("Graphics/Mouse/#{@count/10}.png")
  113.        @mouse_sprite.bitmap = Bitmap.new("Graphics/Mouse/#{@count/10}.png")
  114.     end
  115.   end
  116. end
  117. self.show_light(@mouse_sprite.x, mouse_y)
  118.     self.check
  119.     if left_down[7] == 1
  120.       @left_repeat = (not @left_repeat)
  121.       @left_trigger = (not @left_press)
  122.       @left_press = true
  123.     else
  124.       @left_press = false
  125.       @left_trigger = false
  126.       @left_repeat = false
  127.     end
  128.     if right_down[7] == 1
  129.       @right_repeat = (not @right_repeat)
  130.       @right_trigger = (not @right_press)
  131.       @right_press = true
  132.     else
  133.       @right_press = false
  134.       @right_trigger = false
  135.       @right_repeat = false
  136.     end
  137.   end
  138.   def self.get_mouse_pos
  139.     point_var = [0, 0].pack('ll')
  140.     if $GetCursorPos.call(point_var) != 0
  141.       if $ScreenToClient.call($Window_HWND, point_var) != 0
  142.         x, y = point_var.unpack('ll')
  143.         if (x < 0) or (x > 10000) then x = 0 end
  144.         if (y < 0) or (y > 10000) then y = 0 end
  145.         if x > Graphics.width then x = Graphics.width end
  146.         if y > Graphics.height then y = Graphics.height end
  147.         return x, y
  148.       else
  149.         return 0, 0
  150.       end
  151.     else
  152.       return 0, 0
  153.     end
  154.   end
  155.   def self.press?(mouse_code)
  156.     if mouse_code == LEFT
  157.       if @click_lock
  158.         return false
  159.       else
  160.         return @left_press
  161.       end
  162.     elsif mouse_code == RIGHT
  163.       return @right_press
  164.     else
  165.       return false
  166.     end
  167.   end
  168.   def self.trigger?(mouse_code)
  169.     if mouse_code == LEFT
  170.       if @click_lock
  171.         return false
  172.       else
  173.         return @left_trigger
  174.       end
  175.     elsif mouse_code == RIGHT
  176.       return @right_trigger
  177.     else
  178.       return false
  179.     end
  180.   end
  181.   def self.repeat?(mouse_code)
  182.     if mouse_code == LEFT
  183.       if @click_lock
  184.         return false
  185.       else
  186.         return @left_repeat
  187.       end
  188.     elsif mouse_code == RIGHT
  189.       return @right_repeat
  190.     else
  191.       return false
  192.     end
  193.   end
  194.   def self.click_lock?
  195.     return @click_lock
  196.   end
  197.   def self.click_lock
  198.     @click_lock = true
  199.   end
  200.   def self.click_unlock
  201.     @click_lock = false
  202.   end
  203. end
  204. module Input
  205.   if @self_update == nil
  206.     @self_update = method('update')
  207.     @self_press = method('press?')
  208.     @self_trigger = method('trigger?')
  209.     @self_repeat = method('repeat?')
  210.   end
  211.   def self.update
  212.     @self_update.call
  213.     Mouse.update
  214.   end
  215.   def self.press?(key_code)
  216.     if @self_press.call(key_code)
  217.       return true
  218.     end
  219.     if key_code == C
  220.       return Mouse.press?(Mouse::LEFT)
  221.     elsif key_code == B
  222.       return Mouse.press?(Mouse::RIGHT)if !SceneManager.scene_is?(Scene_Map)
  223.     else
  224.       return @self_press.call(key_code)
  225.     end
  226.   end
  227.   def self.trigger?(key_code)
  228.     if @self_trigger.call(key_code)
  229.       return true
  230.     end
  231.     if key_code == C
  232.       return Mouse.trigger?(Mouse::LEFT)
  233.     elsif key_code == B
  234.       
  235.       return Mouse.trigger?(Mouse::RIGHT) if !SceneManager.scene_is?(Scene_Map)
  236.     else
  237.       return @self_trigger.call(key_code)
  238.     end
  239.   end
  240.   def self.repeat?(key_code)
  241.     if @self_repeat.call(key_code)
  242.       return true
  243.     end
  244.     if key_code == C
  245.       return Mouse.repeat?(Mouse::LEFT)
  246.     elsif key_code == B
  247.       return Mouse.repeat?(Mouse::RIGHT)if !SceneManager.scene_is?(Scene_Map)
  248.     else
  249.       return @self_repeat.call(key_code)
  250.     end
  251.   end
  252. end

  253. class Window_Selectable
  254.   if @self_alias == nil
  255.     alias self_update update
  256.     @self_alias = true
  257.   end
  258.   def update
  259.     #self.cursor_rect.empty
  260.     self_update
  261.     if self.active and item_max > 0
  262.       index_var = @index
  263.       tp_index = @index
  264.       mouse_x, mouse_y = Mouse.get_mouse_pos
  265.       mouse_not_in_rect = true
  266.       for i in 0...item_max
  267.         @index = i
  268.         update_cursor
  269.         top_x = self.cursor_rect.x + self.x + 16
  270.         top_y = self.cursor_rect.y + self.y + 16
  271.         bottom_x = top_x + self.cursor_rect.width
  272.         bottom_y = top_y + self.cursor_rect.height
  273.         
  274.           top_x += self.x_mod
  275.           top_y += self.y_mod
  276.           bottom_x += self.x_mod
  277.           bottom_y += self.y_mod
  278.         
  279.         if (mouse_x > top_x) and (mouse_y > top_y) and
  280.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  281.           mouse_not_in_rect = false
  282.           if tp_index != @index
  283.             tp_index = @index
  284.             $data_system.sounds[0].play
  285.           end
  286.           break
  287.         end
  288.       end
  289.     if Input.trigger?(Input::F9)
  290.     p top_x,top_y,Mouse.get_mouse_pos
  291.     end
  292.       if mouse_not_in_rect
  293.         @index = index_var
  294.         update_cursor
  295.         Mouse.click_lock
  296.       else
  297.         Mouse.click_unlock               
  298.       end
  299.     end
  300.   end
  301. end




  302. class Window_NameInput
  303.   if @self_alias == nil
  304.     alias self_update update
  305.     @self_alias = true
  306.   end
  307.   def update
  308.     #self.cursor_rect.empty
  309.     self_update
  310.     if self.active
  311.       index_var = @index
  312.       mouse_x, mouse_y = Mouse.get_mouse_pos
  313.       mouse_not_in_rect = true
  314.       for i in (0...HIRAGANA.size).to_a.push(180)
  315.         @index = i
  316.         update_cursor
  317.         top_x = self.cursor_rect.x + self.x + 16
  318.         top_y = self.cursor_rect.y + self.y + 16
  319.         bottom_x = top_x + self.cursor_rect.width
  320.         bottom_y = top_y + self.cursor_rect.height
  321.         #
  322.         if (mouse_x > top_x) and (mouse_y > top_y) and
  323.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  324.           mouse_not_in_rect = false
  325.           break
  326.         end
  327.       end
  328.       if mouse_not_in_rect
  329.         @index = index_var
  330.         update_cursor
  331.         Mouse.click_lock
  332.       else
  333.         Mouse.click_unlock
  334.       end
  335.     end
  336.   end
  337. end
  338. =begin

  339. class Window_InputNumber
  340.   if @self_alias == nil
  341.     alias self_update update
  342.     @self_alias = true
  343.   end
  344.   def update
  345.     #self.cursor_rect.empty
  346.     self_update
  347.     mouse_x, mouse_y = Mouse.get_mouse_pos
  348.     if self.active and @digits_max > 0
  349.       index_var = @index
  350.       mouse_not_in_rect = true
  351.       for i in 0...@digits_max
  352.         @index = i
  353.         #update_cursor
  354.         top_x = self.cursor_rect.x + self.x + 16
  355.         bottom_x = top_x + self.cursor_rect.width
  356.         #
  357.         if (mouse_x > top_x) and (mouse_x < bottom_x)
  358.           mouse_not_in_rect = false
  359.           break
  360.         end
  361.       end
  362.       if mouse_not_in_rect
  363.         @index = index_var
  364.         #update_cursor
  365.         Mouse.click_lock
  366.       else
  367.         Mouse.click_unlock
  368.       end
  369.     end
  370.     if @last_mouse_y == nil
  371.       @last_mouse_y = mouse_y
  372.     end
  373.     check_pos = (@last_mouse_y - mouse_y).abs
  374.     if check_pos > 10
  375.       #$game_system.se_play($data_system.cursor_se)
  376.       place = 10 ** (@digits_max - 1 - @index)
  377.       n = @number / place % 10
  378.       @number -= n * place
  379.       n = (n + 1) % 10 if mouse_y < @last_mouse_y
  380.       n = (n + 9) % 10 if mouse_y > @last_mouse_y
  381.       @number += n * place
  382.       refresh
  383.       @last_mouse_y = mouse_y
  384.     end
  385.   end
  386. end
  387. =end

  388. class Scene_File
  389.   if @self_alias == nil
  390.     alias self_update update
  391.     @self_alias = true
  392.   end
  393.   def update
  394.     mouse_x, mouse_y = Mouse.get_mouse_pos
  395.     Mouse.click_lock
  396.     idx = 0
  397.     for i in @savefile_windows
  398.       top_x = i.x + 16
  399.       top_y = i.y + 16
  400.       bottom_x = top_x + i.width
  401.       bottom_y = top_y + i.height
  402.       if (mouse_x > top_x) and (mouse_y > top_y) and
  403.          (mouse_x < bottom_x) and (mouse_y < bottom_y)
  404.         i.selected = true
  405.         if @file_index != idx
  406.           @file_index = idx
  407.           $data_system.sounds[0].play
  408.         end            
  409.         Mouse.click_unlock
  410.       else
  411.         i.selected = false
  412.       end
  413.       idx += 1
  414.     end
  415.     self_update
  416.   end
  417. end

  418. class Game_Player
  419.   if @self_alias == nil
  420.     alias self_update update
  421.     @self_alias = true
  422.   end
  423.   def update
  424.     mouse_x, mouse_y = Mouse.get_mouse_pos
  425.     if @last_move_x == nil
  426.       @last_move_x = false
  427.     end
  428.     if Mouse.trigger?(Mouse::RIGHT)
  429.       Mouse.right_menu(mouse_x, mouse_y)
  430.       Graphics.update
  431.     elsif Mouse.press?(Mouse::LEFT)
  432.       if Mouse.mouse_touch == true
  433.         Mouse.mouse_touch = false
  434.         return
  435.       end
  436.       Mouse.plight
  437.       Mouse.wait
  438.       last_moving = moving?
  439.       last_direction = @direction
  440.     #  return unless movable?
  441.     #  return if $game_map.interpreter.running?
  442.       unless moving? or $game_map.interpreter.running?
  443.       last_x = @x
  444.         if @last_move_x
  445.           @last_move_x = false
  446.         elsif mouse_x > screen_x + 16
  447.           move_straight(6)
  448.         elsif mouse_x < screen_x - 16
  449.           move_straight(4)
  450.         end
  451.         last_y = @y
  452.         if last_x != @x
  453.           @last_move_x = true
  454.         elsif mouse_y > screen_y
  455.           move_straight(2)
  456.         elsif mouse_y < screen_y - 32
  457.           move_straight(8)
  458.         end
  459. =begin        
  460.         if last_y != @y
  461.           @last_move_x = false
  462.         elsif not @last_move_x
  463.           case last_direction
  464.           when 2
  465.             turn_down
  466.           when 4
  467.             turn_left
  468.           when 6
  469.             turn_right
  470.           when 8
  471.             turn_up
  472.           end        
  473.         end
  474. =end         
  475.       end
  476.     end
  477.     self_update
  478.   end
  479. end

  480. Mouse.init
  481. END { Mouse.exit }


  482. class Window_Base < Window
  483.   attr_accessor :x_mod
  484.   attr_accessor :y_mod
  485.   alias ka_initialize initialize
  486.   def initialize(x, y, width, height)
  487.     ka_initialize(x, y, width, height)
  488.     self.x_mod = 0
  489.     self.y_mod = 0
  490.   end
  491. end
  492. class Window_PartyCommand < Window_Command

  493.   alias ka1_initialize initialize
  494.   def initialize
  495.     ka1_initialize
  496.     self.y_mod = Graphics.height-128
  497.   end

  498. end
  499. class Window_ActorCommand < Window_Command

  500.   alias ka2_initialize initialize
  501.   def initialize
  502.     ka2_initialize
  503.     self.x_mod = -128
  504.     self.y_mod = Graphics.height-128
  505.   end

  506. end

  507. #==============================================================================
  508. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  509. #==============================================================================
复制代码
头像被屏蔽

Lv1.梦旅人 (禁止访问)

梦石
0
星屑
88
在线时间
631 小时
注册时间
2014-8-4
帖子
3600
2
发表于 2015-7-26 10:23:20 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
96
在线时间
81 小时
注册时间
2015-6-30
帖子
48
3
 楼主| 发表于 2015-7-26 10:40:37 | 只看该作者
冷峻逸 发表于 2015-7-26 10:23
请问是否能把完整工程放上来?缺少素材,无法运行。
如果在这之间加入了一些脚本,或在新工程中可以使用, ...


请问下怎么更改脚本才能让游戏里面的普通菜单变成这种效果。我的是
这样的
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止访问)

梦石
0
星屑
88
在线时间
631 小时
注册时间
2014-8-4
帖子
3600
4
发表于 2015-7-26 10:46:47 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-20 03:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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