Exemplo n.º 1
0
AINode* CAIGoalAttackProp::HandleGoalAttractors()
{
	// Check if already attacking a prop.
	if( m_pAI->GetState()->GetStateType() != kState_HumanAttackProp )
	{
		CAIHuman* pAIHuman = (CAIHuman*)m_pAI;
		if( pAIHuman->HasHolsterString() || pAIHuman->GetPrimaryWeapon())
		{
			AIGBM_GoalTemplate* pTemplate = g_pAIGoalButeMgr->GetTemplate( GetGoalType() );
			AIASSERT(pTemplate->cAttractors > 0, m_pAI->m_hObject, "CAIGoalAbstract::HandleGoalAttractors: Goal has no attractors.");

			// Check if attractors are triggering activateability.
			AINode* pNode;
			for(uint32 iAttractor=0; iAttractor < pTemplate->cAttractors; ++iAttractor)
			{
				pNode = g_pAINodeMgr->FindNearestNodeInRadius(m_pAI, pTemplate->aAttractors[iAttractor], m_pAI->GetPosition(), pTemplate->fAttractorDistSqr * m_fBaseImportance, LTTRUE);
				if(pNode != LTNULL)
				{
					HOBJECT hObject;
					if ( LT_OK == FindNamedObject(pNode->GetObject(), hObject) )
					{
						Prop* pProp = (Prop*)g_pLTServer->HandleToObject(hObject);
						if(pProp->GetState() != kState_PropDestroyed)
						{
							AIASSERT(pNode->GetType() == kNode_UseObject, m_pAI->m_hObject, "CAIGoalAttackProp::HandleGoalAttractors: AINode is not of type UseObject.");
							m_hNode = pNode->m_hObject;
							SetCurToBaseImportance();
							return pNode;
						}
					}
					
					// Disable node if prop has been destroyed.
					pNode->Disable();				
				}
			}
		}

		m_hNode = LTNULL;
	}
	return LTNULL;
}
Exemplo n.º 2
0
void CAIGoalAttackProp::HandleStateAttackProp()
{
	switch( m_pAI->GetState()->GetStateStatus() )
	{
		case kSStat_Initialized:
			break;

		case kSStat_StateComplete:	
			{
				// Disable node when prop has been destroyed.

				AINode* pNode = (AINode*)g_pLTServer->HandleToObject(m_hNode);
				pNode->Disable();
				m_hNode = LTNULL;
				m_fCurImportance = 0.f;
			}
			break;

		// Unexpected StateStatus.
		default: AIASSERT(0, m_pAI->m_hObject, "CAIGoalAttackProp::HandleStateAttackProp: Unexpected State Status.");
	}
}