查看: 2406|回复: 28

[已经解决] 装备等级判定

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

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

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

×
下面这个脚本已经添加了装备等级显示,如何给装备添加上等级限制。

[pre lang="ruby"]#==============================================================================
# ■ Fenlei_Command
#------------------------------------------------------------------------------
# 物品分类
#==============================================================================

class Fenlei_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(22, 276+28, 365, 50)
    self.contents = Bitmap.new(width - 32, height - 32)
    @commands = ["", "", "", "",""]
#  @commands = ["平时物品", "战斗物品", "武器装备", "宠物道具","任务道具"]

    @item_max = 5
    @column_max = 5
    self.opacity = 0
    self.z = 300
    refresh
    self.index = 0
    # 更改窗口皮肤
    self.windowskin = RPG::Cache.windowskin('物品皮肤/分类')
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      w = contents.text_size(@commands).width
      x = i * 94
      self.contents.font.color = normal_color
      self.contents.draw_text(x, 0, w, 32, @commands)
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  # index : 項目番号
  # color : 文字色
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
  # y = index * 32
    self.contents.draw_text(0, y, 128, 32, @commands[index])
  end
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(@commands[self.index])
  end
  #--------------------------------------------------------------------------
  # ● 更新光标举行
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
    end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽
    cursor_width = self.width / @column_max - 34
    # 计算光标坐标
    x = @index % @column_max * (cursor_width+29)
    # 更新国标矩形
    self.cursor_rect.set(x-3, 0, cursor_width+26, 22)
  end  
end

#==============================================================================
# ■ Actor_Item
#------------------------------------------------------------------------------
#  物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================

