本文整理汇总了C++中CAI::GetAIBlackBoard方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI::GetAIBlackBoard方法的具体用法?C++ CAI::GetAIBlackBoard怎么用?C++ CAI::GetAIBlackBoard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI
的用法示例。
在下文中一共展示了CAI::GetAIBlackBoard方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitActivity
void CAIActivityAbstract::InitActivity()
{
// Find squad members who could be potential participants of this activity.
LTObjRef* pSquadMembers = m_pSquad->GetSquadMembers();
int cSquadMembers = m_pSquad->GetNumSquadMembers();
CAI* pCurAI;
m_cPotentialParticipants = 0;
for( int iMember=0; iMember < cSquadMembers; ++iMember )
{
pCurAI = (CAI*)g_pLTServer->HandleToObject( pSquadMembers[iMember] );
if( !pCurAI )
{
continue;
}
// Add AI to list if he has this activity in his activity set.
ENUM_AIActivitySet eActivitySet = pCurAI->GetAIBlackBoard()->GetBBAIActivitySet();
if( g_pAICoordinator->IsActivityInAIActivitySet( eActivitySet, GetActivityClassType() ) )
{
m_aPotentialParticipants[m_cPotentialParticipants] = pCurAI->m_hObject;
++m_cPotentialParticipants;
}
}
}
示例2: Load
void CAIWeaponAbstract::Load(ILTMessage_Read *pMsg)
{
HOBJECT hOwner = NULL;
HWEAPON hWeapon = NULL;
LOAD_HOBJECT(hOwner);
LOAD_HRECORD( hWeapon, g_pWeaponDB->GetWeaponsCategory() );
LOAD_STDSTRING(m_szFireSocketName);
LOAD_INT_CAST(m_eFiringState, ENUM_AIFiringState);
LOAD_DWORD(m_iAnimRandomSeed);
LOAD_TIME(m_fRandomSeedSelectionTime);
LOAD_FLOAT(m_flWeaponContextInaccuracyScalar);
LOAD_DWORD(m_hWeaponSocket);
LOAD_bool(m_bCanDropWeapon);
ASSERT(IsAI(hOwner));
CAI* pAI = (CAI*)g_pLTServer->HandleToObject(hOwner);
ASSERT(pAI->GetArsenal());
if (pAI)
{
ASSERT(pAI->GetArsenal());
if (CArsenal* pArsenal = pAI->GetArsenal())
{
m_pWeapon = pArsenal->GetWeapon(hWeapon);
}
}
if( m_pWeapon )
{
m_pAIWeaponRecord = AIWeaponUtils::GetAIWeaponRecord(
m_pWeapon->GetWeaponRecord(),
pAI->GetAIBlackBoard()->GetBBAIWeaponOverrideSet() );
}
}
示例3: AllPlayersTargeted
static bool AllPlayersTargeted( CAI* pIgnoreThisAI )
{
CPlayerObj::PlayerObjList::const_iterator itEachPlayer = CPlayerObj::GetPlayerObjList().begin();
CPlayerObj::PlayerObjList::const_iterator itEndPlayer = CPlayerObj::GetPlayerObjList().end();
for ( ; itEachPlayer != itEndPlayer; ++itEachPlayer )
{
// Ignore this player if they are not valid or if they are not alive.
CCharacter* pPlayer = *itEachPlayer;
if ( NULL == pPlayer
|| IsDeadCharacter( pPlayer->GetHOBJECT() ) )
{
continue;
}
HOBJECT hPlayer = pPlayer->GetHOBJECT();
// See if any AIs are targeting the player.
bool bPlayerTargeted = false;
CAI::AIList::const_iterator itEachAI = CAI::GetAIList().begin();
CAI::AIList::const_iterator itEndAI = CAI::GetAIList().end();
for ( ; itEachAI != itEndAI; ++itEachAI )
{
CAI* pCurrentAI = *itEachAI;
if ( NULL == pCurrentAI )
{
continue;
}
if ( pCurrentAI == pIgnoreThisAI )
{
continue;
}
if ( pCurrentAI->GetAIBlackBoard()->GetBBTargetObject() != hPlayer )
{
continue;
}
bPlayerTargeted = true;
break;
}
if ( false == bPlayerTargeted )
{
// Found an untargeted player. Not all players are targeted.
return false;
}
}
// All players are targeted.
return true;
}
示例4: SelectDisturbanceSource
HOBJECT CAITargetSelectDisturbanceBeyondGuard::SelectDisturbanceSource( CAI* pAI, CAIWMFact* pFact )
{
// Sanity check.
if( !( pAI && pFact ) )
{
return NULL;
}
// Disturbance is not from an AI.
if( !IsAI( pFact->GetTargetObject() ) )
{
return pFact->GetTargetObject();
}
// AI is not an ally.
CAI* pOther = (CAI*)g_pLTServer->HandleToObject( pFact->GetTargetObject() );
EnumCharacterStance eStance = g_pCharacterDB->GetStance( pAI->GetAlignment(), pOther->GetAlignment() );
if( eStance != kCharStance_Like )
{
return pFact->GetTargetObject();
}
// Ally is not targeting a character.
if( pOther->GetAIBlackBoard()->GetBBTargetType() != kTarget_Character )
{
return pFact->GetTargetObject();
}
// Return the Ally's target object.
return pOther->GetAIBlackBoard()->GetBBTargetObject();
}
示例5: Activate
void CAITargetSelectCharacterSquad::Activate( CAI* pAI )
{
super::Activate( pAI );
// Sanity check.
if( !pAI )
{
return;
}
// Bail if AI is not in a squad.
ENUM_AI_SQUAD_ID eSquad = g_pAICoordinator->GetSquadID( pAI->m_hObject );
CAISquad* pSquad = g_pAICoordinator->FindSquad( eSquad );
if( !pSquad )
{
return;
}
// Find a squad member targeting a character.
CAI* pMember = NULL;
bool bTargetingCharacter = false;
uint32 cMembers = pSquad->GetNumSquadMembers();
LTObjRef* pMembers = pSquad->GetSquadMembers();
if( pMembers )
{
for( uint32 iMember=0; iMember < cMembers; ++iMember )
{
pMember = (CAI*)g_pLTServer->HandleToObject( pMembers[iMember] );
if( pMember && pMember->HasTarget( kTarget_Character ) )
{
break;
}
}
}
// Bail if we failed to find a squad member.
if( !pMember )
{
return;
}
// Bail if squad member is not targeting a character.
if( !pMember->HasTarget( kTarget_Character ) )
{
return;
}
HOBJECT hTarget = pMember->GetAIBlackBoard()->GetBBTargetObject();
// Bail if squad member has no memory of the character.
CAIWMFact factQuery;
factQuery.SetFactType( kFact_Character );
factQuery.SetTargetObject( hTarget );
CAIWMFact* pFact = pMember->GetAIWorkingMemory()->FindWMFact( factQuery );
if( !pFact )
{
return;
}
// Create a memory for this character.
CAIWMFact* pTargetFact;
pTargetFact = pAI->GetAIWorkingMemory()->CreateWMFact( kFact_Character );
pTargetFact->SetTargetObject( hTarget, 1.f );
EnumAIStimulusID eStimulusID;
EnumAIStimulusType eStimulusType;
pFact->GetStimulus( &eStimulusType, &eStimulusID );
pTargetFact->SetStimulus( eStimulusType, eStimulusID, 0.f );
pTargetFact->SetPos( pFact->GetPos(), 1.f );
pTargetFact->SetRadius( 0.f, 1.f );
// Target the character.
TargetCharacter( pAI, pTargetFact );
}
示例6: TargetDisturbance
void CAITargetSelectDisturbance::TargetDisturbance( CAI* pAI, CAIWMFact* pFact )
{
// Sanity check.
if( !( pAI && pFact ) )
{
return;
}
// Record the existence of a disturbance in the AI's world state.
pAI->GetAIWorldState()->SetWSProp( kWSK_DisturbanceExists, pAI->m_hObject, kWST_bool, true );
// Play a sound corresponding to the type of stimulus.
EnumAIStimulusID eStimulusID;
EnumAIStimulusType eStimulusType;
pFact->GetStimulus( &eStimulusType, &eStimulusID );
switch( eStimulusType )
{
case kStim_WeaponFireSound:
case kStim_WeaponImpactSound:
case kStim_WeaponReloadSound:
case kStim_DisturbanceSound:
case kStim_FootstepSound:
case kStim_DeathSound:
case kStim_PainSound:
{
HOBJECT hAlly = g_pAICoordinator->FindAlly( pAI->m_hObject, NULL );
if( hAlly )
{
// "Check it out!"
// "Roger!"
g_pAISoundMgr->RequestAISound( pAI->m_hObject, kAIS_OrderInvestigate, kAISndCat_DisturbanceHeard, NULL, 1.f );
g_pAISoundMgr->RequestAISoundSequence( hAlly, kAIS_Affirmative, pAI->m_hObject, kAIS_OrderInvestigate, kAIS_OrderInvestigate, kAISndCat_Event, NULL, 0.3f );
}
else {
// "What was that?"
g_pAISoundMgr->RequestAISound( pAI->m_hObject, kAIS_DisturbanceHeardAlarming, kAISndCat_DisturbanceHeard, NULL, 1.f );
}
}
break;
// "Flashlight!"
case kStim_FlashlightBeamVisible:
{
g_pAISoundMgr->RequestAISound( pAI->m_hObject, kAIS_DisturbanceSeenFlashlight, kAISndCat_Event, NULL, 0.5f );
HOBJECT hAlly = g_pAICoordinator->FindAlly( pAI->m_hObject, NULL );
if( hAlly )
{
// "Check it out!"
// "Roger!"
g_pAISoundMgr->RequestAISoundSequence( hAlly, kAIS_OrderInvestigate, pAI->m_hObject, kAIS_DisturbanceSeenFlashlight, kAIS_DisturbanceSeenFlashlight, kAISndCat_DisturbanceHeard, NULL, 0.3f );
g_pAISoundMgr->RequestAISoundSequence( pAI->m_hObject, kAIS_Affirmative, hAlly, kAIS_OrderInvestigate, kAIS_DisturbanceSeenFlashlight, kAISndCat_Event, NULL, 0.3f );
}
}
break;
}
// Record new target on the BlackBoard.
pAI->GetAIBlackBoard()->SetBBTargetType( kTarget_Disturbance );
pAI->GetAIBlackBoard()->SetBBTargetStimulusType( eStimulusType );
pAI->GetAIBlackBoard()->SetBBTargetStimulusID( eStimulusID );
pAI->GetAIBlackBoard()->SetBBTargetChangeTime( g_pLTServer->GetTime() );
pAI->GetAIBlackBoard()->SetBBTargetObject( pFact->GetTargetObject() );
// Record initial disturbance position.
// If the stimulus is dynamic, AITarget will track its movement.
LTVector vTargetPos = pFact->GetPos();
pAI->GetAIBlackBoard()->SetBBTargetPosition( vTargetPos );
// If the disturbance is coming from an ally's weapon fire sound,
// then treat the disturbance position as the position of whatever
// the ally is firing at.
if( IsAI( pFact->GetTargetObject() ) )
{
CAI* pOtherAI = (CAI*)g_pLTServer->HandleToObject( pFact->GetTargetObject() );
if( pOtherAI &&
pOtherAI->HasTarget( kTarget_Character ) &&
( eStimulusType == kStim_WeaponFireSound ) &&
( kCharStance_Like == g_pCharacterDB->GetStance( pAI->GetAlignment(), pOtherAI->GetAlignment() ) ) )
{
LTVector vTargetPos = pOtherAI->GetAIBlackBoard()->GetBBTargetPosition();
pAI->GetAIBlackBoard()->SetBBTargetPosition( vTargetPos );
pFact->SetPos( vTargetPos, 1.f );
}
}
}