SBSPSS/source/enemy/nsshark.cpp

156 lines
2.6 KiB
C++
Raw Normal View History

2001-01-25 18:19:08 +01:00
/*=========================================================================
nsshark.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
#ifndef __ENEMY_NPC_H__
#include "enemy\npc.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
#ifndef __PROJECTL_PROJECTL_H__
#include "projectl\projectl.h"
#endif
void CNpc::processSubSharkMovement( int _frames )
{
if ( m_timerTimer <= 0 )
{
if ( m_salvoCount > 0 )
{
// drop mine
CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, 1024 );
m_salvoCount--;
m_timerTimer = GameState::getOneSecondInFrames() * 1;
}
}
if ( m_movementTimer > 0 )
{
m_movementTimer -= _frames;
if ( m_extendDir == EXTEND_RIGHT )
{
s32 xDist = 300 - Pos.vx;
s32 xDistSqr = xDist * xDist;
if ( xDistSqr > 100 )
{
processGenericGotoTarget( _frames, xDist, 0, m_data[m_type].speed );
}
else
{
m_extendDir = EXTEND_LEFT;
}
}
else
{
s32 xDist = -300 - Pos.vx;
s32 xDistSqr = xDist * xDist;
if ( xDistSqr > 100 )
{
processGenericGotoTarget( _frames, xDist, 0, m_data[m_type].speed );
}
else
{
m_extendDir = EXTEND_RIGHT;
}
}
}
else
{
m_controlFunc = NPC_CONTROL_CLOSE;
}
}
void CNpc::processCloseSubSharkAttack( int _frames )
{
2001-02-07 17:42:13 +01:00
if ( playerXDist > 0 )
2001-01-25 20:57:29 +01:00
{
m_extendDir = EXTEND_RIGHT;
}
else
{
m_extendDir = EXTEND_LEFT;
}
2001-01-25 18:19:08 +01:00
switch( m_state )
{
case SUB_SHARK_MINE_1:
{
2001-02-07 17:42:13 +01:00
if ( playerXDistSqr > 100 )
2001-01-25 18:19:08 +01:00
{
2001-02-07 17:42:13 +01:00
processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed );
2001-01-25 18:19:08 +01:00
}
else
{
// fire at player
m_salvoCount = 5;
m_state = SUB_SHARK_MINE_2;
m_movementTimer = GameState::getOneSecondInFrames() * 8;
m_controlFunc = NPC_CONTROL_MOVEMENT;
}
break;
}
case SUB_SHARK_MINE_2:
{
2001-02-07 17:42:13 +01:00
if ( playerXDistSqr > 100 )
2001-01-25 18:19:08 +01:00
{
2001-02-07 17:42:13 +01:00
processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed );
2001-01-25 18:19:08 +01:00
}
else
{
// fire at player
m_salvoCount = 5;
m_state = SUB_SHARK_CYCLE;
m_movementTimer = GameState::getOneSecondInFrames() * 8;
m_controlFunc = NPC_CONTROL_MOVEMENT;
}
break;
}
case SUB_SHARK_CYCLE:
{
// charge player
2001-02-07 17:42:13 +01:00
if ( playerXDistSqr > 100 )
2001-01-25 18:19:08 +01:00
{
2001-02-07 17:42:13 +01:00
processGenericGotoTarget( _frames, playerXDist, 0, 6 );
2001-01-25 18:19:08 +01:00
}
else
{
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_movementTimer = GameState::getOneSecondInFrames() * 8;
m_state = SUB_SHARK_MINE_1;
}
break;
}
}
}