This commit is contained in:
Charles 2001-04-23 20:40:13 +00:00
parent ceb6672c0f
commit 9ad7e14f55
17 changed files with 467 additions and 857 deletions

View File

@ -74,7 +74,6 @@ enemy_src := npc \
nfskull \
nsklfish \
ngary \
nplatfrm \
nworm \
nhcrab \
nbblob \
@ -82,6 +81,18 @@ enemy_src := npc \
ngen \
nsdart
platform_src := platform \
platdata \
plinear \
pcirculr \
pbubble \
pfishhk \
pgeyser \
pbob \
pfalling \
pcart \
pretract
projectl_src := projectl
fileio_src := fileio \

View File

@ -19,10 +19,6 @@
#include "enemy\npc.h"
#endif
#ifndef __ENEMY_NPLATFRM_H__
#include "enemy\nplatfrm.h"
#endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
@ -147,175 +143,6 @@ CNpcFriend::NPC_FRIEND_DATA CNpcFriend::m_data[NPC_FRIEND_UNIT_TYPE_MAX] =
},
};
CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{
{ // NPC_LINEAR_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_FIXED_PATH,
1,
//512,
2048,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_CIRCULAR_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_FIXED_CIRCULAR,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_BUBBLE_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_BUBBLE,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_FINITE_LIFE_RESPAWN,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_COLLAPSING_BUBBLE_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_STATIC,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE_COLLAPSIBLE,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_FISH_HOOK_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_STATIC,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE_FISH_HOOK,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_RETRACTING_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_STATIC,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
0,
NPC_PLATFORM_TIMER_RETRACT,
},
{ // NPC_GEYSER_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_STATIC,
8,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
4,
NPC_PLATFORM_TIMER_GEYSER,
},
{ // NPC_BOBBING_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_BOB,
0,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
4,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_FALLING_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_FALL,
4,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
4,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_CART_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_CART,
4,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
4,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_PLAYER_BUBBLE_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_PLAYER_BUBBLE,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_FINITE_LIFE,
0,
NPC_PLATFORM_TIMER_NONE,
},
};
CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
{
{ // NPC_FALLING_ITEM
@ -1246,18 +1073,3 @@ CNpcEnemy::NPC_UNIT_TYPE CNpcEnemy::mapEditConvertTable[NPC_UNIT_TYPE_MAX] =
NPC_OIL_BLOB,
NPC_PARASITIC_WORM_SEGMENT,
};
CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATFORM_TYPE_MAX] =
{
NPC_BUBBLE_PLATFORM,
NPC_LINEAR_PLATFORM,
NPC_FALLING_PLATFORM,
NPC_CIRCULAR_PLATFORM,
NPC_COLLAPSING_BUBBLE_PLATFORM,
NPC_FISH_HOOK_PLATFORM,
NPC_RETRACTING_PLATFORM,
NPC_GEYSER_PLATFORM,
NPC_BOBBING_PLATFORM,
NPC_CART_PLATFORM,
NPC_PLAYER_BUBBLE_PLATFORM,
};

View File

@ -27,8 +27,8 @@
#include "enemy\npc.h"
#endif
#ifndef __ENEMY_NPLATFRM_H__
#include "enemy\nplatfrm.h"
#ifndef __PLATFORM_PLATFORM_H__
#include "platform\platform.h"
#endif
#ifndef __PROJECTL_PROJECTL_H__
@ -111,7 +111,7 @@ void CGameScene::init()
SetGeomScreen(RenderZ);
CamMtx.t[2]=RenderZ;
SetTransMatrix(&CamMtx);
SetTransMatrix(&CamMtx);
s_genericFont=new ("CGameScene::Init") FontBank();
s_genericFont->initialise( &standardFont );
@ -257,7 +257,6 @@ void CGameScene::initLevel()
m_player->setMapSize(Level.getMapSize());
// Init actors (needs moving and tidying
int pointNum;
int actorNum;
int platformNum;
@ -291,43 +290,11 @@ void CGameScene::initLevel()
{
for ( platformNum = 0 ; platformNum < Level.getPlatformCount() ; platformNum++ )
{
sThingPlatform *ThisPlatform = platformList[platformNum];
CNpcPlatform *platform;
platform = new ("platform") CNpcPlatform;
ASSERT(platform);
platform->setTypeFromMapEdit( platformList[platformNum]->Type );
u16 *PntList=(u16*)MakePtr(platformList[platformNum],sizeof(sThingPlatform));
u16 newXPos, newYPos;
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4;
platform->init( startPos );
platform = CNpcPlatform::Create( ThisPlatform );
platform->setLayerCollision( Level.getCollisionLayer() );
platform->setTiltable( false );
platform->addWaypoint( newXPos, newYPos );
if ( platformList[platformNum]->PointCount > 1 )
{
for ( pointNum = 1 ; pointNum < platformList[platformNum]->PointCount ; pointNum++ )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
platform->addWaypoint( newXPos, newYPos );
}
}
platform->postInit();
}
}

