Now mobs follow you when holding their breed item
This commit is contained in:
parent
04107fa85d
commit
ebe0f9372f
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "Chicken.h"
|
#include "Chicken.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
|
#include "../Entities/Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -41,6 +41,29 @@ void cChicken::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
{
|
{
|
||||||
m_EggDropTimer++;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,10 +19,13 @@ public:
|
|||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
|
bool IsBegging (void) const { return m_IsBegging; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
int m_EggDropTimer;
|
int m_EggDropTimer;
|
||||||
|
bool m_IsBegging;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -19,6 +19,14 @@ public:
|
|||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||||
virtual void OnRightClicked(cPlayer & a_Player) 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;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
|
|
||||||
#include "Mooshroom.h"
|
#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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,14 @@ public:
|
|||||||
CLASS_PROTODEF(cMooshroom);
|
CLASS_PROTODEF(cMooshroom);
|
||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
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;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,10 +19,14 @@ public:
|
|||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||||
virtual void OnRightClicked(cPlayer & a_Player) 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 IsSaddled(void) const { return m_bIsSaddled; }
|
||||||
|
bool IsBegging (void) const { return m_IsBegging; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool m_IsBegging;
|
||||||
bool m_bIsSaddled;
|
bool m_bIsSaddled;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,11 +21,13 @@ public:
|
|||||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) 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; }
|
bool IsSheared(void) const { return m_IsSheared; }
|
||||||
int GetFurColor(void) const { return m_WoolColor; }
|
int GetFurColor(void) const { return m_WoolColor; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool m_IsBegging;
|
||||||
bool m_IsSheared;
|
bool m_IsSheared;
|
||||||
int m_WoolColor;
|
int m_WoolColor;
|
||||||
int m_TimeToStopEating;
|
int m_TimeToStopEating;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user