Inheritance: Server.Items.Container
        public override void OnDoubleClick(Mobile from)
        {
            PlayerMobile pm = from as PlayerMobile;

            if (!IsChildOf(from.Backpack))
            {
                from.SendMessage("This item must be in your pack before you are able to use it");
            }
            else
            {
                #region If Charge Is Less Than OR Equal To '0' Box Wont Open

                if (Charges <= 0)
                {
                    from.SendMessage("You need to recharge this before you are able to use it again!");
                }

                #endregion If Charge Is Less Than OR Equal To '0' Box Wont Open

                else
                {
                    BankBox box = from.BankBox;
                    if (box != null)
                    {
                        box.Open();
                    }

                    #region This Decreases The Number Of Charges After Using Item

                    Charges--;

                    #endregion This Decreases The Number Of Charges After Using Item
                }
            }
        }
Exemple #2
0
        public override void OnDoubleClick(Mobile from)
        {
            string number;

            BankBox box = from.BankBox;

            if (m_Commodity != null)
            {
                if (box != null && IsChildOf(box))
                {
                    number = "The commodity has been redeemed.";

                    box.DropItem(m_Commodity);

                    m_Commodity = null;
                    Delete();
                }
                else
                {
                    number = "To claim the resources ....";
                }
            }
            else if (box == null || !IsChildOf(box))
            {
                number = "That must be in your bank box to use it.";
            }
            else
            {
                number = "Target the commodity to fill this deed with.";

                from.Target = new InternalTarget(this);
            }

            from.SendAsciiMessage(number);
        }
Exemple #3
0
        public void CheckBank(BankBox bank, Mobile from)
        {
            if (AccountGold.Enabled && bank.Owner == from && from.Account != null)
            {
                List <BankCheck> checks = new List <BankCheck>(Items.OfType <BankCheck>());

                foreach (BankCheck check in checks)
                {
                    if (from.Account.DepositGold(check.Worth))
                    {
                        from.SendLocalizedMessage(1042672, true, check.Worth.ToString("#,0"));
                        check.Delete();
                    }
                    else
                    {
                        from.AddToBackpack(check);
                    }
                }

                checks.Clear();
                checks.TrimExcess();

                UpdateTotals();
            }
        }
        public void EndInvasion()
        {
            WaveTimer.Stop();

            for (int i = 0; i < Spawn.Count; ++i)
            {
                Mobile m = (Mobile)Spawn[i];
                Spawn.Remove(m);
                m.Delete();
            }

            for (int i = 0; i < Players.Count; ++i)
            {
                PlayerMobile pm = (PlayerMobile)Players[i];
                Players.Remove(pm);

                BankBox bank = (BankBox)pm.BankBox;
                bank.DropItem(new BankCheck(InvasionConfig.Reward));
            }

            Killed     = 0;
            inprogress = false;
            ThisRegion.Unregister();
            ThisRegion = null;
        }
        public override void OnDoubleClick(Mobile from)
        {
            PlayerMobile pm = from as PlayerMobile;


            if (from.Criminal)
            {
                from.SendMessage("Thou art a criminal and cannot access thy bank box.");
            }

            else
            {
                BankBox box = from.BankBox;

                if (box != null)
                {
                    box.Open();
                }
            }


            {
                from.SendLocalizedMessage(500446);               // That is too far away.
            }
        }
Exemple #6
0
        public override void OnDoubleClick(Mobile from)
        {
            Backpack  bankbag    = new Backpack();
            Container mobilePack = from.Backpack;
            BankBox   mobileBox  = from.BankBox;
            ArrayList equipitems = new ArrayList(from.Items);

            mobileBox.AddItem(bankbag);
            //				this.AddPlayer( player );
            from.Frozen = true;
            from.SendMessage("All your belongings were transported to your bankbox.  You will need to close you backpack and re-open it for it to display the correct contents.");

            //				if ( Teams.Contains( from ) )
            //				{
            //					from.Frozen = true;
            //				}
            foreach (Item item in equipitems)
            {
                if ((item.Layer != Layer.Bank) && (item.Layer != Layer.Backpack) && (item.Layer != Layer.Hair) && (item.Layer != Layer.FacialHair) && (item.Layer != Layer.Mount))
                {
                    mobilePack.DropItem(item);
                }
            }

            ArrayList packitems = new ArrayList(mobilePack.Items);

            foreach (Item items in packitems)
            {
                bankbag.DropItem(items);
            }
        }
        public override void OnDoubleClick(Mobile from)
        {
            if (!from.Alive)
            {
                return;
            }

            if (!from.InRange(this.GetWorldLocation(), 3))
            {
                from.SendMessage("You are too far away to ring the banker's podium bell.");
                return;
            }

            if (NextUse > TimeSpan.Zero)
            {
                from.SendMessage("The magical bank clerk is busy at the moment. Try back later.");
                return;
            }

            if (from.Criminal)
            {
                from.SendMessage("Thou art a criminal and cannot access thy bank box.");
            }
            else
            {
                BankBox box = from.BankBox;

                if (box != null)
                {
                    box.Open();
                    NextUse = m_Delay;
                }
            }
        }
Exemple #8
0
        public override void OnDoubleClick(Mobile from)
        {
            int number;

            BankBox box = from.FindBankNoCreate();

            if ((box == null || !IsChildOf(box)))
            {
                if (Core.ML)
                {
                    number = 1080526;                     // That must be in your bank box or commodity deed box to use it.
                }
                else
                {
                    number = 1047026;                     // That must be in your bank box to use it.
                }
            }
            else
            {
                number = 1047029;                 // Target the commodity to fill this deed with.

                from.Target = new InternalTarget(this);
            }

            from.SendLocalizedMessage(number);
        }
