summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-04-28 13:51:40 +0200
committerHowaner <franzi.moos@googlemail.com>2014-04-28 13:51:40 +0200
commitacd2804f316114a50b7103158a6bff5d3d14f673 (patch)
tree34c7018d226f2fc29e9eea604a043554abd43a39 /src/Mobs
parentRevert "Changed the old invulnerable methods from the wither to the new." (diff)
downloadcuberite-acd2804f316114a50b7103158a6bff5d3d14f673.tar
cuberite-acd2804f316114a50b7103158a6bff5d3d14f673.tar.gz
cuberite-acd2804f316114a50b7103158a6bff5d3d14f673.tar.bz2
cuberite-acd2804f316114a50b7103158a6bff5d3d14f673.tar.lz
cuberite-acd2804f316114a50b7103158a6bff5d3d14f673.tar.xz
cuberite-acd2804f316114a50b7103158a6bff5d3d14f673.tar.zst
cuberite-acd2804f316114a50b7103158a6bff5d3d14f673.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Wither.cpp29
-rw-r--r--src/Mobs/Wither.h7
2 files changed, 26 insertions, 10 deletions
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index fe4dbb28b..5b6e895e1 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -10,10 +10,9 @@
cWither::cWither(void) :
super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0),
- m_IsSpawnInvulnerable(true)
+ m_WitherInvulnerableTicks(220)
{
SetMaxHealth(300);
- SetInvulnerableTicks(220);
}
@@ -48,6 +47,11 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
return false;
}
+ if (m_WitherInvulnerableTicks > 0)
+ {
+ return false;
+ }
+
if (IsArmored() && (a_TDI.DamageType == dtRangedAttack))
{
return false;
@@ -64,14 +68,21 @@ void cWither::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (GetInvulnerableTicks() <= 0 && m_IsSpawnInvulnerable)
+ if (m_WitherInvulnerableTicks > 0)
{
- m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
- m_IsSpawnInvulnerable = false;
- }
- else if (((GetInvulnerableTicks() % 10) == 0) && (GetInvulnerableTicks() > 10))
- {
- Heal(10);
+ unsigned int NewTicks = m_WitherInvulnerableTicks - 1;
+
+ if (NewTicks == 0)
+ {
+ m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
+ }
+
+ m_WitherInvulnerableTicks = NewTicks;
+
+ if ((NewTicks % 10) == 0)
+ {
+ Heal(10);
+ }
}
m_World->BroadcastEntityMetadata(*this);
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 81c9df1b1..08b460009 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -17,6 +17,10 @@ public:
CLASS_PROTODEF(cWither);
+ unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; }
+
+ void SetWitherInvulnerableTicks(unsigned int a_Ticks) { m_WitherInvulnerableTicks = a_Ticks; }
+
/** Returns whether the wither is invulnerable to arrows. */
bool IsArmored(void) const;
@@ -28,7 +32,8 @@ public:
private:
- bool m_IsSpawnInvulnerable;
+ /** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */
+ unsigned int m_WitherInvulnerableTicks;
} ;