2001-01-25 16:30:11 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
2001-04-20 22:22:16 +02:00
|
|
|
nmjfish.cpp
|
2001-01-25 16:30:11 +01:00
|
|
|
|
|
|
|
Author: CRB
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
#ifndef __ENEMY_NPC_H__
|
|
|
|
#include "enemy\npc.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-20 22:22:16 +02:00
|
|
|
#ifndef __ENEMY_NMJFISH_H__
|
|
|
|
#include "enemy\nmjfish.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-04 22:11:44 +02:00
|
|
|
#ifndef __ENEMY_NPROJJF_H__
|
|
|
|
#include "enemy\nprojjf.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-03 23:39:27 +02:00
|
|
|
#ifndef __VID_HEADER_
|
|
|
|
#include "system\vid.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-10 21:27:57 +02:00
|
|
|
#ifndef __UTILS_HEADER__
|
|
|
|
#include "utils\utils.h"
|
|
|
|
#endif
|
|
|
|
|
2001-01-25 16:30:11 +01:00
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
|
|
#include "player\player.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-06 00:21:30 +02:00
|
|
|
#include "fx\fx.h"
|
|
|
|
#include "fx\fxjfish.h"
|
|
|
|
|
|
|
|
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-05-04 22:11:44 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-20 22:22:16 +02:00
|
|
|
void CNpcMotherJellyfishEnemy::postInit()
|
|
|
|
{
|
|
|
|
m_state = MOTHER_JELLYFISH_RETURN_TO_START_1;
|
2001-05-04 22:11:44 +02:00
|
|
|
m_spawnTimer = 0;
|
2001-05-04 23:58:41 +02:00
|
|
|
|
|
|
|
if ( CLevel::getIsBossRespawn() )
|
|
|
|
{
|
|
|
|
m_health = CLevel::getBossHealth();
|
|
|
|
}
|
2001-05-06 00:21:30 +02:00
|
|
|
|
2001-05-12 01:52:38 +02:00
|
|
|
// CFXJellyFishLegs *T=(CFXJellyFishLegs*)CFX::Create(CFX::FX_TYPE_JELLYFISH_LEGS,this);
|
|
|
|
// T->SetUp(128,4,8,16);
|
2001-04-20 22:22:16 +02:00
|
|
|
}
|
|
|
|
|
2001-05-04 22:11:44 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-10 21:27:57 +02:00
|
|
|
void CNpcMotherJellyfishEnemy::setupWaypoints( sThingActor *ThisActor )
|
|
|
|
{
|
|
|
|
u16 *PntList=(u16*)MakePtr(ThisActor,sizeof(sThingActor));
|
|
|
|
|
|
|
|
u16 newXPos, newYPos;
|
|
|
|
|
|
|
|
s32 startX = 0;
|
|
|
|
|
|
|
|
newXPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
newYPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
|
|
|
|
setStartPos( newXPos, newYPos );
|
|
|
|
addWaypoint( newXPos, newYPos );
|
|
|
|
|
2001-05-16 16:06:59 +02:00
|
|
|
startX = newXPos << 4;
|
|
|
|
|
2001-05-10 21:27:57 +02:00
|
|
|
if ( ThisActor->PointCount > 1 )
|
|
|
|
{
|
|
|
|
for (int pointNum = 1 ; pointNum < ThisActor->PointCount ; pointNum++ )
|
|
|
|
{
|
|
|
|
newXPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
newYPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
|
|
|
|
addWaypoint( newXPos, newYPos );
|
|
|
|
|
|
|
|
if ( pointNum == 1 )
|
|
|
|
{
|
|
|
|
setHeading( newXPos, newYPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pointNum == ThisActor->PointCount - 2 )
|
|
|
|
{
|
|
|
|
startX = newXPos << 4;
|
|
|
|
m_base.vx = startX;
|
|
|
|
m_base.vy = newYPos << 4;
|
|
|
|
}
|
|
|
|
else if ( pointNum == ThisActor->PointCount - 1 )
|
|
|
|
{
|
|
|
|
m_cycleWidth = abs( startX - ( newXPos << 4 ) );
|
|
|
|
m_halfCycleWidth = m_cycleWidth >> 1;
|
2001-05-16 16:06:59 +02:00
|
|
|
m_base.vx += m_halfCycleWidth;
|
2001-05-10 21:27:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-20 22:22:16 +02:00
|
|
|
void CNpcMotherJellyfishEnemy::processMovement( int _frames )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
|
|
|
s32 xDist, yDist;
|
|
|
|
s32 xDistSqr, yDistSqr;
|
|
|
|
|
|
|
|
switch( m_state )
|
|
|
|
{
|
2001-03-12 20:14:38 +01:00
|
|
|
case MOTHER_JELLYFISH_RETURN_TO_START_1:
|
|
|
|
case MOTHER_JELLYFISH_RETURN_TO_START_2:
|
|
|
|
case MOTHER_JELLYFISH_RETURN_TO_START_3:
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-05-10 21:27:57 +02:00
|
|
|
xDist = m_base.vx - this->Pos.vx - m_halfCycleWidth;
|
2001-01-25 16:30:11 +01:00
|
|
|
xDistSqr = xDist * xDist;
|
|
|
|
yDist = m_base.vy - this->Pos.vy;
|
|
|
|
yDistSqr = yDist * yDist;
|
|
|
|
|
|
|
|
if ( xDistSqr + yDistSqr > 100 )
|
|
|
|
{
|
2001-05-09 23:27:23 +02:00
|
|
|
processGenericGotoTarget( _frames, xDist, yDist, m_speed );
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// have arrived at base position
|
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() * 10;
|
|
|
|
m_state++;
|
2001-05-10 21:27:57 +02:00
|
|
|
m_extension = -m_halfCycleWidth;
|
2001-01-25 16:30:11 +01:00
|
|
|
m_extendDir = EXTEND_RIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
case MOTHER_JELLYFISH_CYCLE_1:
|
|
|
|
case MOTHER_JELLYFISH_CYCLE_2:
|
|
|
|
case MOTHER_JELLYFISH_CYCLE_3:
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-03-12 20:14:38 +01:00
|
|
|
m_movementTimer -= _frames;
|
|
|
|
|
|
|
|
s32 xExtension;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
if ( m_extendDir == EXTEND_RIGHT )
|
|
|
|
{
|
2001-05-10 21:27:57 +02:00
|
|
|
if ( m_extension < m_halfCycleWidth )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-03-12 20:14:38 +01:00
|
|
|
m_extension += 3 * _frames;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-05-10 21:27:57 +02:00
|
|
|
xExtension = ( m_halfCycleWidth * rsin( ( m_extension << 10 ) / m_halfCycleWidth ) ) >> 12;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
Pos.vx = m_base.vx + xExtension;
|
2001-05-10 21:27:57 +02:00
|
|
|
Pos.vy = m_base.vy - ( ( 50 * rsin( ( xExtension << 12 ) / m_cycleWidth ) ) >> 12 );
|
2001-03-12 20:14:38 +01:00
|
|
|
|
|
|
|
m_heading = 0;
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-12 20:14:38 +01:00
|
|
|
m_extendDir = EXTEND_LEFT;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
if ( m_movementTimer < 0 )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-03-12 20:14:38 +01:00
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
m_state++;
|
2001-05-04 22:11:44 +02:00
|
|
|
m_jellyfishCount = 3;
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-10 21:27:57 +02:00
|
|
|
if ( m_extension > -m_halfCycleWidth )
|
2001-03-12 20:14:38 +01:00
|
|
|
{
|
|
|
|
m_extension -= 3 * _frames;
|
|
|
|
|
2001-05-10 21:27:57 +02:00
|
|
|
xExtension = ( m_halfCycleWidth * rsin( ( m_extension << 10 ) / m_halfCycleWidth ) ) >> 12;
|
2001-03-12 20:14:38 +01:00
|
|
|
|
|
|
|
Pos.vx = m_base.vx + xExtension;
|
2001-05-10 21:27:57 +02:00
|
|
|
Pos.vy = m_base.vy + ( ( 50 * rsin( ( xExtension << 12 ) / m_cycleWidth ) ) >> 12 );
|
2001-03-12 20:14:38 +01:00
|
|
|
|
|
|
|
m_heading = 2048;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_RIGHT;
|
|
|
|
|
|
|
|
if ( m_movementTimer < 0 )
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
m_state++;
|
2001-05-04 22:11:44 +02:00
|
|
|
m_jellyfishCount = 3;
|
2001-03-12 20:14:38 +01:00
|
|
|
}
|
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-04 22:11:44 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-20 22:22:16 +02:00
|
|
|
void CNpcMotherJellyfishEnemy::processClose( int _frames )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-03-12 20:14:38 +01:00
|
|
|
switch( m_state )
|
|
|
|
{
|
|
|
|
case MOTHER_JELLYFISH_ATTACK_PLAYER_SHOCK:
|
|
|
|
{
|
|
|
|
// seek position above user
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
CPlayer *player = GameScene.getPlayer();
|
|
|
|
DVECTOR playerPos = player->getPos();
|
|
|
|
DVECTOR seekPos;
|
|
|
|
s32 xDist, yDist;
|
|
|
|
s32 xDistSqr, yDistSqr;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
seekPos = playerPos;
|
|
|
|
seekPos.vy -= 100;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
xDist = seekPos.vx - this->Pos.vx;
|
|
|
|
xDistSqr = xDist * xDist;
|
|
|
|
yDist = seekPos.vy - this->Pos.vy;
|
|
|
|
yDistSqr = yDist * yDist;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-03-12 20:14:38 +01:00
|
|
|
if ( xDistSqr + yDistSqr > 400 )
|
|
|
|
{
|
2001-05-09 23:27:23 +02:00
|
|
|
processGenericGotoTarget( _frames, xDist, yDist, m_speed );
|
2001-03-12 20:14:38 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fire at user
|
|
|
|
|
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
|
|
|
m_state = MOTHER_JELLYFISH_RETURN_TO_START_1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
s32 xExtension;
|
|
|
|
|
|
|
|
if ( m_extendDir == EXTEND_RIGHT )
|
|
|
|
{
|
2001-05-10 21:27:57 +02:00
|
|
|
if ( m_extension < m_halfCycleWidth )
|
2001-03-12 20:14:38 +01:00
|
|
|
{
|
|
|
|
m_extension += 3 * _frames;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-05-10 21:27:57 +02:00
|
|
|
xExtension = ( m_halfCycleWidth * rsin( ( m_extension << 10 ) / m_halfCycleWidth ) ) >> 12;
|
2001-03-12 20:14:38 +01:00
|
|
|
|
|
|
|
Pos.vx = m_base.vx + xExtension;
|
2001-05-10 21:27:57 +02:00
|
|
|
Pos.vy = m_base.vy - ( ( 50 * rcos( ( xExtension << 11 ) / m_cycleWidth ) ) >> 12 );
|
2001-03-12 20:14:38 +01:00
|
|
|
|
|
|
|
m_heading = 0;
|
2001-05-04 22:11:44 +02:00
|
|
|
|
|
|
|
spawnJellyfish( _frames );
|
2001-03-12 20:14:38 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
|
|
|
m_state++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-10 21:27:57 +02:00
|
|
|
if ( m_extension > -m_halfCycleWidth )
|
2001-03-12 20:14:38 +01:00
|
|
|
{
|
|
|
|
m_extension -= 3 * _frames;
|
|
|
|
|
2001-05-10 21:27:57 +02:00
|
|
|
xExtension = ( m_halfCycleWidth * rsin( ( m_extension << 10 ) / m_halfCycleWidth ) ) >> 12;
|
2001-03-12 20:14:38 +01:00
|
|
|
|
|
|
|
Pos.vx = m_base.vx + xExtension;
|
2001-05-10 21:27:57 +02:00
|
|
|
Pos.vy = m_base.vy + ( ( 50 * rcos( ( xExtension << 11 ) / m_cycleWidth ) ) >> 12 );
|
2001-03-12 20:14:38 +01:00
|
|
|
|
|
|
|
m_heading = 2048;
|
2001-05-04 22:11:44 +02:00
|
|
|
|
|
|
|
spawnJellyfish( _frames );
|
2001-03-12 20:14:38 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
|
|
|
m_state++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
2001-05-03 23:39:27 +02:00
|
|
|
}
|
|
|
|
|
2001-05-04 01:59:30 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-04 23:58:41 +02:00
|
|
|
void CNpcMotherJellyfishEnemy::shutdown()
|
|
|
|
{
|
|
|
|
if ( m_isActive )
|
|
|
|
{
|
|
|
|
CLevel::setIsBossRespawn( true );
|
|
|
|
CLevel::setBossHealth( m_health );
|
|
|
|
}
|
|
|
|
|
|
|
|
CNpcEnemy::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-04 22:11:44 +02:00
|
|
|
void CNpcMotherJellyfishEnemy::spawnJellyfish( int _frames )
|
|
|
|
{
|
|
|
|
if ( m_jellyfishCount )
|
|
|
|
{
|
|
|
|
if ( m_spawnTimer > 0 )
|
|
|
|
{
|
|
|
|
m_spawnTimer -= _frames;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CNpcEnemy *enemy;
|
|
|
|
enemy = new( "jellyfish projectile" ) CNpcSmallJellyfishProjectileEnemy;
|
|
|
|
ASSERT(enemy);
|
|
|
|
enemy->setType( CNpcEnemy::NPC_PROJECTILE_JELLYFISH );
|
|
|
|
enemy->init();
|
|
|
|
enemy->setLayerCollision( m_layerCollision );
|
|
|
|
enemy->setStartPos( Pos.vx >> 4, ( Pos.vy + 20 ) >> 4 );
|
|
|
|
|
|
|
|
CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList();
|
|
|
|
|
|
|
|
if ( sourceWaypoint )
|
|
|
|
{
|
|
|
|
while( sourceWaypoint )
|
|
|
|
{
|
|
|
|
enemy->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 );
|
|
|
|
sourceWaypoint = sourceWaypoint->nextWaypoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enemy->setPathType( CNpcPath::PONG_PATH );
|
|
|
|
enemy->postInit();
|
|
|
|
|
|
|
|
m_jellyfishCount--;
|
|
|
|
|
|
|
|
m_spawnTimer = 1 * GameState::getOneSecondInFrames();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-04 01:59:30 +02:00
|
|
|
void CNpcMotherJellyfishEnemy::render()
|
2001-05-03 23:39:27 +02:00
|
|
|
{
|
|
|
|
SprFrame = NULL;
|
|
|
|
|
|
|
|
if ( m_isActive )
|
|
|
|
{
|
|
|
|
CEnemyThing::render();
|
|
|
|
|
2001-05-14 23:08:03 +02:00
|
|
|
if (canRender())
|
2001-05-03 23:39:27 +02:00
|
|
|
{
|
2001-05-14 23:08:03 +02:00
|
|
|
DVECTOR &renderPos=getRenderPos();
|
2001-05-04 01:59:30 +02:00
|
|
|
|
2001-05-14 23:08:03 +02:00
|
|
|
SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),false);
|
|
|
|
m_actorGfx->RotateScale( SprFrame, renderPos, 0, 8192, 8192 );
|
|
|
|
|
|
|
|
sBBox boundingBox = m_actorGfx->GetBBox();
|
|
|
|
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
|
|
|
|
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
|
2001-05-03 23:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
2001-05-04 01:59:30 +02:00
|
|
|
}
|
2001-05-10 01:14:35 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcMotherJellyfishEnemy::processUserCollision( CThing *thisThing )
|
|
|
|
{
|
|
|
|
}
|