From d249841bfccda3bdfc9084da81cfdf84d40be78a Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 14 Feb 2001 16:04:41 +0000 Subject: [PATCH] --- source/enemy/npc.cpp | 20 +--------- source/enemy/npcdata.cpp | 2 +- source/enemy/nsstomp.cpp | 86 ++++++++++++++++++---------------------- 3 files changed, 42 insertions(+), 66 deletions(-) diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index b718a6341..fb97e0181 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -54,7 +54,7 @@ class CLayerCollision *CNpc::m_layerCollision; void CNpc::init() { - m_type = NPC_GARY; + m_type = NPC_SKULL_STOMPER; m_heading = m_fireHeading = 0; m_movementTimer = 0; @@ -116,23 +116,7 @@ void CNpc::init() case NPC_INIT_SKULL_STOMPER: { - m_heading = m_fireHeading = 1024; - - m_npcPath.initPath(); - - DVECTOR newPos; - - newPos.vx = 100; - newPos.vy = 100; - - m_npcPath.addWaypoint( newPos ); - - newPos.vx = 100; - newPos.vy = 10; - - m_npcPath.addWaypoint( newPos ); - - m_npcPath.setPathType( SINGLE_USE_PATH ); + m_extendDir = EXTEND_DOWN; break; } diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 5a4f25482..1c3853d2b 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -533,7 +533,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] = NPC_CLOSE_SKULL_STOMPER_ATTACK, NPC_TIMER_NONE, false, - 3, + 5, 2048, false, DAMAGE__LAVA, diff --git a/source/enemy/nsstomp.cpp b/source/enemy/nsstomp.cpp index c93aae9b5..277abfc27 100644 --- a/source/enemy/nsstomp.cpp +++ b/source/enemy/nsstomp.cpp @@ -16,11 +16,11 @@ #endif #ifndef __GAME_GAME_H__ -#include "game\game.h" +#include "game\game.h" #endif #ifndef __PLAYER_PLAYER_H__ -#include "player\player.h" +#include "player\player.h" #endif @@ -32,65 +32,57 @@ void CNpc::processCloseSkullStomperAttack( int _frames ) } else { - s32 velocity; - bool pathComplete; - bool waypointChange; - s16 headingToTarget = m_npcPath.think( Pos, &pathComplete, &waypointChange ); - s32 moveX, moveY; - - if ( waypointChange ) + if ( m_extendDir == EXTEND_DOWN ) { - if ( !pathComplete ) + if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + ( m_data[m_type].speed * _frames ) ) >> 4 ) ) { + // colliding with ground + + s32 distY; + s32 lastPointY = 0; + + for ( distY = 1 ; distY <= ( m_data[m_type].speed * _frames ) ; distY++ ) + { + if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + distY ) >> 4 ) ) + { + break; + } + else + { + lastPointY++; + } + } + + Pos.vy += lastPointY; + // pause and change direction m_timerTimer = GameState::getOneSecondInFrames(); m_extendDir = EXTEND_UP; - - return; - } - } - - if ( pathComplete ) - { - m_controlFunc = NPC_CONTROL_MOVEMENT; - m_timerFunc = NPC_TIMER_ATTACK_DONE; - m_timerTimer = GameState::getOneSecondInFrames(); - m_sensorFunc = NPC_SENSOR_NONE; - m_npcPath.resetPath(); - } - else - { - s32 preShiftX; - s32 preShiftY; - - m_heading = headingToTarget; - - if ( m_extendDir == EXTEND_DOWN ) - { - preShiftX = _frames * 8 * rcos( m_heading ); - preShiftY = _frames * 8 * rsin( m_heading ); } else { - preShiftX = _frames * 2 * rcos( m_heading ); - preShiftY = _frames * 2 * rsin( m_heading ); - } + // drop down - moveX = preShiftX >> 12; - if ( !moveX && preShiftX ) + Pos.vy += m_data[m_type].speed * _frames; + } + } + else + { + if ( m_base.vx - Pos.vx == 0 && m_base.vy - Pos.vy == 0 ) { - moveX = preShiftX / abs( preShiftX ); + m_controlFunc = NPC_CONTROL_MOVEMENT; + m_timerFunc = NPC_TIMER_ATTACK_DONE; + m_timerTimer = GameState::getOneSecondInFrames(); + m_sensorFunc = NPC_SENSOR_NONE; + m_npcPath.resetPath(); } - - moveY = preShiftY >> 12; - if ( !moveY && preShiftY ) + else { - moveY = preShiftY / abs( preShiftY ); - } + // return to original position - Pos.vx += moveX; - Pos.vy += moveY; + processGenericGotoTarget( _frames, m_base.vx - Pos.vx, m_base.vy - Pos.vy, 1 ); + } } } } \ No newline at end of file