查看: 2117|回复: 10

[已经解决] 鼠标在物品栏失效

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

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

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

×
给物品分类里面装了个鼠标脚本,鼠标竟然失效了,鼠标放到默认的工程里,在物品是可以用的,请大佬帮忙看下,

1.png

完整鼠标系统(八方向)V2.0.rar (515.91 KB, 下载次数: 15)
梦石
0
星屑
1748
在线时间
485 小时
注册时间
2006-1-7
回帖
996
发表于 2022-4-19 01:21:52 | 显示全部楼层
本帖最后由 白鬼 于 2022-4-19 01:35 编辑

因为你的分类窗口和物品列表窗口重新定义了选择窗口的内容,且重新命名了。但是鼠标脚本里没有对新命名的选择窗口进行支持。


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

#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  处理地图的类。包含卷动以及可以通行的判断功能。
# 本类的实例请参考 $game_map 。
#==============================================================================
class Game_Map
  def show_rate(event)
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 检查鼠标处是否有自定义的事件并返回类型
  #--------------------------------------------------------------------------
  def check_event_custom(mouse_x, mouse_y)
    for event in $game_map.events.values #循环所有事件检查
      rate =  show_rate(event)
      event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
      event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / 8) * rate
      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
        for i in 0...event.list.size
          if event.list.parameters[0] == "Item" #类型判断
            event.flag = 1
          elsif event.list.parameters[0] == "Npc" #类型判断
            event.flag = 2
          else
            event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
          end
          return event.flag #返回事件类型标志
        end
      end
    end
    return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
    return $mouse_icon_id #使鼠标图不变化
  end
  #--------------------------------------------------------------------------
  # ● 检查鼠标处是否有事件可以开启
  #--------------------------------------------------------------------------
  def check_event_custom_start(mouse_x, mouse_y)
    for event in $game_map.events.values #循环所有事件检查
      #事件角色图片宽度、高度
      rate =  show_rate(event)
      event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
      event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / 8) * rate
      #判断是否鼠标在事件上
      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
        way_x = $game_player.x - event.x
        way_y = $game_player.y - event.y
        if [1,0,-1].include?($game_player.x-event.x) and [1,0,-1].include?($game_player.y-event.y)
          for i in 0...event.list.size
            if ["Item","Npc"].include?(event.list.parameters[0]) #当事件属于自定义事件
              #判断主角朝向
              if way_x == -1
                p_direction = 3 if way_y == -1
                p_direction = 6 if way_y == 0
                p_direction = 9 if way_y == 1
              elsif way_x == 0
                p_direction = 2 if way_y == -1
                p_direction = 8 if way_y == 1
              else
                p_direction = 1 if way_y == -1
                p_direction = 4 if way_y == 0
                p_direction = 7 if way_y == 1
              end
              event.start #开启事件
              return 1, p_direction #返回即将开启事件以及角色朝向
            end
          end
        end
      end
    end
    return 0, 5 #返回不会开启事件以及角色朝向不变
  end
  #--------------------------------------------------------------------------
  # ● 检查鼠标处是否存在自定义事件 for 寻路
  #--------------------------------------------------------------------------
  def check_event_custom_exist(mouse_x, mouse_y)
    for event in $game_map.events.values #循环所有事件检查
      #事件角色图片宽度、高度
      rate =  show_rate(event)
      event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
      event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / 8) * rate
      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
        for i in 0...event.list.size
          return 1, event if ["Item", "Npc"].include?(event.list.parameters[0]) #返回存在自定义事件以及事件体
        end
      end
    end
    return 0, event #返回不存在自定义事件,以及事件体
  end
end
#=================以下两个用来调整战斗时的手感问题,可以自己试试。
$敌人选框扩大 = 20
$角色选框扩大 = 30


#==============================================================================
# ● API调用
#==============================================================================
$ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
$GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
$ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
$GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
$Window_HWND = $GetActiveWindow.call
$GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
module Mouse  
LEFT = 0x01
RIGHT = 0x02

