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

Project1

 找回密码
 注册会员
搜索
Project1 查看内容

物品图鉴

2005-10-19 00:00| 发布者: 柳柳| 查看: 9464| 评论: 0|原作者: 66RPG

摘要:    作者 和希,桜雅来源日本翻译:柳柳  版本与更新  2005年7月更新  相关网址    范例工程 范例工程下载 脚本功能 可以把见到的物品收集到鉴定中去。 有
 

 作者

和希,桜雅
来源日本
翻译:柳柳

 版本与更新

 2005年7月更新

 相关网址

 

 范例工程

范例工程下载



脚本功能

可以把见到的物品收集到鉴定中去。

有关版权的一点说明:脚本是通过某前辈在MSN上向作者直接申请得来,请误随便转载。如有置疑,请联系本站客服。

使用方法

复制全部脚本内容,在Main脚本之前按insert,插入此脚本全部内容。

个性化设置比较复杂,请详细参考脚本开头部分的注释!不要怕麻烦,这是打造你自己系统的时候!

脚本冲突可能:战斗类的一些脚本和菜单类的,比较多。因为他在获得物品、武器等的时候需要入鉴

相关截图


 

 脚本内容

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#============================================================================== 

# ——————————————————————————————————
# 66RPG说明:
# 这是一个使用相对复杂的脚本,脚本调用方式:$scene = Scene_ItemBook.new
#
# 设置方式:
# 首先进行物品分类,对于恢复类的物品,给物品添加上属性:“恢复”
# 对于贵重类的物品,给物品添加属性:“贵重”
#
# 然后武器分类,默认情况下武器会全部加入图鉴,如果只想让一部分武器加入图鉴
# 可以在@weapon_kind_element_name = []中添加武器属性名
#
# 然后是防具分类,对于想入图鉴的防具,盾类添加属性"盾",铠类添加属性"铠"
# 其他类添加属性"其他"
#
# 由于属性中多了一些莫名其妙的东西,所以不能在图鉴的时候把所有属性显示出来
# (显然,属性的作用很多,不能这么简单),所以需要手动设置
# 在整个脚本中搜索elem_temp.push("炎") if elem == "炎" 这样的东西,把“炎”改为
# 你需要显示的属性。至此全部完结。即可使用了。
#
# 其他,请最好仔细看一遍脚本,所有有用的地方都加了注释,而程序性的注释都删除了
# 想来对于能够看懂这个脚本的人,一点点注释也是无关紧要的。
#
# ————————————————————————————————————


module Item_Book_Config
  SHOW_COMPLETE_TYPE = 1         # 图鉴完成率显示方法,一般不要动了
end
class Data_ItemBook
  attr_reader :item_kind_name
  attr_reader :weapon_kind_name
  attr_reader :armor_kind_name
  attr_reader :kind_row
  attr_reader :item_id_data
  attr_reader :weapon_id_data
  attr_reader :armor_id_data
  attr_reader :item_kind_element_name
  attr_reader :weapon_kind_element_name
  attr_reader :armor_kind_element_name
  def initialize
    @item_kind_name = ["恢复物品", "贵重物品"]  #——物品分类的显示名,可以更改
    @weapon_kind_name = ["武器"]                #——武器显示名
    @armor_kind_name = ["盾", "铠甲", "其他"]   #——防具显示名
    @kind_row = ["恢复物品",
                 "武器",
                 "盾",
                 "铠甲",
                 "其他",
                 "贵重物品"]                    #——程序用的显示名,无特殊要求
                                                #——和上面设置相同即可。
    @item_kind_element_name = ["恢复", "贵重"]  #——物品用的分类属性名
    @weapon_kind_element_name = []              #——武器用的属性名,留空则全入鉴
    @armor_kind_element_name = ["盾", "铠", "其他"]#-防具用的属性名
    @item_id_data = item_book_id_set
    @weapon_id_data = weapon_book_id_set
    @armor_id_data = armor_book_id_set
  end
  def kind_search(name)
    if @item_kind_name.include?(name)
      return [0, @item_kind_name.index(name)]
    elsif @weapon_kind_name.include?(name)
      return [1, @weapon_kind_name.index(name)]
    elsif @armor_kind_name.include?(name)
      return [2, @armor_kind_name.index(name)]
    end
  end
  def no_add_element
    no_add = 0
    for i in 1...$data_system.elements.size
      if $data_system.elements[i] =~ /不加入图鉴/ #——不加入图鉴用的属性名
        no_add = i                                #——建议在上面设置不要在这里
        break
      end
    end
    return no_add
  end
  def element_search(element_name)
    return nil if element_name == nil
    for i in 1...$data_system.elements.size
      if $data_system.elements[i] =~ /^#{element_name}/
        return i
      end
    end
  end
  def item_book_id_set
    data = []
    no_add = no_add_element
    if @item_kind_element_name.size == 0
      data[0] = [0]
      for i in 1...$data_items.size
        item = $data_items[i]
        next if item.name == ""
        next if item.element_set.include?(no_add)
        data[0].push(item.id)
      end
    else
      for i in 0...@item_kind_element_name.size
        data[i] = [0]
        element_id = element_search(@item_kind_element_name[i])
        for j in 1...$data_items.size
          item = $data_items[j]
          next if item.name == ""
          next if item.element_set.include?(no_add)
          if item.element_set.include?(element_id)
            data[i].push(item.id)
          end
        end
      end
    end
    return data
  end
  def weapon_book_id_set
    data = []
    no_add = no_add_element
    if @weapon_kind_element_name.size == 0
      data[0] = [0]
      for i in 1...$data_weapons.size
        item = $data_weapons[i]
        next if item.name == ""
        next if item.element_set.include?(no_add)
        data[0].push(item.id)
      end
    else
      for i in 0...@weapon_kind_element_name.size
        data[i] = [0]
        element_id = element_search(@weapon_kind_element_name[i])
        for j in 1...$data_weapons.size
          item = $data_weapons[j]
          next if item.name == ""
          next if item.element_set.include?(no_add)
          if item.element_set.include?(element_id)
            data[i].push(item.id)
          end
        end
      end
    end
    return data
  end
  def armor_book_id_set
    data = []
    no_add = no_add_element
    if @armor_kind_element_name.size == 0
      data[0] = [0]
      for i in 1...$data_armors.size
        item = $data_armors[i]
        next if item.name == ""
        next if item.guard_element_set.include?(no_add)
        data[0].push(item.id)
      end
    else
      for i in 0...@armor_kind_element_name.size
        data[i] = [0]
        element_id = element_search(@armor_kind_element_name[i])
        for j in 1...$data_armors.size
          item = $data_armors[j]
          next if item.name == ""
          next if item.guard_element_set.include?(no_add)
          if item.guard_element_set.include?(element_id)
            data[i].push(item.id)
          end
        end
      end
    end
    return data
  end
