public TaskDungeonMission(object owner, eDungeonType dungeonType = eDungeonType.Ranged) : base(owner) { log.Info("INFO: Successfully entered TaskDungeonMission!"); GamePlayer player = owner as GamePlayer; if (owner is Group) { player = (owner as Group).Leader; //Assign the mission to the group. (owner as Group).Mission = this; } if (player == null) return; //check level range and get region id from it ushort rid = GetRegionFromLevel(player.Level, player.Realm, dungeonType); TaskDungeonInstance instance = (TaskDungeonInstance)WorldMgr.CreateInstance(rid, typeof(TaskDungeonInstance)); m_taskRegion = instance; instance.Mission = this; //Dinberg: I've removed instance level, and have commented this out so it compiles. //I dont have time to implement the rest right now, //m_taskRegion.InstanceLevel = GetLevelFromPlayer(player); //Infact, this clearly isnt in use. I'll fix it to use the new instance system, and then itll work. //Do that later this week ^^. //Lets load the region from the InstanceXElementDB! //First we get the instance keyname. string keyname = "TaskDungeon" + rid + ".1"; //TODO; variations, eg .2, .3 etc. instance.LoadFromDatabase(keyname); //Now, search for the boss and possible targets in the instance! foreach (GameNPC npc in instance.Objects) { if (npc == null) continue; if (npc.Name.ToLower() != npc.Name) { if (m_bossName == "") m_bossName = npc.Name; //Some instances have multiple bosses, eg Gregorian - why break? else if (Util.Chance(50)) m_bossName = npc.Name; } //else what if we aren't looking at a boss, but a normal mob? else if (Util.Chance(20) || m_targetName == "") m_targetName = npc.Name; } int specificCount = 0; //Draw the mission type before we do anymore counting... if (Util.Chance(40) && m_bossName != "") m_missionType = eTDMissionType.Boss; else if (Util.Chance(20) && m_targetName != "") m_missionType = eTDMissionType.Specific; else m_missionType = eTDMissionType.Clear; //Now, count if we need to. if (m_missionType != eTDMissionType.Boss) { foreach (GameNPC entry in instance.Objects) { if (entry == null) continue; //Now, if we want all mobs, get all mobs... if (m_missionType == eTDMissionType.Clear) specificCount++; else if (entry.Name == m_targetName) //only count target mobs for specific dungeons. specificCount++; } } //append the count to the total! m_total = specificCount; //Set the mission description again if owner is group, otherwise //mission description is always "Clear" before entering the dungeon. if (owner is Group) UpdateMission(); m_mobIsAlive = new bool[m_total]; for(int i = 0; i < m_total; i++) m_mobIsAlive[i] = true; }
public TaskDungeonMission(object owner, eDungeonType dungeonType = eDungeonType.Ranged) : base(owner) { log.Info("INFO: Successfully entered TaskDungeonMission!"); GamePlayer player = owner as GamePlayer; if (owner is Group) { player = (owner as Group).Leader; //Assign the mission to the group. (owner as Group).Mission = this; } if (player == null) { return; } //check level range and get region id from it ushort rid = GetRegionFromLevel(player.Level, player.Realm, dungeonType); TaskDungeonInstance instance = (TaskDungeonInstance)WorldMgr.CreateInstance(rid, typeof(TaskDungeonInstance)); m_taskRegion = instance; instance.Mission = this; //Dinberg: I've removed instance level, and have commented this out so it compiles. //I dont have time to implement the rest right now, //m_taskRegion.InstanceLevel = GetLevelFromPlayer(player); //Infact, this clearly isnt in use. I'll fix it to use the new instance system, and then itll work. //Do that later this week ^^. //Lets load the region from the InstanceXElementDB! //First we get the instance keyname. string keyname = "TaskDungeon" + rid + ".1"; //TODO; variations, eg .2, .3 etc. instance.LoadFromDatabase(keyname); //Now, search for the boss and possible targets in the instance! foreach (GameNPC npc in instance.Objects) { if (npc == null) { continue; } if (npc.Name.ToLower() != npc.Name) { if (m_bossName == "") { m_bossName = npc.Name; //Some instances have multiple bosses, eg Gregorian - why break? } else if (Util.Chance(50)) { m_bossName = npc.Name; } } //else what if we aren't looking at a boss, but a normal mob? else if (Util.Chance(20) || m_targetName == "") { m_targetName = npc.Name; } } int specificCount = 0; //Draw the mission type before we do anymore counting... if (Util.Chance(40) && m_bossName != "") { m_missionType = eTDMissionType.Boss; } else if (Util.Chance(20) && m_targetName != "") { m_missionType = eTDMissionType.Specific; } else { m_missionType = eTDMissionType.Clear; } //Now, count if we need to. if (m_missionType != eTDMissionType.Boss) { foreach (GameNPC entry in instance.Objects) { if (entry == null) { continue; } //Now, if we want all mobs, get all mobs... if (m_missionType == eTDMissionType.Clear) { specificCount++; } else if (entry.Name == m_targetName) { //only count target mobs for specific dungeons. specificCount++; } } } //append the count to the total! m_total = specificCount; //Set the mission description again if owner is group, otherwise //mission description is always "Clear" before entering the dungeon. if (owner is Group) { UpdateMission(); } m_mobIsAlive = new bool[m_total]; for (int i = 0; i < m_total; i++) { m_mobIsAlive[i] = true; } }