def self.init(sprite = nil)
   $ShowCursor.call(0)
   
   @show_cursor = false
   
   @mouse_sprite = Sprite.new
   @mouse_sprite.z = 99999
   @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑')

   @left_press = false
   @right_press = false
   @left_trigger = false
   @right_trigger = false
   @left_repeat = false
   @right_repeat = false
   @click_lock = false
   
   update
end
def self.exit
   @mouse_sprite.bitmap.dispose
   @mouse_sprite.dispose
   @show_cursor = true
   $ShowCursor.call(1)
end
def self.mouse_debug
   return @mouse_debug.bitmap
end
def self.update
   left_down = $GetKeyState.call(0x01)
   right_down = $GetKeyState.call(0x02)
   if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
     @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
     @a = !@a
   end
   if $scene.is_a?(Scene_Map) == false
     $mouse_icon_id = 0
   end
   if $mouse_icon_id != $mouse_icon_id_last
     case $mouse_icon_id
     when 1
       if @a
         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
       else
         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
       end
     when 2
       if @a
         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
       else
         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
       end
     when 11
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
     when 12
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
     when 13
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
     when 14
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
     when 16
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
     when 17
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
     when 18
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
     when 19
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
     when 0
       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑')
     end
     $mouse_icon_id_last = $mouse_icon_id
   end
   @click_lock = false
   mouse_x, mouse_y = self.get_mouse_pos
   if @mouse_sprite != nil
     @mouse_sprite.x = mouse_x
     @mouse_sprite.y = mouse_y
   end
   if left_down[7] == 1
     @left_repeat = (not @left_repeat)
     @left_trigger = (not @left_press)
     @left_press = true
   else
     @left_press = false
     @left_trigger = false
     @left_repeat = false
   end
   if right_down[7] == 1
     @right_repeat = (not @right_repeat)
     @right_trigger = (not @right_press)
     @right_press = true
   else
     @right_press = false
     @right_trigger = false
     @right_repeat = false
   end
end
def self.get_mouse_pos
   point_var = [0, 0].pack('ll')
   if $GetCursorPos.call(point_var) != 0
     if $ScreenToClient.call($Window_HWND, point_var) != 0
       x, y = point_var.unpack('ll')
       if (x < 0) or (x > 10000) then x = 0 end
       if (y < 0) or (y > 10000) then y = 0 end
       if x > 640 then x = 640 end
       if y > 480 then y = 480 end
       return x, y
     else
       return 0, 0
     end
   else
     return 0, 0
   end
end
def self.press?(mouse_code)
   if mouse_code == LEFT
     if @click_lock
       return false
     else
       return @left_press
     end
   elsif mouse_code == RIGHT
     return @right_press
   else
     return false
   end
end
def self.trigger?(mouse_code)
   if mouse_code == LEFT
     if @click_lock
       return false
     else
       return @left_trigger
     end
   elsif mouse_code == RIGHT
     return @right_trigger
   else
     return false
   end
end
def self.repeat?(mouse_code)
   if mouse_code == LEFT
     if @click_lock
       return false
     else
       return @left_repeat
     end
   elsif mouse_code == RIGHT
     return @right_repeat
   else
     return false
   end
end
def self.click_lock?
   return @click_lock
end
def self.click_lock
   @click_lock = true
end
def self.click_unlock
   @click_lock = false
end
end
module Input
if @self_update == nil
   @self_update = method('update')
   @self_press = method('press?')
   @self_trigger = method('trigger?')
   @self_repeat = method('repeat?')
end
def self.update
   @self_update.call
   Mouse.update
end
def self.press?(key_code)
   if @self_press.call(key_code)
     return true
   end
   if key_code == C
     return Mouse.press?(Mouse::LEFT)
   elsif key_code == B
     return Mouse.press?(Mouse::RIGHT)
   else
     return @self_press.call(key_code)
   end
end
def self.trigger?(key_code)
   if @self_trigger.call(key_code)
     return true
   end
   if key_code == C
     return Mouse.trigger?(Mouse::LEFT)
   elsif key_code == B
     return Mouse.trigger?(Mouse::RIGHT)
   else
     return @self_trigger.call(key_code)
   end
