//========================================================= // Crea un hijo en la ubicación especificada. //========================================================= bool CDirector_Manager::AddChild(const Vector &vecPosition, int flag) { // No se ha podido acceder al Director. if ( !Director() ) return false; // No es posible crear un hijo aquí. if ( !CanMake(vecPosition) ) return false; // Creamos un hijo de la lista. const char *pChildName = GetChildClass(); CAI_BaseNPC *pChild = (CAI_BaseNPC *)CreateEntityByName(pChildName); QAngle angles = RandomAngle(0, 360); angles.x = 0.0; angles.z = 0.0; pChild->SetAbsAngles(angles); // Establecemos la ubicación de creación. pChild->SetAbsOrigin(vecPosition); // Debe caer al suelo y desaparecer. pChild->AddSpawnFlags(SF_NPC_FALL_TO_GROUND); pChild->AddSpawnFlags(SF_NPC_FADE_CORPSE); UTIL_DropToFloor(pChild, MASK_SOLID); ConVarRef director_debug("director_debug"); DispatchSpawn(pChild); pChild->SetOwnerEntity(Director()); DispatchActivate(pChild); // ¡¡NO CAMBIAR!! pChild->SetName(MAKE_STRING(CHILD_NAME)); // Sin colisiones. if ( flag == SPAWN_NO_COLLISION || flag == SPAWN_NO_COLLISION_AND_POWERFUL ) { pChild->SetCollisionGroup(COLLISION_GROUP_SPECIAL_NPC); Vector vecOriginRadius; if ( Director()->Status == PANIC && RandomInt(0, 4) == 2 ) pChild->SetCollisionGroup(COLLISION_GROUP_NPC); // Intentamos crearlo en un radio de 100 if ( CAI_BaseNPC::FindSpotForNPCInRadius(&vecOriginRadius, vecPosition, pChild, 150, false) ) { // Evitamos que se mueva por debajo del suelo. vecOriginRadius.z = vecPosition.z; // Movemos hacia esta ubicación. pChild->SetAbsOrigin(vecOriginRadius); // Marcamos al nodo afortunado. (Naranja) if ( director_debug.GetBool() ) NDebugOverlay::Box(vecOriginRadius, -Vector(10, 10, 10), Vector(10, 10, 10), 255, 128, 0, 10, 20.0f); } } // Poderoso. if ( flag == SPAWN_POWERFUL || flag == SPAWN_NO_COLLISION_AND_POWERFUL ) { int moreHealth = 3; // Normal: 5 más de salud. if ( InGameRules()->IsSkillLevel(SKILL_MEDIUM) ) moreHealth = 5; // Dificil: 8 más de salud. if ( InGameRules()->IsSkillLevel(SKILL_HARD) ) moreHealth = 8; // Más rápido. pChild->SetAddAccel(40); // Establecemos la nueva salud. pChild->SetMaxHealth(pChild->GetMaxHealth() + moreHealth); pChild->SetHealth(pChild->GetMaxHealth()); // Seleccionamos al jugador más cercano. float flDistance = 0.0f; CIN_Player *pPlayer = UTIL_GetNearestInPlayer(pChild->GetAbsOrigin(), flDistance); if ( pPlayer ) { // Le decimos que su nuevo enemigo es el jugador y le damos la ubicación de este. pChild->SetEnemy(pPlayer); pChild->UpdateEnemyMemory(pPlayer, pPlayer->GetAbsOrigin()); } } // Al parecer se atoro en una pared. if ( !PostSpawn(pChild) ) { // Marcamos al nodo desafortunado. (Negro) if ( director_debug.GetBool() ) NDebugOverlay::Box(vecPosition, -Vector(10, 10, 10), Vector(10, 10, 10), 0, 0, 0, 10, 3.0f); return false; } // Marcamos al nodo afortunado. (Rojo) if ( director_debug.GetBool() ) NDebugOverlay::Box(vecPosition, -Vector(10, 10, 10), Vector(10, 10, 10), 223, 1, 1, 10, 3.0f); DevMsg("[MANAGER] Se ha creado <%s> (faltan %i) \r\n", pChildName, Director()->SpawnQueue); ++Director()->ChildsSpawned; return true; }