本文整理汇总了C++中CAI_BaseNPC::GetFaction方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI_BaseNPC::GetFaction方法的具体用法?C++ CAI_BaseNPC::GetFaction怎么用?C++ CAI_BaseNPC::GetFaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI_BaseNPC
的用法示例。
在下文中一共展示了CAI_BaseNPC::GetFaction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShouldDiscardMemory
bool CAI_Enemies::ShouldDiscardMemory( AI_EnemyInfo_t *pMemory )
{
CBaseEntity *pEnemy = pMemory->hEnemy;
if ( pEnemy )
{
CAI_BaseNPC *pEnemyNPC = pEnemy->MyNPCPointer();
if ( pEnemyNPC )
{
if ( pEnemyNPC->GetState() == NPC_STATE_DEAD )
return true;
// forget about the enemy if he changes faction
if ( pEnemyNPC->GetFaction() != pMemory->nFaction )
return true;
}
}
else
{
if ( !pMemory->bDangerMemory )
return true;
}
if ( !pMemory->bUnforgettable &&
gpGlobals->curtime > pMemory->timeLastSeen + m_flEnemyDiscardTime )
{
return true;
}
return false;
}
示例2: UpdateMemory
bool CAI_Enemies::UpdateMemory(CAI_Network* pAINet, CBaseEntity *pEnemy, const Vector &vPosition, float reactionDelay, bool firstHand )
{
if ( pEnemy == AI_UNKNOWN_ENEMY )
pEnemy = NULL;
const float DIST_TRIGGER_REACQUIRE_SQ = Square(20.0 * 12.0);
const float TIME_TRIGGER_REACQUIRE = 4.0;
const float MIN_DIST_TIME_TRIGGER_REACQUIRE_SQ = Square(4.0 * 12.0);
AI_EnemyInfo_t *pMemory = Find( pEnemy );
// -------------------------------------------
// Otherwise just update my own
// -------------------------------------------
// Update enemy information
if ( pMemory )
{
Assert(pEnemy || pMemory->bDangerMemory == true);
if ( firstHand )
pMemory->timeLastSeen = gpGlobals->curtime;
pMemory->bEludedMe = false;
float deltaDist = (pMemory->vLastKnownLocation - vPosition).LengthSqr();
if (deltaDist>DIST_TRIGGER_REACQUIRE_SQ || ( deltaDist>MIN_DIST_TIME_TRIGGER_REACQUIRE_SQ && ( gpGlobals->curtime - pMemory->timeLastSeen ) > TIME_TRIGGER_REACQUIRE ) )
{
pMemory->timeLastReacquired = gpGlobals->curtime;
}
// Only update if the enemy has moved
if (deltaDist>Square(12.0))
{
pMemory->vLastKnownLocation = vPosition;
}
// Update the time at which we first saw him firsthand
if ( firstHand && pMemory->timeAtFirstHand == AI_INVALID_TIME )
{
pMemory->timeAtFirstHand = gpGlobals->curtime;
}
return false;
}
// If not on my list of enemies add it
AI_EnemyInfo_t *pAddMemory = new AI_EnemyInfo_t;
pAddMemory->vLastKnownLocation = vPosition;
if ( firstHand )
{
pAddMemory->timeLastReacquired = pAddMemory->timeFirstSeen = pAddMemory->timeLastSeen = pAddMemory->timeAtFirstHand = gpGlobals->curtime;
}
else
{
// Block free knowledge
pAddMemory->timeLastReacquired = pAddMemory->timeFirstSeen = pAddMemory->timeLastSeen = ( gpGlobals->curtime - (m_flFreeKnowledgeDuration + 0.01) );
pAddMemory->timeAtFirstHand = AI_INVALID_TIME;
}
if ( reactionDelay > 0.0 )
pAddMemory->timeValidEnemy = gpGlobals->curtime + reactionDelay;
pAddMemory->bEludedMe = false;
// I'm either remembering a position of an enemy or just a danger position
pAddMemory->hEnemy = pEnemy;
pAddMemory->bDangerMemory = ( pEnemy == NULL );
if ( pEnemy )
{
CAI_BaseNPC *pEnemyNPC = pEnemy->MyNPCPointer();
if ( pEnemyNPC )
pAddMemory->nFaction = pEnemyNPC->GetFaction();
}
// add to the list
m_Map.Insert( pEnemy, pAddMemory );
m_serial++;
return true;
}