Example #1
0
void CASW_Director::FrameUpdatePostEntityThink()
{
	// only think when we're in-game
	if ( !ASWGameRules() || ASWGameRules()->GetGameState() != ASW_GS_INGAME )
		return;

	UpdateIntensity();

	if ( ASWSpawnManager() )
	{
		ASWSpawnManager()->Update();
	}

	UpdateMarineRooms();

	if ( !asw_spawning_enabled.GetBool() )
		return;

	UpdateHorde();

	UpdateSpawningState();

	bool bWanderersEnabled = m_bWanderersEnabled || asw_wanderer_override.GetBool();
	if ( bWanderersEnabled )
	{
		UpdateWanderers();
	}
}
Example #2
0
void CASW_Director::LevelInitPreEntity()
{
	if ( ASWSpawnManager() )
	{
		ASWSpawnManager()->LevelInitPreEntity();
	}
}
Example #3
0
void CASW_Director::OnMissionStarted()
{
	// if we have wanders turned on, spawn a couple of encounters
	if ( asw_wanderer_override.GetBool() && ASWGameRules() )
	{
		ASWSpawnManager()->SpawnRandomShieldbug();

		int nParasites = 1;
		switch( ASWGameRules()->GetSkillLevel() )
		{
			case 1: nParasites = RandomInt( 4, 6 ); break;
			default:
			case 2: nParasites = RandomInt( 4, 6 ); break;
			case 3: nParasites = RandomInt( 5, 7 ); break;
			case 4: nParasites = RandomInt( 5, 9 ); break;
			case 5: nParasites = RandomInt( 5, 10 ); break;
		}
		while ( nParasites > 0 )
		{
			int nParasitesInThisPack = RandomInt( 3, 6 );
			if ( ASWSpawnManager()->SpawnRandomParasitePack( nParasitesInThisPack ) )
			{
				nParasites -= nParasitesInThisPack;
			}
			else
			{
				break;
			}
		}
	}
}
Example #4
0
void CASW_Spawner::InitAlienClassName()
{
	if ( m_AlienClassNum < 0 || m_AlienClassNum >= ASWSpawnManager()->GetNumAlienClasses() )
	{
		m_AlienClassNum = 0;
	}

	m_AlienClassName = ASWSpawnManager()->GetAlienClass( m_AlienClassNum )->m_iszAlienClass;
}
Example #5
0
void CASW_Director::LevelInitPostEntity()
{
	Init();

	if ( ASWSpawnManager() )
	{
		ASWSpawnManager()->LevelInitPostEntity();
	}
}
Example #6
0
// creates a batch of aliens at the mouse cursor
void asw_alien_batch_f( const CCommand& args )
{
    MDLCACHE_CRITICAL_SECTION();

    bool allowPrecache = CBaseEntity::IsPrecacheAllowed();
    CBaseEntity::SetAllowPrecache( true );

    // find spawn point
    CASW_Player* pPlayer = ToASW_Player(UTIL_GetCommandClient());
    if (!pPlayer)
        return;
    CASW_Marine *pMarine = pPlayer->GetMarine();
    if (!pMarine)
        return;
    trace_t tr;
    Vector forward;

    AngleVectors( pMarine->EyeAngles(), &forward );
    UTIL_TraceLine(pMarine->EyePosition(),
                   pMarine->EyePosition() + forward * 300.0f,MASK_SOLID,
                   pMarine, COLLISION_GROUP_NONE, &tr );
    if ( tr.fraction != 0.0 )
    {
        // trace to the floor from this spot
        Vector vecSrc = tr.endpos;
        tr.endpos.z += 12;
        UTIL_TraceLine( vecSrc + Vector(0, 0, 12),
                        vecSrc - Vector( 0, 0, 512 ) ,MASK_SOLID,
                        pMarine, COLLISION_GROUP_NONE, &tr );

        ASWSpawnManager()->SpawnAlienBatch( "asw_parasite", 25, tr.endpos, vec3_angle );
    }

    CBaseEntity::SetAllowPrecache( allowPrecache );
}
Example #7
0
void CASW_Director::OnMissionStarted()
{
	// if we have wanders turned on, spawn a couple of encounters
	if ( asw_wanderer_override.GetBool() && ASWGameRules() )
	{
		ASWSpawnManager()->SpawnRandomShieldbug();

		int nParasites = 1;
		switch( ASWGameRules()->GetSkillLevel() )
		{
			case 1: nParasites = RandomInt( 4, 6 ); break;
			default:
			case 2: nParasites = RandomInt( 4, 6 ); break;
			case 3: nParasites = RandomInt( 5, 7 ); break;
			case 4: nParasites = RandomInt( 5, 9 ); break;
			case 5: nParasites = RandomInt( 5, 10 ); break;
		}
		while ( nParasites > 0 )
		{
			int nParasitesInThisPack = RandomInt( 3, 6 );
			if ( ASWSpawnManager()->SpawnRandomParasitePack( nParasitesInThisPack ) )
			{
				nParasites -= nParasitesInThisPack;
			}
			else
			{
				break;
			}
		}
	}

	if (ASWGameRules()->m_iPrespawnScale)
	{
		// spawn random parasites 7, boomers 3, mortars 3, harvesters 4, 
		// drones 15, uber drones 2, shieldbug 1, shaman 7, flies 3

		ASWSpawnManager()->PrespawnAliens(ASWGameRules()->m_iPrespawnScale);
		// get num nodes
		// get random node
		// check if it's far enough from player start, 1000 units
		// check if valid spawn point for an alien
		// spawn alien
	}
}
Example #8
0
void CASW_Director::UpdateWanderers()
{
	if ( !m_bSpawningAliens )
	{
		if ( asw_director_debug.GetInt() > 0 )
		{
			engine->Con_NPrintf( 9, "Not spawning regular aliens" );
		}
		return;
	}

	// spawn an alien every so often
	if ( !m_AlienSpawnTimer.HasStarted() || m_AlienSpawnTimer.IsElapsed() )
	{
		if ( m_fTimeBetweenAliens == 0 )
		{
			// initial time between alien spawns
			m_fTimeBetweenAliens = RandomFloat( asw_interval_initial_min.GetFloat(), asw_interval_initial_max.GetFloat() );
		}
		else
		{
			// reduce the time by some random amount each interval
			m_fTimeBetweenAliens = MAX( asw_interval_min.GetFloat(),
										m_fTimeBetweenAliens * RandomFloat( asw_interval_change_min.GetFloat(), asw_interval_change_max.GetFloat() ) );
		}
		if ( asw_director_debug.GetInt() > 0 )
		{
			engine->Con_NPrintf( 9, "Regular spawn interval = %f", m_fTimeBetweenAliens );
		}

		m_AlienSpawnTimer.Start( m_fTimeBetweenAliens );

		if ( ASWSpawnManager() )
		{
			if ( ASWSpawnManager()->GetAwakeDrones() < 20 )
			{
				ASWSpawnManager()->AddAlien();
			}
		}
	}
}
Example #9
0
void asw_alien_horde_f( const CCommand& args )
{
    if ( args.ArgC() < 2 )
    {
        Msg("supply horde size!\n");
        return;
    }
    if ( !ASWSpawnManager()->AddHorde( atoi(args[1]) ) )
    {
        Msg("Failed to add horde\n");
    }
}
void asw_ClearHousef()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if (!pPlayer)
		return;

	// remove all alien NPCs
	if ( ASWSpawnManager() )
	{
		int nCount = ASWSpawnManager()->GetNumAlienClasses();
		for ( int i = 0; i < nCount; i++ )
		{
			engine->ClientCommand( pPlayer->edict(), CFmtStr( "ent_remove_all %s", ASWSpawnManager()->GetAlienClass(i)->m_pszAlienClass ) );
		}
	}

	// remove non NPC types
	engine->ClientCommand(pPlayer->edict(), "ent_remove_all asw_alien_goo");
	engine->ClientCommand(pPlayer->edict(), "ent_remove_all asw_grub_sac");
	engine->ClientCommand(pPlayer->edict(), "ent_remove_all asw_spawner");
	engine->ClientCommand(pPlayer->edict(), "ent_remove_all asw_egg");
}
Example #11
0
const Vector& CASW_Spawner::GetAlienMaxs()
{
	return NAI_Hull::Maxs( ASWSpawnManager()->GetAlienClass( m_AlienClassNum )->m_nHullType );
}
Example #12
0
void CASW_Director::UpdateHorde()
{
	if ( asw_director_debug.GetInt() > 0 )
	{
		if ( m_bHordeInProgress )
		{
			engine->Con_NPrintf( 11, "Horde in progress.  Left to spawn = %d", ASWSpawnManager()->GetHordeToSpawn() );
		}
		engine->Con_NPrintf( 12, "Next Horde due: %f", m_HordeTimer.GetRemainingTime() );

		engine->Con_NPrintf( 15, "Awake aliens: %d\n", ASWSpawnManager()->GetAwakeAliens() );
		engine->Con_NPrintf( 16, "Awake drones: %d\n", ASWSpawnManager()->GetAwakeDrones() );
	}

	bool bHordesEnabled = m_bHordesEnabled || asw_horde_override.GetBool();
	if ( !bHordesEnabled || !ASWSpawnManager() )
		return;

	if ( !m_HordeTimer.HasStarted() )
	{
		float flDuration = RandomFloat( asw_horde_interval_min.GetFloat(), asw_horde_interval_max.GetFloat() );
		if ( m_bFinale )
		{
			flDuration = RandomFloat( 5.0f, 10.0f );
		}
		if ( asw_director_debug.GetBool() )
		{
			Msg( "Will be spawning a horde in %f seconds\n", flDuration );
		}
		m_HordeTimer.Start( flDuration );
	}
	else if ( m_HordeTimer.IsElapsed() )
	{
		if ( ASWSpawnManager()->GetAwakeDrones() < 25 )
		{
			int iHordeScale = MAX(1, ASWGameRules()->m_iHordeScale);
			int iNumAliens = RandomInt(asw_horde_size_min.GetInt() * iHordeScale, asw_horde_size_max.GetInt() * iHordeScale);

			// riflemod: scale down horde size for solo game mode
			if (ASWGameRules()->m_iNumPlayers == 1)
				iNumAliens /= 2;

			if ( ASWSpawnManager()->AddHorde( iNumAliens ) )
			{
				if ( asw_director_debug.GetBool() )
				{
					Msg("Created horde of size %d\n", iNumAliens);
				}
				m_bHordeInProgress = true;

				if ( ASWGameRules() )
				{
					ASWGameRules()->BroadcastSound( "Spawner.Horde" );
				}
				m_HordeTimer.Invalidate();
			}
			else
			{
				// if we failed to find a horde position, try again shortly.
				m_HordeTimer.Start( RandomFloat( 10.0f, 16.0f ) );
			}
		}
		else
		{
			// if there are currently too many awake aliens, then wait 10 seconds before trying again
			m_HordeTimer.Start( 10.0f );
		}
	}
}
Example #13
0
void CASW_Arena::SpawnArenaWave()
{
	if ( !ASWSpawnManager() )
		return;

	if ( ASWGameRules() )
	{
		ASWGameRules()->BroadcastSound( "Spawner.Horde" );
	}

	// find the 4 corridor spawn points
	CUtlVector<CBaseEntity*> arenaSpawns[4];
	int arenaSpawnsUsed[4];
	memset( arenaSpawnsUsed, 0, sizeof( arenaSpawnsUsed ) );

	CBaseEntity* pEntity = NULL;
	while ((pEntity = gEntList.FindEntityByClassname( pEntity, "info_target" )) != NULL)
	{
		if ( !stricmp( STRING( pEntity->GetEntityName() ), "Spawn_Front" ) )
		{
			arenaSpawns[0].AddToTail( pEntity );
		}
		else if ( !stricmp( STRING( pEntity->GetEntityName() ), "Spawn_Right" ) )
		{
			arenaSpawns[1].AddToTail( pEntity );
		}
		else if ( !stricmp( STRING( pEntity->GetEntityName() ), "Spawn_Below" ) )
		{
			arenaSpawns[2].AddToTail( pEntity );
		}
		else if ( !stricmp( STRING( pEntity->GetEntityName() ), "Spawn_Left" ) )
		{
			arenaSpawns[3].AddToTail( pEntity );
		}
	}
	Msg( "Found arena spawns: N:%d E:%d S:%d W:%d\n", arenaSpawns[0].Count(), arenaSpawns[1].Count(), arenaSpawns[2].Count(), arenaSpawns[3].Count() );

	// decide how many alien types we're going to spawn
	int iAlienTypes = 2;
	float fRandom = RandomFloat();
	if ( fRandom < 0.1f )
	{
		iAlienTypes = 4;
	}
	else if ( fRandom < 0.30f )
	{
		iAlienTypes = 3;
	}

	for ( int i=0 ; i<iAlienTypes; i++ )
	{
		// decide on a direction
		int iDirection = RandomInt( 0, 3 );
		// decide on an alien type
		int iAlienType = RandomInt( 0, m_ArenaAliens.Count() - 1 );
		int iQuantity = asw_arena_quantity_scale.GetFloat() * RandomInt( m_ArenaAliens[iAlienType]->m_iQuantityMin, m_ArenaAliens[iAlienType]->m_iQuantityMax );
		int iArenaLevel = m_iArenaWave / asw_arena_waves_per_difficulty.GetInt();
		iQuantity += iArenaLevel;

		for ( int k=0 ; k < iQuantity ; k++ )
		{
			if ( arenaSpawnsUsed[iDirection] < arenaSpawns[iDirection].Count() )
			{
				CBaseEntity *pSpawnPoint = arenaSpawns[iDirection][arenaSpawnsUsed[iDirection]];
				if ( !pSpawnPoint )
					continue;

				if ( ASWSpawnManager()->SpawnAlienAt( m_ArenaAliens[iAlienType]->m_szAlienClass, pSpawnPoint->GetAbsOrigin(), pSpawnPoint->GetAbsAngles() ) )
				{
					arenaSpawnsUsed[iDirection]++;
				}
			}
		}
	}

	m_iArenaWave++;
}