This commit is contained in:
Charles 2001-05-09 23:14:35 +00:00
parent 7c224ca827
commit 57de623103
10 changed files with 107 additions and 11 deletions

View File

@ -47,7 +47,7 @@ bool CNpcHermitCrabEnemy::processSensor()
default:
{
if ( playerXDistSqr + playerYDistSqr < 400 )
if ( playerXDistSqr + playerYDistSqr < 4000 )
{
m_controlFunc = NPC_CONTROL_CLOSE;

View File

@ -343,3 +343,9 @@ void CNpcMotherJellyfishEnemy::render()
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcMotherJellyfishEnemy::processUserCollision( CThing *thisThing )
{
}

View File

@ -24,6 +24,7 @@ protected:
virtual void processClose( int _frames );
virtual void processMovement( int _frames );
void spawnJellyfish( int _frames );
virtual void processUserCollision( CThing *thisThing );
enum NPC_MOTHER_JELLYFISH_STATE
{

View File

@ -874,12 +874,15 @@ void CNpcEnemy::collidedWith( CThing *_thisThing )
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
processUserCollision( _thisThing );
break;
}
case DETECT_ATTACK_COLLISION_GENERIC:
{
processAttackCollision();
processUserCollision( _thisThing );
break;
}
@ -1456,6 +1459,46 @@ void CNpcEnemy::processEnemyCollision( CThing *thisThing )
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcEnemy::processUserCollision( CThing *thisThing )
{
DVECTOR otherPos = thisThing->getPos();
DVECTOR otherDelta = thisThing->getPosDelta();
s32 xDist = Pos.vx - otherPos.vx;
s32 yDist = Pos.vy - otherPos.vy;
s16 headingFromTarget = ratan2( yDist, xDist );
if ( ( xDist > 0 && otherDelta.vx < 0 ) || ( xDist < 0 && otherDelta.vx > 0 ) )
{
otherDelta.vx = -otherDelta.vx;
}
if ( ( yDist > 0 && otherDelta.vy < 0 ) || ( yDist < 0 && otherDelta.vy > 0 ) )
{
otherDelta.vy = -otherDelta.vy;
}
Pos.vx += otherDelta.vx;
Pos.vy += otherDelta.vy;
m_heading = headingFromTarget;
s32 waypointXDist;
s32 waypointYDist;
m_npcPath.getDistToNextWaypoint( Pos, &waypointXDist, &waypointYDist );
if ( ( xDist > 0 && waypointXDist < 0 ) || ( xDist < 0 && waypointXDist > 0 ) )
{
// try next waypoint to get around other enemy
m_npcPath.incPath();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool CNpcEnemy::processCoralBlowerMovement( int _frames, s32 xDist, s32 yDist, u8 destroyAtTarget )
{
s32 moveX, moveY;

View File

@ -249,6 +249,7 @@ protected:
void processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY );
bool processGroundCollisionReverse( s32 *moveX, s32 *moveY );
virtual void processEnemyCollision( CThing *thisThing );
virtual void processUserCollision( CThing *thisThing );
void reinit();

View File

@ -59,7 +59,7 @@ bool CNpcSpiderCrabEnemy::processSensor()
default:
{
if ( playerXDistSqr + playerYDistSqr < 10000 )
if ( abs( playerXDist ) < 64 )
{
// only attack if within path extents
@ -70,7 +70,7 @@ bool CNpcSpiderCrabEnemy::processSensor()
{
m_extendDir = EXTEND_LEFT;
if ( ( Pos.vx + playerXDist - 128 ) < minX )
if ( ( Pos.vx + playerXDist ) < minX )
{
return( false );
}
@ -79,12 +79,14 @@ bool CNpcSpiderCrabEnemy::processSensor()
{
m_extendDir = EXTEND_RIGHT;
if ( ( Pos.vx + playerXDist + 128 ) > maxX )
if ( ( Pos.vx + playerXDist ) > maxX )
{
return( false );
}
}
m_attackDist = abs( playerXDist );
m_controlFunc = NPC_CONTROL_CLOSE;
m_extension = 0;
m_velocity = 5;
@ -129,19 +131,19 @@ void CNpcSpiderCrabEnemy::processClose( int _frames )
bool completed = false;
if ( m_extension > 128 )
if ( m_extension > m_attackDist )
{
m_extension = 128;
m_extension = m_attackDist;
completed = true;
}
else if ( m_extension < -128 )
else if ( m_extension < -m_attackDist )
{
m_extension = -128;
m_extension = -m_attackDist;
completed = true;
}
newPos.vx = m_base.vx + m_extension;
newPos.vy = m_base.vy - ( ( 20 * rsin( abs( m_extension ) << 4 ) ) >> 12 );
newPos.vy = m_base.vy - ( ( SPIDER_CRAB_HEIGHT * rsin( abs( ( m_extension << 11 ) / m_attackDist ) ) ) >> 12 );
s32 minX, maxX;

View File

@ -32,11 +32,19 @@ protected:
virtual void processMovement( int _frames );
void processSpiderCrabInitJumpMovement( int _frames );
s32 m_attackDist;
enum NPC_SPIDER_CRAB_STATE
{
SPIDER_CRAB_DEFAULT = 0,
SPIDER_CRAB_INIT_JUMP = 1,
};
enum NPC_SPIDER_CRAB_CONSTANTS
{
SPIDER_CRAB_EXTENSION = 64,
SPIDER_CRAB_HEIGHT = 50,
};
};
#endif

View File

@ -36,7 +36,17 @@
void CNpcBranchPlatform::postInit()
{
CNpcPlatform::postInit();
sBBox boundingBox = m_modelGfx->GetBBox();
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ) << 1, 50 + ( boundingBox.YMax - boundingBox.YMin ) );
if ( m_reversed )
{
setCollisionCentreOffset( boundingBox.XMax, 18 + ( ( boundingBox.YMax + boundingBox.YMin ) >> 1 ) );
}
else
{
setCollisionCentreOffset( boundingBox.XMin, 18 + ( ( boundingBox.YMax + boundingBox.YMin ) >> 1 ) );
}
m_angularVelocity = 0;
}
@ -300,3 +310,27 @@ void CNpcBranchPlatform::render()
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBranchPlatform::calculateBoundingBoxSize()
{
int angle;
DVECTOR centre;
int length;
int x1,y1,x2,y2;
angle=getCollisionAngle();
centre=getCollisionCentre();
//halfLength=m_platformWidth/2;
sBBox boundingBox = m_modelGfx->GetBBox();
length = ( boundingBox.XMax - boundingBox.XMin );
x1=-length*mcos(angle&4095)>>12;
y1=-length*msin(angle&4095)>>12;
x2=+length*mcos(angle&4095)>>12;
y2=+length*msin(angle&4095)>>12;
setCollisionSize(abs(x2-x1),50 + abs(y2-y1)+PLATFORMCOLLISIONHEIGHT);
}

View File

@ -28,6 +28,7 @@ protected:
virtual void processMovement( int _frames );
virtual void collidedWith(CThing *_thisThing);
virtual void calculateBoundingBoxSize();
s32 m_angularVelocity;
u8 m_reversed;

View File

@ -218,7 +218,7 @@ protected:
protected:
virtual void setCollisionAngle(int newAngle); // Actually.. this probly doesn't need to be in the base calss anymore.. :/
void calculateBoundingBoxSize();
virtual void calculateBoundingBoxSize();
};