//-----------------------------------------------------------------------------
// Compute the number of respawn stations on this team
//-----------------------------------------------------------------------------
int CSensorTFTeam::ComputeRespawnCount()
{
	int nCount = 0;
	for (int i = m_pTeam->GetNumObjects(); --i >= 0; )
	{
		CBaseObject *pObject = m_pTeam->GetObject(i);
		if ( pObject && (pObject->GetType() == OBJ_RESPAWN_STATION) )
		{
			++nCount;
		}
	}
	return nCount;
}
Ejemplo n.º 2
0
bool OrderCreator_GenericObject( 
	CPlayerClass *pClass, 
	int objectType, 
	float flMaxDist,
	COrder *pOrder
	)
{
	// Can we build one?
	if ( pClass->CanBuild( objectType ) != CB_CAN_BUILD )
		return false;

	CBaseTFPlayer *pPlayer = pClass->GetPlayer();
	CTFTeam *pTeam = pClass->GetTeam();

	// Sort nearby objects.
	CSortBase info;
	info.m_pPlayer = pPlayer;
	info.m_flMaxDist = flMaxDist;
	info.m_ObjectType = objectType;

	int sorted[MAX_TEAM_OBJECTS];
	int nSorted = BuildSortedActiveList(
		sorted,									// the sorted list of objects
		MAX_TEAM_OBJECTS,
		SortFn_DistanceAndConcentration,		// sort on distance and entity concentration
		IsValidFn_NearAndNotCovered,			// filter function
		&info,									// user data
		pTeam->GetNumObjects()					// number of objects to check
		);

	if( nSorted )
	{
		// Ok, make an order to cover the closest object with a sentry gun.
		CBaseEntity *pEnt = pTeam->GetObject( sorted[0] );

		pTeam->AddOrder( 
			ORDER_BUILD,
			pEnt,
			pPlayer,
			flMaxDist,
			60,
			pOrder
			);

		return true;
	}
	else
	{
		return false;
	}
}