当前位置: 首页>>代码示例>>C++>>正文


C++ CAI_BaseNPC类代码示例

本文整理汇总了C++中CAI_BaseNPC的典型用法代码示例。如果您正苦于以下问题:C++ CAI_BaseNPC类的具体用法?C++ CAI_BaseNPC怎么用?C++ CAI_BaseNPC使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CAI_BaseNPC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetOwner

int CWeaponCrowbar::WeaponMeleeAttack1Condition( float flDot, float flDist )
{
    // Attempt to lead the target (needed because citizens can't hit manhacks with the crowbar!)
    CAI_BaseNPC *pNPC	= GetOwner()->MyNPCPointer();
    CBaseEntity *pEnemy = pNPC->GetEnemy();
    if (!pEnemy)
        return COND_NONE;

    Vector vecVelocity;
    vecVelocity = pEnemy->GetSmoothedVelocity( );

    // Project where the enemy will be in a little while
    float dt = sk_crowbar_lead_time.GetFloat();
    dt += SharedRandomFloat( "crowbarmelee1", -0.3f, 0.2f );
    if ( dt < 0.0f )
        dt = 0.0f;

    Vector vecExtrapolatedPos;
    VectorMA( pEnemy->WorldSpaceCenter(), dt, vecVelocity, vecExtrapolatedPos );

    Vector vecDelta;
    VectorSubtract( vecExtrapolatedPos, pNPC->WorldSpaceCenter(), vecDelta );

    if ( fabs( vecDelta.z ) > 70 )
    {
        return COND_TOO_FAR_TO_ATTACK;
    }

    Vector vecForward = pNPC->BodyDirection2D( );
    vecDelta.z = 0.0f;
    float flExtrapolatedDist = Vector2DNormalize( vecDelta.AsVector2D() );
    if ((flDist > 64) && (flExtrapolatedDist > 64))
    {
        return COND_TOO_FAR_TO_ATTACK;
    }

    float flExtrapolatedDot = DotProduct2D( vecDelta.AsVector2D(), vecForward.AsVector2D() );
    if ((flDot < 0.7) && (flExtrapolatedDot < 0.7))
    {
        return COND_NOT_FACING_ATTACK;
    }

    return COND_CAN_MELEE_ATTACK1;
}
开发者ID:chrizonix,项目名称:RCBot2,代码行数:44,代码来源:weapon_crowbar.cpp

示例2: InputSetAggressiveness

	void InputSetAggressiveness( inputdata_t &inputdata )
	{
		int newVal = inputdata.value.Int();
		
		m_aggressiveness = (Aggressiveness_t)newVal;
		ValidateAggression();
		
		UpdateActors();

		const CUtlVector<AIHANDLE> &actors = AccessActors();
		for ( int i = 0; i < actors.Count(); i++ )
		{
			CAI_BaseNPC *pAI = actors[i];
			CAI_StandoffBehavior *pBehavior;
			if ( !pAI->GetBehavior( &pBehavior ) )
				continue;
			SetBehaviorParams( pBehavior);
		}
	}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:19,代码来源:ai_behavior_standoff.cpp

示例3: while

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 );
						}
					}
				}
			}
		}
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:43,代码来源:npc_talker.cpp

示例4: switch

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeapon357::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator )
{
	switch( pEvent->event )
	{
		case EVENT_WEAPON_PISTOL_FIRE:
		{
			Vector vecShootOrigin, vecShootDir;
			vecShootOrigin = pOperator->Weapon_ShootPosition();

			CAI_BaseNPC *npc = pOperator->MyNPCPointer();
			ASSERT(npc != NULL);

			vecShootDir = npc->GetActualShootTrajectory(vecShootOrigin);

			CSoundEnt::InsertSound(SOUND_COMBAT | SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy());

			WeaponSound(SINGLE_NPC);
			pOperator->FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2);
			pOperator->DoMuzzleFlash();
			m_iClip1 = m_iClip1 - 1;
		}
		case EVENT_WEAPON_RELOAD:
		{
			CBasePlayer *pOwner = ToBasePlayer(GetOwner());
			CEffectData data;

			// Emit six spent shells
			for (int i = 0; i < 6; i++)
			{
				data.m_vOrigin = pOwner->WorldSpaceCenter() + RandomVector(-4, 4);
				data.m_vAngles = QAngle(90, random->RandomInt(0, 360), 0);
				data.m_nEntIndex = entindex();

				DispatchEffect("ShellEject", data);
			}
		}
		break;
		default:
			BaseClass::Operator_HandleAnimEvent(pEvent, pOperator);
			break;
	}
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:45,代码来源:weapon_357.cpp

