summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-05-18 23:10:23 +0200
committermadmaxoft <github@xoft.cz>2014-05-18 23:10:23 +0200
commite69a11012fb7543d47230663a01af2a7ec20960c (patch)
tree2c4a5b6759f76059736bdf5b30ea17f2a6ee8570 /src/Entities/Entity.cpp
parentUpdated SandVillage prefabs to latest Gallery content. (diff)
parentThere's no "round" function in MSVC2008. (diff)
downloadcuberite-e69a11012fb7543d47230663a01af2a7ec20960c.tar
cuberite-e69a11012fb7543d47230663a01af2a7ec20960c.tar.gz
cuberite-e69a11012fb7543d47230663a01af2a7ec20960c.tar.bz2
cuberite-e69a11012fb7543d47230663a01af2a7ec20960c.tar.lz
cuberite-e69a11012fb7543d47230663a01af2a7ec20960c.tar.xz
cuberite-e69a11012fb7543d47230663a01af2a7ec20960c.tar.zst
cuberite-e69a11012fb7543d47230663a01af2a7ec20960c.zip
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r--src/Entities/Entity.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 4cf10a219..31ad66779 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, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5));
}
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