SBSPSS/source/enemy/nsstomp.cpp

129 lines
2.2 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
2001-04-20 22:22:16 +02:00
#ifndef __ENEMY_NSSTOMP_H__
#include "enemy\nsstomp.h"
#endif
2001-01-23 18:02:45 +01:00
#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-04-02 17:52:09 +02:00
#ifndef __ANIM_STOMPER_HEADER__
#include <ACTOR_STOMPER_ANIM.h>
#endif
2001-01-23 18:02:45 +01:00
2001-04-24 21:03:06 +02:00
void CNpcSkullStomperEnemy::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
2001-04-20 22:22:16 +02:00
void CNpcSkullStomperEnemy::postInit()
{
m_extendDir = EXTEND_DOWN;
}
bool CNpcSkullStomperEnemy::processSensor()
{
switch( m_sensorFunc )
{
case NPC_SENSOR_NONE:
return( false );
default:
{
if ( playerXDistSqr < 10000 && playerYDist >= 0 )
{
m_controlFunc = NPC_CONTROL_CLOSE;
m_extendDir = EXTEND_DOWN;
return( true );
}
else
{
return( false );
}
}
}
}
void CNpcSkullStomperEnemy::processClose( int _frames )
2001-01-23 18:02:45 +01:00
{
2001-02-15 21:50:52 +01:00
s8 groundHeight;
s8 yMovement;
2001-04-02 17:52:09 +02:00
if ( !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_STOMPER_CRUSH;
m_frame = 0;
}
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
2001-04-18 18:34:17 +02:00
m_timerTimer = 3 * GameState::getOneSecondInFrames();
2001-01-26 16:16:07 +01:00
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
}
}
}
}