Beispiel #1
0
        public Quest TryAddQuest(QuestTemplate template, IQuestHolder questGiver)
        {
            int freeSlot = m_Owner.QuestLog.FindFreeSlot();

            if (freeSlot == -1)
            {
                QuestHandler.SendQuestLogFull(m_Owner);
            }
            else
            {
                QuestInvalidReason reason = template.CheckBasicRequirements(m_Owner);
                if (reason != QuestInvalidReason.Ok)
                {
                    QuestHandler.SendQuestInvalid(m_Owner, reason);
                }
                else if (m_Owner.QuestLog.GetActiveQuest(template.Id) != null)
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyHave);
                }
                else if (!template.Repeatable && m_Owner.QuestLog.FinishedQuests.Contains(template.Id))
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyCompleted);
                }
                else if (!questGiver.CanGiveQuestTo(m_Owner))
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.Tired);
                }
                else
                {
                    Quest quest = m_Owner.QuestLog.AddQuest(template, freeSlot);
                    if (quest.Template.Flags.HasFlag(QuestFlags.Escort))
                    {
                        AutoComplete(quest, m_Owner);
                    }
                    return(quest);
                }
            }

            return(null);
        }
Beispiel #2
0
        public Quest TryAddQuest(QuestTemplate template, IQuestHolder questGiver)
        {
            var slot = m_Owner.QuestLog.FindFreeSlot();

            if (slot == INVALID_SLOT)
            {
                QuestHandler.SendQuestLogFull(m_Owner);
            }
            else
            {
                var err = template.CheckBasicRequirements(m_Owner);
                if (err != QuestInvalidReason.Ok)
                {
                    QuestHandler.SendQuestInvalid(m_Owner, err);
                }
                else if (m_Owner.QuestLog.GetActiveQuest(template.Id) != null)
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyHave);
                }
                else if (!template.Repeatable && m_Owner.QuestLog.FinishedQuests.Contains(template.Id))
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyCompleted);
                }
                else if (!questGiver.CanGiveQuestTo(m_Owner))
                {
                    // cheat protection
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.Tired);
                }
                else
                {
                    var quest = m_Owner.QuestLog.AddQuest(template, slot);
                    if (quest.Template.Flags.HasFlag(QuestFlags.Escort))
                    {
                        AutoComplete(quest, m_Owner);
                    }
                    return(quest);
                }
            }
            return(null);
        }
Beispiel #3
0
		public Quest TryAddQuest(QuestTemplate template, IQuestHolder questGiver)
		{
			var slot = m_Owner.QuestLog.FindFreeSlot();
			if (slot == INVALID_SLOT)
			{
				QuestHandler.SendQuestLogFull(m_Owner);
			}
			else
			{
				var err = template.CheckBasicRequirements(m_Owner);
				if (err != QuestInvalidReason.Ok)
				{
					QuestHandler.SendQuestInvalid(m_Owner, err);
				}
				else if (m_Owner.QuestLog.GetActiveQuest(template.Id) != null)
				{
					QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyHave);
				}
				else if (!template.Repeatable && m_Owner.QuestLog.FinishedQuests.Contains(template.Id))
				{
					QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyCompleted);
				}
				else if (!questGiver.CanGiveQuestTo(m_Owner))
				{
					// cheat protection
					QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.Tired);
				}
				else
				{
					var quest = m_Owner.QuestLog.AddQuest(template, slot);
					if (quest.Template.Flags.HasFlag(QuestFlags.Escort))
					{
						AutoComplete(quest, m_Owner);
					}
					return quest;
				}
			}
			return null;
		}