查看: 3018|回复: 5

[已经解决] 请教状态脚本,中了状态无法治疗或者治疗就减血

[复制链接]
梦石
0
星屑
1182
在线时间
179 小时
注册时间
2018-11-6
回帖
26
发表于 2019-4-29 12:05:40 | 显示全部楼层 |阅读模式

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

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

×
就是中了状态无法治疗或者治疗就减血,加多少扣多少血量,感谢!!
梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2019-4-29 16:49:25 | 显示全部楼层
本帖最后由 KB.Driver 于 2019-4-29 21:46 编辑

[pre lang="ruby"]#==============================================================================
# ■ 禁疗/治疗反转 by Calendar99
#------------------------------------------------------------------------------
#  可以制作禁疗/治疗反转的效果
#   状态备注中写<治疗效果 xx%>
#   比如<治疗效果 0%>为禁疗,<治疗效果 -100%>为完全治疗反转
#==============================================================================

class RPG::State
  
  TAG_HEAL_EFFECT = "(?:治疗效果|heal_effect)"
  
  def heal_effect
    tag = TAG_HEAL_EFFECT
    int = "[ :=]*"
    cap = "(-?[0-9]*)%?"
    reg = /<#{tag}#{int}#{cap}>/
    m = self.note.match(reg)
    m ? m[1].to_i / 100.0 : 1.0
  end
  
  def heal_reverse?
    heal_effect < 0.0
  end
  
  def heal_forbidden?
    heal_effect == 0.0
  end
  
end

class Game_Battler
  #--------------------------------------------------------------------------
  # ● [追加]被禁疗?
  #--------------------------------------------------------------------------
  def heal_forbidden?
    states.any?{|s| s.heal_forbidden?}
  end
  #--------------------------------------------------------------------------
  # ● [追加]被治疗反转?
  #--------------------------------------------------------------------------
  def heal_reverse?
    !heal_forbidden? && states.any?{|s| s.heal_reverse?}
  end
  #--------------------------------------------------------------------------
  # ● [追加]额外治疗效果
  #--------------------------------------------------------------------------
  def extra_heal_effect(heal_reverse = false)
    heal_states = states.select{|s| s.heal_effect != 1.0}
    return 1.0 if heal_states.empty?
    effects = heal_states.collect{|s| s.heal_effect}.sort
    heal_reverse ? effects.first : effects.last
  end
  #--------------------------------------------------------------------------
  # ● [别名修改]处理伤害
  #--------------------------------------------------------------------------
  alias execute_damage_cld99_20190429 execute_damage
  def execute_damage(user)
    if self.heal_forbidden?
      execute_damage_heal_forbidden(user) # 禁疗
    elsif self.heal_reverse?
      execute_damage_heal_reverse(user) # 治疗反转
    else
      execute_damage_cld99_20190429(user) # 原方法
    end
  end
  #--------------------------------------------------------------------------
  # ● [追加]禁疗下的处理伤害
  #--------------------------------------------------------------------------
  def execute_damage_heal_forbidden(user)
    if @result.hp_damage > 0
      on_damage(@result.hp_damage)
      self.hp -= @result.hp_damage
    end
    self.mp -= @result.mp_damage
    user.hp += @result.hp_drain
    user.mp += @result.mp_drain
  end
  #--------------------------------------------------------------------------
  # ● [追加]治疗反转下的处理伤害
  #--------------------------------------------------------------------------
  def execute_damage_heal_reverse(user)
    if @result.hp_damage > 0
      on_damage(@result.hp_damage)
      self.hp -= @result.hp_damage
    elsif @result.hp_damage < 0
      self.hp -= @result.hp_damage * extra_heal_effect(heal_reverse = true)
    end
    self.mp -= @result.mp_damage
    user.hp += @result.hp_drain
    user.mp += @result.mp_drain
  end
end[/pre]

新建工程测试通过,其他问题不负责了。

评分

参与人数 2星屑 +50 赞 +1 收起 理由
VIPArcher + 50 认可答案
leontonydz + 1 我很赞同

查看全部评分

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

使用道具 举报

梦石
0
星屑
1182
在线时间
179 小时
注册时间
2018-11-6
回帖
26
 楼主| 发表于 2019-4-29 19:56:36 | 显示全部楼层
大佬太感谢了!!
回复

使用道具 举报

梦石
0
星屑
1182
在线时间
179 小时
注册时间
2018-11-6
回帖
26
 楼主| 发表于 2019-4-29 20:01:20 | 显示全部楼层
KB.Driver 发表于 2019-4-29 16:49
#==============================================================================
# ■ 禁疗/治疗反转 b ...

大佬,再请教一下我用RGD好像跟怪物图鉴不兼容,是什么原因?

点评

不是说其他问题不负责了吗  发表于 2019-4-29 21:44
回复

使用道具 举报

梦石
0
星屑
1182
在线时间
179 小时
注册时间
2018-11-6
回帖
26
 楼主| 发表于 2019-4-29 22:01:47 | 显示全部楼层
leontonydz 发表于 2019-4-29 20:01
大佬,再请教一下我用RGD好像跟怪物图鉴不兼容,是什么原因?

大佬,这个脚本没问题,我是想就这个主题请教一个新问题
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部