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);
192 switch (a_EffectType)
199 case cEntityEffect::effHaste:
return cpp14::make_unique<cEntityEffectHaste >(a_Duration, a_Intensity, a_DistanceModifier);
201 case cEntityEffect::effHunger:
return cpp14::make_unique<cEntityEffectHunger >(a_Duration, a_Intensity, a_DistanceModifier);
207 case cEntityEffect::effNausea:
return cpp14::make_unique<cEntityEffectNausea >(a_Duration, a_Intensity, a_DistanceModifier);
209 case cEntityEffect::effPoison:
return cpp14::make_unique<cEntityEffectPoison >(a_Duration, a_Intensity, a_DistanceModifier);
213 case cEntityEffect::effSlowness:
return cpp14::make_unique<cEntityEffectSlowness >(a_Duration, a_Intensity, a_DistanceModifier);
214 case cEntityEffect::effSpeed:
return cpp14::make_unique<cEntityEffectSpeed >(a_Duration, a_Intensity, a_DistanceModifier);
215 case cEntityEffect::effStrength:
return cpp14::make_unique<cEntityEffectStrength >(a_Duration, a_Intensity, a_DistanceModifier);
217 case cEntityEffect::effWeakness:
return cpp14::make_unique<cEntityEffectWeakness >(a_Duration, a_Intensity, a_DistanceModifier);
218 case cEntityEffect::effWither:
return cpp14::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);
368 super::OnTick(a_Target);
370 if (a_Target.
IsMob() &&
static_cast<cMonster &
>(a_Target).IsUndead())
378 if ((
m_Ticks % frequency) != 0)
395 super::OnTick(a_Target);
414 if (
World !=
nullptr)
416 World->BroadcastEntityMetadata(a_Target);
429 super::OnTick(a_Target);
447 super::OnTick(a_Target);
449 if (a_Target.
IsMob())
467 if ((
m_Ticks % frequency) == 0)
486 super::OnTick(a_Target);
491 if ((
m_Ticks % frequency) == 0)
eType
All types of entity effects (numbers correspond to protocol / storage types)
void SetFlyingMaxSpeed(double a_Speed)
Sets the flying relative maximum speed.
void SetFoodSaturationLevel(double a_FoodSaturationLevel)
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
double m_DistanceModifier
The distance modifier for affecting potency.
eMonsterType GetMobType(void) const
cEntityEffect(void)
Creates an empty entity effect.
static cEntityEffect::eType GetPotionEffectType(short a_ItemDamage)
Translates the potion's damage value into the entity effect that the potion gives.
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.
void SetSprintingMaxSpeed(double a_Speed)
Sets the sprinting relative maximum speed.
void SetNormalMaxSpeed(double a_Speed)
Sets the normal relative maximum speed.
double GetRelativeWalkSpeed(void) const
virtual void OnActivate(cPawn &a_Target) override
Called when the effect is first added to an entity.
static void BroadcastMetadata(cPawn &a_Target)
void SetRelativeWalkSpeed(double a_WalkSpeed)
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.
cEntityEffect & operator=(cEntityEffect a_OtherEffect)
Creates an entity effect by copying another.
static bool IsPotionDrinkable(short a_ItemDamage)
Returns true if the potion with the given damage is drinkable.
short m_Intensity
How strong the effect will be applied.
virtual void OnTick(cPawn &a_Target)
Called on each tick.
short GetIntensity(void) const
Returns how strong the effect will be applied.
Utilities to allow casting a cWorld to one of its interfaces without including World.h.
int m_Duration
How long this effect will last, in ticks.
static short GetPotionEffectIntensity(short a_ItemDamage)
Retrieves the intensity level from the potion's damage value.
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
double GetNormalMaxSpeed(void) const
Gets the normal relative maximum speed.
static int GetPotionColor(short a_ItemDamage)
Returns the potion color (used by the client for visuals), based on the potion's damage value...
virtual bool IsUndead(void)
Returns whether this mob is undead (skeleton, zombie, etc.)
float GetHealth(void) const
Returns the health of this entity.
double GetFoodSaturationLevel(void) const
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
virtual void OnTick(cPawn &a_Target) override
Called on each tick.
int m_Ticks
How many ticks this effect has been active for.
virtual void OnDeactivate(cPawn &a_Target) override
Called when the effect is removed from an entity.
void TakeDamage(cEntity &a_Attacker)
Makes this pawn take damage from an attack by a_Attacker.
bool IsPlayer(void) const
double GetSprintingMaxSpeed(void) const
Gets the sprinting relative maximum speed.
virtual void Heal(int a_HitPoints)
Heals the specified amount of HPs.
double GetFlyingMaxSpeed(void) const
Gets the flying relative maximum speed.
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.
virtual void OnDeactivate(cPawn &a_Target) override
Called when the effect is removed from an entity.
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)
#define UNREACHABLE(x)
Use to mark code that should be impossible to reach.
void AddFoodExhaustion(double a_Exhaustion)
Adds the specified exhaustion to m_FoodExhaustion.
cWorld * GetWorld(void) const
static int GetPotionEffectDuration(short a_ItemDamage)
Returns the effect duration, in ticks, based on the potion's damage value.
virtual void OnActivate(cPawn &a_Target) override
Called when the effect is first added to an entity.