This commit is contained in:
Charles 2001-05-25 17:09:51 +00:00
parent 14a16d07aa
commit cfee7ad43f
2 changed files with 62 additions and 31 deletions

View file

@ -134,18 +134,7 @@ bool CNpcSquidDartEnemy::processSensor()
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_circleCentre.vx = Pos.vx + ( playerXDist >> 1 ); m_attack = false;
m_circleCentre.vy = Pos.vy + ( playerYDist >> 1 );
m_startAngle = ratan2( Pos.vy - m_circleCentre.vy, Pos.vx - m_circleCentre.vx );
m_startAngle &= 4095;
m_circleRadius = isqrt2( playerXDistSqr + playerYDistSqr ) >> 1;
m_circleCentre.vx = Pos.vx - ( ( m_circleRadius * rcos( m_startAngle ) ) >> 12 );
m_circleCentre.vy = Pos.vy - ( ( m_circleRadius * rsin( m_startAngle ) ) >> 12 );
m_angularDistance = 0;
// sound // sound
@ -165,29 +154,73 @@ bool CNpcSquidDartEnemy::processSensor()
void CNpcSquidDartEnemy::processClose( int _frames ) void CNpcSquidDartEnemy::processClose( int _frames )
{ {
s16 m_currentAngle; s32 movement;
s32 yAim = playerYDist - 20;
s32 maxSpeed = 2 * m_data[m_type].speed * _frames;
m_currentAngle = ( m_startAngle + m_angularDistance ) & 4095; if ( m_attack )
{
movement = m_xPos - Pos.vx;
m_heading = ( m_currentAngle + 1024 ) & 4095; if ( movement )
{
if ( movement > maxSpeed )
{
movement = maxSpeed;
}
else if ( movement < -maxSpeed )
{
movement = -maxSpeed;
}
Pos.vx = m_circleCentre.vx + ( ( m_circleRadius * rcos( m_currentAngle ) ) >> 12 ); Pos.vx += movement;
Pos.vy = m_circleCentre.vy + ( ( m_circleRadius * rsin( m_currentAngle ) ) >> 12 ); }
else
m_angularDistance += 32 * _frames;
if ( m_angularDistance > 4095 )
{ {
m_controlFunc = NPC_CONTROL_MOVEMENT; m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE; m_timerFunc = NPC_TIMER_ATTACK_DONE;
m_timerTimer = GameState::getOneSecondInFrames(); m_timerTimer = GameState::getOneSecondInFrames();
m_sensorFunc = NPC_SENSOR_NONE; m_sensorFunc = NPC_SENSOR_NONE;
} }
}
else
{
if ( yAim )
{
movement = yAim;
if ( movement > maxSpeed )
{
movement = maxSpeed;
}
else if ( movement < -maxSpeed )
{
movement = -maxSpeed;
}
Pos.vy += movement;
}
else
{
m_attack = true;
m_xPos = Pos.vx + playerXDist;
}
if ( playerXDist > 0 )
{
m_heading = 0;
}
else
{
m_heading = 2048;
}
}
if ( !m_animPlaying ) if ( !m_animPlaying )
{ {
m_frame = 0; m_frame = 0;
m_animNo = m_data[m_type].moveAnim; m_animNo = m_data[m_type].moveAnim;
m_animPlaying = true; m_animPlaying = true;
} }
} }

View file

@ -30,10 +30,8 @@ protected:
virtual bool processSensor(); virtual bool processSensor();
virtual void processClose( int _frames ); virtual void processClose( int _frames );
DVECTOR m_circleCentre; s32 m_xPos;
s16 m_angularDistance; u8 m_attack;
s16 m_startAngle;
s32 m_circleRadius;
}; };
#endif #endif