1
0
cuberite-2a/src/Mobs/PassiveAggressiveMonster.cpp
Tiger Wang 47c0b48bfd 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.
2020-12-21 13:52:23 +00:00

49 lines
998 B
C++

#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "PassiveAggressiveMonster.h"
#include "../Entities/Player.h"
cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height) :
Super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_SoundAmbient, a_Width, a_Height)
{
m_EMPersonality = PASSIVE;
}
bool cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (!Super::DoTakeDamage(a_TDI))
{
return false;
}
if ((GetTarget() != nullptr) && GetTarget()->IsPlayer())
{
if (static_cast<cPlayer *>(GetTarget())->CanMobsTarget())
{
m_EMState = CHASING;
}
}
return true;
}
void cPassiveAggressiveMonster::EventSeePlayer(cPlayer *, cChunk & a_Chunk)
{
// don't do anything, neutral mobs don't react to just seeing the player
}