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) :
|
2020-04-13 12:38:06 -04:00
|
|
|
Super("Blaze", mtBlaze, "entity.blaze.hurt", "entity.blaze.death", "entity.blaze.ambient", 0.6, 1.8),
|
2020-03-26 13:54:40 -04:00
|
|
|
m_IsCharging(false),
|
|
|
|
m_ChargeTimer(0)
|
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
|
|
|
{
|
2015-05-19 14:32:10 -04:00
|
|
|
unsigned int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
2014-02-23 13:44:58 -05:00
|
|
|
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-11-08 07:44:17 -05:00
|
|
|
bool cBlaze::Attack(std::chrono::milliseconds a_Dt)
|
2013-11-04 15:46:56 -05:00
|
|
|
{
|
2020-03-26 13:54:40 -04:00
|
|
|
if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0) && (!m_IsCharging))
|
2013-11-04 15:46:56 -05:00
|
|
|
{
|
2020-03-26 13:54:40 -04:00
|
|
|
m_IsCharging = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cBlaze::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
Super::Tick(a_Dt, a_Chunk);
|
2020-03-26 13:54:40 -04:00
|
|
|
if (!IsTicking())
|
|
|
|
{
|
|
|
|
// The base class tick destroyed us
|
|
|
|
return;
|
|
|
|
}
|
2016-12-19 15:12:23 -05:00
|
|
|
|
2020-03-26 13:54:40 -04:00
|
|
|
if (m_IsCharging)
|
|
|
|
{
|
|
|
|
m_ChargeTimer++;
|
|
|
|
if (
|
|
|
|
(m_ChargeTimer == 5) ||
|
|
|
|
(m_ChargeTimer == 10) ||
|
|
|
|
(m_ChargeTimer == 15)
|
|
|
|
)
|
2013-11-04 15:46:56 -05:00
|
|
|
{
|
2020-03-26 13:54:40 -04:00
|
|
|
Vector3d Speed = GetLookVector() * 20;
|
|
|
|
Speed.y = Speed.y + 1;
|
|
|
|
|
2020-08-01 14:18:03 -04:00
|
|
|
auto FireCharge = std::make_unique<cFireChargeEntity>(this, GetPosition().addedY(1), Speed);
|
2020-03-26 13:54:40 -04:00
|
|
|
auto FireChargePtr = FireCharge.get();
|
|
|
|
FireChargePtr->Initialize(std::move(FireCharge), *m_World);
|
|
|
|
|
|
|
|
m_World->BroadcastSoundEffect("entity.ghast.shoot", GetPosition(), 4.0f, 1.0f);
|
2013-11-04 15:46:56 -05:00
|
|
|
}
|
2020-03-26 13:54:40 -04:00
|
|
|
}
|
2016-12-19 15:12:23 -05:00
|
|
|
|
2020-03-26 13:54:40 -04:00
|
|
|
if ((m_IsCharging) && (m_ChargeTimer > 15))
|
|
|
|
{
|
|
|
|
m_ChargeTimer = 0;
|
|
|
|
m_IsCharging = false;
|
2016-01-12 05:11:10 -05:00
|
|
|
ResetAttackCooldown();
|
2013-11-04 15:46:56 -05:00
|
|
|
}
|
2014-03-25 13:15:05 -04:00
|
|
|
}
|
2020-03-26 13:54:40 -04:00
|
|
|
|
|
|
|
|
|
|
|
|