Ejemplo n.º 1
0
        /// <summary>
        /// Tries to hand out the rewards, archives this quest and sends details about the next quest in the chain (if any).
        /// </summary>
        /// <param name="qHolder"></param>
        /// <param name="rewardSlot"></param>
        public bool TryFinish(IQuestHolder qHolder, uint rewardSlot)
        {
            Character owner = m_Log.Owner;

            owner.OnInteract(qHolder as WorldObject);
            if (qHolder is WorldObject &&
                !owner.IsInRadius((WorldObject)qHolder, NPCMgr.DefaultInteractionDistance))
            {
                NPCHandler.SendNPCError(owner, qHolder,
                                        VendorInventoryError.TooFarAway);
                return(false);
            }

            if (!Template.TryGiveRewards(m_Log.Owner, qHolder, rewardSlot))
            {
                return(false);
            }
            ArchiveQuest();
            QuestHandler.SendComplete(Template, owner);
            if (Template.FollowupQuestId != 0U)
            {
                QuestTemplate template = QuestMgr.GetTemplate(Template.FollowupQuestId);
                if (template != null && qHolder.QuestHolderInfo.QuestStarts.Contains(template))
                {
                    QuestHandler.SendDetails(qHolder, template, owner, true);
                    if (template.Flags.HasFlag(QuestFlags.AutoAccept))
                    {
                        owner.QuestLog.TryAddQuest(template, qHolder);
                    }
                }
            }

            if (!Template.Repeatable)
            {
                owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.CompleteQuestCount, 1U, 0U,
                                                                   null);
                owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.CompleteQuest,
                                                                   Entry, 0U, null);
                if (Template.ZoneTemplate != null)
                {
                    owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.CompleteQuestsInZone,
                                                                       (uint)Template.ZoneTemplate.Id, 0U, null);
                }
            }

            if (Template.IsDaily)
            {
                owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.CompleteDailyQuest, 1U, 0U,
                                                                   null);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tries to hand out the rewards, archives this quest and sends details about the next quest in the chain (if any).
        /// </summary>
        /// <param name="qHolder"></param>
        /// <param name="rewardSlot"></param>
        public bool TryFinish(IQuestHolder qHolder, uint rewardSlot)
        {
            var chr = m_Log.Owner;

            chr.OnInteract(qHolder as WorldObject);

            if (qHolder is WorldObject && !chr.IsInRadius((WorldObject)qHolder, NPCMgr.DefaultInteractionDistance))
            {
                NPCHandler.SendNPCError(chr, qHolder, VendorInventoryError.TooFarAway);
                return(false);
            }

            if (Template.TryGiveRewards(m_Log.Owner, qHolder, rewardSlot))
            {
                ArchiveQuest();
                QuestHandler.SendComplete(Template, chr);

                if (Template.FollowupQuestId != 0)
                {
                    var nq = QuestMgr.GetTemplate(Template.FollowupQuestId);
                    if (nq != null && qHolder.QuestHolderInfo.QuestStarts.Contains(nq))
                    {
                        // Offer the next Quest if its also offered by the same QuestGiver
                        QuestHandler.SendDetails(qHolder, nq, chr, true);
                        if (nq.Flags.HasFlag(QuestFlags.AutoAccept))
                        {
                            chr.QuestLog.TryAddQuest(nq, qHolder);
                        }
                    }
                }

                if (!Template.Repeatable)
                {
                    chr.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.CompleteQuestCount, 1);
                    chr.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.CompleteQuest, Entry);
                    if (Template.ZoneTemplate != null)
                    {
                        chr.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.CompleteQuestsInZone,
                                                                         (uint)Template.ZoneTemplate.Id);
                    }
                }

                if (Template.IsDaily)
                {
                    chr.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.CompleteDailyQuest, 1);
                }

                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var qt = QuestMgr.GetTemplate(trigger.Text.NextUInt());

                if (qt != null)
                {
                    var questGiver    = trigger.Args.Character as IQuestHolder;
                    var questReceiver = (Character)trigger.Args.Character.Target;
                    if (questGiver != null)
                    {
                        QuestHandler.SendDetails(questGiver, qt, questReceiver, false);
                    }
                }
                trigger.Reply("Done.");
            }
Ejemplo n.º 4
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                QuestTemplate template = QuestMgr.GetTemplate(trigger.Text.NextUInt());

                if (template != null)
                {
                    IQuestHolder character = trigger.Args.Character as IQuestHolder;
                    Character    target    = (Character)trigger.Args.Character.Target;
                    if (character != null)
                    {
                        QuestHandler.SendDetails(character, template, target, false);
                    }
                }

                trigger.Reply("Done.");
            }
Ejemplo n.º 5
0
        public static void StartQuestDialog(this IQuestHolder qHolder, Character chr)
        {
            chr.OnInteract(qHolder as WorldObject);

            var list = qHolder.QuestHolderInfo.GetAvailableQuests(chr);

            if (list.Count > 0)
            {
                if (list.Count == 1 && !chr.QuestLog.HasActiveQuest(list[0].Id))
                {
                    // start a single quest if there is only one and the user did not start it yet
                    var autoAccept = list[0].Flags.HasFlag(QuestFlags.AutoAccept);
                    QuestHandler.SendDetails(qHolder, list[0], chr, !autoAccept);
                    if (autoAccept)
                    {
                        chr.QuestLog.TryAddQuest(list[0], qHolder);
                    }
                }
                else
                {
                    QuestHandler.SendQuestList(qHolder, list, chr);
                }
            }
        }
Ejemplo n.º 6
0
        public static void StartQuestDialog(this IQuestHolder qHolder, Character chr)
        {
            chr.OnInteract(qHolder as WorldObject);
            List <QuestTemplate> availableQuests = qHolder.QuestHolderInfo.GetAvailableQuests(chr);

            if (availableQuests.Count <= 0)
            {
                return;
            }
            if (availableQuests.Count == 1 && !chr.QuestLog.HasActiveQuest(availableQuests[0].Id))
            {
                bool flag = availableQuests[0].Flags.HasFlag((Enum)QuestFlags.AutoAccept);
                QuestHandler.SendDetails((IEntity)qHolder, availableQuests[0], chr, !flag);
                if (!flag)
                {
                    return;
                }
                chr.QuestLog.TryAddQuest(availableQuests[0], qHolder);
            }
            else
            {
                QuestHandler.SendQuestList(qHolder, availableQuests, chr);
            }
        }