87 lines
1.4 KiB
C++
87 lines
1.4 KiB
C++
/*=========================================================================
|
|
|
|
nsklfish.cpp
|
|
|
|
Author: CRB
|
|
Created:
|
|
Project: Spongebob
|
|
Purpose:
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
===========================================================================*/
|
|
|
|
#ifndef __ENEMY_NPC_H__
|
|
#include "enemy\npc.h"
|
|
#endif
|
|
|
|
#ifndef __ENEMY_NSKLFISH_H__
|
|
#include "enemy\nsklfish.h"
|
|
#endif
|
|
|
|
#ifndef __GAME_GAME_H__
|
|
#include "game\game.h"
|
|
#endif
|
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
#include "player\player.h"
|
|
#endif
|
|
|
|
#ifndef __ANIM_SKELETALFISH_HEADER__
|
|
#include <ACTOR_SKELETALFISH_ANIM.h>
|
|
#endif
|
|
|
|
|
|
void CNpcSkeletalFishEnemy::processClose( int _frames )
|
|
{
|
|
s32 moveX, moveY;
|
|
s16 decDir, incDir, moveDist;
|
|
|
|
s16 headingToPlayer = ratan2( playerYDist, playerXDist );
|
|
|
|
if ( !m_animPlaying )
|
|
{
|
|
m_animPlaying = true;
|
|
m_animNo = ANIM_SKELETALFISH_SWIM;
|
|
m_frame = 0;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|