diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 14:16:44 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 14:16:44 +0200 |
commit | 77a3b65abe5ae07f3a77ac4574559730afcc6a20 (patch) | |
tree | aaee6818ccf2d72f07655ede91dc58af84621189 /src/Mobs/Behaviors | |
parent | creeper initial behaviors (diff) | |
download | cuberite-77a3b65abe5ae07f3a77ac4574559730afcc6a20.tar cuberite-77a3b65abe5ae07f3a77ac4574559730afcc6a20.tar.gz cuberite-77a3b65abe5ae07f3a77ac4574559730afcc6a20.tar.bz2 cuberite-77a3b65abe5ae07f3a77ac4574559730afcc6a20.tar.lz cuberite-77a3b65abe5ae07f3a77ac4574559730afcc6a20.tar.xz cuberite-77a3b65abe5ae07f3a77ac4574559730afcc6a20.tar.zst cuberite-77a3b65abe5ae07f3a77ac4574559730afcc6a20.zip |
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp | 60 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.h | 7 |
2 files changed, 63 insertions, 4 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp b/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp index 27d5c408c..d7791319d 100644 --- a/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp +++ b/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp @@ -6,15 +6,31 @@ #include "../../Entities/Player.h" #include "../../BlockID.h" + + + +cBehaviorAttackerSuicideBomber::cBehaviorAttackerSuicideBomber() : + m_bIsBlowing(false), + m_bIsCharged(false), + m_BurnedWithFlintAndSteel(false), + m_ExplodingTimer(0) +{ + +} + + + + + void cBehaviorAttackerSuicideBomber::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { - if (((GetTarget() == nullptr) || !TargetIsInRange()) && !m_BurnedWithFlintAndSteel) + if (((GetTarget() == nullptr) || !TargetIsInStrikeRadius()) && !m_BurnedWithFlintAndSteel) { if (m_bIsBlowing) { m_ExplodingTimer = 0; m_bIsBlowing = false; - m_Parent->GetWorld()->BroadcastEntityMetadata(*this); + m_Parent->GetWorld()->BroadcastEntityMetadata(*m_Parent); } } else @@ -46,7 +62,7 @@ bool cBehaviorAttackerSuicideBomber::StrikeTarget(int a_StrikeTickCnt) { m_Parent->GetWorld()->BroadcastSoundEffect("entity.creeper.primed", m_Parent->GetPosX(), m_Parent->GetPosY(), m_Parent->GetPosZ(), 1.f, (0.75f + (static_cast<float>((m_Parent->GetUniqueID() * 23) % 32)) / 64)); m_bIsBlowing = true; - m_Parent->GetWorld()->BroadcastEntityMetadata(*this); + m_Parent->GetWorld()->BroadcastEntityMetadata(*m_Parent); return true; } @@ -71,3 +87,41 @@ void cBehaviorAttackerSuicideBomber::OnRightClicked(cPlayer & a_Player) m_BurnedWithFlintAndSteel = true; } } + + +bool cBehaviorAttackerSuicideBomber::IsBlowing(void) const +{ + return m_bIsBlowing; +} + + + + + +bool cBehaviorAttackerSuicideBomber::IsCharged(void) const +{ + return m_bIsCharged; +} + + + + + +bool cBehaviorAttackerSuicideBomber::IsBurnedWithFlintAndSteel(void) const +{ + return m_BurnedWithFlintAndSteel; +} + + + + + +void cBehaviorAttackerSuicideBomber::DoTakeDamage(TakeDamageInfo & a_TDI) +{ + if (a_TDI.DamageType == dtLightning) + { + m_bIsCharged = true; + m_Parent->GetWorld()->BroadcastEntityMetadata(*m_Parent); + } + cBehaviorAttacker::DoTakeDamage(a_TDI); +} diff --git a/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.h b/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.h index 05611611c..99707f083 100644 --- a/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.h +++ b/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.h @@ -7,8 +7,13 @@ Use BehaviorAttackerMelee::SetTarget to attack. */ class cBehaviorAttackerSuicideBomber : public cBehaviorAttacker { public: - bool StrikeTarget(int a_StrikeTickCnt) override; + cBehaviorAttackerSuicideBomber(); + + // cBehaviorAttacker also implements those and we need to call super on them void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + void DoTakeDamage(TakeDamageInfo & a_TDI) override; + + bool StrikeTarget(int a_StrikeTickCnt) override; void OnRightClicked(cPlayer & a_Player) override; bool IsBlowing(void) const {return m_bIsBlowing; } |