summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-09-02 14:16:44 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-09-02 14:16:44 +0200
commit77a3b65abe5ae07f3a77ac4574559730afcc6a20 (patch)
treeaaee6818ccf2d72f07655ede91dc58af84621189 /src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
parentcreeper initial behaviors (diff)
downloadcuberite-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/BehaviorAttackerSuicideBomber.cpp')
-rw-r--r--src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp60
1 files changed, 57 insertions, 3 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);
+}