查看: 2429|回复: 11

[已经解决] 帮助跟随显示异常

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

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

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

×
本帖最后由 黑米馒头 于 2022-4-16 22:40 编辑

在物品界面分类,加了个光标跟随功能,使用完物品的时候,光标还显示被使用物品的描述。。。

好几天了,实在解决不了,大佬帮下

使用前
2.png
使用后
3.png

还有在武器装备这里,把武器或装备下了之后,在点击穿戴装备光标也会出现多一个同样装备的描述....


范例
直接进继续游戏物品栏里面测试BUG

1.rar (487.79 KB, 下载次数: 7)
4.png
梦石
0
星屑
1748
在线时间
485 小时
注册时间
2006-1-7
回帖
996
发表于 2022-4-17 09:54:15 | 显示全部楼层
在脚本 ■物品画面处理 里面
第281行之后,插入以下内容
  1.           #############修改了这里↓########################
  2.           #如果使用后物品归零,则关闭Help_Window
  3.           if $game_party.item_number(@item.id) == 0
  4.             @help_window.visible = false
  5.             #这是为了让光标不要停留在空白处
  6.             if @itemlist_window.index > 0
  7.               @itemlist_window.index -= 1
  8.             end
  9.           end
  10.           #################################################
复制代码
初从文,三年不中;后习武,校场发一矢,中鼓吏,逐之出;遂学医,有所成。自撰一良方,服之,卒。
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-4-17 12:00:21 | 显示全部楼层
本帖最后由 黑米馒头 于 2022-4-17 12:06 编辑
白鬼 发表于 2022-4-17 09:54
在脚本 ■物品画面处理 里面
第281行之后,插入以下内容


使用装备的时候问题还是没解决,还有使用物品结束之后,那个角色选择的框能不能也一起消失了,然后帮助窗口停留在下一个物品上面,没物品的话,帮助窗口就隐藏了

点评

已经@  发表于 2022-4-17 19:53
@一下版主帮忙吧,我也记不住在哪里认定了  发表于 2022-4-17 18:47
亲,可以了吗?可以了记得手动认证,不然哪天版主起夜看见了要扣分了  发表于 2022-4-17 15:08
回复

使用道具 举报

梦石
0
星屑
1748
在线时间
485 小时
注册时间
2006-1-7
回帖
996
发表于 2022-4-17 12:52:40 | 显示全部楼层
本帖最后由 白鬼 于 2022-4-17 13:41 编辑
黑米馒头 发表于 2022-4-17 12:00
使用装备的时候问题还是没解决,还有使用物品结束之后,那个角色选择的框能不能也一起消失了,然后帮助窗 ...


这个问题稍微复杂一点
我修改了两个脚本,我直接放出来吧。你拿去覆盖你的脚本,也可以对比一下看看我修改了哪里。

