From 4c64c9ed4edb92b91865abc69e9e5c630bc2c1a3 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 9 May 2001 21:27:23 +0000 Subject: [PATCH] --- source/enemy/nbblob.cpp | 4 ++-- source/enemy/ndogfish.cpp | 4 ++-- source/enemy/ndustdev.cpp | 4 ++-- source/enemy/nfdutch.cpp | 8 ++++---- source/enemy/nfskull.cpp | 4 ++-- source/enemy/ngeneric.cpp | 10 +++++----- source/enemy/nmjfish.cpp | 4 ++-- source/enemy/npc.cpp | 5 +++-- source/enemy/npc.h | 2 ++ source/enemy/nsshark.cpp | 6 +++--- source/level/level.cpp | 10 ++++++++++ source/platform/pbubble.cpp | 2 +- source/platform/pbwheel.cpp | 2 +- source/platform/pcart.cpp | 2 +- source/platform/pcirculr.cpp | 2 +- source/platform/pfalling.cpp | 2 +- source/platform/pfallnor.cpp | 2 +- source/platform/pfishhk.cpp | 2 +- source/platform/pgeyser.cpp | 4 ++-- source/platform/platform.cpp | 2 ++ source/platform/platform.h | 3 +++ source/platform/pleaf.cpp | 2 +- source/platform/plinear.cpp | 4 ++-- source/platform/praft.cpp | 4 ++-- source/platform/psbarrel.cpp | 4 ++-- 25 files changed, 58 insertions(+), 40 deletions(-) diff --git a/source/enemy/nbblob.cpp b/source/enemy/nbblob.cpp index 5f03d44dc..205995f1b 100644 --- a/source/enemy/nbblob.cpp +++ b/source/enemy/nbblob.cpp @@ -115,11 +115,11 @@ void CNpcBallBlobEnemy::processMovement( int _frames ) if ( waypointHeading == 0 ) { - moveX = m_data[m_type].speed * _frames; + moveX = m_speed * _frames; } else { - moveX = -m_data[m_type].speed * _frames; + moveX = -m_speed * _frames; } processMovementModifier( _frames, moveX, moveY, moveVel, moveDist ); diff --git a/source/enemy/ndogfish.cpp b/source/enemy/ndogfish.cpp index ed92e36b4..e062d1cec 100644 --- a/source/enemy/ndogfish.cpp +++ b/source/enemy/ndogfish.cpp @@ -174,7 +174,7 @@ void CNpcIronDogfishEnemy::processStandardIronDogfishAttack( int _frames ) m_frame = 0; } - processWalkToUser( _frames, m_data[m_type].speed ); + processWalkToUser( _frames, m_speed ); } else { @@ -235,7 +235,7 @@ void CNpcIronDogfishEnemy::processStandardIronDogfishAttack( int _frames ) m_frame = 0; } - processWalkToUser( _frames, m_data[m_type].speed ); + processWalkToUser( _frames, m_speed ); } else { diff --git a/source/enemy/ndustdev.cpp b/source/enemy/ndustdev.cpp index cbf40c4d1..5306197fd 100644 --- a/source/enemy/ndustdev.cpp +++ b/source/enemy/ndustdev.cpp @@ -91,7 +91,7 @@ void CNpcDustDevilEnemy::processMovement( int _frames ) distX = distX / abs( distX ); - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_data[m_type].speed * _frames ), Pos.vy ) < -maxHeight ) + if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -107,7 +107,7 @@ void CNpcDustDevilEnemy::processMovement( int _frames ) { // groundHeight <= yMovement indicates either just above ground or on or below ground - moveX = distX * m_data[m_type].speed * _frames; + moveX = distX * m_speed * _frames; moveY = groundHeight; } else diff --git a/source/enemy/nfdutch.cpp b/source/enemy/nfdutch.cpp index 2acea7216..b5b374709 100644 --- a/source/enemy/nfdutch.cpp +++ b/source/enemy/nfdutch.cpp @@ -65,7 +65,7 @@ void CNpcFlyingDutchmanEnemy::processMovement( int _frames ) if ( xDistSqr > 100 ) { - processGenericGotoTarget( _frames, xDist, 0, m_data[m_type].speed ); + processGenericGotoTarget( _frames, xDist, 0, m_speed ); } else { @@ -76,7 +76,7 @@ void CNpcFlyingDutchmanEnemy::processMovement( int _frames ) if ( yDistSqr > 100 ) { - processGenericGotoTarget( _frames, 0, yDist, m_data[m_type].speed ); + processGenericGotoTarget( _frames, 0, yDist, m_speed ); } else { @@ -90,7 +90,7 @@ void CNpcFlyingDutchmanEnemy::processMovement( int _frames ) if ( yDistSqr > 100 ) { - processGenericGotoTarget( _frames, 0, yDist, m_data[m_type].speed ); + processGenericGotoTarget( _frames, 0, yDist, m_speed ); } else { @@ -134,7 +134,7 @@ void CNpcFlyingDutchmanEnemy::processClose( int _frames ) m_frame = 0; } - processGenericGotoTarget( _frames, 0, playerYDist, m_data[m_type].speed ); + processGenericGotoTarget( _frames, 0, playerYDist, m_speed ); } else { diff --git a/source/enemy/nfskull.cpp b/source/enemy/nfskull.cpp index d04f57d73..c25c0027b 100644 --- a/source/enemy/nfskull.cpp +++ b/source/enemy/nfskull.cpp @@ -79,7 +79,7 @@ void CNpcFlamingSkullEnemy::processClose( int _frames ) } else { - processGenericGotoTarget( _frames, distX, distY, m_data[m_type].speed ); + processGenericGotoTarget( _frames, distX, distY, m_speed ); } } else @@ -102,7 +102,7 @@ void CNpcFlamingSkullEnemy::processClose( int _frames ) } else { - processGenericGotoTarget( _frames, distX, distY, m_data[m_type].speed ); + processGenericGotoTarget( _frames, distX, distY, m_speed ); } } } \ No newline at end of file diff --git a/source/enemy/ngeneric.cpp b/source/enemy/ngeneric.cpp index 78c77b1dd..429aa393f 100644 --- a/source/enemy/ngeneric.cpp +++ b/source/enemy/ngeneric.cpp @@ -245,8 +245,8 @@ void CNpcEnemy::processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY m_heading += *moveDist; m_heading &= 4095; - s32 preShiftX = _frames * m_data[m_type].speed * rcos( m_heading ); - s32 preShiftY = _frames * m_data[m_type].speed * rsin( m_heading ); + s32 preShiftX = _frames * m_speed * rcos( m_heading ); + s32 preShiftY = _frames * m_speed * rsin( m_heading ); *moveX = preShiftX >> 12; if ( !(*moveX) && preShiftX ) @@ -298,7 +298,7 @@ void CNpcEnemy::processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY *moveY = 0; } - *moveVel = ( _frames * m_data[m_type].speed ) << 8; + *moveVel = ( _frames * m_speed ) << 8; //processGroundCollisionReverse( moveX, moveY ); } @@ -346,7 +346,7 @@ void CNpcEnemy::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY distX = distX / abs( distX ); - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_data[m_type].speed * _frames ), Pos.vy ) < -maxHeight ) + if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -362,7 +362,7 @@ void CNpcEnemy::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY { // groundHeight <= yMovement indicates either just above ground or on or below ground - *moveX = distX * m_data[m_type].speed * _frames; + *moveX = distX * m_speed * _frames; *moveY = groundHeight; } else diff --git a/source/enemy/nmjfish.cpp b/source/enemy/nmjfish.cpp index c15128d3b..b8c4581c5 100644 --- a/source/enemy/nmjfish.cpp +++ b/source/enemy/nmjfish.cpp @@ -79,7 +79,7 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames ) if ( xDistSqr + yDistSqr > 100 ) { - processGenericGotoTarget( _frames, xDist, yDist, m_data[m_type].speed ); + processGenericGotoTarget( _frames, xDist, yDist, m_speed ); } else { @@ -187,7 +187,7 @@ void CNpcMotherJellyfishEnemy::processClose( int _frames ) if ( xDistSqr + yDistSqr > 400 ) { - processGenericGotoTarget( _frames, xDist, yDist, m_data[m_type].speed ); + processGenericGotoTarget( _frames, xDist, yDist, m_speed ); } else { diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index af5c2c7e3..2e5df9084 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -636,6 +636,7 @@ void CNpcEnemy::init() m_drawRotation = 0; m_isCaught = false; m_isBlowerOn = false; + m_speed = m_data[m_type].speed; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -942,7 +943,7 @@ bool CNpcEnemy::processSensor() if ( playerXDistSqr + playerYDistSqr < 10000 ) { m_controlFunc = NPC_CONTROL_CLOSE; - m_velocity = m_data[m_type].speed; + m_velocity = m_speed; return( true ); } @@ -1241,7 +1242,7 @@ void CNpcEnemy::processClose(int _frames) { case NPC_CLOSE_GENERIC_USER_SEEK: { - processGenericGotoTarget( _frames, playerXDist, playerYDist, m_data[m_type].speed ); + processGenericGotoTarget( _frames, playerXDist, playerYDist, m_speed ); break; } diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 919b8da89..ee964ed55 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -105,6 +105,7 @@ public: bool canBeCaughtByNet(); void caughtWithNet(); virtual int getFrameCount(); + void setSpeed( s16 newSpeed ) {m_speed = newSpeed;} static CNpcEnemy *Create(sThingActor *ThisActor); void setupWaypoints( sThingActor *ThisActor ); @@ -294,6 +295,7 @@ protected: u8 m_isCaught; u8 m_isBlowerOn; DVECTOR m_caughtPos; + s16 m_speed; s32 m_frame; int m_animNo; diff --git a/source/enemy/nsshark.cpp b/source/enemy/nsshark.cpp index 7cd03bb84..ef9859d3e 100644 --- a/source/enemy/nsshark.cpp +++ b/source/enemy/nsshark.cpp @@ -117,7 +117,7 @@ void CNpcSubSharkEnemy::processMovement( int _frames ) if ( ( xDistSqr + yDistSqr ) > 100 ) { - processGenericGotoTarget( _frames, xDist, yDist, m_data[m_type].speed ); + processGenericGotoTarget( _frames, xDist, yDist, m_speed ); } else { @@ -138,7 +138,7 @@ void CNpcSubSharkEnemy::processMovement( int _frames ) if ( ( xDistSqr + yDistSqr ) > 100 ) { - processGenericGotoTarget( _frames, xDist, yDist, m_data[m_type].speed ); + processGenericGotoTarget( _frames, xDist, yDist, m_speed ); } else { @@ -178,7 +178,7 @@ void CNpcSubSharkEnemy::processClose( int _frames ) m_frame = 0; } - processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed ); + processGenericGotoTarget( _frames, playerXDist, 0, m_speed ); if ( playerXDistSqr < 100 ) { diff --git a/source/level/level.cpp b/source/level/level.cpp index e20c31135..da1f386c0 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -473,6 +473,11 @@ void CLevel::initThings(int _respawningLevel) enemy->setLayerCollision( getCollisionLayer() ); enemy->setupWaypoints( ThisActor ); enemy->postInit(); + + if ( ThisActor->Speed ) + { + enemy->setSpeed( ThisActor->Speed ); + } } break; @@ -501,6 +506,11 @@ void CLevel::initThings(int _respawningLevel) platform = CNpcPlatform::Create( ThisPlatform ); platform->setLayerCollision( getCollisionLayer() ); platform->postInit(); + + if ( ThisPlatform->Speed ) + { + platform->setSpeed( ThisPlatform->Speed ); + } } } diff --git a/source/platform/pbubble.cpp b/source/platform/pbubble.cpp index 0f98934d9..762c477d5 100644 --- a/source/platform/pbubble.cpp +++ b/source/platform/pbubble.cpp @@ -19,7 +19,7 @@ void CNpcBubblePlatform::processMovement( int _frames ) { - Pos.vy -= m_data[m_type].speed * _frames; + Pos.vy -= m_speed * _frames; if ( Pos.vy < 0 ) { diff --git a/source/platform/pbwheel.cpp b/source/platform/pbwheel.cpp index 721638852..a797c35bc 100644 --- a/source/platform/pbwheel.cpp +++ b/source/platform/pbwheel.cpp @@ -24,7 +24,7 @@ void CNpcBigWheelPlatform::processMovement( int _frames ) { - m_rotation += m_data[m_type].speed * _frames; + m_rotation += m_speed * _frames; m_rotation &= 4095; Pos.vx = m_base.vx + ( ( m_extension * rcos( m_rotation ) ) >> 12 ); diff --git a/source/platform/pcart.cpp b/source/platform/pcart.cpp index 3c906df3f..239504a1c 100644 --- a/source/platform/pcart.cpp +++ b/source/platform/pcart.cpp @@ -35,7 +35,7 @@ void CNpcCartPlatform::postInit() m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH ); - m_carSpeed = m_data[m_type].speed << 8; + m_carSpeed = m_speed << 8; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/platform/pcirculr.cpp b/source/platform/pcirculr.cpp index a6732f779..4434e0a00 100644 --- a/source/platform/pcirculr.cpp +++ b/source/platform/pcirculr.cpp @@ -28,7 +28,7 @@ void CNpcCircularPlatform::postInit() void CNpcCircularPlatform::processMovement( int _frames ) { - m_rotation += m_data[m_type].speed; + m_rotation += m_speed; m_rotation &= 4095; Pos.vx = m_base.vx + ( ( m_extension * rcos( m_rotation ) ) >> 12 ); diff --git a/source/platform/pfalling.cpp b/source/platform/pfalling.cpp index 881465aa7..2a85e349f 100644 --- a/source/platform/pfalling.cpp +++ b/source/platform/pfalling.cpp @@ -55,7 +55,7 @@ void CNpcFallingPlatform::processMovement( int _frames ) else { moveX = 0; - moveY = m_data[m_type].speed * _frames; + moveY = m_speed * _frames; if ( heading == 3072 ) { diff --git a/source/platform/pfallnor.cpp b/source/platform/pfallnor.cpp index d6da99b68..888f68ee8 100644 --- a/source/platform/pfallnor.cpp +++ b/source/platform/pfallnor.cpp @@ -49,7 +49,7 @@ void CNpcFallingNoRespawnPlatform::processMovement( int _frames ) else { moveX = 0; - moveY = m_data[m_type].speed * _frames; + moveY = m_speed * _frames; if ( heading == 3072 ) { diff --git a/source/platform/pfishhk.cpp b/source/platform/pfishhk.cpp index a65bf612d..6cdaa2e87 100644 --- a/source/platform/pfishhk.cpp +++ b/source/platform/pfishhk.cpp @@ -59,7 +59,7 @@ void CNpcFishHookPlatform::processMovement( int _frames ) { if ( m_isMoving ) { - Pos.vy -= m_data[m_type].speed * _frames; + Pos.vy -= m_speed * _frames; if ( Pos.vy < 0 ) { diff --git a/source/platform/pgeyser.cpp b/source/platform/pgeyser.cpp index af7510216..7deef0481 100644 --- a/source/platform/pgeyser.cpp +++ b/source/platform/pgeyser.cpp @@ -52,7 +52,7 @@ void CNpcGeyserPlatform::processMovement( int _frames ) } else { - s32 moveY = m_data[m_type].speed * _frames; + s32 moveY = m_speed * _frames; if ( Pos.vy < ( minY + 64 ) ) { @@ -86,7 +86,7 @@ void CNpcGeyserPlatform::processMovement( int _frames ) } else { - s32 moveY = m_data[m_type].speed * _frames; + s32 moveY = m_speed * _frames; if ( Pos.vy < ( minY + 64 ) ) { diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index d49b34a46..5db2bc267 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -428,6 +428,8 @@ void CNpcPlatform::init() m_isShuttingDown = false; m_npcPath.initPath(); + + m_speed = m_data[m_type].speed; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/platform/platform.h b/source/platform/platform.h index a64605f32..c4f668a84 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -112,6 +112,8 @@ public: void setToShutdown(); u8 isSetToShutdown() {return( m_isShuttingDown );} + void setSpeed( s16 newSpeed ) {m_speed = newSpeed;} + protected: // NPC data structure definitions // @@ -202,6 +204,7 @@ protected: s32 m_tiltAngle; s32 m_tiltVelocity; bool m_extendDir; + s16 m_speed; CModelGfx *m_modelGfx; u8 m_isShuttingDown; diff --git a/source/platform/pleaf.cpp b/source/platform/pleaf.cpp index 3638f108d..3b63e3828 100644 --- a/source/platform/pleaf.cpp +++ b/source/platform/pleaf.cpp @@ -59,7 +59,7 @@ void CNpcLeafPlatform::processMovement( int _frames ) else { moveX = 0; - moveY = m_data[m_type].speed * _frames; + moveY = m_speed * _frames; if ( heading == 3072 ) { diff --git a/source/platform/plinear.cpp b/source/platform/plinear.cpp index 45dc04bbe..97a2aff16 100644 --- a/source/platform/plinear.cpp +++ b/source/platform/plinear.cpp @@ -77,8 +77,8 @@ void CNpcLinearPlatform::processMovement( int _frames ) m_heading += moveDist; m_heading &= 4095; - s32 preShiftX = _frames * m_data[m_type].speed * rcos( m_heading ); - s32 preShiftY = _frames * m_data[m_type].speed * rsin( m_heading ); + s32 preShiftX = _frames * m_speed * rcos( m_heading ); + s32 preShiftY = _frames * m_speed * rsin( m_heading ); moveX = preShiftX >> 12; if ( !moveX && preShiftX ) diff --git a/source/platform/praft.cpp b/source/platform/praft.cpp index 73fc52f21..4317f6c48 100644 --- a/source/platform/praft.cpp +++ b/source/platform/praft.cpp @@ -89,7 +89,7 @@ void CNpcRaftPlatform::processMovement( int _frames ) distX = distX / abs( distX ); - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_data[m_type].speed * _frames ), Pos.vy ) < -maxHeight ) + if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -105,7 +105,7 @@ void CNpcRaftPlatform::processMovement( int _frames ) { // groundHeight <= yMovement indicates either just above ground or on or below ground - moveX = distX * m_data[m_type].speed * _frames; + moveX = distX * m_speed * _frames; moveY = groundHeight; } else diff --git a/source/platform/psbarrel.cpp b/source/platform/psbarrel.cpp index 22abc2c8a..6e6c7b522 100644 --- a/source/platform/psbarrel.cpp +++ b/source/platform/psbarrel.cpp @@ -63,11 +63,11 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) { // roll barrel right - moveX = m_data[m_type].speed * _frames; + moveX = m_speed * _frames; } else if ( playerX < -5 ) { - moveX = -m_data[m_type].speed * _frames; + moveX = -m_speed * _frames; } // check for collision