Don't play vfx and sound on fully resisted debuffs

This commit is contained in:
Kuyondo 2025-07-10 23:46:22 +08:00
parent e9a9659abc
commit 25d9c80067
3 changed files with 12 additions and 10 deletions

View File

@ -273,13 +273,14 @@ namespace MWMechanics
}
bool updateSpellWindow = false;
bool playNonLooping = false;
if (ptr.getClass().hasInventoryStore(ptr)
&& !(creatureStats.isDead() && !creatureStats.isDeathAnimationFinished()))
{
auto& store = ptr.getClass().getInventoryStore(ptr);
if (store.getInvListener() != nullptr)
{
bool playNonLooping = !store.isFirstEquip();
playNonLooping = !store.isFirstEquip();
const auto world = MWBase::Environment::get().getWorld();
for (int slotIndex = 0; slotIndex < MWWorld::InventoryStore::Slots; slotIndex++)
{
@ -307,9 +308,6 @@ namespace MWMechanics
applyPurges(ptr);
ActiveSpellParams& params = mSpells.emplace_back(ActiveSpellParams{ *slot, enchantment, ptr });
params.setActiveSpellId(MWBase::Environment::get().getESMStore()->generateId());
for (const auto& effect : params.mEffects)
MWMechanics::playEffects(
ptr, *world->getStore().get<ESM::MagicEffect>().find(effect.mEffectId), playNonLooping);
updateSpellWindow = true;
}
}
@ -327,7 +325,7 @@ namespace MWMechanics
std::optional<ActiveSpellParams> reflected;
for (auto it = spellIt->mEffects.begin(); it != spellIt->mEffects.end();)
{
auto result = applyMagicEffect(ptr, caster, *spellIt, *it, duration);
auto result = applyMagicEffect(ptr, caster, *spellIt, *it, duration, playNonLooping);
if (result.mType == MagicApplicationResult::Type::REFLECTED)
{
if (!reflected)

View File

@ -914,7 +914,7 @@ namespace MWMechanics
}
MagicApplicationResult applyMagicEffect(const MWWorld::Ptr& target, const MWWorld::Ptr& caster,
ActiveSpells::ActiveSpellParams& spellParams, ESM::ActiveEffect& effect, float dt)
ActiveSpells::ActiveSpellParams& spellParams, ESM::ActiveEffect& effect, float dt, bool playNonLooping)
{
const auto world = MWBase::Environment::get().getWorld();
bool invalid = false;
@ -1032,9 +1032,12 @@ namespace MWMechanics
oldMagnitude = effect.mMagnitude;
else
{
if (!spellParams.hasFlag(ESM::ActiveSpells::Flag_Equipment)
&& !spellParams.hasFlag(ESM::ActiveSpells::Flag_Lua))
playEffects(target, *magicEffect, spellParams.hasFlag(ESM::ActiveSpells::Flag_Temporary));
bool isTemporary = spellParams.hasFlag(ESM::ActiveSpells::Flag_Temporary);
bool isEquipment = spellParams.hasFlag(ESM::ActiveSpells::Flag_Equipment);
if (!spellParams.hasFlag(ESM::ActiveSpells::Flag_Lua))
playEffects(target, *magicEffect, (isTemporary || (isEquipment && playNonLooping)));
if (effect.mEffectId == ESM::MagicEffect::Soultrap && !target.getClass().isNpc()
&& target.getType() == ESM::Creature::sRecordId
&& target.get<ESM::Creature>()->mBase->mData.mSoul == 0 && caster == getPlayer())

View File

@ -28,7 +28,8 @@ namespace MWMechanics
// Applies a tick of a single effect. Returns true if the effect should be removed immediately
MagicApplicationResult applyMagicEffect(const MWWorld::Ptr& target, const MWWorld::Ptr& caster,
ActiveSpells::ActiveSpellParams& spellParams, ESM::ActiveEffect& effect, float dt);
ActiveSpells::ActiveSpellParams& spellParams, ESM::ActiveEffect& effect, float dt,
bool playNonLoopingEffect = true);
// Undoes permanent effects created by ESM::MagicEffect::AppliedOnce
void onMagicEffectRemoved(