Exemple #9
0
        public override void OnDoubleClick(Mobile from)
        {
            if (Movable)
            {
                from.SendMessage("This must be secured down in a home to use.");
            }
            else if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("You will have to get closer to use that.");
            }
            else if (!CheckAccess(from))
            {
                from.SendMessage("You cannot use this safe.");
            }
            else
            {
                BankBox box = from.BankBox;
                if (box != null)
                {
                    box.GumpID = BaseContainer.BankGump(from, box);
                    box.Open();
                }
            }

            return;
        }
Exemple #10
0
        public override void OnDoubleClick(Mobile from)
        {
            int number;

            BankBox box = from.FindBankNoCreate();

            if (m_Commodity != null)
            {
                if (box != null && IsChildOf(box))
                {
                    number = 1047031;                     // The commodity has been redeemed.

                    box.DropItem(m_Commodity);

                    m_Commodity = null;
                    Delete();
                }
                else
                {
                    number = 1047024;                     // To claim the resources ....
                }
            }
            else if (box == null || !IsChildOf(box))
            {
                number = 1047026;                 // That must be in your bank box to use it.
            }
            else
            {
                number = 1047029;                 // Target the commodity to fill this deed with.

                from.Target = new InternalTarget(this);
            }

            from.SendLocalizedMessage(number);
        }
        public void ExpireContract()
        {
            BankBox box = m_Issuer.BankBox;

            if (box != null)
            {
                Delete();

                int deposited = 0;

                int toAdd = m_Copper;

                Copper copper;

                while (toAdd > 60000)
                {
                    copper = new Copper(60000);

                    if (box.TryDropItem(m_Issuer, copper, false))
                    {
                        toAdd     -= 60000;
                        deposited += 60000;
                    }
                    else
                    {
                        copper.Delete();

                        m_Issuer.AddToBackpack(new BankCheck(toAdd));
                        toAdd = 0;

                        break;
                    }
                }

                if (toAdd > 0)
                {
                    copper = new Copper(toAdd);

                    if (box.TryDropItem(m_Issuer, copper, false))
                    {
                        deposited += toAdd;
                    }
                    else
                    {
                        copper.Delete();

                        m_Issuer.AddToBackpack(new BankCheck(toAdd));
                    }
                }

                // Gold was deposited in your account:
                m_Issuer.SendLocalizedMessage(1042672, true, " " + deposited.ToString());
            }

            /*else
             * {
             *      //from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it.
             * }*/
        }
        public override void OnDoubleClick(Mobile from)
        {
            BankBox box = from.FindBankNoCreate();

            if (box != null && IsChildOf(box))
            {
                Delete();

                int deposited = 0;

                int toAdd = m_Worth;

                Gold gold;

                while (toAdd > 60000)
                {
                    gold = new Gold(60000);

                    if (box.TryDropItem(from, gold, false))
                    {
                        toAdd     -= 60000;
                        deposited += 60000;
                    }
                    else
                    {
                        gold.Delete();

                        from.AddToBackpack(new BankCheck(toAdd));
                        toAdd = 0;

                        break;
                    }
                }

                if (toAdd > 0)
                {
                    gold = new Gold(toAdd);

                    if (box.TryDropItem(from, gold, false))
                    {
                        deposited += toAdd;
                    }
                    else
                    {
                        gold.Delete();

                        from.AddToBackpack(new BankCheck(toAdd));
                    }
                }

                // Gold was deposited in your account:
                from.SendLocalizedMessage(1042672, true, " " + deposited.ToString());
            }
            else
            {
                from.SendLocalizedMessage(1047026);                   // That must be in your bank box to use it.
            }
        }
Exemple #13
0
        public static bool UnequipPirateItems(Mobile m)
        {
            ArrayList ItemsToMove   = new ArrayList();
            ArrayList ItemsToDelete = new ArrayList();

            Bag     bag     = new Bag();
            BankBox bankBox = m.BankBox;

            if (bankBox == null || !bankBox.TryDropItem(m, bag, false))
            {
                bag.Delete();
                return(false);
            }

            Bag bag2 = new Bag();

            bag2.Name = "Pirate Curse Unequiped Items";
            bag2.Hue  = m.Hue;

            Container pack = m.Backpack;

            if (pack == null && !pack.CheckHold(m, bag2, false, true))
            {
                bag2.Delete();
                return(false);
            }
            pack.AddItem(bag2);

            foreach (Item item in m.Items)
            {
                if (item.Layer != Layer.Bank && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Layer != Layer.Mount && item.Layer != Layer.Backpack)
                {
                    if (item.Layer == Layer.OneHanded || item.Layer == Layer.Shirt || item.Layer == Layer.Pants || item.Layer == Layer.Helm || item.Layer == Layer.Shoes)
                    {
                        ItemsToDelete.Add(item);
                    }
                    else
                    {
                        ItemsToMove.Add(item);
                    }
                }
            }

            foreach (Item item in ItemsToDelete)
            {
                bag.AddItem(item);
            }
            bag.Delete();

            foreach (Item item in ItemsToMove)
            {
                bag2.AddItem(item);
            }

            RestorePlayerItems(m);

            return(true);
        }
