Beispiel #1
0
        public virtual Mobile GetEscorter()
        {
            Mobile master = ControlMaster;

            if (master == null || !Controlled)
            {
                return(master);
            }
            else if (master.Map != Map || !master.InRange(Location, 30) || !master.Alive)
            {
                TimeSpan lastSeenDelay = DateTime.UtcNow - LastSeenEscorter;

                if (lastSeenDelay >= TimeSpan.FromMinutes(2.0))
                {
                    EscortObjective escort = GetObjective();

                    if (escort != null)
                    {
                        master.SendLocalizedMessage(1071194); // You have failed your escort quest…
                        master.PlaySound(0x5B3);
                        escort.Fail();
                    }

                    master.SendLocalizedMessage(1042473); // You have lost the person you were escorting.
                    Say(1005653);                         // Hmmm.  I seem to have lost my master.

                    StopFollow();
                    m_EscortTable.Remove(master);

                    TimerRegistry.Register(m_TimerID, this, TimeSpan.FromSeconds(5.0), e => e.Delete());

                    return(null);
                }
                else
                {
                    ControlOrder = OrderType.Stay;
                }
            }
            else
            {
                if (ControlOrder != OrderType.Follow)
                {
                    StartFollow(master);
                }

                LastSeenEscorter = DateTime.UtcNow;
            }

            return(master);
        }
Beispiel #2
0
        public virtual Mobile GetEscorter()
        {
            Mobile master = this.ControlMaster;

            if (master == null || !this.Controlled)
            {
                return(master);
            }
            else if (master.Map != this.Map || !master.InRange(this.Location, 30) || !master.Alive)
            {
                TimeSpan lastSeenDelay = DateTime.UtcNow - this.m_LastSeenEscorter;

                if (lastSeenDelay >= TimeSpan.FromMinutes(2.0))
                {
                    EscortObjective escort = this.GetObjective();

                    if (escort != null)
                    {
                        master.SendLocalizedMessage(1071194); // You have failed your escort quest…
                        master.PlaySound(0x5B3);
                        escort.Fail();
                    }

                    master.SendLocalizedMessage(1042473); // You have lost the person you were escorting.
                    this.Say(1005653);                    // Hmmm.  I seem to have lost my master.

                    this.StopFollow();
                    m_EscortTable.Remove(master);
                    this.m_DeleteTimer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerCallback(Delete));

                    return(null);
                }
                else
                {
                    this.ControlOrder = OrderType.Stay;
                }
            }
            else
            {
                if (this.ControlOrder != OrderType.Follow)
                {
                    this.StartFollow(master);
                }

                this.m_LastSeenEscorter = DateTime.UtcNow;
            }

            return(master);
        }
        /// <summary>
        /// Overridable. Checks if at destination.
        /// </summary>
        public virtual bool CheckAtDestination()
        {
            EscortObjective escort = GetObjective();

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

            if (escort.Region == null)
            {
                escort.Fail();
                return(CheckAtDestination());
            }

            Mobile escorter = GetEscorter();

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

            if (escort.Region.Contains(Location))
            {
                Say(1042809, escorter.Name);                   // We have arrived! I thank thee, ~1_PLAYER_NAME~! I have no further need of thy services. Here is thy pay.

                escort.Complete();

                if (m_Quest != null)
                {
                    if (m_Quest.Completed)
                    {
                        escorter.SendLocalizedMessage(1046258, null, 0x23);                           // Your quest is complete.

                        if (!QuestHelper.AnyRewards(m_Quest))
                        {
                            m_Quest.GiveRewards();
                        }
                        else
                        {
                            escorter.SendGump(new MondainQuestGump(m_Quest, MondainQuestGump.Section.Rewards, false, true));
                        }

                        escorter.PlaySound(m_Quest.CompleteSound);
                    }
                    else
                    {
                        escorter.PlaySound(m_Quest.UpdateSound);
                    }
                }

                StopFollow();
                SetControlMaster(null);
                m_EscortTable.Remove(escorter);
                BeginDelete();

                // fame, compassion
                if (escort.Fame > 0)
                {
                    Misc.Titles.AwardFame(escorter, escort.Fame, true);

                    bool gainedPath = false;

                    PlayerMobile pm = escorter as PlayerMobile;

                    if (pm != null)
                    {
                        if (pm.CompassionGains > 0 && DateTime.Now > pm.NextCompassionDay)
                        {
                            pm.NextCompassionDay = DateTime.MinValue;
                            pm.CompassionGains   = 0;
                        }

                        if (pm.CompassionGains >= 5)                           // have already gained 5 times in one day, can gain no more
                        {
                            pm.SendLocalizedMessage(1053004);                  // You must wait about a day before you can gain in compassion again.
                        }
                        else if (VirtueHelper.Award(pm, VirtueName.Compassion, 200, ref gainedPath))
                        {
                            if (gainedPath)
                            {
                                pm.SendLocalizedMessage(1053005);                                   // You have achieved a path in compassion!
                            }
                            else
                            {
                                pm.SendLocalizedMessage(1053002);                                   // You have gained in compassion.
                            }
                            pm.NextCompassionDay = DateTime.Now + TimeSpan.FromDays(1.0);           // in one day CompassionGains gets reset to 0
                            ++pm.CompassionGains;
                        }
                        else
                        {
                            pm.SendLocalizedMessage(1053003);                               // You have achieved the highest path of compassion and can no longer gain any further.
                        }
                    }
                }

                return(true);
            }

            return(false);
        }