Enemies can cast spells even if they have zero magicka. I assume this is a bug(?) and not intended.
There is no spell cost check in EntityEffectManager.SetReadySpell() for enemies, only the player.
Also, the call to CalculateTotalEffectCosts() in EntityEffectManager.SetReadySpell() line 320 passes a caster value of null, which causes the spell cost to be calculated based on the player character's skill values instead of the enemy caster's.
Enemies can cast infinite spells...
- DunnyOfPenwick
- Posts: 275
- Joined: Wed Apr 14, 2021 1:58 am
- Location: Southeast US
- pango
- Posts: 3359
- Joined: Wed Jul 18, 2018 6:14 pm
- Location: France
- Contact:
Re: Enemies can cast infinite spells...
Looking at the comments, it seems intended to me:DunnyOfPenwick wrote: ↑Sat Nov 19, 2022 8:37 pm Enemies can cast spells even if they have zero magicka. I assume this is a bug(?) and not intended.
Code: Select all
// Classic does not enforce this for enemies, they can cast any spell as long as they still have at least 1 spell point.
// Doing the same here. This also matters for classic AI combat logic, as it uses the existence of any remaining spell points
// to determine whether or not it can still cast spells.
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
- DunnyOfPenwick
- Posts: 275
- Joined: Wed Apr 14, 2021 1:58 am
- Location: Southeast US
Re: Enemies can cast infinite spells...
According to the comment, classic allows enemies to cast as long as magicka is greater than zero.
In the current build, the enemy magicka isn't checked at all.
Spells that drain magicka are useless, and a strategy of depleting an enemy's magicka is not possible.
<edit>I'm currently working on a mod that alters enemy spellcasting. This bug might make some enemies almost unkillable due to infinite heal spells.
In the current build, the enemy magicka isn't checked at all.
Spells that drain magicka are useless, and a strategy of depleting an enemy's magicka is not possible.
<edit>I'm currently working on a mod that alters enemy spellcasting. This bug might make some enemies almost unkillable due to infinite heal spells.
- Interkarma
- Posts: 7247
- Joined: Sun Mar 22, 2015 1:51 am
Re: Enemies can cast infinite spells...
Enemy spellpoints are checked by their AI and they will stop casting spells once their spell points reach 0. Relevant code is in EnemyMotor CanCastRangedSpell/CanCastTouchSpell. I just tested this with multiple enemies and they stopped casting at 0 spell points as intended. This is not a bug in base DFU that I can reproduce. Maybe an edge case or result of other mod changes?DunnyOfPenwick wrote: ↑Sun Nov 20, 2022 4:04 pm According to the comment, classic allows enemies to cast as long as magicka is greater than zero.
In the current build, the enemy magicka isn't checked at all.
Spells that drain magicka are useless, and a strategy of depleting an enemy's magicka is not possible.
The code linked by Pango applies only to player spell point checks which is why enemies aren't evaluated there. The comment correctly describes the behaviour however and why code block only applies to player.
Yes, this is apparently accurate. I can't find the discussion with Allofich right now, but my understanding is this matches classic. Enemy casting skill essentially scales with player.DunnyOfPenwick wrote: ↑Sat Nov 19, 2022 8:37 pm Also, the call to CalculateTotalEffectCosts() in EntityEffectManager.SetReadySpell() line 320 passes a caster value of null, which causes the spell cost to be calculated based on the player character's skill values instead of the enemy caster's.
- DunnyOfPenwick
- Posts: 275
- Joined: Wed Apr 14, 2021 1:58 am
- Location: Southeast US
Re: Enemies can cast infinite spells...
Yep, I see it. I added additional spellcasting code in my mod and didn't realize I should check magicka myself....Relevant code is in EnemyMotor CanCastRangedSpell/CanCastTouchSpell.
That's rather strange. So enemy spellcasters get nerfed if the player-character has low magic skills?...Enemy casting skill essentially scales with player.
I might have to calculate and reset enemy magicka myself.