6 #include "../Mobs/Monster.h"
15 return (a_ItemDamage & 0x3f);
27 switch (a_ItemDamage & 0x0f)
61 return ((a_ItemDamage & 0x20) != 0) ? 1 : 0;
72 double TierCoeff = 1, ExtCoeff = 1, SplashCoeff = 1;
109 ExtCoeff = (a_ItemDamage & 0x40) ? (8.0 / 3.0) : 1;
119 return static_cast<int>(base * TierCoeff * ExtCoeff * SplashCoeff);
131 return ((a_ItemDamage & 0x4000) == 0);
142 m_DistanceModifier(1)
153 m_Duration(a_Duration),
154 m_Intensity(a_Intensity),
155 m_DistanceModifier(a_DistanceModifier)
165 m_Ticks(a_OtherEffect.m_Ticks),
166 m_Duration(a_OtherEffect.m_Duration),
167 m_Intensity(a_OtherEffect.m_Intensity),
168 m_DistanceModifier(a_OtherEffect.m_DistanceModifier)
192 switch (a_EffectType)
199 case cEntityEffect::effHaste:
return std::make_unique<cEntityEffectHaste >(a_Duration, a_Intensity, a_DistanceModifier);
201 case cEntityEffect::effHunger:
return std::make_unique<cEntityEffectHunger >(a_Duration, a_Intensity, a_DistanceModifier);
207 case cEntityEffect::effNausea:
return std::make_unique<cEntityEffectNausea >(a_Duration, a_Intensity, a_DistanceModifier);
209 case cEntityEffect::effPoison:
return std::make_unique<cEntityEffectPoison >(a_Duration, a_Intensity, a_DistanceModifier);
213 case cEntityEffect::effSlowness:
return std::make_unique<cEntityEffectSlowness >(a_Duration, a_Intensity, a_DistanceModifier);
214 case cEntityEffect::effSpeed:
return std::make_unique<cEntityEffectSpeed >(a_Duration, a_Intensity, a_DistanceModifier);
215 case cEntityEffect::effStrength:
return std::make_unique<cEntityEffectStrength >(a_Duration, a_Intensity, a_DistanceModifier);
217 case cEntityEffect::effWeakness:
return std::make_unique<cEntityEffectWeakness >(a_Duration, a_Intensity, a_DistanceModifier);
218 case cEntityEffect::effWither:
return std::make_unique<cEntityEffectWither >(a_Duration, a_Intensity, a_DistanceModifier);
242 if (a_Target.
IsMob())
262 if (a_Target.
IsMob())
285 if (a_Target.
IsMob())
305 if (a_Target.
IsMob())
331 if (a_Target.
IsMob() &&
static_cast<cMonster &
>(a_Target).IsUndead())
336 a_Target.
Heal(amount);
351 if (a_Target.
IsMob() &&
static_cast<cMonster &
>(a_Target).IsUndead())
353 a_Target.
Heal(amount);
376 int frequency = std::max(1,
FloorC(50.0 /
static_cast<double>(
m_Intensity + 1)));
378 if ((
m_Ticks % frequency) != 0)
414 if (
World !=
nullptr)
416 World->BroadcastEntityMetadata(a_Target);
449 if (a_Target.
IsMob())
465 int frequency = std::max(1,
FloorC(25.0 /
static_cast<double>(
m_Intensity + 1)));
467 if ((
m_Ticks % frequency) == 0)
489 int frequency = std::max(1,
FloorC(40.0 /
static_cast<double>(
m_Intensity + 1)));
491 if ((
m_Ticks % frequency) == 0)
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default).
Utilities to allow casting a cWorld to one of its interfaces without including World....
bool IsPlayer(void) const
void TakeDamage(cEntity &a_Attacker)
Makes this pawn take damage from an attack by a_Attacker.
float GetHealth(void) const
Returns the health of this entity.
virtual void Heal(int a_HitPoints)
Heals the specified amount of HPs.
cWorld * GetWorld(void) const
static int GetPotionEffectDuration(short a_ItemDamage)
Returns the effect duration, in ticks, based on the potion's damage value.
double m_DistanceModifier
The distance modifier for affecting potency.
static int GetPotionColor(short a_ItemDamage)
Returns the potion color (used by the client for visuals), based on the potion's damage value.
short GetIntensity(void) const
Returns how strong the effect will be applied.
int m_Duration
How long this effect will last, in ticks.
eType
All types of entity effects (numbers correspond to protocol / storage types)
cEntityEffect(void)
Creates an empty entity effect.
int m_Ticks
How many ticks this effect has been active for.
short m_Intensity
How strong the effect will be applied.
static std::unique_ptr< cEntityEffect > CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
Creates a pointer to the proper entity effect from the effect type.
static bool IsPotionDrinkable(short a_ItemDamage)
Returns true if the potion with the given damage is drinkable.
virtual void OnTick(cPawn &a_Target)
Called on each tick.
cEntityEffect & operator=(cEntityEffect a_OtherEffect)
Creates an entity effect by copying another.
static short GetPotionEffectIntensity(short a_ItemDamage)
Retrieves the intensity level from the potion's damage value.
static cEntityEffect::eType GetPotionEffectType(short a_ItemDamage)
Translates the potion's damage value into the entity effect that the potion gives.
virtual void OnDeactivate(cPawn &a_Target) override
Called when the effect is removed from an entity.
virtual void OnActivate(cPawn &a_Target) override
Called when the effect is first added to an entity.
virtual void OnDeactivate(cPawn &a_Target) override
Called when the effect is removed from an entity.
virtual void OnActivate(cPawn &a_Target) override
Called when the effect is first added to an entity.
virtual void OnActivate(cPawn &a_Target) override
Called when the effect is first added to an entity.
virtual void OnActivate(cPawn &a_Target) override
Called when the effect is first added to an entity.
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
static void BroadcastMetadata(cPawn &a_Target)
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
double GetSprintingMaxSpeed(void) const
Gets the sprinting relative maximum speed.
void SetNormalMaxSpeed(double a_Speed)
Sets the normal relative maximum speed.
double GetFlyingMaxSpeed(void) const
Gets the flying relative maximum speed.
void SetSprintingMaxSpeed(double a_Speed)
Sets the sprinting relative maximum speed.
void SetFlyingMaxSpeed(double a_Speed)
Sets the flying relative maximum speed.
double GetNormalMaxSpeed(void) const
Gets the normal relative maximum speed.
void SetRelativeWalkSpeed(double a_WalkSpeed)
virtual bool IsUndead(void)
Returns whether this mob is undead (skeleton, zombie, etc.)
double GetRelativeWalkSpeed(void) const