1
0

cTracer can now handle mob sight.

This commit is contained in:
Samuel Barney 2013-11-05 14:11:13 -07:00
parent 9d5d74d826
commit eefc6d37ef
2 changed files with 10 additions and 4 deletions

View File

@ -131,7 +131,7 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance) bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance, bool a_LineOfSight)
{ {
if ((a_Start.y < 0) || (a_Start.y >= cChunkDef::Height)) if ((a_Start.y < 0) || (a_Start.y >= cChunkDef::Height))
{ {
@ -224,8 +224,9 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
} }
BLOCKTYPE BlockID = m_World->GetBlock(pos.x, pos.y, pos.z); BLOCKTYPE BlockID = m_World->GetBlock(pos.x, pos.y, pos.z);
// No collision with water ;) // Block is counted as a collision if we are not doing a line of sight and it is solid,
if (g_BlockIsSolid[BlockID]) // or if the block is not air and not water. That way mobs can still see underwater.
if ((!a_LineOfSight && g_BlockIsSolid[BlockID]) || (BlockID != E_BLOCK_AIR && !IsBlockWater(BlockID)))
{ {
BlockHitPosition = pos; BlockHitPosition = pos;
int Normal = GetHitNormal(a_Start, End, pos ); int Normal = GetHitNormal(a_Start, End, pos );

View File

@ -14,7 +14,12 @@ public: // tolua_export
~cTracer(); // tolua_export ~cTracer(); // tolua_export
/// Determines if a collision occures along a line. Returns true if a collision occurs. /// Determines if a collision occures along a line. Returns true if a collision occurs.
bool Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance); // tolua_export bool Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance) // tolua_export
{
return Trace(a_Start, a_Direction, a_Distance, false);
}
bool Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance, bool a_LineOfSight); // tolua_export
/// Contains the position of the block that caused the collision /// Contains the position of the block that caused the collision
Vector3f BlockHitPosition; // tolua_export Vector3f BlockHitPosition; // tolua_export