maxvalue1 = 0
for t in 1..maxvalue * 10
maxvalue1 = maxvalue1 + t
end
iret = rand(maxvalue1) + 1
itemp = 0
#数值越大,出现几率越小
maxvalue1 = 0
for t in 1..maxvalue * 10
maxvalue1 = maxvalue1 + t
if iret >= (maxvalue1 - t) and iret < maxvalue1 then
break
end
end
iret = (maxvalue * 10 - t).abs
if iret == 0
iret = 1
end
#10%出现增减物防
if r > 40 and r <= 50 then
#变化的攻击力=武器级别 * 10 的随机数 +-各半
itemp = Setrand(tt)
iprice = iprice + itemp * 300
pdef = pdef + itemp
sdce = sdce + "物防+" + itemp.to_s + ";"
$data_weapons[t].pdef = pdef
$data_weapons[t].atk = atk
sname = '物防之'
end
#10%出现增减魔防
if r > 50 and r <= 60 then
#变化的攻击力=武器级别 * 10 的随机数 +-各半
itemp = Setrand(tt)
iprice = iprice + itemp * 400
mdef = mdef + itemp
sdce = sdce + "魔防+" + itemp.to_s + ";"
$data_weapons[t].mdef = mdef
$data_weapons[t].atk = atk
sname = '魔防之'
end
#5%出现增减力量
if r > 60 and r <= 65 then
#变化的攻击力=武器级别 * 10 的随机数 +-各半
itemp = Setrand(tt)
iprice = iprice + itemp * 500
str_plus = str_plus + itemp
sdce = sdce + '力量+' + itemp.to_s + ';'
$data_weapons[t].str_plus = str_plus
$data_weapons[t].atk = atk
sname = '力量之'
end
#5%出现增减力量
if r > 65 and r <= 70 then
#变化的攻击力=武器级别 * 10 的随机数 +-各半
itemp = Setrand(tt)
iprice = iprice + itemp * 500
dex_plus = dex_plus + itemp
sdce = sdce + '灵巧+' + itemp.to_s + ';'
$data_weapons[t].dex_plus = dex_plus
$data_weapons[t].atk = atk
sname = '灵巧之'
end
#5%出现增减力量
if r > 70 and r <= 75 then
#变化的攻击力=武器级别 * 10 的随机数 +-各半
itemp = Setrand(tt)
iprice = iprice + itemp * 500
agi_plus = agi_plus + itemp
$data_weapons[t].agi_plus = agi_plus
sdce = sdce + '速度+' + itemp.to_s + ';'
$data_weapons[t].atk = atk
sname = '速度之'
end
#5%出现增减力量
if r > 75 and r <= 80 then
#变化的攻击力=武器级别 * 10 的随机数 +-各半
itemp = Setrand(tt)
iprice = iprice + itemp * 500
int_plus = int_plus + itemp
sdce = sdce + '魔力+' + itemp.to_s + ';'
$data_weapons[t].int_plus = int_plus
$data_weapons[t].atk = atk
sname = '魔力之'
end
#5%出现增减属性
if r > 80 and r <= 90 and $data_weapons[t].element_set.size < 9 then
r1 = rand(9) + 1
isize = $data_weapons[t].element_set.size
loop do
if isize > 0 then
for ttt in 1..isize
if $data_weapons[t].element_set[ttt] == r1 then
break
end
end
if ttt > isize then
break
end
else
break
end
r1 = rand(9) + 1
end
iprice = iprice + 10000
$data_weapons[t].element_set[isize + 1] = r1
$data_weapons[t].atk = atk
case r1
when 1
sname = '物理之'
sdce = sdce + '+物理属性;'
when 2
sname = '光之'
sdce = sdce + '+光属性;'
when 3
sname = '冰之'
sdce = sdce + '+冰属性;'
when 4
sname = '毒之'
sdce = sdce + '+毒属性;'
when 5
sname = '炎之'
sdce = sdce + '+炎属性;'
when 6
sname = '雷之'
sdce = sdce + '+雷属性;'
when 7
sname = '圣之'
sdce = sdce + '+圣属性;'
when 8
sname = '暗之'
sdce = sdce + '+暗属性;'
when 9
sname = '无之'
sdce = sdce + '+无属性;'
end
end
if (r > 90) then
sname = ''
end
#随即计算名称
$data_weapons[t].name = sname + name
$data_weapons[t].description = sdce
iprice = (iprice/100 + 0.6).to_i * 100
$data_weapons[t].price = iprice