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

Fixed Chocolatiering

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
    So the SA release brought Chocolatiering in to the mix, no pun intended. Nice that the ingredients drop on paragons and we don't need to do a ton of edits to get it to work.....or DO we?

    You will notice if you open your Cooking Craft menu and click on Chocolatiering, then any of the new chocolate crafts that the graphic shows up as Unused. It's baffling because the graphic is actually based on an emerald. What I found out was whomever wrote the chocolatiering made a fatal error, they based all the chocolate on the class of CandyCane, oops. The reason this was done, I'm assuming, was to account for the toothaches and candy timers. Well, it seems to have messed things up a tad. What I had to do was write a new class of Chocolate, give it the candy timers, then base all chocolate off that. Here's the breakdown:

    Code (C#):
    1.  public class Chocolate : Food
    2. {
    3. private static Dictionary<Mobile, ChocolateTimer> m_ToothAches;
    4. public static Dictionary<Mobile, ChocolateTimer> ToothAches
    5. {
    6. get { return m_ToothAches; }
    7. set { m_ToothAches = value; }
    8. }
    9. public static void Initialize()
    10. {
    11. m_ToothAches = new Dictionary<Mobile, ChocolateTimer>();
    12. }
    13. public class ChocolateTimer : Timer
    14. {
    15. private int m_Eaten;
    16. private Mobile m_Eater;
    17. public Mobile Eater { get { return m_Eater; } }
    18. public int Eaten { get { return m_Eaten; } set { m_Eaten = value; } }
    19. public ChocolateTimer( Mobile eater ) : base( TimeSpan.FromSeconds( 30 ), TimeSpan.FromSeconds( 30 ) )
    20. {
    21. m_Eater = eater;
    22. Priority = TimerPriority.FiveSeconds;
    23. Start();
    24. }
    25. protected override void OnTick()
    26. {
    27. Eaten--;
    28. if ( Eater == null || Eater.Deleted || Eaten <= 0 )
    29. {
    30. Stop();
    31. ToothAches.Remove( Eater );
    32. }
    33. else if ( Eater.Map != Map.Internal && Eater.Alive )
    34. {
    35. if( Eaten > 60 )
    36. {
    37. Eater.Say( 1077388 + Utility.Random(5) ); // ARRGH! My tooth hurts sooo much!, etc.
    38. if( Utility.RandomBool() )
    39. {
    40. Eater.Animate( 32, 5, 1, true, false, 0 );
    41. }
    42. }
    43. else if ( Eaten == 60 )
    44. {
    45. Eater.SendLocalizedMessage( 1077393 ); // The extreme pain in your teeth subsides.
    46. }
    47. }
    48. }
    49. }
    50.  
    51. [Constructable]
    52. public Chocolate() : base( 0x0F10 )
    53. {
    54. Hue = 0x465;
    55. Stackable = false;
    56. LootType=LootType.Blessed;
    57. }
    58. public override void OnDoubleClick( Mobile from )
    59. {
    60. if( IsChildOf( from.Backpack ) || from.InRange(this, 1) )
    61. {
    62. from.PlaySound( 0x3a + Utility.Random(3) );
    63. from.Animate( 34, 5, 1, true, false, 0 );
    64. if ( !ToothAches.ContainsKey( from ) )
    65. {
    66. ToothAches.Add( from, new ChocolateTimer( from ) );
    67. }
    68. ToothAches[from].Eaten += 32;
    69. from.SendLocalizedMessage( 1077387 ); // You feel as if you could eat as much as you wanted!
    70. Delete();
    71. }
    72. }
    73. public Chocolate( Serial serial ) : base( serial )
    74. {
    75. }
    76. public override void Serialize( GenericWriter writer )
    77. {
    78. base.Serialize( writer );
    79. writer.Write( (int) 0 ); // version
    80. }
    81. public override void Deserialize( GenericReader reader )
    82. {
    83. base.Deserialize( reader );
    84. int version = reader.ReadInt();
    85. }
    86. }
    The above code gives you a new baseclass of Chocolate. Now you will also notice that the hue is already set for Dark Chocolate, sorry, if you leave the Hue off the above code, your chocolate shows up as Green because the emerald graphic is, um green. Insanity and I were speaking about some issues similar to this last night. The entire crafting system needs to be re-written to show the completed, crafted item, instead of the baseclass it inherits from. Anyway....now we go down into the actual crafted chocolate:

    Code (C#):
    1.  public class DarkChocolate : Chocolate
    2. {
    3. public override int LabelNumber { get { return 1079994; } } // Dark chocolate
    4. public override double DefaultWeight { get { return 1.0; } }
    5. [Constructable]
    6. public DarkChocolate()
    7. {
    8. Hue = 0x465;
    9. LootType = LootType.Regular;
    10. }
    11. public DarkChocolate( Serial serial ) : base( serial )
    12. {
    13. }
    14. public override void Serialize( GenericWriter writer )
    15. {
    16. base.Serialize( writer );
    17. writer.Write( (int) 0 );
    18. }
    19. public override void Deserialize(GenericReader reader)
    20. {
    21. base.Deserialize( reader );
    22. int version = reader.ReadInt();
    23. }
    24. }
    Notice that DarkChocolate is based on Chocolate, which works just fine. Chocolate itself is a based on Food, so we're all good there. Here's how the entire thing should look and keep in mind this is NOT ForkUO CODE, which means it'll likely have to be adjusted to fit in with ForkUO.

    Completed Chocolatiering
    Code (C#):
    1. using System;
    2. using Server;
    3. using System.Collections.Generic;
    4. namespace Server.Items
    5. {
    6. public class Chocolate : Food
    7. {
    8. private static Dictionary<Mobile, ChocolateTimer> m_ToothAches;
    9. public static Dictionary<Mobile, ChocolateTimer> ToothAches
    10. {
    11. get { return m_ToothAches; }
    12. set { m_ToothAches = value; }
    13. }
    14. public static void Initialize()
    15. {
    16. m_ToothAches = new Dictionary<Mobile, ChocolateTimer>();
    17. }
    18. public class ChocolateTimer : Timer
    19. {
    20. private int m_Eaten;
    21. private Mobile m_Eater;
    22. public Mobile Eater { get { return m_Eater; } }
    23. public int Eaten { get { return m_Eaten; } set { m_Eaten = value; } }
    24. public ChocolateTimer( Mobile eater ) : base( TimeSpan.FromSeconds( 30 ), TimeSpan.FromSeconds( 30 ) )
    25. {
    26. m_Eater = eater;
    27. Priority = TimerPriority.FiveSeconds;
    28. Start();
    29. }
    30. protected override void OnTick()
    31. {
    32. Eaten--;
    33. if ( Eater == null || Eater.Deleted || Eaten <= 0 )
    34. {
    35. Stop();
    36. ToothAches.Remove( Eater );
    37. }
    38. else if ( Eater.Map != Map.Internal && Eater.Alive )
    39. {
    40. if( Eaten > 60 )
    41. {
    42. Eater.Say( 1077388 + Utility.Random(5) ); // ARRGH! My tooth hurts sooo much!, etc.
    43. if( Utility.RandomBool() )
    44. {
    45. Eater.Animate( 32, 5, 1, true, false, 0 );
    46. }
    47. }
    48. else if ( Eaten == 60 )
    49. {
    50. Eater.SendLocalizedMessage( 1077393 ); // The extreme pain in your teeth subsides.
    51. }
    52. }
    53. }
    54. }
    55.  
    56. [Constructable]
    57. public Chocolate() : base( 0x0F10 )
    58. {
    59. Hue = 0x465;
    60. Stackable = false;
    61. LootType=LootType.Blessed;
    62. }
    63. public override void OnDoubleClick( Mobile from )
    64. {
    65. if( IsChildOf( from.Backpack ) || from.InRange(this, 1) )
    66. {
    67. from.PlaySound( 0x3a + Utility.Random(3) );
    68. from.Animate( 34, 5, 1, true, false, 0 );
    69. if ( !ToothAches.ContainsKey( from ) )
    70. {
    71. ToothAches.Add( from, new ChocolateTimer( from ) );
    72. }
    73. ToothAches[from].Eaten += 32;
    74. from.SendLocalizedMessage( 1077387 ); // You feel as if you could eat as much as you wanted!
    75. Delete();
    76. }
    77. }
    78. public Chocolate( Serial serial ) : base( serial )
    79. {
    80. }
    81. public override void Serialize( GenericWriter writer )
    82. {
    83. base.Serialize( writer );
    84. writer.Write( (int) 0 ); // version
    85. }
    86. public override void Deserialize( GenericReader reader )
    87. {
    88. base.Deserialize( reader );
    89. int version = reader.ReadInt();
    90. }
    91. }
    92.  
    93. public class DarkChocolate : Chocolate
    94. {
    95. public override int LabelNumber { get { return 1079994; } } // Dark chocolate
    96. public override double DefaultWeight { get { return 1.0; } }
    97. [Constructable]
    98. public DarkChocolate()
    99. {
    100. Hue = 0x465;
    101. LootType = LootType.Regular;
    102. }
    103. public DarkChocolate( Serial serial ) : base( serial )
    104. {
    105. }
    106. public override void Serialize( GenericWriter writer )
    107. {
    108. base.Serialize( writer );
    109. writer.Write( (int) 0 );
    110. }
    111. public override void Deserialize(GenericReader reader)
    112. {
    113. base.Deserialize( reader );
    114. int version = reader.ReadInt();
    115. }
    116. }
    117.  
    118. public class MilkChocolate : Chocolate
    119. {
    120. public override int LabelNumber { get { return 1079995; } } // Milk chocolate
    121. public override double DefaultWeight { get { return 1.0; } }
    122. [Constructable]
    123. public MilkChocolate()
    124. {
    125. Hue = 0x461;
    126. LootType = LootType.Regular;
    127. }
    128. public MilkChocolate( Serial serial ) : base( serial )
    129. {
    130. }
    131. public override void Serialize( GenericWriter writer )
    132. {
    133. base.Serialize( writer );
    134. writer.Write( (int) 0 );
    135. }
    136. public override void Deserialize(GenericReader reader)
    137. {
    138. base.Deserialize( reader );
    139. int version = reader.ReadInt();
    140. }
    141. }
    142. public class WhiteChocolate : Chocolate
    143. {
    144. public override int LabelNumber { get { return 1079996; } } // White chocolate
    145. public override double DefaultWeight { get { return 1.0; } }
    146. [Constructable]
    147. public WhiteChocolate()
    148. {
    149. Hue = 0x47E;
    150. LootType = LootType.Regular;
    151. }
    152. public WhiteChocolate( Serial serial ) : base( serial )
    153. {
    154. }
    155. public override void Serialize( GenericWriter writer )
    156. {
    157. base.Serialize( writer );
    158. writer.Write( (int) 0 );
    159. }
    160. public override void Deserialize(GenericReader reader)
    161. {
    162. base.Deserialize( reader );
    163. int version = reader.ReadInt();
    164. }
    165. }
    166.  
    167. public class CocoaLiquor : Item
    168. {
    169. public override int LabelNumber { get { return 1080007; } } // Cocoa liquor
    170. public override double DefaultWeight { get { return 1.0; } }
    171. [Constructable]
    172. public CocoaLiquor()
    173. : base( 0x103F )
    174. {
    175. Hue = 0x46A;
    176. }
    177. public CocoaLiquor( Serial serial )
    178. : base( serial )
    179. {
    180. }
    181. public override void Serialize( GenericWriter writer )
    182. {
    183. base.Serialize( writer );
    184. writer.Write( (int) 0 ); // version
    185. }
    186. public override void Deserialize( GenericReader reader )
    187. {
    188. base.Deserialize( reader );
    189. int version = reader.ReadInt();
    190. }
    191. }
    192. public class SackOfSugar : Item
    193. {
    194. public override int LabelNumber { get { return 1080003; } } // Sack of sugar
    195. public override double DefaultWeight { get { return 1.0; } }
    196. [Constructable]
    197. public SackOfSugar()
    198. : this( 1 )
    199. {
    200. }
    201. [Constructable]
    202. public SackOfSugar( int amount )
    203. : base( 0x1039 )
    204. {
    205. Hue = 0x461;
    206. Stackable = true;
    207. Amount = amount;
    208. }
    209. public SackOfSugar( Serial serial )
    210. : base( serial )
    211. {
    212. }
    213. public override void Serialize( GenericWriter writer )
    214. {
    215. base.Serialize( writer );
    216. writer.Write( (int) 0 ); // version
    217. }
    218. public override void Deserialize( GenericReader reader )
    219. {
    220. base.Deserialize( reader );
    221. int version = reader.ReadInt();
    222. }
    223. }
    224. public class CocoaButter : Item
    225. {
    226. public override int LabelNumber { get { return 1080005; } } // Cocoa butter
    227. public override double DefaultWeight { get { return 1.0; } }
    228. [Constructable]
    229. public CocoaButter()
    230. : base( 0x1044 )
    231. {
    232. Hue = 0x457;
    233. }
    234. public CocoaButter( Serial serial )
    235. : base( serial )
    236. {
    237. }
    238. public override void Serialize( GenericWriter writer )
    239. {
    240. base.Serialize( writer );
    241. writer.Write( (int) 0 ); // version
    242. }
    243. public override void Deserialize( GenericReader reader )
    244. {
    245. base.Deserialize( reader );
    246. int version = reader.ReadInt();
    247. }
    248. }
    249. public class Vanilla : Item
    250. {
    251. public override int LabelNumber { get { return 1080009; } } // Vanilla
    252. public override double DefaultWeight { get { return 1.0; } }
    253. [Constructable]
    254. public Vanilla()
    255. : this( 1 )
    256. {
    257. }
    258. [Constructable]
    259. public Vanilla( int amount )
    260. : base( 0xE2A )
    261. {
    262. Hue = 0x462;
    263. Stackable = true;
    264. Amount = amount;
    265. }
    266. public Vanilla( Serial serial )
    267. : base( serial )
    268. {
    269. }
    270. public override void Serialize( GenericWriter writer )
    271. {
    272. base.Serialize( writer );
    273. writer.Write( (int) 0 ); // version
    274. }
    275. public override void Deserialize( GenericReader reader )
    276. {
    277. base.Deserialize( reader );
    278. int version = reader.ReadInt();
    279. }
    280. }
    281. public class CocoaPulp : Item
    282. {
    283. public override int LabelNumber { get { return 1080530; } } // cocoa pulp
    284. public override double DefaultWeight { get { return 1.0; } }
    285. [Constructable]
    286. public CocoaPulp()
    287. : this( 1 )
    288. {
    289. }
    290. [Constructable]
    291. public CocoaPulp( int amount )
    292. : base( 0xF7C )
    293. {
    294. Hue = 0x219;
    295. Stackable = true;
    296. Amount = amount;
    297. }
    298. public CocoaPulp( Serial serial )
    299. : base( serial )
    300. {
    301. }
    302. public override void Serialize( GenericWriter writer )
    303. {
    304. base.Serialize( writer );
    305. writer.Write( (int) 0 ); // version
    306. }
    307. public override void Deserialize( GenericReader reader )
    308. {
    309. base.Deserialize( reader );
    310. int version = reader.ReadInt();
    311. }
    312. }
    313. }
     

    Attached Files:

    #1 tass23, Sep 10, 2013
    Last edited: Sep 11, 2013
    • Like Like x 1
  2. sec_goat
    Offline

    sec_goat Member

    Joined:
    Aug 26, 2013
    Messages:
    110
    Likes Received:
    14
    Well sir it appears you have been quite the busy beaver! I am going to go ahead and sift through you posts and try to incorporate your fixes into the ServUO core.
    Thanks a lot for all your help!
     
    #2 sec_goat, Sep 12, 2013
    Last edited: Sep 12, 2013
  3. tass23
    Offline

    Moderator

    Joined:
    Aug 28, 2013
    Messages:
    1,010
    Likes Received:
    131
    :) I noticed that even adding the hue under the base class, the damn chocolate still shows up as green....*shrugs* It has to be because the crafting system is only using the graphic and it won't matter unless we use a different graphic that's already "brown".
     
  4. sec_goat
    Offline

    sec_goat Member

    Joined:
    Aug 26, 2013
    Messages:
    110
    Likes Received:
    14
    @tass23 what client version are you using? I am on 7.0.27 and the graphics and colors actually turn out fine for me: three colors white, brown and dark brown. Something must change at some point in time in the client that fixes the graphics issue, or that broke it depending on what version you are on ;)
     
  5. tass23
    Offline

    Moderator

    Joined:
    Aug 28, 2013
    Messages:
    1,010
    Likes Received:
    131
    I'm using 7.0.12.1. Yeah, the chocolate turns out fine when I craft it, I'm talking about the preview inside the crafting window that is green. Graphics in the crafting windows are exactly what we see when we open Fiddler and look at Items. To my knowledge, that has always been the case because the crafting window doesn't read hue when it displays a preview.
     

    Attached Files:

  6. sec_goat
    Offline

    sec_goat Member

    Joined:
    Aug 26, 2013
    Messages:
    110
    Likes Received:
    14
    Wierd thing is I didn't even try to craft, I just looked at the crafting menu:
    All three have the proper hues for me but white chocolate was the easiest to see:

    ai.imgur.com_bFgFros.png
     

    Attached Files:

  7. tass23
    Offline

    Moderator

    Joined:
    Aug 28, 2013
    Messages:
    1,010
    Likes Received:
    131
    Heh, must be a crafting system change I don't have then. Well glad it works! lol
     
  8. sec_goat
    Offline

    sec_goat Member

    Joined:
    Aug 26, 2013
    Messages:
    110
    Likes Received:
    14
    I think you still have a point with chocolate inheriting from candy cane. It seems like it could be taken a step further and create a baseCandy class that has the timers etc and canycane / chocolate inherit from that.
     
  9. tass23
    Offline

    Moderator

    Joined:
    Aug 28, 2013
    Messages:
    1,010
    Likes Received:
    131
    Yeah. Halloween candy has timers as well. I don't know what happens on OSI when you eat too much candy anymore, but it used to make you sick to your stomach and you'd "throw up".
     
  10. Milva
    Offline

    Admin Moderator

    Joined:
    Mar 3, 2013
    Messages:
    3,430
    Likes Received:
    385
    Gesh you would think a bit larger graphic would be used instead of an emerald :) There are so many graphics which would be a bit larger and look more like chocolate
     
  11. tass23
    Offline

    Moderator

    Joined:
    Aug 28, 2013
    Messages:
    1,010
    Likes Received:
    131
    Yeah. Gotta love Mythic's seeming "last minute" decisions.