PDA

View Full Version : damage reduction bug



Evion
May 30th, 2019, 19:11
a player or monster with more then one type of DR (damage reduction shouldn't stack)
DR 5/-
DR 10 evil
DR 15 silver
is reading it as if it was DR 30
we notice this when a 10th level barbarian (Invulnerable Rager) with DR 5/- was given the spell buff stoneskin DR 10 adamantine, the monster did 16 damage and he took 1 point of damage, this also affects the Invulnerable Rager when he takes nonlethal damage (DR 10 nonlethal damage), its stacking with its DR 5/-
the rules for DR state that they don't stack

Damage Reduction :
Some magic creatures have the supernatural ability to instantly heal damage from weapons or ignore blows altogether as though they were invulnerable.

The numerical part of a creature’s damage reduction (or DR) is the amount of damage the creature ignores from normal attacks. Usually, a certain type of weapon can overcome this reduction (see Overcoming DR). This information is separated from the damage reduction number by a slash. For example, DR 5/magic means that a creature takes 5 less points of damage from all weapons that are not magic. If a dash follows the slash, then the damage reduction is effective against any attack that does not ignore damage reduction.

Whenever damage reduction completely negates the damage from an attack, it also negates most special effects that accompany the attack, such as injury poison, a monk’s stunning, and injury-based disease. Damage Reduction does not negate touch attacks, energy damage dealt along with an attack, or energy drains. Nor does it affect poisons or diseases delivered by inhalation, ingestion, or contact.

Attacks that deal no damage because of the target’s damage reduction do not disrupt spells.

Spells, spell-like abilities, and energy attacks (even non-magical fire) ignore damage reduction.

Sometimes damage reduction represents instant healing. Sometimes it represents the creature’s tough hide or body. In either case, other characters can see that conventional attacks won’t work.

If a creature has damage reduction from more than one source, the two forms of damage reduction do not stack. Instead, the creature gets the benefit of the best damage reduction in a given situation.

Svandal
May 31st, 2019, 08:51
a player or monster with more then one type of DR (damage reduction shouldn't stack)
DR 5/-
DR 10 evil
DR 15 silver
is reading it as if it was DR 30
we notice this when a 10th level barbarian (Invulnerable Rager) with DR 5/- was given the spell buff stoneskin DR 10 adamantine, the monster did 16 damage and he took 1 point of damage, this also affects the Invulnerable Rager when he takes nonlethal damage (DR 10 nonlethal damage), its stacking with its DR 5/-
the rules for DR state that they don't stack

Damage Reduction :
Some magic creatures have the supernatural ability to instantly heal damage from weapons or ignore blows altogether as though they were invulnerable.

The numerical part of a creature’s damage reduction (or DR) is the amount of damage the creature ignores from normal attacks. Usually, a certain type of weapon can overcome this reduction (see Overcoming DR). This information is separated from the damage reduction number by a slash. For example, DR 5/magic means that a creature takes 5 less points of damage from all weapons that are not magic. If a dash follows the slash, then the damage reduction is effective against any attack that does not ignore damage reduction.

Whenever damage reduction completely negates the damage from an attack, it also negates most special effects that accompany the attack, such as injury poison, a monk’s stunning, and injury-based disease. Damage Reduction does not negate touch attacks, energy damage dealt along with an attack, or energy drains. Nor does it affect poisons or diseases delivered by inhalation, ingestion, or contact.

Attacks that deal no damage because of the target’s damage reduction do not disrupt spells.

Spells, spell-like abilities, and energy attacks (even non-magical fire) ignore damage reduction.

Sometimes damage reduction represents instant healing. Sometimes it represents the creature’s tough hide or body. In either case, other characters can see that conventional attacks won’t work.

If a creature has damage reduction from more than one source, the two forms of damage reduction do not stack. Instead, the creature gets the benefit of the best damage reduction in a given situation.

As a workaround you can do dr:5 and dr: 5 adamantine for your barbarian with stoneskin.
It might be a reason It is not implementere in the game. For it to work the game has to apply its damage against each of the dr and then take the lowest, which requires some work

Asgurgolas
June 3rd, 2019, 16:14
I may be wrong but I think I recall it working "as intended" in the past (so far it almost never happened to me to have actors with more than one kind of DR at once)

Moon Wizard
June 3rd, 2019, 22:22
I just reviewed the damage automation code; and it's not something that was ever implemented. Probably because it happens so rarely.

The code does already handle the case where damage reduction is applied across multiple damage components that are both resisted by the same DR effect, so that the DR is only applied once.

It will have to be something I look at down the road a bit; because it requires rewriting the logic from scratch to make both scenarios work. I'll add to my list for future version improvements.

Regards,
JPG

Kelrugem
June 3rd, 2019, 23:29
Could that maybe be fixed by the following code? (In manager_action_damage.lua replacing the whole DR function in line 946 to 978 (v. 3.3.8)) New stuff in blue :)


if not bHasEnergyType and (v + nLocalDamageAdjust) > 0 then
local DRFix = {};
local i = 1;
local bMatchAND, nMatchAND, bMatchDMG, aClausesOR;

local bApplyDR;
for _,vDR in pairs(aDR) do
local kDR = table.concat(vDR.remainder, " ");

if kDR == "" or kDR == "-" or kDR == "all" then
bApplyDR = true;
else
bApplyDR = true;
aClausesOR = decodeAndOrClauses(kDR);
if matchAndOrClauses(aClausesOR, aSrcDmgClauseTypes) then
bApplyDR = false;
end
end

if bApplyDR then
local nApplied = vDR.nApplied or 0;
if nApplied < vDR.mod then
local nChange = math.min((vDR.mod - nApplied), v + nLocalDamageAdjust);
vDR.nApplied = nApplied + nChange;
DRFix[i] = nChange;
i = i + 1;
bResist = true;
end
end
end
table.sort(DRFix);
nLocalDamageAdjust = nLocalDamageAdjust - DRFix[#DRFix];
end

Especially the nLocalDamageAdjust-change is now outside the if-clause of bApplyDR :)

Kelrugem
June 3rd, 2019, 23:31
(can somehow not edit my previous post)

In my modding campaign that worked for some little testing; but I didn't test it for a lot of different situations. My idea was just to collect all damage changes coming from all DR effects in the vector DRFix, then (then after the for-loop) I sort them by their values with table.sort such that DRFix[#DRFix] should be the highest value in that table/vector and only that is now used for the change of nLocalDamageAdjust :) So nLocalDamageAdjust is not changed for each DR effect separately but at the end after the for-loop only taking the highest DR. That is at least my idea, not sure if implemented correctly :) But probably I oversee now some other special situation of DR-effects which is not correctly handled by that type of code :D

Moon Wizard
June 4th, 2019, 01:16
You need to be very specific on which damage clauses are affected, so you can't do it after the fact like that. (If you "refund" to the wrong damage type clause, it could throw off any subsequent calculations done within this function or by an extension.) Like I said, it will need to be rewritten completely to account for overlaps both in damage clauses and damage reduction effects.

Regards,
JPG

Kelrugem
June 4th, 2019, 01:17
You need to be very specific on which damage clauses are affected, so you can't do it after the fact like that. (If you "refund" to the wrong damage type clause, it could throw off any subsequent calculations done within this function or by an extension.) Like I said, it will need to be rewritten completely to account for overlaps both in damage clauses and damage reduction effects.

Regards,
JPG

aaah, okay, I understand :) Thanks for the answer :)

