summaryrefslogtreecommitdiffstats
path: root/src/Entities/Pawn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/Pawn.cpp')
-rw-r--r--src/Entities/Pawn.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index a0095a8a4..233cdfa85 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -197,6 +197,13 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, s
}
a_Duration = static_cast<int>(a_Duration * a_DistanceModifier);
+ // If we already have the effect, we have to deactivate it or else it will act cumulatively
+ auto ExistingEffect = m_EntityEffects.find(a_EffectType);
+ if (ExistingEffect != m_EntityEffects.end())
+ {
+ ExistingEffect->second->OnDeactivate(*this);
+ }
+
auto Res = m_EntityEffects.emplace(a_EffectType, cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_DistanceModifier));
m_World->BroadcastEntityEffect(*this, a_EffectType, a_Intensity, static_cast<short>(a_Duration));
cEntityEffect * Effect = Res.first->second.get();