5 #include "../FastRandom.h"
15 fmt::format(FMT_STRING(
"entity.{}slime.hurt"), GetSizeName(a_Size)),
16 fmt::format(FMT_STRING(
"entity.{}slime.death"), GetSizeName(a_Size)),
33 unsigned int LootingLevel = 0;
34 if (a_Killer !=
nullptr)
75 int SpawnAmount = Random.RandInt(2, 4);
77 for (
int i = 0; i < SpawnAmount; ++i)
79 double AddX = (i % 2 - 0.5) *
m_Size / 4.0;
80 double AddZ = (i / 2 - 0.5) *
m_Size / 4.0;
85 Yaw = Random.RandReal(360.0f),
89 auto NewSlime = std::make_unique<cSlime>(Size);
90 NewSlime->SetPosition(Position);
91 NewSlime->SetYaw(Yaw);
92 a_World.SpawnMobFinalize(std::move(NewSlime));
MTRand & GetRandomProvider()
Returns the current thread's random number source.
std::chrono::duration< signed int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 > >> cTickTime
Vector3< double > Vector3d
Implements custom fmtlib formatting for cChunkCoords.
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
virtual cItem GetEquippedWeapon(void) const
Returns the curently equipped weapon; empty item if none.
float GetHealth(void) const
Returns the health of this entity.
void SetMaxHealth(float a_MaxHealth)
Sets the maximum value for the health.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
cEnchantments m_Enchantments
This class bridges a vector of cItem for safe access via Lua.
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 KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
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 SetAttackDamage(int a_AttackDamage)
cSlime(int a_Size)
Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tal...
int m_Size
Size of the slime, with 1 being the smallest.
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
virtual void GetDrops(cItems &a_Drops, cEntity *a_Killer=nullptr) override
Returns the list of drops for this pawn when it is killed.
virtual bool Attack(std::chrono::milliseconds a_Dt) override
Try to perform attack returns true if attack was deemed successful (hit player, fired projectile,...
static AString GetSizeName(int a_Size)
Returns the text describing the slime's size, as used by the client's resource subsystem for sounds.
void ScheduleTask(cTickTime a_DelayTicks, std::function< void(cWorld &)> a_Task)
Queues a lambda task onto the tick thread, with the specified delay.