This commit is contained in:
Charles 2001-06-16 14:33:00 +00:00
parent 761ed7efef
commit f1343fd78c
2 changed files with 118 additions and 146 deletions

View file

@ -81,9 +81,10 @@ void CNpcMotherJellyfishEnemy::postInit()
m_movementTimer = GameState::getOneSecondInFrames() * 5; m_movementTimer = GameState::getOneSecondInFrames() * 5;
m_pulsateTimer = GameState::getOneSecondInFrames(); m_pulsateTimer = GameState::getOneSecondInFrames();
m_pauseTimer = m_maxPauseTimer = GameState::getOneSecondInFrames();
m_renderScale = 4096; m_renderScale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth );
m_speed = m_data[m_type].speed + ( ( 3 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth );
m_pauseTimer = m_maxPauseTimer = ( GameState::getOneSecondInFrames() * m_health ) / m_data[m_type].initHealth;
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -141,6 +142,10 @@ void CNpcMotherJellyfishEnemy::setupWaypoints( sThingActor *ThisActor )
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcMotherJellyfishEnemy::processMovement( int _frames ) void CNpcMotherJellyfishEnemy::processMovement( int _frames )
{
switch( m_state )
{
case MOTHER_JELLYFISH_CYCLE:
{ {
if ( m_movementTimer <= 0 ) if ( m_movementTimer <= 0 )
{ {
@ -156,7 +161,7 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames )
projectile = CProjectile::Create(); projectile = CProjectile::Create();
DVECTOR newPos = Pos; DVECTOR newPos = Pos;
projectile->init( newPos, heading ); projectile->init( newPos, heading );
projectile->setGraphic( FRM__LIGHTNING2 ); projectile->setGraphic( FRM__LIGHTNING1 );
m_movementTimer = GameState::getOneSecondInFrames() * 5; m_movementTimer = GameState::getOneSecondInFrames() * 5;
m_pulsateTimer = GameState::getOneSecondInFrames(); m_pulsateTimer = GameState::getOneSecondInFrames();
@ -196,102 +201,67 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames )
} }
else else
{ {
s16 headingToTarget = ratan2( distY, distX ); processGenericGotoTarget( _frames, distX, distY, m_speed );
s16 decDir, incDir; }
s16 moveDist;
s16 maxTurnRate = m_data[m_type].turnSpeed;
s32 moveX, moveY;
decDir = m_heading - headingToTarget;
if ( decDir < 0 )
{
decDir += ONE;
} }
incDir = headingToTarget - m_heading; break;
if ( incDir < 0 )
{
incDir += ONE;
} }
if ( decDir < incDir ) case MOTHER_JELLYFISH_BEGIN_CIRCLE:
{ {
moveDist = -decDir; s32 distX, distY;
distX = playerXDist + 70;
distY = playerYDist;
if ( abs( distX ) > 10 || abs( distY ) > 10 )
{
processGenericGotoTarget( _frames, distX, distY, m_speed );
} }
else else
{ {
moveDist = incDir; m_state = MOTHER_JELLYFISH_CIRCLE;
m_extension = 0;
} }
if ( moveDist < -maxTurnRate ) break;
{
moveDist = -maxTurnRate;
}
else if ( moveDist > maxTurnRate )
{
moveDist = maxTurnRate;
} }
m_heading += moveDist; case MOTHER_JELLYFISH_CIRCLE:
m_heading &= 4095; {
m_extension += 64 * _frames;
s32 preShiftX = _frames * m_speed * rcos( m_heading ); if ( m_extension < 3072 )
s32 preShiftY = _frames * m_speed * rsin( m_heading ); {
CPlayer *player = GameScene.getPlayer();
moveX = preShiftX >> 12; DVECTOR playerPos = player->getPos();
if ( !moveX && preShiftX )
{
moveX = preShiftX / abs( preShiftX );
}
if ( distX > 0 ) Pos.vx = playerPos.vx + ( ( 70 * rcos( m_extension ) ) >> 12 );
{ Pos.vy = playerPos.vy + ( ( 70 * rsin( m_extension ) ) >> 12 );
if ( moveX > distX )
{
moveX = distX;
}
}
else if ( distX < 0 )
{
if ( moveX < distX )
{
moveX = distX;
}
} }
else else
{ {
moveX = 0; m_state = MOTHER_JELLYFISH_EXIT;
} }
moveY = preShiftY >> 12; break;
if ( !moveY && preShiftY )
{
moveY = preShiftY / abs( preShiftY );
} }
if ( distY > 0 ) case MOTHER_JELLYFISH_EXIT:
{ {
if ( moveY > distY ) Pos.vx += 8 * _frames;
DVECTOR offset = CLevel::getCameraPos();
if ( Pos.vx - offset.vx > VidGetScrW() )
{ {
moveY = distY; m_isActive = false;
} setToShutdown();
}
else if ( distY < 0 )
{
if ( moveY < distY )
{
moveY = distY;
}
}
else
{
moveY = 0;
} }
Pos.vx += moveX; break;
Pos.vy += moveY;
} }
} }
@ -582,8 +552,6 @@ void CNpcMotherJellyfishEnemy::processShot( int _frames )
{ {
case NPC_GENERIC_HIT_CHECK_HEALTH: case NPC_GENERIC_HIT_CHECK_HEALTH:
{ {
// do not allow to die, must catch in net
if ( m_health > 0 ) if ( m_health > 0 )
{ {
m_health -= 5; m_health -= 5;
@ -591,26 +559,27 @@ void CNpcMotherJellyfishEnemy::processShot( int _frames )
m_renderScale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth ); m_renderScale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth );
m_speed = m_data[m_type].speed + ( ( 3 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth ); m_speed = m_data[m_type].speed + ( ( 3 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth );
m_maxPauseTimer = ( GameState::getOneSecondInFrames() * m_health ) / m_data[m_type].initHealth; m_maxPauseTimer = ( GameState::getOneSecondInFrames() * m_health ) / m_data[m_type].initHealth;
m_state = MOTHER_JELLYFISH_CYCLE;
}
else
{
m_state = MOTHER_JELLYFISH_BEGIN_CIRCLE;
} }
m_state = NPC_GENERIC_HIT_RECOIL;
m_animPlaying = true;
m_animNo = m_data[m_type].recoilAnim;
m_frame = 0;
break;
}
case NPC_GENERIC_HIT_RECOIL:
{
if ( !m_animPlaying )
{
m_state = 0;
m_controlFunc = NPC_CONTROL_MOVEMENT; m_controlFunc = NPC_CONTROL_MOVEMENT;
}
break; break;
} }
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcMotherJellyfishEnemy::collidedWith(CThing *_thisThing)
{
if ( m_state == MOTHER_JELLYFISH_CYCLE )
{
CNpcEnemy::collidedWith( _thisThing );
}
}

View file

@ -29,6 +29,7 @@ protected:
virtual void processClose( int _frames ); virtual void processClose( int _frames );
virtual void processMovement( int _frames ); virtual void processMovement( int _frames );
virtual void processShot( int _frames ); virtual void processShot( int _frames );
virtual void collidedWith(CThing *_thisThing);
//void spawnJellyfish( int _frames ); //void spawnJellyfish( int _frames );
//virtual void processUserCollision( CThing *thisThing ); //virtual void processUserCollision( CThing *thisThing );
@ -44,7 +45,9 @@ protected:
MOTHER_JELLYFISH_CYCLE_3, MOTHER_JELLYFISH_CYCLE_3,
MOTHER_JELLYFISH_ATTACK_PLAYER_SHOCK,*/ MOTHER_JELLYFISH_ATTACK_PLAYER_SHOCK,*/
MOTHER_JELLYFISH_CYCLE = 0, MOTHER_JELLYFISH_CYCLE = 0,
MOTHER_JELLYFISH_ATTACK_PLAYER = 1, MOTHER_JELLYFISH_BEGIN_CIRCLE = 1,
MOTHER_JELLYFISH_CIRCLE,
MOTHER_JELLYFISH_EXIT,
}; };
int m_jellyfishCount; int m_jellyfishCount;