This commit is contained in:
Charles 2001-05-25 19:08:35 +00:00
parent 68ca825123
commit 861c534304
8 changed files with 195 additions and 26 deletions

View File

@ -65,7 +65,7 @@ void CNpcSquidDartEnemy::render()
int frame = FRM_SQUIDDART_SWIM0001 + ( m_frame >> 8 );
SprFrame = CGameScene::getSpriteBank()->printFT4(frame,renderPos.vx,renderPos.vy,m_reversed,0,10);
SprFrame = CGameScene::getSpriteBank()->printFT4(frame,renderPos.vx,renderPos.vy,m_reversed,0,0);
//setRGB0( SprFrame, 255, 128, 255 );

View File

@ -34,6 +34,19 @@ void CNpcGaryFriend::think( int _frames )
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
if ( m_platform )
{
s32 platformHeight = m_platform->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy );
if ( platformHeight < groundHeight )
{
groundHeight = platformHeight;
}
//Pos.vy += platformHeight;
//return;
}
if ( groundHeight <= 0 )
{
// groundHeight <= 0 indicates either on ground or below ground

View File

@ -174,6 +174,7 @@ void CNpcFriend::init()
m_animNo = m_data[m_type].idleAnim;
m_frame = 0;
m_reversed = false;
m_platform = NULL;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -245,6 +246,7 @@ void CNpcFriend::render()
m_actorGfx->Render(renderPos,m_animNo,(m_frame>>8),m_reversed);
sBBox boundingBox = m_actorGfx->GetBBox();
boundingBox.YMax = 0;
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
}

View File

@ -22,6 +22,10 @@
#include "player\player.h"
#endif
#ifndef __PLATFORM_PLATFORM_H__
#include "platform\platform.h"
#endif
class CNpcFriend : public CNpcThing
{
public:
@ -51,6 +55,8 @@ public:
void setType( NPC_FRIEND_UNIT_TYPE newType ) {m_type = newType;}
void setPlatform( CNpcPlatform *platform ) {m_platform = platform;}
void clearPlatform() {m_platform = NULL;}
static CNpcFriend *Create(sThingActor *ThisActor);
static NPC_FRIEND_UNIT_TYPE getTypeFromMapEdit( u16 newType );
@ -93,6 +99,7 @@ protected:
NPC_FRIEND_UNIT_TYPE m_type;
s32 m_extension;
CNpcPlatform *m_platform;
int m_frame;
int m_animNo;

View File

@ -15,6 +15,10 @@
#include "platform\pdual.h"
#endif
#ifndef __HAZARD_HAZARD_H__
#include "hazard\hazard.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
@ -232,3 +236,76 @@ const CRECT *CNpcDualPlatform::getThinkBBox()
return &objThinkBox;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcDualPlatform::collidedWith( CThing *_thisThing )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player;
DVECTOR playerPos;
CRECT collisionArea;
// Only interested in SBs feet colliding with the box (pkg)
player=(CPlayer*)_thisThing;
playerPos=player->getPos();
collisionArea=getCollisionArea();
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
if ( threshold > 16 )
{
threshold = 16;
}
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
{
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
{
player->setPlatform( this );
m_contact = true;
}
else
{
if( playerPos.vy >= collisionArea.y1 && playerPos.vy <= collisionArea.y2 )
{
int height = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy );
if ( height >= -threshold && height < 1 )
{
player->setPlatform( this );
m_contact = true;
}
}
}
}
break;
}
case TYPE_NPC:
break;
case TYPE_HAZARD:
{
m_contact = true;
CNpcHazard *hazard;
hazard = (CNpcHazard *)_thisThing;
hazard->setPlatform( this );
break;
}
default:
ASSERT(0);
break;
}
}

View File

@ -32,6 +32,7 @@ public:
protected:
virtual void setWaypoints( sThingPlatform *ThisPlatform );
virtual void processMovement( int _frames );
virtual void collidedWith(CThing *_thisThing);
u8 m_isMaster;
CNpcDualPlatform *m_otherPlatform;

View File

@ -29,6 +29,10 @@
#include "player\player.h"
#endif
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#endif
#ifndef __HAZARD_HAZARD_H__
#include "hazard\hazard.h"
#endif
@ -966,19 +970,55 @@ void CNpcPlatform::collidedWith( CThing *_thisThing )
break;
}
case TYPE_HAZARD:
case TYPE_NPC:
{
m_contact = true;
CNpcFriend *friendNpc;
DVECTOR friendPos;
CRECT collisionArea;
CNpcHazard *hazard;
friendNpc = (CNpcFriend*) _thisThing;
friendPos = friendNpc->getPos();
collisionArea=getCollisionArea();
hazard = (CNpcHazard *)_thisThing;
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
hazard->setPlatform( this );
if ( threshold > 16 )
{
threshold = 16;
}
if( friendPos.vx >= collisionArea.x1 && friendPos.vx <= collisionArea.x2 )
{
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
{
int height = getHeightFromPlatformAtPosition( friendPos.vx, friendPos.vy );
friendNpc->setPlatform( this );
m_contact = true;
}
else
{
if( friendPos.vy >= collisionArea.y1 && friendPos.vy <= collisionArea.y2 )
{
int height = getHeightFromPlatformAtPosition( friendPos.vx, friendPos.vy );
if ( height >= -threshold && height < 1 )
{
friendNpc->setPlatform( this );
m_contact = true;
}
}
}
}
break;
}
case TYPE_HAZARD:
break;
default:
ASSERT(0);
break;

View File

@ -40,6 +40,10 @@
#include "friend\friend.h"
#include "fx\fx.h"
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#endif
#ifndef __HAZARD_HRWEIGHT_H__
#include "hazard\hrweight.h"
#endif
@ -537,6 +541,32 @@ DVECTOR const &CamPos=CLevel::getCameraPos();
}
thing1=thing1->m_nextCollisionThing;
}
// Friendly npc -> Platform projectile collision - first clear platforms
CNpcFriend *friendNpc = (CNpcFriend *) s_CollisionLists[CThing::TYPE_NPC];
while( friendNpc )
{
friendNpc->clearPlatform();
friendNpc = (CNpcFriend *) friendNpc->m_nextCollisionThing;
}
// now detect new platform
thing1=s_CollisionLists[CThing::TYPE_PLATFORM];
while(thing1)
{
thing2=s_CollisionLists[CThing::TYPE_NPC];
while(thing2)
{
if(thing1->checkCollisionAgainst(thing2, _frames))
{
thing1->collidedWith(thing2);
}
thing2=thing2->m_nextCollisionThing;
}
thing1=thing1->m_nextCollisionThing;
}
}
// Shut emm down, sh sh shut em down, we shutem down
for(i=0;i<CThing::MAX_TYPE;i++)
@ -1327,4 +1357,3 @@ void CTriggerThing::setTargetBox(int _x,int _y,int _w,int _h)
}