1
0
cuberite-2a/src/Mobs/Wither.cpp

92 lines
1.3 KiB
C++
Raw Normal View History

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