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

Project1

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

[已经解决] 全鼠标脚本有BUG

 关闭 [复制链接]

Lv1.梦旅人

℃ake

梦石
0
星屑
50
在线时间
8 小时
注册时间
2009-6-6
帖子
787
跳转到指定楼层
1
发表于 2009-8-8 15:28:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 凌辰 于 2009-8-8 20:29 编辑

作为全鼠标脚本的作者,是不是应该注意“全”鼠标脚本的BUG呢。

我都要快被你搞晕了。

我一个脚本盲,好不容易花了三个小时把Window_Target改成想要的样式了。

刷新矩形光标我是写了又写,写了好几个小时。

还是搞不定。

(光标矩形的位置呀,什么都还好搞定。但是对于全体目标、单体目标、使用者的情况我却怎么也搞不定。)

我本来还以为是我自己的问题,结果我把Window_Target还原了重新一步一步写,一步一步检查问题。

结果。

****(此句已被格林宝贝屏蔽)

我又不精通脚本,好不容易写完了我容易吗我。

结果是鼠标脚本的问题。

跟我写的都无关的。

害我重写了一遍又一遍。

害我....

你做鼠标的时候就不能细心点吗。

这么大的BUG都不知道加个判定。

本来是作用全体目标的,按任何方向键都无法移动光标的,但是把鼠标移动到Window_Target的窗口里面,也会默认作用鼠标指定的一个目标。

更可恶的是,只能对使用者本人使用的,按↑和↓都无法选择其他目标的,把鼠标移动进去也能轻而易举选择指定的其它作用目标。

这个判定难道对于你来说很难吗,怎么忽略了??

害的我。

好好检查检查吧。

