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

Project1

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

[原创发布] 随机武器

[复制链接]

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
跳转到指定楼层
1
发表于 2014-1-5 08:03:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 恐惧剑刃 于 2014-7-16 23:26 编辑

简单示例请自改
  1. # 随机武器
  2. # 好吧不是一次看到随机装备的问题了
  3. # 其实很简单
  4. # 原理
  5. # 由于RPG::Weapon中定义的属性均可写可读,因此可以如此
  6. weapon_hash = {}
  7. for i in 1..999
  8.   weapon_hash[i] = RPG::Weapon.new
  9.   weapon_hash[i].id = i
  10.   # ----------------------
  11.   # 名字随机的简单示例
  12.   random_name = ""
  13.   # 武器材质
  14.   str_1 = ["铜", "钢", "精铁", "石", "木"]
  15.   yy = str_1[rand(str_1.size)]
  16.   # 武器类型
  17.   str_2 = ["剑", "刀", "枪", "棍", "弓"]
  18.   mm = str_2[rand(str_2.size)]
  19.   random_name << yy << mm
  20.   # 根据材质生成说明
  21.   description = ""
  22.   description << yy << "锻造的" << mm << "。"
  23.   # 根据材质好坏判断价格
  24.   case yy
  25.   when "木"
  26.     price = (a=[*100..200])[rand(a.size)]
  27.   when "石"
  28.     price = (a=[*201..300])[rand(a.size)]
  29.   when "铜"
  30.     price = (a=[*401..500])[rand(a.size)]
  31.   when "精铁"
  32.     price = (a=[*501..600])[rand(a.size)]
  33.   when "钢"
  34.     price = (a=[*601..700])[rand(a.size)]
  35.   end
  36.   # 根据材质好坏判断atk
  37.   case yy
  38.   when "木"
  39.     atk = (a=[*50..100])[rand(a.size)]
  40.   when "石"
  41.     atk = (a=[*101..150])[rand(a.size)]
  42.   when "铜"
  43.     atk = (a=[*151..200])[rand(a.size)]
  44.   when "精铁"
  45.     atk = (a=[*251..300])[rand(a.size)]
  46.   when "钢"
  47.     atk = (a=[*301..400])[rand(a.size)]
  48.   end
  49.   # 示例 0 也可自行随机
  50.   # 物理防御
  51.   pdef = 0
  52.   # 魔法防御
  53.   mdef = 0
  54.   # 力量+
  55.   str_plus = 0
  56.   # 灵巧+
  57.   dex_plus = 0
  58.   # 速度+
  59.   agi_plus = 0
  60.   # 魔力+
  61.   int_plus = 0
  62.   # 附加的属性id的数组
  63.   element_set = []
  64.   # 附加的状态id的数组
  65.   plus_state_set = []
  66.   # 解除的状态id的数组
  67.   minus_state_set = []
  68.   # ----------------------
  69.   weapon_hash[i].name = random_name
  70.   # ----------------------
  71.   # 图标随机的简单示例
  72.   random_icon_name = ""
  73.   str = ["001-Action01.png", "002-Action02.png", "003-Attack01.png",
  74.   "004-Attack02.png", "005-Attack03.png"]
  75.   random_icon_name << str[rand(str.size)]
  76.   # ----------------------
  77.   weapon_hash[i].icon_name = random_icon_name
  78.   weapon_hash[i].icon_name = random_icon_name
  79.   weapon_hash[i].description = description
  80.   # --------------------------------------------
  81.   # 攻击方动画id 示例为 1-10 号动画为特定攻击动画
  82.   # 对象方动画id 示例为 11-20 号动画为特定攻击动画
  83.   # --------------------------------------------
  84.   weapon_hash[i].animation1_id = [*1..10][rand(10)]
  85.   weapon_hash[i].animation2_id = [*11..20][rand(10)]
  86.   weapon_hash[i].price = price
  87.   weapon_hash[i].atk = atk
  88.   weapon_hash[i].pdef = pdef
  89.   weapon_hash[i].mdef = mdef
  90.   weapon_hash[i].str_plus = str_plus
  91.   weapon_hash[i].dex_plus = dex_plus
  92.   weapon_hash[i].agi_plus = agi_plus
  93.   weapon_hash[i].int_plus = int_plus
  94.   weapon_hash[i].element_set = element_set
  95.   weapon_hash[i].plus_state_set = plus_state_set
  96.   weapon_hash[i].minus_state_set = minus_state_set
  97. end
  98. # 直接改Data
  99. file = File.open("Data/Weapons.rxdata", "wb")
  100. Marshal.dump(weapon_hash, file)
  101. file.close

  102. print "成功,请重新打开工程查看数据库中的随机效果吧"
  103. exit
复制代码

评分

参与人数 1星屑 +350 梦石 +1 收起 理由
怪蜀黍 + 350 + 1 发布奖励!

查看全部评分

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

2
发表于 2014-1-5 13:52:31 | 只看该作者
要关掉工程再运行这个脚本给数据库增加武器的意思吗?
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
152
在线时间
201 小时
注册时间
2014-2-24
帖子
125
3
发表于 2014-4-30 21:55:35 | 只看该作者
再也不用担心武器没有名字啦······

点评

噗……好生动的广告词  发表于 2014-5-5 14:21
好尴尬
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
11 小时
注册时间
2010-8-14
帖子
3
4
发表于 2014-7-16 20:47:11 | 只看该作者
貌似好东西啊啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-5-13 07:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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