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

Project1

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

[已经解决] 能否个别设定战斗后获得的奖励?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
35
在线时间
2 小时
注册时间
2019-2-12
帖子
2
跳转到指定楼层
1
发表于 2019-2-12 15:59:01 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
就是同一个敌人在不个的敌群内,战斗获胜后所获得的经验值、金钱、掉落品都不同

或是改为同一个敌人如果在A敌群内,战斗获胜后不会获得任何奖励,只有在B敌群战胜时才会有奖励

请问能够做到吗?

Lv5.捕梦者

梦石
10
星屑
39440
在线时间
1914 小时
注册时间
2010-11-14
帖子
3315

R考场第七期纪念奖

2
发表于 2019-2-12 18:09:33 | 只看该作者
本帖最后由 KB.Driver 于 2019-2-12 18:10 编辑

Project1.zip (1.43 MB, 下载次数: 50)



RUBY 代码复制
  1. =begin
  2. 例:敌人备注写
  3.  
  4. <掉落物 敌群:1>
  5. 经验:100
  6. 金钱:100
  7. 物品:1(2) # 1号物品 1/2概率获得
  8. 武器:2(3) # 2号武器 1/3概率获得
  9. 防具:3(4) # 3号防具 1/4概率获得
  10. </掉落物>
  11.  
  12. =end
  13. class RPG::Enemy
  14.  
  15.   DROP_TAG = "(?:掉落物|drop_item)"
  16.  
  17.   TROOP_REG = "[ ]*(?:敌群|troop)[ :=]*"
  18.  
  19.   CUSTOM_DROP_REG = /<#{DROP_TAG}#{TROOP_REG}(\d+)>((?:\s*\S\s*)+)<\/#{DROP_TAG}>/mi
  20.  
  21.   CUSTOM_EXP_REG = /(?:经验|exp)[ :=]*(\d+)/mi
  22.  
  23.   CUSTOM_GOLD_REG = /(?:金钱|gold)[ :=]*(\d+)/mi
  24.  
  25.   CUSTOM_ITEM_REG = /(?:物品|item|武器|weapon|防具|armor)[ :=]*\d+\(\d+\)/mi
  26.  
  27.   def drop_notes
  28.     self.note =~ CUSTOM_DROP_REG ? [$1, $2] : nil
  29.   end
  30.  
  31.   def drop_condition?
  32.     return false unless drop_notes
  33.     $game_troop.troop_id == drop_notes[0].to_i
  34.   end
  35.  
  36.   alias exp_for_custom exp
  37.   def exp
  38.     drop_condition? ? custom_exp : exp_for_custom
  39.   end
  40.  
  41.   def custom_exp
  42.     drop_notes[1] =~ CUSTOM_EXP_REG ? $1.to_i : exp_for_custom
  43.   end
  44.  
  45.   alias gold_for_custom gold
  46.   def gold
  47.     drop_condition? ? custom_gold : gold_for_custom
  48.   end
  49.  
  50.   def custom_gold
  51.     drop_notes[1] =~ CUSTOM_GOLD_REG ? $1.to_i : gold_for_custom
  52.   end
  53.  
  54.   alias drop_items_for_custom drop_items
  55.   def drop_items
  56.     drop_condition? ? custom_drop_items : drop_items_for_custom
  57.   end
  58.  
  59.   def custom_drop_items
  60.     droping_items = drop_notes[1].scan(CUSTOM_ITEM_REG)
  61.     return drop_items_for_custom if droping_items.empty?
  62.     droping_items.inject([]) do |r,s|
  63.       item = RPG::Enemy::DropItem.new
  64.       if    s =~ /物品|item/   then item.kind = 1
  65.       elsif s =~ /武器|weapon/ then item.kind = 2
  66.       elsif s =~ /防具|armor/  then item.kind = 3
  67.       end
  68.       item.data_id     = $1.to_i if s =~ /(\d+)/
  69.       item.denominator = $1.to_i if s =~ /\((\d+)\)/
  70.       r << item
  71.     end
  72.   end
  73.  
  74. end
  75.  
  76. class Game_Troop
  77.   attr_reader :troop_id
  78. end

点评

成功,谢谢!  发表于 2019-2-13 18:47

评分

参与人数 1星屑 +40 收起 理由
VIPArcher + 40 认可答案

查看全部评分

用头画头像,用脚写脚本
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-24 00:14

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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