#------------------------------------------------------------------------------
# 无责任随机装备系统 v0.5
# by pigsss
#
# 使用方法:装备备注<EXTRA=单个属性最大值>
# eg. <EXTRA=100> 那么每项最多赋予+100基础属性,特性计算有所不同
# <SNAME> 表示该物品不需要名字前缀
# 最近玩大菠萝3有感的产物,后续会不会更新看心情(大雾)
#------------------------------------------------------------------------------
module Setup
#----品质与几率
LEVELS = {0 => 0.7, # 白色
1 => 0.2, # 蓝色
2 => 0.05, # 黄色
3 => 0.025,# 橙色
4 => 0.015,# 紫色
5 => 0.01} # 红色
#----基础属性(描述用)
PARAM = {0 => "生命",
1 => "魔法",
2 => "攻击力",
3 => "防御力",
4 => "魔法攻击力",
5 => "魔法防御力",
6 => "敏捷",
7 => "幸运"}
BASICWORDS = {0 => "野熊之",
1 => "夜枭之",
2 => "锋利的",
3 => "坚强的",
4 => "强能之",
5 => "明镜之",
6 => "猫鼬之",
7 => "兔脚之"}
#----特性(描述用)
FEA = {11 => "属性抗性",
13 => "状态抗性",
14 => "状态免疫",
22 => ["命中率","回避率","必杀率","必杀回避率","魔法回避率","魔法反射率","反击率","生命回复率","魔法回复率","特技值回复率"],
23 => ["嘲讽","防御加成","回复加成","药效加成","耗魔","特技值回复","物理伤害","魔法伤害","地形伤害","经验获取"],
31 => "攻击属性",
32 => "击中附加",
33 => "攻击速度",
34 => "攻击次数",
# 可以被赋予的技能id列表
43 => ["技能赋予",[26,61,117]],
64 => ["遇敌几率减半","随机遇敌无效","偷袭无效","先制几率提高","双倍金钱","双倍掉率",]
}
FEAWORDS = {11 => "抗",
13 => "抗",
14 => "免",
22 => ["青铜之","闪避之","杀戮之","轻巧之","五彩之","镜面之","尖刺之","重生之","精神之","暴戾之",],
23 => ["孙子之","坚硬之","生命之","药师之","节能之","冲动之","暴力之","聪慧之","洞察之","经验之",],
31 => "之",
32 => "之",
33 => "迅速的",
34 => "连击之",
64 => ["隐遁之","策略之","光明之","暗影之","财富之","机遇之",]
}
end
class Array
def random(weights)
weights ||= [1.0] * length
total = weights.inject(0.0) {|sum, w| sum + w}
point = rand * total
zip(weights).sort{|a, b| a[1] <=> b[1]}.each do |element, weight|
return element if weight >= point
point -= weight
end
end
end
class RPG::EquipItem < RPG::BaseItem
@@plus_id = 0
end
class RPG::Weapon
attr_accessor :features
attr_accessor :level
EX = /<EXTRA=(\d+)\s*>/i
SNAME = /<SNAME>/
def initialize
super
@wtype_id = 0
@animation_id = 0
@features.push(RPG::BaseItem::Feature.new(31, 1, 0))
@features.push(RPG::BaseItem::Feature.new(22, 0, 0))
@level = 0
end
def extra
@note =~ EX ? $1.to_i.abs : 0
end
def sname?
@note =~ SNAME ? true : false
end
def plus_id
@@plus_id
end
def plus_id=(id)
@@plus_id = id
end
end
class RPG::Armor
attr_accessor :features
attr_accessor :level
EX = /<EXTRA=(\d+)\s*>/i
SNAME = /<SNAME>/
def initialize
super
@atype_id = 0
@etype_id = 1
@features.push(RPG::BaseItem::Feature.new(22, 1, 0))
@level = 0
end
def extra
@note =~ EX ? $1.to_i.abs : 0
end
def sname?
@note =~ SNAME ? true : false
end
def plus_id
@@plus_id
end
def plus_id=(id)
@@plus_id = id
end
end
class RPG::UsableItem < RPG::BaseItem
attr_accessor :level
alias :o_initialize :initialize
def initialize
o_initialize
@level = 0
end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 获取物品实例
#--------------------------------------------------------------------------
def item_object(kind, data_id)
return $data_items [data_id] if kind == 1
r = RandomEquip.new
l = Setup::LEVELS.keys.random(Setup::LEVELS.values)
return r.make_new_weapon(data_id, l) if kind == 2
return r.make_new_armor(data_id, l) if kind == 3
return nil
end
end
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 增减武器
#--------------------------------------------------------------------------
def command_127
value = operate_value(@params[1], @params[2], @params[3])
r = RandomEquip.new
l = Setup::LEVELS.keys.random(Setup::LEVELS.values)
$game_party.gain_item(r.make_new_weapon(@params[0], l), value, @params[4])
end
#--------------------------------------------------------------------------
# ● 增减护甲
#--------------------------------------------------------------------------
def command_128
value = operate_value(@params[1], @params[2], @params[3])
r = RandomEquip.new
l = Setup::LEVELS.keys.random(Setup::LEVELS.values)
$game_party.gain_item(r.make_new_armor(@params[0], l), value, @params[4])
end
end
class RandomEquip
include Setup
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
@new_weapon = nil
@new_armor = nil
@point = 0
end
def make_new_weapon(id, level)
@new_weapon = $data_weapons[id].clone
@new_weapon.plus_id += 1
@new_weapon.id = @new_weapon.id + @new_weapon.id * 1000 + @new_weapon.plus_id
@new_weapon.params = @new_weapon.params.clone
@new_weapon.features = @new_weapon.features.clone
@point = @new_weapon.extra
ss = rand(level + 1)
fs = level - ss
puts ss,fs
params = PARAM.keys
ss.times {
break if params.empty?
i = params.random([1 / params.size.to_f] * params.size)
params.delete(i)
value = randst
value = [value, level * 5].max
@new_weapon.params[i] += value
@new_weapon.name = BASICWORDS[i] + @new_weapon.name unless @new_weapon.sname?
#@new_weapon.description = @new_weapon.description + " " + (randst > 0 ? PARAM[i] + "+" + value.to_s + " " : "")
}
features = FEA.keys
fs.times {
break if features.empty?
i = features.random([1 / features.size.to_f] * features.size)
features.delete(i)
add_features(@new_weapon, i, level)
}
@new_weapon.level = level
$data_weapons[id + id * 1000 + @new_weapon.plus_id] = @new_weapon
save_data($data_weapons, "Data/Weapons.rvdata2")
@new_weapon
end
def make_new_armor(id, level)
@new_armor = $data_armors[id].clone
@new_armor.plus_id += 1
@new_armor.id = @new_armor.id + @new_armor.id * 1000 + @new_armor.plus_id
@new_armor.params = @new_armor.params.clone
@new_armor.features = @new_armor.features.clone
@point = @new_armor.extra
ss = rand(level + 1)
fs = level - ss
params = PARAM.keys
ss.times {
break if params.empty?
i = params.random([1 / params.size.to_f] * params.size)
params.delete(i)
value = randst
value = [value, level * 5].max
@new_armor.params[i] += value
@new_armor.name = BASICWORDS[i] + @new_armor.name unless @new_armor.sname?
#@new_armor.description = @new_armor.description + " " + (randst > 0 ? PARAM[i] + "+" + value.to_s + " " : "")
}
features = FEA.keys
fs.times {
break if features.empty?
i = features.random([1 / features.size.to_f] * features.size)
features.delete(i)
add_features(@new_armor, i, level)
}
@new_armor.level = level
$data_armors[id + id * 1000 + @new_armor.plus_id] = @new_armor
save_data($data_armors, "Data/Armors.rvdata2")
@new_armor
end
def add_features(equip, i, level)
value = randst
case i
when 33,34 # 次数&攻击速度
value /= 10 if i == 34
value = [[value, 1].max, level].min if i == 34
equip.features << RPG::BaseItem::Feature.new(i, 0, value)
equip.name = FEAWORDS[i] + equip.name unless equip.sname?
#equip.description = equip.description + " " + (value > 0 ? FEA[i] + "+" + value.to_s + " " : "")
when 11,31 # 属性相关
j = rand($data_system.elements.size)
j = [[j,1].max, $data_system.elements.size - 1].min
value = [[100 - value, 5].max, 99].min if i == 11
equip.features << RPG::BaseItem::Feature.new(i, j, value)
equip.name = $data_system.elements[j] + FEAWORDS[i] + equip.name if i == 31 unless equip.sname?
equip.name = FEAWORDS[i] + $data_system.elements[j] + equip.name if i == 11 unless equip.sname?
#equip.description = equip.description + " " + FEA[i] + ":" + $data_system.elements[j] + " " if i == 31
#equip.description = equip.description + " " + $data_system.elements[j] + FEA[i] + "+" + value.to_s + "% " if i == 11
when 13,14,32 # 状态相关
value = [[value, level * 5].max, 99].min
j = rand(9)
j = [[j,2].max,8].min
equip.features << RPG::BaseItem::Feature.new(i, j, value)
equip.name = FEAWORDS[i] + $data_states[j].name + equip.name if i != 32 unless equip.sname?
equip.name = $data_states[j].name + FEAWORDS[i] + equip.name if i == 32 unless equip.sname?
#equip.description = equip.description + " " + FEA[i] + value.to_s + "%" + "附加" + $data_states[j].name + " "if i == 32
value = 100 - value
#equip.description = equip.description + " " + $data_states[j].name + FEA[i] + "+" + value.to_s + "% " if i == 13
#equip.description = equip.description + " " + FEA[i] + $data_states[j].name + " " if i == 14
when 22 # 强化能力
j = rand(10)
value = [[value, level * 5].max, level * 10].min
equip.features << RPG::BaseItem::Feature.new(i, j, value)
equip.name = FEAWORDS[i][j] + equip.name unless equip.sname?
#equip.description = equip.description + " " + FEA[i][j] + "+" + value.to_s + "% "
when 23 # 特殊能力
j = rand(10)
value = value + 100
value = rand(100) if j == 4
value = [[value, level * 5].max, level * 100].min
equip.features << RPG::BaseItem::Feature.new(i, j, value)
equip.name = FEAWORDS[i][j] + equip.name unless equip.sname?
#equip.description = equip.description + " " + FEA[i][j] + "*" + value.to_s + "% "
when 43 # 技能赋予
j = FEA[i][1].random([1 / FEA[i][1].size.to_f] * FEA[i][1].size)
index = FEA[i][1].index(j)
equip.features << RPG::BaseItem::Feature.new(i, j, 0)
equip.name = $data_skills[FEA[i][1][index]].name + equip.name unless equip.sname?
#equip.description = equip.description + " " + FEA[i][0] + ":" + $data_skills[FEA[i][1][index]].name + " "
when 64 # 队伍能力
j = rand(6)
equip.features << RPG::BaseItem::Feature.new(i, j, 0)
equip.name = FEAWORDS[i][j] + equip.name unless equip.sname?
#equip.description = equip.description + " " + FEA[i][j] + " "
end
if @new_weapon
@new_weapon = equip
@new_weapon.features = equip.features
elsif @new_armor
@new_armor = equip
@new_armor.features = equip.features
end
end
def randst
s = rand(@point) + 1
s
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 绘制物品名称
# enabled : 有效的标志。false 的时候使用半透明效果绘制
#--------------------------------------------------------------------------
def draw_item_name(item, x, y, enabled = true, width = 172)
return unless item
draw_icon(item.icon_index, x, y, enabled)
change_color(normal_color, enabled)
case item.level
when 1
change_color(Color.new(100, 100, 255), enabled)
when 2
change_color(Color.new(255, 255, 50), enabled)
when 3
change_color(Color.new(255, 155, 50), enabled)
when 4
change_color(Color.new(250, 0, 250), enabled)
when 5
change_color(Color.new(255, 100, 100), enabled)
end
draw_text(x + 24, y, width, line_height, item.name)
change_color(normal_color, enabled)
end
end