Relevant code to save some search time:
Ghoul racial
Code:
newTalent{
name = "Ghoul",
type = {"undead/ghoul", 1},
mode = "passive",
require = undeads_req1,
points = 5,
statBonus = function(self, t) return math.ceil(self:combatTalentScale(t, 2, 15, 0.75)) end,
getMaxDamage = function(self, t) return math.max(50, 100 - self:getTalentLevelRaw(t) * 10) end,
passives = function(self, t, p)
self:talentTemporaryValue(p, "inc_stats", {[self.STAT_STR]=t.statBonus(self, t)})
self:talentTemporaryValue(p, "inc_stats", {[self.STAT_CON]=t.statBonus(self, t)})
self:talentTemporaryValue(p, "flat_damage_cap", {all=t.getMaxDamage(self, t)})
end,
info = function(self, t)
return ([[Improves your ghoulish body, increasing Strength and Constitution by %d.
Your body also becomes incredibly resilient to damage, you can never take a blow that deals more than %d%% of your maximum life.]])
:format(t.statBonus(self, t), t.getMaxDamage(self, t))
end,
}
Where the reduction is handled (actor.lua)
Code:
if self.flat_damage_cap and self.max_life and death_note and death_note.damtype then
local cap = nil
if self.flat_damage_cap.all then cap = self.flat_damage_cap.all end
if self.flat_damage_cap[death_note.damtype] then cap = self.flat_damage_cap[death_note.damtype] end
if cap and cap > 0 then
local ignored = math.max(0, value - cap * self.max_life / 100)
if ignored > 0 then game:delayedLogDamage(src, self, 0, ("#LIGHT_GREY#(%d resilience)#LAST#"):format(ignored), false) end
value = value - ignored
print("[TAKE HIT] after flat damage cap", value)
end
end