summaryrefslogblamecommitdiffstats
path: root/src/Mobs/Wither.cpp
blob: fe4dbb28b929a0f326e9fa0a3c4fca4833d0573a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11



                                                                                              
                     





                        
                                                                                   
                                   
 
                          
                                  





 








                                                   
                                          










                                                   
                                                  


                                           
                             

         

                                                                
                             

         
                                          









                                                
                                                                 
         





                                                                                                         
         

                                                













                                                             

#include "Globals.h"  // NOTE: MSVC stupidness requires this to be the same across all modules

#include "Wither.h"
#include "../World.h"





cWither::cWither(void) :
	super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0),
	m_IsSpawnInvulnerable(true)
{
	SetMaxHealth(300);
	SetInvulnerableTicks(220);
}





bool cWither::IsArmored(void) const
{
	return GetHealth() <= (GetMaxHealth() / 2);
}





bool cWither::Initialize(cWorld * a_World)
{
	// Set health before BroadcastSpawnEntity()
	SetHealth(GetMaxHealth() / 3);

	return super::Initialize(a_World);
}





bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
{
	if (a_TDI.DamageType == dtDrowning)
	{
		return false;
	}

	if (IsArmored() && (a_TDI.DamageType == dtRangedAttack))
	{
		return false;
	}

	return super::DoTakeDamage(a_TDI);
}





void cWither::Tick(float a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);

	if (GetInvulnerableTicks() <= 0 && m_IsSpawnInvulnerable)
	{
		m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
		m_IsSpawnInvulnerable = false;
	}
	else if (((GetInvulnerableTicks() % 10) == 0) && (GetInvulnerableTicks() > 10))
	{
		Heal(10);
	}

	m_World->BroadcastEntityMetadata(*this);
}





void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
	AddRandomDropItem(a_Drops, 1, 1, E_ITEM_NETHER_STAR);
}