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


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

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


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

示例1: DeactivateGoal

void CAIGoalCircleFlamePot::DeactivateGoal()
{
	super::DeactivateGoal();

	// If:
	// 1) The player is an enemy.
	// 2) There is another AI very close by
	// 3) That AI does not have a blitz task
	// ...this AI should blitz the player.  This is an anti-clumping measure.

	HOBJECT hTarget = m_pAI->GetAIBlackBoard()->GetBBTargetObject();

	bool bShouldBlitz = false;

	if ( m_pAI->HasTarget( kTarget_Character ) 
		&& IsPlayer( hTarget ) )
	{
		CAI::AIList::const_iterator itEachAI = CAI::GetAIList().begin();
		CAI::AIList::const_iterator itLastAI = CAI::GetAIList().end();
		for ( ; itEachAI != itLastAI; ++itEachAI )
		{
			CAI* pCurrentAI = *itEachAI;

			// Ignore NULL, self and dead AI.

			if ( NULL == pCurrentAI 
				|| pCurrentAI == m_pAI 
				|| IsDeadAI( pCurrentAI->GetHOBJECT() ) )
			{
				continue;
			}

			// Ignore AIs who are far away in 2D (false positives are okay).

			LTVector vDelta2D = ( pCurrentAI->GetPosition() - m_pAI->GetPosition() );
			vDelta2D.y = 0.0f;

			if ( vDelta2D.MagSqr() > g_flTooCloseToEnemySqr )
			{
				continue;
			}

			// Ignore AI who are already blitzing.

			CAIWMFact factQuery;
			factQuery.SetFactType( kFact_Task );
			factQuery.SetTaskType( kTask_BlitzCharacter );
			if ( pCurrentAI->GetAIWorkingMemory()->FindWMFact( factQuery ) )
			{
				continue;
			}

			// AI should blitz.

			bShouldBlitz = true;
			break;
		}
	}

	if ( bShouldBlitz || ( 0 == GetRandom( 0, 2 ) ) )
	{
		CAIWMFact factQuery;
		factQuery.SetFactType( kFact_Task );
		factQuery.SetTaskType( kTask_BlitzCharacter );
		CAIWMFact* pFact = m_pAI->GetAIWorkingMemory()->CreateWMFact( kFact_Task );
		if ( pFact )
		{
			pFact->SetTaskType( kTask_BlitzCharacter );
			pFact->SetTargetObject( hTarget );
			pFact->SetIndex( kContext_None );
			pFact->SetFactFlags( kFactFlag_Scripted, 1.f );
		}
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:74,代码来源:AIGoalCircleFlamePot.cpp


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