Fixed Plant Pigments

tass23

Moderator
Okay, so Orb3.0 brought the plant pigments and basketweaving to SA. Kewl, nice job figuring that one out mitty, seriously we banged our heads against walls for days over this mess. It seems though that we only made it halfway. Everything works perfectly, except once you craft softened reeds, they don't retain the hue properly, thus the crafted basket does not retain hue either. I'm going to attempt to backtrack the fixes I made and post them here. Bare with me as there was a lot of head-scratching and the banging of my head against the wall again. This requires distro edits and again these distro edits were NOT FROM ForkUO, so be warned, you might have to compensate.

First things first, getting everything organized to start distro editing. You will need the following:
CraftItem.cs
MiscSAResources.cs (contains DryReeds and SoftenedReeds)

Now lets open CraftItem.cs and make the distro edits. Look for m_ColoredItemTable first, make it look like this:
Code:
 private static Type[] m_ColoredItemTable = new Type[]
{
#region Mondain's Legacy
typeof( BaseContainer ), typeof( ParrotPerchAddonDeed ),
#endregion
typeof( BaseWeapon ), typeof( BaseArmor ), typeof( BaseClothing ),
typeof( BaseJewel ), typeof( DragonBardingDeed ), typeof( BaseAddonDeed ),
typeof( BaseAddon ), typeof( PlantPigment ),
typeof( SoftenedReeds), typeof( DryReeds ), typeof ( PlantClippings )
};
The above code adds PlantPigment, SoftenedReeds, DryReeds and PlantClippings to the table that defines what gets colored.

Next scroll down and look for m_ColoredResourceTable (should be right under the ColoredItemTable) and make it look like this:
Code:
 private static Type[] m_ColoredResourceTable = new Type[]
{
#region Mondain's Legacy
typeof( Board ), typeof( Log ),
#endregion
typeof( BaseIngot ), typeof( BaseOre ),
typeof( BaseLeather ), typeof( BaseHides ),
typeof( UncutCloth ), typeof( Cloth ),
typeof( BaseGranite ), typeof( BaseScales ),
typeof( PlantClippings ), typeof( DryReeds ),
typeof( SoftenedReeds ), typeof( PlantPigment ), typeof(BaseContainer)
};
The above code adds PlantClippings, DryReeds, SoftenedReeds and PlantPigments to the list of items that have a hue that should be carried over.

Finally, you probably want to replace both of these methods with the code I have here. So look for RetainsColor and RetainsColorFrom and replace both with this code.
Code:
 public static bool RetainsColor(Type type)
{
bool inItemTable = false;
for (int i = 0; !inItemTable && i < m_ColoredItemTable.Length; ++i)
inItemTable = (type == m_ColoredItemTable[i] || type.IsSubclassOf(m_ColoredItemTable[i]));
return inItemTable;
}
public bool RetainsColorFrom(CraftSystem system, Type type)
{
if (system.RetainsColorFrom(this, type))
return true;
bool inItemTable = false, inResourceTable = false;
for (int i = 0; !inItemTable && i < m_ColoredItemTable.Length; ++i)
inItemTable = (m_Type == m_ColoredItemTable[i] || m_Type.IsSubclassOf(m_ColoredItemTable[i]));
for (int i = 0; inItemTable && !inResourceTable && i < m_ColoredResourceTable.Length; ++i)
inResourceTable = (type == m_ColoredResourceTable[i] || type.IsSubclassOf(m_ColoredResourceTable[i]));
return (inItemTable && inResourceTable);
}
I believe those were all the changes I had to make to CraftItem.cs, however if you make these changes and it's not working, PM me and I'll walk you through it because it's possible I missed something.

Now lets open MiscSAResources.cs and change our DryReeds and SoftenedReeds. All this code can be used to replace the existing code in the entire file:
Code:
using System;
using Server;
using Server.Items;
using Server.Engines.Plants;
namespace Server.Items
{
public class DryReeds : Item
{
private PlantHue m_PlantHue;
[CommandProperty(AccessLevel.GameMaster)]
public PlantHue PlantHue
{
get { return m_PlantHue; }
set { m_PlantHue = value; Hue = PlantHueInfo.GetInfo(value).Hue; InvalidateProperties(); }
}
public override bool ForceShowProperties { get { return ObjectPropertyList.Enabled; } }
 
public bool RetainsColorFrom
{
get
{
return true;
}
}
public override int LabelNumber { get { return 1112248; } } // Dry Reeds
[Constructable]
public DryReeds()
: this(1)
{
}
[Constructable]
public DryReeds(int amount)
: base(0x1BD5)
{
Stackable = true;
Amount = amount;
}
public override void AddNameProperty(ObjectPropertyList list)
{
PlantHueInfo hueInfo = PlantHueInfo.GetInfo(m_PlantHue);
list.Add(1112289, "#" + hueInfo.Name); // ~1_COLOR~ dry reeds
}
public DryReeds(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1); // version
writer.Write((int)m_PlantHue);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
m_PlantHue = (PlantHue)reader.ReadInt();
break;
}
}
}
public class SoftenedReeds : Item
{
 
private PlantHue m_PlantHue;
[CommandProperty(AccessLevel.GameMaster)]
public PlantHue PlantHue
{
get { return m_PlantHue; }
set { m_PlantHue = value; Hue = PlantHueInfo.GetInfo(value).Hue; InvalidateProperties(); }
}
public override bool ForceShowProperties { get { return ObjectPropertyList.Enabled; } }
public bool RetainsColorFrom
{
get
{
return true;
}
}
public override int LabelNumber { get { return 1112246; } } // Softened Reeds
[Constructable]
public SoftenedReeds()
: this(1)
{
}
[Constructable]
public SoftenedReeds(int amount)
: base(0x4006)
{
Stackable = true;
Amount = amount;
}
public override void AddNameProperty(ObjectPropertyList list)
{
 
PlantHueInfo hueInfo = PlantHueInfo.GetInfo(m_PlantHue);
list.Add(1112346, "#" + hueInfo.Name); // ~1_COLOR~ Softened Reeds
}
public SoftenedReeds(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}

This should now allow for Softened Reeds to retain the hue from the Dry Reeds when crafted and also allow for the baskets to have the hue of the Softened Reeds.

Just a quick sidenote as well, the clippers had the wrong itemID and hue:
Code:
 [Constructable]
public Clippers()
: base(0x0DFC)
{
Weight = 1.0;
Hue = 1168;
}

Sidenote 2: I am still trying to figure out WHY this does not work for allowing Goza Mats to retain hue.
 
Last edited: