[0.11.0] Elemental Resistance Effect Not Working As Advertised

Moderators will move topics here from Help & Support once an issue has been confirmed and enough information provided to reproduce.
Post Reply
User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

[0.11.0] Elemental Resistance Effect Not Working As Advertised

Post by Magicono43 »

So I was reading about the "Elemental Resistance" spell effect and how the "Spell Resistance" effect are supposed to be different from one another. At least from what I was reading, and what seemed to make the most sense to me. It is supposed to be the case that "Elemental Resistance" is supposed to be the weaker but cheaper version of "Spell Resistance" in that, ER is locked to a specific type of magic (that being either Fire, Frost, Shock, Poison, and Magicka) and if the ER roll succeeds against a spell of that same type being cast, then the effect is entirely negated, but if the roll fails the spell effect goes through (if other racial and background resistances negate it later on of course) HOWEVER, the nice thing with ER that is written on the spell description is that even if the effect goes through, if it has a magnitude attached to it, such as a damage health effect, that effect will be halved in magnitude. Sounds simple enough. And Spell Resistance is similar to the ER effect, with the differences being, SR is universal across magic types, it costs more to cast generally, and it is completely binary in its effect, you either succeed the roll and negate the spell, or you fail and get hit with the spell.

After that long explanation to how I THINK these two effects are intended to work and be different from one another, I now get on to what is related to the title of the post. The Elemental Resistance effect is not fully functional, in that it does not halve the magnitude of spells coming at the target that get through the resistance roll, they just go through unchanged magnitude-wise.

I tested this in-game with a 50 damage flat fireball spell against the wall and even while under the effect of a "Fire Resistance" effect the Fireball spell was still dealing 50 damage every-time it was not fully resisted. I had a feeling this was the case when I looked at the "SavingThrow" method of "FormulaHelper.cs" and only saw that the "HasResistanceFlag" was used once at the start to check if the spell was fully negated or not, nothing at the bottom when the magnitude part is being modified.

I'll make a more properly formatted bug report if necessary, but I think it's fairly self-explanatory and how to reproduce the test I did, thanks!

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Elemental Resistance Effect Not Working As Advertised

Post by Interkarma »

Magicono43 wrote: Mon Jan 18, 2021 1:57 am The Elemental Resistance effect is not fully functional, in that it does not halve the magnitude of spells coming at the target that get through the resistance roll, they just go through unchanged magnitude-wise.
Clear and understood, thank you. :) Happy to accept this as a bug report unless you want to add more detail?

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Elemental Resistance Effect Not Working As Advertised

Post by Magicono43 »

Interkarma wrote: Mon Jan 18, 2021 2:23 am
Magicono43 wrote: Mon Jan 18, 2021 1:57 am The Elemental Resistance effect is not fully functional, in that it does not halve the magnitude of spells coming at the target that get through the resistance roll, they just go through unchanged magnitude-wise.
Clear and understood, thank you. :) Happy to accept this as a bug report unless you want to add more detail?
Nah, that's about all I wanted to say for now. I'm doing some more testing and finding some interesting things, so I might add more about this general topic if I find anything more worth investigating further.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: [0.11.0] Elemental Resistance Effect Not Working As Advertised

Post by Interkarma »

Cheers!

Just something to note - any work done by Allofich around formulas and handling is likely spot-on. It's not usual for the spell description not to match the actual function of spell. In these cases where Allofich did the work, the functionality will almost certainly be correct and the spell description is wrong.

The Elemental Resistance handling is mine though, so I'm just assuming for now that I've made mistake and will look into further. :)

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: [0.11.0] Elemental Resistance Effect Not Working As Advertised

Post by Magicono43 »

Interkarma wrote: Mon Jan 18, 2021 2:55 am Cheers!

Just something to note - any work done by Allofich around formulas and handling is likely spot-on. It's not usual for the spell description not to match the actual function of spell. In these cases where Allofich did the work, the functionality will almost certainly be correct and the spell description is wrong.

The Elemental Resistance handling is mine though, so I'm just assuming for now that I've made mistake and will look into further. :)
Fair enough, it was mostly one of those things that would make sense in my mind just in terms of balance and such, but we all know Elder Scrolls games generally were never balanced in any regard, lol. As I was testing I just remembered that there is even that "Leeway" effect that happens if your saving throw was within 20 or something of the spell effect roll, reducing the magnitude. If you were to add this resistance halving in, I would assume putting it around that area would make sense, probably after this check to half the final effect if it was modified by that leeway reduction as well. Appreciate your time, IK.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: [0.11.0] Elemental Resistance Effect Not Working As Advertised

