diff options
author | Mat <mail@mathias.is> | 2020-03-26 18:54:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-26 18:54:40 +0100 |
commit | 84f86a467e7c289936571c738f9422868ecaaee6 (patch) | |
tree | 3145442b002ae6eb18589a3d9e6ebd0de27e4197 /src/Mobs/Blaze.cpp | |
parent | Update Core (diff) | |
download | cuberite-84f86a467e7c289936571c738f9422868ecaaee6.tar cuberite-84f86a467e7c289936571c738f9422868ecaaee6.tar.gz cuberite-84f86a467e7c289936571c738f9422868ecaaee6.tar.bz2 cuberite-84f86a467e7c289936571c738f9422868ecaaee6.tar.lz cuberite-84f86a467e7c289936571c738f9422868ecaaee6.tar.xz cuberite-84f86a467e7c289936571c738f9422868ecaaee6.tar.zst cuberite-84f86a467e7c289936571c738f9422868ecaaee6.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/Blaze.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
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<cFireChargeEntity>(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<cFireChargeEntity>(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; } + + + |