Exemple #14
0
        public override void OnDoubleClick(Mobile from)
        {
            int number;

            BankBox          box = from.FindBankNoCreate();
            CommodityDeedBox cox = CommodityDeedBox.Find(this);

            // Veteran Rewards mods
            if (m_Commodity != null)
            {
                if (box != null && IsChildOf(box))
                {
                    number = 1047031;                     // The commodity has been redeemed.


                    box.DropItem(m_Commodity);

                    m_Commodity = null;
                    Delete();
                }
                else if (cox != null)
                {
                    if (cox.IsSecure)
                    {
                        number = 1047031;                         // The commodity has been redeemed.
                        m_Commodity.InstanceID = cox.InstanceID;
                        cox.DropItem(m_Commodity);

                        m_Commodity = null;
                        Delete();
                    }
                    else
                    {
                        number = 1080525;                         // The commodity deed box must be secured before you can use it.
                    }
                }
                else
                {
                    number = 1080526;                     // That must be in your bank box or commodity deed box to use it.
                }
            }
            else if (cox != null && !cox.IsSecure)
            {
                number = 1080525;                 // The commodity deed box must be secured before you can use it.
            }
            else if ((box == null || !IsChildOf(box)) && cox == null)
            {
                number = 1080526;                 // That must be in your bank box or commodity deed box to use it.
            }
            else
            {
                number = 1047029;                 // Target the commodity to fill this deed with.

                from.Target = new InternalTarget(this);
            }

            from.SendLocalizedMessage(number);
        }
