Example #1
0
        public virtual void ClearQuest(bool completed)
        {
            StopTimer();

            if (m_From.Quest == this)
            {
                m_From.Quest = null;

                TimeSpan restartDelay = this.RestartDelay;

                if ((completed && restartDelay > TimeSpan.Zero) || (!completed && restartDelay == TimeSpan.MaxValue))
                {
                    List <QuestRestartInfo> doneQuests = m_From.DoneQuests;

                    if (doneQuests == null)
                    {
                        m_From.DoneQuests = doneQuests = new List <QuestRestartInfo>();
                    }

                    bool found = false;

                    Type ourQuestType = this.GetType();

                    for (int i = 0; i < doneQuests.Count; ++i)
                    {
                        QuestRestartInfo restartInfo = doneQuests[i];

                        if (restartInfo.QuestType == ourQuestType)
                        {
                            restartInfo.Reset(restartDelay);
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        doneQuests.Add(new QuestRestartInfo(ourQuestType, restartDelay));
                    }
                }
            }
        }
Example #2
0
        public static bool CanOfferQuest(Mobile check, Type questType, out bool inRestartPeriod)
        {
            inRestartPeriod = false;

            PlayerMobile pm = check as PlayerMobile;

            if (pm == null)
            {
                return(false);
            }

            if (pm.HasGump(typeof(QuestOfferGump)))
            {
                return(false);
            }

            if (questType == typeof(Necro.DarkTidesQuest) && pm.Profession != 4) // necromancer
            {
                return(false);
            }

            if (questType == typeof(Haven.UzeraanTurmoilQuest) && pm.Profession != 1 && pm.Profession != 2 && pm.Profession != 5) // warrior / magician / paladin
            {
                return(false);
            }

            if (questType == typeof(Samurai.HaochisTrialsQuest) && pm.Profession != 6) // samurai
            {
                return(false);
            }

            if (questType == typeof(Ninja.EminosUndertakingQuest) && pm.Profession != 7) // ninja
            {
                return(false);
            }

            List <QuestRestartInfo> doneQuests = pm.DoneQuests;

            if (doneQuests != null)
            {
                for (int i = 0; i < doneQuests.Count; ++i)
                {
                    QuestRestartInfo restartInfo = doneQuests[i];

                    if (restartInfo.QuestType == questType)
                    {
                        DateTime endTime = restartInfo.RestartTime;

                        if (DateTime.UtcNow < endTime)
                        {
                            inRestartPeriod = true;
                            return(false);
                        }

                        doneQuests.RemoveAt(i--);
                        return(true);
                    }
                }
            }

            return(true);
        }