mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-13 07:17:57 +03:00
Integrated custom cover hints into base AI movement code
This commit is contained in:
parent
dfa7e6c0c2
commit
ece1a612ce
@ -1095,9 +1095,9 @@ void CBaseAnimatingOverlay::SetLayerNoRestore( int iLayer, bool bNoRestore )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef MAPBASE // From Alien Swarm SDK
|
#ifdef MAPBASE
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// From Alien Swarm SDK
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CBaseAnimatingOverlay::SetLayerNoEvents( int iLayer, bool bNoEvents )
|
void CBaseAnimatingOverlay::SetLayerNoEvents( int iLayer, bool bNoEvents )
|
||||||
{
|
{
|
||||||
@ -1113,6 +1113,17 @@ void CBaseAnimatingOverlay::SetLayerNoEvents( int iLayer, bool bNoEvents )
|
|||||||
m_AnimOverlay[iLayer].m_fFlags &= ~ANIM_LAYER_NOEVENTS;
|
m_AnimOverlay[iLayer].m_fFlags &= ~ANIM_LAYER_NOEVENTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CBaseAnimatingOverlay::IsLayerFinished( int iLayer )
|
||||||
|
{
|
||||||
|
if (!IsValidLayer( iLayer ))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return m_AnimOverlay[iLayer].m_bSequenceFinished;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,8 +181,10 @@ public:
|
|||||||
void SetLayerAutokill( int iLayer, bool bAutokill );
|
void SetLayerAutokill( int iLayer, bool bAutokill );
|
||||||
void SetLayerLooping( int iLayer, bool bLooping );
|
void SetLayerLooping( int iLayer, bool bLooping );
|
||||||
void SetLayerNoRestore( int iLayer, bool bNoRestore );
|
void SetLayerNoRestore( int iLayer, bool bNoRestore );
|
||||||
#ifdef MAPBASE // From Alien Swarm SDK
|
#ifdef MAPBASE
|
||||||
void SetLayerNoEvents( int iLayer, bool bNoEvents );
|
void SetLayerNoEvents( int iLayer, bool bNoEvents ); // From Alien Swarm SDK
|
||||||
|
|
||||||
|
bool IsLayerFinished( int iLayer );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Activity GetLayerActivity( int iLayer );
|
Activity GetLayerActivity( int iLayer );
|
||||||
|
@ -2598,7 +2598,11 @@ bool CAI_BaseNPC::FValidateHintType ( CAI_Hint *pHint )
|
|||||||
Activity CAI_BaseNPC::GetHintActivity( short sHintType, Activity HintsActivity )
|
Activity CAI_BaseNPC::GetHintActivity( short sHintType, Activity HintsActivity )
|
||||||
{
|
{
|
||||||
if ( HintsActivity != ACT_INVALID )
|
if ( HintsActivity != ACT_INVALID )
|
||||||
|
#ifdef MAPBASE
|
||||||
|
return TranslateActivity( HintsActivity ); // Always translate the activity
|
||||||
|
#else
|
||||||
return HintsActivity;
|
return HintsActivity;
|
||||||
|
#endif
|
||||||
|
|
||||||
return ACT_IDLE;
|
return ACT_IDLE;
|
||||||
}
|
}
|
||||||
@ -6866,7 +6870,12 @@ void CAI_BaseNPC::ResolveActivityToSequence(Activity NewActivity, int &iSequence
|
|||||||
|
|
||||||
translatedActivity = TranslateActivity( NewActivity, &weaponActivity );
|
translatedActivity = TranslateActivity( NewActivity, &weaponActivity );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Cover cases where TranslateActivity() returns a sequence by using ACT_SCRIPT_CUSTOM_MOVE
|
||||||
|
if ( NewActivity == ACT_SCRIPT_CUSTOM_MOVE || translatedActivity == ACT_SCRIPT_CUSTOM_MOVE )
|
||||||
|
#else
|
||||||
if ( NewActivity == ACT_SCRIPT_CUSTOM_MOVE )
|
if ( NewActivity == ACT_SCRIPT_CUSTOM_MOVE )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
iSequence = GetScriptCustomMoveSequence();
|
iSequence = GetScriptCustomMoveSequence();
|
||||||
}
|
}
|
||||||
@ -7339,6 +7348,15 @@ void CAI_BaseNPC::OnChangeActivity( Activity eNewActivity )
|
|||||||
eNewActivity == ACT_WALK )
|
eNewActivity == ACT_WALK )
|
||||||
{
|
{
|
||||||
Stand();
|
Stand();
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Unlock custom cover nodes
|
||||||
|
if (GetHintNode() && GetHintNode()->HintType() == HINT_TACTICAL_COVER_CUSTOM && HasMemory(bits_MEMORY_INCOVER))
|
||||||
|
{
|
||||||
|
GetHintNode()->Unlock( GetHintDelay( GetHintNode()->HintType() ) );
|
||||||
|
SetHintNode( NULL );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9358,6 +9376,13 @@ float CAI_BaseNPC::CalcIdealYaw( const Vector &vecTarget )
|
|||||||
|
|
||||||
return UTIL_VecToYaw( vecProjection - GetLocalOrigin() );
|
return UTIL_VecToYaw( vecProjection - GetLocalOrigin() );
|
||||||
}
|
}
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Allow hint nodes to override the yaw without needing to control AI
|
||||||
|
else if (GetHintNode() && GetHintNode()->OverridesNPCYaw( this ))
|
||||||
|
{
|
||||||
|
return GetHintNode()->Yaw();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return UTIL_VecToYaw ( vecTarget - GetLocalOrigin() );
|
return UTIL_VecToYaw ( vecTarget - GetLocalOrigin() );
|
||||||
|
@ -980,11 +980,12 @@ bool CAI_BaseNPC::FindCoverFromEnemy( bool bNodesOnly, float flMinDistance, floa
|
|||||||
// FIXME: add to goal
|
// FIXME: add to goal
|
||||||
if (GetHintNode())
|
if (GetHintNode())
|
||||||
{
|
{
|
||||||
GetNavigator()->SetArrivalActivity( GetCoverActivity( GetHintNode() ) );
|
|
||||||
#ifdef MAPBASE
|
#ifdef MAPBASE
|
||||||
if (GetHintNode()->GetIgnoreFacing() != HIF_NO)
|
GetHintNode()->NPCHandleStartNav( this, true );
|
||||||
#endif
|
#else
|
||||||
|
GetNavigator()->SetArrivalActivity( GetCoverActivity( GetHintNode() ) );
|
||||||
GetNavigator()->SetArrivalDirection( GetHintNode()->GetDirection() );
|
GetNavigator()->SetArrivalDirection( GetHintNode()->GetDirection() );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3431,6 +3432,17 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )
|
|||||||
// If the yaw is locked, this function will not act correctly
|
// If the yaw is locked, this function will not act correctly
|
||||||
Assert( GetMotor()->IsYawLocked() == false );
|
Assert( GetMotor()->IsYawLocked() == false );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( GetHintNode() && GetHintNode()->OverridesNPCYaw( this ) )
|
||||||
|
{
|
||||||
|
// If the yaw is supposed to use that of a hint node, chain to TASK_FACE_HINTNODE
|
||||||
|
GetMotor()->SetIdealYaw( GetHintNode()->Yaw() );
|
||||||
|
GetMotor()->SetIdealYaw( CalcReasonableFacing( true ) ); // CalcReasonableFacing() is based on previously set ideal yaw
|
||||||
|
ChainRunTask( TASK_FACE_HINTNODE, pTask->flTaskData );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Vector vecEnemyLKP = GetEnemyLKP();
|
Vector vecEnemyLKP = GetEnemyLKP();
|
||||||
if (!FInAimCone( vecEnemyLKP ))
|
if (!FInAimCone( vecEnemyLKP ))
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
#include "ai_basenpc.h"
|
#include "ai_basenpc.h"
|
||||||
#include "ai_localnavigator.h"
|
#include "ai_localnavigator.h"
|
||||||
#include "ai_moveprobe.h"
|
#include "ai_moveprobe.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "ai_hint.h"
|
||||||
|
#endif
|
||||||
#include "saverestore_utlvector.h"
|
#include "saverestore_utlvector.h"
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
@ -836,9 +839,20 @@ void CAI_Motor::MoveFacing( const AILocalMoveGoal_t &move )
|
|||||||
{
|
{
|
||||||
// FIXME: move this up to navigator so that path goals can ignore these overrides.
|
// FIXME: move this up to navigator so that path goals can ignore these overrides.
|
||||||
Vector dir;
|
Vector dir;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (IsDeceleratingToGoal() && (GetOuter()->GetHintNode() /*|| GetOuter()->m_hOpeningDoor*/))
|
||||||
|
{
|
||||||
|
// Don't let the facing queue interfere with arrival direction in important cases
|
||||||
|
dir = move.facing;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
float flInfluence = GetFacingDirection( dir );
|
float flInfluence = GetFacingDirection( dir );
|
||||||
dir = move.facing * (1 - flInfluence) + dir * flInfluence;
|
dir = move.facing * (1 - flInfluence) + dir * flInfluence;
|
||||||
VectorNormalize( dir );
|
VectorNormalize( dir );
|
||||||
|
}
|
||||||
|
|
||||||
// ideal facing direction
|
// ideal facing direction
|
||||||
float idealYaw = UTIL_AngleMod( UTIL_VecToYaw( dir ) );
|
float idealYaw = UTIL_AngleMod( UTIL_VecToYaw( dir ) );
|
||||||
|
@ -87,6 +87,9 @@ public:
|
|||||||
const Vector & GetCurVel() const { return m_vecVelocity; }
|
const Vector & GetCurVel() const { return m_vecVelocity; }
|
||||||
|
|
||||||
virtual float OverrideMaxYawSpeed( Activity activity ) { return -1; }
|
virtual float OverrideMaxYawSpeed( Activity activity ) { return -1; }
|
||||||
|
#ifdef MAPBASE
|
||||||
|
virtual
|
||||||
|
#endif
|
||||||
bool IsDeceleratingToGoal() const { return false; }
|
bool IsDeceleratingToGoal() const { return false; }
|
||||||
|
|
||||||
//---------------------------------
|
//---------------------------------
|
||||||
|
@ -999,13 +999,24 @@ int CAI_Navigator::GetArrivalSequence( int curSequence )
|
|||||||
activity = ACT_IDLE;
|
activity = ACT_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( activity ), curSequence );
|
Activity translatedActivity = GetOuter()->TranslateActivity( activity );
|
||||||
|
sequence = GetOuter()->SelectWeightedSequence( translatedActivity, curSequence );
|
||||||
|
|
||||||
if ( sequence == ACT_INVALID )
|
if ( sequence == ACT_INVALID )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( translatedActivity == ACT_SCRIPT_CUSTOM_MOVE )
|
||||||
|
{
|
||||||
|
// ACT_SCRIPT_CUSTOM_MOVE allows activity translation to resolve into specific sequences
|
||||||
|
sequence = GetOuter()->GetScriptCustomMoveSequence();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
DevMsg( GetOuter(), "No appropriate sequence for arrival activity %s (%d)\n", GetOuter()->GetActivityName( GetPath()->GetArrivalActivity() ), GetPath()->GetArrivalActivity() );
|
DevMsg( GetOuter(), "No appropriate sequence for arrival activity %s (%d)\n", GetOuter()->GetActivityName( GetPath()->GetArrivalActivity() ), GetPath()->GetArrivalActivity() );
|
||||||
sequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( ACT_IDLE ), curSequence );
|
sequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( ACT_IDLE ), curSequence );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Assert( sequence != ACT_INVALID );
|
Assert( sequence != ACT_INVALID );
|
||||||
GetPath()->SetArrivalSequence( sequence );
|
GetPath()->SetArrivalSequence( sequence );
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,12 @@ int CAI_TacticalServices::FindCoverNode(const Vector &vNearPos, const Vector &vT
|
|||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
pNode->Lock( 1.0 );
|
pNode->Lock( 1.0 );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( pNode->GetHint() && ( pNode->GetHint()->HintType() == HINT_TACTICAL_COVER_MED || pNode->GetHint()->HintType() == HINT_TACTICAL_COVER_LOW
|
||||||
|
|| pNode->GetHint()->HintType() == HINT_TACTICAL_COVER_CUSTOM ) )
|
||||||
|
#else
|
||||||
if ( pNode->GetHint() && ( pNode->GetHint()->HintType() == HINT_TACTICAL_COVER_MED || pNode->GetHint()->HintType() == HINT_TACTICAL_COVER_LOW ) )
|
if ( pNode->GetHint() && ( pNode->GetHint()->HintType() == HINT_TACTICAL_COVER_MED || pNode->GetHint()->HintType() == HINT_TACTICAL_COVER_LOW ) )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if ( GetOuter()->GetHintNode() )
|
if ( GetOuter()->GetHintNode() )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user