SBSPSS/source/enemy/nworm.cpp

611 lines
16 KiB
C++
Raw Normal View History

2001-03-26 16:28:02 +02:00
/*=========================================================================
nworm.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __ENEMY_NPC_H__
#include "enemy\npc.h"
#endif
2001-04-20 22:22:16 +02:00
#ifndef __ENEMY_NWORM_H__
#include "enemy\nworm.h"
#endif
2001-04-11 18:39:31 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-03-26 16:28:02 +02:00
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2001-05-04 15:45:55 +02:00
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
2001-04-20 22:22:16 +02:00
2001-05-16 18:02:10 +02:00
#ifdef SHOW_BBOX
#include "gfx\prim.h"
#endif
2001-05-24 16:07:13 +02:00
#ifndef __ANIM_GIANTWORM_HEADER__
#include <ACTOR_GIANTWORM_ANIM.h>
2001-05-16 18:15:38 +02:00
#endif
2001-05-16 18:02:10 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcParasiticWormSegment::init()
{
2001-05-24 16:07:13 +02:00
m_actorGfx=CActorPool::GetActor( (FileEquate) ACTORS_GIANTWORM_SBK );
2001-05-16 18:02:10 +02:00
m_heading = 0;
m_nextSegment = NULL;
setCollisionSize( 20, 20 );
setCollisionCentreOffset( 10, 10 );
updateCollisionArea();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcParasiticWormSegment::updateCollisionArea()
{
m_collisionCentre.vx=Pos.vx+m_collisionCentreOffset.vx;
m_collisionCentre.vy=Pos.vy+m_collisionCentreOffset.vy;
m_collisionArea.x1=m_collisionCentre.vx-(m_collisionSize.vx/2);
m_collisionArea.x2=m_collisionArea.x1+m_collisionSize.vx;
m_collisionArea.y1=m_collisionCentre.vy-(m_collisionSize.vy/2);
m_collisionArea.y2=m_collisionArea.y1+m_collisionSize.vy;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcParasiticWormSegment::setCollisionSize(int _w,int _h)
{
m_collisionSize.vx=_w;
m_collisionSize.vy=_h;
if(m_collisionSize.vx>m_collisionSize.vy)
{
m_collisionRadius=m_collisionSize.vx;
}
else
{
m_collisionRadius=m_collisionSize.vy;
}
}
2001-05-04 15:45:55 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-20 22:22:16 +02:00
2001-05-04 15:45:55 +02:00
void CNpcParasiticWormEnemy::postInit()
{
m_npcPath.setPathType( CNpcPath::REPEATING_PATH );
2001-04-20 22:22:16 +02:00
2001-06-14 18:07:48 +02:00
s16 maxArraySize = NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING;
2001-04-20 22:22:16 +02:00
2001-06-14 18:07:48 +02:00
m_positionHistoryArray[0].pos = Pos;
m_positionHistoryArray[0].next = &m_positionHistoryArray[1];
m_positionHistoryArray[0].prev = &m_positionHistoryArray[maxArraySize - 1];
2001-04-20 22:22:16 +02:00
2001-06-14 18:07:48 +02:00
for ( int histLength = 1 ; histLength < maxArraySize - 1 ; histLength++ )
2001-04-20 22:22:16 +02:00
{
2001-06-14 18:07:48 +02:00
m_positionHistoryArray[histLength].pos = Pos;
m_positionHistoryArray[histLength].next = &m_positionHistoryArray[histLength + 1];
m_positionHistoryArray[histLength].prev = &m_positionHistoryArray[histLength - 1];
2001-04-20 22:22:16 +02:00
}
2001-06-14 18:07:48 +02:00
m_positionHistoryArray[maxArraySize - 1].pos = Pos;
m_positionHistoryArray[maxArraySize - 1].next = &m_positionHistoryArray[0];
m_positionHistoryArray[maxArraySize - 1].prev = &m_positionHistoryArray[maxArraySize - 2];
2001-04-20 22:22:16 +02:00
2001-06-14 18:07:48 +02:00
m_positionHistory = &m_positionHistoryArray[0];
2001-04-20 22:22:16 +02:00
2001-05-04 15:45:55 +02:00
u16 segScale;
int initLength = NPC_PARASITIC_WORM_LENGTH / 3;
int remLength = NPC_PARASITIC_WORM_LENGTH - initLength;
2001-04-20 22:22:16 +02:00
for ( int segCount = 0 ; segCount < NPC_PARASITIC_WORM_LENGTH ; segCount++ )
{
2001-06-14 18:07:48 +02:00
m_segmentArray[segCount].init();
2001-05-04 15:45:55 +02:00
if ( segCount < initLength )
{
2001-05-25 00:11:16 +02:00
/*u16 sum = ONE;
2001-05-04 15:45:55 +02:00
u16 start = ONE >> 1;
u16 end = sum - start;
2001-05-25 00:11:16 +02:00
segScale = start + ( ( end * segCount ) / initLength );*/
segScale = ONE;
2001-05-04 15:45:55 +02:00
}
else
{
u16 sum = ONE;
u16 start = ONE >> 3;
u16 end = sum - start;
segScale = start + ( ( end * ( NPC_PARASITIC_WORM_LENGTH - segCount ) ) / remLength );
}
2001-06-14 18:07:48 +02:00
m_segmentArray[segCount].setScale( segScale );
2001-05-16 18:02:10 +02:00
2001-06-21 00:02:19 +02:00
if ( segCount == NPC_PARASITIC_WORM_LENGTH - 1 )
{
m_segmentArray[segCount].setAnim( ANIM_GIANTWORM_TAIL );
}
else
{
m_segmentArray[segCount].setAnim( ANIM_GIANTWORM_BODYSTATIC );
}
2001-06-14 18:07:48 +02:00
// attach snake segment
2001-05-16 18:02:10 +02:00
2001-06-14 18:07:48 +02:00
if ( segCount < NPC_PARASITIC_WORM_LENGTH - 1 )
2001-05-16 18:02:10 +02:00
{
2001-06-14 18:07:48 +02:00
m_segmentArray[segCount].m_nextSegment = &m_segmentArray[segCount + 1];
2001-05-16 18:02:10 +02:00
}
2001-04-20 22:22:16 +02:00
}
m_movementTimer = 2 * GameState::getOneSecondInFrames();
2001-05-16 20:07:38 +02:00
m_collTimer = 0;
2001-04-20 22:22:16 +02:00
}
2001-05-04 15:45:55 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-05-16 22:16:58 +02:00
void CNpcParasiticWormSegment::shutdown()
{
delete m_actorGfx;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-26 23:29:44 +02:00
void CNpcParasiticWormEnemy::shutdown()
{
2001-05-16 18:02:10 +02:00
// delete worm segments
2001-04-26 23:29:44 +02:00
2001-06-14 18:07:48 +02:00
for ( int segCount = 0 ; segCount < NPC_PARASITIC_WORM_LENGTH ; segCount++ )
2001-05-16 18:02:10 +02:00
{
2001-06-14 18:07:48 +02:00
m_segmentArray[segCount].shutdown();
2001-05-16 18:02:10 +02:00
}
2001-05-04 15:45:55 +02:00
2001-05-16 18:02:10 +02:00
CNpcEnemy::shutdown();
2001-04-20 22:22:16 +02:00
}
2001-05-04 15:45:55 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-20 22:22:16 +02:00
bool CNpcParasiticWormEnemy::processSensor()
{
2001-05-04 15:45:55 +02:00
/*if ( playerXDistSqr + playerYDistSqr < 40000 )
2001-04-20 22:22:16 +02:00
{
m_controlFunc = NPC_CONTROL_CLOSE;
return( true );
}
else
{
return( false );
2001-05-04 15:45:55 +02:00
}*/
return( false );
2001-04-20 22:22:16 +02:00
}
2001-05-04 15:45:55 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-20 22:22:16 +02:00
void CNpcParasiticWormEnemy::processMovement( int _frames )
2001-03-26 16:28:02 +02:00
{
s32 moveX = 0, moveY = 0;
s32 moveVel = 0;
s32 moveDist = 0;
2001-03-26 18:44:45 +02:00
DVECTOR oldPos = Pos;
u8 skipCounter;
2001-03-26 16:28:02 +02:00
processGenericFixedPathMove( _frames, &moveX, &moveY, &moveVel, &moveDist );
Pos.vx += moveX;
Pos.vy += moveY;
2001-03-26 18:44:45 +02:00
m_extension += 256;
m_extension &= 4095;
2001-04-11 16:52:28 +02:00
m_positionHistory = m_positionHistory->prev;
m_positionHistory->pos = oldPos;
CNpcPositionHistory *newPos;
newPos = m_positionHistory;
for ( skipCounter = 1 ; skipCounter < NPC_PARASITIC_WORM_SPACING ; skipCounter++ )
{
newPos = newPos->next;
}
oldPos = Pos;
s32 extension = m_extension;
u8 downShift = 2;
2001-04-11 18:39:31 +02:00
u8 timeShift;
if ( m_movementTimer > 0 )
{
m_movementTimer -= _frames;
if ( m_movementTimer < 0 )
{
m_movementTimer = 0;
}
}
timeShift = m_movementTimer / GameState::getOneSecondInFrames();
2001-04-11 16:52:28 +02:00
2001-06-14 18:07:48 +02:00
int segmentCount;
for ( segmentCount = 0 ; segmentCount < NPC_PARASITIC_WORM_LENGTH ; segmentCount++ )
2001-04-11 16:52:28 +02:00
{
s32 xDist = oldPos.vx - newPos->pos.vx;
s32 yDist = oldPos.vy - newPos->pos.vy;
2001-07-27 15:31:52 +02:00
s16 headingToTarget = ratan2( yDist, xDist ) & 4095;
2001-04-11 16:52:28 +02:00
DVECTOR sinPos;
sinPos = newPos->pos;
2001-05-25 00:11:16 +02:00
s32 diff = ( ( ( 2 >> downShift ) * rsin( extension ) ) >> 12 ) >> timeShift;
2001-04-11 16:52:28 +02:00
sinPos.vx += ( diff * rcos( headingToTarget + 1024 ) ) >> 12;
sinPos.vy += ( diff * rsin( headingToTarget + 1024 ) ) >> 12;
2001-06-14 18:07:48 +02:00
m_segmentArray[segmentCount].setPos( sinPos );
2001-05-04 15:45:55 +02:00
oldPos = sinPos;
2001-04-11 16:52:28 +02:00
2001-06-14 18:07:48 +02:00
for ( skipCounter = 0 ; skipCounter < NPC_PARASITIC_WORM_SPACING ; skipCounter++ )
2001-04-11 16:52:28 +02:00
{
2001-06-14 18:07:48 +02:00
newPos = newPos->next;
2001-04-11 16:52:28 +02:00
}
2001-05-25 00:11:16 +02:00
extension += 256;
2001-04-11 16:52:28 +02:00
extension &= 4095;
if ( downShift > 0 )
{
downShift--;
}
}
2001-05-04 15:45:55 +02:00
oldPos = Pos;
2001-06-14 18:07:48 +02:00
for ( segmentCount = 0 ; segmentCount < NPC_PARASITIC_WORM_LENGTH ; segmentCount++ )
2001-05-04 15:45:55 +02:00
{
2001-07-23 21:26:37 +02:00
DVECTOR const &currentPos = m_segmentArray[segmentCount].getPos();
2001-05-04 15:45:55 +02:00
s32 xDist = oldPos.vx - currentPos.vx;
s32 yDist = oldPos.vy - currentPos.vy;
2001-07-27 15:31:52 +02:00
s16 headingToPrev = ratan2( yDist, xDist ) & 4095;
2001-05-04 15:45:55 +02:00
s16 headingFromNext;
s16 heading = headingToPrev;
oldPos = currentPos;
2001-06-14 18:07:48 +02:00
if ( segmentCount < NPC_PARASITIC_WORM_LENGTH - 1 )
2001-05-04 15:45:55 +02:00
{
2001-07-23 21:26:37 +02:00
DVECTOR const &nextPos = m_segmentArray[segmentCount + 1].getPos();
2001-05-04 15:45:55 +02:00
xDist = currentPos.vx - nextPos.vx;
yDist = currentPos.vy - nextPos.vy;
2001-07-27 15:31:52 +02:00
headingFromNext = ratan2( yDist, xDist ) & 4095;
2001-05-04 15:45:55 +02:00
s16 decDir, incDir, moveDist;
decDir = headingFromNext - headingToPrev;
if ( decDir < 0 )
{
decDir += ONE;
}
incDir = headingToPrev - headingFromNext;
if ( incDir < 0 )
{
incDir += ONE;
}
if ( decDir < incDir )
{
moveDist = -decDir;
}
else
{
moveDist = incDir;
}
heading -= moveDist >> 1;
}
2001-06-14 18:07:48 +02:00
m_segmentArray[segmentCount].setHeading( heading );
m_segmentArray[segmentCount].updateCollisionArea();
2001-05-04 15:45:55 +02:00
}
2001-05-16 20:07:38 +02:00
if ( m_collTimer > 0 )
{
m_collTimer -= _frames;
}
2001-04-11 18:39:31 +02:00
}
2001-04-11 16:52:28 +02:00
2001-05-04 15:45:55 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-05-16 18:02:10 +02:00
/*void CNpcParasiticWormEnemy::resetParasiticWormHeadToTail()
2001-04-11 18:39:31 +02:00
{
DVECTOR startPos;
DVECTOR endPos;
int posCounter;
CNpcPositionHistory *currentPos;
2001-03-26 18:44:45 +02:00
2001-04-11 18:39:31 +02:00
startPos = Pos;
2001-03-26 18:44:45 +02:00
2001-04-11 18:39:31 +02:00
currentPos = m_positionHistory;
for ( posCounter = 0 ; posCounter < ( NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ) - 1 ; posCounter++ )
2001-03-26 18:44:45 +02:00
{
2001-04-11 18:39:31 +02:00
currentPos = currentPos->next;
2001-03-26 18:44:45 +02:00
}
2001-04-11 18:39:31 +02:00
endPos = currentPos->pos;
currentPos = m_positionHistory;
for ( posCounter = 0 ; posCounter < NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ; posCounter++ )
{
currentPos->pos.vx = startPos.vx + ( posCounter * ( endPos.vx - startPos.vx ) ) / ( ( NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ) - 1 );
currentPos->pos.vy = startPos.vy + ( posCounter * ( endPos.vy - startPos.vy ) ) / ( ( NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ) - 1 );
currentPos = currentPos->next;
}
2001-03-26 18:44:45 +02:00
2001-04-11 18:39:31 +02:00
CNpcPositionHistory *newPos;
2001-03-26 18:44:45 +02:00
newPos = m_positionHistory;
2001-04-11 18:39:31 +02:00
u8 skipCounter;
2001-03-26 18:44:45 +02:00
for ( skipCounter = 1 ; skipCounter < NPC_PARASITIC_WORM_SPACING ; skipCounter++ )
{
newPos = newPos->next;
}
CThing *List=Next;
2001-04-11 18:39:31 +02:00
DVECTOR oldPos = Pos;
2001-03-26 18:44:45 +02:00
s32 extension = m_extension;
while( List )
{
CNpcEnemy *segment = (CNpcEnemy *) List;
s32 xDist = oldPos.vx - newPos->pos.vx;
s32 yDist = oldPos.vy - newPos->pos.vy;
s16 headingToTarget = ratan2( yDist, xDist );
segment->setHeading( headingToTarget );
2001-04-11 18:39:31 +02:00
List->setPos( newPos->pos );
2001-03-26 18:44:45 +02:00
oldPos = newPos->pos;
List = List->getNext();
if ( List )
{
for ( skipCounter = 0 ; skipCounter < NPC_PARASITIC_WORM_SPACING ; skipCounter++ )
{
newPos = newPos->next;
}
}
extension += 1024;
extension &= 4095;
2001-04-11 18:39:31 +02:00
}
2001-05-16 18:02:10 +02:00
}*/
2001-04-11 18:39:31 +02:00
2001-05-04 15:45:55 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-20 22:22:16 +02:00
void CNpcParasiticWormEnemy::processClose( int _frames )
2001-04-11 18:39:31 +02:00
{
2001-05-16 18:02:10 +02:00
//resetParasiticWormHeadToTail();
2001-04-11 18:39:31 +02:00
m_movementTimer = 2 * GameState::getOneSecondInFrames();
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE;
m_timerTimer = GameState::getOneSecondInFrames();
m_sensorFunc = NPC_SENSOR_NONE;
}
2001-03-26 18:44:45 +02:00
2001-05-04 15:45:55 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcParasiticWormEnemy::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcParasiticWormSegment::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcParasiticWormEnemy::render()
{
SprFrame = NULL;
if ( m_isActive )
{
CEnemyThing::render();
2001-05-14 23:08:03 +02:00
if (canRender())
2001-05-04 15:45:55 +02:00
{
2001-05-14 23:08:03 +02:00
DVECTOR &renderPos=getRenderPos();
2001-05-04 15:45:55 +02:00
2001-05-25 00:11:16 +02:00
SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),0);
2001-05-14 23:08:03 +02:00
m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, 4096 );
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 );
2001-05-04 15:45:55 +02:00
}
2001-05-16 18:02:10 +02:00
2001-06-14 18:07:48 +02:00
for ( int segmentCount = 0 ; segmentCount < NPC_PARASITIC_WORM_LENGTH ; segmentCount++ )
2001-05-16 18:02:10 +02:00
{
2001-06-14 18:07:48 +02:00
m_segmentArray[segmentCount].render();
2001-05-16 18:02:10 +02:00
}
2001-05-04 15:45:55 +02:00
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-05-16 18:15:38 +02:00
int CNpcParasiticWormEnemy::checkCollisionAgainst( CThing *_thisThing, int _frames )
{
2001-07-23 21:26:37 +02:00
// DVECTOR pos,thisThingPos;
2001-05-16 18:15:38 +02:00
int radius;
int collided;
2001-07-23 21:26:37 +02:00
DVECTOR const &pos=getCollisionCentre();
DVECTOR const &thisThingPos=_thisThing->getCollisionCentre();
2001-05-16 18:15:38 +02:00
radius=getCollisionRadius()+_thisThing->getCollisionRadius();
collided=false;
if(abs(pos.vx-thisThingPos.vx)<radius&&
abs(pos.vy-thisThingPos.vy)<radius)
{
2001-07-23 21:26:37 +02:00
// CRECT thisRect,thatRect;
2001-05-16 18:15:38 +02:00
2001-07-23 21:26:37 +02:00
CRECT const &thisRect=getCollisionArea();
CRECT const &thatRect=_thisThing->getCollisionArea();
2001-05-16 18:15:38 +02:00
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
2001-06-14 18:07:48 +02:00
for ( int segmentCount = 0 ; segmentCount < NPC_PARASITIC_WORM_LENGTH ; segmentCount++ )
2001-05-16 18:15:38 +02:00
{
2001-06-14 18:07:48 +02:00
if ( m_segmentArray[segmentCount].checkCollisionAgainst( _thisThing, _frames ) )
2001-05-16 18:15:38 +02:00
{
collided = true;
}
}
return collided;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-05-04 15:45:55 +02:00
void CNpcParasiticWormSegment::render()
{
2001-05-16 18:02:10 +02:00
POLY_FT4 *SprFrame = NULL;
2001-05-04 15:45:55 +02:00
2001-05-16 18:02:10 +02:00
sBBox &ScrBBox=CThingManager::getRenderBBox();
DVECTOR const &CamPos=CLevel::getCameraPos();
DVECTOR renderPos;
renderPos.vx = Pos.vx - CamPos.vx;
renderPos.vy = Pos.vy - CamPos.vy;
u8 renderFlag = true;
if ( m_collisionArea.x2 < ScrBBox.XMin || m_collisionArea.x1 > ScrBBox.XMax ) renderFlag=false;
if ( m_collisionArea.y2 < ScrBBox.YMin || m_collisionArea.y1 > ScrBBox.YMax ) renderFlag=false;
if ( renderFlag )
2001-05-04 15:45:55 +02:00
{
2001-06-21 00:02:19 +02:00
SprFrame = m_actorGfx->Render(renderPos,m_animNo,0,0);
2001-05-16 18:02:10 +02:00
m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, m_scale );
2001-05-04 15:45:55 +02:00
2001-05-16 18:02:10 +02:00
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 );
2001-05-04 15:45:55 +02:00
2001-05-16 18:02:10 +02:00
#if defined (__USER_charles__)
DVECTOR const &ofs=CLevel::getCameraPos();
CRECT area;
2001-05-14 23:08:03 +02:00
2001-05-16 18:02:10 +02:00
area=getCollisionArea();
area.x1-=ofs.vx;
area.y1-=ofs.vy;
area.x2-=ofs.vx;
area.y2-=ofs.vy;
if(area.x1<=511&&area.x2>=0 && area.y1<=255&&area.y2>=0)
{
DrawLine(area.x1,area.y1,area.x2,area.y1,255,255,255,0);
DrawLine(area.x2,area.y1,area.x2,area.y2,255,255,255,0);
DrawLine(area.x2,area.y2,area.x1,area.y2,255,255,255,0);
DrawLine(area.x1,area.y2,area.x1,area.y1,255,255,255,0);
area.x1=Pos.vx-10-ofs.vx;
area.y1=Pos.vy-10-ofs.vy;
area.x2=Pos.vx+10-ofs.vx;
area.y2=Pos.vy+10-ofs.vy;
DrawLine(area.x1,area.y1,area.x2,area.y2,255,0,0,0);
DrawLine(area.x2,area.y1,area.x1,area.y2,255,0,0,0);
2001-05-04 15:45:55 +02:00
}
2001-05-16 18:02:10 +02:00
#endif
2001-05-04 15:45:55 +02:00
}
}
2001-05-16 18:15:38 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CNpcParasiticWormSegment::checkCollisionAgainst( CThing *_thisThing, int _frames )
{
2001-07-23 21:26:37 +02:00
// DVECTOR pos,thisThingPos;
2001-05-16 18:15:38 +02:00
int radius;
int collided;
2001-07-23 21:26:37 +02:00
DVECTOR const &pos = getCollisionCentre();
DVECTOR const &thisThingPos = _thisThing->getCollisionCentre();
2001-05-16 18:15:38 +02:00
radius = getCollisionRadius() + _thisThing->getCollisionRadius();
collided = false;
if(abs(pos.vx-thisThingPos.vx)<radius&&
abs(pos.vy-thisThingPos.vy)<radius)
{
2001-07-23 21:26:37 +02:00
// CRECT thisRect,thatRect;
2001-05-16 18:15:38 +02:00
2001-07-23 21:26:37 +02:00
CRECT const &thisRect=getCollisionArea();
CRECT const &thatRect=_thisThing->getCollisionArea();
2001-05-16 18:15:38 +02:00
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;
2001-05-16 20:07:38 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-06-28 22:29:14 +02:00
void CNpcParasiticWormEnemy::processShotDeathEnd( int _frames )
2001-05-16 20:07:38 +02:00
{
2001-06-28 22:29:14 +02:00
CNpcEnemy::processShotDeathEnd( _frames );
2001-05-16 20:07:38 +02:00
2001-06-28 22:29:14 +02:00
// go through segments
2001-05-16 20:07:38 +02:00
2001-06-28 22:29:14 +02:00
for ( int segCount = 0 ; segCount < NPC_PARASITIC_WORM_LENGTH ; segCount++ )
{
DVECTOR segPos = m_segmentArray[segCount].getPos();
segPos.vy += m_speed * _frames;
m_segmentArray[segCount].setPos( segPos );
m_segmentArray[segCount].updateCollisionArea();
2001-05-16 20:07:38 +02:00
}
}
2001-06-28 22:29:14 +02:00