This commit is contained in:
Charles 2001-05-29 22:07:28 +00:00
parent 9f667e7bbc
commit c7e46d02ef
24 changed files with 328 additions and 469 deletions

View File

@ -267,26 +267,19 @@ void CNpcAnemone2Enemy::processShot( int _frames )
{ {
case NPC_GENERIC_HIT_CHECK_HEALTH: case NPC_GENERIC_HIT_CHECK_HEALTH:
{ {
if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) m_health -= 5;
if ( m_health < 0 )
{ {
m_state = NPC_GENERIC_HIT_DEATH_START; m_state = NPC_GENERIC_HIT_DEATH_START;
} }
else else
{ {
m_health -= 5; m_state = NPC_GENERIC_HIT_RECOIL;
if ( m_health < 0 ) m_animPlaying = true;
{ m_animNo = m_data[m_type].recoilAnim;
m_state = NPC_GENERIC_HIT_DEATH_START; m_frame = 0;
}
else
{
m_state = NPC_GENERIC_HIT_RECOIL;
m_animPlaying = true;
m_animNo = m_data[m_type].recoilAnim;
m_frame = 0;
}
} }
break; break;

View File

@ -105,40 +105,34 @@ void CNpcJumpingClamEnemy::setupWaypoints( sThingActor *ThisActor )
u16 newXPos, newYPos; u16 newXPos, newYPos;
u16 startXPos, startYPos, endXPos, endYPos; u16 startXPos, startYPos, endXPos, endYPos;
m_npcPath.setWaypointCount( ThisActor->PointCount - 1 );
startXPos = newXPos = (u16) *PntList; startXPos = newXPos = (u16) *PntList;
setWaypointPtr( PntList );
PntList++; PntList++;
startYPos = newYPos = (u16) *PntList; startYPos = newYPos = (u16) *PntList;
PntList++; PntList++;
setStartPos( newXPos, newYPos ); setStartPos( newXPos, newYPos );
addWaypoint( newXPos, newYPos );
m_maxExtension = 10; m_maxExtension = 10;
if ( ThisActor->PointCount > 1 ) if ( ThisActor->PointCount > 1 )
{ {
for (int pointNum = 1 ; pointNum < ThisActor->PointCount ; pointNum++ ) newXPos = (u16) *PntList;
{ PntList++;
newXPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
newYPos = (u16) *PntList;
PntList++;
addWaypoint( newXPos, newYPos ); endXPos = newXPos;
endYPos = newYPos;
if ( pointNum == 1 ) setHeading( newXPos, newYPos );
{
endXPos = newXPos;
endYPos = newYPos;
setHeading( newXPos, newYPos ); s32 xDist = ( endXPos - startXPos ) << 4;
s32 yDist = ( endYPos - startYPos ) << 4;
s32 xDist = ( endXPos - startXPos ) << 4; m_maxExtension = isqrt2( ( xDist * xDist ) + ( yDist * yDist ) );
s32 yDist = ( endYPos - startYPos ) << 4;
m_maxExtension = isqrt2( ( xDist * xDist ) + ( yDist * yDist ) );
}
}
} }
} }

View File

@ -236,23 +236,16 @@ void CNpcEyeballEnemy::processShot( int _frames )
{ {
case NPC_GENERIC_HIT_CHECK_HEALTH: case NPC_GENERIC_HIT_CHECK_HEALTH:
{ {
if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) m_health -= 5;
if ( m_health < 0 )
{ {
m_state = NPC_GENERIC_HIT_DEATH_START; m_state = NPC_GENERIC_HIT_DEATH_START;
} }
else else
{ {
m_health -= 5; m_state = 0;
m_controlFunc = NPC_CONTROL_MOVEMENT;
if ( m_health < 0 )
{
m_state = NPC_GENERIC_HIT_DEATH_START;
}
else
{
m_state = 0;
m_controlFunc = NPC_CONTROL_MOVEMENT;
}
} }
break; break;

View File

@ -37,12 +37,12 @@ void CNpcFishFolk::postInit()
newPos.vx = 200; newPos.vx = 200;
newPos.vy = 400; newPos.vy = 400;
m_npcPath.addWaypoint( newPos ); //m_npcPath.addWaypoint( newPos );
newPos.vx = 500; newPos.vx = 500;
newPos.vy = 400; newPos.vy = 400;
m_npcPath.addWaypoint( newPos ); //m_npcPath.addWaypoint( newPos );
m_npcPath.setPathType( CNpcPath::PONG_PATH ); m_npcPath.setPathType( CNpcPath::PONG_PATH );
} }

View File

@ -54,20 +54,14 @@ void CNpcEnemyGenerator::think(int _frames)
enemy->init(); enemy->init();
enemy->setStartPos( Pos.vx >> 4, Pos.vy >> 4 ); enemy->setStartPos( Pos.vx >> 4, Pos.vy >> 4 );
CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); u16 *waypointPtr = m_npcPath.getWaypointPtr();
if ( sourceWaypoint ) // skip first waypoint
{ waypointPtr++;
// skip first waypoint waypointPtr++;
sourceWaypoint = sourceWaypoint->nextWaypoint; enemy->setWaypointCount( m_npcPath.getWaypointCount() - 1 );
enemy->setWaypointPtr( waypointPtr );
while( sourceWaypoint )
{
enemy->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 );
sourceWaypoint = sourceWaypoint->nextWaypoint;
}
}
enemy->setPathType( m_npcPath.getPathType() ); enemy->setPathType( m_npcPath.getPathType() );

View File

