From ebe0f9372fa8787b3fe709937ebd3af30810f910 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Wed, 29 Jan 2014 18:08:33 +0100 Subject: Now mobs follow you when holding their breed item --- src/Mobs/Chicken.cpp | 25 ++++++++++++++++++++++++- src/Mobs/Chicken.h | 3 +++ src/Mobs/Cow.cpp | 28 ++++++++++++++++++++++++++-- src/Mobs/Cow.h | 8 ++++++++ src/Mobs/Mooshroom.cpp | 27 +++++++++++++++++++++++++++ src/Mobs/Mooshroom.h | 8 ++++++++ src/Mobs/Pig.cpp | 27 ++++++++++++++++++++++++++- src/Mobs/Pig.h | 4 ++++ src/Mobs/Sheep.cpp | 24 ++++++++++++++++++++++++ src/Mobs/Sheep.h | 4 +++- 10 files changed, 153 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp index 087fd088a..52c8d3788 100644 --- a/src/Mobs/Chicken.cpp +++ b/src/Mobs/Chicken.cpp @@ -2,7 +2,7 @@ #include "Chicken.h" #include "../World.h" - +#include "../Entities/Player.h" @@ -41,6 +41,29 @@ void cChicken::Tick(float a_Dt, cChunk & a_Chunk) { m_EggDropTimer++; } + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + if (a_Closest_Player != NULL) + { + if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_SEEDS) + { + if (!IsBegging()) + { + m_IsBegging = true; + m_World->BroadcastEntityMetadata(*this); + } + Vector3d PlayerPos = a_Closest_Player->GetPosition(); + PlayerPos.y++; + m_FinalDestination = PlayerPos; + } + else + { + if (IsBegging()) + { + m_IsBegging = false; + m_World->BroadcastEntityMetadata(*this); + } + } + } } diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h index 979c4d8a0..b9cff40d4 100644 --- a/src/Mobs/Chicken.h +++ b/src/Mobs/Chicken.h @@ -19,10 +19,13 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + bool IsBegging (void) const { return m_IsBegging; } + private: int m_EggDropTimer; + bool m_IsBegging; } ; diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp index 9eb74dac2..205ecc73f 100644 --- a/src/Mobs/Cow.cpp +++ b/src/Mobs/Cow.cpp @@ -41,5 +41,29 @@ void cCow::OnRightClicked(cPlayer & a_Player) } } - - +void cCow::Tick(float a_Dt, cChunk & a_Chunk) +{ + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + if (a_Closest_Player != NULL) + { + if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT) + { + if (!IsBegging()) + { + m_IsBegging = true; + m_World->BroadcastEntityMetadata(*this); + } + Vector3d PlayerPos = a_Closest_Player->GetPosition(); + PlayerPos.y++; + m_FinalDestination = PlayerPos; + } + else + { + if (IsBegging()) + { + m_IsBegging = false; + m_World->BroadcastEntityMetadata(*this); + } + } + } +} diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h index 0391d4a31..b001ea856 100644 --- a/src/Mobs/Cow.h +++ b/src/Mobs/Cow.h @@ -19,6 +19,14 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + + bool IsBegging (void) const { return m_IsBegging; } + +private: + + bool m_IsBegging; + } ; diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp index 940e2db44..1ff90392d 100644 --- a/src/Mobs/Mooshroom.cpp +++ b/src/Mobs/Mooshroom.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Mooshroom.h" +#include "../Entities/Player.h" @@ -29,5 +30,31 @@ void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer) } +void cMooshroom::Tick(float a_Dt, cChunk & a_Chunk) +{ + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + if (a_Closest_Player != NULL) + { + if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT) + { + if (!IsBegging()) + { + m_IsBegging = true; + m_World->BroadcastEntityMetadata(*this); + } + Vector3d PlayerPos = a_Closest_Player->GetPosition(); + PlayerPos.y++; + m_FinalDestination = PlayerPos; + } + else + { + if (IsBegging()) + { + m_IsBegging = false; + m_World->BroadcastEntityMetadata(*this); + } + } + } +} diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h index 73f6348b6..c288f68a9 100644 --- a/src/Mobs/Mooshroom.h +++ b/src/Mobs/Mooshroom.h @@ -18,6 +18,14 @@ public: CLASS_PROTODEF(cMooshroom); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + + bool IsBegging (void) const { return m_IsBegging; } + +private: + + bool m_IsBegging; + } ; diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index 0871a38a9..e31bc90ba 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -71,7 +71,32 @@ void cPig::OnRightClicked(cPlayer & a_Player) } } - +void cPig::Tick(float a_Dt, cChunk & a_Chunk) +{ + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + if (a_Closest_Player != NULL) + { + if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_CARROT) + { + if (!IsBegging()) + { + m_IsBegging = true; + m_World->BroadcastEntityMetadata(*this); + } + Vector3d PlayerPos = a_Closest_Player->GetPosition(); + PlayerPos.y++; + m_FinalDestination = PlayerPos; + } + else + { + if (IsBegging()) + { + m_IsBegging = false; + m_World->BroadcastEntityMetadata(*this); + } + } + } +} diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index 4fd0d8db8..f42a4f412 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -19,10 +19,14 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + bool IsSaddled(void) const { return m_bIsSaddled; } + bool IsBegging (void) const { return m_IsBegging; } private: + bool m_IsBegging; bool m_bIsSaddled; } ; diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 702108ae4..3fb9351ad 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -96,4 +96,28 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk) } } } + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + if (a_Closest_Player != NULL) + { + if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT) + { + if (!IsBegging()) + { + m_IsBegging = true; + m_World->BroadcastEntityMetadata(*this); + } + Vector3d PlayerPos = a_Closest_Player->GetPosition(); + PlayerPos.y++; + m_FinalDestination = PlayerPos; + } + else + { + if (IsBegging()) + { + m_IsBegging = false; + m_World->BroadcastEntityMetadata(*this); + } + } + } } + diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 4eee3db1c..322b31dd9 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -21,11 +21,13 @@ public: virtual void OnRightClicked(cPlayer & a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + bool IsBegging(void) const { return m_IsBegging; } bool IsSheared(void) const { return m_IsSheared; } int GetFurColor(void) const { return m_WoolColor; } private: - + + bool m_IsBegging; bool m_IsSheared; int m_WoolColor; int m_TimeToStopEating; -- cgit v1.2.3 From 73d9a285d511a3cd1016aafc8c492924e6a7b249 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Wed, 29 Jan 2014 18:25:10 +0100 Subject: Fixed a copypasta error... --- src/Mobs/Cow.cpp | 3 ++- src/Mobs/Mooshroom.cpp | 1 + src/Mobs/Pig.cpp | 1 + src/Mobs/Sheep.cpp | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp index 205ecc73f..4063f034d 100644 --- a/src/Mobs/Cow.cpp +++ b/src/Mobs/Cow.cpp @@ -42,7 +42,8 @@ void cCow::OnRightClicked(cPlayer & a_Player) } void cCow::Tick(float a_Dt, cChunk & a_Chunk) -{ +{ + super::Tick(a_Dt, a_Chunk); cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); if (a_Closest_Player != NULL) { diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp index 1ff90392d..60721f0ee 100644 --- a/src/Mobs/Mooshroom.cpp +++ b/src/Mobs/Mooshroom.cpp @@ -32,6 +32,7 @@ void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cMooshroom::Tick(float a_Dt, cChunk & a_Chunk) { + super::Tick(a_Dt, a_Chunk); cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); if (a_Closest_Player != NULL) { diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index e31bc90ba..b6d11d856 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -73,6 +73,7 @@ void cPig::OnRightClicked(cPlayer & a_Player) void cPig::Tick(float a_Dt, cChunk & a_Chunk) { + super::Tick(a_Dt, a_Chunk); cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); if (a_Closest_Player != NULL) { diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 3fb9351ad..2478ec79c 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -68,6 +68,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player) void cSheep::Tick(float a_Dt, cChunk & a_Chunk) { + super::Tick(a_Dt, a_Chunk); // The sheep should not move when he's eating so only handle the physics. if (m_TimeToStopEating > 0) { -- cgit v1.2.3 From ba4865f7ee99490ff46d4b584ffa0ae85fa21aae Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Wed, 29 Jan 2014 18:32:46 +0100 Subject: Fixed sheep --- src/Mobs/Sheep.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 2478ec79c..c8ff8f5c8 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -68,7 +68,6 @@ void cSheep::OnRightClicked(cPlayer & a_Player) void cSheep::Tick(float a_Dt, cChunk & a_Chunk) { - super::Tick(a_Dt, a_Chunk); // The sheep should not move when he's eating so only handle the physics. if (m_TimeToStopEating > 0) { @@ -96,27 +95,27 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk) m_TimeToStopEating = 40; } } - } - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); - if (a_Closest_Player != NULL) - { - if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT) + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + if (a_Closest_Player != NULL) { - if (!IsBegging()) + if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT) { - m_IsBegging = true; - m_World->BroadcastEntityMetadata(*this); + if (!IsBegging()) + { + m_IsBegging = true; + m_World->BroadcastEntityMetadata(*this); + } + Vector3d PlayerPos = a_Closest_Player->GetPosition(); + PlayerPos.y++; + m_FinalDestination = PlayerPos; } - Vector3d PlayerPos = a_Closest_Player->GetPosition(); - PlayerPos.y++; - m_FinalDestination = PlayerPos; - } - else - { - if (IsBegging()) + else { - m_IsBegging = false; - m_World->BroadcastEntityMetadata(*this); + if (IsBegging()) + { + m_IsBegging = false; + m_World->BroadcastEntityMetadata(*this); + } } } } -- cgit v1.2.3 From 1c1832b6ce08de71e6a46187420d91eacb18d16e Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Wed, 29 Jan 2014 19:15:26 +0100 Subject: Rewritten code. Implemented xoft suggestion. Using MoveToPosition as tigerw suggested. --- src/Mobs/Chicken.cpp | 23 ----------------------- src/Mobs/Chicken.h | 4 +--- src/Mobs/Cow.cpp | 27 --------------------------- src/Mobs/Cow.h | 7 +------ src/Mobs/Mooshroom.cpp | 28 ---------------------------- src/Mobs/Mooshroom.h | 8 +------- src/Mobs/PassiveMonster.cpp | 16 +++++++++++++++- src/Mobs/PassiveMonster.h | 2 ++ src/Mobs/Pig.cpp | 28 ---------------------------- src/Mobs/Pig.h | 5 ++--- src/Mobs/Sheep.cpp | 23 ----------------------- src/Mobs/Sheep.h | 6 +++--- 12 files changed, 25 insertions(+), 152 deletions(-) (limited to 'src') diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp index 52c8d3788..90d56d1de 100644 --- a/src/Mobs/Chicken.cpp +++ b/src/Mobs/Chicken.cpp @@ -41,29 +41,6 @@ void cChicken::Tick(float a_Dt, cChunk & a_Chunk) { m_EggDropTimer++; } - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); - if (a_Closest_Player != NULL) - { - if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_SEEDS) - { - if (!IsBegging()) - { - m_IsBegging = true; - m_World->BroadcastEntityMetadata(*this); - } - Vector3d PlayerPos = a_Closest_Player->GetPosition(); - PlayerPos.y++; - m_FinalDestination = PlayerPos; - } - else - { - if (IsBegging()) - { - m_IsBegging = false; - m_World->BroadcastEntityMetadata(*this); - } - } - } } diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h index b9cff40d4..a4c1d6b9e 100644 --- a/src/Mobs/Chicken.h +++ b/src/Mobs/Chicken.h @@ -19,13 +19,11 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - bool IsBegging (void) const { return m_IsBegging; } + virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); } private: - int m_EggDropTimer; - bool m_IsBegging; } ; diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp index 4063f034d..d8e905217 100644 --- a/src/Mobs/Cow.cpp +++ b/src/Mobs/Cow.cpp @@ -41,30 +41,3 @@ void cCow::OnRightClicked(cPlayer & a_Player) } } -void cCow::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); - if (a_Closest_Player != NULL) - { - if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT) - { - if (!IsBegging()) - { - m_IsBegging = true; - m_World->BroadcastEntityMetadata(*this); - } - Vector3d PlayerPos = a_Closest_Player->GetPosition(); - PlayerPos.y++; - m_FinalDestination = PlayerPos; - } - else - { - if (IsBegging()) - { - m_IsBegging = false; - m_World->BroadcastEntityMetadata(*this); - } - } - } -} diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h index b001ea856..973171ab5 100644 --- a/src/Mobs/Cow.h +++ b/src/Mobs/Cow.h @@ -19,13 +19,8 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - bool IsBegging (void) const { return m_IsBegging; } - -private: - - bool m_IsBegging; + virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } } ; diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp index 60721f0ee..00ba339a6 100644 --- a/src/Mobs/Mooshroom.cpp +++ b/src/Mobs/Mooshroom.cpp @@ -30,32 +30,4 @@ void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer) } -void cMooshroom::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); - if (a_Closest_Player != NULL) - { - if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT) - { - if (!IsBegging()) - { - m_IsBegging = true; - m_World->BroadcastEntityMetadata(*this); - } - Vector3d PlayerPos = a_Closest_Player->GetPosition(); - PlayerPos.y++; - m_FinalDestination = PlayerPos; - } - else - { - if (IsBegging()) - { - m_IsBegging = false; - m_World->BroadcastEntityMetadata(*this); - } - } - } -} - diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h index c288f68a9..c94301098 100644 --- a/src/Mobs/Mooshroom.h +++ b/src/Mobs/Mooshroom.h @@ -18,14 +18,8 @@ public: CLASS_PROTODEF(cMooshroom); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - - bool IsBegging (void) const { return m_IsBegging; } - -private: - - bool m_IsBegging; + virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } } ; diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index d774d3170..903761a95 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -3,7 +3,7 @@ #include "PassiveMonster.h" #include "../World.h" - +#include "../Entities/Player.h" @@ -39,6 +39,20 @@ void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk) { CheckEventLostPlayer(); } + cItem FollowedItem = GetFollowedItem(); + if (FollowedItem.IsEmpty()) + { + return; + } + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + if (a_Closest_Player != NULL) + { + if (a_Closest_Player->GetEquippedItem().m_ItemType == FollowedItem.m_ItemType) + { + Vector3d PlayerPos = a_Closest_Player->GetPosition(); + MoveToPosition(PlayerPos); + } + } } diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h index 14a6be6b1..7da5d71bc 100644 --- a/src/Mobs/PassiveMonster.h +++ b/src/Mobs/PassiveMonster.h @@ -20,6 +20,8 @@ public: /// When hit by someone, run away virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual const cItem GetFollowedItem(void) const { return cItem(); } + } ; diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index b6d11d856..d8f3dda37 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -71,33 +71,5 @@ void cPig::OnRightClicked(cPlayer & a_Player) } } -void cPig::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); - if (a_Closest_Player != NULL) - { - if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_CARROT) - { - if (!IsBegging()) - { - m_IsBegging = true; - m_World->BroadcastEntityMetadata(*this); - } - Vector3d PlayerPos = a_Closest_Player->GetPosition(); - PlayerPos.y++; - m_FinalDestination = PlayerPos; - } - else - { - if (IsBegging()) - { - m_IsBegging = false; - m_World->BroadcastEntityMetadata(*this); - } - } - } -} - diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index f42a4f412..d434324c1 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -19,14 +19,13 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + + virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); } bool IsSaddled(void) const { return m_bIsSaddled; } - bool IsBegging (void) const { return m_IsBegging; } private: - bool m_IsBegging; bool m_bIsSaddled; } ; diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index c8ff8f5c8..4761103e5 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -95,29 +95,6 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk) m_TimeToStopEating = 40; } } - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); - if (a_Closest_Player != NULL) - { - if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT) - { - if (!IsBegging()) - { - m_IsBegging = true; - m_World->BroadcastEntityMetadata(*this); - } - Vector3d PlayerPos = a_Closest_Player->GetPosition(); - PlayerPos.y++; - m_FinalDestination = PlayerPos; - } - else - { - if (IsBegging()) - { - m_IsBegging = false; - m_World->BroadcastEntityMetadata(*this); - } - } - } } } diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 322b31dd9..402e8e61c 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -21,13 +21,13 @@ public: virtual void OnRightClicked(cPlayer & a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - bool IsBegging(void) const { return m_IsBegging; } + virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } + bool IsSheared(void) const { return m_IsSheared; } int GetFurColor(void) const { return m_WoolColor; } private: - - bool m_IsBegging; + bool m_IsSheared; int m_WoolColor; int m_TimeToStopEating; -- cgit v1.2.3 From e9c1d1ea9c79d9a57d48b625d9a31604e927609c Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Wed, 29 Jan 2014 20:02:41 +0100 Subject: Did what xoft said --- src/Mobs/Chicken.cpp | 1 - src/Mobs/Mooshroom.cpp | 2 -- src/Mobs/PassiveMonster.cpp | 2 +- src/Mobs/PassiveMonster.h | 3 ++- 4 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp index 90d56d1de..fab92ce49 100644 --- a/src/Mobs/Chicken.cpp +++ b/src/Mobs/Chicken.cpp @@ -2,7 +2,6 @@ #include "Chicken.h" #include "../World.h" -#include "../Entities/Player.h" diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp index 00ba339a6..88101cd83 100644 --- a/src/Mobs/Mooshroom.cpp +++ b/src/Mobs/Mooshroom.cpp @@ -2,8 +2,6 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Mooshroom.h" -#include "../Entities/Player.h" - diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index 903761a95..904cd63cc 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -47,7 +47,7 @@ void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk) cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); if (a_Closest_Player != NULL) { - if (a_Closest_Player->GetEquippedItem().m_ItemType == FollowedItem.m_ItemType) + if (a_Closest_Player->GetEquippedItem().IsEqual(FollowedItem)) { Vector3d PlayerPos = a_Closest_Player->GetPosition(); MoveToPosition(PlayerPos); diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h index 7da5d71bc..0b3c155da 100644 --- a/src/Mobs/PassiveMonster.h +++ b/src/Mobs/PassiveMonster.h @@ -19,7 +19,8 @@ public: /// When hit by someone, run away virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; - + /** Returns the item that the animal of this class follows when a player holds it in hand + Return an empty item not to follow (default). */ virtual const cItem GetFollowedItem(void) const { return cItem(); } } ; -- cgit v1.2.3