From 2c3c1f15273835923d9bd4950a19ee88a95ee0f4 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 11 May 2017 14:34:36 +0200 Subject: Tracer replacement (#3704) * Replaced cTracer usage with cLineBlockTracer. * Exported new cLineBlockTracer utility functions to Lua API. --- src/Mobs/Enderman.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/Mobs/Enderman.cpp') diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index f58e2132c..3c0717f8f 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -3,7 +3,7 @@ #include "Enderman.h" #include "../Entities/Player.h" -#include "../Tracer.h" +#include "../LineBlockTracer.h" @@ -29,9 +29,8 @@ public: return false; } - Vector3d Direction = m_EndermanPos - a_Player->GetPosition(); - - // Don't check players who are more then SightDistance (64) blocks away + // Don't check players who are more than SightDistance (64) blocks away + auto Direction = m_EndermanPos - a_Player->GetPosition(); if (Direction.Length() > m_SightDistance) { return false; @@ -43,19 +42,16 @@ public: return false; } - - Vector3d LookVector = a_Player->GetLookVector(); - double dot = Direction.Dot(LookVector); - - // 0.09 rad ~ 5 degrees // If the player's crosshair is within 5 degrees of the enderman, it counts as looking - if (dot <= cos(0.09)) + auto LookVector = a_Player->GetLookVector(); + auto dot = Direction.Dot(LookVector); + if (dot <= cos(0.09)) // 0.09 rad ~ 5 degrees { return false; } - cTracer LineOfSight(a_Player->GetWorld()); - if (LineOfSight.Trace(m_EndermanPos, Direction, static_cast(Direction.Length()))) + // TODO: Check if endermen are angered through water in Vanilla + if (!cLineBlockTracer::LineOfSightTrace(*a_Player->GetWorld(), m_EndermanPos, a_Player->GetPosition(), cLineBlockTracer::losAirWater)) { // No direct line of sight return false; -- cgit v1.2.3