From 020e9286859925c2fe4c18565a70b1b1fce82558 Mon Sep 17 00:00:00 2001 From: wiseoldman95 Date: Wed, 6 May 2015 06:46:10 +0300 Subject: [PATCH 1/2] PF - Fixed mobs not reaching leaning player --- src/Mobs/Monster.cpp | 5 +++-- src/Mobs/Path.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 7ced89e45..37774b08f 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -143,10 +143,11 @@ bool cMonster::TickPathFinding(cChunk & a_Chunk) { /* If we reached the last path waypoint, Or if we haven't re-calculated for too long. - Interval is proportional to distance squared. (Recalculate lots when close, calculate rarely when far) */ + Interval is proportional to distance squared, and its minimum is 10. + (Recalculate lots when close, calculate rarely when far) */ if ( ((GetPosition() - m_PathFinderDestination).Length() < 0.25) || - m_TicksSinceLastPathReset > (0.15 * (m_FinalDestination - GetPosition()).SqrLength()) + ((m_TicksSinceLastPathReset > 10) && (m_TicksSinceLastPathReset > (0.15 * (m_FinalDestination - GetPosition()).SqrLength()))) ) { ResetPathFinding(); diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp index 8701dad10..a0b83f593 100644 --- a/src/Mobs/Path.cpp +++ b/src/Mobs/Path.cpp @@ -182,7 +182,13 @@ bool cPath::Step_Internal() } // Path found. - if (CurrentCell->m_Location == m_Destination) + if ( + (CurrentCell->m_Location == m_Destination + Vector3i(0, 0, 1)) || + (CurrentCell->m_Location == m_Destination + Vector3i(1, 0, 0)) || + (CurrentCell->m_Location == m_Destination + Vector3i(-1, 0, 0)) || + (CurrentCell->m_Location == m_Destination + Vector3i(0, 0, -1)) || + (CurrentCell->m_Location == m_Destination + Vector3i(0, -1, 0)) + ) { do { From c6dd455d7211a4f0819fc0a0b7839b10732965bd Mon Sep 17 00:00:00 2001 From: wiseoldman95 Date: Wed, 6 May 2015 09:27:47 +0300 Subject: [PATCH 2/2] PF - Swimming bugfix --- src/Mobs/Path.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp index a0b83f593..84d888bf2 100644 --- a/src/Mobs/Path.cpp +++ b/src/Mobs/Path.cpp @@ -60,12 +60,12 @@ cPath::cPath( { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; - int RelX = m_Destination.x - m_Chunk->GetPosX() * cChunkDef::Width; - int RelZ = m_Destination.z - m_Chunk->GetPosZ() * cChunkDef::Width; + int RelX = m_Destination.x - Chunk->GetPosX() * cChunkDef::Width; + int RelZ = m_Destination.z - Chunk->GetPosZ() * cChunkDef::Width; bool inwater = false; for (;;) { - m_Chunk->GetBlockTypeMeta(RelX, m_Destination.y, RelZ, BlockType, BlockMeta); + Chunk->GetBlockTypeMeta(RelX, m_Destination.y, RelZ, BlockType, BlockMeta); if (BlockType != E_BLOCK_STATIONARY_WATER) { break;