//=========================================================
// Crea un Jefe.
//=========================================================
CAI_BaseNPC *CDirectorSpawn::MakeBoss()
{
	// Desactivado
	if ( Disabled )
		return NULL;

	// Seleccionamos una clase de NPC para crear.
	const char *pClass	= SelectRandomBoss();
	CAI_BaseNPC *pNPC	= VerifyClass(pClass);

	// Ocurrio algún problema.
	if ( !pNPC )
	{
		Warning("[DIRECTOR SPAWN] Ha ocurrido un problema al intentar crear un Jefe. \r\n");
		return NULL;
	}

	Vector origin;

	// Verificamos si podemos crear el Grunt en el radio.
	if ( !CanMakeNPC(pNPC, &origin) )
		return NULL;

	// Lugar de creación.
	pNPC->SetAbsOrigin(origin);

	// Nombre del Jefe.
	pNPC->SetName(MAKE_STRING(BOSS_NAME));

	QAngle angles	= GetAbsAngles();
	angles.x		= 0.0;
	angles.z		= 0.0;

	pNPC->SetAbsAngles(angles);

	// Tiene que caer al suelo.
	pNPC->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

	// Creamos al Jefe, le decimos quien es su dios (creador) y lo activamos.
	DispatchSpawn(pNPC);
	pNPC->SetOwnerEntity(this);
	DispatchActivate(pNPC);

	// Al parecer se atoro en una pared.
	if ( !PostSpawn(pNPC) )
		return NULL;

	// Debe conocer la ubicación del jugador (Su enemigo)
	CIN_Player *pPlayer = UTIL_GetRandomInPlayer();

	if ( pPlayer )
	{
		// Ataca al jugador YA
		pNPC->SetEnemy(pPlayer);
		pNPC->UpdateEnemyMemory(pPlayer, pPlayer->GetAbsOrigin());
	}

	return pNPC;
}
//=========================================================
// Crea un NPC Grunt.
//=========================================================
CAI_BaseNPC *CSurvivalZombieSpawn::MakeGrunt()
{
	// Desactivado
	if ( Disabled || !sv_spawn_zombies.GetBool() )
		return NULL;

	CAI_BaseNPC *pGrunt = (CAI_BaseNPC *)CreateEntityByName("npc_grunt");

	// Ocurrio algún problema.
	if ( !pGrunt )
	{
		Warning("[SURVIVAL ZOMBIE MAKER] Ha ocurrido un problema al intentar crear un grunt. \r\n");
		return NULL;
	}

	Vector origin;

	if ( !CanMakeNPC(pGrunt, &origin) )
		return NULL;

	// Lugar de creación.
	pGrunt->SetAbsOrigin(origin);

	// Nombre del Grunt.
	// [¡NO CAMBIAR!] Es utilizado por otras entidades para referirse a los zombis creados por esta entidad.
	pGrunt->SetName(MAKE_STRING("survival_grunt"));

	QAngle angles	= GetAbsAngles();
	angles.x		= 0.0;
	angles.z		= 0.0;

	pGrunt->SetAbsAngles(angles);

	// Tiene que caer al suelo.
	pGrunt->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

	// Creamos al grunt, le decimos quien es su dios (creador) y lo activamos.
	DispatchSpawn(pGrunt);
	pGrunt->SetOwnerEntity(this);
	DispatchActivate(pGrunt);

	// Ahora creamos la música.
	pGruntMusic = (CEnvSound *)CreateEntityByName("env_sound");
	pGruntMusic->SetSourceEntityName(MAKE_STRING("survival_grunt"));
	pGruntMusic->SetSoundName(MAKE_STRING("NPC_Grunt.BackgroundMusic"));
	pGruntMusic->SetRadius(8000.0);
	
	pGruntMusic->SetAbsOrigin(origin);
	DispatchSpawn(pGruntMusic);
	pGruntMusic->SetOwnerEntity(this);
	DispatchActivate(pGruntMusic);

	pGruntMusic->SetPitch(100);
	pGruntMusic->SetVolume(1);
	pGruntMusic->PlayManual(1, 100);

	return pGrunt;
}
Пример #3
0
//-----------------------------------------------------------------------------
// Purpose: Place NPC somewhere on the perimeter of my radius.
//-----------------------------------------------------------------------------
void CTemplateNPCMaker::MakeNPCInRadius( void )
{
	if ( !CanMakeNPC(true))
		return;

	CAI_BaseNPC	*pent = NULL;
	CBaseEntity *pEntity = NULL;
	MapEntity_ParseEntity( pEntity, STRING(m_iszTemplateData), NULL );
	if ( pEntity != NULL )
	{
		pent = (CAI_BaseNPC *)pEntity;
	}

	if ( !pent )
	{
		Warning("NULL Ent in NPCMaker!\n" );
		return;
	}
	
	if ( !PlaceNPCInRadius( pent ) )
	{
		// Failed to place the NPC. Abort
		UTIL_RemoveImmediate( pent );
		return;
	}

	m_OnSpawnNPC.Set( pEntity, pEntity, this );

	pent->AddSpawnFlags( SF_NPC_FALL_TO_GROUND );

	pent->RemoveSpawnFlags( SF_NPC_TEMPLATE );
	ChildPreSpawn( pent );

	DispatchSpawn( pent );

	pent->SetOwnerEntity( this );
	DispatchActivate( pent );

	ChildPostSpawn( pent );

	m_nLiveChildren++;// count this NPC

	if (!(m_spawnflags & SF_NPCMAKER_INF_CHILD))
	{
		m_nMaxNumNPCs--;

		if ( IsDepleted() )
		{
			m_OnAllSpawned.FireOutput( this, this );

			// Disable this forever.  Don't kill it because it still gets death notices
			SetThink( NULL );
			SetUse( NULL );
		}
	}
}
Пример #4
0
//-----------------------------------------------------------------------------
// Purpose: Creates the NPC.
//-----------------------------------------------------------------------------
void CHL1NPCMaker::MakeNPC( void )
{
	if (!CanMakeNPC())
	{
		return;
	}

	CBaseEntity	*pent = (CBaseEntity*)CreateEntityByName( STRING(m_iszNPCClassname) );

	if ( !pent )
	{
		Warning("NULL Ent in NPCMakerHL1!\n" );
		return;
	}
	
	m_OnSpawnNPC.FireOutput( this, this );

	pent->SetLocalOrigin( GetAbsOrigin() );
	pent->SetLocalAngles( GetAbsAngles() );

	pent->AddSpawnFlags( SF_NPC_FALL_TO_GROUND );

	if ( m_spawnflags & SF_NPCMakerHL1_FADE )
	{
		pent->AddSpawnFlags( SF_NPC_FADE_CORPSE );
	}


	DispatchSpawn( pent );
	pent->SetOwnerEntity( this );

	m_cLiveChildren++;// count this NPC

	if (!(m_spawnflags & SF_NPCMakerHL1_INF_CHILD))
	{
		m_iMaxNumNPCs--;

		if ( IsDepleted() )
		{
			// Disable this forever.  Don't kill it because it still gets death notices
			SetThink( NULL );
			SetUse( NULL );
		}
	}
}
Пример #5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTemplateNPCMaker::MakeNPC( void )
{
	// If we should be using the radius spawn method instead, do so
	if ( m_flRadius && HasSpawnFlags(SF_NPCMAKER_ALWAYSUSERADIUS) )
	{
		MakeNPCInRadius();
		return;
	}

	if (!CanMakeNPC( ( m_iszDestinationGroup != NULL_STRING ) ))
		return;

	CNPCSpawnDestination *pDestination = NULL;
	if ( m_iszDestinationGroup != NULL_STRING )
	{
		pDestination = FindSpawnDestination();
		if ( !pDestination )
		{
			DevMsg( 2, "%s '%s' failed to find a valid spawnpoint in destination group: '%s'\n", GetClassname(), STRING(GetEntityName()), STRING(m_iszDestinationGroup) );
			return;
		}
	}

	CAI_BaseNPC	*pent = NULL;
	CBaseEntity *pEntity = NULL;
	MapEntity_ParseEntity( pEntity, STRING(m_iszTemplateData), NULL );
	if ( pEntity != NULL )
	{
		pent = (CAI_BaseNPC *)pEntity;
	}

	if ( !pent )
	{
		Warning("NULL Ent in NPCMaker!\n" );
		return;
	}
	
	if ( pDestination )
	{
		pent->SetAbsOrigin( pDestination->GetAbsOrigin() );

		// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
		QAngle angles = pDestination->GetAbsAngles();
		angles.x = 0.0;
		angles.z = 0.0;
		pent->SetAbsAngles( angles );

		pDestination->OnSpawnedNPC( pent );
	}
	else
	{
		pent->SetAbsOrigin( GetAbsOrigin() );

		// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
		QAngle angles = GetAbsAngles();
		angles.x = 0.0;
		angles.z = 0.0;
		pent->SetAbsAngles( angles );
	}

	m_OnSpawnNPC.Set( pEntity, pEntity, this );

	if ( m_spawnflags & SF_NPCMAKER_FADE )
	{
		pent->AddSpawnFlags( SF_NPC_FADE_CORPSE );
	}

	pent->RemoveSpawnFlags( SF_NPC_TEMPLATE );

	if ( ( m_spawnflags & SF_NPCMAKER_NO_DROP ) == false )
	{
		pent->RemoveSpawnFlags( SF_NPC_FALL_TO_GROUND ); // don't fall, slam
	}

	ChildPreSpawn( pent );

	DispatchSpawn( pent );
	pent->SetOwnerEntity( this );
	DispatchActivate( pent );

	ChildPostSpawn( pent );

	m_nLiveChildren++;// count this NPC

	if (!(m_spawnflags & SF_NPCMAKER_INF_CHILD))
	{
		m_nMaxNumNPCs--;

		if ( IsDepleted() )
		{
			m_OnAllSpawned.FireOutput( this, this );

			// Disable this forever.  Don't kill it because it still gets death notices
			SetThink( NULL );
			SetUse( NULL );
		}
	}
}
Пример #6
0
//-----------------------------------------------------------------------------
// Purpose: Creates the NPC.
//-----------------------------------------------------------------------------
void CNPCMaker::MakeNPC( void )
{
	if (!CanMakeNPC())
		return;

	CAI_BaseNPC	*pent = (CAI_BaseNPC*)CreateEntityByName( STRING(m_iszNPCClassname) );

	if ( !pent )
	{
		Warning("NULL Ent in NPCMaker!\n" );
		return;
	}
	
	// ------------------------------------------------
	//  Intialize spawned NPC's relationships
	// ------------------------------------------------
	pent->SetRelationshipString( m_RelationshipString );

	m_OnSpawnNPC.Set( pent, pent, this );

	pent->SetAbsOrigin( GetAbsOrigin() );

	// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
	QAngle angles = GetAbsAngles();
	angles.x = 0.0;
	angles.z = 0.0;
	pent->SetAbsAngles( angles );

	pent->AddSpawnFlags( SF_NPC_FALL_TO_GROUND );

	if ( m_spawnflags & SF_NPCMAKER_FADE )
	{
		pent->AddSpawnFlags( SF_NPC_FADE_CORPSE );
	}

	pent->m_spawnEquipment	= m_spawnEquipment;
	pent->SetSquadName( m_SquadName );
	pent->SetHintGroup( m_strHintGroup );

	ChildPreSpawn( pent );

	DispatchSpawn( pent );
	pent->SetOwnerEntity( this );
	DispatchActivate( pent );

	if ( m_ChildTargetName != NULL_STRING )
	{
		// if I have a netname (overloaded), give the child NPC that name as a targetname
		pent->SetName( m_ChildTargetName );
	}

	ChildPostSpawn( pent );

	m_nLiveChildren++;// count this NPC

	if (!(m_spawnflags & SF_NPCMAKER_INF_CHILD))
	{
		m_nMaxNumNPCs--;

		if ( IsDepleted() )
		{
			m_OnAllSpawned.FireOutput( this, this );

			// Disable this forever.  Don't kill it because it still gets death notices
			SetThink( NULL );
			SetUse( NULL );
		}
	}
}
//=========================================================
// Crea un Zombi.
//=========================================================
CAI_BaseNPC *CSurvivalZombieSpawn::MakeNPC()
{
	// Desactivado
	if ( Disabled || !sv_spawn_zombies.GetBool() )
		return NULL;

	// Seleccionamos una clase de zombi para crear.
	const char *pZombieClass	= SelectRandomZombie();

	// El elegido es un Grunt.
	if ( pZombieClass == "npc_grunt" )
		return MakeGrunt();

	// Creamos al zombi.
	CAI_BaseNPC *pZombie = (CAI_BaseNPC *)CreateEntityByName(pZombieClass);

	// Emm... ¿puso todas las clases en "no crear"? :genius:
	if ( !pZombie )
	{
		Warning("[SURVIVAL ZOMBIE MAKER] Ha ocurrido un problema al intentar crear un zombie. \r\n");
		return NULL;
	}

	Vector origin;

	if ( !CanMakeNPC(pZombie, &origin) )
		return NULL;

	// Lugar de creación.
	pZombie->SetAbsOrigin(origin);

	// Nombre del zombie.
	// [¡NO CAMBIAR!] Es utilizado por otras entidades para referirse a los zombis creados por esta entidad.
	pZombie->SetName(MAKE_STRING("survival_zombie"));

	QAngle angles	= GetAbsAngles();
	angles.x		= 0.0;
	angles.z		= 0.0;

	pZombie->SetAbsAngles(angles);

	// Tiene que caer al suelo.
	pZombie->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);
	// Su cuerpo tiene que desaparecer al morir.
	pZombie->AddSpawnFlags(SF_NPC_FADE_CORPSE);

	// No colisionan con otros NPC's. (Zombis)
	if ( random->RandomInt(1, 3) == 2 )
		pZombie->SetCollisionGroup(COLLISION_GROUP_SPECIAL_NPC);

	// Creamos al zombi, le decimos quien es su dios (creador) y lo activamos.
	DispatchSpawn(pZombie);
	pZombie->SetOwnerEntity(this);
	DispatchActivate(pZombie);

	// Skin al azar.
	pZombie->m_nSkin = random->RandomInt(1, 4);

	Childs++;
	ChildsAlive++;
	LastSpawn = gpGlobals->curtime;

	OnSpawnZombie.FireOutput(pZombie, this);
	return pZombie;
}
//=========================================================
// Crea un Zombi.
//=========================================================
CAI_BaseNPC *CDirectorSpawn::MakeNPC(bool Horde, bool disclosePlayer, bool checkRadius)
{
	// Desactivado
	// Esta entidad no funciona en Multiplayer.
	if ( Disabled )
		return NULL;

	// Seleccionamos una clase de NPC para crear.
	const char *pClass	= SelectRandom();
	CAI_BaseNPC *pNPC	= VerifyClass(pClass);

	// Emm... ¿puso todas las clases en "no crear"? :genius:
	if ( !pNPC )
	{
		Warning("[DIRECTOR SPAWN] Ha ocurrido un problema al intentar crear un NPC. \r\n");
		return NULL;
	}

	Vector origin;

	// Verificamos si podemos crear un zombi en el radio.
	if ( checkRadius )
	{
		if ( !CanMakeNPC(pNPC, &origin) )
			return NULL;
	}

	// Lugar de creación.
	pNPC->SetAbsOrigin(origin);

	QAngle angles	= GetAbsAngles();
	angles.x		= 0.0;
	angles.z		= 0.0;

	pNPC->SetAbsAngles(angles);

	// Tiene que caer al suelo.
	pNPC->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);
	// Su cuerpo tiene que desaparecer al morir.
	pNPC->AddSpawnFlags(SF_NPC_FADE_CORPSE);

	// Creamos al NPC, le decimos quien es su dios (creador) y lo activamos.
	DispatchSpawn(pNPC);
	pNPC->SetOwnerEntity(this);
	DispatchActivate(pNPC);

	// Al parecer se atoro en una pared.
	if ( !PostSpawn(pNPC) )
		return NULL;

	// Nombre del NPC.
	pNPC->SetName(MAKE_STRING(CHILD_NAME));

