This commit is contained in:
Charles 2001-05-10 19:27:57 +00:00
parent 3ea8916a41
commit 0112cd13e2
10 changed files with 112 additions and 25 deletions

View File

@ -27,6 +27,10 @@
#include "system\vid.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
@ -39,9 +43,6 @@
#include "fx\fxjfish.h"
#define MJ_CYCLE_WIDTH 400
#define MJ_HALF_CYCLE_WIDTH ( MJ_CYCLE_WIDTH >> 1 )
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -61,6 +62,55 @@ void CNpcMotherJellyfishEnemy::postInit()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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 );
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;
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcMotherJellyfishEnemy::processMovement( int _frames )
{
s32 xDist, yDist;
@ -72,7 +122,7 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames )
case MOTHER_JELLYFISH_RETURN_TO_START_2:
case MOTHER_JELLYFISH_RETURN_TO_START_3:
{
xDist = m_base.vx - this->Pos.vx - MJ_HALF_CYCLE_WIDTH;
xDist = m_base.vx - this->Pos.vx - m_halfCycleWidth;
xDistSqr = xDist * xDist;
yDist = m_base.vy - this->Pos.vy;
yDistSqr = yDist * yDist;
@ -87,7 +137,7 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames )
m_movementTimer = GameState::getOneSecondInFrames() * 10;
m_state++;
m_extension = -MJ_HALF_CYCLE_WIDTH;
m_extension = -m_halfCycleWidth;
m_extendDir = EXTEND_RIGHT;
}
@ -104,14 +154,14 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames )
if ( m_extendDir == EXTEND_RIGHT )
{
if ( m_extension < MJ_HALF_CYCLE_WIDTH )
if ( m_extension < m_halfCycleWidth )
{
m_extension += 3 * _frames;
xExtension = ( MJ_HALF_CYCLE_WIDTH * rsin( ( m_extension << 10 ) / MJ_HALF_CYCLE_WIDTH ) ) >> 12;
xExtension = ( m_halfCycleWidth * rsin( ( m_extension << 10 ) / m_halfCycleWidth ) ) >> 12;
Pos.vx = m_base.vx + xExtension;
Pos.vy = m_base.vy - ( ( 50 * rsin( ( xExtension << 12 ) / MJ_CYCLE_WIDTH ) ) >> 12 );
Pos.vy = m_base.vy - ( ( 50 * rsin( ( xExtension << 12 ) / m_cycleWidth ) ) >> 12 );
m_heading = 0;
}
@ -129,14 +179,14 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames )
}
else
{
if ( m_extension > -MJ_HALF_CYCLE_WIDTH )
if ( m_extension > -m_halfCycleWidth )
{
m_extension -= 3 * _frames;
xExtension = ( MJ_HALF_CYCLE_WIDTH * rsin( ( m_extension << 10 ) / MJ_HALF_CYCLE_WIDTH ) ) >> 12;
xExtension = ( m_halfCycleWidth * rsin( ( m_extension << 10 ) / m_halfCycleWidth ) ) >> 12;
Pos.vx = m_base.vx + xExtension;
Pos.vy = m_base.vy + ( ( 50 * rsin( ( xExtension << 12 ) / MJ_CYCLE_WIDTH ) ) >> 12 );
Pos.vy = m_base.vy + ( ( 50 * rsin( ( xExtension << 12 ) / m_cycleWidth ) ) >> 12 );
m_heading = 2048;
}
@ -206,14 +256,14 @@ void CNpcMotherJellyfishEnemy::processClose( int _frames )
if ( m_extendDir == EXTEND_RIGHT )
{
if ( m_extension < MJ_HALF_CYCLE_WIDTH )
if ( m_extension < m_halfCycleWidth )
{
m_extension += 3 * _frames;
xExtension = ( MJ_HALF_CYCLE_WIDTH * rsin( ( m_extension << 10 ) / MJ_HALF_CYCLE_WIDTH ) ) >> 12;
xExtension = ( m_halfCycleWidth * rsin( ( m_extension << 10 ) / m_halfCycleWidth ) ) >> 12;
Pos.vx = m_base.vx + xExtension;
Pos.vy = m_base.vy - ( ( 50 * rcos( ( xExtension << 11 ) / MJ_CYCLE_WIDTH ) ) >> 12 );
Pos.vy = m_base.vy - ( ( 50 * rcos( ( xExtension << 11 ) / m_cycleWidth ) ) >> 12 );
m_heading = 0;
@ -227,14 +277,14 @@ void CNpcMotherJellyfishEnemy::processClose( int _frames )
}
else
{
if ( m_extension > -MJ_HALF_CYCLE_WIDTH )
if ( m_extension > -m_halfCycleWidth )
{
m_extension -= 3 * _frames;
xExtension = ( MJ_HALF_CYCLE_WIDTH * rsin( ( m_extension << 10 ) / MJ_HALF_CYCLE_WIDTH ) ) >> 12;
xExtension = ( m_halfCycleWidth * rsin( ( m_extension << 10 ) / m_halfCycleWidth ) ) >> 12;
Pos.vx = m_base.vx + xExtension;
Pos.vy = m_base.vy + ( ( 50 * rcos( ( xExtension << 11 ) / MJ_CYCLE_WIDTH ) ) >> 12 );
Pos.vy = m_base.vy + ( ( 50 * rcos( ( xExtension << 11 ) / m_cycleWidth ) ) >> 12 );
m_heading = 2048;

View File

@ -20,6 +20,7 @@ public:
virtual void postInit();
void render();
virtual void shutdown();
virtual void setupWaypoints( sThingActor *ThisActor );
protected:
virtual void processClose( int _frames );
virtual void processMovement( int _frames );
@ -41,6 +42,8 @@ protected:
int m_jellyfishCount;
s32 m_spawnTimer;
s32 m_cycleWidth;
s32 m_halfCycleWidth;
};
#endif

View File

@ -362,12 +362,12 @@ CNpcEnemy *CNpcEnemy::Create(sThingActor *ThisActor)
{
printf("NPC_MOTHER_JELLYFISH\n");
if ( CLevel::getCurrentChapterLevel() == 4 )
/*if ( CLevel::getCurrentChapterLevel() == 4 )
{
enemy = new ("mother jellyfish background") CNpcMotherJellyfishBackground;
enemyType = NPC_MOTHER_JELLYFISH_BACKGROUND;
}
else
else*/
{
enemy = new ("mother jellyfish") CNpcMotherJellyfishEnemy;
}

View File

@ -109,7 +109,7 @@ public:
void setSpeed( s16 newSpeed ) {m_speed = newSpeed;}
static CNpcEnemy *Create(sThingActor *ThisActor);
void setupWaypoints( sThingActor *ThisActor );
virtual void setupWaypoints( sThingActor *ThisActor );
virtual int canCollide();

View File

@ -61,6 +61,7 @@ public:
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
virtual void setWaypoints( sThingHazard *ThisHazard );
void addWaypoint( s32 xPos, s32 yPos );
virtual void setRespawnRate( s16 newRespawnRate ) {m_respawnRate=newRespawnRate;}
static NPC_HAZARD_UNIT_TYPE getTypeFromMapEdit( u16 newType );
static CNpcHazard *Create(sThingHazard *ThisHazard);
@ -96,6 +97,7 @@ protected:
bool m_extendDir;
s32 m_heading;
CModelGfx *m_modelGfx;
s16 m_respawnRate;
CThing *m_platform;

View File

@ -166,3 +166,26 @@ void CNpcBoatHazard::render()
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBoatHazard::collidedWith( CThing *_thisThing )
{
if ( m_isActive )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
break;
}
default:
ASSERT(0);
break;
}
}
}

View File

@ -25,6 +25,7 @@ public:
virtual void render();
protected:
void processMovement( int _frames );
virtual void collidedWith(CThing *_thisThing);
u8 m_reversed;
};

