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

Project1

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

[已经过期] 如何在生成新装备之后调用原来装备的图标

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
24 小时
注册时间
2012-9-6
帖子
45
跳转到指定楼层
1
发表于 2012-10-8 08:25:01 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
我使用了随机装备脚本,通过鉴定使得装备的属性出现随机变化。那么如何使得装备的图标保持不变呢?
涉及的主要脚本如下:
      #---------------------------------------------------------------------
      # ● 取得基本屬性
      #---------------------------------------------------------------------
      case type
      when "weapon"
        equipment = $data_weapons[id]
        new_atk = equipment.atk
        new_element = equipment.element_set
        new_state = equipment.plus_state_set
      when "armor"
        equipment = $data_armors[id]
        new_state = equipment.guard_state_set # 防禦狀態組
        new_element = equipment.guard_element_set # 防禦屬性組
      end
      new_name = equipment.name.split(/(未鉴定)/)[0]
      new_pdef = equipment.pdef
      new_mdef = equipment.mdef
      new_str = equipment.str_plus
      new_dex = equipment.dex_plus
      new_agi = equipment.agi_plus
      new_int = equipment.int_plus
      new_des = equipment.description
      new_price = equipment.price
      new_dur = equipment.max_duration
      #---------------------------------------------------------------------
      # ● 隨機生成屬性
      #---------------------------------------------------------------------
      # 如果設定增加屬性以及狀態:
      if @set.elements_set.size > 0 and @set.states_set.size > 0
        c = 3
      # 否則
      else
        c = 2
      end
      100.times do
        break if possible_quality < 2
        kind = rand(c)
        case kind
        when 0 # 附加兩防
          random_pdef = rand(possible_quality/3).round
          random_mdef = rand(possible_quality/3).round
          new_pdef += random_pdef * @set.f_pdef
          new_mdef += random_mdef * @set.f_mdef
          possible_quality-=(random_pdef + random_mdef)
          quality +=(random_pdef + random_pdef)
        when 1 # 附加四參數
          random_str = rand(possible_quality/4).round
          random_dex = rand(possible_quality/4).round
          random_agi = rand(possible_quality/4).round
          random_int = rand(possible_quality/4).round
          new_str += random_str
          new_dex += random_dex
          new_agi += random_agi
          new_int += random_int
          possible_quality-=(random_str + random_dex + random_agi + random_int)
          quality+=(random_str + random_dex + random_agi + random_int)
        when 2 # 附加屬性以及狀態
          next if @set.rate["element"] < rand(1000)
          cost = @set.cost
          plus_kind = rand(2) if possible_quality >= cost
          case plus_kind
          when 0 #屬性附加
            n_el = @set.elements_set[rand(@set.elements_set.size)]
            new_element = new_element|[n_el]
            possible_quality -= cost
            quality += cost
          when 1 #狀態附加
            n_st = @set.states_set[rand(@set.states_set.size)]
            new_state = new_state|[n_st]
            possible_quality -= cost
            quality += cost
          end
        end
      end
      # 生成耐久度
      new_dur = quality
      # 更新價值
      new_price *= (1 + quality/@set.best_quality)
      new_price = new_price.to_i
      #---------------------------------------------------------------------
      # ● 更改名字顔色以及前後綴
      #---------------------------------------------------------------------
      new_color = 0
      a = @set.best_quality
      @set.level_set.each do |setting|
        a -= setting[0] unless setting[0].nil?
        if quality > a
          new_color = setting[1] unless setting[1].nil?
          new_name = setting[2] + new_name unless setting[2].nil?
          new_name = new_name + setting[3] unless setting[3].nil?
          break
        end
      end
      #---------------------------------------------------------------------
      # ● 更改資料并取得裝備
      #---------------------------------------------------------------------
      if equipment.identified
        new_equipment = equipment.clone
        case type
        when "weapon"
          new_equipment.id = $data_weapons.size
          new_equipment.atk = new_atk
          new_equipment.element_set = new_element
          new_equipment.plus_state_set = new_state
        when "armor"
          new_equipment.id = $data_armors.size
          new_equipment.guard_element_set = new_element
          new_equipment.guard_state_set = new_state
        end
        new_equipment.name = new_name
        new_equipment.description = new_des
        new_equipment.price = new_price
        new_equipment.pdef = new_pdef
        new_equipment.mdef = new_mdef
        new_equipment.str_plus = new_str
        new_equipment.dex_plus = new_dex
        new_equipment.agi_plus = new_agi
        new_equipment.int_plus = new_int
        new_equipment.color = new_color
        new_equipment.quality = quality
        new_equipment.identified = true # 取消未鑒定標志
        new_equipment.slots = new_slots if defined? @set.materia
        case type
        when "weapon"
          $data_weapons.push(new_equipment)
        when "armor"
          $data_armors.push(new_equipment)
        end
        # 加入職業可裝備列表中
        push_into_classes(id, new_equipment.id, type)
        # 獲得裝備
        get_equipment(new_equipment.id, 1, type)
      else
        case type
        when "weapon"
          equipment.atk = new_atk
          equipment.element_set = new_element
          equipment.plus_state_set = new_state
        when "armor"
          equipment.guard_element_set = new_element
          equipment.guard_state_set = new_state
        end
        equipment.name = new_name
        equipment.description = new_des
        equipment.price = new_price
        equipment.pdef = new_pdef
        equipment.mdef = new_mdef
        equipment.str_plus = new_str
        equipment.dex_plus = new_dex
        equipment.agi_plus = new_agi
        equipment.int_plus = new_int
        equipment.color = new_color
        equipment.quality = quality
        equipment.identified = true # 取消未鑒定標志
        equipment.slots = new_slots if defined? @set.materia
        # 獲得裝備
        get_equipment(equipment.id, 1, type)
      end
    end
  end
  #---------------------------------------------------------------------
  # ● 加入職業可裝備列表中
  #---------------------------------------------------------------------
  def push_into_classes(old_id, new_id, type)
    for i in 1...$data_classes.size
      case type
      #------------------------------------------------
      # 武器
      #------------------------------------------------
      when "weapon"
        if $data_classes[i].weapon_set.include?(old_id)
          $data_classes[i].weapon_set.push(new_id)
        end
      #------------------------------------------------
      # 防具
      #------------------------------------------------
      when "armor"
        if $data_classes[i].armor_set.include?(old_id)
          $data_classes[i].armor_set.push(new_id)
        end
      end
    end
  end
  #---------------------------------------------------------------------
  # ● 獲得裝備
  #---------------------------------------------------------------------
  def get_equipment(id, n, type)
    return if id.zero?
    @weapons[id] = [[weapon_number(id) + n, 0].max, 99].min if type == "weapon"
    @armors[id] = [[armor_number(id) + n, 0].max, 99].min if type == "armor"
  end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-1 17:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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