end
def self.repeat?(key_code)
   if @self_repeat.call(key_code)
     return true
   end
   if key_code == C
     return Mouse.repeat?(Mouse::LEFT)
   elsif key_code == B
     return Mouse.repeat?(Mouse::RIGHT)
   else
     return @self_repeat.call(key_code)
   end
end
end
class Window_Selectable
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   self_update
   if self.active and @item_max > 0
     index_var = @index
     tp_index = @index
     mouse_x, mouse_y = Mouse.get_mouse_pos
     mouse_not_in_rect = true
     for i in 0...@item_max
       @index = i
       update_cursor_rect
       top_x = self.cursor_rect.x + self.x + 16
       top_y = self.cursor_rect.y + self.y + 16
       bottom_x = top_x + self.cursor_rect.width
       bottom_y = top_y + self.cursor_rect.height
       if (mouse_x > top_x) and (mouse_y > top_y) and
          (mouse_x < bottom_x) and (mouse_y < bottom_y)
         mouse_not_in_rect = false
         if tp_index != @index
           tp_index = @index
           $game_system.se_play($data_system.cursor_se)
         end
         break
       end
     end
     if mouse_not_in_rect
       @index = index_var
       update_cursor_rect
       Mouse.click_lock
     else
       Mouse.click_unlock               
     end
   end
end
end
##########################################################
class Window_Selectable_Item
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   self_update
   if self.active and @item_max > 0
     index_var = @index
     tp_index = @index
     mouse_x, mouse_y = Mouse.get_mouse_pos
     mouse_not_in_rect = true
     for i in 0...@item_max
       @index = i
       update_cursor_rect
       top_x = self.cursor_rect.x + self.x + 16
       top_y = self.cursor_rect.y + self.y + 16
       bottom_x = top_x + self.cursor_rect.width
       bottom_y = top_y + self.cursor_rect.height
       if (mouse_x > top_x) and (mouse_y > top_y) and
          (mouse_x < bottom_x) and (mouse_y < bottom_y)
         mouse_not_in_rect = false
         if tp_index != @index
           tp_index = @index
           $game_system.se_play($data_system.cursor_se)
         end
         break
       end
     end
     if mouse_not_in_rect
       @index = index_var
       update_cursor_rect
       Mouse.click_lock
     else
       Mouse.click_unlock               
     end
   end
end
end
####################################################################
class Window_NameInput
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   self_update
   if self.active
     index_var = @index
     mouse_x, mouse_y = Mouse.get_mouse_pos
     mouse_not_in_rect = true
     for i in (0...CHARACTER_TABLE.size).to_a.push(180)
       @index = i
       update_cursor_rect
       top_x = self.cursor_rect.x + self.x + 16
       top_y = self.cursor_rect.y + self.y + 16
       bottom_x = top_x + self.cursor_rect.width
       bottom_y = top_y + self.cursor_rect.height
       if (mouse_x > top_x) and (mouse_y > top_y) and
          (mouse_x < bottom_x) and (mouse_y < bottom_y)
         mouse_not_in_rect = false
         break
       end
     end
     if mouse_not_in_rect
       @index = index_var
       update_cursor_rect
       Mouse.click_lock
     else
       Mouse.click_unlock
     end
   end
end
end
class Window_InputNumber
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   self_update
   mouse_x, mouse_y = Mouse.get_mouse_pos
   if self.active and @digits_max > 0
     index_var = @index
     mouse_not_in_rect = true
     for i in 0...@digits_max
       @index = i
       update_cursor_rect
       top_x = self.cursor_rect.x + self.x + 16
       bottom_x = top_x + self.cursor_rect.width
       if (mouse_x > top_x) and (mouse_x < bottom_x)
         mouse_not_in_rect = false
         break
       end
     end
     if mouse_not_in_rect
       @index = index_var
       update_cursor_rect
       Mouse.click_lock
     else
       Mouse.click_unlock
     end
   end
   if @last_mouse_y == nil
     @last_mouse_y = mouse_y
   end
   check_pos = (@last_mouse_y - mouse_y).abs
   if check_pos > 10
     $game_system.se_play($data_system.cursor_se)
     place = 10 ** (@digits_max - 1 - @index)
     n = @number / place % 10
     @number -= n * place
     n = (n + 1) % 10 if mouse_y < @last_mouse_y
     n = (n + 9) % 10 if mouse_y > @last_mouse_y
     @number += n * place
     refresh
     @last_mouse_y = mouse_y
   end
