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"
|
2013-08-16 04:48:19 -04:00
|
|
|
#include "../World.h"
|
2014-01-29 13:15:26 -05:00
|
|
|
#include "../Entities/Player.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
|
2013-10-20 04:23:30 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-25 18:32:30 -04:00
|
|
|
bool cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-04-25 18:32:30 -04:00
|
|
|
if (!super::DoTakeDamage(a_TDI))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-10-20 16:55:07 -04:00
|
|
|
if ((a_TDI.Attacker != this) && (a_TDI.Attacker != nullptr))
|
2012-12-21 06:04:08 -05:00
|
|
|
{
|
2012-06-14 09:06:06 -04:00
|
|
|
m_EMState = ESCAPING;
|
2012-12-21 06:04:08 -05:00
|
|
|
}
|
2014-04-25 18:32:30 -04:00
|
|
|
return true;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
void cPassiveMonster::Tick(std::chrono::milliseconds 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
|
|
|
|
2014-01-24 14:57:32 -05:00
|
|
|
if (m_EMState == ESCAPING)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-01-24 14:57:32 -05:00
|
|
|
CheckEventLostPlayer();
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2015-11-14 10:42:26 -05:00
|
|
|
cItems FollowedItems;
|
|
|
|
GetFollowedItems(FollowedItems);
|
|
|
|
if (FollowedItems.Size() <= 0)
|
2014-01-29 13:15:26 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-05-24 07:56:56 -04:00
|
|
|
cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance));
|
2014-10-20 16:55:07 -04:00
|
|
|
if (a_Closest_Player != nullptr)
|
2014-01-29 13:15:26 -05:00
|
|
|
{
|
2015-11-14 10:42:26 -05:00
|
|
|
cItem EquippedItem = a_Closest_Player->GetEquippedItem();
|
|
|
|
if (FollowedItems.ContainsType(EquippedItem))
|
2014-01-29 13:15:26 -05:00
|
|
|
{
|
|
|
|
Vector3d PlayerPos = a_Closest_Player->GetPosition();
|
|
|
|
MoveToPosition(PlayerPos);
|
|
|
|
}
|
|
|
|
}
|
2012-12-21 06:04:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-07 14:02:50 -04:00
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
|