diff options
author | Mattes D <github@xoft.cz> | 2014-04-28 20:58:15 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-04-28 20:58:15 +0200 |
commit | 709015369df050d3d5b1d12b7d74ae814cd046df (patch) | |
tree | 106568e25f564d0e0e414269a8fbb28ed3f1507e /src/Entities/Entity.cpp | |
parent | Fixed braces. (diff) | |
parent | Revert "Withers now use the new invulnerable." (diff) | |
download | cuberite-709015369df050d3d5b1d12b7d74ae814cd046df.tar cuberite-709015369df050d3d5b1d12b7d74ae814cd046df.tar.gz cuberite-709015369df050d3d5b1d12b7d74ae814cd046df.tar.bz2 cuberite-709015369df050d3d5b1d12b7d74ae814cd046df.tar.lz cuberite-709015369df050d3d5b1d12b7d74ae814cd046df.tar.xz cuberite-709015369df050d3d5b1d12b7d74ae814cd046df.tar.zst cuberite-709015369df050d3d5b1d12b7d74ae814cd046df.zip |
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r-- | src/Entities/Entity.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 2d325805b..5c675a387 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -62,6 +62,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Mass (0.001) // Default 1g , m_Width(a_Width) , m_Height(a_Height) + , m_InvulnerableTicks(0) { cCSLock Lock(m_CSCount); m_EntityCount++; @@ -296,17 +297,23 @@ void cEntity::SetPitchFromSpeed(void) -void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) +bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) { if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI)) { - return; + return false; } if (m_Health <= 0) { // Can't take damage if already dead - return; + return false; + } + + if (m_InvulnerableTicks > 0) + { + // Entity is invulnerable + return false; } if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) @@ -364,10 +371,13 @@ void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) m_World->BroadcastEntityStatus(*this, esGenericHurt); + m_InvulnerableTicks = 10; + if (m_Health <= 0) { KilledBy(a_TDI.Attacker); } + return true; } @@ -564,6 +574,11 @@ void cEntity::SetHealth(int a_Health) void cEntity::Tick(float a_Dt, cChunk & a_Chunk) { + if (m_InvulnerableTicks > 0) + { + m_InvulnerableTicks--; + } + if (m_AttachedTo != NULL) { if ((m_Pos - m_AttachedTo->GetPosition()).Length() > 0.5) |