This commit is contained in:
Charles 2001-04-03 18:32:24 +00:00
parent 8c791a4ab5
commit 4807987d37
7 changed files with 145 additions and 3 deletions

View File

@ -76,7 +76,8 @@ enemy_src := npc \
ngary \
nplatfrm \
nworm \
nhcrab
nhcrab \
nbblob
projectl_src := projectl

View File

@ -15,6 +15,125 @@
#include "enemy\npc.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __ANIM_BALLBLOB_HEADER__
#include <ACTOR_BALLBLOB_ANIM.h>
#endif
void CNpcEnemy::processBallBlobMovement( int _frames, s32 *moveX, s32 *moveY )
{
s32 waypointXDist;
s32 waypointYDist;
s32 waypointHeading;
if ( !m_animPlaying && m_frame != 0 )
{
m_animNo = ANIM_BALLBLOB_WOBBLE;
m_frame = 0;
}
else if ( m_animNo == ANIM_BALLBLOB_BOUNCE )
{
*moveX = 0;
*moveY = 0;
return;
}
// deal with horizontal
if ( m_npcPath.thinkFlat( Pos, &waypointXDist, &waypointYDist, &waypointHeading ) )
{
// increment waypoint
if ( waypointHeading == 0 )
{
// head right
if ( m_heading >= 1024 && m_heading <= 3072 )
{
// currently heading in the wrong direction, reverse horizontal
s32 headingDiff = m_heading - 2048;
headingDiff = -headingDiff;
headingDiff += 4096;
m_heading = headingDiff % 4096;
m_animPlaying = true;
m_animNo = ANIM_BALLBLOB_WOBBLE;
m_frame = 0;
}
}
else
{
// head left
if ( m_heading < 1024 || m_heading > 3072 )
{
// currently heading in the wrong direction, reverse horizontal
s32 headingDiff = m_heading;
headingDiff = -headingDiff;
headingDiff += 6144;
m_heading = headingDiff % 4096;
m_animPlaying = true;
m_animNo = ANIM_BALLBLOB_WOBBLE;
m_frame = 0;
}
}
}
s32 preShiftX = _frames * m_data[m_type].speed * rcos( m_heading );
s32 preShiftY = _frames * m_data[m_type].speed * rsin( m_heading );
*moveX = preShiftX >> 12;
if ( !(*moveX) && preShiftX )
{
*moveX = preShiftX / abs( preShiftX );
}
*moveY = preShiftY >> 12;
if ( !(*moveY) && preShiftY )
{
*moveY = preShiftY / abs( preShiftY );
}
// deal with vertical
if ( Pos.vy < 0 || m_layerCollision->Get( ( Pos.vx + *moveX ) >> 4, ( Pos.vy + *moveY ) >> 4 ) )
{
// reflect heading in vertical
m_heading = 4096 - m_heading;
m_animPlaying = true;
m_animNo = ANIM_BALLBLOB_BOUNCE;
m_frame = 0;
// get new movement values
preShiftX = _frames * m_data[m_type].speed * rcos( m_heading );
preShiftY = _frames * m_data[m_type].speed * rsin( m_heading );
*moveX = preShiftX >> 12;
if ( !(*moveX) && preShiftX )
{
*moveX = preShiftX / abs( preShiftX );
}
*moveY = preShiftY >> 12;
if ( !(*moveY) && preShiftY )
{
*moveY = preShiftY / abs( preShiftY );
}
}
}

View File

@ -235,7 +235,7 @@ void CNpcEnemy::init()
m_animNo = m_data[m_type].initAnim;
m_frame = 0;
m_heading = m_fireHeading = 0;
m_heading = m_fireHeading = 128;
m_movementTimer = 0;
m_timerTimer = 0;
m_velocity = 0;
@ -1093,6 +1093,13 @@ void CNpcEnemy::processMovement(int _frames)
break;
}
case NPC_MOVEMENT_BALL_BLOB:
{
processBallBlobMovement( _frames, &moveX, &moveY );
break;
}
default:
break;

View File

@ -277,6 +277,7 @@ protected:
NPC_MOVEMENT_PARASITIC_WORM,
NPC_MOVEMENT_STATIC_CYCLE_ANIM,
NPC_MOVEMENT_SHARK_MAN,
NPC_MOVEMENT_BALL_BLOB,
};
enum NPC_MOVEMENT_MODIFIER_FUNC
@ -417,6 +418,10 @@ protected:
void processFishFolkMovementModifier( int _frames, s32 distX, s32 distY );
// ball blob functions
void processBallBlobMovement( int _frames, s32 *moveX, s32 *moveY );
// clam functions
void processCloseClamJumpAttack( int _frames );

View File

@ -906,7 +906,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
ANIM_BALLBLOB_WOBBLE,
NPC_INIT_DEFAULT,
NPC_SENSOR_NONE,
NPC_MOVEMENT_FIXED_PATH,
NPC_MOVEMENT_BALL_BLOB,
NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_NONE,
NPC_TIMER_NONE,

View File

@ -224,6 +224,9 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang
{
*pathComplete = incPath();
*waypointChange = true;
xDist = currentWaypoint->pos.vx - currentPos.vx;
yDist = currentWaypoint->pos.vy - currentPos.vy;
}
s32 headingToTarget = ratan2( yDist, xDist );
@ -256,6 +259,9 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *headi
incPath();
}
*distX = currentWaypoint->pos.vx - currentPos.vx;
*distY = currentWaypoint->pos.vy - currentPos.vy;
if ( *distX > 0 )
{
*heading = 0;

View File

@ -113,6 +113,10 @@ SOURCE=..\..\..\source\enemy\nanemone.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\enemy\nbblob.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\enemy\nbooger.cpp
# End Source File
# Begin Source File