From 84f86a467e7c289936571c738f9422868ecaaee6 Mon Sep 17 00:00:00 2001 From: Mat Date: Thu, 26 Mar 2020 19:54:40 +0200 Subject: Improvements to blaze and ghast (#4547) --- src/Mobs/Blaze.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 13 deletions(-) (limited to 'src/Mobs/Blaze.cpp') diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 80a887b03..1c48a88d2 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -9,7 +9,9 @@ cBlaze::cBlaze(void) : - super("Blaze", mtBlaze, "entity.blaze.hurt", "entity.blaze.death", "entity.blaze.ambient", 0.6, 1.8) + super("Blaze", mtBlaze, "entity.blaze.hurt", "entity.blaze.death", "entity.blaze.ambient", 0.6, 1.8), + m_IsCharging(false), + m_ChargeTimer(0) { SetGravity(-8.0f); SetAirDrag(0.05f); @@ -34,23 +36,54 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer) bool cBlaze::Attack(std::chrono::milliseconds a_Dt) { - if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0)) + if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0) && (!m_IsCharging)) { - // Setting this higher gives us more wiggle room for attackrate - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; + m_IsCharging = true; + return true; + } + return false; +} + + + + + +void cBlaze::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) +{ + super::Tick(a_Dt, a_Chunk); + if (!IsTicking()) + { + // The base class tick destroyed us + return; + } - auto FireCharge = cpp14::make_unique(this, GetPosition().addedY(1), Speed); - auto FireChargePtr = FireCharge.get(); - if (!FireChargePtr->Initialize(std::move(FireCharge), *m_World)) + if (m_IsCharging) + { + m_ChargeTimer++; + if ( + (m_ChargeTimer == 5) || + (m_ChargeTimer == 10) || + (m_ChargeTimer == 15) + ) { - return false; + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + + auto FireCharge = cpp14::make_unique(this, GetPosition().addedY(1), Speed); + auto FireChargePtr = FireCharge.get(); + FireChargePtr->Initialize(std::move(FireCharge), *m_World); + + m_World->BroadcastSoundEffect("entity.ghast.shoot", GetPosition(), 4.0f, 1.0f); } + } + if ((m_IsCharging) && (m_ChargeTimer > 15)) + { + m_ChargeTimer = 0; + m_IsCharging = false; ResetAttackCooldown(); - // ToDo: Shoot 3 fireballs instead of 1. - - return true; } - return false; } + + + -- cgit v1.2.3