diff options
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Mobs/Monster.cpp | 24 | ||||
-rw-r--r-- | src/Mobs/Monster.h | 1 | ||||
-rw-r--r-- | src/Mobs/Path.cpp | 10 | ||||
-rw-r--r-- | src/Mobs/Path.h | 4 | ||||
-rw-r--r-- | src/PolarSSL++/CMakeLists.txt | 2 |
7 files changed, 27 insertions, 18 deletions
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 4cc73b350..366284fcb 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -142,5 +142,5 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPER if(NOT MSVC) add_library(Bindings ${SRCS} ${HDRS}) - target_link_libraries(Bindings lua sqlite tolualib polarssl) + target_link_libraries(Bindings lua sqlite tolualib mbedtls) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b91c4f65a..e04e6311f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -324,4 +324,4 @@ endif () if (WIN32) target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib) endif() -target_link_libraries(${EXECUTABLE} luaexpat jsoncpp polarssl zlib sqlite lua SQLiteCpp event_core event_extra) +target_link_libraries(${EXECUTABLE} luaexpat jsoncpp mbedtls zlib sqlite lua SQLiteCpp event_core event_extra) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 9b9bec51e..70c3b096b 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) @@ -131,12 +132,12 @@ void cMonster::TickPathFinding(cChunk & a_Chunk) // Can someone explain why are these two NOT THE SAME??? // m_Path = new cPath(GetWorld(), GetPosition(), m_FinalDestination, 30); - m_Path = new cPath(&a_Chunk, Vector3d(floor(position.x), floor(position.y), floor(position.z)), Vector3d(floor(Dest.x), floor(Dest.y), floor(Dest.z)), 20); + m_Path = new cPath(a_Chunk, Vector3d(floor(position.x), floor(position.y), floor(position.z)), Vector3d(floor(Dest.x), floor(Dest.y), floor(Dest.z)), 20); m_IsFollowingPath = false; } - m_PathStatus = m_Path->Step(&a_Chunk); + m_PathStatus = m_Path->Step(a_Chunk); switch (m_PathStatus) { @@ -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; /* =========================== */ diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp index d1b9d6963..2dd2a3c99 100644 --- a/src/Mobs/Path.cpp +++ b/src/Mobs/Path.cpp @@ -35,17 +35,16 @@ bool compareHeuristics::operator()(cPathCell * & a_Cell1, cPathCell * & a_Cell2) /* cPath implementation */ cPath::cPath( - cChunk * a_Chunk, + cChunk & a_Chunk, const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps, double a_BoundingBoxWidth, double a_BoundingBoxHeight, int a_MaxUp, int a_MaxDown ) { - ASSERT(m_Chunk != nullptr); // TODO: if src not walkable OR dest not walkable, then abort. // Borrow a new "isWalkable" from ProcessIfWalkable, make ProcessIfWalkable also call isWalkable - m_Chunk = a_Chunk; + m_Chunk = &a_Chunk; m_Source = a_StartingPoint.Floor(); m_Destination = a_EndingPoint.Floor(); @@ -80,10 +79,9 @@ cPath::~cPath() -ePathFinderStatus cPath::Step(cChunk * a_Chunk) +ePathFinderStatus cPath::Step(cChunk & a_Chunk) { - m_Chunk = a_Chunk; - ASSERT(m_Chunk != nullptr); + m_Chunk = &a_Chunk; if (m_Status != ePathFinderStatus::CALCULATING) { return m_Status; diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index 9927d0a34..1bce0ace0 100644 --- a/src/Mobs/Path.h +++ b/src/Mobs/Path.h @@ -52,7 +52,7 @@ public: @param a_EndingPoint "The block where the Zombie's knees want to be". @param a_MaxSteps The maximum steps before giving up. */ cPath( - cChunk * a_Chunk, + cChunk & a_Chunk, const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps, double a_BoundingBoxWidth = 1, double a_BoundingBoxHeight = 2, int a_MaxUp = 1, int a_MaxDown = 1 @@ -62,7 +62,7 @@ public: ~cPath(); /** Performs part of the path calculation and returns true if the path computation has finished. */ - ePathFinderStatus Step(cChunk * a_Chunk); + ePathFinderStatus Step(cChunk & a_Chunk); /* Point retrieval functions, inlined for performance. */ /** Returns the next point in the path. */ diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index 39d41292d..b11d16e33 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -37,6 +37,6 @@ if(NOT MSVC) add_library(PolarSSL++ ${SRCS} ${HDRS}) if (UNIX) - target_link_libraries(PolarSSL++ polarssl) + target_link_libraries(PolarSSL++ mbedtls) endif() endif() |