File size: 899 Bytes
b6a38d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- ========== GENERATED BY CharacterEffectCompositeDef Editor DO NOT EDIT MANUALLY! ==========

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()  -- without wounds
					local hpLoseAt = MulDivRound(maxHp, CageFightingLostAtPercent, 100)
					if hpTotal < hpLoseAt then
						Msg("CageFightingLose", target)
						return target.HitPoints - hpLoseAt
					end
				end
			end,
		}),
	},
}