2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
|
|
|
#include "Blaze.h"
|
2013-11-04 15:46:56 -05:00
|
|
|
#include "../World.h"
|
2014-04-27 20:03:06 -04:00
|
|
|
#include "../Entities/FireChargeEntity.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cBlaze::cBlaze(void) :
|
2014-06-07 03:40:01 -04:00
|
|
|
super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.6, 1.8)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2015-03-30 19:42:32 -04:00
|
|
|
SetGravity(-8.0f);
|
2015-03-31 11:03:35 -04:00
|
|
|
SetAirDrag(0.05f);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|
|
|
{
|
2014-10-20 16:55:07 -04:00
|
|
|
if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
|
2014-02-23 13:44:58 -05:00
|
|
|
{
|
|
|
|
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
|
|
|
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD);
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-04 15:46:56 -05:00
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
void cBlaze::Attack(std::chrono::milliseconds a_Dt)
|
2013-11-04 15:46:56 -05:00
|
|
|
{
|
2015-03-12 14:37:39 -04:00
|
|
|
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
|
2013-11-04 15:46:56 -05:00
|
|
|
|
2014-12-05 06:56:53 -05:00
|
|
|
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
2013-11-04 15:46:56 -05:00
|
|
|
{
|
|
|
|
// Setting this higher gives us more wiggle room for attackrate
|
|
|
|
Vector3d Speed = GetLookVector() * 20;
|
|
|
|
Speed.y = Speed.y + 1;
|
|
|
|
cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
|
2014-10-20 16:55:07 -04:00
|
|
|
if (FireCharge == nullptr)
|
2013-11-04 15:46:56 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-06-08 15:58:08 -04:00
|
|
|
if (!FireCharge->Initialize(*m_World))
|
2013-11-04 15:46:56 -05:00
|
|
|
{
|
|
|
|
delete FireCharge;
|
2014-10-20 16:55:07 -04:00
|
|
|
FireCharge = nullptr;
|
2013-11-04 15:46:56 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_World->BroadcastSpawnEntity(*FireCharge);
|
|
|
|
m_AttackInterval = 0.0;
|
|
|
|
// ToDo: Shoot 3 fireballs instead of 1.
|
|
|
|
}
|
2014-03-25 13:15:05 -04:00
|
|
|
}
|