Ejemplo n.º 1
0
        // when we deserialize we don't know the ordr in which the deeds will be read,
        //	so insure they are stored sorted.
        public static void AddSorted(PlayerQuestDeed pqd)
        {
            // find the correct insert point
            if (m_Table.Count > 0)
            {
                foreach (object temp in m_Table)
                {
                    if (temp == null || temp is PlayerQuestDeed == false)
                    {
                        continue;
                    }

                    PlayerQuestDeed px = temp as PlayerQuestDeed;
                    if (pqd.Expires < px.Expires)
                    {                           // insert before this one
                        m_Table.Insert(m_Table.IndexOf(temp), pqd);
                        return;
                    }
                }
            }

            // just add it, it's either the first element, or the oldest
            m_Table.Add(pqd);
        }
Ejemplo n.º 2
0
        public static int Announce(out int PlayerQuestsAnnounced)
        {
            PlayerQuestsAnnounced = 0;
            //LogHelper Logger = new LogHelper("PlayerQuest.log", false);
            int count = 0;

            try
            {
                int       msgndx       = 0;
                ArrayList ToDelete     = new ArrayList();
                ArrayList ParentMobile = new ArrayList();

                // clear any messages currently on the TC
                PlayerQuestManager.ClearAllMessages();

                // find expired
                foreach (object o in PlayerQuestManager.Deeds)
                {
                    if (o is PlayerQuestDeed == false)
                    {
                        continue;
                    }
                    PlayerQuestDeed pqd = o as PlayerQuestDeed;

                    if (pqd.Deleted == true)
                    {
                        ToDelete.Add(pqd);
                    }
                    else
                    {
                        object root = pqd.RootParent;
                        //bool exclude = false;
                        count++;

                        // don't announce an expired quest
                        if (pqd.Expired == true)
                        {
                            continue;
                        }

                        // don't announce if in a locked down container in a house
                        if (root is BaseContainer && Server.Multis.BaseHouse.FindHouseAt(pqd) != null)
                        {
                            BaseContainer bc = root as BaseContainer;
                            if (bc.IsLockedDown == true || bc.IsSecure == true)
                            {
                                continue;
                            }
                        }

                        // don't announce if locked down or secure
                        if (pqd.IsLockedDown == true || pqd.IsSecure == true)
                        {
                            continue;
                        }

                        // don't announce if on the internal map
                        if (pqd.Map == Map.Internal || root is Mobile && (root as Mobile).Map == Map.Internal)
                        {
                            continue;
                        }

                        // don't announce if in bankbox
                        if (root is Mobile && pqd.IsChildOf((root as Mobile).BankBox))
                        {
                            continue;
                        }

                        // only announce 1 ticket per mobile or container
                        // (15 tickets on a mob, or in a chest should generate 1 announcement)
                        if (root != null)
                        {
                            if (ParentMobile.Contains(root))
                            {
                                continue;
                            }
                        }

                        // only public houses
                        Server.Multis.BaseHouse house = null;
                        if (root is Item)
                        {
                            house = Server.Multis.BaseHouse.FindHouseAt(root as Item);
                        }
                        if (root is Mobile)
                        {
                            house = Server.Multis.BaseHouse.FindHouseAt(root as Mobile);
                        }
                        if (house != null && house.Public == false)
                        {
                            continue;
                        }

                        ///////////////////////////////////////////////////////
                        // okay announce it !
                        // record the parent
                        if (root != null)
                        {
                            ParentMobile.Add(root);
                        }

                        // format the message
                        string[] lines = new string[2];
                        if (root is Mobile)
                        {
                            Mobile mob = root as Mobile;
                            lines[0] = String.Format(
                                "{0} was last seen near {1}. {2} is not to be trusted.",
                                mob.Name,
                                BaseOverland.DescribeLocation(mob),
                                mob.Female == true ? "She" : "He");

                            lines[1] = String.Format(
                                "Do what you will with {0}, but get that quest ticket {1} carries.",
                                mob.Female == true ? "her" : "him",
                                mob.Female == true ? "she" : "he");
                        }
                        else
                        {
                            lines[0] = String.Format(
                                "A quest ticket was last seen near {0}",
                                BaseOverland.DescribeLocation(root == null ? pqd : root as Item));

                            lines[1] = String.Format(
                                "It may be of significant value, but be careful!");
                        }

                        // queue it
                        PlayerQuestManager.SetMessage(lines, msgndx++);

                        // count it
                        PlayerQuestsAnnounced++;
                    }

                    // record the expiring quest chest
                    //Logger.Log(LogType.Item, bc, "Player Quest prize being deleted because the quest has expired.");
                }

                // cleanup
                for (int i = 0; i < ToDelete.Count; i++)
                {
                    PlayerQuestDeed pqd = ToDelete[i] as PlayerQuestDeed;
                    if (pqd != null)
                    {
                        PlayerQuestManager.Deeds.Remove(pqd);
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.LogException(e);
                Console.WriteLine("Exception while running PlayerQuestManager.Announce() job");
                Console.WriteLine(e);
            }
            finally
            {
                //Logger.Finish();
            }

            return(count);
        }
Ejemplo n.º 3
0
			protected override void OnTarget(Mobile from, object o)
			{
				try
				{
					if (from == null)
					{
						return;
					}

					if (o == null)
					{
						from.SendMessage("Target does not exist.");
						return;
					}


					if (o is BaseContainer == false)
					{
						from.SendMessage("That is not a container.");
						return;
					}

					BaseContainer bc = o as BaseContainer;

					if (Misc.Diagnostics.Assert(from.Backpack != null, "from.Backpack == null") == false)
					{
						from.SendMessage("You cannot use this deed without a backpack.");
						return;
					}

					// mobile backpacks may not be used
					if (bc == from.Backpack || bc.Parent is Mobile)
					{
						from.SendMessage("You may not use that container.");
						return;
					}

					// must not be locked down
					if (bc.IsLockedDown == true || bc.IsSecure == true)
					{
						from.SendMessage("That container is locked down.");
						return;
					}

					// if it's in your bankbox, or it's in YOUR house, you can deed it
					if ((bc.IsChildOf(from.BankBox) || CheckAccess(from)) == false)
					{
						from.SendMessage("The container must be in your bankbox, or a home you own.");
						return;
					}

					// cannot be in another container
					if (bc.RootParent is BaseContainer && bc.IsChildOf(from.BankBox) == false)
					{
						from.SendMessage("You must remove it from that container first.");
						return;
					}

					// okay, done with target checking, now deed the container.
					// place a special deed to reclaim the container in the players backpack
					PlayerQuestDeed deed = new PlayerQuestDeed(bc);
					if (from.Backpack.CheckHold(from, deed, true, false, 0, 0))
					{
						bc.PlayerQuest = true;							// mark as special
						bc.MoveToWorld(from.Location, Map.Internal);	// put it on the internal map
						bc.SetLastMoved();								// record the move (will use this in Heartbeat cleanup)
						//while (deed.Expires.Hours + deed.Expires.Minutes == 0)
						//Console.WriteLine("Waiting...");
						//int hours = deed.Expires.Hours;
						//int minutes = deed.Expires.Minutes;
						//string text = String.Format("{0} {1}, and {2} {3}",	hours, hours == 1 ? "hour" : "hours", minutes, minutes == 1 ? "minute" : "minutes");
						from.Backpack.DropItem(deed);
						from.SendMessage("A deed for the container has been placed in your backpack.");
						//from.SendMessage( "This quest will expire in {0}.", text);
					}
					else
					{
						from.SendMessage("Your backpack is full and connot hold the deed.");
						deed.Delete();
					}
				}
				catch (Exception e)
				{
					LogHelper.LogException(e);
				}
			}
Ejemplo n.º 4
0
		// when we deserialize we don't know the ordr in which the deeds will be read,
		//	so insure they are stored sorted.
		public static void AddSorted(PlayerQuestDeed pqd)
		{
			// find the correct insert point
			if (m_Table.Count > 0)
				foreach (object temp in m_Table)
				{
					if (temp == null || temp is PlayerQuestDeed == false )
						continue;

					PlayerQuestDeed px = temp as PlayerQuestDeed;
					if (pqd.Expires < px.Expires)
					{	// insert before this one
						m_Table.Insert(m_Table.IndexOf(temp), pqd);
						return;
					}
				}
			
			// just add it, it's either the first element, or the oldest
			m_Table.Add(pqd);
		}