end
end
class Scene_File
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   mouse_x, mouse_y = Mouse.get_mouse_pos
   Mouse.click_lock
   idx = 0
   for i in @savefile_windows
     top_x = i.x + 16
     top_y = i.y + 16
     bottom_x = top_x + i.width
     bottom_y = top_y + i.height
     if (mouse_x > top_x) and (mouse_y > top_y) and
        (mouse_x < bottom_x) and (mouse_y < bottom_y)
       i.selected = true
       if @file_index != idx
         @file_index = idx
         $game_system.se_play($data_system.cursor_se)
       end            
       Mouse.click_unlock
     else
       i.selected = false
     end
     idx += 1
   end
   self_update
end
end
class Arrow_Enemy
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   mouse_x, mouse_y = Mouse.get_mouse_pos
   idx = 0
   for i in $game_troop.enemies do
     if i.exist?
       top_x = i.screen_x - self.ox
       top_y = i.screen_y - self.oy
       bottom_x = top_x + self.src_rect.width
       bottom_y = top_y + self.src_rect.height
       if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
          (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
         if @index != idx
           $game_system.se_play($data_system.cursor_se)
           @index = idx
         end
       end
     end
     idx += 1
   end
   self_update
end
end
class Arrow_Actor
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   mouse_x, mouse_y = Mouse.get_mouse_pos
   idx = 0
   for i in $game_party.actors do
     if i.exist?
       top_x = i.screen_x - self.ox
       top_y = i.screen_y - self.oy
       bottom_x = top_x + self.src_rect.width
       bottom_y = top_y + self.src_rect.height
       if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
          (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
         if @index != idx
           $game_system.se_play($data_system.cursor_se)
           @index = idx
         end
       end
     end
     idx += 1
   end
   self_update
end
end
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#  处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#   鼠标控制角色的主程序
#==============================================================================
class Game_Player
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
#--------------------------------------------------------------------------
# ● 得到鼠标的状态
#--------------------------------------------------------------------------
def get_mouse_sta
   return @mouse_sta
end
#--------------------------------------------------------------------------
# ● 完整鼠标系统
#--------------------------------------------------------------------------
def update
   mouse_x, mouse_y = Mouse.get_mouse_pos
   @mtp_x = mouse_x
   @mtp_y = mouse_y
   unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
     #得到鼠标图标方向
     $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)
   else
     #令鼠标图标为正常
     $mouse_icon_id = 0 if @mouse_sta != 2
   end
   
   #单击鼠标时进行判断寻路或跟随
   if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
     unless $game_system.map_interpreter.running? or
            @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
       #初始化
       @mouse_sta = 1
       p_direction = 5
       #检查鼠标处能否开启事件
       event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
       #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
       @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
       if @mouse_sta != 2
         #鼠标状态不为跟随状态则取数据并初始化路径
         trg_x = (mouse_x + $game_map.display_x / 4) / 32
         trg_y = (mouse_y + $game_map.display_y / 4) / 32
         @paths = []
         @paths_id = 0
         if event_start == 0 #若不能开启事件
           if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
             find_path = Find_Path.new
             @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
           end
         else #若能开启事件则改变角色朝向
           @direction = p_direction
         end
       end
     end
   end

   #开始移动
   if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
     unless moving? or $game_system.map_interpreter.running? or
            @move_route_forcing or $game_temp.message_window_showing #排除无效情况
       if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
         case @paths[@paths_id] #判断路径
         when 6
           @last_move_x = true
           move_right
           @paths_id += 1
           @direction = 6
         when 4
           @last_move_x = true
           move_left
           @paths_id += 1
           @direction = 4
         when 2
           @last_move_x = false
           move_down
           @direction = 2
           @paths_id += 1
         when 8
           @last_move_x = false
           move_up
           @direction = 8
           @paths_id += 1
         #斜四方向
         when 1
           @last_move_x = false
           move_lower_left
           @direction = 1
           @paths_id += 1
         when 3
           @last_move_x = false
           move_lower_right
           @direction = 3
           @paths_id += 1
         when 7
           @last_move_x = false
           move_upper_left
           @direction = 7
           @paths_id += 1
         when 9
           @last_move_x = false
           move_upper_right
           @direction = 9
           @paths_id += 1
         end
       end
     end
   elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
     if Mouse.press?(Mouse::LEFT) #持续按住鼠标
       unless moving? or $game_system.map_interpreter.running? or
              @move_route_forcing or $game_temp.message_window_showing #排除无效情况
         #跟随方向判断并跟随
         rate =  $game_map.show_rate(self)
         width = (RPG::Cache.character(self.character_name,self.character_hue).width / $c3_每一步的帧数) * rate
         height = (RPG::Cache.character(self.character_name,self.character_hue).height / 8) * rate
         self_ox = (self.screen_x - width / 2 + self.screen_x + width / 2) / 2
         self_oy = (self.screen_y - height + self.screen_y) / 2
         #self_ox = self.screen_x
         #self_oy = self.screen_y
         if (@mtp_x - self_ox)*(@mtp_x - self_ox) + (@mtp_y - self_oy)*(@mtp_y - self_oy) >= 961
           if @mtp_x > self_ox
             if self_oy - @mtp_y < 0.4 * (@mtp_x - self_ox) and
                @mtp_y - self_oy < 0.4 * (@mtp_x - self_ox)
               move_right
               $mouse_icon_id = 16
               @direction = 6
             end
             if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
                @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
               move_lower_right
               $mouse_icon_id = 13
               @direction = 3
             end
             if @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x ) and
                @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
               move_upper_right
               $mouse_icon_id = 19
               @direction = 9
             end
             if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
               move_down
               $mouse_icon_id = 12
               @direction = 2
             end
             if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
               move_up
               $mouse_icon_id = 18
               @direction = 8
             end
           end
           if @mtp_x < self_ox
             if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
                @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
               move_left
               $mouse_icon_id = 14
               @direction = 4
             end
             if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
                @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
               move_lower_left
               $mouse_icon_id = 11
               @direction = 1
             end
             if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
                @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
               move_upper_left
               $mouse_icon_id = 17
               @direction = 7
             end
             if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
               move_down
               $mouse_icon_id = 12
               @direction = 2
             end
             if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
               move_up
               $mouse_icon_id = 18
               @direction = 8
             end
           end
         end
           #...................................................................
           if @mtp_x > self_ox
             if @mtp_y - self_oy > - 0.4 * ( @mtp_x - self_ox ) and
                @mtp_y - self_oy < 0.4 * ( @mtp_x - self_ox )
               $mouse_icon_id = 16
               @direction = 6
             end
             if @mtp_y - self_oy > 0.4 * ( @mtp_x - self_ox ) and
               @mtp_y - self_oy < 2.4 * ( @mtp_x - self_ox )
               $mouse_icon_id = 13
               @direction = 3
             end
             if @mtp_y - self_oy < - 0.4 * ( @mtp_x - self_ox ) and
               @mtp_y - self_oy > - 2.4 * ( @mtp_x - self_ox )
               $mouse_icon_id = 19
               @direction = 9
             end
             if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
               $mouse_icon_id = 12
               @direction = 2
             end
             if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
               $mouse_icon_id = 18
               @direction = 8
             end
           end
           if @mtp_x < self_ox
             if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
                @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
               $mouse_icon_id = 14
               @direction = 4
             end
             if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
                @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
               $mouse_icon_id = 11
               @direction = 1
             end
             if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
                @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
               $mouse_icon_id = 17
               @direction = 7
             end
             if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
               $mouse_icon_id = 12
               @direction = 2
             end
             if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
               $mouse_icon_id = 18
               @direction = 8
             end
           end
           #...................................................................
       end
     else #没状态的情况
       $mouse_icon_id = 0
       @mouse_sta = 0
       @paths_id = @paths.size #终止寻路移动
     end
   end
   self_update
