diff options
author | xdot <xdotftw@gmail.com> | 2014-05-21 10:14:44 +0200 |
---|---|---|
committer | xdot <xdotftw@gmail.com> | 2014-05-21 10:14:44 +0200 |
commit | 671c73c6396a1d5ec00bdf6578745b05a1c6ac83 (patch) | |
tree | 42aa3b9000120d4a8dcb9cb6625063adf49d4b61 /src/Entities/Player.cpp | |
parent | Fixed MCADefrag compilation. (diff) | |
parent | Fixed cWither::KilledBy (diff) | |
download | cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.gz cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.bz2 cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.lz cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.xz cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.zst cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Player.cpp | 71 |
1 files changed, 57 insertions, 14 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c3b763278..0eacb67f9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -456,8 +456,18 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) else { float Dist = (float)(m_LastGroundHeight - floor(GetPosY())); + + if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above + { + // Increment statistic + m_Stats.AddValue(statDistFallen, (StatValue)floor(Dist * 100 + 0.5)); + } + int Damage = (int)(Dist - 3.f); - if (m_LastJumpHeight > m_LastGroundHeight) Damage++; + if (m_LastJumpHeight > m_LastGroundHeight) + { + Damage++; + } m_LastJumpHeight = (float)GetPosY(); if (Damage > 0) @@ -1951,32 +1961,65 @@ void cPlayer::HandleFloater() +bool cPlayer::IsClimbing(void) const +{ + int PosX = POSX_TOINT; + int PosY = POSY_TOINT; + int PosZ = POSZ_TOINT; + + if ((PosY < 0) || (PosY >= cChunkDef::Height)) + { + return false; + } + + BLOCKTYPE Block = m_World->GetBlock(PosX, PosY, PosZ); + switch (Block) + { + case E_BLOCK_LADDER: + case E_BLOCK_VINES: + { + return true; + } + default: return false; + } +} + + + + + void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) { StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5); if (m_AttachedTo == NULL) { - int PosX = POSX_TOINT; - int PosY = POSY_TOINT; - int PosZ = POSZ_TOINT; - - BLOCKTYPE Block; - NIBBLETYPE Meta; - if (!m_World->GetBlockTypeMeta(PosX, PosY, PosZ, Block, Meta)) + if (IsClimbing()) { - return; + if (a_DeltaPos.y > 0.0) // Going up + { + m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); + } } - - if ((Block == E_BLOCK_LADDER) && (a_DeltaPos.y > 0.0)) // Going up + else if (IsSubmerged()) { - m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); + m_Stats.AddValue(statDistDove, Value); } - else + else if (IsSwimming()) + { + m_Stats.AddValue(statDistSwum, Value); + } + else if (IsOnGround()) { - // TODO 2014-05-12 xdot: Other types m_Stats.AddValue(statDistWalked, Value); } + else + { + if (Value >= 25) // Ignore small/slow movement + { + m_Stats.AddValue(statDistFlown, Value); + } + } } else { |