检查了之后快更新。

  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.   
  22. class Game_Event
  23.   attr_accessor :flag
  24. end
  25. #==============================================================================
  26. # ■ Game_Map
  27. #------------------------------------------------------------------------------
  28. #  处理地图的类。包含卷动以及可以通行的判断功能。
  29. # 本类的实例请参考 $game_map 。
  30. #==============================================================================
  31. class Game_Map


  32.   #--------------------------------------------------------------------------
  33.   # ● 检查鼠标处是否有自定义的事件并返回类型
  34.   #--------------------------------------------------------------------------
  35.   def check_event_custom(mouse_x, mouse_y)
  36.     for event in $game_map.events.values #循环所有事件检查
  37.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / 4
  38.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 4
  39.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  40.         if event.list != nil
  41.         for i in 0...event.list.size
  42.           if event.list[i].parameters[0] == "Item" #类型判断
  43.             event.flag = 1
  44.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  45.             event.flag = 2
  46.           else
  47.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  48.           end
  49.           return event.flag #返回事件类型标志
  50.         end
  51.       end
  52.     end
  53.   end
  54.   
  55.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  56.     return $mouse_icon_id #使鼠标图不变化
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ● 检查鼠标处是否有事件可以开启
  60.   #--------------------------------------------------------------------------
  61.   def check_event_custom_start(mouse_x, mouse_y)
  62.     for event in $game_map.events.values #循环所有事件检查
  63.       #事件角色图片宽度、高度
  64.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  65.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  66.       #判断是否鼠标在事件上
  67.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  68.         way_x = $game_player.x - event.x
  69.         way_y = $game_player.y - event.y
  70.         if ([1, -1].include?($game_player.x-event.x) and $game_player.y-event.y == 0) or ([1, -1].include?($game_player.y-event.y) and $game_player.x-event.x == 0)
  71.           for i in 0...event.list.size
  72.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  73.               #判断主角朝向
  74.               if way_x == -1
  75.                 p_direction = 6 if way_y == 0
  76.               elsif way_x == 0
  77.                 p_direction = 2 if way_y == -1
  78.                 p_direction = 8 if way_y == 1
  79.               else
  80.                 p_direction = 4 if way_y == 0
  81.               end
  82.               event.start #开启事件
  83.               return 1, p_direction #返回即将开启事件以及角色朝向
  84.             end
  85.           end
  86.         end
  87.       end
  88.     end
  89.     return 0, 5 #返回不会开启事件以及角色朝向不变
  90.   end
  91.   
  92.   #--------------------------------------------------------------------------
  93.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  94.   #--------------------------------------------------------------------------
  95.   def check_event_custom_exist(mouse_x, mouse_y)
  96.     for event in $game_map.events.values #循环所有事件检查
  97.       #事件角色图片宽度、高度
  98.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  99.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  100.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  101.         for i in 0...event.list.size
  102.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  103.         end
  104.       end
  105.     end
  106.     return 0, event #返回不存在自定义事件,以及事件体
  107.   end
  108. end


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


  112. #==============================================================================
  113. # ● API调用
  114. #==============================================================================
  115. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  116. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  117. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  118. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  119. $Window_HWND = $GetActiveWindow.call
  120. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  121. module Mouse  
  122. LEFT = 0x01
  123. RIGHT = 0x02

  124. def self.init(sprite = nil)
  125.    $ShowCursor.call(0)



  126.    
  127.    @show_cursor = false
  128.    
  129.    @mouse_ani_viewport = Viewport.new(0,0,640,480)
  130.    @mouse_ani_viewport.z = 9
  131.    @mouse_ani = RPG::Sprite.new(@mouse_ani_viewport)
  132.    @mouse_ani.z = 9
  133.    @mouse_sprite = Sprite.new
  134.    @mouse_sprite.z = 99999
  135.    @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M.png')
  136.    
  137.    
  138.    $data_animations = load_data("Data/Animations.rxdata")
  139.    @mouse_wait_count = $data_animations[1].frame_max * 2
  140.    @mouse_wait = 0
  141.    @b = 1

  142.    @left_press = false
  143.    @right_press = false
  144.    @left_trigger = false
  145.    @right_trigger = false
  146.    @left_repeat = false
  147.    @right_repeat = false
  148.    @click_lock = false
  149.    
  150.    update
  151. end
  152. def self.exit
  153.    @mouse_sprite.bitmap.dispose
  154.    @mouse_sprite.dispose
  155.    @mouse_ani.dispose
  156.    @show_cursor = true
  157.    $ShowCursor.call(1)
  158. end
  159. def self.mouse_debug
  160.    return @mouse_debug.bitmap
  161. end
  162. def self.set_ani(x, y)
  163.    @ani_x = x
  164.    @ani_y = y
  165.    x -= $game_map.display_x / 4
  166.    y -= $game_map.display_y / 4
  167.    @mouse_ani.x, @mouse_ani.y = x, y
  168.    @mouse_ani.animation($data_animations[1],true)
  169.    @mouse_wait = @mouse_wait_count
  170. end
  171.   def self.update_ani
  172.    if @mouse_wait > 0
  173.      x = @ani_x
  174.      y = @ani_y
  175.      x -= $game_map.display_x / 4
  176.      y -= $game_map.display_y / 4
  177.      @mouse_ani.x, @mouse_ani.y = x, y
  178.      @mouse_ani.update
  179.      @mouse_wait -= 1
  180.    end
  181. end

  182.   
  183. def self.update
  184.    left_down = $GetKeyState.call(0x01)
  185.    right_down = $GetKeyState.call(0x02)
  186.    
  187.    if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  188.      @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  189.      @a = !@a
  190.    end

  191.    if $scene.is_a?(Scene_Map) == false
  192.      $mouse_icon_id = 0
  193.    end
  194.    if $mouse_icon_id != $mouse_icon_id_last
  195.      case $mouse_icon_id
  196.      when 1
  197.        if @a
  198.          @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/I')
  199.        else
  200.          @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/I2')
  201.        end
  202.      when 2
  203.        if @a
  204.          @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/N')
  205.        else
  206.          @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/N2')
  207.        end
  208.      when 11
  209.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M2')
  210.      when 12
  211.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M2')
  212.      when 13
  213.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M2')
  214.      when 14
  215.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M2')
  216.      when 16
  217.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M2')
  218.      when 17
  219.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M2')
  220.      when 18
  221.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M2')
  222.      when 19
  223.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M2')
  224.      when 0
  225.        @mouse_sprite.bitmap = Bitmap.new('Menu/Mouse/M')
  226.      end
  227.      $mouse_icon_id_last = $mouse_icon_id
  228.    end
  229.    @click_lock = false
  230.    mouse_x, mouse_y = self.get_mouse_pos
  231.    if @mouse_sprite != nil
  232.      @mouse_sprite.x = mouse_x
  233.      @mouse_sprite.y = mouse_y
  234.    end
  235.    if left_down[7] == 1
  236.      @left_repeat = (not @left_repeat)
  237.      @left_trigger = (not @left_press)
  238.      @left_press = true
  239.    else
  240.      @left_press = false
  241.      @left_trigger = false
  242.      @left_repeat = false
  243.    end
  244.    if right_down[7] == 1
  245.      @right_repeat = (not @right_repeat)
  246.      @right_trigger = (not @right_press)
  247.      @right_press = true
  248.    else
  249.      @right_press = false
  250.      @right_trigger = false
  251.      @right_repeat = false
  252.    end
  253. end


  254. def self.get_mouse_pos
  255.    point_var = [0, 0].pack('ll')
  256.    if $GetCursorPos.call(point_var) != 0
  257.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  258.        x, y = point_var.unpack('ll')
  259.        if (x < 0) or (x > 10000) then x = 0 end
  260.        if (y < 0) or (y > 10000) then y = 0 end
  261.        if x > 640 then x = 640 end
  262.        if y > 480 then y = 480 end
  263.        return x, y
  264.      else
  265.        return 0, 0
  266.      end
  267.    else
  268.      return 0, 0
  269.    end
  270. end
  271. def self.press?(mouse_code)
  272.    if mouse_code == LEFT
  273.      if @click_lock
  274.        return false
  275.      else
  276.        return @left_press
  277.      end
  278.    elsif mouse_code == RIGHT
  279.      return @right_press
  280.    else
  281.      return false
  282.    end
  283. end
  284. def self.trigger?(mouse_code)
  285.    if mouse_code == LEFT
  286.      if @click_lock
  287.        return false
  288.      else
  289.        return @left_trigger
  290.      end
  291.    elsif mouse_code == RIGHT
  292.      return @right_trigger
  293.    else
  294.      return false
  295.    end
  296. end
  297. def self.repeat?(mouse_code)
  298.    if mouse_code == LEFT
  299.      if @click_lock
  300.        return false
  301.      else
  302.        return @left_repeat
  303.      end
  304.    elsif mouse_code == RIGHT
  305.      return @right_repeat
  306.    else
  307.      return false
  308.    end
  309. end
  310. def self.click_lock?
  311.    return @click_lock
  312. end
  313. def self.click_lock
  314.    @click_lock = true
  315. end
  316. def self.click_unlock
  317.    @click_lock = false
  318. end
  319. end
  320. module Input
  321. if @self_update == nil
  322.    @self_update = method('update')
  323.    @self_press = method('press?')
  324.    @self_trigger = method('trigger?')
  325.    @self_repeat = method('repeat?')
  326. end
  327. def self.update
  328.    @self_update.call
  329.    Mouse.update
  330. end
  331. def self.press?(key_code)
  332.    if @self_press.call(key_code)
  333.      return true
  334.    end
  335.    if key_code == C
  336.      return Mouse.press?(Mouse::LEFT)
  337.    elsif key_code == B
  338.      return Mouse.press?(Mouse::RIGHT)
  339.    else
  340.      return @self_press.call(key_code)
  341.    end
  342. end
  343. def self.trigger?(key_code)
  344.    if @self_trigger.call(key_code)
  345.      return true
  346.    end
  347.    if key_code == C
  348.      return Mouse.trigger?(Mouse::LEFT)
  349.    elsif key_code == B
  350.      return Mouse.trigger?(Mouse::RIGHT)
  351.    else
  352.      return @self_trigger.call(key_code)
  353.    end
  354. end
  355. def self.repeat?(key_code)
  356.    if @self_repeat.call(key_code)
  357.      return true
  358.    end
  359.    if key_code == C
  360.      return Mouse.repeat?(Mouse::LEFT)
  361.    elsif key_code == B
  362.      return Mouse.repeat?(Mouse::RIGHT)
  363.    else
  364.      return @self_repeat.call(key_code)
  365.    end
  366. end
  367. end
  368. class Window_Selectable
  369. if @self_alias == nil
  370.    alias self_update update
  371.    @self_alias = true
  372. end
  373. def update
  374.    self_update
  375.    if self.active and @item_max > 0
  376.      index_var = @index
  377.      tp_index = @index
  378.      mouse_x, mouse_y = Mouse.get_mouse_pos
  379.      mouse_not_in_rect = true
  380.      for i in 0...@item_max
  381.        @index = i
  382.        update_cursor_rect
  383.        top_x = self.cursor_rect.x + self.x + 16
  384.        top_y = self.cursor_rect.y + self.y + 16
  385.        bottom_x = top_x + self.cursor_rect.width
  386.        bottom_y = top_y + self.cursor_rect.height
  387.        if (mouse_x > top_x) and (mouse_y > top_y) and
  388.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  389.          mouse_not_in_rect = false
  390.          if tp_index != @index
  391.            tp_index = @index
  392.            $game_system.se_play($data_system.cursor_se)
  393.          end
  394.          break
  395.        end
  396.      end
  397.      if mouse_not_in_rect
  398.        @index = index_var
  399.        update_cursor_rect
  400.        Mouse.click_lock
  401.      else
  402.        Mouse.click_unlock               
  403.      end
  404.    end
  405. end
  406. end
  407. class Window_NameInput
  408. if @self_alias == nil
  409.    alias self_update update
  410.    @self_alias = true
  411. end
  412. def update
  413.    self_update
  414.    if self.active
  415.      index_var = @index
  416.      mouse_x, mouse_y = Mouse.get_mouse_pos
  417.      mouse_not_in_rect = true
  418.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  419.        @index = i
  420.        update_cursor_rect
  421.        top_x = self.cursor_rect.x + self.x + 16
  422.        top_y = self.cursor_rect.y + self.y + 16
  423.        bottom_x = top_x + self.cursor_rect.width
  424.        bottom_y = top_y + self.cursor_rect.height
  425.        if (mouse_x > top_x) and (mouse_y > top_y) and
  426.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  427.          mouse_not_in_rect = false
  428.          break
  429.        end
  430.      end
  431.      if mouse_not_in_rect
  432.        @index = index_var
  433.        update_cursor_rect
  434.        Mouse.click_lock
  435.      else
  436.        Mouse.click_unlock
  437.      end
  438.    end
  439. end
  440. end
  441. class Window_InputNumber
  442. if @self_alias == nil
  443.    alias self_update update
  444.    @self_alias = true
  445. end
  446. def update
  447.    self_update
  448.    mouse_x, mouse_y = Mouse.get_mouse_pos
  449.    if self.active and @digits_max > 0
  450.      index_var = @index
  451.      mouse_not_in_rect = true
  452.      for i in 0...@digits_max
  453.        @index = i
  454.        update_cursor_rect
  455.        top_x = self.cursor_rect.x + self.x + 16
  456.        bottom_x = top_x + self.cursor_rect.width
  457.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  458.          mouse_not_in_rect = false
  459.          break
  460.        end
  461.      end
  462.      if mouse_not_in_rect
  463.        @index = index_var
  464.        update_cursor_rect
  465.        Mouse.click_lock
  466.      else
  467.        Mouse.click_unlock
  468.      end
  469.    end
  470.    if @last_mouse_y == nil
  471.      @last_mouse_y = mouse_y
  472.    end
  473.    check_pos = (@last_mouse_y - mouse_y).abs
  474.    if check_pos > 10
  475.      $game_system.se_play($data_system.cursor_se)
  476.      place = 10 ** (@digits_max - 1 - @index)
  477.      n = @number / place % 10
  478.      @number -= n * place
  479.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  480.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  481.      @number += n * place
  482.      refresh
  483.      @last_mouse_y = mouse_y
  484.    end
  485. end
  486. end
  487. class Scene_File
  488. if @self_alias == nil
  489.    alias self_update update
  490.    @self_alias = true
  491. end
  492. def update
  493.    mouse_x, mouse_y = Mouse.get_mouse_pos
  494.    Mouse.click_lock
  495.    idx = 0
  496.    for i in @savefile_windows
  497.      top_x = i.x + 16
  498.      top_y = i.y + 16
  499.      bottom_x = top_x + i.width
  500.      bottom_y = top_y + i.height
  501.      if (mouse_x > top_x) and (mouse_y > top_y) and
  502.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  503.        i.selected = true
  504.        if @file_index != idx
  505.          @file_index = idx
  506.          $game_system.se_play($data_system.cursor_se)
  507.        end            
  508.        Mouse.click_unlock
  509.      else
  510.        i.selected = false
  511.      end
  512.      idx += 1
  513.    end
  514.    self_update
  515. end
  516. end
  517. class Arrow_Enemy
  518. if @self_alias == nil
  519.    alias self_update update
  520.    @self_alias = true
  521. end
  522. def update
  523.    mouse_x, mouse_y = Mouse.get_mouse_pos
  524.    idx = 0
  525.    for i in $game_troop.enemies do
  526.      if i.exist?
  527.        top_x = i.screen_x - self.ox
  528.        top_y = i.screen_y - self.oy
  529.        bottom_x = top_x + self.src_rect.width
  530.        bottom_y = top_y + self.src_rect.height
  531.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  532.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  533.          if @index != idx
  534.            $game_system.se_play($data_system.cursor_se)
  535.            @index = idx
  536.          end
  537.        end
  538.      end
  539.      idx += 1
  540.    end
  541.    self_update
  542. end
  543. end
  544. class Arrow_Actor
  545. if @self_alias == nil
  546.    alias self_update update
  547.    @self_alias = true
  548. end
  549. def update
  550.    mouse_x, mouse_y = Mouse.get_mouse_pos
  551.    idx = 0
  552.    for i in $game_party.actors do
  553.      if i.exist?
  554.        top_x = i.screen_x - self.ox
  555.        top_y = i.screen_y - self.oy
  556.        bottom_x = top_x + self.src_rect.width
  557.        bottom_y = top_y + self.src_rect.height
  558.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  559.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  560.          if @index != idx
  561.            $game_system.se_play($data_system.cursor_se)
  562.            @index = idx
  563.          end
  564.        end
  565.      end
  566.      idx += 1
  567.    end
  568.    self_update
  569. end
  570. end
  571. #==============================================================================
  572. # ■ Game_Player
  573. #------------------------------------------------------------------------------
  574. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  575. # 本类的实例请参考 $game_player。
  576. #   鼠标控制角色的主程序
  577. #==============================================================================
  578. class Game_Player
  579. if @self_alias == nil
  580.    alias self_update update
  581.    @self_alias = true
  582. end
  583. #--------------------------------------------------------------------------
  584. # ● 得到鼠标的状态
  585. #--------------------------------------------------------------------------
  586. def get_mouse_sta
  587.    return @mouse_sta
  588. end
  589. #--------------------------------------------------------------------------
  590. # ● 完整鼠标系统
  591. #--------------------------------------------------------------------------
  592. def update
  593.    mouse_x, mouse_y = Mouse.get_mouse_pos
  594.    @mtp_x = mouse_x
  595.    @mtp_y = mouse_y
  596.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  597.      #得到鼠标图标方向
  598.      $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)
  599.    else
  600.      #令鼠标图标为正常
  601.      $mouse_icon_id = 0 if @mouse_sta != 2
  602.    end
  603.    
  604.    
  605.    
  606.    

  607.   
  608.    #单击鼠标时进行判断寻路或跟随
  609.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  610.      unless $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing
  611.             unless  mouse_x > 500 and mouse_x < 560 and mouse_y > 0 and mouse_y < 60
  612.               unless mouse_x > 355 and mouse_x < 640 and mouse_y > 429 and mouse_y < 480#各种无效情况的排除
  613.        #初始化
  614.        @mouse_sta = 1
  615.        p_direction = 5
  616.        #检查鼠标处能否开启事件
  617.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  618.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  619.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  620.        if @mouse_sta != 2
  621.          #鼠标状态不为跟随状态则取数据并初始化路径
  622.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  623.          trg_y = (mouse_y + $game_map.display_y  / 4) / 32
  624.          @paths = []
  625.          @paths_id = 0
  626.          if event_start == 0 #若不能开启事件
  627.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  628.              find_path = Find_Path.new
  629.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  630.              end
  631.            else #若能开启事件则改变角色朝向
  632.            @direction = p_direction
  633.          end
  634.        end
  635.      end
  636.    end
  637. end
  638. end



  639.    #开始移动
  640.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  641.      unless moving? or $game_system.map_interpreter.running? or
  642.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  643.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  644.          case @paths[@paths_id] #判断路径
  645.          when 6
  646.            @last_move_x = true
  647.            move_right
  648.            @paths_id += 1
  649.            @direction = 6
  650.          when 4
  651.            @last_move_x = true
  652.            move_left
  653.            @paths_id += 1
  654.            @direction = 4
  655.          when 2
  656.            @last_move_x = false
  657.            move_down
  658.            @direction = 2
  659.            @paths_id += 1
  660.          when 8
  661.            @last_move_x = false
  662.            move_up
  663.            @direction = 8
  664.            @paths_id += 1
  665.          end
  666.        end
  667.      end
  668.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  669.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  670.        unless moving? or $game_system.map_interpreter.running? or
  671.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  672.          #跟随方向判断并跟随
  673.       
  674.          if @mtp_x > self.screen_x
  675.            if @mtp_y - self.screen_y > - ( @mtp_x - self.screen_x ) and
  676.               @mtp_y - self.screen_y < @mtp_x - self.screen_x
  677.              move_right
  678.              $mouse_icon_id = 16
  679.              @direction = 6
  680.            end
  681.            if @mtp_y - self.screen_y > @mtp_x - self.screen_x
  682.              move_down
  683.              $mouse_icon_id = 12
  684.              @direction = 2
  685.            end
  686.            if @mtp_y - self.screen_y < - ( @mtp_x - self.screen_x )
  687.              move_up
  688.              $mouse_icon_id = 18
  689.              @direction = 8
  690.            end
  691.          end
  692.          if @mtp_x < self.screen_x
  693.            if @mtp_y - self.screen_y > - ( self.screen_x - @mtp_x ) and
  694.               @mtp_y - self.screen_y < self.screen_x - @mtp_x
  695.              move_left
  696.              $mouse_icon_id = 14
  697.              @direction = 4
  698.            end
  699.            if @mtp_y - self.screen_y > self.screen_x - @mtp_x
  700.              move_down
  701.              $mouse_icon_id = 12
  702.              @direction = 2
  703.            end
  704.            if @mtp_y - self.screen_y < - ( self.screen_x - @mtp_x )
  705.              move_up
  706.              $mouse_icon_id = 18
  707.              @direction = 8
  708.            end
  709.          end
  710.        end
  711.      else #没状态的情况
  712.        $mouse_icon_id = 0
  713.        @mouse_sta = 0
  714.        @paths_id = @paths.size #终止寻路移动
  715.      end
  716.    end

  717.    
  718.    
  719.    
  720.    
  721.    
  722. self_update
  723. end
  724. end


  725. Mouse.init
  726. END { Mouse.exit }


