/// <summary> /// Returns the item property from props that newProp replaces, null if it does not replace any. /// </summary> public static BaseAttrInfo GetReplaced(BaseAttrInfo newProp, PropCollection props) { foreach (PropCollection.PropEntry entry in props.Properties) { BaseAttrInfo attr = entry.Property; if (newProp.Replaces(attr)) { return(attr); } } return(null); }
public static int GetUnravelWeight(Mobile from, Item item) { PropCollection props = new PropCollection(item); int intensity = props.Intensity; if (props.Count == 0) { return(0); } if (props.Count > 5) { intensity = 5 * (intensity / props.Count); } intensity = (int)(intensity * GetMaterialScalar(item)); if (from.Race == Race.Gargoyle) { intensity += 20; } if (from.InRange(new Point2D(797, 3432), 3)) { intensity += 10; } if (from.Region.IsPartOf("Queen's Palace")) { intensity += 30; } double correctionRate = 1.0; if (item is IDurability) { correctionRate -= GetDurabilityPenalty((IDurability)item); } if (item is IImbuable && ((IImbuable)item).TimesImbued > 0) { correctionRate -= 0.2; } intensity = (int)(intensity * correctionRate); return(intensity); }
public static int GetInsuranceCost( Item item ) { int cost; if ( item is ICollectionItem ) cost = 600; else if ( item is ISetItem ) cost = 600; else if ( item is IFactionArtifact ) cost = 800; else if ( item is IImbuable ) { int intensity = new PropCollection( item ).WeightedIntensity; if ( item is BaseWeapon ) { BaseWeapon weapon = item as BaseWeapon; cost = intensity; if ( weapon.Attributes.WeaponDamage <= 40 ) cost -= ( weapon.Attributes.WeaponDamage * 2 ); } else if ( item is BaseArmor ) { BaseArmor armor = item as BaseArmor; int totalResist = armor.PhysicalResistance + armor.FireResistance + armor.ColdResistance + armor.PoisonResistance + armor.EnergyResistance; cost = (int) Math.Ceiling( intensity + ( totalResist * 0.1 ) ); if ( intensity < 200 ) cost += (int) Math.Ceiling( intensity * 0.35 ); } else { cost = intensity; } } else cost = BaseVendor.GetVendorPrice( item.GetType() ); Utility.FixMinMax( ref cost, 10, 800 ); return cost; }
public static ConfirmationGump SelectProp( Mobile from, Item item, BaseAttrInfo propToImbue ) { PropCollection props = new PropCollection( item ); BaseAttrInfo propToReplace = Imbuing.GetReplaced( propToImbue, props ); int totalProperties = props.Count; int totalIntensity = props.WeightedIntensity; if ( propToReplace == null ) totalProperties++; else totalIntensity -= (int) ( Imbuing.ComputeIntensity( item, propToReplace ) * propToReplace.Weight ); if ( totalProperties > 5 || totalIntensity > ( (IImbuable) item ).MaxIntensity ) { from.SendLocalizedMessage( 1079772 ); // You cannot imbue this item with any more item properties. from.EndAction( typeof( Imbuing ) ); return null; } else return new ConfirmationGump( from, item, props, propToImbue, propToReplace, 1, Imbuing.GetIntensitySteps( propToImbue ) ); }
public ConfirmationGump(Mobile from, Item itemToImbue, PropCollection itemProperties, BaseAttrInfo propToImbue, BaseAttrInfo propToReplace, int intensityStep, int totalSteps) : base(50, 50) { // Var declarations int intensity; // intensity of the prop we are imbuing int wIntensity; // weighted intensity of the prop we are imbuing int totalIntensity; // total intensity of all props, weighted int wTotalIntensity; // total intensity of all props, weighted int totalProperties; // total number of properties the item will possess when imbued string newValueString; // the new value of the prop we are imbuing // Save the parameters. m_ItemToImbue = itemToImbue; m_Imbuable = m_ItemToImbue as IImbuable; m_ItemProperties = itemProperties; m_PropToImbue = propToImbue; m_PropToReplace = propToReplace; m_IntensityStep = intensityStep; m_TotalIntensitySteps = totalSteps; // Make sure we don't perverse the intensities. Utility.FixMinMax(ref m_IntensityStep, 1, m_TotalIntensitySteps); // Gets info about the prop that we are going to imbue. intensity = (int)(100 * ((double)m_IntensityStep / m_TotalIntensitySteps)); wIntensity = (int)(intensity * m_PropToImbue.Weight); totalIntensity = m_ItemProperties.Intensity + intensity; wTotalIntensity = m_ItemProperties.WeightedIntensity + wIntensity; totalProperties = m_ItemProperties.Count; m_ValueToImbue = ComputeValue(m_IntensityStep, m_TotalIntensitySteps, m_PropToImbue.MinIntensity, m_PropToImbue.MaxIntensity); newValueString = FormatValue(m_PropToImbue.Modify(m_ItemToImbue, m_ValueToImbue), m_PropToImbue); // ********************** // Gump Structure // ********************** AddPage(0); AddBackground(0, 0, 520, 440, 0x13BE); AddImageTiled(10, 10, 500, 20, 0xA40); AddImageTiled(10, 40, 245, 140, 0xA40); AddImageTiled(265, 40, 245, 140, 0xA40); AddImageTiled(10, 190, 245, 140, 0xA40); AddImageTiled(265, 190, 245, 140, 0xA40); AddImageTiled(10, 340, 500, 60, 0xA40); AddImageTiled(10, 410, 500, 20, 0xA40); AddAlphaRegion(10, 10, 500, 420); AddHtmlLocalized(10, 12, 500, 20, 1079717, 0x7FFF, false, false); // <CENTER>IMBUING CONFIRMATION</CENTER> // ********************** // Property Info // ********************** AddHtmlLocalized(50, 50, 250, 20, 1114269, 0x7FFF, false, false); // PROPERTY INFORMATION AddHtmlLocalized(25, 80, 390, 20, 1114270, 0x7FFF, false, false); // Property: AddHtmlLocalized(95, 80, 150, 20, m_PropToImbue.Name, 0x7FFF, false, false); AddHtmlLocalized(25, 100, 390, 20, 1114271, 0x7FFF, false, false); // Replaces: if (m_PropToReplace != null) { m_ValueToReplace = m_PropToReplace.GetValue(m_ItemToImbue); AddHtmlLocalized(95, 100, 150, 20, m_PropToReplace.Name, 0x7FFF, false, false); // The intensity of the property replaced may not count in the total. int replaceIntensity = Imbuing.ComputeIntensity(m_ItemToImbue, m_PropToReplace); totalIntensity -= replaceIntensity; wTotalIntensity -= (int)(m_PropToReplace.Weight * replaceIntensity); } else { // Since we are not replacing any prop, it means we are adding one ^^u totalProperties++; } m_WTotalIntensity = wTotalIntensity; AddHtmlLocalized(25, 120, 200, 20, 1114272, 0x7FFF, false, false); // Weight: AddLabel(95, 120, 0x481, String.Format("{0:0.0}x", m_PropToImbue.Weight)); AddHtmlLocalized(25, 140, 200, 20, 1114273, 0x7FFF, false, false); // Intensity: AddLabel(95, 140, 0x481, String.Format("{0}%", wIntensity)); AddHtmlLocalized(280, 55, 205, 115, m_PropToImbue.Description, 0x7FFF, false, false); // ********************** // Material Info // ********************** AddHtmlLocalized(100, 200, 80, 20, 1044055, 0x7FFF, false, false); // <CENTER>MATERIALS</CENTER> m_Resources1 = Math.Max(1, (int)(intensity / 20)); m_Resources2 = Math.Max(1, (int)(intensity / 10)); m_Resources3 = Math.Max(0, (intensity - 90)); AddHtmlLocalized(40, 220, 390, 20, (int)m_PropToImbue.PrimaryResource, 0x7FFF, false, false); AddLabel(210, 220, 0x481, m_Resources1.ToString()); AddHtmlLocalized(40, 240, 390, 20, (int)m_PropToImbue.SecondaryResource, 0x7FFF, false, false); AddLabel(210, 240, 0x481, m_Resources2.ToString()); if (m_Resources3 > 0) { AddHtmlLocalized(40, 260, 390, 20, (int)m_PropToImbue.FullResource, 0x7FFF, false, false); AddLabel(210, 260, 0x481, m_Resources3.ToString()); } // ********************** // Results // ********************** AddHtmlLocalized(350, 200, 65, 20, 1113650, 0x7FFF, false, false); // RESULTS AddHtmlLocalized(280, 220, 140, 20, 1113645, 0x7FFF, false, false); // Properties: AddFractionLabel(430, 220, totalProperties, 5); AddHtmlLocalized(280, 240, 260, 20, 1113646, 0x7FFF, false, false); // Total Property Weight: AddFractionLabel(430, 240, wTotalIntensity, m_Imbuable.MaxIntensity); AddHtmlLocalized(280, 260, 200, 20, 1113647, 0x7FFF, false, false); // Times Imbued: AddFractionLabel(430, 260, m_Imbuable.TimesImbued, 20); // ********************** // Choose Intensity // ********************** if (m_PropToImbue.MinIntensity != m_PropToImbue.MaxIntensity) { AddHtmlLocalized(235, 350, 200, 20, 1062300, 0x7FFF, false, false); // New Value: AddLabel(256, 370, 0x481, newValueString); AddButton(179, 372, 0x1464, 0x1464, 310, GumpButtonType.Reply, 0); AddButton(187, 372, 0x1466, 0x1466, 310, GumpButtonType.Reply, 0); AddLabel(181, 370, 0x0, "<"); AddLabel(185, 370, 0x0, "<"); AddLabel(189, 370, 0x0, "<"); AddButton(199, 372, 0x1464, 0x1464, 314, GumpButtonType.Reply, 0); AddButton(207, 372, 0x1466, 0x1466, 314, GumpButtonType.Reply, 0); AddLabel(202, 370, 0x0, "<"); AddLabel(207, 370, 0x0, "<"); AddButton(221, 372, 0x1464, 0x1464, 311, GumpButtonType.Reply, 0); AddButton(229, 372, 0x1466, 0x1466, 311, GumpButtonType.Reply, 0); AddLabel(224, 370, 0x0, "<"); AddButton(280, 372, 0x1464, 0x1464, 312, GumpButtonType.Reply, 0); AddButton(288, 372, 0x1466, 0x1466, 312, GumpButtonType.Reply, 0); AddLabel(286, 370, 0x0, ">"); AddButton(300, 372, 0x1464, 0x1464, 315, GumpButtonType.Reply, 0); AddButton(308, 372, 0x1466, 0x1466, 315, GumpButtonType.Reply, 0); AddLabel(304, 370, 0x0, ">"); AddLabel(308, 370, 0x0, ">"); AddButton(320, 372, 0x1464, 0x1464, 313, GumpButtonType.Reply, 0); AddButton(328, 372, 0x1466, 0x1466, 313, GumpButtonType.Reply, 0); AddLabel(322, 370, 0x0, ">"); AddLabel(326, 370, 0x0, ">"); AddLabel(330, 370, 0x0, ">"); } // ********************** // Self Repair Warning // ********************** bool selfRepair = (m_ItemToImbue is IArmor && ((IArmor)m_ItemToImbue).ArmorAttributes.SelfRepair != 0) || (m_ItemToImbue is ICloth && ((ICloth)m_ItemToImbue).ClothingAttributes.SelfRepair != 0) || (m_ItemToImbue is IWeapon && ((IWeapon)m_ItemToImbue).WeaponAttributes.SelfRepair != 0); if (selfRepair) { AddHtmlLocalized(20, 330, 390, 20, 1080417, 0x7FFF, false, false); // WARNING! Imbuing will remove Self Repair from this item. } // ********************** // Success Chance // ********************** m_SuccessChance = Imbuing.GetSuccessChance(from, m_ItemToImbue, totalIntensity); AddHtmlLocalized(300, 300, 250, 20, 1044057, 0x7FFF, false, false); // Success Chance: AddLabel(420, 300, GetSuccessChanceHue(), String.Format("{0:0.0}%", Math.Max(0, (m_SuccessChance * 100)))); // ********************** // Are we ready to rock? // ********************** AddButton(15, 410, 0xFA5, 0xFA6, 301, GumpButtonType.Reply, 0); AddHtmlLocalized(50, 412, 100, 20, 1114268, 0x7FFF, false, false); // Back AddButton(390, 410, 0xFA5, 0xFA6, 302, GumpButtonType.Reply, 0); AddHtmlLocalized(425, 412, 100, 20, 1114267, 0x7FFF, false, false); // Imbue Item }
public static int GetUnravelWeight( Mobile from, Item item ) { PropCollection props = new PropCollection( item ); int intensity = props.Intensity; if ( props.Count == 0 ) return 0; if ( props.Count > 5 ) intensity = 5 * ( intensity / props.Count ); intensity = (int) ( intensity * GetMaterialScalar( item ) ); if ( from.Race == Race.Gargoyle ) intensity += 20; if ( from.InRange( new Point2D( 797, 3432 ), 3 ) ) intensity += 10; if ( from.Region.IsPartOf( "Queen's Palace" ) ) intensity += 30; double correctionRate = 1.0; if ( item is IDurability ) correctionRate -= GetDurabilityPenalty( (IDurability) item ); if ( item is IImbuable && ( (IImbuable) item ).TimesImbued > 0 ) correctionRate -= 0.2; intensity = (int) ( intensity * correctionRate ); return intensity; }
/// <summary> /// Returns the item property from props that newProp replaces, null if it does not replace any. /// </summary> public static BaseAttrInfo GetReplaced( BaseAttrInfo newProp, PropCollection props ) { foreach ( PropCollection.PropEntry entry in props.Properties ) { BaseAttrInfo attr = entry.Property; if ( newProp.Replaces( attr ) ) return attr; } return null; }