SBSPSS/source/enemy/nsklfish.cpp

87 lines
1.4 KiB
C++
Raw Normal View History

2001-02-12 16:37:31 +01:00
/*=========================================================================
nsklfish.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 16:48:15 +02:00
#ifndef __ENEMY_NSKLFISH_H__
#include "enemy\nsklfish.h"
#endif
2001-02-12 16:37:31 +01:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2001-04-02 17:52:09 +02:00
#ifndef __ANIM_SKELETALFISH_HEADER__
#include <ACTOR_SKELETALFISH_ANIM.h>
#endif
2001-02-12 16:37:31 +01:00
2001-04-20 16:48:15 +02:00
void CNpcSkeletalFishEnemy::processClose( int _frames )
2001-02-12 16:37:31 +01:00
{
s32 moveX, moveY;
s16 decDir, incDir, moveDist;
s16 headingToPlayer = ratan2( playerYDist, playerXDist );
2001-04-02 17:52:09 +02:00
if ( !m_animPlaying )
{
m_animPlaying = true;
m_animNo = ANIM_SKELETALFISH_SWIM;
m_frame = 0;
}
2001-02-12 16:37:31 +01:00
decDir = m_heading - headingToPlayer;
if ( decDir < 0 )
{
decDir += ONE;
}
incDir = headingToPlayer - m_heading;
if ( incDir < 0 )
{
incDir += ONE;
}
if ( decDir < incDir )
{
moveDist = -decDir;
}
else
{
moveDist = incDir;
}
s32 xDistWaypoint, yDistWaypoint;
m_npcPath.getDistToNextWaypoint( Pos, &xDistWaypoint, &yDistWaypoint );
if ( abs( moveDist ) < 1024 && abs( xDistWaypoint ) >= abs( playerXDist ) )
{
// continue charge
processGenericGotoTarget( _frames, playerXDist, playerYDist, m_velocity );
}
else
{
m_controlFunc = NPC_CONTROL_MOVEMENT;
}
}