示例5: CallForHelp

void CNPC_Vortigaunt::CallForHelp( char *szClassname, float flDist, CBaseEntity * pEnemy, Vector &vecLocation )
{
    // ALERT( at_aiconsole, "help " );

    // skip ones not on my netname
    if ( !m_pSquad )
        return;

    AISquadIter_t iter;
    for (CAI_BaseNPC *pSquadMember = m_pSquad->GetFirstMember( &iter ); pSquadMember; pSquadMember = m_pSquad->GetNextMember( &iter ) )
    {
        float d = ( GetAbsOrigin() - pSquadMember->GetAbsOrigin() ).Length();

        if ( d < flDist )
        {
            pSquadMember->Remember( bits_MEMORY_PROVOKED );
            pSquadMember->UpdateEnemyMemory( pEnemy, vecLocation );
        }
    }
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例6: while

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pKiller - 
//-----------------------------------------------------------------------------
void CNPCSimpleTalker::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 )) != NULL )
		{
			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 )
				{
					CNPCSimpleTalker*pTalkNPC = (CNPCSimpleTalker *)pFriend;

					if (pTalkNPC && pTalkNPC->IsOkToCombatSpeak())
					{
						// FIXME: need to check CanSpeakConcept?
						pTalkNPC->Speak( TLK_BETRAYED );
					}
				}
				else
				{
					if( IRelationType(pKiller) == D_HT)
					{
						// Killed by an enemy!!!
						CNPCSimpleTalker *pAlly = (CNPCSimpleTalker *)pNPC;
						
						if( pAlly && pAlly->GetExpresser()->CanSpeakConcept( TLK_ALLY_KILLED ) )
						{
							pAlly->Speak( TLK_ALLY_KILLED );
						}
					}
				}
			}
		}
	}
}
开发者ID:Denzeriko,项目名称:hl2-mod,代码行数:45,代码来源:npc_talker.cpp

示例7:

