diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index f937d1d0e..3188d69e2 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -3,9 +3,9 @@ nanemone.cpp Author: CRB - Created: + Created: Project: Spongebob - Purpose: + Purpose: Copyright (c) 2000 Climax Development Ltd @@ -39,6 +39,12 @@ #include #endif +void CNpcAnemoneEnemy::postInit() +{ + CNpcEnemy::postInit(); + m_drawRotation = m_heading + 1024; +} + void CNpcAnemoneEnemy::processEnemyCollision( CThing *thisThing ) { // do nothing @@ -207,6 +213,10 @@ void CNpcAnemone2Enemy::postInit() heading &= 4095; spikePos = Pos; + + spikePos.vx += ( 10 * rcos( m_heading ) ) >> 12; + spikePos.vy += ( 10 * rsin( m_heading ) ) >> 12; + spikePos.vx += ( 40 * rcos( heading ) ) >> 12; spikePos.vy += ( 40 * rsin( heading ) ) >> 12; @@ -216,6 +226,14 @@ void CNpcAnemone2Enemy::postInit() addChild( projectile ); } + + m_drawRotation = m_heading + 1024; +} + +void CNpcAnemone2Enemy::shutdown() +{ + deleteAllChild(); + CNpcEnemy::shutdown(); } void CNpcAnemone2Enemy::processClose( int _frames ) @@ -267,6 +285,10 @@ void CNpcAnemone2Enemy::processClose( int _frames ) heading &= 4095; spikePos = Pos; + + spikePos.vx += ( 10 * rcos( m_heading ) ) >> 12; + spikePos.vy += ( 10 * rsin( m_heading ) ) >> 12; + spikePos.vx += ( 40 * rcos( heading ) ) >> 12; spikePos.vy += ( 40 * rsin( heading ) ) >> 12; diff --git a/source/enemy/nanemone.h b/source/enemy/nanemone.h index 5c5f876db..3f4fbf32d 100644 --- a/source/enemy/nanemone.h +++ b/source/enemy/nanemone.h @@ -20,6 +20,8 @@ class CNpcAnemoneEnemy : public CNpcEnemy { +public: + virtual void postInit(); protected: virtual void processEnemyCollision( CThing *thisThing ); virtual bool processSensor(); @@ -35,6 +37,7 @@ class CNpcAnemone2Enemy : public CNpcAnemoneEnemy { public: virtual void postInit(); + virtual void shutdown(); protected: virtual void processClose( int _frames ); }; diff --git a/source/enemy/ngen.cpp b/source/enemy/ngen.cpp index 238434177..b7e799dec 100644 --- a/source/enemy/ngen.cpp +++ b/source/enemy/ngen.cpp @@ -29,6 +29,14 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcEnemyGenerator::shutdown() +{ + deleteAllChild(); + CNpcEnemy::shutdown(); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcEnemyGenerator::think(int _frames) { if ( getNumChildren() < 3 ) diff --git a/source/enemy/ngen.h b/source/enemy/ngen.h index 025e263c6..ae05b8ff7 100644 --- a/source/enemy/ngen.h +++ b/source/enemy/ngen.h @@ -21,9 +21,11 @@ class CNpcEnemyGenerator : public CNpcEnemy { public: + virtual void shutdown(); virtual void processEnemyCollision( CThing *thisThing ); void render(); void think(int _frames); + virtual u8 canCollideWithEnemy() {return( false );} }; #endif \ No newline at end of file diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 32657cb6c..deddad135 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -804,8 +804,6 @@ void CNpcEnemy::shutdown() if (m_actorGfx) delete m_actorGfx; - deleteAllChild(); - CEnemyThing::shutdown(); } @@ -985,7 +983,12 @@ void CNpcEnemy::collidedWith( CThing *_thisThing ) case TYPE_ENEMY: { - processEnemyCollision( _thisThing ); + CNpcEnemy *enemy = (CNpcEnemy *) _thisThing; + + if ( enemy->canCollideWithEnemy() ) + { + processEnemyCollision( _thisThing ); + } break; } @@ -1517,11 +1520,11 @@ void CNpcEnemy::processEnemyCollision( CThing *thisThing ) if ( yDist > 0 ) { - Pos.vy += 6; + Pos.vy += 3; } else { - Pos.vy -= 6; + Pos.vy -= 3; } Pos.vx += otherDelta.vx; diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 2b6870d4c..754a7d140 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -160,12 +160,14 @@ public: void init(); virtual void postInit(); - void shutdown(); + virtual void shutdown(); + virtual u8 canCollideWithEnemy() {return( true );} virtual void think(int _frames); virtual void render(); void processEvent( GAME_EVENT evt, CThing *sourceThing ); void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} void setType( NPC_UNIT_TYPE newType ) {m_type = newType;} + NPC_UNIT_TYPE getType() {return( m_type );} static NPC_UNIT_TYPE getTypeFromMapEdit( u16 newType ); void setHeading( s32 newHeading ) {m_heading = newHeading;} void setHeading( s32 xPos, s32 yPos ); diff --git a/source/enemy/nscrab.cpp b/source/enemy/nscrab.cpp index 0009c2661..e567dc28c 100644 --- a/source/enemy/nscrab.cpp +++ b/source/enemy/nscrab.cpp @@ -38,7 +38,7 @@ void CNpcSpiderCrabEnemy::postInit() { m_npcPath.setPathType( CNpcPath::PONG_PATH ); - if ( m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, 16 ) < 0 ) + if ( m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy - 8, 16 ) <= 0 ) { // starting off below ground, jump initially @@ -251,7 +251,7 @@ void CNpcSpiderCrabEnemy::processSpiderCrabInitJumpMovement( int _frames ) Pos.vy = m_base.vy - ( ( 50 * rsin( abs( m_extension ) << 4 ) ) >> 12 ); - if ( m_extension > 64 ) + /*if ( m_extension > 64 ) { // check for collision on the way back down @@ -262,6 +262,11 @@ void CNpcSpiderCrabEnemy::processSpiderCrabInitJumpMovement( int _frames ) } if ( completed || collision ) + { + m_state = SPIDER_CRAB_DEFAULT; + }*/ + + if ( m_extension > 64 ) { m_state = SPIDER_CRAB_DEFAULT; } @@ -319,3 +324,20 @@ void CNpcSpiderCrabEnemy::processMovementModifier( int _frames, s32 distX, s32 d m_drawRotation = heading; } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcSpiderCrabEnemy::processEnemyCollision( CThing *thisThing ) +{ + if ( m_state != SPIDER_CRAB_INIT_JUMP ) + { + CNpcEnemy::processEnemyCollision( thisThing ); + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +u8 CNpcSpiderCrabEnemy::canCollideWithEnemy() +{ + return( m_state != SPIDER_CRAB_INIT_JUMP ); +} diff --git a/source/enemy/nscrab.h b/source/enemy/nscrab.h index 5bb889d37..21523bda2 100644 --- a/source/enemy/nscrab.h +++ b/source/enemy/nscrab.h @@ -22,6 +22,8 @@ class CNpcSpiderCrabEnemy : public CNpcEnemy { public: virtual void postInit(); + virtual u8 canCollideWithEnemy(); + virtual void processEnemyCollision( CThing *thisThing ); protected: virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); virtual bool processSensor(); diff --git a/source/enemy/nworm.cpp b/source/enemy/nworm.cpp index 3cb04ffc8..de836a963 100644 --- a/source/enemy/nworm.cpp +++ b/source/enemy/nworm.cpp @@ -98,6 +98,12 @@ void CNpcParasiticWormEnemy::postInit() m_movementTimer = 2 * GameState::getOneSecondInFrames(); } +void CNpcParasiticWormEnemy::shutdown() +{ + deleteAllChild(); + CNpcEnemy::shutdown(); +} + void CNpcParasiticWormSegment::postInit() { } diff --git a/source/enemy/nworm.h b/source/enemy/nworm.h index 29a33485b..4e426fdaf 100644 --- a/source/enemy/nworm.h +++ b/source/enemy/nworm.h @@ -18,6 +18,7 @@ class CNpcParasiticWormEnemy : public CNpcEnemy { public: virtual void postInit(); + virtual void shutdown(); protected: virtual bool processSensor(); virtual void processClose( int _frames );