#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "AggressiveMonster.h"
#include "../World.h"
#include "../Entities/Player.h"
#include "../MersenneTwister.h"
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
{
m_EMPersonality = AGGRESSIVE;
}
// What to do if in Chasing State
void cAggressiveMonster::InStateChasing(float a_Dt)
{
super::InStateChasing(a_Dt);
if (m_Target != NULL)
{
if (m_Target->IsPlayer())
{
if (((cPlayer *)m_Target)->IsGameModeCreative())
{
m_EMState = IDLE;
return;
}
}
if (((float)m_FinalDestination.x != (float)m_Target->GetPosX()) || ((float)m_FinalDestination.z != (float)m_Target->GetPosZ()))
{
MoveToPosition(m_Target->GetPosition());
}
}
}
void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity)
{
super::EventSeePlayer(a_Entity);
if (!((cPlayer *)a_Entity)->IsGameModeCreative())
{
m_EMState = CHASING;
}
}
void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (m_EMState == CHASING)
{
CheckEventLostPlayer();
}
else
{
CheckEventSeePlayer();
}
}
void cAggressiveMonster::Attack(float a_Dt)
{
super::Attack(a_Dt);
if ((m_Target != NULL) && (m_AttackInterval > 3.0))
{
// Setting this higher gives us more wiggle room for attackrate
m_AttackInterval = 0.0;
m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
}
}