summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Pig.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Pig.cpp')
-rw-r--r--src/Mobs/Pig.cpp27
1 files changed, 26 insertions, 1 deletions
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);
+ }
+ }
+ }
+}