From ce0c6759fb4e4e2072a6eac9eb6357ef86de54af Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 21 May 2001 19:18:35 +0000 Subject: [PATCH] --- source/enemy/nclam.cpp | 67 ++++++++++++++++++++++++++++++++++++++---- source/enemy/nclam.h | 2 ++ 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/source/enemy/nclam.cpp b/source/enemy/nclam.cpp index e563aef44..de10f1195 100644 --- a/source/enemy/nclam.cpp +++ b/source/enemy/nclam.cpp @@ -44,16 +44,22 @@ #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcClamEnemy::processEnemyCollision( CThing *thisThing ) { // do nothing } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcClamEnemy::processUserCollision( CThing *thisThing ) { // do nothing } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool CNpcClamEnemy::processSensor() { switch( m_sensorFunc ) @@ -81,6 +87,8 @@ bool CNpcClamEnemy::processSensor() } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcJumpingClamEnemy::postInit() { CNpcClamEnemy::postInit(); @@ -88,6 +96,8 @@ void CNpcJumpingClamEnemy::postInit() m_drawRotation = m_heading + 1024; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcJumpingClamEnemy::processClose( int _frames ) { s32 velocity; @@ -151,6 +161,8 @@ void CNpcJumpingClamEnemy::processClose( int _frames ) } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcStaticClamEnemy::postInit() { CNpcClamEnemy::postInit(); @@ -170,26 +182,32 @@ void CNpcStaticClamEnemy::postInit() platform->postInit(); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcStaticClamEnemy::processClose( int _frames ) { - if ( !m_isAnimating && !m_isStunned ) + if ( !m_animPlaying && !m_isStunned ) { m_animPlaying = true; m_animNo = ANIM_CLAM_SIDESNAP; m_frame = 0; - m_isAnimating = true; } - else if ( !m_animPlaying ) + /*else if ( !m_animPlaying ) { m_controlFunc = NPC_CONTROL_MOVEMENT; m_animNo = m_data[m_type].initAnim; m_frame = 0; m_isAnimating = false; - } + }*/ - m_isStunned = false; + if ( m_isStunned ) + { + m_isStunned = false; + } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcStaticClamEnemy::collidedWith( CThing *_thisThing ) { if ( m_isActive && !m_isCaught && !m_isDying ) @@ -198,7 +216,18 @@ void CNpcStaticClamEnemy::collidedWith( CThing *_thisThing ) { case TYPE_PLAYER: { - m_isStunned = true; + if ( m_frame < ( 5 << 8 ) ) + { + m_animNo = ANIM_CLAM_SIDESNAP; + m_frame = 0; + m_isStunned = true; + m_animPlaying = false; + } + else + { + m_oldControlFunc = m_controlFunc; + m_controlFunc = NPC_CONTROL_COLLISION; + } break; } @@ -208,3 +237,29 @@ void CNpcStaticClamEnemy::collidedWith( CThing *_thisThing ) } } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcStaticClamEnemy::processCollision() +{ + CPlayer *player = GameScene.getPlayer(); + + player->takeDamage( m_data[m_type].damageToUserType,REACT__GET_DIRECTION_FROM_THING,(CThing*)this ); + processUserCollision( (CThing *) player ); + + m_controlFunc = m_oldControlFunc; + + if ( !m_animPlaying && !m_isStunned ) + { + m_animPlaying = true; + m_animNo = ANIM_CLAM_SIDESNAP; + m_frame = 0; + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +s32 CNpcStaticClamEnemy::getFrameShift( int _frames ) +{ + return( ( _frames << 8 ) >> 2 ); +} diff --git a/source/enemy/nclam.h b/source/enemy/nclam.h index 9bb067f8a..7ee691018 100644 --- a/source/enemy/nclam.h +++ b/source/enemy/nclam.h @@ -38,8 +38,10 @@ public: virtual void postInit(); virtual u8 hasBeenAttacked() {return( false );} protected: + virtual s32 getFrameShift( int _frames ); virtual void collidedWith(CThing *_thisThing); virtual void processClose( int _frames ); + virtual void processCollision(); u8 m_isStunned; u8 m_isAnimating;