SBSPSS/source/enemy/nsstomp.cpp

80 lines
1.5 KiB
C++
Raw Normal View History

2001-01-23 18:02:45 +01:00
/*=========================================================================
nsstomp.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
#ifndef __ENEMY_NPC_H__
#include "enemy\npc.h"
#endif
#ifndef __GAME_GAME_H__
2001-02-14 17:04:41 +01:00
#include "game\game.h"
2001-01-23 18:02:45 +01:00
#endif
#ifndef __PLAYER_PLAYER_H__
2001-02-14 17:04:41 +01:00
#include "player\player.h"
2001-01-23 18:02:45 +01:00
#endif
2001-02-27 22:25:22 +01:00
void CNpcEnemy::processCloseSkullStomperAttack( int _frames )
2001-01-23 18:02:45 +01:00
{
2001-02-15 21:50:52 +01:00
s8 groundHeight;
s8 yMovement;
2001-01-23 18:02:45 +01:00
if ( m_timerTimer > 0 )
{
// wait
}
else
{
2001-02-14 17:04:41 +01:00
if ( m_extendDir == EXTEND_DOWN )
2001-01-23 18:02:45 +01:00
{
2001-02-15 21:50:52 +01:00
yMovement = m_data[m_type].speed * _frames;
2001-02-14 17:04:41 +01:00
2001-02-15 21:50:52 +01:00
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
2001-02-14 17:04:41 +01:00
2001-02-15 21:50:52 +01:00
if ( groundHeight < yMovement )
{
// colliding with ground
2001-02-14 17:04:41 +01:00
2001-02-15 21:50:52 +01:00
Pos.vy += groundHeight;
2001-02-14 17:04:41 +01:00
2001-01-26 16:16:07 +01:00
// pause and change direction
m_timerTimer = GameState::getOneSecondInFrames();
m_extendDir = EXTEND_UP;
}
2001-02-14 17:04:41 +01:00
else
{
// drop down
2001-01-26 16:16:07 +01:00
2001-02-15 21:50:52 +01:00
Pos.vy += yMovement;
2001-02-14 17:04:41 +01:00
}
2001-01-23 18:02:45 +01:00
}
else
{
2001-02-14 17:04:41 +01:00
if ( m_base.vx - Pos.vx == 0 && m_base.vy - Pos.vy == 0 )
2001-01-23 18:02:45 +01:00
{
2001-02-14 17:04:41 +01:00
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE;
m_timerTimer = GameState::getOneSecondInFrames();
m_sensorFunc = NPC_SENSOR_NONE;
m_npcPath.resetPath();
2001-01-23 18:02:45 +01:00
}
else
{
2001-02-14 17:04:41 +01:00
// return to original position
2001-01-26 16:16:07 +01:00
2001-02-14 17:04:41 +01:00
processGenericGotoTarget( _frames, m_base.vx - Pos.vx, m_base.vy - Pos.vy, 1 );
2001-01-23 18:02:45 +01:00
}
}
}
}