Exemple #15
0
        public override void OnDoubleClick(Mobile from)
        {
            BankBox box = from.BankBox;

            if (box != null && IsChildOf(box))
            {
                Delete();

                int deposited = 0;

                int toAdd = m_Worth;

                Deathcoin Deathcoin;

                while (toAdd > 60000)
                {
                    Deathcoin = new Deathcoin(60000);

                    if (box.TryDropItem(from, Deathcoin, false))
                    {
                        toAdd     -= 60000;
                        deposited += 60000;
                    }
                    else
                    {
                        Deathcoin.Delete();

                        from.AddToBackpack(new DeathCoinBankCheck(toAdd));
                        toAdd = 0;

                        break;
                    }
                }

                if (toAdd > 0)
                {
                    Deathcoin = new Deathcoin(toAdd);

                    if (box.TryDropItem(from, Deathcoin, false))
                    {
                        deposited += toAdd;
                    }
                    else
                    {
                        Deathcoin.Delete();

                        from.AddToBackpack(new DeathCoinBankCheck(toAdd));
                    }
                }

                // Tokens was deposited in your Backpack:
                from.SendMessage(m_Worth / 1000 + "Death Coins were placed in your backpack.");
            }
            else
            {
                from.SendLocalizedMessage(1047026);
            }
        }
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (m_Deed.Commodity != null)
                {
                    number = 1047028;                     // The commodity deed has already been filled.
                }
                else if (targeted is Item)
                {
                    Item targetedItem = (Item)targeted;
                    if (targetedItem.Association > 0)
                    {
                        from.SendLocalizedMessage(1047027);  // That is not a commodity the bankers will fill a commodity deed with.
                        return;
                    }
                    BankBox          box = from.FindBankNoCreate();
                    CommodityDeedBox cox = CommodityDeedBox.Find(m_Deed);

                    // Veteran Rewards mods
                    if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box) ||
                        cox != null && cox.IsSecure && ((Item)targeted).IsChildOf(cox))
                    {
                        if (m_Deed.SetCommodity((Item)targeted))
                        {
                            m_Deed.Hue = 0x47;
                            number     = 1047030;                         // The commodity deed has been filled.
                        }
                        else
                        {
                            number = 1047027;                             // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                    else
                    {
                        if (m_Deed.EraML)
                        {
                            number = 1080526;                             // That must be in your bank box or commodity deed box to use it.
                        }
                        else
                        {
                            number = 1047026;                             // That must be in your bank box to use it.
                        }
                    }
                }
                else
                {
                    number = 1047027;                     // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }
Exemple #17
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            PlayerMobile pm = from as PlayerMobile;

            if (info.ButtonID == 1)
            {
                BankBox bank = from.BankBox;

                if (bank == null)
                {
                    return;
                }

                Accounting.Account acct = from.Account as Accounting.Account;

                switch (token.Type)
                {
                case PromotionalType.SoulStone:
                {
                    SoulStone ss = new SoulStone(acct.Username);

                    bank.DropItem(ss);

                    from.SendLocalizedMessage(1070743);                                       // A Soulstone has been created in your bank box!

                    break;
                }

                case PromotionalType.SoulStoneFragment:
                {
                    int offset = Utility.Random(0, 8);

                    SoulStoneFragment ssf = new SoulStoneFragment(0x2AA1 + offset, acct.Username);

                    bank.DropItem(ssf);

                    from.SendLocalizedMessage(1070976);                                       // A soulstone fragment has been created in your bank box.

                    break;
                }

                case PromotionalType.AdvancedCharacter:
                {
                    pm.SendGump(new AdvancedCharacterChoiceGump());

                    pm.ACState = AdvancedCharacterState.InUse;

                    break;
                }
                    // TODO: character transfer, seventh anniversary
                }

                token.Delete();
            }
        }
Exemple #18
0
        public override void OnDoubleClick(Mobile from)
        {
            //from.Handled = true;

            BankBox box = from.BankBox;

            if (box != null)
            {
                box.Open();
            }
        }
Exemple #19
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (this.m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (this.m_Deed.Commodity != null)
                {
                    number = 1047028; // The commodity deed has already been filled.
                }
                else if (targeted is Item)
                {
                    BankBox          box  = from.FindBankNoCreate();
                    CommodityDeedBox cox  = CommodityDeedBox.Find(this.m_Deed);
                    GalleonHold      hold = ((Item)targeted).RootParent as GalleonHold;

                    // Veteran Rewards mods
                    if (box != null && this.m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box) ||
                        (cox != null && cox.IsSecure && ((Item)targeted).IsChildOf(cox)) ||
                        hold != null)
                    {
                        if (this.m_Deed.SetCommodity((Item)targeted))
                        {
                            this.m_Deed.Hue = 0x592;
                            number          = 1047030; // The commodity deed has been filled.
                        }
                        else
                        {
                            number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                    else
                    {
                        if (Core.ML)
                        {
                            number = 1080526; // That must be in your bank box or commodity deed box to use it.
                        }
                        else
                        {
                            number = 1047026; // That must be in your bank box to use it.
                        }
                    }
                }
                else
                {
                    number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }
Exemple #20
0
 public override void OnDoubleClick(Mobile from)
 {
     if (Charges > 0)
     {
         ConsumeCharge(from);
         BankBox box = from.BankBox;
         if (box != null)
         {
             box.Open();
         }
     }
 }
 public override void OnDoubleClick(Mobile from)
 {
     if (Charges > 0)
     {
         ConsumeCharge(from);
         BankBox box = from.BankBox;
         if (box != null)
         {
             box.GumpID = BaseContainer.BankGump(from, box);
             box.Open();
         }
     }
 }
        public override void OnDoubleClick(Mobile from)
        {
            int number;

            BankBox box = from.BankBox;

            //if ( m_Commodity != null )
            if (m_Type != null)
            {
                if (box != null && IsChildOf(box))
                {
                    number = 1047031;                     // The commodity has been redeemed.

                    Item commodity = null;
                    System.Reflection.ConstructorInfo ci = m_Type.GetConstructor(new Type[0]);
                    if (ci != null)
                    {
                        commodity = ci.Invoke(null) as Item;
                    }

                    if (commodity != null)
                    {
                        commodity.Amount = m_Amount;

                        box.DropItem(commodity);

                        Delete();
                    }
                    else
                    {
                        from.SendMessage("Error with Commodity Deed - please contact GM.");
                    }
                }
                else
                {
                    number = 1047024;                     // To claim the resources ....
                }
            }
            else if (box == null || !IsChildOf(box))
            {
                number = 1047026;                 // That must be in your bank box to use it.
            }
            else
            {
                number = 1047029;                 // Target the commodity to fill this deed with.

                from.Target = new InternalTarget(this);
            }

            from.SendLocalizedMessage(number);
        }
Exemple #23
0
        public override void OnDoubleClick(Mobile from)
        {
            BankBox box = from.BankBox;

            if (box != null && IsChildOf(box))
            {
                PlayerMobile pm = from as PlayerMobile;

                base.OnDoubleClick(from);

                BankCheck check;

                if (this.Amount == 1)
                {
                    check = new BankCheck(1000000);

                    this.Delete();

                    if (box.TryDropItem(pm, check, false))
                    {
                        pm.SendMessage("You return your gold bar to the bank and receive a 1,000,000 check.");
                    }
                    else
                    {
                        check.Delete();
                        pm.AddToBackpack(new BankCheck(1000000));
                        pm.SendMessage("You return your gold bar to the bank and receive a 1,000,000 check.");
                    }
                }
                else if (this.Amount >= 2)
                {
                    check = new BankCheck(1000000);

                    if (box.TryDropItem(pm, check, false))
                    {
                        this.Amount -= 1;
                        pm.SendMessage("You return your gold bar to the bank and receive a 1,000,000 check.");
                    }
                    else
                    {
                        check.Delete();
                        pm.SendMessage("There is not enough room in your bank box for the check.");
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(1047026);                   // That must be in your bank box to use it.
            }
        }
Exemple #24
0
        public override void OnDoubleClick(Mobile from)
        {
            if (this.Movable == true)
            {
                from.SendMessage("This must be locked down to use!");
                return;
            }
            BankBox box = from.BankBox;

            if (box != null)
            {
                box.Open();
            }
        }
Exemple #25
0
        public override void OnDoubleClick(Mobile from)
        {
            BankBox box = from.FindBankNoCreate();

            if (box != null && IsChildOf(box))
            {
                Delete();
                int nGold = this.Amount * 5;
                from.AddToBackpack(new Gold(nGold));
            }
            else
            {
                from.SendLocalizedMessage(1047026);                   // That must be in your bank box to use it.
            }
        }
Exemple #26
0
        public override void OnDoubleClick(Mobile m)
        {
            BaseHouse house = BaseHouse.FindHouseAt(this);

            if (house != null && house.IsLockedDown(this))
            {
                BankBox box = m.BankBox;
                if (box != null)
                {
                    box.Open();
                }
            }
            //public override int DefaultGumpID{ get{ return 0x49; } }
            //public override int DefaultDropSound{ get{ return 0x42; } }
        }
Exemple #27
0
        public void DoOpenBank(Mobile from, BankToken bt)
        {
            BankBox box = from.BankBox;

            if (box != null)
            {
                box.Open();
                bt.Charges--;
                bt.Name = "A bank token. Charges: " + Charges + " Recharges left: " + (MaxCharges - Recharges);
            }
            else
            {
                from.SendMessage("Please page a gm immediately... you seem to have misplaced your bankbox....Boggle!");
            }
        }
Exemple #28
0
 public override void OnDoubleClick(Mobile from)
 {
     if (from.InRange(this.GetWorldLocation(), 4))
     {
         BankBox box = from.BankBox;
         if (box != null)
         {
             box.Open();
         }
     }
     else
     {
         from.SendLocalizedMessage(502138);                   // That is too far away for you to use
     }
 }
 public override void OnDoubleClick(Mobile from)
 {
     if (!IsChildOf(from.Backpack))
     {
         from.SendMessage("This item must be in your pack before you are able to use it");
     }
     else
     {
         BankBox box = from.BankBox;
         if (box != null)
         {
             box.Open();
         }
     }
 }
        public static bool Deposit(Mobile from, int amount)
        {
            BankBox box = from.FindBankNoCreate();

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

            List <Item> items = new List <Item>();

            while (amount > 0)
            {
                Item item;
                if (amount < 5000)
                {
                    item   = new Gold(amount);
                    amount = 0;
                }
                else if (amount <= 1000000)
                {
                    item   = new BankCheck(amount);
                    amount = 0;
                }
                else
                {
                    item    = new BankCheck(1000000);
                    amount -= 1000000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    items.Add(item);
                }
                else
                {
                    item.Delete();
                    foreach (Item curItem in items)
                    {
                        curItem.Delete();
                    }

                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        ///     Push values to the player, based on this state.
        /// </summary>
        public bool Push()
        {
            if (Owner == null || Owner.Deleted)
            {
                return false;
            }

            #region BankBox

            if (BankBox == null || BankBox.Deleted)
            {
                BankBox = new BankBox(Owner, Expansion);
            }

            BankBox.Layer = Layer.Bank;
            BankBox.BlessedFor = null;
            BankBox.Visible = true;
            BankBox.Hue = 0;

            Owner.BankBox.Layer = Layer.Invalid;
            Owner.BankBox.BlessedFor = Owner;
            Owner.BankBox.Visible = false;
            Owner.BankBox.Hue = 34;

            Owner.BankBox.Close();
            Owner.Send(Owner.BankBox.RemovePacket);

            Owner.AddItem(BankBox);

            Owner.BankBox = BankBox;

            Owner.BankBox.UpdateTotals();

            #endregion

            #region Backpack

            if (Backpack == null || Backpack.Deleted)
            {
                Backpack = new Backpack(Expansion);
            }

            Backpack.Layer = Layer.Backpack;
            Backpack.BlessedFor = null;
            Backpack.Visible = true;
            Backpack.Movable = true;
            Backpack.Hue = 0;

            Owner.Backpack.Layer = Layer.Invalid;
            Owner.Backpack.BlessedFor = Owner;
            Owner.Backpack.Visible = false;
            Owner.Backpack.Movable = false;
            Owner.Backpack.Hue = 34;

            Owner.Send(Owner.Backpack.RemovePacket);

            Owner.AddItem(Backpack);

            Owner.Backpack = Backpack;

            Owner.Backpack.UpdateTotals();

            #endregion

            Owner.StatCap = StatCap;

            Owner.RawStr = RawStr;
            Owner.RawDex = RawDex;
            Owner.RawInt = RawInt;

            Owner.SkillsCap = SkillsCap;

            Owner.Skills.For(
                (i, s) =>
                {
                    Skill sk = Skills[i];

                    s.SetCap(sk.Cap);
                    s.SetBase(sk.Base, true, false);
                });

            return true;
        }
Exemple #32
0
        private static void AddPowerScrolls( BankBox bank )
        {
            Bag bag = new Bag();

            for ( int i = 0; i < PowerScroll.Skills.Count; ++i )
                bag.DropItem( new PowerScroll( PowerScroll.Skills[i], 120.0 ) );

            bag.DropItem( new StatCapScroll( 250 ) );

            bank.DropItem( bag );
        }
        // genova: flags PowerScrolls and StatusCapScrolls
        private static void AddPowerScrolls(BankBox bank)
        {
            Bag bag = new Bag();

            if (GeNovaXML.Flags_Active(XMLNames.PowerScrolls))
            {
                for (int i = 0; i < PowerScroll.Skills.Length; ++i)
                    bag.DropItem(new PowerScroll(PowerScroll.Skills[i], 120.0));
            }

            if (GeNovaXML.Flags_Active(XMLNames.StatusCapScrolls))
                bag.DropItem(new StatCapScroll(250));

            if (bag.Items.Count > 0)
                bank.DropItem(bag);
        }
Exemple #34
0
        public static void ImportWorld()
        {
            ArrayList retry = new ArrayList(), houses = new ArrayList();
            int count = 0;

            foreach ( Account a in Accounts.List.Values )
            {
                for (int i = 0; i < 6; i++)
                {
                    if ( a[i] != null )
                        a[i].Player = false;

                    a[i] = null;
                }
            }

            using (StreamReader r = new StreamReader("world.txt", System.Text.Encoding.ASCII))
            {
                string line;
                IEntity curObj = null;
                Mobile prevMob = null;
                Type curType = null;

                while ((line = r.ReadLine()) != null)
                {
                    if (string.IsNullOrEmpty(line))
                        continue;

                    string[] parts = line.Split(new char[] { '=' }, 3, StringSplitOptions.None);

                    if ( parts.Length != 3 )
                    {
                        Console.WriteLine( "Warning! Wrong number of fields: {0} -- {1}", parts.Length, line );
                        continue;
                    }

                    /*if (parts[0] == "Profile")
                    {
                        long prevPos = r.BaseStream.Position;
                        while ((line = r.ReadLine()) != null)
                        {
                            string[] split = line.Split(new char[] { '=' }, 3, StringSplitOptions.None);

                            if (split.Length != 3)
                            {
                                parts[2] += "\n" + line;
                                prevPos = r.BaseStream.Position;
                            }
                            else
                            {
                                r.BaseStream.Seek(prevPos, SeekOrigin.Begin);
                                break;
                            }
                        }
                    }*/

                    try
                    {
                        if (parts[0] == "Object")
                        {
                            PostProcess( curObj );
                            parts[1] = TranslateType( parts[1] );
                            curObj = null;
                            curType = ScriptCompiler.FindTypeByFullName(parts[1], true);

                            if (curType == null)
                            {
                                InsertError( "{0}: Type missing", parts[1] );
                                continue;
                            }

                            Serial oldSer = Utility.ToInt32(parts[2]);
                            /*if (IsType(curType, typeof(Item)))
                                Serial.NewItem = Utility.ToInt32(parts[2]) - 1;
                            else if (IsType(curType, typeof(Mobile) ))
                                Serial.NewMobile = Utility.ToInt32(parts[2]) - 1;
                            */
                            try { curObj = Activator.CreateInstance(curType, new object[0]) as IEntity; } catch { }

                            if (curObj == null)
                            {
                                try
                                {
                                    if (curType == typeof(BankBox) && prevMob != null)
                                        curObj = new BankBox(prevMob);
                                    //curObj = Activator.CreateInstance( curType, new object[1]{prevMob} ) as IEntity;
                                }
                                catch { }

                                if (curObj == null)
                                {
                                    InsertError("{0}: Unable to construct", parts[1]);
                                    continue;
                                }
                            }

                            if (curObj is Mobile)
                            {
                                _Mobiles[oldSer] = curObj;
                                prevMob = (Mobile)curObj;
                            }
                            else if ( curObj is Item )
                            {
                                _Items[oldSer] = curObj;
                            }

                            count++;
                            if ((count % 10000) == 0)
                                Console.WriteLine("Completed {0} objects so far", count - 1);
                        }
                        else if (parts[0] == "House")
                        {
                            string type, loc, map, owner;

                            type = r.ReadLine();
                            loc = r.ReadLine();
                            map = r.ReadLine();
                            owner = r.ReadLine();
                            houses.Add(new string[] { type, loc, map, owner });
                        }
                        else if (parts[0] == "Skills")
                        {
                            Mobile m = FindMobile(Utility.ToInt32(parts[2]));

                            while ((line = r.ReadLine()) != null)
                            {
                                if (line == "EndSkills" || line == "")
                                    break;

                                parts = line.Split(new char[] { '=' }, 3, StringSplitOptions.None);

                                if (parts.Length != 3)
                                    continue;

                                SkillName name = (SkillName)Enum.Parse(typeof(SkillName), parts[0]);

                                m.Skills[name].BaseFixedPoint = Utility.ToInt32(parts[2]);
                            }
                        }
                        else if (parts[0] == "RuneBookEntry")
                        {
                            if (curObj is Runebook)
                            {
                                Point3D pt = Point3D.Parse(parts[1]);

                                bool okay = true;
                                if (Spells.SpellHelper.IsAnyT2A(Map.Felucca, pt))
                                    okay = false;
                                else if (Spells.SpellHelper.IsFeluccaDungeon(Map.Felucca, pt))
                                {
                                    Regions.DungeonRegion reg = Region.Find(pt, Map.Felucca) as Regions.DungeonRegion;

                                    if (reg != null)
                                    {
                                        if (reg.Name == "Fire" || reg.Name == "Ice" || reg.Name == "Orc Cave" || reg.Name == "Terathan Keep")
                                            okay = false;
                                    }
                                }

                                if (okay)
                                    ((Runebook)curObj).Entries.Add(new RunebookEntry(pt, Map.Felucca, parts[2], null));
                            }
                        }
                        else if (curObj != null)
                        {
                            DoProperty(curObj, curType, parts, retry);
                        }
                    }
                    catch ( Exception e )
                    {
                        InsertError("Exception '{0}' for line '{1}'", e.Message, line);
                    }
                }

                PostProcess( curObj );
            }

            foreach (object[] list in retry)
                DoProperty( list[0], list[1] as Type, list[2] as string[], null );

            foreach (string[] list in houses)
            {
                list[0] = TranslateType(list[0]);
                Type deedType = ScriptCompiler.FindTypeByFullName(list[0], true);
                Point3D loc = Point3D.Parse(list[1]);
                Map map = Map.Parse(list[2]);
                Mobile owner = FindMobile(Utility.ToInt32(list[3]));

                if (deedType == null || !deedType.IsSubclassOf(typeof(HouseDeed)))
                {
                    InsertError("{0}: Type missing\n", list[0]);
                    continue;
                }

                if (owner == null || map == null || map == Map.Internal || loc == Point3D.Zero)
                {
                    InsertError("House properties messed up (owner probably missing)\n");
                    continue;
                }

                HouseDeed deed = null ;
                try { deed = Activator.CreateInstance(deedType, new object[0]) as HouseDeed; }
                catch { }

                if (deed == null)
                {
                    InsertError("Failed to create deed {0}\n", list[0]);
                    continue;
                }

                BaseHouse house = deed.GetHouse(owner);
                house.MoveToWorld(loc, map);
                deed.Delete();
            }

            Console.WriteLine("Import complete, imported {0} objects.", count);
            Console.WriteLine( "\nErrors:" );
            foreach ( string err in _Errors.Keys )
                Console.WriteLine( "{0}  (Count={1})", err, _Errors[err] );

            Console.WriteLine("Done.  Saving...");
            World.Save();

            Console.WriteLine( "Press enter to quit.  REMOVE THIS SCRIPT BEFORE RUNNING THE SERVER AGAIN" );
            Console.ReadLine();
            System.Diagnostics.Process.GetCurrentProcess().Kill();
        }
        private static void AddPowerScrolls( BankBox bank )
        {
            Bag bag = new Bag();

            for ( int i = 0; i < PowerScroll.Skills.Length; ++i )
                //bag.DropItem( new PowerScroll( PowerScroll.Skills[i], 100.0 ) );

            //bag.DropItem( new StatCapScroll( 225 ) );

            bank.DropItem( bag );
        }
Exemple #36
0
        public BankBox FindBankNoCreate()
        {
            if ( m_BankBox != null && !m_BankBox.Deleted && m_BankBox.Parent == this )
                return m_BankBox;

            m_BankBox = FindItemOnLayer( Layer.Bank ) as BankBox;

            return m_BankBox;
        }
 private static void AddPowerScrolls( BankBox bank )
 {
 }
Exemple #38
0
		public static void RestoreState(
			PlayerMobile m,
			bool moveExisting,
			bool logging,
			out int created,
			out int deleted,
			out int ignored,
			out int moved)
		{
			var pack = m.Backpack;

			if (pack == null || pack.Deleted)
			{
				m.AddItem(
					pack = new Backpack
					{
						Movable = false
					});
			}

			var bank = m.BankBox;

			if (bank == null || bank.Deleted)
			{
				m.AddItem(
					bank = new BankBox(m)
					{
						Movable = false
					});
			}

			var root = VitaNexCore.DataDirectory + "/PlayerBackup/" + m.Account.Username + "/" + m.Serial;

			var idxFile = IOUtility.EnsureFile(root + ".idx");
			var binFile = IOUtility.EnsureFile(root + ".bin");

			var logFile = logging ? IOUtility.EnsureFile(root + ".log") : null;
			var log = logging ? new StringBuilder() : null;

			if (log != null)
			{
				log.AppendLine();
				log.AppendLine(new String('*', 10));
				log.AppendLine();
				log.AppendLine("RESTORE:\tDate[{0}]\tMobile[{1}]", DateTime.UtcNow, m);
				log.AppendLine();
			}

			int idxCreated = 0, idxDeleted = 0, idxIgnored = 0, idxMoved = 0;

			idxFile.Deserialize(
				idx =>
				{
					idx.GetVersion();

					var ser = idx.ReadInt();

					if (ser != m.Serial)
					{
						if (log != null)
						{
							log.AppendLine("INVALID:\tSerial[{0}]", ser);
						}

						return;
					}

					long idxLength;
					int idxCount;

					ReadLength(idx, false, out idxLength, out idxCount);

					if (log != null)
					{
						log.AppendLine("INDEX:\tCount[{0}]\tLength[{1}]", idxCount, idxLength);
					}

					var items = new Tuple<Item, Serial, long, long, string>[idxCount];

					binFile.Deserialize(
						bin =>
						{
							bin.GetVersion();

							var restored = new Dictionary<Item, Serial>();

							Backpack oldPack = null;
							BankBox oldBank = null;

							for (var i = 0; i < idxCount; i++)
							{
								Type type;
								Serial serial, parent;
								long binIndex, binLength;

								ReadIndex(idx, out type, out serial, out parent, out binIndex, out binLength);

								var valid = serial.IsValid && serial.IsItem;
								var exists = World.Items.ContainsKey(serial);

								Item item = null;

								if (exists)
								{
									item = World.Items[serial];

									if (item == null || item.Deleted)
									{
										World.Items.Remove(serial);
										exists = false;
									}
								}

								object logItem;
								string status;

								if (!exists && valid && type.IsEqualOrChildOf<Item>())
								{
									item = type.CreateInstanceSafe<Item>(serial);

									if (item == null)
									{
										++idxIgnored;

										logItem = serial;
										status = "NULL";
									}
									else if (item.Deleted)
									{
										++idxDeleted;

										item = null;
										logItem = serial;
										status = "DELETED";
									}
									else
									{
										++idxCreated;

										World.AddItem(item);

										logItem = item;
										status = "CREATED";
									}
								}
								else if (exists && valid && moveExisting && item.RootParent != m)
								{
									++idxMoved;

									logItem = item;
									status = "MOVE";
								}
								else
								{
									++idxIgnored;

									item = null;
									logItem = serial;
									status = exists ? "EXISTS" : "INVALID";
								}

								if (log != null)
								{
									log.AppendLine(
										"DATA:\tIndex[{0}]\t\tLength[{1}]\tStatus[{2}]\tItem[{3}]\t\t\tParent[{4}]",
										//
										binIndex,
										binLength,
										status,
										logItem,
										parent);
								}

								items[i] = Tuple.Create(item, parent, binIndex, binLength, status);
							}

							foreach (var t in items)
							{
								var item = t.Item1;
								var parent = t.Item2;
								var index = t.Item3;
								var length = t.Item4;
								var status = t.Item5;

								bin.Seek(index, SeekOrigin.Begin);

								if (item == null)
								{
									bin.Seek(index + length, SeekOrigin.Begin);
									continue;
								}

								Exception x = null;

								if (status == "MOVE")
								{
									bin.Seek(index + length, SeekOrigin.Begin);

									status = "IGNORED";
								}
								else
								{
									try
									{
										item.Deserialize(bin);

										status = "LOADED";
									}
									catch (Exception e)
									{
										--idxCreated;
										++idxDeleted;

										item.Delete();
										x = e;

										status = "ERROR";
									}
								}

								if (log != null)
								{
									log.AppendLine(
										"READ:\tIndex[{0}]\tLength[{1}]\tStatus[{2}]\tItem[{3}]\t\t\tParent[{4}]",
										index,
										length,
										status,
										item,
										parent);

									if (x != null)
									{
										log.AppendLine();
										log.AppendLine(new String('*', 10));
										log.AppendLine(x.ToString());
										log.AppendLine(new String('*', 10));
										log.AppendLine();
									}
								}

								if (parent == m.Serial)
								{
									if (item is BankBox)
									{
										oldBank = (BankBox)item;
									}
									else if (item is Backpack)
									{
										oldPack = (Backpack)item;
									}
								}

								restored.Add(item, parent);
							}

							if (log != null)
							{
								log.AppendLine();
							}

							Point3D p;

							foreach (var kv in restored.Where(kv => !kv.Key.Deleted).OrderBy(kv => kv.Value))
							{
								var item = kv.Key;

								if ((item == oldPack || item == oldBank) && item != pack && item != bank)
								{
									if (item.Parent is Item)
									{
										((Item)item.Parent).RemoveItem(item);
									}
									else if (item.Parent is Mobile)
									{
										((Mobile)item.Parent).RemoveItem(item);
									}

									item.Parent = null;
									continue;
								}

								var parent = World.FindEntity(kv.Value);

								if (item != pack && item != bank && (item.Parent == oldPack || item.Parent == oldBank))
								{
									((Item)item.Parent).RemoveItem(item);
								}

								if (parent != null)
								{
									if (item == pack || item == bank)
									{
										m.AddItem(item);
									}
									else if (parent == pack || parent == oldPack)
									{
										p = item.Location;
										pack.DropItem(item);
										item.Location = p;
									}
									else if (parent == bank || parent == oldBank)
									{
										p = item.Location;
										bank.DropItem(item);
										item.Location = p;
									}
									else if (parent is Container)
									{
										if (parent.Deleted)
										{
											bank.DropItem(item);
										}
										else
										{
											p = item.Location;
											((Container)parent).DropItem(item);
											item.Location = p;
										}
									}
									else if (parent is Mobile)
									{
										if (!m.EquipItem(item))
										{
											pack.DropItem(item);
										}
									}
									else
									{
										bank.DropItem(item);
									}

									item.SetLastMoved();
									item.UpdateTotals();
									item.Delta(ItemDelta.Update);
								}
								else if (Cleanup.IsBuggable(item))
								{
									--idxCreated;
									++idxDeleted;

									item.Delete();
								}
								else
								{
									item.Internalize();
								}
							}

							if (oldPack != null && oldPack != pack && !restored.ContainsKey(oldPack))
							{
								oldPack.Delete();
							}

							if (oldBank != null && oldBank != bank && !restored.ContainsKey(oldBank))
							{
								oldBank.Delete();
							}

							if (log != null)
							{
								log.AppendLine();
							}

							foreach (var kv in restored)
							{
								if (kv.Key.Deleted)
								{
									if (log != null)
									{
										log.AppendLine("DELETED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value);
									}
								}
								else if (kv.Key.RootParent == m && kv.Key.Map == Map.Internal && kv.Key.Location == Point3D.Zero)
								{
									if (log != null)
									{
										log.AppendLine("INTERNAL:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value);
									}
								}
								else if (kv.Key.RootParent != m)
								{
									if (log != null)
									{
										log.AppendLine("IGNORED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value);
									}
								}
								else
								{
									if (log != null)
									{
										log.AppendLine("RESTORED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Key.Parent);
									}
								}
							}

							restored.Clear();

							m.SendEverything();
						});
				});

			created = idxCreated;
			deleted = idxDeleted;
			ignored = idxIgnored;
			moved = idxMoved;

			if (log == null)
			{
				return;
			}

			log.AppendLine();
			log.AppendLine(
				"RESULT:\tCreated[{0}]\t\tDeleted[{1}]\t\tIgnored[{2}]\t\tMoved[{3}]",
				created,
				deleted,
				ignored,
				moved);

			logFile.AppendText(false, log.ToString());
		}
		public SavingsGump( Mobile from ) : base( 400, 300 )
		{
			from.CloseGump( typeof( SavingsGump ));

			m_Bank = from.BankBox;
			m_Pack = from.Backpack;
			m_Account = (SavingsAccount)m_Bank.FindItemByType( typeof( SavingsAccount ));

			String gold = m_Account.Gold.ToString( "#,0" ) + " Gold";
			String tokens = m_Account.Tokens.ToString( "#,0" ) + " Tokens";

			m_MaximumCheckValue = AuctionConfig.MaximumCheckValue.ToString( "#,0" );

			Closable = true;
			Disposable = true;
			Dragable = true;
			Resizable = false;
			AddPage( 0 );
			AddBackground( 0, 0, 240, 268, 9200 );
			AddAlphaRegion( 10, 9, 220, 100 );
			AddAlphaRegion( 10, 115, 220, 145 );

			AddLabel( 50, 15, 4, @"Savings Account Ledger" );
			AddLabel( 50, 35, 4, @"-----------------------" );
			AddLabel( 25, 55, 53, gold );
			if ( Arya.Savings.SavingsAccount.EnableTokens )
				AddLabel( 25, 80, 18, tokens );

			AddLabel( 40, 130, 4, @"Withdraw 1 to " + m_MaximumCheckValue );
			AddBackground( 75, 155, 95, 25, 0x2486 );
			AddTextEntry( 85, 155, 90, 20, 0, m_AmountID, "" );

			AddButton( 25, 180, 4005, 4007, 1, GumpButtonType.Reply, 0 );
			AddLabel( 65, 180, 53, @"Make this gold check." );

			if ( Arya.Savings.SavingsAccount.EnableTokens )
			{
				AddButton( 25, 205, 4005, 4007, 2, GumpButtonType.Reply, 0 );
				AddLabel( 65, 205, 18, @"Make this token check." );
			}	
			AddButton( 25, 230, 4017, 4019, 0, GumpButtonType.Reply, 0 );
			AddLabel( 65, 230, 4, @"Done." );
		}