diff options
author | Mattes D <github@xoft.cz> | 2017-05-28 20:56:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-28 20:56:17 +0200 |
commit | 0551d78dffd5d377de382e34d9f6c77773c68202 (patch) | |
tree | 1e0629ff3b9d602c2c058b2bcf07fd8c93a30974 /src/Mobs/Monster.cpp | |
parent | Minor cBrewingRecipes cleanup (#3731) (diff) | |
download | cuberite-0551d78dffd5d377de382e34d9f6c77773c68202.tar cuberite-0551d78dffd5d377de382e34d9f6c77773c68202.tar.gz cuberite-0551d78dffd5d377de382e34d9f6c77773c68202.tar.bz2 cuberite-0551d78dffd5d377de382e34d9f6c77773c68202.tar.lz cuberite-0551d78dffd5d377de382e34d9f6c77773c68202.tar.xz cuberite-0551d78dffd5d377de382e34d9f6c77773c68202.tar.zst cuberite-0551d78dffd5d377de382e34d9f6c77773c68202.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/Monster.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index ef8794e53..00045fc69 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -149,20 +149,21 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk) return; } - - if (m_JumpCoolDown == 0) + if (m_JumpCoolDown <= 0) { if (DoesPosYRequireJump(FloorC(m_NextWayPointPosition.y))) { - if (((IsOnGround()) && (GetSpeed().SqrLength() == 0.0f)) || - (IsSwimming())) + if ( + (IsOnGround() && (GetSpeed().SqrLength() <= 0.5)) || // If walking on the ground, we need to slow down first, otherwise we miss the jump + IsSwimming() + ) { m_bOnGround = false; m_JumpCoolDown = 20; - // TODO: Change to AddSpeedY once collision detection is fixed - currently, mobs will go into blocks attempting to jump without a teleport AddPosY(1.6); // Jump!! + SetSpeedY(1); SetSpeedX(3.2 * (m_NextWayPointPosition.x - GetPosition().x)); // Move forward in a preset speed. - SetSpeedZ(3.2 * (m_NextWayPointPosition.z - GetPosition().z)); // The numbers were picked based on trial and error and 1.6 and 3.2 are perfect. + SetSpeedZ(3.2 * (m_NextWayPointPosition.z - GetPosition().z)); // The numbers were picked based on trial and error } } } @@ -172,7 +173,7 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk) } Vector3d Distance = m_NextWayPointPosition - GetPosition(); - if ((Distance.x != 0.0f) || (Distance.z != 0.0f)) + if ((std::abs(Distance.x) > 0.05) || (std::abs(Distance.z) > 0.05)) { Distance.y = 0; Distance.Normalize(); |