diff --git a/source/enemy/nmjback.cpp b/source/enemy/nmjback.cpp index 5fc50d3bc..89d208475 100644 --- a/source/enemy/nmjback.cpp +++ b/source/enemy/nmjback.cpp @@ -68,7 +68,7 @@ void CNpcMotherJellyfishBackground::render() if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() ) { SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),false); - m_actorGfx->RotateScale( SprFrame, renderPos, m_drawRotation, 8192, 8192 ); + m_actorGfx->RotateScale( SprFrame, renderPos, 0, 8192, 8192 ); sBBox boundingBox = m_actorGfx->GetBBox(); setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) ); diff --git a/source/enemy/nmjfish.cpp b/source/enemy/nmjfish.cpp index a9e9b56a1..24dcf7b51 100644 --- a/source/enemy/nmjfish.cpp +++ b/source/enemy/nmjfish.cpp @@ -334,7 +334,7 @@ void CNpcMotherJellyfishEnemy::render() if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() ) { SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),false); - m_actorGfx->RotateScale( SprFrame, renderPos, m_drawRotation, 8192, 8192 ); + m_actorGfx->RotateScale( SprFrame, renderPos, 0, 8192, 8192 ); sBBox boundingBox = m_actorGfx->GetBBox(); setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) ); diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 1dcd1e3aa..8ff144e34 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -612,6 +612,7 @@ void CNpcEnemy::init() m_reversed = false; m_salvoCount = 0; m_isActive = true; + m_isDying = false; m_health = m_data[this->m_type].initHealth; @@ -663,6 +664,7 @@ void CNpcEnemy::reinit() m_reversed = false; m_salvoCount = 0; m_isActive = true; + m_isDying = false; m_health = m_data[this->m_type].initHealth; @@ -764,7 +766,7 @@ void CNpcEnemy::think(int _frames) { if ( m_isActive ) { - if ( m_animPlaying ) + if ( m_animPlaying && !m_isDying ) { s32 frameCount; @@ -844,7 +846,7 @@ void CNpcEnemy::processAttackCollision() void CNpcEnemy::collidedWith( CThing *_thisThing ) { - if ( m_isActive && !m_isCaught ) + if ( m_isActive && !m_isCaught && !m_isDying ) { switch(_thisThing->getThingType()) { @@ -1208,6 +1210,9 @@ void CNpcEnemy::processShot( int _frames ) m_frame = 0; m_state = NPC_GENERIC_HIT_DEATH_END; + m_isDying = true; + m_speed = -5; + if (m_data[m_type].skelType) { m_actorGfx->SetOtPos( 0 ); @@ -1218,7 +1223,15 @@ void CNpcEnemy::processShot( int _frames ) case NPC_GENERIC_HIT_DEATH_END: { - Pos.vy += 5 * _frames; + m_drawRotation += 64 * _frames; + m_drawRotation &= 4095; + + Pos.vy += m_speed * _frames; + + if ( m_speed < 5 ) + { + m_speed++; + } DVECTOR offset = CLevel::getCameraPos(); @@ -1387,7 +1400,7 @@ void CNpcEnemy::processEvent( GAME_EVENT evt, CThing *sourceThing ) bool CNpcEnemy::canBeCaughtByNet() { - return( m_isActive && m_data[m_type].canBeNetted ); + return( m_isActive && !m_isDying && m_data[m_type].canBeNetted ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1414,7 +1427,7 @@ void CNpcEnemy::caughtWithNet() int CNpcEnemy::canCollide() { - return( m_isActive ); + return( m_isActive && !m_isDying ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1480,7 +1493,17 @@ void CNpcEnemy::processUserCollision( CThing *thisThing ) } Pos.vx += otherDelta.vx; - Pos.vy += otherDelta.vy; + + s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, 16 ); + + if ( groundHeight < 8 ) + { + Pos.vy += groundHeight; + } + else + { + Pos.vy += otherDelta.vy; + } m_heading = headingFromTarget; diff --git a/source/enemy/npc.h b/source/enemy/npc.h index a25355080..52ecad724 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -299,6 +299,7 @@ protected: u8 m_isBlowerOn; DVECTOR m_caughtPos; s16 m_speed; + u8 m_isDying; s32 m_frame; int m_animNo; diff --git a/source/enemy/nsjback.cpp b/source/enemy/nsjback.cpp index 4ae143138..4f3de9b2b 100644 --- a/source/enemy/nsjback.cpp +++ b/source/enemy/nsjback.cpp @@ -27,6 +27,10 @@ #include "system\vid.h" #endif +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -71,7 +75,23 @@ void CNpcSmallJellyfishBackgroundEnemy::processMovement( int _frames ) if ( directionChange == 0 ) { - m_targetHeading += -1024 + ( getRnd() % 2049 ); + CPlayer *player = GameScene.getPlayer(); + + if ( player->isHoldingNet() ) + { + if ( ( getRnd() % 4 ) == 0 ) + { + m_targetHeading = ratan2( playerYDist, playerXDist ); + } + else + { + m_targetHeading += -1024 + ( getRnd() % 2049 ); + } + } + else + { + m_targetHeading += -1024 + ( getRnd() % 2049 ); + } } } } @@ -135,7 +155,7 @@ void CNpcSmallJellyfishBackgroundEnemy::processMovement( int _frames ) if ( processGroundCollisionReverse( &moveX, &moveY ) ) { - m_targetHeading += 2048; + m_targetHeading += 1024; m_targetHeading &= 4095; } diff --git a/source/jellfish/jellfish.cpp b/source/jellfish/jellfish.cpp index a7ba9526a..13343b7f3 100644 --- a/source/jellfish/jellfish.cpp +++ b/source/jellfish/jellfish.cpp @@ -40,6 +40,7 @@ u8 CJellyfishGenerator::m_jellyfishCount; s32 CJellyfishGenerator::m_timer; +u8 CJellyfishGenerator::m_on; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -47,54 +48,75 @@ void CJellyfishGenerator::init() { m_timer = 1 * GameState::getOneSecondInFrames(); m_jellyfishCount = 0; + + m_on = true; + + switch( CLevel::getCurrentChapter() ) + { + case 1: + { + switch( CLevel::getCurrentChapterLevel() ) + { + case 2: + { + m_on = false; + } + } + + break; + } + } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CJellyfishGenerator::think( int _frames, CLevel *level ) { - if ( m_timer <= 0 ) + if ( m_on ) { - if ( m_jellyfishCount < 10 ) + if ( m_timer <= 0 ) { - // add jellyfish - - m_timer = 1 * GameState::getOneSecondInFrames(); - - m_jellyfishCount++; - - CNpcEnemy *enemy; - enemy = new( "jellyfish" ) CNpcSmallJellyfishBackgroundEnemy; - ASSERT(enemy); - enemy->setType( CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND ); - enemy->init(); - enemy->setLayerCollision( level->getCollisionLayer() ); - - DVECTOR offset = CLevel::getCameraPos(); - - DVECTOR startPos; - if ( ( getRnd() % 10 ) > 4 ) + if ( m_jellyfishCount < 10 ) { - CNpcSmallJellyfishBackgroundEnemy *jfish = ( CNpcSmallJellyfishBackgroundEnemy * ) enemy; - jfish->setTargetHeading( 0 ); - startPos.vx = offset.vx - 20; - } - else - { - CNpcSmallJellyfishBackgroundEnemy *jfish = ( CNpcSmallJellyfishBackgroundEnemy * ) enemy; - jfish->setTargetHeading( 2048 ); - startPos.vx = offset.vx + VidGetScrW() + 20; - } + // add jellyfish - startPos.vy = offset.vy + ( getRnd() % VidGetScrH() ); + m_timer = 1 * GameState::getOneSecondInFrames(); - enemy->setStartPos( startPos.vx >> 4, startPos.vy >> 4 ); - enemy->postInit(); + m_jellyfishCount++; + + CNpcEnemy *enemy; + enemy = new( "jellyfish" ) CNpcSmallJellyfishBackgroundEnemy; + ASSERT(enemy); + enemy->setType( CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND ); + enemy->init(); + enemy->setLayerCollision( level->getCollisionLayer() ); + + DVECTOR offset = CLevel::getCameraPos(); + + DVECTOR startPos; + if ( ( getRnd() % 10 ) > 4 ) + { + CNpcSmallJellyfishBackgroundEnemy *jfish = ( CNpcSmallJellyfishBackgroundEnemy * ) enemy; + jfish->setTargetHeading( 0 ); + startPos.vx = offset.vx - 20; + } + else + { + CNpcSmallJellyfishBackgroundEnemy *jfish = ( CNpcSmallJellyfishBackgroundEnemy * ) enemy; + jfish->setTargetHeading( 2048 ); + startPos.vx = offset.vx + VidGetScrW() + 20; + } + + startPos.vy = offset.vy + ( getRnd() % VidGetScrH() ); + + enemy->setStartPos( startPos.vx >> 4, startPos.vy >> 4 ); + enemy->postInit(); + } + } + else + { + m_timer -= _frames; } - } - else - { - m_timer -= _frames; } } diff --git a/source/jellfish/jellfish.h b/source/jellfish/jellfish.h index d40034472..4f2581275 100644 --- a/source/jellfish/jellfish.h +++ b/source/jellfish/jellfish.h @@ -31,6 +31,7 @@ public: protected: static u8 m_jellyfishCount; static s32 m_timer; + static u8 m_on; }; #endif \ No newline at end of file diff --git a/source/platform/pbranch.cpp b/source/platform/pbranch.cpp index cd604a7a8..9357c7a43 100644 --- a/source/platform/pbranch.cpp +++ b/source/platform/pbranch.cpp @@ -258,6 +258,7 @@ void CNpcBranchPlatform::render() m_modelGfx->Render(renderPos,&rotation,&scale); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR offset = CLevel::getCameraPos(); DVECTOR size; DVECTOR centre; int halfLength; diff --git a/source/platform/pcart.cpp b/source/platform/pcart.cpp index 0eef1b972..5471924c4 100644 --- a/source/platform/pcart.cpp +++ b/source/platform/pcart.cpp @@ -167,6 +167,7 @@ void CNpcCartPlatform::render() m_modelGfx->Render(renderPos,&rotation,&scale); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR offset = CLevel::getCameraPos(); DVECTOR size; DVECTOR centre; int halfLength; diff --git a/source/platform/pdual.cpp b/source/platform/pdual.cpp index d0f318aac..283c9ab39 100644 --- a/source/platform/pdual.cpp +++ b/source/platform/pdual.cpp @@ -216,6 +216,7 @@ void CNpcDualPlatform::render() m_modelGfx->Render(renderPos); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR offset = CLevel::getCameraPos(); DVECTOR size; DVECTOR centre; int halfLength; diff --git a/source/platform/pfgen.cpp b/source/platform/pfgen.cpp index 68881bd17..cbaaecd1c 100644 --- a/source/platform/pfgen.cpp +++ b/source/platform/pfgen.cpp @@ -49,7 +49,7 @@ void CNpcFallingPlatformGenerator::think( int _frames ) if ( m_timer < 0 ) { - m_timer = GameState::getOneSecondInFrames() + ( getRnd() % ( ( m_data[m_type].initTimer - 1 ) * GameState::getOneSecondInFrames() ) ); + m_timer = ( 3 * GameState::getOneSecondInFrames() ) + ( getRnd() % ( ( m_data[m_type].initTimer - 1 ) * GameState::getOneSecondInFrames() ) ); // generate new falling platform diff --git a/source/platform/pfishhk.cpp b/source/platform/pfishhk.cpp index 79ab11e83..14543bc01 100644 --- a/source/platform/pfishhk.cpp +++ b/source/platform/pfishhk.cpp @@ -87,6 +87,7 @@ void CNpcFishHookPlatform::render() m_modelGfx->Render(renderPos); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR offset = CLevel::getCameraPos(); DVECTOR size; DVECTOR centre; int halfLength; diff --git a/source/platform/platdata.cpp b/source/platform/platdata.cpp index df4384718..f3cae873a 100644 --- a/source/platform/platdata.cpp +++ b/source/platform/platdata.cpp @@ -143,7 +143,7 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] = }, { // NPC_FISH_HOOK_2_PLATFORM - 3, + 8, 128, true, DAMAGE__NONE, diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index f7b369ecc..d0ceafa03 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -894,9 +894,9 @@ void CNpcPlatform::render() DVECTOR &renderPos=getRenderPos(); m_modelGfx->Render(renderPos); - } #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR offset = CLevel::getCameraPos(); DVECTOR size; DVECTOR centre; int halfLength; @@ -920,6 +920,7 @@ void CNpcPlatform::render() DrawLine(x1,y1,x2,y2,0,255,0,0); #endif + } } } diff --git a/source/platform/ppendulm.cpp b/source/platform/ppendulm.cpp index 4683803a8..87262314f 100644 --- a/source/platform/ppendulm.cpp +++ b/source/platform/ppendulm.cpp @@ -100,7 +100,7 @@ void CNpcPendulumPlatform::processMovement( int _frames ) } else { - m_extension += _frames << 3; + m_extension += m_speed * _frames; } } else @@ -111,7 +111,7 @@ void CNpcPendulumPlatform::processMovement( int _frames ) } else { - m_extension -= _frames << 3; + m_extension -= m_speed * _frames; } } @@ -126,6 +126,8 @@ void CNpcPendulumPlatform::render() int x1,y1,x2,y2; int x1Boundary,y1Boundary,x2Boundary,y2Boundary; + DVECTOR offset = CLevel::getCameraPos(); + if ( m_isActive ) { CPlatformThing::render(); @@ -159,53 +161,52 @@ void CNpcPendulumPlatform::render() DrawLine(x1,y1,x2,y2,0,255,0,0); #endif -/* - x1 = x1Boundary = Pos.vx - offset.vx; - x2 = x2Boundary = m_lineBase.vx - offset.vx; + } - y1 = y1Boundary = Pos.vy - offset.vy; - y2 = y2Boundary = m_lineBase.vy - offset.vy; + x1 = x1Boundary = Pos.vx - offset.vx; + x2 = x2Boundary = m_lineBase.vx - offset.vx; - int angle = ratan2( x1 - x2, y1 - y2 ); + y1 = y1Boundary = Pos.vy - offset.vy; + y2 = y2Boundary = m_lineBase.vy - offset.vy; - if ( y2 < 0 ) + int angle = ratan2( x1 - x2, y1 - y2 ); + + if ( y2 < 0 ) + { + int yDiff = -y2; + y2 = y2Boundary = 0; + int hyp = ( yDiff << 12 ) / rcos( angle ); + x2 += ( hyp * rsin( angle ) ) >> 12; + } + + if ( y1 > VidGetScrH() ) + { + int yDiff = y1 - VidGetScrH(); + y1 = y1Boundary = VidGetScrH(); + int hyp = ( yDiff << 12 ) / rcos( angle ); + x1 -= ( hyp * rsin( angle ) ) >> 12; + } + + if ( x1Boundary > x2Boundary ) + { + int tempX = x1Boundary; + x1Boundary = x2Boundary; + x2Boundary = tempX; + } + + if ( y1Boundary > y2Boundary ) + { + int tempY = y1Boundary; + y1Boundary = y2Boundary; + y2Boundary = tempY; + } + + if ( x2Boundary >= 0 && x1Boundary <= VidGetScrW() ) + { + if ( y2Boundary >= 0 && y1Boundary <= VidGetScrH() ) { - int yDiff = -y2; - y2 = y2Boundary = 0; - int hyp = ( yDiff << 12 ) / rcos( angle ); - x2 += ( hyp * rsin( angle ) ) >> 12; + DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 ); } - - if ( y1 > VidGetScrH() ) - { - int yDiff = y1 - VidGetScrH(); - y1 = y1Boundary = VidGetScrH(); - int hyp = ( yDiff << 12 ) / rcos( angle ); - x1 -= ( hyp * rsin( angle ) ) >> 12; - } - - if ( x1Boundary > x2Boundary ) - { - int tempX = x1Boundary; - x1Boundary = x2Boundary; - x2Boundary = tempX; - } - - if ( y1Boundary > y2Boundary ) - { - int tempY = y1Boundary; - y1Boundary = y2Boundary; - y2Boundary = tempY; - } - - if ( x2Boundary >= 0 && x1Boundary <= VidGetScrW() ) - { - if ( y2Boundary >= 0 && y1Boundary <= VidGetScrH() ) - { - DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 ); - } - } -*/ } } } diff --git a/source/platform/pretract.cpp b/source/platform/pretract.cpp index a2c81b5a6..b8e6dcbe0 100644 --- a/source/platform/pretract.cpp +++ b/source/platform/pretract.cpp @@ -126,6 +126,7 @@ void CNpcRetractingPlatform::render() m_modelGfx->Render(renderPos,&rotation,&scale); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR offset = CLevel::getCameraPos(); DVECTOR size; DVECTOR centre; int halfLength; diff --git a/source/platform/pseesaw.cpp b/source/platform/pseesaw.cpp index 2cc385d81..ca7575110 100644 --- a/source/platform/pseesaw.cpp +++ b/source/platform/pseesaw.cpp @@ -134,6 +134,7 @@ void CNpcSeesawPlatform::render() m_modelGfx->Render(renderPos,&rotation,&scale); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR offset = CLevel::getCameraPos(); DVECTOR size; DVECTOR centre; int halfLength;