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

Project1

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

如何增加一个分类?

 关闭 [复制链接]

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

跳转到指定楼层
1
发表于 2008-8-18 06:04:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RT,这个是66黑剑的物品分类脚本
#==============================================================================
# ■ Window_ItemTitle
#------------------------------------------------------------------------------
#  选择类别
#==============================================================================
class Window_ItemTitle < Window_Base  #"使用物品"四个字的窗口
  def initialize
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
  end
end
#==============================================================================
# ■ Window_ItemCommand
#------------------------------------------------------------------------------
#  选择类别
#==============================================================================
class Window_ItemCommand < Window_Selectable
  
#———— 初始化 ————
  def initialize
    super(0, 64, 160, 224)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 6
   
    #——各类物品的判别标志————
    #——药物:分散度0 ——————
    #——食物:分散度1 ——————
    #——书报杂志:分散度2 ——————
    #——装备:根据原本类push———
    #——曲谱:分散度3 ——————
    #——特殊:分散度4 ——————
    @commands = ["药物类", "食物类", "书报杂志", "各种装备", "曲谱乐谱", "特殊道具"]
    refresh
    self.index = 0
  end
  
#———— 刷新 ————
  def refresh  
    self.contents.clear
    for i in 0...@item_max
    draw_item(i, normal_color)
    end
  end

#—— 描绘项目 ——| index:编号,color:颜色——————
  def draw_item(index, color)
    self.contents.font.color = color
    y = index * 32
    self.contents.draw_text(4, y, 128, 32, @commands[index])
  end
#—— 帮助部分更新 ————
  def update_help
    case self.index
    when 0
      @text = @commands[0]
    when 1
      @text = @commands[1]
    when 2
      @text = @commands[2]
    when 3
      @text = @commands[3]
    when 4
      @text = @commands[4]
    when 5
      @text = @commands[5]
    end
    @help_window.set_text(@text)
  end  
end  # Window_ItemCommand的



#==============================================================================
# ■ Window_ItemList
#------------------------------------------------------------------------------
#  物品窗口。 item.variance是物品的"分散度",借来用做分类
#==============================================================================

class Window_ItemList < Window_Selectable

#———— 初始化 ————
  def initialize
    super(160, 0, 480, 416)
    refresh
    self.index = 0
  end

#—— 取得现在选择的物品 ——
  def item
    return @data[self.index]
  end
  
#—— 刷新 ———
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
  end
  
  
#—— 设置不同类别的物品 ———
  def set_item(command)
    refresh
   
    #—— 根据现在的选项决定物品 ——
    case command  
    when 0            #药品,特点是分散度为0
      for i in 1...$data_items.size
        if ($data_items.variance == 0 and $game_party.item_number(i) > 0)
          @data.push($data_items)
        end
      end
    when 1            #食物类,特点是分散度为1  
      for i in 1...$data_items.size
        if ($data_items.variance == 1 and $game_party.item_number(i) > 0)
          @data.push($data_items)
        end
      end
    when 2            #杂货类,特点是分散度为2
      for i in 1...$data_items.size
        if ($data_items.variance == 2 and $game_party.item_number(i) > 0)
          @data.push($data_items)
        end
      end
    when 3            #各种装备:根据原本类push
      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
    when 4            #各类曲谱:特点是分散度为3
      for i in 1...$data_items.size
        if ($data_items.variance == 3 and $game_party.item_number(i) > 0)
          @data.push($data_items)
        end
      end
    when 5            #特殊物品:特点是分散度为4
      for i in 1...$data_items.size
        if ($data_items.variance == 4 and $game_party.item_number(i) > 0)
          @data.push($data_items)
        end
      end
    end

    @item_max = @data.size  
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.clear
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

#——— 单类物品的个数 ————
  def item_number
    return @item_max
  end
  
  
#——— 项目内容的描画 ————
  def draw_item(index)
    item = @data[index]  
    #—— 取得具体物品数量 ——
    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 = half_disabled_color
    end
   
    #—— 描绘物体图标、物体名、数量 ——
    x = 4
    y = index * 32
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
  end
  
#——— 更新帮助窗口 ————
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end

end #—— Window_ItemList 的 ——








#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
#    处理物品
#==============================================================================

class Scene_Item
  
#—— 透明度的准备 ——
  include OPACITY

#——— 主处理 ————
  def main
    create_screen_print  # 创建截图
   
    #——— 各种窗口预定义 ————
    @itemtitle_window = Window_ItemTitle.new
   
    @itemcommand_window = Window_ItemCommand.new
    @command_index = @itemcommand_window.index
   
    @itemlist_window = Window_ItemList.new
    @itemlist_window.active = false
    @itemlist_window.set_item(@command_index)
   
    @help_window = Window_Help.new
    @help_window.x = 0
    @help_window.y = 416
    @itemcommand_window.help_window = @help_window
    @itemlist_window.help_window = @help_window
   
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
   
    Graphics.transition

    #—— 主循环 ——
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
   
    #—— 释放窗口 ——
    Graphics.freeze
    @itemtitle_window.dispose
    @itemcommand_window.dispose
    @itemlist_window.dispose
    @help_window.dispose
    @target_window.dispose
    dispose_screen_print  # 释放截图
   
  end  # main的

  #—— update的定义 ——
  def update
    @itemtitle_window.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
   
    #—— 当某窗体在active的时候,更新之 ——
    if @itemcommand_window.active
      update_itemcommand
      return
    end
    if @itemlist_window.active
      update_itemlist
      return
    end
    if @target_window.active
      update_target
      return
    end
  end  # update的

