diff --git a/source/enemy/ndogfish.cpp b/source/enemy/ndogfish.cpp index 5681ad3f5..0c56d3de3 100644 --- a/source/enemy/ndogfish.cpp +++ b/source/enemy/ndogfish.cpp @@ -39,7 +39,6 @@ #include "system\vid.h" #endif -#include "fx\fx.h" #include "fx\fxnrgbar.h" @@ -72,7 +71,7 @@ bool CNpcIronDogfishEnemy::processSensor() default: { - if ( playerXDistSqr + playerYDistSqr < 5000 ) + if ( m_movementTimer > 0 && playerXDistSqr + playerYDistSqr < 5000 ) { m_controlFunc = NPC_CONTROL_CLOSE; @@ -140,32 +139,12 @@ void CNpcIronDogfishEnemy::processWalkToUser( int _frames, int speed ) if ( playerXDist > 0 ) { m_heading = 0; - - if ( Pos.vx + playerXDist > maxX ) - { - // abort - - m_movementTimer = GameState::getOneSecondInFrames() * 3; - } - else - { - Pos.vx += _frames * speed; - } + Pos.vx += _frames * speed; } else { m_heading = 2048; - - if ( Pos.vx + playerXDist < minX ) - { - // abort - - m_movementTimer = GameState::getOneSecondInFrames() * 3; - } - else - { - Pos.vx -= _frames * speed; - } + Pos.vx -= _frames * speed; } s32 fallSpeed = 3; @@ -190,13 +169,18 @@ void CNpcIronDogfishEnemy::processWalkToUser( int _frames, int speed ) void CNpcIronDogfishEnemy::processStandardIronDogfishAttack( int _frames ) { - if ( playerXDist > 0 ) + if ( m_state != IRON_DOGFISH_LASER_EYE_1_WAIT && m_state != IRON_DOGFISH_LASER_EYE_2_WAIT ) { - m_extendDir = EXTEND_RIGHT; - } - else - { - m_extendDir = EXTEND_LEFT; + if ( playerXDist > 0 ) + { + m_extendDir = EXTEND_RIGHT; + m_heading = 0; + } + else + { + m_extendDir = EXTEND_LEFT; + m_heading = 2048; + } } switch( m_state ) @@ -204,7 +188,27 @@ void CNpcIronDogfishEnemy::processStandardIronDogfishAttack( int _frames ) case IRON_DOGFISH_THUMP_1: case IRON_DOGFISH_THUMP_2: { - if ( playerXDistSqr > 100 ) + s32 minX, maxX; + m_npcPath.getPathXExtents( &minX, &maxX ); + + u8 thump = false; + + if ( playerXDist > 0 ) + { + if ( Pos.vx + playerXDist > maxX ) + { + thump = true; + } + } + else + { + if ( Pos.vx + playerXDist < minX ) + { + thump = true; + } + } + + if ( playerXDistSqr > 100 && !thump ) { if ( !m_animPlaying ) { @@ -238,23 +242,75 @@ void CNpcIronDogfishEnemy::processStandardIronDogfishAttack( int _frames ) case IRON_DOGFISH_LASER_EYE_1: case IRON_DOGFISH_LASER_EYE_2: { + if ( m_animNo != ANIM_IRONDOGFISH_IDLE || !m_animPlaying ) + { + m_animPlaying = true; + m_animNo = ANIM_IRONDOGFISH_IDLE; + m_frame = 0; + } + // fire at user s16 headingToPlayer = ratan2( playerYDist, playerXDist ) & 4095; - CProjectile *projectile; + /*CProjectile *projectile; projectile = CProjectile::Create(); DVECTOR startPos = Pos; startPos.vy -= 20; - projectile->init( startPos, headingToPlayer ); + projectile->init( startPos, headingToPlayer );*/ + + m_laserTimer = GameState::getOneSecondInFrames(); + + m_effect = (CFXLaser*) CFX::Create( CFX::FX_TYPE_LASER, this ); + DVECTOR targetPos = GameScene.getPlayer()->getPos(); + targetPos.vy -= 45; + m_effect->setTarget( targetPos ); + DVECTOR offsetPos; + if ( m_heading == 0 ) + { + offsetPos.vx = 30; + } + else + { + offsetPos.vx = -30; + } + offsetPos.vy = -45; + m_effect->setOffset( offsetPos ); + m_effect->setRGB( 255, 0, 0 ); m_state++; - if ( m_state > IRON_DOGFISH_LASER_EYE_2 ) - { - // return to first state + break; + } - m_state = IRON_DOGFISH_THUMP_1; + case IRON_DOGFISH_LASER_EYE_1_WAIT: + case IRON_DOGFISH_LASER_EYE_2_WAIT: + { + if ( !m_animPlaying ) + { + m_animPlaying = true; + m_animNo = ANIM_IRONDOGFISH_IDLE; + m_frame = 0; + } + + if ( m_laserTimer > 0 ) + { + m_laserTimer -= _frames; + } + else + { + m_effect->killFX(); + + m_state++; + + if ( m_state > IRON_DOGFISH_LASER_EYE_2_WAIT ) + { + // return to first state + + m_state = IRON_DOGFISH_THUMP_1; + } + + m_movementTimer = GameState::getOneSecondInFrames() * 3; } break; @@ -262,9 +318,27 @@ void CNpcIronDogfishEnemy::processStandardIronDogfishAttack( int _frames ) case IRON_DOGFISH_ROLL: { - // charge user + s32 minX, maxX; + m_npcPath.getPathXExtents( &minX, &maxX ); - if ( playerXDistSqr > 100 ) + u8 thump = false; + + if ( playerXDist > 0 ) + { + if ( Pos.vx + playerXDist > maxX ) + { + thump = true; + } + } + else + { + if ( Pos.vx + playerXDist < minX ) + { + thump = true; + } + } + + if ( playerXDistSqr > 100 && !thump ) { if ( !m_animPlaying ) { @@ -517,15 +591,12 @@ void CNpcIronDogfishEnemy::collidedWith( CThing *_thisThing ) m_oldControlFunc = m_controlFunc; m_controlFunc = NPC_CONTROL_COLLISION; - processUserCollision( _thisThing ); - break; } case DETECT_ATTACK_COLLISION_GENERIC: { processAttackCollision(); - processUserCollision( _thisThing ); break; } @@ -558,7 +629,7 @@ void CNpcIronDogfishEnemy::collidedWith( CThing *_thisThing ) if ( canCollideWithEnemy() && enemy->canCollideWithEnemy() ) { - processEnemyCollision( _thisThing ); + //processEnemyCollision( _thisThing ); } break; @@ -614,3 +685,12 @@ void CNpcIronDogfishEnemy::render() } } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcIronDogfishEnemy::processCollision() +{ + CPlayer *player = GameScene.getPlayer(); + player->takeDamage( m_data[m_type].damageToUserType,REACT__GET_DIRECTION_FROM_THING,(CThing*)this ); + m_controlFunc = m_oldControlFunc; +} diff --git a/source/enemy/ndogfish.h b/source/enemy/ndogfish.h index 4dc49f15b..59bb091c5 100644 --- a/source/enemy/ndogfish.h +++ b/source/enemy/ndogfish.h @@ -14,6 +14,9 @@ #ifndef __ENEMY_NDOGFISH_H__ #define __ENEMY_NDOGFISH_H__ +#include "fx\fx.h" +#include "fx\fxlaser.h" + class CNpcIronDogfishEnemy : public CNpcEnemy { public: @@ -27,6 +30,7 @@ protected: virtual void processMovement( int _frames ); void processStandardIronDogfishAttack( int _frames ); void processWalkToUser( int _frames, int speed ); + virtual void processCollision(); virtual void processAttackCollision(); virtual void hasBeenSteamed( DVECTOR &steamPos ); virtual void processShot( int _frames ); @@ -36,14 +40,19 @@ protected: { IRON_DOGFISH_THUMP_1 = 0, IRON_DOGFISH_LASER_EYE_1 = 1, + IRON_DOGFISH_LASER_EYE_1_WAIT, IRON_DOGFISH_THUMP_2, IRON_DOGFISH_ROLL, IRON_DOGFISH_LASER_EYE_2, + IRON_DOGFISH_LASER_EYE_2_WAIT, }; s32 m_steamTimer; s32 m_vulnerableTimer; + s32 m_laserTimer; bool m_meterOn; + + CFXLaser *m_effect; }; #endif \ No newline at end of file diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index ba5d03e91..8164bfe3b 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -637,6 +637,14 @@ SOURCE=..\..\..\source\fx\fx.h # End Source File # Begin Source File +SOURCE=..\..\..\source\fx\fxattachanim.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\fx\fxattachanim.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\fx\fxbaseanim.cpp # End Source File # Begin Source File @@ -685,6 +693,14 @@ SOURCE=..\..\..\source\fx\fxjfish.h # End Source File # Begin Source File +SOURCE=..\..\..\source\fx\fxlaser.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\fx\fxlaser.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\fx\fxnrgbar.cpp # End Source File # Begin Source File @@ -699,6 +715,14 @@ SOURCE=..\..\..\source\fx\fxsteam.cpp SOURCE=..\..\..\source\fx\fxsteam.h # End Source File +# Begin Source File + +SOURCE=..\..\..\source\fx\fxthwack.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\fx\fxthwack.h +# End Source File # End Group # Begin Group "game"