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"
#endif
#ifndef __PLATFORM_PCLAM_H__
#include "platform\pclam.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
@ -218,49 +222,17 @@ void CNpcStaticClamEnemy::postInit()
platform->setTiltable( false );
platform->postInit();
CNpcClamPlatform *clamPlatform;
clamPlatform = (CNpcClamPlatform *) platform;
clamPlatform->setClam( this );
m_animPlaying = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcStaticClamEnemy::processClose( int _frames )
{
if ( !m_animPlaying && m_isStunned == 0 )
{
m_animPlaying = true;
m_animNo = ANIM_CLAM_SIDESNAP;
m_controlFunc = NPC_CONTROL_MOVEMENT;
}
if ( m_isStunned )
{
m_isStunned -= _frames;
if ( m_isStunned < 0 )
{
m_isStunned = 0;
}
}
if ( !m_isStunned )
{
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE;
m_timerTimer = GameState::getOneSecondInFrames();
m_sensorFunc = NPC_SENSOR_NONE;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcStaticClamEnemy::collidedWith( CThing *_thisThing )
{
if ( m_isActive && !m_isCaught && !m_isDying )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
void CNpcStaticClamEnemy::stoodOn()
{
if ( m_frame < ( 5 << 8 ) )
{
@ -282,6 +254,71 @@ void CNpcStaticClamEnemy::collidedWith( CThing *_thisThing )
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcStaticClamEnemy::think( int _frames )
{
if ( m_isStunned )
{
m_isStunned -= _frames;
if ( m_isStunned < 0 )
{
m_isStunned = 0;
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_movementTimer = GameState::getOneSecondInFrames();
}
}
CNpcEnemy::think( _frames );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcStaticClamEnemy::processMovement( int _frames )
{
if ( !m_animPlaying && m_isStunned == 0 )
{
if ( m_movementTimer > 0 )
{
m_movementTimer -= _frames;
}
else
{
m_animPlaying = true;
m_animNo = ANIM_CLAM_SIDESNAP;
m_movementTimer = GameState::getOneSecondInFrames();
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcStaticClamEnemy::collidedWith( CThing *_thisThing )
{
if ( m_isActive && !m_isCaught && !m_isDying )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
if ( m_isStunned <= 0 )
{
if ( !player->isRecoveringFromHit() )
{
//if ( m_frame >= ( 5 << 8 ) )
{
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
}
}
}
break;
}

View file

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

View file

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

View file

@ -29,7 +29,7 @@
void CNpcClamPlatform::postInit()
{
sBBox boundingBox = m_modelGfx->GetBBox();
setCollisionSize( 80, 30 );
setCollisionSize( 80, 34 );
setCollisionCentreOffset( 0, -15 );
calculateNonRotatedCollisionData();
@ -45,9 +45,65 @@ void CNpcClamPlatform::render()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*void CNpcClamPlatform::setBBox()
void CNpcClamPlatform::collidedWith( CThing *_thisThing )
{
//setCollisionSize( 54, PLATFORMCOLLISIONHEIGHT);
//setCollisionSize( 54, 10 );
setCollisionCentreOffset( 50, -100 );
}*/
switch(_thisThing->getThingType())
{
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"
#endif
#ifndef __ENEMY_NCLAM_H__
#include "enemy\nclam.h"
#endif
class CNpcClamPlatform : public CNpcPlatform
{
public:
void postInit();
void render();
CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );}
//void setBBox();
void setClam( CNpcStaticClamEnemy *newClam) {m_clam=newClam;}
protected:
void collidedWith(CThing *_thisThing);
CNpcStaticClamEnemy *m_clam;
};
#endif