This commit is contained in:
parent
415a7d7f4f
commit
f821541cf3
5 changed files with 213 additions and 47 deletions
|
@ -185,7 +185,7 @@ void CNpcSquidDartEnemy::processClose( int _frames )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( yAim )
|
if ( abs( yAim ) > 20 )
|
||||||
{
|
{
|
||||||
movement = yAim;
|
movement = yAim;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,11 @@
|
||||||
#include "platform\pfallnor.h"
|
#include "platform\pfallnor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VID_HEADER_
|
||||||
|
#include "system\vid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcConveyorPlatformGenerator::collidedWith(CThing *_thisThing)
|
void CNpcConveyorPlatformGenerator::collidedWith(CThing *_thisThing)
|
||||||
|
@ -102,6 +107,9 @@ void CNpcConveyorPlatform::postInit()
|
||||||
CNpcPlatform::postInit();
|
CNpcPlatform::postInit();
|
||||||
|
|
||||||
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
||||||
|
|
||||||
|
m_spinFinish = false;
|
||||||
|
m_rotation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -112,40 +120,59 @@ void CNpcConveyorPlatform::processMovement( int _frames )
|
||||||
s32 distX, distY;
|
s32 distX, distY;
|
||||||
bool pathComplete, waypointChange;
|
bool pathComplete, waypointChange;
|
||||||
|
|
||||||
m_npcPath.think( Pos, &pathComplete, &waypointChange, &distX, &distY );
|
if ( m_spinFinish )
|
||||||
|
|
||||||
if ( pathComplete )
|
|
||||||
{
|
{
|
||||||
setToShutdown();
|
m_rotation += 64 * _frames;
|
||||||
|
m_rotation &= 4095;
|
||||||
|
|
||||||
|
DVECTOR offset = CLevel::getCameraPos();
|
||||||
|
|
||||||
|
Pos.vy += 3 * _frames;
|
||||||
|
|
||||||
|
s32 yPos = Pos.vy - offset.vy;
|
||||||
|
|
||||||
|
if ( yPos > VidGetScrH() )
|
||||||
|
{
|
||||||
|
setToShutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( distX )
|
m_npcPath.think( Pos, &pathComplete, &waypointChange, &distX, &distY );
|
||||||
{
|
|
||||||
moveX = distX;
|
|
||||||
|
|
||||||
if ( moveX > 1 )
|
if ( pathComplete )
|
||||||
{
|
{
|
||||||
moveX = 1;
|
m_spinFinish = true;
|
||||||
}
|
|
||||||
else if ( moveX < -1 )
|
|
||||||
{
|
|
||||||
moveX = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
moveY = distY;
|
if ( distX )
|
||||||
|
|
||||||
s32 verticalMovement = 3 * _frames;
|
|
||||||
|
|
||||||
if ( moveY > verticalMovement )
|
|
||||||
{
|
{
|
||||||
moveY = verticalMovement;
|
moveX = distX;
|
||||||
|
|
||||||
|
if ( moveX > 1 )
|
||||||
|
{
|
||||||
|
moveX = 1;
|
||||||
|
}
|
||||||
|
else if ( moveX < -1 )
|
||||||
|
{
|
||||||
|
moveX = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( moveY < -verticalMovement )
|
else
|
||||||
{
|
{
|
||||||
moveY = -verticalMovement;
|
moveY = distY;
|
||||||
|
|
||||||
|
s32 verticalMovement = 3 * _frames;
|
||||||
|
|
||||||
|
if ( moveY > verticalMovement )
|
||||||
|
{
|
||||||
|
moveY = verticalMovement;
|
||||||
|
}
|
||||||
|
else if ( moveY < -verticalMovement )
|
||||||
|
{
|
||||||
|
moveY = -verticalMovement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,9 +252,10 @@ void CNpcConveyorPlatform::collidedWith( CThing *_thisThing )
|
||||||
|
|
||||||
case TYPE_HAZARD:
|
case TYPE_HAZARD:
|
||||||
{
|
{
|
||||||
// needs to explode or something
|
if ( !m_spinFinish )
|
||||||
|
{
|
||||||
setToShutdown();
|
m_spinFinish = true;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -237,3 +265,45 @@ void CNpcConveyorPlatform::collidedWith( CThing *_thisThing )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcConveyorPlatform::render()
|
||||||
|
{
|
||||||
|
if ( m_isActive )
|
||||||
|
{
|
||||||
|
CPlatformThing::render();
|
||||||
|
|
||||||
|
// Render
|
||||||
|
if (canRender())
|
||||||
|
{
|
||||||
|
DVECTOR &renderPos=getRenderPos();
|
||||||
|
|
||||||
|
SVECTOR rotation;
|
||||||
|
rotation.vx = 0;
|
||||||
|
rotation.vy = 0;
|
||||||
|
rotation.vz = m_rotation;
|
||||||
|
|
||||||
|
VECTOR scale;
|
||||||
|
scale.vx = ONE;
|
||||||
|
scale.vy = ONE;
|
||||||
|
scale.vz = ONE;
|
||||||
|
|
||||||
|
m_modelGfx->Render(renderPos,&rotation,&scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
int CNpcConveyorPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames)
|
||||||
|
{
|
||||||
|
if ( m_spinFinish )
|
||||||
|
{
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return( CNpcPlatform::checkCollisionAgainst( _thisThing, _frames ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,9 +23,14 @@ class CNpcConveyorPlatform : public CNpcPlatform
|
||||||
public:
|
public:
|
||||||
virtual void postInit();
|
virtual void postInit();
|
||||||
virtual CRECT const *getThinkBBox();
|
virtual CRECT const *getThinkBBox();
|
||||||
|
virtual void render();
|
||||||
|
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
|
||||||
protected:
|
protected:
|
||||||
virtual void processMovement( int _frames );
|
virtual void processMovement( int _frames );
|
||||||
virtual void collidedWith(CThing *_thisThing);
|
virtual void collidedWith(CThing *_thisThing);
|
||||||
|
|
||||||
|
u8 m_spinFinish;
|
||||||
|
s16 m_rotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CNpcConveyorPlatformGenerator : public CNpcPlatform
|
class CNpcConveyorPlatformGenerator : public CNpcPlatform
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
#include "utils\utils.h"
|
#include "utils\utils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VID_HEADER_
|
||||||
|
#include "system\vid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcFallingNoRespawnPlatform::postInit()
|
void CNpcFallingNoRespawnPlatform::postInit()
|
||||||
|
@ -30,46 +35,84 @@ void CNpcFallingNoRespawnPlatform::postInit()
|
||||||
CNpcPlatform::postInit();
|
CNpcPlatform::postInit();
|
||||||
|
|
||||||
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
||||||
|
|
||||||
|
m_spinFinish = false;
|
||||||
|
m_rotation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcFallingNoRespawnPlatform::processMovement( int _frames )
|
void CNpcFallingNoRespawnPlatform::processMovement( int _frames )
|
||||||
{
|
{
|
||||||
s32 moveX, moveY;
|
s32 moveX = 0, moveY = 0;
|
||||||
s32 distX, distY, heading;
|
s32 distX, distY, heading;
|
||||||
bool pathComplete;
|
bool pathComplete;
|
||||||
|
|
||||||
m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading );
|
if ( m_spinFinish )
|
||||||
|
|
||||||
if ( pathComplete )
|
|
||||||
{
|
{
|
||||||
setToShutdown();
|
m_rotation += 64 * _frames;
|
||||||
|
m_rotation &= 4095;
|
||||||
|
|
||||||
|
DVECTOR offset = CLevel::getCameraPos();
|
||||||
|
|
||||||
|
if ( m_bounceDir )
|
||||||
|
{
|
||||||
|
Pos.vx += 2 * _frames;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pos.vx -= 2 * _frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pos.vy += m_speed * _frames;
|
||||||
|
|
||||||
|
if ( m_speed < 3 )
|
||||||
|
{
|
||||||
|
m_speed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 yPos = Pos.vy - offset.vy;
|
||||||
|
|
||||||
|
if ( yPos > VidGetScrH() )
|
||||||
|
{
|
||||||
|
setToShutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
moveX = 0;
|
m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading );
|
||||||
moveY = m_speed * _frames;
|
|
||||||
|
|
||||||
if ( heading == 3072 )
|
if ( pathComplete )
|
||||||
{
|
{
|
||||||
moveY = -moveY;
|
m_spinFinish = true;
|
||||||
|
m_speed = -5;
|
||||||
|
m_bounceDir = getRnd() % 2;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 );
|
|
||||||
|
|
||||||
if ( groundHeight < moveY )
|
|
||||||
{
|
{
|
||||||
if ( ( CGameScene::getCollision()->getCollisionBlock( Pos.vx, Pos.vy + groundHeight + 8 ) & COLLISION_TYPE_MASK ) != COLLISION_TYPE_FLAG_DEATH_FALL )
|
moveX = 0;
|
||||||
|
moveY = m_speed * _frames;
|
||||||
|
|
||||||
|
if ( heading == 3072 )
|
||||||
{
|
{
|
||||||
moveY = groundHeight;
|
moveY = -moveY;
|
||||||
moveX = 2 * _frames;
|
}
|
||||||
|
|
||||||
|
s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 );
|
||||||
|
|
||||||
|
if ( groundHeight < moveY )
|
||||||
|
{
|
||||||
|
if ( ( CGameScene::getCollision()->getCollisionBlock( Pos.vx, Pos.vy + groundHeight + 8 ) & COLLISION_TYPE_MASK ) != COLLISION_TYPE_FLAG_DEATH_FALL )
|
||||||
|
{
|
||||||
|
moveY = groundHeight;
|
||||||
|
moveX = 2 * _frames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pos.vx += moveX;
|
|
||||||
Pos.vy += moveY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pos.vx += moveX;
|
||||||
|
Pos.vy += moveY;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -85,4 +128,46 @@ const CRECT *CNpcFallingNoRespawnPlatform::getThinkBBox()
|
||||||
objThinkBox.y2 = thinkBBox.YMax;
|
objThinkBox.y2 = thinkBBox.YMax;
|
||||||
|
|
||||||
return &objThinkBox;
|
return &objThinkBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcFallingNoRespawnPlatform::render()
|
||||||
|
{
|
||||||
|
if ( m_isActive )
|
||||||
|
{
|
||||||
|
CPlatformThing::render();
|
||||||
|
|
||||||
|
// Render
|
||||||
|
if (canRender())
|
||||||
|
{
|
||||||
|
DVECTOR &renderPos=getRenderPos();
|
||||||
|
|
||||||
|
SVECTOR rotation;
|
||||||
|
rotation.vx = 0;
|
||||||
|
rotation.vy = 0;
|
||||||
|
rotation.vz = m_rotation;
|
||||||
|
|
||||||
|
VECTOR scale;
|
||||||
|
scale.vx = ONE;
|
||||||
|
scale.vy = ONE;
|
||||||
|
scale.vz = ONE;
|
||||||
|
|
||||||
|
m_modelGfx->Render(renderPos,&rotation,&scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
int CNpcFallingNoRespawnPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames)
|
||||||
|
{
|
||||||
|
if ( m_spinFinish )
|
||||||
|
{
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return( CNpcPlatform::checkCollisionAgainst( _thisThing, _frames ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,8 +23,14 @@ class CNpcFallingNoRespawnPlatform : public CNpcPlatform
|
||||||
public:
|
public:
|
||||||
virtual void postInit();
|
virtual void postInit();
|
||||||
virtual CRECT const *getThinkBBox();
|
virtual CRECT const *getThinkBBox();
|
||||||
|
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
|
||||||
protected:
|
protected:
|
||||||
|
virtual void render();
|
||||||
virtual void processMovement( int _frames );
|
virtual void processMovement( int _frames );
|
||||||
|
|
||||||
|
u8 m_spinFinish;
|
||||||
|
s16 m_rotation;
|
||||||
|
u8 m_bounceDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue