1
0
Fork 0

Only nether-native mobs can see through lava

This commit is contained in:
Rorkh 2021-09-18 14:10:31 +05:00 committed by Tiger Wang
parent 798fdb0709
commit 4c5d9d38f4
13 changed files with 95 additions and 88 deletions

View File

@ -72,7 +72,7 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
*GetWorld(), *GetWorld(),
GetPosition().addedY(GetHeight()), GetPosition().addedY(GetHeight()),
GetTarget()->GetPosition().addedY(GetTarget()->GetHeight()), GetTarget()->GetPosition().addedY(GetTarget()->GetHeight()),
cLineBlockTracer::losAirWaterLava // TODO: Currently all mobs see through lava, but only Nether-native mobs should be able to. (IsNetherNative() ? cLineBlockTracer::losAirWaterLava : cLineBlockTracer::losAirWater)
) && ) &&
(GetHealth() > 0.0) (GetHealth() > 0.0)
) )

View File

@ -21,19 +21,6 @@ cBlaze::cBlaze(void) :
void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
{
unsigned int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD);
}
}
bool cBlaze::Attack(std::chrono::milliseconds a_Dt) bool cBlaze::Attack(std::chrono::milliseconds a_Dt)
{ {
if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0) && (!m_IsCharging)) if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0) && (!m_IsCharging))
@ -48,6 +35,19 @@ bool cBlaze::Attack(std::chrono::milliseconds a_Dt)
void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
{
unsigned int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD);
}
}
void cBlaze::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) void cBlaze::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{ {
Super::Tick(a_Dt, a_Chunk); Super::Tick(a_Dt, a_Chunk);
@ -84,6 +84,3 @@ void cBlaze::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
ResetAttackCooldown(); ResetAttackCooldown();
} }
} }

View File

@ -18,11 +18,13 @@ public:
CLASS_PROTODEF(cBlaze) CLASS_PROTODEF(cBlaze)
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
private: private:
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool IsNetherNative(void) override { return true; }
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
/** Specifies whether or not the blaze has started shooting fireballs. */ /** Specifies whether or not the blaze has started shooting fireballs. */
bool m_IsCharging; bool m_IsCharging;

View File

@ -22,21 +22,6 @@ cGhast::cGhast(void) :
void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
unsigned int LootingLevel = 0;
if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GHAST_TEAR);
}
bool cGhast::Attack(std::chrono::milliseconds a_Dt) bool cGhast::Attack(std::chrono::milliseconds a_Dt)
{ {
if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0) && (!m_IsCharging)) if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0) && (!m_IsCharging))
@ -71,6 +56,21 @@ bool cGhast::DoTakeDamage(TakeDamageInfo & a_TDI)
void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
unsigned int LootingLevel = 0;
if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GHAST_TEAR);
}
void cGhast::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) void cGhast::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{ {
Super::Tick(a_Dt, a_Chunk); Super::Tick(a_Dt, a_Chunk);
@ -113,5 +113,3 @@ void cGhast::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
AddSpeed(SpeedVector); AddSpeed(SpeedVector);
} }
} }

View File

@ -18,14 +18,16 @@ public:
CLASS_PROTODEF(cGhast) CLASS_PROTODEF(cGhast)
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
bool IsCharging(void) const { return m_IsCharging; } bool IsCharging(void) const { return m_IsCharging; }
private: private:
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool IsNetherNative(void) override { return true; }
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
/** Specifies whether or not the ghast has started shooting a fireball. */ /** Specifies whether or not the ghast has started shooting a fireball. */
bool m_IsCharging; bool m_IsCharging;
@ -36,7 +38,3 @@ private:
Only used while m_IsCharging is true. */ Only used while m_IsCharging is true. */
int m_TicksUntilShot; int m_TicksUntilShot;
} ; } ;

View File

