This commit is contained in:
parent
f124531cc2
commit
a30342b6b3
@ -859,7 +859,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
||||
false,
|
||||
3,
|
||||
128,
|
||||
DETECT_NO_COLLISION,
|
||||
DETECT_ALL_COLLISION,
|
||||
DAMAGE__HIT_ENEMY,
|
||||
256,
|
||||
0,
|
||||
@ -928,7 +928,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
||||
false,
|
||||
3,
|
||||
2048,
|
||||
DETECT_NO_COLLISION,
|
||||
DETECT_ALL_COLLISION,
|
||||
DAMAGE__HIT_ENEMY,
|
||||
256,
|
||||
0,
|
||||
|
@ -35,6 +35,10 @@
|
||||
#include "gfx\prim.h"
|
||||
#endif
|
||||
|
||||
#ifndef __ANIM_SEASNAKE_HEADER__
|
||||
#include <ACTOR_SEASNAKE_ANIM.h>
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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()
|
||||
{
|
||||
POLY_FT4 *SprFrame = NULL;
|
||||
@ -512,7 +562,7 @@ void CNpcParasiticWormSegment::render()
|
||||
|
||||
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 );
|
||||
|
||||
sBBox boundingBox = m_actorGfx->GetBBox();
|
||||
@ -546,3 +596,35 @@ void CNpcParasiticWormSegment::render()
|
||||
#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;
|
||||
}
|
@ -26,12 +26,14 @@ public:
|
||||
virtual DVECTOR getPos() {return( Pos );}
|
||||
virtual void setHeading( s16 newHeading ) {m_heading = newHeading;}
|
||||
void updateCollisionArea();
|
||||
|
||||
protected:
|
||||
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
|
||||
virtual void setCollisionSize(int _w,int _h);
|
||||
virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
|
||||
virtual CRECT const &getCollisionArea() {return m_collisionArea;}
|
||||
DVECTOR const &getCollisionCentre() {return m_collisionCentre;}
|
||||
int getCollisionRadius() {return m_collisionRadius;}
|
||||
|
||||
protected:
|
||||
u16 m_scale;
|
||||
CActorGfx *m_actorGfx;
|
||||
DVECTOR Pos;
|
||||
@ -49,6 +51,7 @@ public:
|
||||
virtual void postInit();
|
||||
virtual void shutdown();
|
||||
virtual void render();
|
||||
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
|
||||
protected:
|
||||
virtual bool processSensor();
|
||||
virtual void processClose( int _frames );
|
||||
|
Loading…
Reference in New Issue
Block a user