summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp')
-rw-r--r--src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp b/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
index d7791319d..ddf30326a 100644
--- a/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
+++ b/src/Mobs/Behaviors/BehaviorAttackerSuicideBomber.cpp
@@ -22,51 +22,41 @@ cBehaviorAttackerSuicideBomber::cBehaviorAttackerSuicideBomber() :
-void cBehaviorAttackerSuicideBomber::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
+bool cBehaviorAttackerSuicideBomber::StrikeTarget(int a_StrikeTickCnt)
{
- if (((GetTarget() == nullptr) || !TargetIsInStrikeRadius()) && !m_BurnedWithFlintAndSteel)
+ UNUSED(a_StrikeTickCnt);
+
+ ASSERT(GetTarget() != nullptr);// mobTodo guaranteed ?
+
+ if ((!TargetIsInStrikeRadius()) && (!m_BurnedWithFlintAndSteel))
{
if (m_bIsBlowing)
{
- m_ExplodingTimer = 0;
m_bIsBlowing = false;
m_Parent->GetWorld()->BroadcastEntityMetadata(*m_Parent);
}
}
- else
- {
- if (m_bIsBlowing)
- {
- m_ExplodingTimer += 1;
- }
-
- if ((m_ExplodingTimer == 30) && (m_Parent->GetHealth() > 0.0)) // only explode when not already dead
- {
- m_Parent->GetWorld()->DoExplosionAt((m_bIsCharged ? 5 : 3), m_Parent->GetPosX(), m_Parent->GetPosY(), m_Parent->GetPosZ(), false, esMonster, this);
- m_Parent->Destroy(); // Just in case we aren't killed by the explosion
- }
- }
-
- cBehaviorAttacker::Tick(a_Dt, a_Chunk);
-}
-
-
-
-
-bool cBehaviorAttackerSuicideBomber::StrikeTarget(int a_StrikeTickCnt)
-{
- UNUSED(a_StrikeTickCnt);
-
- if (!m_bIsBlowing)
+ // phase 1: start blowing up
+ if (a_StrikeTickCnt == 1)
{
+ ASSERT(!m_bIsBlowing);
+
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(*m_Parent);
- return true;
+ return false;
}
return false;
+
+
+ if (a_StrikeTickCnt == 30)
+ {
+ // mobTodo && (m_Parent->GetHealth() > 0.0) guaranteed ?
+ m_Parent->GetWorld()->DoExplosionAt((m_bIsCharged ? 5 : 3), m_Parent->GetPosX(), m_Parent->GetPosY(), m_Parent->GetPosZ(), false, esMonster, this);
+ m_Parent->Destroy(); // Just in case we aren't killed by the explosion
+ }
}
@@ -81,10 +71,14 @@ void cBehaviorAttackerSuicideBomber::OnRightClicked(cPlayer & a_Player)
{
a_Player.UseEquippedItem();
}
- 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(*m_Parent);
- m_BurnedWithFlintAndSteel = true;
+ if (!m_BurnedWithFlintAndSteel)
+ {
+ 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(*m_Parent);
+ m_BurnedWithFlintAndSteel = true;
+ m_Parent->PinBehavior(this);
+ }
}
}