@ -24,19 +24,6 @@ cMagmaCube::cMagmaCube(int a_Size) :
void cMagmaCube::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
UNUSED(a_Killer);
if (GetSize() > 1)
{
AddRandomUncommonDropItem(a_Drops, 25.0f, E_ITEM_MAGMA_CREAM);
}
}
AString cMagmaCube::GetSizeName(int a_Size) AString cMagmaCube::GetSizeName(int a_Size)
{ {
if (a_Size == 1) if (a_Size == 1)
@ -45,3 +32,16 @@ AString cMagmaCube::GetSizeName(int a_Size)
} }
return ""; return "";
} }
void cMagmaCube::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
UNUSED(a_Killer);
if (GetSize() > 1)
{
AddRandomUncommonDropItem(a_Drops, 25.0f, E_ITEM_MAGMA_CREAM);
}
}

View File

@ -18,19 +18,17 @@ public:
CLASS_PROTODEF(cMagmaCube) CLASS_PROTODEF(cMagmaCube)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
int GetSize(void) const { return m_Size; } int GetSize(void) const { return m_Size; }
/** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds. /** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds.
Returns either "big" or "small". */ Returns either "big" or "small". */
static AString GetSizeName(int a_Size); static AString GetSizeName(int a_Size);
protected: private:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool IsNetherNative(void) override { return true; }
/** Size of the MagmaCube, with 1 being the smallest */ /** Size of the MagmaCube, with 1 being the smallest */
int m_Size; int m_Size;
} ; } ;

View File

@ -979,6 +979,15 @@ void cMonster::GetMonsterConfig(const AString & a_Name)
bool cMonster::IsNetherNative(void)
{
return false;
}
bool cMonster::IsUndead(void) bool cMonster::IsUndead(void)
{ {
return false; return false;

View File

@ -108,6 +108,10 @@ public:
/** Reads the monster configuration for the specified monster name and assigns it to this object. */ /** Reads the monster configuration for the specified monster name and assigns it to this object. */
void GetMonsterConfig(const AString & a_Name); void GetMonsterConfig(const AString & a_Name);
/** Returns whether this mob spawns in the Nether in Vanilla.
This is a fixed value and is not affected by custom mob spawning settings. */
virtual bool IsNetherNative(void);
/** Returns whether this mob is undead (skeleton, zombie, etc.) */ /** Returns whether this mob is undead (skeleton, zombie, etc.) */
virtual bool IsUndead(void); virtual bool IsUndead(void);

View File

@ -18,12 +18,10 @@ public:
CLASS_PROTODEF(cWitherSkeleton) CLASS_PROTODEF(cWitherSkeleton)
private:
virtual bool Attack(std::chrono::milliseconds a_Dt) override; virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool IsNetherNative(void) override { return true; }
virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
} ; } ;

View File

@ -38,16 +38,6 @@ void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cZombiePigman::SpawnOn(cClientHandle & a_ClientHandle)
{
Super::SpawnOn(a_ClientHandle);
a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_GOLD_SWORD));
}
void cZombiePigman::KilledBy(TakeDamageInfo & a_TDI) void cZombiePigman::KilledBy(TakeDamageInfo & a_TDI)
{ {
Super::KilledBy(a_TDI); Super::KilledBy(a_TDI);
@ -62,3 +52,9 @@ void cZombiePigman::KilledBy(TakeDamageInfo & a_TDI)
void cZombiePigman::SpawnOn(cClientHandle & a_ClientHandle)
{
Super::SpawnOn(a_ClientHandle);
a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_GOLD_SWORD));
}

View File

@ -17,13 +17,11 @@ public:
CLASS_PROTODEF(cZombiePigman) CLASS_PROTODEF(cZombiePigman)
private:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool IsUndead(void) override { return true; }
virtual bool IsNetherNative(void) override { return true; }
virtual void KilledBy(TakeDamageInfo & a_TDI) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual bool IsUndead(void) override { return true; }
} ; } ;

View File

@ -954,9 +954,18 @@ void cMonster::CheckEventSeePlayer(class cChunk & a_Chunk)
bool cMonster::IsNetherNative(void)
{
return false;
}
bool cMonster::IsUndead(void) bool cMonster::IsUndead(void)
{ {
return true; return false;
} }