首先是
[fold=■物品界面直接装备武器]
  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  物品画面、战斗画面、显示浏览物品的窗口。
  5. #==============================================================================

  6. class Harts_Window_ItemList < Window_Selectable_Item
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize(actor)
  11.     super(9, 210+27+30, 293, 200)
  12.     @column_max = 6
  13.     @actor = actor
  14.     refresh
  15.     self.index = -1
  16.     #self.opacity = 200
  17.     #@menu_com = Sprite.new
  18.     #@menu_com.bitmap = RPG::Cache.picture("道具栏")
  19.     # 战斗中的情况下将窗口移至中央并将其半透明化
  20.     if $game_temp.in_battle
  21.       self.y = 64
  22.       self.height = 242
  23.       self.back_opacity = 160
  24.     end
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 获取物品
  28.   #--------------------------------------------------------------------------
  29.   def item
  30.     return @data[self.index]
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 刷新
  34.   #--------------------------------------------------------------------------
  35.   def refresh
  36.     if self.contents != nil
  37.       self.contents.dispose
  38.       self.contents = nil
  39.     end
  40.     @data = []
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● アイテム一覧設定
  44.   # command : 選択中のコマンド
  45.   #--------------------------------------------------------------------------
  46.   def set_item(command)
  47.     refresh
  48.     case command
  49.     when 0
  50.       for i in 1...$data_items.size
  51.         if ($data_items[i].occasion == 0 or $data_items[i].occasion == 2) and $game_party.item_number(i) > 0 and $data_items[i].element_set.include?(11) == false
  52.           @data.push($data_items[i])
  53.         end
  54.       end
  55.     when 1
  56.       for i in 1...$data_items.size
  57.         if ($data_items[i].occasion == 1 and $game_party.item_number(i) > 0)
  58.           @data.push($data_items[i])
  59.         end
  60.       end
  61.     when 2
  62.       for i in 1...$data_weapons.size
  63.         if $game_party.weapon_number(i) > 0
  64.           @data.push($data_weapons[i])
  65.         end
  66.       end
  67.       for i in 1...$data_armors.size
  68.         if $game_party.armor_number(i) > 0
  69.           @data.push($data_armors[i])
  70.         end
  71.       end
  72.       @data.push(nil)
  73.     when 3
  74.       for i in 1...$data_items.size
  75.         if $data_items[i].element_set.include?(11) and $game_party.item_number(i) > 0
  76.           @data.push($data_items[i])
  77.         end
  78.       end  
  79.     when 4
  80.       for i in 1...$data_items.size
  81.         if $data_items[i].occasion == 3 and $game_party.item_number(i) > 0
  82.           unless $data_items[i].element_set.include?(11) or $data_items[i].element_set.include?(12)
  83.             @data.push($data_items[i])
  84.           end
  85.         end
  86.       end
  87.     end
  88.     # 項目数が 0 でなければビットマップを作成し、全項目を描画
  89.     @item_max = @data.size
  90.     if @item_max > 0
  91.       self.contents = Bitmap.new(width - 42, row_max * 42)
  92.       self.contents.clear
  93.       for i in 0...@item_max
  94.         draw_item(i)
  95.       end
  96.     end
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # ● 種類別アイテム数の取得
  100.   #--------------------------------------------------------------------------
  101.   def item_number
  102.     return @item_max
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 描绘项目
  106.   #     index : 项目编号
  107.   #--------------------------------------------------------------------------
  108.   def draw_item(index)
  109.     item = @data[index]
  110.     return if item.nil?
  111.     case item
  112.     when RPG::Item
  113.       number = $game_party.item_number(item.id)
  114.     when RPG::Weapon
  115.       number = $game_party.weapon_number(item.id)
  116.     when RPG::Armor
  117.       number = $game_party.armor_number(item.id)
  118.     end
  119.     if item.is_a?(RPG::Item) and
  120.       $game_party.item_can_use?(item.id)
  121.       self.contents.font.color = normal_color
  122.     else
  123.       ### 增加能否装备(颜色)判断。######################
  124.       self.contents.font.color = @actor.can_equip?(item) ? normal_color : disabled_color
  125.       ####################################################
  126.     end
  127.     x = index % 6 * 42
  128.     y = (index / 6) * 42
  129.     rect = Rect.new(x, y, self.width - 42, 42)
  130.     bitmap = RPG::Cache.icon(item.icon_name)
  131.     opacity = self.contents.font.color == normal_color ? 255 : 128
  132.     self.contents.blt(x, y , bitmap, Rect.new(0, 0, 42, 42), opacity)
  133. #   self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  134. #    self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
  135.     self.contents.font.size = 15
  136.     self.contents.draw_text(x + 17, y-7, 23, 32, number.to_s, 2)
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● 刷新帮助文本
  140.   #--------------------------------------------------------------------------
  141.   def update_help
  142.     if item == nil
  143.       @help_window.visible = false
  144.     else
  145.       @help_window.set_text(item)
  146.       #校正帮助窗口位置
  147.       @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  148.     end
  149.   end
  150. end
复制代码
[/fold]




然后是   

