2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
2012-09-23 16:53:08 -04:00
|
|
|
#include "PassiveMonster.h"
|
|
|
|
#include "../MersenneTwister.h"
|
2013-08-16 04:48:19 -04:00
|
|
|
#include "../World.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-20 04:23:30 -04:00
|
|
|
cPassiveMonster::cPassiveMonster(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)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
m_EMPersonality = PASSIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2012-12-21 06:04:08 -05:00
|
|
|
super::DoTakeDamage(a_TDI);
|
|
|
|
if ((a_TDI.Attacker != this) && (a_TDI.Attacker != NULL))
|
|
|
|
{
|
2012-06-14 09:06:06 -04:00
|
|
|
m_EMState = ESCAPING;
|
2012-12-21 06:04:08 -05:00
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-13 17:02:10 -04:00
|
|
|
void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-04-13 17:02:10 -04:00
|
|
|
super::Tick(a_Dt, a_Chunk);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
m_SeePlayerInterval += a_Dt;
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
if (m_SeePlayerInterval > 1) // Check every second
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-04-13 17:02:10 -04:00
|
|
|
int rem = m_World->GetTickRandomNumber(3) + 1; // Check most of the time but miss occasionally
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
m_SeePlayerInterval = 0.0;
|
2012-12-21 06:04:08 -05:00
|
|
|
if (rem >= 2)
|
|
|
|
{
|
|
|
|
if (m_EMState == ESCAPING)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-04-13 17:02:10 -04:00
|
|
|
CheckEventLostPlayer();
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-21 06:04:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-07 14:02:50 -04:00
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
|