class Actor_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(8, 326, 420, 270)
    @column_max = 6
    self.opacity = 0
    self.z = 300
    @actor = actor
    refresh
    self.index = -1
    # 更改窗口皮肤
    self.windowskin = RPG::Cache.windowskin('物品皮肤/物品')
  end
  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
  end
  #--------------------------------------------------------------------------
  # ● 项目列表设置
  # command : 选中的命令
  #--------------------------------------------------------------------------
  def set_item(command)
    refresh
    case command
    # 平时物品
    when 0
      for i in 1...$data_items.size
        # 选项在0-2时不显示11号属性的物品
        if ($data_items.occasion == 0 or $data_items.occasion == 2) and $game_party.item_number(i) > 0 and $data_items.element_set.include?(11) == false
          @data.push($data_items)
        end
      end
    # 战斗物品  
    when 1
      for i in 1...$data_items.size
        if ($data_items.occasion == 1 and $game_party.item_number(i) > 0)
          @data.push($data_items)
        end
      end
    # 武器装备  
    when 2
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons)
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0
          @data.push($data_armors)
        end
      end
      @data.push(nil)
    # 宠物道具  
    when 3
      for i in 1...$data_items.size
        # 显示11号和12号属性的物品
        if $data_items.element_set.include?(11) or $data_items.element_set.include?(12) and $game_party.item_number(i) > 0
          @data.push($data_items)
        end
      end
    # 任务道具  
    when 4
      for i in 1...$data_items.size
        if $data_items.occasion == 3 and $game_party.item_number(i) > 0
          # 不显示11号和12号属性的物品
          unless $data_items.element_set.include?(11) or $data_items.element_set.include?(12)
            @data.push($data_items)
          end
        end
      end
    end
    # 如果项目数不是 0 就生成位图、重新描绘全部项目
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 59.5, row_max * 61)
      self.contents.clear
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 按类型检索项目数
  #--------------------------------------------------------------------------
  def item_number
    return @item_max
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    return if item.nil?
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
      $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      ### 增加能否装备(颜色)判断。######################
      self.contents.font.color = @actor.can_equip?(item) ? normal_color : disabled_color
      ####################################################
    end
    x = index % 6 * 59.5
    y = (index / 6) * 60
    rect = Rect.new(x, y, self.width - 59.5, 60)
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = 255
    self.contents.blt(x, y , bitmap, Rect.new(0, 0, 59.5, 60), opacity)
    self.contents.font.size = 18
    # 字体加粗
    self.contents.font.bold = true
    self.contents.draw_text(x-4, y-7, 23, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help  
   # 当没有物品时
   if item == nil
     # 关闭帮助窗口
     @help_window.visible = false
   else
     # 打开帮助窗口
     @help_window.visible = true
     # 显示描述内容
     @help_window.set_text(item)
     #校正帮助窗口位置
     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
   end
end
  #--------------------------------------------------------------------------
  # ● 获取开头行
  #--------------------------------------------------------------------------
  def top_row
    # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
    return self.oy / 60
  end
  #--------------------------------------------------------------------------
  # ● 设置开头行
  #     row : 显示开头的行
  #--------------------------------------------------------------------------
  def top_row=(row)
    # row 未满 0 的场合更正为 0
    if row < 0
      row = 0
    end
    # row 超过 row_max - 1 的情况下更正为 row_max - 1
    if row > row_max - 1
      row = row_max - 1
    end
    # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
    self.oy = row * 60
  end
  #--------------------------------------------------------------------------
  # ● 获取 1 页可以显示的行数
  #--------------------------------------------------------------------------
  def page_row_max
    # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
    return (self.height) / 61
  end
  #--------------------------------------------------------------------------
  # ● 获取 1 页可以显示的项目数
  #--------------------------------------------------------------------------
  def page_item_max
    # 将行数 page_row_max 乘上列数 @column_max
    return page_row_max * @column_max
  end
  #--------------------------------------------------------------------------
  # ● 更新光标举行
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
    end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽
    cursor_width = 61
    # 计算光标坐标
    x = @index % @column_max * (cursor_width-1.5)
    y = @index / @column_max * 60 - self.oy
    # 更新国标矩形
    self.cursor_rect.set(x, y, cursor_width, 61)
  end  
end

# ■装备判断
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  处理角色的类。本类在 Game_Actors 类 ($game_actors)
# 的内部使用、Game_Party 类请参考 ($game_party) 。
#==============================================================================

# 判断能否装备。
class Game_Actor < Game_Battler
  def can_equip?(equip)
    if equip.is_a?(RPG::Weapon)
      set = $data_classes[@class_id].weapon_set
    else
      set = $data_classes[@class_id].armor_set
    end
    # 装备为无时返回
    return true if equip.nil?
    # 穿戴装备
    return set.include?(equip.id)
  end
end

# 装备等级限制
module RPG
  class Weapon
    def level
     return 1 if @description.split(/★/)[1] == nil
     return @description.split(/★/)[1]
    end
    def description      
      return @description.split(/★/)[0]
    end
  end
class Armor
    def level
     return 1 if @description.split(/★/)[1] == nil
     return @description.split(/★/)[1]
    end
    def description      
      return @description.split(/★/)[0]
    end
  end
end[/pre]
梦石
0
星屑
2821
在线时间
585 小时
注册时间
2022-7-13
回帖
81
发表于 2022-9-2 08:57:51 | 显示全部楼层
本帖最后由 我为鱼肉 于 2022-9-5 21:39 编辑

描绘项目那里,改变颜色那一部分替换为
[pre lang="ruby"]
  self.contents.font.color = disabled_color
  if (item.is_a?(RPG::Item) and
      $game_party.item_can_use?(item.id)) or
     ((item.is_a?(RPG::Weapon) or item.is_a?(
RPG::Armor)) and @actor.can_equip?(item))
      self.contents.font.color = normal_color
  end[/pre]

[pre lang="ruby"]# 判断能否装备。
class Game_Actor < Game_Battler
  def can_equip?(equip)
    return true if equip.nil?
    list = equip.is_a?(RPG::Weapon) ?
$data_classes[@class_id].weapon_set : $data_classes[@class_id].armor_set
    # 装备为无时返回
    return false if not list.include?(equip.id) or equip.level > self.level
    # 允许穿戴装备
    return true
  end
end[/pre]

判定能否装备的方法可以改一下,用false和nil区分不能装备和等级不够
[pre lang="ruby"]# 判断能否装备。
class Game_Actor < Game_Battler
  def can_equip?(equip)
    return true if equip.nil?
    list = equip.is_a?(RPG::Weapon) ?
$data_classes[@class_id].weapon_set : $data_classes[@class_id].armor_set
    #用false和nil做一个区分,用来判定为什么不能装备
    # 不能装备
    if not list.include?(equip.id)
      return false
    end
    # 等级不够
    if equip.level > self.level
      return nil
    end
    # 允许穿戴装备
    return true
  end
end[/pre]
[pre lang="ruby"]#--------------------------------------------------------------------------
  # ● 刷新画面 (目标窗口被激活的情况下)
  #--------------------------------------------------------------------------
  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
      # 索引返回到0,在回到-1达到隐藏效果
      0.downto(-1) { |x|  @itemlist_window.index = x }
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 获取项目窗口中当前选定的数据
      @item = @itemlist_window.item
      # 非使用项目时
      unless @item.is_a?(RPG::Item)
        if @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
          case @actor.can_equip?(@item)
          when false
            tip_str = "你不能装备!"
          when nil
            tip_str = "等级过低无法穿戴!"
          else
            tip_str = false
          end
          if tip_str
            $game_system.se_play($data_system.buzzer_se)
            @tip.tip(tip_str)
            return
          end
        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
        # 关闭物品栏窗口
        @itemlist_window.active = false
        @right_window.index = @type.nil? ? 0 : @type
        # 打开装备栏窗口
        @right_window.active = true
        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.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[/pre]

点评

可以,太牛了!  发表于 2022-9-5 21:54
现在再试试看吧  发表于 2022-9-5 21:40
我知道问题了,因为判断能否装备的方法本身就判断了等级。所以如果等级不够只会提示无法装备  发表于 2022-9-5 21:34
p出来是武器,论坛又出问题了,发不了图片...,算了放弃吧,还是很感谢  发表于 2022-9-5 21:31
我已经晕了。。。  发表于 2022-9-5 21:26

评分

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

查看全部评分

回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-9-5 08:55:10 | 显示全部楼层
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color

下面这个说明能不能帮忙添加1个等级限制显示,等级不够时显示,“等级不够无法穿戴!”


[pre lang="ruby"]    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 获取项目窗口中当前选定的数据
      @item = @itemlist_window.item
      # 非使用项目时
      unless @item.is_a?(RPG::Item)
        # 不能装备演奏冻结SE。
        unless @actor.can_equip?(@item)
          # 演奏冻结 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
        # 关闭物品栏窗口
        @itemlist_window.active = false
        @right_window.index = @type.nil? ? 0 : @type
        # 打开装备栏窗口
        @right_window.active = true
        return
      end[/pre]

点评

好了  发表于 2022-9-5 09:44
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-9-5 18:43:28 | 显示全部楼层
本帖最后由 黑米馒头 于 2022-9-5 18:44 编辑
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color


我意思是,现在这样和原来的效果一样。。人物等级比武器等级低的时候,也只显示"不能装备",是不是哪里没修改好。。
还有我在空白处点装备的时候,直接弹脚本错误。

1.jpg


2.png

点评

现在应该可以了。把>=改为<就行了  发表于 2022-9-5 18:51
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-9-5 19:23:43 | 显示全部楼层
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color

还是不行,
        p"111"
        tip_str = "等级过低无法穿戴!" if @actor.level < @item.level
我这P,都P不出这个描述。。

还有应该是前面加了这句,return if @item.nil?导致无法拆卸装备了

点评

现在应该不会报错了。还有就是检查一下此@actor,判断我没找到问题  发表于 2022-9-5 19:41
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-9-5 19:52:49 | 显示全部楼层
我为鱼肉 发表于 2022-9-2 08:57
描绘项目那里,改变颜色那一部分替换为

  self.contents.font.color = disabled_color

非常感谢,不过还是不行,不知道啥情况。。。。我把全部脚本贴出来吧,实在不行就不改了,挺不好意思的

[pre lang="ruby"]#==============================================================================
# ■ 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_Eq.new(@actor)
    # 隐藏装备栏索引
    @right_window.index = -1
    # 隐藏装备栏窗口
    @right_window.active = false
   
    # 生成装备帮助窗口
    @help1_window = Shop_Help.new
    # 关联装备帮助窗口
    @right_window.help_window = @help1_window
    @right_window.help_window.z = 2000
   
    # 提示窗口
    @tip = Window_Tip_Item.new
   
    # 显示人物动态图窗口
    @dongtaitu_window = Window_dtt.new(@actor)
   
    # 生成物品分类窗口
    @itemcommand_window = Fenlei_Command.new
    @command_index = @itemcommand_window.index
   
    # 生成物品窗口
    @itemlist_window = Actor_Item.new(@actor)
    @itemlist_window.active = false
   
    # 生成物品帮助窗口
    @help_window = Shop_Help.new
   
    # 关联物品帮助窗口
    @itemlist_window.help_window = @help_window
   
    # 生成目标窗口 (设置为不可见・不活动)
    @target_window = Window_Target_zl.new
    @target_window.visible = false
    @target_window.active = false
   
    # 生成头像框
    @sthero_window = Window_Sthero.new
   
    # 显示游戏界面1图片
    @jiemian = Sprite.new
    @jiemian.bitmap = Bitmap.new("Graphics/Pictures/Ui/主界面/游戏界面1")
    @jiemian.z = 200   
    # 显示游戏界面2图片
    @jiemian1 = Sprite.new
    @jiemian1.bitmap = Bitmap.new("Graphics/Pictures/Ui/主界面/游戏界面2")
    @jiemian1.y = 715
    @jiemian1.z = 200
   
    # 生成背景图窗口
    @back = Sprite.new
    @back.bitmap = Bitmap.new("Graphics/Pictures/Ui/物品界面/物品背景")  
    @back.y = (768-555)/2-53/2
    @back.z = 200
   
    # 生成现实时间窗口
    @realtime_window = Window_RealTime.new
    # 生成游戏时间窗口
    @playtime_window = Window_PlayTime.new
   
    # 显示队伍头像
    @dtx = Window_DuiTouxiang.new
   
    # 生成金钱窗口
    @gold_window = Window_Gold.new
    @gold_window.x = 58+2
    @gold_window.y = 571
    @gold_window.opacity = 0
   
    # 生成队标窗口
    @db = Window_db.new
    # 队伍人数大于1
    if $game_party.actors.size <= 1
      # 隐藏队标窗口
      @db.visible = false
    else
      # 显示队标窗口
      @db.visible = true
    end
   
    # 物品窗口索引
    @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
    # 释放装备帮助窗口
    @help1_window.dispose
    # 释放人物动态图窗口
    @dongtaitu_window.dispose
    # 释放头像框
    @sthero_window.dispose
    # 释放现实时间窗口
    @realtime_window.dispose
    # 释放游戏时间窗口
    @playtime_window.dispose
    # 释放队伍头像
    @dtx.dispose
    # 释放界面图片
    @jiemian.dispose
    @jiemian.bitmap.dispose
    @jiemian1.dispose
    @jiemian1.bitmap.dispose
    # 释放背景图窗口
    @back.dispose
    # 释放背景图图片
    @back.bitmap.dispose
    # 释放金钱窗口
    @gold_window.dispose
    # 释放队标窗口
    @db.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    #【仿网游动态地图界面】
    $spriteset.update
    # 刷新队伍头像
    @dtx.update
    # 刷新游戏时间窗口
    @playtime_window.update   
    # 刷新显示时间窗口
    @realtime_window.update
    # 刷新装备窗口   
    @right_window.update
    # 物品提示窗口
    @tip.update
    # 刷新物品分类
    @itemcommand_window.update
    # 刷新物品栏窗口
    @itemlist_window.update
    # 刷新人物动态图窗口
    @dongtaitu_window.update
    # 刷新物品帮助窗口
    @help_window.update
    # 刷新装备帮助窗口
    @help1_window.update
    # 刷新头像框
    @sthero_window.update
    # 刷新界面图片
    @jiemian.update
    @jiemian1.update
    # 刷新背景图窗口
    @back.update
    # 刷新金钱窗口
    @gold_window.update
   
    # 队伍人数大于1
    if $game_party.actors.size <= 1
      # 隐藏队标窗口
      @db.visible = false
      # 刷新队标窗口
      @db.update
    else
      # 显示队标窗口
      @db.visible = true
      # 刷新队标窗口
      @db.update
    end
   
    # 调整装备栏光标距离
    irect = @right_window.cursor_rect
      w = @help1_window
    w.x = @right_window.x + irect.x + irect.width + 13
    w.y = @right_window.y + irect.y + irect.height + 13
    if w.x + w.width > 1024
      w.x = 1024 - w.width
    end
    if w.y + w.height > 400#768
      w.y = 400 - w.height
    end   
   
    # 按下 ALT 的情况
    if Kboard.keyboard(226)
      # 按下 ALT + E 关闭物品画面  
      if Kboard.key(8,1)      
        # 演奏取消 SE
        $game_system.se_play($data_system.cancel_se)
        # 回到带头角色头像框
        $temp_mapface_id = $game_party.actors[0].id
        # 切换到地图画面
        $scene = Scene_Map.new
        return
      end
    end  
  # 队伍人数大于1时
  if $game_party.actors.size > 1   
    # 按下 W 键的情况下
    if Kboard.key(26,1)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 移至下一位角色
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # 角色头像对应角色索引
      $temp_mapface_id = $game_party.actors[@actor_index].id
      # 回到物品栏索引
      $scene = Scene_Item.new(@actor_index)
      return
    end
    # 按下 Q 键的情况下
    if Kboard.key(20,1)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 移至上一位角色
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # 角色头像对应角色索引
      $temp_mapface_id = $game_party.actors[@actor_index].id
      # 回到物品栏索引
      $scene = Scene_Item.new(@actor_index)
      return
    end      
  end
  
    # 刷新目标被激活的窗口
    @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
    # 角色装备栏被激活的情况下:调用 update_equip
    if @right_window.active
      update_equip
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (物品分类窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_itemcommand
    # 按下 B 键的情况下 主窗口 B 键 退出
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 回到带头角色头像框
      $temp_mapface_id = $game_party.actors[0].id
      # 切换到地图画面
      $scene = Scene_Map.new
      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
      # 显示帮助窗口
      @help_window.visible = true
      # 激活物品栏窗口--打开
      @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
      # 索引返回到0,在回到-1达到隐藏效果
      0.downto(-1) { |x|  @itemlist_window.index = x }
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 获取项目窗口中当前选定的数据
      @item = @itemlist_window.item
      # 非使用项目时
      unless @item.is_a?(RPG::Item)
        # 不能装备演奏冻结SE。
        unless @actor.can_equip?(@item)
          # 演奏冻结 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
        
        # 关闭物品栏窗口
        @itemlist_window.active = false
        @right_window.index = @type.nil? ? 0 : @type
        # 打开装备栏窗口
        @right_window.active = true
        
        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.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
            # 删除目标窗口
            @target_window.visible = false
            @target_window.active  = false
            # 物品提示
            @tip.tip("物品已用完!")
            
            #这是为了让光标不要停留在空白处
            if @itemlist_window.index > 0
              @itemlist_window.index -= 1
            end

            # 激活物品窗口状态
            @itemlist_window.active = true
          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
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # #隐藏物品分类
      @itemlist_window.active = true
      # 隐藏装备栏窗口
      @right_window.active = false
      # 隐藏装备帮助窗口
      @help1_window.visible = false
      # 隐藏装备索引
      @right_window.index = -1
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      if @type != nil and @right_window.index != @type
        # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        # 物品提示
        @tip.tip("不能装备在这儿!")
        return
      end
      # 演奏装备 SE
      $game_system.se_play($data_system.equip_se)
      # 变更装备
      @actor.equip(@right_window.index, @item == nil ? 0 : @item.id)
   
=begin   
      # 如果穿着后,装备归零,则关闭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
=end

      # 索引=物品分类
      @itemlist_window.set_item(@command_index)
      # 刷新装备窗口
      @right_window.refresh
      # 关闭物品窗口激活状态
      @itemlist_window.active = true
      # 隐藏装备栏窗口
      @right_window.active = false
      # 隐藏装备帮助窗口
      @help1_window.visible = false
      # 隐藏装备索引
      @right_window.index = -1
    end
  end
end
[/pre]
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部