Example #1
0
        /// <summary>
        /// If we want this method to be public,
        /// it should update all Quests correctly (remove non-existant ones etc)
        /// </summary>
        internal void Load()
        {
            QuestRecord[] records;
            try
            {
                records = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }
            catch (Exception e)
            {
                RealmDBMgr.OnDBError(e);
                records = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }

            if (records != null)
            {
                foreach (var record in records)
                {
                    var templ = QuestMgr.GetTemplate(record.QuestTemplateId);
                    if (templ != null)
                    {
                        var quest = new Quest(this, record, templ);
                        AddQuest(quest);

                        //Cancel any quests relating to inactive events
                        if (templ.EventIds.Count > 0)
                        {
                            if (!templ.EventIds.Where(WorldEventMgr.IsEventActive).Any())
                            {
                                quest.Cancel(false);
                            }
                        }
                    }
                    else
                    {
                        log.Error("Character {0} had Invalid Quest: {1} (Record: {2})", Owner,
                                  record.QuestTemplateId, record.QuestRecordId);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// If we want this method to be public,
        /// it should update all Quests correctly (remove non-existant ones etc)
        /// </summary>
        internal void Load()
        {
            QuestRecord[] recordForCharacter;
            try
            {
                recordForCharacter = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }
            catch (Exception ex)
            {
                RealmDBMgr.OnDBError(ex);
                recordForCharacter = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }

            if (recordForCharacter == null)
            {
                return;
            }
            foreach (QuestRecord record in recordForCharacter)
            {
                QuestTemplate template = QuestMgr.GetTemplate(record.QuestTemplateId);
                if (template != null)
                {
                    Quest quest = new Quest(this, record, template);
                    AddQuest(quest);
                    if (template.EventIds.Count > 0 && !template.EventIds
                        .Where(WorldEventMgr.IsEventActive).Any())
                    {
                        quest.Cancel(false);
                    }
                }
                else
                {
                    log.Error("Character {0} had Invalid Quest: {1} (Record: {2})", Owner,
                              record.QuestTemplateId, record.QuestRecordId);
                }
            }
        }
Example #3
0
 public static void Initialize()
 {
     QuestMgr.LoadAll();
 }
Example #4
0
        /// <summary>Creates the graph of all quests and their relations</summary>
        private static void CreateQuestRelationGraph()
        {
            Dictionary <int, List <uint> > map = new Dictionary <int, List <uint> >();

            foreach (QuestTemplate template1 in QuestMgr.Templates)
            {
                if (template1 != null)
                {
                    if (template1.Id == 10068U)
                    {
                        template1.ToString();
                    }
                    if (template1.ExclusiveGroup != 0)
                    {
                        map.GetOrCreate <int, uint>(template1.ExclusiveGroup).AddUnique <uint>(template1.Id);
                    }
                    else if (template1.NextQuestId != 0)
                    {
                        QuestTemplate template2 = QuestMgr.GetTemplate((uint)Math.Abs(template1.NextQuestId));
                        if (template2 == null)
                        {
                            ContentMgr.OnInvalidDBData("NextQuestId {0} is invalid in: {1}",
                                                       (object)template1.NextQuestId, (object)template1);
                        }
                        else if (template1.NextQuestId > 0)
                        {
                            template2.ReqAllFinishedQuests.AddUnique <uint>(template1.Id);
                        }
                        else
                        {
                            template2.ReqAllActiveQuests.AddUnique <uint>(template1.Id);
                        }
                    }

                    if (template1.PreviousQuestId != 0)
                    {
                        if (template1.PreviousQuestId > 0)
                        {
                            template1.ReqAllFinishedQuests.AddUnique <uint>((uint)template1.PreviousQuestId);
                        }
                        else
                        {
                            template1.ReqAllActiveQuests.AddUnique <uint>((uint)-template1.PreviousQuestId);
                        }
                    }

                    if (template1.FollowupQuestId != 0U)
                    {
                        QuestTemplate template2 = QuestMgr.GetTemplate(template1.FollowupQuestId);
                        if (template2 != null)
                        {
                            template2.ReqAllFinishedQuests.AddUnique <uint>(template1.Id);
                        }
                    }
                }
            }

            foreach (KeyValuePair <int, List <uint> > keyValuePair in map)
            {
                foreach (uint id in keyValuePair.Value)
                {
                    QuestTemplate template1 = QuestMgr.GetTemplate(id);
                    foreach (uint num in keyValuePair.Value)
                    {
                        if ((int)num != (int)id && keyValuePair.Key > 0)
                        {
                            template1.ReqUndoneQuests.AddUnique <uint>(num);
                        }
                    }

                    if (template1.NextQuestId != 0)
                    {
                        QuestTemplate template2 = QuestMgr.GetTemplate((uint)Math.Abs(template1.NextQuestId));
                        if (template2 == null)
                        {
                            ContentMgr.OnInvalidDBData("NextQuestId {0} is invalid in: {1}",
                                                       (object)template1.NextQuestId, (object)template1);
                        }
                        else if (keyValuePair.Key > 0)
                        {
                            template2.ReqAllFinishedQuests.AddUnique <uint>(template1.Id);
                        }
                        else
                        {
                            template2.ReqAnyFinishedQuests.AddUnique <uint>(template1.Id);
                        }
                    }
                }
            }
        }