View File

@ -15,6 +15,10 @@
#include "platform\pcart.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcCartPlatform::postInit()

View File

@ -15,6 +15,10 @@
#include "platform\pfalling.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingPlatform::postInit()

View File

@ -29,10 +29,13 @@ void CNpcFishHookPlatform::processLifetime( int _frames )
void CNpcFishHookPlatform::processMovement( int _frames )
{
Pos.vy -= m_data[m_type].speed * _frames;
if ( Pos.vy < 0 )
if ( m_isMoving )
{
shutdown();
Pos.vy -= m_data[m_type].speed * _frames;
if ( Pos.vy < 0 )
{
shutdown();
}
}
}

View File

@ -20,48 +20,68 @@
void CNpcGeyserPlatform::postInit()
{
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
m_isFiring = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcGeyserPlatform::processMovement( int _frames )
{
s32 moveY = 0;
s32 distX, distY, heading;
bool pathComplete;
m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading );
if ( pathComplete )
if ( m_isFiring )
{
m_npcPath.resetPath();
reinit();
s32 moveY = 0;
s32 distX, distY, heading;
bool pathComplete;
m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading );
if ( pathComplete )
{
m_npcPath.resetPath();
reinit();
m_isFiring = false;
}
else
{
s32 minY, maxY;
m_npcPath.getPathYExtents( &minY, &maxY );
moveY = m_data[m_type].speed * _frames;
if ( Pos.vy < ( minY + 64 ) )
{
s32 multiplier = Pos.vy - minY;
moveY = ( multiplier * moveY ) >> 6;
if ( moveY < 1 )
{
moveY = 1;
}
}
if ( heading == 3072 )
{
moveY = -moveY;
}
Pos.vy += moveY;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcGeyserPlatform::processTimer( int _frames )
{
if ( m_timer > 0 )
{
m_timer -= _frames;
}
else
{
s32 minY, maxY;
m_npcPath.getPathYExtents( &minY, &maxY );
moveY = m_data[m_type].speed * _frames;
if ( Pos.vy < ( minY + 64 ) )
{
s32 multiplier = Pos.vy - minY;
moveY = ( multiplier * moveY ) >> 6;
if ( moveY < 1 )
{
moveY = 1;
}
}
if ( heading == 3072 )
{
moveY = -moveY;
}
Pos.vy += moveY;
m_isFiring = true;
}
}
}

View File

@ -24,6 +24,9 @@ public:
virtual void postInit();
protected:
virtual void processMovement( int _frames );
virtual void processTimer( int _frames );
bool m_isFiring;
};
#endif

View File

