コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: Static debug function to make all selected npcs run around
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CAI_BaseNPC::ForceSelectedGoRandom(void) 
{
	CAI_BaseNPC *npc = gEntList.NextEntByClass( (CAI_BaseNPC *)NULL );

	while (npc)
	{
		if (npc->m_debugOverlays & OVERLAY_NPC_SELECTED_BIT) 
		{
			// If a behavior is active, we need to stop running it
			npc->SetPrimaryBehavior( NULL );
			npc->SetSchedule( SCHED_RUN_RANDOM );
			npc->GetNavigator()->SetMovementActivity(ACT_RUN);
		}
		npc = gEntList.NextEntByClass(npc);
	}
}
コード例 #2
0
void CAI_PlayerAlly::AlertFriends( CBaseEntity *pKiller )
{
	CBaseEntity *pFriend = NULL;
	int i;

	// for each friend in this bsp...
	for ( i = 0; i < TLK_CFRIENDS; i++ )
	{
		while (pFriend = EnumFriends( pFriend, i, true ))
		{
			CAI_BaseNPC *pNPC = pFriend->MyNPCPointer();
			if ( pNPC->IsAlive() )
			{
				// If a client killed me, make everyone else mad/afraid of him
				if ( pKiller->GetFlags() & FL_CLIENT )
				{
					pNPC->SetSchedule( SCHED_TALKER_BETRAYED );
#ifdef ALLIES_CAN_BE_PROVOKED
					pNPC->Remember( bits_MEMORY_PROVOKED );

					if( IsSelected() )
					{
						PlayerSelect( false );
					}
#endif
				}
				else
				{
					if( IRelationType(pKiller) == D_HT)
					{
						// Killed by an enemy!!!
						CAI_PlayerAlly *pAlly = (CAI_PlayerAlly *)pNPC;
						
						if( pAlly && pAlly->GetExpresser()->CanSpeakConcept( TLK_ALLY_KILLED ) )
						{
							pAlly->Speak( TLK_ALLY_KILLED );
						}
					}
				}
			}
		}
	}
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: Static debug function to force all selected npcs to go to the 
//			given node
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CAI_BaseNPC::ForceSelectedGo(CBaseEntity *pPlayer, const Vector &targetPos, const Vector &traceDir, bool bRun) 
{
	CAI_BaseNPC *npc = gEntList.NextEntByClass( (CAI_BaseNPC *)NULL );
	for ( ; npc; npc = gEntList.NextEntByClass(npc) )
	{
		if ( ( npc->m_debugOverlays & OVERLAY_NPC_SELECTED_BIT ) == 0 )
			continue;

		// If a behavior is active, we need to stop running it
		npc->SetPrimaryBehavior( NULL );

		Vector chasePosition = targetPos;
		npc->TranslateNavGoal( pPlayer, chasePosition );
		// It it legal to drop me here
		Vector	vUpBit = chasePosition;
		vUpBit.z += 1;

		trace_t tr;
		AI_TraceHull( chasePosition, vUpBit, npc->GetHullMins(), 
			npc->GetHullMaxs(), npc->GetAITraceMask(), npc, COLLISION_GROUP_NONE, &tr );
		if (tr.startsolid || tr.fraction != 1.0 )
		{
			NDebugOverlay::BoxAngles(chasePosition, npc->GetHullMins(), 
				npc->GetHullMaxs(), npc->GetAbsAngles(), 255,0,0,20,0.5);
		}

		npc->m_vecLastPosition = chasePosition;

		if (npc->m_hCine != NULL)
		{
			npc->ExitScriptedSequence();
		}

		npc->SetSchedule( bRun ? SCHED_FORCED_GO_RUN : SCHED_FORCED_GO );
		npc->m_flMoveWaitFinished = gpGlobals->curtime;
	}
}