SBSPSS/source/enemy/nmjfish.cpp

889 lines
19 KiB
C++
Raw Normal View History

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-06-15 23:24:14 +02:00
#ifndef __PROJECTL_PROJECTL_H__
#include "projectl\projectl.h"
#endif
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()
{
2001-06-15 23:24:14 +02:00
m_state = MOTHER_JELLYFISH_CYCLE;
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-07-09 17:39:09 +02:00
legsPos[0].vx = 69;
2001-06-11 21:32:41 +02:00
legsPos[0].vy = -5;
2001-07-09 17:39:09 +02:00
legsPos[1].vx = 23;
legsPos[1].vy = -10;
2001-06-11 21:32:41 +02:00
2001-07-09 17:39:09 +02:00
legsPos[2].vx = -23;
2001-06-11 21:32:41 +02:00
legsPos[2].vy = -5;
2001-07-09 17:39:09 +02:00
legsPos[3].vx = -69;
legsPos[3].vy = -10;
2001-06-11 21:32:41 +02:00
2001-06-29 18:13:24 +02:00
s16 scale;
scale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth );
2001-06-11 21:32:41 +02:00
for ( int i = 0 ; i < 4 ; i++ )
{
legs[i] = (CFXJellyFishLegs*)CFX::Create(CFX::FX_TYPE_JELLYFISH_LEGS,this);
2001-06-29 18:13:24 +02:00
legs[i]->Setup( ( legsPos[i].vx * scale ) >> 12, legsPos[i].vy, i > 1 );
legs[i]->setScale( scale );
2001-06-11 21:32:41 +02:00
}
2001-06-21 17:06:22 +02:00
m_RGB = MJ_PINK;
2001-06-15 23:24:14 +02:00
targetPos = Pos;
2001-07-03 17:02:50 +02:00
m_movementTimer = GameState::getOneSecondInFrames() * 2;
2001-06-15 23:24:14 +02:00
m_pulsateTimer = GameState::getOneSecondInFrames();
2001-06-16 16:33:00 +02:00
m_renderScale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth );
2001-07-04 23:37:51 +02:00
m_speed = m_data[m_type].speed + ( ( 2 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth );
2001-06-16 16:33:00 +02:00
m_pauseTimer = m_maxPauseTimer = ( GameState::getOneSecondInFrames() * m_health ) / m_data[m_type].initHealth;
2001-06-20 21:39:00 +02:00
m_invulnerableTimer = 0;
2001-06-21 17:06:22 +02:00
m_attackCounter = 0;
2001-07-04 23:37:51 +02:00
m_patternNum = 0;
m_patternPoint = 0;
2001-06-27 20:28:21 +02:00
2001-06-30 17:39:43 +02:00
CNpcBossEnemy::postInit();
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;
2001-05-30 00:07:28 +02:00
m_npcPath.setWaypointCount( ThisActor->PointCount - 1 );
2001-05-10 21:27:57 +02:00
newXPos = (u16) *PntList;
2001-05-30 00:07:28 +02:00
setWaypointPtr( PntList );
2001-05-10 21:27:57 +02:00
PntList++;
newYPos = (u16) *PntList;
PntList++;
setStartPos( newXPos, newYPos );
2001-05-31 18:24:48 +02:00
startX = ( newXPos << 4 ) + 8;
2001-05-16 16:06:59 +02:00
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++;
if ( pointNum == 1 )
{
setHeading( newXPos, newYPos );
}
if ( pointNum == ThisActor->PointCount - 2 )
{
2001-05-31 18:24:48 +02:00
startX = ( newXPos << 4 ) + 8;
2001-05-10 21:27:57 +02:00
m_base.vx = startX;
2001-05-31 18:24:48 +02:00
m_base.vy = ( newYPos << 4 ) + 16;
2001-05-10 21:27:57 +02:00
}
else if ( pointNum == ThisActor->PointCount - 1 )
{
2001-05-31 18:24:48 +02:00
m_cycleWidth = abs( startX - ( ( newXPos << 4 ) + 8 ) );
2001-05-10 21:27:57 +02:00
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-06-19 22:07:57 +02:00
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
m_thinkArea.x1 = minX;
m_thinkArea.x2 = maxX;
m_thinkArea.y1 = minY;
m_thinkArea.y2 = maxY;
2001-07-04 23:37:51 +02:00
// setup patterns
m_pattern[0][0].vx = minX;
m_pattern[0][0].vy = maxY;
m_pattern[0][1].vx = maxX;
m_pattern[0][1].vy = maxY;
m_pattern[0][2].vx = minX;
m_pattern[0][2].vy = maxY;
m_pattern[0][3].vx = maxX;
m_pattern[0][3].vy = maxY;
m_pattern[1][0].vx = minX;
m_pattern[1][0].vy = minY;
m_pattern[1][1].vx = maxX;
m_pattern[1][1].vy = maxY;
m_pattern[1][2].vx = maxX;
m_pattern[1][2].vy = minY;
m_pattern[1][3].vx = minX;
m_pattern[1][3].vy = maxY;
m_pattern[2][0].vx = maxX;
m_pattern[2][0].vy = minY;
m_pattern[2][1].vx = maxX;
m_pattern[2][1].vy = maxY;
m_pattern[2][2].vx = minX;
m_pattern[2][2].vy = maxY;
m_pattern[2][3].vx = minX;
m_pattern[2][3].vy = minY;
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
{
2001-06-20 21:39:00 +02:00
if ( m_invulnerableTimer > 0 )
{
m_invulnerableTimer -= _frames;
}
2001-06-16 16:33:00 +02:00
switch( m_state )
2001-06-15 23:24:14 +02:00
{
2001-06-16 16:33:00 +02:00
case MOTHER_JELLYFISH_CYCLE:
2001-06-15 23:24:14 +02:00
{
2001-06-16 16:33:00 +02:00
if ( m_movementTimer <= 0 )
2001-06-16 00:05:32 +02:00
{
2001-06-16 16:33:00 +02:00
if ( m_pulsateTimer <= 0 )
{
if ( m_pauseTimer <= 0 )
{
// fire at player
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
s16 heading = ratan2( playerYDist, playerXDist ) & 4095;
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
CProjectile *projectile;
projectile = CProjectile::Create();
DVECTOR newPos = Pos;
projectile->init( newPos, heading );
projectile->setGraphic( FRM__LIGHTNING1 );
2001-07-02 21:02:46 +02:00
projectile->setSpeed( 6 );
projectile->setXScale( 8192 );
2001-06-15 23:24:14 +02:00
2001-07-03 17:02:50 +02:00
m_movementTimer = GameState::getOneSecondInFrames() * 2;
2001-06-16 16:33:00 +02:00
m_pulsateTimer = GameState::getOneSecondInFrames();
m_pauseTimer = m_maxPauseTimer;
2001-06-21 17:06:22 +02:00
m_RGB = MJ_PINK;
2001-07-04 23:37:51 +02:00
/*m_attackCounter++;
2001-06-21 17:06:22 +02:00
2001-07-04 23:37:51 +02:00
if ( m_attackCounter > 8 )
2001-06-21 17:06:22 +02:00
{
m_attackCounter = 0;
m_state = MOTHER_JELLYFISH_STRAFE_START;
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
targetPos.vx = minX;
targetPos.vy = minY;
2001-07-04 23:37:51 +02:00
}*/
2001-06-16 16:33:00 +02:00
}
else
{
2001-06-21 17:06:22 +02:00
if ( m_RGB == MJ_PINK )
{
m_RGB = MJ_WHITE;
}
else
{
m_RGB = MJ_PINK;
}
2001-06-16 16:33:00 +02:00
m_pauseTimer -= _frames;
2001-07-12 22:37:28 +02:00
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_JELLYFISH_ATTACK, true );
}
2001-06-16 16:33:00 +02:00
}
}
else
{
m_pulsateTimer -= _frames;
m_renderScale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth );
m_renderScale += ( ( 256 * rsin( ( ( m_pulsateTimer << 14 ) / GameState::getOneSecondInFrames() ) & 4095 ) ) >> 12 );
2001-07-12 22:37:28 +02:00
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_NAUTILUS_ATTACK, true );
}
2001-06-16 16:33:00 +02:00
}
2001-06-16 00:05:32 +02:00
}
else
{
2001-06-16 16:33:00 +02:00
m_movementTimer -= _frames;
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
s32 distX, distY;
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
distX = targetPos.vx - Pos.vx;
distY = targetPos.vy - Pos.vy;
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
if( abs( distX ) < 10 && abs( distY ) < 10 )
{
2001-07-04 23:37:51 +02:00
m_patternPoint++;
if ( m_patternPoint > 3 )
{
m_state = MOTHER_JELLYFISH_STRAFE_START;
2001-06-15 23:24:14 +02:00
2001-07-04 23:37:51 +02:00
s32 minX, maxX, minY, maxY;
2001-06-15 23:24:14 +02:00
2001-07-04 23:37:51 +02:00
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
targetPos.vx = minX;
targetPos.vy = minY;
}
else
{
targetPos.vx = m_pattern[m_patternNum][m_patternPoint].vx;
targetPos.vy = m_pattern[m_patternNum][m_patternPoint].vy;
}
2001-06-16 16:33:00 +02:00
}
else
{
processGenericGotoTarget( _frames, distX, distY, m_speed );
}
2001-07-12 22:37:28 +02:00
if ( m_movementTimer > 0 )
{
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_JELLYFISH_MOVE, true );
}
}
else
{
if ( m_soundId != NOT_PLAYING )
{
CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId );
m_soundId = NOT_PLAYING;
}
}
2001-06-16 16:33:00 +02:00
}
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
break;
2001-06-15 23:24:14 +02:00
}
2001-06-16 16:33:00 +02:00
case MOTHER_JELLYFISH_BEGIN_CIRCLE:
{
s32 distX, distY;
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
distX = playerXDist + 70;
distY = playerYDist;
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
if ( abs( distX ) > 10 || abs( distY ) > 10 )
2001-06-15 23:24:14 +02:00
{
2001-06-16 16:33:00 +02:00
processGenericGotoTarget( _frames, distX, distY, m_speed );
2001-06-15 23:24:14 +02:00
}
else
{
2001-06-16 16:33:00 +02:00
m_state = MOTHER_JELLYFISH_CIRCLE;
m_extension = 0;
2001-06-15 23:24:14 +02:00
}
2001-07-12 22:37:28 +02:00
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_JELLYFISH_MOVE, true );
}
2001-06-16 16:33:00 +02:00
break;
}
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
case MOTHER_JELLYFISH_CIRCLE:
{
m_extension += 64 * _frames;
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
if ( m_extension < 3072 )
2001-06-15 23:24:14 +02:00
{
2001-06-16 16:33:00 +02:00
CPlayer *player = GameScene.getPlayer();
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
DVECTOR playerPos = player->getPos();
Pos.vx = playerPos.vx + ( ( 70 * rcos( m_extension ) ) >> 12 );
Pos.vy = playerPos.vy + ( ( 70 * rsin( m_extension ) ) >> 12 );
2001-06-15 23:24:14 +02:00
}
else
{
2001-06-16 16:33:00 +02:00
m_state = MOTHER_JELLYFISH_EXIT;
2001-06-15 23:24:14 +02:00
}
2001-07-12 22:37:28 +02:00
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_JELLYFISH_MOVE, true );
}
2001-06-16 16:33:00 +02:00
break;
}
2001-06-15 23:24:14 +02:00
2001-06-16 16:33:00 +02:00
case MOTHER_JELLYFISH_EXIT:
{
Pos.vx += 8 * _frames;
DVECTOR offset = CLevel::getCameraPos();
if ( Pos.vx - offset.vx > VidGetScrW() )
2001-06-15 23:24:14 +02:00
{
2001-06-16 16:33:00 +02:00
m_isActive = false;
setToShutdown();
2001-06-25 16:14:08 +02:00
CGameScene::setBossHasBeenKilled();
2001-06-15 23:24:14 +02:00
}
2001-07-12 22:37:28 +02:00
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_JELLYFISH_MOVE, true );
}
2001-06-16 16:33:00 +02:00
break;
2001-06-15 23:24:14 +02:00
}
2001-06-21 17:06:22 +02:00
case MOTHER_JELLYFISH_STRAFE_START:
{
s32 distX, distY;
distX = targetPos.vx - Pos.vx;
distY = targetPos.vy - Pos.vy;
if( abs( distX ) < 10 && abs( distY ) < 10 )
{
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
targetPos.vx = maxX;
targetPos.vy = minY;
m_state = MOTHER_JELLYFISH_STRAFE;
}
else
{
processGenericGotoTarget( _frames, distX, distY, m_speed );
}
2001-07-12 22:37:28 +02:00
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_JELLYFISH_MOVE, true );
}
2001-06-21 17:06:22 +02:00
break;
}
case MOTHER_JELLYFISH_STRAFE:
{
if ( m_RGB == MJ_PINK )
{
m_RGB = MJ_WHITE;
}
else
{
m_RGB = MJ_PINK;
}
2001-07-12 22:37:28 +02:00
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_JELLYFISH_ATTACK, true );
}
2001-06-21 17:06:22 +02:00
s32 distX, distY;
distX = targetPos.vx - Pos.vx;
distY = targetPos.vy - Pos.vy;
if( abs( distX ) < 10 && abs( distY ) < 10 )
{
2001-07-04 23:37:51 +02:00
m_patternNum = getRnd() % 3;
m_patternPoint = 0;
2001-06-21 17:06:22 +02:00
2001-07-04 23:37:51 +02:00
targetPos.vx = m_pattern[m_patternNum][m_patternPoint].vx;
targetPos.vy = m_pattern[m_patternNum][m_patternPoint].vy;
2001-06-21 17:06:22 +02:00
m_state = MOTHER_JELLYFISH_CYCLE;
m_RGB = MJ_PINK;
}
else
{
processGenericGotoTarget( _frames, distX, distY, m_speed );
}
break;
}
2001-06-15 23:24:14 +02:00
}
/*s32 xDist, yDist;
2001-01-25 16:30:11 +01:00
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-06-15 23:24:14 +02:00
}*/
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::processClose( int _frames )
2001-01-25 16:30:11 +01:00
{
2001-06-15 23:24:14 +02:00
/*switch( m_state )
2001-03-12 20:14:38 +01:00
{
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;
2001-06-01 18:30:37 +02:00
CSoundMediator::playSfx( CSoundMediator::SFX_JELLYFISH_ATTACK );
2001-03-12 20:14:38 +01:00
}
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
2001-06-15 23:24:14 +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
2001-06-15 23:24:14 +02:00
//spawnJellyfish( _frames );
2001-03-12 20:14:38 +01:00
}
else
{
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_state++;
}
}
break;
}
2001-06-15 23:24:14 +02: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()
{
2001-07-06 16:55:58 +02:00
CLevel::setIsBossRespawn( true );
2001-05-04 23:58:41 +02:00
if ( m_isActive )
{
CLevel::setBossHealth( m_health );
}
2001-07-06 16:55:58 +02:00
else
{
CLevel::setBossHealth( 0 );
}
2001-05-04 23:58:41 +02:00
2001-07-05 16:39:00 +02:00
for ( int i = 0 ; i < 4 ; i++ )
{
legs[i]->killFX();
}
2001-06-30 17:39:43 +02:00
CNpcBossEnemy::shutdown();
2001-05-04 23:58:41 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-06-15 23:24:14 +02:00
/*void CNpcMotherJellyfishEnemy::spawnJellyfish( int _frames )
2001-05-04 22:11:44 +02:00
{
if ( m_jellyfishCount )
{
if ( m_spawnTimer > 0 )
{
m_spawnTimer -= _frames;
}
else
{
CNpcEnemy *enemy;
2001-06-14 18:07:48 +02:00
enemy = CNpcEnemy::Create( NPC_PROJECTILE_JELLYFISH );
2001-05-04 22:11:44 +02:00
enemy->setStartPos( Pos.vx >> 4, ( Pos.vy + 20 ) >> 4 );
2001-05-30 00:07:28 +02:00
enemy->setWaypointCount( m_npcPath.getWaypointCount() );
enemy->setWaypointPtr( m_npcPath.getWaypointPtr() );
2001-05-04 22:11:44 +02:00
enemy->setPathType( CNpcPath::PONG_PATH );
enemy->postInit();
m_jellyfishCount--;
m_spawnTimer = 1 * GameState::getOneSecondInFrames();
}
}
2001-06-15 23:24:14 +02:00
}*/
2001-05-04 22:11:44 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);
2001-06-15 23:24:14 +02:00
m_actorGfx->RotateScale( SprFrame, renderPos, 0, m_renderScale, m_renderScale );
2001-05-14 23:08:03 +02:00
2001-06-21 17:06:22 +02:00
setRGB0( SprFrame, ( m_RGB & 255 ), ( ( m_RGB >> 8 ) & 255 ), ( ( m_RGB >> 16 ) & 255 ) );
2001-05-14 23:08:03 +02:00
sBBox boundingBox = m_actorGfx->GetBBox();
2001-07-11 15:58:48 +02:00
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) << 1 );
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( ( boundingBox.YMax + boundingBox.YMin ) >> 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
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-06-11 21:32:41 +02:00
/*void CNpcMotherJellyfishEnemy::processUserCollision( CThing *thisThing )
{
}*/
void CNpcMotherJellyfishEnemy::processShot( int _frames )
2001-05-10 01:14:35 +02:00
{
2001-06-11 21:32:41 +02:00
s16 scale;
2001-06-15 23:24:14 +02:00
scale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth );
2001-06-11 21:32:41 +02:00
for ( int i = 0 ; i < 4 ; i++ )
{
2001-06-15 23:24:14 +02:00
legs[i]->Setup( ( legsPos[i].vx * scale ) >> 12, legsPos[i].vy, i > 1 );
legs[i]->setScale( scale );
2001-06-11 21:32:41 +02:00
}
2001-06-11 23:00:35 +02:00
switch ( m_state )
{
case NPC_GENERIC_HIT_CHECK_HEALTH:
{
if ( m_health > 0 )
{
m_health -= 5;
2001-06-15 23:24:14 +02:00
m_renderScale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth );
2001-07-04 23:37:51 +02:00
m_speed = m_data[m_type].speed + ( ( 2 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth );
2001-06-16 00:05:32 +02:00
m_maxPauseTimer = ( GameState::getOneSecondInFrames() * m_health ) / m_data[m_type].initHealth;
2001-06-11 23:00:35 +02:00
2001-06-16 16:33:00 +02:00
m_state = MOTHER_JELLYFISH_CYCLE;
}
else
{
m_state = MOTHER_JELLYFISH_BEGIN_CIRCLE;
}
2001-06-11 23:00:35 +02:00
2001-06-16 16:33:00 +02:00
m_controlFunc = NPC_CONTROL_MOVEMENT;
2001-06-27 18:04:14 +02:00
m_RGB = MJ_PINK;
2001-06-11 23:00:35 +02:00
2001-06-20 21:39:00 +02:00
m_invulnerableTimer = 2 * GameState::getOneSecondInFrames();
2001-06-11 23:00:35 +02:00
break;
}
2001-06-16 16:33:00 +02:00
}
}
2001-06-11 23:00:35 +02:00
2001-06-16 16:33:00 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-06-11 23:00:35 +02:00
2001-06-16 16:33:00 +02:00
void CNpcMotherJellyfishEnemy::collidedWith(CThing *_thisThing)
{
2001-07-03 17:02:50 +02:00
switch( m_state )
2001-06-16 16:33:00 +02:00
{
2001-07-03 17:02:50 +02:00
case MOTHER_JELLYFISH_CYCLE:
case MOTHER_JELLYFISH_STRAFE_START:
case MOTHER_JELLYFISH_STRAFE:
2001-06-20 21:39:00 +02:00
{
2001-07-03 17:02:50 +02:00
if ( m_isActive && !m_isCaught && !m_isDying )
2001-06-20 21:39:00 +02:00
{
2001-07-03 17:02:50 +02:00
switch(_thisThing->getThingType())
2001-06-20 21:39:00 +02:00
{
2001-07-03 17:02:50 +02:00
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
ATTACK_STATE playerState = player->getAttackState();
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
if(playerState==ATTACK_STATE__NONE)
2001-06-20 21:39:00 +02:00
{
2001-07-03 17:02:50 +02:00
if ( !player->isRecoveringFromHit() )
2001-06-20 21:39:00 +02:00
{
2001-07-03 17:02:50 +02:00
switch( m_data[m_type].detectCollision )
2001-06-20 21:39:00 +02:00
{
2001-07-03 17:02:50 +02:00
case DETECT_NO_COLLISION:
{
// ignore
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
break;
}
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
case DETECT_ALL_COLLISION:
{
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
processUserCollision( _thisThing );
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
break;
}
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
case DETECT_ATTACK_COLLISION_GENERIC:
{
processAttackCollision();
processUserCollision( _thisThing );
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
break;
}
2001-06-20 21:39:00 +02:00
}
}
}
2001-07-03 17:02:50 +02:00
else if ( m_invulnerableTimer <= 0 )
2001-06-20 21:39:00 +02:00
{
2001-07-03 17:02:50 +02:00
// player is attacking, respond appropriately
if ( m_controlFunc != NPC_CONTROL_SHOT )
2001-06-20 21:39:00 +02:00
{
2001-07-03 17:02:50 +02:00
if(playerState==ATTACK_STATE__BUTT_BOUNCE)
{
player->justButtBouncedABadGuy();
}
m_controlFunc = NPC_CONTROL_SHOT;
m_state = NPC_GENERIC_HIT_CHECK_HEALTH;
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
drawAttackEffect();
}
2001-06-20 21:39:00 +02:00
}
2001-07-03 17:02:50 +02:00
break;
2001-06-20 21:39:00 +02:00
}
2001-07-03 17:02:50 +02:00
case TYPE_ENEMY:
{
CNpcEnemy *enemy = (CNpcEnemy *) _thisThing;
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
if ( canCollideWithEnemy() && enemy->canCollideWithEnemy() )
{
processEnemyCollision( _thisThing );
}
2001-06-20 21:39:00 +02:00
2001-07-03 17:02:50 +02:00
break;
2001-06-20 21:39:00 +02:00
}
2001-07-03 17:02:50 +02:00
default:
ASSERT(0);
break;
2001-06-20 21:39:00 +02:00
}
}
2001-07-03 17:02:50 +02:00
break;
2001-06-20 21:39:00 +02:00
}
2001-06-11 23:00:35 +02:00
}
}