This commit is contained in:
Charles 2001-02-14 16:04:41 +00:00
parent 55888be3d1
commit d249841bfc
3 changed files with 42 additions and 66 deletions

View File

@ -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;
}

View File

@ -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,

View File

@ -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 );
}
}
}
}