public CraftItem(Type type, TextDefinition groupName, TextDefinition name) { m_arCraftRes = new CraftResCol(); m_arCraftSkill = new CraftSkillCol(); m_Type = type; m_GroupNameString = groupName; m_NameString = name; m_GroupNameNumber = groupName; m_NameNumber = name; }
public CraftItem( Type type, TextDefinition groupName, TextDefinition name ) { m_arCraftRes = new CraftResCol(); m_arCraftSkill = new CraftSkillCol(); m_Type = type; m_GroupNameString = groupName; m_NameString = name; m_GroupNameNumber = groupName; m_NameNumber = name; }
public CraftItem(Type type, TextDefinition groupName, TextDefinition name) { m_arCraftRes = new CraftResCol(); m_arCraftSkill = new CraftSkillCol(); m_Type = type; m_GroupNameString = groupName; m_NameString = name; m_GroupNameNumber = groupName; m_NameNumber = name; m_RequiredBeverage = BeverageType.Water; }
public CraftItem(Type type, TextDefinition groupName, TextDefinition name) { Resources = new CraftResCol(); Skills = new CraftSkillCol(); ItemType = type; GroupNameString = groupName; NameString = name; GroupNameNumber = groupName; NameNumber = name; RequiredBeverage = BeverageType.Water; }
public CraftItem(Type type, int groupName, string name) { m_arCraftRes = new CraftResCol(); m_arCraftSkill = new CraftSkillCol(); m_Type = type; m_GroupNameNumber = groupName; m_NameString = name; }
private RecycleResult Recycle(Mobile from, Item item) { if (from == null || item == null || m_CraftSystem == null || m_Tool == null) { return(RecycleResult.Invalid); } if (from.Backpack == null) { return(RecycleResult.Invalid); } CraftContext craftContext = m_CraftSystem.GetContext(from); if (craftContext == null) { return(RecycleResult.Invalid); } bool recycleEntireBackpack = false; if (craftContext.RecycleOption == CraftRecycleOption.RecycleEverything && item == from.Backpack) { recycleEntireBackpack = true; } List <CraftSystem> m_RecycleableCraftSystems = GetRecyclableCraftSystems(); List <Type> m_ItemTypes = new List <Type>(); if (recycleEntireBackpack) { List <Item> m_BackpackItems = from.Backpack.FindItemsByType <Item>(); foreach (Item backpackItem in m_BackpackItems) { if (backpackItem is BaseTool) { continue; } Type itemType = backpackItem.GetType(); if (!m_ItemTypes.Contains(itemType)) { m_ItemTypes.Add(itemType); } } } else { m_ItemTypes.Add(item.GetType()); } List <int> m_RecycleSounds = new List <int>(); int deletedCount = 0; foreach (Type itemType in m_ItemTypes) { foreach (CraftSystem craftSystem in m_RecycleableCraftSystems) { CraftItem craftItem = craftSystem.CraftItems.SearchFor(itemType); if (craftItem == null || craftItem.Resources.Count == 0) { continue; } 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) { continue; } List <Item> m_ItemMatches = 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.RecycleSingle && targetItem == item) { m_ItemMatches.Add(targetItem); continue; } if (craftContext.RecycleOption == CraftRecycleOption.RecycleRegularByType && targetItem.Quality == Quality.Regular && !targetItem.IsMagical) { m_ItemMatches.Add(targetItem); continue; } if (craftContext.RecycleOption == CraftRecycleOption.RecycleExceptionalByType && targetItem.Quality == Quality.Exceptional) { m_ItemMatches.Add(targetItem); continue; } if (craftContext.RecycleOption == CraftRecycleOption.RecycleExceptionalByType && targetItem.IsMagical) { m_ItemMatches.Add(targetItem); continue; } if (craftContext.RecycleOption == CraftRecycleOption.RecycleAnyByType) { m_ItemMatches.Add(targetItem); continue; } if (craftContext.RecycleOption == CraftRecycleOption.RecycleEverything) { m_ItemMatches.Add(targetItem); continue; } } foreach (Item recycleItem in m_ItemMatches) { if (!recycleItem.Movable) { continue; } if (recycleItem.LootType != LootType.Regular) { continue; } if (recycleItem.DecorativeEquipment) { continue; } if (recycleItem.TierLevel > 0 && recycleItem.Aspect != AspectEnum.None) { continue; } if (recycleItem is BaseContainer && recycleItem.TotalItems > 0) { continue; } m_ItemsToRecycle.Add(recycleItem); } if (m_ItemsToRecycle.Count == 0) { continue; } Queue m_Queue = new Queue(); foreach (Item recycleItem in m_ItemsToRecycle) { m_Queue.Enqueue(recycleItem); } while (m_Queue.Count > 0) { Item recycleItem = (Item)m_Queue.Dequeue(); bool deleteItem = false; foreach (KeyValuePair <Type, int> pair in m_ValidRecipeResources) { double salvageScalar = .5; if (recycleItem.ItemGroup != ItemGroupType.Crafted) { salvageScalar = .25; } Type resourceType = pair.Key; int totalResourceAmount = (int)(Math.Floor((double)pair.Value * (double)recycleItem.Amount * salvageScalar)); if (totalResourceAmount < 1) { 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 = totalResourceAmount; 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); } if (deletedCount > 1) { return(RecycleResult.SuccessMultiple); } else { return(RecycleResult.Success); } } else { if (recycleEntireBackpack) { return(RecycleResult.InvalidEntireBackpack); } else { return(RecycleResult.Invalid); } } }
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); } }