diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-02-04 13:09:06 +0100 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-02-04 19:44:55 +0100 |
commit | 6661e5d27f548f3f9d82c1d5a784a24a8730f5b5 (patch) | |
tree | c72f1119f8ab6f0479779489af8520cb2caad812 /src/Mobs | |
parent | Merge pull request #2939 from LogicParrot/m_Target (diff) | |
download | cuberite-6661e5d27f548f3f9d82c1d5a784a24a8730f5b5.tar cuberite-6661e5d27f548f3f9d82c1d5a784a24a8730f5b5.tar.gz cuberite-6661e5d27f548f3f9d82c1d5a784a24a8730f5b5.tar.bz2 cuberite-6661e5d27f548f3f9d82c1d5a784a24a8730f5b5.tar.lz cuberite-6661e5d27f548f3f9d82c1d5a784a24a8730f5b5.tar.xz cuberite-6661e5d27f548f3f9d82c1d5a784a24a8730f5b5.tar.zst cuberite-6661e5d27f548f3f9d82c1d5a784a24a8730f5b5.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/PassiveMonster.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index 30b46500d..53288a54c 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -157,19 +157,33 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) virtual bool Item(cEntity * a_Entity) override { - // if we're the same species as someone around and they don't have a partner, start mating with them - if ((a_Entity->GetEntityType() == m_Me->GetEntityType()) && (a_Entity != m_Me)) + // If the entity is not a monster, don't breed with it + // Also, do not self-breed + if ((a_Entity->GetEntityType() != etMonster) || (a_Entity == m_Me)) { - cPassiveMonster * Me = static_cast<cPassiveMonster*>(m_Me); - cPassiveMonster * Partner = static_cast<cPassiveMonster*>(a_Entity); - if (Partner->IsInLove() && (Partner->GetPartner() == nullptr)) - { - Partner->EngageLoveMode(Me); - Me->EngageLoveMode(Partner); - return true; - } + return false; } - return false; + + cPassiveMonster * Me = static_cast<cPassiveMonster*>(m_Me); + cPassiveMonster * PotentialPartner = static_cast<cPassiveMonster*>(a_Entity); + + // If the potential partner is not of the same species, don't breed with it + if (PotentialPartner->GetMobType() != Me->GetMobType()) + { + return false; + } + + // If the potential partner is not in love + // Or they already have a mate, do not breed with them + if ((!PotentialPartner->IsInLove()) || (PotentialPartner->GetPartner() != nullptr)) + { + return false; + } + + // All conditions met, let's breed! + PotentialPartner->EngageLoveMode(Me); + Me->EngageLoveMode(PotentialPartner); + return true; } } Callback(this); |