#ifdef APOCALYPSE
	// Skin al azar.
	if ( pNPC->GetClassname() == "npc_zombie" )	
		pNPC->m_nSkin = random->RandomInt(1, 4);
#endif

	// Es un NPC para la horda ¡woot!
	if ( Horde )
	{
		AddHealth(pNPC);

#ifdef APOCALYPSE
		// Más rápido.
		pNPC->SetAddAccel(40);

		// No colisiona con otros NPC's. (Zombis)
		if ( random->RandomInt(1, 4) == 2 )
			pNPC->SetCollisionGroup(COLLISION_GROUP_SPECIAL_NPC);
#endif
	}

	// Debe conocer la ubicación del jugador (Su enemigo)
	if ( disclosePlayer )
	{
		CIN_Player *pPlayer = UTIL_GetRandomInPlayer();

		if ( pPlayer )
			pNPC->UpdateEnemyMemory(pPlayer, pPlayer->GetAbsOrigin());
	}

	Childs++;
	ChildsAlive++;
	LastSpawn = gpGlobals->curtime;

	OnSpawnNPC.FireOutput(pNPC, this);
	return pNPC;
}
//-----------------------------------------------------------------------------
// Purpose: Creates the NPC.
//-----------------------------------------------------------------------------
void CNPCMakerXenInvasion::MakeNPC(void)
{
	if (!CanMakeNPC())
		return;
	
	if (g_pGameRules->bHasRandomized)
	{
		if (g_pGameRules->iRandomGamemode == FIREFIGHT_PRIMARY_XENINVASION)
		{
			int nNPCs = ARRAYSIZE(g_charNPCSXenInvasionSupport);
			int randomChoice = rand() % nNPCs;
			const char *pRandomName = g_charNPCSXenInvasionSupport[randomChoice];

			CAI_BaseNPC	*pent = (CAI_BaseNPC*)CreateEntityByName(pRandomName);

			if (!pent)
			{
				Warning("npc_maker_firefight: Entity classname does not exist in database.\n");
				return;
			}

			// ------------------------------------------------
			//  Intialize spawned NPC's relationships
			// ------------------------------------------------
			pent->SetRelationshipString(m_RelationshipString);

			m_OnSpawnNPC.Set(pent, pent, this);

			pent->SetAbsOrigin(GetAbsOrigin());

			// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
			QAngle angles = GetAbsAngles();
			angles.x = 0.0;
			angles.z = 0.0;
			pent->SetAbsAngles(angles);

			pent->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

			if (m_spawnflags & SF_NPCMAKER_FADE)
			{
				pent->AddSpawnFlags(SF_NPC_FADE_CORPSE);
			}

			pent->m_isRareEntity = false;
			pent->SetSquadName(m_SquadName);
			pent->SetHintGroup(m_strHintGroup);

			ChildPreSpawn(pent);

			DispatchSpawn(pent);
			pent->SetOwnerEntity(this);
			DispatchActivate(pent);

			if (m_ChildTargetName != NULL_STRING)
			{
				// if I have a netname (overloaded), give the child NPC that name as a targetname
				pent->SetName(m_ChildTargetName);
			}

			ChildPostSpawn(pent);
		}
		else
		{
			CAI_BaseNPC	*pent = (CAI_BaseNPC*)CreateEntityByName(STRING(m_iszNPCClassname));

			if (!pent)
			{
				Warning("npc_maker_firefight: Entity classname does not exist in database.\n");
				return;
			}

			// ------------------------------------------------
			//  Intialize spawned NPC's relationships
			// ------------------------------------------------
			pent->SetRelationshipString(m_RelationshipString);

			m_OnSpawnNPC.Set(pent, pent, this);

			pent->SetAbsOrigin(GetAbsOrigin());

			// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
			QAngle angles = GetAbsAngles();
			angles.x = 0.0;
			angles.z = 0.0;
			pent->SetAbsAngles(angles);

			pent->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

			if (m_spawnflags & SF_NPCMAKER_FADE)
			{
				pent->AddSpawnFlags(SF_NPC_FADE_CORPSE);
			}

			pent->m_spawnEquipment = m_spawnEquipment;
			pent->m_isRareEntity = false;
			pent->SetSquadName(m_SquadName);
			pent->SetHintGroup(m_strHintGroup);

			ChildPreSpawn(pent);

			DispatchSpawn(pent);
			pent->SetOwnerEntity(this);
			DispatchActivate(pent);

			if (m_ChildTargetName != NULL_STRING)
			{
				// if I have a netname (overloaded), give the child NPC that name as a targetname
				pent->SetName(m_ChildTargetName);
			}

			ChildPostSpawn(pent);
		}
	}
	else
	{
		if (g_pGameRules->GetGamemode() == FIREFIGHT_PRIMARY_XENINVASION)
		{
			int nNPCs = ARRAYSIZE(g_charNPCSXenInvasionSupport);
			int randomChoice = rand() % nNPCs;
			const char *pRandomName = g_charNPCSXenInvasionSupport[randomChoice];

			CAI_BaseNPC	*pent = (CAI_BaseNPC*)CreateEntityByName(pRandomName);

			if (!pent)
			{
				Warning("npc_maker_firefight: Entity classname does not exist in database.\n");
				return;
			}

			// ------------------------------------------------
			//  Intialize spawned NPC's relationships
			// ------------------------------------------------
			pent->SetRelationshipString(m_RelationshipString);

			m_OnSpawnNPC.Set(pent, pent, this);

			pent->SetAbsOrigin(GetAbsOrigin());

			// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
			QAngle angles = GetAbsAngles();
			angles.x = 0.0;
			angles.z = 0.0;
			pent->SetAbsAngles(angles);

			pent->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

			if (m_spawnflags & SF_NPCMAKER_FADE)
			{
				pent->AddSpawnFlags(SF_NPC_FADE_CORPSE);
			}

			pent->m_isRareEntity = false;
			pent->SetSquadName(m_SquadName);
			pent->SetHintGroup(m_strHintGroup);

			ChildPreSpawn(pent);

			DispatchSpawn(pent);
			pent->SetOwnerEntity(this);
			DispatchActivate(pent);

			if (m_ChildTargetName != NULL_STRING)
			{
				// if I have a netname (overloaded), give the child NPC that name as a targetname
				pent->SetName(m_ChildTargetName);
			}

			ChildPostSpawn(pent);
		}
		else
		{
			CAI_BaseNPC	*pent = (CAI_BaseNPC*)CreateEntityByName(STRING(m_iszNPCClassname));

			if (!pent)
			{
				Warning("npc_maker_firefight: Entity classname does not exist in database.\n");
				return;
			}

			// ------------------------------------------------
			//  Intialize spawned NPC's relationships
			// ------------------------------------------------
			pent->SetRelationshipString(m_RelationshipString);

			m_OnSpawnNPC.Set(pent, pent, this);

			pent->SetAbsOrigin(GetAbsOrigin());

			// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
			QAngle angles = GetAbsAngles();
			angles.x = 0.0;
			angles.z = 0.0;
			pent->SetAbsAngles(angles);

			pent->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

			if (m_spawnflags & SF_NPCMAKER_FADE)
			{
				pent->AddSpawnFlags(SF_NPC_FADE_CORPSE);
			}

			pent->m_spawnEquipment = m_spawnEquipment;
			pent->m_isRareEntity = false;
			pent->SetSquadName(m_SquadName);
			pent->SetHintGroup(m_strHintGroup);

			ChildPreSpawn(pent);

			DispatchSpawn(pent);
			pent->SetOwnerEntity(this);
			DispatchActivate(pent);

			if (m_ChildTargetName != NULL_STRING)
			{
				// if I have a netname (overloaded), give the child NPC that name as a targetname
				pent->SetName(m_ChildTargetName);
			}

			ChildPostSpawn(pent);
		}
	}

	m_nLiveChildren++;// count this NPC
}