1
0

Zombies and skeletons use AI

This commit is contained in:
Tiger Wang 2014-01-24 23:56:05 +00:00
parent a988063915
commit b367a74d3e
2 changed files with 15 additions and 9 deletions

View File

@ -30,15 +30,18 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSkeleton::MoveToPosition(const Vector3f & a_Position) void cSkeleton::MoveToPosition(const Vector3f & a_Position)
{ {
m_Destination = a_Position;
// If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement. // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement.
if (!IsOnFire() && m_World->GetTimeOfDay() < 13187 && m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) if (
!IsOnFire() &&
(m_World->GetTimeOfDay() < 13187) &&
(m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15)
)
{ {
m_bMovingToDestination = false; m_bMovingToDestination = false;
return; return;
} }
m_bMovingToDestination = true;
super::MoveToPosition(a_Position);
} }

View File

@ -34,15 +34,18 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cZombie::MoveToPosition(const Vector3f & a_Position) void cZombie::MoveToPosition(const Vector3f & a_Position)
{ {
m_Destination = a_Position; // If the destination is in the sun and if it is not night AND the zombie isn't on fire then block the movement.
if (
// If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement. !IsOnFire() &&
if ((m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15) && (m_World->GetTimeOfDay() < 13187) && !IsOnFire()) (m_World->GetTimeOfDay() < 13187) &&
(m_World->GetBlockSkyLight((int)a_Position.x, (int)a_Position.y, (int)a_Position.z) == 15)
)
{ {
m_bMovingToDestination = false; m_bMovingToDestination = false;
return; return;
} }
m_bMovingToDestination = true;
super::MoveToPosition(a_Position);
} }