Post by Interkarma »

Looking back through forums, I've found this conversation has come up before. Here are my earlier comments. It seems I was confident in the past this was working as intended and the spell description was wrong. This was only a few months ago too. :?
Interkarma wrote: Fri Aug 07, 2020 3:35 pm Spell text descriptions are often misleading, as is information on UESP and elsewhere. The saving throw code was reverse engineered by Allofich and included no such logic to halve damage when Chance roll fails. I have great confidence Allofich would have implemented this if it was actually happening in classic.

If Elemental Resistance succeeds, the incoming effect is scrubbed. If it fails, the effect is handed off to native resistances and saving throw logic, which can partially or fully reduce damage/duration based on those mechanics.
This then received some testing from forum user "npc", who seems to agree the damage halving doesn't actually happen in classic.
npc wrote: Mon Aug 10, 2020 3:47 pm
1) incomplete spell effect
Description:
The description of the spell effect "Elemental Resistance <element>" say "Target takes half damage if spell is unsuccessful." which doesn't seem to happen in DFU (not tested in vanilla DF).
I had to test this in classic DF just to make sure.

I used a downloadable save file, Tlalac Boram, a level 24 redguard. So I wouldn't have to level up by myself. He has "spell absorption in darkness", but this is fine, since it either works or it doesn't, it wont reduce the damage.

Then I ran off and found myself a Fire Daedra. I think they are level 16, or near that (they got 16d8+10 hitpoints). So a Fireball can be expected to hit for (7x16+1) 113 and Fire Storm for (5x16+20) 100, or close to that.

While using a Elemental Resistance Fire spell (magic items not tested), the first fire spell that hit me dealt 106 pts of damage. Which proved immediately that the spell description is indeed wrong. Another test gave me 120 pts of damage (so they are at least level 17 then, doesn't matter).

Result: Elemental Resistance does NOT cut the damage in half in classic DF. Just like you said. The description is wrong.
With all that said, I can't find any conversations with Allofich confirming this spell description is wrong. That just appears to be the case based on classic observation. So if there's a mistake here, it's mine alone.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: [0.11.0] Elemental Resistance Effect Not Working As Advertised

Post by Interkarma »

I'll dig back through git commits to confirm who actually wrote the ElementalResistance short-circuit in SavingThrow. If this was Allofich, there's almost a 100% chance it's correct and the description is wrong.

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: [0.11.0] Elemental Resistance Effect Not Working As Advertised

Post by Magicono43 »

I wish it were easier to search posts, maybe then I would not have brought this topic up then, lol. But yeah, if that seems to be the case then I don't see this being necessary to change for DFU. However, this does give me the green-light to change this behavior in my own project though, as I personally think this would make sense to help differentiate the resistance effects. Now I just need to figure out a way to discriminate between the "Elemental Resistance" flag and the "Spell Resistance" HasResistance flag in this case, lol.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: [0.11.0] Elemental Resistance Effect Not Working As Advertised

Post by Interkarma »

OK, here it is. This was originally reverse engineered by Allofich. Here's his original code before it was refactored into the effect system proper.

Code: Select all

// Handle resistances granted by magical effects
// elementTypes are 0 = fire, 1 = frost, 2 = disease/poison, 3 = shock, 4 = magick

int[] SavingThrowResistFlags = { 0x02, 0x10000000, 0x20000000, 0x40000000, 0x80000000 }; // These map to classic magicEffects 1 through 4 concatenated together as 4 bytes.
if (target.magicEffects & SavingThrowResistTypes[elementType]
{
    int chance = target.ResistanceTo(elementType);
    if (UnityEngine.Random.Range(1, 100 + 1) <= chance)
        return 0;
}
This means that ElementalResistance almost certainly does not apply the half damage as described, or Allofich would have constructed the logic that way.

Thankfully git history is better than my memory. Yeesh. :oops:

So there's still a bug here, just it's the description that needs to be fixed rather than the behaviour.

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: [0.11.0] Elemental Resistance Effect Not Working As Advertised

Post by Magicono43 »

Interkarma wrote: Mon Jan 18, 2021 3:50 am So there's still a bug here, just it's the description that needs to be fixed rather than the behaviour.
Yeah, that would probably help a lot more in this sort of confusion with how the effects work.

Post Reply