diff options
author | Rorkh <rorkh@internet.ru> | 2021-09-18 11:10:31 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-10-02 22:18:18 +0200 |
commit | 4c5d9d38f45ae7c18a3e9799152305757a8a1d2a (patch) | |
tree | 6c369d0901427be8ab92bef9cd229e60a21486a0 /src | |
parent | Snipe skeleton achievment (diff) | |
download | cuberite-4c5d9d38f45ae7c18a3e9799152305757a8a1d2a.tar cuberite-4c5d9d38f45ae7c18a3e9799152305757a8a1d2a.tar.gz cuberite-4c5d9d38f45ae7c18a3e9799152305757a8a1d2a.tar.bz2 cuberite-4c5d9d38f45ae7c18a3e9799152305757a8a1d2a.tar.lz cuberite-4c5d9d38f45ae7c18a3e9799152305757a8a1d2a.tar.xz cuberite-4c5d9d38f45ae7c18a3e9799152305757a8a1d2a.tar.zst cuberite-4c5d9d38f45ae7c18a3e9799152305757a8a1d2a.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Mobs/AggressiveMonster.cpp | 2 | ||||
-rw-r--r-- | src/Mobs/Blaze.cpp | 21 | ||||
-rw-r--r-- | src/Mobs/Blaze.h | 8 | ||||
-rw-r--r-- | src/Mobs/Ghast.cpp | 32 | ||||
-rw-r--r-- | src/Mobs/Ghast.h | 16 | ||||
-rw-r--r-- | src/Mobs/MagmaCube.cpp | 16 | ||||
-rw-r--r-- | src/Mobs/MagmaCube.h | 10 | ||||
-rw-r--r-- | src/Mobs/Monster.cpp | 9 | ||||
-rw-r--r-- | src/Mobs/Monster.h | 4 | ||||
-rw-r--r-- | src/Mobs/WitherSkeleton.h | 8 | ||||
-rw-r--r-- | src/Mobs/ZombiePigman.cpp | 16 | ||||
-rw-r--r-- | src/Mobs/ZombiePigman.h | 10 |
12 files changed, 75 insertions, 77 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index bcc824bba..f7392d92e 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.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) ) diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index b771ef7e7..4a87e698b 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -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(); } } - - - diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h index 6f1d240a9..9ebc1ffcf 100644 --- a/src/Mobs/Blaze.h +++ b/src/Mobs/Blaze.h @@ -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; diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp index 3b20bea28..39fc2e99b 100644 --- a/src/Mobs/Ghast.cpp +++ b/src/Mobs/Ghast.cpp @@ -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); } } - - diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h index 8161b93bf..755ec3b89 100644 --- a/src/Mobs/Ghast.h +++ b/src/Mobs/Ghast.h @@ -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; } ; - - - - diff --git a/src/Mobs/MagmaCube.cpp b/src/Mobs/MagmaCube.cpp index e84577433..45dbbc519 100644 --- a/src/Mobs/MagmaCube.cpp +++ b/src/Mobs/MagmaCube.cpp @@ -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 ""; } diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h index 3a7d25055..07794cc5a 100644 --- a/src/Mobs/MagmaCube.h +++ b/src/Mobs/MagmaCube.h @@ -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; } ; - - - - diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index d99f2cddc..dc77dc0f8 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -979,6 +979,15 @@ void cMonster::GetMonsterConfig(const AString & a_Name) +bool cMonster::IsNetherNative(void) +{ + return false; +} + + + + + bool cMonster::IsUndead(void) { return false; diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 410754663..0127ec4ce 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -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); diff --git a/src/Mobs/WitherSkeleton.h b/src/Mobs/WitherSkeleton.h index 41e55e073..8aa7574df 100644 --- a/src/Mobs/WitherSkeleton.h +++ b/src/Mobs/WitherSkeleton.h @@ -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; - } ; - - - - diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp index 60d5ab9f1..755f585ab 100644 --- a/src/Mobs/ZombiePigman.cpp +++ b/src/Mobs/ZombiePigman.cpp @@ -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)); +} diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h index ccc07e9a2..93535a3ce 100644 --- a/src/Mobs/ZombiePigman.h +++ b/src/Mobs/ZombiePigman.h @@ -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; } } ; - - - - |