2001-01-25 16:30:11 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
nfdutch.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_NFDUTCH_H__
|
|
|
|
#include "enemy\nfdutch.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
|
|
|
|
|
|
|
|
#ifndef __PROJECTL_PROJECTL_H__
|
|
|
|
#include "projectl\projectl.h"
|
|
|
|
#endif
|
|
|
|
|
2001-06-12 20:12:34 +02:00
|
|
|
#ifndef __VID_HEADER_
|
|
|
|
#include "system\vid.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-04 21:55:49 +02:00
|
|
|
#ifndef __ANIM_FLYINGDUTCHMAN_HEADER__
|
|
|
|
#include <ACTOR_FLYINGDUTCHMAN_ANIM.h>
|
|
|
|
#endif
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-06-12 22:40:08 +02:00
|
|
|
#ifndef __SPR_SPRITES_H__
|
|
|
|
#include <sprites.h>
|
|
|
|
#endif
|
|
|
|
|
2001-07-05 16:07:27 +02:00
|
|
|
#ifndef __UTILS_HEADER__
|
|
|
|
#include "utils\utils.h"
|
|
|
|
#endif
|
|
|
|
|
2001-06-12 20:12:34 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-20 22:22:16 +02:00
|
|
|
void CNpcFlyingDutchmanEnemy::postInit()
|
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_UP;
|
|
|
|
|
|
|
|
s32 minX, maxX;
|
|
|
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
2001-05-04 00:15:13 +02:00
|
|
|
m_npcPath.getPathYExtents( &m_minY, &m_maxY );
|
2001-04-20 22:22:16 +02:00
|
|
|
|
|
|
|
m_extension = minX;
|
2001-06-16 18:16:57 +02:00
|
|
|
m_inRange = false;
|
|
|
|
|
|
|
|
if ( CLevel::getIsBossRespawn() )
|
|
|
|
{
|
|
|
|
m_health = CLevel::getBossHealth();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_fireCount = 0;
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-02 23:25:13 +02:00
|
|
|
m_fadeVal = 128;
|
2001-07-04 21:39:13 +02:00
|
|
|
m_fadeDown = true;
|
2001-07-02 23:25:13 +02:00
|
|
|
|
2001-06-30 17:39:43 +02:00
|
|
|
CNpcBossEnemy::postInit();
|
2001-06-20 21:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFlyingDutchmanEnemy::think( int _frames )
|
|
|
|
{
|
2001-07-02 23:25:13 +02:00
|
|
|
if ( m_fadeDown )
|
|
|
|
{
|
|
|
|
if ( m_fadeVal > 0 )
|
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
m_fadeVal -= 4 * _frames;
|
2001-07-02 23:25:13 +02:00
|
|
|
|
|
|
|
if ( m_fadeVal < 0 )
|
|
|
|
{
|
|
|
|
m_fadeVal = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( m_fadeVal < 128 )
|
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
m_fadeVal += 4 * _frames;
|
2001-07-02 23:25:13 +02:00
|
|
|
|
|
|
|
if ( m_fadeVal > 128 )
|
|
|
|
{
|
|
|
|
m_fadeVal = 128;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-20 21:39:00 +02:00
|
|
|
CNpcEnemy::think( _frames );
|
2001-04-20 22:22:16 +02:00
|
|
|
}
|
|
|
|
|
2001-06-12 20:12:34 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-20 22:22:16 +02:00
|
|
|
void CNpcFlyingDutchmanEnemy::processMovement( int _frames )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-04-04 21:55:49 +02:00
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:06:51 +02:00
|
|
|
s32 xDist = m_extension - Pos.vx;
|
|
|
|
s32 xDistSqr = xDist * xDist;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-06-26 20:06:51 +02:00
|
|
|
if ( xDistSqr > 100 )
|
|
|
|
{
|
|
|
|
processGenericGotoTarget( _frames, xDist, 0, m_speed );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( m_movementTimer > 0 )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-06-26 20:06:51 +02:00
|
|
|
m_movementTimer -= _frames;
|
|
|
|
|
2001-03-13 21:45:51 +01:00
|
|
|
if ( m_extendDir == EXTEND_UP )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-05-04 00:15:13 +02:00
|
|
|
s32 yDist = m_minY - Pos.vy;
|
2001-03-13 21:45:51 +01:00
|
|
|
|
2001-06-26 20:06:51 +02:00
|
|
|
if ( abs( yDist ) > 10 )
|
2001-03-13 21:45:51 +01:00
|
|
|
{
|
2001-05-09 23:27:23 +02:00
|
|
|
processGenericGotoTarget( _frames, 0, yDist, m_speed );
|
2001-03-13 21:45:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_DOWN;
|
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-04 00:15:13 +02:00
|
|
|
s32 yDist = m_maxY - Pos.vy;
|
2001-03-13 21:45:51 +01:00
|
|
|
|
2001-06-26 20:06:51 +02:00
|
|
|
if ( abs( yDist ) > 10 )
|
2001-03-13 21:45:51 +01:00
|
|
|
{
|
2001-05-09 23:27:23 +02:00
|
|
|
processGenericGotoTarget( _frames, 0, yDist, m_speed );
|
2001-03-13 21:45:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_UP;
|
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
}
|
2001-06-26 20:06:51 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
CPlayer *player = GameScene.getPlayer();
|
|
|
|
|
2001-07-23 21:26:37 +02:00
|
|
|
DVECTOR const &playerPos = player->getPos();
|
2001-06-26 20:06:51 +02:00
|
|
|
|
|
|
|
s32 minX, maxX;
|
|
|
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
|
|
|
|
|
|
|
if ( playerPos.vx >= minX && playerPos.vx <= maxX &&
|
|
|
|
playerPos.vy >= m_minY && playerPos.vy <= m_maxY )
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
2001-07-04 21:39:13 +02:00
|
|
|
m_state = FLYING_DUTCHMAN_GOTO_PLAYER;
|
2001-06-26 20:06:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-02 22:34:37 +02:00
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() * 2;
|
2001-06-26 20:06:51 +02:00
|
|
|
}
|
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
2001-04-04 21:55:49 +02:00
|
|
|
|
|
|
|
if ( playerXDist > 0 )
|
|
|
|
{
|
|
|
|
m_heading = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_heading = 2048;
|
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
|
2001-06-12 20:12:34 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-20 22:22:16 +02:00
|
|
|
void CNpcFlyingDutchmanEnemy::processClose( int _frames )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerYDist > 0 )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_DOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_UP;
|
|
|
|
}
|
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
if ( !m_inRange )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
if ( playerYDistSqr > 100 )
|
2001-04-04 21:55:49 +02:00
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
2001-04-04 21:55:49 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
processGenericGotoTarget( _frames, 0, playerYDist, m_speed );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_inRange = true;
|
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( m_state )
|
2001-07-04 21:39:13 +02:00
|
|
|
{
|
|
|
|
case FLYING_DUTCHMAN_GOTO_PLAYER:
|
|
|
|
{
|
2001-07-23 23:43:57 +02:00
|
|
|
if ( m_soundId == NOT_PLAYING )
|
|
|
|
{
|
|
|
|
m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].moveSfx, true );
|
|
|
|
}
|
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// charge player
|
|
|
|
|
2001-07-09 18:30:16 +02:00
|
|
|
if ( ( playerXDistSqr + playerYDistSqr ) > 25000 )
|
2001-07-04 21:39:13 +02:00
|
|
|
{
|
|
|
|
processGenericGotoTarget( _frames, playerXDist, playerYDist, 8 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-05 23:50:02 +02:00
|
|
|
int val = getRnd() % 3;
|
|
|
|
|
|
|
|
switch( val )
|
2001-07-05 16:07:27 +02:00
|
|
|
{
|
2001-07-05 23:50:02 +02:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
m_state = FLYING_DUTCHMAN_ATTACK_PLAYER;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
m_state = FLYING_DUTCHMAN_CHARGE_PLAYER_START;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
m_state = FLYING_DUTCHMAN_LEVEL_SHAKE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2001-07-05 16:07:27 +02:00
|
|
|
}
|
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
m_fadeDown = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FLYING_DUTCHMAN_ATTACK_PLAYER:
|
|
|
|
{
|
|
|
|
if ( m_fadeVal == 128 )
|
|
|
|
{
|
|
|
|
if ( m_timerTimer > 0 )
|
|
|
|
{
|
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_timerTimer -= _frames;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( m_animNo != ANIM_FLYINGDUTCHMAN_FIREATTACK )
|
|
|
|
{
|
|
|
|
m_animNo = ANIM_FLYINGDUTCHMAN_FIREATTACK;
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
//else if ( !m_animPlaying )
|
|
|
|
else if ( m_frame > ( getFrameCount() >> 1 ) )
|
|
|
|
{
|
|
|
|
// fire at player
|
|
|
|
|
|
|
|
s16 heading;
|
|
|
|
|
|
|
|
if ( playerXDist > 0 )
|
|
|
|
{
|
|
|
|
heading = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
heading = 2048;
|
|
|
|
}
|
|
|
|
|
|
|
|
CProjectile *projectile;
|
|
|
|
projectile = CProjectile::Create();
|
|
|
|
DVECTOR newPos = Pos;
|
|
|
|
newPos.vy -= 50;
|
|
|
|
projectile->init( newPos, heading );
|
|
|
|
projectile->setGraphic( FRM__SNAKEBILE );
|
|
|
|
projectile->setSpeed( 6 );
|
|
|
|
|
|
|
|
m_fireCount++;
|
|
|
|
|
|
|
|
if ( m_health < ( m_data[m_type].initHealth >> 2 ) && m_fireCount < 2 )
|
|
|
|
{
|
|
|
|
m_timerTimer = GameState::getOneSecondInFrames() >> 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_state = FLYING_DUTCHMAN_RETURN;
|
2001-07-05 16:07:27 +02:00
|
|
|
m_timerTimer = 2 * GameState::getOneSecondInFrames();
|
2001-07-04 21:39:13 +02:00
|
|
|
}
|
2001-07-14 00:11:49 +02:00
|
|
|
|
|
|
|
CSoundMediator::playSfx( CSoundMediator::SFX_FLYING_DUTCHMAN );
|
2001-07-04 21:39:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-07-05 16:07:27 +02:00
|
|
|
case FLYING_DUTCHMAN_CHARGE_PLAYER_START:
|
|
|
|
{
|
|
|
|
if ( m_fadeVal == 128 )
|
|
|
|
{
|
|
|
|
// charge at player
|
|
|
|
|
|
|
|
if ( playerXDist > 0 )
|
|
|
|
{
|
|
|
|
m_heading = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_heading = 2048;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_state = FLYING_DUTCHMAN_CHARGE_PLAYER;
|
|
|
|
|
|
|
|
m_timerTimer = GameState::getOneSecondInFrames();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FLYING_DUTCHMAN_CHARGE_PLAYER:
|
|
|
|
{
|
|
|
|
if ( m_timerTimer > 0 )
|
|
|
|
{
|
2001-07-23 23:43:57 +02:00
|
|
|
if ( m_soundId == NOT_PLAYING )
|
|
|
|
{
|
|
|
|
m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].moveSfx, true );
|
|
|
|
}
|
|
|
|
|
2001-07-05 16:07:27 +02:00
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_heading )
|
|
|
|
{
|
|
|
|
Pos.vx -= _frames * m_speed * 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Pos.vx += _frames * m_speed * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_timerTimer -= _frames;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_state = FLYING_DUTCHMAN_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-07-05 23:50:02 +02:00
|
|
|
case FLYING_DUTCHMAN_LEVEL_SHAKE:
|
|
|
|
{
|
|
|
|
if ( m_fadeVal == 128 )
|
|
|
|
{
|
|
|
|
CThingManager::shakePlatformLoose();
|
|
|
|
|
|
|
|
m_timerTimer = 5 * GameState::getOneSecondInFrames();
|
|
|
|
|
|
|
|
m_state = FLYING_DUTCHMAN_LEVEL_SHAKE_WAIT;
|
|
|
|
|
|
|
|
CGameScene::setCameraShake(0,8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FLYING_DUTCHMAN_LEVEL_SHAKE_WAIT:
|
|
|
|
{
|
|
|
|
if ( m_timerTimer > 0 )
|
|
|
|
{
|
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_frame = 0;
|
|
|
|
|
|
|
|
CGameScene::setCameraShake(0,8);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_timerTimer -= _frames;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_state = FLYING_DUTCHMAN_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
case FLYING_DUTCHMAN_RETURN:
|
|
|
|
{
|
|
|
|
if ( m_timerTimer > 0 )
|
|
|
|
{
|
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_timerTimer -= _frames;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() * 2;
|
|
|
|
m_inRange = false;
|
|
|
|
m_fadeDown = true;
|
|
|
|
m_timerTimer = 0;
|
|
|
|
m_fireCount = 0;
|
|
|
|
|
|
|
|
s32 minX, maxX;
|
|
|
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
|
|
|
|
|
|
|
if ( m_extension == minX )
|
|
|
|
{
|
|
|
|
m_extension = maxX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extension = minX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*switch( m_state )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
|
|
|
case FLYING_DUTCHMAN_ATTACK_PLAYER_1:
|
|
|
|
case FLYING_DUTCHMAN_ATTACK_PLAYER_2:
|
|
|
|
{
|
2001-06-16 18:16:57 +02:00
|
|
|
if ( m_timerTimer > 0 )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-06-16 18:16:57 +02:00
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_timerTimer -= _frames;
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
2001-06-16 18:16:57 +02:00
|
|
|
else
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-06-16 18:16:57 +02:00
|
|
|
if ( m_animNo != ANIM_FLYINGDUTCHMAN_FIREATTACK )
|
2001-04-04 21:55:49 +02:00
|
|
|
{
|
2001-06-16 18:16:57 +02:00
|
|
|
m_animNo = ANIM_FLYINGDUTCHMAN_FIREATTACK;
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_frame = 0;
|
2001-04-04 21:55:49 +02:00
|
|
|
}
|
2001-07-02 22:34:37 +02:00
|
|
|
//else if ( !m_animPlaying )
|
|
|
|
else if ( m_frame > ( getFrameCount() >> 1 ) )
|
2001-04-04 21:55:49 +02:00
|
|
|
{
|
2001-06-16 18:16:57 +02:00
|
|
|
// fire at player
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-06-16 18:16:57 +02:00
|
|
|
s16 heading;
|
2001-01-25 16:30:11 +01:00
|
|
|
|
2001-06-16 18:16:57 +02:00
|
|
|
if ( playerXDist > 0 )
|
|
|
|
{
|
|
|
|
heading = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
heading = 2048;
|
|
|
|
}
|
2001-04-04 21:55:49 +02:00
|
|
|
|
2001-06-16 18:16:57 +02:00
|
|
|
CProjectile *projectile;
|
|
|
|
projectile = CProjectile::Create();
|
|
|
|
DVECTOR newPos = Pos;
|
|
|
|
newPos.vy -= 50;
|
|
|
|
projectile->init( newPos, heading );
|
2001-07-02 21:59:04 +02:00
|
|
|
projectile->setGraphic( FRM__SNAKEBILE );
|
2001-07-02 22:19:22 +02:00
|
|
|
projectile->setSpeed( 6 );
|
2001-06-16 18:16:57 +02:00
|
|
|
|
|
|
|
m_fireCount++;
|
|
|
|
|
|
|
|
if ( m_health < ( m_data[m_type].initHealth >> 2 ) && m_fireCount < 2 )
|
|
|
|
{
|
|
|
|
m_timerTimer = GameState::getOneSecondInFrames() >> 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
2001-07-02 22:34:37 +02:00
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() * 2;
|
2001-06-16 18:16:57 +02:00
|
|
|
|
|
|
|
m_state++;
|
|
|
|
m_inRange = false;
|
|
|
|
m_timerTimer = 0;
|
|
|
|
m_fireCount = 0;
|
|
|
|
}
|
|
|
|
}
|
2001-04-04 21:55:49 +02:00
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
2001-04-04 21:55:49 +02:00
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
2001-01-25 16:30:11 +01:00
|
|
|
// charge player
|
|
|
|
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr > 100 )
|
2001-01-25 16:30:11 +01:00
|
|
|
{
|
2001-07-02 23:25:13 +02:00
|
|
|
processGenericGotoTarget( _frames, playerXDist, playerYDist, 8 );
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
2001-07-02 22:34:37 +02:00
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() * 2;
|
2001-01-25 16:30:11 +01:00
|
|
|
m_state = FLYING_DUTCHMAN_ATTACK_PLAYER_1;
|
2001-06-16 18:16:57 +02:00
|
|
|
m_inRange = false;
|
2001-03-13 21:45:51 +01:00
|
|
|
|
2001-04-06 15:43:03 +02:00
|
|
|
s32 minX, maxX;
|
|
|
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
|
|
|
|
|
|
|
if ( m_extension == minX )
|
2001-03-13 21:45:51 +01:00
|
|
|
{
|
2001-04-06 15:43:03 +02:00
|
|
|
m_extension = maxX;
|
2001-03-13 21:45:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-06 15:43:03 +02:00
|
|
|
m_extension = minX;
|
2001-03-13 21:45:51 +01:00
|
|
|
}
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2001-07-04 21:39:13 +02:00
|
|
|
}*/
|
2001-01-25 16:30:11 +01:00
|
|
|
}
|
2001-04-04 21:55:49 +02:00
|
|
|
|
|
|
|
if ( playerXDist > 0 )
|
|
|
|
{
|
|
|
|
m_heading = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_heading = 2048;
|
|
|
|
}
|
2001-06-12 20:12:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-07-02 22:34:37 +02:00
|
|
|
void CNpcFlyingDutchmanEnemy::processShotRecoil( int _frames )
|
|
|
|
{
|
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
2001-07-04 21:39:13 +02:00
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() * 2;
|
2001-07-05 16:07:27 +02:00
|
|
|
m_inRange = false;
|
|
|
|
m_fadeDown = true;
|
|
|
|
m_timerTimer = 0;
|
|
|
|
m_fireCount = 0;
|
2001-07-02 22:34:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-06-28 22:29:14 +02:00
|
|
|
void CNpcFlyingDutchmanEnemy::processShotDeathEnd( int _frames )
|
|
|
|
{
|
2001-07-02 22:19:22 +02:00
|
|
|
if ( !m_animPlaying )
|
2001-06-28 22:29:14 +02:00
|
|
|
{
|
2001-07-02 22:19:22 +02:00
|
|
|
CNpcEnemy::processShotDeathEnd( _frames );
|
|
|
|
|
|
|
|
if ( isSetToShutdown() )
|
|
|
|
{
|
|
|
|
CGameScene::setBossHasBeenKilled();
|
|
|
|
}
|
2001-06-12 20:12:34 +02:00
|
|
|
}
|
|
|
|
}
|
2001-06-16 18:16:57 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFlyingDutchmanEnemy::shutdown()
|
|
|
|
{
|
2001-07-06 16:55:58 +02:00
|
|
|
CLevel::setIsBossRespawn( true );
|
|
|
|
|
2001-06-16 18:16:57 +02:00
|
|
|
if ( m_state != NPC_GENERIC_HIT_DEATH_END )
|
|
|
|
{
|
|
|
|
CLevel::setBossHealth( m_health );
|
|
|
|
}
|
2001-07-06 16:55:58 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
CLevel::setBossHealth( 0 );
|
|
|
|
}
|
2001-06-16 18:16:57 +02:00
|
|
|
|
2001-06-30 17:39:43 +02:00
|
|
|
CNpcBossEnemy::shutdown();
|
2001-06-16 18:16:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFlyingDutchmanEnemy::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);
|
2001-07-23 23:43:57 +02:00
|
|
|
setShadeTex(SprFrame,0);
|
2001-06-25 23:59:34 +02:00
|
|
|
setSemiTrans( SprFrame, true );
|
2001-07-05 23:50:02 +02:00
|
|
|
SprFrame->tpage|=1<<5;
|
2001-06-16 18:16:57 +02:00
|
|
|
m_actorGfx->RotateScale( SprFrame, renderPos, 0, 4096, 4096 );
|
2001-07-02 23:25:13 +02:00
|
|
|
setRGB0( SprFrame, m_fadeVal, m_fadeVal, m_fadeVal );
|
2001-06-16 18:16:57 +02:00
|
|
|
|
|
|
|
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 CNpcFlyingDutchmanEnemy::collidedWith(CThing *_thisThing)
|
|
|
|
{
|
|
|
|
if ( m_isActive && !m_isCaught && !m_isDying )
|
|
|
|
{
|
|
|
|
switch(_thisThing->getThingType())
|
|
|
|
{
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
if ( m_fadeVal == 128 )
|
|
|
|
{
|
|
|
|
CPlayer *player = (CPlayer *) _thisThing;
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
ATTACK_STATE playerState = player->getAttackState();
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
if(playerState==ATTACK_STATE__NONE)
|
2001-06-20 21:39:00 +02:00
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
if ( !player->isRecoveringFromHit() )
|
2001-06-20 21:39:00 +02:00
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
switch( m_data[m_type].detectCollision )
|
2001-06-20 21:39:00 +02:00
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
case DETECT_NO_COLLISION:
|
|
|
|
{
|
|
|
|
// ignore
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
break;
|
|
|
|
}
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
case DETECT_ALL_COLLISION:
|
|
|
|
{
|
2001-07-31 21:20:19 +02:00
|
|
|
if ( m_controlFunc != NPC_CONTROL_COLLISION )
|
|
|
|
{
|
|
|
|
m_oldControlFunc = m_controlFunc;
|
|
|
|
m_controlFunc = NPC_CONTROL_COLLISION;
|
|
|
|
}
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
processUserCollision( _thisThing );
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
break;
|
|
|
|
}
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
case DETECT_ATTACK_COLLISION_GENERIC:
|
|
|
|
{
|
|
|
|
processAttackCollision();
|
|
|
|
processUserCollision( _thisThing );
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
break;
|
|
|
|
}
|
2001-06-20 21:39:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-04 21:39:13 +02:00
|
|
|
else
|
2001-06-20 21:39:00 +02:00
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
// player is attacking, respond appropriately
|
2001-06-20 21:39:00 +02:00
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
if ( m_controlFunc != NPC_CONTROL_SHOT )
|
|
|
|
{
|
|
|
|
if(playerState==ATTACK_STATE__BUTT_BOUNCE)
|
|
|
|
{
|
|
|
|
player->justButtBouncedABadGuy();
|
|
|
|
}
|
2001-07-05 16:07:27 +02:00
|
|
|
m_controlFunc = NPC_CONTROL_SHOT;
|
|
|
|
m_state = NPC_GENERIC_HIT_CHECK_HEALTH;
|
2001-07-02 21:59:04 +02:00
|
|
|
|
2001-07-06 17:21:14 +02:00
|
|
|
s32 minX, maxX;
|
|
|
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
|
|
|
|
|
|
|
if ( m_extension == minX )
|
|
|
|
{
|
|
|
|
m_extension = maxX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extension = minX;
|
|
|
|
}
|
|
|
|
|
2001-07-04 21:39:13 +02:00
|
|
|
drawAttackEffect();
|
|
|
|
}
|
2001-06-20 21:39:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TYPE_ENEMY:
|
|
|
|
{
|
|
|
|
CNpcEnemy *enemy = (CNpcEnemy *) _thisThing;
|
|
|
|
|
|
|
|
if ( canCollideWithEnemy() && enemy->canCollideWithEnemy() )
|
|
|
|
{
|
|
|
|
processEnemyCollision( _thisThing );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-02 21:59:04 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
u8 CNpcFlyingDutchmanEnemy::hasBeenAttacked()
|
|
|
|
{
|
2001-07-04 21:39:13 +02:00
|
|
|
if ( m_fadeVal == 128 )
|
2001-07-02 21:59:04 +02:00
|
|
|
{
|
|
|
|
if ( m_controlFunc != NPC_CONTROL_SHOT )
|
|
|
|
{
|
2001-07-05 16:07:27 +02:00
|
|
|
m_controlFunc = NPC_CONTROL_SHOT;
|
|
|
|
m_state = NPC_GENERIC_HIT_CHECK_HEALTH;
|
|
|
|
|
|
|
|
/*m_controlFunc = NPC_CONTROL_MOVEMENT;
|
2001-07-04 21:39:13 +02:00
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() * 2;
|
|
|
|
m_inRange = false;
|
|
|
|
m_fadeDown = true;
|
|
|
|
m_timerTimer = 0;
|
2001-07-05 16:07:27 +02:00
|
|
|
m_fireCount = 0;*/
|
2001-07-06 17:21:14 +02:00
|
|
|
|
|
|
|
s32 minX, maxX;
|
|
|
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
|
|
|
|
|
|
|
if ( m_extension == minX )
|
|
|
|
{
|
|
|
|
m_extension = maxX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extension = minX;
|
|
|
|
}
|
2001-07-02 21:59:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|