2013-09-18 17:17:43 -04:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
|
|
|
#include "Wither.h"
|
2014-03-24 06:29:19 -04:00
|
|
|
#include "../World.h"
|
2013-09-18 17:17:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cWither::cWither(void) :
|
2014-03-24 06:29:19 -04:00
|
|
|
super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0),
|
2014-04-28 07:51:40 -04:00
|
|
|
m_WitherInvulnerableTicks(220)
|
2013-09-18 17:17:43 -04:00
|
|
|
{
|
2014-03-24 06:29:19 -04:00
|
|
|
SetMaxHealth(300);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-25 04:32:58 -04:00
|
|
|
bool cWither::IsArmored(void) const
|
|
|
|
{
|
|
|
|
return GetHealth() <= (GetMaxHealth() / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-25 05:40:54 -04:00
|
|
|
bool cWither::Initialize(cWorld * a_World)
|
2014-03-25 05:13:27 -04:00
|
|
|
{
|
|
|
|
// Set health before BroadcastSpawnEntity()
|
|
|
|
SetHealth(GetMaxHealth() / 3);
|
|
|
|
|
|
|
|
return super::Initialize(a_World);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-25 18:32:30 -04:00
|
|
|
bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
|
2014-03-24 06:29:19 -04:00
|
|
|
{
|
|
|
|
if (a_TDI.DamageType == dtDrowning)
|
|
|
|
{
|
2014-04-25 18:32:30 -04:00
|
|
|
return false;
|
2014-03-24 06:29:19 -04:00
|
|
|
}
|
|
|
|
|
2014-04-28 07:51:40 -04:00
|
|
|
if (m_WitherInvulnerableTicks > 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-25 04:32:58 -04:00
|
|
|
if (IsArmored() && (a_TDI.DamageType == dtRangedAttack))
|
|
|
|
{
|
2014-04-25 18:32:30 -04:00
|
|
|
return false;
|
2014-03-25 04:32:58 -04:00
|
|
|
}
|
|
|
|
|
2014-04-25 18:32:30 -04:00
|
|
|
return super::DoTakeDamage(a_TDI);
|
2014-03-24 06:29:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cWither::Tick(float a_Dt, cChunk & a_Chunk)
|
|
|
|
{
|
|
|
|
super::Tick(a_Dt, a_Chunk);
|
|
|
|
|
2014-04-28 07:51:40 -04:00
|
|
|
if (m_WitherInvulnerableTicks > 0)
|
2014-03-24 06:29:19 -04:00
|
|
|
{
|
2014-04-28 07:51:40 -04:00
|
|
|
unsigned int NewTicks = m_WitherInvulnerableTicks - 1;
|
|
|
|
|
|
|
|
if (NewTicks == 0)
|
|
|
|
{
|
|
|
|
m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_WitherInvulnerableTicks = NewTicks;
|
|
|
|
|
|
|
|
if ((NewTicks % 10) == 0)
|
|
|
|
{
|
|
|
|
Heal(10);
|
|
|
|
}
|
2014-03-24 06:29:19 -04:00
|
|
|
}
|
2014-03-25 04:32:58 -04:00
|
|
|
|
|
|
|
m_World->BroadcastEntityMetadata(*this);
|
2013-09-18 17:17:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|
|
|
{
|
|
|
|
AddRandomDropItem(a_Drops, 1, 1, E_ITEM_NETHER_STAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|