View File

@ -29,7 +29,9 @@ void CNpcFallingHazard::init()
{
CNpcHazard::init();
m_movementTimer = 3 * GameState::getOneSecondInFrames();
m_movementTimer = 2 * GameState::getOneSecondInFrames();
m_respawnRate = 4;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -67,7 +69,7 @@ void CNpcFallingHazard::processMovement( int _frames )
m_isActive = false;
m_timerActive = true;
m_timer = 3 * GameState::getOneSecondInFrames();
m_timer = ( m_respawnRate - 1 ) * GameState::getOneSecondInFrames();
}
else
{
@ -89,6 +91,6 @@ void CNpcFallingHazard::processTimer( int _frames )
m_timerActive = false;
m_isActive = true;
Pos = m_base;
m_movementTimer = 3 * GameState::getOneSecondInFrames();
m_movementTimer = 2 * GameState::getOneSecondInFrames();
}
}

View File

@ -40,7 +40,8 @@ void CNpcFireballHazard::init()
m_extension = 0;
m_velocity = 40;
m_timer = GameState::getOneSecondInFrames() * 3;
m_respawnRate = 4;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -75,7 +76,7 @@ void CNpcFireballHazard::processMovement( int _frames )
m_extension = 0;
m_isActive = false;
m_timerActive = true;
m_timer = 3 * GameState::getOneSecondInFrames();
m_timer = ( m_respawnRate - 1 ) * GameState::getOneSecondInFrames();
return;
}

View File

@ -527,6 +527,11 @@ void CLevel::initThings(int _respawningLevel)
CNpcHazard *hazard;
hazard = CNpcHazard::Create( ThisHazard );
hazard->setLayerCollision( getCollisionLayer() );
if ( ThisHazard->Respawn )
{
hazard->setRespawnRate( ThisHazard->Respawn );
}
}
}