Exemplo n.º 1
0
		/// <summary>
		/// Recreate existing Quest-progress
		/// </summary>
		internal Quest(QuestLog log, QuestRecord record, QuestTemplate template)
			: this(log, template, record)
		{
			m_saved = true;

			// reset initial state

			if (template.GOInteractions != null)
			{
				if (UsedGOs == null)
				{
					UsedGOs = new uint[template.NPCInteractions.Length];
				}

				for (var i = 0; i < Template.NPCInteractions.Length; i++)
				{
					var interaction = Template.NPCInteractions[i];
					log.Owner.SetQuestCount(Slot, interaction.Index, (byte)UsedGOs[i]);
				}
			}
			if (Template.NPCInteractions != null)
			{
				if (KilledNPCs == null)
				{
					KilledNPCs = new uint[template.NPCInteractions.Length];
				}

				for (var i = 0; i < Template.NPCInteractions.Length; i++)
				{
					var interaction = Template.NPCInteractions[i];
					log.Owner.SetQuestCount(Slot, interaction.Index, (byte)KilledNPCs[i]);
				}
			}
			UpdateStatus();
		}
Exemplo n.º 2
0
		/// <summary>
		/// Load Quest progress
		/// </summary>
		internal Quest(QuestLog log, QuestRecord record, QuestTemplate template)
			: this(log, template, record)
		{
			m_saved = true;

			// reset initial state

			if (template.HasObjectOrSpellInteractions)
			{
				if (Interactions == null ||
				//template has been changed, probably due to a quest fix
				template.ObjectOrSpellInteractions.Count() != Interactions.Count())
				{
					Interactions = new uint[template.ObjectOrSpellInteractions.Length];
				}

				for (var i = 0; i < Template.ObjectOrSpellInteractions.Length; i++)
				{
					var interaction = Template.ObjectOrSpellInteractions[i];
					
					if (interaction == null || !interaction.IsValid) continue;

					log.Owner.SetQuestCount(Slot, interaction.Index, (byte)Interactions[i]);
				}
			}
			UpdateStatus();
		}
Exemplo n.º 3
0
        public Quest(Character owner, QuestStepTemplate step)
        {
            m_record = new QuestRecord()
            {
                Finished = false,
                QuestId  = step.QuestId,
                StepId   = step.Id,
            };

            CurrentStep = new QuestStep(this, step);
        }
Exemplo n.º 4
0
 public QuestDemand()
 {
     DemandQuest     = new QuestRecord[0];
     DemandItem      = new ItemInfo[0];
     DemandSkill     = new SkillInfo[0];
     DemandMob       = new MobInfo[0];
     DemandMap       = new MapInfo[0];
     EquipAllNeed    = new int[0];
     EquipSelectNeed = new int[0];
     FieldEnter      = new int[0];
     Job             = new int[0];
 }
Exemplo n.º 5
0
 private Quest(QuestLog log, QuestTemplate template, QuestRecord record)
 {
     m_record = record;
     if (template.CollectableItems.Length > 0)
     {
         CollectedItems = new int[template.CollectableItems.Length];
     }
     if (template.CollectableSourceItems.Length > 0)
     {
         CollectedSourceItems = new int[template.CollectableSourceItems.Length];
     }
     m_Log    = log;
     Template = template;
 }
Exemplo n.º 6
0
        public Quest(Character owner, QuestRecord record)
        {
            m_record = record;

            Owner    = owner;
            Template = QuestManager.Instance.GetQuestTemplate(record.QuestId);

            if (Template == null)
            {
                logger.Error($"Quest id {record.QuestId} doesn't exist");
                return;
            }

            CurrentStep = new QuestStep(this, QuestManager.Instance.GetQuestStep(record.StepId));
        }
Exemplo n.º 7
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);
                    }
                }
            }
        }
Exemplo n.º 8
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);
                }
            }
        }
Exemplo n.º 9
0
		private Quest(QuestLog log, QuestTemplate template, QuestRecord record)
		{
			m_record = record;

			if (template.CollectableItems.Length > 0)
			{
				CollectedItems = new int[template.CollectableItems.Length];
			}

            if (template.CollectableSourceItems.Length > 0)
            {
                CollectedSourceItems = new int[template.CollectableSourceItems.Length];
            }

			m_Log = log;
			Template = template;
		}