From 37852c12a2de8428126d7f68d914aa75816eff57 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 3 Apr 2001 22:01:52 +0000 Subject: [PATCH] --- source/enemy/neyeball.cpp | 17 +++++++++++++++-- source/enemy/npc.cpp | 35 ++++++++++++++++++++++++++++++----- source/enemy/npc.h | 3 ++- source/enemy/npcdata.cpp | 2 +- source/game/game.cpp | 2 ++ source/projectl/projectl.cpp | 27 +++++++++++++++++++++++++++ source/projectl/projectl.h | 9 +++++++-- 7 files changed, 84 insertions(+), 11 deletions(-) diff --git a/source/enemy/neyeball.cpp b/source/enemy/neyeball.cpp index bc8982325..e69107f8c 100644 --- a/source/enemy/neyeball.cpp +++ b/source/enemy/neyeball.cpp @@ -31,6 +31,19 @@ void CNpcEnemy::processCloseEyeballAttack( int _frames ) { if ( Next ) + { + CProjectile *projectile; + + projectile = (CProjectile *) Next; + + if ( projectile->getMovementType() == CProjectile::PROJECTILE_FIXED ) + { + projectile->setMovementType( CProjectile::PROJECTILE_USER_SEEK ); + projectile->setState( CProjectile::PROJECTILE_ATTACK ); + } + } + + /*if ( Next ) { // already have child, ignore } @@ -40,8 +53,8 @@ void CNpcEnemy::processCloseEyeballAttack( int _frames ) CProjectile *projectile; projectile = new ( "test projectile" ) CProjectile; - projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_USER_SEEK, CProjectile::PROJECTILE_INFINITE_LIFE ); + projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE ); addChild( projectile ); - } + }*/ } \ No newline at end of file diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 4257ca063..3f32d8098 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -52,6 +52,10 @@ #include "system\vid.h" #endif +#ifndef __PROJECTL_PROJECTL_H__ +#include "projectl\projectl.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Friend NPCs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -274,7 +278,12 @@ void CNpcEnemy::init() setCollisionCentreOffset( 0, -( ofs.vy >> 1 ) ); m_positionHistory = NULL; +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcEnemy::postInit() +{ switch ( m_data[this->m_type].initFunc ) { case NPC_INIT_DEFAULT: @@ -426,6 +435,17 @@ void CNpcEnemy::init() break; } + case NPC_INIT_EYEBALL: + { + CProjectile *projectile; + projectile = new ( "eyeball projectile" ) CProjectile; + projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE ); + + addChild( projectile ); + + break; + } + case NPC_INIT_CIRCULAR_PLATFORM: { Pos.vx = 300; @@ -557,9 +577,9 @@ void CNpcEnemy::think(int _frames) { int frameCount = m_actorGfx->getFrameCount(m_animNo); - if ( frameCount - m_frame > _frames ) + if ( frameCount - m_frame > _frames >> 1 ) { - m_frame += _frames; + m_frame += _frames >> 1; } else { @@ -1400,9 +1420,14 @@ void CNpcEnemy::processEvent( GAME_EVENT evt, CThing *sourceThing ) m_timerTimer = GameState::getOneSecondInFrames(); m_sensorFunc = NPC_SENSOR_NONE; - removeChild( sourceThing ); - sourceThing->shutdown(); - delete sourceThing; + //removeChild( sourceThing ); + //sourceThing->shutdown(); + //delete sourceThing; + + CProjectile *projectile; + projectile = (CProjectile *) sourceThing; + projectile->setMovementType( CProjectile::PROJECTILE_FIXED ); + projectile->setPosition( Pos ); break; } diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 51497635e..38af6c94d 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -158,6 +158,7 @@ public: }; void init(); + void postInit(); void shutdown(); void think(int _frames); void render(); @@ -200,6 +201,7 @@ protected: NPC_INIT_PARASITIC_WORM, NPC_INIT_PARASITIC_WORM_SEGMENT, NPC_INIT_HERMIT_CRAB, + NPC_INIT_EYEBALL, }; enum NPC_CONTROL_FUNC @@ -554,7 +556,6 @@ protected: }; CNpcPositionHistory *m_positionHistory; - }; diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index d0cd13d37..3cb7c64ce 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -616,7 +616,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = { // NPC_EYEBALL ACTORS_EYEBALL_SBK, ANIM_EYEBALL_STALK, - NPC_INIT_DEFAULT, + NPC_INIT_EYEBALL, NPC_SENSOR_EYEBALL_USER_CLOSE, NPC_MOVEMENT_STATIC, NPC_MOVEMENT_MODIFIER_NONE, diff --git a/source/game/game.cpp b/source/game/game.cpp index 337e48729..d9a7d5d3d 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -309,6 +309,8 @@ void CGameScene::initLevel() enemy->addWaypoint( newXPos, newYPos ); } } + + enemy->postInit(); } // Song is loaded/dumped by the level, and played from here. This just gives some diff --git a/source/projectl/projectl.cpp b/source/projectl/projectl.cpp index ed891ad59..105606cba 100644 --- a/source/projectl/projectl.cpp +++ b/source/projectl/projectl.cpp @@ -190,12 +190,39 @@ bool CProjectile::processTargetSeek( int _frames, DVECTOR targetPos ) } } +void CProjectile::setMovementType( PROJECTILE_MOVEMENT_TYPE moveType ) +{ + m_movementType = moveType; +} + +CProjectile::PROJECTILE_MOVEMENT_TYPE CProjectile::getMovementType() +{ + return( m_movementType ); +} + +void CProjectile::setState( PROJECTILE_STATE newState ) +{ + m_state = newState; +} + +void CProjectile::setPosition( DVECTOR newPos ) +{ + Pos = newPos; +} + void CProjectile::think(int _frames) { CEnemyProjectileThing::think( _frames ); switch( m_movementType ) { + case PROJECTILE_FIXED: + { + // don't move at all + + break; + } + case PROJECTILE_USER_SEEK: { switch( m_state ) diff --git a/source/projectl/projectl.h b/source/projectl/projectl.h index 6284d2a89..57efd65fe 100644 --- a/source/projectl/projectl.h +++ b/source/projectl/projectl.h @@ -25,8 +25,9 @@ class CProjectile : public CEnemyProjectileThing public: enum PROJECTILE_MOVEMENT_TYPE { - PROJECTILE_DUMBFIRE = 0, - PROJECTILE_USER_SEEK = 1, + PROJECTILE_FIXED = 0, + PROJECTILE_DUMBFIRE = 1, + PROJECTILE_USER_SEEK, PROJECTILE_GAS_CLOUD, }; @@ -50,6 +51,10 @@ public: void think(int _frames); virtual void render(); void processEvent( GAME_EVENT evt, CThing *sourceThing ); + void setMovementType( PROJECTILE_MOVEMENT_TYPE moveType ); + PROJECTILE_MOVEMENT_TYPE getMovementType(); + void setState( PROJECTILE_STATE newState ); + void setPosition( DVECTOR newPos ); protected: DVECTOR getScreenOffset();