This commit is contained in:
parent
3903242d0f
commit
db1f69c0e3
@ -58,7 +58,7 @@ void CNpcEnemy::processCloseHermitCrabAttack( int _frames )
|
|||||||
|
|
||||||
case HERMIT_CRAB_ROLL_ATTACK:
|
case HERMIT_CRAB_ROLL_ATTACK:
|
||||||
{
|
{
|
||||||
if ( !m_animPlaying )
|
if ( !m_animPlaying || m_animNo == m_data[m_type].moveAnim )
|
||||||
{
|
{
|
||||||
switch( m_animNo )
|
switch( m_animNo )
|
||||||
{
|
{
|
||||||
@ -68,6 +68,15 @@ void CNpcEnemy::processCloseHermitCrabAttack( int _frames )
|
|||||||
m_animNo = ANIM_HERMITCRAB_ROLLATTACK;
|
m_animNo = ANIM_HERMITCRAB_ROLLATTACK;
|
||||||
m_frame = 0;
|
m_frame = 0;
|
||||||
|
|
||||||
|
if ( playerXDist > 0 )
|
||||||
|
{
|
||||||
|
m_extendDir = EXTEND_RIGHT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_extendDir = EXTEND_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,15 +106,6 @@ void CNpcEnemy::processCloseHermitCrabAttack( int _frames )
|
|||||||
m_animNo = ANIM_HERMITCRAB_ROLLATTACKSTART;
|
m_animNo = ANIM_HERMITCRAB_ROLLATTACKSTART;
|
||||||
m_frame = 0;
|
m_frame = 0;
|
||||||
|
|
||||||
if ( playerXDist > 0 )
|
|
||||||
{
|
|
||||||
m_extendDir = EXTEND_RIGHT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_extendDir = EXTEND_LEFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +130,23 @@ void CNpcEnemy::processCloseHermitCrabAttack( int _frames )
|
|||||||
m_heading = 2048;
|
m_heading = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
s32 minX, maxX, newX;
|
||||||
|
|
||||||
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
||||||
|
|
||||||
|
newX = Pos.vx + moveX;
|
||||||
|
|
||||||
|
if ( newX < minX || newX > maxX )
|
||||||
|
{
|
||||||
|
// moving outside path constraints, abort
|
||||||
|
|
||||||
|
m_animPlaying = true;
|
||||||
|
m_animNo = ANIM_HERMITCRAB_ROLLATTACKEND;
|
||||||
|
m_frame = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
groundHeight = m_layerCollision->getHeightFromGround( newX, Pos.vy, yMovement + 16 );
|
||||||
|
|
||||||
if ( groundHeight <= yMovement )
|
if ( groundHeight <= yMovement )
|
||||||
{
|
{
|
||||||
@ -139,10 +155,11 @@ void CNpcEnemy::processCloseHermitCrabAttack( int _frames )
|
|||||||
moveY = groundHeight;
|
moveY = groundHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pos.vx += moveX;
|
Pos.vx = newX;
|
||||||
Pos.vy += moveY;
|
Pos.vy += moveY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -43,6 +43,7 @@ void CNpcPath::initPath()
|
|||||||
lastWaypoint = NULL;
|
lastWaypoint = NULL;
|
||||||
waypointCount = 0;
|
waypointCount = 0;
|
||||||
reversePath = false;
|
reversePath = false;
|
||||||
|
minX = maxX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNpcPath::resetPath()
|
void CNpcPath::resetPath()
|
||||||
@ -74,6 +75,15 @@ void CNpcPath::addWaypoint( DVECTOR newPos )
|
|||||||
|
|
||||||
testWaypoint->nextWaypoint = newWaypoint;
|
testWaypoint->nextWaypoint = newWaypoint;
|
||||||
waypointCount++;
|
waypointCount++;
|
||||||
|
|
||||||
|
if ( newPos.vx < minX )
|
||||||
|
{
|
||||||
|
minX = newPos.vx;
|
||||||
|
}
|
||||||
|
else if ( newPos.vx > maxX )
|
||||||
|
{
|
||||||
|
maxX = newPos.vx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -88,9 +98,17 @@ void CNpcPath::addWaypoint( DVECTOR newPos )
|
|||||||
waypointCount++;
|
waypointCount++;
|
||||||
|
|
||||||
currentWaypoint = this->waypoint;
|
currentWaypoint = this->waypoint;
|
||||||
|
|
||||||
|
minX = maxX = newPos.vx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CNpcPath::getPathXExtents( s32 *minExtent, s32 *maxExtent )
|
||||||
|
{
|
||||||
|
*minExtent = minX;
|
||||||
|
*maxExtent = maxX;
|
||||||
|
}
|
||||||
|
|
||||||
void CNpcPath::removeAllWaypoints()
|
void CNpcPath::removeAllWaypoints()
|
||||||
{
|
{
|
||||||
CNpcWaypoint *testWaypoint;
|
CNpcWaypoint *testWaypoint;
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange );
|
s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange );
|
||||||
bool thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *heading );
|
bool thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *heading );
|
||||||
bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY );
|
bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY );
|
||||||
|
void getPathXExtents( s32 *minExtent, s32 *maxExtent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CNpcWaypoint *waypoint;
|
CNpcWaypoint *waypoint;
|
||||||
@ -54,6 +55,7 @@ private:
|
|||||||
bool reversePath;
|
bool reversePath;
|
||||||
CNpcWaypoint *currentWaypoint;
|
CNpcWaypoint *currentWaypoint;
|
||||||
CNpcWaypoint *lastWaypoint;
|
CNpcWaypoint *lastWaypoint;
|
||||||
|
s32 minX, maxX;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user