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


C++ CAI::GetTarget方法代码示例

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


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

示例1: OnTrigger

bool Alarm::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg)
{
	static CParsedMsg::CToken s_cTok_Activate(s_szActivate);
	static CParsedMsg::CToken s_cTok_Lock(s_szLock);
	static CParsedMsg::CToken s_cTok_Unlock(s_szUnlock);

	if ( cMsg.GetArg(0) == s_cTok_Activate )
	{
		// If the alarm is activated from a command, the sender is
		// NULL (dammit!).  So treat it as player-activated.
		// If the alarm is activated by something other than AI
		// (e.g. a command object) consider it player activated.

		if( !IsAI( hSender ) )
		{
			CPlayerObj *pPlayer = g_pCharacterMgr->FindPlayer();
			hSender = pPlayer->m_hObject;
		}

		HOBJECT hStimulus = hSender;

		if( IsPlayer(hSender) )
		{
			// Run the alarm's player-activate command.

			if( m_hstrPlayerActivateCommand )
			{
				const char *szCmd = g_pLTServer->GetStringData( m_hstrPlayerActivateCommand );

				if( g_pCmdMgr->IsValidCmd( szCmd ) )
				{
					g_pCmdMgr->Process( szCmd, m_hObject, m_hObject );
				}
			}
		}
		else
		{
			// The stimulus is the target of the AI who activated the alarm.

			CAI* pAI = (CAI*)g_pLTServer->HandleToObject(hSender);
			hStimulus = pAI->GetTarget()->GetObject();
		}

		// Ensure that lists of Alert and Respond regions are set up.

		if( ( m_fRegionsGroupRadius == 0.f ) && 
			( ( m_lstAlertRegions.size() > 0 ) || 
			( m_lstRespondRegions.size() > 0 ) || 
			( m_lstSearchRegions.size() > 0 ) ) ) 
		{
			CalculateRegionsGroupRadius();
		}

		// Place an alarm stimulus.
		// The stimulus position and radius are set to values that encompass
		// all of the regions affected by the alarm.

		g_pAIStimulusMgr->RegisterStimulus(kStim_EnemyAlarmSound, hStimulus, m_hObject, m_vRegionsGroupCenter, m_fRegionsGroupRadius, m_fAlarmSoundTime);
		AITRACE( AIShowAlarms, ( m_hObject, "Triggering alarm" ) );
	}
	else if ( cMsg.GetArg(0) == s_cTok_Lock )
	{
		m_bLocked = LTTRUE;
	}
	else if ( cMsg.GetArg(0) == s_cTok_Unlock )
	{
		m_bLocked = LTFALSE;
	}
	else
		return Prop::OnTrigger(hSender, cMsg);

	return true;
}
开发者ID:emoose,项目名称:lithtech,代码行数:73,代码来源:Alarm.cpp

示例2: ActivateGoal

void CAIGoalDrawWeapon::ActivateGoal()
{
	super::ActivateGoal();

	// Bail if no holstered weapon, or already have a weapon armed.

	if( ( !m_pAI->HasHolsterString() ) ||
		( m_pAI->GetPrimaryWeapon() ) )
	{
		m_fCurImportance = 0.f;
		return;
	}

//	ASSERT(m_hStimulusSource != LTNULL);

	// Ignore senses other than see enemy.
	m_pAI->SetCurSenseFlags( kSense_SeeEnemy | kSense_SeeDangerousProjectile | kSense_SeeCatchableProjectile );

	m_pGoalMgr->LockGoal( this );

	// Set Draw state.

	m_pAI->SetState( kState_HumanDraw );

	if( m_pAI->GetAlarmLevel() >= m_pAI->GetBrain()->GetMajorAlarmThreshold() )
	{
		m_pAI->SetAwareness( kAware_Alert );
	}

	// If stimulated by an AI, target whatever he is targeting.

	if( IsAI( m_hStimulusSource ) )
	{
		CAI* pAI = (CAI*)g_pLTServer->HandleToObject( m_hStimulusSource );
		if( pAI )
		{
			if( pAI->HasTarget() )
			{
				m_pAI->Target( pAI->GetTarget()->GetObject() );
			}
		}
	}
	
	else if( IsCharacter( m_hStimulusSource ) )
	{
		// Only set a target to turn towards for specified senses.

		switch( m_eSenseType )
		{
			case kSense_SeeEnemy:
			case kSense_SeeEnemyLean:
			case kSense_HearEnemyWeaponFire:
			case kSense_HearEnemyFootstep:
				{
					// Only target hated characters.

					CCharacter *pChar = (CCharacter*)g_pLTServer->HandleToObject( m_hStimulusSource );
					if( pChar )
					{
						CharacterAlignment eAlignment = GetAlignment( pChar->GetRelationSet(), m_pAI->GetRelationData() );
						if( eAlignment == HATE )
						{
							m_pAI->Target( m_hStimulusSource );

							CAIHumanStateDraw* pStateDraw = (CAIHumanStateDraw*)m_pAI->GetState();
							pStateDraw->SetFaceTarget( LTTRUE );
						}
					}
				}
				break;
		}
	}
}
开发者ID:rickyharis39,项目名称:nolf2,代码行数:73,代码来源:AIGoalDrawWeapon.cpp


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