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

Project1

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

[已经解决] 鼠标脚本的速度调整?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
68 小时
注册时间
2011-8-1
帖子
95
跳转到指定楼层
1
发表于 2012-1-13 17:15:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
   憋了这个问题很久了……首先声明本人不怎么懂脚本。然后,之前在6R收了个鼠标脚本(有点击触发事件的),插入后测试,发现点击一个地方后角色刷一下跑那去 速度太XX快了、不知道在脚本改哪里可以调整?
   下面是我用的那个脚本
  1. #==============================================================================
  2. # 本脚本来自www.66rpg.com,源自geocities.jp,转载和使用请注明此内容
  3. #
  4. # 初始鼠标图案在39行和68行改,变换的鼠标图案在66行改
  5. # 这个脚本的思路是判断鼠标所在位置是否有事件,所以响应的情况只有一种。
  6. # 如果想有多种响应的话,思路复杂,比如拆分事件名称等,做出来的东西将繁琐。
  7. #                                                           —— JesseKiss
  8. #==============================================================================
  9. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  10. $敌人选框扩大 = 20
  11. $角色选框扩大 = 30
  12. #==============================================================================
  13. # API调用
  14. #==============================================================================
  15. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  16. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  17. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  18. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  19. $Window_HWND = $GetActiveWindow.call
  20. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  21. #$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
  22. #$HookStart  = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
  23. #$HookEnd  = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
  24. #$GetMouseStatus  = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
  25. #$Window_HWND = $FindWindow.call(nil, 'mousetry')

  26. module Mouse  
  27.   LEFT = 0x01
  28.   RIGHT = 0x02

  29.   def self.init(sprite = nil)
  30. #   $HookStart.call($Window_HWND)
  31.     $ShowCursor.call(0)
  32.    
  33.     @show_cursor = false
  34.    
  35.     @mouse_sprite = Sprite.new
  36.     @mouse_sprite.z = 99999
  37.     @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/001-Weapon01.png')
  38.     #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))

  39.     @left_press = false
  40.     @right_press = false
  41.     @left_trigger = false
  42.     @right_trigger = false
  43.     @left_repeat = false
  44.     @right_repeat = false
  45.     @click_lock = false
  46.    
  47.     update
  48.   end
  49.   def self.exit
  50.     @mouse_sprite.bitmap.dispose
  51.     @mouse_sprite.dispose
  52.     @show_cursor = true
  53. #    $HookEnd.call
  54.     $ShowCursor.call(1)
  55.   end
  56.   def self.mouse_debug
  57.     return @mouse_debug.bitmap
  58.   end
  59.   def self.update
  60.     left_down = $GetKeyState.call(0x01)
  61.     right_down = $GetKeyState.call(0x02)
  62.     #if $pop == 1
  63.     #@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/041-Item10.png')
  64.     #else
  65.     #@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/CD.png')
  66.     #end
  67.     @click_lock = false
  68.     mouse_x, mouse_y = self.get_mouse_pos
  69.     if @mouse_sprite != nil
  70.       @mouse_sprite.x = mouse_x
  71.       @mouse_sprite.y = mouse_y
  72.     end
  73.     if left_down[7] == 1
  74.       @left_repeat = (not @left_repeat)
  75.       @left_trigger = (not @left_press)
  76.       @left_press = true
  77.     else
  78.       @left_press = false
  79.       @left_trigger = false
  80.       @left_repeat = false
  81.     end
  82.     if right_down[7] == 1
  83.       @right_repeat = (not @right_repeat)
  84.       @right_trigger = (not @right_press)
  85.       @right_press = true
  86.     else
  87.       @right_press = false
  88.       @right_trigger = false
  89.       @right_repeat = false
  90.     end
  91.   end
  92.   def self.get_mouse_pos
  93.     point_var = [0, 0].pack('ll')
  94.     if $GetCursorPos.call(point_var) != 0
  95.       if $ScreenToClient.call($Window_HWND, point_var) != 0
  96.         x, y = point_var.unpack('ll')
  97.         if (x < 0) or (x > 10000) then x = 0 end
  98.         if (y < 0) or (y > 10000) then y = 0 end
  99.         if x > 640 then x = 640 end
  100.         if y > 480 then y = 480 end
  101.         return x, y
  102.       else
  103.         return 0, 0
  104.       end
  105.     else
  106.       return 0, 0
  107.     end
  108.   end
  109.   def self.press?(mouse_code)
  110.     if mouse_code == LEFT
  111.       if @click_lock
  112.         return false
  113.       else
  114.         return @left_press
  115.       end
  116.     elsif mouse_code == RIGHT
  117.       return @right_press
  118.     else
  119.       return false
  120.     end
  121.   end
  122.   def self.trigger?(mouse_code)
  123.     if mouse_code == LEFT
  124.       if @click_lock
  125.         return false
  126.       else
  127.         return @left_trigger
  128.       end
  129.     elsif mouse_code == RIGHT
  130.       return @right_trigger
  131.     else
  132.       return false
  133.     end
  134.   end
  135.   def self.repeat?(mouse_code)
  136.     if mouse_code == LEFT
  137.       if @click_lock
  138.         return false
  139.       else
  140.         return @left_repeat
  141.       end
  142.     elsif mouse_code == RIGHT
  143.       return @right_repeat
  144.     else
  145.       return false
  146.     end
  147.   end
  148.   def self.click_lock?
  149.     return @click_lock
  150.   end
  151.   def self.click_lock
  152.     @click_lock = true
  153.   end
  154.   def self.click_unlock
  155.     @click_lock = false
  156.   end
  157. end
  158. module Input
  159.   if @self_update == nil
  160.     @self_update = method('update')
  161.     @self_press = method('press?')
  162.     @self_trigger = method('trigger?')
  163.     @self_repeat = method('repeat?')
  164.   end
  165.   def self.update
  166.     @self_update.call
  167.     Mouse.update
  168.   end
  169.   def self.press?(key_code)
  170.     if @self_press.call(key_code)
  171.       return true
  172.     end
  173.     if key_code == C
  174.       return Mouse.press?(Mouse::LEFT)
  175.     elsif key_code == B
  176.       return Mouse.press?(Mouse::RIGHT)
  177.     else
  178.       return @self_press.call(key_code)
  179.     end
  180.   end
  181.   def self.trigger?(key_code)
  182.     if @self_trigger.call(key_code)
  183.       return true
  184.     end
  185.     if key_code == C
  186.       return Mouse.trigger?(Mouse::LEFT)
  187.     elsif key_code == B
  188.       return Mouse.trigger?(Mouse::RIGHT)
  189.     else
  190.       return @self_trigger.call(key_code)
  191.     end
  192.   end
  193.   def self.repeat?(key_code)
  194.     if @self_repeat.call(key_code)
  195.       return true
  196.     end
  197.     if key_code == C
  198.       return Mouse.repeat?(Mouse::LEFT)
  199.     elsif key_code == B
  200.       return Mouse.repeat?(Mouse::RIGHT)
  201.     else
  202.       return @self_repeat.call(key_code)
  203.     end
  204.   end
  205. end
  206. class Window_Selectable
  207.   if @self_alias == nil
  208.     alias self_update update
  209.     @self_alias = true
  210.   end
  211.   def update
  212.     #self.cursor_rect.empty
  213.     self_update
  214.     if self.active and @item_max > 0
  215.       index_var = @index
  216.       tp_index = @index
  217.       mouse_x, mouse_y = Mouse.get_mouse_pos
  218.       mouse_not_in_rect = true
  219.       for i in 0...@item_max
  220.         @index = i
  221.         update_cursor_rect
  222.         top_x = self.cursor_rect.x + self.x + 16
  223.         top_y = self.cursor_rect.y + self.y + 16
  224.         bottom_x = top_x + self.cursor_rect.width
  225.         bottom_y = top_y + self.cursor_rect.height
  226.         if (mouse_x > top_x) and (mouse_y > top_y) and
  227.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  228.           mouse_not_in_rect = false
  229.           if tp_index != @index
  230.             tp_index = @index
  231.             $game_system.se_play($data_system.cursor_se)
  232.           end
  233.           break
  234.         end
  235.       end
  236.       if mouse_not_in_rect
  237.         @index = index_var
  238.         update_cursor_rect
  239.         Mouse.click_lock
  240.       else
  241.         Mouse.click_unlock               
  242.       end
  243.     end
  244.   end
  245. end
  246. class Window_NameInput
  247.   if @self_alias == nil
  248.     alias self_update update
  249.     @self_alias = true
  250.   end
  251.   def update
  252.     #self.cursor_rect.empty
  253.     self_update
  254.     if self.active
  255.       index_var = @index
  256.       mouse_x, mouse_y = Mouse.get_mouse_pos
  257.       mouse_not_in_rect = true
  258.       for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  259.         @index = i
  260.         update_cursor_rect
  261.         top_x = self.cursor_rect.x + self.x + 16
  262.         top_y = self.cursor_rect.y + self.y + 16
  263.         bottom_x = top_x + self.cursor_rect.width
  264.         bottom_y = top_y + self.cursor_rect.height
  265.         #
  266.         if (mouse_x > top_x) and (mouse_y > top_y) and
  267.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  268.           mouse_not_in_rect = false
  269.           break
  270.         end
  271.       end
  272.       if mouse_not_in_rect
  273.         @index = index_var
  274.         update_cursor_rect
  275.         Mouse.click_lock
  276.       else
  277.         Mouse.click_unlock
  278.       end
  279.     end
  280.   end
  281. end
  282. class Window_InputNumber
  283.   if @self_alias == nil
  284.     alias self_update update
  285.     @self_alias = true
  286.   end
  287.   def update
  288.     #self.cursor_rect.empty
  289.     self_update
  290.     mouse_x, mouse_y = Mouse.get_mouse_pos
  291.     if self.active and @digits_max > 0
  292.       index_var = @index
  293.       mouse_not_in_rect = true
  294.       for i in 0...@digits_max
  295.         @index = i
  296.         update_cursor_rect
  297.         top_x = self.cursor_rect.x + self.x + 16
  298.         bottom_x = top_x + self.cursor_rect.width
  299.         #
  300.         if (mouse_x > top_x) and (mouse_x < bottom_x)
  301.           mouse_not_in_rect = false
  302.           break
  303.         end
  304.       end
  305.       if mouse_not_in_rect
  306.         @index = index_var
  307.         update_cursor_rect
  308.         Mouse.click_lock
  309.       else
  310.         Mouse.click_unlock
  311.       end
  312.     end
  313.     if @last_mouse_y == nil
  314.       @last_mouse_y = mouse_y
  315.     end
  316.     check_pos = (@last_mouse_y - mouse_y).abs
  317.     if check_pos > 10
  318.       $game_system.se_play($data_system.cursor_se)
  319.       place = 10 ** (@digits_max - 1 - @index)
  320.       n = @number / place % 10
  321.       @number -= n * place
  322.       n = (n + 1) % 10 if mouse_y < @last_mouse_y
  323.       n = (n + 9) % 10 if mouse_y > @last_mouse_y
  324.       @number += n * place
  325.       refresh
  326.       @last_mouse_y = mouse_y
  327.     end
  328.   end
  329. end
  330. class Scene_File
  331.   if @self_alias == nil
  332.     alias self_update update
  333.     @self_alias = true
  334.   end
  335.   def update
  336.     mouse_x, mouse_y = Mouse.get_mouse_pos
  337.     Mouse.click_lock
  338.     idx = 0
  339.     for i in @savefile_windows
  340.       top_x = i.x + 16
  341.       top_y = i.y + 16
  342.       bottom_x = top_x + i.width
  343.       bottom_y = top_y + i.height
  344.       if (mouse_x > top_x) and (mouse_y > top_y) and
  345.          (mouse_x < bottom_x) and (mouse_y < bottom_y)
  346.         i.selected = true
  347.         if @file_index != idx
  348.           @file_index = idx
  349.           $game_system.se_play($data_system.cursor_se)
  350.         end            
  351.         Mouse.click_unlock
  352.       else
  353.         i.selected = false
  354.       end
  355.       idx += 1
  356.     end
  357.     self_update
  358.   end
  359. end
  360. class Arrow_Enemy
  361.   if @self_alias == nil
  362.     alias self_update update
  363.     @self_alias = true
  364.   end
  365.   def update
  366.     mouse_x, mouse_y = Mouse.get_mouse_pos
  367.     idx = 0
  368.     for i in $game_troop.enemies do
  369.       if i.exist?
  370.         top_x = i.screen_x - self.ox
  371.         top_y = i.screen_y - self.oy
  372.         bottom_x = top_x + self.src_rect.width
  373.         bottom_y = top_y + self.src_rect.height
  374.         if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  375.            (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  376.           if @index != idx
  377.             $game_system.se_play($data_system.cursor_se)
  378.             @index = idx
  379.           end
  380.         end
  381.       end
  382.       idx += 1
  383.     end
  384.     self_update
  385.   end
  386. end
  387. class Arrow_Actor
  388.   if @self_alias == nil
  389.     alias self_update update
  390.     @self_alias = true
  391.   end
  392.   def update
  393.     mouse_x, mouse_y = Mouse.get_mouse_pos
  394.     idx = 0
  395.     for i in $game_party.actors do
  396.       if i.exist?
  397.         top_x = i.screen_x - self.ox
  398.         top_y = i.screen_y - self.oy
  399.         bottom_x = top_x + self.src_rect.width
  400.         bottom_y = top_y + self.src_rect.height
  401.         if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  402.            (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  403.           if @index != idx
  404.             $game_system.se_play($data_system.cursor_se)
  405.             @index = idx
  406.           end
  407.         end
  408.       end
  409.       idx += 1
  410.     end
  411.     self_update
  412.   end
  413. end
  414. class Game_Player
  415.   if @self_alias == nil
  416.     alias self_update update
  417.     @self_alias = true
  418.   end
  419.   def update
  420.     mouse_x, mouse_y = Mouse.get_mouse_pos
  421.     $e_id = $game_map.check_event(mouse_x/32,mouse_y/32)
  422.     if $e_id != -1 then
  423.       $pop = 1
  424.      ####点击启动事件###################
  425.      
  426.      if Mouse.press?(Mouse::LEFT)
  427.        # 信息窗口一个也不显示的时候
  428.        unless moving? or $game_system.map_interpreter.running? or
  429.         @move_route_forcing or $game_temp.message_window_showing
  430.           $game_map.events[$e_id].start
  431.        end
  432.      end
  433.      ####################
  434.     else
  435.       $pop = 0
  436.     end
  437.     if @last_move_x == nil
  438.       @last_move_x = false
  439.     end
  440.     if Mouse.press?(Mouse::LEFT)
  441.       last_moving = moving?
  442.       last_direction = @direction
  443.       unless moving? or $game_system.map_interpreter.running? or
  444.              @move_route_forcing or $game_temp.message_window_showing
  445.         last_x = @x
  446.         if @last_move_x
  447.           @last_move_x = false
  448.         elsif mouse_x > screen_x + 16
  449.           move_right
  450.         elsif mouse_x < screen_x - 16
  451.           move_left
  452.         end
  453.         last_y = @y
  454.         if last_x != @x
  455.           @last_move_x = true
  456.         elsif mouse_y > screen_y
  457.           move_down
  458.         elsif mouse_y < screen_y - 32
  459.           move_up
  460.         end
  461.         if last_y != @y
  462.           @last_move_x = false
  463.         elsif not @last_move_x
  464.           case last_direction
  465.           when 2
  466.             turn_down
  467.           when 4
  468.             turn_left
  469.           when 6
  470.             turn_right
  471.           when 8
  472.             turn_up
  473.           end
  474.         end
  475.       end
  476.     end
  477.     self_update
  478.   end
  479. end
  480. Mouse.init
  481. END { Mouse.exit }

  482. class Game_Map
  483. alias check_event_1 check_event
  484.   def check_event(x, y)
  485.     for event in $game_map.events.values
  486.       if event.screen_x/32 == x and event.screen_y/32-1 == y
  487.         return event.id      
  488.       end
  489.     end
  490.     return -1
  491.   end
  492. end
复制代码
速度求教!

点评

是说鼠标快,还是角色快捏,还是都快捏...  发表于 2012-1-13 22:11
《魔军复燃2:博弈》
   跨年大作        完成度           30%   

                

Lv1.梦旅人

梦石
0
星屑
50
在线时间
68 小时
注册时间
2011-8-1
帖子
95
2
 楼主| 发表于 2012-1-13 20:39:03 | 只看该作者
求知啊急~
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
270 小时
注册时间
2010-2-4
帖子
1305
3
发表于 2012-1-13 22:53:41 | 只看该作者
就角色移动很快的话,疑似是你鼠标点得很猛,连点?把player class这里的定义移到Scene_Map去或许会比较好?
好歹当年也当过大魔王过,orz
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
68 小时
注册时间
2011-8-1
帖子
95
4
 楼主| 发表于 2012-1-13 22:56:07 | 只看该作者
zhangbanxian 发表于 2012-1-13 22:53
就角色移动很快的话,疑似是你鼠标点得很猛,连点?把player class这里的定义移到Scene_Map去或许会比较好 ...

,没有猛点、后面听不懂说啥= =原谅我无知

点评

player就是Game_Player的简称嘛= =b,这个脚本疑似是不带寻路,按着走的吧...  发表于 2012-1-13 22:58
《魔军复燃2:博弈》
   跨年大作        完成度           30%   

                
回复

使用道具 举报

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
5
发表于 2012-1-14 10:18:39 | 只看该作者
测试确定脚本无问题,请查看角色本身的速度是否过快,如果用键盘也那么快就是角色本身的问题了

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
68 小时
注册时间
2011-8-1
帖子
95
6
 楼主| 发表于 2012-1-14 11:07:19 | 只看该作者
Wind2010 发表于 2012-1-14 10:18
测试确定脚本无问题,请查看角色本身的速度是否过快,如果用键盘也那么快就是角色本身的问题了 ...

   用键盘的速度是正常的,就是用鼠标就特快、
《魔军复燃2:博弈》
   跨年大作        完成度           30%   

                
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
68 小时
注册时间
2011-8-1
帖子
95
7
 楼主| 发表于 2012-1-14 16:57:54 | 只看该作者
求知啊…
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
68 小时
注册时间
2011-8-1
帖子
95
8
 楼主| 发表于 2012-1-15 10:11:07 | 只看该作者
求助求助…………

点评

连楼自重  发表于 2012-1-15 12:09
《魔军复燃2:博弈》
   跨年大作        完成度           30%   

                
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
732
在线时间
1270 小时
注册时间
2011-2-14
帖子
5589
9
发表于 2012-1-15 12:09:16 | 只看该作者
仔细看了下脚本,里面没有改变角色移动速度的命令

你指的是不是反应速度太快了?

点评

多谢帮忙修改、  发表于 2012-1-17 14:52
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
68 小时
注册时间
2011-8-1
帖子
95
10
 楼主| 发表于 2012-1-15 13:33:33 | 只看该作者
R-零 发表于 2012-1-15 12:09
仔细看了下脚本,里面没有改变角色移动速度的命令

你指的是不是反应速度太快了? ...

  是啊是啊、点击一下角色基本上是瞬间移动到那里的……

点评

哎、出错了昂、【终止程序】,去掉不去掉这八方向都看不到变化了……= =  发表于 2012-1-16 08:39
汗,这么多脚本,目测是伪八方向、伪3D加强版可能会有冲突...  发表于 2012-1-15 20:23
[@]R-零[/@]  发表于 2012-1-15 13:43
还有菜单显示血槽、中毒状态、鼠标功能、对话框加强、伪3D加强版……就这些了= =  发表于 2012-1-15 13:42
没有寻路和奔跑脚本,但应该是脚本影响、我用了这些脚本,不知会不会是因为这些:伪八方向、菜单自动装备、得失物品提醒、显示地图名、……  发表于 2012-1-15 13:41
《魔军复燃2:博弈》
   跨年大作        完成度           30%   

                
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-3 00:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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