I'm making a supply bag that has about everything. When I try to include a container that has treasure maps into the script, I get errors. Both container scripts work fine on their own when you add them in game, but I'm trying to include the map chest in the bag and somehow I'm messing it up. When in game I type [add XanthoriaBonusTreasureChest Gift 5 and it will product a metal chest named gift with level 5 treasure maps. XanthoriaBonusTreasureChest.cs is the chest I'm trying to put into BagOfSupplies.cs. If I can get the correct format for including the chest, the rest should be easy for me to add other container sets. Here is a paste of the script I'm working with and trying to get XanthorBonusChest into it. In game again, I have to type [add XanthorBonusChest Gift(or whatever name I want shown on metal chest) 5(5 is level of treasuremaps) Thanks.

using System;

namespace Server.Items
{
public class BagOfSupplies : Bag
{
[Constructable]
public BagOfSupplies()
: this(60000)
{
this.Movable = true;
this.Hue = 0x503;
}

[Constructable]
public BagOfSupplies(int amount)
{
this.DropItem(new BankCheck(600000000));
this.DropItem(new BlackPearl(60000));
this.DropItem(new Bloodmoss(60000));
this.DropItem(new Garlic(60000));
this.DropItem(new Ginseng(60000));
this.DropItem(new MandrakeRoot(60000));
this.DropItem(new Nightshade(60000));
this.DropItem(new SulfurousAsh(60000));
this.DropItem(new SpidersSilk(60000));
this.DropItem(new BatWing(60000));
this.DropItem(new GraveDust(60000));
this.DropItem(new DaemonBlood(60000));
this.DropItem(new NoxCrystal(60000));
this.DropItem(new PigIron(60000));
this.DropItem(new DullCopperIngot(60000));
this.DropItem(new ShadowIronIngot(60000));
this.DropItem(new CopperIngot(60000));
this.DropItem(new BronzeIngot(60000));
this.DropItem(new GoldIngot(60000));
this.DropItem(new AgapiteIngot(60000));
this.DropItem(new VeriteIngot(60000));
this.DropItem(new ValoriteIngot(60000));
this.DropItem(new IronIngot(60000));
this.DropItem(new Tongs());
this.DropItem(new TinkerTools());
}

public BagOfSupplies(Serial serial)
: base(serial)
{
}

public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);

writer.Write((int)0); // version
}

public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);

int version = reader.ReadInt();
}
}
}
 
Could you post what the script looks like with the code included to add the chest into it and also the console errors you are receiving (or messages/errors in game)? When including code try to use the code tags -- [c ode] at the beginning and [/c ode] at the end (without the space between letters). It makes the code much more readable. Also, you may want to try changing

Code:
[Constructable]
public BagOfSupplies()
: this(60000)

to

Code:
[Constructable]
public BagOfSupplies() : base()

Edit: Realized you may not know how to copy console errors if you're getting some -- the best way to copy them is to click the top left icon in the server console and goto Edit--->Select All and then Ctrl+C or Edit--->Copy
 
Last edited:
Thebagofsupplies.cs script is what I'm trying to get the XanthoriaBonusTreasureChest.cs to include. Both scripts work separately with no errors. If I type [add Thebagofsupplies and target ground, it places with no problem. If I type [add XanthoriaBonusTreasureChest BonusChest 5 and target ground, I'll get a chest with the name BonusChest with all level treasure maps. For the life of me, I can't figure how script TheBagOfSupplies to include the XanthoriaBonusTreasureChest. Here are the two scripts I modified:

