6 #include "../Entities/Player.h"
7 #include "../Items/ItemHandler.h"
8 #include "../Items/ItemSpawnEgg.h"
15 Super(
"Wolf",
mtWolf,
"entity.wolf.hurt",
"entity.wolf.death",
"entity.wolf.ambient", 0.6f, 0.85f),
21 m_NotificationCooldown(0)
41 if ((currTarget !=
nullptr) && currTarget->IsPlayer())
131 if (!a_IsPlayerInvolved)
151 cWolf * Wolf =
static_cast<cWolf *
>(a_Opponent);
171 const int EquippedItemType = EquippedItem.
m_ItemType;
205 switch (EquippedItemType)
313 case E_ITEM_RAW_BEEF:
315 case E_ITEM_RAW_CHICKEN:
316 case E_ITEM_COOKED_CHICKEN:
317 case E_ITEM_ROTTEN_FLESH:
318 case E_ITEM_RAW_PORKCHOP:
319 case E_ITEM_COOKED_PORKCHOP:
324 m_World->BroadcastEntityMetadata(*this);
327 m_FinalDestination = a_Player.GetPosition();
332 MoveToPosition(a_Player.GetPosition());
342 m_World->BroadcastEntityMetadata(*this);
358 MoveToPosition(GetTarget()->GetPosition());
359 if (TargetIsInRange())
366 if (IsTame() && !IsSitting())
370 else if (IsSitting())
372 StopMovingToPosition();
386 auto Callback = [&](
cPlayer & a_Player)
388 OwnerPos = a_Player.GetPosition();
389 OwnerFlying = a_Player.IsFlying();
444 const auto Parent1 =
static_cast<cWolf *
>(a_Parent1);
445 const auto Parent2 =
static_cast<cWolf *
>(a_Parent2);
446 if (Parent1->GetOwnerUUID() == Parent2->GetOwnerUUID())
448 SetOwner(Parent1->GetOwnerName(), Parent2->GetOwnerUUID());
452 auto Parent1Age = Parent1->GetAge();
453 auto Parent2Age = Parent2->GetAge();
455 if (Parent1Age > Parent2Age)
457 SetOwner(Parent2->GetOwnerName(), Parent2->GetOwnerUUID());
461 SetOwner(Parent1->GetOwnerName(), Parent1->GetOwnerUUID());
MTRand & GetRandomProvider()
Returns the current thread's random number source.
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).
eMonsterType
Identifies individual monster type.
unsigned char Distance(const BlockState Block)
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
Teleports to the coordinates specified.
bool IsPlayer(void) const
static const UInt32 INVALID_ID
Special ID that is considered an "invalid value", signifying no entity.
bool IsTicking(void) const
Returns true if the entity is valid and ticking.
double GetPosX(void) const
double GetPosZ(void) const
double GetPosY(void) const
void SetMaxHealth(float a_MaxHealth)
Sets the maximum value for the health.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
virtual void Heal(int a_HitPoints)
Heals the specified amount of HPs.
const AString & GetName(void) const
const cUUID & GetUUID(void) const
Returns the UUID that has been read from the client, or nil if not available.
const cItem & GetEquippedItem(void) const
void NotifyNearbyWolves(cPawn *a_Opponent, bool a_IsPlayerInvolved)
Notify nearby wolves that the player or one of the player's wolves took damage or did damage to an en...
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
cInventory & GetInventory(void)
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful,...
const cItemHandler & GetHandler(void) const
Returns the cItemHandler responsible for this item type.
virtual FoodInfo GetFoodInfo(const cItem *a_Item) const
Returns the FoodInfo for this item.
static eMonsterType ItemDamageToMonsterType(short a_ItemDamage)
Converts the Spawn egg item damage to the monster type to spawn.
virtual bool Attack(std::chrono::milliseconds a_Dt)
Try to perform attack returns true if attack was deemed successful (hit player, fired projectile,...
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
double m_RelativeWalkSpeed
void LoveTick(void)
Does the whole love and breeding processing.
void SetTarget(cPawn *a_NewTarget)
Sets the target that this mob will chase.
virtual void MoveToPosition(const Vector3d &a_Position)
Engage pathfinder and tell it to calculate a path to a given position, and move the mob accordingly.
cPawn * GetTarget()
Returns the current target.
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
int FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
Finds the lowest non-air block position (not the highest, as cWorld::GetHeight does) If current Y is ...
eMonsterType GetMobType(void) const
virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
void RightClickFeed(cPlayer &a_Player)
Right click call to process feeding.
void StopMovingToPosition()
Stops pathfinding.
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
void SetIsTame(bool a_IsTame)
void SetIsSitting(bool a_IsSitting)
cUUID GetOwnerUUID(void) const
AString GetOwnerName(void) const
void SetOwner(const AString &a_NewOwnerName, const cUUID &a_NewOwnerUUID)
void SetCollarColor(int a_CollarColor)
virtual void TickFollowPlayer()
int m_NotificationCooldown
bool IsSitting(void) const override
virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
virtual void InheritFromParents(cMonster *a_Parent1, cMonster *a_Parent2) override
Called after the baby is born, allows the baby to inherit the parents' properties (color,...
void NotifyAlliesOfFight(cPawn *a_Opponent)
virtual bool Attack(std::chrono::milliseconds a_Dt) override
Try to perform attack returns true if attack was deemed successful (hit player, fired projectile,...
void ReceiveNearbyFightInfo(const cUUID &a_PlayerUUID, cPawn *a_Opponent, bool a_IsPlayerInvolved)
Notfies the wolf of a nearby fight.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
bool IsTame(void) const override
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
bool DoWithPlayerByUUID(const cUUID &a_PlayerUUID, cPlayerListCallback a_Callback)
Finds the player over his uuid and calls the callback.
virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType, bool a_Baby=false) override
Spawns a mob of the specified type.
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation, const cClientHandle *a_Exclude=nullptr) override
bool DoWithNearestPlayer(Vector3d a_Pos, double a_RangeLimit, cPlayerListCallback a_Callback, bool a_CheckLineOfSight=true, bool a_IgnoreSpectator=true)
Calls the callback for nearest player for given position, Returns false if player not found,...