#————具体更新定义————
  def update_itemcommand
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(0,1)
      return
    end
   
    if Input.trigger?(Input::C)
      if @itemlist_window.item_number == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $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
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @itemcommand_window.active = true
      @itemlist_window.active = false
      @itemlist_window.index = 0
      @itemcommand_window.index = @command_index
      return
    end
   
    if Input.trigger?(Input::C)
      @item = @itemlist_window.item
      unless @item.is_a?(RPG::Item)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      unless $game_party.item_can_use?(@item.id)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $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
          if @item.common_event_id > 0
            $game_temp.common_event_id = @item.common_event_id
            $game_system.se_play(@item.menu_se)
            used = false
            for i in $game_party.actors
              used |= i.item_effect(@item)
            end
            if @item.consumable
              $game_party.lose_item(@item.id, 1)
            end
            $game_switches[25] = true
            $scene = Scene_Map.new
            return
          else
            @target_window.index = -1
          end         
        else
          @target_window.index = 0
        end
      else
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.common_event_id
          $game_system.se_play(@item.menu_se)
          if @item.consumable  #——消耗品的情况
            $game_party.lose_item(@item.id, 1)
            @itemlist_window.draw_item(@itemlist_window.index)  #——重新描绘
          end
          $game_switches[25] = true
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
  end

#———— 更新target窗口————
  def update_target
    if Input.trigger?(Input::B)
      $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
   
    if Input.trigger?(Input::C)
      if $game_party.item_number(@item.id) == 0
        $game_system.se_play($data_system.buzzer_se)
        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
        $game_system.se_play(@item.menu_se)
        if @item.consumable
          $game_party.lose_item(@item.id, 1)
          @itemlist_window.draw_item(@itemlist_window.index)
          @itemlist_window.set_item(@command_index)
        end
        @target_window.refresh
        if $game_party.all_dead?
          $scene = Scene_Gameover.new
          return
        end
        
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.common_event_id
          $scene = Scene_Map.new
          return
        end  
      end
   
      unless used
        $game_system.se_play($data_system.buzzer_se)
      end
    return
    end
  end     #target窗口的
end #Class Scene_Item的
怎么加多一个选项……可以的话把思路跟我说说
版务信息:本贴由楼主自主结贴~

Lv1.梦旅人

梦石
0
星屑
50
在线时间
93 小时
注册时间
2008-5-16
帖子
745
2
发表于 2008-8-18 06:09:27 | 只看该作者
   when 5            #特殊物品:特点是分散度为4
     for i in 1...$data_items.size
       if ($data_items.variance == 4 and $game_party.item_number(i) > 0)
         @data.push($data_items)
       end
     end
  when 6   #你想分类的物品:特点是分散度为5
     for i in 1...$data_items.size
       if ($data_items.variance == 5 and $game_party.item_number(i) > 0)
         @data.push($data_items)
       end
     end
回复 支持 反对

使用道具 举报

Lv3.寻梦者

小柯的徒弟

梦石
0
星屑
1500
在线时间
1157 小时
注册时间
2008-5-24
帖子
3085

贵宾

3
发表于 2008-8-18 06:11:17 | 只看该作者
还要改着:
@commands = ["药物类", "食物类", "书报杂志", "各种装备", "曲谱乐谱", "特殊道具","新建"]
应该没错{/gg}
回复 支持 反对

使用道具 举报

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

4
 楼主| 发表于 2008-8-18 07:22:59 | 只看该作者
不行,还是报错,这种方法我试过了,没用
回复 支持 反对

使用道具 举报

Lv3.寻梦者

小柯的徒弟

梦石
0
星屑
1500
在线时间
1157 小时
注册时间
2008-5-24
帖子
3085

贵宾

5
发表于 2008-8-18 07:26:47 | 只看该作者
@item_max = 6
改为
@item_max = 7
回复 支持 反对

使用道具 举报

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

6
 楼主| 发表于 2008-8-18 07:28:38 | 只看该作者
一样,还是报错,我把积分提到200了大家帮帮忙
回复 支持 反对

使用道具 举报

Lv3.寻梦者

小柯的徒弟

梦石
0
星屑
1500
在线时间
1157 小时
注册时间
2008-5-24
帖子
3085

贵宾

7
发表于 2008-8-18 07:33:56 | 只看该作者
def update_help
case self.index
when 0
@text = @commands[0]
when 1
@text = @commands[1]
…………
when 6
@text = @commands[6]
回复 支持 反对

使用道具 举报

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

8
 楼主| 发表于 2008-8-18 07:41:18 | 只看该作者
还是没用,麻烦测试一下再回帖好吗?
回复 支持 反对

使用道具 举报

Lv3.寻梦者

小柯的徒弟

梦石
0
星屑
1500
在线时间
1157 小时
注册时间
2008-5-24
帖子
3085

贵宾

9
发表于 2008-8-18 07:47:43 | 只看该作者
顶楼的脚本没法用…是在哪拿的…说明一下
回复 支持 反对

使用道具 举报

Lv1.梦旅人

魔王 ⑨

梦石
0
星屑
90
在线时间
379 小时
注册时间
2006-10-16
帖子
4299

贵宾

10
 楼主| 发表于 2008-8-18 07:54:05 | 只看该作者
就在黑剑里,额……忘了说了,用的时候把
225,229,270行也就是出错的那几行注释掉或删掉,因为没有黑剑的那2个脚本
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-25 12:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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