diff options
author | andrew <xdotftw@gmail.com> | 2014-03-24 11:29:19 +0100 |
---|---|---|
committer | andrew <xdotftw@gmail.com> | 2014-03-24 11:29:19 +0100 |
commit | 6b77dc74ade3d8088da09d26c1b701d92ef28e9e (patch) | |
tree | 78e16164d1668d628ef0f545a5e62f5cbc1025fc /src/Mobs | |
parent | Plugins can set flying speed. (diff) | |
download | cuberite-6b77dc74ade3d8088da09d26c1b701d92ef28e9e.tar cuberite-6b77dc74ade3d8088da09d26c1b701d92ef28e9e.tar.gz cuberite-6b77dc74ade3d8088da09d26c1b701d92ef28e9e.tar.bz2 cuberite-6b77dc74ade3d8088da09d26c1b701d92ef28e9e.tar.lz cuberite-6b77dc74ade3d8088da09d26c1b701d92ef28e9e.tar.xz cuberite-6b77dc74ade3d8088da09d26c1b701d92ef28e9e.tar.zst cuberite-6b77dc74ade3d8088da09d26c1b701d92ef28e9e.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/Monster.cpp | 1 | ||||
-rw-r--r-- | src/Mobs/Wither.cpp | 52 | ||||
-rw-r--r-- | src/Mobs/Wither.h | 14 |
3 files changed, 66 insertions, 1 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 16d6aed1f..d3e0f1c26 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -758,6 +758,7 @@ cMonster::eFamily cMonster::FamilyFromType(eType a_Type) case mtSquid: return mfWater; case mtVillager: return mfPassive; case mtWitch: return mfHostile; + case mtWither: return mfHostile; case mtWolf: return mfHostile; case mtZombie: return mfHostile; case mtZombiePigman: return mfHostile; diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index c46e0beab..0e42194ac 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -2,14 +2,64 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Wither.h" +#include "../World.h" cWither::cWither(void) : - super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0) + super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0), + m_InvulnerableTicks(220) { + SetMaxHealth(300); + + SetHealth(GetMaxHealth() / 3); +} + + + + + +void cWither::DoTakeDamage(TakeDamageInfo & a_TDI) +{ + if (a_TDI.DamageType == dtDrowning) + { + return; + } + + if (m_InvulnerableTicks > 0) + { + return; + } + + super::DoTakeDamage(a_TDI); +} + + + + + +void cWither::Tick(float a_Dt, cChunk & a_Chunk) +{ + super::Tick(a_Dt, a_Chunk); + + if (m_InvulnerableTicks > 0) + { + unsigned int NewTicks = m_InvulnerableTicks - 1; + + if (NewTicks == 0) + { + m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this); + } + + m_InvulnerableTicks = NewTicks; + + if ((NewTicks % 10) == 0) + { + Heal(10); + } + } } diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 56effc6bb..df3a57798 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -16,8 +16,22 @@ public: cWither(void); CLASS_PROTODEF(cWither); + + unsigned int GetNumInvulnerableTicks(void) const { return m_InvulnerableTicks; } + + void SetNumInvulnerableTicks(unsigned int a_Ticks) { m_InvulnerableTicks = a_Ticks; } + // Override functions 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; + +private: + + /** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */ + unsigned int m_InvulnerableTicks; } ; |