public void PackItems() { DropItem(new GreenDriedFlowers()); DropItem(new WhiteDriedFlowers()); DropItem(new Candelabra()); DropItem(new Item(0xf03)); //bottle DropItem(new Item(0xe29)); //bottle2 DropItem(new AniRedRibbedFlask()); DropItem(new AniLargeVioletFlask()); DropItem(new SmallYellowFlask()); var bookcase = new RuinedBookcase(); bookcase.Movable = true; DropItem(bookcase); var pentagram = new PentagramDeed(); double rand = Utility.RandomDouble(); if (rand < 0.1) { pentagram.Hue = 2405; } else if (rand < 0.4) { pentagram.Hue = 2414; } else { pentagram.Hue = 2101; } DropItem(pentagram); }
public void CompleteCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool) { 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); 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); 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); return; } bool toolBroken = false; int ignored = 1; int endquality = 1; bool allRequiredSkills = true; // pla, 01/04/07 // ----------------------------------------------------------------- // Additional checks required here to prevent skill gain exploit with special dye tubs. if (craftSystem is DefAlchemy && (ItemType == typeof(SpecialDyeTub) || ItemType == typeof(SpecialDye))) { // note here that if lighten or darken was chosen, there will always be at least one special tub, // as it's set as a resource requirement. if (m_NameString == "> Darken the mix" || m_NameString == "> Lighten the mix") { // darken/lighten requires a special tub // Get list of all special tubs Item[] sdtubs = ((Container)from.Backpack).FindItemsByType(typeof(SpecialDyeTub), true); SpecialDyeTub sdtub; if (sdtubs.Length == 0) { //should be impossible as in reqs return; } else if (sdtubs.Length == 1) { // in this case we have just one tub. This means we will leave skill gain and execution to the // standard craft code below. However, we need to first check if the tub can be lightened/darkened, // and if not then return to prevent skill gain with no resource use. sdtub = (SpecialDyeTub)sdtubs[0]; if (sdtub != null) { if (m_NameString == "> Darken the mix") { if (!sdtub.CanDarken) { from.SendMessage("You attempt to darken the mix, but it will go no darker."); from.SendGump(new CraftGump(from, craftSystem, tool, 0)); return; } } else { if (!sdtub.CanLighten) { from.SendMessage("You attempt to lighten the mix, but it will go no lighter."); from.SendGump(new CraftGump(from, craftSystem, tool, 0)); return; } } } } else if (sdtubs.Length > 1) { // in this case we have more than one possible tub to select so we hand execution over to the target. //target also deals with all skill gain and failure/tool use etc. int resHue = 0; int maxAmount = 0; object message = null; from.SendMessage("Select the dye tub you wish to use for the process."); from.Target = new SpecialDyeTubTarget(this, typeRes, craftSystem, ref resHue, ref maxAmount, ref message, m_NameString, (m_NameString == "> Darken the mix" ? 1 : 2), tool); //and now return to prevent the rest of the code executing return; } } else { // Create/append dye. This can either add to a same coloured special tub, or a fresh non-special tub. // So first we find all the valid tubs... Item[] dtubs = ((Container)from.Backpack).FindItemsByType(typeof(DyeTub), true); int iFound = 0; if (dtubs.Length > 0) { for (int i = 0; i < dtubs.Length; i++) { if (dtubs[i] is SpecialDyeTub) { // Is the same color? if (((SpecialDyeTub)dtubs[i]).StoredColorName == m_NameString && ((SpecialDyeTub)dtubs[i]).Uses < 100 && !((SpecialDyeTub)dtubs[i]).Prepped) { iFound++; } } else { iFound++; } } } if (iFound == 0) { from.SendMessage("You need a fresh dye tub or one that is not yet full and of the same color as the dye you are preparing."); from.SendGump(new CraftGump(from, craftSystem, tool, 0)); return; } else if (iFound == 1) { // once again if no target is required then we just let it fall through } else if (iFound > 1) { //ok in this case we found more than one valid tub so hand execution over to the target and end int resHue = 0; int maxAmount = 0; object message = null; from.SendMessage("Select the dye tub you wish to use for the process."); from.Target = new SpecialDyeTubTarget(this, typeRes, craftSystem, ref resHue, ref maxAmount, ref message, m_NameString, 0, tool); return; } } } // ----------------------------------------------------------------- / //This check is where skill is (possibly) gained! //PLA: 04/06/09 - Prevent skillgain from special tubs entirely if (!(craftSystem is DefAlchemy && (ItemType == typeof(SpecialDyeTub) || ItemType == typeof(SpecialDye)))) { CheckSkills(from, typeRes, craftSystem, ref ignored, ref allRequiredSkills); } if (quality >= 0) { // Resource int resHue = 0; int maxAmount = 0; object message = null; ConsumeType ct = ConsumeType.All; // erl: if this is special dye, forget about consumption for now // .. if (craftSystem is DefAlchemy && (ItemType == typeof(SpecialDyeTub) || ItemType == typeof(SpecialDye))) ct = ConsumeType.None; // .. // Not enough resource to craft it ha if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ct, 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); return; } 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); return; } tool.UsesRemaining--; if (tool.UsesRemaining < 1) toolBroken = true; if (toolBroken) tool.Delete(); // Adam: this is it. Make the item Item item = Activator.CreateInstance(ItemType) as Item; bool bTinkerTrap = false; if (item != null) { // Adam: mark it as PlayerCrafted item.PlayerCrafted = true; if (item is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)item; weapon.Quality = (WeaponQuality)quality; endquality = quality; if (makersMark) weapon.Crafter = from; // Adam: one day we can obsolete and and use item.PlayerCrafted // erl: 10 Nov 05: that day is today! // weapon.PlayerConstructed = true; /*if ( Core.AOS ) { Type resourceType = typeRes; if ( resourceType == null ) resourceType = Ressources.GetAt( 0 ).ItemType; weapon.Resource = CraftResources.GetFromType( resourceType ); CraftContext context = craftSystem.GetContext( from ); if ( context != null && context.DoNotColor ) weapon.Hue = 0; if ( tool is BaseRunicTool ) ((BaseRunicTool)tool).ApplyAttributesTo( weapon ); if ( quality == 2 ) { if ( weapon.Attributes.WeaponDamage > 35 ) weapon.Attributes.WeaponDamage -= 20; else weapon.Attributes.WeaponDamage = 15; } } else */ if (tool is BaseRunicTool) { Type resourceType = typeRes; if (resourceType == null) resourceType = Ressources.GetAt(0).ItemType; CraftResource thisResource = CraftResources.GetFromType(resourceType); if (thisResource == ((BaseRunicTool)tool).Resource) { weapon.Resource = thisResource; CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) weapon.Hue = 0; switch (thisResource) { case CraftResource.DullCopper: { weapon.Identified = true; weapon.DurabilityLevel = WeaponDurabilityLevel.Durable; weapon.AccuracyLevel = WeaponAccuracyLevel.Accurate; break; } case CraftResource.ShadowIron: { weapon.Identified = true; weapon.DurabilityLevel = WeaponDurabilityLevel.Durable; weapon.DamageLevel = WeaponDamageLevel.Ruin; break; } case CraftResource.Copper: { weapon.Identified = true; weapon.DurabilityLevel = WeaponDurabilityLevel.Fortified; weapon.DamageLevel = WeaponDamageLevel.Ruin; weapon.AccuracyLevel = WeaponAccuracyLevel.Surpassingly; break; } case CraftResource.Bronze: { weapon.Identified = true; weapon.DurabilityLevel = WeaponDurabilityLevel.Fortified; weapon.DamageLevel = WeaponDamageLevel.Might; weapon.AccuracyLevel = WeaponAccuracyLevel.Surpassingly; break; } case CraftResource.Gold: { weapon.Identified = true; weapon.DurabilityLevel = WeaponDurabilityLevel.Indestructible; weapon.DamageLevel = WeaponDamageLevel.Force; weapon.AccuracyLevel = WeaponAccuracyLevel.Eminently; break; } case CraftResource.Agapite: { weapon.Identified = true; weapon.DurabilityLevel = WeaponDurabilityLevel.Indestructible; weapon.DamageLevel = WeaponDamageLevel.Power; weapon.AccuracyLevel = WeaponAccuracyLevel.Eminently; break; } case CraftResource.Verite: { weapon.Identified = true; weapon.DurabilityLevel = WeaponDurabilityLevel.Indestructible; weapon.DamageLevel = WeaponDamageLevel.Power; weapon.AccuracyLevel = WeaponAccuracyLevel.Exceedingly; break; } case CraftResource.Valorite: { weapon.Identified = true; weapon.DurabilityLevel = WeaponDurabilityLevel.Indestructible; weapon.DamageLevel = WeaponDamageLevel.Vanq; weapon.AccuracyLevel = WeaponAccuracyLevel.Supremely; break; } } } } } else if (item is BaseArmor) { BaseArmor armor = (BaseArmor)item; armor.Quality = (ArmorQuality)quality; endquality = quality; if (makersMark) armor.Crafter = from; Type resourceType = typeRes; if (resourceType == null) resourceType = Ressources.GetAt(0).ItemType; armor.Resource = CraftResources.GetFromType(resourceType); // Adam: one day we can obsolete and and use item.PlayerCrafted // erl: 10 Nov 05: that day is today! // armor.PlayerConstructed = true; CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) armor.Hue = 0; if (quality == 2) armor.DistributeBonuses((tool is BaseRunicTool ? 6 : 14)); if (Core.AOS && tool is BaseRunicTool) ((BaseRunicTool)tool).ApplyAttributesTo(armor); } else if (item is FullBookcase || item is FullBookcase2 || item is FullBookcase3) { // Does it now become a ruined bookcase? 5% chance. if (Utility.RandomDouble() > 0.95) { from.SendMessage("You craft the bookcase, but it is ruined."); item.Delete(); item = new RuinedBookcase(); item.Movable = true; } else from.SendMessage("You finish the bookcase and fill it with books."); // Consume single charge from scribe pen... Item[] spens = ((Container)from.Backpack).FindItemsByType(typeof(ScribesPen), true); if (--((ScribesPen)spens[0]).UsesRemaining == 0) { from.SendMessage("You have worn out your tool!"); spens[0].Delete(); } } else if (item is DragonBardingDeed) { DragonBardingDeed deed = (DragonBardingDeed)item; deed.Exceptional = (quality >= 2); endquality = quality; if (makersMark) deed.Crafter = from; Type resourceType = typeRes; if (resourceType == null) resourceType = Ressources.GetAt(0).ItemType; deed.Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) deed.Hue = 0; } else if (item is BaseInstrument) { BaseInstrument instrument = (BaseInstrument)item; instrument.Quality = (InstrumentQuality)quality; endquality = quality; if (makersMark) instrument.Crafter = from; } else if (item is BaseJewel) { BaseJewel jewel = (BaseJewel)item; Type resourceType = typeRes; endquality = quality; if (resourceType == null) resourceType = Ressources.GetAt(0).ItemType; jewel.Resource = CraftResources.GetFromType(resourceType); if (1 < Ressources.Count) { resourceType = Ressources.GetAt(1).ItemType; if (resourceType == typeof(StarSapphire)) jewel.GemType = GemType.StarSapphire; else if (resourceType == typeof(Emerald)) jewel.GemType = GemType.Emerald; else if (resourceType == typeof(Sapphire)) jewel.GemType = GemType.Sapphire; else if (resourceType == typeof(Ruby)) jewel.GemType = GemType.Ruby; else if (resourceType == typeof(Citrine)) jewel.GemType = GemType.Citrine; else if (resourceType == typeof(Amethyst)) jewel.GemType = GemType.Amethyst; else if (resourceType == typeof(Tourmaline)) jewel.GemType = GemType.Tourmaline; else if (resourceType == typeof(Amber)) jewel.GemType = GemType.Amber; else if (resourceType == typeof(Diamond)) jewel.GemType = GemType.Diamond; } if (makersMark) jewel.Crafter = from; jewel.Quality = (JewelQuality)quality; } else if (item is BaseClothing) { BaseClothing clothing = (BaseClothing)item; clothing.Quality = (ClothingQuality)quality; endquality = quality; if (makersMark) clothing.Crafter = from; // Adam: one day we can obsolete and and use item.PlayerCrafted // erl: 10 Nov 05: that day is today! // clothing.PlayerConstructed = true; if (item is BaseShoes) { BaseShoes shoes = (BaseShoes)item; if (shoes.Resource != CraftResource.None) { Type resourceType = typeRes; if (resourceType == null) resourceType = Ressources.GetAt(0).ItemType; shoes.Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) shoes.Hue = 0; } else { shoes.Hue = resHue; } } else if ((item is BaseGloves) && (resHue == 0)) { clothing.Hue = 1001; // Rhi: The default color for cloth gloves should be white, // not the leather gloves color, which is what it will be if the hue is 0. } else { clothing.Hue = resHue; } // erl: give clothing initial hitpoint values // .. int iMax = clothing.InitMaxHits; int iMin = clothing.InitMinHits; if (clothing.Quality == ClothingQuality.Exceptional) { // Add 50% to both iMax = (iMax * 3) / 2; // Fixed order of precedence bug iMin = (iMin * 3) / 2; // make exceptional clothes newbied clothing.LootType = LootType.Newbied; } else if (clothing.Quality == ClothingQuality.Low) { // Lose 20% to both iMax = (iMax * 4) / 5; // Fixed order of precedence bug iMin = (iMin * 4) / 5; } clothing.HitPoints = clothing.MaxHitPoints = (short)Utility.RandomMinMax(iMin, iMax); // .. } else if (item is BaseTool || item is BaseHarvestTool && quality == 2) { endquality = quality; if (item is BaseTool) ((BaseTool)item).UsesRemaining *= 3; else ((BaseHarvestTool)item).UsesRemaining *= 3; } else if (item is MapItem) { ((MapItem)item).CraftInit(from); } else if (item is LockableContainer) { if (from.CheckSkill(SkillName.Tinkering, -5.0, 15.0)) { LockableContainer cont = (LockableContainer)item; from.SendLocalizedMessage(500636); // Your tinker skill was sufficient to make the item lockable. Key key = new Key(KeyType.Copper, Key.RandomValue()); cont.KeyValue = key.KeyValue; cont.DropItem(key); /* double tinkering = from.Skills[SkillName.Tinkering].Value; int level = (int)(tinkering * 0.8); cont.RequiredSkill = level - 4; cont.LockLevel = level - 14; cont.MaxLockLevel = level + 35; if ( cont.LockLevel == 0 ) cont.LockLevel = -1; else if ( cont.LockLevel > 95 ) cont.LockLevel = 95; if ( cont.RequiredSkill > 95 ) cont.RequiredSkill = 95; if ( cont.MaxLockLevel > 95 ) cont.MaxLockLevel = 95; Commented out by darva to try new tinker lock strength code.*/ double tinkering = from.Skills[SkillName.Tinkering].Value; int level = (int)(tinkering); cont.RequiredSkill = 36; if (level >= 65) cont.RequiredSkill = 76; if (level >= 80) cont.RequiredSkill = 84; if (level >= 90) cont.RequiredSkill = 92; if (level >= 100) cont.RequiredSkill = 100; cont.LockLevel = cont.RequiredSkill - 10; cont.MaxLockLevel = cont.RequiredSkill + 40; } else { from.SendLocalizedMessage(500637); // Your tinker skill was insufficient to make the item lockable. } } else if (item is Runebook) { int charges = 5 + quality + (int)(from.Skills[SkillName.Inscribe].Value / 30); endquality = quality; if (charges > 10) charges = 10; ((Runebook)item).MaxCharges = charges; if (makersMark) ((Runebook)item).Crafter = from; ((Runebook)item).Quality = (RunebookQuality)quality; } else if (item is Bola) { Bola b = (Bola)item; b.Quality = (WeaponQuality)quality; endquality = quality; if (makersMark) b.Crafter = from; } else if (item.Hue == 0) { item.Hue = resHue; } if (maxAmount > 0) item.Amount = maxAmount; // ********************************************** if (craftSystem is DefAlchemy && item is BasePotion) { BasePotion pot = (BasePotion)item; Container pack = from.Backpack; if (pack != null) { Item[] kegs = pack.FindItemsByType(typeof(PotionKeg), true); for (int i = 0; i < kegs.Length; ++i) { PotionKeg keg = kegs[i] as PotionKeg; if (keg == null) continue; if (keg.Held <= 0 || keg.Held >= 100) continue; if (keg.Type != pot.PotionEffect) continue; ++keg.Held; item.Delete(); item = new Bottle(); endquality = -1; // signal placed in keg break; } } } if (craftSystem is DefAlchemy && (item is SpecialDye || item is SpecialDyeTub)) { // Which special dye tub do we want to use? Item[] sdtubs = ((Container)from.Backpack).FindItemsByType(typeof(SpecialDyeTub), true); SpecialDyeTub sdtub; if (m_NameString == "> Darken the mix" || m_NameString == "> Lighten the mix" && sdtubs.Length > 0) { sdtub = (SpecialDyeTub)sdtubs[0]; if (sdtubs.Length > 1) { // Pla, 04/01/07 // This code will never be called now but left it in for sanity. // ----------------------------------------------------------------- // Let the target take over from here //from.Target = new SpecialDyeTubTarget( this, typeRes, craftSystem, ref resHue, ref maxAmount, ref message, ref item, m_NameString, (m_NameString == "> Darken the mix" ? 1 : 2) ); //from.SendMessage("Select the dye tub you wish to use for the process."); } else { int iConsume = 0; if (m_NameString == "> Darken the mix") { if (sdtub.DarkenMix()) { from.SendMessage("You darken the mix with black pearl..."); double dCalc = sdtub.Uses; dCalc /= 5; iConsume = ((int)dCalc) + 1; } else //pla: This will never happen now from.SendMessage("You attempt to darken the mix, but it will go no darker."); } else { if (sdtub.LightenMix()) { from.SendMessage("You lighten the mix with sulfurous ash..."); double dCalc = sdtub.Uses; dCalc /= 5; iConsume = ((int)dCalc) + 1; } else //pla: This will never happen now from.SendMessage("You attempt to lighten the mix, but it will go no lighter."); } for (int i = 0; i < iConsume; i++) ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message); from.PlaySound(0x242); } } else { // Make sure they've got a regular dye tub / a special one of the same color Item[] dtub = ((Container)from.Backpack).FindItemsByType(typeof(DyeTub), true); DyeTub dt = null; int iFound = 0; if (dtub.Length > 0) { for (int i = 0; i < dtub.Length; i++) { if (dtub[i] is SpecialDyeTub) { // Is the same color? if (((SpecialDyeTub)dtub[i]).StoredColorName == m_NameString && ((SpecialDyeTub)dtub[i]).Uses < 100 && !((SpecialDyeTub)dtub[i]).Prepped) { dt = (DyeTub)dtub[i]; iFound++; } continue; } else { dt = (DyeTub)dtub[i]; iFound++; } } } sdtub = (SpecialDyeTub)item; if (dt == null) { from.SendMessage("You need a fresh dye tub or one that is not yet full and of the same color as the dye you are preparing."); sdtub.Delete(); } else { if (iFound > 1) { // Pla, 04/01/07 // This code will never be called now but left it in for sanity // ----------------------------------------------------------------- // Let the target take over from here //from.Target = new SpecialDyeTubTarget( this, typeRes, craftSystem, ref resHue, ref maxAmount, ref message, ref item, m_NameString, 0 ); //from.SendMessage("Select the dye tub you wish to use for the process."); } else { if (dt is SpecialDyeTub) { sdtub.Delete(); ((SpecialDyeTub)dt).Uses++; from.SendMessage("You mix the dye and add it to an existing batch."); } else { sdtub.StoreColor(m_NameString); dt.Delete(); from.SendMessage("You successfully mix the dye."); from.AddToBackpack(item); } ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message); } } } } if (craftSystem is DefTinkering && item is BaseTinkerTrap) { //Need to send target cursor to target //the trappable container bTinkerTrap = true; int power = (int)from.Skills[SkillName.Tinkering].Value + Utility.Random(0, 15); if (power <= 10) power = 10; ((BaseTinkerTrap)item).Power = power; from.SendMessage("Target the container you wish to trap."); from.Target = new TrappableContainerTarget(this, item, craftSystem, toolBroken, tool); } if (!bTinkerTrap && (!(item is SpecialDyeTub || item is SpecialDye))) { from.AddToBackpack(item); } //from.PlaySound( 0x57 ); } if (!bTinkerTrap) { int num = craftSystem.PlayEndingEffect(from, false, true, toolBroken, endquality, makersMark, this); 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. } else { ConsumeType consumeType = (UseAllRes ? ConsumeType.Fail : ConsumeType.Half); 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)) { 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); 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); } }