1
0
Fork 0

Only nether-native mobs can see through lava

master
Rorkh 1 year ago committed by Tiger Wang
parent 798fdb0709
commit 4c5d9d38f4
  1. 2
      src/Mobs/AggressiveMonster.cpp
  2. 21
      src/Mobs/Blaze.cpp
  3. 8
      src/Mobs/Blaze.h
  4. 32
      src/Mobs/Ghast.cpp
  5. 16
      src/Mobs/Ghast.h
  6. 16
      src/Mobs/MagmaCube.cpp
  7. 10
      src/Mobs/MagmaCube.h
  8. 9
      src/Mobs/Monster.cpp
  9. 4
      src/Mobs/Monster.h
  10. 8
      src/Mobs/WitherSkeleton.h
  11. 16
      src/Mobs/ZombiePigman.cpp
  12. 10
      src/Mobs/ZombiePigman.h
  13. 11
      tests/Generating/Stubs.cpp

@ -72,7 +72,7 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
*GetWorld(),
GetPosition().addedY(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)
)

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

@ -18,11 +18,13 @@ public:
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;
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;
private:
/** Specifies whether or not the blaze has started shooting fireballs. */
bool m_IsCharging;

@ -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)
{
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)
{
Super::Tick(a_Dt, a_Chunk);
@ -113,5 +113,3 @@ void cGhast::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
AddSpeed(SpeedVector);
}
}

@ -18,14 +18,16 @@ public:
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; }
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. */
bool m_IsCharging;
@ -36,7 +38,3 @@ private:
Only used while m_IsCharging is true. */
int m_TicksUntilShot;
} ;

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

@ -18,19 +18,17 @@ public:
CLASS_PROTODEF(cMagmaCube)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
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 either "big" or "small". */
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 */
int m_Size;
} ;

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

@ -108,6 +108,10 @@ public:
/** Reads the monster configuration for the specified monster name and assigns it to this object. */
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.) */
virtual bool IsUndead(void);

@ -18,12 +18,10 @@ public:
CLASS_PROTODEF(cWitherSkeleton)
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 SpawnOn(cClientHandle & a_ClientHandle) override;
} ;

@ -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)
{
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));
}

@ -17,13 +17,11 @@ public:
CLASS_PROTODEF(cZombiePigman)
private:
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 SpawnOn(cClientHandle & a_ClientHandle) override;
virtual bool IsUndead(void) override { return true; }
} ;

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

Loading…
Cancel
Save