Hi,

I'm trying to get the craftresource from an item (armor, jewerly,weapon) to get the resource bonus and add or substract that bonus.

Per example if the resource type is spinned substract 40 luck bonus and add some other.

But i dont have any clue how to make that.

Anybody can give an example?

TY.
 
Last edited:
What type of script are you writing? Gump? Item? Mobile?

In what method are you trying to access the resource type of an item? Who has the item? Where is the item located?
 
assuming your ontarget method looks like this:
protected override void OnTarget( Mobile from, object target )
{
if ( target is BaseWeapon || target is BaseArmor || target is BaseClothing || target is BaseJewel )
{
Item item = (Item)target;

I think you can check the item resource with: item.CraftResource

edit: or are you not asking to check it for a targeted item?
 
Yeah its my first idea but:

int Resource_Type = Item.CraftResource;

or

int ResourceType = get { return {Item.CraftResource};}

Error:

* get don't exist
* 'object' does not contain a definition for 'CraftResource' and no extension method 'CraftResource' accepting a first argument of type 'object' found


 
bishou, answering Lokai's question would help as well as if you posted the script you're working on

also you would need to use item.CraftResource ...the I in Item would have to be lower case in the situation i mentioned.
 
There's the script
Code:
using System;
using Server;
using Server.Targeting;
using Server.Mobiles;
using Server.Network;
using Server.Items;
using Server.Gumps;
using System.Collections;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Commands;

namespace Server.SkillHandlers
{

    public class Modify_Item : Item
    {

        [Constructable]
        public Modify_Item()
            : base(0xED4)
        {
            Movable = false;
            Hue = 0xB83;
            Name = "A Item Modificator";
        }

    // Here on click to open the gump

    }

    public class Modify_ItemGump : Gump
    {

        public Modify_ItemGump(Mobile from)
            : base(80, 80)
        {
            Mobile m = from;
            PlayerMobile pm = from as PlayerMobile;

            pm.Imbue_ModVal = 0;
            pm.ImbMenu_Cat = 0;

            AddPage(0);
            this.AddBackground(0, 0, 200, 200, 9270);
            this.AddAlphaRegion(12, 12, 486, 20);
            this.AddAlphaRegion(12, 40, 486, 247);
            this.AddAlphaRegion(12, 199, 486, 25);
            this.AddLabel(221, 18, 1359, "MODIFY ITEM MENU");

            AddButton(25, 66, 4005, 4006, 10002, GumpButtonType.Reply, 0);
            AddHtml(66, 68, 430, 18, "<BASEFONT COLOR=#FFFFFF>Adds an item property on an item", false, false);
            AddButton(25, 95, 4005, 4006, 10003, GumpButtonType.Reply, 0);
            AddHtml(66, 97, 430, 18, "<BASEFONT COLOR=#FFFFFF>Removes an item property on an item", false, false);

            AddButton(19, 301, 4020, 4021, 10001, GumpButtonType.Reply, 0);
            this.AddLabel(58, 302, 1359, "CLOSE");

        }

        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;
            PlayerMobile pm = from as PlayerMobile;

            int buttonNum = 0;

            if (info.ButtonID > 0 && info.ButtonID < 10000)
                buttonNum = 1;
            else if (info.ButtonID > 20004)
                buttonNum = 30000;
            else
                buttonNum = info.ButtonID;

            switch (buttonNum)
            {

                case 10001:  // = Close button
                    {
                        break;
                    }
                case 10002:  // = Adds an item property on an item
                    {
                        from.CloseGump(typeof(Modify_ItemGump));

                        from.SendMessage("Target a item to add a propertie.");
                        from.Target = new InternalTarget();

                        break;
                    }
                case 10003:  // = Removes an item property on an item
                    {
                        from.CloseGump(typeof(Modify_ItemGump));

                        from.SendMessage("Target a item to remove a propertie.");
                        from.Target = new InternalTarget();

                        break;

                    }
            }

            return;
        }



        // ===== Targetting Item =====

        private class InternalTarget : Target
        {
            public InternalTarget()
                : base(1, false, TargetFlags.None)
            {
                AllowNonlocal = true;
            }

            protected override void OnTarget(Mobile from, object o)
            {
                PlayerMobile pm = from as PlayerMobile;

                int Irf = Modify_ItemGump.GetItemRef(o);
                return;
            }
        }

        public static int GetItemRef(object i)
        {

            int item_type = 0;

            if (i is BaseWeapon)
            {
                item_type = 1;
            }
            if (i is BaseRanged)
            {
                item_type = 2;
            }

            if (i is BaseArmor)
            {
                item_type = 3;
            }

            if (i is BaseShield)
            {
                item_type = 4;
            }

            if (i is BaseHat)
            {
                item_type = 5;
            }

            if (i is BaseJewel)
            {
                item_type = 6;
            }

            return item_type;


            // HERE IS WHERE I TRY TO GET CRAFTRESOURCES

            // item Craftresources  --> number

            // Example

            // if item_type = 3 && CraftresourcesNumber = 102 -->  Remove 40 Luck from item

        
        
//CraftResource (Enum)
//None = 0,
//Iron = 1,
//DullCopper = 2,
//ShadowIron = 3,
//Copper = 4,
//Bronze = 5,
//Gold = 6,
//Agapite = 7,
//Verite = 8,
//Valorite = 9,
//RegularLeather = 101,
//SpinedLeather = 102,
//HornedLeather = 103,
//BarbedLeather = 104,
//RedScales = 201,
//YellowScales = 202,
//BlackScales = 203,
//GreenScales = 204,
//WhiteScales = 205,
//BlueScales = 206,
//RegularWood = 301,
//OakWood = 302,
//AshWood = 303,
//YewWood = 304,
//Heartwood = 305,
//Bloodwood = 306,
//Frostwood = 307

        }

    }

}

Also I found this post in runuo forums:

http://www.runuo.com/community/threads/finding-the-resource-type-of-an-item.41484/
 

Attachments

  • ModifyItemProps.cs
    5 KB · Views: 5
This will get you started:

Code:
using System;
using Server;
using Server.Targeting;
using Server.Mobiles;
using Server.Network;
using Server.Items;
using Server.Gumps;
using System.Collections;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Commands;

namespace Server.SkillHandlers
{

    public class Modify_Item : Item
    {

        [Constructable]
        public Modify_Item()
            : base(0xED4)
        {
            Movable = false;
            Hue = 0xB83;
            Name = "A Item Modificator";
        }

        // Here on click to open the gump

    }

    public class Modify_ItemGump : Gump
    {

        public Modify_ItemGump(Mobile from)
            : base(80, 80)
        {
            Mobile m = from;
            PlayerMobile pm = from as PlayerMobile;

            pm.Imbue_ModVal = 0;
            pm.ImbMenu_Cat = 0;

            AddPage(0);
            this.AddBackground(0, 0, 540, 340, 9270);
            this.AddAlphaRegion(17, 17, 486, 20);
            this.AddAlphaRegion(17, 45, 486, 247);
            this.AddAlphaRegion(17, 299, 486, 25);
            this.AddLabel(221, 18, 1359, "MODIFY ITEM MENU");

            AddButton(25, 66, 4005, 4006, 10002, GumpButtonType.Reply, 0);
            AddHtml(66, 68, 430, 18, "<BASEFONT COLOR=#FFFFFF>Adds an item property on an item", false, false);
            AddButton(25, 95, 4005, 4006, 10003, GumpButtonType.Reply, 0);
            AddHtml(66, 97, 430, 18, "<BASEFONT COLOR=#FFFFFF>Removes an item property on an item", false, false);

            AddButton(19, 301, 4020, 4021, 10001, GumpButtonType.Reply, 0);
            this.AddLabel(58, 302, 1359, "CLOSE");

        }

        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;
            PlayerMobile pm = from as PlayerMobile;

            int buttonNum = 0;

            if (info.ButtonID > 0 && info.ButtonID < 10000)
                buttonNum = 1;
            else if (info.ButtonID > 20004)
                buttonNum = 30000;
            else
                buttonNum = info.ButtonID;

            switch (buttonNum)
            {

                case 10001:  // = Close button
                    {
                        break;
                    }
                case 10002:  // = Adds an item property on an item
                    {
                        from.CloseGump(typeof(Modify_ItemGump));

                        from.SendMessage("Target a item to add a propertie.");
                        from.Target = new InternalTarget();

                        break;
                    }
                case 10003:  // = Removes an item property on an item
                    {
                        from.CloseGump(typeof(Modify_ItemGump));

                        from.SendMessage("Target a item to remove a propertie.");
                        from.Target = new InternalTarget();

                        break;

                    }
            }

            return;
        }



        // ===== Targetting Item =====

        private class InternalTarget : Target
        {
            public InternalTarget()
                : base(1, false, TargetFlags.None)
            {
                AllowNonlocal = true;
            }

            protected override void OnTarget(Mobile from, object o)
            {
                PlayerMobile pm = from as PlayerMobile;

                Item item = (Item)o;
                if (item == null || pm == null) return;

                CraftResource cr = CraftResource.None;

                if (item is BaseWeapon) cr = ((BaseWeapon)item).Resource;
                if (item is BaseArmor) cr = ((BaseArmor)item).Resource;
                if (item is BaseClothing) cr = ((BaseClothing)item).Resource;
                if (item is BaseJewel) cr = ((BaseJewel)item).Resource;

                switch (cr)
                {
                    case CraftResource.Frostwood:
                    {
                        // do your stuff to the item here.

                        if (item is BaseWeapon) ((BaseWeapon)item).WeaponAttributes.HitColdArea = 30;
                        if (item is BaseArmor)
                        {
                            ((BaseArmor) item).Attributes.Luck -= 20;
                            ((BaseArmor) item).Attributes.ReflectPhysical += 20;
                        }
                        if (item is BaseClothing)
                        {
                            ((BaseClothing)item).Attributes.Luck -= 20;
                            ((BaseClothing)item).Attributes.ReflectPhysical += 20;
                        }
                        // if (item is BaseJewel); //do nothing

                        break;
                    }
                    case CraftResource.Gold:
                    {
                        // do your stuff to the item here.
                        break;
                    }
                }
            }
        }

    }

}
 
You are welcome. You will need to add your other case statements to check for whatever resources you are looking for, but now that you have a template, that should be no problem.
 
Back