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_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 )
{
switch( m_state )
{
case MOTHER_JELLYFISH_CYCLE:
{
if ( m_movementTimer <= 0 )
{
@ -156,7 +161,7 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames )
projectile = CProjectile::Create();
DVECTOR newPos = Pos;
projectile->init( newPos, heading );
projectile->setGraphic( FRM__LIGHTNING2 );
projectile->setGraphic( FRM__LIGHTNING1 );
m_movementTimer = GameState::getOneSecondInFrames() * 5;
m_pulsateTimer = GameState::getOneSecondInFrames();
@ -196,102 +201,67 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames )
}
else
{
s16 headingToTarget = ratan2( distY, distX );
s16 decDir, incDir;
s16 moveDist;
s16 maxTurnRate = m_data[m_type].turnSpeed;
s32 moveX, moveY;
decDir = m_heading - headingToTarget;
if ( decDir < 0 )
{
decDir += ONE;
processGenericGotoTarget( _frames, distX, distY, m_speed );
}
}
incDir = headingToTarget - m_heading;
if ( incDir < 0 )
{
incDir += ONE;
break;
}
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
{
moveDist = incDir;
m_state = MOTHER_JELLYFISH_CIRCLE;
m_extension = 0;
}
if ( moveDist < -maxTurnRate )
{
moveDist = -maxTurnRate;
}
else if ( moveDist > maxTurnRate )
{
moveDist = maxTurnRate;
break;
}
m_heading += moveDist;
m_heading &= 4095;
case MOTHER_JELLYFISH_CIRCLE:
{
m_extension += 64 * _frames;
s32 preShiftX = _frames * m_speed * rcos( m_heading );
s32 preShiftY = _frames * m_speed * rsin( m_heading );
if ( m_extension < 3072 )
{
CPlayer *player = GameScene.getPlayer();
moveX = preShiftX >> 12;
if ( !moveX && preShiftX )
{
moveX = preShiftX / abs( preShiftX );
}
DVECTOR playerPos = player->getPos();
if ( distX > 0 )
{
if ( moveX > distX )
{
moveX = distX;
}
}
else if ( distX < 0 )
{
if ( moveX < distX )
{
moveX = distX;
}
Pos.vx = playerPos.vx + ( ( 70 * rcos( m_extension ) ) >> 12 );
Pos.vy = playerPos.vy + ( ( 70 * rsin( m_extension ) ) >> 12 );
}
else
{
moveX = 0;
m_state = MOTHER_JELLYFISH_EXIT;
}
moveY = preShiftY >> 12;
if ( !moveY && preShiftY )
{
moveY = preShiftY / abs( preShiftY );
break;
}
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;
}
}
else if ( distY < 0 )
{
if ( moveY < distY )
{
moveY = distY;
}
}
else
{
moveY = 0;
m_isActive = false;
setToShutdown();
}
Pos.vx += moveX;
Pos.vy += moveY;
break;
}
}
@ -582,8 +552,6 @@ void CNpcMotherJellyfishEnemy::processShot( int _frames )
{
case NPC_GENERIC_HIT_CHECK_HEALTH:
{
// do not allow to die, must catch in net
if ( m_health > 0 )
{
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_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_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;
}
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 processMovement( int _frames );
virtual void processShot( int _frames );
virtual void collidedWith(CThing *_thisThing);
//void spawnJellyfish( int _frames );
//virtual void processUserCollision( CThing *thisThing );
@ -44,7 +45,9 @@ protected:
MOTHER_JELLYFISH_CYCLE_3,
MOTHER_JELLYFISH_ATTACK_PLAYER_SHOCK,*/
MOTHER_JELLYFISH_CYCLE = 0,
MOTHER_JELLYFISH_ATTACK_PLAYER = 1,
MOTHER_JELLYFISH_BEGIN_CIRCLE = 1,
MOTHER_JELLYFISH_CIRCLE,
MOTHER_JELLYFISH_EXIT,
};
int m_jellyfishCount;