Merge pull request #599 from tonibm19/master
Now mobs follow you when holding their breed item.
This commit is contained in:
commit
07fb1bca23
@ -9,7 +9,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
cChicken::cChicken(void) :
|
||||
super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4),
|
||||
m_EggDropTimer(0)
|
||||
|
@ -19,8 +19,9 @@ public:
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
|
||||
private:
|
||||
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); }
|
||||
|
||||
private:
|
||||
|
||||
int m_EggDropTimer;
|
||||
} ;
|
||||
|
@ -41,5 +41,3 @@ void cCow::OnRightClicked(cPlayer & a_Player)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -19,6 +19,9 @@ public:
|
||||
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||
|
||||
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: Milk Cow
|
||||
|
||||
|
||||
@ -30,4 +29,3 @@ void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -18,6 +18,8 @@ public:
|
||||
CLASS_PROTODEF(cMooshroom);
|
||||
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
|
||||
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -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().IsEqual(FollowedItem))
|
||||
{
|
||||
Vector3d PlayerPos = a_Closest_Player->GetPosition();
|
||||
MoveToPosition(PlayerPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,9 @@ 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(); }
|
||||
|
||||
} ;
|
||||
|
||||
|
@ -73,5 +73,3 @@ void cPig::OnRightClicked(cPlayer & a_Player)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -19,6 +19,9 @@ public:
|
||||
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||
|
||||
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); }
|
||||
|
||||
bool IsSaddled(void) const { return m_bIsSaddled; }
|
||||
|
||||
private:
|
||||
|
@ -97,3 +97,4 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ public:
|
||||
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_WHEAT); }
|
||||
|
||||
bool IsSheared(void) const { return m_IsSheared; }
|
||||
int GetFurColor(void) const { return m_WoolColor; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user