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


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

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


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

示例1: StartTask

//---------------------------------------------------------
// Purpose: 
//---------------------------------------------------------
void CNPC_Assassin::StartTask( const Task_t *pTask )
{
	switch( pTask->iTask )
	{
	case TASK_ASSASSIN_SET_EYE_STATE:
		{
			SetEyeState( (eyeState_t) ( (int) pTask->flTaskData ) );
			TaskComplete();
		}
		break;

	case TASK_ASSASSIN_EVADE:
		{
			Activity flipAct = ACT_INVALID;

			const Vector *avoidPos = ( GetEnemy() != NULL ) ? &(GetEnemy()->GetAbsOrigin()) : NULL;

			for ( int i = FLIP_LEFT; i < NUM_FLIP_TYPES; i++ )
			{
				if ( CanFlip( i, flipAct, avoidPos ) )
				{
					// Don't flip back to where we just were
					if ( ( ( i == FLIP_LEFT ) && ( m_nLastFlipType == FLIP_RIGHT ) ) ||
						 ( ( i == FLIP_RIGHT ) && ( m_nLastFlipType == FLIP_LEFT ) ) ||
						 ( ( i == FLIP_FORWARD ) && ( m_nLastFlipType == FLIP_BACKWARD ) ) ||
						 ( ( i == FLIP_BACKWARD ) && ( m_nLastFlipType == FLIP_FORWARD ) ) )
					{
						flipAct = ACT_INVALID;
						continue;
					}

					m_nNumFlips--;
					ResetIdealActivity( flipAct );
					m_flNextFlipTime = gpGlobals->curtime + 2.0f;
					m_nLastFlipType = i;
					break;
				}
			}

			if ( flipAct == ACT_INVALID )
			{
				m_nNumFlips = 0;
				m_nLastFlipType = -1;
				m_flNextFlipTime = gpGlobals->curtime + 2.0f;
				TaskFail( "Unable to find flip evasion direction!\n" );
			}
		}
		break;

	case TASK_ASSASSIN_GET_PATH_TO_VANTAGE_POINT:
		{
			assert( GetEnemy() != NULL );
			if ( GetEnemy() == NULL )
				break;

			Vector	goalPos;

			CHintCriteria	hint;

			// Find a disadvantage node near the player, but away from ourselves
			hint.SetHintType( HINT_TACTICAL_ENEMY_DISADVANTAGED );
			hint.AddExcludePosition( GetAbsOrigin(), 256 );
			hint.AddExcludePosition( GetEnemy()->GetAbsOrigin(), 256 );

			if ( ( m_pSquad != NULL ) && ( m_pSquad->NumMembers() > 1 ) )
			{
				AISquadIter_t iter;
				for ( CAI_BaseNPC *pSquadMember = m_pSquad->GetFirstMember( &iter ); pSquadMember; pSquadMember = m_pSquad->GetNextMember( &iter ) )
				{
					if ( pSquadMember == NULL )
						continue;

					hint.AddExcludePosition( pSquadMember->GetAbsOrigin(), 128 );
				}
			}
	
			hint.SetFlag( bits_HINT_NODE_NEAREST );

			CAI_Hint *pHint = CAI_HintManager::FindHint( this, GetEnemy()->GetAbsOrigin(), &hint );

			if ( pHint == NULL )
			{
				TaskFail( "Unable to find vantage point!\n" );
				break;
			}

			pHint->GetPosition( this, &goalPos );

			AI_NavGoal_t goal( goalPos );
			
			//Try to run directly there
			if ( GetNavigator()->SetGoal( goal ) == false )
			{
				TaskFail( "Unable to find path to vantage point!\n" );
				break;
			}
			
//.........这里部分代码省略.........
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:101,代码来源:npc_assassin.cpp

示例2: vecDeltaUp

//-----------------------------------------------------------------------------
// Purpose: 
//
//
// Output : 
//-----------------------------------------------------------------------------
CBaseEntity *CNPC_RollerDozer::FindDebris( void )
{
	if( !m_pHintNode )
	{
		// Detect rubbish near a hint node.
		CAI_Hint* pHintNode = CAI_Hint::FindHint( this, HINT_ROLLER_CLEANUP_POINT, 0, 1024 ); 


		if( pHintNode)
		{
			// Search around the hint node for debris that should be cleared.
			Vector vecHintNodeOrigin;
			
			// Get hint node position
			vecHintNodeOrigin;
			pHintNode->GetPosition(this,&vecHintNodeOrigin);

			CBaseEntity *pList[ 16 ];
			Vector vecDeltaUp( 200, 200, 64 );
			Vector vecDeltaDown( 200, 200, 10 );
			int i;
			IPhysicsObject	*pPhysObj;

			int count = UTIL_EntitiesInBox( pList, 16, vecHintNodeOrigin - vecDeltaDown, vecHintNodeOrigin + vecDeltaUp, 0 );
			
			float m_flHeaviestMass = 0;
			CBaseEntity *pHeaviest = NULL;
			
			for( i = 0 ; i < count ; i++ )
			{
				pPhysObj = pList[ i ]->VPhysicsGetObject();

				if( !pPhysObj || FClassnameIs( pList[ i ], "npc_rollerdozer" ) )
				{
					// Only consider physics objects. Exclude rollers.
					continue;
				}

				if( pPhysObj->GetMass() <= 400 )
				{
					if( pPhysObj->GetMass() > m_flHeaviestMass )
					{
						m_flHeaviestMass = pPhysObj->GetMass();
						pHeaviest = pList[ i ];
					}

/*
					// Report to the cleanup point and doze this piece of debris away.
					SetCondition( COND_ROLLERDOZER_FOUND_DEBRIS );
					m_vecCleanupPoint = vecHintNodeOrigin;


					return pList[ i ];
*/
				}
			}

			if( pHeaviest )
			{
				SetCondition( COND_ROLLERDOZER_FOUND_DEBRIS );
				//NDebugOverlay::Line( GetLocalOrigin(), pHeaviest->GetLocalOrigin(), 255,255,0, true, 3 );
				m_vecCleanupPoint = vecHintNodeOrigin;
				return pHeaviest;
			}
		}
	}

	return NULL;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:75,代码来源:npc_rollerdozer.cpp


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