本文整理汇总了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;
}
示例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;
}
}
}