EDIT: Indeed, just tested it, for subsequent rolls (like it happens for crits) some error happens :)

Kelrugem
June 8th, 2019, 21:11
There is also a similar bug with "RESIST" etc. which is the reason why I mention it here :) As far as I can see effects like RESIST are not stacking but only in the "classes" of "specific damage types" or "all" or "[no mentioned dmg type]" but there is no connection between these with respect to stacking, i.e. e.g. RESIST: 2 all and RESIST: 1 fire results into resistance of 3 against fire. But that is even a rarer occasion, for completeness I wanted to mention that though (since it is nearly at the same place of the code) :)

EDIT: One mistake, it is more like that RESIST: (N) [damage type] overwrites RESIST: (N) all which overwrites RESIST: (N), regardless of the number (N) :) (maybe I had some other effect on while testing that)

Kelrugem
June 9th, 2019, 01:31
I just find now some other bug related to dmg types (therefore again this thread) :) Now it is a more common situation: VULN doesn't work correctly when there are normal energy types and energy types of critical rolls. See the attached picture: The Aboleth has vulnerability against acid damage and my wolf has some weapon with acid damage and also an effect describing e.g. acid burst. As you can see the vulnerability only increases the damage of one of the damage dice with the type acid. (In that case it was the one of the critical die, the normal acid die is not increased in its damage)

I guess this is due to that the code checks if vulnerability is already applied to avoid doubled uses of vulnerability when one has vulnerability against more than one damage type etc. which is correct but the situation of critical damages has to be treated differently (isn't it?) :)

PS: I am looking at that code because one of my extensions has a similar problem with damage types; this damage type stuff drives me crazy, I believe :D So many different special situations depending on which damage types occur... :D

PPS: How one can embed a picture in a post such that it is shown directly in the post btw? :)

Kelrugem
June 17th, 2019, 04:37
In my upcoming update of my advanced effects extension for 3.3.8 I now fixed the problems mentioned above (except the one of DR since that is more complicated as MoonWizard mentioned), I will upload these fixes in some days :) I also realized that effects like RESIST stack for different type of damages when these different types are in the same damage die (same for VULN), but that is also a very rare situation in standard rules. But I also fixed that in my extension (I try to streamline the codes of all these effects since they are somewhat similar except in their effect to the total damage; I will explain that a bit more in the thread of my extension)

Moreover, there is also a rounding error in things like VULN and incorporeal (for Pathfinder). E.g. for VULN the total damage is multiplied by 1.5 and then rounded down but FG does this for each involved subresult of some die. For example, when the total fire damage is 2, VULN: fire would imply a total damage of 3. But when the total damage 2 comes from 1 + 1 (so two separate fire damage dice which were not gathered together by FG since one of the dice have an additional damage type like "critical") then FG would still give a total damage of 2 (after fixing the problem that VULN ignores following damage dice as mentioned above; but this problem also exists in incorporeal already), see the attached picture. The reason is that FG applies the factor of 1.5 and the rounding of the number afterwards to each involved die separately such that rounding errors can occur. To fix that one has to change the rounding rule (down or up) every time when an odd damage number was affected in the code :) But the error is small, it would only increase in a high number of "dice which are not gathered by FG due to damage type differences" :) I will also correct that in my extension then :)

Yeah, a lot of complicated things in these "damage-affecting effects", not just DR :D

Kelrugem
June 19th, 2019, 21:26
I may have fixed that DR issue now in my extension (I hope :) ), when one wants to look into that