diff options
author | Mattes D <github@xoft.cz> | 2014-05-18 22:30:34 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-05-18 22:30:34 +0200 |
commit | ac005681839134018f0162cfb8cb1453e11cbb46 (patch) | |
tree | 41cc966732262c0a8f5441932b758344856d6259 /src/Entities/Entity.cpp | |
parent | Merge pull request #1005 from SphinxC0re/LoadPluginfolder (diff) | |
parent | Fixes (diff) | |
download | cuberite-ac005681839134018f0162cfb8cb1453e11cbb46.tar cuberite-ac005681839134018f0162cfb8cb1453e11cbb46.tar.gz cuberite-ac005681839134018f0162cfb8cb1453e11cbb46.tar.bz2 cuberite-ac005681839134018f0162cfb8cb1453e11cbb46.tar.lz cuberite-ac005681839134018f0162cfb8cb1453e11cbb46.tar.xz cuberite-ac005681839134018f0162cfb8cb1453e11cbb46.tar.zst cuberite-ac005681839134018f0162cfb8cb1453e11cbb46.zip |
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r-- | src/Entities/Entity.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4cf10a219..c393f89fd 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -312,12 +312,16 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) { + cPlayer * Player = (cPlayer *)a_TDI.Attacker; + // IsOnGround() only is false if the player is moving downwards - if (!((cPlayer *)a_TDI.Attacker)->IsOnGround()) // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) + if (!Player->IsOnGround()) // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) { a_TDI.FinalDamage += 2; m_World->BroadcastEntityAnimation(*this, 4); // Critical hit } + + Player->GetStatManager().AddValue(statDamageDealt, round(a_TDI.FinalDamage * 10)); } m_Health -= (short)a_TDI.FinalDamage; @@ -370,6 +374,11 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if (m_Health <= 0) { KilledBy(a_TDI.Attacker); + + if (a_TDI.Attacker != NULL) + { + a_TDI.Attacker->Killed(this); + } } return true; } @@ -575,9 +584,16 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk) if (m_AttachedTo != NULL) { - if ((m_Pos - m_AttachedTo->GetPosition()).Length() > 0.5) + Vector3d DeltaPos = m_Pos - m_AttachedTo->GetPosition(); + if (DeltaPos.Length() > 0.5) { SetPosition(m_AttachedTo->GetPosition()); + + if (IsPlayer()) + { + cPlayer * Player = (cPlayer *)this; + Player->UpdateMovementStats(DeltaPos); + } } } else |