int	CAI_Squad::BroadcastInteraction( int interactionType, void *data, CBaseCombatCharacter *sender )
{
	//Must have a squad
	if ( m_SquadMembers.Count() == 0 )
		return false;

	//Broadcast to all members of the squad
	for ( int i = 0; i < m_SquadMembers.Count(); i++ )
	{
		CAI_BaseNPC *pMember = m_SquadMembers[i]->MyNPCPointer();
		
		//Validate and don't send again to the sender
		if ( ( pMember != NULL) && ( pMember != sender ) )
		{
			//Send it
			pMember->DispatchInteraction( interactionType, data, sender );
		}
	}

	return true;
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:21,代码来源:ai_squad.cpp

示例8: GetActor

//-----------------------------------------------------------------------------
// Purpose: ENTITY I/O method for telling the assault behavior to cue assault
// Input  : &inputdata - 
//-----------------------------------------------------------------------------
void CAI_AssaultGoal::InputBeginAssault( inputdata_t &inputdata )
{
	int i;

	for( i = 0 ; i < NumActors() ; i++ )
	{
		CAI_BaseNPC *pActor = GetActor( i );

		if( pActor )
		{
			// Now use this actor to lookup the Behavior
			CAI_AssaultBehavior *pBehavior;

			if( pActor->GetBehavior( &pBehavior ) )
			{
				// GOT IT! Now tell the behavior that entity i/o wants to cue the assault.
				pBehavior->ReceiveAssaultCue( CUE_ENTITY_INPUT );
			}
		}
	}
}
开发者ID:paralin,项目名称:hl2sdk,代码行数:25,代码来源:ai_behavior_assault.cpp

示例9: Disclose

//=========================================================
// Revela la posición de los jugadores.
//=========================================================
void CDirector_Manager::Disclose()
{
	CAI_BaseNPC *pNPC = NULL;

	do
	{
		// Buscamos a todos los hijos en el mapa.
		pNPC = (CAI_BaseNPC *)gEntList.FindEntityByName(pNPC, CHILD_NAME);

		// No existe o esta muerto.
		if ( !pNPC || !pNPC->IsAlive() )
			continue;

		// Ya tiene a un jugador como enemigo.
		if ( pNPC->GetEnemy() && pNPC->GetEnemy()->IsPlayer() )
			continue;

		// Seleccionamos al jugador más cercano.
		float flDistance = 0.0f;
		CIN_Player *pPlayer = UTIL_GetNearestInPlayer(pPlayer->GetAbsOrigin(), flDistance);

		if ( !pPlayer )
			continue;

		// Le decimos que su nuevo enemigo es el jugador y le damos la ubicación de este.
		pNPC->SetEnemy(pPlayer);
		pNPC->UpdateEnemyMemory(pPlayer, pPlayer->GetAbsOrigin());

	}
	while ( pNPC );
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:34,代码来源:director_manager.cpp

示例10: Event_Killed

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pInflictor - 
//			pAttacker - 
//			flDamage - 
//			bitsDamageType - 
//-----------------------------------------------------------------------------
void CNPC_Stalker::Event_Killed( const CTakeDamageInfo &info )
{
	if( IsInSquad() && info.GetAttacker()->IsPlayer() )
	{
		AISquadIter_t iter;
		for ( CAI_BaseNPC *pSquadMember = GetSquad()->GetFirstMember( &iter ); pSquadMember; pSquadMember = GetSquad()->GetNextMember( &iter ) )
		{
			if ( pSquadMember->IsAlive() && pSquadMember != this )
			{
				CNPC_Stalker *pStalker = dynamic_cast <CNPC_Stalker*>(pSquadMember);

				if( pStalker && pStalker->FVisible(info.GetAttacker()) )
				{
					pStalker->m_iPlayerAggression++;
				}
			}
		}
	}

	KillAttackBeam();
	BaseClass::Event_Killed( info );
}
开发者ID:Muini,项目名称:Nag-asw,代码行数:29,代码来源:npc_stalker.cpp

示例11: GetOuter

bool CAI_OperatorBehavior::CanSeePositionEntity()
{
    CAI_BaseNPC *pOuter = GetOuter();

    Assert( m_hPositionEnt.Get() != NULL );

    // early out here.
    if( !pOuter->QuerySeeEntity(m_hPositionEnt) )
    {
        m_WatchSeeEntity.Stop();
        return false;
    }

    bool bSpotted = (pOuter->EyePosition().DistToSqr(m_hPositionEnt->GetAbsOrigin()) <= POSITION_ENT_ALWAYS_SEE_DIST);
    if ( !bSpotted )
    {
        bSpotted = ( pOuter->FInViewCone(m_hPositionEnt) && pOuter->FVisible(m_hPositionEnt) );
    }

    if (bSpotted )
    {
        // If we haven't seen it up until now, start a timer. If we have seen it, wait for the
        // timer to finish. This prevents edge cases where turning on the flashlight makes
        // NPC spot the position entity a frame before she spots an enemy.
        if ( !m_WatchSeeEntity.IsRunning() )
        {
            m_WatchSeeEntity.Start( 0.3,0.31 );
            return false;
        }

        if ( !m_WatchSeeEntity.Expired() )
            return false;

        return true;
    }

    m_WatchSeeEntity.Stop();
    return false;
}
开发者ID:Black-Stormy,项目名称:DoubleAction,代码行数:39,代码来源:ai_behavior_operator.cpp

示例12: TraceAttack

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pAttacker - 
//			flDamage - 
//			&vecDir - 
//			*ptr - 
//			bitsDamageType - 
//-----------------------------------------------------------------------------
void CNPC_Bullseye::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr )
{
	//If specified, we must be the enemy of the target
	if ( m_spawnflags & SF_BULLSEYE_ENEMYDAMAGEONLY )
	{
		CAI_BaseNPC *pInstigator = info.GetAttacker()->MyNPCPointer();

		if ( pInstigator == NULL )
			return;

		if ( pInstigator->GetEnemy() != this )
			return;
	}

	//We can bleed if we want to, we can leave decals behind...
	if ( ( m_spawnflags & SF_BULLSEYE_BLEED ) && ( m_takedamage == DAMAGE_NO ) )
	{
		TraceBleed( info.GetDamage(), vecDir, ptr, info.GetDamageType() );
	}

	BaseClass::TraceAttack( info, vecDir, ptr );
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:30,代码来源:npc_bullseye.cpp

示例13: Assert

//-------------------------------------
// Purpose: Addes the given NPC to the squad
//-------------------------------------
void CAI_Squad::AddToSquad(CAI_BaseNPC *pNPC)
{
	if ( !pNPC || !pNPC->IsAlive() )
	{
		Assert(0);
		return;
	}

	if ( pNPC->GetSquad() == this )
		return;

	if ( pNPC->GetSquad() )
	{
		pNPC->GetSquad()->RemoveFromSquad(pNPC);
	}

	if (m_SquadMembers.Count() == MAX_SQUAD_MEMBERS)
	{
		DevMsg("Error!! Squad %s is too big!!! Replacing last member\n",this->m_Name);
		m_SquadMembers.Remove(m_SquadMembers.Count()-1);
	}
	m_SquadMembers.AddToTail(pNPC);
	pNPC->SetSquad( this );
	pNPC->SetSquadName( m_Name );

	if ( m_SquadMembers.Count() > 1 )
	{
		CAI_BaseNPC *pCopyFrom = m_SquadMembers[0];
		CAI_Enemies *pEnemies = pCopyFrom->GetEnemies();
		AIEnemiesIter_t iter;
		AI_EnemyInfo_t *pInfo = pEnemies->GetFirst( &iter );
		while ( pInfo )
		{
			pNPC->UpdateEnemyMemory( pInfo->hEnemy, pInfo->vLastKnownLocation, pCopyFrom );
			pInfo = pEnemies->GetNext( &iter );
		}
	}

}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:42,代码来源:ai_squad.cpp

示例14: GetAbsAngles

//=========================================================
// Crea un NPC Grunt.
//=========================================================
CAI_BaseNPC *CSurvivalZombieSpawn::MakeGrunt()
{
	// Desactivado
	if ( Disabled || !sv_spawn_zombies.GetBool() )
		return NULL;

	CAI_BaseNPC *pGrunt = (CAI_BaseNPC *)CreateEntityByName("npc_grunt");

	// Ocurrio algún problema.
	if ( !pGrunt )
	{
		Warning("[SURVIVAL ZOMBIE MAKER] Ha ocurrido un problema al intentar crear un grunt. \r\n");
		return NULL;
	}

	Vector origin;

	if ( !CanMakeNPC(pGrunt, &origin) )
		return NULL;

	// Lugar de creación.
	pGrunt->SetAbsOrigin(origin);

	// Nombre del Grunt.
	// [¡NO CAMBIAR!] Es utilizado por otras entidades para referirse a los zombis creados por esta entidad.
	pGrunt->SetName(MAKE_STRING("survival_grunt"));

	QAngle angles	= GetAbsAngles();
	angles.x		= 0.0;
	angles.z		= 0.0;

	pGrunt->SetAbsAngles(angles);

	// Tiene que caer al suelo.
	pGrunt->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

	// Creamos al grunt, le decimos quien es su dios (creador) y lo activamos.
	DispatchSpawn(pGrunt);
	pGrunt->SetOwnerEntity(this);
	DispatchActivate(pGrunt);

	// Ahora creamos la música.
	pGruntMusic = (CEnvSound *)CreateEntityByName("env_sound");
	pGruntMusic->SetSourceEntityName(MAKE_STRING("survival_grunt"));
	pGruntMusic->SetSoundName(MAKE_STRING("NPC_Grunt.BackgroundMusic"));
	pGruntMusic->SetRadius(8000.0);
	
	pGruntMusic->SetAbsOrigin(origin);
	DispatchSpawn(pGruntMusic);
	pGruntMusic->SetOwnerEntity(this);
	DispatchActivate(pGruntMusic);

	pGruntMusic->SetPitch(100);
	pGruntMusic->SetVolume(1);
	pGruntMusic->PlayManual(1, 100);

	return pGrunt;
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:61,代码来源:director_spawn.cpp

示例15: switch

void CWeaponOICW::Operator_HandleAnimEvent(animevent_t *pEvent, CBaseCombatCharacter *pOperator)
{
	switch (pEvent->event)
	{
	case EVENT_WEAPON_AR2:
	{
		Vector vecShootOrigin, vecShootDir;
		vecShootOrigin = pOperator->Weapon_ShootPosition();

		CAI_BaseNPC *npc = pOperator->MyNPCPointer();
		ASSERT(npc != NULL);
		vecShootDir = npc->GetActualShootTrajectory(vecShootOrigin);
		WeaponSound(SINGLE_NPC);
		pOperator->FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2);
		pOperator->DoMuzzleFlash();
		m_iClip1 = m_iClip1 - 1;
	}
	break;
	default:
		CBaseCombatWeapon::Operator_HandleAnimEvent(pEvent, pOperator);
		break;
	}
}
开发者ID:,项目名称:,代码行数:23,代码来源:


注:本文中的CAI_BaseNPC类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。