Entity effects: changed User to Creator, removed pawn pass-by-value
This commit is contained in:
parent
a37d5410b4
commit
68c30790db
|
@ -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)
|
||||
{
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user