复制代码
我爱66RPG,但我讨厌66.

Lv1.梦旅人

梦石
0
星屑
50
在线时间
128 小时
注册时间
2009-1-28
帖子
2790
2
发表于 2009-8-8 15:31:08 | 只看该作者
这种事应该直接用短信息PM作者.....

作者不一定会看到这个帖子,而且对其他回答者也不公平

炼金术的根本法则是等价交换。想要获得,必须失去同等价值的东西。每当烦躁的时候,煎熬在不想做却又正在做的烦心事中的时候,我就安慰自己,提醒自己做这些事情的目的所在,告诉自己不要忽略所获得或者即将获得的回报,物质的,精神的,肉体的,灵魂的回报!只做想做的事情,就会失去不想失去的东西。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

℃ake

梦石
0
星屑
50
在线时间
8 小时
注册时间
2009-6-6
帖子
787
3
 楼主| 发表于 2009-8-8 15:34:34 | 只看该作者
这种事应该直接用短信息PM作者.....

作者不一定会看到这个帖子,而且对其他回答者也不公平
霜冻之狼 发表于 2009-8-8 15:31


呃,知道了,谢谢。
我爱66RPG,但我讨厌66.
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
84
在线时间
156 小时
注册时间
2009-8-5
帖子
533
4
发表于 2009-8-8 15:36:33 | 只看该作者
  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.   #--------------------------------------------------------------------------
  32.   # ● 检查鼠标处是否有自定义的事件并返回类型
  33.   #--------------------------------------------------------------------------
  34.   def check_event_custom(mouse_x, mouse_y)
  35.     for event in $game_map.events.values #循环所有事件检查
  36.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / 4
  37.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 4
  38.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  39.         for i in 0...event.list.size
  40.           if event.list[i].parameters[0] == "Item" #类型判断
  41.             event.flag = 1
  42.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  43.             event.flag = 2
  44.           else
  45.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  46.           end
  47.           return event.flag #返回事件类型标志
  48.         end
  49.       end
  50.     end
  51.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  52.     return $mouse_icon_id #使鼠标图不变化
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 检查鼠标处是否有事件可以开启
  56.   #--------------------------------------------------------------------------
  57.   def check_event_custom_start(mouse_x, mouse_y)
  58.     for event in $game_map.events.values #循环所有事件检查
  59.       #事件角色图片宽度、高度
  60.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  61.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  62.       #判断是否鼠标在事件上
  63.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  64.         way_x = $game_player.x - event.x
  65.         way_y = $game_player.y - event.y
  66.         if ([1, -1].include?($game_player.x-event.x) and $game_player.y-event.y == 0) or ([1, -1].include?($game_player.y-event.y) and $game_player.x-event.x == 0)
  67.           for i in 0...event.list.size
  68.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  69.               #判断主角朝向
  70.               if way_x == -1
  71.                 p_direction = 6 if way_y == 0
  72.               elsif way_x == 0
  73.                 p_direction = 2 if way_y == -1
  74.                 p_direction = 8 if way_y == 1
  75.               else
  76.                 p_direction = 4 if way_y == 0
  77.               end
  78.               event.start #开启事件
  79.               return 1, p_direction #返回即将开启事件以及角色朝向
  80.             end
  81.           end
  82.         end
  83.       end
  84.     end
  85.     return 0, 5 #返回不会开启事件以及角色朝向不变
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  89.   #--------------------------------------------------------------------------
  90.   def check_event_custom_exist(mouse_x, mouse_y)
  91.     for event in $game_map.events.values #循环所有事件检查
  92.       #事件角色图片宽度、高度
  93.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  94.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  95.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  96.         for i in 0...event.list.size
  97.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  98.         end
  99.       end
  100.     end
  101.     return 0, event #返回不存在自定义事件,以及事件体
  102.   end
  103. end


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


  107. #==============================================================================
  108. # ● API调用
  109. #==============================================================================
  110. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  111. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  112. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  113. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  114. $Window_HWND = $GetActiveWindow.call
  115. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  116. module Mouse  
  117. LEFT = 0x01
  118. RIGHT = 0x02

  119. def self.init(sprite = nil)
  120.    $ShowCursor.call(0)
  121.    
  122.    @show_cursor = false
  123.    
  124.    @mouse_sprite = Sprite.new
  125.    @mouse_sprite.z = 99999
  126.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/001-Weapon01.png')

  127.    @left_press = false
  128.    @right_press = false
  129.    @left_trigger = false
  130.    @right_trigger = false
  131.    @left_repeat = false
  132.    @right_repeat = false
  133.    @click_lock = false
  134.    
  135.    update
  136. end
  137. def self.exit
  138.    @mouse_sprite.bitmap.dispose
  139.    @mouse_sprite.dispose
  140.    @show_cursor = true
  141.    $ShowCursor.call(1)
  142. end
  143. def self.mouse_debug
  144.    return @mouse_debug.bitmap
  145. end
  146. def self.update
  147.    left_down = $GetKeyState.call(0x01)
  148.    right_down = $GetKeyState.call(0x02)
  149.    if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  150.      @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  151.      @a = !@a
  152.    end
  153.    if $scene.is_a?(Scene_Map) == false
  154.      $mouse_icon_id = 0
  155.    end
  156.    if $mouse_icon_id != $mouse_icon_id_last
  157.      case $mouse_icon_id
  158.      when 1
  159.        if @a
  160.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
  161.        else
  162.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
  163.        end
  164.      when 2
  165.        if @a
  166.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
  167.        else
  168.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
  169.        end
  170.      when 11
  171.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
  172.      when 12
  173.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
  174.      when 13
  175.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
  176.      when 14
  177.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
  178.      when 16
  179.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
  180.      when 17
  181.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
  182.      when 18
  183.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
  184.      when 19
  185.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
  186.      when 0
  187.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑')
  188.      end
  189.      $mouse_icon_id_last = $mouse_icon_id
  190.    end
  191.    @click_lock = false
  192.    mouse_x, mouse_y = self.get_mouse_pos
  193.    if @mouse_sprite != nil
  194.      @mouse_sprite.x = mouse_x
  195.      @mouse_sprite.y = mouse_y
  196.    end
  197.    if left_down[7] == 1
  198.      @left_repeat = (not @left_repeat)
  199.      @left_trigger = (not @left_press)
  200.      @left_press = true
  201.    else
  202.      @left_press = false
  203.      @left_trigger = false
  204.      @left_repeat = false
  205.    end
  206.    if right_down[7] == 1
  207.      @right_repeat = (not @right_repeat)
  208.      @right_trigger = (not @right_press)
  209.      @right_press = true
  210.    else
  211.      @right_press = false
  212.      @right_trigger = false
  213.      @right_repeat = false
  214.    end
  215. end
  216. def self.get_mouse_pos
  217.    point_var = [0, 0].pack('ll')
  218.    if $GetCursorPos.call(point_var) != 0
  219.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  220.        x, y = point_var.unpack('ll')
  221.        if (x < 0) or (x > 10000) then x = 0 end
  222.        if (y < 0) or (y > 10000) then y = 0 end
  223.        if x > 640 then x = 640 end
  224.        if y > 480 then y = 480 end
  225.        return x, y
  226.      else
  227.        return 0, 0
  228.      end
  229.    else
  230.      return 0, 0
  231.    end
  232. end
  233. def self.press?(mouse_code)
  234.    if mouse_code == LEFT
  235.      if @click_lock
  236.        return false
  237.      else
  238.        return @left_press
  239.      end
  240.    elsif mouse_code == RIGHT
  241.      return @right_press
  242.    else
  243.      return false
  244.    end
  245. end
  246. def self.trigger?(mouse_code)
  247.    if mouse_code == LEFT
  248.      if @click_lock
  249.        return false
  250.      else
  251.        return @left_trigger
  252.      end
  253.    elsif mouse_code == RIGHT
  254.      return @right_trigger
  255.    else
  256.      return false
  257.    end
  258. end
  259. def self.repeat?(mouse_code)
  260.    if mouse_code == LEFT
  261.      if @click_lock
  262.        return false
  263.      else
  264.        return @left_repeat
  265.      end
  266.    elsif mouse_code == RIGHT
  267.      return @right_repeat
  268.    else
  269.      return false
  270.    end
  271. end
  272. def self.click_lock?
  273.    return @click_lock
  274. end
  275. def self.click_lock
  276.    @click_lock = true
  277. end
  278. def self.click_unlock
  279.    @click_lock = false
  280. end
  281. end
  282. module Input
  283. if @self_update == nil
  284.    @self_update = method('update')
  285.    @self_press = method('press?')
  286.    @self_trigger = method('trigger?')
  287.    @self_repeat = method('repeat?')
  288. end
  289. def self.update
  290.    @self_update.call
  291.    Mouse.update
  292. end
  293. def self.press?(key_code)
  294.    if @self_press.call(key_code)
  295.      return true
  296.    end
  297.    if key_code == C
  298.      return Mouse.press?(Mouse::LEFT)
  299.    elsif key_code == B
  300.      return Mouse.press?(Mouse::RIGHT)
  301.    else
  302.      return @self_press.call(key_code)
  303.    end
  304. end
  305. def self.trigger?(key_code)
  306.    if @self_trigger.call(key_code)
  307.      return true
  308.    end
  309.    if key_code == C
  310.      return Mouse.trigger?(Mouse::LEFT)
  311.    elsif key_code == B
  312.      return Mouse.trigger?(Mouse::RIGHT)
  313.    else
  314.      return @self_trigger.call(key_code)
  315.    end
  316. end
  317. def self.repeat?(key_code)
  318.    if @self_repeat.call(key_code)
  319.      return true
  320.    end
  321.    if key_code == C
  322.      return Mouse.repeat?(Mouse::LEFT)
  323.    elsif key_code == B
  324.      return Mouse.repeat?(Mouse::RIGHT)
  325.    else
  326.      return @self_repeat.call(key_code)
  327.    end
  328. end
  329. end
  330. class Window_Selectable
  331. if @self_alias == nil
  332.    alias self_update update
  333.    @self_alias = true
  334. end
  335. def update
  336.    self_update
  337.    if self.active and @item_max > 0
  338.      index_var = @index
  339.      tp_index = @index
  340.      mouse_x, mouse_y = Mouse.get_mouse_pos
  341.      mouse_not_in_rect = true
  342.      for i in 0...@item_max
  343.        @index = i
  344.        update_cursor_rect
  345.        top_x = self.cursor_rect.x + self.x + 16
  346.        top_y = self.cursor_rect.y + self.y + 16
  347.        bottom_x = top_x + self.cursor_rect.width
  348.        bottom_y = top_y + self.cursor_rect.height
  349.        if (mouse_x > top_x) and (mouse_y > top_y) and
  350.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  351.          mouse_not_in_rect = false
  352.          if tp_index != @index
  353.            tp_index = @index
  354.            $game_system.se_play($data_system.cursor_se)
  355.          end
  356.          break
  357.        end
  358.      end
  359.      if mouse_not_in_rect
  360.        @index = index_var
  361.        update_cursor_rect
  362.        Mouse.click_lock
  363.      else
  364.        Mouse.click_unlock               
  365.      end
  366.    end
  367. end
  368. end
  369. class Window_NameInput
  370. if @self_alias == nil
  371.    alias self_update update
  372.    @self_alias = true
  373. end
  374. def update
  375.    self_update
  376.    if self.active
  377.      index_var = @index
  378.      mouse_x, mouse_y = Mouse.get_mouse_pos
  379.      mouse_not_in_rect = true
  380.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  381.        @index = i
  382.        update_cursor_rect
  383.        top_x = self.cursor_rect.x + self.x + 16
  384.        top_y = self.cursor_rect.y + self.y + 16
  385.        bottom_x = top_x + self.cursor_rect.width
  386.        bottom_y = top_y + self.cursor_rect.height
  387.        if (mouse_x > top_x) and (mouse_y > top_y) and
  388.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  389.          mouse_not_in_rect = false
  390.          break
  391.        end
  392.      end
  393.      if mouse_not_in_rect
  394.        @index = index_var
  395.        update_cursor_rect
  396.        Mouse.click_lock
  397.      else
  398.        Mouse.click_unlock
  399.      end
  400.    end
  401. end
  402. end
  403. class Window_InputNumber
  404. if @self_alias == nil
  405.    alias self_update update
  406.    @self_alias = true
  407. end
  408. def update
  409.    self_update
  410.    mouse_x, mouse_y = Mouse.get_mouse_pos
  411.    if self.active and @digits_max > 0
  412.      index_var = @index
  413.      mouse_not_in_rect = true
  414.      for i in 0...@digits_max
  415.        @index = i
  416.        update_cursor_rect
  417.        top_x = self.cursor_rect.x + self.x + 16
  418.        bottom_x = top_x + self.cursor_rect.width
  419.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  420.          mouse_not_in_rect = false
  421.          break
  422.        end
  423.      end
  424.      if mouse_not_in_rect
  425.        @index = index_var
  426.        update_cursor_rect
  427.        Mouse.click_lock
  428.      else
  429.        Mouse.click_unlock
  430.      end
  431.    end
  432.    if @last_mouse_y == nil
  433.      @last_mouse_y = mouse_y
  434.    end
  435.    check_pos = (@last_mouse_y - mouse_y).abs
  436.    if check_pos > 10
  437.      $game_system.se_play($data_system.cursor_se)
  438.      place = 10 ** (@digits_max - 1 - @index)
  439.      n = @number / place % 10
  440.      @number -= n * place
  441.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  442.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  443.      @number += n * place
  444.      refresh
  445.      @last_mouse_y = mouse_y
  446.    end
  447. end
  448. end
  449. class Scene_File
  450. if @self_alias == nil
  451.    alias self_update update
  452.    @self_alias = true
  453. end
  454. def update
  455.    mouse_x, mouse_y = Mouse.get_mouse_pos
  456.    Mouse.click_lock
  457.    idx = 0
  458.    for i in @savefile_windows
  459.      top_x = i.x + 16
  460.      top_y = i.y + 16
  461.      bottom_x = top_x + i.width
  462.      bottom_y = top_y + i.height
  463.      if (mouse_x > top_x) and (mouse_y > top_y) and
  464.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  465.        i.selected = true
  466.        if @file_index != idx
  467.          @file_index = idx
  468.          $game_system.se_play($data_system.cursor_se)
  469.        end            
  470.        Mouse.click_unlock
  471.      else
  472.        i.selected = false
  473.      end
  474.      idx += 1
  475.    end
  476.    self_update
  477. end
  478. end
  479. class Arrow_Enemy
  480. if @self_alias == nil
  481.    alias self_update update
  482.    @self_alias = true
  483. end
  484. def update
  485.    mouse_x, mouse_y = Mouse.get_mouse_pos
  486.    idx = 0
  487.    for i in $game_troop.enemies do
  488.      if i.exist?
  489.        top_x = i.screen_x - self.ox
  490.        top_y = i.screen_y - self.oy
  491.        bottom_x = top_x + self.src_rect.width
  492.        bottom_y = top_y + self.src_rect.height
  493.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  494.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  495.          if @index != idx
  496.            $game_system.se_play($data_system.cursor_se)
  497.            @index = idx
  498.          end
  499.        end
  500.      end
  501.      idx += 1
  502.    end
  503.    self_update
  504. end
  505. end
  506. class Arrow_Actor
  507. if @self_alias == nil
  508.    alias self_update update
  509.    @self_alias = true
  510. end
  511. def update
  512.    mouse_x, mouse_y = Mouse.get_mouse_pos
  513.    idx = 0
  514.    for i in $game_party.actors do
  515.      if i.exist?
  516.        top_x = i.screen_x - self.ox
  517.        top_y = i.screen_y - self.oy
  518.        bottom_x = top_x + self.src_rect.width
  519.        bottom_y = top_y + self.src_rect.height
  520.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  521.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  522.          if @index != idx
  523.            $game_system.se_play($data_system.cursor_se)
  524.            @index = idx
  525.          end
  526.        end
  527.      end
  528.      idx += 1
  529.    end
  530.    self_update
  531. end
  532. end
  533. #==============================================================================
  534. # ■ Game_Player
  535. #------------------------------------------------------------------------------
  536. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  537. # 本类的实例请参考 $game_player。
  538. #   鼠标控制角色的主程序
  539. #==============================================================================
  540. class Game_Player
  541. if @self_alias == nil
  542.    alias self_update update
  543.    @self_alias = true
  544. end
  545. #--------------------------------------------------------------------------
  546. # ● 得到鼠标的状态
  547. #--------------------------------------------------------------------------
  548. def get_mouse_sta
  549.    return @mouse_sta
  550. end
  551. #--------------------------------------------------------------------------
  552. # ● 完整鼠标系统
  553. #--------------------------------------------------------------------------
  554. def update
  555.    mouse_x, mouse_y = Mouse.get_mouse_pos
  556.    @mtp_x = mouse_x
  557.    @mtp_y = mouse_y
  558.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  559.      #得到鼠标图标方向
  560.      $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)
  561.    else
  562.      #令鼠标图标为正常
  563.      $mouse_icon_id = 0 if @mouse_sta != 2
  564.    end
  565.    
  566.    #单击鼠标时进行判断寻路或跟随
  567.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  568.      unless $game_system.map_interpreter.running? or
  569.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  570.        #初始化
  571.        @mouse_sta = 1
  572.        p_direction = 5
  573.        #检查鼠标处能否开启事件
  574.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  575.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  576.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  577.        if @mouse_sta != 2
  578.          #鼠标状态不为跟随状态则取数据并初始化路径
  579.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  580.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  581.          @paths = []
  582.          @paths_id = 0
  583.          if event_start == 0 #若不能开启事件
  584.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  585.              find_path = Find_Path.new
  586.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  587.            end
  588.          else #若能开启事件则改变角色朝向
  589.            @direction = p_direction
  590.          end
  591.        end
  592.      end
  593.    end

  594.    #开始移动
  595.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  596.      unless moving? or $game_system.map_interpreter.running? or
  597.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  598.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  599.          case @paths[@paths_id] #判断路径
  600.          when 6
  601.            @last_move_x = true
  602.            move_right
  603.            @paths_id += 1
  604.            @direction = 6
  605.          when 4
  606.            @last_move_x = true
  607.            move_left
  608.            @paths_id += 1
  609.            @direction = 4
  610.          when 2
  611.            @last_move_x = false
  612.            move_down
  613.            @direction = 2
  614.            @paths_id += 1
  615.          when 8
  616.            @last_move_x = false
  617.            move_up
  618.            @direction = 8
  619.            @paths_id += 1
  620.          end
  621.        end
  622.      end
  623.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  624.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  625.        unless moving? or $game_system.map_interpreter.running? or
  626.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  627.          #跟随方向判断并跟随
  628.          if @mtp_x > self.screen_x
  629.            if @mtp_y - self.screen_y > - ( @mtp_x - self.screen_x ) and
  630.               @mtp_y - self.screen_y < @mtp_x - self.screen_x
  631.              move_right
  632.              $mouse_icon_id = 16
  633.              @direction = 6
  634.            end
  635.            if @mtp_y - self.screen_y > @mtp_x - self.screen_x
  636.              move_down
  637.              $mouse_icon_id = 12
  638.              @direction = 2
  639.            end
  640.            if @mtp_y - self.screen_y < - ( @mtp_x - self.screen_x )
  641.              move_up
  642.              $mouse_icon_id = 18
  643.              @direction = 8
  644.            end
  645.          end
  646.          if @mtp_x < self.screen_x
  647.            if @mtp_y - self.screen_y > - ( self.screen_x - @mtp_x ) and
  648.               @mtp_y - self.screen_y < self.screen_x - @mtp_x
  649.              move_left
  650.              $mouse_icon_id = 14
  651.              @direction = 4
  652.            end
  653.            if @mtp_y - self.screen_y > self.screen_x - @mtp_x
  654.              move_down
  655.              $mouse_icon_id = 12
  656.              @direction = 2
  657.            end
  658.            if @mtp_y - self.screen_y < - ( self.screen_x - @mtp_x )
  659.              move_up
  660.              $mouse_icon_id = 18
  661.              @direction = 8
  662.            end
  663.          end
  664.        end
  665.      else #没状态的情况
  666.        $mouse_icon_id = 0
  667.        @mouse_sta = 0
  668.        @paths_id = @paths.size #终止寻路移动
  669.      end
  670.    end
  671. self_update
  672. end
  673. end
  674. Mouse.init
  675. END { Mouse.exit }
复制代码
一样不一样我不知道,,,你试试
回复 支持 反对

使用道具 举报

Lv1.梦旅人

℃ake

梦石
0
星屑
50
在线时间
8 小时
注册时间
2009-6-6
帖子
787
5
 楼主| 发表于 2009-8-8 15:58:25 | 只看该作者
#==============================================================================
# ■ 完整鼠标系统(四方向)
#------------------------------------------------------------------------------
#  使用时务必 ...
传说中di 发表于 2009-8-8 15:36


嗯,一样的,就是这个。
难道您没出现过相同的问题吗?
就是在使用目标为全体或使用者自己的特技或者物品的时候召唤出Window_Target的时候鼠标放进框框里会无视目标,可以任意选择。
我爱66RPG,但我讨厌66.
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
84
在线时间
156 小时
注册时间
2009-8-5
帖子
533
6
发表于 2009-8-8 16:31:54 | 只看该作者
试了下,..真的如您所说的那样..........
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 17:08

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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