class Game_Party
#==========================================================================
# 武器
#==========================================================================
def gain_weapon(weapon_id, n)
if weapon_id > 0
# 装备栏中卸下的武器、物品栏里卸下的武器
if $scene.is_a?(Scene_Equip) or $scene.is_a?(Scene_Shop)
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
else
# 随机浮动范围~
add_atk = rand(100) - 20
if add_atk == 0
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
else
now = 0
# 判断数据库中是否已经有 相同属性的武器~
for i in weapon_id...$data_weapons.size
if $data_weapons[i].atk == $data_weapons[weapon_id].atk+add_atk and
($data_weapons[i].name.split('+')[0] == $data_weapons[weapon_id].name or $data_weapons[i].name.split('-')[0] == $data_weapons[weapon_id].name)
now = i
break
end
end
if now == 0
# 无相同属性时则 重新生成~
new_weapon = $data_weapons[weapon_id].clone
new_weapon.id = $data_weapons.size
case add_atk
when 1..29
new_weapon.name = "粗糙的 " + $data_weapons[weapon_id].name+"+"
when 30..69
new_weapon.name = "精良的 " + $data_weapons[weapon_id].name+"+"
when 70..100
new_weapon.name = "极品的 " + $data_weapons[weapon_id].name+"+"
else
new_weapon.name = "破烂的 " + $data_weapons[weapon_id].name+"-"
end
new_weapon.atk = $data_weapons[weapon_id].atk+add_atk
$data_weapons.push(new_weapon)
# 职业可装备武器数组更新~
for i in 1...$data_classes.size
if $data_classes[i].weapon_set.include?(weapon_id)
$data_classes[i].weapon_set.push(new_weapon.id)
end
end
# 增加武器~
@weapons[new_weapon.id] = [[weapon_number(new_weapon.id) + n, 0].max, 99].min
else
# 有相同属性则直接 增加武器~
@weapons[now] = [[weapon_number(now) + n, 0].max, 99].min
end
end
end
end
end
def lose_weapon(weapon_id, n)
if weapon_id > 0
@weapons[weapon_id] = [[weapon_number(weapon_id) - n, 0].max, 99].min
end
end
#==========================================================================
# 防具
#==========================================================================
def gain_armor(armor_id, n)
if armor_id > 0
#
if $scene.is_a?(Scene_Equip) or $scene.is_a?(Scene_Shop)
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
else
# 随机浮动范围~
add_rand = (0...6).inject([]){|a,i|a<<rand(50)-25}
# 生成对应属性
add_attribute = ["pdef", "mdef", "str_plus", "dex_plus", "agi_plus", "int_plus"]
# 6次随机数有属性一致几率很小,直接生成
new_armor = $data_armors[armor_id].clone
new_armor.id = $data_armors.size
# 迭代,增加属性
6.times{|i|eval("new_armor.#{add_attribute[i]} += #{add_rand[i]} if new_armor.#{add_attribute[i]} > 0")}
# 生成名称
for i in 0...add_rand.size
add_rand[i] = 0 unless eval("new_armor.#{add_attribute[i]} > 0")
end
case add_rand.inject(0){|a,b|a+b}
when -25*6...-10*6
new_armor.name ="破烂的 " + $data_armors[armor_id].name
when -10*6...0
new_armor.name ="粗糙的 " + $data_armors[armor_id].name
when 1...10*6
new_armor.name ="精良的 " + $data_armors[armor_id].name
when 10*6...25*6
new_armor.name ="极品的 " + $data_armors[armor_id].name
end
# 数据库生成数据
$data_armors << new_armor
($data_classes.size-1).times{|i|$data_classes[i+1].armor_set.push(new_armor.id) unless $data_classes[i+1].armor_set.include?(new_armor)}
@armors[new_armor.id] = [[armor_number(new_armor.id) + n, 0].max, 99].min
end
end
end
def lose_armor(armor_id, n)
if armor_id > 0
@armors[armor_id] = [[armor_number(armor_id) - n, 0].max, 99].min
end
end
end