/// <summary> /// Spawn some (10-20) nasty level 62-68 drakulvs around the spot the /// retriever has reported back from, then make these spawns aggro the /// raid inside the lair. /// </summary> /// <param name="numAdds"></param> /// <param name="x"></param> /// <param name="y"></param> private void SpawnDrakulvs(int numAdds, int x, int y) { GameNPC drakulv; bool isDisciple = false; for (int add = 0; add < numAdds; ++add) { isDisciple = Util.Chance(25); drakulv = SpawnTimedAdd((isDisciple) ? 613 : 612, Util.Random(62, 68), x + Util.Random(250), y + Util.Random(250), 120, false); if (drakulv != null && drakulv.Brain is StandardMobBrain && this.Brain is DragonBrain) { (Brain as DragonBrain).AddAggroListTo(drakulv.Brain as StandardMobBrain); } } }
/// <summary> /// Loads elements relating to the given instance keyname from the database and populates the instance. /// </summary> /// <param name="instanceName"></param> public virtual void LoadFromDatabase(string instanceName) { var objects = GameServer.Database.SelectObjects <DBInstanceXElement>("`InstanceID` = @InstanceID", new QueryParameter("@InstanceID", instanceName)); if (objects.Count == 0) { return; } int count = 0; // Now we have a list of DBElements, lets create the various entries // associated with them and populate the instance. foreach (DBInstanceXElement entry in objects) { if (entry == null) { continue; // an odd error, but experience knows best. } GameObject obj = null; string theType = "DOL.GS.GameNPC"; // Switch the classtype to see what we are making. switch (entry.ClassType) { case "entrance": // create the entrance, then move to the next. m_entranceLocation = new GameLocation($"{instanceName}entranceRegion{ID}", ID, entry.X, entry.Y, entry.Z, entry.Heading); // move to the next entry, nothing more to do here... continue; case "region": continue; // This is used to save the regionID as NPCTemplate. case "DOL.GS.GameNPC": break; default: theType = entry.ClassType; break; } // Now we have the classtype to create, create it thus! // This is required to ensure we check scripts for the space aswell, such as quests! foreach (Assembly asm in ScriptMgr.GameServerScripts) { obj = (GameObject)asm.CreateInstance(theType, false); if (obj != null) { break; } } if (obj == null) { continue; } // We now have an object that isnt null. Lets place it at the location, in this region. obj.X = entry.X; obj.Y = entry.Y; obj.Z = entry.Z; obj.Heading = entry.Heading; obj.CurrentRegionID = ID; // If its an npc, load from the npc template about now. // By default, we ignore npctemplate if its set to 0. if (!Util.IsEmpty(entry.NPCTemplate, true)) { var listTemplate = entry.NPCTemplate.SplitCSV(true); if (int.TryParse(listTemplate[Util.Random(listTemplate.Count - 1)], out var template) && template > 0) { INpcTemplate npcTemplate = NpcTemplateMgr.GetTemplate(template); // we only want to load the template if one actually exists, or there could be trouble! if (npcTemplate != null) { ((GameNPC)obj).LoadTemplate(npcTemplate); } } } // Finally, add it to the world! obj.AddToWorld(); // Keep track of numbers. count++; } log.Info($"Successfully loaded a db entry to {Description} - Region ID {ID}. Loaded Entities: {count}"); }
/// <summary> /// Register a generator for the given parameters, /// If all parameters are null a global generaotr for all mobs will be registered /// </summary> /// <param name="generator"></param> /// <param name="mobname"></param> /// <param name="mobguild"></param> /// <param name="mobfaction"></param> /// <param name="mobregion"></param> public static void RegisterLootGenerator(ILootGenerator generator, string mobname, string mobguild, string mobfaction, int mobregion) { if (generator == null) { return; } // Loot Generator Name Indexed if (!Util.IsEmpty(mobname)) { // Parse CSV try { List<string> mobNames = Util.SplitCSV(mobname); foreach (string mob in mobNames) { if ((IList)m_mobNameGenerators[mob] == null) { m_mobNameGenerators[mob] = new ArrayList(); } ((IList)m_mobNameGenerators[mob]).Add(generator); } } catch { if (log.IsDebugEnabled) { log.Debug("Could not Parse mobNames for Registering LootGenerator : " + generator.GetType().FullName); } } } // Loot Generator Guild Indexed if (!Util.IsEmpty(mobguild)) { // Parse CSV try { List<string> mobGuilds = Util.SplitCSV(mobguild); foreach (string guild in mobGuilds) { if ((IList)m_mobGuildGenerators[guild] == null) { m_mobGuildGenerators[guild] = new ArrayList(); } ((IList)m_mobGuildGenerators[guild]).Add(generator); } } catch { if (log.IsDebugEnabled) { log.Debug("Could not Parse mobGuilds for Registering LootGenerator : " + generator.GetType().FullName); } } } // Loot Generator Region Indexed if (mobregion > 0) { IList regionList = (IList)m_mobRegionGenerators[mobregion]; if (regionList == null) { regionList = new ArrayList(); m_mobRegionGenerators[mobregion] = regionList; } regionList.Add(generator); } if (Util.IsEmpty(mobname) && Util.IsEmpty(mobguild) && Util.IsEmpty(mobfaction) && mobregion == 0) { m_globalGenerators.Add(generator); } }