end
class Window_Base < Window
  def draw_attack_element(x, y, element_set)
    elem_temp = []
    for i in element_set
      elem = $data_system.elements[i]       #——这些是基本属性设置
      elem_temp.push("炎") if elem == "炎"  #——需要显示的属性在这里添加
      elem_temp.push("氷") if elem == "氷"
      elem_temp.push("雷") if elem == "雷"
      elem_temp.push("水") if elem == "水"
      elem_temp.push("土") if elem == "土"
      elem_temp.push("风") if elem == "风"
      elem_temp.push("光") if elem == "光"
      elem_temp.push("暗") if elem == "暗"
    end
    if elem_temp.size == 0
      self.contents.draw_text(x, y, 64, 32, "无属性")
      return
    end
    ox = 0
    for name in elem_temp
      cx = self.contents.text_size(name).width
      self.contents.draw_text(x+ox, y, cx, 32, name)
      ox += cx+8
    end
  end
  #--------------------------------------------------------------------------
  # ● 武器属性表示
  #--------------------------------------------------------------------------
  def draw_attack_wp_element(x, y, element_set)
    elem_temp = []
    for i in element_set
      elem = $data_system.elements[i]      #——这里是武器的属性设置
      elem_temp.push("斬") if elem == "斬" #——可以自行添加
      elem_temp.push("打") if elem == "打"
      elem_temp.push("突") if elem == "突"
      elem_temp.push("射") if elem == "射"
      elem_temp.push("魔") if elem == "魔"
    end
    if elem_temp.size == 0
      self.contents.draw_text(x, y, 64, 32, "无属性")
      return
    end
    ox = 0
    for name in elem_temp
      cx = self.contents.text_size(name).width
      self.contents.draw_text(x+ox, y, cx, 32, name)
      ox += cx+8
    end
  end
  #--------------------------------------------------------------------------
  # ● 特技属性表示
  #--------------------------------------------------------------------------
  def draw_attack_weak_element(x, y, element_set)
    elem_temp = []
    for i in element_set
      elem = $data_system.elements[i]
      elem_temp.push("不死") if elem == "対 不死"  #——这些是特技的属性设置
      elem_temp.push("蛇")   if elem == "対 蛇"    #——也可以添加
      elem_temp.push("水棲") if elem == "対 水棲"  #——注意这里用的是日文而不是
      elem_temp.push("獣")   if elem == "対 獣"    #——中文,默认工程不认
      elem_temp.push("鬼")   if elem == "対 鬼"
      elem_temp.push("鳥")   if elem == "対 鳥"
      elem_temp.push("悪魔") if elem == "対 悪魔"
      elem_temp.push("天使") if elem == "対 天使"
    end
    if elem_temp.size == 0
      self.contents.draw_text(x, y, 64, 32, "无属性")
      return
    end
    ox = 0
    for name in elem_temp
      cx = self.contents.text_size(name).width
      self.contents.draw_text(x+ox, y, cx, 32, name)
      ox += cx+8
    end
  end
  def draw_attack_add_state(x, y, plus_state_set)
    state_temp = []
    for i in plus_state_set
      state = $data_states[i]
      state_temp.push(state.name) if state.name != ""
    end
    if state_temp.size == 0
      self.contents.draw_text(x, y, 64, 32, "无状态")
      return
    end
    ox = 0
    oy = 0
    for name in state_temp
      cx = self.contents.text_size(name).width
      if ox + cx + 4 >= self.contents.width - 128
        ox = 0
        oy += 1
      end
      self.contents.draw_text(x+ox, y+oy*32, cx, 32, name)
      ox += cx+8
    end
  end
  def draw_scope(scope)
    case scope
    when 0
      return "不能使用"
    when 1
      return "敌方单体"
    when 2
      return "敌方全体"
    when 3
      return "我方单体"
    when 4
      return "我方全体"
    when 5
      return "我方单体(HP 0)"
    when 6
      return "我方全体(HP 0)"
    when 7
      return "使用者"
    end
  end
