コード例 #1
0
        public static void EmptyPackOnExit(Mobile m, bool DeletePasses, bool KeepStartup)
        {
            Container backpack = m.Backpack;

            if (backpack == null)
            {
                return;
            }

            // put whatever you are holding in you backpack
            // (the 'drag' kind of holding)
            Item held = m.Holding;

            if (held != null)
            {
                held.ClearBounce();
                if (m.Backpack != null)
                {
                    m.Backpack.DropItem(held);
                }
            }
            m.Holding = null;

            // put whatever you are holding in your backpack
            // (actually in your hand kind of holding)
            Item weapon = m.Weapon as Item;

            if (weapon != null && weapon.Parent == m && !(weapon is Fists))
            {
                backpack.DropItem(weapon);
            }

            ArrayList stuff = backpack.FindAllItems();

            if (stuff != null && stuff.Count > 0)
            {
                for (int ix = 0; ix < stuff.Count; ix++)
                {
                    Item item = stuff[ix] as Item;
                    // process items as follows
                    //	delete weapons (except stinger) and reagents
                    //	change stinger to regular loot
                    //	delete reagents
                    //	Oprional delete lighthouse passes - (they were handled on entrance to the escape cave)
                    //	delete spellbook
                    // we don't delete EVERYTHING because we may allow some rares to be found here in the future

                    if (item is BaseWeapon && item is AIStinger == false)
                    {
                        item.Delete();
                    }

                    if (item is AIStinger && KeepStartup == false)
                    {
                        item.LootType = LootType.Regular;
                    }

                    if (item is BaseReagent)
                    {
                        item.Delete();
                    }

                    if (item is AILHPass && DeletePasses)
                    {
                        item.Delete();
                    }

                    if (item is Spellbook && KeepStartup == false)
                    {
                        item.Delete();
                    }
                }
            }

            return;
        }