|
|
|
|
|
UndefineClass('CageFighting') |
|
DefineClass.CageFighting = { |
|
__parents = { "CharacterEffect" }, |
|
__generated_by_class = "CharacterEffectCompositeDef", |
|
|
|
|
|
object_class = "CharacterEffect", |
|
unit_reactions = { |
|
PlaceObj('UnitReaction', { |
|
Event = "PreUnitTakeDamage", |
|
Handler = function (self, target, damage, attacker, attack_target, hit) |
|
if target:HasStatusEffect("CageFightingToTheDeath") then return end |
|
|
|
if target == attack_target then |
|
local hpTotal = Max(0, target.HitPoints - damage) |
|
local maxHp = target:GetInitialMaxHitPoints() |
|
local hpLoseAt = MulDivRound(maxHp, CageFightingLostAtPercent, 100) |
|
if hpTotal < hpLoseAt then |
|
Msg("CageFightingLose", target) |
|
return target.HitPoints - hpLoseAt |
|
end |
|
end |
|
end, |
|
}), |
|
}, |
|
} |
|
|
|
|