This commit is contained in:
Charles 2001-05-16 16:15:38 +00:00
parent f124531cc2
commit a30342b6b3
3 changed files with 90 additions and 5 deletions

View File

@ -859,7 +859,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
128, 128,
DETECT_NO_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
256, 256,
0, 0,
@ -928,7 +928,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
2048, 2048,
DETECT_NO_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
256, 256,
0, 0,

View File

@ -35,6 +35,10 @@
#include "gfx\prim.h" #include "gfx\prim.h"
#endif #endif
#ifndef __ANIM_SEASNAKE_HEADER__
#include <ACTOR_SEASNAKE_ANIM.h>
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcParasiticWormSegment::init() void CNpcParasiticWormSegment::init()
@ -495,6 +499,52 @@ void CNpcParasiticWormEnemy::render()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CNpcParasiticWormEnemy::checkCollisionAgainst( CThing *_thisThing, int _frames )
{
DVECTOR pos,thisThingPos;
int radius;
int collided;
pos=getCollisionCentre();
thisThingPos=_thisThing->getCollisionCentre();
radius=getCollisionRadius()+_thisThing->getCollisionRadius();
collided=false;
if(abs(pos.vx-thisThingPos.vx)<radius&&
abs(pos.vy-thisThingPos.vy)<radius)
{
CRECT thisRect,thatRect;
thisRect=getCollisionArea();
thatRect=_thisThing->getCollisionArea();
if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&&
((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2)))
{
collided=true;
}
}
// go through segments
CNpcParasiticWormSegment *segment = m_segment;
while( segment )
{
if ( segment->checkCollisionAgainst( _thisThing, _frames ) )
{
collided = true;
}
segment = segment->m_nextSegment;
}
return collided;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcParasiticWormSegment::render() void CNpcParasiticWormSegment::render()
{ {
POLY_FT4 *SprFrame = NULL; POLY_FT4 *SprFrame = NULL;
@ -512,7 +562,7 @@ void CNpcParasiticWormSegment::render()
if ( renderFlag ) if ( renderFlag )
{ {
SprFrame = m_actorGfx->Render(renderPos,0,0,0); SprFrame = m_actorGfx->Render(renderPos,ANIM_SEASNAKE_BODYSTATIC,0,0);
m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, m_scale ); m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, m_scale );
sBBox boundingBox = m_actorGfx->GetBBox(); sBBox boundingBox = m_actorGfx->GetBBox();
@ -546,3 +596,35 @@ void CNpcParasiticWormSegment::render()
#endif #endif
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CNpcParasiticWormSegment::checkCollisionAgainst( CThing *_thisThing, int _frames )
{
DVECTOR pos,thisThingPos;
int radius;
int collided;
pos = getCollisionCentre();
thisThingPos = _thisThing->getCollisionCentre();
radius = getCollisionRadius() + _thisThing->getCollisionRadius();
collided = false;
if(abs(pos.vx-thisThingPos.vx)<radius&&
abs(pos.vy-thisThingPos.vy)<radius)
{
CRECT thisRect,thatRect;
thisRect=getCollisionArea();
thatRect=_thisThing->getCollisionArea();
if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&&
((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2)))
{
collided=true;
}
}
return collided;
}

View File

@ -26,12 +26,14 @@ public:
virtual DVECTOR getPos() {return( Pos );} virtual DVECTOR getPos() {return( Pos );}
virtual void setHeading( s16 newHeading ) {m_heading = newHeading;} virtual void setHeading( s16 newHeading ) {m_heading = newHeading;}
void updateCollisionArea(); void updateCollisionArea();
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
protected:
virtual void setCollisionSize(int _w,int _h); virtual void setCollisionSize(int _w,int _h);
virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;} virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
virtual CRECT const &getCollisionArea() {return m_collisionArea;} virtual CRECT const &getCollisionArea() {return m_collisionArea;}
DVECTOR const &getCollisionCentre() {return m_collisionCentre;}
int getCollisionRadius() {return m_collisionRadius;}
protected:
u16 m_scale; u16 m_scale;
CActorGfx *m_actorGfx; CActorGfx *m_actorGfx;
DVECTOR Pos; DVECTOR Pos;
@ -49,6 +51,7 @@ public:
virtual void postInit(); virtual void postInit();
virtual void shutdown(); virtual void shutdown();
virtual void render(); virtual void render();
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
protected: protected:
virtual bool processSensor(); virtual bool processSensor();
virtual void processClose( int _frames ); virtual void processClose( int _frames );