This commit is contained in:
parent
09988b65e3
commit
9de1206cc2
4 changed files with 99 additions and 50 deletions
|
@ -1,2 +1,2 @@
|
||||||
Idle
|
Idle
|
||||||
Move
|
|
||||||
|
|
|
@ -29,6 +29,35 @@
|
||||||
void CNpcDustDevilEnemy::postInit()
|
void CNpcDustDevilEnemy::postInit()
|
||||||
{
|
{
|
||||||
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
||||||
|
|
||||||
|
m_fadeVal = 128;
|
||||||
|
m_fadeOut = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcDustDevilEnemy::render()
|
||||||
|
{
|
||||||
|
SprFrame = NULL;
|
||||||
|
|
||||||
|
if ( m_isActive )
|
||||||
|
{
|
||||||
|
CEnemyThing::render();
|
||||||
|
|
||||||
|
if (canRender())
|
||||||
|
{
|
||||||
|
DVECTOR &renderPos=getRenderPos();
|
||||||
|
|
||||||
|
SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed);
|
||||||
|
setSemiTrans( SprFrame, true );
|
||||||
|
m_actorGfx->RotateScale( SprFrame, renderPos, m_drawRotation, 4096, 4096 );
|
||||||
|
setRGB0( SprFrame, m_fadeVal, m_fadeVal, m_fadeVal );
|
||||||
|
|
||||||
|
sBBox boundingBox = m_actorGfx->GetBBox();
|
||||||
|
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
|
||||||
|
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -57,73 +86,88 @@ void CNpcDustDevilEnemy::processMovement( int _frames )
|
||||||
m_animNo = m_data[m_type].moveAnim;
|
m_animNo = m_data[m_type].moveAnim;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore y component of waypoint, since we are stuck to the ground
|
if ( m_fadeOut )
|
||||||
|
|
||||||
if ( m_npcPath.thinkFlat( Pos, &pathComplete, &distX, &distY, &m_heading ) )
|
|
||||||
{
|
{
|
||||||
// path has finished, waypoint has changed, or there are no waypoints - do not move horizontally
|
m_fadeVal -= _frames * 12;
|
||||||
|
|
||||||
if ( pathComplete )
|
if ( m_fadeVal < 0 )
|
||||||
{
|
{
|
||||||
m_npcPath.resetPath();
|
m_npcPath.resetPath();
|
||||||
|
|
||||||
Pos = m_base;
|
Pos = m_base;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// check for vertical movement
|
|
||||||
|
|
||||||
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
m_fadeOut = false;
|
||||||
|
m_fadeVal = 128;
|
||||||
if ( groundHeight <= yMovement )
|
|
||||||
{
|
|
||||||
// groundHeight <= yMovement indicates either just above ground or on or below ground
|
|
||||||
|
|
||||||
moveY = groundHeight;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// fall
|
|
||||||
|
|
||||||
moveY = yMovement;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check for collision
|
// ignore y component of waypoint, since we are stuck to the ground
|
||||||
|
|
||||||
distX = distX / abs( distX );
|
if ( m_npcPath.thinkFlat( Pos, &pathComplete, &distX, &distY, &m_heading ) )
|
||||||
|
|
||||||
if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight )
|
|
||||||
{
|
{
|
||||||
// there is an obstacle in the way, increment the path point (hopefully this will resolve the problem)
|
// path has finished, waypoint has changed, or there are no waypoints - do not move horizontally
|
||||||
|
|
||||||
m_npcPath.incPath();
|
if ( pathComplete )
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// check for vertical movement
|
|
||||||
|
|
||||||
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
|
||||||
|
|
||||||
if ( groundHeight <= yMovement )
|
|
||||||
{
|
{
|
||||||
// groundHeight <= yMovement indicates either just above ground or on or below ground
|
m_fadeOut = true;
|
||||||
|
|
||||||
moveX = distX * m_speed * _frames;
|
|
||||||
moveY = groundHeight;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fall
|
// check for vertical movement
|
||||||
|
|
||||||
moveY = yMovement;
|
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
||||||
|
|
||||||
|
if ( groundHeight <= yMovement )
|
||||||
|
{
|
||||||
|
// groundHeight <= yMovement indicates either just above ground or on or below ground
|
||||||
|
|
||||||
|
moveY = groundHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// fall
|
||||||
|
|
||||||
|
moveY = yMovement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
// check for collision
|
||||||
|
|
||||||
processMovementModifier( _frames, moveX, moveY, moveVel, moveDist );
|
distX = distX / abs( distX );
|
||||||
|
|
||||||
|
if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight )
|
||||||
|
{
|
||||||
|
// there is an obstacle in the way, increment the path point (hopefully this will resolve the problem)
|
||||||
|
|
||||||
|
m_npcPath.incPath();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check for vertical movement
|
||||||
|
|
||||||
|
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
||||||
|
|
||||||
|
if ( groundHeight <= yMovement )
|
||||||
|
{
|
||||||
|
// groundHeight <= yMovement indicates either just above ground or on or below ground
|
||||||
|
|
||||||
|
moveX = distX * m_speed * _frames;
|
||||||
|
moveY = groundHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// fall
|
||||||
|
|
||||||
|
moveY = yMovement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processMovementModifier( _frames, moveX, moveY, moveVel, moveDist );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -18,10 +18,15 @@ class CNpcDustDevilEnemy : public CNpcEnemy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void postInit();
|
void postInit();
|
||||||
|
void render();
|
||||||
|
u8 canCollideWithEnemy() {return( false );}
|
||||||
protected:
|
protected:
|
||||||
s32 getFrameShift( int _frames );
|
s32 getFrameShift( int _frames );
|
||||||
void processMovement( int _frames );
|
void processMovement( int _frames );
|
||||||
void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange );
|
void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange );
|
||||||
|
|
||||||
|
s16 m_fadeVal;
|
||||||
|
u8 m_fadeOut;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -123,8 +123,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
||||||
false,
|
false,
|
||||||
3,
|
3,
|
||||||
2048,
|
2048,
|
||||||
DETECT_NO_COLLISION,
|
DETECT_ALL_COLLISION,
|
||||||
DAMAGE__NONE,
|
DAMAGE__HIT_ENEMY,
|
||||||
1,
|
1,
|
||||||
ANIM_DUSTDEVIL_TWIST,
|
ANIM_DUSTDEVIL_TWIST,
|
||||||
NPC_SHOT_GENERIC,
|
NPC_SHOT_GENERIC,
|
||||||
|
@ -133,7 +133,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
false,
|
||||||
CSoundMediator::NUM_SFXIDS,
|
CSoundMediator::NUM_SFXIDS,
|
||||||
CSoundMediator::NUM_SFXIDS,
|
CSoundMediator::NUM_SFXIDS,
|
||||||
false,
|
false,
|
||||||
|
@ -699,7 +699,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
||||||
DETECT_ALL_COLLISION,
|
DETECT_ALL_COLLISION,
|
||||||
DAMAGE__HIT_ENEMY,
|
DAMAGE__HIT_ENEMY,
|
||||||
1,
|
1,
|
||||||
ANIM_GHOST_MOVE,
|
ANIM_GHOST_IDLE,
|
||||||
NPC_SHOT_GENERIC,
|
NPC_SHOT_GENERIC,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue