diff --git a/source/enemy/npcpath.cpp b/source/enemy/npcpath.cpp index f445b1a88..de757c9d9 100644 --- a/source/enemy/npcpath.cpp +++ b/source/enemy/npcpath.cpp @@ -271,7 +271,7 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang return( headingToTarget ); } -bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ) +bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist ) { bool pointChange = false; @@ -292,7 +292,7 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s3 *distX = currentWaypoint->pos.vx - currentPos.vx; *distY = currentWaypoint->pos.vy - currentPos.vy; - if ( abs( *distX ) < 10 ) + if ( abs( *distX ) < waypointDist ) { pointChange = true; *pathComplete = incPath(); diff --git a/source/enemy/npcpath.h b/source/enemy/npcpath.h index 8e1d9b00c..9f3fce75f 100644 --- a/source/enemy/npcpath.h +++ b/source/enemy/npcpath.h @@ -45,7 +45,7 @@ public: void resetPath(); void reversePathDir(); s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY ); - bool thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ); + bool thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist = 10 ); bool thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ); bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ); void getPathXExtents( s32 *minExtent, s32 *maxExtent ); diff --git a/source/hazard/hbbarrel.cpp b/source/hazard/hbbarrel.cpp index 0b90310d6..c4b9eac7f 100644 --- a/source/hazard/hbbarrel.cpp +++ b/source/hazard/hbbarrel.cpp @@ -57,7 +57,7 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames ) bool pathComplete; - if ( m_npcPath.thinkFlat( Pos, &pathComplete, &waypointXDist, &waypointYDist, &waypointHeading ) ) + if ( m_npcPath.thinkFlat( Pos, &pathComplete, &waypointXDist, &waypointYDist, &waypointHeading, 1 ) ) { if ( pathComplete ) { @@ -68,7 +68,12 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames ) m_lastWaypoint = Pos; } - moveX = 3 * _frames; + moveX = 4 * _frames; + + if ( moveX > abs( waypointXDist ) ) + { + moveX = abs( waypointXDist ); + } if ( waypointHeading == 2048 ) { @@ -110,15 +115,22 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames ) nextWaypoint.vx = waypointXDist + Pos.vx; nextWaypoint.vy = waypointYDist + Pos.vy; + s32 waypointDist = abs( nextWaypoint.vx - m_lastWaypoint.vx ); + + if ( waypointDist < 1 ) + { + waypointDist = 1; + } + if ( waypointYDist > 0 ) { - s32 sineVal = ( abs( Pos.vx - nextWaypoint.vx ) * 1024 ) / abs( nextWaypoint.vx - m_lastWaypoint.vx ); + s32 sineVal = ( abs( Pos.vx - nextWaypoint.vx ) * 1024 ) / waypointDist; Pos.vy = nextWaypoint.vy - ( ( abs( nextWaypoint.vy - m_lastWaypoint.vy ) * rsin( sineVal ) ) >> 12 ); } else if ( waypointYDist < 0 ) { - s32 sineVal = ( abs( Pos.vx - m_lastWaypoint.vx ) * 1024 ) / abs( nextWaypoint.vx - m_lastWaypoint.vx ); + s32 sineVal = ( abs( Pos.vx - m_lastWaypoint.vx ) * 1024 ) / waypointDist; Pos.vy = m_lastWaypoint.vy - ( ( abs( nextWaypoint.vy - m_lastWaypoint.vy ) * rsin( sineVal ) ) >> 12 ); }