4 #include "../Entities/Pawn.h"
56 virtual void Tick(std::chrono::milliseconds a_Dt,
cChunk & a_Chunk)
override;
92 void Unleash(
bool a_ShouldDropLeashPickup);
100 void Unleash(
bool a_ShouldDropLeashPickup,
bool a_ShouldBroadcast);
152 virtual bool IsTame (
void)
const {
return false; }
285 return (a_PosY >
GetPosY() + 0.8);
350 void AddRandomDropItem(
cItems & a_Drops,
unsigned int a_Min,
unsigned int a_Max,
short a_Item,
short a_ItemHealth = 0);
#define CLASS_PROTODEF(classname)
std::chrono::duration< signed int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 > >> cTickTime
eMonsterType
Identifies individual monster type.
double GetPosY(void) const
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
cPawn(eEntityType a_EntityType, float a_Width, float a_Height)
This class bridges a vector of cItem for safe access via Lua.
void SetDropChanceBoots(float a_DropChanceBoots)
void SetCanBeLeashed(bool a_CanBeLeashed)
Sets whether the mob can be leashed, for extensibility in plugins.
cMonster(const AString &a_ConfigName, eMonsterType a_MobType, const AString &a_SoundHurt, const AString &a_SoundDeath, const AString &a_SoundAmbient, float a_Width, float a_Height)
Creates the mob object.
std::chrono::milliseconds m_IdleInterval
int m_LoveCooldown
If above 0, the monster is in cooldown mode and will refuse to breed.
void SetPitchAndYawFromDestination(bool a_IsFollowingPath)
Sets the body yaw and head yaw.
cPathFinder m_PathFinder
The pathfinder instance handles pathfinding for this monster.
virtual bool IsNetherNative(void)
Returns whether this mob spawns in the Nether in Vanilla.
void ResetAttackCooldown()
void SetCustomName(const AString &a_CustomName)
Sets the custom name of the monster.
double m_RelativeWalkSpeed
virtual bool IsSitting(void) const
static AString MobTypeToVanillaName(eMonsterType a_MobType)
Translates MobType enum to the vanilla name of the mob, empty string if unknown.
void SetRelativeWalkSpeed(double a_WalkSpeed)
eFamily GetMobFamily(void) const
void SetCanPickUpLoot(bool a_CanPickUpLoot)
void SetBurnsInDaylight(bool a_BurnsInDaylight)
virtual void InStateChasing(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
Vector3d m_FinalDestination
Coordinates for the ultimate, final destination.
cMonster * GetPartner(void) const
Returns the partner which the monster is currently mating with.
void SetDropChanceLeggings(float a_DropChanceLeggings)
void SetDropChanceHelmet(float a_DropChanceHelmet)
virtual void CheckEventLostPlayer(std::chrono::milliseconds a_Dt)
bool WouldBurnAt(Vector3d a_Location, cChunk &a_Chunk)
bool HasCustomName(void) const
Returns true if the monster has a custom name.
virtual void GetFollowedItems(cItems &a_Items)
Returns the items that the animal of this class follows when a player holds it in hand.
static cTickTime GetSpawnDelay(cMonster::eFamily a_MobFamily)
Returns the spawn delay (number of game ticks between spawn attempts) for the given mob family.
virtual bool IsTame(void) const
void LoveTick(void)
Does the whole love and breeding processing.
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
void AddRandomRareDropItem(cItems &a_Drops, cItems &a_Items, unsigned int a_LootingLevel)
Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel...
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
cUUID m_Feeder
Remembers the player is was last fed by for statistics tracking.
static std::unique_ptr< cMonster > NewMonsterFromType(eMonsterType a_MobType)
Creates a new object of the specified mob.
void SetTarget(cPawn *a_NewTarget)
Sets the target that this mob will chase.
void SetLeashToPos(Vector3d *pos)
Sets entity position to where is leashed this mob.
void GetMonsterConfig(const AString &a_Name)
Reads the monster configuration for the specified monster name and assigns it to this object.
cMonster * m_LovePartner
The monster's breeding partner.
const AString & GetCustomName(void) const
Gets the custom name of the monster.
bool IsInLoveCooldown() const
Returns whether the monster is tired of breeding and is in the cooldown state.
virtual void HandleFalling(void) override
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.
float m_DropChanceChestplate
float GetDropChanceChestplate()
void AddRandomDropItem(cItems &a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth=0)
Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops.
void MoveToWayPoint(cChunk &a_Chunk)
Move in a straight line to the next waypoint in the path, will jump if needed.
void SetDropChanceWeapon(float a_DropChanceWeapon)
bool m_PathfinderActivated
Stores if pathfinder is being used - set when final destination is set, and unset when stopped moving...
static eFamily FamilyFromType(eMonsterType a_MobType)
Returns the mob family based on the type.
cPawn * GetTarget()
Returns the current target.
void HandleDaylightBurning(cChunk &a_Chunk, bool WouldBurn)
float GetDropChanceHelmet()
void EngageLoveMode(cMonster *a_Partner)
Start the mating process.
void UnsafeUnsetTarget()
Unset the target without notifying the target entity.
cPawn * m_Target
A pointer to the entity this mobile is aiming to reach.
virtual void GetBreedingItems(cItems &a_Items)
Returns the items that make the animal breed - this is usually the same as the ones that make the ani...
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
Vector3d * GetLeashToPos() const
Gets entity position to where mob should be leashed.
bool IsCustomNameAlwaysVisible(void) const
Is the custom name of this monster always visible? If not, you only see the name when you sight the m...
virtual void InStateEscaping(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
bool IsLeashed() const
Returns whether the monster is leashed to an entity.
void SetAttackRate(double a_AttackRate)
float GetDropChanceWeapon()
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 ...
virtual bool IsUndead(void)
Returns whether this mob is undead (skeleton, zombie, etc.)
eMonsterType GetMobType(void) const
void SetAttackDamage(int a_AttackDamage)
bool IsInLove() const
Returns whether the monster has just been fed and is ready to mate.
cEntity * m_LeashedTo
Entity leashed to.
bool BurnsInDaylight() const
cEntity * GetLeashedTo() const
Returns the entity to where this mob is leashed, returns nullptr if it's not leashed.
static AString MobTypeToString(eMonsterType a_MobType)
Translates MobType enum to a string, empty string if unknown.
int m_MatingTimer
The monster is engaged in mating, once this reaches zero, a baby will be born.
bool WasLastTargetAPlayer() const
Returns if this mob last target was a player to avoid destruction on player quit.
void Unleash(bool a_ShouldDropLeashPickup)
Unleash the monster.
std::chrono::milliseconds m_DestroyTimer
void AddRandomWeaponDropItem(cItems &a_Drops, unsigned int a_LootingLevel)
Adds weapon that is equipped with the chance saved in m_DropChance... to the drop.
void AddRandomArmorDropItem(cItems &a_Drops, unsigned int a_LootingLevel)
Adds armor that is equipped with the chance saved in m_DropChance... to the drop.
Vector3d m_NextWayPointPosition
Coordinates of the next position that should be reached.
bool m_IsLeashActionJustDone
Mob has ben leashed or unleashed in current player action.
bool DoesPosYRequireJump(double a_PosY)
Returns whether the monster needs to jump to reach a given height.
bool TargetIsInRange(void)
Returns whether or not the target is close enough for attack.
enum cMonster::MState m_EMState
void SetAttackRange(double a_AttackRange)
bool m_WasLastTargetAPlayer
virtual void EventSeePlayer(cPlayer *a_Player, cChunk &a_Chunk)
std::chrono::milliseconds m_LoseSightAbandonTargetTimer
bool m_CustomNameAlwaysVisible
int m_TicksSinceLastDamaged
bool m_CanBeLeashed
Determines whether a monster can be leashed.
void ResetLoveMode()
Finish the mating process.
virtual void EventLosePlayer(void)
void SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible)
Sets the custom name visiblity of this monster.
void LeashTo(cEntity &a_Entity, bool a_ShouldBroadcast=true)
Leash the monster to an entity.
float GetDropChanceBoots()
int m_AttackCoolDownTicksLeft
std::unique_ptr< Vector3d > m_LeashToPos
Entity pos where this mob was leashed to.
virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
bool CanBeLeashed() const
Returns whether the mob can be leashed.
float GetDropChanceLeggings()
void SetSightDistance(int a_SightDistance)
virtual void InheritFromParents(cMonster *a_Parent1, cMonster *a_Parent2)
Called after the baby is born, allows the baby to inherit the parents' properties (color,...
double GetRelativeWalkSpeed(void) const
float m_DropChanceLeggings
bool ReachedFinalDestination(void)
Returns if the ultimate, final destination has been reached.
void RightClickFeed(cPlayer &a_Player)
Right click call to process feeding.
void CalcLeashActions(std::chrono::milliseconds a_Dt)
Leash calculations inside Tick function.
enum cMonster::MPersonality m_EMPersonality
void AddRandomUncommonDropItem(cItems &a_Drops, float a_Chance, short a_Item, short a_ItemHealth=0)
Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops.
static AString MobTypeToVanillaNBT(eMonsterType a_MobType)
Translates the MobType enum to the vanilla nbt name.
void SetDropChanceChestplate(float a_DropChanceChestplate)
int m_LoveTimer
If above 0, the monster is in love mode, and will breed if a nearby monster is also in love mode.
virtual void CheckEventSeePlayer(cChunk &a_Chunk)
virtual void OnRemoveFromWorld(cWorld &a_World) override
Called when the entity is removed from a world.
static eMonsterType StringToMobType(const AString &a_MobTypeName)
Translates MobType string to the enum, mtInvalidType if not recognized.
void StopMovingToPosition()
Stops pathfinding.