RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

How do I add random Magic Attributes to items.

Erucid

Sorceror
So, how do I make the daisho and the katana have random magic attributes assigned to them. Preferably lower level.
Code:
/
 using System;
using System; 
using Server; 
using Server.Items; 
 
namespace Server.Items 
{ 
    public class OneItemBag : Bag 
    { 
        public override string DefaultName 
        { 
            get { return "Deed Bag"; } 
        } 
 
        [Constructable] 
        public OneItemBag() : this( 1 ) 
        { 
            Movable = true; 
            Hue = 453; 
        } 
 
        [Constructable] 
        public OneItemBag( int amount )//public DeedBag( int amount ) 
        { 
 
            Item myitem = null; 
                    switch ( Utility.Random( 2 ) ) 
                    { 
                case 0: myitem =  new Katana();break; 
                case 1: myitem =  new Daisho();break; 
                 
                    } 
            AddItem( myitem ); 
        } 
         
        public OneItemBag( 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(); 
        } 
    } 
}

using Server;

using Server.Items;
  
namespace Server.Items

{

    public class OneItemBag : Bag

    {

        public override string DefaultName

        {

            get { return "Deed Bag"; }

        }
  
        [Constructable]

        public OneItemBag() : this( 1 )

        {

            Movable = true;

            Hue = 453;

        }
  
        [Constructable]

        public OneItemBag( int amount )//public DeedBag( int amount )

        {
  
            Item myitem = null;

                    switch ( Utility.Random( 2 ) )

                    {

                case 0: myitem =  new Katana();break;

                case 1: myitem =  new Daisho();break;
  
                    }

            AddItem( myitem );

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

        }

    }

}
 

KillerBeeZ

Knight
also for the random...
Code:
                        switch ( Utility.Random( 2 )) // 2 items
                        {
                            case 0: // item 1
                            // add your weapon attribute here
                            break;
                            case 1: // item 2
                            // add a different weapon attribute here
                            break;
                        }
plus you can substitute the value (if its a number) for Utility.RandomMinMax(2,5)
 

Erucid

Sorceror
So there is not build in method to add a random attribute as though this was a random piece of loot? Doing a case for each item I want to use and then a case for each attribute doesn't sound like an optimal way of doing this. :-/
 

tass23

Page
Lootpack.cs. By adding items to that, it adds the loot globally to mob drops. Saves you some time and effort ;)
 

tass23

Page
Almost all monster drops are controlled by a file called Lootpack.cs. If you want to add something to all monster drops universally, you should add it to Lootpack.cs. Look for it in your Scripts->Misc folder.
 

Erucid

Sorceror
No, I don't want to add it to all monster drops. I just want to be able to add random magic attributes to a given item. I guess another way to look at it is I want to create a bag, and within that bag would be a random weapon from a list that I choose. (probably through case) and whatever item is randomly selected, it gets a random magic attribute applied to it. Then I can spawn or drop the bag (using xmlspawner) and be assured that it created an item I specified, but with a random magic attribute. In the code above, it would be like...
Code:
        public OneItemBag( int amount )//public DeedBag( int amount )
        {

            Item myitem = null;
                    switch ( Utility.Random( 2 ) )
                    {
                case 0: myitem =  new Katana( WITH RANDOM MAGIC ABILITY);break;
                case 1: myitem =  new Daisho( WITH RANDOM MAGIC ABILITY);break;

                    }
            AddItem( myitem );
        }
But I don't know what to put for the WITH RANDOM MAGIC ABILITY or even if it can be done.
 

Erucid

Sorceror
Yeah, i was just hoping that someone already invented a shortcut.
in the above example
Code:
                        switch ( Utility.Random( 2 )) // 2 items
                        {
                            case 0: // item 1
                            // add your weapon attribute here
                            break;
                            case 1: // item 2
                            // add a different weapon attribute here
                            break;
                        }
What would an "// add a different weapon attribute here" look like?
 
Top