Exemplo n.º 1
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);
                }
            }
Exemplo n.º 2
0
        protected override void OnTarget(Mobile from, object o)
        {
            if (o is BaseReagent)
            {
                BaseReagent reg = o as BaseReagent;
                if (reg.Movable && reg.IsChildOf(from))
                {
                    if (!reg.OnDroppedOnto(from, m_Container))
                    {
                        from.SendMessage("You cannot move that into the container.");
                    }
                }
                else
                {
                    from.SendMessage("That must be in your backpack or bankbox to move it.");
                }
            }
            else if (o is BaseContainer)
            {
                BaseContainer to = o as BaseContainer;

                if (to.IsChildOf(from))
                {
                    bool movedItems = true;
                    for (int i = to.Items.Count - 1; i >= 0; i--)
                    {
                        if (to.Items[i] is BaseReagent)
                        {
                            BaseReagent reg = to.Items[i] as BaseReagent;
                            if (reg != null)
                            {
                                if (reg.Movable)
                                {
                                    if (m_Amount < 0 || reg.Amount <= m_Amount)
                                    {
                                        if (!reg.OnDroppedOnto(from, m_Container))
                                        {
                                            movedItems = false;
                                        }
                                    }
                                    else
                                    {
                                        BaseReagent newreg = Activator.CreateInstance(reg.GetType()) as BaseReagent;
                                        newreg.Amount = m_Amount;
                                        if (!newreg.OnDroppedOnto(from, m_Container))
                                        {
                                            movedItems = false;
                                            newreg.Delete();
                                        }
                                        else
                                        {
                                            reg.Consume(m_Amount);
                                        }
                                    }
                                }
                                else
                                {
                                    movedItems = false;
                                }
                            }
                        }
                    }

                    if (!movedItems)
                    {
                        from.SendMessage("Some reagents could not be moved.");
                    }
                }
                else
                {
                    from.SendMessage("That must be in your backpack or bank box to move reagents from it.");
                }
            }
        }