Rewritten code.
Implemented xoft suggestion. Using MoveToPosition as tigerw suggested.
This commit is contained in:
@@ -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().m_ItemType == FollowedItem.m_ItemType)
|
||||
{
|
||||
Vector3d PlayerPos = a_Closest_Player->GetPosition();
|
||||
MoveToPosition(PlayerPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user