查看: 2533|回复: 2

[已经过期] 鼠标不能用

[复制链接]
梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
发表于 2022-11-5 22:19:39 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 黑米馒头 于 2022-11-5 22:36 编辑

RGU如何支持鼠标,用了RGU之后,原先的鼠标脚本都不能用了,
一进游戏就脚本错误,RGU的作者修改了Game.exe.导致不支持Win32API.new,
有没有大佬能解决这个问题。。。。,或者有用不到Win32API.new的鼠标脚本


1.png



  1. #==============================================================================
  2. # ■ 完整鼠标系统(八方向)
  3. #------------------------------------------------------------------------------
  4. #  使用时务必配合专用寻路算法
  5. #   By whbm
  6. #==============================================================================
  7. #下面做一下介绍与使用说明:
  8. #    在屏幕上单击鼠标的时候,会自动进行寻路,这里为了速度更快并且为了进行迷
  9. #宫时的难度寻路被限定在当时的屏幕内部。(否则玩家直接点到终点,呵呵....知道
  10. #后果了吧)
  11. #    在角色移动过程中再次单击鼠标(即双击)并在单击第二次鼠标的时候不松手,
  12. #角色将会跟随鼠标方向移动。(这个应该好理解,不用多说吧)当角色贴着欲被启动
  13. #的事件的时候,单击NPC即可启动事件。若未贴着,将会产生自动寻路到NPC附近的某
  14. #点,那时在单击NPC即可。
  15. #    当鼠标停在某些事件上时候会发现有不同的图标,设置方法为:宝箱事件请在事
  16. #件的执行内容中添加 注释,注释内容为 Item 注意大小写。NPC事件请在事件的执行
  17. #内容中添加 注释注释内容为 NPC 注意大小写。若不箱改变某事件的图标,则不要写
  18. #那两个注释。
  19. #    当把脚本转到您工程的时候千万别忘了那个寻路用的脚本。
  20. #==============================================================================
  21. class Game_Event
  22.   attr_accessor :flag
  23. end

  24. #==============================================================================
  25. # ■ Game_Map
  26. #------------------------------------------------------------------------------
  27. #  处理地图的类。包含卷动以及可以通行的判断功能。
  28. # 本类的实例请参考 $game_map 。
  29. #==============================================================================
  30. class Game_Map
  31.   def show_rate(event)
  32.     return 1
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 检查鼠标处是否有自定义的事件并返回类型
  36.   #--------------------------------------------------------------------------
  37.   def check_event_custom(mouse_x, mouse_y)
  38.     for event in $game_map.events.values #循环所有事件检查
  39.       rate =  show_rate(event)
  40.       # 修改#####################################
  41.       # 调整鼠标点击NPC的时获取图片范围的宽和高
  42.       ###########################################
  43.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  44.       # 增加一个判定,当行走图名字带★的
  45.       event_height_rate = event.character_name.include?("★") ?  33 : 15
  46.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / event_height_rate) * rate
  47.       ###########################################
  48.       # 调整鼠标点击时图片距离的判定
  49.       # 图片宽度 + 图片X坐标 + 图片高度+ 图片Y坐标
  50.       if mouse_x > event.screen_x - event_width / 8 - 16 and mouse_x < event.screen_x + event_width / 8 - 16 and mouse_y > event.screen_y - event_height / 2 - 64 and mouse_y < event.screen_y + event_height / 4 - 30
  51.         for i in 0...event.list.size
  52.           if event.list[i].parameters[0] == "Item" #类型判断
  53.             event.flag = 1
  54.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  55.             event.flag = 2
  56.           else
  57.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  58.           end
  59.           return event.flag #返回事件类型标志
  60.         end
  61.       end
  62.     end
  63.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  64.     return $mouse_icon_id #使鼠标图不变化
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 检查鼠标处是否有事件可以开启
  68.   #--------------------------------------------------------------------------
  69.   def check_event_custom_start(mouse_x, mouse_y)
  70.     for event in $game_map.events.values #循环所有事件检查
  71.       #事件角色图片宽度、高度
  72.       rate =  show_rate(event)
  73.       # 修改#####################################
  74.       # 调整鼠标点击NPC的时获取图片范围的宽和高
  75.       ###########################################
  76.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  77.       # 增加一个判定,当行走图名字带★的
  78.       event_height_rate = event.character_name.include?("★") ?  33 : 15
  79.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / event_height_rate) * rate
  80.       #判断是否鼠标在事件上
  81.       ###########################################
  82.       # 调整鼠标点击时图片距离的判定
  83.       # 图片宽度 + 图片X坐标 + 图片高度+ 图片Y坐标
  84.       if mouse_x > event.screen_x - event_width / 8 - 16 and mouse_x < event.screen_x + event_width / 8 - 16 and mouse_y > event.screen_y - event_height / 2 - 64 and mouse_y < event.screen_y + event_height / 4 - 30
  85.         way_x = $game_player.x - event.x
  86.         way_y = $game_player.y - event.y
  87.         if [1,0,-1].include?($game_player.x-event.x) and [1,0,-1].include?($game_player.y-event.y)
  88.           for i in 0...event.list.size
  89.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  90.               #判断主角朝向
  91.               if way_x == -1
  92.                 p_direction = 1 if way_y == -1  # 右下
  93.                 p_direction = 6 if way_y == 0   # 右
  94.                 p_direction = 7 if way_y == 1   # 右上
  95.               elsif way_x == 0
  96.                 p_direction = 2 if way_y == -1  # 下
  97.                 p_direction = 8 if way_y == 1   # 上
  98.               else
  99.                 p_direction = 3 if way_y == -1  # 左下
  100.                 p_direction = 4 if way_y == 0   # 左
  101.                 p_direction = 9 if way_y == 1   # 左上
  102.               end
  103.               event.start #开启事件
  104.               return 1, p_direction #返回即将开启事件以及角色朝向
  105.             end
  106.           end
  107.         end
  108.       end
  109.     end
  110.     return 0, 5 #返回不会开启事件以及角色朝向不变
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  114.   #--------------------------------------------------------------------------
  115.   def check_event_custom_exist(mouse_x, mouse_y)
  116.     for event in $game_map.events.values #循环所有事件检查
  117.       #事件角色图片宽度、高度
  118.       rate =  show_rate(event)
  119.       # 修改#####################################
  120.       # 调整鼠标点击NPC的时获取图片范围的宽和高
  121.       ###########################################
  122.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  123.       # 增加一个判定,当行走图名字带★的
  124.       event_height_rate = event.character_name.include?("★") ?  33 : 15
  125.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / event_height_rate) * rate
  126.       ###########################################
  127.       # 调整鼠标点击时图片距离的判定
  128.       # 图片宽度 + 图片X坐标 + 图片高度+ 图片Y坐标
  129.       if mouse_x > event.screen_x - event_width / 8 - 16 and mouse_x < event.screen_x + event_width / 8 - 16 and mouse_y > event.screen_y - event_height / 2 - 64 and mouse_y < event.screen_y + event_height / 4 - 30
  130.         for i in 0...event.list.size
  131.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  132.         end
  133.       end
  134.     end
  135.     return 0, event #返回不存在自定义事件,以及事件体
  136.   end
  137. end
  138. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  139. $敌人选框扩大 = 60
  140. $角色选框扩大 = 60


  141. #==============================================================================
  142. # ● API调用
  143. #==============================================================================
  144. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  145. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  146. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  147. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  148. $Window_HWND = $GetActiveWindow.call
  149. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  150. module Mouse  
  151. LEFT = 0x01
  152. RIGHT = 0x02

  153. def self.init(sprite = nil)
  154.    $ShowCursor.call(0)
  155.    
  156.    @show_cursor = false
  157.    
  158.    @mouse_sprite = Sprite.new
  159.    @mouse_sprite.z = 99999
  160.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/鼠标指针')

  161.    @left_press = false
  162.    @right_press = false
  163.    @left_trigger = false
  164.    @right_trigger = false
  165.    @left_repeat = false
  166.    @right_repeat = false
  167.    @click_lock = false
  168.    
  169.    update
  170. end
  171. def self.exit
  172.    @mouse_sprite.bitmap.dispose
  173.    @mouse_sprite.dispose
  174.    @show_cursor = true
  175.    $ShowCursor.call(1)
  176. end
  177. def self.mouse_debug
  178.    return @mouse_debug.bitmap
  179. end
  180. def self.update
  181.    left_down = $GetKeyState.call(0x01)
  182.    right_down = $GetKeyState.call(0x02)
  183.    if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  184.      @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  185.      @a = !@a
  186.    end
  187.    if $scene.is_a?(Scene_Map) == false
  188.      $mouse_icon_id = 0
  189.    end
  190.    if $mouse_icon_id != $mouse_icon_id_last
  191.      case $mouse_icon_id
  192.      when 1
  193.        if @a
  194.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/GetItem1')
  195.        else
  196.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/GetItem2')
  197.        end
  198.      when 2
  199.        if @a
  200.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/TalkTo1')
  201.        else
  202.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/TalkTo2')
  203.        end
  204.      when 11
  205.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_LOWER_LEFT')
  206.      when 12
  207.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_DOWN')
  208.      when 13
  209.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_LOWER_RIGHT')
  210.      when 14
  211.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_LEFT')
  212.      when 16
  213.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_RIGHT')
  214.      when 17
  215.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_UPPER_LEFT')
  216.      when 18
  217.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_UP')
  218.      when 19
  219.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_UPPER_RIGHT')
  220.      when 0
  221.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/鼠标指针')
  222.      end
  223.      $mouse_icon_id_last = $mouse_icon_id
  224.    end
  225.    @click_lock = false
  226.    mouse_x, mouse_y = self.get_mouse_pos
  227.    if @mouse_sprite != nil
  228.      @mouse_sprite.x = mouse_x
  229.      @mouse_sprite.y = mouse_y
  230.    end
  231.    if left_down[7] == 1
  232.      @left_repeat = (not @left_repeat)
  233.      @left_trigger = (not @left_press)
  234.      @left_press = true
  235.    else
  236.      @left_press = false
  237.      @left_trigger = false
  238.      @left_repeat = false
  239.    end
  240.    if right_down[7] == 1
  241.      @right_repeat = (not @right_repeat)
  242.      @right_trigger = (not @right_press)
  243.      @right_press = true
  244.    else
  245.      @right_press = false
  246.      @right_trigger = false
  247.      @right_repeat = false
  248.    end
  249. end
  250. def self.get_mouse_pos
  251.    point_var = [0, 0].pack('ll')
  252.    if $GetCursorPos.call(point_var) != 0
  253.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  254.        x, y = point_var.unpack('ll')
  255.        if (x < 0) or (x > 1500) then x = 0 end # 鼠标可以超出窗口的距离,默认10000
  256.        if (y < 0) or (y > 1500) then y = 0 end # 鼠标可以超出窗口的距离,默认10000
  257.       
  258.        # 修改###############################
  259.        #####################################
  260.        if x > 1024 then x = 1024 end # 调整屏幕范围 宽度 默认640
  261.        if y > 768 then y = 768 end   # 调整屏幕范围 长度 默认480
  262.        return x, y
  263.      else
  264.        return 0, 0
  265.      end
  266.    else
  267.      return 0, 0
  268.    end
  269. end
  270. def self.press?(mouse_code)
  271.    if mouse_code == LEFT
  272.      if @click_lock
  273.        return false
  274.      else
  275.        return @left_press
  276.      end
  277.    elsif mouse_code == RIGHT
  278.      return @right_press
  279.    else
  280.      return false
  281.    end
  282. end
  283. def self.trigger?(mouse_code)
  284.    if mouse_code == LEFT
  285.      if @click_lock
  286.        return false
  287.      else
  288.        return @left_trigger
  289.      end
  290.    elsif mouse_code == RIGHT
  291.      return @right_trigger
  292.    else
  293.      return false
  294.    end
  295. end
  296. def self.repeat?(mouse_code)
  297.    if mouse_code == LEFT
  298.      if @click_lock
  299.        return false
  300.      else
  301.        return @left_repeat
  302.      end
  303.    elsif mouse_code == RIGHT
  304.      return @right_repeat
  305.    else
  306.      return false
  307.    end
  308. end
  309. def self.click_lock?
  310.    return @click_lock
  311. end
  312. def self.click_lock
  313.    @click_lock = true
  314. end
  315. def self.click_unlock
  316.    @click_lock = false
  317. end
  318. end
  319. module Input
  320. if @self_update == nil
  321.    @self_update = method('update')
  322.    @self_press = method('press?')
  323.    @self_trigger = method('trigger?')
  324.    @self_repeat = method('repeat?')
  325. end
  326. def self.update
  327.    @self_update.call
  328.    Mouse.update
  329. end
  330. def self.press?(key_code)
  331.    if @self_press.call(key_code)
  332.      return true
  333.    end
  334.    if key_code == C
  335.      return Mouse.press?(Mouse::LEFT)
  336.    elsif key_code == B
  337.      return Mouse.press?(Mouse::RIGHT)
  338.    else
  339.      return @self_press.call(key_code)
  340.    end
  341. end
  342. def self.trigger?(key_code)
  343.    if @self_trigger.call(key_code)
  344.      return true
  345.    end
  346.    if key_code == C
  347.      return Mouse.trigger?(Mouse::LEFT)
  348.    elsif key_code == B
  349.      return Mouse.trigger?(Mouse::RIGHT)
  350.    else
  351.      return @self_trigger.call(key_code)
  352.    end
  353. end
  354. def self.repeat?(key_code)
  355.    if @self_repeat.call(key_code)
  356.      return true
  357.    end
  358.    if key_code == C
  359.      return Mouse.repeat?(Mouse::LEFT)
  360.    elsif key_code == B
  361.      return Mouse.repeat?(Mouse::RIGHT)
  362.    else
  363.      return @self_repeat.call(key_code)
  364.    end
  365. end
  366. end
  367. class Window_Selectable
  368. if @self_alias == nil
  369.    alias self_update update
  370.    @self_alias = true
  371. end
  372. def update
  373.    self_update
  374.    if self.active and @item_max > 0
  375.      index_var = @index
  376.      tp_index = @index
  377.      mouse_x, mouse_y = Mouse.get_mouse_pos
  378.      mouse_not_in_rect = true
  379.      for i in 0...@item_max
  380.        @index = i
  381.        update_cursor_rect
  382.        top_x = self.cursor_rect.x + self.x + 16
  383.        top_y = self.cursor_rect.y + self.y + 16
  384.        bottom_x = top_x + self.cursor_rect.width
  385.        bottom_y = top_y + self.cursor_rect.height
  386.        if (mouse_x > top_x) and (mouse_y > top_y) and
  387.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  388.          mouse_not_in_rect = false
  389.          if tp_index != @index
  390.            tp_index = @index
  391.            $game_system.se_play($data_system.cursor_se)
  392.          end
  393.          break
  394.        end
  395.      end
  396.      if mouse_not_in_rect
  397.        @index = index_var
  398.        update_cursor_rect
  399.        Mouse.click_lock
  400.      else
  401.        Mouse.click_unlock               
  402.      end
  403.    end
  404. end
  405. end
  406. class Window_NameInput
  407. if @self_alias == nil
  408.    alias self_update update
  409.    @self_alias = true
  410. end
  411. def update
  412.    self_update
  413.    if self.active
  414.      index_var = @index
  415.      mouse_x, mouse_y = Mouse.get_mouse_pos
  416.      mouse_not_in_rect = true
  417.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  418.        @index = i
  419.        update_cursor_rect
  420.        top_x = self.cursor_rect.x + self.x + 16
  421.        top_y = self.cursor_rect.y + self.y + 16
  422.        bottom_x = top_x + self.cursor_rect.width
  423.        bottom_y = top_y + self.cursor_rect.height
  424.        if (mouse_x > top_x) and (mouse_y > top_y) and
  425.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  426.          mouse_not_in_rect = false
  427.          break
  428.        end
  429.      end
  430.      if mouse_not_in_rect
  431.        @index = index_var
  432.        update_cursor_rect
  433.        Mouse.click_lock
  434.      else
  435.        Mouse.click_unlock
  436.      end
  437.    end
  438. end
  439. end

  440. ##########################################################
  441. # 角色分类 和 物品栏 支持光标移动
  442. class Window_Selectable_Item
  443. if @self_alias == nil
  444.    alias self_update update
  445.    @self_alias = true
  446. end
  447. def update
  448.    self_update
  449.    if self.active and @item_max > 0
  450.      index_var = @index
  451.      tp_index = @index
  452.      mouse_x, mouse_y = Mouse.get_mouse_pos
  453.      mouse_not_in_rect = true
  454.      for i in 0...@item_max
  455.        @index = i
  456.        update_cursor_rect
  457.        top_x = self.cursor_rect.x + self.x + 16
  458.        top_y = self.cursor_rect.y + self.y + 16
  459.        bottom_x = top_x + self.cursor_rect.width
  460.        bottom_y = top_y + self.cursor_rect.height
  461.        if (mouse_x > top_x) and (mouse_y > top_y) and
  462.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  463.          mouse_not_in_rect = false
  464.          if tp_index != @index
  465.            tp_index = @index
  466.            $game_system.se_play($data_system.cursor_se)
  467.          end
  468.          break
  469.        end
  470.      end
  471.      if mouse_not_in_rect
  472.        @index = index_var
  473.        update_cursor_rect
  474.        Mouse.click_lock
  475.      else
  476.        Mouse.click_unlock               
  477.      end
  478.    end
  479. end
  480. end

  481. ##########################################################
  482. # 角色装备栏支持鼠标光标移动
  483. class Window_Selectable_Item_w
  484. if @self_alias == nil
  485.    alias self_update update
  486.    @self_alias = true
  487. end
  488. def update
  489.    self_update
  490.    if self.active and @item_max > 0
  491.      index_var = @index
  492.      tp_index = @index
  493.      mouse_x, mouse_y = Mouse.get_mouse_pos
  494.      mouse_not_in_rect = true
  495.      for i in 0...@item_max
  496.        @index = i
  497.        update_cursor_rect
  498.        top_x = self.cursor_rect.x + self.x + 16
  499.        top_y = self.cursor_rect.y + self.y + 16
  500.        bottom_x = top_x + self.cursor_rect.width
  501.        bottom_y = top_y + self.cursor_rect.height
  502.        if (mouse_x > top_x) and (mouse_y > top_y) and
  503.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  504.          mouse_not_in_rect = false
  505.          if tp_index != @index
  506.            tp_index = @index
  507.            $game_system.se_play($data_system.cursor_se)
  508.          end
  509.          break
  510.        end
  511.      end
  512.      if mouse_not_in_rect
  513.        @index = index_var
  514.        update_cursor_rect
  515.        Mouse.click_lock
  516.      else
  517.        Mouse.click_unlock               
  518.      end
  519.    end
  520. end
  521. end
  522. ##########################################################

  523. class Window_InputNumber
  524. if @self_alias == nil
  525.    alias self_update update
  526.    @self_alias = true
  527. end
  528. def update
  529.    self_update
  530.    mouse_x, mouse_y = Mouse.get_mouse_pos
  531.    if self.active and @digits_max > 0
  532.      index_var = @index
  533.      mouse_not_in_rect = true
  534.      for i in 0...@digits_max
  535.        @index = i
  536.        update_cursor_rect
  537.        top_x = self.cursor_rect.x + self.x + 16
  538.        bottom_x = top_x + self.cursor_rect.width
  539.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  540.          mouse_not_in_rect = false
  541.          break
  542.        end
  543.      end
  544.      if mouse_not_in_rect
  545.        @index = index_var
  546.        update_cursor_rect
  547.        Mouse.click_lock
  548.      else
  549.        Mouse.click_unlock
  550.      end
  551.    end
  552.    if @last_mouse_y == nil
  553.      @last_mouse_y = mouse_y
  554.    end
  555.    check_pos = (@last_mouse_y - mouse_y).abs
  556.    if check_pos > 10
  557.      $game_system.se_play($data_system.cursor_se)
  558.      place = 10 ** (@digits_max - 1 - @index)
  559.      n = @number / place % 10
  560.      @number -= n * place
  561.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  562.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  563.      @number += n * place
  564.      refresh
  565.      @last_mouse_y = mouse_y
  566.    end
  567. end
  568. end

  569. class Scene_File
  570. if @self_alias == nil
  571.    alias self_update update
  572.    @self_alias = true
  573. end
  574. def update
  575.    mouse_x, mouse_y = Mouse.get_mouse_pos
  576.    Mouse.click_lock
  577.    idx = 0
  578.    for i in @savefile_windows
  579.      top_x = i.x + 16
  580.      top_y = i.y + 16
  581.      bottom_x = top_x + i.width
  582.      bottom_y = top_y + i.height
  583.      if (mouse_x > top_x) and (mouse_y > top_y) and
  584.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  585.        i.selected = true
  586.        if @file_index != idx
  587.          @file_index = idx
  588.          $game_system.se_play($data_system.cursor_se)
  589.        end            
  590.        Mouse.click_unlock
  591.      else
  592.        i.selected = false
  593.      end
  594.      idx += 1
  595.    end
  596.    self_update
  597. end
  598. end

  599. class Arrow_Enemy
  600. if @self_alias == nil
  601.    alias self_update update
  602.    @self_alias = true
  603. end
  604. def update
  605.    mouse_x, mouse_y = Mouse.get_mouse_pos
  606.    idx = 0
  607.    for i in $game_troop.enemies do
  608.      if i.exist?
  609.        top_x = i.screen_x - self.ox
  610.        top_y = i.screen_y - self.oy
  611.        bottom_x = top_x + self.src_rect.width
  612.        bottom_y = top_y + self.src_rect.height
  613.           # 战斗时 鼠标获取 敌人战斗图的 宽 和 高
  614.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大 - 10) and
  615.           # 战斗时 鼠标获取 敌人X,Y坐标位置
  616.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大 - 30)
  617.          if @index != idx
  618.            $game_system.se_play($data_system.cursor_se)
  619.            @index = idx
  620.          end
  621.        end
  622.      end
  623.      idx += 1
  624.    end
  625.    self_update
  626. end
  627. end
  628. class Arrow_Actor
  629. if @self_alias == nil
  630.    alias self_update update
  631.    @self_alias = true
  632. end
  633. def update
  634.    mouse_x, mouse_y = Mouse.get_mouse_pos
  635.    idx = 0
  636.    for i in $game_party.actors do
  637.      if i.exist?
  638.        top_x = i.screen_x - self.ox
  639.        top_y = i.screen_y - self.oy
  640.        bottom_x = top_x + self.src_rect.width
  641.        bottom_y = top_y + self.src_rect.height
  642.        # 战斗时 鼠标获取 角色战斗图的 宽 和 高
  643.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大 - 50) and
  644.          # 战斗时 鼠标获取 角色X,Y坐标位置
  645.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大 - 30)
  646.          if @index != idx
  647.            $game_system.se_play($data_system.cursor_se)
  648.            @index = idx
  649.          end
  650.        end
  651.      end
  652.      idx += 1
  653.    end
  654.    self_update
  655. end
  656. end
  657. #==============================================================================
  658. # ■ Game_Player
  659. #------------------------------------------------------------------------------
  660. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  661. # 本类的实例请参考 $game_player。
  662. #   鼠标控制角色的主程序
  663. #==============================================================================
  664. class Game_Player
  665. if @self_alias == nil
  666.    alias self_update update
  667.    @self_alias = true
  668. end
  669. #--------------------------------------------------------------------------
  670. # ● 得到鼠标的状态
  671. #--------------------------------------------------------------------------
  672. def get_mouse_sta
  673.    return @mouse_sta
  674. end
  675. #--------------------------------------------------------------------------
  676. # ● 完整鼠标系统
  677. #--------------------------------------------------------------------------
  678. def update
  679.    mouse_x, mouse_y = Mouse.get_mouse_pos
  680.    @mtp_x = mouse_x
  681.    @mtp_y = mouse_y
  682.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  683.      #得到鼠标图标方向
  684.      $mouse_icon_id = $game_map.check_event_custom(mouse_x,mouse_y)  if not [11, 12, 13, 14, 16, 17, 18, 19].include?($mouse_icon_id)
  685.    else
  686.      #令鼠标图标为正常
  687.      $mouse_icon_id = 0 if @mouse_sta != 2
  688.    end
  689.    
  690.    #单击鼠标时进行判断寻路或跟随
  691.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  692.      unless $game_system.map_interpreter.running? or
  693.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  694.        #初始化
  695.        @mouse_sta = 1
  696.        p_direction = 5
  697.        #检查鼠标处能否开启事件
  698.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  699.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  700.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  701.        if @mouse_sta != 2
  702.          #鼠标状态不为跟随状态则取数据并初始化路径
  703.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  704.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  705.          @paths = []
  706.          @paths_id = 0
  707.          if event_start == 0 #若不能开启事件
  708.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  709.              find_path = Find_Path.new
  710.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  711.            end
  712.          else #若能开启事件则改变角色朝向
  713.            @direction = p_direction
  714.          end
  715.        end
  716.      end
  717.    end

  718.    #开始移动
  719.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  720.      unless moving? or $game_system.map_interpreter.running? or
  721.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  722.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  723.          case @paths[@paths_id] #判断路径
  724.          when 6
  725.            @last_move_x = true
  726.            move_right
  727.            @paths_id += 1
  728.            @direction = 6 # 右
  729.          when 4
  730.            @last_move_x = true
  731.            move_left
  732.            @paths_id += 1
  733.            @direction = 4 # 左
  734.          when 2
  735.            @last_move_x = false
  736.            move_down
  737.            @direction = 2 # 下
  738.            @paths_id += 1
  739.          when 8
  740.            @last_move_x = false
  741.            move_up
  742.            @direction = 8 #上
  743.            @paths_id += 1
  744.          #斜四方向
  745.          when 1
  746.            @last_move_x = false
  747.            move_lower_left
  748.            @direction = 3 # 左下
  749.            @paths_id += 1
  750.          when 3
  751.            @last_move_x = false
  752.            move_lower_right
  753.            @direction = 1 # 右下
  754.            @paths_id += 1
  755.          when 7
  756.            @last_move_x = false
  757.            move_upper_left
  758.            @direction = 9 #左上
  759.            @paths_id += 1
  760.          when 9
  761.            @last_move_x = false
  762.            move_upper_right
  763.            @direction = 7 #右上
  764.            @paths_id += 1
  765.          end
  766.        end
  767.      end
  768.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  769.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  770.        unless moving? or $game_system.map_interpreter.running? or
  771.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  772.          #跟随方向判断并跟随
  773.          rate =  $game_map.show_rate(self)
  774.          width = (RPG::Cache.character(self.character_name,self.character_hue).width / $c3_每一步的帧数) * rate
  775.          height = (RPG::Cache.character(self.character_name,self.character_hue).height / 8) * rate
  776.          self_ox = (self.screen_x - width / 2 + self.screen_x + width / 2) / 2
  777.          self_oy = (self.screen_y - height + self.screen_y) / 2
  778.          #self_ox = self.screen_x
  779.          #self_oy = self.screen_y
  780.          if (@mtp_x - self_ox)*(@mtp_x - self_ox) + (@mtp_y - self_oy)*(@mtp_y - self_oy) >= 961
  781.            if @mtp_x > self_ox
  782.              if self_oy - @mtp_y < 0.4 * (@mtp_x - self_ox) and
  783.                 @mtp_y - self_oy < 0.4 * (@mtp_x - self_ox)
  784.                move_right
  785.                $mouse_icon_id = 16
  786.                @direction = 6 ## 右
  787.              end
  788.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  789.                 @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  790.                move_lower_right
  791.                $mouse_icon_id = 13
  792.                @direction = 3 ## 左下
  793.              end
  794.              if @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x ) and
  795.                 @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  796.                move_upper_right
  797.                $mouse_icon_id = 19
  798.                @direction = 7 ## 右上
  799.              end
  800.              if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
  801.                move_down
  802.                $mouse_icon_id = 12
  803.                @direction = 2 ## 下
  804.              end
  805.              if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
  806.                move_up
  807.                $mouse_icon_id = 18
  808.                @direction = 8 ## 上
  809.              end
  810.            end
  811.            if @mtp_x < self_ox
  812.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  813.                 @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
  814.                move_left
  815.                $mouse_icon_id = 14
  816.                @direction = 4 ## 左
  817.              end
  818.              if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
  819.                 @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
  820.                move_lower_left
  821.                $mouse_icon_id = 11
  822.                @direction = 1 ## 左下
  823.              end
  824.              if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
  825.                 @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
  826.                move_upper_left
  827.                $mouse_icon_id = 17
  828.                @direction = 9 ## 左上
  829.              end
  830.              if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  831.                move_down
  832.                $mouse_icon_id = 12
  833.                @direction = 2 ## 下
  834.              end
  835.              if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  836.                move_up
  837.                $mouse_icon_id = 18
  838.                @direction = 8 ## 上
  839.              end
  840.            end
  841.          end
  842.            #...................................................................
  843.            if @mtp_x > self_ox
  844.              if @mtp_y - self_oy > - 0.4 * ( @mtp_x - self_ox ) and
  845.                 @mtp_y - self_oy < 0.4 * ( @mtp_x - self_ox )
  846.                $mouse_icon_id = 16
  847.                @direction = 6 # 右
  848.              end
  849.              if @mtp_y - self_oy > 0.4 * ( @mtp_x - self_ox ) and
  850.                @mtp_y - self_oy < 2.4 * ( @mtp_x - self_ox )
  851.                $mouse_icon_id = 13
  852.                @direction = 1 # 右下
  853.              end
  854.              if @mtp_y - self_oy < - 0.4 * ( @mtp_x - self_ox ) and
  855.                @mtp_y - self_oy > - 2.4 * ( @mtp_x - self_ox )
  856.                $mouse_icon_id = 19
  857.                @direction = 7 # 右上
  858.              end
  859.              if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
  860.                $mouse_icon_id = 12
  861.                @direction = 2 # 下
  862.              end
  863.              if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
  864.                $mouse_icon_id = 18
  865.                @direction = 8 # 上
  866.              end
  867.            end
  868.            if @mtp_x < self_ox
  869.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  870.                 @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
  871.                $mouse_icon_id = 14
  872.                @direction = 4 # 左
  873.              end
  874.              if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
  875.                 @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
  876.                $mouse_icon_id = 11
  877.                @direction = 3 # 左下
  878.              end
  879.              if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
  880.                 @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
  881.                $mouse_icon_id = 17
  882.                @direction = 9 # 左上
  883.              end
  884.              if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  885.                $mouse_icon_id = 12
  886.                @direction = 2 # 下
  887.              end
  888.              if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  889.                $mouse_icon_id = 18
  890.                @direction = 8 # 上
  891.              end
  892.            end
  893.            #...................................................................
  894.        end
  895.      else #没状态的情况
  896.        $mouse_icon_id = 0
  897.        @mouse_sta = 0
  898.        @paths_id = @paths.size #终止寻路移动
  899.      end
  900.    end
  901.    self_update
  902. end
  903. end
  904. Mouse.init
  905. END { Mouse.exit }
复制代码
梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
回帖
205
发表于 2022-11-6 16:09:05 | 显示全部楼层
RGU我的电脑运行RMXP直接闪退……,就没发试
对ruby1.8还比较熟悉,后续版本没用过……
好像有个Fiddle的模块取代了Win32API,应该也能调用这些DLL的函数,自己上网查一下吧
回复

使用道具 举报

梦石
0
星屑
2821
在线时间
585 小时
注册时间
2022-7-13
回帖
81
发表于 2022-11-8 07:04:16 | 显示全部楼层
我多次尝试,无解,只能等作者优化
使用sion鼠标系统可以正常获取到鼠标坐标,且不出错
但是由于获取不到句柄无法转化为屏幕坐标,依然无解
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部