From 58756ef7551a596bea6c746d6e443b88f72faea2 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 10 May 2001 21:30:17 +0000 Subject: [PATCH] --- makefile.gaz | 3 +- source/enemy/nanemone.cpp | 125 +++++++++++++++++- source/enemy/nanemone.h | 6 + source/enemy/npc.h | 1 + source/enemy/npcdata.cpp | 23 ++++ source/enemy/nsjback.cpp | 10 ++ source/hazard/hfalling.cpp | 73 +++++++--- source/hazard/hfalling.h | 3 + source/jellfish/jellfish.cpp | 67 ++++++++-- source/jellfish/jellfish.h | 1 + .../spongebob project/spongebob project.dsp | 8 ++ 11 files changed, 287 insertions(+), 33 deletions(-) diff --git a/makefile.gaz b/makefile.gaz index 23e3b7457..20c4ccc65 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -82,7 +82,8 @@ enemy_src := npc \ npbug \ nprojjf \ nmjback \ - nsjback + nsjback \ + nsj2back friend_src := friend \ fdata \ diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index 8eb7c0e73..019a4d35f 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -252,8 +252,8 @@ void CNpcAnemone2Enemy::postInit() // move appropriate to scaling (anemone origin is 90 degrees off, hence:) - xDiff = ( m_scaleY * 40 ) >> 12; - yDiff = ( m_scaleX * 40 ) >> 12; + xDiff = ( m_scaleY * SPIKE_RADIUS ) >> 12; + yDiff = ( m_scaleX * SPIKE_RADIUS ) >> 12; offset.vx = ( xDiff * rcos( relativeHeading ) ) >> 12; offset.vy = ( yDiff * rsin( relativeHeading ) ) >> 12; @@ -280,12 +280,123 @@ void CNpcAnemone2Enemy::postInit() void CNpcAnemone2Enemy::shutdown() { - deleteAllChild(); CNpcEnemy::shutdown(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcAnemone2Enemy::processShot( int _frames ) +{ + switch( m_data[m_type].shotFunc ) + { + case NPC_SHOT_NONE: + { + // do nothing + + break; + } + + case NPC_SHOT_GENERIC: + { + switch ( m_state ) + { + case NPC_GENERIC_HIT_CHECK_HEALTH: + { + if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + { + m_state = NPC_GENERIC_HIT_DEATH_START; + } + else + { + m_health -= 5; + + if ( m_health < 0 ) + { + m_state = NPC_GENERIC_HIT_DEATH_START; + } + else + { + m_state = NPC_GENERIC_HIT_RECOIL; + + m_animPlaying = true; + m_animNo = m_data[m_type].recoilAnim; + m_frame = 0; + } + } + + break; + } + + case NPC_GENERIC_HIT_RECOIL: + { + if ( !m_animPlaying ) + { + m_state = 0; + m_controlFunc = NPC_CONTROL_MOVEMENT; + } + + break; + } + + case NPC_GENERIC_HIT_DEATH_START: + { + m_animPlaying = true; + m_animNo = m_data[m_type].dieAnim; + m_frame = 0; + m_state = NPC_GENERIC_HIT_DEATH_END; + + deleteAllChild(); + m_isDying = true; + m_speed = -5; + + if (m_data[m_type].skelType) + { + m_actorGfx->SetOtPos( 0 ); + } + + break; + } + + case NPC_GENERIC_HIT_DEATH_END: + { + m_drawRotation += 64 * _frames; + m_drawRotation &= 4095; + + Pos.vy += m_speed * _frames; + + if ( m_speed < 5 ) + { + m_speed++; + } + + DVECTOR offset = CLevel::getCameraPos(); + + if ( Pos.vy - offset.vy > VidGetScrH() ) + { + if ( m_data[m_type].respawning ) + { + m_isActive = false; + + m_timerFunc = NPC_TIMER_RESPAWN; + m_timerTimer = 4 * GameState::getOneSecondInFrames(); + } + else + { + setToShutdown(); + } + } + + break; + } + } + + break; + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemone2Enemy::processClose( int _frames ) { int fireLoop; @@ -354,8 +465,8 @@ void CNpcAnemone2Enemy::processClose( int _frames ) // move appropriate to scaling (anemone origin is 90 degrees off, hence:) - xDiff = ( m_scaleY * 40 ) >> 12; - yDiff = ( m_scaleX * 40 ) >> 12; + xDiff = ( m_scaleY * SPIKE_RADIUS ) >> 12; + yDiff = ( m_scaleX * SPIKE_RADIUS ) >> 12; offset.vx = ( xDiff * rcos( relativeHeading ) ) >> 12; offset.vy = ( yDiff * rsin( relativeHeading ) ) >> 12; @@ -426,8 +537,8 @@ void CNpcAnemone2Enemy::processMovementModifier( int _frames, s32 distX, s32 dis // move appropriate to scaling (anemone origin is 90 degrees off, hence:) - xDiff = ( m_scaleY * 40 ) >> 12; - yDiff = ( m_scaleX * 40 ) >> 12; + xDiff = ( m_scaleY * SPIKE_RADIUS ) >> 12; + yDiff = ( m_scaleX * SPIKE_RADIUS ) >> 12; offset.vx = ( xDiff * rcos( relativeHeading ) ) >> 12; offset.vy = ( yDiff * rsin( relativeHeading ) ) >> 12; diff --git a/source/enemy/nanemone.h b/source/enemy/nanemone.h index 1b91890ac..79da3711c 100644 --- a/source/enemy/nanemone.h +++ b/source/enemy/nanemone.h @@ -39,11 +39,17 @@ public: virtual void postInit(); virtual void shutdown(); virtual void render(); + virtual void processShot( int _frames ); protected: virtual void processClose( int _frames ); virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); u16 m_scaleX, m_scaleY; + + enum + { + SPIKE_RADIUS = 20, + }; }; class CNpcAnemone3Enemy : public CNpcAnemoneEnemy diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 9284921bf..565b89396 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -83,6 +83,7 @@ public: NPC_PROJECTILE_JELLYFISH, NPC_MOTHER_JELLYFISH_BACKGROUND, NPC_SMALL_JELLYFISH_BACKGROUND, + NPC_SMALL_JELLYFISH_2_BACKGROUND, NPC_UNIT_TYPE_MAX, }; diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 287f2669f..574062eab 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -1056,6 +1056,29 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = false, false, }, + + { // NPC_SMALL_JELLYFISH_2_BACKGROUND + 0,//ACTORS_JELLYFISH1_SBK, + FRM_JELLYFISH1_SWIM1, + NPC_SENSOR_USER_CLOSE, + NPC_MOVEMENT_FIXED_PATH, + NPC_CLOSE_NONE, + NPC_TIMER_NONE, + false, + 2, + 128, + DETECT_ALL_COLLISION, + DAMAGE__SHOCK_ENEMY, + 16, + FRM_JELLYFISH1_SWIM1, + NPC_SHOT_GENERIC, + 0, + FRM_JELLYFISH1_SWIM1, + true, + false, + false, + false, + }, }; CNpcEnemy::NPC_UNIT_TYPE CNpcEnemy::mapEditConvertTable[NPC_UNIT_TYPE_MAX] = diff --git a/source/enemy/nsjback.cpp b/source/enemy/nsjback.cpp index 62e5911c1..a105b79a5 100644 --- a/source/enemy/nsjback.cpp +++ b/source/enemy/nsjback.cpp @@ -195,6 +195,16 @@ void CNpcSmallJellyfishBackgroundEnemy::processUserCollision( CThing *thisThing if ( !otherDelta.vx && !otherDelta.vy ) { + if ( !xDist ) + { + xDist = 1; + } + + if ( !yDist ) + { + yDist = 1; + } + otherDelta.vx = ( 1 * xDist ) / abs( xDist ); otherDelta.vy = ( 1 * yDist ) / abs( yDist ); } diff --git a/source/hazard/hfalling.cpp b/source/hazard/hfalling.cpp index 98ef8ff98..2325b962e 100644 --- a/source/hazard/hfalling.cpp +++ b/source/hazard/hfalling.cpp @@ -23,6 +23,11 @@ #include "utils\utils.h" #endif +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcFallingHazard::init() @@ -32,6 +37,7 @@ void CNpcFallingHazard::init() m_movementTimer = 2 * GameState::getOneSecondInFrames(); m_respawnRate = 4; + m_bounceFinish = false; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -41,41 +47,73 @@ void CNpcFallingHazard::processMovement( int _frames ) s8 groundHeight; s8 yMovement; - if ( m_movementTimer > 0 ) + if ( m_bounceFinish ) { - m_movementTimer -= _frames; - - if ( m_movementTimer <= 0 ) + if ( m_bounceDir ) { - Pos = m_base; + Pos.vx += 2 * _frames; } else { - Pos.vx = m_base.vx + ( -3 + ( getRnd() % 7 ) ); - Pos.vy = m_base.vy + ( -3 + ( getRnd() % 7 ) ); + Pos.vx -= 2 * _frames; } - } - else - { - yMovement = 3 * _frames; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + Pos.vy += m_speed * _frames; - if ( groundHeight < yMovement ) + if ( m_speed < 5 ) { - // colliding with ground + m_speed++; + } - Pos.vy += groundHeight; + DVECTOR offset = CLevel::getCameraPos(); + s32 yPos = Pos.vy - offset.vy; + + if ( yPos > VidGetScrH() || yPos < 0 ) + { m_isActive = false; m_timerActive = true; m_timer = ( m_respawnRate - 1 ) * GameState::getOneSecondInFrames(); } + } + else + { + if ( m_movementTimer > 0 ) + { + m_movementTimer -= _frames; + + if ( m_movementTimer <= 0 ) + { + Pos = m_base; + } + else + { + Pos.vx = m_base.vx + ( -3 + ( getRnd() % 7 ) ); + Pos.vy = m_base.vy + ( -3 + ( getRnd() % 7 ) ); + } + } else { - // drop down + yMovement = 3 * _frames; - Pos.vy += yMovement; + groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + + if ( groundHeight < yMovement ) + { + // colliding with ground + + Pos.vy += groundHeight; + + m_bounceFinish = true; + m_speed = -5; + m_bounceDir = getRnd() % 2; + } + else + { + // drop down + + Pos.vy += yMovement; + } } } } @@ -92,5 +130,6 @@ void CNpcFallingHazard::processTimer( int _frames ) m_isActive = true; Pos = m_base; m_movementTimer = 2 * GameState::getOneSecondInFrames(); + m_bounceFinish = false; } } diff --git a/source/hazard/hfalling.h b/source/hazard/hfalling.h index 3931902a6..ea0d87aec 100644 --- a/source/hazard/hfalling.h +++ b/source/hazard/hfalling.h @@ -27,6 +27,9 @@ protected: void processTimer( int _frames ); s32 m_movementTimer; + u8 m_bounceFinish; + s32 m_speed; + u8 m_bounceDir; }; #endif \ No newline at end of file diff --git a/source/jellfish/jellfish.cpp b/source/jellfish/jellfish.cpp index 13343b7f3..b71dbd858 100644 --- a/source/jellfish/jellfish.cpp +++ b/source/jellfish/jellfish.cpp @@ -23,6 +23,10 @@ #include "enemy\nsjback.h" #endif +#ifndef __ENEMY_NSJ2BACK_H__ +#include "enemy\nsj2back.h" +#endif + #ifndef __ENEMY_NPC_H__ #include "enemy\npc.h" #endif @@ -41,6 +45,7 @@ u8 CJellyfishGenerator::m_jellyfishCount; s32 CJellyfishGenerator::m_timer; u8 CJellyfishGenerator::m_on; +u8 CJellyfishGenerator::m_level; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -50,6 +55,7 @@ void CJellyfishGenerator::init() m_jellyfishCount = 0; m_on = true; + m_level = 1; switch( CLevel::getCurrentChapter() ) { @@ -60,6 +66,15 @@ void CJellyfishGenerator::init() case 2: { m_on = false; + + break; + } + + case 4: + { + m_level = 2; + + break; } } @@ -85,26 +100,62 @@ void CJellyfishGenerator::think( int _frames, CLevel *level ) m_jellyfishCount++; CNpcEnemy *enemy; - enemy = new( "jellyfish" ) CNpcSmallJellyfishBackgroundEnemy; + + if ( m_level == 1 ) + { + enemy = new( "jellyfish" ) CNpcSmallJellyfishBackgroundEnemy; + } + else + { + enemy = new( "jellyfish" ) CNpcSmallJellyfish2BackgroundEnemy; + } + ASSERT(enemy); - enemy->setType( CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND ); + + if ( m_level == 1 ) + { + enemy->setType( CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND ); + } + else + { + enemy->setType( CNpcEnemy::NPC_SMALL_JELLYFISH_2_BACKGROUND ); + } + enemy->init(); enemy->setLayerCollision( level->getCollisionLayer() ); DVECTOR offset = CLevel::getCameraPos(); DVECTOR startPos; - if ( ( getRnd() % 10 ) > 4 ) + if ( m_level == 1 ) { CNpcSmallJellyfishBackgroundEnemy *jfish = ( CNpcSmallJellyfishBackgroundEnemy * ) enemy; - jfish->setTargetHeading( 0 ); - startPos.vx = offset.vx - 20; + + if ( ( getRnd() % 10 ) > 4 ) + { + jfish->setTargetHeading( 0 ); + startPos.vx = offset.vx - 20; + } + else + { + jfish->setTargetHeading( 2048 ); + startPos.vx = offset.vx + VidGetScrW() + 20; + } } else { - CNpcSmallJellyfishBackgroundEnemy *jfish = ( CNpcSmallJellyfishBackgroundEnemy * ) enemy; - jfish->setTargetHeading( 2048 ); - startPos.vx = offset.vx + VidGetScrW() + 20; + CNpcSmallJellyfish2BackgroundEnemy *jfish = ( CNpcSmallJellyfish2BackgroundEnemy * ) enemy; + + if ( ( getRnd() % 10 ) > 4 ) + { + jfish->setTargetHeading( 0 ); + startPos.vx = offset.vx - 20; + } + else + { + jfish->setTargetHeading( 2048 ); + startPos.vx = offset.vx + VidGetScrW() + 20; + } } startPos.vy = offset.vy + ( getRnd() % VidGetScrH() ); diff --git a/source/jellfish/jellfish.h b/source/jellfish/jellfish.h index 4f2581275..568c63018 100644 --- a/source/jellfish/jellfish.h +++ b/source/jellfish/jellfish.h @@ -32,6 +32,7 @@ protected: static u8 m_jellyfishCount; static s32 m_timer; static u8 m_on; + static u8 m_level; }; #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 45b308440..1b8c1ceb0 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -329,6 +329,14 @@ SOURCE=..\..\..\source\enemy\nshrkman.h # End Source File # Begin Source File +SOURCE=..\..\..\source\enemy\nsj2back.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\enemy\nsj2back.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\enemy\nsjback.cpp # End Source File # Begin Source File