end

class Game_Temp
  attr_accessor :item_book_data
  alias temp_item_book_data_initialize initialize
  def initialize
    temp_item_book_data_initialize
    @item_book_data = Data_ItemBook.new
  end
end

class Game_Party
  attr_accessor :item_count             
  attr_accessor :weapon_count          
  attr_accessor :armor_count           
  alias item_book_info_initialize initialize
  def initialize
    item_book_info_initialize
    @item_count = {}
    @weapon_count = {}
    @armor_count = {}
  end
  alias item_book_gain_item gain_item
  def gain_item(item_id, n)
    add_item_count(item_id, 0) if n > 0
    item_book_gain_item(item_id, n)
  end
  alias item_book_gain_weapon gain_weapon
  def gain_weapon(item_id, n)
    add_weapon_count(item_id, 0) if n > 0
    item_book_gain_weapon(item_id, n)
  end
  alias item_book_gain_armor gain_armor
  def gain_armor(item_id, n)
    add_armor_count(item_id, 0) if n > 0
    item_book_gain_armor(item_id, n)
  end
  def add_item_count(item_id, type = 0)
    if type == -1
      @item_count[item_id] = 0
    else
      @item_count[item_id] = 1
    end
  end
  def add_weapon_count(weapon_id, type = 0)
    if type == -1
      @weapon_count[weapon_id] = 0
    else
      @weapon_count[weapon_id] = 1
    end
  end
  def add_armor_count(armor_id, type = 0)
    if type == -1
      @armor_count[armor_id] = 0
    else
      @armor_count[armor_id] = 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 这里是图鉴最大登陆数,上面的内容是获得物品的时候加入图鉴
  #--------------------------------------------------------------------------
  def item_book_max
    kind_data = []
    kind_data[0] = $game_temp.item_book_data.item_kind_name
    kind_data[1] = $game_temp.item_book_data.weapon_kind_name
    kind_data[2] = $game_temp.item_book_data.armor_kind_name
    size = 0
    for i in 0..2
      for kind in kind_data[i]
        size += item_book_category_max(kind)
      end
    end
    return size
  end
  def item_book_now
    kind_data = []
    kind_data[0] = $game_temp.item_book_data.item_kind_name
    kind_data[1] = $game_temp.item_book_data.weapon_kind_name
    kind_data[2] = $game_temp.item_book_data.armor_kind_name
    size = 0
    for i in 0..2
      for kind in kind_data[i]
        size += item_book_category_now(kind)
      end
    end
    return size
  end
  def item_book_complete_percentage
    i_max = item_book_max.to_f
    i_now = item_book_now.to_f
    comp = i_now / i_max * 100
    return comp.truncate
  end
  def item_book_category_max(category)
    kind_data = $game_temp.item_book_data.kind_search(category)
    case kind_data[0]
    when 0
      id_data = $game_temp.item_book_data.item_id_data.dup
    when 1
      id_data = $game_temp.item_book_data.weapon_id_data.dup
    when 2
      id_data = $game_temp.item_book_data.armor_id_data.dup
    end
    index = kind_data[1]
    size = id_data[index].size - 1
    return size
  end
  def item_book_category_now(category)
    kind_data = $game_temp.item_book_data.kind_search(category)
    index = kind_data[1]
    case kind_data[0]
    when 0
      now_item_info = @item_count.keys
      elename = $game_temp.item_book_data.item_kind_element_name[index]
      item_set = $data_items
    when 1
      now_item_info = @weapon_count.keys
      elename = $game_temp.item_book_data.weapon_kind_element_name[index]
      item_set = $data_weapons
    when 2
      now_item_info = @armor_count.keys
      elename = $game_temp.item_book_data.armor_kind_element_name[index]
      item_set = $data_armors
    end
    no_add = $game_temp.item_book_data.no_add_element
    element_id = $game_temp.item_book_data.element_search(elename)
    new_item_info = []
    for i in now_item_info
      item = item_set[i]
      next if item == nil
      next if item.name == ""  #——数据库中名称为空白的物品不添加
      case item
      when RPG::Item
        ele_set = item.element_set
      when RPG::Weapon
        ele_set = item.element_set
      when RPG::Armor
        ele_set = item.guard_element_set
      end
      next if ele_set.include?(no_add)
      if element_id == nil or ele_set.include?(element_id)
        new_item_info.push(item.id)
      end
    end
    return new_item_info.size
  end
  def item_book_category_complete_percentage(category)
    i_max = item_book_category_max(category).to_f
    i_now = item_book_category_now(category).to_f
    comp = i_now / i_max * 100
    return comp#.truncate
  end
