1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-13 04:43:06 +00:00

Remove invalid permanent effects

This commit is contained in:
Evil Eye 2025-10-11 13:21:22 +02:00
parent c75aed5175
commit b905836f45
2 changed files with 8 additions and 1 deletions

View file

@ -895,6 +895,12 @@ namespace MWMechanics
bool shouldRemoveEffect(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect) bool shouldRemoveEffect(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect)
{ {
if ((effect.mFlags & (ESM::ActiveEffect::Flag_Remove | ESM::ActiveEffect::Flag_Applied))
== ESM::ActiveEffect::Flag_Remove)
{
// Previously marked invalid
return true;
}
const auto world = MWBase::Environment::get().getWorld(); const auto world = MWBase::Environment::get().getWorld();
switch (effect.mEffectId) switch (effect.mEffectId)
{ {
@ -1102,6 +1108,7 @@ namespace MWMechanics
auto anim = world->getAnimation(target); auto anim = world->getAnimation(target);
if (anim) if (anim)
anim->removeEffect(ESM::MagicEffect::indexToName(effect.mEffectId)); anim->removeEffect(ESM::MagicEffect::indexToName(effect.mEffectId));
// Note that we can't return REMOVED here because the effect still needs to be detectable
} }
else else
effect.mFlags |= ESM::ActiveEffect::Flag_Applied | ESM::ActiveEffect::Flag_Remove; effect.mFlags |= ESM::ActiveEffect::Flag_Applied | ESM::ActiveEffect::Flag_Remove;

View file

@ -626,7 +626,7 @@ namespace MWScript
{ {
for (const auto& effect : spell.getEffects()) for (const auto& effect : spell.getEffects())
{ {
if (effect.mFlags & ESM::ActiveEffect::Flag_Applied && effect.mEffectId == key) if (effect.mFlags & ESM::ActiveEffect::Flag_Remove && effect.mEffectId == key)
{ {
runtime.push(1); runtime.push(1);
return; return;