summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mobs/Wolf.cpp36
-rw-r--r--src/Mobs/Wolf.h1
2 files changed, 26 insertions, 11 deletions
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 483f1d193..11e3f690a 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -37,6 +37,26 @@ void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
+void cWolf::Attack(float a_Dt)
+{
+ UNUSED(a_Dt);
+
+ if ((m_Target != NULL) && (m_Target->IsPlayer()))
+ {
+ if (((cPlayer *)m_Target)->GetName() != m_OwnerName)
+ {
+ super::Attack(a_Dt);
+ }
+ }
+ else
+ {
+ super::Attack(a_Dt);
+ }
+}
+
+
+
+
void cWolf::OnRightClicked(cPlayer & a_Player)
{
@@ -108,7 +128,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
m_bMovingToDestination = false;
}
- cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), m_SightDistance);
+ cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance);
if (a_Closest_Player != NULL)
{
switch (a_Closest_Player->GetEquippedItem().m_ItemType)
@@ -125,9 +145,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
SetIsBegging(true);
m_World->BroadcastEntityMetadata(*this);
}
- Vector3f a_NewDestination = a_Closest_Player->GetPosition();
- a_NewDestination.y = a_NewDestination.y + 1; // Look at the head of the player, not his feet.
- m_Destination = Vector3f(a_NewDestination);
+ m_FinalDestination = a_Closest_Player->GetPosition();;
m_bMovingToDestination = false;
break;
}
@@ -163,23 +181,19 @@ void cWolf::TickFollowPlayer()
return false;
}
public:
- Vector3f OwnerPos;
+ Vector3d OwnerPos;
} Callback;
if (m_World->DoWithPlayer(m_OwnerName, Callback))
{
// The player is present in the world, follow them:
double Distance = (Callback.OwnerPos - GetPosition()).Length();
- if (Distance < 3)
- {
- m_bMovingToDestination = false;
- }
- else if ((Distance > 30) && (!IsSitting()))
+ if ((Distance > 30) && (!IsSitting()))
{
TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
}
else
{
- m_Destination = Callback.OwnerPos;
+ MoveToPosition(Callback.OwnerPos);
}
}
}
diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h
index 040e2cf7a..9e5ad03c7 100644
--- a/src/Mobs/Wolf.h
+++ b/src/Mobs/Wolf.h
@@ -22,6 +22,7 @@ public:
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void TickFollowPlayer();
+ virtual void Attack(float a_Dt) override;
// Get functions
bool IsSitting (void) const { return m_IsSitting; }