summaryrefslogtreecommitdiffstats
path: root/src/Entities/Pawn.cpp
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-06-13 10:50:09 +0200
committerarchshift <admin@archshift.com>2014-06-17 20:39:21 +0200
commit22761bb6ad4b121ae3b2319a9a2541a6bb8a982c (patch)
tree963f0f90cb29a2cbd4c201bcae06d3fb20965394 /src/Entities/Pawn.cpp
parentFixed MSVC compilation. (diff)
downloadcuberite-22761bb6ad4b121ae3b2319a9a2541a6bb8a982c.tar
cuberite-22761bb6ad4b121ae3b2319a9a2541a6bb8a982c.tar.gz
cuberite-22761bb6ad4b121ae3b2319a9a2541a6bb8a982c.tar.bz2
cuberite-22761bb6ad4b121ae3b2319a9a2541a6bb8a982c.tar.lz
cuberite-22761bb6ad4b121ae3b2319a9a2541a6bb8a982c.tar.xz
cuberite-22761bb6ad4b121ae3b2319a9a2541a6bb8a982c.tar.zst
cuberite-22761bb6ad4b121ae3b2319a9a2541a6bb8a982c.zip
Diffstat (limited to 'src/Entities/Pawn.cpp')
-rw-r--r--src/Entities/Pawn.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 186e7df2a..0273981f9 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -30,14 +30,14 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
// Apply entity effect
HandleEntityEffect(effect_type, effect_values);
- // Reduce the effect's duration
- effect_values.m_Ticks--;
+ // Increase the effect's tick counter
+ effect_values.m_Ticks++;
// Iterates (must be called before any possible erasure)
++iter;
// Remove effect if duration has elapsed
- if (effect_values.m_Ticks <= 0)
+ if (effect_values.GetDuration() - effect_values.m_Ticks <= 0)
{
RemoveEntityEffect(effect_type);
}
@@ -68,8 +68,9 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E
return;
}
+ a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier());
m_EntityEffects[a_EffectType] = a_Effect;
- m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks * a_Effect.GetDistanceModifier());
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration());
}
@@ -143,12 +144,9 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1));
- // TODO: The counter needs to be specific to one cPawn, make it a member variable.
- static short counter = 0;
- if (++counter >= frequency)
+ if (a_Effect.m_Ticks % frequency == 0)
{
Heal(1);
- counter = 0;
}
return;
@@ -158,16 +156,13 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
- // TODO: The counter needs to be specific to one cPawn, make it a member variable.
- static short counter = 0;
- if (++counter >= frequency)
+ if (a_Effect.m_Ticks % frequency == 0)
{
// Cannot take poison damage when health is at 1
if (GetHealth() > 1)
{
TakeDamage(dtPoisoning, a_Effect.GetUser(), 1, 0);
}
- counter = 0;
}
return;
@@ -177,12 +172,9 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
- // TODO: The counter needs to be specific to one cPawn, make it a member variable.
- static short counter = 0;
- if (++counter >= frequency)
+ if (a_Effect.m_Ticks % frequency == 0)
{
TakeDamage(dtWither, a_Effect.GetUser(), 1, 0);
- counter = 0;
}
//TODO: "<Player> withered away>
return;