public void CraftItem(CraftItem item) { int num = m_CraftSystem.CanCraft(m_From, m_Tool, item.ItemType); if (num > 0) { m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num)); } else { Type type = null; CraftContext context = m_CraftSystem.GetContext(m_From); if (context != null) { CraftSubResCol res = (item.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes); int resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex); if (resIndex >= 0 && resIndex < res.Count) { type = res.GetAt(resIndex).ItemType; } } m_CraftSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item); } }
public void CreateResList(bool opt, Mobile from) { CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes); for (int i = 0; i < res.Count; ++i) { int index = i % 10; CraftSubRes subResource = res.GetAt(i); if (index == 0) { if (i > 0) { AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1); } AddPage((i / 10) + 1); if (i > 0) { AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10); } CraftContext context = m_CraftSystem.GetContext(m_From); AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0); AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false); } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(subResource.ItemType, true); for (int j = 0; j < items.Length; ++j) { resourceCount += items[j].Amount; } } AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0); if (subResource.NameNumber > 0) { AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false); } else { AddLabel(255, 60 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount)); } } }
public static void BeginTarget(Mobile from, CraftSystem craftSystem, BaseTool tool) { CraftContext context = craftSystem.GetContext(from); if (context == null) { return; } int lastRes = context.LastResourceIndex; CraftSubResCol subRes = craftSystem.CraftSubRes; if (lastRes >= 0 && lastRes < subRes.Count) { CraftSubRes res = subRes.GetAt(lastRes); if (from.Skills[craftSystem.MainSkill].Value < res.RequiredSkill) { from.SendGump(new CraftGump(from, craftSystem, tool, res.Message)); } else { CraftResource resource = CraftResources.GetFromType(res.ItemType); if (resource != CraftResource.None) { from.Target = new InternalTarget(craftSystem, tool, res.ItemType, resource); from.SendLocalizedMessage(1061004); // Target an item to enhance with the properties of your selected material. } else { from.SendGump(new CraftGump(from, craftSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties. } } } else { from.SendGump(new CraftGump(from, craftSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties. } }
public override void OnResponse(NetState sender, RelayInfo info) { // Back Button if (info.ButtonID == 0) { CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null); m_From.SendGump(craftGump); } else // Make Button { int num = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType); if (num > 0) { m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num)); } else { Type type = null; CraftContext context = m_CraftSystem.GetContext(m_From); if (context != null) { CraftSubResCol res = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes); int resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex); if (resIndex > -1) { type = res.GetAt(resIndex).ItemType; } } m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem); } } }
public void DrawResource() { bool retainedColor = false; CraftContext context = m_CraftSystem.GetContext(m_From); CraftSubResCol res = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes); int resIndex = -1; if (context != null) { resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex); } bool cropScroll = (m_CraftItem.Resources.Count > 1) && m_CraftItem.Resources.GetAt(m_CraftItem.Resources.Count - 1).ItemType == typeofBlankScroll && typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType); for (int i = 0; i < m_CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++) { Type type; string nameString; int nameNumber; CraftRes craftResource = m_CraftItem.Resources.GetAt(i); type = craftResource.ItemType; nameString = craftResource.NameString; nameNumber = craftResource.NameNumber; // Resource Mutation if (type == res.ResType && resIndex > -1) { CraftSubRes subResource = res.GetAt(resIndex); type = subResource.ItemType; nameString = subResource.NameString; nameNumber = subResource.GenericNameNumber; if (nameNumber <= 0) { nameNumber = subResource.NameNumber; } } // ****************** if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type)) { retainedColor = true; AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044152, LabelColor, false, false); // * The item retains the color of this material AddLabel(500, 219 + (i * 20), LabelHue, "*"); } if (nameNumber > 0) { AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false); } else { AddLabel(170, 219 + (i * 20), LabelHue, nameString); } AddLabel(430, 219 + (i * 20), LabelHue, craftResource.Amount.ToString()); } if (m_CraftItem.NameNumber == 1041267) // runebook { AddHtmlLocalized(170, 219 + (m_CraftItem.Resources.Count * 20), 310, 18, 1044447, LabelColor, false, false); AddLabel(430, 219 + (m_CraftItem.Resources.Count * 20), LabelHue, "1"); } if (cropScroll) { AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044379, LabelColor, false, false); // Inscribing scrolls also requires a blank scroll and mana. } }
public void DrawSkill() { for (int i = 0; i < m_CraftItem.Skills.Count; i++) { CraftSkill skill = m_CraftItem.Skills.GetAt(i); double minSkill = skill.MinSkill, maxSkill = skill.MaxSkill; if (minSkill < 0) { minSkill = 0; } AddHtmlLocalized(170, 132 + (i * 20), 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor, false, false); AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill)); } 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 = 0.0; } else if (chance > 1.0) { chance = 1.0; } AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false); // Success Chance: AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100)); if (m_ShowExceptionalChance) { if (excepChance < 0.0) { excepChance = 0.0; } else if (excepChance > 1.0) { excepChance = 1.0; } AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false); // Exceptional Chance: AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100)); } }