summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mobs/AggressiveMonster.cpp6
-rw-r--r--src/Mobs/AggressiveMonster.h2
-rw-r--r--src/Mobs/Blaze.cpp8
-rw-r--r--src/Mobs/Blaze.h2
-rw-r--r--src/Mobs/CaveSpider.cpp8
-rw-r--r--src/Mobs/CaveSpider.h2
-rw-r--r--src/Mobs/Creeper.cpp5
-rw-r--r--src/Mobs/Creeper.h2
-rw-r--r--src/Mobs/Ghast.cpp9
-rw-r--r--src/Mobs/Ghast.h2
-rw-r--r--src/Mobs/Skeleton.cpp9
-rw-r--r--src/Mobs/Skeleton.h2
-rw-r--r--src/Mobs/Slime.cpp6
-rw-r--r--src/Mobs/Slime.h2
-rw-r--r--src/Mobs/Wolf.cpp8
-rw-r--r--src/Mobs/Wolf.h2
16 files changed, 48 insertions, 27 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 1355a3627..a7a1eeef5 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -92,15 +92,17 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
-void cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
+bool cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
if ((m_Target == nullptr) || (m_AttackInterval < 3.0))
{
- return;
+ return false;
}
// Setting this higher gives us more wiggle room for attackrate
m_AttackInterval = 0.0;
m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
+
+ return true;
}
diff --git a/src/Mobs/AggressiveMonster.h b/src/Mobs/AggressiveMonster.h
index f46a5c1ef..90b2988dc 100644
--- a/src/Mobs/AggressiveMonster.h
+++ b/src/Mobs/AggressiveMonster.h
@@ -20,7 +20,7 @@ public:
virtual void InStateChasing(std::chrono::milliseconds a_Dt) override;
virtual void EventSeePlayer(cEntity *) override;
- virtual void Attack(std::chrono::milliseconds a_Dt);
+ virtual bool Attack(std::chrono::milliseconds a_Dt);
} ;
diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp
index 731da6b18..cb1ed23cb 100644
--- a/src/Mobs/Blaze.cpp
+++ b/src/Mobs/Blaze.cpp
@@ -32,7 +32,7 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cBlaze::Attack(std::chrono::milliseconds a_Dt)
+bool cBlaze::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
@@ -44,16 +44,18 @@ void cBlaze::Attack(std::chrono::milliseconds a_Dt)
cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
if (FireCharge == nullptr)
{
- return;
+ return false;
}
if (!FireCharge->Initialize(*m_World))
{
delete FireCharge;
FireCharge = nullptr;
- return;
+ return false;
}
m_World->BroadcastSpawnEntity(*FireCharge);
m_AttackInterval = 0.0;
// ToDo: Shoot 3 fireballs instead of 1.
+ return true;
}
+ return false;
}
diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h
index 493953a14..8265deffa 100644
--- a/src/Mobs/Blaze.h
+++ b/src/Mobs/Blaze.h
@@ -18,5 +18,5 @@ public:
CLASS_PROTODEF(cBlaze)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Attack(std::chrono::milliseconds a_Dt) override;
+ virtual bool Attack(std::chrono::milliseconds a_Dt) override;
} ;
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index a8b40f52e..ee3f4803c 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -27,15 +27,19 @@ void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
-void cCaveSpider::Attack(std::chrono::milliseconds a_Dt)
+bool cCaveSpider::Attack(std::chrono::milliseconds a_Dt)
{
- super::Attack(a_Dt);
+ if (!super::Attack(a_Dt))
+ {
+ return false;
+ }
if (m_Target->IsPawn())
{
// TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
static_cast<cPawn *>(m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0);
}
+ return true;
}
diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h
index d3e56fd2b..7fbafeb54 100644
--- a/src/Mobs/CaveSpider.h
+++ b/src/Mobs/CaveSpider.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cCaveSpider)
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
- virtual void Attack(std::chrono::milliseconds a_Dt) override;
+ virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index 353d0f009..141f77d08 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -121,7 +121,7 @@ bool cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cCreeper::Attack(std::chrono::milliseconds a_Dt)
+bool cCreeper::Attack(std::chrono::milliseconds a_Dt)
{
UNUSED(a_Dt);
@@ -130,7 +130,10 @@ void cCreeper::Attack(std::chrono::milliseconds a_Dt)
m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
+
+ return true;
}
+ return false;
}
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index 1827c416e..ac8b7cf35 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -19,7 +19,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
- virtual void Attack(std::chrono::milliseconds a_Dt) override;
+ virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp
index 15bbe484b..fe3cc8be3 100644
--- a/src/Mobs/Ghast.cpp
+++ b/src/Mobs/Ghast.cpp
@@ -32,7 +32,7 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cGhast::Attack(std::chrono::milliseconds a_Dt)
+bool cGhast::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
@@ -44,17 +44,20 @@ void cGhast::Attack(std::chrono::milliseconds a_Dt)
cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
if (GhastBall == nullptr)
{
- return;
+ return false;
}
if (!GhastBall->Initialize(*m_World))
{
delete GhastBall;
GhastBall = nullptr;
- return;
+ return false;
}
m_World->BroadcastSpawnEntity(*GhastBall);
m_AttackInterval = 0.0;
+
+ return true;
}
+ return false;
}
diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h
index 431edaf6d..f74150169 100644
--- a/src/Mobs/Ghast.h
+++ b/src/Mobs/Ghast.h
@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cGhast)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Attack(std::chrono::milliseconds a_Dt) override;
+ virtual bool Attack(std::chrono::milliseconds a_Dt) override;
bool IsCharging(void) const {return false; }
} ;
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index 767e5b95c..27e038e1e 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -48,7 +48,7 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
+bool cSkeleton::Attack(std::chrono::milliseconds a_Dt)
{
cFastRandom Random;
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
@@ -60,17 +60,20 @@ void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
if (Arrow == nullptr)
{
- return;
+ return false;
}
if (!Arrow->Initialize(*m_World))
{
delete Arrow;
Arrow = nullptr;
- return;
+ return false;
}
m_World->BroadcastSpawnEntity(*Arrow);
m_AttackInterval = 0.0;
+
+ return true;
}
+ return false;
}
diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h
index 1b6ce4bf2..0316fb9b5 100644
--- a/src/Mobs/Skeleton.h
+++ b/src/Mobs/Skeleton.h
@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cSkeleton)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Attack(std::chrono::milliseconds a_Dt) override;
+ virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual bool IsUndead(void) override { return true; }
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp
index 4988d1082..d7ea50dda 100644
--- a/src/Mobs/Slime.cpp
+++ b/src/Mobs/Slime.cpp
@@ -46,13 +46,15 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cSlime::Attack(std::chrono::milliseconds a_Dt)
+bool cSlime::Attack(std::chrono::milliseconds a_Dt)
{
if (m_Size > 1)
{
// Only slimes larger than size 1 attack a player.
- super::Attack(a_Dt);
+ return super::Attack(a_Dt);
}
+
+ return false;
}
diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h
index 40131b101..c03a82bf4 100644
--- a/src/Mobs/Slime.h
+++ b/src/Mobs/Slime.h
@@ -20,7 +20,7 @@ public:
// cAggressiveMonster overrides:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Attack(std::chrono::milliseconds a_Dt) override;
+ virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
int GetSize(void) const { return m_Size; }
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 7b5953523..679136213 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -45,7 +45,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cWolf::Attack(std::chrono::milliseconds a_Dt)
+bool cWolf::Attack(std::chrono::milliseconds a_Dt)
{
UNUSED(a_Dt);
@@ -53,13 +53,15 @@ void cWolf::Attack(std::chrono::milliseconds a_Dt)
{
if (static_cast<cPlayer *>(m_Target)->GetName() != m_OwnerName)
{
- super::Attack(a_Dt);
+ return super::Attack(a_Dt);
}
}
else
{
- super::Attack(a_Dt);
+ return super::Attack(a_Dt);
}
+
+ return false;
}
diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h
index 5de83acd8..ed37367b9 100644
--- a/src/Mobs/Wolf.h
+++ b/src/Mobs/Wolf.h
@@ -22,7 +22,7 @@ public:
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void TickFollowPlayer();
- virtual void Attack(std::chrono::milliseconds a_Dt) override;
+ virtual bool Attack(std::chrono::milliseconds a_Dt) override;
// Get functions
bool IsSitting (void) const override { return m_IsSitting; }