public void DrawChances() { CraftSubResCol res = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes); int resIndex = -1; CraftContext context = m_CraftSystem.GetContext(m_From); if (context != null) { resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex); } bool allRequiredSkills = true; double chance = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills); double excepChance = m_CraftItem.GetExceptionalChance(m_CraftSystem, chance, m_From); if (chance > 0.0) { chance += m_CraftItem.GetTalismanBonus(m_From, m_CraftSystem); } if (chance < 0.0) { chance = 0.0; } else if (chance > 1.0) { chance = 1.0; } if (excepChance < 0.0) { excepChance = 0.0; } else if (excepChance > 1.0) { excepChance = 1.0; } AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false); // Success Chance: AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100).Replace(",", ".")); if (m_ShowExceptionalChance) { AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false); // Exceptional Chance: AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100).Replace(",", ".")); } }
public static void DoCraft( Mobile from, CraftSystem system, Type typeRes, BaseTool tool, CraftItem craftItem, PlantPigment pigments ) { CraftContext context = system.GetContext( from ); if ( context != null ) context.OnMade( craftItem ); bool allRequiredSkills = true; double chance = craftItem.GetSuccessChance( from, typeRes, system, true, ref allRequiredSkills ); if ( chance > 0.0 ) chance += craftItem.GetTalismanBonus( from, system ); if ( allRequiredSkills ) { pigments.Consume(); if ( chance < Utility.RandomDouble() ) { from.SendGump( new CraftGump( from, system, tool, 1044043 ) ); // You failed to create the item, and some of your materials are lost. } else { from.Backpack.ConsumeTotal( typeof( ColorFixative ), 1 ); bool toolBroken = false; tool.UsesRemaining--; if ( tool.UsesRemaining < 1 ) toolBroken = true; if ( toolBroken ) { tool.Delete(); from.SendLocalizedMessage( 1044038 ); // You have worn out your tool! from.SendLocalizedMessage( 1044154 ); // You create the item. } else { // You create the item. from.SendGump( new CraftGump( from, system, tool, 1044154 ) ); } from.AddToBackpack( new NaturalDye( pigments.PlantHue ) ); } } else { // You don't have the required skills to attempt this item. from.SendGump( new CraftGump( from, system, tool, 1044153 ) ); } }