summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Entities/EntityEffects.cpp6
-rw-r--r--src/Entities/EntityEffects.h10
-rw-r--r--src/Entities/Pawn.cpp25
-rw-r--r--src/Entities/Pawn.h11
-rw-r--r--src/Entities/SplashPotionEntity.cpp2
-rw-r--r--src/Mobs/Monster.cpp2
6 files changed, 20 insertions, 36 deletions
diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp
index e8448a6f1..a9edeee25 100644
--- a/src/Entities/EntityEffects.cpp
+++ b/src/Entities/EntityEffects.cpp
@@ -10,7 +10,7 @@ cEntityEffect::cEntityEffect():
m_Ticks(0),
m_Duration(0),
m_Intensity(0),
- m_User(NULL),
+ m_Creator(NULL),
m_DistanceModifier(1)
{
@@ -20,11 +20,11 @@ cEntityEffect::cEntityEffect():
-cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier):
+cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier):
m_Ticks(0),
m_Duration(a_Duration),
m_Intensity(a_Intensity),
- m_User(a_User),
+ m_Creator(a_Creator),
m_DistanceModifier(a_DistanceModifier)
{
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index 2a4d0f723..9de3fcb86 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -46,14 +46,14 @@ public:
short GetIntensity() { return m_Intensity; }
/** Returns the pawn that produced this entity effect */
- cPawn *GetUser() { return m_User; }
+ cPawn *GetCreator() { return m_Creator; }
/** Returns the distance modifier for affecting potency */
double GetDistanceModifier() { return m_DistanceModifier; }
void SetDuration(int a_Duration) { m_Duration = a_Duration; }
void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
- void SetUser(cPawn * a_User) { m_User = a_User; }
+ void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; }
void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
/** Creates an empty entity effect */
@@ -62,9 +62,9 @@ public:
/** Creates an entity effect of the specified type
@param a_Duration How long this effect will last, in ticks
@param a_Intensity How strong the effect will be applied
- @param a_User The pawn that produced this entity effect
+ @param a_Creator The pawn that produced this entity effect
@param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
- cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_User, double a_DistanceModifier = 1);
+ cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1);
private:
/** How long this effect will last, in ticks */
@@ -74,7 +74,7 @@ private:
short m_Intensity;
/** The pawn that produced this entity effect (threw the potion, etc) */
- cPawn *m_User;
+ cPawn *m_Creator;
/** The distance modifier for affecting potency */
double m_DistanceModifier;
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 41a5b33ff..6c70fd2a6 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -62,19 +62,10 @@ void cPawn::KilledBy(cEntity * a_Killer)
-void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier)
-{
- AddEntityEffect(a_EffectType, cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, a_User, a_DistanceModifier));
-}
-
-
-
-
-
-void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier)
{
// Check if the plugins allow the addition:
- if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Effect.GetDuration(), a_Effect.GetIntensity(), a_Effect.GetUser(), a_Effect.GetDistanceModifier()))
+ if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Creator, a_DistanceModifier))
{
// A plugin disallows the addition, bail out.
return;
@@ -86,9 +77,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.GetDuration());
+ int EffectDuration = (int)(a_EffectDurationTicks * a_DistanceModifier);
+ m_EntityEffects[a_EffectType] = cEntityEffect(EffectDuration, a_EffectIntensity, a_Creator, a_DistanceModifier);
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, EffectDuration);
}
@@ -140,7 +131,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
{
// Base damage = 6, doubles for every increase in intensity
int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
- TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0);
+ TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0);
return;
}
case cEntityEffect::effStrength:
@@ -179,7 +170,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Cannot take poison damage when health is at 1
if (GetHealth() > 1)
{
- TakeDamage(dtPoisoning, a_Effect.GetUser(), 1, 0);
+ TakeDamage(dtPoisoning, a_Effect.GetCreator(), 1, 0);
}
}
@@ -192,7 +183,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
if (a_Effect.m_Ticks % frequency == 0)
{
- TakeDamage(dtWither, a_Effect.GetUser(), 1, 0);
+ TakeDamage(dtWither, a_Effect.GetCreator(), 1, 0);
}
//TODO: "<Player> withered away>
return;
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index c6be6f668..9f7771d79 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -30,17 +30,10 @@ public:
@param a_EffectType The entity effect to apply
@param a_EffectDurationTicks The duration of the effect
@param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc)
- @param a_User The pawn that produced the effect (e.g. threw the potion)
+ @param a_Creator The pawn that produced the effect (e.g. threw the potion)
@param a_DistanceModifier The scalar multiplied to the potion duration, only applies to splash potions)
*/
- void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1);
-
- /** Applies an entity effect
- Checks with plugins if they allow the addition.
- @param a_EffectType The entity effect to apply
- @param a_Effect The parameters of the effect
- */
- void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
+ void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier = 1);
/** Removes a currently applied entity effect
@param a_EffectType The entity effect to remove
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 714e4021d..2a1e9d981 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -79,7 +79,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
}
m_EntityEffect.SetDistanceModifier(Reduction);
- ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect);
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction);
}
return false;
}
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 8a8c4f67a..4c59960f6 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -470,7 +470,7 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe
// Undead mobs are damaged by instant health
// Base damage = 6, doubles for every increase in intensity
int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
- TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0);
+ TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0);
return;
}
}