summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Blaze.cpp2
-rw-r--r--src/Mobs/Blaze.h4
-rw-r--r--src/Mobs/Skeleton.cpp2
-rw-r--r--src/Mobs/Wither.cpp26
-rw-r--r--src/Mobs/Wither.h4
5 files changed, 32 insertions, 6 deletions
diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp
index ac42cf40b..84ff8929b 100644
--- a/src/Mobs/Blaze.cpp
+++ b/src/Mobs/Blaze.cpp
@@ -53,4 +53,4 @@ void cBlaze::Attack(float a_Dt)
m_AttackInterval = 0.0;
// ToDo: Shoot 3 fireballs instead of 1.
}
-} \ No newline at end of file
+}
diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h
index cdb3a1306..5970451c7 100644
--- a/src/Mobs/Blaze.h
+++ b/src/Mobs/Blaze.h
@@ -20,7 +20,3 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Attack(float a_Dt) override;
} ;
-
-
-
-
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index 47fcdbb26..1685f40c5 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -88,4 +88,4 @@ void cSkeleton::Attack(float a_Dt)
m_World->BroadcastSpawnEntity(*Arrow);
m_AttackInterval = 0.0;
}
-} \ No newline at end of file
+}
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index 0e42194ac..8f5d28b68 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -13,8 +13,27 @@ cWither::cWither(void) :
m_InvulnerableTicks(220)
{
SetMaxHealth(300);
+}
+
+
+
+
+
+bool cWither::IsArmored(void) const
+{
+ return GetHealth() <= (GetMaxHealth() / 2);
+}
+
+
+
+
+bool cWither::Initialize(cWorld * a_World)
+{
+ // Set health before BroadcastSpawnEntity()
SetHealth(GetMaxHealth() / 3);
+
+ return super::Initialize(a_World);
}
@@ -33,6 +52,11 @@ void cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
return;
}
+ if (IsArmored() && (a_TDI.DamageType == dtRangedAttack))
+ {
+ return;
+ }
+
super::DoTakeDamage(a_TDI);
}
@@ -60,6 +84,8 @@ void cWither::Tick(float a_Dt, cChunk & a_Chunk)
Heal(10);
}
}
+
+ m_World->BroadcastEntityMetadata(*this);
}
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index d09e3607a..bc78bfaad 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -20,8 +20,12 @@ public:
unsigned int GetNumInvulnerableTicks(void) const { return m_InvulnerableTicks; }
void SetNumInvulnerableTicks(unsigned int a_Ticks) { m_InvulnerableTicks = a_Ticks; }
+
+ /** Returns whether the wither is invulnerable to arrows. */
+ bool IsArmored(void) const;
// cEntity overrides
+ virtual bool Initialize(cWorld * a_World) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;