This commit is contained in:
parent
796aeddca7
commit
bc760c2dd3
15 changed files with 447 additions and 367 deletions
|
@ -15,6 +15,14 @@
|
|||
#include "enemy\npc.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ENEMY_NSJFISH_H__
|
||||
#include "enemy\nsjfish.h"
|
||||
#endif
|
||||
|
||||
#ifndef __UTILS_HEADER__
|
||||
#include "utils\utils.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAME_H__
|
||||
#include "game\game.h"
|
||||
#endif
|
||||
|
@ -23,94 +31,17 @@
|
|||
#include "player\player.h"
|
||||
#endif
|
||||
|
||||
|
||||
void CNpcEnemy::processSmallJellyfishMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange )
|
||||
void CNpcSmallJellyfishEnemy::render()
|
||||
{
|
||||
s32 newX, newY;
|
||||
s32 preShiftX, preShiftY;
|
||||
s16 headingVal;
|
||||
CNpcEnemy::render();
|
||||
|
||||
//u16 jellyfishData[5] = { 96, 192, 256, 192, 128, };
|
||||
u16 jellyfishData[6] = { 256, 192, 96, 48, 96, 128, };
|
||||
|
||||
u32 dataPoint;
|
||||
|
||||
m_movementTimer += _frames;
|
||||
|
||||
if ( m_movementTimer > GameState::getOneSecondInFrames() )
|
||||
if ( SprFrame )
|
||||
{
|
||||
m_movementTimer = 0;
|
||||
setRGB0( SprFrame, 255, 128, 255 );
|
||||
}
|
||||
|
||||
dataPoint = 5 * m_movementTimer;
|
||||
|
||||
if ( dataPoint != 0 )
|
||||
{
|
||||
dataPoint /= GameState::getOneSecondInFrames();
|
||||
}
|
||||
|
||||
m_frame = ( ( m_movementTimer * ( m_actorGfx->getFrameCount(m_animNo) - 1 ) << 8 ) ) / GameState::getOneSecondInFrames();
|
||||
|
||||
s32 resistance;
|
||||
s32 absVelocity = abs( m_velocity );
|
||||
s32 reqVelocity = dist;
|
||||
|
||||
resistance = _frames * NPC_JELLYFISH_RESISTANCE;
|
||||
|
||||
if ( absVelocity < resistance )
|
||||
{
|
||||
resistance = absVelocity;
|
||||
}
|
||||
|
||||
if ( absVelocity != 0 )
|
||||
{
|
||||
resistance = -( resistance * m_velocity ) / absVelocity;
|
||||
}
|
||||
else
|
||||
{
|
||||
resistance = 0;
|
||||
}
|
||||
|
||||
m_velocity += resistance;
|
||||
|
||||
headingVal = abs( headingChange );
|
||||
if ( headingVal > 128 )
|
||||
{
|
||||
headingVal = 128;
|
||||
}
|
||||
|
||||
reqVelocity = dist * jellyfishData[dataPoint];
|
||||
reqVelocity >>= 8;
|
||||
reqVelocity *= 128 + ( 128 - headingVal );
|
||||
reqVelocity >>= 8;
|
||||
|
||||
s32 absReqVelocity = abs( reqVelocity );
|
||||
|
||||
if ( absReqVelocity > absVelocity )
|
||||
{
|
||||
m_velocity += reqVelocity >> 1;
|
||||
}
|
||||
|
||||
preShiftX = ( m_velocity >> 8 ) * rcos( m_heading );
|
||||
preShiftY = ( m_velocity >> 8 ) * rsin( m_heading );
|
||||
|
||||
newX = preShiftX >> 12;
|
||||
if ( !newX && preShiftX )
|
||||
{
|
||||
newX = preShiftX / abs( preShiftX );
|
||||
}
|
||||
|
||||
newY = preShiftY >> 12;
|
||||
if ( !newY && preShiftY )
|
||||
{
|
||||
newY = preShiftY / abs( preShiftY );
|
||||
}
|
||||
|
||||
Pos.vx += newX;
|
||||
Pos.vy += newY;
|
||||
}
|
||||
|
||||
void CNpcEnemy::processCloseSmallJellyfishEvade( int _frames )
|
||||
void CNpcSmallJellyfishEnemy::processClose( int _frames )
|
||||
{
|
||||
s32 moveX = 0, moveY = 0;
|
||||
|
||||
|
@ -241,3 +172,113 @@ void CNpcEnemy::processCloseSmallJellyfishEvade( int _frames )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CNpcSmallJellyfishEnemy::processSensor()
|
||||
{
|
||||
switch( m_sensorFunc )
|
||||
{
|
||||
case NPC_SENSOR_NONE:
|
||||
return( false );
|
||||
|
||||
default:
|
||||
{
|
||||
if ( playerXDistSqr + playerYDistSqr < 5625 )
|
||||
{
|
||||
m_controlFunc = NPC_CONTROL_CLOSE;
|
||||
m_evadeClockwise = getRnd() % 2;
|
||||
|
||||
return( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CNpcSmallJellyfishEnemy::processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange )
|
||||
{
|
||||
s32 newX, newY;
|
||||
s32 preShiftX, preShiftY;
|
||||
s16 headingVal;
|
||||
|
||||
//u16 jellyfishData[5] = { 96, 192, 256, 192, 128, };
|
||||
u16 jellyfishData[6] = { 256, 192, 96, 48, 96, 128, };
|
||||
|
||||
u32 dataPoint;
|
||||
|
||||
m_movementTimer += _frames;
|
||||
|
||||
if ( m_movementTimer > GameState::getOneSecondInFrames() )
|
||||
{
|
||||
m_movementTimer = 0;
|
||||
}
|
||||
|
||||
dataPoint = 5 * m_movementTimer;
|
||||
|
||||
if ( dataPoint != 0 )
|
||||
{
|
||||
dataPoint /= GameState::getOneSecondInFrames();
|
||||
}
|
||||
|
||||
m_frame = ( ( m_movementTimer * ( m_actorGfx->getFrameCount(m_animNo) - 1 ) << 8 ) ) / GameState::getOneSecondInFrames();
|
||||
|
||||
s32 resistance;
|
||||
s32 absVelocity = abs( m_velocity );
|
||||
s32 reqVelocity = dist;
|
||||
|
||||
resistance = _frames * NPC_JELLYFISH_RESISTANCE;
|
||||
|
||||
if ( absVelocity < resistance )
|
||||
{
|
||||
resistance = absVelocity;
|
||||
}
|
||||
|
||||
if ( absVelocity != 0 )
|
||||
{
|
||||
resistance = -( resistance * m_velocity ) / absVelocity;
|
||||
}
|
||||
else
|
||||
{
|
||||
resistance = 0;
|
||||
}
|
||||
|
||||
m_velocity += resistance;
|
||||
|
||||
headingVal = abs( headingChange );
|
||||
if ( headingVal > 128 )
|
||||
{
|
||||
headingVal = 128;
|
||||
}
|
||||
|
||||
reqVelocity = dist * jellyfishData[dataPoint];
|
||||
reqVelocity >>= 8;
|
||||
reqVelocity *= 128 + ( 128 - headingVal );
|
||||
reqVelocity >>= 8;
|
||||
|
||||
s32 absReqVelocity = abs( reqVelocity );
|
||||
|
||||
if ( absReqVelocity > absVelocity )
|
||||
{
|
||||
m_velocity += reqVelocity >> 1;
|
||||
}
|
||||
|
||||
preShiftX = ( m_velocity >> 8 ) * rcos( m_heading );
|
||||
preShiftY = ( m_velocity >> 8 ) * rsin( m_heading );
|
||||
|
||||
newX = preShiftX >> 12;
|
||||
if ( !newX && preShiftX )
|
||||
{
|
||||
newX = preShiftX / abs( preShiftX );
|
||||
}
|
||||
|
||||
newY = preShiftY >> 12;
|
||||
if ( !newY && preShiftY )
|
||||
{
|
||||
newY = preShiftY / abs( preShiftY );
|
||||
}
|
||||
|
||||
Pos.vx += newX;
|
||||
Pos.vy += newY;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue