large flying NPCs now teleport when You Teleport? is on

This commit is contained in:
Pinsplash 2024-03-07 03:29:22 -06:00
parent 83176a19b1
commit 8c86d79fa0
4 changed files with 27 additions and 6 deletions

1
.gitignore vendored
View File

@ -24,6 +24,7 @@ ipch
*.codeanalysis *.codeanalysis
*.codeanalysisast *.codeanalysisast
*.nativecodeanalysis.all.xml *.nativecodeanalysis.all.xml
*.pchast
# OSX/Linux build products # OSX/Linux build products
*.mak *.mak

View File

@ -16,6 +16,7 @@
#define TRACKPATHER_DEBUG_PATH 2 #define TRACKPATHER_DEBUG_PATH 2
#define TRACKPATHER_DEBUG_TRACKS 3 #define TRACKPATHER_DEBUG_TRACKS 3
ConVar g_debug_trackpather("g_debug_trackpather", "0", FCVAR_NONE); ConVar g_debug_trackpather("g_debug_trackpather", "0", FCVAR_NONE);
extern ConVar chaos_npc_teleport;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -1393,6 +1394,13 @@ void CAI_TrackPather::UpdateTrackNavigation( void )
FlyToPathTrack( m_target ); FlyToPathTrack( m_target );
m_target = NULL_STRING; m_target = NULL_STRING;
} }
Vector targetPos;
if (chaos_npc_teleport.GetBool() && GetTrackPatherTarget(&targetPos))
{
CPathTrack *pDest = BestPointOnPath(m_pCurrentPathTarget, targetPos, m_flAvoidDistance, true, m_bChooseFarthestPoint);
if (pDest)
Teleport(&pDest->GetAbsOrigin(), NULL, NULL);
}
if ( !IsLeading() ) if ( !IsLeading() )
{ {

View File

@ -26,6 +26,7 @@ class CAI_TrackPather : public CAI_BaseNPC
public: public:
bool IsOnPathTrack() { return (m_pCurrentPathTarget != NULL); } bool IsOnPathTrack() { return (m_pCurrentPathTarget != NULL); }
CPathTrack * CurrentPathTrack() { return m_pCurrentPathTarget; }
protected: protected:
void InitPathingData( float flTrackArrivalTolerance, float flTargetDistance, float flAvoidDistance ); void InitPathingData( float flTrackArrivalTolerance, float flTargetDistance, float flAvoidDistance );
@ -153,9 +154,12 @@ protected:
// Deal with teleportation // Deal with teleportation
void Teleported(); void Teleported();
private: CPathTrack *BestPointOnPath(CPathTrack *pPath, const Vector &targetPos, float avoidRadius, bool visible, bool bFarthestPointOnPath);
CHandle<CPathTrack> m_pCurrentPathTarget;
float m_flAvoidDistance; //
bool m_bChooseFarthestPoint;
CPathTrack *BestPointOnPath( CPathTrack *pPath, const Vector &targetPos, float avoidRadius, bool visible, bool bFarthestPointOnPath ); private:
// Input methods // Input methods
void InputSetTrack( inputdata_t &inputdata ); void InputSetTrack( inputdata_t &inputdata );
@ -218,7 +222,7 @@ private:
float ComputePathDistance( CPathTrack *pStart, CPathTrack *pDest, bool bForward ) const; float ComputePathDistance( CPathTrack *pStart, CPathTrack *pDest, bool bForward ) const;
// Compute the distance to a particular point on the path // Compute the distance to a particular point on the path
float ComputeDistanceAlongPathToPoint( CPathTrack *pStartTrack, CPathTrack *pDestTrack, const Vector &vecDestPosition, bool bMovingForward ); float ComputeDistanceAlongPathToPoint(CPathTrack *pStartTrack, CPathTrack *pDestTrack, const Vector &vecDestPosition, bool bMovingForward);
private: private:
//--------------------------------- //---------------------------------
@ -232,7 +236,6 @@ private:
// and *before* the desired point when moving backward. // and *before* the desired point when moving backward.
// DestPathTarget + TargetNearestPath always represent points // DestPathTarget + TargetNearestPath always represent points
// *after* the desired point. // *after* the desired point.
CHandle<CPathTrack> m_pCurrentPathTarget;
CHandle<CPathTrack> m_pDestPathTarget; CHandle<CPathTrack> m_pDestPathTarget;
CHandle<CPathTrack> m_pLastPathTarget; CHandle<CPathTrack> m_pLastPathTarget;
CHandle<CPathTrack> m_pTargetNearestPath; // Used only by leading, it specifies the path point *after* where the target is CHandle<CPathTrack> m_pTargetNearestPath; // Used only by leading, it specifies the path point *after* where the target is
@ -251,13 +254,11 @@ private:
// Derived class pathing data // Derived class pathing data
float m_flTargetDistanceThreshold;// Distance threshold used to determine when a target has moved enough to update our navigation to it float m_flTargetDistanceThreshold;// Distance threshold used to determine when a target has moved enough to update our navigation to it
float m_flAvoidDistance; //
float m_flTargetTolerance; // How far from a path track do we need to be before we 'reached' it? float m_flTargetTolerance; // How far from a path track do we need to be before we 'reached' it?
Vector m_vecSegmentStartPoint; // Starting point for the current segment Vector m_vecSegmentStartPoint; // Starting point for the current segment
Vector m_vecSegmentStartSplinePoint; // Used to define a spline which is used to compute path velocity Vector m_vecSegmentStartSplinePoint; // Used to define a spline which is used to compute path velocity
bool m_bMovingForward; bool m_bMovingForward;
bool m_bChooseFarthestPoint;
float m_flFarthestPathDist; // How far from a path track do we need to be before we 'reached' it? float m_flFarthestPathDist; // How far from a path track do we need to be before we 'reached' it?
float m_flPathMaxSpeed; float m_flPathMaxSpeed;

View File

@ -31,6 +31,8 @@
#include "EntityFlame.h" #include "EntityFlame.h"
#include "entityblocker.h" #include "entityblocker.h"
#include "eventqueue.h" #include "eventqueue.h"
#include "ai_trackpather.h"
#include "trains.h"
// memdbgon must be the last include file in a .cpp file!!! // memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h" #include "tier0/memdbgon.h"
@ -75,6 +77,7 @@
#define DROPSHIP_GUN_SPEED 10 // Rotation speed #define DROPSHIP_GUN_SPEED 10 // Rotation speed
#define DROPSHIP_CRATE_ROCKET_HITS 4 #define DROPSHIP_CRATE_ROCKET_HITS 4
extern ConVar chaos_npc_teleport;
enum DROP_STATES enum DROP_STATES
{ {
@ -2731,6 +2734,14 @@ void CNPC_CombineDropship::Hunt( void )
UpdateTrackNavigation(); UpdateTrackNavigation();
} }
Vector targetPos;
if (chaos_npc_teleport.GetBool() && GetLandingState() != LANDING_DESCEND && GetLandingState() != LANDING_TOUCHDOWN && GetLandingState() != LANDING_UNLOADING)// && GetTrackPatherTarget(&targetPos))
{
//CPathTrack *pDest = BestPointOnPath(m_pCurrentPathTarget, targetPos, m_flAvoidDistance, true, m_bChooseFarthestPoint);
//if (pDest)
Teleport(&GetDesiredPosition(), NULL, NULL);
}
// don't face player ever, only face nav points // don't face player ever, only face nav points
Vector desiredDir = GetDesiredPosition() - GetAbsOrigin(); Vector desiredDir = GetDesiredPosition() - GetAbsOrigin();
VectorNormalize( desiredDir ); VectorNormalize( desiredDir );