1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Plant Pigments

Discussion in 'Archived Bug Reports' started by tass23, Sep 10, 2013.

  1. tass23
    Offline

    Moderator

    Joined:
    Aug 28, 2013
    Messages:
    1,010
    Likes Received:
    131
    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 (C#):
    1.  private static Type[] m_ColoredItemTable = new Type[]
    2. {
    3. #region Mondain's Legacy
    4. typeof( BaseContainer ), typeof( ParrotPerchAddonDeed ),
    5. #endregion
    6. typeof( BaseWeapon ), typeof( BaseArmor ), typeof( BaseClothing ),
    7. typeof( BaseJewel ), typeof( DragonBardingDeed ), typeof( BaseAddonDeed ),
    8. typeof( BaseAddon ), typeof( PlantPigment ),
    9. typeof( SoftenedReeds), typeof( DryReeds ), typeof ( PlantClippings )
    10. };
    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 (C#):
    1.  private static Type[] m_ColoredResourceTable = new Type[]
    2. {
    3. #region Mondain's Legacy
    4. typeof( Board ), typeof( Log ),
    5. #endregion
    6. typeof( BaseIngot ), typeof( BaseOre ),
    7. typeof( BaseLeather ), typeof( BaseHides ),
    8. typeof( UncutCloth ), typeof( Cloth ),
    9. typeof( BaseGranite ), typeof( BaseScales ),
    10. typeof( PlantClippings ), typeof( DryReeds ),
    11. typeof( SoftenedReeds ), typeof( PlantPigment ), typeof(BaseContainer)
    12. };
    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 (C#):
    1.  public static bool RetainsColor(Type type)
    2. {
    3. bool inItemTable = false;
    4. for (int i = 0; !inItemTable && i < m_ColoredItemTable.Length; ++i)
    5. inItemTable = (type == m_ColoredItemTable[i] || type.IsSubclassOf(m_ColoredItemTable[i]));
    6. return inItemTable;
    7. }
    8. public bool RetainsColorFrom(CraftSystem system, Type type)
    9. {
    10. if (system.RetainsColorFrom(this, type))
    11. return true;
    12. bool inItemTable = false, inResourceTable = false;
    13. for (int i = 0; !inItemTable && i < m_ColoredItemTable.Length; ++i)
    14. inItemTable = (m_Type == m_ColoredItemTable[i] || m_Type.IsSubclassOf(m_ColoredItemTable[i]));
    15. for (int i = 0; inItemTable && !inResourceTable && i < m_ColoredResourceTable.Length; ++i)
    16. inResourceTable = (type == m_ColoredResourceTable[i] || type.IsSubclassOf(m_ColoredResourceTable[i]));
    17. return (inItemTable && inResourceTable);
    18. }
    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 (C#):
    1. using System;
    2. using Server;
    3. using Server.Items;
    4. using Server.Engines.Plants;
    5. namespace Server.Items
    6. {
    7. public class DryReeds : Item
    8. {
    9. private PlantHue m_PlantHue;
    10. [CommandProperty(AccessLevel.GameMaster)]
    11. public PlantHue PlantHue
    12. {
    13. get { return m_PlantHue; }
    14. set { m_PlantHue = value; Hue = PlantHueInfo.GetInfo(value).Hue; InvalidateProperties(); }
    15. }
    16. public override bool ForceShowProperties { get { return ObjectPropertyList.Enabled; } }
    17.  
    18. public bool RetainsColorFrom
    19. {
    20. get
    21. {
    22. return true;
    23. }
    24. }
    25. public override int LabelNumber { get { return 1112248; } } // Dry Reeds
    26. [Constructable]
    27. public DryReeds()
    28. : this(1)
    29. {
    30. }
    31. [Constructable]
    32. public DryReeds(int amount)
    33. : base(0x1BD5)
    34. {
    35. Stackable = true;
    36. Amount = amount;
    37. }
    38. public override void AddNameProperty(ObjectPropertyList list)
    39. {
    40. PlantHueInfo hueInfo = PlantHueInfo.GetInfo(m_PlantHue);
    41. list.Add(1112289, "#" + hueInfo.Name); // ~1_COLOR~ dry reeds
    42. }
    43. public DryReeds(Serial serial)
    44. : base(serial)
    45. {
    46. }
    47. public override void Serialize(GenericWriter writer)
    48. {
    49. base.Serialize(writer);
    50. writer.Write((int)1); // version
    51. writer.Write((int)m_PlantHue);
    52. }
    53. public override void Deserialize(GenericReader reader)
    54. {
    55. base.Deserialize(reader);
    56. int version = reader.ReadInt();
    57. switch (version)
    58. {
    59. case 1:
    60. m_PlantHue = (PlantHue)reader.ReadInt();
    61. break;
    62. }
    63. }
    64. }
    65. public class SoftenedReeds : Item
    66. {
    67.  
    68. private PlantHue m_PlantHue;
    69. [CommandProperty(AccessLevel.GameMaster)]
    70. public PlantHue PlantHue
    71. {
    72. get { return m_PlantHue; }
    73. set { m_PlantHue = value; Hue = PlantHueInfo.GetInfo(value).Hue; InvalidateProperties(); }
    74. }
    75. public override bool ForceShowProperties { get { return ObjectPropertyList.Enabled; } }
    76. public bool RetainsColorFrom
    77. {
    78. get
    79. {
    80. return true;
    81. }
    82. }
    83. public override int LabelNumber { get { return 1112246; } } // Softened Reeds
    84. [Constructable]
    85. public SoftenedReeds()
    86. : this(1)
    87. {
    88. }
    89. [Constructable]
    90. public SoftenedReeds(int amount)
    91. : base(0x4006)
    92. {
    93. Stackable = true;
    94. Amount = amount;
    95. }
    96. public override void AddNameProperty(ObjectPropertyList list)
    97. {
    98.  
    99. PlantHueInfo hueInfo = PlantHueInfo.GetInfo(m_PlantHue);
    100. list.Add(1112346, "#" + hueInfo.Name); // ~1_COLOR~ Softened Reeds
    101. }
    102. public SoftenedReeds(Serial serial)
    103. : base(serial)
    104. {
    105. }
    106. public override void Serialize(GenericWriter writer)
    107. {
    108. base.Serialize(writer);
    109. writer.Write((int)1); // version
    110. }
    111. public override void Deserialize(GenericReader reader)
    112. {
    113. base.Deserialize(reader);
    114. int version = reader.ReadInt();
    115. }
    116. }
    117. }
    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 (C#):
    1.  [Constructable]
    2. public Clippers()
    3. : base(0x0DFC)
    4. {
    5. Weight = 1.0;
    6. Hue = 1168;
    7. }
    Sidenote 2: I am still trying to figure out WHY this does not work for allowing Goza Mats to retain hue.
     
    #1 tass23, Sep 10, 2013
    Last edited: Sep 20, 2013
    • Like Like x 1
  2. Milva
    Offline

    Admin Moderator

    Joined:
    Mar 3, 2013
    Messages:
    3,430
    Likes Received:
    385
    Nice fix thanks for sharing :)
     
    • Like Like x 1
Similar Threads: Plant Pigments
Forum Title Date
Archived Bug Reports Planting - Seed of Renewal -& Whipping Vines Drops Aug 1, 2017
Archived Bug Reports New plants & resources Mar 2, 2017
Custom Releases Plant Sprinklers May 1, 2016
Custom Releases Plant Harvesting System 2.0 Jan 1, 2016
Art Waterplants Jun 3, 2015
Custom Releases Plant Water Sprinkler May 18, 2015
Custom Releases 2015 Easter Potted Plants Apr 4, 2015