end
end
Mouse.init
END { Mouse.exit }[/fold]


话说你这个帖子的问题解决了没?
血条显示不同步

点评

血条暂时解决了,谢谢  发表于 2022-4-19 08:13

评分

参与人数 1星屑 +150 赞 +1 收起 理由
RyanBern + 150 + 1 认可答案

查看全部评分

初从文,三年不中;后习武,校场发一矢,中鼓吏,逐之出;遂学医,有所成。自撰一良方,服之,卒。
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-4-19 08:12:00 | 显示全部楼层
白鬼 发表于 2022-4-19 01:21
因为你的分类窗口和物品列表窗口重新定义了选择窗口的内容,且重新命名了。但是鼠标脚本里没有对新命名的选 ...

这个难问题解决了,还有个问题,帮我看下,怎么一读档,人物进入游戏界面就会自动跑几步,好奇怪,好像是和读档界面的光标移动有关系

点评

不知道哪里出错了,走了几步重新存档又没问题了,好奇怪  发表于 2022-4-19 10:40
是这个工程,点继续游戏,进去的时候角色会自动几步,开始游戏没问题  发表于 2022-4-19 10:27
是这个工程的吗?为啥我没遇到这种情况?我测试了几次,进入游戏人物都没有走动。  发表于 2022-4-19 10:00
回复

