This commit is contained in:
Charles 2001-07-23 14:16:26 +00:00
parent 6ec59f5ff7
commit 6c1bb7ecec
5 changed files with 142 additions and 34 deletions

View file

@ -23,6 +23,10 @@
#include "platform\platform.h" #include "platform\platform.h"
#endif #endif
#ifndef __PLATFORM_PCLAM_H__
#include "platform\pclam.h"
#endif
#ifndef __GAME_GAME_H__ #ifndef __GAME_GAME_H__
#include "game\game.h" #include "game\game.h"
#endif #endif
@ -218,21 +222,44 @@ void CNpcStaticClamEnemy::postInit()
platform->setTiltable( false ); platform->setTiltable( false );
platform->postInit(); platform->postInit();
CNpcClamPlatform *clamPlatform;
clamPlatform = (CNpcClamPlatform *) platform;
clamPlatform->setClam( this );
m_animPlaying = false; m_animPlaying = false;
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcStaticClamEnemy::processClose( int _frames ) void CNpcStaticClamEnemy::stoodOn()
{ {
if ( !m_animPlaying && m_isStunned == 0 ) if ( m_frame < ( 5 << 8 ) )
{ {
m_animPlaying = true; if ( m_frame != 0 )
m_animNo = ANIM_CLAM_SIDESNAP; {
m_frame = 0;
m_controlFunc = NPC_CONTROL_MOVEMENT; if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_CLAM_ATTACK, true );
}
}
m_isStunned = 2 * GameState::getOneSecondInFrames();
m_animPlaying = false;
} }
else
{
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcStaticClamEnemy::think( int _frames )
{
if ( m_isStunned ) if ( m_isStunned )
{ {
m_isStunned -= _frames; m_isStunned -= _frames;
@ -240,15 +267,32 @@ void CNpcStaticClamEnemy::processClose( int _frames )
if ( m_isStunned < 0 ) if ( m_isStunned < 0 )
{ {
m_isStunned = 0; m_isStunned = 0;
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_movementTimer = GameState::getOneSecondInFrames();
} }
} }
if ( !m_isStunned ) CNpcEnemy::think( _frames );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcStaticClamEnemy::processMovement( int _frames )
{
if ( !m_animPlaying && m_isStunned == 0 )
{ {
m_controlFunc = NPC_CONTROL_MOVEMENT; if ( m_movementTimer > 0 )
m_timerFunc = NPC_TIMER_ATTACK_DONE; {
m_timerTimer = GameState::getOneSecondInFrames(); m_movementTimer -= _frames;
m_sensorFunc = NPC_SENSOR_NONE; }
else
{
m_animPlaying = true;
m_animNo = ANIM_CLAM_SIDESNAP;
m_movementTimer = GameState::getOneSecondInFrames();
}
} }
} }
@ -262,25 +306,18 @@ void CNpcStaticClamEnemy::collidedWith( CThing *_thisThing )
{ {
case TYPE_PLAYER: case TYPE_PLAYER:
{ {
if ( m_frame < ( 5 << 8 ) ) CPlayer *player = (CPlayer *) _thisThing;
{
if ( m_frame != 0 )
{
m_frame = 0;
if ( m_soundId == NOT_PLAYING ) if ( m_isStunned <= 0 )
{
if ( !player->isRecoveringFromHit() )
{
//if ( m_frame >= ( 5 << 8 ) )
{ {
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_CLAM_ATTACK, true ); m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
} }
} }
m_isStunned = 2 * GameState::getOneSecondInFrames();
m_animPlaying = false;
}
else
{
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
} }
break; break;

View file

@ -14,6 +14,10 @@
#ifndef __ENEMY_NCLAM_H__ #ifndef __ENEMY_NCLAM_H__
#define __ENEMY_NCLAM_H__ #define __ENEMY_NCLAM_H__
#ifndef __ENEMY_NPC_H__
#include "enemy\npc.h"
#endif
class CNpcClamEnemy : public CNpcEnemy class CNpcClamEnemy : public CNpcEnemy
{ {
public: public:
@ -39,12 +43,15 @@ class CNpcStaticClamEnemy : public CNpcClamEnemy
{ {
public: public:
void postInit(); void postInit();
void think( int _frames );
u8 hasBeenAttacked() {return( false );} u8 hasBeenAttacked() {return( false );}
CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );} CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );}
void stoodOn();
protected: protected:
s32 getFrameShift( int _frames ); s32 getFrameShift( int _frames );
void collidedWith(CThing *_thisThing); void collidedWith(CThing *_thisThing);
void processClose( int _frames ); void processMovement( int _frames );
//void processClose( int _frames );
void processCollision(); void processCollision();
void processAnimFrames( int _frames ); void processAnimFrames( int _frames );

View file

@ -324,7 +324,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
{ // NPC_CLAM_STATIC { // NPC_CLAM_STATIC
ACTORS_CLAM_SBK, ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP, ANIM_CLAM_SIDESNAP,
NPC_SENSOR_USER_CLOSE, NPC_SENSOR_NONE,
NPC_MOVEMENT_STATIC, NPC_MOVEMENT_STATIC,
NPC_CLOSE_NONE, NPC_CLOSE_NONE,
NPC_TIMER_NONE, NPC_TIMER_NONE,

View file

@ -29,7 +29,7 @@
void CNpcClamPlatform::postInit() void CNpcClamPlatform::postInit()
{ {
sBBox boundingBox = m_modelGfx->GetBBox(); sBBox boundingBox = m_modelGfx->GetBBox();
setCollisionSize( 80, 30 ); setCollisionSize( 80, 34 );
setCollisionCentreOffset( 0, -15 ); setCollisionCentreOffset( 0, -15 );
calculateNonRotatedCollisionData(); calculateNonRotatedCollisionData();
@ -45,9 +45,65 @@ void CNpcClamPlatform::render()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*void CNpcClamPlatform::setBBox() void CNpcClamPlatform::collidedWith( CThing *_thisThing )
{ {
//setCollisionSize( 54, PLATFORMCOLLISIONHEIGHT); switch(_thisThing->getThingType())
//setCollisionSize( 54, 10 ); {
setCollisionCentreOffset( 50, -100 ); case TYPE_PLAYER:
}*/ {
CPlayer *player;
DVECTOR playerPos;
CRECT collisionArea;
CRECT playerCollisionArea;
// Only interested in SBs feet colliding with the box (pkg)
player=(CPlayer*)_thisThing;
playerPos=player->getPos();
playerCollisionArea = player->getCollisionArea();
collisionArea=getCollisionArea();
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
if ( threshold > 16 )
{
threshold = 16;
}
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
{
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
{
player->setPlatform( this );
m_clam->stoodOn();
m_contact = true;
}
else
{
if( playerPos.vy >= collisionArea.y1 && playerPos.vy <= collisionArea.y2 )
{
int height = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy );
if ( height >= -threshold && height < 1 )
{
player->setPlatform( this );
m_clam->stoodOn();
m_contact = true;
}
}
}
}
break;
}
case TYPE_NPC:
case TYPE_HAZARD:
break;
default:
ASSERT(0);
break;
}
}

View file

@ -18,13 +18,21 @@
#include "platform\platform.h" #include "platform\platform.h"
#endif #endif
#ifndef __ENEMY_NCLAM_H__
#include "enemy\nclam.h"
#endif
class CNpcClamPlatform : public CNpcPlatform class CNpcClamPlatform : public CNpcPlatform
{ {
public: public:
void postInit(); void postInit();
void render(); void render();
CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );} CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );}
//void setBBox(); void setClam( CNpcStaticClamEnemy *newClam) {m_clam=newClam;}
protected:
void collidedWith(CThing *_thisThing);
CNpcStaticClamEnemy *m_clam;
}; };
#endif #endif