[fold=■物品画面处理]
  1. #==============================================================================
  2. # ■ Harts_Scene_Item
  3. #------------------------------------------------------------------------------
  4. #  处理物品画面的类。
  5. #==============================================================================

  6. class Scene_Item
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像■■■■■■■■■■■■■■■■■■■■■■
  9.   #     actor_index : 角色索引
  10.   #--------------------------------------------------------------------------
  11.   def initialize(actor_index = 0, equip_index = 0)
  12.     @actor_index = actor_index
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 主处理
  16.   #--------------------------------------------------------------------------
  17.   def main
  18.    
  19.     # 获取角色
  20.     @actor = $game_party.actors[@actor_index]
  21.     @right_window = Window_EquipRight.new(@actor)
  22.     @right_window.x = 0
  23.     @right_window.y = 10
  24.     @right_window.index = -1
  25.     # 提示窗口
  26.     @tip = Window_Tip.new
  27.     # 生成物品分类窗口
  28.     @itemcommand_window = Harts_Window_ItemCommand.new
  29.     @command_index = @itemcommand_window.index
  30.     # 生成物品窗口
  31.     @itemlist_window = Harts_Window_ItemList.new(@actor)
  32.     @itemlist_window.active = false
  33.     # 生成帮助窗口
  34.     @help_window = Harts_Window_ItemList_Help.new
  35.     # 关联帮助窗口
  36.     @itemlist_window.help_window = @help_window
  37.     # 生成目标窗口 (设置为不可见・不活动)
  38.     @target_window = Window_Target.new
  39.     @target_window.visible = false
  40.     @target_window.active = false
  41.     # 物品窗口索引
  42.     @itemlist_window.set_item(@command_index)
  43.     # 执行过度
  44.     Graphics.transition
  45.     # 主循环
  46.     loop do
  47.       # 刷新游戏画面
  48.       Graphics.update
  49.       # 刷新输入信息
  50.       Input.update
  51.       # 刷新画面
  52.       update
  53.       # 如果画面切换就中断循环
  54.       if $scene != self
  55.         break
  56.       end
  57.     end
  58.     # 装备过渡
  59.     Graphics.freeze
  60.     # 释放窗口
  61.     @itemcommand_window.dispose
  62.     @itemlist_window.dispose
  63.     @target_window.dispose
  64.     @tip.dispose
  65.     @right_window.dispose
  66.     @help_window.dispose
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 刷新画面
  70.   #--------------------------------------------------------------------------
  71.   def update
  72.     # 刷新窗口   
  73.     @right_window.update
  74.     # 物品提示窗口
  75.     @tip.update
  76.     @itemcommand_window.update
  77.     @itemlist_window.update
  78.     @help_window.update
  79.     @target_window.update
  80.     if @command_index != @itemcommand_window.index
  81.       @command_index = @itemcommand_window.index
  82.       @itemlist_window.set_item(@command_index)
  83.     end
  84.     # 物品分类被激活的情况下: 调用 update_itemcommand
  85.     if @itemcommand_window.active
  86.       update_itemcommand
  87.       return
  88.     end
  89.     # 物品窗口被激活的情况下: 调用 update_itemlist
  90.     if @itemlist_window.active
  91.       update_itemlist
  92.       return
  93.     end
  94.     # 目标窗口被激活的情况下: 调用 update_target
  95.     if @target_window.active
  96.       update_target
  97.       return
  98.     end
  99.     if @right_window.active
  100.       update_equip
  101.       return
  102.     end
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 刷新画面 (物品分类窗口被激活的情况下)
  106.   #--------------------------------------------------------------------------
  107.   def update_itemcommand
  108.     # 按下 B 键的情况下
  109.   if Input.trigger?(Input::B)
  110.       # 演奏取消 SE
  111.   $game_system.se_play($data_system.cancel_se)
  112.       # 切换到菜单画面
  113.   $scene = Scene_Menu.new(0)
  114.   return
  115.   end
  116.     # 按下 C 键的情况下
  117.   if Input.trigger?(Input::C)
  118.   # 選択中のコマンドのアイテムがない場合
  119.   if @itemlist_window.item_number == 0
  120.       # 演奏冻结 SE
  121.   $game_system.se_play($data_system.buzzer_se)
  122.   return
  123.   end
  124.      # 演奏确定 SE
  125.   $game_system.se_play($data_system.decision_se)
  126.   # アイテムウィンドウをアクティブにする
  127.   @itemcommand_window.active = false
  128.   @itemlist_window.active = true
  129.   @itemlist_window.index = 0
  130.   return
  131.   end
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 刷新画面 (目标窗口被激活的情况下)
  135.   #--------------------------------------------------------------------------
  136.   def update_itemlist
  137.     # 按下 B 键的情况下
  138.     if Input.trigger?(Input::B)
  139.       # 演奏取消 SE
  140.       $game_system.se_play($data_system.cancel_se)
  141.       # アイテムウィンドウをアクティブにする
  142.       @itemcommand_window.active = true
  143.       @itemlist_window.active = false
  144.       @itemlist_window.index = -1
  145.       # 隐藏帮助窗口
  146.       @help_window.visible = false
  147.       @itemcommand_window.index = @command_index
  148.       return
  149.     end
  150.     # 按下 C 键的情况下
  151.     if Input.trigger?(Input::C)
  152.       # アイテムウィンドウで現在選択されているデータを取得
  153.       @item = @itemlist_window.item
  154.       # 使用アイテムではない場合
  155.       unless @item.is_a?(RPG::Item)
  156.         
  157.         ######################################################################
  158.         unless @actor.can_equip?(@item) #不能装备演奏冻结SE。
  159.         # 演奏冻结 SE
  160.           $game_system.se_play($data_system.buzzer_se)
  161.          
  162.           @tip.tip("你不能装备!")
  163.          
  164.           return
  165.         end
  166.         # 激活装备界面
  167.         $game_system.se_play($data_system.decision_se)
  168.         if @item.nil?
  169.           @type = nil
  170.         else
  171.           @type = @item.is_a?(RPG::Weapon) ? 0 : @item.kind + 1
  172.         end
  173.         ########↓↓↓↓↓↓↓↓↓↓↓↓###########
  174.         if @item != nil
  175.           @item1 == @itemlist_window.item
  176.         end
  177.         ###########################################
  178.         @itemlist_window.active = false
  179.         @right_window.index = @type.nil? ? 0 : @type
  180.         @right_window.active = true
  181.         return
  182.       end
  183.        #######################################################################
  184.       # 使用できない場合
  185.       unless $game_party.item_can_use?(@item.id)
  186.        # 演奏冻结 SE
  187.         $game_system.se_play($data_system.buzzer_se)
  188.         
  189.         @tip.tip("你不能使用该物品!")
  190.         
  191.         return
  192.       end
  193.      # 演奏确定 SE
  194.       $game_system.se_play($data_system.decision_se)
  195.       # 效果范围是我方的情况下
  196.       if @item.scope >= 3
  197.         # 激活目标窗口
  198.         @itemlist_window.active = false
  199.          # 调整物品画面使用对像角色选择的窗口位置
  200.         @target_window.x = 304
  201.         @target_window.visible = true
  202.         @target_window.active = true
  203.          # 设置效果范围 (单体/全体) 的对应光标位置
  204.         if @item.scope == 4 || @item.scope == 6
  205.           @target_window.index = -1
  206.         else
  207.           @target_window.index = 0
  208.         end
  209.        # 效果在我方以外的情况下
  210.       else
  211.         # 公共事件 ID 有效的情况下
  212.         if @item.common_event_id > 0
  213.           # 预约调用公共事件
  214.           $game_temp.common_event_id = @item.common_event_id
  215.        # 演奏物品使用时的 SE
  216.           $game_system.se_play(@item.menu_se)
  217.           # 消耗品的情况下
  218.             if @item.consumable
  219.             # 使用的物品数减 1
  220.               $game_party.lose_item(@item.id, 1)
  221.               # 再描绘物品窗口的项目
  222.               @itemlist_window.draw_item(@itemlist_window.index)              
  223.             end
  224.          # 切换到地图画面
  225.           $scene = Scene_Map.new
  226.           return
  227.         end
  228.       end
  229.       return
  230.     end
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 刷新画面 (目标窗口被激活的情况下)
  234.   #--------------------------------------------------------------------------
  235.   def update_target
  236.     # 按下 B 键的情况下
  237.     if Input.trigger?(Input::B)
  238.        # 演奏取消 SE
  239.       $game_system.se_play($data_system.cancel_se)
  240.      # 由于物品用完而不能使用的场合
  241.       unless $game_party.item_can_use?(@item.id)
  242.              # 再次生成物品窗口的内容
  243.         @itemlist_window.refresh
  244.       end
  245.       # 删除目标窗口
  246.       @itemlist_window.active = true
  247.       @target_window.visible = false
  248.       @target_window.active = false
  249.       @itemlist_window.set_item(@command_index)
  250.       return
  251.     end
  252.       # 按下 C 键的情况下
  253.     if Input.trigger?(Input::C)
  254.        # 如果物品用完的情况下
  255.       if $game_party.item_number(@item.id) == 0
  256.         # 演奏冻结 SE
  257.         $game_system.se_play($data_system.buzzer_se)
  258.         # 物品提示
  259.         @tip.tip("物品已用完!")
  260.         return
  261.       end
  262.      # 目标是全体的情况下
  263.       if @target_window.index == -1
  264.          # 对同伴全体应用物品使用效果
  265.         used = false
  266.         for i in $game_party.actors
  267.           used |= i.item_effect(@item)
  268.         end
  269.       end
  270.      # 目标是单体的情况下
  271.       if @target_window.index >= 0
  272.         # 对目标角色应用物品的使用效果
  273.         target = $game_party.actors[@target_window.index]
  274.         used = target.item_effect(@item)
  275.       end
  276.      # 使用物品的情况下
  277.       if used
  278.         # 演奏物品使用时的 SE
  279.         $game_system.se_play(@item.menu_se)
  280.        # 消耗品的情况下
  281.         if @item.consumable
  282.          # 使用的物品数减 1
  283.           $game_party.lose_item(@item.id, 1)
  284.           # 再描绘物品窗口的项目
  285.           @itemlist_window.draw_item(@itemlist_window.index)
  286.           @itemlist_window.set_item(@command_index)
  287.           #############修改了这里↓########################
  288.           #如果使用后物品归零,则关闭Help_Window
  289.           if $game_party.item_number(@item.id) == 0
  290.             @help_window.visible = false
  291.             #这是为了让光标不要停留在空白处
  292.             if @itemlist_window.index > 0
  293.               @itemlist_window.index -= 1
  294.             end
  295.           end
  296.           #################################################
  297.         end
  298.          # 再生成目标窗口的内容
  299.         @target_window.refresh
  300.        # 全灭的情况下
  301.         if $game_party.all_dead?
  302.         # 切换到游戏结束画面
  303.           $scene = Scene_Gameover.new
  304.           return
  305.         end
  306.         # 公共事件 ID 有效的情况下
  307.         if @item.common_event_id > 0
  308.          # 预约调用公共事件
  309.           $game_temp.common_event_id = @item.common_event_id
  310.            # 切换到地图画面
  311.           $scene = Scene_Map.new
  312.           return
  313.         end
  314.       end
  315.      # 无法使用物品的情况下
  316.       unless used
  317.        # 演奏冻结 SE
  318.         $game_system.se_play($data_system.buzzer_se)
  319.         # 物品提示
  320.         @tip.tip("你不能使用该物品!")
  321.       end
  322.     return
  323.     end
  324.   end
  325.   ##########################################################################
  326.   # 刷新(角色装备)。
  327.   def update_equip
  328.       # 按下 B 键的情况下
  329.     if Input.trigger?(Input::B)
  330.         # 演奏取消 SE
  331.       $game_system.se_play($data_system.cancel_se)
  332.       @itemlist_window.active = true
  333.       @right_window.index = -1
  334.       @right_window.active = false
  335.       return
  336.     end
  337.       # 按下 C 键的情况下
  338.     if Input.trigger?(Input::C)
  339.       if @type != nil and @right_window.index != @type
  340.           # 演奏冻结 SE
  341.         $game_system.se_play($data_system.buzzer_se)
  342.         # 物品提示
  343.         @tip.tip("不能装备在这儿!")
  344.         return
  345.       end
  346.       $game_system.se_play($data_system.equip_se)
  347.       @actor.equip(@right_window.index, @item == nil ? 0 : @item.id)
  348.       
  349.       #############修改了这里↓########################
  350.       #如果穿着后,装备归零,则关闭Help_Window
  351.       if $game_party.item_number(@item1.id) == 0
  352.         @help_window.visible = false
  353.         #这是为了让光标不要停留在空白处
  354.         if @itemlist_window.index > 0
  355.           @itemlist_window.index -= 1
  356.         end
  357.         @item1 = nil
  358.       end
  359.       #################################################
  360.       
  361.       
  362.       
  363.       @itemlist_window.set_item(@command_index)
  364.       @right_window.refresh
  365.       @itemlist_window.active = true
  366.       @itemlist_window.index = 0
  367.       @right_window.index = -1
  368.       @right_window.active = false
  369.     end
  370.   end
  371. end
  372. #==============================================================================
复制代码
[/fold]

点评

不能手动认可,我或者其他版主会定期看帖子内容帮你点认可  发表于 2022-4-18 13:52
完美解决!如何手动认真啊  发表于 2022-4-17 17:46
@soulsaga 大恩大德,恩公在上,受在下一拜  发表于 2022-4-17 13:42
关键字TOGGL  发表于 2022-4-17 13:31
呃……谁能教教我论坛怎么用折叠那个功能。一大长篇看着好乱  发表于 2022-4-17 12:53

评分

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

查看全部评分

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

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部