summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwiseoldman95 <softwatt@gmx.com>2015-05-02 20:22:28 +0200
committerwiseoldman95 <softwatt@gmx.com>2015-05-03 13:24:24 +0200
commitd68b75a6793f794b2261f48d2405afab26e5a20e (patch)
tree478f82e6c7f48a9203910dc4efac757a6ccc4272
parentMerge pull request #1925 from SafwatHalaby/PathFinder_Optimze (diff)
downloadcuberite-d68b75a6793f794b2261f48d2405afab26e5a20e.tar
cuberite-d68b75a6793f794b2261f48d2405afab26e5a20e.tar.gz
cuberite-d68b75a6793f794b2261f48d2405afab26e5a20e.tar.bz2
cuberite-d68b75a6793f794b2261f48d2405afab26e5a20e.tar.lz
cuberite-d68b75a6793f794b2261f48d2405afab26e5a20e.tar.xz
cuberite-d68b75a6793f794b2261f48d2405afab26e5a20e.tar.zst
cuberite-d68b75a6793f794b2261f48d2405afab26e5a20e.zip
-rw-r--r--src/Mobs/Monster.cpp20
-rw-r--r--src/Mobs/Monster.h1
2 files changed, 16 insertions, 5 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 9b9bec51e..1db6e69ff 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -80,6 +80,7 @@ cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const A
, m_GiveUpCounter(0)
, m_bMovingToDestination(false)
, m_LastGroundHeight(POSY_TOINT)
+ , m_JumpCoolDown(0)
, m_IdleInterval(0)
, m_DestroyTimer(0)
, m_MobType(a_MobType)
@@ -286,12 +287,21 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_bOnGround)
{
- if (DoesPosYRequireJump((int)floor(m_Destination.y)))
+ if (m_JumpCoolDown == 0)
{
- m_bOnGround = false;
-
- // TODO: Change to AddSpeedY once collision detection is fixed - currently, mobs will go into blocks attempting to jump without a teleport
- AddPosY(1.2); // Jump!!
+ if (DoesPosYRequireJump(static_cast<int>(floor(m_Destination.y))))
+ {
+ 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!!
+ SetSpeedX(3.2 * (m_Destination.x - GetPosition().x)); // Move forward in a preset speed.
+ SetSpeedZ(3.2 * (m_Destination.z - GetPosition().z)); // The numbers were picked based on trial and error and 1.6 and 3.2 are perfect.
+ }
+ }
+ else
+ {
+ --m_JumpCoolDown;
}
}
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 9699e74ad..978266165 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -217,6 +217,7 @@ protected:
virtual void HandleFalling(void);
int m_LastGroundHeight;
+ int m_JumpCoolDown;
/* =========================== */