This commit is contained in:
Charles 2001-07-06 15:54:47 +00:00
parent 93ae663ddb
commit 11410abd64
2 changed files with 62 additions and 8 deletions

View File

@ -92,14 +92,68 @@ void CNpcFallingBlockPlatform::processMovement( int _frames )
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CNpcFallingBlockPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames)
void CNpcFallingBlockPlatform::collidedWith( CThing *_thisThing )
{
if ( m_isFalling )
switch(_thisThing->getThingType())
{
return( false );
}
else
{
return( CNpcPlatform::checkCollisionAgainst( _thisThing, _frames ) );
case TYPE_PLAYER:
{
CPlayer *player;
DVECTOR playerPos;
CRECT collisionArea;
// Only interested in SBs feet colliding with the box (pkg)
player=(CPlayer*)_thisThing;
playerPos=player->getPos();
collisionArea=getCollisionArea();
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
if ( threshold > 16 )
{
threshold = 16;
}
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
{
if ( m_isFalling )
{
int height = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy );
if ( height < -threshold )
{
player->takeDamage( DAMAGE__HIT_ENEMY, REACT__GET_DIRECTION_FROM_THING, this );
}
}
else
{
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
{
player->setPlatform( this );
m_contact = true;
}
else
{
if( playerPos.vy >= collisionArea.y1 && playerPos.vy <= collisionArea.y2 )
{
int height = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy );
if ( height >= -threshold && height < 1 )
{
player->setPlatform( this );
m_contact = true;
}
}
}
}
}
break;
}
default:
break;
}
}

View File

@ -23,9 +23,9 @@ class CNpcFallingBlockPlatform : public CNpcPlatform
public:
void postInit();
CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );}
int checkCollisionAgainst(CThing *_thisThing, int _frames);
void trigger();
protected:
void collidedWith(CThing *_thisThing);
void processMovement( int _frames );
u8 m_isTriggered;