From af9b4d5697952690c7108364d94a2929e94f4037 Mon Sep 17 00:00:00 2001 From: sruon Date: Sun, 15 Feb 2026 21:26:49 -0700 Subject: [PATCH] Dont broadcast effect wears off messages --- src/map/status_effect_container.cpp | 34 ++++++++++++++++++++++------- src/map/status_effect_container.h | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/map/status_effect_container.cpp b/src/map/status_effect_container.cpp index 026c27b4719..d19ed176302 100644 --- a/src/map/status_effect_container.cpp +++ b/src/map/status_effect_container.cpp @@ -611,7 +611,7 @@ void CStatusEffectContainer::DeleteStatusEffects() } } -void CStatusEffectContainer::RemoveStatusEffect(CStatusEffect* PStatusEffect, EffectNotice notice) +void CStatusEffectContainer::RemoveStatusEffect(CStatusEffect* PStatusEffect, const EffectNotice notice) { if (!PStatusEffect->deleted) { @@ -622,26 +622,44 @@ void CStatusEffectContainer::RemoveStatusEffect(CStatusEffect* PStatusEffect, Ef m_POwner->delModifiers(&PStatusEffect->modList); if (m_POwner->objtype == TYPE_PC) { - CCharEntity* PChar = (CCharEntity*)m_POwner; + auto* PChar = static_cast(m_POwner); - if (PStatusEffect->GetIcon() != 0) + if (notice != EffectNotice::Silent && PStatusEffect->GetIcon() != 0 && !(PStatusEffect->HasEffectFlag(EFFECTFLAG_NO_LOSS_MESSAGE))) { - if (notice != EffectNotice::Silent && !(PStatusEffect->HasEffectFlag(EFFECTFLAG_NO_LOSS_MESSAGE))) + // Notify owner that they lost their buff. + PChar->pushPacket(PChar, PChar, PStatusEffect->GetIcon(), 0, MsgStd::EffectWearsOff); + + // Notify origin entity if they are in the same zone, and we are in their spawn list. + const auto originId = PStatusEffect->GetOriginID(); + if (originId != 0 && originId != PChar->id && m_POwner->loc.zone) { - PChar->pushPacket(PChar, PChar, PStatusEffect->GetIcon(), 0, MsgStd::EffectWearsOff); + auto* POriginEntity = m_POwner->loc.zone->GetCharByID(originId); + if (POriginEntity && charutils::hasEntitySpawned(POriginEntity, PChar)) + { + POriginEntity->pushPacket(PChar, PChar, PStatusEffect->GetIcon(), 0, MsgStd::EffectWearsOff); + } } } if (PStatusEffect->GetStatusID() >= EFFECT_FIRE_MANEUVER && PStatusEffect->GetStatusID() <= EFFECT_DARK_MANEUVER) { - puppetutils::CheckAttachmentsForManeuver((CCharEntity*)m_POwner, PStatusEffect->GetStatusID(), false); + puppetutils::CheckAttachmentsForManeuver(static_cast(m_POwner), PStatusEffect->GetStatusID(), false); } } else { - if (notice != EffectNotice::Silent && PStatusEffect->GetIcon() != 0 && (!(PStatusEffect->HasEffectFlag(EFFECTFLAG_NO_LOSS_MESSAGE))) && !m_POwner->isDead()) + if (notice != EffectNotice::Silent && PStatusEffect->GetIcon() != 0 && !(PStatusEffect->HasEffectFlag(EFFECTFLAG_NO_LOSS_MESSAGE)) && !m_POwner->isDead()) { - m_POwner->loc.zone->PushPacket(m_POwner, CHAR_INRANGE, std::make_unique(m_POwner, m_POwner, PStatusEffect->GetIcon(), 0, MsgStd::EffectWearsOff)); + // Notify origin entity if they are in the same zone, and we are in their spawn list. + const auto originId = PStatusEffect->GetOriginID(); + if (originId != 0 && m_POwner->loc.zone) + { + auto* POriginEntity = m_POwner->loc.zone->GetCharByID(originId); + if (POriginEntity && charutils::hasEntitySpawned(POriginEntity, m_POwner)) + { + POriginEntity->pushPacket(m_POwner, m_POwner, PStatusEffect->GetIcon(), 0, MsgStd::EffectWearsOff); + } + } } } } diff --git a/src/map/status_effect_container.h b/src/map/status_effect_container.h index 63d9a2b80fd..b63a9473715 100644 --- a/src/map/status_effect_container.h +++ b/src/map/status_effect_container.h @@ -139,7 +139,7 @@ class CStatusEffectContainer CBattleEntity* m_POwner = nullptr; // void ReplaceStatusEffect(EFFECT effect); //this needs to be implemented - void RemoveStatusEffect(CStatusEffect* PEffect, EffectNotice notice = EffectNotice::ShowMessage); // We remove the effect by its number in the container + void RemoveStatusEffect(CStatusEffect* PStatusEffect, EffectNotice notice = EffectNotice::ShowMessage); // We remove the effect by its number in the container void DeleteStatusEffects(); auto SetEffectParams(CStatusEffect* StatusEffect) -> void; // We set the effect of the effect void HandleAura(CStatusEffect* PStatusEffect);