ExX

Member
So I have been working on a simple bad that I can give new warriors. I want the bag to contain some items most specifically a set of plate mail with lower stat requirements so that they can wear it as a new player. I have been searching this forum and mostly the RunUO forums and have found a "little" bit of information regarding creating an item with a specific propertie but I can't seem to get it down properly. This is the full script.

Code:
using System;
using Server;
using Server.Items;

namespace Server.Items
{
    public class WarriorBag : Bag
    {
        [Constructable]
        public WarriorBag()
            : this(50)
        {
        }

        [Constructable]
        public WarriorBag(int amount)
        {
			this.DropItem(new Gold(2000));
			this.DropItem(new Bandage(50));
			this.DropItem(new Daat99Tokens(100));
			
			PlateChest item = new PlateChest();
            item.LowerStatReq = 50;
			this.DropItem(new item());			
        }

        public WarriorBag(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();
        }
    }
}

As you can see I am trying to add a PlateChest with the lowerstatreq propertie of 50 but this is the errors I get.
Code:
Errors:
 + Custom/Zelda Quest/Zelda Quest Items/Warrior Bag.cs:
    CS1061: Line 23: 'Server.Items.PlateChest' does not contain a definition for
 'LowerStatReq' and no extension method 'LowerStatReq' accepting a first argumen
t of type 'Server.Items.PlateChest' could be found (are you missing a using dire
ctive or an assembly reference?)
    CS0246: Line 24: The type or namespace name 'item' could not be found (are y
ou missing a using directive or an assembly reference?)
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.

Now by all counts of what I can find I was pretty sure the propertie was called LowerStatReq but if it's not, I am unsure what the specific name definition is. Also I'm not sure why I am getting a refrence assembly error I am calling the server, system and items. Sorry if I am overlooking something dumb still learning a lot.
 
I'm not sure about LowerStatReq since thats an AOS property and I've never used/scripted/played AOS but how you are adding the item is incorrect

This code:
Code:
PlateChest item = new PlateChest();
item.LowerStatReq = 50;
this.DropItem(new item());

Should be:
Code:
PlateChest item = new PlateChest();
item.LowerStatReq = 50;
this.DropItem(item);

You already new'd up the item to a variable called "item" so you can just pass "item" to DropItem. No need to new it up again :)

To test you could just use the following(basically remove the LowerStatReq line):
Code:
PlateChest item = new PlateChest();
this.DropItem(item);
Just to make sure your code is working. Then figure out the LowerStatReq afterward.
 
On a quick look, I think you can do
Code:
item.ArmorAttributes.LowerStatReq = 50
But I havent tried it, just looking at the code ;)
 
OMG I feel like an idiot. I knew it was something silly, Can't believe I didn't catch I was calling new item twice. I love this shit lol. Also you were SPOT ON about the ArmorAttributes.LowerStatReq I can't thank you enough man. Just for anyone that may be searching for a similiar issue, this was the working code.

PlateChest item = new PlateChest();
item.ArmorAttributes.LowerStatReq = 50;
this.DropItem(item);
 
So now I am trying to add a bow with +10 archery to a bag. I did research and found some examples like in the death robe calling for +10 necromancy. So using those examples I made the following code

Code:
        [Constructable]
        public ArcherBag(int amount)
        {
            this.DropItem(new Arrow(200));
			this.DropItem(new Gold(2000));
			this.DropItem(new Bandage(30));
			this.DropItem(new Daat99Tokens(100));
			
			CompositeBow ItemBow = new CompositeBow();
			ItemBow.SetSkillBonuses.SetValues(0, SkillName.Archery, 10);
			this.DropItem(ItemBow);  	
        }

It compiles fine with no errors what so ever but the bow doesn't actually have +10 archery on it. Any suggestions as to why? It might have something to do with the 0 before the SkillName.Archery? I am unsure what that 0 represents but all the code in the other scripts has it just like that.
 
So now I am trying to add a bow with +10 archery to a bag. I did research and found some examples like in the death robe calling for +10 necromancy. So using those examples I made the following code

Code:
        [Constructable]
        public ArcherBag(int amount)
        {
            this.DropItem(new Arrow(200));
			this.DropItem(new Gold(2000));
			this.DropItem(new Bandage(30));
			this.DropItem(new Daat99Tokens(100));
			
			CompositeBow ItemBow = new CompositeBow();
			ItemBow.SetSkillBonuses.SetValues(0, SkillName.Archery, 10);
			this.DropItem(ItemBow);  	
        }

It compiles fine with no errors what so ever but the bow doesn't actually have +10 archery on it. Any suggestions as to why? It might have something to do with the 0 before the SkillName.Archery? I am unsure what that 0 represents but all the code in the other scripts has it just like that.
Here is your problem bud:
Code:
ItemBow.SetSkillBonuses.SetValues(0, SkillName.Archery, 10);

That will give +10 to Archery but only if the player has the complete SET. You want it to be like this:
Code:
ItemBow.SkillBonuses.SetValues(0, SkillName.Archery, 10);
 
Doh, I feel slow. You all are freaking awesome. I have 1 last quesiton regarding this. It is about adding multiple properties. let's say I want to add 2 skillbonuses. I was naive and thought I could do this

ItemApron.SkillBonuses.SetValues(0, SkillName.Tinkering, 10), (0, SkillName.Tailoring 10);

or even this

