SBSPSS/source/enemy/nsshark.cpp

850 lines
17 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
2001-04-20 22:22:16 +02:00
#ifndef __ENEMY_NSSHARK_H__
#include "enemy\nsshark.h"
#endif
2001-01-25 18:19:08 +01:00
#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
2001-02-28 22:05:39 +01:00
#ifndef __ANIM_SHARKSUB_HEADER__
2001-05-03 23:39:27 +02:00
#include <ACTOR_SHARKSUB_ANIM.h>
2001-02-28 22:05:39 +01:00
#endif
2001-06-11 23:49:49 +02:00
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
2001-06-21 17:51:28 +02:00
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
2001-06-18 21:06:43 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
#endif
2001-06-11 23:49:49 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-02-28 22:05:39 +01:00
2001-04-20 22:22:16 +02:00
void CNpcSubSharkEnemy::postInit()
{
m_state = SUB_SHARK_MINE_1;
m_extendDir = EXTEND_RIGHT;
2001-05-03 23:39:27 +02:00
m_npcPath.setPathType( CNpcPath::PONG_PATH );
2001-05-16 21:04:40 +02:00
m_salvoCount = 0;
2001-06-16 17:43:04 +02:00
if ( CLevel::getIsBossRespawn() )
{
m_health = CLevel::getBossHealth();
m_speed = m_data[m_type].speed + ( ( 3 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth );
}
2001-06-20 21:39:00 +02:00
m_invulnerableTimer = 0;
2001-06-21 17:51:28 +02:00
m_timerTimer = 0;
m_salvoCount = 5;
2001-07-03 22:49:30 +02:00
m_carryPlayer = false;
2001-06-21 17:51:28 +02:00
m_movementTimer = GameState::getOneSecondInFrames() * ( 1 + ( ( 7 * m_health ) / m_data[m_type].initHealth ) );
2001-06-27 20:28:21 +02:00
2001-06-30 17:39:43 +02:00
CNpcBossEnemy::postInit();
2001-06-20 21:39:00 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSubSharkEnemy::think( int _frames )
{
if ( m_invulnerableTimer > 0 )
{
m_invulnerableTimer -= _frames;
}
CNpcEnemy::think( _frames );
2001-04-20 22:22:16 +02:00
}
2001-06-11 23:49:49 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-20 22:22:16 +02:00
void CNpcSubSharkEnemy::processMovement( int _frames )
2001-01-25 18:19:08 +01:00
{
2001-06-21 17:51:28 +02:00
if ( m_movementTimer > 0 )
{
m_movementTimer -= _frames;
}
switch( m_state )
{
case SUB_SHARK_MINE_1:
{
if ( !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_SHARKSUB_SWIM;
m_frame = 0;
}
if ( m_timerTimer <= 0 )
{
if ( m_salvoCount > 0 )
{
// drop mine
CProjectile *projectile;
projectile = CProjectile::Create();
projectile->init( Pos, 1024, CProjectile::PROJECTILE_MINE, CProjectile::PROJECTILE_FINITE_LIFE );
projectile->setGraphic( FRM__SHARKMINE );
m_salvoCount--;
m_timerTimer = ( GameState::getOneSecondInFrames() >> 2 ) * ( 1 + ( ( 3 * m_health ) / m_data[m_type].initHealth ) );
}
}
if ( m_movementTimer <= 0 && m_salvoCount <= 0 )
{
m_state++;
m_timerTimer = 0;
m_movementTimer = GameState::getOneSecondInFrames() * ( 1 + ( ( 7 * m_health ) / m_data[m_type].initHealth ) );
m_salvoCount = 5;
if ( m_state == SUB_SHARK_GOTO_CHARGE )
{
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
m_targetPos.vx = minX;
m_targetPos.vy = minY;
}
}
s32 moveX = 0, moveY = 0;
s32 moveVel = 0;
s32 moveDist = 0;
processGenericFixedPathMove( _frames, &moveX, &moveY, &moveVel, &moveDist );
if ( moveX > 0 )
{
m_extendDir = EXTEND_RIGHT;
}
else
{
m_extendDir = EXTEND_LEFT;
}
Pos.vx += moveX;
Pos.vy += moveY;
break;
}
case SUB_SHARK_GOTO_CHARGE:
{
if ( !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_SHARKSUB_SWIM;
m_frame = 0;
}
s32 distX, distY;
distX = m_targetPos.vx - Pos.vx;
distY = m_targetPos.vy - Pos.vy;
if ( distX > 0 )
{
m_extendDir = EXTEND_RIGHT;
}
else
{
m_extendDir = EXTEND_LEFT;
}
if( abs( distX ) < 10 && abs( distY ) < 10 )
{
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
m_targetPos.vx = minX;
m_targetPos.vy = maxY;
m_state = SUB_SHARK_DROP;
}
else
{
processGenericGotoTarget( _frames, distX, distY, m_speed );
}
break;
}
case SUB_SHARK_DROP:
{
if ( !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_SHARKSUB_SWIM;
m_frame = 0;
}
s32 distX, distY;
distX = m_targetPos.vx - Pos.vx;
distY = m_targetPos.vy - Pos.vy;
m_extendDir = EXTEND_RIGHT;
if( abs( distY ) == 0 )
{
m_state = SUB_SHARK_START_CHARGE;
2001-06-21 18:28:49 +02:00
m_timerTimer = GameState::getOneSecondInFrames() >> 8;
m_movementTimer = GameState::getOneSecondInFrames();
2001-06-21 17:51:28 +02:00
}
else
{
processGenericGotoTarget( _frames, distX, distY, m_speed );
}
break;
}
case SUB_SHARK_START_CHARGE:
{
if ( !m_animPlaying )
{
m_animPlaying = true;
2001-07-03 22:49:30 +02:00
m_animNo = ANIM_SHARKSUB_SPRINTOPEN;
2001-06-21 17:51:28 +02:00
m_frame = 0;
}
2001-06-21 18:28:49 +02:00
if ( m_movementTimer <= 0 )
2001-06-21 17:51:28 +02:00
{
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
m_targetPos.vx = maxX;
m_targetPos.vy = maxY;
m_state = SUB_SHARK_CHARGE;
}
2001-06-21 18:28:49 +02:00
if ( m_timerTimer > 0 )
{
m_timerTimer -= _frames;
}
else
{
DVECTOR bubblePos = Pos;
bubblePos.vx -= 20 + ( getRnd() % 30 );
bubblePos.vy -= getRnd() % 50;
CFX::Create( CFX::FX_TYPE_BUBBLE_WATER, bubblePos );
m_timerTimer = GameState::getOneSecondInFrames() >> 8;
}
2001-06-21 17:51:28 +02:00
break;
}
case SUB_SHARK_CHARGE:
{
2001-07-03 22:49:30 +02:00
if ( !m_carryPlayer && abs( playerXDist ) < 200 )
2001-06-21 17:51:28 +02:00
{
2001-07-03 22:49:30 +02:00
if ( m_animNo != ANIM_SHARKSUB_CHOMP || !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_SHARKSUB_CHOMP;
m_frame = 0;
}
}
else
{
if ( !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_SHARKSUB_SPRINTOPEN;
m_frame = 0;
}
2001-06-21 17:51:28 +02:00
}
s32 distX, distY;
distX = m_targetPos.vx - Pos.vx;
distY = m_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 );
m_targetPos.vx = maxX;
m_targetPos.vy = minY;
m_state = SUB_SHARK_END_CHARGE;
}
else
{
2001-07-04 21:51:22 +02:00
processGenericGotoTarget( _frames, distX, distY, m_speed << 2 );
2001-06-21 17:51:28 +02:00
}
break;
}
case SUB_SHARK_END_CHARGE:
{
if ( !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_SHARKSUB_SWIM;
m_frame = 0;
}
s32 distX, distY;
distX = m_targetPos.vx - Pos.vx;
distY = m_targetPos.vy - Pos.vy;
if( abs( distX ) < 10 && abs( distY ) < 10 )
{
m_state = SUB_SHARK_MINE_1;
m_movementTimer = GameState::getOneSecondInFrames() * ( 1 + ( ( 7 * m_health ) / m_data[m_type].initHealth ) );
}
else
{
processGenericGotoTarget( _frames, distX, distY, m_speed );
}
2001-07-03 22:49:30 +02:00
if ( m_carryPlayer )
{
// spit out player
CPlayer *player = GameScene.getPlayer();
player->setMode( m_oldPlayerMode );
m_carryPlayer = false;
DVECTOR move;
move.vx = 16 * _frames;
move.vy = -16 * _frames;
player->shove( move );
player->setMoveVelocity( &move );
}
2001-06-21 17:51:28 +02:00
break;
}
}
2001-07-03 22:49:30 +02:00
if ( m_carryPlayer )
{
CPlayer *player = GameScene.getPlayer();
player->setPos( Pos );
}
2001-06-21 17:51:28 +02:00
/*if ( !m_animPlaying )
2001-02-28 22:05:39 +01:00
{
2001-03-13 18:01:35 +01:00
if ( playerXDistSqr + playerYDistSqr < 100 && !m_salvoCount )
{
m_animPlaying = true;
2001-05-03 23:39:27 +02:00
m_animNo = ANIM_SHARKSUB_SWIPE;
2001-03-13 18:01:35 +01:00
m_frame = 0;
}
else
{
m_animPlaying = true;
2001-05-03 23:39:27 +02:00
m_animNo = ANIM_SHARKSUB_SWIM;
2001-03-13 18:01:35 +01:00
m_frame = 0;
}
2001-02-28 22:05:39 +01:00
}
2001-01-25 18:19:08 +01:00
if ( m_timerTimer <= 0 )
{
if ( m_salvoCount > 0 )
{
// drop mine
CProjectile *projectile;
2001-06-14 18:07:48 +02:00
projectile = CProjectile::Create();
2001-06-18 15:47:50 +02:00
projectile->init( Pos, 1024, CProjectile::PROJECTILE_MINE, CProjectile::PROJECTILE_FINITE_LIFE );
2001-06-18 21:06:43 +02:00
projectile->setGraphic( FRM__SHARKMINE );
2001-01-25 18:19:08 +01:00
m_salvoCount--;
2001-06-16 17:43:04 +02:00
m_timerTimer = ( GameState::getOneSecondInFrames() >> 2 ) * ( 1 + ( ( 3 * m_health ) / m_data[m_type].initHealth ) );
2001-01-25 18:19:08 +01:00
}
}
if ( m_movementTimer > 0 )
{
m_movementTimer -= _frames;
2001-03-13 18:01:35 +01:00
}
2001-01-25 18:19:08 +01:00
2001-05-03 23:39:27 +02:00
s32 moveX = 0, moveY = 0;
s32 moveVel = 0;
s32 moveDist = 0;
processGenericFixedPathMove( _frames, &moveX, &moveY, &moveVel, &moveDist );
if ( moveX > 0 )
{
m_extendDir = EXTEND_RIGHT;
}
else
{
m_extendDir = EXTEND_LEFT;
}
Pos.vx += moveX;
Pos.vy += moveY;
2001-06-16 17:43:04 +02:00
if ( m_movementTimer <= 0 && m_salvoCount < 1 )
2001-05-03 23:39:27 +02:00
{
m_controlFunc = NPC_CONTROL_CLOSE;
2001-06-21 17:51:28 +02:00
}*/
2001-05-03 23:39:27 +02:00
/*if ( m_extendDir == EXTEND_RIGHT )
2001-03-13 18:01:35 +01:00
{
s32 xDist = 600 - Pos.vx;
s32 xDistSqr = xDist * xDist;
s32 yDist = m_base.vy - Pos.vy;
s32 yDistSqr = yDist * yDist;
2001-01-25 18:19:08 +01:00
2001-03-13 18:01:35 +01:00
if ( ( xDistSqr + yDistSqr ) > 100 )
{
2001-05-09 23:27:23 +02:00
processGenericGotoTarget( _frames, xDist, yDist, m_speed );
2001-01-25 18:19:08 +01:00
}
else
{
2001-03-13 18:01:35 +01:00
m_extendDir = EXTEND_LEFT;
2001-01-25 18:19:08 +01:00
2001-03-13 18:01:35 +01:00
if ( m_movementTimer <= 0 )
2001-01-25 18:19:08 +01:00
{
2001-03-13 18:01:35 +01:00
m_controlFunc = NPC_CONTROL_CLOSE;
2001-01-25 18:19:08 +01:00
}
}
}
else
{
2001-03-13 18:01:35 +01:00
s32 xDist = 100 - Pos.vx;
s32 xDistSqr = xDist * xDist;
s32 yDist = m_base.vy - Pos.vy;
s32 yDistSqr = yDist * yDist;
if ( ( xDistSqr + yDistSqr ) > 100 )
{
2001-05-09 23:27:23 +02:00
processGenericGotoTarget( _frames, xDist, yDist, m_speed );
2001-03-13 18:01:35 +01:00
}
else
{
m_extendDir = EXTEND_RIGHT;
if ( m_movementTimer <= 0 )
{
m_controlFunc = NPC_CONTROL_CLOSE;
}
}
2001-05-03 23:39:27 +02:00
}*/
2001-01-25 18:19:08 +01:00
}
2001-06-11 23:49:49 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-06-21 17:51:28 +02:00
/*void CNpcSubSharkEnemy::processClose( int _frames )
2001-01-25 18:19:08 +01:00
{
2001-03-13 18:01:35 +01:00
if ( m_state != SUB_SHARK_SWALLOW )
2001-01-25 20:57:29 +01:00
{
2001-03-13 18:01:35 +01:00
if ( playerXDist > 0 )
{
m_extendDir = EXTEND_RIGHT;
}
else
{
m_extendDir = EXTEND_LEFT;
}
2001-01-25 20:57:29 +01:00
}
2001-01-25 18:19:08 +01:00
switch( m_state )
{
case SUB_SHARK_MINE_1:
2001-03-13 18:01:35 +01:00
case SUB_SHARK_MINE_2:
2001-01-25 18:19:08 +01:00
{
2001-05-03 23:39:27 +02:00
if ( !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_SHARKSUB_SWIM;
m_frame = 0;
}
2001-05-09 23:27:23 +02:00
processGenericGotoTarget( _frames, playerXDist, 0, m_speed );
2001-03-13 18:01:35 +01:00
2001-06-05 16:54:56 +02:00
s32 minX, maxX;
m_npcPath.getPathXExtents( &minX, &maxX );
if ( Pos.vx < minX || Pos.vx > maxX || playerXDistSqr < 100 )
2001-01-25 18:19:08 +01:00
{
// fire at player
m_salvoCount = 5;
2001-03-13 18:01:35 +01:00
m_state++;
2001-06-16 17:43:04 +02:00
m_movementTimer = GameState::getOneSecondInFrames() * ( 1 + ( ( 7 * m_health ) / m_data[m_type].initHealth ) );
2001-01-25 18:19:08 +01:00
m_controlFunc = NPC_CONTROL_MOVEMENT;
}
break;
}
2001-03-13 18:01:35 +01:00
case SUB_SHARK_CYCLE:
2001-01-25 18:19:08 +01:00
{
2001-03-13 18:01:35 +01:00
// charge player
if ( !m_animPlaying )
2001-01-25 18:19:08 +01:00
{
2001-03-13 18:01:35 +01:00
m_animPlaying = true;
2001-05-03 23:39:27 +02:00
m_animNo = ANIM_SHARKSUB_SPRINTOPEN;
2001-03-13 18:01:35 +01:00
m_frame = 0;
2001-01-25 18:19:08 +01:00
}
2001-03-13 18:01:35 +01:00
processGenericGotoTarget( _frames, playerXDist, 0, NPC_SUB_SHARK_HIGH_SPEED );
2001-06-05 16:54:56 +02:00
s32 minX, maxX;
m_npcPath.getPathXExtents( &minX, &maxX );
if ( Pos.vx < minX || Pos.vx > maxX || playerXDistSqr < 10000 )
2001-01-25 18:19:08 +01:00
{
2001-03-13 18:01:35 +01:00
m_animPlaying = true;
2001-05-03 23:39:27 +02:00
m_animNo = ANIM_SHARKSUB_CHOMP;
2001-03-13 18:01:35 +01:00
m_frame = 0;
2001-01-25 18:19:08 +01:00
2001-03-13 18:01:35 +01:00
m_state = SUB_SHARK_SWALLOW;
2001-01-25 18:19:08 +01:00
}
break;
}
2001-03-13 18:01:35 +01:00
case SUB_SHARK_SWALLOW:
2001-01-25 18:19:08 +01:00
{
2001-03-13 18:01:35 +01:00
// if ( collision )
// else
2001-01-25 18:19:08 +01:00
2001-06-05 16:54:56 +02:00
s32 minX, maxX;
m_npcPath.getPathXExtents( &minX, &maxX );
2001-03-13 18:01:35 +01:00
if ( m_extendDir == EXTEND_RIGHT )
2001-01-25 18:19:08 +01:00
{
2001-06-05 16:54:56 +02:00
//s32 xDist = 600 - Pos.vx;
s32 xDist = maxX - Pos.vx;
2001-03-13 20:46:15 +01:00
s32 xDistSqr = xDist * xDist;
if ( xDistSqr > 100 )
{
processGenericGotoTarget( _frames, xDist, 0, NPC_SUB_SHARK_HIGH_SPEED );
}
else
{
m_extendDir = EXTEND_LEFT;
}
2001-01-25 18:19:08 +01:00
}
else
{
2001-06-05 16:54:56 +02:00
//s32 xDist = 100 - Pos.vx;
s32 xDist = minX - Pos.vx;
2001-03-13 20:46:15 +01:00
s32 xDistSqr = xDist * xDist;
if ( xDistSqr > 100 )
{
processGenericGotoTarget( _frames, xDist, 0, NPC_SUB_SHARK_HIGH_SPEED );
}
else
{
m_extendDir = EXTEND_RIGHT;
}
2001-03-13 18:01:35 +01:00
}
if ( !m_animPlaying )
{
m_animPlaying = true;
2001-05-03 23:39:27 +02:00
m_animNo = ANIM_SHARKSUB_SWIM;
2001-03-13 18:01:35 +01:00
m_frame = 0;
2001-01-25 18:19:08 +01:00
m_controlFunc = NPC_CONTROL_MOVEMENT;
2001-06-16 17:43:04 +02:00
m_movementTimer = GameState::getOneSecondInFrames() * ( 1 + ( ( 7 * m_health ) / m_data[m_type].initHealth ) );
2001-01-25 18:19:08 +01:00
m_state = SUB_SHARK_MINE_1;
}
break;
}
}
2001-06-21 17:51:28 +02:00
}*/
2001-06-11 23:49:49 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSubSharkEnemy::processShot( int _frames )
{
switch( m_data[m_type].shotFunc )
{
case NPC_SHOT_NONE:
{
// do nothing
break;
}
case NPC_SHOT_GENERIC:
{
switch ( m_state )
{
case NPC_GENERIC_HIT_CHECK_HEALTH:
{
m_health -= 5;
if ( m_health < 0 )
{
m_state = NPC_GENERIC_HIT_DEATH_START;
m_isDying = true;
}
else
{
m_state = NPC_GENERIC_HIT_RECOIL;
m_animPlaying = true;
m_animNo = m_data[m_type].recoilAnim;
m_frame = 0;
2001-06-16 17:43:04 +02:00
m_speed = m_data[m_type].speed + ( ( 3 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth );
2001-06-11 23:49:49 +02:00
}
break;
}
case NPC_GENERIC_HIT_RECOIL:
{
2001-06-20 21:39:00 +02:00
m_invulnerableTimer = 2 * GameState::getOneSecondInFrames();
2001-06-11 23:49:49 +02:00
if ( !m_animPlaying )
{
m_state = 0;
m_controlFunc = NPC_CONTROL_MOVEMENT;
}
break;
}
case NPC_GENERIC_HIT_DEATH_START:
{
2001-06-28 22:29:14 +02:00
CNpcEnemy::processShotDeathStart( _frames );
2001-06-11 23:49:49 +02:00
break;
}
case NPC_GENERIC_HIT_DEATH_END:
{
if ( !m_animPlaying )
{
2001-06-28 22:29:14 +02:00
CNpcEnemy::processShotDeathEnd( _frames );
2001-06-11 23:49:49 +02:00
2001-06-28 22:29:14 +02:00
if ( isSetToShutdown() )
2001-06-11 23:49:49 +02:00
{
2001-06-28 22:29:14 +02:00
CGameScene::setBossHasBeenKilled();
2001-06-11 23:49:49 +02:00
}
}
break;
}
}
break;
}
}
}
2001-06-16 17:43:04 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSubSharkEnemy::shutdown()
{
if ( m_state != NPC_GENERIC_HIT_DEATH_END )
{
CLevel::setIsBossRespawn( true );
CLevel::setBossHealth( m_health );
}
2001-06-30 17:39:43 +02:00
CNpcBossEnemy::shutdown();
2001-06-16 17:43:04 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSubSharkEnemy::render()
{
SprFrame = NULL;
if ( m_isActive )
{
CEnemyThing::render();
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed);
m_actorGfx->RotateScale( SprFrame, renderPos, 0, 4096, 4096 );
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-06-20 21:39:00 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSubSharkEnemy::collidedWith(CThing *_thisThing)
{
if ( m_isActive && !m_isCaught && !m_isDying )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
ATTACK_STATE playerState = player->getAttackState();
if(playerState==ATTACK_STATE__NONE)
{
2001-07-03 22:49:30 +02:00
CPlayer *player = GameScene.getPlayer();
if ( !player->isRecoveringFromHit() && !m_carryPlayer )
2001-06-20 21:39:00 +02:00
{
2001-06-21 17:51:28 +02:00
player->takeDamage( m_data[m_type].damageToUserType,REACT__GET_DIRECTION_FROM_THING,(CThing*)this );
2001-06-20 21:39:00 +02:00
}
2001-07-03 22:49:30 +02:00
if ( m_state == SUB_SHARK_CHARGE && player->getMode() != PLAYER_MODE_SWALLOW )
{
m_carryPlayer = true;
m_oldPlayerMode = player->getMode();
player->setMode( PLAYER_MODE_SWALLOW );
}
2001-06-20 21:39:00 +02:00
}
else if ( m_invulnerableTimer <= 0 )
{
// player is attacking, respond appropriately
if ( m_controlFunc != NPC_CONTROL_SHOT )
{
if(playerState==ATTACK_STATE__BUTT_BOUNCE)
{
player->justButtBouncedABadGuy();
}
m_controlFunc = NPC_CONTROL_SHOT;
m_state = NPC_GENERIC_HIT_CHECK_HEALTH;
drawAttackEffect();
}
}
break;
}
case TYPE_ENEMY:
{
CNpcEnemy *enemy = (CNpcEnemy *) _thisThing;
if ( canCollideWithEnemy() && enemy->canCollideWithEnemy() )
{
processEnemyCollision( _thisThing );
}
break;
}
default:
ASSERT(0);
break;
}
}
}
2001-06-21 17:51:28 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
s32 CNpcSubSharkEnemy::getFrameShift( int _frames )
{
if ( m_state == SUB_SHARK_START_CHARGE )
{
return( ( _frames << 8 ) << 1 );
}
else
{
return( ( _frames << 8 ) >> 1 );
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSubSharkEnemy::setupWaypoints( sThingActor *ThisActor )
{
u16 *PntList=(u16*)MakePtr(ThisActor,sizeof(sThingActor));
u16 newXPos, newYPos;
m_npcPath.setWaypointCount( ThisActor->PointCount - 1 );
newXPos = (u16) *PntList;
setWaypointPtr( PntList );
PntList++;
newYPos = (u16) *PntList;
PntList++;
setStartPos( newXPos, newYPos );
if ( ThisActor->PointCount > 1 )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
setHeading( newXPos, newYPos );
}
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;
m_npcPath.setWaypointCount( ThisActor->PointCount - 2 );
}