summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-01-26 13:40:16 +0100
committerMattes D <github@xoft.cz>2014-01-26 13:40:16 +0100
commit1f4e12c50cd434b16d9a0a198f4d0c1c7756c4cf (patch)
treecde579a62e37fa4f92e1765f6933e5347e51f649 /src/Mobs
parentFixed segmentation fault on villager damage (diff)
parentFixed bug where wolfs would teleport while they were sitting. (diff)
downloadcuberite-1f4e12c50cd434b16d9a0a198f4d0c1c7756c4cf.tar
cuberite-1f4e12c50cd434b16d9a0a198f4d0c1c7756c4cf.tar.gz
cuberite-1f4e12c50cd434b16d9a0a198f4d0c1c7756c4cf.tar.bz2
cuberite-1f4e12c50cd434b16d9a0a198f4d0c1c7756c4cf.tar.lz
cuberite-1f4e12c50cd434b16d9a0a198f4d0c1c7756c4cf.tar.xz
cuberite-1f4e12c50cd434b16d9a0a198f4d0c1c7756c4cf.tar.zst
cuberite-1f4e12c50cd434b16d9a0a198f4d0c1c7756c4cf.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Wolf.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 11e3f690a..c0c7892e3 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -75,10 +75,12 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
SetIsTame(true);
SetOwner(a_Player.GetName());
m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMED);
+ m_World->BroadcastParticleEffect("heart", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5);
}
else
{
m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMING);
+ m_World->BroadcastParticleEffect("smoke", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5);
}
}
}
@@ -122,7 +124,8 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
}
-
+
+ // The wolf is sitting so don't move him at all.
if (IsSitting())
{
m_bMovingToDestination = false;
@@ -145,8 +148,18 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
SetIsBegging(true);
m_World->BroadcastEntityMetadata(*this);
}
- m_FinalDestination = a_Closest_Player->GetPosition();;
- m_bMovingToDestination = false;
+ // Don't move to the player if the wolf is sitting.
+ if (IsSitting())
+ {
+ m_bMovingToDestination = false;
+ }
+ else
+ {
+ m_bMovingToDestination = true;
+ }
+ Vector3d PlayerPos = a_Closest_Player->GetPosition();
+ PlayerPos.y++;
+ m_FinalDestination = PlayerPos;
break;
}
default:
@@ -185,15 +198,26 @@ void cWolf::TickFollowPlayer()
} Callback;
if (m_World->DoWithPlayer(m_OwnerName, Callback))
{
- // The player is present in the world, follow them:
+ // The player is present in the world, follow him:
double Distance = (Callback.OwnerPos - GetPosition()).Length();
- if ((Distance > 30) && (!IsSitting()))
+ if (Distance > 30)
{
- TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
+ if (!IsSitting())
+ {
+ TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
+ }
}
else
{
- MoveToPosition(Callback.OwnerPos);
+ m_FinalDestination = Callback.OwnerPos;
+ if (IsSitting())
+ {
+ m_bMovingToDestination = false;
+ }
+ else
+ {
+ m_bMovingToDestination = true;
+ }
}
}
}