ItemApron.SkillBonuses.SetValues(0, SkillName.Tinkering, 10, SkillName.Tailoring 10);

But neither will compuke nor work. I also tried doing 2 lines like this.

ItemApron.SkillBonuses.SetValues(0, SkillName.Alchemy, 10);
ItemApron.SkillBonuses.SetValues(0, SkillName.Carpentry, 10);

With no luck either. I searched the scripts and RunUO and here for any examples of it on create and can't find any. I do apolagize for what I'm sure is so many silly questions.

PS to help me better understand what is going on here, what does the 0 represent anyways?
 
NVM, I took a shot in the dark and played with that zero and it seems its the number of the propertie. I got multiple ones to work. Just in case anyone is looking to see how this is what I used.

[Constructable]
public CrafterBag(int amount)
{
this.DropItem(new Gold(2000));
this.DropItem(new Daat99Tokens(100));

FullApron ItemApron = new FullApron();
ItemApron.SkillBonuses.SetValues(0, SkillName.Tinkering, 10);
ItemApron.SkillBonuses.SetValues(1, SkillName.Tailoring, 10);
ItemApron.SkillBonuses.SetValues(2, SkillName.Fletching, 10);
ItemApron.SkillBonuses.SetValues(3, SkillName.Blacksmith, 10);
ItemApron.SkillBonuses.SetValues(4, SkillName.Alchemy, 10);
ItemApron.SkillBonuses.SetValues(5, SkillName.Carpentry, 10);
this.DropItem(ItemApron);
}

Thanks so much everyone!
 
Was just going to suggest :) Glad you figured it out
ItemApron.SkillBonuses.SetValues(0, SkillName.Tinkering, 10);
ItemApron.SkillBonuses.SetValues(1, SkillName.Tailoring, 10);
 
Just a quick note, it looks like you can only have a total of 5 bonuses. Anything over that won't display or work. Kind of sucks but I'll work with the limitation. :)
 
Found this in the Repo which might be handy in the future

switch( Utility.Random(15) )
{
case 0:
this.SkillBonuses.SetValues(0, SkillName.EvalInt, 10);
this.SkillBonuses.SetValues(1, SkillName.Magery, 10);
break;
case 1:
this.SkillBonuses.SetValues(0, SkillName.AnimalLore, 10);
this.SkillBonuses.SetValues(1, SkillName.AnimalTaming, 10);
break;
case 2:
this.SkillBonuses.SetValues(0, SkillName.Swords, 10);
this.SkillBonuses.SetValues(1, SkillName.Tactics, 10);
break;
case 3:
this.SkillBonuses.SetValues(0, SkillName.Discordance, 10);
this.SkillBonuses.SetValues(1, SkillName.Musicianship, 10);
break;
case 4:
this.SkillBonuses.SetValues(0, SkillName.Fencing, 10);
this.SkillBonuses.SetValues(1, SkillName.Tactics, 10);
break;
case 5:
this.SkillBonuses.SetValues(0, SkillName.Chivalry, 10);
this.SkillBonuses.SetValues(1, SkillName.MagicResist, 10);
break;
case 6:
this.SkillBonuses.SetValues(0, SkillName.Anatomy, 10);
this.SkillBonuses.SetValues(1, SkillName.Healing, 10);
break;
case 7:
this.SkillBonuses.SetValues(0, SkillName.Ninjitsu, 10);
this.SkillBonuses.SetValues(1, SkillName.Stealth, 10);
break;
case 8:
this.SkillBonuses.SetValues(0, SkillName.Bushido, 10);
this.SkillBonuses.SetValues(1, SkillName.Parry, 10);
break;
case 9:
this.SkillBonuses.SetValues(0, SkillName.Archery, 10);
this.SkillBonuses.SetValues(1, SkillName.Tactics, 10);
break;
case 10:
this.SkillBonuses.SetValues(0, SkillName.Macing, 10);
this.SkillBonuses.SetValues(1, SkillName.Tactics, 10);
break;
case 11:
this.SkillBonuses.SetValues(0, SkillName.Necromancy, 10);
this.SkillBonuses.SetValues(1, SkillName.SpiritSpeak, 10);
break;
case 12:
this.SkillBonuses.SetValues(0, SkillName.Stealth, 10);
this.SkillBonuses.SetValues(1, SkillName.Stealing, 10);
break;
case 13:
this.SkillBonuses.SetValues(0, SkillName.Peacemaking, 10);
this.SkillBonuses.SetValues(1, SkillName.Musicianship, 10);
break;
case 14:
this.SkillBonuses.SetValues(0, SkillName.Provocation, 10);
this.SkillBonuses.SetValues(1, SkillName.Musicianship, 10);
break;
}
}
 
Just a quick note, it looks like you can only have a total of 5 bonuses. Anything over that won't display or work. Kind of sucks but I'll work with the limitation. :)
Yes, 5 is the limit for Skill Bonuses. However, if we go back to your original post, were I pointed out the SetSkillBonuses issue, and if you were to make that part of an armor set for example, you could then have 5 Skill Bonuses on the regular weapon THEN have up to 5 more as part of the SET. Make sense?
(Note: There are a few more things to change besides just adding SetSkillBonuses. You have to set up the script so UO knows it's part of a set and you have to go into the ArmorSets.cs and add the new set, plus each piece has to be set up in it's script. Just FYI).
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back