public GetContext ( Mobile m ) : CraftContext | ||
m | Mobile | |
return | CraftContext |
public AutoCraftTimer(Mobile from, CraftSystem system, CraftItem item, BaseTool tool, int amount, TimeSpan delay, TimeSpan interval) : base(delay, interval) { m_From = from; m_CraftSystem = system; m_CraftItem = item; m_Tool = tool; m_Amount = amount; m_Ticks = 0; m_Success = 0; 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) m_TypeRes = res.GetAt(resIndex).ItemType; } m_AutoCraftTable[from] = this; this.Start(); }
public static void BeginTarget( Mobile from, CraftSystem craftSystem, BaseTool tool ) { CraftContext context = craftSystem.GetContext( from ); PlayerMobile user = from as PlayerMobile; 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 ); if ( user.NextEnhanceSuccess ) { from.SendLocalizedMessage( 1149869, "100" ); // Target an item to enhance with the properties of your selected material (Success Rate: ~1_VAL~%). } else { 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 virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, IBaseTool tool, CraftItem craftItem, int resHue ) { Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Resources.GetAt( 0 ).ItemType; CraftResource resource = CraftResources.GetFromType( resourceType ); CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; else if ( resource == CraftResource.None ) Hue = resHue; else Hue = CraftResources.GetHue( resource ); return 1; }
protected override void OnTarget(Mobile from, object targeted) { int number; if (m_CraftSystem is DefTinkering) { if (targeted is Golem) { Golem g = (Golem)targeted; int damage = g.HitsMax - g.Hits; if (g.IsDeadBondedPet) { if (from.Skills[SkillName.Tinkering].Value > 79.9) { if (!g.Map.CanFit(g.Location, 16, false, false)) { number = 501042; // Target can not be resurrected at that location. } else { double chance = ((from.Skills[SkillName.Tinkering].Value - 68.0) / 50.0); if (chance > Utility.RandomDouble()) { Mobile master = g.ControlMaster; if (master != null && master.InRange(g, 3)) { number = 503255; // You are able to resurrect the creature. master.SendGump(new PetResurrectGump(from, g)); } else { number = 1049670; // The pet's owner must be nearby to attempt resurrection. } } else { number = 503256; // You fail to resurrect the creature. } } } else { number = 503256; // You fail to resurrect the creature. } } else if (damage <= 0) { number = 500423; // That is already in full repair. } else { double skillValue = from.Skills[SkillName.Tinkering].Value; if (skillValue < 60.0) { number = 1044153; // You don't have the required skills to attempt this item. } else if (!from.CanBeginAction(typeof(Golem))) { number = 501789; // You must wait before trying again. } else { if (damage > (int)(skillValue * 0.3)) { damage = (int)(skillValue * 0.3); //max 33 } damage += 30; if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0)) { damage /= 2; } Container pack = from.Backpack; if (pack != null) { int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5); if (v > 0) { g.Hits += (v * 5 + (int)(from.Skills[SkillName.Blacksmith].Value / 5)); //max 36.8 w/o ancient hammer g.Hits += (int)(from.Skills[SkillName.Tailoring].Value / 5); //max24 g.Hits += (int)(from.Skills[SkillName.ArmsLore].Value / 5); //max24 number = 1044279; // You repair the item. from.BeginAction(typeof(Golem)); Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerStateCallback(EndGolemRepair), from); } else { number = 1044037; // You do not have sufficient metal to make that. } } else { number = 1044037; // You do not have sufficient metal to make that. } } } } else { number = 500426; // You can't repair that. } } else if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null) { number = 1044277; // That item cannot be repaired. } else if (!weapon.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (weapon.MaxHitPoints <= toWeaken) { number = 500424; // You destroyed the item. m_CraftSystem.PlayCraftEffect(from); weapon.Delete(); } else if (from.CheckSkill(skill, -285.0, 100.0)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.MaxHitPoints -= toWeaken; weapon.HitPoints = weapon.MaxHitPoints; } else { number = 1044280; // You fail to repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.MaxHitPoints -= toWeaken; weapon.HitPoints -= toWeaken; } if (weapon.MaxHitPoints <= toWeaken) { from.SendLocalizedMessage(1044278); // That item has been repaired many times, and will break if repairs are attempted again. } } else if (targeted is BaseArmor) { BaseArmor armor = (BaseArmor)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null) { number = 1044277; // That item cannot be repaired. } else if (!armor.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (armor.MaxHitPoints <= toWeaken) { number = 500424; // You destroyed the item. m_CraftSystem.PlayCraftEffect(from); armor.Delete(); } else if (from.CheckSkill(skill, -285.0, 100.0)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); armor.MaxHitPoints -= toWeaken; armor.HitPoints = armor.MaxHitPoints; } else { number = 1044280; // You fail to repair the item. m_CraftSystem.PlayCraftEffect(from); armor.MaxHitPoints -= toWeaken; armor.HitPoints -= toWeaken; } if (armor.MaxHitPoints <= toWeaken) { from.SendLocalizedMessage(1044278); // That item has been repaired many times, and will break if repairs are attempted again. } } else if (targeted is Item) { number = 1044277; // That item cannot be repaired. } else { number = 500426; // You can't repair that. } CraftContext context = m_CraftSystem.GetContext(from); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number)); }
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Quality = (ArmorQuality)quality; if ( makersMark ) Crafter = from; Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Ressources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); PlayerConstructed = true; CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; if ( quality == 2 ) DistributeBonuses( (tool is BaseRunicTool ? 6 : 14) ); if ( Core.AOS && tool is BaseRunicTool ) ((BaseRunicTool)tool).ApplyAttributesTo( this ); return quality; }
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Ressources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; if ( 1 < craftItem.Ressources.Count ) { resourceType = craftItem.Ressources.GetAt( 1 ).ItemType; if ( resourceType == typeof( StarSapphire ) ) GemType = GemType.StarSapphire; else if ( resourceType == typeof( Emerald ) ) GemType = GemType.Emerald; else if ( resourceType == typeof( Sapphire ) ) GemType = GemType.Sapphire; else if ( resourceType == typeof( Ruby ) ) GemType = GemType.Ruby; else if ( resourceType == typeof( Citrine ) ) GemType = GemType.Citrine; else if ( resourceType == typeof( Amethyst ) ) GemType = GemType.Amethyst; else if ( resourceType == typeof( Tourmaline ) ) GemType = GemType.Tourmaline; else if ( resourceType == typeof( Amber ) ) GemType = GemType.Amber; else if ( resourceType == typeof( Diamond ) ) GemType = GemType.Diamond; } return 1; }
private CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page ) : base(40, 40) { m_From = from; m_CraftSystem = craftSystem; m_Tool = tool; m_Page = page; CraftContext context = craftSystem.GetContext( from ); from.CloseGump( typeof( CraftGump ) ); from.CloseGump( typeof( CraftGumpItem ) ); AddPage( 0 ); AddBackground( 0, 0, 530, 437, 5054 ); AddImageTiled( 10, 10, 510, 22, 2624 ); AddImageTiled( 10, 292, 150, 45, 2624 ); AddImageTiled( 165, 292, 355, 45, 2624 ); AddImageTiled( 10, 342, 510, 85, 2624 ); AddImageTiled( 10, 37, 200, 250, 2624 ); AddImageTiled( 215, 37, 305, 250, 2624 ); AddAlphaRegion( 10, 10, 510, 417 ); if ( craftSystem.GumpTitleNumber > 0 ) AddHtmlLocalized( 10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false ); else AddHtml( 10, 12, 510, 20, craftSystem.GumpTitleString, false, false ); AddHtmlLocalized( 10, 37, 200, 22, 1044010, LabelColor, false, false ); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized( 215, 37, 305, 22, 1044011, LabelColor, false, false ); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized( 10, 302, 150, 25, 1044012, LabelColor, false, false ); // <CENTER>NOTICES</CENTER> AddButton( 15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 50, 405, 150, 18, 1011441, LabelColor, false, false ); // EXIT AddButton( 270, 402, 4005, 4007, GetButtonID( 6, 2 ), GumpButtonType.Reply, 0 ); AddHtmlLocalized( 305, 405, 150, 18, 1044013, LabelColor, false, false ); // MAKE LAST // Mark option if ( craftSystem.MarkOption ) { AddButton( 270, 362, 4005, 4007, GetButtonID( 6, 6 ), GumpButtonType.Reply, 0 ); AddHtmlLocalized( 305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false ); // MARK ITEM } // **************************************** // Resmelt option if ( craftSystem.Resmelt ) { AddButton( 15, 342, 4005, 4007, GetButtonID( 6, 1 ), GumpButtonType.Reply, 0 ); AddHtmlLocalized( 50, 345, 150, 18, 1044259, LabelColor, false, false ); // SMELT ITEM } // **************************************** // Repair option if ( craftSystem.Repair ) { AddButton( 270, 342, 4005, 4007, GetButtonID( 6, 5 ), GumpButtonType.Reply, 0 ); AddHtmlLocalized( 305, 345, 150, 18, 1044260, LabelColor, false, false ); // REPAIR ITEM } // **************************************** // Enhance option if ( craftSystem.CanEnhance ) { AddButton( 270, 382, 4005, 4007, GetButtonID( 6, 8 ), GumpButtonType.Reply, 0 ); AddHtmlLocalized( 305, 385, 150, 18, 1061001, LabelColor, false, false ); // ENHANCE ITEM } // **************************************** if ( notice is int && (int)notice > 0 ) AddHtmlLocalized( 170, 295, 350, 40, (int)notice, LabelColor, false, false ); else if ( notice is string ) AddHtml( 170, 295, 350, 40, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice ), false, false ); // If the system has more than one resource if ( craftSystem.CraftSubRes.Init ) { string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int resIndex = ( context == null ? -1 : context.LastResourceIndex ); Type resourceType = craftSystem.CraftSubRes.ResType; if ( resIndex > -1 ) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt( resIndex ); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if ( from.Backpack != null ) { Item[] items = from.Backpack.FindItemsByType( resourceType, true ); for ( int i = 0; i < items.Length; ++i ) resourceCount += items[i].Amount; } AddButton( 15, 362, 4005, 4007, GetButtonID( 6, 0 ), GumpButtonType.Reply, 0 ); if ( nameNumber > 0 ) AddHtmlLocalized( 50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false ); else AddLabel( 50, 362, LabelHue, String.Format( "{0} ({1} Available)", nameString, resourceCount ) ); } // **************************************** // For dragon scales if ( craftSystem.CraftSubRes2.Init ) { string nameString = craftSystem.CraftSubRes2.NameString; int nameNumber = craftSystem.CraftSubRes2.NameNumber; int resIndex = ( context == null ? -1 : context.LastResourceIndex2 ); Type resourceType = craftSystem.CraftSubRes.ResType; if ( resIndex > -1 ) { CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt( resIndex ); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if ( from.Backpack != null ) { Item[] items = from.Backpack.FindItemsByType( resourceType, true ); for ( int i = 0; i < items.Length; ++i ) resourceCount += items[i].Amount; } AddButton( 15, 382, 4005, 4007, GetButtonID( 6, 7 ), GumpButtonType.Reply, 0 ); if ( nameNumber > 0 ) AddHtmlLocalized( 50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false ); else AddLabel( 50, 385, LabelHue, String.Format( "{0} ({1} Available)", nameString, resourceCount ) ); } // **************************************** CreateGroupList(); if ( page == CraftPage.PickResource ) CreateResList( false ); else if ( page == CraftPage.PickResource2 ) CreateResList( true ); else if ( context != null && context.LastGroupIndex > -1 ) CreateItemList( context.LastGroupIndex ); }
public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { this.Quality = (ItemQuality)quality; if (makersMark) this.Crafter = from; Type resourceType = typeRes; if (resourceType == null) resourceType = craftItem.Resources.GetAt(0).ItemType; this.Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) this.Hue = 0; return quality; }
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40) { m_From = from; m_CraftSystem = craftSystem; m_Tool = tool; m_Page = page; CraftContext context = craftSystem.GetContext(from); from.CloseGump(typeof(CraftGump)); from.CloseGump(typeof(CraftGumpItem)); AddPage(0); AddBackground(0, 0, 830, 537, 5054); AddImageTiled(10, 10, 810, 22, 2624); AddImageTiled(10, 37, 200, 350, 2624); AddImageTiled(215, 37, 605, 350, 2624); AddImageTiled(10, 392, 150, 45, 2624); AddImageTiled(165, 392, 655, 45, 2624); AddImageTiled(10, 442, 810, 85, 2624); AddAlphaRegion(10, 10, 810, 517); if (craftSystem.GumpTitleNumber > 0) { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); } else { // AddHtml( 10, 12, 510, 20, craftSystem.GumpTitleString, false, false ); AddHtml(10, 12, 500, 20, "<h3><basefont color=#FFFFFF>" + craftSystem.GumpTitleString + "<basefont></h3>", false, false); } //AddHtmlLocalized( 10, 37, 200, 22, 1044010, LabelColor, false, false ); // <CENTER>CATEGORIES</CENTER> //AddHtmlLocalized( 215, 37, 305, 22, 1044011, LabelColor, false, false ); // <CENTER>SELECTIONS</CENTER> //AddHtmlLocalized( 10, 302, 150, 25, 1044012, LabelColor, false, false ); // <CENTER>NOTICES</CENTER> AddHtml(13, 37, 200, 20, "<h3><basefont color=#FFFFFF>Catégories<basefont></h3>", false, false); AddHtml(218, 37, 200, 20, "<h3><basefont color=#FFFFFF>Sélections<basefont></h3>", false, false); AddHtml(13, 402, 200, 20, "<h3><basefont color=#FFFFFF>Message<basefont></h3>", false, false); AddButton(15, 502, 4017, 4019, 0, GumpButtonType.Reply, 0); //AddHtmlLocalized( 50, 405, 150, 18, 1011441, LabelColor, false, false ); // EXIT AddHtml(50, 502, 200, 20, "<h3><basefont color=#FFFFFF>Quitter<basefont></h3>", false, false); AddButton(650, 482, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); //AddHtmlLocalized( 305, 405, 150, 18, 1044013, LabelColor, false, false ); // MAKE LAST AddHtml(685, 485, 200, 20, "<h3><basefont color=#FFFFFF>Refaire<basefont></h3>", false, false); // Mark option if (craftSystem.MarkOption) { AddButton(650, 462, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); //AddHtmlLocalized( 305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false ); // MARK ITEM if (context.MarkOption == CraftMarkOption.DoNotMark) { AddHtml(685, 465, 200, 20, "<h3><basefont color=#FFFFFF>Marquer<basefont></h3>", false, false); } else { AddHtml(685, 465, 200, 20, "<h3><basefont color=#FFFFFF>Ne Pas Marquer<basefont></h3>", false, false); } } // **************************************** // Resmelt option if (craftSystem.Resmelt) { AddButton(415, 442, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); //AddHtmlLocalized( 50, 345, 150, 18, 1044259, LabelColor, false, false ); // SMELT ITEM AddHtml(450, 445, 150, 20, "<h3><basefont color=#FFFFFF>Fondre<basefont></h3>", false, false); } // **************************************** // Repair option if (craftSystem.Repair) { AddButton(650, 442, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); //AddHtmlLocalized( 305, 345, 150, 18, 1044260, LabelColor, false, false ); // REPAIR ITEM AddHtml(685, 445, 200, 20, "<h3><basefont color=#FFFFFF>Réparer<basefont></h3>", false, false); } // **************************************** // Enhance option //if ( craftSystem.CanEnhance ) //{ // AddButton( 270, 402, 4005, 4007, GetButtonID( 6, 8 ), GumpButtonType.Reply, 0 ); // AddHtmlLocalized( 305, 405, 150, 18, 1061001, LabelColor, false, false ); // ENHANCE ITEM //} // **************************************** if (notice is int && (int)notice > 0) { AddHtmlLocalized(170, 395, 350, 40, (int)notice, LabelColor, false, false); } else if (notice is string) { // AddHtml( 170, 295, 350, 40, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice ), false, false ); AddHtml(170, 345, 350, 40, "<h3><basefont color=#FFFFFF>" + notice + "<basefont></h3>", false, false); } // If the system has more than one resource if (craftSystem.CraftSubRes.Init) { string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex); Type resourceType = craftSystem.CraftSubRes.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } AddButton(15, 442, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 445, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { //AddLabel( 50, 362, LabelHue, String.Format( "{0} ({1} Available)", nameString, resourceCount ) ); AddHtml(50, 442, 450, 40, "<h3><basefont color=#FFFFFF>" + nameString + " " + resourceCount + "<basefont></h3>", false, false); } } // **************************************** // If the system has more than one resource type if (craftSystem.CraftSubRes2.Init) { string nameString = craftSystem.CraftSubRes2.NameString; int nameNumber = craftSystem.CraftSubRes2.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex2); Type resourceType = craftSystem.CraftSubRes2.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } AddButton(15, 462, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 465, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { //AddLabel( 50, 385, LabelHue, String.Format( "{0} ({1} Available)", nameString, resourceCount ) ); AddHtml(50, 462, 450, 40, "<h3><basefont color=#FFFFFF>" + nameString + " " + resourceCount + "<basefont></h3>", false, false); } } // **************************************** CreateGroupList(); if (page == CraftPage.PickResource) { CreateResList(false, from); } else if (page == CraftPage.PickResource2) { CreateResList(true, from); } else if (context != null && context.LastGroupIndex > -1) { CreateItemList(context.LastGroupIndex); } }
public override void OnResponse(GameClient sender, RelayInfo info) { if (m_MakeTimer != null) { m_MakeTimer.Stop(); } if (info.ButtonID <= 0) { return; // Canceled } int type = info.ButtonID / 1000; int index = info.ButtonID % 1000; CraftSystem system = m_CraftSystem; CraftGroupCol groups = system.CraftGroups; CraftContext context = system.GetContext(m_From); switch (type) { case 0: // Create Item { if (context == null) { break; } CraftItem item = system.CraftItems.GetAt(index); if (item != null) { CraftItem(item); } break; } case 1: // Item Details && Make Last { if (context == null) { break; } switch (index) { case 999: // Make Last { CraftItem item = context.LastMade; if (item != null) { CraftItem(item); } else { // You haven't made anything yet. m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page)); } break; } default: // Item Details { CraftItem item = system.CraftItems.GetAt(index); if (item != null) { m_From.SendGump(new CraftGumpItem(m_From, system, item, m_Tool)); } break; } } break; } case 2: // Enhance Item { if (system.CanEnhance) { Enhance.BeginTarget(m_From, system, m_Tool); } break; } case 3: // Toggle use resource hue { if (context == null) { break; } context.DoNotColor = !context.DoNotColor; m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } case 4: // 2nd resource selected { if (index >= 0 && index < system.CraftSubRes2.Count) { CraftSubRes res = system.CraftSubRes2.GetAt(index); if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex2 = index; } m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } } break; } case 5: // Resource selected { if (index >= 0 && index < system.CraftSubRes.Count) { CraftSubRes res = system.CraftSubRes.GetAt(index); if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex = index; } m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } } break; } case 6: // Craft system features { if (context == null) { break; } switch (index) { case 0: // Toggle mark option { if (!system.MarkOption) { break; } switch (context.MarkOption) { case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break; case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break; case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break; } m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } case 1: // Toggle mark option (KR Version) { if (!system.MarkOption) { break; } switch (context.MarkOption) { case CraftMarkOption.PromptForMark: case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break; case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.MarkItem; break; } m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } case 2: // Toggle quest item option { context.QuestItem = !context.QuestItem; m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } case 3: // Make last { context.MakeLast = !context.MakeLast; m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } case 4: // Reset Make number { context.Total = 1; m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } case 5: // Make Max { if (!context.MakeMax) { context.Total = 9999; } else { context.Total = 1; context.Making = null; } m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } default: // Make number { int amount = index - 100; Utility.FixMinMax(ref amount, 1, 100); context.Total = amount; m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } } break; } case 7: // Smelt item { if (system.Resmelt) { Resmelt.Do(m_From, system, m_Tool); } break; } case 8: // Repair item { if (system.Repair) { Repair.Do(m_From, system, m_Tool); } break; } case 9: // Show group && Last 10 { if (context == null) { break; } switch (index) { case 0: // Alter Item (Gargoyle) { if (system.Alter) { Alter.Do(m_From, system, m_Tool); } break; } case 99: // Last 10 { context.LastGroupIndex = 501; m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); break; } default: // Show group { index--; if (index >= 0 && index < groups.Count) { context.LastGroupIndex = index; m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } break; } } break; } case 12: // Cancel Make { context.Total = 1; m_From.SendLocalizedMessage(501806); // Request cancelled. m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } } }
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(50, 50) { m_From = from; m_CraftSystem = craftSystem; m_Tool = tool; m_Page = page; CraftContext context = craftSystem.GetContext(from); from.CloseGump(typeof(CraftGump)); from.CloseGump(typeof(CraftGumpItem)); AddPage((int)CraftPage.None); AddBackground(0, 0, 530, 497, 5054); AddImageTiled(10, 10, 510, 22, 2624); AddImageTiled(10, 292, 150, 45, 2624); AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 145, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 497); if (craftSystem.GumpTitleNumber > 0) { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, FontColor, false, false); } else { AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); } AddHtmlLocalized(10, 302, 150, 25, 1044012, FontColor, false, false); // <CENTER>NOTICES</CENTER> AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(50, 445, 150, 18, 1011441, FontColor, false, false); // EXIT AddButton(270, 442, 4005, 4007, 1999, GumpButtonType.Reply, 0); AddHtmlLocalized(305, 445, 150, 18, 1044013, FontColor, false, false); // MAKE LAST AddButton(115, 442, 4017, 4019, 12000, GumpButtonType.Reply, 0); AddHtmlLocalized(150, 445, 150, 18, 1112698, FontColor, false, false); // CANCEL MAKE // Resmelt option if (craftSystem.Resmelt) { AddButton(15, 342, 4005, 4007, 7000, GumpButtonType.Reply, 0); AddHtmlLocalized(50, 345, 150, 18, 1044259, FontColor, false, false); // SMELT ITEM } // **************************************** // Repair option if (craftSystem.Repair) { AddButton(270, 342, 4005, 4007, 8000, GumpButtonType.Reply, 0); AddHtmlLocalized(305, 345, 150, 18, 1044260, FontColor, false, false); // REPAIR ITEM } // **************************************** // Alter option if (craftSystem.Alter) { AddButton(270, 402, 4005, 4007, 9000, GumpButtonType.Reply, 0); AddHtmlLocalized(305, 405, 300, 18, 1094726, FontColor, false, false); // ALTER ITEM (GARGOYLE) } // **************************************** AddHtmlLocalized(10, 37, 200, 22, 1044010, FontColor, false, false); // <CENTER>CATEGORIES</CENTER> CreateGroupList(); if (craftSystem.CraftSubRes.Init) { CreateResList(false); } if (craftSystem.CraftSubRes2.Init) { CreateResList(true); } AddPage(0); // Enhance option if (craftSystem.CanEnhance) { AddButton(270, 382, 4005, 4007, 2000, GumpButtonType.Reply, 0); AddHtmlLocalized(305, 385, 150, 18, 1061001, FontColor, false, false); // ENHANCE ITEM } // **************************************** if (craftSystem.CraftSubRes2.Init) { AddButton(15, 382, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 10); } if (craftSystem.CraftSubRes.Init) { AddButton(15, 362, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 9); } if (context != null && context.LastGroupIndex > -1) { CreateItemList(context.LastGroupIndex); } // If the system has more than one resource if (craftSystem.CraftSubRes.Init) { AddPage(0); string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int amount; int resIndex = (context == null ? -1 : context.LastResourceIndex); if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; amount = GetAmount(subResource.ItemType); } else { amount = GetAmount(craftSystem.CraftSubRes.ResType); } if (nameNumber > 0) { AddHtmlLocalized(50, 365, 170, 18, nameNumber, amount.ToString(), LabelColor, false, false); AddKRHtmlLocalized(50, 365, 170, 18, nameNumber, LabelColor, false, false); } else { AddLabel(50, 362, LabelHue, nameString); } AddPage(9); AddButton(220, 260, 4005, 4007, 3000, GumpButtonType.Reply, 0); AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false); } // **************************************** // For dragon scales if (craftSystem.CraftSubRes2.Init) { AddPage(0); string nameString = craftSystem.CraftSubRes2.NameString; int nameNumber = craftSystem.CraftSubRes2.NameNumber; int amount; int resIndex = (context == null ? -1 : context.LastResourceIndex2); if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; amount = GetAmount(subResource.ItemType); } else { amount = GetAmount(craftSystem.CraftSubRes2.ResType); } if (nameNumber > 0) { AddHtmlLocalized(50, 385, 150, 18, nameNumber, amount.ToString(), LabelColor, false, false); AddKRHtmlLocalized(50, 385, 150, 18, nameNumber, LabelColor, false, false); } else { AddLabel(50, 385, LabelHue, nameString); } AddPage(10); AddButton(220, 260, 4005, 4007, 3001, GumpButtonType.Reply, 0); AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false); } // **************************************** // Notice if (notice is int && (int)notice > 0) { AddPage(0); AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false); } else if (notice is string) { AddPage(0); AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false); } // **************************************** // Mark option if (craftSystem.MarkOption) { AddPage(0); AddButton(270, 362, 4005, 4007, 6000, GumpButtonType.Reply, 0); AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM if (context != null && context.MarkOption == CraftMarkOption.MarkItem) { AddKRButton(0, 0, 0, 0, 6001, GumpButtonType.Page, 0); } } // **************************************** // Quest Item option bool questItem = (context != null && context.QuestItem); AddPage(0); AddButton(270, 422, 0xFA5, 0xFA7, 6002, GumpButtonType.Reply, 0); AddHtmlLocalized(305, 425, 150, 18, questItem ? 1112534 : 1112533, LabelColor, false, false); // **************************************** if (context != null) { if (context.MakeLast) { AddKRButton(0, 0, 0, 0, 6003, GumpButtonType.Page, 0); } if (context.MakeNumber) { AddKRButton(0, 0, 0, 0, context.Total + 6100, GumpButtonType.Page, 0); } if (context.MakeMax) { AddKRButton(0, 0, 0, 0, 6005, GumpButtonType.Page, 0); } } if (context != null) { if (context.Success) { context.Done++; } int done = 0, total = 1; done = context.Done; total = context.Total; AddHtmlLocalized(270, 465, 200, 18, 1079443, String.Format("{0}@{1}", done, total), FontColor, false, false); // ~1_DONE~/~2_TOTAL~ COMPLETED if (context.Making != null && context.Success) { m_MakeTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.25), new TimerCallback(DoMake)); } context.Success = false; } }
protected override void OnTarget(Mobile from, object targeted) { if (from == null) { return; } int num = m_CraftSystem.CanCraft(from, m_Tool, null); if (num > 0) { from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, num)); return; } RecycleResult result = RecycleResult.Invalid; string message = ""; CraftContext craftContext = m_CraftSystem.GetContext(from); if (craftContext == null) { return; } if (craftContext.RecycleOption == CraftRecycleOption.RecycleEverything && targeted == from && from.Backpack != null) { result = Recycle(from, from.Backpack); switch (result) { case RecycleResult.Invalid: message = "That cannot be recycled."; break; case RecycleResult.InvalidEntireBackpack: message = "No recyclable items were found in your backpack."; break; case RecycleResult.NoSkill: message = "You do not know how to recycle this material."; break; case RecycleResult.Success: message = "You recycle an item."; break; case RecycleResult.SuccessMultiple: message = "You recycle several items."; break; } from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message)); return; } Item item = targeted as Item; if (item == null) { return; } else { result = Recycle(from, item); } switch (result) { case RecycleResult.Invalid: message = "That cannot be recycled."; break; case RecycleResult.InvalidEntireBackpack: message = "No recyclable items were found in your backpack."; break; case RecycleResult.NoSkill: message = "You do not know how to recycle this material."; break; case RecycleResult.Success: message = "You recycle an item."; break; case RecycleResult.SuccessMultiple: message = "You recycle several items."; break; } from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message)); }
public void DrawSkill() { CraftSubResCol res = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes); int resIndex = -1; for (int i = 0; i < m_CraftItem.Skills.Count; i++) { CraftSkill skill = m_CraftItem.Skills.GetAt(i); double minSkill = m_CraftItem.ScaleWithRessource(skill.MinSkill, m_From, m_CraftSystem); if (minSkill < 0) { minSkill = 0; } AddHtml(170, 132 + (i * 20), 300, 20, "<h3><basefont color=#FFFFFF>" + skill.SkillToMake.ToString() + "<basefont></h3>", false, false); AddHtml(480, 132 + (i * 20), 300, 20, "<h3><basefont color=#FFFFFF>" + Convert.ToInt32(minSkill) + "%<basefont></h3>", false, false); } 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(chance, m_From, false); if (chance < 0.0) { chance = 0.0; } else if (chance > 1.0) { chance = 1.0; } try { int chan = Convert.ToInt32(chance * 100); AddHtml(170, 80, 300, 20, "<h3><basefont color=#FFFFFF>Chance de Succès :<basefont></h3>", false, false); AddHtml(480, 80, 300, 20, "<h3><basefont color=#FFFFFF>" + chan.ToString() + "%<basefont></h3>", false, false); } catch (OverflowException e) { Misc.ExceptionLogging.WriteLine(e, "La valeur convertie en int était {0} * 100. L'item était {1}", chance, m_CraftItem.ItemType.ToString()); } if (excepChance < 0.0) { excepChance = 0.0; } else if (excepChance > 1.0) { excepChance = 1.0; } try { int exept = Convert.ToInt32(excepChance * 100); AddHtml(170, 100, 300, 20, "<h3><basefont color=#FFFFFF>Chance d'Objet Exceptionel:<basefont></h3>", false, false); AddHtml(480, 100, 300, 20, "<h3><basefont color=#FFFFFF>" + exept.ToString() + "%<basefont></h3>", false, false); } catch (OverflowException e) { Misc.ExceptionLogging.WriteLine(e, "La valeur convertie en int était {0} * 100. The original chance value was : {1}. L'item était {2}", excepChance, chance, m_CraftItem.ItemType.ToString()); } }
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 % numitemsPerPage; CraftSubRes subResource = res.GetAt(i); if (index == 0) { if (i > 0) { AddButton(485, 320, 4005, 4007, 0, GumpButtonType.Page, (i / numitemsPerPage) + 1); } AddPage((i / numitemsPerPage) + 1); if (i > 0) { AddButton(455, 320, 4014, 4015, 0, GumpButtonType.Page, i / numitemsPerPage); } CraftContext context = m_CraftSystem.GetContext(m_From); AddButton(220, 320, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0); AddHtmlLocalized(255, 323, 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 { if (m_From.NetState.Version.Major <= 3) { AddHtml(255, 63 + (index * 20), 250, 18, String.Format("<BASEFONT COLOR=BLACK>{0}", subResource.NameString), false, false); } else { AddHtml(255, 63 + (index * 20), 250, 18, String.Format("<BASEFONT COLOR=WHITE>{0}", subResource.NameString), false, false); } //else // AddHtml(255, 63 + (index * 20), 250, 18, String.Format("{0} ({1})", subResource.NameString, resourceCount), false, false); } //AddLabel( 255, 60 + ( index * 20 ), LabelHue, String.Format( "{0} ({1})", subResource.NameString, resourceCount ) ); } }
private RecycleResult Recycle(Mobile from, Item item) { if (from == null || item == null || m_CraftSystem == null || m_Tool == null) { return(RecycleResult.Invalid); } CraftContext craftContext = m_CraftSystem.GetContext(from); if (craftContext == null) { return(RecycleResult.Invalid); } Type itemType = item.GetType(); CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor(itemType); if (craftItem == null || craftItem.Resources.Count == 0) { return(RecycleResult.Invalid); } Dictionary <Type, int> m_ValidRecipeResources = new Dictionary <Type, int>(); CraftResCol craftResourceCollection = craftItem.Resources; for (int a = 0; a < craftResourceCollection.Count; a++) { CraftRes craftResource = craftResourceCollection.GetAt(a); if (!IsRecycleResource(craftResource.ItemType)) { continue; } if (!m_ValidRecipeResources.ContainsKey(craftResource.ItemType)) { m_ValidRecipeResources.Add(craftResource.ItemType, craftResource.Amount); } } if (m_ValidRecipeResources.Count == 0) { return(RecycleResult.Invalid); } if (from.Backpack == null) { return(RecycleResult.Invalid); } else if (from.Backpack.Deleted) { return(RecycleResult.Invalid); } List <Item> m_Items = new List <Item>(); List <Item> m_ItemsToRecycle = new List <Item>(); Item[] m_MatchingItems = from.Backpack.FindItemsByType(itemType); for (int a = 0; a < m_MatchingItems.Length; a++) { Item targetItem = m_MatchingItems[a]; if (craftContext.RecycleOption == CraftRecycleOption.RecycleItem && targetItem == item) { m_ItemsToRecycle.Add(targetItem); continue; } if (craftContext.RecycleOption == CraftRecycleOption.RecycleAllNonExceptional && targetItem.Quality != Quality.Exceptional) { m_Items.Add(targetItem); continue; } if (craftContext.RecycleOption == CraftRecycleOption.RecycleAll) { m_ItemsToRecycle.Add(targetItem); continue; } } foreach (Item recycleItem in m_Items) { if (recycleItem.LootType != LootType.Regular) { continue; } if (recycleItem.PlayerClassCurrencyValue > 0) { continue; } if (recycleItem.QuestItem) { continue; } if (recycleItem.Nontransferable) { continue; } if (recycleItem.DonationItem) { continue; } if (recycleItem.DecorativeEquipment) { continue; } m_ItemsToRecycle.Add(recycleItem); } if (m_ItemsToRecycle.Count == 0) { return(RecycleResult.Invalid); } Queue m_Queue = new Queue(); foreach (Item recycleItem in m_ItemsToRecycle) { m_Queue.Enqueue(recycleItem); } int deletedCount = 0; List <int> m_RecycleSounds = new List <int>(); while (m_Queue.Count > 0) { Item recycleItem = (Item)m_Queue.Dequeue(); bool deleteItem = false; foreach (KeyValuePair <Type, int> pair in m_ValidRecipeResources) { Type resourceType = pair.Key; int totalResourceAmount = pair.Value * recycleItem.Amount; if (totalResourceAmount < 2) { continue; } //Ingot if (resourceType == typeof(IronIngot)) { if (!m_RecycleSounds.Contains(0x2A)) { m_RecycleSounds.Add(0x2A); } if (!m_RecycleSounds.Contains(0x240)) { m_RecycleSounds.Add(0x240); } if (recycleItem.Resource != CraftResource.Iron) { resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource); if (resourceType == null) { resourceType = typeof(IronIngot); } } } //Leather if (resourceType == typeof(Leather)) { if (!m_RecycleSounds.Contains(0x3E3)) { m_RecycleSounds.Add(0x3E3); } if (recycleItem.Resource != CraftResource.RegularLeather) { resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource); if (resourceType == null) { resourceType = typeof(Leather); } } } //Wood if (resourceType == typeof(Board)) { if (!m_RecycleSounds.Contains(0x23D)) { m_RecycleSounds.Add(0x23D); } if (recycleItem.Resource != CraftResource.RegularWood) { resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource); if (resourceType == null) { resourceType = typeof(Board); } } } Item newResource = (Item)Activator.CreateInstance(resourceType); if (newResource == null) { continue; } //Cloth if (resourceType == typeof(Cloth)) { if (!m_RecycleSounds.Contains(0x248)) { m_RecycleSounds.Add(0x248); } newResource.Hue = recycleItem.Hue; } deleteItem = true; deletedCount++; newResource.Amount = (int)(Math.Floor((double)totalResourceAmount / 2)); from.AddToBackpack(newResource); } int arcaneEssenceValue = recycleItem.GetArcaneEssenceValue(); if (arcaneEssenceValue > 0) { ArcaneEssence arcaneEssenceItem = new ArcaneEssence(arcaneEssenceValue); from.AddToBackpack(arcaneEssenceItem); } if (deleteItem) { recycleItem.Delete(); } } if (deletedCount > 0) { foreach (int sound in m_RecycleSounds) { from.PlaySound(sound); } return(RecycleResult.Success); } else { return(RecycleResult.Invalid); } }
public int GetPlantHueAmount(Mobile from, CraftSystem craftSystem, Container cont, Type[] types) { Item[] items = cont.FindItemsByType(types, true); CraftContext context = craftSystem.GetContext(from); int amount = 0; for (int i = 0; i < items.Length; ++i) { IPlantHue ph = items[i] as IPlantHue; IPigmentHue pigh = items[i] as IPigmentHue; if (context == null || (ph != null && ph.PlantHue != context.RequiredPlantHue)) continue; else if (context == null || (pigh != null && pigh.PigmentHue != context.RequiredPigmentHue)) continue; amount += items[i].Amount; } return amount; }
public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { this.Quality = (ClothingQuality)quality; if (makersMark) this.Crafter = from; #region Mondain's Legacy if (!craftItem.ForceNonExceptional) { if (this.DefaultResource != CraftResource.None) { Type resourceType = typeRes; if (resourceType == null) resourceType = craftItem.Resources.GetAt(0).ItemType; this.Resource = CraftResources.GetFromType(resourceType); } else { this.Hue = resHue; } } #endregion this.PlayerConstructed = true; CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) this.Hue = 0; return quality; }
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; } //Taran: Bad fix to check for boards in backpack when using carpenting //Needs to be fixed in a better way if (m_CraftSystem is DefCarpentry) { Item[] item; if (subResource.ItemType == typeof(Log)) { item = from.Backpack.FindItemsByType(typeof(Board), true); } else if (subResource.ItemType == typeof(OakLog)) { item = from.Backpack.FindItemsByType(typeof(OakBoard), true); } else if (subResource.ItemType == typeof(AshLog)) { item = from.Backpack.FindItemsByType(typeof(AshBoard), true); } else if (subResource.ItemType == typeof(YewLog)) { item = from.Backpack.FindItemsByType(typeof(YewBoard), true); } else if (subResource.ItemType == typeof(HeartwoodLog)) { item = from.Backpack.FindItemsByType(typeof(HeartwoodBoard), true); } else if (subResource.ItemType == typeof(BloodwoodLog)) { item = from.Backpack.FindItemsByType(typeof(BloodwoodBoard), true); } else if (subResource.ItemType == typeof(FrostwoodLog)) { item = from.Backpack.FindItemsByType(typeof(FrostwoodBoard), true); } else if (subResource.ItemType == typeof(MahoganyLog)) { item = from.Backpack.FindItemsByType(typeof(MahoganyBoard), true); } else if (subResource.ItemType == typeof(CedarLog)) { item = from.Backpack.FindItemsByType(typeof(CedarBoard), true); } else if (subResource.ItemType == typeof(WillowLog)) { item = from.Backpack.FindItemsByType(typeof(WillowBoard), true); } else if (subResource.ItemType == typeof(MystWoodLog)) { item = from.Backpack.FindItemsByType(typeof(MystWoodBoard), true); } else { item = from.Backpack.FindItemsByType(typeof(Board), true); } for (int j = 0; j < item.Length; ++j) { resourceCount += item[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 int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Quality = (FurnitureQuality)quality; if ( makersMark ) Crafter = from; Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Ressources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); PlayerConstructed = true; CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; return quality; }
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page, int resind) : base(40, 40) { from.CloseGump(typeof(CraftGump)); m_From = from; m_CraftSystem = craftSystem; m_Tool = tool; m_Page = page; m_LastResourceIndex = resind; CraftContext context = craftSystem.GetContext(from); if (resind > -1) { context.LastResourceIndex = m_LastResourceIndex; } from.CloseGump(typeof(CraftGump)); from.CloseGump(typeof(CraftGumpItem)); AddPage(0); AddBackground(0, 0, 530, 437, 5054); AddImageTiled(10, 10, 510, 22, 2624); AddImageTiled(10, 292, 150, 45, 2624); AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 85, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 417); if (craftSystem.GumpTitleNumber > 0) { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); } else { AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); } AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER> AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false); // EXIT AddButton(270, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST // Mark option if (craftSystem.MarkOption) { AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM } // **************************************** // Resmelt option if (craftSystem.Resmelt) { AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM } // **************************************** // Repair option if (craftSystem.Repair) { AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM } // **************************************** // Enhance option if (craftSystem.CanEnhance) { AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM } // **************************************** if (notice is int && (int)notice > 0) { AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false); } else if (notice is string) { AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false); } // If the system has more than one resource if (craftSystem.CraftSubRes.Init) { string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex); Type resourceType = craftSystem.CraftSubRes.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } //Taran: Bad fix to check for boards in backpack when using carpenting //Needs to be fixed in a better way if (m_CraftSystem is DefCarpentry) { Item[] item; if (resourceType == typeof(Log)) { item = from.Backpack.FindItemsByType(typeof(Board), true); } else if (resourceType == typeof(OakLog)) { item = from.Backpack.FindItemsByType(typeof(OakBoard), true); } else if (resourceType == typeof(AshLog)) { item = from.Backpack.FindItemsByType(typeof(AshBoard), true); } else if (resourceType == typeof(OakLog)) { item = from.Backpack.FindItemsByType(typeof(OakBoard), true); } else if (resourceType == typeof(YewLog)) { item = from.Backpack.FindItemsByType(typeof(YewBoard), true); } else if (resourceType == typeof(HeartwoodLog)) { item = from.Backpack.FindItemsByType(typeof(HeartwoodBoard), true); } else if (resourceType == typeof(BloodwoodLog)) { item = from.Backpack.FindItemsByType(typeof(BloodwoodBoard), true); } else if (resourceType == typeof(FrostwoodLog)) { item = from.Backpack.FindItemsByType(typeof(FrostwoodBoard), true); } else if (resourceType == typeof(MahoganyLog)) { item = from.Backpack.FindItemsByType(typeof(MahoganyBoard), true); } else if (resourceType == typeof(CedarLog)) { item = from.Backpack.FindItemsByType(typeof(CedarBoard), true); } else if (resourceType == typeof(WillowLog)) { item = from.Backpack.FindItemsByType(typeof(WillowBoard), true); } else if (resourceType == typeof(MystWoodLog)) { item = from.Backpack.FindItemsByType(typeof(MystWoodBoard), true); } else { item = from.Backpack.FindItemsByType(typeof(Board), true); } for (int j = 0; j < item.Length; ++j) { resourceCount += item[j].Amount; } } } AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { AddLabel(50, 362, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount)); } } // **************************************** // For dragon scales if (craftSystem.CraftSubRes2.Init) { string nameString = craftSystem.CraftSubRes2.NameString; int nameNumber = craftSystem.CraftSubRes2.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex2); Type resourceType = craftSystem.CraftSubRes2.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } //Taran: Bad fix to check for boards in backpack when using carpenting //Needs to be fixed in a better way if (m_CraftSystem is DefCarpentry) { Item[] item; if (resourceType == typeof(Log)) { item = from.Backpack.FindItemsByType(typeof(Board), true); } else if (resourceType == typeof(OakLog)) { item = from.Backpack.FindItemsByType(typeof(OakBoard), true); } else if (resourceType == typeof(AshLog)) { item = from.Backpack.FindItemsByType(typeof(AshBoard), true); } else if (resourceType == typeof(OakLog)) { item = from.Backpack.FindItemsByType(typeof(OakBoard), true); } else if (resourceType == typeof(YewLog)) { item = from.Backpack.FindItemsByType(typeof(YewBoard), true); } else if (resourceType == typeof(HeartwoodLog)) { item = from.Backpack.FindItemsByType(typeof(HeartwoodBoard), true); } else if (resourceType == typeof(BloodwoodLog)) { item = from.Backpack.FindItemsByType(typeof(BloodwoodBoard), true); } else if (resourceType == typeof(FrostwoodLog)) { item = from.Backpack.FindItemsByType(typeof(FrostwoodBoard), true); } else if (resourceType == typeof(MahoganyLog)) { item = from.Backpack.FindItemsByType(typeof(MahoganyBoard), true); } else if (resourceType == typeof(CedarLog)) { item = from.Backpack.FindItemsByType(typeof(CedarBoard), true); } else if (resourceType == typeof(WillowLog)) { item = from.Backpack.FindItemsByType(typeof(WillowBoard), true); } else if (resourceType == typeof(MystWoodLog)) { item = from.Backpack.FindItemsByType(typeof(MystWoodBoard), true); } else { item = from.Backpack.FindItemsByType(typeof(Board), true); } for (int j = 0; j < item.Length; ++j) { resourceCount += item[j].Amount; } } } AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { AddLabel(50, 385, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount)); } } // **************************************** CreateGroupList(); if (page == CraftPage.PickResource) { CreateResList(false, from); } else if (page == CraftPage.PickResource2) { CreateResList(true, from); } else if (context != null && context.LastGroupIndex > -1) { CreateItemList(context.LastGroupIndex); } }
public void Craft( Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool ) { if ( from.BeginAction( typeof( CraftSystem ) ) ) { int flags = from.NetState == null ? 0 : from.NetState.Flags; if( !RequiresSE || (flags & 0x10) != 0 )// SE 2D = 0x1F SE 3D = 0x11F { bool allRequiredSkills = true; double chance = GetSuccessChance( from, typeRes, craftSystem, false, ref allRequiredSkills ); if ( allRequiredSkills && chance >= 0.0 ) { string badCraft = craftSystem.CanCraft( from, tool, m_Type ); if ( badCraft == "" ) { int resHue = 0; int maxAmount = 0; object message = null; if ( ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message ) ) { message = null; if ( ConsumeAttributes( from, ref message, false ) ) { CraftContext context = craftSystem.GetContext( from ); if ( context != null ) context.OnMade( this ); int iMin = craftSystem.MinCraftEffect; int iMax = ( craftSystem.MaxCraftEffect - iMin ) + 1; int iRandom = Utility.Random( iMax ); iRandom += iMin + 1; new InternalTimer( from, craftSystem, this, typeRes, tool, iRandom ).Start(); } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, message ) ); } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, message ) ); } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, badCraft ) ); } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, 1044153 ) ); // You don't have the required skills to attempt this item. } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, 1063307 ) ); //The "Samurai Empire" expansion is required to attempt this item. } } else { from.SendAsciiMessage( "You must wait to perform another action." ); } }
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, 290, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1); } AddPage((i / 10) + 1); if (i > 0) { AddButton(455, 290, 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, 260, 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; } Type alt = GetAltType(subResource.ItemType); if (alt != null) { Item[] items2 = m_From.Backpack.FindItemsByType(alt, true); for (int j = 0; j < items2.Length; ++j) { resourceCount += items2[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 int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Quality = (ArmorQuality)quality; if ( makersMark ) Crafter = from; Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Resources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); PlayerConstructed = true; CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; if( Quality == ArmorQuality.Exceptional ) { if ( !( Core.ML && this is BaseShield )) // Guessed Core.ML removed exceptional resist bonuses from crafted shields DistributeBonuses( (tool is BaseRunicTool ? 6 : Core.SE ? 15 : 14) ); // Not sure since when, but right now 15 points are added, not 14. if( Core.ML && !(this is BaseShield) ) { int bonus = (int)(from.Skills.ArmsLore.Value / 20); for( int i = 0; i < bonus; i++ ) { switch( Utility.Random( 5 ) ) { case 0: m_PhysicalBonus++; break; case 1: m_FireBonus++; break; case 2: m_ColdBonus++; break; case 3: m_EnergyBonus++; break; case 4: m_PoisonBonus++; break; } } from.CheckSkill( SkillName.ArmsLore, 0, 100 ); } } if ( Core.AOS && tool is BaseRunicTool ) ((BaseRunicTool)tool).ApplyAttributesTo( this ); return quality; }
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40) { m_From = from; m_CraftSystem = craftSystem; m_Tool = tool; m_Page = page; CraftContext context = craftSystem.GetContext(from); from.CloseGump(typeof(CraftGump)); from.CloseGump(typeof(CraftGumpItem)); AddPage(0); AddBackground(0, 0, 530, 437, 5054); AddImageTiled(10, 10, 510, 22, 2624); // AddImageTiled(10, 292, 150, 45, 2624); // AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 85, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 417); if (craftSystem.GumpTitleNumber > 0) { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); } else { AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); } AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER> int textHue = 2499; int highlightColor = 2599; //Guide AddButton(10, 0, 2094, 2095, 1000, GumpButtonType.Reply, 0); AddLabel(35, 5, textHue, "Guide"); #region Left Side Button Controls //Smelt Mode if (craftSystem.Recycle) { AddButton(15, 342, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0); switch (context.RecycleOption) { case CraftRecycleOption.RecycleItem: AddLabel(50, 345, textHue, "Recycle Mode: Single Item"); break; case CraftRecycleOption.RecycleAllNonExceptional: AddLabel(50, 345, textHue, "Recycle Mode: All Non-Exceptional"); break; case CraftRecycleOption.RecycleAll: AddLabel(50, 345, textHue, "Recycle Mode: All"); break; } } //Smelt Button if (craftSystem.Recycle) { AddButton(15, 362, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); if (context.RecycleOption == CraftRecycleOption.RecycleItem) { AddLabel(50, 365, textHue, "Recycle Item"); } else { AddLabel(50, 365, textHue, "Recyle Items (Select Type)"); } } //Repair Button if (craftSystem.Repair) { AddButton(15, 382, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); AddLabel(50, 385, textHue, "Repair Item"); } //Exit Button AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0); AddLabel(50, 405, textHue, "Exit"); #endregion #region Right Side Button Controls //Material Selection if (craftSystem.CraftSubRes.Init) { string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex); Type resourceType = craftSystem.CraftSubRes.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } AddButton(270, 342, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); AddLabel(305, 345, textHue, nameString + " (" + resourceCount + " Available)"); } // Highlight Skillgain AddButton(270, 362, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0); if (context.HighlightSkillGainItems) { AddLabel(305, 365, highlightColor, "Highlight Skillgain Items"); } else { AddLabel(305, 365, textHue, "Do Not Highlight Skillgain Items"); } // Mark Button if (craftSystem.MarkOption) { AddButton(270, 382, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); if (context == null) { AddLabel(305, 385, textHue, "Do Not Mark"); } else { switch (context.MarkOption) { case CraftMarkOption.DoNotMark: AddLabel(305, 385, textHue, "Do Not Mark"); break; case CraftMarkOption.MarkItem: AddLabel(305, 385, textHue, "Mark Item"); break; case CraftMarkOption.PromptForMark: AddLabel(305, 385, textHue, "Prompt For Mark"); break; } } } //Make Last AddButton(270, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); AddLabel(305, 405, textHue, "Make Last Item"); #endregion if (notice is int && (int)notice > 0) { AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false); } else if (notice is string) { AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false); } CreateGroupList(); if (page == CraftPage.PickResource) { CreateResList(false, from); } else if (page == CraftPage.PickResource2) { CreateResList(true, from); } else if (context != null && context.LastGroupIndex > -1) { CreateItemList(context.LastGroupIndex); } }
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Quality = (WineQuality)quality; if ( makersMark ) Crafter = from; Item[] items = from.Backpack.FindItemsByType( typeof( VinyardLabelMaker ) ); if ( items.Length != 0 ) { foreach( VinyardLabelMaker lm in items ) { if (lm.VinyardName != null) { this.Name = lm.VinyardName; break; } } } Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Resources.GetAt( 0 ).ItemType; Variety = WinemakingResources.GetFromType( resourceType ); CraftContext context = craftSystem.GetContext( from ); //if ( context != null && context.DoNotColor ) Hue = 0; return quality; }
public override void OnResponse(NetState sender, RelayInfo info) { //Cancel if (info.ButtonID <= 0) { return; } int buttonID = info.ButtonID - 1; int type = buttonID % 7; int index = buttonID / 7; CraftSystem system = m_CraftSystem; CraftGroupCol groups = system.CraftGroups; CraftContext context = system.GetContext(m_From); //Guide if (info.ButtonID == 1000) { string url = "http://www.uoancorp.com"; sender.Mobile.LaunchBrowser(url); m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); return; } //Crafting else { switch (type) { //Group case 0: { if (context == null) { break; } if (index >= 0 && index < groups.Count) { context.LastGroupIndex = index; m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } break; } //Create Item case 1: { if (context == null) { break; } int groupIndex = context.LastGroupIndex; if (groupIndex >= 0 && groupIndex < groups.Count) { CraftGroup group = groups.GetAt(groupIndex); if (index >= 0 && index < group.CraftItems.Count) { CraftItem(group.CraftItems.GetAt(index)); } } break; } //Item Details case 2: { if (context == null) { break; } int groupIndex = context.LastGroupIndex; if (groupIndex >= 0 && groupIndex < groups.Count) { CraftGroup group = groups.GetAt(groupIndex); if (index >= 0 && index < group.CraftItems.Count) { m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool)); } } break; } //Create Item: Last 10 case 3: { if (context == null) { break; } List <CraftItem> lastTen = context.Items; if (index >= 0 && index < lastTen.Count) { CraftItem(lastTen[index]); } break; } //Item Details: Last Ten case 4: { if (context == null) { break; } List <CraftItem> lastTen = context.Items; if (index >= 0 && index < lastTen.Count) { m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool)); } break; } //Resource Selected case 5: { if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count) { int groupIndex = (context == null ? -1 : context.LastGroupIndex); CraftSubRes res = system.CraftSubRes.GetAt(index); if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex = index; } m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } } else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count) { int groupIndex = (context == null ? -1 : context.LastGroupIndex); CraftSubRes res = system.CraftSubRes2.GetAt(index); if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex2 = index; } m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } } break; } //Main Controls case 6: { switch (index) { //Resource Selection case 0: { if (system.CraftSubRes.Init) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource)); } break; } //Smelt Item case 1: { if (system.Recycle) { Recycle.Do(m_From, system, m_Tool); } break; } //Make Last case 2: { if (context == null) { break; } CraftItem item = context.LastMade; if (item != null) { CraftItem(item); } else { m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page)); // You haven't made anything yet. } break; } //Last Ten case 3: { if (context == null) { break; } context.LastGroupIndex = 501; m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); break; } //Toggle Resource Hue case 4: { if (context == null) { break; } context.DoNotColor = !context.DoNotColor; m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } //Repair Item case 5: { if (system.Repair) { Repair.Do(m_From, system, m_Tool); } break; } //Toggle Mark Option case 6: { if (context == null || !system.MarkOption) { break; } switch (context.MarkOption) { case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break; case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break; case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break; } m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } //Toggle Smelt option case 9: { if (context == null || !system.Recycle) { break; } switch (context.RecycleOption) { case CraftRecycleOption.RecycleItem: context.RecycleOption = CraftRecycleOption.RecycleAllNonExceptional; break; case CraftRecycleOption.RecycleAllNonExceptional: context.RecycleOption = CraftRecycleOption.RecycleAll; break; case CraftRecycleOption.RecycleAll: context.RecycleOption = CraftRecycleOption.RecycleItem; break; } m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } //Highlight Skill Gain case 10: { if (context == null) { break; } context.HighlightSkillGainItems = !context.HighlightSkillGainItems; m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } } break; } } } }
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { Quality = (WeaponQuality)quality; if (makersMark) { Crafter = from; } PlayerConstructed = true; if (typeRes == null) { typeRes = craftItem.Resources.GetAt(0).ItemType; } if (Core.AOS) { if (!craftItem.ForceNonExceptional) { Resource = CraftResources.GetFromType(typeRes); } CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } if (Quality == WeaponQuality.Exceptional) { Attributes.WeaponDamage += 35; } if (!craftItem.ForceNonExceptional) { if (tool is BaseRunicTool) { ((BaseRunicTool)tool).ApplyAttributesTo(this); } } if (Core.ML && Quality == WeaponQuality.Exceptional) { Attributes.WeaponDamage += (int)(from.Skills.ArmsLore.Value / 20); from.CheckSkill(SkillName.ArmsLore, 0, 100); } } else if (tool is BaseRunicTool) { if (craftItem != null && !craftItem.ForceNonExceptional) { CraftResource thisResource = CraftResources.GetFromType(typeRes); if (thisResource == ((BaseRunicTool)tool).Resource) { Resource = thisResource; CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } switch (thisResource) { case CraftResource.DullCopper: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Durable; AccuracyLevel = WeaponAccuracyLevel.Accurate; break; } case CraftResource.ShadowIron: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Durable; DamageLevel = WeaponDamageLevel.Ruin; break; } case CraftResource.Copper: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Fortified; DamageLevel = WeaponDamageLevel.Ruin; AccuracyLevel = WeaponAccuracyLevel.Surpassingly; break; } case CraftResource.Bronze: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Fortified; DamageLevel = WeaponDamageLevel.Might; AccuracyLevel = WeaponAccuracyLevel.Surpassingly; break; } case CraftResource.Gold: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Force; AccuracyLevel = WeaponAccuracyLevel.Eminently; break; } case CraftResource.Agapite: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Power; AccuracyLevel = WeaponAccuracyLevel.Eminently; break; } case CraftResource.Verite: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Power; AccuracyLevel = WeaponAccuracyLevel.Exceedingly; break; } case CraftResource.Valorite: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Vanq; AccuracyLevel = WeaponAccuracyLevel.Supremely; break; } } } } } if (craftItem != null && !craftItem.ForceNonExceptional) { CraftResourceInfo resInfo = CraftResources.GetInfo(m_Resource); if (resInfo == null) { return quality; } CraftAttributeInfo attrInfo = resInfo.AttributeInfo; if (attrInfo == null) { return quality; } if (m_Resource != CraftResource.Heartwood) { m_AosAttributes.WeaponDamage += attrInfo.WeaponDamage; m_AosAttributes.WeaponSpeed += attrInfo.WeaponSwingSpeed; m_AosAttributes.AttackChance += attrInfo.WeaponHitChance; m_AosAttributes.RegenHits += attrInfo.WeaponRegenHits; m_AosWeaponAttributes.HitLeechHits += attrInfo.WeaponHitLifeLeech; } else { switch (Utility.Random(6)) { case 0: m_AosAttributes.WeaponDamage += attrInfo.WeaponDamage; break; case 1: m_AosAttributes.WeaponSpeed += attrInfo.WeaponSwingSpeed; break; case 2: m_AosAttributes.AttackChance += attrInfo.WeaponHitChance; break; case 3: m_AosAttributes.Luck += attrInfo.WeaponLuck; break; case 4: m_AosWeaponAttributes.LowerStatReq += attrInfo.WeaponLowerRequirements; break; case 5: m_AosWeaponAttributes.HitLeechHits += attrInfo.WeaponHitLifeLeech; break; } } } #endregion return quality; }
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40) { this.m_From = from; this.m_CraftSystem = craftSystem; this.m_Tool = tool; this.m_Page = page; CraftContext context = craftSystem.GetContext(from); from.CloseGump(typeof(CraftGump)); from.CloseGump(typeof(CraftGumpItem)); this.AddPage(0); this.AddBackground(0, 0, 550, 587, 5054); this.AddImageTiled(10, 10, 530, 22, 2624); //Section for Gump Heading this.AddImageTiled(10, 375, 132, 45, 2624); //Section for Notices this.AddImageTiled(146, 375, 395, 45, 2624); //Section across from Notices this.AddImageTiled(10, 422, 530, 155, 2624); //Section where Exit is this.AddImageTiled(10, 37, 200, 335, 2624); //Section for Categories this.AddImageTiled(215, 37, 325, 335, 2624); //Section for Sublisted Items this.AddAlphaRegion(10, 10, 530, 567); if (craftSystem.GumpTitleNumber > 0) { this.AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); } else { this.AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); } this.AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER> this.AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER> this.AddHtmlLocalized(10, 385, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER> this.AddButton(15, 542, 4017, 4019, 0, GumpButtonType.Reply, 0); this.AddHtmlLocalized(50, 545, 150, 18, 1011441, LabelColor, false, false); // EXIT this.AddButton(270, 542, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); this.AddHtmlLocalized(305, 545, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST this.AddButton(270, 522, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0); this.AddHtmlLocalized(305, 525, 150, 18, 1112533 + (context == null ? 0 : (int)context.QuestOption), LabelColor, false, false); // QUEST ITEM this.AddButton(115, 542, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0); this.AddHtmlLocalized(150, 545, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE // Mark option if (craftSystem.MarkOption) { this.AddButton(270, 462, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); this.AddHtmlLocalized(305, 465, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM } // **************************************** // Resmelt option if (craftSystem.Resmelt) { this.AddButton(15, 442, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); this.AddHtmlLocalized(50, 445, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM } // **************************************** // Repair option if (craftSystem.Repair) { this.AddButton(270, 442, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); this.AddHtmlLocalized(305, 445, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM } // **************************************** // Enhance option if (craftSystem.CanEnhance) { this.AddButton(270, 482, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0); this.AddHtmlLocalized(305, 485, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM } // **************************************** // Alter option if (craftSystem.CanAlter) { this.AddButton(270, 502, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0); this.AddHtmlLocalized(304, 505, 1152, 18, 1094726, LabelColor, false, false); // ALTER ITEM } // **************************************** if (notice is int && (int)notice > 0) { this.AddHtmlLocalized(170, 377, 350, 40, (int)notice, LabelColor, false, false); } else if (notice is string) { this.AddHtml(170, 377, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false); } // If the system has more than one resource if (craftSystem.CraftSubRes.Init) { string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex); Type resourceType = craftSystem.CraftSubRes.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } this.AddButton(15, 462, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); if (nameNumber > 0) { this.AddHtmlLocalized(50, 465, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { this.AddLabel(50, 465, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount)); } } // **************************************** // For dragon scales if (craftSystem.CraftSubRes2.Init) { string nameString = craftSystem.CraftSubRes2.NameString; int nameNumber = craftSystem.CraftSubRes2.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex2); Type resourceType = craftSystem.CraftSubRes2.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } this.AddButton(15, 482, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); if (nameNumber > 0) { this.AddHtmlLocalized(50, 485, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { this.AddLabel(50, 485, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount)); } } // **************************************** this.CreateGroupList(); if (page == CraftPage.PickResource) { this.CreateResList(false, from); } else if (page == CraftPage.PickResource2) { this.CreateResList(true, from); } else if (context != null && context.LastGroupIndex > -1) { this.CreateItemList(context.LastGroupIndex); } }
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Held = 75; Quality = (WineQuality)quality; if ( makersMark ) Crafter = from; Item[] items = from.Backpack.FindItemsByType( typeof( VinyardLabelMaker ) ); if ( items.Length != 0 ) { foreach( VinyardLabelMaker lm in items ) { if (lm.VinyardName != null) { this.Name = lm.VinyardName; break; } } } Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Resources.GetAt( 0 ).ItemType; Variety = WinemakingResources.GetFromType( resourceType ); CraftContext context = craftSystem.GetContext( from ); Hue = 0; BottleDuration = 7.0; AllowBottling = false; m_Start = DateTime.Now; return quality; }
protected override void OnTarget(Mobile from, object targeted) { int number; if (m_CraftSystem is DefTinkering && targeted is Golem) { Golem g = (Golem)targeted; int damage = g.HitsMax - g.Hits; if (g.IsDeadBondedPet) { number = 500426; // You can't repair that. } else if (damage <= 0) { number = 500423; // That is already in full repair. } else { double skillValue = from.Skills[SkillName.Tinkering].Value; if (skillValue < 60.0) { number = 1044153; // You don't have the required skills to attempt this item. } else if (!from.CanBeginAction(typeof(Golem))) { number = 501789; // You must wait before trying again. } else { if (damage > (int)(skillValue * 0.3)) { damage = (int)(skillValue * 0.3); } damage += 30; if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0)) { damage /= 2; } Container pack = from.Backpack; if (pack != null) { int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5); if (v > 0) { g.Hits += v * 5; number = 1044279; // You repair the item. from.BeginAction(typeof(Golem)); Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from); } else { number = 1044037; // You do not have sufficient metal to make that. } } else { number = 1044037; // You do not have sufficient metal to make that. } } } } else if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon)) { number = 1044277; // That item cannot be repaired. } else if (!weapon.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits) { number = 1044281; // That item is in full repair } else if (weapon.MaxHits <= toWeaken) { number = 500424; // You destroyed the item. m_CraftSystem.PlayCraftEffect(from); weapon.Delete(); } else if (from.CheckSkill(skill, -285.0, 100.0)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.MaxHits -= toWeaken; weapon.Hits = weapon.MaxHits; } else { number = 1044280; // You fail to repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.MaxHits -= toWeaken; if (weapon.Hits - toWeaken < 0) { weapon.Hits = 0; } else { weapon.Hits -= toWeaken; } } if (weapon.MaxHits <= toWeaken) { from.SendLocalizedMessage(1044278); // That item has been repaired many times, and will break if repairs are attempted again. } } else if (targeted is BaseArmor) { BaseArmor armor = (BaseArmor)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null) { number = 1044277; // That item cannot be repaired. } else if (!armor.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (armor.MaxHitPoints <= toWeaken) { number = 500424; // You destroyed the item. m_CraftSystem.PlayCraftEffect(from); armor.Delete(); } else if (from.CheckSkill(skill, -285.0, 100.0)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); armor.MaxHitPoints -= toWeaken; armor.HitPoints = armor.MaxHitPoints; } else { number = 1044280; // You fail to repair the item. m_CraftSystem.PlayCraftEffect(from); armor.MaxHitPoints -= toWeaken; if (armor.HitPoints - toWeaken < 0) { armor.HitPoints = 0; } else { armor.HitPoints -= toWeaken; } } if (armor.MaxHitPoints <= toWeaken) { from.SendLocalizedMessage(1044278); // That item has been repaired many times, and will break if repairs are attempted again. } } else if (targeted is Item) { number = 1044277; // That item cannot be repaired. } else { number = 500426; // You can't repair that. } CraftContext context = m_CraftSystem.GetContext(from); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number)); }
public int ConsumeQuantityByPlantHue(Mobile from, CraftSystem craftSystem, Container cont, Type[][] types, int[] amounts) { if (types.Length != amounts.Length) throw new ArgumentException(); CraftContext context = craftSystem.GetContext(from); if (context == null) return 0; Item[][] items = new Item[types.Length][]; int[] totals = new int[types.Length]; for (int i = 0; i < types.Length; ++i) { items[i] = cont.FindItemsByType(types[i], true); for (int j = 0; j < items[i].Length; ++j) { IPlantHue plantHue = items[i][j] as IPlantHue; IPigmentHue pigmentHue = items[i][j] as IPigmentHue; if (plantHue != null && plantHue.PlantHue != context.RequiredPlantHue) continue; else if (pigmentHue != null && pigmentHue.PigmentHue != context.RequiredPigmentHue) continue; totals[i] += items[i][j].Amount; } if (totals[i] < amounts[i]) return i; } for (int i = 0; i < types.Length; ++i) { int need = amounts[i]; for (int j = 0; j < items[i].Length; ++j) { Item item = items[i][j]; IPlantHue ph = item as IPlantHue; IPigmentHue pigh = item as IPigmentHue; int theirAmount = item.Amount; if (ph != null && ph.PlantHue != context.RequiredPlantHue) continue; else if (pigh != null && pigh.PigmentHue != context.RequiredPigmentHue) continue; if (theirAmount < need) { OnResourceConsumed(item, theirAmount); item.Delete(); need -= theirAmount; } else { OnResourceConsumed(item, need); item.Consume(need); break; } } } return -1; }
public void CreateResList(bool opt, Mobile from) { var res = opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes; for (var i = 0; i < res.Count; ++i) { var index = i % 10; var subResource = res[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); } var context = m_CraftSystem.GetContext(m_From); AddButton(220, 260, 4005, 4007, GetButtonID(6, 4)); AddHtmlLocalized( 255, 263, 200, 18, context?.DoNotColor != true ? 1061591 : 1061590, LabelColor ); } var resourceCount = 0; if (from.Backpack != null) { var items = from.Backpack.FindItemsByType(subResource.ItemType); for (var j = 0; j < items.Length; ++j) { resourceCount += items[j].Amount; } } AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(5, i)); if (subResource.Name.Number > 0) { AddHtmlLocalized( 255, 63 + index * 20, 250, 18, subResource.Name.Number, resourceCount.ToString(), LabelColor ); } else { AddLabel(255, 60 + index * 20, LabelHue, $"{subResource.Name.String} ({resourceCount})"); } } }
public bool ConsumeRes( Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure) { Container ourPack = from.Backpack; if (ourPack == null) { return false; } if (m_NeedHeat && !Find(from, m_HeatSources)) { message = 1044487; // You must be near a fire source to cook. return false; } if (m_NeedOven && !Find(from, m_Ovens)) { message = 1044493; // You must be near an oven to bake that. return false; } if (m_NeedMill && !Find(from, m_Mills)) { message = 1044491; // You must be near a flour mill to do that. return false; } var types = new Type[m_arCraftRes.Count][]; var amounts = new int[m_arCraftRes.Count]; maxAmount = int.MaxValue; CraftSubResCol resCol = (m_UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes); for (int i = 0; i < types.Length; ++i) { CraftRes craftRes = m_arCraftRes.GetAt(i); Type baseType = craftRes.ItemType; if (typeRes != null && ForceTypeRes) { Type outType; if (m_ResourceConversionTable.TryGetValue(typeRes, out outType)) baseType = outType; } // Resource Mutation if ((baseType == resCol.ResType) && (typeRes != null)) { baseType = typeRes; CraftSubRes subResource = resCol.SearchFor(baseType); if (subResource != null && from.Skills[craftSystem.MainSkill].Base < subResource.RequiredSkill) { message = subResource.Message; return false; } } // ****************** for (int j = 0; types[i] == null && j < m_TypesTable.Length; ++j) { if (m_TypesTable[j][0] == baseType) { types[i] = m_TypesTable[j]; } } if (types[i] == null) { types[i] = new[] {baseType}; } amounts[i] = craftRes.Amount; // For stackable items that can ben crafted more than one at a time if (UseAllRes) { int tempAmount = ourPack.GetAmount(types[i]); tempAmount /= amounts[i]; if (tempAmount < maxAmount) { maxAmount = tempAmount; if (maxAmount == 0) { CraftRes res = m_arCraftRes.GetAt(i); if (res.MessageNumber > 0) { message = res.MessageNumber; } else if (!String.IsNullOrEmpty(res.MessageString)) { message = res.MessageString; } else { message = 502925; // You don't have the resources required to make that item. } return false; } } } // **************************** if (isFailure && !craftSystem.ConsumeOnFailure(from, types[i][0], this)) { amounts[i] = 0; } } // We adjust the amount of each resource to consume the max posible if (UseAllRes) { for (int i = 0; i < amounts.Length; ++i) { amounts[i] *= maxAmount; } } else { maxAmount = -1; } Item consumeExtra = null; if (m_NameNumber == 1041267) { // Runebooks are a special case, they need a blank recall rune var runes = ourPack.FindItemsByType<RecallRune>(); for (int i = 0; i < runes.Count; ++i) { RecallRune rune = runes[i]; if (rune != null && !rune.Marked) { consumeExtra = rune; break; } } if (consumeExtra == null) { message = 1044253; // You don't have the components needed to make that. return false; } } int index = 0; // Consume ALL if (consumeType == ConsumeType.All) { m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem; if (IsQuantityType(types)) { index = ConsumeQuantity(ourPack, types, amounts); } else if (IsPlantHueType(types)) { index = ConsumeQuantityByPlantHue(from, craftSystem, ourPack, types, amounts); } else { index = ourPack.ConsumeTotalGrouped(types, amounts, true, OnResourceConsumed, CheckHueGrouping); } resHue = m_ResHue; } // Consume Half ( for use all resource craft type ) else if (consumeType == ConsumeType.Half) { for (int i = 0; i < amounts.Length; i++) { amounts[i] /= 2; if (amounts[i] < 1) { amounts[i] = 1; } } m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem; if (IsQuantityType(types)) { index = ConsumeQuantity(ourPack, types, amounts); } else if (IsPlantHueType(types)) { index = ConsumeQuantityByPlantHue(from, craftSystem, ourPack, types, amounts); } else { index = ourPack.ConsumeTotalGrouped(types, amounts, true, OnResourceConsumed, CheckHueGrouping); } resHue = m_ResHue; } else // ConstumeType.None ( it's basicaly used to know if the crafter has enough resource before starting the process ) { index = -1; if (IsQuantityType(types)) { for (int i = 0; i < types.Length; i++) { if (GetQuantity(ourPack, types[i]) < amounts[i]) { index = i; break; } } } else if (IsPlantHueType(types)) { CraftContext c = craftSystem.GetContext(from); for (int i = 0; i < types.Length; i++) { if (GetPlantHueAmount(from, craftSystem, ourPack, types[i]) < amounts[i]) { index = i; break; } } } else { for (int i = 0; i < types.Length; i++) { if (ourPack.GetBestGroupAmount(types[i], true, CheckHueGrouping) < amounts[i]) { index = i; break; } } } } if (index == -1) { if (consumeType != ConsumeType.None) { if (consumeExtra != null) { consumeExtra.Delete(); } } return true; } else { CraftRes res = m_arCraftRes.GetAt(index); if (res.MessageNumber > 0) { message = res.MessageNumber; } else if (res.MessageString != null && res.MessageString != String.Empty) { message = res.MessageString; } else { message = 502925; // You don't have the resources required to make that item. } return false; } }
public CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool, TextDefinition notice, CraftPage page = CraftPage.None ) : base(40, 40) { m_From = from; m_CraftSystem = craftSystem; m_Tool = tool; m_Page = page; var context = craftSystem.GetContext(from); from.CloseGump <CraftGump>(); from.CloseGump <CraftGumpItem>(); AddPage(0); AddBackground(0, 0, 530, 437, 5054); AddImageTiled(10, 10, 510, 22, 2624); AddImageTiled(10, 292, 150, 45, 2624); AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 85, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 417); if (craftSystem.GumpTitle.Number > 0) { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitle.Number, LabelColor); } else { AddHtml(10, 12, 510, 20, craftSystem.GumpTitle.String); } AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor); // <CENTER>NOTICES</CENTER> AddButton(15, 402, 4017, 4019, 0); AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor); // EXIT AddButton(270, 402, 4005, 4007, GetButtonID(6, 2)); AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor); // MAKE LAST // Mark option if (craftSystem.MarkOption) { AddButton(270, 362, 4005, 4007, GetButtonID(6, 6)); AddHtmlLocalized( 305, 365, 150, 18, 1044017 + (int)(context?.MarkOption ?? CraftMarkOption.MarkItem), // MARK ITEM LabelColor ); } // **************************************** // Resmelt option if (craftSystem.Resmelt) { AddButton(15, 342, 4005, 4007, GetButtonID(6, 1)); AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor); // SMELT ITEM } // **************************************** // Repair option if (craftSystem.Repair) { AddButton(270, 342, 4005, 4007, GetButtonID(6, 5)); AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor); // REPAIR ITEM } // **************************************** // Enhance option if (craftSystem.CanEnhance) { AddButton(270, 382, 4005, 4007, GetButtonID(6, 8)); AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor); // ENHANCE ITEM } // **************************************** if (notice != null) { if (notice.Number > 0) { AddHtmlLocalized(170, 295, 350, 40, notice.Number, LabelColor); } else { AddHtml(170, 295, 350, 40, $"<BASEFONT COLOR=#{FontColor:X6}>{notice.String}</BASEFONT>"); } } // If the system has more than one resource if (craftSystem.CraftSubRes.Init) { var nameString = craftSystem.CraftSubRes.Name.String; var nameNumber = craftSystem.CraftSubRes.Name.Number; var resIndex = context?.LastResourceIndex ?? -1; var resourceType = craftSystem.CraftSubRes.ResType; if (resIndex > -1) { var subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.Name.String; nameNumber = subResource.Name.Number; resourceType = subResource.ItemType; } var resourceCount = 0; if (from.Backpack != null) { var items = from.Backpack.FindItemsByType(resourceType); for (var i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } AddButton(15, 362, 4005, 4007, GetButtonID(6, 0)); if (nameNumber > 0) { AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor); } else { AddLabel(50, 362, LabelHue, $"{nameString} ({resourceCount} Available)"); } } // **************************************** // For dragon scales if (craftSystem.CraftSubRes2.Init) { var nameString = craftSystem.CraftSubRes2.Name.String; var nameNumber = craftSystem.CraftSubRes2.Name.Number; var resIndex = context?.LastResourceIndex2 ?? -1; var resourceType = craftSystem.CraftSubRes2.ResType; if (resIndex > -1) { var subResource = craftSystem.CraftSubRes2.GetAt(resIndex); nameString = subResource.Name.String; nameNumber = subResource.Name.Number; resourceType = subResource.ItemType; } var resourceCount = 0; if (from.Backpack != null) { var items = from.Backpack.FindItemsByType(resourceType); for (var i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } AddButton(15, 382, 4005, 4007, GetButtonID(6, 7)); if (nameNumber > 0) { AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor); } else { AddLabel(50, 385, LabelHue, $"{nameString} ({resourceCount} Available)"); } } // **************************************** CreateGroupList(); if (page == CraftPage.PickResource) { CreateResList(false, from); } else if (page == CraftPage.PickResource2) { CreateResList(true, from); } else if (context?.LastGroupIndex > -1) { CreateItemList(context.LastGroupIndex); } }
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, Type typeRes2, BaseTool tool, CraftItem craftItem, int resHue ) { // TODO: Adapt to use typeRes2 Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Resources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; return quality; }
protected override void OnTarget(Mobile from, object targeted) { bool usingDeed = (m_Deed != null) || (m_Addon != null); bool toDelete = false; int number; double value = 0; if (m_Deed != null) { value = m_Deed.SkillLevel; } else if (m_Addon != null) { var tool = m_Addon.Tools.Find(x => x.System == m_CraftSystem); if (tool.Charges == 0) { from.SendLocalizedMessage(1019073);// This item is out of charges. m_Addon.Using = false; return; } value = tool.SkillValue; } else { value = from.Skills[m_CraftSystem.MainSkill].Base; } if (m_CraftSystem is DefTinkering && targeted is IRepairableMobile) { if (TryRepairMobile(from, (IRepairableMobile)targeted, usingDeed, out toDelete)) { number = 1044279; // You repair the item. m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, (IRepairableMobile)targeted); } else { number = 500426; // You can't repair that. } } else if (targeted is Item) { if (from.InRange(((Item)targeted).GetWorldLocation(), 2)) { if (!CheckDeed(from)) { if (m_Addon != null) { m_Addon.Using = false; } return; } if (!AllowsRepair(targeted, m_CraftSystem)) { from.SendLocalizedMessage(500426); // You can't repair that. if (m_Addon != null) { m_Addon.Using = false; } return; } if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267) { number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's * } else if (!usingDeed && m_CraftSystem is DefTinkering && targeted is BrokenAutomatonHead) { if (((BrokenAutomatonHead)targeted).TryRepair(from)) { number = 1044279; // You repair the item. } else { number = 1044280; // You fail to repair the item. } } else if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !CheckSpecial(weapon)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!weapon.IsChildOf(from.Backpack) && weapon.Parent != from) { number = 1044275; // The item must be in your backpack to repair it. } else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (weapon.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (weapon.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { weapon.MaxHitPoints -= toWeaken; weapon.HitPoints = Math.Max(0, weapon.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.HitPoints = weapon.MaxHitPoints; m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, weapon); } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseArmor) { BaseArmor armor = (BaseArmor)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !CheckSpecial(armor)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!armor.IsChildOf(from.Backpack) && armor.Parent != from) { number = 1044275; // The item must be in your backpack to repair it. } else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (armor.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (armor.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints)) { armor.MaxHitPoints -= toWeaken; armor.HitPoints = Math.Max(0, armor.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); armor.HitPoints = armor.MaxHitPoints; m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, armor); } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseJewel) { BaseJewel jewel = (BaseJewel)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (m_CraftSystem.CraftItems.SearchForSubclass(jewel.GetType()) == null && !CheckSpecial(jewel)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!jewel.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (jewel.MaxHitPoints <= 0 || jewel.HitPoints == jewel.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (jewel.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (jewel.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, jewel.HitPoints, jewel.MaxHitPoints)) { jewel.MaxHitPoints -= toWeaken; jewel.HitPoints = Math.Max(0, jewel.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, jewel.HitPoints, jewel.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); jewel.HitPoints = jewel.MaxHitPoints; m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, jewel); } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseClothing) { BaseClothing clothing = (BaseClothing)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !CheckSpecial(clothing)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!clothing.IsChildOf(from.Backpack) && clothing.Parent != from) { number = 1044275; // The item must be in your backpack to repair it. } else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (clothing.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (clothing.NegativeAttributes.NoRepair > 0) // quick fix { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { clothing.MaxHitPoints -= toWeaken; clothing.HitPoints = Math.Max(0, clothing.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); clothing.HitPoints = clothing.MaxHitPoints; m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, clothing); } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (!(m_CraftSystem is DefTinkering)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!talisman.IsChildOf(from.Backpack) && talisman.Parent != from) { number = 1044275; // The item must be in your backpack to repair it. } else if (talisman.MaxHitPoints <= 0 || talisman.HitPoints == talisman.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (talisman.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (!talisman.CanRepair) // quick fix { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, talisman.HitPoints, talisman.MaxHitPoints)) { talisman.MaxHitPoints -= toWeaken; talisman.HitPoints = Math.Max(0, talisman.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, talisman.HitPoints, talisman.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); talisman.HitPoints = talisman.MaxHitPoints; m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, talisman); } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BlankScroll) { if (!usingDeed) { SkillName skill = m_CraftSystem.MainSkill; if (from.Skills[skill].Value >= 50.0) { ((BlankScroll)targeted).Consume(1); RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from); from.AddToBackpack(deed); number = 500442; // You create the item and put it in your backpack. } else { number = 1047005; // You must be at least apprentice level to create a repair service contract. } } else { number = 1061136; // You cannot repair that item with this type of repair contract. } } else { number = 500426; // You can't repair that. } } else { number = 500446; // That is too far away. } } else { number = 500426; // You can't repair that. } if (!usingDeed) { CraftContext context = m_CraftSystem.GetContext(from); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number)); } else { if (m_Addon != null && !m_Addon.Deleted) { var tool = m_Addon.Tools.Find(x => x.System == m_CraftSystem); tool.Charges--; from.SendGump(new RepairBenchGump(from, m_Addon)); from.SendLocalizedMessage(number); } else { from.SendLocalizedMessage(number); if (toDelete) { m_Deed.Delete(); } } } }
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Quality = (WeaponQuality)quality; if ( makersMark ) Crafter = from; PlayerConstructed = true; Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Resources.GetAt( 0 ).ItemType; // Begin arms lore check int armsLoreBracket = (int)(from.Skills.ArmsLore.Value / 10); switch ( armsLoreBracket ) { case 1: DamageLevel = WeaponDamageLevel.TenArmsLore; break; case 2: DamageLevel = WeaponDamageLevel.TwentyArmsLore; break; case 3: DamageLevel = WeaponDamageLevel.ThirtyArmsLore; break; case 4: DamageLevel = WeaponDamageLevel.FortyArmsLore; break; case 5: DamageLevel = WeaponDamageLevel.FiftyArmsLore; break; case 6: DamageLevel = WeaponDamageLevel.SixtyArmsLore; break; case 7: DamageLevel = WeaponDamageLevel.SeventyArmsLore; break; case 8: DamageLevel = WeaponDamageLevel.EightyArmsLore; break; case 9: DamageLevel = WeaponDamageLevel.NinetyArmsLore; break; case 10: DamageLevel = WeaponDamageLevel.GMArmsLore; break; } Attributes.WeaponDamage += (int)(from.Skills.ArmsLore.Value / 20); if ( Attributes.WeaponDamage > 50 ) Attributes.WeaponDamage = 50; from.CheckSkill( SkillName.ArmsLore, 0, 100 ); // End arms lore check if ( tool is BaseRunicTool ) { CraftResource thisResource = CraftResources.GetFromType( resourceType ); if ( thisResource == ((BaseRunicTool)tool).Resource ) { Resource = thisResource; CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; switch ( thisResource ) { case CraftResource.DullCopper: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Durable; AccuracyLevel = WeaponAccuracyLevel.Accurate; break; } case CraftResource.ShadowIron: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Durable; DamageLevel = WeaponDamageLevel.Ruin; break; } case CraftResource.Copper: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Fortified; DamageLevel = WeaponDamageLevel.Ruin; AccuracyLevel = WeaponAccuracyLevel.Surpassingly; break; } case CraftResource.Bronze: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Fortified; DamageLevel = WeaponDamageLevel.Might; AccuracyLevel = WeaponAccuracyLevel.Surpassingly; break; } case CraftResource.Gold: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Force; AccuracyLevel = WeaponAccuracyLevel.Eminently; break; } case CraftResource.Agapite: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Power; AccuracyLevel = WeaponAccuracyLevel.Eminently; break; } case CraftResource.Verite: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Power; AccuracyLevel = WeaponAccuracyLevel.Exceedingly; break; } case CraftResource.Valorite: { Identified = true; DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Vanq; AccuracyLevel = WeaponAccuracyLevel.Supremely; break; } } } } return quality; }
public void Craft(Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool) { if (from.BeginAction(typeof(CraftSystem))) { if (RequiredExpansion == Expansion.None || (from.NetState != null && from.NetState.SupportsExpansion(RequiredExpansion))) { bool allRequiredSkills = true; double chance = GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { if (this.Recipe == null || !(from is PlayerMobile) || ((PlayerMobile)from).HasRecipe(this.Recipe)) { int badCraft = craftSystem.CanCraft(from, tool, m_Type); if (badCraft <= 0) { int resHue = 0; int maxAmount = 0; object message = null; if (ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message)) { message = null; if (ConsumeAttributes(from, ref message, false)) { CraftContext context = craftSystem.GetContext(from); if (context != null) { context.OnMade(this); } int iMin = craftSystem.MinCraftEffect; int iMax = (craftSystem.MaxCraftEffect - iMin) + 1; int iRandom = Utility.Random(iMax); iRandom += iMin + 1; new InternalTimer(from, craftSystem, this, typeRes, tool, iRandom).Start(); } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, message)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, message)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, badCraft)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, 1072847)); // You must learn that recipe from a scroll. } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); // You don't have the required skills to attempt this item. } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, RequiredExpansionMessage(RequiredExpansion))); //The {0} expansion is required to attempt this item. } } else { from.SendLocalizedMessage(500119); // You must wait to perform another action } }
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40) { this.m_From = from; this.m_CraftSystem = craftSystem; this.m_Tool = tool; this.m_Page = page; CraftContext context = craftSystem.GetContext(from); from.CloseGump(typeof(CraftGump)); from.CloseGump(typeof(CraftGumpItem)); this.AddPage(0); AddBackground(0, 0, 530, 497, 5054); AddImageTiled(10, 10, 510, 22, 2624); AddImageTiled(10, 292, 150, 45, 2624); AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 145, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 477); if (craftSystem.GumpTitleNumber > 0) this.AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); else this.AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER> this.AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0); this.AddHtmlLocalized(50, 445, 150, 18, 1011441, LabelColor, false, false); // EXIT this.AddButton(115, 442, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0); this.AddHtmlLocalized(150, 445, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE // Repair option if (m_CraftSystem.Repair) { AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM } // **************************************** // Mark option if (m_CraftSystem.MarkOption) { AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM } // **************************************** // Enhance option if (m_CraftSystem.CanEnhance) { AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM } // **************************************** #region SA // Alter option if (Core.SA && m_CraftSystem.CanAlter) { AddButton(270, 402, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0); AddHtmlLocalized(304, 405, 250, 18, 1094726, LabelColor, false, false); // ALTER ITEM (Gargoyle) } // **************************************** // Quest item if (Core.SA) { AddButton(270, 422, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 425, 150, 18, context != null && context.QuestOption == CraftQuestOption.QuestItem ? 1112534 : 1112533, LabelColor, false, false); // QUEST ITEM } // **************************************** #endregion AddButton(270, 442, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 445, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST #region Stygian Abyss int total = 1; int made = 0; if (Locked && AutoCraftTimer.AutoCraftTable.ContainsKey(m_From)) { AutoCraftTimer timer = AutoCraftTimer.AutoCraftTable[m_From]; if (timer != null) { total = timer.Amount; made = timer.Attempts; } else { if (context != null) total = context.MakeTotal; } } string args = String.Format("{0}\t{1}", made.ToString(), total.ToString()); AddHtmlLocalized(270, 468, 150, 18, 1079443, args, LabelColor, false, false); //~1_DONE~/~2_TOTAL~ COMPLETED #endregion // Resmelt option if (m_CraftSystem.Resmelt) { AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM } // **************************************** if (notice is int && (int)notice > 0) this.AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false); else if (notice is string) this.AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false); // If the system has more than one resource if (craftSystem.CraftSubRes.Init) { string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex); Type resourceType = craftSystem.CraftSubRes.ResType; Type resourceType2 = GetAltType(resourceType); if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) resourceCount += items[i].Amount; if (resourceType2 != null) { Item[] items2 = m_From.Backpack.FindItemsByType(resourceType2, true); for (int i = 0; i < items2.Length; ++i) resourceCount += items2[i].Amount; } } this.AddButton(15, 382, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); if (nameNumber > 0) { if (context.DoNotColor) AddLabel(50, 385, LabelHue, "*"); AddHtmlLocalized(50 + (context.DoNotColor ? 13 : 0), 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else AddLabel(50, 382, LabelHue, (context.DoNotColor ? "*" : "") + String.Format("{0} ({1} Available)", nameString, resourceCount)); } // **************************************** // For dragon scales if (craftSystem.CraftSubRes2.Init) { string nameString = craftSystem.CraftSubRes2.NameString; int nameNumber = craftSystem.CraftSubRes2.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex2); Type resourceType = craftSystem.CraftSubRes2.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) resourceCount += items[i].Amount; } this.AddButton(15, 402, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); if (nameNumber > 0) AddHtmlLocalized(50, 405, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); else AddLabel(50, 405, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount)); } // **************************************** this.CreateGroupList(); if (page == CraftPage.PickResource) this.CreateResList(false, from); else if (page == CraftPage.PickResource2) this.CreateResList(true, from); else if (context != null && context.LastGroupIndex > -1) this.CreateItemList(context.LastGroupIndex); }
public void Craft(Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool) { if (from.BeginAction(typeof(CraftSystem))) { int flags = from.NetState == null ? 0 : from.NetState.Flags; if (!RequiresSE || (flags & 0x10) != 0) // SE 2D = 0x1F SE 3D = 0x11F { bool allRequiredSkills = true; double chance = GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { string badCraft = craftSystem.CanCraft(from, tool, m_Type); if (badCraft == "") { int resHue = 0; int maxAmount = 0; object message = null; if (ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message)) { message = null; if (ConsumeAttributes(from, ref message, false)) { CraftContext context = craftSystem.GetContext(from); if (context != null) { context.OnMade(this); } int iMin = craftSystem.MinCraftEffect; int iMax = (craftSystem.MaxCraftEffect - iMin) + 1; int iRandom = Utility.Random(iMax); iRandom += iMin + 1; new InternalTimer(from, craftSystem, this, typeRes, tool, iRandom).Start(); } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, message)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, message)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, badCraft)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); // You don't have the required skills to attempt this item. } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, 1063307)); //The "Samurai Empire" expansion is required to attempt this item. } } else { from.SendAsciiMessage("You must wait to perform another action."); } }
public override int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { Quality = (ArmorQuality)quality; if (makersMark) Crafter = from; Type resourceType = typeRes; if (resourceType == null) resourceType = craftItem.Resources.GetAt(0).ItemType; Resource = CraftResources.GetFromType(resourceType); PlayerConstructed = true; CraftContext context = craftSystem.GetContext(from); Hue = CraftResources.GetHue(Resource); return quality; }
public void CreateResList(bool opt, Mobile from) { CraftSubResCol res = (opt ? this.m_CraftSystem.CraftSubRes2 : this.m_CraftSystem.CraftSubRes); //daat99 OWLTR start - recipe craft bool b_RecipeCraft = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.RECIPE_CRAFT), b_Blacksmithy = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.BLACKSMITH_RECIPES), b_BowFletching = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.BOWFLETCH_RECIPES), b_Carpentry = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.CARPENTRY_RECIPES), b_Masonry = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.MASONRY_RECIPES), b_Tailoring = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.TAILORING_RECIPES), b_Tinkering = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.TINKERING_RECIPES); if (b_RecipeCraft) { NewDaat99Holder dh = (NewDaat99Holder)daat99.Daat99OWLTR.TempHolders[m_From]; int i_Length = 0; for (int i = 0; i < res.Count; ++i) { int index = i_Length % 10; CraftSubRes subResource = res.GetAt(i); if (!dh.Resources.Contains(CraftResources.GetFromType(subResource.ItemType)) || (!b_Blacksmithy && m_CraftSystem is DefBlacksmithy) || (!b_BowFletching && m_CraftSystem is DefBowFletching) || (!b_Carpentry && m_CraftSystem is DefCarpentry) || (!b_Masonry && m_CraftSystem is DefMasonry) || (!b_Tailoring && m_CraftSystem is DefTailoring) || (!b_Tinkering && m_CraftSystem is DefTinkering)) { 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); } 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, LabelColor, false, false); } else { AddLabel(255, 60 + (index * 20), LabelHue, subResource.NameString); } i_Length++; } } } else { //daat99 OWLTR end - recipe craft for (int i = 0; i < res.Count; ++i) { int index = i % 10; CraftSubRes subResource = res.GetAt(i); if (index == 0) { if (i > 0) { this.AddButton(485, 290, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1); } this.AddPage((i / 10) + 1); if (i > 0) { this.AddButton(455, 290, 4014, 4015, 0, GumpButtonType.Page, i / 10); } CraftContext context = this.m_CraftSystem.GetContext(this.m_From); this.AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0); this.AddHtmlLocalized(255, 260, 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; } Type alt = GetAltType(subResource.ItemType); if (alt != null) { Item[] items2 = m_From.Backpack.FindItemsByType(alt, true); for (int j = 0; j < items2.Length; ++j) { resourceCount += items2[j].Amount; } } //daat99 OWLTR start - craft from storage ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, subResource.ItemType); if (storageCount > 0) { if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue) { resourceCount += (int)storageCount; } else { resourceCount = int.MaxValue; } } //daat99 OWLTR end - craft from storage } this.AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0); if (subResource.NameNumber > 0) { this.AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false); } else { this.AddLabel(255, 60 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount)); } } } }
public virtual int OnCraft( int quality, bool makersMark, Mobile m, CraftSystem craftSystem, Type typeRes, //Compatibility with UOF fix IBaseTool tool, CraftItem craftItem, int resHue) { if (makersMark) { Crafter = m; } if (craftSystem is Pyrotechnics && craftItem != null) { CraftContext context = craftSystem.GetContext(m); if (context != null && !context.DoNotColor) { Hue = resHue; } CraftRes[] fuses = new CraftRes[craftItem.Resources.Count]; fuses.SetAll(i => craftItem.Resources.GetAt(i)); fuses = fuses.Where(res => res.ItemType.IsEqualOrChildOf<FireworkFuse>()).ToArray(); double fuseDelay = FuseDelay.TotalSeconds * fuses.Sum(r => r.Amount); if (fuseDelay > 0) { FuseDelay = TimeSpan.FromSeconds(fuseDelay); } } return quality; }
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40) { this.m_From = from; this.m_CraftSystem = craftSystem; this.m_Tool = tool; this.m_Page = page; CraftContext context = craftSystem.GetContext(from); from.CloseGump(typeof(CraftGump)); from.CloseGump(typeof(CraftGumpItem)); this.AddPage(0); AddBackground(0, 0, 530, 497, 5054); AddImageTiled(10, 10, 510, 22, 2624); AddImageTiled(10, 292, 150, 45, 2624); AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 145, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 477); if (craftSystem.GumpTitleNumber > 0) { this.AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); } else { this.AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); } AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER> this.AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0); this.AddHtmlLocalized(50, 445, 150, 18, 1011441, LabelColor, false, false); // EXIT this.AddButton(115, 442, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0); this.AddHtmlLocalized(150, 445, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE // Repair option if (m_CraftSystem.Repair) { AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM } // **************************************** // Mark option if (m_CraftSystem.MarkOption) { AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM } // **************************************** // Enhance option if (m_CraftSystem.CanEnhance) { AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM } // **************************************** #region SA // Alter option if (Core.SA && m_CraftSystem.CanAlter) { AddButton(270, 402, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0); AddHtmlLocalized(304, 405, 250, 18, 1094726, LabelColor, false, false); // ALTER ITEM (Gargoyle) } // **************************************** // Quest item if (Core.SA) { AddButton(270, 422, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 425, 150, 18, context != null && context.QuestOption == CraftQuestOption.QuestItem ? 1112534 : 1112533, LabelColor, false, false); // QUEST ITEM } // **************************************** #endregion AddButton(270, 442, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 445, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST #region Stygian Abyss int total = 1; int made = 0; if (Locked && AutoCraftTimer.AutoCraftTable.ContainsKey(m_From)) { AutoCraftTimer timer = AutoCraftTimer.AutoCraftTable[m_From]; if (timer != null) { total = timer.Amount; made = timer.Attempts; } else { if (context != null) { total = context.MakeTotal; } } } string args = String.Format("{0}\t{1}", made.ToString(), total.ToString()); AddHtmlLocalized(270, 468, 150, 18, 1079443, args, LabelColor, false, false); //~1_DONE~/~2_TOTAL~ COMPLETED #endregion // Resmelt option if (m_CraftSystem.Resmelt) { AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM } // **************************************** if (notice is int && (int)notice > 0) { this.AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false); } else if (notice is string) { this.AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false); } // If the system has more than one resource if (craftSystem.CraftSubRes.Init) { string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex); Type resourceType = craftSystem.CraftSubRes.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } Type resourceType2 = GetAltType(resourceType); int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } if (resourceType2 != null) { Item[] items2 = m_From.Backpack.FindItemsByType(resourceType2, true); for (int i = 0; i < items2.Length; ++i) { resourceCount += items2[i].Amount; } } //daat99 OWLTR start - craft from storage ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, resourceType); if (storageCount > 0) { if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue) { resourceCount += (int)storageCount; } else { resourceCount = int.MaxValue; } } //daat99 OWLTR end - craft from storage } this.AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); if (nameNumber > 0) { if (context.DoNotColor) { AddLabel(50, 365, LabelHue, "*"); } AddHtmlLocalized(50 + (context.DoNotColor ? 13 : 0), 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { AddLabel(50, 362, LabelHue, (context.DoNotColor ? "*" : "") + String.Format("{0} ({1} Available)", nameString, resourceCount)); } } // **************************************** // For dragon scales if (craftSystem.CraftSubRes2.Init) { string nameString = craftSystem.CraftSubRes2.NameString; int nameNumber = craftSystem.CraftSubRes2.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex2); Type resourceType = craftSystem.CraftSubRes2.ResType; if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } //daat99 OWLTR start - craft from storage ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, resourceType); if (storageCount > 0) { if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue) { resourceCount += (int)storageCount; } else { resourceCount = int.MaxValue; } } //daat99 OWLTR end - craft from storage } this.AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { AddLabel(50, 385, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount)); } } // **************************************** this.CreateGroupList(); if (page == CraftPage.PickResource) { this.CreateResList(false, from); } else if (page == CraftPage.PickResource2) { this.CreateResList(true, from); } else if (context != null && context.LastGroupIndex > -1) { this.CreateItemList(context.LastGroupIndex); } }
public void CompleteCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CustomCraft customCraft) { int badCraft = craftSystem.CanCraft(from, tool, m_Type); if (badCraft > 0) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, badCraft)); } else { from.SendLocalizedMessage(badCraft); } AutoCraftTimer.EndTimer(from); return; } int checkResHue = 0, checkMaxAmount = 0; object checkMessage = null; // Not enough resource to craft it if (!ConsumeRes(from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage)); } else if (checkMessage is int && (int)checkMessage > 0) { from.SendLocalizedMessage((int)checkMessage); } else if (checkMessage is string) { from.SendMessage((string)checkMessage); } AutoCraftTimer.EndTimer(from); return; } else if (!ConsumeAttributes(from, ref checkMessage, false)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage)); } else if (checkMessage is int && (int)checkMessage > 0) { from.SendLocalizedMessage((int)checkMessage); } else if (checkMessage is string) { from.SendMessage((string)checkMessage); } AutoCraftTimer.EndTimer(from); return; } bool toolBroken = false; int ignored = 1; int endquality = 1; bool allRequiredSkills = true; if (CheckSkills(from, typeRes, craftSystem, ref ignored, ref allRequiredSkills)) { // Resource int resHue = 0; int maxAmount = 0; object message = null; // Not enough resource to craft it if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, message)); } else if (message is int && (int)message > 0) { from.SendLocalizedMessage((int)message); } else if (message is string) { from.SendMessage((string)message); } AutoCraftTimer.EndTimer(from); return; } else if (!ConsumeAttributes(from, ref message, true)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, message)); } else if (message is int && (int)message > 0) { from.SendLocalizedMessage((int)message); } else if (message is string) { from.SendMessage((string)message); } AutoCraftTimer.EndTimer(from); return; } tool.UsesRemaining--; if (craftSystem is DefBlacksmithy) { AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer; if (hammer != null && hammer != tool) { #region Mondain's Legacy if (hammer is HammerOfHephaestus) { if (hammer.UsesRemaining > 0) { hammer.UsesRemaining--; } if (hammer.UsesRemaining < 1) { from.PlaceInBackpack(hammer); } } else { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } #endregion } } #region Mondain's Legacy if (tool is HammerOfHephaestus) { if (tool.UsesRemaining < 1) { tool.UsesRemaining = 0; } } else { if (tool.UsesRemaining < 1) { toolBroken = true; } if (toolBroken) { tool.Delete(); } } #endregion int num = 0; Item item; if (customCraft != null) { item = customCraft.CompleteCraft(out num); } else if (typeof(MapItem).IsAssignableFrom(ItemType) && from.Map != Map.Trammel && from.Map != Map.Felucca) { item = new IndecipherableMap(); from.SendLocalizedMessage(1070800); // The map you create becomes mysteriously indecipherable. } else { item = Activator.CreateInstance(ItemType) as Item; } if (item != null) { #region Mondain's Legacy if (item is Board) { Type resourceType = typeRes; if (resourceType == null) { resourceType = Resources.GetAt(0).ItemType; } CraftResource thisResource = CraftResources.GetFromType(resourceType); switch (thisResource) { case CraftResource.OakWood: item = new OakBoard(); break; case CraftResource.AshWood: item = new AshBoard(); break; case CraftResource.YewWood: item = new YewBoard(); break; case CraftResource.Heartwood: item = new HeartwoodBoard(); break; case CraftResource.Bloodwood: item = new BloodwoodBoard(); break; case CraftResource.Frostwood: item = new FrostwoodBoard(); break; default: item = new Board(); break; } } #endregion if (item is ICraftable) { endquality = ((ICraftable)item).OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, this, resHue); } else if (item is Food) { ((Food)item).PlayerConstructed = true; } else if (item.Hue == 0) { item.Hue = resHue; } if (maxAmount > 0) { if (!item.Stackable && item is IUsesRemaining) { ((IUsesRemaining)item).UsesRemaining *= maxAmount; } else { item.Amount = maxAmount; } } #region Plant Pigments if (item is PlantPigment && (craftSystem is DefAlchemy || craftSystem is DefCooking)) { ((PlantPigment)item).PigmentHue = PlantPigmentHueInfo.HueFromPlantHue(m_PlantHue); } if (item is NaturalDye && (craftSystem is DefAlchemy || craftSystem is DefCooking)) { ((NaturalDye)item).PigmentHue = PlantPigmentHueInfo.GetInfo(m_PlantPigmentHue).PlantPigmentHue; } if (item is SoftenedReeds && (craftSystem is DefAlchemy || craftSystem is DefCooking)) { ((SoftenedReeds)item).PlantHue = PlantHueInfo.GetInfo(m_PlantHue).PlantHue; } if (item is BaseContainer && (craftSystem is DefBasketweaving)) { (item).Hue = PlantHueInfo.GetInfo(m_PlantHue).Hue; } CraftContext context = craftSystem.GetContext(from); if (context.QuestOption == CraftQuestOption.QuestItem) { PlayerMobile px = from as PlayerMobile; if (!QuestHelper.CheckItem(px, item)) from.SendLocalizedMessage(1072355, null, 0x23); // That item does not match any of your quest criteria } #endregion from.AddToBackpack(item); if (from.IsStaff()) { CommandLogging.WriteLine( from, "Crafting {0} with craft system {1}", CommandLogging.Format(item), craftSystem.GetType().Name); } AutoCraftTimer.OnSuccessfulCraft(from); //from.PlaySound( 0x57 ); } if (num == 0) { num = craftSystem.PlayEndingEffect(from, false, true, toolBroken, endquality, makersMark, this); } bool queryFactionImbue = false; int availableSilver = 0; FactionItemDefinition def = null; Faction faction = null; if (item is IFactionItem) { def = FactionItemDefinition.Identify(item); if (def != null) { faction = Faction.Find(from); if (faction != null) { Town town = Town.FromRegion(from.Region); if (town != null && town.Owner == faction) { Container pack = from.Backpack; if (pack != null) { availableSilver = pack.GetAmount(typeof(Silver)); if (availableSilver >= def.SilverCost) { queryFactionImbue = Faction.IsNearType(from, def.VendorType, 12); } } } } } } // TODO: Scroll imbuing if (queryFactionImbue) { from.SendGump(new FactionImbueGump(quality, item, from, craftSystem, tool, num, availableSilver, faction, def)); } else if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, num)); } else if (num > 0) { from.SendLocalizedMessage(num); } } else if (!allRequiredSkills) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); } else { from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item. } AutoCraftTimer.EndTimer(from); } else { ConsumeType consumeType = (UseAllRes ? ConsumeType.Half : ConsumeType.All); int resHue = 0; int maxAmount = 0; object message = null; // Not enough resource to craft it if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, message)); } else if (message is int && (int)message > 0) { from.SendLocalizedMessage((int)message); } else if (message is string) { from.SendMessage((string)message); } AutoCraftTimer.EndTimer(from); return; } tool.UsesRemaining--; if (tool.UsesRemaining < 1) { toolBroken = true; } if (toolBroken) { tool.Delete(); } // SkillCheck failed. int num = craftSystem.PlayEndingEffect(from, true, true, toolBroken, endquality, false, this); if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, num)); } else if (num > 0) { from.SendLocalizedMessage(num); } } }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID <= 0) { return; // Canceled } int buttonID = info.ButtonID - 1; int type = buttonID % 7; int index = buttonID / 7; CraftSystem system = this.m_CraftSystem; CraftGroupCol groups = system.CraftGroups; CraftContext context = system.GetContext(this.m_From); #region Stygian Abyss if (Locked) { if (type == 6 && index == 11) { // Cancel Make AutoCraftTimer.EndTimer(m_From); } return; } #endregion switch (type) { case 0: // Show group { if (context == null) { break; } if (index >= 0 && index < groups.Count) { context.LastGroupIndex = index; this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null)); } break; } case 1: // Create item { if (context == null) { break; } int groupIndex = context.LastGroupIndex; if (groupIndex >= 0 && groupIndex < groups.Count) { CraftGroup group = groups.GetAt(groupIndex); if (index >= 0 && index < group.CraftItems.Count) { this.CraftItem(group.CraftItems.GetAt(index)); } } break; } case 2: // Item details { if (context == null) { break; } int groupIndex = context.LastGroupIndex; if (groupIndex >= 0 && groupIndex < groups.Count) { CraftGroup group = groups.GetAt(groupIndex); if (index >= 0 && index < group.CraftItems.Count) { this.m_From.SendGump(new CraftGumpItem(this.m_From, system, group.CraftItems.GetAt(index), this.m_Tool)); } } break; } case 3: // Create item (last 10) { if (context == null) { break; } List <CraftItem> lastTen = context.Items; if (index >= 0 && index < lastTen.Count) { this.CraftItem(lastTen[index]); } break; } case 4: // Item details (last 10) { if (context == null) { break; } List <CraftItem> lastTen = context.Items; if (index >= 0 && index < lastTen.Count) { this.m_From.SendGump(new CraftGumpItem(this.m_From, system, lastTen[index], this.m_Tool)); } break; } case 5: // Resource selected { if (this.m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count) { int groupIndex = (context == null ? -1 : context.LastGroupIndex); CraftSubRes res = system.CraftSubRes.GetAt(index); if (this.m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex = index; } this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null)); } } else if (this.m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count) { int groupIndex = (context == null ? -1 : context.LastGroupIndex); CraftSubRes res = system.CraftSubRes2.GetAt(index); if (this.m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex2 = index; } this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null)); } } break; } case 6: // Misc. buttons { switch (index) { case 0: // Resource selection { if (system.CraftSubRes.Init) { this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null, CraftPage.PickResource)); } break; } case 1: // Smelt item { if (system.Resmelt) { Resmelt.Do(this.m_From, system, this.m_Tool); } break; } case 2: // Make last { if (context == null) { break; } CraftItem item = context.LastMade; if (item != null) { this.CraftItem(item); } else { this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, 1044165, this.m_Page)); // You haven't made anything yet. } break; } case 3: // Last 10 { if (context == null) { break; } context.LastGroupIndex = 501; this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null)); break; } case 4: // Toggle use resource hue { if (context == null) { break; } context.DoNotColor = !context.DoNotColor; this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page)); break; } case 5: // Repair item { if (system.Repair) { Repair.Do(this.m_From, system, this.m_Tool); } break; } case 6: // Toggle mark option { if (context == null || !system.MarkOption) { break; } switch (context.MarkOption) { case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break; case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break; case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break; } this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page)); break; } case 7: // Resource selection 2 { if (system.CraftSubRes2.Init) { this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null, CraftPage.PickResource2)); } break; } case 8: // Enhance item { if (system.CanEnhance) { Enhance.BeginTarget(this.m_From, system, this.m_Tool); } break; } #region Stygian Abyss case 9: // Alter Item (Gargoyle) { if (system.CanAlter) { if (Server.SkillHandlers.Imbuing.CheckSoulForge(m_From, 1, false)) { AlterItem.BeginTarget(this.m_From, system, this.m_Tool); } else { m_From.SendLocalizedMessage(1111867); // You must be near a soulforge to alter an item. } } break; } case 10: // Quest Item/Non Quest Item toggle { //if (context == null || !system.QuestOption) //break; switch (context.QuestOption) { case CraftQuestOption.QuestItem: context.QuestOption = CraftQuestOption.NonQuestItem; break; case CraftQuestOption.NonQuestItem: context.QuestOption = CraftQuestOption.QuestItem; break; } this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page)); break; } case 11: // Cancel Make { AutoCraftTimer.EndTimer(m_From); break; } #endregion } break; } } }
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { if ( Core.ML ) { Quality = (CraftQuality)quality; if ( makersMark ) Crafter = from; Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Resources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Resource = DefaultResource; } else Resource = DefaultResource; return quality; }
public CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page = CraftPage.None ) : base(40, 40) { m_From = from; m_CraftSystem = craftSystem; m_Tool = tool; m_Page = page; var context = craftSystem.GetContext(from); from.CloseGump <CraftGump>(); from.CloseGump <CraftGumpItem>(); AddPage(0); AddBackground(0, 0, 530, 437, 5054); AddImageTiled(10, 10, 510, 22, 2624); AddImageTiled(10, 292, 150, 45, 2624); AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 85, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 417); if (craftSystem.GumpTitleNumber > 0) { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor); } else { AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString); } AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor); // <CENTER>NOTICES</CENTER> AddButton(15, 402, 4017, 4019, 0); AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor); // EXIT AddButton(270, 402, 4005, 4007, GetButtonID(6, 2)); AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor); // MAKE LAST // Mark option if (craftSystem.MarkOption) { AddButton(270, 362, 4005, 4007, GetButtonID(6, 6)); AddHtmlLocalized( 305, 365, 150, 18, 1044017 + (int)(context?.MarkOption ?? CraftMarkOption.MarkItem), // MARK ITEM LabelColor ); } // **************************************** // Resmelt option if (craftSystem.Resmelt) { AddButton(15, 342, 4005, 4007, GetButtonID(6, 1)); AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor); // SMELT ITEM } // **************************************** // Repair option if (craftSystem.Repair) { AddButton(270, 342, 4005, 4007, GetButtonID(6, 5)); AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor); // REPAIR ITEM } // **************************************** // Enhance option if (craftSystem.CanEnhance) { AddButton(270, 382, 4005, 4007, GetButtonID(6, 8)); AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor); // ENHANCE ITEM } // **************************************** if (notice is int noticeInt && noticeInt > 0) { AddHtmlLocalized(170, 295, 350, 40, noticeInt, LabelColor); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { Type resourceType = typeRes; if (resourceType == null) resourceType = craftItem.Resources.GetAt(0).ItemType; if (!craftItem.ForceNonExceptional) this.Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) this.Hue = 0; if (1 < craftItem.Resources.Count) { resourceType = craftItem.Resources.GetAt(1).ItemType; if (resourceType == typeof(StarSapphire)) this.GemType = GemType.StarSapphire; else if (resourceType == typeof(Emerald)) this.GemType = GemType.Emerald; else if (resourceType == typeof(Sapphire)) this.GemType = GemType.Sapphire; else if (resourceType == typeof(Ruby)) this.GemType = GemType.Ruby; else if (resourceType == typeof(Citrine)) this.GemType = GemType.Citrine; else if (resourceType == typeof(Amethyst)) this.GemType = GemType.Amethyst; else if (resourceType == typeof(Tourmaline)) this.GemType = GemType.Tourmaline; else if (resourceType == typeof(Amber)) this.GemType = GemType.Amber; else if (resourceType == typeof(Diamond)) this.GemType = GemType.Diamond; } #region Mondain's Legacy this.m_Quality = (ArmorQuality)quality; if (makersMark) this.m_Crafter = from; #endregion return 1; }
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40) { m_From = from; m_CraftSystem = craftSystem; m_Tool = tool; m_Page = page; CraftContext context = craftSystem.GetContext(from); from.CloseGump(typeof(CraftGump)); from.CloseGump(typeof(CraftGumpItem)); AddPage(0); AddBackground(0, 0, 530, 437, 5054); AddImageTiled(10, 10, 510, 22, 2624); AddImageTiled(10, 292, 150, 45, 2624); AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 85, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 417); if (craftSystem.GumpTitleNumber > 0) { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); } else { AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); } AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER> AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false); // EXIT AddButton(270, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST // Mark option if (craftSystem.MarkOption) { AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM } // **************************************** // Resmelt option if (craftSystem.Resmelt) { AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM } // **************************************** // Repair option if (craftSystem.Repair) { AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM } // **************************************** // Enhance option if (craftSystem.CanEnhance) { AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM } // **************************************** if (notice is int && (int)notice > 0) { AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false); } else if (notice is string) { AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false); } // If the system has more than one resource if (craftSystem.CraftSubRes.Init) { string nameString = craftSystem.CraftSubRes.NameString; int nameNumber = craftSystem.CraftSubRes.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex); if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; } AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 365, 250, 18, nameNumber, LabelColor, false, false); } else { AddLabel(50, 362, LabelHue, nameString); } } // **************************************** // For dragon scales if (craftSystem.CraftSubRes2.Init) { string nameString = craftSystem.CraftSubRes2.NameString; int nameNumber = craftSystem.CraftSubRes2.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex2); if (resIndex > -1) { CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; } AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 385, 250, 18, nameNumber, LabelColor, false, false); } else { AddLabel(50, 385, LabelHue, nameString); } } // **************************************** CreateGroupList(); if (page == CraftPage.PickResource) { CreateResList(false); } else if (page == CraftPage.PickResource2) { CreateResList(true); } else if (context != null && context.LastGroupIndex > -1) { CreateItemList(context.LastGroupIndex); } }
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { if( !Identified ) Identified = true; Quality = (WeaponQuality)quality; if( makersMark ) Crafter = from; PlayerConstructed = true; Type resourceType = typeRes; if( resourceType == null ) resourceType = craftItem.Resources.GetAt(0).ItemType; Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if( context != null && context.DoNotColor ) Hue = 0; if( Core.AOS ) { if( tool is BaseRunicTool ) ((BaseRunicTool)tool).ApplyAttributesTo(this); if( Quality == WeaponQuality.Exceptional ) { if( Attributes.WeaponDamage > 35 ) Attributes.WeaponDamage -= 20; else Attributes.WeaponDamage = 15; } } else if( tool is BaseRunicTool ) { CraftResource thisResource = CraftResources.GetFromType(resourceType); if( thisResource == ((BaseRunicTool)tool).Resource ) { switch( thisResource ) { case CraftResource.DullCopper: { DurabilityLevel = WeaponDurabilityLevel.Durable; AccuracyLevel = WeaponAccuracyLevel.Accurate; break; } case CraftResource.ShadowIron: { DurabilityLevel = WeaponDurabilityLevel.Durable; DamageLevel = WeaponDamageLevel.Ruin; break; } case CraftResource.Copper: { DurabilityLevel = WeaponDurabilityLevel.Fortified; DamageLevel = WeaponDamageLevel.Ruin; AccuracyLevel = WeaponAccuracyLevel.Surpassingly; break; } case CraftResource.Bronze: { DurabilityLevel = WeaponDurabilityLevel.Fortified; DamageLevel = WeaponDamageLevel.Might; AccuracyLevel = WeaponAccuracyLevel.Surpassingly; break; } case CraftResource.Gold: { DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Force; AccuracyLevel = WeaponAccuracyLevel.Eminently; break; } case CraftResource.Agapite: { DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Power; AccuracyLevel = WeaponAccuracyLevel.Eminently; break; } case CraftResource.Verite: { DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Power; AccuracyLevel = WeaponAccuracyLevel.Exceedingly; break; } case CraftResource.Valorite: { DurabilityLevel = WeaponDurabilityLevel.Indestructible; DamageLevel = WeaponDamageLevel.Vanq; AccuracyLevel = WeaponAccuracyLevel.Supremely; break; } } } } return quality; }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID <= 0) { return; // Canceled } int buttonID = info.ButtonID - 1; int type = buttonID % 7; int index = buttonID / 7; CraftSystem system = m_CraftSystem; CraftGroupCol groups = system.CraftGroups; CraftContext context = system.GetContext(m_From); switch (type) { case 0: // Show group { if (context == null) { break; } if (index >= 0 && index < groups.Count) { context.LastGroupIndex = index; m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } break; } case 1: // Create item { if (context == null) { break; } int groupIndex = context.LastGroupIndex; if (groupIndex >= 0 && groupIndex < groups.Count) { CraftGroup group = groups.GetAt(groupIndex); if (index >= 0 && index < group.CraftItems.Count) { CraftItem(group.CraftItems.GetAt(index)); } } break; } case 2: // Item details { if (context == null) { break; } int groupIndex = context.LastGroupIndex; if (groupIndex >= 0 && groupIndex < groups.Count) { CraftGroup group = groups.GetAt(groupIndex); if (index >= 0 && index < group.CraftItems.Count) { m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool)); } } break; } case 3: // Create item (last 10) { if (context == null) { break; } ArrayList lastTen = context.Items; if (index >= 0 && index < lastTen.Count) { CraftItem((CraftItem)lastTen[index]); } break; } case 4: // Item details (last 10) { if (context == null) { break; } ArrayList lastTen = context.Items; if (index >= 0 && index < lastTen.Count) { m_From.SendGump(new CraftGumpItem(m_From, system, (CraftItem)lastTen[index], m_Tool)); } break; } case 5: // Resource selected { if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count) { CraftSubRes res = system.CraftSubRes.GetAt(index); if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex = index; } m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } } else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count) { CraftSubRes res = system.CraftSubRes2.GetAt(index); if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex2 = index; } m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } } break; } case 6: // Misc. buttons { switch (index) { case 0: // Resource selection { if (system.CraftSubRes.Init) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource)); } break; } case 1: // Smelt item { if (system.Resmelt) { Resmelt.Do(m_From, system, m_Tool); } break; } case 2: // Make last { if (context == null) { break; } CraftItem item = context.LastMade; if (item != null) { CraftItem(item); } else { m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page)); // You haven't made anything yet. } break; } case 3: // Last 10 { if (context == null) { break; } context.LastGroupIndex = 501; m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); break; } case 4: // Toggle use resource hue { if (context == null) { break; } context.DoNotColor = !context.DoNotColor; m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } case 5: // Repair item { if (system.Repair) { Repair.Do(m_From, system, m_Tool); } break; } case 6: // Toggle mark option { if (context == null || !system.MarkOption) { break; } switch (context.MarkOption) { case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break; case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break; case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break; } m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); break; } case 7: // Resource selection 2 { if (system.CraftSubRes2.Init) { m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2)); } break; } case 8: // Enhance item { if (system.CanEnhance) { Enhance.BeginTarget(m_From, system, m_Tool); } break; } } break; } } }
public void Craft( Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool ) { if ( from.BeginAction( typeof( CraftSystem ) ) ) { if( RequiredExpansion == Expansion.None || ( from.NetState != null && from.NetState.SupportsExpansion( RequiredExpansion ) ) ) { bool allRequiredSkills = true; double chance = GetSuccessChance( from, typeRes, craftSystem, false, ref allRequiredSkills ); if ( allRequiredSkills && chance >= 0.0 ) { if( this.Recipe == null || !(from is PlayerMobile) || ((PlayerMobile)from).HasRecipe( this.Recipe ) ) { int badCraft = craftSystem.CanCraft( from, tool, m_Type ); if( badCraft <= 0 ) { int resHue = 0; int maxAmount = 0; object message = null; if( ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message ) ) { message = null; if( ConsumeAttributes( from, ref message, false ) ) { CraftContext context = craftSystem.GetContext( from ); if( context != null ) context.OnMade( this ); int iMin = craftSystem.MinCraftEffect; int iMax = (craftSystem.MaxCraftEffect - iMin) + 1; int iRandom = Utility.Random( iMax ); iRandom += iMin + 1; new InternalTimer( from, craftSystem, this, typeRes, tool, iRandom ).Start(); } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, message ) ); } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, message ) ); } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, badCraft ) ); } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, 1072847 ) ); // You must learn that recipe from a scroll. } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, 1044153 ) ); // You don't have the required skills to attempt this item. } } else { from.EndAction( typeof( CraftSystem ) ); from.SendGump( new CraftGump( from, craftSystem, tool, RequiredExpansionMessage( RequiredExpansion ) ) ); //The {0} expansion is required to attempt this item. } } else { from.SendLocalizedMessage( 500119 ); // You must wait to perform another action } }
protected override void OnTick() { m_iCount++; m_From.DisruptiveAction(); if (m_iCount < m_iCountMax) { m_CraftSystem.PlayCraftEffect(m_From); } else { m_From.EndAction(typeof(CraftSystem)); int badCraft = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.m_Type); if (badCraft > 0) { if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0) { m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, badCraft)); } else { m_From.SendLocalizedMessage(badCraft); } return; } int quality = 1; bool allRequiredSkills = true; m_CraftItem.CheckSkills(m_From, m_TypeRes, m_CraftSystem, ref quality, ref allRequiredSkills, false); CraftContext context = m_CraftSystem.GetContext(m_From); if (context == null) { return; } bool makersMark = false; if (quality == 2 && m_From.Skills[m_CraftSystem.MainSkill].Base >= 100.0) { makersMark = m_CraftItem.IsMarkable(m_CraftItem.ItemType); } if (makersMark && context.MarkOption == CraftMarkOption.PromptForMark) { m_From.SendGump(new QueryMakersMarkGump(quality, m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool)); } else { if (context.MarkOption == CraftMarkOption.DoNotMark) { makersMark = false; } m_CraftItem.CompleteCraft(quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool); } } }
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Quality = (ArmorQuality)quality; if ( makersMark ) Crafter = from; #region Mondain's Legacy if ( !craftItem.ForceNonExceptional ) { Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Resources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); } #endregion PlayerConstructed = true; CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; if( Quality == ArmorQuality.Exceptional ) { DistributeBonuses( (tool is BaseRunicTool ? 6 : Core.SE ? 15 : 14) ); // Not sure since when, but right now 15 points are added, not 14. if( Core.ML && !(this is BaseShield) ) { int bonus = (int)(from.Skills.ArmsLore.Value / 20); for( int i = 0; i < bonus; i++ ) { switch( Utility.Random( 5 ) ) { case 0: m_PhysicalBonus++; break; case 1: m_FireBonus++; break; case 2: m_ColdBonus++; break; case 3: m_EnergyBonus++; break; case 4: m_PoisonBonus++; break; } } from.CheckSkill( SkillName.ArmsLore, 0, 100 ); } } #region Mondain's Legacy if ( craftItem != null && !craftItem.ForceNonExceptional ) { if ( Core.AOS && tool is BaseRunicTool ) ( (BaseRunicTool) tool ).ApplyAttributesTo( this ); if ( Core.ML ) { CraftResourceInfo resInfo = CraftResources.GetInfo( m_Resource ); if ( resInfo == null ) return quality; CraftAttributeInfo attrInfo = resInfo.AttributeInfo; if ( attrInfo == null ) return quality; if ( m_Resource != CraftResource.Heartwood ) { m_AosAttributes.WeaponDamage += attrInfo.ArmorDamage; m_AosAttributes.AttackChance += attrInfo.ArmorHitChance; m_AosAttributes.RegenHits += attrInfo.ArmorRegenHits; m_AosArmorAttributes.MageArmor += attrInfo.ArmorMage; } else { switch ( Utility.Random( 5 ) ) { case 0: m_AosAttributes.WeaponDamage += attrInfo.ArmorDamage; break; case 1: m_AosAttributes.AttackChance += attrInfo.ArmorHitChance; break; case 2: m_AosArmorAttributes.MageArmor += attrInfo.ArmorMage; break; case 3: m_AosAttributes.Luck += attrInfo.ArmorLuck; break; case 4: m_AosArmorAttributes.LowerStatReq += attrInfo.ArmorLowerRequirements; break; } } } } #endregion return quality; }
public void Craft(Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool) { if (from.BeginAction(typeof(CraftSystem))) { Item item = Activator.CreateInstance(ItemType) as Item; if (item is BaseCraftableTrap) { BaseCraftableTrap trap = item as BaseCraftableTrap; trap.OnCraft(0, false, from, craftSystem, typeRes, tool, this, 0); return; } if (item is CutUpCloth) { CutUpCloth cutup = item as CutUpCloth; Item[] items = from.Backpack.FindItemsByType(typeof(BoltOfCloth)); if (items.Length > 0) { cutup.CutUp(from, items); 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. } from.EndAction(typeof(CraftSystem)); if (!toolBroken) { // You create the item. from.SendGump(new CraftGump(from, craftSystem, tool, 1044154)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, 1044253)); // You don't have the components needed to make that. } cutup.Delete(); return; } if (item is CombineCloth) { CombineCloth combine = item as CombineCloth; Item[] items = from.Backpack.FindItemsByType(typeof(Cloth)); if (items.Length > 0) { combine.Combine(from, items); 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. } from.EndAction(typeof(CraftSystem)); if (!toolBroken) { // You create the item. from.SendGump(new CraftGump(from, craftSystem, tool, 1044154)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, 1044253)); // You don't have the components needed to make that. } combine.Delete(); return; } item.Delete(); int flags = from.NetState == null ? 0 : from.NetState.Flags; if (!RequiresSE || (flags & 0x10) != 0) // SE 2D = 0x1F SE 3D = 0x11F { bool allRequiredSkills = true; double chance = GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { int badCraft = craftSystem.CanCraft(from, tool, m_Type); if (badCraft <= 0) { int resHue = 0; int maxAmount = 0; object message = null; if (ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message)) { message = null; if (ConsumeAttributes(from, ref message, false)) { CraftContext context = craftSystem.GetContext(from); if (context != null) { context.OnMade(this); } int iMin = craftSystem.MinCraftEffect; int iMax = (craftSystem.MaxCraftEffect - iMin) + 1; int iRandom = Utility.Random(iMax); iRandom += iMin + 1; new InternalTimer(from, craftSystem, this, typeRes, tool, iRandom).Start(); } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, message)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, message)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, badCraft)); } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); // You don't have the required skills to attempt this item. } } else { from.EndAction(typeof(CraftSystem)); from.SendGump(new CraftGump(from, craftSystem, tool, 1063307)); //The "Samurai Empire" expansion is required to attempt this item. } } else { from.SendLocalizedMessage(500119); // You must wait to perform another action } }
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Exceptional = ( quality >= 2 ); if ( makersMark ) Crafter = from; Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Ressources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; return quality; }
protected override void OnTarget(Mobile from, object targeted) { int number; if (!CheckDeed(from)) { return; } var usingDeed = m_Deed != null; var toDelete = false; // TODO: Make an IRepairable if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267) { number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's * } else if (m_CraftSystem is DefTinkering && targeted is Golem g) { var damage = g.HitsMax - g.Hits; if (g.IsDeadBondedPet) { number = 500426; // You can't repair that. } else if (damage <= 0) { number = 500423; // That is already in full repair. } else { var skillValue = usingDeed ? m_Deed.SkillLevel : from.Skills.Tinkering.Value; if (skillValue < 60.0) { number = 1044153; // You don't have the required skills to attempt this item. //TODO: How does OSI handle this with deeds with golems? } else if (!from.CanBeginAction <Golem>()) { number = 501789; // You must wait before trying again. } else { if (damage > (int)(skillValue * 0.3)) { damage = (int)(skillValue * 0.3); } damage += 30; if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0)) { damage /= 2; } var pack = from.Backpack; if (pack != null) { var v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5); if (v > 0) { g.Hits += v * 5; number = 1044279; // You repair the item. toDelete = true; from.BeginAction <Golem>(); Timer.StartTimer(TimeSpan.FromSeconds(12.0), from.EndAction <Golem>); } else { number = 1044037; // You do not have sufficient metal to make that. } } else { number = 1044037; // You do not have sufficient metal to make that. } } } } else if (targeted is BaseWeapon weapon) { var skill = m_CraftSystem.MainSkill; var toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { var skillLevel = usingDeed ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon)) { number = usingDeed ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (!Core.AOS && weapon.PoisonCharges != 0) { number = 1005012; // You cannot repair an item while a caustic substance is on it. } else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (weapon.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { weapon.MaxHitPoints -= toWeaken; weapon.HitPoints = Math.Max(0, weapon.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.HitPoints = weapon.MaxHitPoints; } else { number = usingDeed ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseArmor armor) { var skill = m_CraftSystem.MainSkill; var toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { var skillLevel = usingDeed ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !IsSpecialArmor(armor)) { number = usingDeed ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (armor.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints)) { armor.MaxHitPoints -= toWeaken; armor.HitPoints = Math.Max(0, armor.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); armor.HitPoints = armor.MaxHitPoints; } else { number = usingDeed ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseClothing clothing) { var skill = m_CraftSystem.MainSkill; var toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { var skillLevel = usingDeed ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !IsSpecialClothing(clothing) && !(clothing is TribalMask || clothing is HornedTribalMask)) { number = usingDeed ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (clothing.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { clothing.MaxHitPoints -= toWeaken; clothing.HitPoints = Math.Max(0, clothing.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); clothing.HitPoints = clothing.MaxHitPoints; } else { number = usingDeed ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (!usingDeed && targeted is BlankScroll scroll) { var skill = m_CraftSystem.MainSkill; if (from.Skills[skill].Value >= 50.0) { scroll.Consume(1); var deed = new RepairDeed( RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from ); from.AddToBackpack(deed); number = 500442; // You create the item and put it in your backpack. } else { number = 1047005; // You must be at least apprentice level to create a repair service contract. } } else if (targeted is Item) { number = usingDeed ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else { number = 500426; // You can't repair that. } if (!usingDeed) { var context = m_CraftSystem.GetContext(from); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number)); } else { from.SendLocalizedMessage(number); if (toDelete) { m_Deed.Delete(); } } }
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) { Quality = (ClothingQuality)quality; if ( makersMark ) Crafter = from; if ( DefaultResource != CraftResource.None ) { Type resourceType = typeRes; if ( resourceType == null ) resourceType = craftItem.Ressources.GetAt( 0 ).ItemType; Resource = CraftResources.GetFromType( resourceType ); } else { Hue = resHue; } PlayerConstructed = true; CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) Hue = 0; return quality; }
public void DrawResource() { bool retainedColor = false; CraftContext context = CraftSystem.GetContext(From); CraftSubResCol res = CraftItem.UseSubRes2 ? CraftSystem.CraftSubRes2 : CraftSystem.CraftSubRes; int resIndex = -1; if (context != null) { resIndex = CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex; } bool cropScroll = CraftItem.Resources.Count > 1 && CraftItem.Resources[CraftItem.Resources.Count - 1].ItemType == typeofBlankScroll && typeofSpellScroll.IsAssignableFrom(CraftItem.ItemType); for (int i = 0; i < CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++) { Type type; string nameString; int nameNumber; CraftRes craftResource = CraftItem.Resources[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 && CraftItem.RetainsColorFrom(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 (CraftItem.NameNumber == 1041267) // runebook { AddHtmlLocalized(170, 219 + CraftItem.Resources.Count * 20, 310, 18, 1044447, LabelColor, false, false); AddLabel(430, 219 + 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. } }