BagOfSupplies.cs
Code:
using System;
namespace Server.Items 
{ 
    public class BagOfSupplies : Bag 
    { 
        public BagOfSupplies() : base()
        {
            this.Movable = true;
            this.Hue = 0x503;
        }
        [Constructable]	  
        public BagOfSupplies(int amount) 
        { 
		 this.DropItem(new BankCheck(600000000));
		 this.DropItem(new BlackPearl(60000));
            this.DropItem(new Bloodmoss(60000));
            this.DropItem(new Garlic(60000));
            this.DropItem(new Ginseng(60000));
            this.DropItem(new MandrakeRoot(60000));
            this.DropItem(new Nightshade(60000));
            this.DropItem(new SulfurousAsh(60000));
            this.DropItem(new SpidersSilk(60000));
            this.DropItem(new BatWing(60000));
            this.DropItem(new GraveDust(60000));
            this.DropItem(new DaemonBlood(60000));
            this.DropItem(new NoxCrystal(60000));
            this.DropItem(new PigIron(60000));
            this.DropItem(new DullCopperIngot(60000)); 
            this.DropItem(new ShadowIronIngot(60000)); 
            this.DropItem(new CopperIngot(60000)); 
            this.DropItem(new BronzeIngot(60000)); 
            this.DropItem(new GoldIngot(60000)); 
            this.DropItem(new AgapiteIngot(60000)); 
            this.DropItem(new VeriteIngot(60000)); 
            this.DropItem(new ValoriteIngot(60000)); 
            this.DropItem(new IronIngot(60000));
            this.DropItem(new Tongs());
            this.DropItem(new TinkerTools());
        }
        public BagOfSupplies(Serial serial)
            : base(serial)
        { 
        }
        public override void Serialize(GenericWriter writer) 
        { 
            base.Serialize(writer); 
            writer.Write((int)0); // version 
        }
        public override void Deserialize(GenericReader reader) 
        { 
            base.Deserialize(reader); 
            int version = reader.ReadInt(); 
        }
    }
}

