Project1
标题:
随机武器
[打印本页]
作者:
恐惧剑刃
时间:
2014-1-5 08:03
标题:
随机武器
本帖最后由 恐惧剑刃 于 2014-7-16 23:26 编辑
简单示例请自改
# 随机武器
# 好吧不是一次看到随机装备的问题了
# 其实很简单
# 原理
# 由于RPG::Weapon中定义的属性均可写可读,因此可以如此
weapon_hash = {}
for i in 1..999
weapon_hash[i] = RPG::Weapon.new
weapon_hash[i].id = i
# ----------------------
# 名字随机的简单示例
random_name = ""
# 武器材质
str_1 = ["铜", "钢", "精铁", "石", "木"]
yy = str_1[rand(str_1.size)]
# 武器类型
str_2 = ["剑", "刀", "枪", "棍", "弓"]
mm = str_2[rand(str_2.size)]
random_name << yy << mm
# 根据材质生成说明
description = ""
description << yy << "锻造的" << mm << "。"
# 根据材质好坏判断价格
case yy
when "木"
price = (a=[*100..200])[rand(a.size)]
when "石"
price = (a=[*201..300])[rand(a.size)]
when "铜"
price = (a=[*401..500])[rand(a.size)]
when "精铁"
price = (a=[*501..600])[rand(a.size)]
when "钢"
price = (a=[*601..700])[rand(a.size)]
end
# 根据材质好坏判断atk
case yy
when "木"
atk = (a=[*50..100])[rand(a.size)]
when "石"
atk = (a=[*101..150])[rand(a.size)]
when "铜"
atk = (a=[*151..200])[rand(a.size)]
when "精铁"
atk = (a=[*251..300])[rand(a.size)]
when "钢"
atk = (a=[*301..400])[rand(a.size)]
end
# 示例 0 也可自行随机
# 物理防御
pdef = 0
# 魔法防御
mdef = 0
# 力量+
str_plus = 0
# 灵巧+
dex_plus = 0
# 速度+
agi_plus = 0
# 魔力+
int_plus = 0
# 附加的属性id的数组
element_set = []
# 附加的状态id的数组
plus_state_set = []
# 解除的状态id的数组
minus_state_set = []
# ----------------------
weapon_hash[i].name = random_name
# ----------------------
# 图标随机的简单示例
random_icon_name = ""
str = ["001-Action01.png", "002-Action02.png", "003-Attack01.png",
"004-Attack02.png", "005-Attack03.png"]
random_icon_name << str[rand(str.size)]
# ----------------------
weapon_hash[i].icon_name = random_icon_name
weapon_hash[i].icon_name = random_icon_name
weapon_hash[i].description = description
# --------------------------------------------
# 攻击方动画id 示例为 1-10 号动画为特定攻击动画
# 对象方动画id 示例为 11-20 号动画为特定攻击动画
# --------------------------------------------
weapon_hash[i].animation1_id = [*1..10][rand(10)]
weapon_hash[i].animation2_id = [*11..20][rand(10)]
weapon_hash[i].price = price
weapon_hash[i].atk = atk
weapon_hash[i].pdef = pdef
weapon_hash[i].mdef = mdef
weapon_hash[i].str_plus = str_plus
weapon_hash[i].dex_plus = dex_plus
weapon_hash[i].agi_plus = agi_plus
weapon_hash[i].int_plus = int_plus
weapon_hash[i].element_set = element_set
weapon_hash[i].plus_state_set = plus_state_set
weapon_hash[i].minus_state_set = minus_state_set
end
# 直接改Data
file = File.open("Data/Weapons.rxdata", "wb")
Marshal.dump(weapon_hash, file)
file.close
print "成功,请重新打开工程查看数据库中的随机效果吧"
exit
复制代码
作者:
chd114
时间:
2014-1-5 13:52
要关掉工程再运行这个脚本给数据库增加武器的意思吗?
作者:
2537200335
时间:
2014-4-30 21:55
再也不用担心武器没有名字啦······
作者:
dai754814791
时间:
2014-7-16 20:47
貌似好东西啊啊
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1