使用道具 举报

梦石
0
星屑
1748
在线时间
485 小时
注册时间
2006-1-7
回帖
996
发表于 2022-4-19 11:07:30 | 显示全部楼层
本帖最后由 白鬼 于 2022-4-19 11:10 编辑
黑米馒头 发表于 2022-4-19 08:12
这个难问题解决了,还有个问题,帮我看下,怎么一读档,人物进入游戏界面就会自动跑几步,好奇怪,好像是 ...


没观测到你说的bug
你可以把你的存档发来我看一下吧

另外,我又修改了点东西

在武器装备分类时,点击装备,可以自动装备到该放的地方,比如你点的武器,自动更换到武器上,点的头部防具,自动更换头部防具

不需要再到装备界面去选择了。
需要的话,自行替换下面这个脚本

[fold=■物品画面处理]#==============================================================================
# ■ Harts_Scene_Item
#------------------------------------------------------------------------------
#  处理物品画面的类。
#==============================================================================

class Scene_Item
  #--------------------------------------------------------------------------
  # ● 初始化对像■■■■■■■■■■■■■■■■■■■■■■
  #     actor_index : 角色索引
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main
   
    # 获取角色
    @actor = $game_party.actors[@actor_index]
    @right_window = Window_EquipRight.new(@actor)
    @right_window.x = 0
    @right_window.y = 10
    @right_window.index = -1
    # 提示窗口
    @tip = Window_Tip.new
    # 生成物品分类窗口
    @itemcommand_window = Harts_Window_ItemCommand.new
    @command_index = @itemcommand_window.index
    # 生成物品窗口
    @itemlist_window = Harts_Window_ItemList.new(@actor)
    @itemlist_window.active = false
    # 生成帮助窗口
    @help_window = Harts_Window_ItemList_Help.new
    # 关联帮助窗口
    @itemlist_window.help_window = @help_window
    # 生成目标窗口 (设置为不可见・不活动)
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    # 物品窗口索引
    @itemlist_window.set_item(@command_index)
    # 执行过度
    Graphics.transition
    # 主循环
    loop do
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      # 如果画面切换就中断循环
      if $scene != self
        break
      end
    end
    # 装备过渡
    Graphics.freeze
    # 释放窗口
    @itemcommand_window.dispose
    @itemlist_window.dispose
    @target_window.dispose
    @tip.dispose
    @right_window.dispose
    @help_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 刷新窗口   
    @right_window.refresh
    # 物品提示窗口
    @tip.update
    @itemcommand_window.update
    @itemlist_window.update
    @help_window.update
    @target_window.update
    if @command_index != @itemcommand_window.index
      @command_index = @itemcommand_window.index
      @itemlist_window.set_item(@command_index)
    end
    # 物品分类被激活的情况下: 调用 update_itemcommand
    if @itemcommand_window.active
      update_itemcommand
      return
    end
    # 物品窗口被激活的情况下: 调用 update_itemlist
    if @itemlist_window.active
      update_itemlist
      return
    end
    # 目标窗口被激活的情况下: 调用 update_target
    if @target_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (物品分类窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_itemcommand
    # 按下 B 键的情况下
  if Input.trigger?(Input::B)
      # 演奏取消 SE
  $game_system.se_play($data_system.cancel_se)
      # 切换到菜单画面
  $scene = Scene_Menu.new(0)
  return
  end
    # 按下 C 键的情况下
  if Input.trigger?(Input::C)
  # 選択中のコマンドのアイテムがない場合
  if @itemlist_window.item_number == 0
      # 演奏冻结 SE
  $game_system.se_play($data_system.buzzer_se)
  return
  end
     # 演奏确定 SE
  $game_system.se_play($data_system.decision_se)
  # アイテムウィンドウをアクティブにする
  @itemcommand_window.active = false
  @itemlist_window.active = true
  @itemlist_window.index = 0
  return
  end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (目标窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_itemlist
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # アイテムウィンドウをアクティブにする
      @itemcommand_window.active = true
      @itemlist_window.active = false
      @itemlist_window.index = -1
      # 隐藏帮助窗口
      @help_window.visible = false
      @itemcommand_window.index = @command_index
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # アイテムウィンドウで現在選択されているデータを取得
      @item = @itemlist_window.item
      # 使用アイテムではない場合
      unless @item.is_a?(RPG::Item)
        ######################################################################
        unless @actor.can_equip?(@item) #不能装备演奏冻结SE。
        # 演奏冻结 SE
          $game_system.se_play($data_system.buzzer_se)
          @tip.tip("这件装备不适合你!")
          return
        end
        # 激活装备界面
        $game_system.se_play($data_system.decision_se)
        if @item.nil?
          @type = nil
        else
          @type = @item.is_a?(RPG::Weapon) ? 0 : @item.kind + 1
        end
        ########↓↓↓↓↓↓↓↓↓↓↓↓###########
        if @item != nil
          @item1 == @itemlist_window.item
        end
        ###########################################
        update_equip#重新定义了
        return
      end
       #######################################################################
      # 使用できない場合
      unless $game_party.item_can_use?(@item.id)
       # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        @tip.tip("你不能使用该物品!")
        return
      end
     # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 效果范围是我方的情况下
      if @item.scope >= 3
        # 激活目标窗口
        @itemlist_window.active = false
         # 调整物品画面使用对像角色选择的窗口位置
        @target_window.x = 304
        @target_window.visible = true
        @target_window.active = true
         # 设置效果范围 (单体/全体) 的对应光标位置
        if @item.scope == 4 || @item.scope == 6
          @target_window.index = -1
        else
          @target_window.index = 0
        end
       # 效果在我方以外的情况下
      else
        # 公共事件 ID 有效的情况下
        if @item.common_event_id > 0
          # 预约调用公共事件
          $game_temp.common_event_id = @item.common_event_id
       # 演奏物品使用时的 SE
          $game_system.se_play(@item.menu_se)
          # 消耗品的情况下
            if @item.consumable
           # 使用的物品数减 1
              $game_party.lose_item(@item.id, 1)
             # 再描绘物品窗口的项目
              @itemlist_window.draw_item(@itemlist_window.index)
            end
         # 切换到地图画面
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (目标窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_target
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
       # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
     # 由于物品用完而不能使用的场合
      unless $game_party.item_can_use?(@item.id)
             # 再次生成物品窗口的内容
        @itemlist_window.refresh
      end
      # 删除目标窗口
      @itemlist_window.active = true
      @target_window.visible = false
      @target_window.active = false
      @itemlist_window.set_item(@command_index)
      return
    end
      # 按下 C 键的情况下
    if Input.trigger?(Input::C)
       # 如果物品用完的情况下
      if $game_party.item_number(@item.id) == 0
        # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        # 物品提示
        @tip.tip("物品已用完!")
        return
      end
     # 目标是全体的情况下
      if @target_window.index == -1
         # 对同伴全体应用物品使用效果
        used = false
        for i in $game_party.actors
          used |= i.item_effect(@item)
        end
      end
     # 目标是单体的情况下
      if @target_window.index >= 0
        # 对目标角色应用物品的使用效果
        target = $game_party.actors[@target_window.index]
        used = target.item_effect(@item)
      end
     # 使用物品的情况下
      if used
        # 演奏物品使用时的 SE
        $game_system.se_play(@item.menu_se)
       # 消耗品的情况下
        if @item.consumable
         # 使用的物品数减 1
          $game_party.lose_item(@item.id, 1)
          # 再描绘物品窗口的项目
          @itemlist_window.draw_item(@itemlist_window.index)
          @itemlist_window.set_item(@command_index)
         
          #############修改了这里↓########################
          #如果使用后物品归零,则关闭Help_Window
          if $game_party.item_number(@item.id) == 0
            @help_window.visible = false
            #这是为了让光标不要停留在空白处
            if @itemlist_window.index > 0
              @itemlist_window.index -= 1
            end
          end
          #################################################     
        end
         # 再生成目标窗口的内容
        @target_window.refresh
       # 全灭的情况下
        if $game_party.all_dead?
        # 切换到游戏结束画面
          $scene = Scene_Gameover.new
          return
        end
        # 公共事件 ID 有效的情况下
        if @item.common_event_id > 0
         # 预约调用公共事件
          $game_temp.common_event_id = @item.common_event_id
           # 切换到地图画面
          $scene = Scene_Map.new
          return
        end
      end
     # 无法使用物品的情况下
      unless used
       # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        # 物品提示
        @tip.tip("你不能使用该物品!")
      end
    return
    end
  end
  ##########################################################################
  # 刷新(角色装备)。
  def update_equip
      # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      
      # 固定装备的情况下
      if @actor.equip_fix?(@type)
        # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        @tip.tip("不能更换装备!")
      else
        $game_system.se_play($data_system.equip_se)
        #变更装备
        @actor.equip(@type, @item == nil ? 0 : @item.id)#直接修改了这里
      end
      #############修改了这里↓########################
      #如果穿着后,装备归零,则关闭Help_Window
      if $game_party.item_number(@item1.id) == 0
        @help_window.visible = false
        #这是为了让光标不要停留在空白处
        if @itemlist_window.index > 0
          @itemlist_window.index -= 1
        end
        @item1 = nil
      end
      #################################################
      @itemlist_window.set_item(@command_index)
      @right_window.refresh
      @itemlist_window.active = true
    end
  end
end
#==============================================================================[/fold]



另外我觉得还有很多可以继续更改优化。
比如加入背包系统,就像大话西游2那样,转生之后开一个包裹
为啥这样呢,因为你配合鼠标脚本,一旦物品过多需要翻页时,就搞不定了。
反正我是没搞定,不知道鼠标脚本有没有更新支持跟随鼠标翻页
初从文,三年不中;后习武,校场发一矢,中鼓吏,逐之出;遂学医,有所成。自撰一良方,服之,卒。
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-4-19 12:40:02 | 显示全部楼层
白鬼 发表于 2022-4-19 11:07
没观测到你说的bug
你可以把你的存档发来我看一下吧

我是想这样弄,物品这一块有好几页,每页24格,满了之后超出的物品会变到后面几页,类似大话那样,XP默认没有分页功能,物品是在一个页面显示

点评

对的,所以需要自己设置背包 可以参考物品仓库,但是在获得物品的时候记得搞好。挺麻烦的一个项目。  发表于 2022-4-19 14:25
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-4-19 16:19:54 | 显示全部楼层
2楼解决
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部