SBSPSS/source/enemy/nbooger.cpp
Charles e77ef80771
2001-02-07 16:42:13 +00:00

86 lines
1.5 KiB
C++

/*=========================================================================
nbooger.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__
#include "game\game.h"
#endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
void CNpc::processCloseBoogerMonsterAttack( int _frames )
{
s32 velocity;
if ( playerXDistSqr + playerYDistSqr > 10000 )
{
// user out of range, retract
if ( m_extension > 0 )
{
// retract
velocity = 1 * _frames;
if ( m_extension < velocity )
{
velocity = m_extension;
}
m_extension -= velocity;
Pos.vx += ( -velocity * rcos( m_heading ) ) >> 12;
Pos.vy += ( -velocity * rsin( m_heading ) ) >> 12;
}
else
{
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE;
m_timerTimer = GameState::getOneSecondInFrames();
m_sensorFunc = NPC_SENSOR_NONE;
}
}
else
{
if ( m_extension < NPC_BOOGER_MONSTER_MAX_EXTENSION )
{
// extend
velocity = 1 * _frames;
if ( m_extension + velocity < NPC_BOOGER_MONSTER_MAX_EXTENSION )
{
m_extension += velocity;
}
else
{
velocity = NPC_BOOGER_MONSTER_MAX_EXTENSION - m_extension;
m_extension = NPC_BOOGER_MONSTER_MAX_EXTENSION;
}
Pos.vx += ( velocity * rcos( m_heading ) ) >> 12;
Pos.vy += ( velocity * rsin( m_heading ) ) >> 12;
}
else
{
// grab player
}
}
}