#==============================================================================
# ■ 禁疗/治疗反转 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