This commit is contained in:
parent
0cb7d8d491
commit
4ceea8876b
6 changed files with 377 additions and 67 deletions
|
@ -211,7 +211,7 @@ void CNpcEnemy::setStartPos( s32 xPos, s32 yPos )
|
|||
Pos.vx = xPos << 4;
|
||||
Pos.vy = yPos << 4;
|
||||
|
||||
m_base = Pos;
|
||||
m_initPos = m_base = Pos;
|
||||
}
|
||||
|
||||
|
||||
|
@ -245,6 +245,7 @@ void CNpcEnemy::init()
|
|||
m_rotation = 0;
|
||||
m_reversed = false;
|
||||
m_salvoCount = 0;
|
||||
m_isActive = true;
|
||||
|
||||
m_health = m_data[this->m_type].initHealth;
|
||||
|
||||
|
@ -549,6 +550,36 @@ void CNpcEnemy::postInit()
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcEnemy::reinit()
|
||||
{
|
||||
m_animPlaying = true;
|
||||
m_animNo = m_data[m_type].initAnim;
|
||||
m_frame = 0;
|
||||
|
||||
m_heading = m_fireHeading = 0;
|
||||
m_movementTimer = 0;
|
||||
m_timerTimer = 0;
|
||||
m_velocity = 0;
|
||||
m_extension = 0;
|
||||
m_rotation = 0;
|
||||
m_reversed = false;
|
||||
m_salvoCount = 0;
|
||||
m_isActive = true;
|
||||
|
||||
m_health = m_data[this->m_type].initHealth;
|
||||
|
||||
m_extendDir = EXTEND_RIGHT;
|
||||
|
||||
m_timerFunc = m_data[this->m_type].timerFunc;
|
||||
m_sensorFunc = m_data[this->m_type].sensorFunc;
|
||||
|
||||
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
||||
|
||||
Pos = m_initPos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcEnemy::shutdown()
|
||||
{
|
||||
// remove waypoints
|
||||
|
@ -581,70 +612,73 @@ void CNpcEnemy::think(int _frames)
|
|||
{
|
||||
CEnemyThing::think(_frames);
|
||||
|
||||
processGenericGetUserDist( _frames, &playerXDist, &playerYDist );
|
||||
playerXDistSqr = playerXDist * playerXDist;
|
||||
playerYDistSqr = playerYDist * playerYDist;
|
||||
|
||||
if ( m_animPlaying )
|
||||
if ( m_isActive )
|
||||
{
|
||||
s32 frameCount = m_actorGfx->getFrameCount(m_animNo);
|
||||
s32 frameShift = ( _frames << 8 ) >> 1;
|
||||
processGenericGetUserDist( _frames, &playerXDist, &playerYDist );
|
||||
playerXDistSqr = playerXDist * playerXDist;
|
||||
playerYDistSqr = playerYDist * playerYDist;
|
||||
|
||||
if ( ( frameCount << 8 ) - m_frame > frameShift ) //( _frames >> 1 ) )
|
||||
if ( m_animPlaying )
|
||||
{
|
||||
//m_frame += _frames >> 1;
|
||||
m_frame += frameShift;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_frame = ( frameCount - 1 ) << 8;
|
||||
m_animPlaying = false;
|
||||
}
|
||||
}
|
||||
s32 frameCount = m_actorGfx->getFrameCount(m_animNo);
|
||||
s32 frameShift = ( _frames << 8 ) >> 1;
|
||||
|
||||
switch ( this->m_controlFunc )
|
||||
{
|
||||
case NPC_CONTROL_NONE:
|
||||
return;
|
||||
|
||||
case NPC_CONTROL_MOVEMENT:
|
||||
if ( !processSensor() )
|
||||
if ( ( frameCount << 8 ) - m_frame > frameShift ) //( _frames >> 1 ) )
|
||||
{
|
||||
processMovement(_frames);
|
||||
//m_frame += _frames >> 1;
|
||||
m_frame += frameShift;
|
||||
}
|
||||
else
|
||||
{
|
||||
processClose(_frames);
|
||||
m_frame = ( frameCount - 1 ) << 8;
|
||||
m_animPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
switch ( this->m_controlFunc )
|
||||
{
|
||||
case NPC_CONTROL_NONE:
|
||||
return;
|
||||
|
||||
case NPC_CONTROL_SHOT:
|
||||
processShot();
|
||||
case NPC_CONTROL_MOVEMENT:
|
||||
if ( !processSensor() )
|
||||
{
|
||||
processMovement(_frames);
|
||||
}
|
||||
else
|
||||
{
|
||||
processClose(_frames);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case NPC_CONTROL_CLOSE:
|
||||
processClose(_frames);
|
||||
case NPC_CONTROL_SHOT:
|
||||
processShot();
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case NPC_CONTROL_COLLISION:
|
||||
processCollision();
|
||||
case NPC_CONTROL_CLOSE:
|
||||
processClose(_frames);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case NPC_CONTROL_COLLISION:
|
||||
processCollision();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ( m_heading > 1024 && m_heading < 3072 )
|
||||
{
|
||||
m_reversed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_reversed = false;
|
||||
}
|
||||
}
|
||||
|
||||
processTimer(_frames);
|
||||
|
||||
if ( m_heading > 1024 && m_heading < 3072 )
|
||||
{
|
||||
m_reversed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_reversed = false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -659,7 +693,7 @@ void CNpcEnemy::collidedWith( CThing *_thisThing )
|
|||
{
|
||||
// only detect collision if one isn't already happening
|
||||
|
||||
switch( m_data[m_type].detectCollision )
|
||||
switch( m_data[m_type].detectCollision && m_isActive )
|
||||
{
|
||||
case DETECT_NO_COLLISION:
|
||||
{
|
||||
|
@ -1474,7 +1508,7 @@ void CNpcEnemy::processTimer(int _frames)
|
|||
{
|
||||
if ( m_timerTimer > 0 )
|
||||
{
|
||||
this->m_timerTimer -= _frames;
|
||||
m_timerTimer -= _frames;
|
||||
}
|
||||
|
||||
switch( m_timerFunc )
|
||||
|
@ -1489,8 +1523,18 @@ void CNpcEnemy::processTimer(int _frames)
|
|||
{
|
||||
if ( m_timerTimer <= 0 )
|
||||
{
|
||||
this->m_timerFunc = NPC_TIMER_NONE;
|
||||
this->m_sensorFunc = m_data[this->m_type].sensorFunc;
|
||||
m_timerFunc = NPC_TIMER_NONE;
|
||||
m_sensorFunc = m_data[this->m_type].sensorFunc;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case NPC_TIMER_RESPAWN:
|
||||
{
|
||||
if ( m_timerTimer <= 0 )
|
||||
{
|
||||
reinit();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1505,20 +1549,23 @@ void CNpcEnemy::processTimer(int _frames)
|
|||
|
||||
void CNpcEnemy::render()
|
||||
{
|
||||
CEnemyThing::render();
|
||||
|
||||
// Render
|
||||
DVECTOR renderPos;
|
||||
DVECTOR offset = CLevel::getCameraPos();
|
||||
|
||||
renderPos.vx = Pos.vx - offset.vx;
|
||||
renderPos.vy = Pos.vy - offset.vy;
|
||||
|
||||
if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
|
||||
if ( m_isActive )
|
||||
{
|
||||
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
|
||||
CEnemyThing::render();
|
||||
|
||||
// Render
|
||||
DVECTOR renderPos;
|
||||
DVECTOR offset = CLevel::getCameraPos();
|
||||
|
||||
renderPos.vx = Pos.vx - offset.vx;
|
||||
renderPos.vy = Pos.vy - offset.vy;
|
||||
|
||||
if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
|
||||
{
|
||||
m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed);
|
||||
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
|
||||
{
|
||||
m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1577,4 +1624,24 @@ void CNpcEnemy::processEvent( GAME_EVENT evt, CThing *sourceThing )
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool CNpcEnemy::canBeCaughtByNet()
|
||||
{
|
||||
return( m_data[m_type].canBeNetted );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcEnemy::caughtWithNet()
|
||||
{
|
||||
if ( m_isActive )
|
||||
{
|
||||
m_isActive = false;
|
||||
|
||||
m_timerFunc = NPC_TIMER_RESPAWN;
|
||||
m_timerTimer = 4 * GameState::getOneSecondInFrames();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,6 +172,8 @@ public:
|
|||
void setPathType( u8 newType ) {m_npcPath.setPathType( newType );}
|
||||
void setStartPos( s32 xPos, s32 yPos );
|
||||
void hasBeenAttacked();
|
||||
bool canBeCaughtByNet();
|
||||
void caughtWithNet();
|
||||
|
||||
static void CacheActor(int Type);
|
||||
|
||||
|
@ -302,6 +304,7 @@ protected:
|
|||
NPC_TIMER_NONE = 0,
|
||||
NPC_TIMER_EVADE_DONE = 1,
|
||||
NPC_TIMER_ATTACK_DONE,
|
||||
NPC_TIMER_RESPAWN,
|
||||
};
|
||||
|
||||
enum NPC_SHOT_FUNC
|
||||
|
@ -427,6 +430,7 @@ protected:
|
|||
u16 dieAnim;
|
||||
u16 recoilAnim;
|
||||
NPC_COLLISION_FUNC collisionFunc;
|
||||
bool canBeNetted;
|
||||
}
|
||||
NPC_DATA;
|
||||
|
||||
|
@ -449,6 +453,8 @@ protected:
|
|||
void processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY );
|
||||
bool processGroundCollisionReverse( s32 *moveX, s32 *moveY );
|
||||
|
||||
void reinit();
|
||||
|
||||
// small jellyfish functions
|
||||
|
||||
void processSmallJellyfishSensor();
|
||||
|
@ -582,11 +588,13 @@ protected:
|
|||
bool m_extendDir;
|
||||
s16 m_rotation;
|
||||
DVECTOR m_base;
|
||||
DVECTOR m_initPos;
|
||||
u8 m_state;
|
||||
u8 m_salvoCount;
|
||||
bool m_animPlaying;
|
||||
bool m_reversed;
|
||||
s32 m_health;
|
||||
bool m_isActive;
|
||||
|
||||
s32 m_frame;
|
||||
int m_animNo;
|
||||
|
|
|
@ -206,6 +206,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_FISH_HOOK
|
||||
|
@ -228,6 +229,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_DUST_DEVIL
|
||||
|
@ -250,6 +252,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_PENDULUM
|
||||
|
@ -272,6 +275,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_FIREBALL
|
||||
|
@ -294,6 +298,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SAW_BLADE
|
||||
|
@ -316,6 +321,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SMALL_JELLYFISH_1
|
||||
|
@ -338,6 +344,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
ANIM_JELLYFISH1_SWIM,
|
||||
NPC_COLLISION_GENERIC,
|
||||
true,
|
||||
},
|
||||
|
||||
{ // NPC_SMALL_JELLYFISH_2
|
||||
|
@ -360,6 +367,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_ANEMONE_1
|
||||
|
@ -382,6 +390,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_ANEMONE_2
|
||||
|
@ -404,6 +413,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_ANEMONE_3
|
||||
|
@ -426,6 +436,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SKELETAL_FISH
|
||||
|
@ -448,6 +459,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
ANIM_SKELETALFISH_DIE,
|
||||
ANIM_SKELETALFISH_GETHIT,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_CLAM_JUMP
|
||||
|
@ -470,6 +482,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_CLAM_STATIC
|
||||
|
@ -492,6 +505,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SQUID_DART
|
||||
|
@ -514,6 +528,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_FISH_FOLK
|
||||
|
@ -536,6 +551,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_PRICKLY_BUG
|
||||
|
@ -558,6 +574,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
ANIM_CATERPILLAR_DIE,
|
||||
ANIM_CATERPILLAR_GETHIT,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SEA_SNAKE
|
||||
|
@ -580,6 +597,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_PUFFA_FISH
|
||||
|
@ -602,6 +620,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_ANGLER_FISH
|
||||
|
@ -624,6 +643,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_HERMIT_CRAB
|
||||
|
@ -646,6 +666,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
ANIM_HERMITCRAB_DIE,
|
||||
ANIM_HERMITCRAB_GETHIT,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_MINE
|
||||
|
@ -668,6 +689,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_BOOGER_MONSTER
|
||||
|
@ -690,6 +712,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SPIDER_CRAB
|
||||
|
@ -712,6 +735,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
ANIM_SPIDERCRAB_DIE,
|
||||
ANIM_SPIDERCRAB_HIT,
|
||||
NPC_COLLISION_SPIDER_CRAB_BITE,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_EYEBALL
|
||||
|
@ -734,6 +758,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_BABY_OCTOPUS
|
||||
|
@ -756,6 +781,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
ANIM_BABYOCTOPUS_DIE,
|
||||
ANIM_BABYOCTOPUS_HIT,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_ZOMBIE_FISH_FOLK
|
||||
|
@ -778,6 +804,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_NINJA_STARFISH
|
||||
|
@ -800,6 +827,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_GHOST
|
||||
|
@ -822,6 +850,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_GHOST_PIRATE
|
||||
|
@ -844,6 +873,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_FLAMING_SKULL
|
||||
|
@ -866,6 +896,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SHARK_MAN
|
||||
|
@ -888,6 +919,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
ANIM_SHARKMAN_DIE,
|
||||
ANIM_SHARKMAN_BLOCK,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_OIL_BLOB
|
||||
|
@ -910,6 +942,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SKULL_STOMPER
|
||||
|
@ -932,6 +965,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_MOTHER_JELLYFISH
|
||||
|
@ -954,6 +988,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_SUB_SHARK
|
||||
|
@ -976,6 +1011,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_PARASITIC_WORM
|
||||
|
@ -998,6 +1034,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_FLYING_DUTCHMAN
|
||||
|
@ -1020,6 +1057,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
ANIM_FLYINGDUTCHMAN_GETHIT,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_IRON_DOGFISH
|
||||
|
@ -1042,6 +1080,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
ANIM_IRONDOGFISH_GETHIT,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_PARASITIC_WORM_SEGMENT
|
||||
|
@ -1064,6 +1103,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
|
||||
{ // NPC_BALL_BLOB
|
||||
|
@ -1086,6 +1126,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
|||
0,
|
||||
0,
|
||||
NPC_COLLISION_GENERIC,
|
||||
false,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -36,6 +36,18 @@
|
|||
#include <ingamefx.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ENEMY_NPC_H__
|
||||
#include "enemy\npc.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PROJECTL_PROJECTL_H__
|
||||
#include "projectl\projectl.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAME_H__
|
||||
#include "game\game.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
|
@ -114,11 +126,10 @@ void CPlayerModeNet::think()
|
|||
thing=CThingManager::checkCollisionAreaAgainstThings(&netRect,CThing::TYPE_ENEMY,false);
|
||||
while(thing)
|
||||
{
|
||||
// if((CEnemy*)thing)->canBeCaughtByNet()) ( or whatever.. )
|
||||
if(1) // just to stop the complier complaining until the above line can be put it..
|
||||
if(((CNpcEnemy*)thing)->canBeCaughtByNet())
|
||||
{
|
||||
PAUL_DBGMSG("Caught!");
|
||||
//((CEnemy*)thing)->caughtWithNet(); ( or whatever.. )
|
||||
((CNpcEnemy*)thing)->caughtWithNet();
|
||||
m_netState=NET_STATE__JUST_CAUGHT_SOMETHING;
|
||||
thing=NULL;
|
||||
}
|
||||
|
@ -138,7 +149,20 @@ PAUL_DBGMSG("Caught!");
|
|||
{
|
||||
// Launch projectile at halfway through the swing..
|
||||
PAUL_DBGMSG("Released!");
|
||||
// new cprojectile ( or whatever.. )
|
||||
CPlayerProjectile *projectile;
|
||||
|
||||
int playerFacing=m_player->getFacing();
|
||||
|
||||
int fireHeading = 1024 + ( 1024 * playerFacing );
|
||||
|
||||
|
||||
projectile = new( "user projectile" ) CPlayerProjectile;
|
||||
projectile->init( m_player->getPos(),
|
||||
fireHeading,
|
||||
CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE,
|
||||
CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE,
|
||||
5 * GameState::getOneSecondInFrames() );
|
||||
|
||||
m_netState=NET_STATE__JUST_LAUNCHED_SOMETHING;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -336,3 +336,131 @@ void CProjectile::processEvent( GAME_EVENT evt, CThing *sourceThing )
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void CPlayerProjectile::init()
|
||||
{
|
||||
CPlayerProjectileThing::init();
|
||||
|
||||
m_spriteBank=new ("projectile sprites") SpriteBank();
|
||||
m_spriteBank->load(INGAMEFX_INGAMEFX_SPR);
|
||||
|
||||
m_heading = 0;
|
||||
m_lifetime = GameState::getOneSecondInFrames() * 2;
|
||||
m_movementType = PLAYER_PROJECTILE_DUMBFIRE;
|
||||
m_lifetimeType = PLAYER_PROJECTILE_FINITE_LIFE;
|
||||
m_turnSpeed = 256;
|
||||
m_extension = 0;
|
||||
}
|
||||
|
||||
void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading )
|
||||
{
|
||||
init();
|
||||
|
||||
m_heading = initHeading;
|
||||
m_initPos = Pos = initPos;
|
||||
}
|
||||
|
||||
void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType )
|
||||
{
|
||||
init( initPos, initHeading );
|
||||
|
||||
m_movementType = initMoveType;
|
||||
m_lifetimeType = initLifeType;
|
||||
}
|
||||
|
||||
void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType, s32 initLifetime )
|
||||
{
|
||||
init( initPos, initHeading, initMoveType, initLifeType );
|
||||
|
||||
m_lifetime = initLifetime;
|
||||
}
|
||||
|
||||
void CPlayerProjectile::shutdown()
|
||||
{
|
||||
m_spriteBank->dump(); delete m_spriteBank;
|
||||
|
||||
CPlayerProjectileThing::shutdown();
|
||||
}
|
||||
|
||||
void CPlayerProjectile::setMovementType( PLAYER_PROJECTILE_MOVEMENT_TYPE moveType )
|
||||
{
|
||||
m_movementType = moveType;
|
||||
}
|
||||
|
||||
CPlayerProjectile::PLAYER_PROJECTILE_MOVEMENT_TYPE CPlayerProjectile::getMovementType()
|
||||
{
|
||||
return( m_movementType );
|
||||
}
|
||||
|
||||
void CPlayerProjectile::setPosition( DVECTOR newPos )
|
||||
{
|
||||
Pos = newPos;
|
||||
}
|
||||
|
||||
void CPlayerProjectile::setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType )
|
||||
{
|
||||
m_lifetimeType = lifeType;
|
||||
}
|
||||
|
||||
void CPlayerProjectile::think(int _frames)
|
||||
{
|
||||
CPlayerProjectileThing::think( _frames );
|
||||
|
||||
switch( m_movementType )
|
||||
{
|
||||
case PLAYER_PROJECTILE_DUMBFIRE:
|
||||
default:
|
||||
{
|
||||
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
|
||||
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_lifetimeType == PLAYER_PROJECTILE_FINITE_LIFE )
|
||||
{
|
||||
m_lifetime -= _frames;
|
||||
|
||||
if ( m_lifetime <= 0 )
|
||||
{
|
||||
shutdown();
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPlayerProjectile::render()
|
||||
{
|
||||
CPlayerProjectileThing::render();
|
||||
|
||||
DVECTOR offset;
|
||||
int x,y;
|
||||
int scrnWidth = VidGetScrW();
|
||||
int scrnHeight = VidGetScrH();
|
||||
int spriteWidth = m_spriteBank->getFrameWidth(FRM_BARNACLEBOY);
|
||||
int spriteHeight = m_spriteBank->getFrameHeight(FRM_BARNACLEBOY);
|
||||
|
||||
offset = getScreenOffset();
|
||||
|
||||
x = Pos.vx - offset.vx /*+ ( scrnWidth >> 1 )*/ - ( spriteWidth >> 1 );
|
||||
y = Pos.vy - offset.vy /*+ ( scrnHeight >> 1 )*/ - ( spriteHeight >> 1 );
|
||||
|
||||
if ( x < -spriteWidth || y < -spriteHeight || x > scrnWidth || y > scrnHeight )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_spriteBank->printFT4(FRM_BARNACLEBOY,x,y,0,0,0);
|
||||
}
|
||||
|
||||
DVECTOR CPlayerProjectile::getScreenOffset()
|
||||
{
|
||||
return CLevel::getCameraPos();
|
||||
}
|
||||
|
||||
void CPlayerProjectile::processEvent( GAME_EVENT evt, CThing *sourceThing )
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -72,6 +72,48 @@ protected:
|
|||
u16 m_turnSpeed;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class CPlayerProjectile : public CPlayerProjectileThing
|
||||
{
|
||||
public:
|
||||
enum PLAYER_PROJECTILE_MOVEMENT_TYPE
|
||||
{
|
||||
PLAYER_PROJECTILE_DUMBFIRE = 0,
|
||||
};
|
||||
|
||||
enum PLAYER_PROJECTILE_LIFETIME_TYPE
|
||||
{
|
||||
PLAYER_PROJECTILE_FINITE_LIFE = 0,
|
||||
PLAYER_PROJECTILE_INFINITE_LIFE = 1,
|
||||
};
|
||||
|
||||
void init();
|
||||
void init( DVECTOR initPos, s16 initHeading );
|
||||
void init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType );
|
||||
void init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType, s32 initLifetime );
|
||||
void shutdown();
|
||||
void think(int _frames);
|
||||
virtual void render();
|
||||
void processEvent( GAME_EVENT evt, CThing *sourceThing );
|
||||
void setMovementType( PLAYER_PROJECTILE_MOVEMENT_TYPE moveType );
|
||||
PLAYER_PROJECTILE_MOVEMENT_TYPE getMovementType();
|
||||
void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType );
|
||||
void setPosition( DVECTOR newPos );
|
||||
|
||||
protected:
|
||||
DVECTOR getScreenOffset();
|
||||
|
||||
class SpriteBank *m_spriteBank;
|
||||
DVECTOR m_initPos;
|
||||
s16 m_heading;
|
||||
s32 m_lifetime;
|
||||
s32 m_extension;
|
||||
PLAYER_PROJECTILE_MOVEMENT_TYPE m_movementType;
|
||||
PLAYER_PROJECTILE_LIFETIME_TYPE m_lifetimeType;
|
||||
u16 m_turnSpeed;
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue