From 18ff4b0a3ff431ea9a6d2a9ef725026b48ae028b Mon Sep 17 00:00:00 2001 From: Pierre Etchemaite Date: Wed, 31 Jul 2024 00:34:18 +0200 Subject: [PATCH 1/2] Fix spell absorption capping When absorbing magicka from own spells, DFU explicitly ensures that magicka recovered is not larger than the magicka that was used. For this, it needs to track how much magicka was spent for the last spell: lastReadySpellCastingCost A special case was not correctly handled though: when the last spell came from a magic item, lastReadySpellCastingCost should be set 0 so that next absorption of own spells is not capped. That worked by luck when the game was just started because lastReadySpellCastingCost was still 0, but broke after first spell casting. Forums: https://forums.dfworkshop.net/viewtopic.php?t=6755 --- Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs b/Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs index 1a142d4e7e..f90fb6bc6e 100644 --- a/Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs +++ b/Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs @@ -2131,6 +2131,10 @@ private void PlayerSpellCasting_OnReleaseFrame() lastSpell = readySpell; lastReadySpellCastingCost = readySpellCastingCost; } + else + { + lastReadySpellCastingCost = 0; + } readySpell = null; readySpellCastingCost = 0; instantCast = false; From 5245714772e64bf2d39e853a64d64e2b6aaf75e7 Mon Sep 17 00:00:00 2001 From: Pierre Etchemaite Date: Wed, 31 Jul 2024 09:18:03 +0200 Subject: [PATCH 2/2] "invert if" refacto --- .../Scripts/Game/MagicAndEffects/EntityEffectManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs b/Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs index f90fb6bc6e..4a8813c06b 100644 --- a/Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs +++ b/Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs @@ -2126,14 +2126,14 @@ private void PlayerSpellCasting_OnReleaseFrame() // Clear ready spell and reset casting - do not update last spell if casting from item RaiseOnCastReadySpell(readySpell); - if (!readySpellDoesNotCostSpellPoints) + if (readySpellDoesNotCostSpellPoints) { - lastSpell = readySpell; - lastReadySpellCastingCost = readySpellCastingCost; + lastReadySpellCastingCost = 0; } else { - lastReadySpellCastingCost = 0; + lastSpell = readySpell; + lastReadySpellCastingCost = readySpellCastingCost; } readySpell = null; readySpellCastingCost = 0;