diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 8adb4089f..9a97b5b3a 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -742,20 +742,35 @@ bool CNpcEnemy::processSensor() { if ( playerXDistSqr + playerYDistSqr < 10000 ) { - m_controlFunc = NPC_CONTROL_CLOSE; - m_extension = 0; - m_velocity = 5; - m_base = Pos; + // only attack if within path extents + + s32 minX, maxX; + m_npcPath.getPathXExtents( &minX, &maxX ); if ( playerXDist < 0 ) { m_extendDir = EXTEND_LEFT; + + if ( ( Pos.vx + playerXDist - 128 ) < minX ) + { + return( false ); + } } else { m_extendDir = EXTEND_RIGHT; + + if ( ( Pos.vx + playerXDist + 128 ) > maxX ) + { + return( false ); + } } + m_controlFunc = NPC_CONTROL_CLOSE; + m_extension = 0; + m_velocity = 5; + m_base = Pos; + return( true ); } else