public void Add( CraftRes craftRes ) { List.Add( craftRes ); }
private bool Resmelt(Mobile from, Item item, CraftResource resource) { try { if (CraftResources.GetType(resource) != CraftResourceType.Metal) { return(false); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(false); } CraftItem craftItem = DefBlacksmithy.CraftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) { return(false); } CraftRes craftResource = craftItem.Resources.GetAt(0); if (craftResource.Amount < 2) { return(false); // Not enough metal to resmelt } var difficulty = resource switch { CraftResource.DullCopper => 65.0, CraftResource.ShadowIron => 70.0, CraftResource.Copper => 75.0, CraftResource.Bronze => 80.0, CraftResource.Gold => 85.0, CraftResource.Agapite => 90.0, CraftResource.Verite => 95.0, CraftResource.Valorite => 99.0, _ => 0.0 }; Type resourceType = info.ResourceTypes[0]; Item ingot = (Item)ActivatorUtil.CreateInstance(resourceType); if (item is DragonBardingDeed || item is BaseArmor armor && armor.PlayerConstructed || item is BaseWeapon weapon && weapon.PlayerConstructed || item is BaseClothing clothing && clothing.PlayerConstructed) { double mining = from.Skills.Mining.Value; if (mining > 100.0) { mining = 100.0; } double amount = ((4 + mining) * craftResource.Amount - 4) * 0.0068; if (amount < 2) { ingot.Amount = 2; } else { ingot.Amount = (int)amount; } } else { ingot.Amount = 2; } if (difficulty > from.Skills.Mining.Value) { m_Failure = true; ingot.Delete(); } else { item.Delete(); } from.AddToBackpack(ingot); from.PlaySound(0x2A); from.PlaySound(0x240); return(true); }
public static int GetPointsForEquipment(Item item) { if (item is IEpiphanyArmor) { return(1000); } foreach (CraftSystem system in CraftSystem.Systems) { CraftItem crItem = null; if (system != null && system.CraftItems != null) { var type = item.GetType(); if (type == typeof(SilverRing)) { type = typeof(GoldRing); } else if (type == typeof(SilverBracelet)) { type = typeof(GoldBracelet); } crItem = system.CraftItems.SearchFor(type); if (crItem != null && crItem.Resources != null) { CraftRes craftRes = crItem.Resources.GetAt(0); double amount = 1; if (craftRes != null) { amount = craftRes.Amount; } double award = 1; if (item is IResource) { switch (((IResource)item).Resource) { default: award = amount * .1; break; case CraftResource.DullCopper: award = amount * .47; break; case CraftResource.ShadowIron: award = amount * .73; break; case CraftResource.Copper: award = amount * 1.0; break; case CraftResource.Bronze: award = amount * 1.47; break; case CraftResource.Gold: award = amount * 2.5; break; case CraftResource.Agapite: award = amount * 5.0; break; case CraftResource.Verite: award = amount * 8.5; break; case CraftResource.Valorite: award = amount * 10; break; case CraftResource.SpinedLeather: award = amount * 0.5; break; case CraftResource.HornedLeather: award = amount * 1.0; break; case CraftResource.BarbedLeather: award = amount * 2.0; break; case CraftResource.OakWood: award = amount * .17; break; case CraftResource.AshWood: award = amount * .33; break; case CraftResource.YewWood: award = amount * .67; break; case CraftResource.Heartwood: award = amount * 1.0; break; case CraftResource.Bloodwood: award = amount * 2.17; break; case CraftResource.Frostwood: award = amount * 3.17; break; } } int weight = item is BaseWeapon && !((BaseWeapon)item).DImodded ? Imbuing.GetTotalWeight(item, 12, false, true) : Imbuing.GetTotalWeight(item, -1, false, true); if (weight > 0) { award += weight / 30; } return((int)award); } } } return(0); }
private bool Resmelt(Mobile from, Item item, CraftResource resource) { try { if (CraftResources.GetType(resource) != CraftResourceType.Metal) { return(false); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(false); } CraftItem craftItem = DefBlacksmithy.CraftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) { return(false); } CraftRes craftResource = craftItem.Resources.GetAt(0); if (craftResource.Amount < 2) { return(false); // Not enough metal to resmelt } double difficulty = 0.0; switch (resource) { case CraftResource.DullCopper: difficulty = 65.0; break; case CraftResource.ShadowIron: difficulty = 70.0; break; case CraftResource.Copper: difficulty = 75.0; break; case CraftResource.Bronze: difficulty = 80.0; break; case CraftResource.Gold: difficulty = 85.0; break; case CraftResource.Agapite: difficulty = 90.0; break; case CraftResource.Verite: difficulty = 95.0; break; case CraftResource.Valorite: difficulty = 99.0; break; } Type resourceType = info.ResourceTypes[0]; Item ingot = (Item)Activator.CreateInstance(resourceType); if (item is DragonBardingDeed || (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed)) { double mining = from.Skills[SkillName.Mining].Value; if (mining > 100.0) { mining = 100.0; } double amount = (((4 + mining) * craftResource.Amount - 4) * 0.0068); if (amount < 2) { ingot.Amount = 2; } else { ingot.Amount = (int)amount; } } else { ingot.Amount = 2; } if (difficulty > from.Skills[SkillName.Mining].Value) { this.m_Failure = true; ingot.Delete(); } else { item.Delete(); } from.AddToBackpack(ingot); from.PlaySound(0x2A); from.PlaySound(0x240); return(true); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(false); }
public void Add(CraftRes craftRes) { List.Add(craftRes); }
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 (NeedHeat && !Find(from, m_HeatSources)) { message = 1044487; // You must be near a fire source to cook. return(false); } if (NeedOven && !Find(from, m_Ovens)) { message = 1044493; // You must be near an oven to bake that. return(false); } if (NeedMill && !Find(from, m_Mills)) { message = 1044491; // You must be near a flour mill to do that. return(false); } Type[][] types = new Type[Resources.Count][]; int[] amounts = new int[Resources.Count]; maxAmount = int.MaxValue; CraftSubResCol resCol = UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes; for (int i = 0; i < types.Length; ++i) { CraftRes craftRes = Resources[i]; Type baseType = craftRes.ItemType; // 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 = Resources[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 (NameNumber == 1041267) { // Runebooks are a special case, they need a blank recall rune List <RecallRune> 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 { 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 { 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 { 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 = Resources[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 void AddRes(Type type, TextDefinition name, int amount, TextDefinition message) { CraftRes craftRes = new CraftRes(type, name, amount, message); Resources.Add(craftRes); }
private SmeltResult Resmelt(Mobile from, Item item, CraftResource resource) { try { if (CraftResources.GetType(resource) != CraftResourceType.Metal) { return(SmeltResult.Invalid); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(SmeltResult.Invalid); } CraftItem craftItem = Craft.CraftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Ressources.Count == 0) { return(SmeltResult.Invalid); } CraftRes craftResource = craftItem.Ressources.GetAt(0); if (craftResource.Amount < 2) { return(SmeltResult.Invalid); // Not enough metal to resmelt } double difficulty = 0.0; switch (resource) { case CraftResource.DullCopper: difficulty = 65.0; break; case CraftResource.ShadowIron: difficulty = 70.0; break; case CraftResource.Copper: difficulty = 75.0; break; case CraftResource.Bronze: difficulty = 80.0; break; case CraftResource.Gold: difficulty = 85.0; break; case CraftResource.Agapite: difficulty = 90.0; break; case CraftResource.Verite: difficulty = 95.0; break; case CraftResource.Valorite: difficulty = 99.0; break; } if (difficulty > from.Skills[SkillName.Mining].Value) { return(SmeltResult.NoSkill); } Type resourceType = info.ResourceTypes[0]; Item ingot = (Item)Activator.CreateInstance(resourceType); if (item is DragonBardingDeed || (item is BaseArmor && !item.StoreBought) || (item is BaseWeapon && !item.StoreBought) || (item is BaseClothing && !item.StoreBought)) { ingot.Amount = craftResource.Amount / 2; } else { ingot.Amount = 1; } /* Publish - September 22, 1999 * Items you wish to smelt must be in your back-pack. * Smelting will be tied to the mining skill. The higher your skill in mining, the more ingots you will get back. * The more wear and tear on an item, the less ingots it will return. * Items purchased from an NPC will yield only one ingot when smelted. * http://www.uoguide.com/Publish_-_September_22,_1999 */ if (Core.UOSP) { double amount = (double)ingot.Amount; // Smelting will be tied to the mining skill. The higher your skill in mining, the more ingots you will get back. amount = amount / 2 + ((amount / 2) * (from.Skills[SkillName.Mining].Value / 100)); // The more wear and tear on an item, the less ingots it will return. double MaxHitPoints = 0; double HitPoints = 0; if (item is BaseWeapon) { MaxHitPoints = (double)(item as BaseWeapon).MaxHitPoints; HitPoints = (double)(item as BaseWeapon).HitPoints; } else if (item is BaseArmor) { MaxHitPoints = (double)(item as BaseArmor).MaxHitPoints; HitPoints = (double)(item as BaseArmor).HitPoints; } // reduce the ingots by the amount of wear on the item. An item that is 50% worn out will reduce the ingots by 50% double difference = ((MaxHitPoints - HitPoints) / MaxHitPoints) * 100.0; if (difference > 0.0) { amount *= (100.0 - difference) / 100.0; } // okay, adjust ingot output ingot.Amount = (int)Math.Round(amount); if (ingot.Amount < 1) { ingot.Amount = 1; } } item.Delete(); from.AddToBackpack(ingot); from.PlaySound(0x2A); from.PlaySound(0x240); return(SmeltResult.Success); } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } return(SmeltResult.Success); }