@ -24,7 +24,6 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{ // NPC_LINEAR_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_FIXED_PATH,
1,
//512,
2048,
@ -40,7 +39,6 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{ // NPC_CIRCULAR_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_FIXED_CIRCULAR,
3,
128,
true,
@ -55,7 +53,6 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{ // NPC_BUBBLE_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_BUBBLE,
3,
128,
true,
@ -70,7 +67,6 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{ // NPC_COLLAPSING_BUBBLE_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_STATIC,
3,
128,
true,
@ -85,22 +81,6 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{ // NPC_FISH_HOOK_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_STATIC,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE_FISH_HOOK,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_RETRACTING_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_STATIC,
3,
128,
true,
@ -109,13 +89,26 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
4,
NPC_PLATFORM_INFINITE_LIFE,
0,
NPC_PLATFORM_TIMER_RETRACT,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_RETRACTING_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_GEYSER_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_STATIC,
8,
128,
true,
@ -124,13 +117,12 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
4,
NPC_PLATFORM_INFINITE_LIFE,
4,
NPC_PLATFORM_TIMER_GEYSER,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_BOBBING_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_BOB,
0,
128,
true,
@ -145,7 +137,6 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{ // NPC_FALLING_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_FALL,
4,
128,
true,
@ -160,7 +151,6 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{ // NPC_CART_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_CART,
4,
128,
true,
@ -175,7 +165,6 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
{ // NPC_PLAYER_BUBBLE_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
NPC_PLATFORM_MOVEMENT_PLAYER_BUBBLE,
3,
128,
true,

View File

@ -1,6 +1,6 @@
/*=========================================================================
nplatfrm.cpp
platform.cpp
Author: CRB
Created:
@ -11,7 +11,7 @@
===========================================================================*/
#include "enemy\nplatfrm.h"
#include "platform\platform.h"
#ifndef __LEVEL_LEVEL_H__
#include "level\level.h"
@ -43,12 +43,161 @@
#include "system\vid.h"
#endif
#ifndef __PLATFORM_PLINEAR_H__
#include "platform\plinear.h"
#endif
#ifndef __PLATFORM_PCIRCULR_H__
#include "platform\pcirculr.h"
#endif
#ifndef __PLATFORM_PBUBBLE_H__
#include "platform\pbubble.h"
#endif
#ifndef __PLATFORM_PCBUBBLE_H__
#include "platform\pcbubble.h"
#endif
#ifndef __PLATFORM_PFISHHK_H__
#include "platform\pfishhk.h"
#endif
#ifndef __PLATFORM_PRETRACT_H__
#include "platform\pretract.h"
#endif
#ifndef __PLATFORM_PGEYSER_H__
#include "platform\pgeyser.h"
#endif
#ifndef __PLATFORM_PBOB_H__
#include "platform\pbob.h"
#endif
#ifndef __PLATFORM_PFALLING_H__
#include "platform\pfalling.h"
#endif
#ifndef __PLATFORM_PPLAYER_H__
#include "platform\pplayer.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CLayerCollision *CNpcPlatform::m_layerCollision;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform)
{
int pointNum;
CNpcPlatform *platform;
NPC_PLATFORM_UNIT_TYPE platformType = getTypeFromMapEdit( ThisPlatform->Type );
switch( platformType )
{
case NPC_LINEAR_PLATFORM:
{
platform = new ("linear platform") CNpcLinearPlatform;
break;
}
case NPC_CIRCULAR_PLATFORM:
{
platform = new ("circular platform") CNpcCircularPlatform;
break;
}
case NPC_BUBBLE_PLATFORM:
{
platform = new ("bubble platform") CNpcBubblePlatform;
break;
}
case NPC_COLLAPSING_BUBBLE_PLATFORM:
{
platform = new ("collapsing bubble platform") CNpcCollapsingBubblePlatform;
break;
}
case NPC_FISH_HOOK_PLATFORM:
{
platform = new ("fish hook platform") CNpcFishHookPlatform;
break;
}
case NPC_RETRACTING_PLATFORM:
{
platform = new ("retracting platform") CNpcRetractingPlatform;
break;
}
case NPC_GEYSER_PLATFORM:
{
platform = new ("geyser platform") CNpcGeyserPlatform;
break;
}
case NPC_BOBBING_PLATFORM:
{
platform = new ("bobbing platform") CNpcBobbingPlatform;
break;
}
case NPC_FALLING_PLATFORM:
{
platform = new ("falling platform") CNpcFallingPlatform;
break;
}
default:
{
platform = new ("platform") CNpcPlatform;
break;
}
}
ASSERT(platform);
platform->setType( platformType );
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
u16 newXPos, newYPos;
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4;
platform->init( startPos );
platform->setTiltable( false );
platform->addWaypoint( newXPos, newYPos );
if ( ThisPlatform->PointCount > 1 )
{
for ( pointNum = 1 ; pointNum < ThisPlatform->PointCount ; pointNum++ )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
platform->addWaypoint( newXPos, newYPos );
}
}
return( platform );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::init()
{
CPlatformThing::init();
@ -70,7 +219,6 @@ void CNpcPlatform::init()
m_timer = m_data[m_type].initTimer * GameState::getOneSecondInFrames();
m_timerType = m_data[m_type].initTimerType;
m_isActive = true;
m_movementFunc = m_data[m_type].movementFunc;
m_detectCollision = m_data[m_type].detectCollision;
m_state = 0;
m_tiltAngle = 0;
@ -86,23 +234,6 @@ void CNpcPlatform::init()
m_lifetimeType = m_data[m_type].lifetimeType;
m_npcPath.initPath();
if ( m_type == NPC_LINEAR_PLATFORM || m_type == NPC_CART_PLATFORM )
{
m_npcPath.setPathType( CNpcPath::PONG_PATH );
}
else if ( m_type == NPC_GEYSER_PLATFORM )
{
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
}
else if ( m_type == NPC_FALLING_PLATFORM )
{
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
}
else
{
m_extension = 100;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -141,7 +272,6 @@ void CNpcPlatform::reinit()
m_timer = m_data[m_type].initTimer * GameState::getOneSecondInFrames();
m_timerType = m_data[m_type].initTimerType;
m_isActive = true;
m_movementFunc = m_data[m_type].movementFunc;
m_detectCollision = m_data[m_type].detectCollision;
m_state = 0;
m_tiltAngle = 0;
@ -149,18 +279,13 @@ void CNpcPlatform::reinit()
m_lifetime = m_initLifetime;
if ( m_type == NPC_LINEAR_PLATFORM )
{
Pos = m_initPos;
Pos = m_initPos;
}
m_extension = 0;
}
else
{
Pos = m_initPos;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
m_extension = 100;
}
void CNpcPlatform::postInit()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -176,6 +301,61 @@ void CNpcPlatform::shutdown()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::processLifetime( int _frames )
{
switch( m_lifetimeType )
{
case NPC_PLATFORM_FINITE_LIFE:
{
m_lifetime -= _frames;
if ( m_lifetime <= 0 )
{
shutdown();
delete this;
return;
}
break;
}
case NPC_PLATFORM_FINITE_LIFE_RESPAWN:
{
m_lifetime -= _frames;
if ( m_lifetime <= 0 )
{
reinit();
}
break;
}
case NPC_PLATFORM_INFINITE_LIFE_COLLAPSIBLE:
{
if ( m_contact )
{
m_lifetime -= _frames;
if ( m_lifetime <= 0 )
{
m_isActive = false;
m_timer = 3 * GameState::getOneSecondInFrames();
m_timerType = NPC_PLATFORM_TIMER_RESPAWN;
}
}
break;
}
default:
break;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::think(int _frames)
{
@ -186,65 +366,7 @@ void CNpcPlatform::think(int _frames)
processTilt( _frames );
}
switch( m_lifetimeType )
{
case NPC_PLATFORM_FINITE_LIFE:
{
m_lifetime -= _frames;
if ( m_lifetime <= 0 )
{
shutdown();
delete this;
return;
}
break;
}
case NPC_PLATFORM_FINITE_LIFE_RESPAWN:
{
m_lifetime -= _frames;
if ( m_lifetime <= 0 )
{
reinit();
}
break;
}
case NPC_PLATFORM_INFINITE_LIFE_COLLAPSIBLE:
{
if ( m_contact )
{
m_lifetime -= _frames;
if ( m_lifetime <= 0 )
{
m_isActive = false;
m_timer = 3 * GameState::getOneSecondInFrames();
m_timerType = NPC_PLATFORM_TIMER_RESPAWN;
}
}
break;
}
case NPC_PLATFORM_INFINITE_LIFE_FISH_HOOK:
{
if ( m_contact )
{
m_movementFunc = NPC_PLATFORM_MOVEMENT_FISH_HOOK;
}
break;
}
default:
break;
}
processLifetime( _frames );
if ( m_animPlaying )
{
@ -383,52 +505,6 @@ void CNpcPlatform::processTimer( int _frames )
break;
}
case NPC_PLATFORM_TIMER_RETRACT:
{
if ( m_timer > 0 )
{
m_timer -= _frames;
}
else
{
m_timer = 4 * GameState::getOneSecondInFrames();
m_timerType = NPC_PLATFORM_TIMER_EXTEND;
m_detectCollision = false;
}
break;
}
case NPC_PLATFORM_TIMER_EXTEND:
{
if ( m_timer > 0 )
{
m_timer -= _frames;
}
else
{
m_timer = 4 * GameState::getOneSecondInFrames();
m_timerType = NPC_PLATFORM_TIMER_RETRACT;
m_detectCollision = true;
}
break;
}
case NPC_PLATFORM_TIMER_GEYSER:
{
if ( m_timer > 0 )
{
m_timer -= _frames;
}
else
{
m_movementFunc = NPC_PLATFORM_MOVEMENT_GEYSER;
}
break;
}
}
}
@ -463,367 +539,8 @@ void CNpcPlatform::collidedWith( CThing *_thisThing )
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::processGenericCircularPath( int _frames )
void CNpcPlatform::processMovement( int _frames )
{
m_rotation += m_data[m_type].speed;
m_rotation &= 4095;
Pos.vx = m_base.vx + ( ( m_extension * rcos( m_rotation ) ) >> 12 );
Pos.vy = m_base.vy + ( ( m_extension * rsin( m_rotation ) ) >> 12 );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY, s32 *moveVel, s32 *moveDist )
{
bool pathComplete;
bool waypointChange;
s16 headingToTarget = m_npcPath.think( Pos, &pathComplete, &waypointChange );
if ( !pathComplete )
{
s16 decDir, incDir;
s16 maxTurnRate = m_data[m_type].turnSpeed;
decDir = m_heading - headingToTarget;
if ( decDir < 0 )
{
decDir += ONE;
}
incDir = headingToTarget - m_heading;
if ( incDir < 0 )
{
incDir += ONE;
}
if ( decDir < incDir )
{
*moveDist = -decDir;
}
else
{
*moveDist = incDir;
}
if ( *moveDist < -maxTurnRate )
{
*moveDist = -maxTurnRate;
}
else if ( *moveDist > maxTurnRate )
{
*moveDist = maxTurnRate;
}
m_heading += *moveDist;
m_heading &= 4095;
s32 preShiftX = _frames * m_data[m_type].speed * rcos( m_heading );
s32 preShiftY = _frames * m_data[m_type].speed * rsin( m_heading );
*moveX = preShiftX >> 12;
if ( !(*moveX) && preShiftX )
{
*moveX = preShiftX / abs( preShiftX );
}
*moveY = preShiftY >> 12;
if ( !(*moveY) && preShiftY )
{
*moveY = preShiftY / abs( preShiftY );
}
*moveVel = ( _frames * m_data[m_type].speed ) << 8;
//processGroundCollisionReverse( moveX, moveY );
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::processGeyserMove( int _frames, s32 *moveX, s32 *moveY )
{
s32 distX, distY, heading;
bool pathComplete;
m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading );
if ( pathComplete )
{
m_npcPath.resetPath();
reinit();
}
else
{
s32 minY, maxY;
m_npcPath.getPathYExtents( &minY, &maxY );
*moveY = m_data[m_type].speed * _frames;
if ( Pos.vy < ( minY + 64 ) )
{
s32 multiplier = Pos.vy - minY;
*moveY = ( multiplier * (*moveY) ) >> 6;
if ( *moveY < 1 )
{
*moveY = 1;
}
}
if ( heading == 3072 )
{
*moveY = -(*moveY);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::processFallingMove( int _frames, s32 *moveX, s32 *moveY )
{
s32 distX, distY, heading;
bool pathComplete;
m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading );
if ( pathComplete )
{
m_isActive = false;
m_timer = 4 * GameState::getOneSecondInFrames();
m_timerType = NPC_PLATFORM_TIMER_RESPAWN;
}
else
{
*moveY = m_data[m_type].speed * _frames;
if ( heading == 3072 )
{
*moveY = -(*moveY);
}
s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + (*moveX), Pos.vy + (*moveY), 16 );
if ( groundHeight < *moveY )
{
*moveY = groundHeight;
*moveX = 2 * _frames;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::processCartMove( int _frames, s32 *moveX, s32 *moveY )
{
s32 fallSpeed = 3;
s8 yMovement = fallSpeed * _frames;
s32 distX, distY, heading;
s32 groundHeight;
bool pathComplete;
m_npcPath.thinkFlat( Pos, &pathComplete, &distX, &distY, &heading );
*moveX = m_data[m_type].speed * _frames;
if ( heading == 2048 )
{
*moveX = -(*moveX);
}
// check for vertical movement
groundHeight = m_layerCollision->getHeightFromGround( ( Pos.vx + *moveX ), Pos.vy, yMovement + 16 );
if ( groundHeight <= yMovement )
{
// groundHeight <= yMovement indicates either just above ground or on or below ground
*moveY = groundHeight;
}
else
{
// fall
*moveY = yMovement;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::processBobMove( int _frames, s32 *moveX, s32 *moveY )
{
if ( m_contact )
{
CPlayer *player = GameScene.getPlayer();
DVECTOR playerPos = player->getPos();
int height = player->getHeightFromGroundNoPlatform( playerPos.vx, playerPos.vy );
// if stood on, increase velocity
if ( m_velocity < 0 )
{
m_velocity = 0;
}
else if ( m_velocity < 4 )
{
if ( height <= 0 )
{
m_velocity = 0;
}
else
{
m_velocity += 1;
}
}
m_state = NPC_BOB_MOVE;
}
else
{
if ( m_state == NPC_BOB_MOVE )
{
// otherwise drop velocity and ultimately reverse course
if ( m_velocity > -2 )
{
m_velocity--;
}
}
}
if ( m_velocity )
{
*moveY = m_velocity * _frames;
if ( Pos.vy + (*moveY) < m_initPos.vy )
{
Pos.vy = m_initPos.vy;
m_velocity = 0;
m_state = NPC_BOB_STOP;
*moveY = 0;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::processMovement(int _frames)
{
VECTOR rotPos;
DVECTOR newPos;
DVECTOR oldPos;
SVECTOR relPos;
if ( _frames > 2 )
{
_frames = 2;
}
s32 moveX = 0, moveY = 0;
s32 moveVel = 0;
s32 moveDist = 0;
switch( m_movementFunc )
{
case NPC_PLATFORM_MOVEMENT_FIXED_PATH:
{
processGenericFixedPathMove( _frames, &moveX, &moveY, &moveVel, &moveDist );
break;
}
case NPC_PLATFORM_MOVEMENT_FIXED_CIRCULAR:
{
processGenericCircularPath( _frames );
break;
}
case NPC_PLATFORM_MOVEMENT_FISH_HOOK:
{
moveY = -m_data[m_type].speed * _frames;
if ( Pos.vx + moveY < 0 )
{
shutdown();
}
break;
}
case NPC_PLATFORM_MOVEMENT_BUBBLE:
{
moveY = -m_data[m_type].speed * _frames;
break;
}
case NPC_PLATFORM_MOVEMENT_GEYSER:
{
processGeyserMove( _frames, &moveX, &moveY );
break;
}
case NPC_PLATFORM_MOVEMENT_FALL:
{
processFallingMove( _frames, &moveX, &moveY );
break;
}
case NPC_PLATFORM_MOVEMENT_BOB:
{
processBobMove( _frames, &moveX, &moveY );
break;
}
case NPC_PLATFORM_MOVEMENT_CART:
{
processCartMove( _frames, &moveX, &moveY );
break;
}
case NPC_PLATFORM_MOVEMENT_PLAYER_BUBBLE:
case NPC_PLATFORM_MOVEMENT_STATIC:
{
break;
}
default:
break;
}
int angleChange = 3;
Pos.vx += moveX;
Pos.vy += moveY;
/*CThing *thisThing = Next;
while ( thisThing )
{
newPos.vx = moveX;
newPos.vy = moveY;
thisThing->shove( newPos );
thisThing = thisThing->getNext();
}*/
//setCollisionAngle( ( getCollisionAngle() + angleChange ) % 4096 );
//setCollisionAngle( 512 );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1146,4 +863,11 @@ void CNpcPlatform::addWaypoint( s32 xPos, s32 yPos )
void CNpcPlatform::setTypeFromMapEdit( u16 newType )
{
m_type = mapEditConvertTable[newType];
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::getTypeFromMapEdit( u16 newType )
{
return( mapEditConvertTable[newType] );
}

View File

@ -1,6 +1,6 @@
/*=========================================================================
nplatfrm.h
platform.h
Author: CRB
Created:
@ -11,8 +11,8 @@
===========================================================================*/
#ifndef __ENEMY_NPLATFRM_H__
#define __ENEMY_NPLATFRM_H__
#ifndef __PLATFORM_PLATFORM_H__
#define __PLATFORM_PLATFORM_H__
//#include <dstructs.h>
@ -59,6 +59,7 @@ public:
void init();
void init( DVECTOR initPos );
void init( DVECTOR initPos, s32 initLifetime );
virtual void postInit();
void shutdown();
void think(int _frames);
void render();
@ -69,46 +70,25 @@ public:
virtual s32 getNewYPos( CThing *_thisThing );
void setTiltable( bool isTiltable );
void addWaypoint( s32 xPos, s32 yPos );
static NPC_PLATFORM_UNIT_TYPE getTypeFromMapEdit( u16 newType );
static CNpcPlatform *Create(sThingPlatform *ThisPlatform);
protected:
// NPC data structure definitions //
enum NPC_PLATFORM_MOVEMENT_FUNC
{
NPC_PLATFORM_MOVEMENT_STATIC = 0,
NPC_PLATFORM_MOVEMENT_FIXED_PATH = 1,
NPC_PLATFORM_MOVEMENT_FIXED_CIRCULAR,
NPC_PLATFORM_MOVEMENT_BUBBLE,
NPC_PLATFORM_MOVEMENT_FISH_HOOK,
NPC_PLATFORM_MOVEMENT_GEYSER,
NPC_PLATFORM_MOVEMENT_BOB,
NPC_PLATFORM_MOVEMENT_FALL,
NPC_PLATFORM_MOVEMENT_CART,
NPC_PLATFORM_MOVEMENT_PLAYER_BUBBLE,
};
enum NPC_PLATFORM_LIFETIME_TYPE
{
NPC_PLATFORM_FINITE_LIFE = 0,
NPC_PLATFORM_INFINITE_LIFE = 1,
NPC_PLATFORM_FINITE_LIFE_RESPAWN,
NPC_PLATFORM_INFINITE_LIFE_COLLAPSIBLE,
NPC_PLATFORM_INFINITE_LIFE_FISH_HOOK,
};
enum NPC_PLATFORM_TIMER_TYPE
{
NPC_PLATFORM_TIMER_NONE = 0,
NPC_PLATFORM_TIMER_RESPAWN = 1,
NPC_PLATFORM_TIMER_RETRACT,
NPC_PLATFORM_TIMER_EXTEND,
NPC_PLATFORM_TIMER_GEYSER,
};
enum NPC_BOB_STATE
{
NPC_BOB_STOP = 0,
NPC_BOB_MOVE = 1,
};
typedef struct NPC_PLATFORM_DATA_TYPE
@ -116,7 +96,6 @@ protected:
FileEquate ActorType;
// FileEquate animData;
u16 initAnim;
NPC_PLATFORM_MOVEMENT_FUNC movementFunc;
u8 speed;
u16 turnSpeed;
bool detectCollision;
@ -125,7 +104,7 @@ protected:
s32 lifetime;
NPC_PLATFORM_LIFETIME_TYPE lifetimeType;
s32 initTimer;
NPC_PLATFORM_TIMER_TYPE initTimerType;
u8 initTimerType;
}
NPC_PLATFORM_DATA;
@ -133,22 +112,15 @@ protected:
void reinit();
bool processSensor();
void processMovement( int _frames );
void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange );
virtual void processMovement( int _frames );
virtual void processLifetime( int _frames );
void processShot();
void processClose( int _frames );
void processCollision();
void processTimer( int _frames );
virtual void processTimer( int _frames );
void processTilt( int _frames );
bool isCollisionWithGround();
void processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY, s32 *moveVel, s32 *moveDist );
void processGenericCircularPath( int _frames );
void processGeyserMove( int _frames, s32 *moveX, s32 *moveY );
void processFallingMove( int _frames, s32 *moveX, s32 *moveY );
void processBobMove( int _frames, s32 *moveX, s32 *moveY );
void processCartMove( int _frames, s32 *moveX, s32 *moveY );
// data
static NPC_PLATFORM_DATA m_data[NPC_PLATFORM_TYPE_MAX];
@ -180,8 +152,7 @@ protected:
bool m_contact;
s32 m_timer;
bool m_isActive;
NPC_PLATFORM_TIMER_TYPE m_timerType;
NPC_PLATFORM_MOVEMENT_FUNC m_movementFunc;
u8 m_timerType;
bool m_detectCollision;
bool m_tiltable;
s32 m_tiltAngle;

View File

@ -55,38 +55,38 @@ void CNpcLinearPlatform::processMovement( int _frames )
if ( decDir < incDir )
{
*moveDist = -decDir;
moveDist = -decDir;
}
else
{
*moveDist = incDir;
moveDist = incDir;
}
if ( *moveDist < -maxTurnRate )
if ( moveDist < -maxTurnRate )
{
*moveDist = -maxTurnRate;
moveDist = -maxTurnRate;
}
else if ( *moveDist > maxTurnRate )
else if ( moveDist > maxTurnRate )
{
*moveDist = maxTurnRate;
moveDist = maxTurnRate;
}
m_heading += *moveDist;
m_heading += moveDist;
m_heading &= 4095;
s32 preShiftX = _frames * m_data[m_type].speed * rcos( m_heading );
s32 preShiftY = _frames * m_data[m_type].speed * rsin( m_heading );
*moveX = preShiftX >> 12;
if ( !(*moveX) && preShiftX )
moveX = preShiftX >> 12;
if ( !moveX && preShiftX )
{
*moveX = preShiftX / abs( preShiftX );
moveX = preShiftX / abs( preShiftX );
}
*moveY = preShiftY >> 12;
if ( !(*moveY) && preShiftY )
moveY = preShiftY >> 12;
if ( !moveY && preShiftY )
{
*moveY = preShiftY / abs( preShiftY );
moveY = preShiftY / abs( preShiftY );
}
//processGroundCollisionReverse( moveX, moveY );

View File

@ -23,7 +23,7 @@ class CNpcLinearPlatform : public CNpcPlatform
public:
virtual void postInit();
protected:
void processMovement( int _frames );
virtual void processMovement( int _frames );
};
#endif

View File

@ -15,6 +15,10 @@
#include "platform\pretract.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRetractingPlatform::postInit()

View File

@ -20,6 +20,16 @@
class CNpcRetractingPlatform : public CNpcPlatform
{
public:
virtual void postInit();
protected:
void processTimer( int _frames );
enum NPC_PLATFORM_TIMER_TYPE
{
NPC_PLATFORM_TIMER_RETRACT = 0,
NPC_PLATFORM_TIMER_EXTEND = 1,
};
};
#endif

View File

@ -17,8 +17,8 @@
#include "player\pmbubble.h"
#ifndef __ENEMY_NPLATFRM_H__
#include "enemy\nplatfrm.h"
#ifndef __PLATFORM_PPLAYER_H__
#include "platform\pplayer.h"
#endif
#ifndef __GFX_FONT_H__
@ -102,9 +102,9 @@ void CPlayerModeBubbleMixture::think()
if(!m_blowing&&getPadInputDown()&PI_ACTION&&canBlowBubbleFromThisState()&&m_player->getBubbleAmmo())
{
// Spawn the bubbly platform thingy..!
CNpcPlatform *bubble;
CNpcPlayerBubblePlatform *bubble;
DVECTOR pos;
bubble=new ("bubble platform") CNpcPlatform;
bubble=new ("bubble platform") CNpcPlayerBubblePlatform;
bubble->setType( CNpcPlatform::NPC_PLAYER_BUBBLE_PLATFORM );
pos=m_player->getPos();
pos.vx+=buboff.vx*m_player->getFacing();

View File

@ -277,14 +277,6 @@ SOURCE=..\..\..\source\enemy\npcpath.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\enemy\nplatfrm.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\enemy\nplatfrm.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\enemy\npuffa.cpp
# End Source File
# Begin Source File
@ -1356,6 +1348,102 @@ SOURCE=..\..\..\source\fmv\fmv.cpp
SOURCE=..\..\..\source\fmv\fmv.h
# End Source File
# End Group
# Begin Group "platform"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\source\platform\pbob.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pbob.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pbubble.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pbubble.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pcart.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pcart.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pcbubble.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pcirculr.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pcirculr.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pfalling.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pfalling.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pfishhk.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pfishhk.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pgeyser.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pgeyser.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\platdata.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\platform.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\platform.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\plinear.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\plinear.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pplayer.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pretract.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pretract.h
# End Source File
# End Group
# End Group
# Begin Group "makefiles"