DaggorathMaster wrote: ↑Wed Jul 19, 2023 2:57 pmIt accepts damage type, but doesn't know about the attack's "pierce" rating, so how can it do anything but raw damage, in which case why does it take damage type in the first place (unless it's sound or something superficial)?
The damage type is used to determine whether to apply fire/cold/shock/poison resistance, and is also passed to the party's onDamage hook. Also, if the damage type is "dispel", the function call has no effect.
Damage type does not interact with pierce or protection. Here's the source code of Champion:damage() from the umod pack:
Code: Select all
function Champion:damage(dmg, damageType)
damageType = damageType or "physical"
dmg = math.floor(dmg)
if damageType == "dispel" then return end
if self:isAlive() and not self:hasCondition("petrified") then
-- apply damage resistance
if damageType ~= "physical" and damageType ~= "drowning" and damageType ~= "pure" then
local resist = self:getResistance(damageType)
if resist == 100 then
dmg = 0
elseif resist > 0 then
dmg = math.floor(dmg * (100 - resist) / 100 + 0.5)
end
end
if party:callHook("onDamage", objectToProxy(self), dmg, damageType) == false then
return
end
-- trigger minotaur rage?
if self:hasTrait("rage") then
local oldHealth = self:getHealth() / self:getMaxHealth()
local newHealth = (self:getHealth() - dmg) / self:getMaxHealth()
local threshold = 0.2
if oldHealth > threshold and newHealth <= threshold then
self:setConditionValue("rage", self:getConditionValue("rage") + 20)
end
end
if dmg > 0 then
self:modifyBaseStat("health", -dmg)
self:showDamageIndicator(dmg)
messageSystem:sendMessageNEW("onChampionDamaged", self, dmg, damageType)
end
-- champion died?
if not self:isAlive() then
if party:callHook("onDie", objectToProxy(self)) == false then
if self:getBaseStat("health") < 1 then self:setBaseStat("health", 1) end
return
end
self:die()
end
end
end