1
0

Monsters: improve targeting

* Replace DoWithNearestPlayer with bounding box search (avoid iterating through all players in world).
* Do line-of-sight checks from eye-to-eye.
+ Added LOS and LOS lost timer to target lost checks, in addition to distance.
This commit is contained in:
Tiger Wang
2020-12-18 20:48:32 +00:00
parent 491238f799
commit 47c0b48bfd
8 changed files with 92 additions and 63 deletions

View File

@@ -113,14 +113,8 @@ void cEnderman::CheckEventSeePlayer(cChunk & a_Chunk)
ASSERT(Callback.GetPlayer() != nullptr);
if (!Callback.GetPlayer()->CanMobsTarget())
{
return;
}
// Target the player
cMonster::EventSeePlayer(Callback.GetPlayer(), a_Chunk);
m_EMState = CHASING;
// Target the player:
cAggressiveMonster::EventSeePlayer(Callback.GetPlayer(), a_Chunk);
m_bIsScreaming = true;
GetWorld()->BroadcastEntityMetadata(*this);
}
@@ -129,16 +123,6 @@ void cEnderman::CheckEventSeePlayer(cChunk & a_Chunk)
void cEnderman::CheckEventLostPlayer(void)
{
Super::CheckEventLostPlayer();
EventLosePlayer();
}
void cEnderman::EventLosePlayer()
{
Super::EventLosePlayer();