XanthoriaBonusTreasureChest.cs
Code:
using System;
namespace Server.Items
{
    [Flipable]
    public class XanthoriaBonusTreasureChest : LockableContainer
    {
        private static readonly int[] m_ItemIDs = new int[]
        {
            0x9AB, 0xE40, 0xE41, 0xE7C
        };
        private static readonly int[] m_Hues = new int[]
        {
            0x0, 0x455, 0x47E, 0x89F, 0x8A5, 0x8AB,
            0x966, 0x96D, 0x972, 0x973, 0x979, 0x10, 0xD1, 0xE6, 		 0x16F, 0x480, 0x483, 0x484, 0x487, 0x485, 0x488, 			 0x489, 0x48B, 0x48D, 0x48E, 0x492, 0x496, 0x509, 			 0x508, 0x507, 0x503, 0x562, 0x55C, 0x5B6, 0x777, 			 0x778, 0x779, 0x77A, 0x77B, 0x77C, 0x77D, 0x77E, 			 0x77F, 0x780, 0x781, 0x782, 0x783, 0x784, 0x785,
		 0x786, 0x787, 0x788, 0x789, 0x78A, 0x78B, 0x78C, 			 0x78D, 0x78E, 0x78F, 0x790, 0x791, 0x792, 0x793, 			 0x794, 0x795, 0x796, 0x797, 0x798, 0x799, 0x79A
        };
        private string m_Name;
        [Constructable]
        public XanthoriaBonusTreasureChest(string name, int level)
            : base(Utility.RandomList(m_ItemIDs))
        {
            this.m_Name = name;
            this.Hue = Utility.RandomList(m_Hues);
            this.Fill(level);
        }
        public XanthoriaBonusTreasureChest(Serial serial)
            : base(serial)
        {
        }
        public override void OnSingleClick(Mobile from)
        {
            this.LabelTo(from, 1063449, this.m_Name);
        }
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);
            list.Add(1063449, this.m_Name);
        }
        public void Flip()
        {
            switch ( this.ItemID )
            {
                case 0x9AB :
                    this.ItemID = 0xE7C;
                    break;
                case 0xE7C :
                    this.ItemID = 0x9AB;
                    break;
                case 0xE40 :
                    this.ItemID = 0xE41;
                    break;
                case 0xE41 :
                    this.ItemID = 0xE40;
                    break;
            }
        }
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0); // version
            writer.Write(this.m_Name);
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
            this.m_Name = Utility.Intern(reader.ReadString());
        }
        private static void GetRandomAOSStats(out int attributeCount, out int min, out int max)
        {
            int rnd = Utility.Random(15);
            if (rnd < 1)
            {
                attributeCount = Utility.RandomMinMax(2, 6);
                min = 20;
                max = 70;
            }
            else if (rnd < 3)
            {
                attributeCount = Utility.RandomMinMax(2, 4);
                min = 20;
                max = 50;
            }
            else if (rnd < 6)
            {
                attributeCount = Utility.RandomMinMax(2, 3);
                min = 20;
                max = 40;
            }
            else if (rnd < 10)
            {
                attributeCount = Utility.RandomMinMax(1, 2);
                min = 10;
                max = 30;
            }
            else
            {
                attributeCount = 1;
                min = 10;
                max = 20;
            }
        }
        private void Fill(int level)
        {
            this.TrapType = TrapType.ExplosionTrap;
            this.TrapPower = level * 25;
            this.TrapLevel = level;
            this.Locked = true;
            switch ( level )
            {
                case 1:
                    this.RequiredSkill = 36;
                    break;
                case 2:
                    this.RequiredSkill = 76;
                    break;
                case 3:
                    this.RequiredSkill = 84;
                    break;
                case 4:
                    this.RequiredSkill = 92;
                    break;
                case 5:
                    this.RequiredSkill = 100;
                    break;
            }
            this.LockLevel = this.RequiredSkill - 10;
            this.MaxLockLevel = this.RequiredSkill + 40;
            this.DropItem(new Gold(level * 200));
            for (int i = 0; i < level; ++i)
                this.DropItem(Loot.RandomScroll(0, 63, SpellbookType.Regular));
            for (int i = 0; i < level * 2; ++i)
            {
                Item item;
                if (Core.AOS)
                    item = Loot.RandomArmorOrShieldOrWeaponOrJewelry();
                else
                    item = Loot.RandomArmorOrShieldOrWeapon();

                if (item is BaseWeapon)
                {
                    BaseWeapon weapon = (BaseWeapon)item;
                    if (Core.AOS)
                    {
                        int attributeCount;
                        int min, max;
                        GetRandomAOSStats(out attributeCount, out min, out max);
                        BaseRunicTool.ApplyAttributesTo(weapon, attributeCount, min, max);
                    }
                    else
                    {
                        weapon.DamageLevel = (WeaponDamageLevel)Utility.Random(6);
                        weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random(6);
                        weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(6);
                    }
                    this.DropItem(item);
                }
                else if (item is BaseArmor)
                {
                    BaseArmor armor = (BaseArmor)item;
                    if (Core.AOS)
                    {
                        int attributeCount;
                        int min, max;
                        GetRandomAOSStats(out attributeCount, out min, out max);
                        BaseRunicTool.ApplyAttributesTo(armor, attributeCount, min, max);
                    }
                    else
                    {
                        armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(6);
                        armor.Durability = (ArmorDurabilityLevel)Utility.Random(6);
                    }
                    this.DropItem(item);
                }
                else if (item is BaseHat)
                {
                    BaseHat hat = (BaseHat)item;
                    if (Core.AOS)
                    {
                        int attributeCount;
                        int min, max;
                        GetRandomAOSStats(out attributeCount, out min, out max);
                        BaseRunicTool.ApplyAttributesTo(hat, attributeCount, min, max);
                    }
                    this.DropItem(item);
                }
                else if (item is BaseJewel)
                {
                    int attributeCount;
                    int min, max;
                    GetRandomAOSStats(out attributeCount, out min, out max);
                    BaseRunicTool.ApplyAttributesTo((BaseJewel)item, attributeCount, min, max);
                    this.DropItem(item);
                }
            }
            for (int i = 0; i < level; i++)
            {
                Item item = Loot.RandomPossibleReagent();
                item.Amount = Utility.RandomMinMax(40, 60);
                this.DropItem(item);
            }
            for (int i = 0; i < level; i++)
            {
                Item item = Loot.RandomGem();
                this.DropItem(item);
            }
            this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(6, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(5, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
            this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(4, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
            this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(3, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
            this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(2, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
            this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
		 this.DropItem(new TreasureMap(1, (Utility.RandomBool() ? Map.Felucca : Map.Trammel)));
        }
    }
}
 

Attachments

  • BagOfSupplies.cs
    2 KB · Views: 2
  • XanthoriaBonusTreasureChest.cs
    13 KB · Views: 4
Try adding
Code:
this.DropItem(new XanthoriaBonusTreasureChest(bonuschest, 5))

under all the other items you have listed to drop in the bagofsupplies.
 
I got a few errors, but not posting yet. For some reason, taking the spaces out of the BagOfSupplies script made it run differently. After putting them back in, it ran ok. XanthoriaBonusTreasureChest is acting up too, so will be back in a bit and see what happens. Thanks for the help Denjiki. I'll let you know later what happened. Got to take my son to doctors so will be a bit.

Editing this so I don't spam. Thanks again Denjiki, the line of script is fine. Its my modification that's messed up. It shouldn't even be asking me for map and level as the data already has that information. I'm redoing the script with your correct info once I'm done.
 
Last edited:
I got a few errors, but not posting yet. For some reason, taking the spaces out of the BagOfSupplies script made it run differently. After putting them back in, it ran ok. XanthoriaBonusTreasureChest is acting up too, so will be back in a bit and see what happens. Thanks for the help Denjiki. I'll let you know later what happened. Got to take my son to doctors so will be a bit.

Editing this so I don't spam. Thanks again Denjiki, the line of script is fine. Its my modification that's messed up. It shouldn't even be asking me for map and level as the data already has that information. I'm redoing the script with your correct info once I'm done.
The reason you have to define the "level" is because of this:
Code:
public XanthoriaBonusTreasureChest(string name, int level)
As you can see, the parameters for the item are the name of the item in a "string" or text value, and "level" in the form of an integer. Later in, it takes the"level" you defined and uses it here:
Code:
 this.Fill(level);
this line of code runs the "Fill" method with the level you specify in the parameters as an input. When you scroll down to the Fill method, you can see it uses the specified "level" for a number of things including TrapPower, TrapLevel, the required skill to open the container, the amount of gold dropped in the container, etc. So while yes, you have modified the code later on to drop a ton of treasure maps of all different levels (with the long list of this.DropItem toward the end of the script), it still needs the "level" defined when you add the item in game or create it in other code (such as your bag of supplies).

Edit: If you understood what I just said already and I misinterpreted your post, I apologize.
 
The reason you have to define the "level" is because of this:
Code:
public XanthoriaBonusTreasureChest(string name, int level)
As you can see, the parameters for the item are the name of the item in a "string" or text value, and "level" in the form of an integer. Later in, it takes the"level" you defined and uses it here:
Code:
 this.Fill(level);
this line of code runs the "Fill" method with the level you specify in the parameters as an input. When you scroll down to the Fill method, you can see it uses the specified "level" for a number of things including TrapPower, TrapLevel, the required skill to open the container, the amount of gold dropped in the container, etc. So while yes, you have modified the code later on to drop a ton of treasure maps of all different levels (with the long list of this.DropItem toward the end of the script), it still needs the "level" defined when you add the item in game or create it in other code (such as your bag of supplies).

Edit: If you understood what I just said already and I misinterpreted your post, I apologize.
No, you got it 100% right. Going to use the info Greed gave me to correct this. Sorry took so long to reply. I somehow missed the reply and thanks to the alerts that save the info, was able to go back and find this. Might have happened when power slammed down .
 
Back