From d6dabe439a0ba394ba84274b0a91c339fe0d7042 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 13 Mar 2001 17:01:35 +0000 Subject: [PATCH] --- source/enemy/npc.cpp | 5 +- source/enemy/npc.h | 8 +- source/enemy/npcdata.cpp | 2 +- source/enemy/nsshark.cpp | 155 +++++++++++++++++++++++---------------- 4 files changed, 101 insertions(+), 69 deletions(-) diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 0d9c04955..800ad860a 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -209,7 +209,7 @@ void CNpcEnemy::init() { CEnemyThing::init(); - m_type = NPC_MOTHER_JELLYFISH; + m_type = NPC_SUB_SHARK; // sActorHdr *Hdr = m_skel.Load( m_data[m_type].skelType ); // m_skel.Init( Hdr ); @@ -229,6 +229,7 @@ void CNpcEnemy::init() m_extension = 0; m_rotation = 0; m_reversed = false; + m_salvoCount = 0; m_health = m_data[this->m_type].initHealth; @@ -312,7 +313,7 @@ void CNpcEnemy::init() case NPC_INIT_SUB_SHARK: { - m_state = SUB_SHARK_CYCLE; + m_state = SUB_SHARK_MINE_1; m_extendDir = EXTEND_RIGHT; break; diff --git a/source/enemy/npc.h b/source/enemy/npc.h index ef8315ecc..f607514ca 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -285,9 +285,10 @@ protected: enum NPC_SUB_SHARK_STATE { - SUB_SHARK_CYCLE = 0, - SUB_SHARK_MINE_1 = 1, - SUB_SHARK_MINE_2, + SUB_SHARK_MINE_1 = 0, + SUB_SHARK_MINE_2 = 1, + SUB_SHARK_CYCLE, + SUB_SHARK_SWALLOW, }; enum NPC_FLYING_DUTCHMAN_STATE @@ -316,6 +317,7 @@ protected: { NPC_JELLYFISH_RESISTANCE = 64, NPC_BOOGER_MONSTER_MAX_EXTENSION = 20, + NPC_SUB_SHARK_HIGH_SPEED = 6, EXTEND_UP = true, EXTEND_DOWN = false, EXTEND_RIGHT = true, diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 9533de3d7..a9fa7e4fd 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -714,7 +714,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = NPC_TIMER_NONE, false, 3, - 64, + 2048, false, DAMAGE__HIT_ENEMY, 256, diff --git a/source/enemy/nsshark.cpp b/source/enemy/nsshark.cpp index 08bd5b476..f328f555a 100644 --- a/source/enemy/nsshark.cpp +++ b/source/enemy/nsshark.cpp @@ -36,9 +36,18 @@ void CNpcEnemy::processSubSharkMovement( int _frames ) { if ( !m_animPlaying ) { - m_animPlaying = true; - m_animNo = ANIM_SHARKSUB_SHARKSUBSWIM; - m_frame = 0; + if ( playerXDistSqr + playerYDistSqr < 100 && !m_salvoCount ) + { + m_animPlaying = true; + m_animNo = ANIM_SHARKSUB_SHARKSUBSWIPE; + m_frame = 0; + } + else + { + m_animPlaying = true; + m_animNo = ANIM_SHARKSUB_SHARKSUBSWIM; + m_frame = 0; + } } if ( m_timerTimer <= 0 ) @@ -60,93 +69,79 @@ void CNpcEnemy::processSubSharkMovement( int _frames ) if ( m_movementTimer > 0 ) { m_movementTimer -= _frames; + } - if ( m_extendDir == EXTEND_RIGHT ) + if ( m_extendDir == EXTEND_RIGHT ) + { + s32 xDist = 600 - Pos.vx; + s32 xDistSqr = xDist * xDist; + s32 yDist = m_base.vy - Pos.vy; + s32 yDistSqr = yDist * yDist; + + if ( ( xDistSqr + yDistSqr ) > 100 ) { - s32 xDist = 600 - Pos.vx; - s32 xDistSqr = xDist * xDist; - - if ( xDistSqr > 100 ) - { - processGenericGotoTarget( _frames, xDist, 0, m_data[m_type].speed ); - } - else - { - m_extendDir = EXTEND_LEFT; - } + processGenericGotoTarget( _frames, xDist, yDist, m_data[m_type].speed ); } else { - s32 xDist = 100 - Pos.vx; - s32 xDistSqr = xDist * xDist; + m_extendDir = EXTEND_LEFT; - if ( xDistSqr > 100 ) + if ( m_movementTimer <= 0 ) { - processGenericGotoTarget( _frames, xDist, 0, m_data[m_type].speed ); - } - else - { - m_extendDir = EXTEND_RIGHT; + m_controlFunc = NPC_CONTROL_CLOSE; } } } else { - m_controlFunc = NPC_CONTROL_CLOSE; + s32 xDist = 100 - Pos.vx; + s32 xDistSqr = xDist * xDist; + s32 yDist = m_base.vy - Pos.vy; + s32 yDistSqr = yDist * yDist; + + if ( ( xDistSqr + yDistSqr ) > 100 ) + { + processGenericGotoTarget( _frames, xDist, yDist, m_data[m_type].speed ); + } + else + { + m_extendDir = EXTEND_RIGHT; + + if ( m_movementTimer <= 0 ) + { + m_controlFunc = NPC_CONTROL_CLOSE; + } + } } } void CNpcEnemy::processCloseSubSharkAttack( int _frames ) { - if ( !m_animPlaying ) + if ( m_state != SUB_SHARK_SWALLOW ) { - m_animPlaying = true; - m_animNo = ANIM_SHARKSUB_SHARKSUBCHOMP; - m_frame = 0; - } - - if ( playerXDist > 0 ) - { - m_extendDir = EXTEND_RIGHT; - } - else - { - m_extendDir = EXTEND_LEFT; + if ( playerXDist > 0 ) + { + m_extendDir = EXTEND_RIGHT; + } + else + { + m_extendDir = EXTEND_LEFT; + } } switch( m_state ) { case SUB_SHARK_MINE_1: - { - if ( playerXDistSqr > 100 ) - { - processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed ); - } - else - { - // fire at player - - m_salvoCount = 5; - m_state = SUB_SHARK_MINE_2; - m_movementTimer = GameState::getOneSecondInFrames() * 8; - m_controlFunc = NPC_CONTROL_MOVEMENT; - } - - break; - } - case SUB_SHARK_MINE_2: { - if ( playerXDistSqr > 100 ) - { - processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed ); - } - else + processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed ); + + if ( playerXDistSqr < 100 ) { // fire at player m_salvoCount = 5; - m_state = SUB_SHARK_CYCLE; + m_state++; m_movementTimer = GameState::getOneSecondInFrames() * 8; m_controlFunc = NPC_CONTROL_MOVEMENT; } @@ -158,12 +153,46 @@ void CNpcEnemy::processCloseSubSharkAttack( int _frames ) { // charge player - if ( playerXDistSqr > 100 ) + if ( !m_animPlaying ) { - processGenericGotoTarget( _frames, playerXDist, 0, 6 ); + m_animPlaying = true; + m_animNo = ANIM_SHARKSUB_SHARKSUBSPRINTOPEN; + m_frame = 0; + } + + processGenericGotoTarget( _frames, playerXDist, 0, NPC_SUB_SHARK_HIGH_SPEED ); + + if ( playerXDistSqr < 10000 ) + { + m_animPlaying = true; + m_animNo = ANIM_SHARKSUB_SHARKSUBCHOMP; + m_frame = 0; + + m_state = SUB_SHARK_SWALLOW; + } + + break; + } + + case SUB_SHARK_SWALLOW: + { + // if ( collision ) + // else + + if ( m_extendDir == EXTEND_RIGHT ) + { + Pos.vx += NPC_SUB_SHARK_HIGH_SPEED; } else { + Pos.vx -= NPC_SUB_SHARK_HIGH_SPEED; + } + + if ( !m_animPlaying ) + { + m_animPlaying = true; + m_animNo = ANIM_SHARKSUB_SHARKSUBSWIM; + m_frame = 0; m_controlFunc = NPC_CONTROL_MOVEMENT; m_movementTimer = GameState::getOneSecondInFrames() * 8; m_state = SUB_SHARK_MINE_1;