@ -283,30 +283,23 @@ void CNpcHermitCrabEnemy::processShot( int _frames )
{ {
case NPC_GENERIC_HIT_CHECK_HEALTH: case NPC_GENERIC_HIT_CHECK_HEALTH:
{ {
if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) m_health -= 5;
if ( m_health < 0 )
{ {
m_state = NPC_GENERIC_HIT_DEATH_START; m_state = NPC_GENERIC_HIT_DEATH_START;
m_animPlaying = true;
m_animNo = m_data[m_type].dieAnim;
m_frame = 0;
} }
else else
{ {
m_health -= 5; m_state = NPC_GENERIC_HIT_RECOIL;
if ( m_health < 0 ) m_animPlaying = true;
{ m_animNo = m_data[m_type].recoilAnim;
m_state = NPC_GENERIC_HIT_DEATH_START; m_frame = 0;
m_animPlaying = true;
m_animNo = m_data[m_type].dieAnim;
m_frame = 0;
}
else
{
m_state = NPC_GENERIC_HIT_RECOIL;
m_animPlaying = true;
m_animNo = m_data[m_type].recoilAnim;
m_frame = 0;
}
} }
break; break;

View File

@ -70,13 +70,15 @@ void CNpcMotherJellyfishEnemy::setupWaypoints( sThingActor *ThisActor )
s32 startX = 0; s32 startX = 0;
m_npcPath.setWaypointCount( ThisActor->PointCount - 1 );
newXPos = (u16) *PntList; newXPos = (u16) *PntList;
setWaypointPtr( PntList );
PntList++; PntList++;
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
setStartPos( newXPos, newYPos ); setStartPos( newXPos, newYPos );
addWaypoint( newXPos, newYPos );
startX = newXPos << 4; startX = newXPos << 4;
@ -89,8 +91,6 @@ void CNpcMotherJellyfishEnemy::setupWaypoints( sThingActor *ThisActor )
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
addWaypoint( newXPos, newYPos );
if ( pointNum == 1 ) if ( pointNum == 1 )
{ {
setHeading( newXPos, newYPos ); setHeading( newXPos, newYPos );
@ -337,16 +337,8 @@ void CNpcMotherJellyfishEnemy::spawnJellyfish( int _frames )
enemy->init(); enemy->init();
enemy->setStartPos( Pos.vx >> 4, ( Pos.vy + 20 ) >> 4 ); enemy->setStartPos( Pos.vx >> 4, ( Pos.vy + 20 ) >> 4 );
CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); enemy->setWaypointCount( m_npcPath.getWaypointCount() );
enemy->setWaypointPtr( m_npcPath.getWaypointPtr() );
if ( sourceWaypoint )
{
while( sourceWaypoint )
{
enemy->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 );
sourceWaypoint = sourceWaypoint->nextWaypoint;
}
}
enemy->setPathType( CNpcPath::PONG_PATH ); enemy->setPathType( CNpcPath::PONG_PATH );
enemy->postInit(); enemy->postInit();

View File

@ -64,30 +64,23 @@ void CNpcPricklyBugEnemy::processShot( int _frames )
{ {
case NPC_GENERIC_HIT_CHECK_HEALTH: case NPC_GENERIC_HIT_CHECK_HEALTH:
{ {
if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) m_health -= 5;
if ( m_health < 0 )
{ {
m_state = NPC_GENERIC_HIT_DEATH_START; m_state = NPC_GENERIC_HIT_DEATH_START;
m_animPlaying = true;
m_animNo = m_data[m_type].dieAnim;
m_frame = 0;
} }
else else
{ {
m_health -= 5; m_state = NPC_GENERIC_HIT_RECOIL;
if ( m_health < 0 ) m_animPlaying = true;
{ m_animNo = m_data[m_type].recoilAnim;
m_state = NPC_GENERIC_HIT_DEATH_START; m_frame = 0;
m_animPlaying = true;
m_animNo = m_data[m_type].dieAnim;
m_frame = 0;
}
else
{
m_state = NPC_GENERIC_HIT_RECOIL;
m_animPlaying = true;
m_animNo = m_data[m_type].recoilAnim;
m_frame = 0;
}
} }
break; break;

View File

@ -468,47 +468,43 @@ void CNpcEnemy::setupWaypoints( sThingActor *ThisActor )
u16 newXPos, newYPos; u16 newXPos, newYPos;
m_npcPath.setWaypointCount( ThisActor->PointCount - 1 );
newXPos = (u16) *PntList; newXPos = (u16) *PntList;
setWaypointPtr( PntList );
PntList++; PntList++;
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
setStartPos( newXPos, newYPos ); setStartPos( newXPos, newYPos );
addWaypoint( newXPos, newYPos );
if ( ThisActor->PointCount > 1 ) if ( ThisActor->PointCount > 1 )
{ {
for (int pointNum = 1 ; pointNum < ThisActor->PointCount ; pointNum++ ) newXPos = (u16) *PntList;
{ PntList++;
newXPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
newYPos = (u16) *PntList;
PntList++;
addWaypoint( newXPos, newYPos ); setHeading( newXPos, newYPos );
if ( pointNum == 1 )
{
setHeading( newXPos, newYPos );
}
}
} }
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcEnemy::addWaypoint( s32 xPos, s32 yPos ) /*void CNpcEnemy::addWaypoint( u16 *ptr )
{ {
DVECTOR newPos; m_npcPath.addWaypoint( ptr );
newPos.vx = xPos << 4;
newPos.vy = yPos << 4;
m_npcPath.addWaypoint( newPos );
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcEnemy::addWaypoint( u16 *ptrX, u16 *ptrY )
{
m_npcPath.addWaypoint( ptrX, ptrY );
}*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcEnemy::setStartPos( s32 xPos, s32 yPos ) void CNpcEnemy::setStartPos( s32 xPos, s32 yPos )
{ {
Pos.vx = xPos << 4; Pos.vx = xPos << 4;
@ -552,7 +548,6 @@ void CNpcEnemy::init()
m_isDying = false; m_isDying = false;
m_health = m_data[this->m_type].initHealth; m_health = m_data[this->m_type].initHealth;
m_health = 1;
m_extendDir = EXTEND_RIGHT; m_extendDir = EXTEND_RIGHT;
@ -615,7 +610,7 @@ void CNpcEnemy::reinit()
void CNpcEnemy::shutdown() void CNpcEnemy::shutdown()
{ {
m_npcPath.removeAllWaypoints(); //m_npcPath.removeAllWaypoints();
if (m_actorGfx) delete m_actorGfx; if (m_actorGfx) delete m_actorGfx;
@ -1088,26 +1083,19 @@ void CNpcEnemy::processShot( int _frames )
{ {
case NPC_GENERIC_HIT_CHECK_HEALTH: case NPC_GENERIC_HIT_CHECK_HEALTH:
{ {
if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) m_health -= 5;
if ( m_health < 0 )
{ {
m_state = NPC_GENERIC_HIT_DEATH_START; m_state = NPC_GENERIC_HIT_DEATH_START;
} }
else else
{ {
m_health -= 5; m_state = NPC_GENERIC_HIT_RECOIL;
if ( m_health < 0 ) m_animPlaying = true;
{ m_animNo = m_data[m_type].recoilAnim;
m_state = NPC_GENERIC_HIT_DEATH_START; m_frame = 0;
}
else
{
m_state = NPC_GENERIC_HIT_RECOIL;
m_animPlaying = true;
m_animNo = m_data[m_type].recoilAnim;
m_frame = 0;
}
} }
break; break;

View File

@ -104,7 +104,10 @@ public:
static NPC_UNIT_TYPE getTypeFromMapEdit( u16 newType ); static NPC_UNIT_TYPE getTypeFromMapEdit( u16 newType );
void setHeading( s32 newHeading ) {m_heading = newHeading;} void setHeading( s32 newHeading ) {m_heading = newHeading;}
void setHeading( s32 xPos, s32 yPos ); void setHeading( s32 xPos, s32 yPos );
void addWaypoint( s32 xPos, s32 yPos ); //void addWaypoint( u16 *ptr );
//void addWaypoint( u16 *ptrX, u16 *ptrY );
void setWaypointPtr( u16 *newPtr ) {m_npcPath.setWaypointPtr( newPtr );}
void setWaypointCount( u8 newCount ) {m_npcPath.setWaypointCount( newCount );}
void setPathType( u8 newType ) {m_npcPath.setPathType( newType );} void setPathType( u8 newType ) {m_npcPath.setPathType( newType );}
void setStartPos( s32 xPos, s32 yPos ); void setStartPos( s32 xPos, s32 yPos );
virtual u8 hasBeenAttacked(); virtual u8 hasBeenAttacked();

View File

@ -125,7 +125,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__NONE, DAMAGE__NONE,
0, 1,
ANIM_DUSTDEVIL_TWIST, ANIM_DUSTDEVIL_TWIST,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -150,7 +150,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__SHOCK_ENEMY, DAMAGE__SHOCK_ENEMY,
16, 1,
FRM_JELLYFISH1_SWIM1, FRM_JELLYFISH1_SWIM1,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -175,7 +175,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__SHOCK_ENEMY, DAMAGE__SHOCK_ENEMY,
32, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -200,7 +200,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
16, 16,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__NONE, DAMAGE__NONE,
16, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -225,7 +225,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__NONE, DAMAGE__NONE,
32, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -250,7 +250,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
16, 16,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__NONE, DAMAGE__NONE,
48, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -275,7 +275,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__BITE_ENEMY, DAMAGE__BITE_ENEMY,
0, 1,
ANIM_SKELETALFISH_SWIM, ANIM_SKELETALFISH_SWIM,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -300,7 +300,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ATTACK_COLLISION_GENERIC, DETECT_ATTACK_COLLISION_GENERIC,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
0, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -325,7 +325,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
0, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -350,7 +350,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
14, 1,
FRM_SQUIDDART_SWIM0001, FRM_SQUIDDART_SWIM0001,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -375,7 +375,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__NONE, DAMAGE__NONE,
0, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -400,7 +400,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__POISON_ENEMY, DAMAGE__POISON_ENEMY,
9, 1,
ANIM_CATERPILLAR_CRAWL, ANIM_CATERPILLAR_CRAWL,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
ANIM_CATERPILLAR_DIE, ANIM_CATERPILLAR_DIE,
@ -425,7 +425,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
256, 256,
DETECT_ATTACK_COLLISION_GENERIC, DETECT_ATTACK_COLLISION_GENERIC,
DAMAGE__SHOCK_ENEMY, DAMAGE__SHOCK_ENEMY,
56, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -450,7 +450,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
64, 1,
ANIM_PUFFAFISH_SWIM, ANIM_PUFFAFISH_SWIM,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -475,7 +475,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__NONE, DAMAGE__NONE,
0, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -500,7 +500,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ATTACK_COLLISION_GENERIC, DETECT_ATTACK_COLLISION_GENERIC,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
14, 1,
ANIM_HERMITCRAB_SCUTTLE, ANIM_HERMITCRAB_SCUTTLE,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -525,7 +525,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
0, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -550,7 +550,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ATTACK_COLLISION_GENERIC, DETECT_ATTACK_COLLISION_GENERIC,
DAMAGE__BITE_ENEMY, DAMAGE__BITE_ENEMY,
0, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -575,7 +575,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_ATTACK_COLLISION_GENERIC, DETECT_ATTACK_COLLISION_GENERIC,
DAMAGE__PINCH_ENEMY, DAMAGE__PINCH_ENEMY,
0, 1,
ANIM_SPIDERCRAB_RUN, ANIM_SPIDERCRAB_RUN,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -600,7 +600,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__PINCH_ENEMY, DAMAGE__PINCH_ENEMY,
0, 1,
ANIM_SPIDERCRAB_RUN, ANIM_SPIDERCRAB_RUN,
NPC_SHOT_NONE, NPC_SHOT_NONE,
0, 0,
@ -625,7 +625,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
32, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -650,7 +650,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
512, 512,
DETECT_ATTACK_COLLISION_GENERIC, DETECT_ATTACK_COLLISION_GENERIC,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
32, 1,
ANIM_BABYOCTOPUS_SWIM, ANIM_BABYOCTOPUS_SWIM,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -675,7 +675,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
16, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -700,7 +700,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
64, 64,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
16, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -725,7 +725,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
0, 1,
ANIM_GHOST_MOVE, ANIM_GHOST_MOVE,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -750,7 +750,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
160, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -775,7 +775,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__BURN_ENEMY, DAMAGE__BURN_ENEMY,
16, 1,
ANIM_FLAMINGSKULL_MOVE, ANIM_FLAMINGSKULL_MOVE,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -800,7 +800,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__BITE_ENEMY, DAMAGE__BITE_ENEMY,
16, 1,
ANIM_SHARKMAN_RUN, ANIM_SHARKMAN_RUN,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -825,7 +825,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
64, 64,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
0, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -850,7 +850,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__SQUASH_ENEMY, DAMAGE__SQUASH_ENEMY,
0, 1,
ANIM_STOMPER_CRUSH, ANIM_STOMPER_CRUSH,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -925,7 +925,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
256, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -1000,7 +1000,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
2048, 2048,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__HIT_ENEMY, DAMAGE__HIT_ENEMY,
256, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -1025,7 +1025,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__BURN_ENEMY, DAMAGE__BURN_ENEMY,
16, 1,
ANIM_BALLBLOB_IDLE, ANIM_BALLBLOB_IDLE,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -1050,7 +1050,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__BURN_ENEMY, DAMAGE__BURN_ENEMY,
16, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -1075,7 +1075,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__SHOCK_ENEMY, DAMAGE__SHOCK_ENEMY,
16, 1,
FRM_JELLYFISH1_SWIM1, FRM_JELLYFISH1_SWIM1,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -1100,7 +1100,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__SHOCK_ENEMY, DAMAGE__SHOCK_ENEMY,
256, 1,
0, 0,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -1125,7 +1125,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__NONE, DAMAGE__NONE,
16, 1,
FRM_JELLYFISH1_SWIM1, FRM_JELLYFISH1_SWIM1,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -1150,7 +1150,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_ALL_COLLISION, DETECT_ALL_COLLISION,
DAMAGE__SHOCK_ENEMY, DAMAGE__SHOCK_ENEMY,
16, 1,
FRM_JELLYFISH1_SWIM1, FRM_JELLYFISH1_SWIM1,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,
@ -1175,7 +1175,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
128, 128,
DETECT_NO_COLLISION, DETECT_NO_COLLISION,
DAMAGE__NONE, DAMAGE__NONE,
16, 1,
FRM_JELLYFISH1_SWIM1, FRM_JELLYFISH1_SWIM1,
NPC_SHOT_GENERIC, NPC_SHOT_GENERIC,
0, 0,

View File

@ -15,14 +15,22 @@
#include "enemy\npcpath.h" #include "enemy\npcpath.h"
#endif #endif
bool CNpcWaypoint::isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist )
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool CNpcPath::isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist )
{ {
s32 xDistSqr, yDistSqr; s32 xDistSqr, yDistSqr;
*xDist = this->pos.vx - testPos.vx; u16 *waypoint = waypointPtr;
waypoint += 2 * currentWaypoint;
*xDist = ( *waypoint << 4 ) - testPos.vx;
xDistSqr = (*xDist) * (*xDist); xDistSqr = (*xDist) * (*xDist);
*yDist = this->pos.vy - testPos.vy; waypoint++;
*yDist = ( *waypoint << 4 ) - testPos.vy;
yDistSqr = (*yDist) * (*yDist); yDistSqr = (*yDist) * (*yDist);
if ( xDistSqr + yDistSqr < 100 ) if ( xDistSqr + yDistSqr < 100 )
@ -35,83 +43,29 @@ bool CNpcWaypoint::isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist )
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPath::initPath() void CNpcPath::initPath()
{ {
waypoint = NULL; //waypoint = NULL;
pathType = SINGLE_USE_PATH; pathType = SINGLE_USE_PATH;
currentWaypoint = NULL; currentWaypoint = 0;
lastWaypoint = NULL; lastWaypoint = 0;
waypointCount = 0; waypointCount = 0;
reversePath = false; reversePath = false;
minX = maxX = minY = maxY = 0; minX = maxX = minY = maxY = 0;
waypointPtr = NULL;
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPath::resetPath() void CNpcPath::resetPath()
{ {
currentWaypoint = waypoint; lastWaypoint = currentWaypoint = 0;
lastWaypoint = NULL;
} }
void CNpcPath::addWaypoint( DVECTOR newPos ) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
CNpcWaypoint *testWaypoint;
CNpcWaypoint *newWaypoint;
testWaypoint = this->waypoint;
if ( testWaypoint )
{
// find end of path
while ( testWaypoint->nextWaypoint )
{
testWaypoint = testWaypoint->nextWaypoint;
}
newWaypoint = new( "waypoint" ) CNpcWaypoint;
newWaypoint->pos = newPos;
newWaypoint->nextWaypoint = NULL;
newWaypoint->prevWaypoint = testWaypoint;
testWaypoint->nextWaypoint = newWaypoint;
waypointCount++;
if ( newPos.vx < minX )
{
minX = newPos.vx;
}
else if ( newPos.vx > maxX )
{
maxX = newPos.vx;
}
if ( newPos.vy < minY )
{
minY = newPos.vy;
}
else if ( newPos.vy > maxY )
{
maxY = newPos.vy;
}
}
else
{
// no waypoints exist in this path, create
newWaypoint = new( "waypoint" ) CNpcWaypoint;
newWaypoint->pos = newPos;
newWaypoint->nextWaypoint = NULL;
newWaypoint->prevWaypoint = NULL;
this->waypoint = newWaypoint;
waypointCount++;
currentWaypoint = this->waypoint;
minX = maxX = newPos.vx;
minY = maxY = newPos.vy;
}
}
void CNpcPath::getPathXExtents( s32 *minExtent, s32 *maxExtent ) void CNpcPath::getPathXExtents( s32 *minExtent, s32 *maxExtent )
{ {
@ -119,48 +73,93 @@ void CNpcPath::getPathXExtents( s32 *minExtent, s32 *maxExtent )
*maxExtent = maxX; *maxExtent = maxX;
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPath::getPathYExtents( s32 *minExtent, s32 *maxExtent ) void CNpcPath::getPathYExtents( s32 *minExtent, s32 *maxExtent )
{ {
*minExtent = minY; *minExtent = minY;
*maxExtent = maxY; *maxExtent = maxY;
} }
void CNpcPath::removeAllWaypoints() ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
CNpcWaypoint *testWaypoint;
CNpcWaypoint *lastWaypoint;
testWaypoint = this->waypoint;
while ( testWaypoint )
{
lastWaypoint = testWaypoint;
testWaypoint = testWaypoint->nextWaypoint;
delete lastWaypoint;
}
this->waypoint = NULL;
}
void CNpcPath::setPathType( u8 newPathType ) void CNpcPath::setPathType( u8 newPathType )
{ {
pathType = (NPC_PATH_TYPE) newPathType; pathType = (NPC_PATH_TYPE) newPathType;
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
u8 CNpcPath::getPathType() u8 CNpcPath::getPathType()
{ {
return( pathType ); return( pathType );
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPath::setWaypointPtr( u16 *newPtr )
{
waypointPtr = newPtr;
setPathExtents();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPath::setPathExtents()
{
u8 tempWaypoint;
u16 *tempPtr = waypointPtr;
DVECTOR mapPos;
if ( tempPtr )
{
mapPos.vx = *tempPtr << 4;
*tempPtr++;
mapPos.vy = *tempPtr << 4;
*tempPtr++;
minX = maxX = mapPos.vx;
minY = maxY = mapPos.vy;
for ( tempWaypoint = 1 ; tempWaypoint <= waypointCount ; tempWaypoint++ )
{
mapPos.vx = *tempPtr << 4;
*tempPtr++;
mapPos.vy = *tempPtr << 4;
*tempPtr++;
if ( mapPos.vx < minX )
{
minX = mapPos.vx;
}
else if ( mapPos.vx > maxX )
{
maxX = mapPos.vx;
}
if ( mapPos.vy < minY )
{
minY = mapPos.vy;
}
else if ( mapPos.vy > maxY )
{
maxY = mapPos.vy;
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool CNpcPath::incPath() bool CNpcPath::incPath()
{ {
if ( !reversePath ) if ( !reversePath )
{ {
if ( currentWaypoint->nextWaypoint ) if ( currentWaypoint < waypointCount )
{ {
lastWaypoint = currentWaypoint; lastWaypoint = currentWaypoint;
currentWaypoint = currentWaypoint->nextWaypoint; currentWaypoint++;
} }
else else
{ {
@ -175,7 +174,7 @@ bool CNpcPath::incPath()
// go back to start // go back to start
lastWaypoint = currentWaypoint; lastWaypoint = currentWaypoint;
currentWaypoint = this->waypoint; currentWaypoint = 0;
break; break;
@ -184,10 +183,10 @@ bool CNpcPath::incPath()
reversePath = !reversePath; reversePath = !reversePath;
if ( currentWaypoint->prevWaypoint ) if ( currentWaypoint > 0 )
{ {
lastWaypoint = currentWaypoint; lastWaypoint = currentWaypoint;
currentWaypoint = currentWaypoint->prevWaypoint; currentWaypoint--;
} }
break; break;
@ -198,19 +197,19 @@ bool CNpcPath::incPath()
{ {
// must be pong path if reversed // must be pong path if reversed
if ( currentWaypoint->prevWaypoint ) if ( currentWaypoint > 0 )
{ {
lastWaypoint = currentWaypoint; lastWaypoint = currentWaypoint;
currentWaypoint = currentWaypoint->prevWaypoint; currentWaypoint--;
} }
else else
{ {
reversePath = !reversePath; reversePath = !reversePath;
if ( currentWaypoint->nextWaypoint ) if ( currentWaypoint < waypointCount )
{ {
lastWaypoint = currentWaypoint; lastWaypoint = currentWaypoint;
currentWaypoint = currentWaypoint->nextWaypoint; currentWaypoint++;
} }
} }
} }
@ -218,11 +217,13 @@ bool CNpcPath::incPath()
return( false ); return( false );
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPath::reversePathDir() void CNpcPath::reversePathDir()
{ {
if ( lastWaypoint ) if ( lastWaypoint )
{ {
CNpcWaypoint *tempWaypoint; u8 tempWaypoint;
tempWaypoint = currentWaypoint; tempWaypoint = currentWaypoint;
currentWaypoint = lastWaypoint; currentWaypoint = lastWaypoint;
@ -235,35 +236,36 @@ void CNpcPath::reversePathDir()
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool CNpcPath::getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ) bool CNpcPath::getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY )
{ {
return( currentWaypoint->isPointNear( currentPos, distX, distY ) ); return( isPointNear( currentPos, distX, distY ) );
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY ) s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY )
{ {
if ( !this->waypoint ) if ( !waypointPtr )
{ {
return( 0 ); return( 0 );
} }
if ( !currentWaypoint )
{
// if no currentWaypoint set, start it off
currentWaypoint = this->waypoint;
}
*pathComplete = false; *pathComplete = false;
*waypointChange = false; *waypointChange = false;
if ( currentWaypoint->isPointNear( currentPos, distX, distY ) ) if ( isPointNear( currentPos, distX, distY ) )
{ {
*pathComplete = incPath(); *pathComplete = incPath();
*waypointChange = true; *waypointChange = true;
*distX = currentWaypoint->pos.vx - currentPos.vx; u16 *waypoint = waypointPtr;
*distY = currentWaypoint->pos.vy - currentPos.vy; waypoint += 2 * currentWaypoint;
*distX = ( *waypoint << 4 ) - currentPos.vx;
waypoint++;
*distY = ( *waypoint << 4 ) - currentPos.vy;
} }
s32 headingToTarget = ratan2( *distY, *distX ); s32 headingToTarget = ratan2( *distY, *distX );
@ -271,26 +273,25 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang
return( headingToTarget ); return( headingToTarget );
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist ) bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist )
{ {
bool pointChange = false; bool pointChange = false;
*pathComplete = false; *pathComplete = false;
if ( !this->waypoint ) if ( !waypointPtr )
{ {
return( true ); return( true );
} }
if ( !currentWaypoint ) u16 *waypoint = waypointPtr;
{ waypoint += 2 * currentWaypoint;
// if no currentWaypoint set, start it off
currentWaypoint = this->waypoint; *distX = ( *waypoint << 4 ) - currentPos.vx;
} waypoint++;
*distY = ( *waypoint << 4 ) - currentPos.vy;
*distX = currentWaypoint->pos.vx - currentPos.vx;
*distY = currentWaypoint->pos.vy - currentPos.vy;
if ( abs( *distX ) < waypointDist ) if ( abs( *distX ) < waypointDist )
{ {
@ -298,8 +299,12 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s3
*pathComplete = incPath(); *pathComplete = incPath();
} }
*distX = currentWaypoint->pos.vx - currentPos.vx; waypoint = waypointPtr;
*distY = currentWaypoint->pos.vy - currentPos.vy; waypoint += 2 * currentWaypoint;
*distX = ( *waypoint << 4 ) - currentPos.vx;
waypoint++;
*distY = ( *waypoint << 4 ) - currentPos.vy;
if ( *distX > 0 ) if ( *distX > 0 )
{ {
@ -313,26 +318,25 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s3
return( pointChange ); return( pointChange );
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ) bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading )
{ {
bool pointChange = false; bool pointChange = false;
*pathComplete = false; *pathComplete = false;
if ( !this->waypoint ) if ( !waypointPtr )
{ {
return( true ); return( true );
} }
if ( !currentWaypoint ) u16 *waypoint = waypointPtr;
{ waypoint += 2 * currentWaypoint;
// if no currentWaypoint set, start it off
currentWaypoint = this->waypoint; *distX = ( *waypoint << 4 ) - currentPos.vx;
} waypoint++;
*distY = ( *waypoint << 4 ) - currentPos.vy;
*distX = currentWaypoint->pos.vx - currentPos.vx;
*distY = currentWaypoint->pos.vy - currentPos.vy;
if ( abs( *distY ) < 10 ) if ( abs( *distY ) < 10 )
{ {
@ -340,8 +344,12 @@ bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX
*pathComplete = incPath(); *pathComplete = incPath();
} }
*distX = currentWaypoint->pos.vx - currentPos.vx; waypoint = waypointPtr;
*distY = currentWaypoint->pos.vy - currentPos.vy; waypoint += 2 * currentWaypoint;
*distX = ( *waypoint << 4 ) - currentPos.vx;
waypoint++;
*distY = ( *waypoint << 4 ) - currentPos.vy;
if ( *distY > 0 ) if ( *distY > 0 )
{ {
@ -354,8 +362,3 @@ bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX
return( pointChange ); return( pointChange );
} }
CNpcWaypoint *CNpcPath::getWaypointList()
{
return( waypoint );
}

View File

@ -16,16 +16,6 @@
#include "system\global.h" #include "system\global.h"
class CNpcWaypoint
{
public:
DVECTOR pos;
CNpcWaypoint *nextWaypoint;
CNpcWaypoint *prevWaypoint;
bool isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist );
};
class CNpcPath class CNpcPath
{ {
public: public:
@ -37,7 +27,6 @@ public:
}; };
void initPath(); void initPath();
void addWaypoint( DVECTOR newPos );
void removeAllWaypoints(); void removeAllWaypoints();
void setPathType( u8 newPathType ); void setPathType( u8 newPathType );
u8 getPathType(); u8 getPathType();
@ -51,17 +40,22 @@ public:
void getPathXExtents( s32 *minExtent, s32 *maxExtent ); void getPathXExtents( s32 *minExtent, s32 *maxExtent );
void getPathYExtents( s32 *minExtent, s32 *maxExtent ); void getPathYExtents( s32 *minExtent, s32 *maxExtent );
u8 getWaypointCount() { return( waypointCount ); } u8 getWaypointCount() { return( waypointCount ); }
CNpcWaypoint *getWaypointList(); void setWaypointCount( u8 newCount ) { waypointCount = newCount; }
void setWaypointPtr( u16 *newPtr );
void setPathExtents();
u16 *getWaypointPtr() { return( waypointPtr ); }
bool isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist );
private: private:
CNpcWaypoint *waypoint;
NPC_PATH_TYPE pathType; NPC_PATH_TYPE pathType;
u8 waypointCount; u8 waypointCount;
bool reversePath; bool reversePath;
CNpcWaypoint *currentWaypoint; u8 currentWaypoint;
CNpcWaypoint *lastWaypoint; u8 lastWaypoint;
s32 minX, maxX; s32 minX, maxX;
s32 minY, maxY; s32 minY, maxY;
u16 *waypointPtr;
}; };
#endif #endif

View File

@ -673,26 +673,19 @@ void CNpcParasiticWormEnemy::processShot( int _frames )
{ {
case NPC_GENERIC_HIT_CHECK_HEALTH: case NPC_GENERIC_HIT_CHECK_HEALTH:
{ {
if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) m_health -= 5;
if ( m_health < 0 )
{ {
m_state = NPC_GENERIC_HIT_DEATH_START; m_state = NPC_GENERIC_HIT_DEATH_START;
} }
else else
{ {
m_health -= 5; m_state = NPC_GENERIC_HIT_RECOIL;
if ( m_health < 0 ) m_animPlaying = true;
{ m_animNo = m_data[m_type].recoilAnim;
m_state = NPC_GENERIC_HIT_DEATH_START; m_frame = 0;
}
else
{
m_state = NPC_GENERIC_HIT_RECOIL;
m_animPlaying = true;
m_animNo = m_data[m_type].recoilAnim;
m_frame = 0;
}
} }
break; break;

View File

@ -306,7 +306,10 @@ void CNpcHazard::setWaypoints( sThingHazard *ThisHazard )
u16 newXPos, newYPos; u16 newXPos, newYPos;
m_npcPath.setWaypointCount( ThisHazard->PointCount - 1 );
newXPos = (u16) *PntList; newXPos = (u16) *PntList;
setWaypointPtr( PntList );
PntList++; PntList++;
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
@ -317,33 +320,6 @@ void CNpcHazard::setWaypoints( sThingHazard *ThisHazard )
Pos = startPos; Pos = startPos;
m_base = Pos; m_base = Pos;
addWaypoint( newXPos, newYPos );
if ( ThisHazard->PointCount > 1 )
{
for ( pointNum = 1 ; pointNum < ThisHazard->PointCount ; pointNum++ )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
addWaypoint( newXPos, newYPos );
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcHazard::addWaypoint( s32 xPos, s32 yPos )
{
DVECTOR newPos;
newPos.vx = xPos << 4;
newPos.vy = yPos << 4;
m_npcPath.addWaypoint( newPos );
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -391,7 +367,7 @@ void CNpcHazard::shutdown()
delete m_modelGfx; delete m_modelGfx;
// remove waypoints // remove waypoints
m_npcPath.removeAllWaypoints(); //m_npcPath.removeAllWaypoints();
//if (m_actorGfx) delete m_actorGfx; //if (m_actorGfx) delete m_actorGfx;

View File

@ -70,7 +70,8 @@ public:
void think(int _frames); void think(int _frames);
virtual void render(); virtual void render();
virtual void setWaypoints( sThingHazard *ThisHazard ); virtual void setWaypoints( sThingHazard *ThisHazard );
void addWaypoint( s32 xPos, s32 yPos ); void setWaypointPtr( u16 *newPtr ) {m_npcPath.setWaypointPtr( newPtr );}
void setWaypointCount( u8 newCount ) {m_npcPath.setWaypointCount( newCount );}
virtual void setRespawnRate( s16 newRespawnRate ) {m_respawnRate=newRespawnRate;} virtual void setRespawnRate( s16 newRespawnRate ) {m_respawnRate=newRespawnRate;}
static NPC_HAZARD_UNIT_TYPE getTypeFromMapEdit( u16 newType ); static NPC_HAZARD_UNIT_TYPE getTypeFromMapEdit( u16 newType );

View File

@ -213,7 +213,10 @@ void CNpcFallingHazard::setWaypoints( sThingHazard *ThisHazard )
u16 newXPos, newYPos; u16 newXPos, newYPos;
m_npcPath.setWaypointCount( ThisHazard->PointCount - 1 );
newXPos = (u16) *PntList; newXPos = (u16) *PntList;
setWaypointPtr( PntList );
PntList++; PntList++;
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
@ -224,21 +227,6 @@ void CNpcFallingHazard::setWaypoints( sThingHazard *ThisHazard )
Pos = startPos; Pos = startPos;
m_base = Pos; m_base = Pos;
addWaypoint( newXPos, newYPos );
if ( ThisHazard->PointCount > 1 )
{
for ( pointNum = 1 ; pointNum < ThisHazard->PointCount ; pointNum++ )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
addWaypoint( newXPos, newYPos );
}
}
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -47,13 +47,14 @@ void CNpcFireballHazard::setWaypoints( sThingHazard *ThisHazard )
u16 newXPos, newYPos; u16 newXPos, newYPos;
m_npcPath.setWaypointCount( ThisHazard->PointCount - 1 );
newXPos = (u16) *PntList; newXPos = (u16) *PntList;
setWaypointPtr( PntList );
PntList++; PntList++;
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
addWaypoint( newXPos, newYPos );
DVECTOR startPos; DVECTOR startPos;
startPos.vx = newXPos << 4; startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4; startPos.vy = newYPos << 4;
@ -61,23 +62,6 @@ void CNpcFireballHazard::setWaypoints( sThingHazard *ThisHazard )
Pos = startPos; Pos = startPos;
m_base = Pos; m_base = Pos;
if ( ThisHazard->PointCount > 1 )
{
for ( pointNum = 1 ; pointNum < ThisHazard->PointCount ; pointNum++ )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
addWaypoint( newXPos, newYPos );
}
}
else
{
addWaypoint( newXPos, newYPos );
}
s32 minX, maxX, minY, maxY; s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX ); m_npcPath.getPathXExtents( &minX, &maxX );

View File

@ -30,7 +30,7 @@ void CNpcSawbladeHazard::init()
newPos.vx = 300; newPos.vx = 300;
newPos.vy = 100; newPos.vy = 100;
m_npcPath.addWaypoint( newPos ); //m_npcPath.addWaypoint( newPos );
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH ); m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
} }

View File

@ -82,16 +82,8 @@ void CNpcGeyserPlatformGenerator::think( int _frames )
startPos.vx += ( -5 + ( getRnd() % 11 ) ); startPos.vx += ( -5 + ( getRnd() % 11 ) );
newPlatform->init( startPos ); newPlatform->init( startPos );
CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); newPlatform->setWaypointCount( m_npcPath.getWaypointCount() );
newPlatform->setWaypointPtr( m_npcPath.getWaypointPtr() );
if ( sourceWaypoint )
{
while( sourceWaypoint )
{
newPlatform->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 );
sourceWaypoint = sourceWaypoint->nextWaypoint;
}
}
newPlatform->setTiltable( false ); newPlatform->setTiltable( false );
newPlatform->postInit(); newPlatform->postInit();

View File

@ -59,7 +59,7 @@ void CNpcConveyorPlatformGenerator::think( int _frames )
//m_timer = ( 3 * GameState::getOneSecondInFrames() ) + ( getRnd() % ( ( m_data[m_type].initTimer - 1 ) * GameState::getOneSecondInFrames() ) ); //m_timer = ( 3 * GameState::getOneSecondInFrames() ) + ( getRnd() % ( ( m_data[m_type].initTimer - 1 ) * GameState::getOneSecondInFrames() ) );
// generate new falling platform // generate new conveyor platform
CNpcPlatform *newPlatform = NULL; CNpcPlatform *newPlatform = NULL;
newPlatform = CNpcPlatform::Create( NPC_CONVEYOR_PLATFORM ); newPlatform = CNpcPlatform::Create( NPC_CONVEYOR_PLATFORM );
@ -69,24 +69,11 @@ void CNpcConveyorPlatformGenerator::think( int _frames )
newPlatform->setThingSubType( NPC_CONVEYOR_PLATFORM ); newPlatform->setThingSubType( NPC_CONVEYOR_PLATFORM );
newPlatform->setGraphic( m_graphicNum ); newPlatform->setGraphic( m_graphicNum );
CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); DVECTOR startPos = Pos;
newPlatform->init( startPos );
if ( sourceWaypoint ) newPlatform->setWaypointCount( m_npcPath.getWaypointCount() );
{ newPlatform->setWaypointPtr( m_npcPath.getWaypointPtr() );
DVECTOR startPos;
startPos.vx = sourceWaypoint->pos.vx;
startPos.vy = sourceWaypoint->pos.vy;
//startPos.vx = 100;
//startPos.vy = 100;
newPlatform->init( startPos );
while( sourceWaypoint )
{
newPlatform->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 );
sourceWaypoint = sourceWaypoint->nextWaypoint;
}
}
newPlatform->setTiltable( false ); newPlatform->setTiltable( false );
newPlatform->postInit(); newPlatform->postInit();

View File

@ -87,24 +87,28 @@ void CNpcFallingPlatformGenerator::think( int _frames )
newPlatform->setThingSubType( m_targetType ); newPlatform->setThingSubType( m_targetType );
newPlatform->setGraphic( m_graphicNum ); newPlatform->setGraphic( m_graphicNum );
CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); DVECTOR startPos = Pos;
newPlatform->init( startPos );
newPlatform->setWaypointCount( m_npcPath.getWaypointCount() );
newPlatform->setWaypointPtr( m_npcPath.getWaypointPtr() );
/*CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList();
if ( sourceWaypoint ) if ( sourceWaypoint )
{ {
DVECTOR startPos; DVECTOR startPos;
startPos.vx = sourceWaypoint->pos.vx; startPos.vx = *sourceWaypoint->posX << 4;
startPos.vy = sourceWaypoint->pos.vy; startPos.vy = *sourceWaypoint->posY << 4;
//startPos.vx = 100;
//startPos.vy = 100;
newPlatform->init( startPos ); newPlatform->init( startPos );
while( sourceWaypoint ) while( sourceWaypoint )
{ {
newPlatform->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 ); newPlatform->addWaypoint( sourceWaypoint->posX, sourceWaypoint->posY );
sourceWaypoint = sourceWaypoint->nextWaypoint; sourceWaypoint = sourceWaypoint->nextWaypoint;
} }
} }*/
newPlatform->setTiltable( false ); newPlatform->setTiltable( false );
newPlatform->postInit(); newPlatform->postInit();

View File

@ -449,10 +449,12 @@ void CNpcPlatform::setWaypoints( sThingPlatform *ThisPlatform )
int pointNum; int pointNum;
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform)); u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
u16 *waypoints;
u16 newXPos, newYPos; u16 newXPos, newYPos;
newXPos = (u16) *PntList; newXPos = (u16) *PntList;
waypoints = PntList;
PntList++; PntList++;
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
@ -463,20 +465,9 @@ void CNpcPlatform::setWaypoints( sThingPlatform *ThisPlatform )
init( startPos ); init( startPos );
addWaypoint( newXPos, newYPos ); setWaypointCount( ThisPlatform->PointCount - 1 );
if ( ThisPlatform->PointCount > 1 ) setWaypointPtr( waypoints );
{
for ( pointNum = 1 ; pointNum < ThisPlatform->PointCount ; pointNum++ )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
addWaypoint( newXPos, newYPos );
}
}
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -605,7 +596,7 @@ void CNpcPlatform::postInit()
void CNpcPlatform::shutdown() void CNpcPlatform::shutdown()
{ {
delete m_modelGfx; delete m_modelGfx;
m_npcPath.removeAllWaypoints(); //m_npcPath.removeAllWaypoints();
// temporary // temporary
CPlatformThing::shutdown(); CPlatformThing::shutdown();
@ -1191,18 +1182,20 @@ int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, in
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::addWaypoint( s32 xPos, s32 yPos ) /*void CNpcPlatform::addWaypoint( u16 *ptr )
{ {
DVECTOR newPos; m_npcPath.addWaypoint( ptr );
newPos.vx = xPos << 4;
newPos.vy = yPos << 4;
m_npcPath.addWaypoint( newPos );
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::addWaypoint( u16 *ptrX, u16 *ptrY )
{
m_npcPath.addWaypoint( ptrX, ptrY );
}*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::setTypeFromMapEdit( u16 newType ) void CNpcPlatform::setTypeFromMapEdit( u16 newType )
{ {
int Type= mapEditConvertTable[newType]; int Type= mapEditConvertTable[newType];

View File

@ -108,7 +108,8 @@ public:
virtual u8 checkCollisionDelta( CThing *_thisThing, int threshold, CRECT collisionArea ); virtual u8 checkCollisionDelta( CThing *_thisThing, int threshold, CRECT collisionArea );
virtual int getHeightFromPlatformAtPosition(int _x,int _y, int offsetX = 0, int offsetY = 0); virtual int getHeightFromPlatformAtPosition(int _x,int _y, int offsetX = 0, int offsetY = 0);
void setTiltable( bool isTiltable ); void setTiltable( bool isTiltable );
void addWaypoint( s32 xPos, s32 yPos ); void setWaypointPtr( u16 *newPtr ) {m_npcPath.setWaypointPtr( newPtr );}
void setWaypointCount( u8 newCount ) {m_npcPath.setWaypointCount( newCount );}
void setGraphic( sThingPlatform *ThisPlatform ); void setGraphic( sThingPlatform *ThisPlatform );
void setGraphic( u8 graphicNum ); void setGraphic( u8 graphicNum );
virtual void setWaypoints( sThingPlatform *ThisPlatform ); virtual void setWaypoints( sThingPlatform *ThisPlatform );