Пример #1
0
void CASW_Spawn_Manager::Update()
{
    if ( m_iHordeToSpawn > 0 )
    {
        if ( m_vecHordePosition != vec3_origin && ( !m_batchInterval.HasStarted() || m_batchInterval.IsElapsed() ) )
        {
            int iToSpawn = MIN( m_iHordeToSpawn, asw_max_alien_batch.GetInt() );
            int iSpawned = SpawnAlienBatch( asw_horde_class.GetString(), iToSpawn, m_vecHordePosition, m_angHordeAngle, 0 );
            m_iHordeToSpawn -= iSpawned;
            if ( m_iHordeToSpawn <= 0 )
            {
                ASWDirector()->OnHordeFinishedSpawning();
                m_vecHordePosition = vec3_origin;
            }
            else if ( iSpawned == 0 )			// if we failed to spawn any aliens, then try to find a new horde location
            {
                if ( asw_director_debug.GetBool() )
                {
                    Msg( "Horde failed to spawn any aliens, trying new horde position.\n" );
                }
                if ( !FindHordePosition() )		// if we failed to find a new location, just abort this horde
                {
                    m_iHordeToSpawn = 0;
                    ASWDirector()->OnHordeFinishedSpawning();
                    m_vecHordePosition = vec3_origin;
                }
            }
            m_batchInterval.Start( asw_batch_interval.GetFloat() );
        }
        else if ( m_vecHordePosition == vec3_origin )
        {
            Msg( "Warning: Had horde to spawn but no position, clearing.\n" );
            m_iHordeToSpawn = 0;
            ASWDirector()->OnHordeFinishedSpawning();
        }
    }

    if ( asw_director_debug.GetBool() )
    {
        engine->Con_NPrintf( 14, "SM: Batch interval: %f pos = %f %f %f\n", m_batchInterval.HasStarted() ? m_batchInterval.GetRemainingTime() : -1, VectorExpand( m_vecHordePosition ) );
    }

    if ( m_iAliensToSpawn > 0 )
    {
        if (wandererSize() < WANDERER_QUEUE_SIZE-1) {
            queueWanderers();
            m_iAliensToSpawn--;
        }

    }

    if (wandererQueueStart != wandererQueueEnd) {
        while ( wandererQueueStart != wandererQueueEnd && SpawnAlientAtRandomNode());
    }
}
Пример #2
0
void CASW_Spawn_Manager::Update()
{
	if ( m_iHordeToSpawn > 0 )
	{		
		if ( m_vecHordePosition != vec3_origin && ( !m_batchInterval.HasStarted() || m_batchInterval.IsElapsed() ) )
		{
			int iToSpawn = MIN( m_iHordeToSpawn, asw_max_alien_batch.GetInt() );
			int iSpawned = SpawnAlienBatch( asw_horde_class.GetString(), iToSpawn, m_vecHordePosition, m_angHordeAngle, 0 );
			if (asw_director_debug.GetInt() >= 4)
				Msg("spawned %d/%d %s (horde) at (%f, %f, %f)\n", iSpawned, m_iHordeToSpawn, asw_horde_class.GetString(), VectorExpand(m_vecHordePosition));
			m_iHordeToSpawn -= iSpawned;

			for (int i = 0; i < iSpawned; i++)
			{
				if (RandomFloat() < asw_horde_wanderers.GetFloat())
				{
					KeyValues *pWanderer = RandomWanderer();
					if (pWanderer)
					{
						FOR_EACH_TRUE_SUBKEY(pWanderer, pNPC)
						{
							if (V_stricmp(pNPC->GetName(), "NPC"))
							{
								Warning("Spawn Manager ignoring non-NPC key in WANDERER definition: %s\n", pNPC->GetName());
								continue;
							}

							const char *szAlienClass = pNPC->GetString("AlienClass");
							if (SpawnAlienAt(szAlienClass, m_vecHordePosition + Vector(0, 0, !V_stricmp(szAlienClass, "asw_buzzer") ? 128 : 32), m_angHordeAngle, pNPC))
							{
								if (asw_director_debug.GetInt() >= 4)
								{
									Msg("spawned %s (horde wanderer) at (%f, %f, %f)\n", szAlienClass, VectorExpand(m_vecHordePosition));
								}
							}
						}
					}
					else
					{
						const char *szAlienClass = asw_wanderer_class.GetString();
						if (SpawnAlienAt(szAlienClass, m_vecHordePosition + Vector(0, 0, !V_stricmp(szAlienClass, "asw_buzzer") ? 128 : 32), m_angHordeAngle))
						{
							if (asw_director_debug.GetInt() >= 4)
							{
								Msg("spawned %s (horde wanderer) at (%f, %f, %f)\n", szAlienClass, VectorExpand(m_vecHordePosition));
							}
						}
					}
				}
			}