end
class Interpreter
  def item_book_max(category=nil)
    if category == nil
      return $game_party.item_book_max
    else
      return $game_party.item_book_category_max(category)
    end
  end
  def item_book_now(category=nil)
    if category == nil
      return $game_party.item_book_now
    else
      return $game_party.item_book_category_now(category)
    end
  end
  def item_book_comp(category=nil)
    if category == nil
      return $game_party.item_book_complete_percentage
    else
      return $game_party.item_book_category_complete_percentage(category)
    end
  end
end

class Window_ItemBook < Window_Selectable
  attr_reader   :data
  attr_reader   :item_kind
  attr_reader   :item_index
  def initialize(index=0)
    super(0, 64, 640, 416)
    @column_max = 2
    @book_data = $game_temp.item_book_data
    @data = data_set(index)
    @data.shift
    #@data.sort!
    @item_max = @data.size
    @item_kind = index
    self.index = 0
    #refresh
  end
  def new_data_set(index)
    @data = data_set(index)
    @data.shift
    #@data.sort!
    @item_max = @data.size
  end
  def data_set(index)
    kind_row_data = @book_data.kind_search(@book_data.kind_row[index])
    @item_kind = kind_row_data[0]
    @item_index = kind_row_data[1]
    data = []
    case @item_kind
    when 0
      data = @book_data.item_id_data[@item_index].dup
    when 1
      data = @book_data.weapon_id_data[@item_index].dup
    when 2
      data = @book_data.armor_id_data[@item_index].dup
    end
    return data
  end
  def show?(kind, id)
    case kind
    when 0
      if $game_party.item_count[id] == 0 or $game_party.item_count[id] == nil
        return false
      else
        return true
      end
    when 1
      if $game_party.weapon_count[id] == 0 or $game_party.weapon_count[id] == nil
        return false
      else
        return true
      end
    when 2
      if $game_party.armor_count[id] == 0 or $game_party.armor_count[id] == nil
        return false
      else
        return true
      end
    end
  end
  def item
    return @data[self.index]
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    return if @item_max == 0
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max
      draw_item(i)
    end
  end
  def draw_item(index)
    case @item_kind
    when 0
      item = $data_items[@data[index]]
      id = @book_data.item_id_data[@item_index].index(item.id)
    when 1
      item = $data_weapons[@data[index]]
      id = @book_data.weapon_id_data[@item_index].index(item.id)
    when 2
      item = $data_armors[@data[index]]
      id = @book_data.armor_id_data[@item_index].index(item.id)
    end
    return if item == nil
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 32, 32, id.to_s)
    if show?(@item_kind, item.id)
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = 255
      self.contents.blt(x+48, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
      self.contents.draw_text(x+48 + 28, y, 212, 32, item.name, 0)
    else
      self.contents.draw_text(x+48 + 28, y, 212, 32, "-----", 0)
      return
    end
  end
end
class Window_ItemBook_Info < Window_Selectable
  def initialize
    super(0, 0+64+64, 640, 480-64-64)
    @book_data = $game_temp.item_book_data
    self.contents = Bitmap.new(width - 32, height - 32)
    self.index = -1
  end
  def refresh(item_id, item_kind, item_index)
    self.contents.clear
    self.contents.font.size = 22
    case item_kind
    when 0
      draw_item_info(item_id, item_index)
    when 1
      draw_weapon_info(item_id, item_index)
    when 2
      draw_armor_info(item_id, item_index)
    end
  end
  def draw_item_info(item_id, item_index)
    item = $data_items[item_id]
    rect = Rect.new(4, 0, 160, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = 255
    self.contents.blt(4+48, 0 + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.color = normal_color
    id = @book_dat

2

鲜花

刚表态过的朋友 (2 人)

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