Exemple #1
0
        public static bool Delayed(PlayerMobile player, BaseQuest quest, bool message)
        {
            List<QuestRestartInfo> doneQuests = player.DoneQuests;
																					
            for (int i = doneQuests.Count - 1; i >= 0; i --)
            { 
                QuestRestartInfo restartInfo = doneQuests[i];

                if (restartInfo.QuestType == quest.GetType())
                {
                    if (quest.DoneOnce)
                    {
                        if (message && quest.StartingMobile != null)
                            quest.StartingMobile.Say(1075454); // I can not offer you the quest again.
					
                        return false;
                    }
						
                    DateTime endTime = restartInfo.RestartTime;
					
                    if (DateTime.UtcNow < endTime)
                        return false;
					
                    if (quest.RestartDelay > TimeSpan.Zero)
                        doneQuests.RemoveAt(i);
													
                    return true;
                }
            }
			
            return true;
        }
Exemple #2
0
        public static bool CanOfferQuest(Mobile check, Type questType, out bool inRestartPeriod)
        {
            inRestartPeriod = false;

            if (!(check is PlayerMobile pm))
            {
                return(false);
            }

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

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

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

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

            if (questType == typeof(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);
        }
Exemple #3
0
        public static bool Delayed(PlayerMobile player, BaseQuest quest, object quester, bool message)
        {
            QuestRestartInfo restartInfo = GetRestartInfo(player, quest.GetType());

            if (restartInfo != null)
            {
                if (quest.DoneOnce)
                {
                    if (message && quester is Mobile)
                    {
                        ((Mobile)quester).Say(1075454); // I can not offer you the quest again.
                    }

                    return(false);
                }

                DateTime endTime = restartInfo.RestartTime;

                if (DateTime.UtcNow < endTime)
                {
                    if (message && quester is Mobile)
                    {
                        TimeSpan ts = endTime - DateTime.UtcNow;
                        string   str;

                        if (ts.TotalDays > 1)
                        {
                            str = string.Format("I cannot offer this quest again for about {0} more days.", ts.TotalDays);
                        }
                        else if (ts.TotalHours > 1)
                        {
                            str = string.Format("I cannot offer this quest again for about {0} more hours.", ts.TotalHours);
                        }
                        else if (ts.TotalMinutes > 1)
                        {
                            str = string.Format("I cannot offer this quest again for about {0} more minutes.", ts.TotalMinutes);
                        }
                        else
                        {
                            str = "I can offer this quest again very soon.";
                        }

                        ((Mobile)quester).SayTo(player, false, str);
                    }

                    return(false);
                }

                if (quest.RestartDelay > TimeSpan.Zero)
                {
                    player.DoneQuests.Remove(restartInfo);
                }

                return(true);
            }

            return(true);
        }
Exemple #4
0
        public static void Delay(PlayerMobile player, Type type, TimeSpan delay)
        {
            QuestRestartInfo restartInfo = GetRestartInfo(player, type);

            if (restartInfo != null)
            {
                restartInfo.Reset(delay);
                return;
            }

            player.DoneQuests.Add(new QuestRestartInfo(type, delay));
        }
Exemple #5
0
        public static bool TryReceiveQuestItem(PlayerMobile player, Type type, TimeSpan delay)
        {
            if (type.IsSubclassOf(typeof(Item)))
            {
                QuestRestartInfo info = null;

                for (var index = 0; index < player.DoneQuests.Count; index++)
                {
                    var x = player.DoneQuests[index];

                    if (x.QuestType == type)
                    {
                        info = x;
                        break;
                    }
                }

                if (info != null)
                {
                    DateTime endTime = info.RestartTime;

                    if (DateTime.UtcNow < endTime)
                    {
                        TimeSpan ts = endTime - DateTime.UtcNow;

                        if (ts.Days > 0)
                        {
                            player.SendLocalizedMessage(1158377, string.Format("{0}\t{1}", ts.Days.ToString(), "day[s]"));
                        }
                        else if (ts.Hours > 0)
                        {
                            player.SendLocalizedMessage(1158377, string.Format("{0}\t{1}", ts.Hours.ToString(), "hour[s]"));
                        }
                        else
                        {
                            player.SendLocalizedMessage(1158377, string.Format("{0}\t{1}", ts.Minutes.ToString(), "minute[s]"));
                        }

                        return(false);
                    }

                    info.Reset(delay);
                }
                else
                {
                    player.DoneQuests.Add(new QuestRestartInfo(type, delay));
                }

                return(true);
            }

            return(false);
        }
Exemple #6
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);
            }

            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.Now < endTime)
                        {
                            inRestartPeriod = true;
                            return(false);
                        }

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

            return(true);
        }
Exemple #7
0
        public static void Delay(PlayerMobile player, Type type, TimeSpan delay)
        {
            for (int i = 0; i < player.DoneQuests.Count; i++)
            {
                QuestRestartInfo restartInfo = player.DoneQuests[i];

                if (restartInfo.QuestType == type)
                {
                    restartInfo.Reset(delay);
                    return;
                }
            }

            player.DoneQuests.Add(new QuestRestartInfo(type, delay));
        }
Exemple #8
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));
                    }
                }
            }
        }
Exemple #9
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);
            }

            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);
        }
Exemple #10
0
        public static bool FindCompletedQuest(PlayerMobile from, Type type, bool delete)
        {
            if (type == null)
                return false;
				
            for (int i = from.DoneQuests.Count - 1; i >= 0; i --)
            {
                QuestRestartInfo restartInfo = from.DoneQuests[i];

                if (restartInfo.QuestType == type)
                {
                    if (delete)
                        from.DoneQuests.RemoveAt(i);
						
                    return true;
                }
            }
			
            return false;
        }
Exemple #11
0
        public virtual void ClearQuest(bool completed)
        {
            StopTimer();

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

                TimeSpan restartDelay = RestartDelay;

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

                    bool found = false;

                    Type ourQuestType = GetType();

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

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

                    if (!found)
                    {
                        From.DoneQuests.Add(new QuestRestartInfo(ourQuestType, restartDelay));
                    }
                }
            }
        }