diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index fa85f0427..d8b0c0c3c 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -1696,3 +1696,15 @@ void CNpcEnemy::processCoralBlower( int _frames ) m_isBlowerOn = false; } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +CVECTOR CNpcEnemy::getRGB() +{ + CVECTOR rgb; + rgb.r = 0; + rgb.g = 0; + rgb.b = 0; + + return( rgb ); +} diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 910c1276f..0220a7960 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -110,6 +110,7 @@ public: virtual int getFrameCount(); virtual int getFrame() {return( m_frame );} void setSpeed( s16 newSpeed ) {m_speed = newSpeed;} + virtual CVECTOR getRGB(); static CNpcEnemy *Create(sThingActor *ThisActor); virtual void setupWaypoints( sThingActor *ThisActor ); diff --git a/source/enemy/nprojjf.cpp b/source/enemy/nprojjf.cpp index 047f4958c..041de0183 100644 --- a/source/enemy/nprojjf.cpp +++ b/source/enemy/nprojjf.cpp @@ -139,307 +139,3 @@ void CNpcSmallJellyfishProjectileEnemy::think(int _frames) setToShutdown(); } } - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcSmallJellyfishProjectileEnemy::render() -{ - SprFrame = NULL; - - if ( m_isActive ) - { - CEnemyThing::render(); - - if (canRender()) - { - DVECTOR &renderPos=getRenderPos(); - - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); - setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) - - // get xmax, xmin, ymax, ymin - - s32 XMax; - s32 XMin; - - s32 YMax; - s32 YMin; - - XMin=SprFrame->x0; - if (XMin>SprFrame->x1) XMin=SprFrame->x1; - if (XMin>SprFrame->x2) XMin=SprFrame->x2; - if (XMin>SprFrame->x3) XMin=SprFrame->x3; - XMax=SprFrame->x0; - if (XMaxx1) XMax=SprFrame->x1; - if (XMaxx2) XMax=SprFrame->x2; - if (XMaxx3) XMax=SprFrame->x3; - YMin=SprFrame->y0; - if (YMin>SprFrame->y1) YMin=SprFrame->y1; - if (YMin>SprFrame->y2) YMin=SprFrame->y2; - if (YMin>SprFrame->y3) YMin=SprFrame->y3; - YMax=SprFrame->y0; - if (YMaxy1) YMax=SprFrame->y1; - if (YMaxy2) YMax=SprFrame->y2; - if (YMaxy3) YMax=SprFrame->y3; - - XMax -= renderPos.vx; - XMin -= renderPos.vx; - YMax -= renderPos.vy; - YMin -= renderPos.vy; - - setCollisionSize( ( XMax - XMin ), ( YMax - YMin ) ); - setCollisionCentreOffset( ( XMax + XMin ) >> 1, ( YMax + YMin ) >> 1 ); - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcSmallJellyfishProjectileEnemy::processClose( int _frames ) -{ - s32 moveX = 0, moveY = 0; - - s16 moveDist = 0; - - s32 moveVel = 0; - - if ( playerXDistSqr + playerYDistSqr > 10000 ) - { - this->m_controlFunc = NPC_CONTROL_MOVEMENT; - } - else - { - bool pathComplete; - bool waypointChange; - s32 xDist, yDist; - - s16 headingToTarget = m_npcPath.think( Pos, &pathComplete, &waypointChange, &xDist, &yDist ); - - if ( pathComplete ) - { - this->m_controlFunc = NPC_CONTROL_MOVEMENT; - } - else - { - if ( !m_animPlaying ) - { - m_animPlaying = true; - m_animNo = m_data[m_type].moveAnim; - m_frame = 0; - } - - s16 headingToPlayer = ratan2( playerYDist, playerXDist ); - - if ( m_evadeClockwise ) - { - headingToPlayer += 1024; - } - else - { - headingToPlayer -= 1024; - } - - headingToPlayer &= 4095; - - s16 decDir, incDir; - - decDir = headingToPlayer - headingToTarget; - - if ( decDir < 0 ) - { - decDir += ONE; - } - - incDir = headingToTarget - headingToPlayer; - - if ( incDir < 0 ) - { - incDir += ONE; - } - - if ( decDir < incDir ) - { - moveDist = decDir; - } - else - { - moveDist = incDir; - } - - if ( moveDist < 128 ) - { - // evasion angle is close to angle required to go to waypoint, hence resume waypoint movement - - this->m_controlFunc = NPC_CONTROL_MOVEMENT; - this->m_timerFunc = NPC_TIMER_EVADE_DONE; - this->m_timerTimer = GameState::getOneSecondInFrames(); - this->m_sensorFunc = NPC_SENSOR_NONE; - } - else - { - decDir = m_heading - headingToPlayer; - - if ( decDir < 0 ) - { - decDir += ONE; - } - - incDir = headingToPlayer - m_heading; - - if ( incDir < 0 ) - { - incDir += ONE; - } - - if ( decDir < incDir ) - { - moveDist = -decDir; - } - else - { - moveDist = incDir; - } - - if ( moveDist < -128 ) - { - moveDist = -128; - } - else if ( moveDist > 128 ) - { - moveDist = 128; - } - - m_heading += moveDist; - - m_heading &= 4095; - - moveX = ( _frames * 3 * rcos( m_heading ) ) >> 12; - moveY = ( _frames * 3 * rsin( m_heading ) ) >> 12; - moveVel = ( _frames * 3 ) << 8; - - if ( processGroundCollisionReverse( &moveX, &moveY ) ) - { - m_evadeClockwise = !m_evadeClockwise; - } - - processMovementModifier(_frames, moveX, moveY, moveVel, moveDist); - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -bool CNpcSmallJellyfishProjectileEnemy::processSensor() -{ - switch( m_sensorFunc ) - { - case NPC_SENSOR_NONE: - return( false ); - - default: - { - if ( playerXDistSqr + playerYDistSqr < 5625 ) - { - m_controlFunc = NPC_CONTROL_CLOSE; - m_evadeClockwise = getRnd() % 2; - - return( true ); - } - else - { - return( false ); - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcSmallJellyfishProjectileEnemy::processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ) -{ - s32 newX, newY; - s32 preShiftX, preShiftY; - s16 headingVal; - - //u16 jellyfishData[5] = { 96, 192, 256, 192, 128, }; - u16 jellyfishData[6] = { 256, 256, 96, 48, 96, 256, }; - - u32 dataPoint; - - m_movementTimer += _frames; - - if ( m_movementTimer > ( GameState::getOneSecondInFrames() >> 1 ) ) - { - m_movementTimer = 0; - } - - dataPoint = 5 * m_movementTimer; - - if ( dataPoint != 0 ) - { - dataPoint /= ( GameState::getOneSecondInFrames() >> 1 ); - } - - m_frame = ( ( m_movementTimer * ( getFrameCount() - 1 ) << 8 ) ) / GameState::getOneSecondInFrames(); - - s32 resistance; - s32 absVelocity = abs( m_velocity ); - s32 reqVelocity = dist; - - resistance = _frames * NPC_JELLYFISH_RESISTANCE; - - if ( absVelocity < resistance ) - { - resistance = absVelocity; - } - - if ( absVelocity != 0 ) - { - resistance = -( resistance * m_velocity ) / absVelocity; - } - else - { - resistance = 0; - } - - m_velocity += resistance; - - headingVal = abs( headingChange ); - if ( headingVal > 128 ) - { - headingVal = 128; - } - - reqVelocity = dist * jellyfishData[dataPoint]; - reqVelocity >>= 8; - reqVelocity *= 128 + ( 128 - headingVal ); - reqVelocity >>= 8; - - s32 absReqVelocity = abs( reqVelocity ); - - if ( absReqVelocity > absVelocity ) - { - m_velocity += reqVelocity >> 1; - } - - preShiftX = ( m_velocity >> 8 ) * rcos( m_heading ); - preShiftY = ( m_velocity >> 8 ) * rsin( m_heading ); - - newX = preShiftX >> 12; - if ( !newX && preShiftX ) - { - newX = preShiftX / abs( preShiftX ); - } - - newY = preShiftY >> 12; - if ( !newY && preShiftY ) - { - newY = preShiftY / abs( preShiftY ); - } - - Pos.vx += newX; - Pos.vy += newY; - - m_drawRotation = m_heading; -} diff --git a/source/enemy/nprojjf.h b/source/enemy/nprojjf.h index 7bc3b5c1b..2eb1b85d4 100644 --- a/source/enemy/nprojjf.h +++ b/source/enemy/nprojjf.h @@ -14,34 +14,21 @@ #ifndef __ENEMY_NPROJJF_H__ #define __ENEMY_NPROJJF_H__ -#ifndef __ENEMY_NPC_H__ -#include "enemy\npc.h" +#ifndef __ENEMY_NSJFISH_H__ +#include "enemy\nsjfish.h" #endif #ifndef __SPR_SPRITES_H__ #include #endif -class CNpcSmallJellyfishProjectileEnemy : public CNpcEnemy +class CNpcSmallJellyfishProjectileEnemy : public CNpcSmallJellyfishEnemy { public: - void render(); - virtual int getFrameCount() {return( FRM_JELLYFISH1_SWIM6 - FRM_JELLYFISH1_SWIM1 + 1 );} - virtual u8 canCollideWithEnemy() {return( false );} virtual void postInit(); virtual void think(int _frames); protected: - virtual bool processSensor(); - virtual void processClose( int _frames ); - virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); - - enum - { - NPC_JELLYFISH_RESISTANCE = 64, - }; - s32 m_lifetime; - bool m_evadeClockwise; }; #endif diff --git a/source/enemy/nsj2back.cpp b/source/enemy/nsj2back.cpp index ece319c8f..ce42d78ac 100644 --- a/source/enemy/nsj2back.cpp +++ b/source/enemy/nsj2back.cpp @@ -141,3 +141,16 @@ void CNpcSmallJellyfish2BackgroundEnemy::collidedWith( CThing *_thisThing ) } } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +CVECTOR CNpcSmallJellyfish2BackgroundEnemy::getRGB() +{ + CVECTOR rgb; + + rgb.r = 128; + rgb.g = 128; + rgb.b = 255; + + return( rgb ); +} diff --git a/source/enemy/nsj2back.h b/source/enemy/nsj2back.h index eb9300be7..4167ac924 100644 --- a/source/enemy/nsj2back.h +++ b/source/enemy/nsj2back.h @@ -22,6 +22,7 @@ class CNpcSmallJellyfish2BackgroundEnemy : public CNpcSmallJellyfishBackgroundEn { public: virtual void render(); + virtual CVECTOR getRGB(); protected: virtual void collidedWith(CThing *_thisThing); }; diff --git a/source/enemy/nsjfish.cpp b/source/enemy/nsjfish.cpp index 2e9729c9a..7b75b62ac 100644 --- a/source/enemy/nsjfish.cpp +++ b/source/enemy/nsjfish.cpp @@ -375,4 +375,17 @@ void CNpcSmallJellyfishEnemy::fireAsProjectile( s16 heading ) projectile->setGraphic( FRM_JELLYFISH1_SWIM1 ); projectile->setHasRGB( true ); projectile->setRGB( 255, 128, 255 ); -} \ No newline at end of file +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +CVECTOR CNpcSmallJellyfishEnemy::getRGB() +{ + CVECTOR rgb; + + rgb.r = 255; + rgb.g = 128; + rgb.b = 255; + + return( rgb ); +} diff --git a/source/enemy/nsjfish.h b/source/enemy/nsjfish.h index e84961dbc..a45b40d5e 100644 --- a/source/enemy/nsjfish.h +++ b/source/enemy/nsjfish.h @@ -28,6 +28,7 @@ public: virtual void render(); virtual int getFrameCount() {return( FRM_JELLYFISH1_SWIM7 - FRM_JELLYFISH1_SWIM1 + 1 );} virtual u8 canCollideWithEnemy() {return( false );} + virtual CVECTOR getRGB(); protected: virtual bool processSensor(); virtual void processClose( int _frames ); diff --git a/source/hazard/hbbarrel.cpp b/source/hazard/hbbarrel.cpp index 4177063b0..6ca9f5d75 100644 --- a/source/hazard/hbbarrel.cpp +++ b/source/hazard/hbbarrel.cpp @@ -159,3 +159,18 @@ void CNpcBouncingBarrelHazard::render() m_modelGfx->Render(renderPos,&rotation,&scale); } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +const CRECT *CNpcBouncingBarrelHazard::getThinkBBox() +{ + CRECT objThinkBox = getCollisionArea(); + + sBBox &thinkBBox = CThingManager::getThinkBBox(); + objThinkBox.x1 = thinkBBox.XMin; + objThinkBox.x2 = thinkBBox.XMax; + objThinkBox.y1 = thinkBBox.YMin; + objThinkBox.y2 = thinkBBox.YMax; + + return &objThinkBox; +} \ No newline at end of file diff --git a/source/hazard/hbbarrel.h b/source/hazard/hbbarrel.h index 62e2d7c91..10a62b7be 100644 --- a/source/hazard/hbbarrel.h +++ b/source/hazard/hbbarrel.h @@ -23,6 +23,7 @@ class CNpcBouncingBarrelHazard : public CNpcHazard public: void init(); void render(); + virtual CRECT const *getThinkBBox(); protected: void processMovement( int _frames ); diff --git a/source/player/pmnet.cpp b/source/player/pmnet.cpp index 7c490262d..de588c782 100644 --- a/source/player/pmnet.cpp +++ b/source/player/pmnet.cpp @@ -193,6 +193,7 @@ void CPlayerModeNet::think() if(((CNpcEnemy*)thing)->canBeCaughtByNet()) { ((CNpcEnemy*)thing)->caughtWithNet(); + m_RGB = ((CNpcEnemy*)thing)->getRGB(); m_netState=NET_STATE__JUST_CAUGHT_SOMETHING; thing=NULL; if(m_player->getJellyFishAmmo()==0) @@ -238,6 +239,7 @@ void CPlayerModeNet::think() 5*60); projectile->setLayerCollision( m_player->getLayerCollision() ); projectile->updateCollisionArea(); + projectile->setRGB( m_RGB ); m_netState=NET_STATE__JUST_LAUNCHED_SOMETHING; m_player->useOneJellyFishAmmo(); diff --git a/source/player/pmnet.h b/source/player/pmnet.h index 44204375f..deef28409 100644 --- a/source/player/pmnet.h +++ b/source/player/pmnet.h @@ -60,6 +60,7 @@ private: int m_netFrame; NetState m_netState; int m_netSin; + CVECTOR m_RGB; }; diff --git a/source/projectl/projectl.cpp b/source/projectl/projectl.cpp index 31cc970b0..5746de3b1 100644 --- a/source/projectl/projectl.cpp +++ b/source/projectl/projectl.cpp @@ -428,6 +428,10 @@ void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading ) { m_reversed = 1; } + + m_RGB.r = 0; + m_RGB.g = 0; + m_RGB.b = 0; } void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType ) @@ -554,7 +558,7 @@ void CPlayerProjectile::render() } SprFrame = m_spriteBank->printFT4(FRM_JELLYFISH1_SWIM1 + m_frame,x,y,m_reversed,0,10); - setRGB0( SprFrame, 255, 128, 255 ); + setRGB0( SprFrame, m_RGB.r, m_RGB.g, m_RGB.b ); } DVECTOR CPlayerProjectile::getScreenOffset() diff --git a/source/projectl/projectl.h b/source/projectl/projectl.h index 8dc07e5d6..995912d79 100644 --- a/source/projectl/projectl.h +++ b/source/projectl/projectl.h @@ -112,6 +112,7 @@ public: void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType ); void setPosition( DVECTOR newPos ); void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} + void setRGB( CVECTOR new_RGB ) {m_RGB = new_RGB;} private: class CLayerCollision *m_layerCollision; @@ -131,6 +132,7 @@ protected: int m_frame; POLY_FT4 *SprFrame; u8 m_reversed; + CVECTOR m_RGB; };