4 #include "../Entities/Pawn.h" 46 virtual void Destroy(
bool a_ShouldBroadcast =
true)
override;
54 virtual void Tick(std::chrono::milliseconds a_Dt,
cChunk & a_Chunk)
override;
90 void Unleash(
bool a_ShouldDropLeashPickup);
98 void Unleash(
bool a_ShouldDropLeashPickup,
bool a_ShouldBroadcast);
146 virtual bool IsTame (
void)
const {
return false; }
247 return (a_PosY >
GetPosY() + 0.8);
308 void AddRandomDropItem(
cItems & a_Drops,
unsigned int a_Min,
unsigned int a_Max,
short a_Item,
short a_ItemHealth = 0);
double m_RelativeWalkSpeed
Vector3d m_FinalDestination
Coordinates for the ultimate, final destination.
double GetPosY(void) const
virtual void InStateEscaping(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
void SetSightDistance(int a_SightDistance)
virtual void Destroyed() override
eMonsterType GetMobType(void) const
float GetDropChanceChestplate()
void AddRandomWeaponDropItem(cItems &a_Drops, unsigned int a_LootingLevel)
Adds weapon that is equipped with the chance saved in m_DropChance... to the drop.
bool DoesPosYRequireJump(double a_PosY)
Returns whether the monster needs to jump to reach a given height.
static std::unique_ptr< cMonster > NewMonsterFromType(eMonsterType a_MobType)
Creates a new object of the specified mob.
void MoveToWayPoint(cChunk &a_Chunk)
Move in a straight line to the next waypoint in the path, will jump if needed.
const AString & GetCustomName(void) const
Gets the custom name of the monster.
double GetRelativeWalkSpeed(void) const
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
float GetDropChanceLeggings()
void SetDropChanceChestplate(float a_DropChanceChestplate)
void AddRandomArmorDropItem(cItems &a_Drops, unsigned int a_LootingLevel)
Adds armor that is equipped with the chance saved in m_DropChance... to the drop. ...
cPawn * GetTarget()
Returns the current target.
void SetCanPickUpLoot(bool a_CanPickUpLoot)
cPawn * m_Target
A pointer to the entity this mobile is aiming to reach.
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.
bool HasCustomName(void) const
Returns true if the monster has a custom name.
virtual ~cMonster() 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 GetDropChanceHelmet()
void SetRelativeWalkSpeed(double a_WalkSpeed)
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.
cEntity * GetLeashedTo() const
Returns the entity to where this mob is leashed, returns nullptr if it's not leashed.
cEntity * m_LeashedTo
Entity leashed to.
void SetDropChanceBoots(float a_DropChanceBoots)
void SetAttackRate(float a_AttackRate)
enum cMonster::MState m_EMState
bool m_CanBeLeashed
Determines whether a monster can be leashed.
eMonsterType
Identifies individual monster type, as well as their network type-ID.
bool ReachedFinalDestination(void)
Returns if the ultimate, final destination has been reached.
bool WouldBurnAt(Vector3d a_Location, cChunk &a_Chunk)
bool m_IsLeashActionJustDone
Mob has ben leashed or unleashed in current player action.
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 CheckEventLostPlayer(void)
void SetDropChanceLeggings(float a_DropChanceLeggings)
virtual void EventLosePlayer(void)
void SetAttackDamage(int a_AttackDamage)
static int GetSpawnDelay(cMonster::eFamily a_MobFamily)
Returns the spawn delay (number of game ticks between spawn attempts) for the given mob family...
void UnsafeUnsetTarget()
Unset the target without notifying the target entity.
void SetCustomName(const AString &a_CustomName)
Sets the custom name of the monster.
bool m_WasLastTargetAPlayer
float GetDropChanceWeapon()
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...
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
virtual bool IsUndead(void)
Returns whether this mob is undead (skeleton, zombie, etc.)
Vector3d m_NextWayPointPosition
Coordinates of the next position that should be reached.
bool WasLastTargetAPlayer() const
Returns if this mob last target was a player to avoid destruction on player quit. ...
void SetPitchAndYawFromDestination(bool a_IsFollowingPath)
Sets the body yaw and head yaw.
static eFamily FamilyFromType(eMonsterType a_MobType)
Returns the mob family based on the type.
bool TargetIsInRange(void)
Returns whether or not the target is close enough for attack.
int m_TicksSinceLastDamaged
std::chrono::milliseconds m_DestroyTimer
void SetTarget(cPawn *a_NewTarget)
Sets the target that this mob will chase.
cMonster(const AString &a_ConfigName, eMonsterType a_MobType, const AString &a_SoundHurt, const AString &a_SoundDeath, double a_Width, double a_Height)
Creates the mob object.
static AString MobTypeToVanillaNBT(eMonsterType a_MobType)
Translates the MobType enum to the vanilla nbt name.
bool IsLeashed() const
Returns whether the monster is leashed to an entity.
int m_AttackCoolDownTicksLeft
float GetDropChanceBoots()
float m_DropChanceLeggings
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...
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 ...
std::chrono::milliseconds m_IdleInterval
float m_DropChanceChestplate
virtual void Destroy(bool a_ShouldBroadcast=true) override
Destroys the entity and schedules it for memory freeing; if a_ShouldBroadcast is set to true...
virtual void CheckEventSeePlayer(cChunk &a_Chunk)
bool BurnsInDaylight() const
void SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible)
Sets the custom name visiblity of this monster.
static AString MobTypeToString(eMonsterType a_MobType)
Translates MobType enum to a string, empty string if unknown.
cPathFinder m_PathFinder
The pathfinder instance handles pathfinding for this monster.
void HandleDaylightBurning(cChunk &a_Chunk, bool WouldBurn)
static eMonsterType StringToMobType(const AString &a_MobTypeName)
Translates MobType string to the enum, mtInvalidType if not recognized.
void SetAttackRange(int a_AttackRange)
void ResetAttackCooldown()
void SetDropChanceHelmet(float a_DropChanceHelmet)
virtual bool IsSitting(void) const
void CalcLeashActions(std::chrono::milliseconds a_Dt)
Leash calculations inside Tick function.
bool m_CustomNameAlwaysVisible
virtual void EventSeePlayer(cPlayer *a_Player, cChunk &a_Chunk)
Vector3d * GetLeashToPos() const
Gets entity position to where mob should be leashed.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
void SetCanBeLeashed(bool a_CanBeLeashed)
Sets whether the mob can be leashed, for extensibility in plugins.
virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
void GetMonsterConfig(const AString &a_Name)
Reads the monster configuration for the specified monster name and assigns it to this object...
eFamily GetMobFamily(void) const
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
#define CLASS_PROTODEF(classname)
void LeashTo(cEntity &a_Entity, bool a_ShouldBroadcast=true)
Leash the monster to an entity.
void Unleash(bool a_ShouldDropLeashPickup)
Unleash the monster.
void StopMovingToPosition()
Stops pathfinding.
virtual void InStateChasing(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
static AString MobTypeToVanillaName(eMonsterType a_MobType)
Translates MobType enum to the vanilla name of the mob, empty string if unknown.
virtual bool IsTame(void) const
enum cMonster::MPersonality m_EMPersonality
void SetLeashToPos(Vector3d *pos)
Sets entity position to where is leashed this mob.
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. ...
void SetBurnsInDaylight(bool a_BurnsInDaylight)
This class bridges a vector of cItem for safe access via Lua.
virtual void HandleFalling(void) override
bool CanBeLeashed() const
Returns whether the mob can be leashed.
std::unique_ptr< Vector3d > m_LeashToPos
Entity pos where this mob was leashed to.