public static void BeginTarget(Mobile from, CraftSystem craftSystem, BaseTool tool) { CraftContext context = craftSystem.GetContext(from); if (context == null) { return; } int lastRes = context.LastResourceIndex; CraftSubResCol subRes = craftSystem.CraftSubRes; if (lastRes >= 0 && lastRes < subRes.Count) { CraftSubRes res = subRes.GetAt(lastRes); if (from.Skills[craftSystem.MainSkill].Value < res.RequiredSkill) { from.SendGump(new CraftGump(from, craftSystem, tool, res.Message)); } else { CraftResource resource = CraftResources.GetFromType(res.ItemType); if (resource != CraftResource.None) { from.Target = new InternalTarget(craftSystem, tool, res.ItemType, resource); from.SendLocalizedMessage(1061004); // Target an item to enhance with the properties of your selected material. } else { from.SendGump(new CraftGump(from, craftSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties. } } } else { from.SendGump(new CraftGump(from, craftSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties. } }
public override int OnCraft( int quality, bool makersMark, Mobile m, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { if (craftSystem is Pyrotechnics && craftItem != null) { var resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType; if (resourceType != null) { Resource = CraftResources.GetFromType(resourceType); } } return(base.OnCraft(quality, makersMark, m, craftSystem, typeRes, tool, craftItem, resHue)); }
public int GetResourceAmount(Type resourceType) { int resourceCount = 0; Item[] items; if (m_From.Backpack != null) { if (m_CraftSystem is DefCarpentry || m_CraftSystem is DefTailoring) { CraftResource resource = CraftResources.GetFromType(resourceType); CraftResourceInfo resourceInfo = CraftResources.GetInfo(resource); Type[] typeList = resourceInfo.ResourceTypes; for (int i = 0; i < typeList.Length; ++i) { items = m_From.Backpack.FindItemsByType(typeList[i], true); for (int j = 0; j < items.Length; ++j) { resourceCount += items[j].Amount; } } } else { items = m_From.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } } return(resourceCount); }
public bool CheckSkills(Mobile from, Type typeRes, CraftSystem craftSystem, ref int mark, ref double quality, ref int craftSkill, ref bool allRequiredSkills, bool gainSkills) { var craftSkillRequired = GetCraftSkillRequired(from, typeRes, craftSystem); var exceptionalDifficulty = craftSkillRequired; var points = gainSkills ? GetCraftPoints(from, typeRes, craftSystem) : 0; var exceptionalChance = GetExceptionalChance(from, craftSystem, ref exceptionalDifficulty); var resource = CraftResources.GetFromType(typeRes); var resQuality = CraftResources.GetQuality(resource); craftSkill = craftSkillRequired; quality = resQuality; if (exceptionalChance > Utility.Random(100) && from.ShilCheckSkill(craftSystem.MainSkill, exceptionalDifficulty, 0)) { mark = 2; quality = (double)(int)(quality * GetQualityBonus(from)) / 100; } return(from.ShilCheckSkill(craftSystem.MainSkill, craftSkillRequired, points)); }
public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested, Type type) { if (tool is GargoylesPickaxe && def == this.m_OreAndStone && 0.1 > Utility.RandomDouble()) { HarvestResource res = vein.PrimaryResource; if (res == resource && res.Types.Length >= 3) { try { Map map = from.Map; if (map == null) { return; } //daat99 OWLTR start - gargoyle spawn BaseCreature spawned = null; try { int i_Level = CraftResources.GetIndex(CraftResources.GetFromType(type)) + 1; if (i_Level > 1) { spawned = new Elementals(i_Level); } } catch {} if (spawned == null) { //daat99 OWLTR end - gargoyle spawn spawned = Activator.CreateInstance(res.Types[2], new object[] { 25 }) as BaseCreature; } if (spawned != null) { int offset = Utility.Random(8) * 2; for (int i = 0; i < m_Offsets.Length; i += 2) { int x = from.X + m_Offsets[(offset + i) % m_Offsets.Length]; int y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length]; if (map.CanSpawnMobile(x, y, from.Z)) { spawned.OnBeforeSpawn(new Point3D(x, y, from.Z), map); spawned.MoveToWorld(new Point3D(x, y, from.Z), map); spawned.Combatant = from; return; } else { int z = map.GetAverageZ(x, y); if (Math.Abs(z - from.Z) < 10 && map.CanSpawnMobile(x, y, z)) { spawned.OnBeforeSpawn(new Point3D(x, y, z), map); spawned.MoveToWorld(new Point3D(x, y, z), map); spawned.Combatant = from; return; } } } spawned.OnBeforeSpawn(from.Location, from.Map); spawned.MoveToWorld(from.Location, from.Map); spawned.Combatant = from; } } catch { } } } }
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_Lenght = 0; for (int i = 0; i < res.Count; ++i) { int index = i_Lenght % 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_Lenght++; } } } 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, 290, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0); this.AddHtmlLocalized(255, 293, 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; } //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, 70 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0); if (subResource.NameNumber > 0) { this.AddHtmlLocalized(255, 73 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false); } else { this.AddLabel(255, 70 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount)); } } } }
public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested, Type type) { if (tool is GargoylesAxe && 0.1 < Utility.RandomDouble()) { HarvestResource res = vein.PrimaryResource; Map map = from.Map; if (map == null) { return; } BaseCreature spawned = null; int i_Level = 0; if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.DAAT99_LUMBERJACKING)) { i_Level = CraftResources.GetIndex(CraftResources.GetFromType(type)) + 301; } else if (res == resource) { try { i_Level = Array.IndexOf(def.Veins, vein) + 301; } catch { } } // if (i_Level > 300 && OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.HARVEST_GIVE_TOKENS)) // TokenSystem.GiveTokensToPlayer(from as PlayerMobile, (i_Level - 300)*10); if (i_Level > 301) { spawned = new Elementals(i_Level); } else { spawned = null; } try { if (spawned != null) { int offset = Utility.Random(8) * 2; for (int i = 0; i < m_Offsets.Length; i += 2) { int x = from.X + m_Offsets[(offset + i) % m_Offsets.Length]; int y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length]; if (map.CanSpawnMobile(x, y, from.Z)) { spawned.MoveToWorld(new Point3D(x, y, from.Z), map); spawned.Combatant = from; return; } else { int z = map.GetAverageZ(x, y); if (map.CanSpawnMobile(x, y, z)) { spawned.MoveToWorld(new Point3D(x, y, z), map); spawned.Combatant = from; return; } } } spawned.MoveToWorld(from.Location, from.Map); spawned.Combatant = from; } } catch { } } }
public override int GetCraftSkillRequired(int itemSkillRequired, Type craftResourceType) { var resource = CraftResources.GetFromType(craftResourceType); return(itemSkillRequired + (int)(CraftResources.GetCraftSkillRequired(resource) / 3)); }
private static void GenerateTable(CraftSystem system) { var stw = new StreamWriter("web/" + system.MainSkill.ToString() + ".json"); using (JsonWriter writer = new JsonTextWriter(stw)) { writer.Formatting = Formatting.Indented; //writer.WritePropertyName("items"); writer.WriteStartArray(); foreach (CraftItem item in system.CraftItems) { writer.WriteStartObject(); writer.WritePropertyName("Name"); if (item.NameNumber == 0) { writer.WriteValue(item.NameString); } else { writer.WriteValue(CliLoc.LocToString(item.NameNumber)); } writer.WritePropertyName("hue"); writer.WriteValue(item.ItemHue); writer.WritePropertyName("type"); writer.WriteValue(CraftItem.ItemIDOf(item.ItemType)); writer.WritePropertyName("skills"); writer.WriteStartArray(); foreach (CraftSkill skill in item.Skills) { writer.WriteStartObject(); writer.WritePropertyName("skill"); writer.WriteValue(skill.SkillToMake.ToString()); writer.WritePropertyName("minskill"); writer.WriteValue(skill.MinSkill); writer.WritePropertyName("maxskill"); writer.WriteValue(skill.MaxSkill); writer.WriteEndObject(); } writer.WriteEndArray(); writer.WritePropertyName("resources"); writer.WriteStartArray(); foreach (CraftRes res in item.Resources) { writer.WriteStartObject(); writer.WritePropertyName("res"); if (res.NameNumber != 0) { writer.WriteValue(CliLoc.LocToString(res.NameNumber)); } else if (res.NameString?.Length > 2) { writer.WriteValue(res.NameString); } else { if (CraftResources.GetFromType(res.ItemType) != CraftResource.None) { var resource = CraftResources.GetName(CraftResources.GetFromType(res.ItemType)); writer.WriteValue(resource); } } writer.WritePropertyName("qty"); writer.WriteValue(res.Amount); writer.WriteEndObject(); } writer.WriteEndArray(); writer.WriteEndObject(); } writer.WriteEndArray(); } }
/* End Captcha Mod */ public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked) { from.EndAction(locked); if (!this.CheckHarvest(from, tool)) { return; } int tileID; Map map; Point3D loc; if (!this.GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc)) { this.OnBadHarvestTarget(from, tool, toHarvest); return; } else if (!def.Validate(tileID)) { this.OnBadHarvestTarget(from, tool, toHarvest); return; } if (!this.CheckRange(from, tool, def, map, loc, true)) { return; } else if (!this.CheckResources(from, tool, def, map, loc, true)) { return; } else if (!this.CheckHarvest(from, tool, def, toHarvest)) { return; } if (this.SpecialHarvest(from, tool, def, map, loc)) { return; } HarvestBank bank = def.GetBank(map, loc.X, loc.Y); if (bank == null) { return; } HarvestVein vein = bank.Vein; if (vein != null) { vein = this.MutateVein(from, tool, def, bank, toHarvest, vein); } if (vein == null) { return; } HarvestResource primary = vein.PrimaryResource; HarvestResource fallback = vein.FallbackResource; HarvestResource resource = this.MutateResource(from, tool, def, map, loc, vein, primary, fallback); double skillBase = from.Skills[def.Skill].Base; double skillValue = from.Skills[def.Skill].Value; Type type = null; //daat99 OWLTR start - daat99 harvesting type = GetResourceType(from, tool, def, map, loc, resource); bool daatHarvesting = false; if (daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_MINING) && (type.IsSubclassOf(typeof(BaseOre)) || type.IsSubclassOf(typeof(BaseGranite)))) { daatHarvesting = true; } else if (daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_LUMBERJACKING) && type.IsSubclassOf(typeof(BaseLog))) { daatHarvesting = true; } if (daatHarvesting || (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))) { if (type != null) //añadido 18/03/2018 { type = GetResourceType(from, tool, def, map, loc, resource); } if (type != null) { type = MutateType(type, from, tool, def, map, loc, resource); } if (daatHarvesting) { type = ResourceHelper.GetDaat99HarvestedType(type, bank.Vein.IsProspected, skillValue); from.CheckSkill(def.Skill, 0.0, from.Skills[def.Skill].Cap + (vein.IsProspected?10.0:0.0)); } //daat99 OWLTR end - daat99 harvesting if (type != null) { Item item = this.Construct(type, from); if (item == null) { type = null; } else { //The whole harvest system is kludgy and I'm sure this is just adding to it. if (item.Stackable) { int amount = def.ConsumedPerHarvest; int feluccaAmount = def.ConsumedPerFeluccaHarvest; int racialAmount = (int)Math.Ceiling(amount * 1.1); int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1); bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human); bool inFelucca = (map == Map.Felucca); if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble()) { item.Amount = feluccaRacialAmount; } else if (inFelucca && bank.Current >= feluccaAmount) { item.Amount = feluccaAmount; } else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble()) { item.Amount = racialAmount; } else { item.Amount = amount; } } bank.Consume(item.Amount, from); //daat99 OWLTR start - custom harvesting CraftResource craftResourceFromType = CraftResources.GetFromType(type); string s_Type = "UNKNOWN"; int i_Tokens = 1; if (craftResourceFromType != CraftResource.None) { s_Type = CraftResources.GetInfo(craftResourceFromType).Name; i_Tokens = CraftResources.GetIndex(craftResourceFromType) + 1; } if (craftResourceFromType != CraftResource.None && daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_MINING) && def.Skill == SkillName.Mining && (type.IsSubclassOf(typeof(Server.Items.BaseOre)) || type.IsSubclassOf(typeof(Server.Items.BaseGranite)))) { if (type.IsSubclassOf(typeof(Server.Items.BaseOre))) { if (Give(from, item, def.PlaceAtFeetIfFull)) { from.SendMessage("You dig some {0} ore and placed it in your backpack.", s_Type); } else { from.SendMessage("Your backpack is full, so the ore you mined is lost."); item.Delete(); } } else { if (Give(from, item, def.PlaceAtFeetIfFull)) { from.SendMessage("You carefully extract some workable stone from the ore vein."); } else { from.SendMessage("Your backpack is full, so the ore you mined is lost."); item.Delete(); } } } else if (craftResourceFromType != CraftResource.None && OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.DAAT99_LUMBERJACKING) && def.Skill == SkillName.Lumberjacking) { if (Give(from, item, def.PlaceAtFeetIfFull)) { from.SendMessage("You placed some {0} logs in your backpack.", s_Type); } else { from.SendMessage("You can't place any wood into your backpack!"); item.Delete(); } } else { //daat99 OWLTR end - custom harvesting if (Give(from, item, def.PlaceAtFeetIfFull)) { SendSuccessTo(from, item, resource); } else { SendPackFullTo(from, item, def, resource); item.Delete(); } //daat99 OWLTR start - custom harvesting } if (from.Map == Map.Felucca) { i_Tokens = (int)(i_Tokens * 1.5); } if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.HARVEST_GIVE_TOKENS)) { TokenSystem.GiveTokensToPlayer(from as Server.Mobiles.PlayerMobile, i_Tokens); } //daat99 OWLTR end - custom harvesting BonusHarvestResource bonus = def.GetBonusResource(); if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill) { Item bonusItem = this.Construct(bonus.Type, from); if (this.Give(from, bonusItem, true)) //Bonuses always allow placing at feet, even if pack is full irregrdless of def { bonus.SendSuccessTo(from); } else { item.Delete(); } } if (tool is IUsesRemaining) { IUsesRemaining toolWithUses = (IUsesRemaining)tool; toolWithUses.ShowUsesRemaining = true; if (toolWithUses.UsesRemaining > 0) { --toolWithUses.UsesRemaining; } if (toolWithUses.UsesRemaining < 1) { tool.Delete(); def.SendMessageTo(from, def.ToolBrokeMessage); } } } } } }
public ItemListEntry[] CreateItemList() { CraftGroupCol craftGroupCol = CurrentCraftSystem.CraftGroups; CraftGroup craftGroup = craftGroupCol.GetAt(SelectedGroupIndex); CraftItemCol craftItemCol = craftGroup.CraftItems; ItemListEntry[] toReturn = new ItemListEntry[craftItemCol.Count + 1]; toReturn[0] = new ItemListEntry("Previous menu", 4766);//Previous page int hue = 0; if (CurrentCraftSystem.CraftSubRes.Init && CurrentCraftSystem.CraftSubRes.Count >= 1 && SelectedResType != CurrentCraftSystem.CraftSubRes.GetAt(0).ItemType) { hue = ResourceInfoList[CurrentCraftSystem.CraftSubRes.GetAt(SelectedResourceIndex)].Hue; } if (hue > 1) { --hue; } string resourceList = string.Empty; for (int i = 0; i < craftItemCol.Count; ++i) { CraftItem craftItem = craftItemCol.GetAt(i); //Get the item id and resources required for the items int itemID; if (craftItemCol.Count >= 1) { itemID = CraftItem.ItemIDOf(craftItemCol.GetAt(i).ItemType); int amount = CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).Amount; if (SelectedResType == null) { if (!string.IsNullOrEmpty(CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameString)) { resourceList = string.Format(" [{0} {1}]", resourceList, amount); } else if (CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameNumber > 0) { resourceList = string.Format(" [{0} {1}]", amount, CliLoc.LocToString(CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameNumber)); } } else { resourceList = string.Format(" [{0} {1}]", amount, CraftResources.GetName(CraftResources.GetFromType(SelectedResType))); } } else { itemID = 5360; //Deed ID } //Becomes 0 if we use a string instead if (craftItem.NameNumber > 0) { toReturn[i + 1] = new ItemListEntry(CliLoc.LocToString(craftItem.NameNumber) + resourceList, itemID, hue); } else { toReturn[i + 1] = new ItemListEntry(craftItem.NameString + resourceList, itemID, hue); } } return(toReturn); }
public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked) { from.EndAction(locked); if (!CheckHarvest(from, tool)) { return; } int tileID; Map map; Point3D loc; if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc)) { OnBadHarvestTarget(from, tool, toHarvest); return; } if (!def.Validate(tileID)) { OnBadHarvestTarget(from, tool, toHarvest); return; } if (!CheckRange(from, tool, def, map, loc, true)) { return; } if (!CheckResources(from, tool, def, map, loc, true)) { return; } if (!CheckHarvest(from, tool, def, toHarvest)) { return; } if (SpecialHarvest(from, tool, def, map, loc)) { return; } HarvestBank bank = def.GetBank(map, loc.X, loc.Y); if (bank == null) { return; } HarvestVein vein = bank.Vein; if (vein != null) { vein = MutateVein(from, tool, def, bank, toHarvest, vein); } if (vein == null) { return; } HarvestResource primary = vein.PrimaryResource; HarvestResource fallback = vein.FallbackResource; HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback); double skillBase = from.Skills[def.Skill].Base; //double skillValue = from.Skills[def.Skill].Value; Type type = null; if (from.Expansion >= resource.ReqExpansion && skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill)) { type = GetResourceType(from, tool, def, map, loc, resource); if (type != null) { type = MutateType(type, from, tool, def, map, loc, resource); } if (type != null) { Item item = Construct(type, from); if (item == null) { type = null; } else { //The whole harvest system is kludgy and I'm sure this is just adding to it. if (item.Stackable) { int amount = def.ConsumedPerHarvest; int feluccaAmount = def.ConsumedPerFeluccaHarvest; var racialAmount = (int)Math.Ceiling(amount * 1.1); var feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1); bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human); bool inFelucca = (map == Map.Felucca); if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble()) { item.Amount = feluccaRacialAmount; } else if (inFelucca && bank.Current >= feluccaAmount) { item.Amount = feluccaAmount; } else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble()) { item.Amount = racialAmount; } else { item.Amount = amount; } } bank.Consume(item.Amount, from); if (Give(from, item, def.PlaceAtFeetIfFull)) { SendSuccessTo(from, item, resource); Conquests.Conquests.CheckProgress <HarvestConquest>( from as PlayerMobile, item, CraftResources.GetFromType(item.GetType()), this); } else { SendPackFullTo(from, item, def, resource); item.Delete(); } LogHarvest(from, type); BonusHarvestResource bonus = def.GetBonusResource(from.Expansion); if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill) { Item bonusItem = Construct(bonus.Type, from); if (Give(from, bonusItem, true)) //Bonuses always allow placing at feet, even if pack is full regrdless of def { bonus.SendSuccessTo(from); Conquests.Conquests.CheckProgress <HarvestConquest>( from as PlayerMobile, bonusItem, CraftResources.GetFromType(bonus.Type), this); } else { item.Delete(); } } if (tool is IUsesRemaining) { var toolWithUses = (IUsesRemaining)tool; toolWithUses.ShowUsesRemaining = true; if (toolWithUses.UsesRemaining > 0) { --toolWithUses.UsesRemaining; } if (toolWithUses.UsesRemaining < 1) { tool.Delete(); def.SendMessageTo(from, def.ToolBrokeMessage); } } } } } if (type == null) { def.SendMessageTo(from, def.FailMessage); } OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest); }
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 if (tool.Parent is Container) { Container cntnr = (Container) tool.Parent; cntnr.TryDropItem(from, item, false); } else { from.AddToBackpack(item); } EventSink.InvokeCraftSuccess(new CraftSuccessEventArgs(from, item, tool)); 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); } } }