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

Project1

 找回密码
 注册会员
搜索
查看: 813|回复: 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.梦旅人

℃ake

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

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


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

使用道具 举报

Lv1.梦旅人

℃ake

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


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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-6-10 12:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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