查看: 2367|回复: 2

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

[复制链接]
梦石
0
星屑
35
在线时间
2 小时
注册时间
2019-2-12
回帖
1
发表于 2019-2-12 15:59:01 | 显示全部楼层 |阅读模式

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

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

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

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

请问能够做到吗?
梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2019-2-12 18:09:33 | 显示全部楼层
本帖最后由 KB.Driver 于 2019-2-12 18:10 编辑

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

QQ截图20190212181047.png

[pre lang="ruby"]=begin
例:敌人备注写

<掉落物 敌群:1>
经验:100
金钱:100
物品:1(2) # 1号物品 1/2概率获得
武器:2(3) # 2号武器 1/3概率获得
防具:3(4) # 3号防具 1/4概率获得
</掉落物>

=end
class RPG::Enemy
  
  DROP_TAG = "(?:掉落物|drop_item)"
  
  TROOP_REG = "[ ]*(?:敌群|troop)[ :=]*"
  
  CUSTOM_DROP_REG = /<#{DROP_TAG}#{TROOP_REG}(\d+)>((?:\s*\S\s*)+)<\/#{DROP_TAG}>/mi
  
  CUSTOM_EXP_REG = /(?:经验|exp)[ :=]*(\d+)/mi
  
  CUSTOM_GOLD_REG = /(?:金钱|gold)[ :=]*(\d+)/mi
  
  CUSTOM_ITEM_REG = /(?:物品|item|武器|weapon|防具|armor)[ :=]*\d+\(\d+\)/mi
  
  def drop_notes
    self.note =~ CUSTOM_DROP_REG ? [$1, $2] : nil
  end
  
  def drop_condition?
    return false unless drop_notes
    $game_troop.troop_id == drop_notes[0].to_i
  end
  
  alias exp_for_custom exp
  def exp
    drop_condition? ? custom_exp : exp_for_custom
  end
  
  def custom_exp
    drop_notes[1] =~ CUSTOM_EXP_REG ? $1.to_i : exp_for_custom
  end
  
  alias gold_for_custom gold
  def gold
    drop_condition? ? custom_gold : gold_for_custom
  end
  
  def custom_gold
    drop_notes[1] =~ CUSTOM_GOLD_REG ? $1.to_i : gold_for_custom
  end
  
  alias drop_items_for_custom drop_items
  def drop_items
    drop_condition? ? custom_drop_items : drop_items_for_custom
  end
  
  def custom_drop_items
    droping_items = drop_notes[1].scan(CUSTOM_ITEM_REG)
    return drop_items_for_custom if droping_items.empty?
    droping_items.inject([]) do |r,s|
      item = RPG::Enemy::DropItem.new
      if    s =~ /物品|item/   then item.kind = 1
      elsif s =~ /武器|weapon/ then item.kind = 2
      elsif s =~ /防具|armor/  then item.kind = 3
      end
      item.data_id     = $1.to_i if s =~ /(\d+)/
      item.denominator = $1.to_i if s =~ /\((\d+)\)/
      r << item
    end
  end
  
end

class Game_Troop
  attr_reader :troop_id
end[/pre]

点评

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

评分

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

查看全部评分

用头画头像,用脚写脚本
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部