Added speed modifier to scanners and rollermines

This commit is contained in:
Blixibon 2021-09-28 12:09:29 -05:00
parent a1bc5196f2
commit 6d04c46dc0
3 changed files with 46 additions and 8 deletions

View File

@ -1278,6 +1278,14 @@ void CNPC_BaseScanner::MoveToTarget( float flInterval, const Vector &vecMoveTarg
myZAccel = flDist / flInterval;
}
#ifdef MAPBASE
if (m_flSpeedModifier != 1.0f)
{
myAccel *= m_flSpeedModifier;
//myZAccel *= m_flSpeedModifier;
}
#endif
MoveInDirection( flInterval, targetDir, myAccel, myZAccel, myDecay );
// calc relative banking targets

View File

@ -310,6 +310,16 @@ protected:
bool IsActive() { return m_flActiveTime > gpGlobals->curtime ? false : true; }
inline float GetForwardSpeed() const
{
#ifdef MAPBASE
if (m_flSpeedModifier != 1.0f)
return m_flForwardSpeed * m_flSpeedModifier;
else
#endif
return m_flForwardSpeed;
}
// INPCInteractive Functions
virtual bool CanInteractWith( CAI_BaseNPC *pUser ) { return true; }
virtual bool HasBeenInteractedWith() { return m_bHackedByAlyx; }
@ -1313,7 +1323,7 @@ void CNPC_RollerMine::RunTask( const Task_t *pTask )
Vector vecRight;
AngleVectors( QAngle( 0, yaw, 0 ), NULL, &vecRight, NULL );
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, -m_flForwardSpeed * 5 );
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, -GetForwardSpeed() * 5 );
TaskComplete();
return;
@ -1323,6 +1333,8 @@ void CNPC_RollerMine::RunTask( const Task_t *pTask )
}
{
float flForwardSpeed = GetForwardSpeed();
float yaw = UTIL_VecToYaw( GetNavigator()->GetCurWaypointPos() - GetLocalOrigin() );
Vector vecRight;
@ -1362,17 +1374,17 @@ void CNPC_RollerMine::RunTask( const Task_t *pTask )
vecCompensate.y = -vecVelocity.x;
vecCompensate.z = 0;
m_RollerController.m_vecAngular = WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecCompensate, m_flForwardSpeed * -0.75 );
m_RollerController.m_vecAngular = WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecCompensate, flForwardSpeed * -0.75 );
}
if( m_bHackedByAlyx )
{
// Move faster.
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, m_flForwardSpeed * 2.0f );
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, flForwardSpeed * 2.0f );
}
else
{
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, m_flForwardSpeed );
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, flForwardSpeed );
}
}
break;
@ -1496,8 +1508,10 @@ void CNPC_RollerMine::RunTask( const Task_t *pTask )
vecCompensate.z = 0;
VectorNormalize( vecCompensate );
m_RollerController.m_vecAngular = WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecCompensate, m_flForwardSpeed * -0.75 );
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, m_flForwardSpeed * flTorqueFactor );
float flForwardSpeed = GetForwardSpeed();
m_RollerController.m_vecAngular = WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecCompensate, flForwardSpeed * -0.75 );
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, flForwardSpeed * flTorqueFactor );
// Taunt when I get closer
if( !(m_iSoundEventFlags & ROLLERMINE_SE_TAUNT) && UTIL_DistApprox( GetLocalOrigin(), vecTargetPosition ) <= 400 )
@ -1615,8 +1629,10 @@ void CNPC_RollerMine::RunTask( const Task_t *pTask )
vecCompensate.z = 0;
VectorNormalize( vecCompensate );
m_RollerController.m_vecAngular = WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecCompensate, m_flForwardSpeed * -0.75 );
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, m_flForwardSpeed * flTorqueFactor );
float flForwardSpeed = GetForwardSpeed();
m_RollerController.m_vecAngular = WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecCompensate, flForwardSpeed * -0.75 );
m_RollerController.m_vecAngular += WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, flForwardSpeed * flTorqueFactor );
// Once we're near the player, slow & stop
if ( GetAbsOrigin().DistToSqr( vecTargetPosition ) < (ROLLERMINE_RETURN_TO_PLAYER_DIST*2.0) )
@ -2572,6 +2588,12 @@ float CNPC_RollerMine::RollingSpeed()
float rollingSpeed = angVel.Length() - 90;
rollingSpeed = clamp( rollingSpeed, 1, MAX_ROLLING_SPEED );
rollingSpeed *= (1/MAX_ROLLING_SPEED);
#ifdef MAPBASE
if (m_flSpeedModifier != 1.0f)
{
rollingSpeed *= m_flSpeedModifier;
}
#endif
return rollingSpeed;
}
return 0;

View File

@ -2567,6 +2567,14 @@ void CNPC_CScanner::MoveToTarget( float flInterval, const Vector &vecMoveTarget
myZAccel = flDist / flInterval;
}
#ifdef MAPBASE
if (m_flSpeedModifier != 1.0f)
{
myAccel *= m_flSpeedModifier;
//myZAccel *= m_flSpeedModifier;
}
#endif
MoveInDirection( flInterval, targetDir, myAccel, myZAccel, myDecay );
// calc relative banking targets