diff --git a/source/enemy/nhcrab.cpp b/source/enemy/nhcrab.cpp index c65d1835d..0333b23cb 100644 --- a/source/enemy/nhcrab.cpp +++ b/source/enemy/nhcrab.cpp @@ -65,7 +65,21 @@ void CNpcHermitCrabEnemy::processClose( int _frames ) { if ( m_state == HERMIT_CRAB_NO_ATTACK ) { - m_state = ( getRnd() % 2 ) + 1; + //m_state = ( getRnd() % 2 ) + 1; + m_state = HERMIT_CRAB_ROLL_ATTACK_JUMP1; + m_movementTimer = 0; + m_jumpBase = Pos.vy; + + if ( playerXDist > 0 ) + { + m_extendDir = EXTEND_RIGHT; + m_heading = 0; + } + else + { + m_extendDir = EXTEND_LEFT; + m_heading = 2048; + } } switch( m_state ) @@ -90,7 +104,26 @@ void CNpcHermitCrabEnemy::processClose( int _frames ) break; } - case HERMIT_CRAB_ROLL_ATTACK: + case HERMIT_CRAB_ROLL_ATTACK_JUMP1: + case HERMIT_CRAB_ROLL_ATTACK_JUMP2: + { + s16 sineVal = ( m_movementTimer << 11 ) / ( GameState::getOneSecondInFrames() >> 3 ); + Pos.vy = m_jumpBase - ( ( 10 * rsin( sineVal ) ) >> 12 ); + + if ( m_movementTimer < ( GameState::getOneSecondInFrames() >> 3 ) ) + { + m_movementTimer++; + } + else + { + m_state++; + m_movementTimer = 0; + } + + break; + } + + case HERMIT_CRAB_ROLL_ATTACK_ROLL: { if ( !m_animPlaying || m_animNo == m_data[m_type].moveAnim ) { @@ -102,15 +135,6 @@ void CNpcHermitCrabEnemy::processClose( int _frames ) m_animNo = ANIM_HERMITCRAB_ROLLATTACK; m_frame = 0; - if ( playerXDist > 0 ) - { - m_extendDir = EXTEND_RIGHT; - } - else - { - m_extendDir = EXTEND_LEFT; - } - break; } diff --git a/source/enemy/nhcrab.h b/source/enemy/nhcrab.h index 31ac3a597..771648cb9 100644 --- a/source/enemy/nhcrab.h +++ b/source/enemy/nhcrab.h @@ -27,11 +27,15 @@ protected: virtual bool processSensor(); virtual void processClose( int _frames ); + s32 m_jumpBase; + enum NPC_HERMIT_CRAB_STATE { HERMIT_CRAB_NO_ATTACK = 0, HERMIT_CRAB_PUNCH_ATTACK = 1, - HERMIT_CRAB_ROLL_ATTACK, + HERMIT_CRAB_ROLL_ATTACK_JUMP1, + HERMIT_CRAB_ROLL_ATTACK_JUMP2, + HERMIT_CRAB_ROLL_ATTACK_ROLL, }; }; diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 6497921a1..5e491b1ad 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -1456,6 +1456,21 @@ void CNpcEnemy::processEnemyCollision( CThing *thisThing ) Pos.vx += otherDelta.vx; + if ( m_npcPath.getWaypointCount() ) + { + s32 minX, maxX; + m_npcPath.getPathXExtents( &minX, &maxX ); + + if ( Pos.vx < minX ) + { + Pos.vx = minX; + } + else if ( Pos.vx > maxX ) + { + Pos.vx = maxX; + } + } + s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, 16 ); if ( groundHeight < 8 ) diff --git a/source/enemy/npcpath.h b/source/enemy/npcpath.h index 9f3fce75f..ce55b0a8f 100644 --- a/source/enemy/npcpath.h +++ b/source/enemy/npcpath.h @@ -50,6 +50,7 @@ public: bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ); void getPathXExtents( s32 *minExtent, s32 *maxExtent ); void getPathYExtents( s32 *minExtent, s32 *maxExtent ); + u8 getWaypointCount() { return( waypointCount ); } CNpcWaypoint *getWaypointList(); private: diff --git a/source/enemy/nsjfish.h b/source/enemy/nsjfish.h index 541a1bb2d..46c95b049 100644 --- a/source/enemy/nsjfish.h +++ b/source/enemy/nsjfish.h @@ -26,7 +26,7 @@ class CNpcSmallJellyfishEnemy : public CNpcEnemy { public: virtual void render(); - virtual int getFrameCount() {return( FRM_JELLYFISH1_SWIM6 - FRM_JELLYFISH1_SWIM1 + 1 );} + virtual int getFrameCount() {return( FRM_JELLYFISH1_SWIM7 - FRM_JELLYFISH1_SWIM1 + 1 );} virtual u8 canCollideWithEnemy() {return( false );} protected: virtual bool processSensor();