Piotr

Member
Hey guys,

Would you happen to know how to make a crafted item not to retain its resource color?
Let's say "Longsword" would always create itself with 0x000 hue, no matter which material you use.

I tried overriding the hue itself in Longsword.cs, but doesn't seem to work.

I also tried this in DefBlacksmithy.cs - no luck there either.


Code:
     public override bool RetainsColorFrom(CraftItem item, Type type)
       {
           return false;
       }
 
Last edited:
Look in BaseWeapon.cs

There are a couple of places that set the item's hue based on its CraftResource. Simply change those lines to hue=0 and it should do what you're looking for.

Code:
#region Factions
        private FactionItem m_FactionState;

        public FactionItem FactionItemState
        {
            get { return m_FactionState; }
            set
            {
                m_FactionState = value;

                if (m_FactionState == null)
                {
                    Hue = CraftResources.GetHue(Resource);
                }

                LootType = (m_FactionState == null ? LootType.Regular : LootType.Blessed);
            }
        }
        #endregion

and

Code:
    [CommandProperty(AccessLevel.GameMaster)]
     public CraftResource Resource
     {
       get { return m_Resource; }
       set
       {
         UnscaleDurability();
         m_Resource = value;
         Hue = CraftResources.GetHue(m_Resource);
         InvalidateProperties();
         ScaleDurability();
       }
     }
 
if you want that only for some items, use Hue property with timer in Constructor:
Code:
        [Constructable]
        public Longsword()
            : base(0xF61)
        {
            this.Weight = 7.0;
           
            if (this.GetType() == typeof(Longsword))
                Timer.DelayCall(TimeSpan.FromSeconds(0.1), delegate { Hue = 35; });
        }
but best solution it's:
set Resource property in BaseWeapon to virtual and override this property where you need it:
BaseWeapon.cs
Code:
        [CommandProperty(AccessLevel.GameMaster)]
        public virtual CraftResource Resource
        {
            get { return m_Resource; }
            set
            {
                UnscaleDurability();
                m_Resource = value;
                Hue = CraftResources.GetHue(m_Resource);
                InvalidateProperties();
                ScaleDurability();
            }
        }
Longsword.cs -
add next override:
Code:
public override CraftResource Resource { get { return base.Resource; } set { base.Resource = value; Hue = 35;} }
 
Last edited:
Thanks a lot!
Will test it as soon as I get back from work
[doublepost=1527022922][/doublepost]It worked like a charm!
Thanks, guys, exactly what I wanted.

@Juzzver, do you think it would be possible to apply a similar method to override the material you make the longsword with?
Like, you can make something with iron, bronze or whatever ingots, but it would always come out as verite, for example?
It is actually a topic that I mention in another thread, but maybe it can be done with something similar to this hue override?

I'd appreciate a bit of help. Those are the 2 things that I need to make my blacksmith idea work. Forced hue, check. Forced resource... not so much.

Thanks!
 
Last edited:
Yes, certainly. Almost any property can be overridden/changed this way.
Code:
Resource = CraftResource.Verite;
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back