upload "kind" alien swarm

This commit is contained in:
nillerusr
2023-10-03 17:23:56 +03:00
parent b7bd94c52e
commit 7d3c0d8b5a
4229 changed files with 462900 additions and 495155 deletions
+121 -10
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Functions and data pertaining to the NPCs' AI scheduling system.
// Implements default NPC tasks and schedules.
@@ -32,8 +32,9 @@
#include "IEffects.h"
#include "vstdlib/random.h"
#include "ndebugoverlay.h"
#include "tier0/vcrmode.h"
#include "env_debughistory.h"
#include "ai_behavior.h"
#include "global_event_log.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -161,6 +162,8 @@ bool CAI_BaseNPC::SetSchedule( int localScheduleID )
void CAI_BaseNPC::SetSchedule( CAI_Schedule *pNewSchedule )
{
Assert( pNewSchedule != NULL );
OnSetSchedule();
m_ScheduleState.timeCurTaskStarted = m_ScheduleState.timeStarted = gpGlobals->curtime;
m_ScheduleState.bScheduleWasInterrupted = false;
@@ -193,6 +196,16 @@ void CAI_BaseNPC::SetSchedule( CAI_Schedule *pNewSchedule )
{
DevMsg(this, AIMF_IGNORE_SELECTED, "Schedule: %s (time: %.2f)\n", pNewSchedule->GetName(), gpGlobals->curtime );
}
if ( m_pEvent != NULL )
{
if ( m_pScheduleEvent != NULL )
{
GlobalEventLog.RemoveEvent( m_pScheduleEvent );
}
m_pScheduleEvent = GlobalEventLog.CreateEvent( "Schedule", false, m_pEvent );
GlobalEventLog.AddKeyValue( m_pScheduleEvent, false, "Schedule", pNewSchedule->GetName() );
}
ADD_DEBUG_HISTORY( HISTORY_AI_DECISIONS, UTIL_VarArgs("%s(%d): Schedule: %s (time: %.2f)\n", GetDebugName(), entindex(), pNewSchedule->GetName(), gpGlobals->curtime ) );
@@ -698,7 +711,7 @@ void CAI_BaseNPC::MaintainSchedule ( void )
return;
}
AI_PROFILE_SCOPE_BEGIN_( CAI_BaseNPC::GetSchedulingSymbols()->ScheduleIdToSymbol( GetCurSchedule()->GetId() ) );
AI_PROFILE_SCOPE_BEGIN_( GetCurSchedule() ? CAI_BaseNPC::GetSchedulingSymbols()->ScheduleIdToSymbol( GetCurSchedule()->GetId() ) : "NULL SCHEDULE" );
if ( GetTaskStatus() == TASKSTATUS_NEW )
{
@@ -719,6 +732,12 @@ void CAI_BaseNPC::MaintainSchedule ( void )
{
DevMsg(this, AIMF_IGNORE_SELECTED, " Task: %s\n", pszTaskName );
}
if ( m_pScheduleEvent != NULL )
{
CGlobalEvent *pEvent = GlobalEventLog.CreateTempEvent( "New Task", m_pScheduleEvent );
GlobalEventLog.AddKeyValue( pEvent, false, "Task", pszTaskName );
}
ADD_DEBUG_HISTORY( HISTORY_AI_DECISIONS, UTIL_VarArgs("%s(%d): Task: %s\n", GetDebugName(), entindex(), pszTaskName ) );
@@ -747,7 +766,7 @@ void CAI_BaseNPC::MaintainSchedule ( void )
// UNDONE: Twice?!!!
MaintainActivity();
AI_PROFILE_SCOPE_BEGIN_( CAI_BaseNPC::GetSchedulingSymbols()->ScheduleIdToSymbol( GetCurSchedule()->GetId() ) );
AI_PROFILE_SCOPE_BEGIN_( GetCurSchedule() ? CAI_BaseNPC::GetSchedulingSymbols()->ScheduleIdToSymbol( GetCurSchedule()->GetId() ) : "NULL SCHEDULE" );
if ( !TaskIsComplete() && GetTaskStatus() != TASKSTATUS_NEW )
{
@@ -813,6 +832,11 @@ void CAI_BaseNPC::MaintainSchedule ( void )
bStopProcessing = true;
}
for ( i = 0; i < m_Behaviors.Count(); i++ )
{
m_Behaviors[i]->MaintainChannelSchedules();
}
// UNDONE: We have to do this so that we have an animation set to blend to if RunTask changes the animation
// RunTask() will always change animations at the end of a script!
// Don't do this twice
@@ -1914,7 +1938,7 @@ void CAI_BaseNPC::StartTask( const Task_t *pTask )
flMinRange = InnateRange1MinRange();
}
//Check against NPC's max range
//Check against NPC's MAX range
if ( flMaxRange > m_flDistTooFar )
{
flMaxRange = m_flDistTooFar;
@@ -2082,7 +2106,7 @@ void CAI_BaseNPC::StartTask( const Task_t *pTask )
flMinRange = InnateRange1MinRange();
}
// Check against NPC's max range
// Check against NPC's MAX range
if ( flMaxRange > m_flDistTooFar )
{
flMaxRange = m_flDistTooFar;
@@ -2238,7 +2262,7 @@ void CAI_BaseNPC::StartTask( const Task_t *pTask )
flMinRange = InnateRange1MinRange();
}
// Check against NPC's max range
// Check against NPC's MAX range
if (flMaxRange > m_flDistTooFar)
{
flMaxRange = m_flDistTooFar;
@@ -2346,6 +2370,14 @@ void CAI_BaseNPC::StartTask( const Task_t *pTask )
}
break;
case TASK_GET_PATH_OFF_OF_NPC:
{
Assert( ( GetGroundEntity() && ( GetGroundEntity()->IsPlayer() || ( GetGroundEntity()->IsNPC() && IRelationType( GetGroundEntity() ) == D_LI ) ) ) );
GetNavigator()->SetAllowBigStep( GetGroundEntity() );
ChainStartTask( TASK_MOVE_AWAY_PATH, 48 );
}
break;
case TASK_GET_PATH_TO_TARGET:
{
if (m_hTargetEnt == NULL)
@@ -2623,6 +2655,12 @@ void CAI_BaseNPC::StartTask( const Task_t *pTask )
case TASK_WAIT_FOR_MOVEMENT_STEP:
{
if ( IsMovementFrozen() )
{
TaskFail(FAIL_FROZEN);
break;
}
if(!GetNavigator()->IsGoalActive())
{
TaskComplete();
@@ -2640,6 +2678,12 @@ void CAI_BaseNPC::StartTask( const Task_t *pTask )
case TASK_WAIT_FOR_MOVEMENT:
{
if ( IsMovementFrozen() )
{
TaskFail(FAIL_FROZEN);
break;
}
if (GetNavigator()->GetGoalType() == GOALTYPE_NONE)
{
TaskComplete();
@@ -3142,6 +3186,7 @@ void CAI_BaseNPC::RunDieTask()
}
else // !!!HACKHACK - put NPC in a thin, wide bounding box until we fix the solid type/bounding volume problem
UTIL_SetSize ( this, WorldAlignMins(), Vector ( WorldAlignMaxs().x, WorldAlignMaxs().y, WorldAlignMins().z + 1 ) );
}
}
@@ -3354,7 +3399,7 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )
GetMotor()->UpdateYaw();
if ( FacingIdeal() )
if ( FacingIdeal( m_flFaceEnemyTolerance ) )
{
TaskComplete();
}
@@ -3636,6 +3681,16 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )
break;
}
case TASK_GET_PATH_OFF_OF_NPC:
{
if ( AI_IsSinglePlayer() )
{
GetNavigator()->SetAllowBigStep( UTIL_GetLocalPlayer() );
}
ChainRunTask( TASK_MOVE_AWAY_PATH, 48 );
}
break;
case TASK_MOVE_AWAY_PATH:
{
QAngle ang = GetLocalAngles();
@@ -3654,7 +3709,7 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )
hintCriteria.AddHintType( HINT_PLAYER_ALLY_MOVE_AWAY_DEST );
hintCriteria.SetFlag( bits_HINT_NODE_NEAREST );
hintCriteria.AddIncludePosition( GetAbsOrigin(), (20.0f * 12.0f) ); // 20 feet max
hintCriteria.AddIncludePosition( GetAbsOrigin(), (20.0f * 12.0f) ); // 20 feet MAX
hintCriteria.AddExcludePosition( GetAbsOrigin(), 28.0f ); // don't plant on an hint that you start on
pHint = CAI_HintManager::FindHint( this, hintCriteria );
@@ -3800,6 +3855,12 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )
case TASK_WAIT_FOR_MOVEMENT_STEP:
case TASK_WAIT_FOR_MOVEMENT:
{
if ( IsMovementFrozen() )
{
TaskFail(FAIL_FROZEN);
break;
}
bool fTimeExpired = ( pTask->flTaskData != 0 && pTask->flTaskData < gpGlobals->curtime - GetTimeTaskStarted() );
if (fTimeExpired || GetNavigator()->GetGoalType() == GOALTYPE_NONE)
@@ -4111,7 +4172,7 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )
vecDown.z -= 0.2;
trace_t trace;
m_pMoveProbe->TraceHull( vecStart, vecDown, mins, maxs, MASK_NPCSOLID, &trace );
m_pMoveProbe->TraceHull( vecStart, vecDown, mins, maxs, GetAITraceMask(), &trace );
if( trace.m_pEnt )
{
@@ -4132,6 +4193,10 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )
break;
case TASK_FREEZE:
if ( m_flFrozen < 1.0f )
{
Unfreeze();
}
break;
default:
@@ -4345,6 +4410,52 @@ const Task_t *CAI_BaseNPC::GetTask( void )
}
void CAI_BaseNPC::TranslateAddOnAttachment( char *pchAttachmentName, int iCount )
{
#ifdef HL2_DLL
if( Classify() == CLASS_ZOMBIE || ClassMatches( "npc_combine*" ) )
{
if ( Q_strcmp( pchAttachmentName, "addon_rear" ) == 0 ||
Q_strcmp( pchAttachmentName, "addon_front" ) == 0 ||
Q_strcmp( pchAttachmentName, "addon_rear_or_front" ) == 0 )
{
if ( iCount == 0 )
{
Q_strcpy( pchAttachmentName, "eyes" );
}
else
{
Q_strcpy( pchAttachmentName, "" );
}
return;
}
}
#endif
if( Q_strcmp( pchAttachmentName, "addon_baseshooter" ) == 0 )
{
switch ( iCount )
{
case 0:
Q_strcpy( pchAttachmentName, "anim_attachment_lh" );
break;
case 1:
Q_strcpy( pchAttachmentName, "anim_attachment_rh" );
break;
default:
Q_strcpy( pchAttachmentName, "" );
}
return;
}
Q_strcpy( pchAttachmentName, "" );
}
//-----------------------------------------------------------------------------
bool CAI_BaseNPC::IsInterruptable()
{