public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; if (info.ButtonID == 0) { return; } int index = info.ButtonID - 100; if (index >= 0 && index <= 12 && RunicReforging.HasSelection(index, m_ToReforge, m_Tool, m_Options, (int)m_Prefix, (int)m_Suffix)) { var context = ReforgingContext.GetContext(from); if (m_IsPrefix) { context.Prefix = (ReforgedPrefix)index; m_Prefix = (ReforgedPrefix)index; } else { context.Suffix = (ReforgedSuffix)index; m_Suffix = (ReforgedSuffix)index; } } from.SendGump(new RunicReforgingGump(from, m_ToReforge, m_Tool)); }
public ItemNameGump(Item toreforge, BaseRunicTool tool, ReforgingOption options, ReforgedPrefix prefix, ReforgedSuffix suffix, bool isprefix) : base(100, 100) { m_Tool = tool; m_ToReforge = toreforge; m_Options = options; m_Prefix = prefix; m_Suffix = suffix; m_IsPrefix = isprefix; AddBackground(0, 0, 370, 440, 83); AddHtmlLocalized(10, 10, 350, 18, 1114513, "#1152089", 0x4BB7, false, false); // Runic Crafting - Item Name Selection int buttonID = 4005; int buttonHue = 0x4BB2; int y = 50; foreach (int i in Enum.GetValues(typeof(ReforgedPrefix))) { if (i == 0) { continue; } if ((isprefix && prefix == (ReforgedPrefix)i) || (!isprefix && suffix == (ReforgedSuffix)i)) { buttonID = 4006; buttonHue = Green; } else { buttonID = 4005; buttonHue = White; } if (RunicReforging.HasSelection(i, toreforge, tool, m_Options, (int)m_Prefix, (int)m_Suffix)) { AddButton(15, y, buttonID, buttonID, 100 + i, GumpButtonType.Reply, 0); } else { buttonHue = Yellow; } AddHtmlLocalized(55, y, 250, 20, RunicReforging.GetName(i), buttonHue, false, false); y += 25; } AddHtmlLocalized(45, 412, 100, 20, 1060675, White, false, false); AddButton(10, 412, 4017, 4019, 0, GumpButtonType.Reply, 0); }
public ItemNameGump(Item toreforge, BaseRunicTool tool, ReforgingOption options, ReforgedPrefix prefix, ReforgedSuffix suffix, bool isprefix) : base(25, 25) { m_Tool = tool; m_ToReforge = toreforge; m_Options = options; m_Prefix = prefix; m_Suffix = suffix; m_IsPrefix = isprefix; AddBackground(0, 0, 376, 445, 83); AddHtmlObject(72, 10, 250, 100, 1152089, DarkGreen, false, false); int buttonID = 4005; int buttonHue = White; int y = 50; foreach (int i in Enum.GetValues(typeof(ReforgedPrefix))) { if ((isprefix && prefix == (ReforgedPrefix)i) || (!isprefix && suffix == (ReforgedSuffix)i)) { buttonID = 4006; buttonHue = LightGreen; } else { buttonID = 4005; buttonHue = White; } if (HasSelection(i, toreforge, tool)) { AddButton(15, y, buttonID, buttonID, 100 + i, GumpButtonType.Reply, 0); AddHtmlObject(55, y, 250, 20, RunicReforging.GetName(i), buttonHue, false, false); } y += 25; } AddHtmlObject(55, 410, 100, 20, "CLOSE", White, false, false); AddButton(15, 410, 4017, 4019, 0, GumpButtonType.Reply, 0); }
public ReforgingContext(GenericReader reader) { Contexts = new Dictionary <BaseTool, ReforgingOption>(); int version = reader.ReadInt(); Prefix = (ReforgedPrefix)reader.ReadInt(); Suffix = (ReforgedSuffix)reader.ReadInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { BaseTool tool = reader.ReadItem() as BaseTool; ReforgingOption option = (ReforgingOption)reader.ReadInt(); if (tool != null) { Contexts[tool] = option; } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch ( version ) { case 8: { this.m_IsImbued = reader.ReadBool(); goto case 7; } case 7: { m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this, reader); #region Runic Reforging m_ReforgedPrefix = (ReforgedPrefix)reader.ReadInt(); m_ReforgedSuffix = (ReforgedSuffix)reader.ReadInt(); m_ItemPower = (ItemPower)reader.ReadInt(); m_BlockRepair = reader.ReadBool(); #endregion #region Stygian Abyss m_GorgonLenseCharges = reader.ReadInt(); m_GorgonLenseType = (LenseType)reader.ReadInt(); m_PhysImbuing = reader.ReadInt(); m_FireImbuing = reader.ReadInt(); m_ColdImbuing = reader.ReadInt(); m_PoisonImbuing = reader.ReadInt(); m_EnergyImbuing = reader.ReadInt(); goto case 6; } case 6: { if(version == 6) m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this); this.m_TimesImbued = reader.ReadInt(); #endregion this.m_BlessedBy = reader.ReadMobile(); #region Mondain's Legacy Sets SetFlag sflags = (SetFlag)reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.Attributes)) this.m_SetAttributes = new AosAttributes(this, reader); else this.m_SetAttributes = new AosAttributes(this); if (GetSaveFlag(sflags, SetFlag.ArmorAttributes)) this.m_SetSelfRepair = (new AosArmorAttributes(this, reader)).SelfRepair; if (GetSaveFlag(sflags, SetFlag.SkillBonuses)) this.m_SetSkillBonuses = new AosSkillBonuses(this, reader); else this.m_SetSkillBonuses = new AosSkillBonuses(this); if (GetSaveFlag(sflags, SetFlag.PhysicalBonus)) this.m_SetPhysicalBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.FireBonus)) this.m_SetFireBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.ColdBonus)) this.m_SetColdBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.PoisonBonus)) this.m_SetPoisonBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.EnergyBonus)) this.m_SetEnergyBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.SetHue)) this.m_SetHue = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.LastEquipped)) this.m_LastEquipped = reader.ReadBool(); if (GetSaveFlag(sflags, SetFlag.SetEquipped)) this.m_SetEquipped = reader.ReadBool(); if (GetSaveFlag(sflags, SetFlag.SetSelfRepair)) this.m_SetSelfRepair = reader.ReadEncodedInt(); #endregion goto case 5; } case 5: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.NegativeAttributes)) m_NegativeAttributes = new NegativeAttributes(this, reader); else m_NegativeAttributes = new NegativeAttributes(this); if (GetSaveFlag(flags, SaveFlag.Resource)) this.m_Resource = (CraftResource)reader.ReadEncodedInt(); else this.m_Resource = this.DefaultResource; if (GetSaveFlag(flags, SaveFlag.Attributes)) this.m_AosAttributes = new AosAttributes(this, reader); else this.m_AosAttributes = new AosAttributes(this); if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) this.m_AosClothingAttributes = new AosArmorAttributes(this, reader); else this.m_AosClothingAttributes = new AosArmorAttributes(this); if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) this.m_AosSkillBonuses = new AosSkillBonuses(this, reader); else this.m_AosSkillBonuses = new AosSkillBonuses(this); if (GetSaveFlag(flags, SaveFlag.Resistances)) this.m_AosResistances = new AosElementAttributes(this, reader); else this.m_AosResistances = new AosElementAttributes(this); if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) this.m_MaxHitPoints = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.HitPoints)) this.m_HitPoints = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Crafter)) this.m_Crafter = reader.ReadMobile(); if (GetSaveFlag(flags, SaveFlag.Quality)) this.m_Quality = (ClothingQuality)reader.ReadEncodedInt(); else this.m_Quality = ClothingQuality.Regular; if (GetSaveFlag(flags, SaveFlag.StrReq)) this.m_StrReq = reader.ReadEncodedInt(); else this.m_StrReq = -1; if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) this.m_PlayerConstructed = true; break; } case 4: { this.m_Resource = (CraftResource)reader.ReadInt(); goto case 3; } case 3: { this.m_AosAttributes = new AosAttributes(this, reader); this.m_AosClothingAttributes = new AosArmorAttributes(this, reader); this.m_AosSkillBonuses = new AosSkillBonuses(this, reader); this.m_AosResistances = new AosElementAttributes(this, reader); goto case 2; } case 2: { this.m_PlayerConstructed = reader.ReadBool(); goto case 1; } case 1: { this.m_Crafter = reader.ReadMobile(); this.m_Quality = (ClothingQuality)reader.ReadInt(); break; } case 0: { this.m_Crafter = null; this.m_Quality = ClothingQuality.Regular; break; } } #region Mondain's Legacy Sets if (this.m_SetAttributes == null) this.m_SetAttributes = new AosAttributes(this); if (this.m_SetSkillBonuses == null) this.m_SetSkillBonuses = new AosSkillBonuses(this); #endregion if (version < 2) this.m_PlayerConstructed = true; // we don't know, so, assume it's crafted if (version < 3) { this.m_AosAttributes = new AosAttributes(this); this.m_AosClothingAttributes = new AosArmorAttributes(this); this.m_AosSkillBonuses = new AosSkillBonuses(this); this.m_AosResistances = new AosElementAttributes(this); } if (version < 4) this.m_Resource = this.DefaultResource; if (this.m_MaxHitPoints == 0 && this.m_HitPoints == 0) this.m_HitPoints = this.m_MaxHitPoints = Utility.RandomMinMax(this.InitMinHits, this.InitMaxHits); Mobile parent = this.Parent as Mobile; if (parent != null) { if (Core.AOS) this.m_AosSkillBonuses.AddTo(parent); this.AddStatBonuses(parent); parent.CheckStatTimers(); } }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; if (info.ButtonID == 0) return; int index = info.ButtonID - 100; if (index >= 0 && index <= 12 && HasSelection(index, m_ToReforge, m_Tool)) { if (m_IsPrefix) { m_Prefix = (ReforgedPrefix)index; } else { m_Suffix = (ReforgedSuffix)index; } } from.SendGump(new RunicReforgingGump(from, m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix)); }
public RunicReforgingGump(Mobile from, Item toReforge, BaseRunicTool tool) : base(100, 100) { from.CloseGump(typeof(RunicReforgingGump)); from.CloseGump(typeof(ImbueGump)); m_Context = ReforgingContext.GetContext(from); if (!m_Context.Contexts.ContainsKey(tool)) { m_Context.Contexts[tool] = ReforgingOption.None; } m_Tool = tool; m_ToReforge = toReforge; m_Options = m_Context.Contexts[tool]; m_Prefix = m_Context.Prefix; m_Suffix = m_Context.Suffix; AddBackground(0, 0, 370, 440, 83); AddHtmlLocalized(10, 10, 350, 18, 1114513, "#1151952", 0x4BB7, false, false); // Runic Crafting Options int buttonHue = 0x4BB2; int buttonID = 0x4005; int y = 40; int idx = 0; for (int i = 0; i < Options.Length; i++) { ReforgingOption option = Options[i]; if ((m_Options & option) != 0) { if (CanReforge(from, option) && HasMetPrerequisite(option)) { buttonHue = 0x4BB2; buttonID = 4006; } else { buttonHue = 0x7652; buttonID = 4006; } } else { if (CanReforge(from, option) && HasMetPrerequisite(option)) { buttonHue = 0x6F7B; buttonID = 4005; } else { buttonHue = 0x7652; buttonID = 4006; } } if (HasMetPrerequisite(option) && CanReforge(from, option)) { AddButton(15, y, buttonID, buttonID, i + 100, GumpButtonType.Reply, 0); } AddHtmlLocalized(55, y, 250, 20, GetCliloc(option), buttonHue, false, false); y += 25; idx++; } int totalCharges = GetTotalCharges(); if ((m_Options & ReforgingOption.InspiredArtifice) != 0) { AddButton(15, 305, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(55, 305, 250, 20, 1152087, 0x6F7B, false, false); AddHtmlLocalized(190, 305, 250, 20, RunicReforging.GetName((int)m_Prefix), 0x5757, false, false); } if ((m_Options & ReforgingOption.SublimeArtifice) != 0) { AddButton(15, 330, 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(55, 330, 250, 20, 1152088, 0x6F7B, false, false); AddHtmlLocalized(190, 330, 250, 20, RunicReforging.GetName((int)m_Suffix), 0x5757, false, false); } AddHtmlLocalized(10, 363, 140, 22, 1114514, "#1152078", 0x4BB2, false, false); // CHARGES NEEDED: AddLabel(160, 363, 0x113, totalCharges.ToString()); AddHtmlLocalized(10, 385, 140, 22, 1114514, "#1152077", 0x6F7B, false, false); // TOOL CHARGES: AddLabel(160, 385, 0x44E, m_Tool.UsesRemaining.ToString()); AddButton(10, 412, 4017, 4018, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(45, 410, 200, 20, 1060675, 0x6F7B, false, false); // CLOSE AddButton(330, 363, 4014, 4016, 3, GumpButtonType.Reply, 0); AddHtmlLocalized(190, 363, 135, 22, 1114514, "#1152080", 0x6F7B, false, false); // REFORGE ITEM AddButton(330, 412, 4011, 4013, 4, GumpButtonType.Reply, 0); AddHtmlLocalized(185, 412, 140, 18, 1114514, "#1149735", 0x6F7B, false, false); // HELP }
public ItemNameGump(Item toreforge, BaseRunicTool tool, ReforgingOption options, ReforgedPrefix prefix, ReforgedSuffix suffix, bool isprefix) : base(25, 25) { m_Tool = tool; m_ToReforge = toreforge; m_Options = options; m_Prefix = prefix; m_Suffix = suffix; m_IsPrefix = isprefix; AddBackground(0, 0, 376, 445, 83); AddHtmlObject(72, 10, 250, 100, 1152089, DarkGreen, false, false); int buttonID = 4005; int buttonHue = White; int y = 50; foreach (int i in Enum.GetValues(typeof(ReforgedPrefix))) { if ((isprefix && prefix == (ReforgedPrefix)i) || (!isprefix && suffix == (ReforgedSuffix)i)) { buttonID = 4006; buttonHue = LightGreen; } else { buttonID = 4005; buttonHue = White; } if(HasSelection(i, toreforge, tool)) { AddButton(15, y, buttonID, buttonID, 100 + i, GumpButtonType.Reply, 0); AddHtmlObject(55, y, 250, 20, RunicReforging.GetName(i), buttonHue, false, false); } y += 25; } AddHtmlObject(55, 410, 100, 20, "CLOSE", White, false, false); AddButton(15, 410, 4017, 4019, 0, GumpButtonType.Reply, 0); }
public static bool GenerateRandomItem(Item item, Mobile killer, BaseCreature creature, ReforgedPrefix prefix, ReforgedSuffix suffix) { if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat) { GenerateRandomItem(item, killer, Math.Max(100, GetDifficultyFor(creature)), LootPack.GetLuckChanceForKiller(creature), prefix, suffix); return true; } return false; }
public static int GetSuffixName(ReforgedSuffix suffix) { return NameTable[(int)suffix - 1][1]; }
public static void ApplyReforgedProperties(Item item, ReforgedPrefix prefix, ReforgedSuffix suffix, bool playermade, int budget, int perclow, int perchigh, int maxmods, int luckchance) { ApplyReforgedProperties(item, prefix, suffix, playermade, budget, perclow, perchigh, maxmods, 0, luckchance); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch ( version ) { case 9: { #region Runic Reforging m_ReforgedPrefix = (ReforgedPrefix)reader.ReadInt(); m_ReforgedSuffix = (ReforgedSuffix)reader.ReadInt(); m_ItemPower = (ItemPower)reader.ReadInt(); m_BlockRepair = reader.ReadBool(); #endregion #region Stygian Abyss m_GorgonLenseCharges = reader.ReadInt(); m_GorgonLenseType = (LenseType)reader.ReadInt(); m_PhysImbuing = reader.ReadInt(); m_FireImbuing = reader.ReadInt(); m_ColdImbuing = reader.ReadInt(); m_PoisonImbuing = reader.ReadInt(); m_EnergyImbuing = reader.ReadInt(); goto case 8; } case 8: { this.m_TimesImbued = reader.ReadInt(); #endregion this.m_BlessedBy = reader.ReadMobile(); SetFlag sflags = (SetFlag)reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.Attributes)) this.m_SetAttributes = new AosAttributes(this, reader); else this.m_SetAttributes = new AosAttributes(this); if (GetSaveFlag(sflags, SetFlag.ArmorAttributes)) this.m_SetSelfRepair = (new AosArmorAttributes(this, reader)).SelfRepair; if (GetSaveFlag(sflags, SetFlag.SkillBonuses)) this.m_SetSkillBonuses = new AosSkillBonuses(this, reader); else this.m_SetSkillBonuses = new AosSkillBonuses(this); if (GetSaveFlag(sflags, SetFlag.PhysicalBonus)) this.m_SetPhysicalBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.FireBonus)) this.m_SetFireBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.ColdBonus)) this.m_SetColdBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.PoisonBonus)) this.m_SetPoisonBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.EnergyBonus)) this.m_SetEnergyBonus = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.Hue)) this.m_SetHue = reader.ReadEncodedInt(); if (GetSaveFlag(sflags, SetFlag.LastEquipped)) this.m_LastEquipped = reader.ReadBool(); if (GetSaveFlag(sflags, SetFlag.SetEquipped)) this.m_SetEquipped = reader.ReadBool(); if (GetSaveFlag(sflags, SetFlag.SetSelfRepair)) this.m_SetSelfRepair = reader.ReadEncodedInt(); goto case 5; } case 7: case 6: case 5: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) this.m_AosAttributes = new AosAttributes(this, reader); else this.m_AosAttributes = new AosAttributes(this); if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) this.m_AosArmorAttributes = new AosArmorAttributes(this, reader); else this.m_AosArmorAttributes = new AosArmorAttributes(this); if (GetSaveFlag(flags, SaveFlag.PhysicalBonus)) this.m_PhysicalBonus = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.FireBonus)) this.m_FireBonus = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.ColdBonus)) this.m_ColdBonus = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.PoisonBonus)) this.m_PoisonBonus = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.EnergyBonus)) this.m_EnergyBonus = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Identified)) this.m_Identified = (version >= 7 || reader.ReadBool()); if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) this.m_MaxHitPoints = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.HitPoints)) this.m_HitPoints = reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Crafter)) this.m_Crafter = reader.ReadMobile(); if (GetSaveFlag(flags, SaveFlag.Quality)) this.m_Quality = (ArmorQuality)reader.ReadEncodedInt(); else this.m_Quality = ArmorQuality.Regular; if (version == 5 && this.m_Quality == ArmorQuality.Low) this.m_Quality = ArmorQuality.Regular; if (GetSaveFlag(flags, SaveFlag.Durability)) { this.m_Durability = (ArmorDurabilityLevel)reader.ReadEncodedInt(); if (this.m_Durability > ArmorDurabilityLevel.Indestructible) this.m_Durability = ArmorDurabilityLevel.Durable; } if (GetSaveFlag(flags, SaveFlag.Protection)) { this.m_Protection = (ArmorProtectionLevel)reader.ReadEncodedInt(); if (this.m_Protection > ArmorProtectionLevel.Invulnerability) this.m_Protection = ArmorProtectionLevel.Defense; } if (GetSaveFlag(flags, SaveFlag.Resource)) this.m_Resource = (CraftResource)reader.ReadEncodedInt(); else this.m_Resource = this.DefaultResource; if (this.m_Resource == CraftResource.None) this.m_Resource = this.DefaultResource; if (GetSaveFlag(flags, SaveFlag.BaseArmor)) this.m_ArmorBase = reader.ReadEncodedInt(); else this.m_ArmorBase = -1; if (GetSaveFlag(flags, SaveFlag.StrBonus)) this.m_StrBonus = reader.ReadEncodedInt(); else this.m_StrBonus = -1; if (GetSaveFlag(flags, SaveFlag.DexBonus)) this.m_DexBonus = reader.ReadEncodedInt(); else this.m_DexBonus = -1; if (GetSaveFlag(flags, SaveFlag.IntBonus)) this.m_IntBonus = reader.ReadEncodedInt(); else this.m_IntBonus = -1; if (GetSaveFlag(flags, SaveFlag.StrReq)) this.m_StrReq = reader.ReadEncodedInt(); else this.m_StrReq = -1; if (GetSaveFlag(flags, SaveFlag.DexReq)) this.m_DexReq = reader.ReadEncodedInt(); else this.m_DexReq = -1; if (GetSaveFlag(flags, SaveFlag.IntReq)) this.m_IntReq = reader.ReadEncodedInt(); else this.m_IntReq = -1; if (GetSaveFlag(flags, SaveFlag.MedAllowance)) this.m_Meditate = (AMA)reader.ReadEncodedInt(); else this.m_Meditate = (AMA)(-1); if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) this.m_AosSkillBonuses = new AosSkillBonuses(this, reader); if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) this.m_PlayerConstructed = true; if (version > 7 && GetSaveFlag(flags, SaveFlag.xAbsorptionAttributes)) this.m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this, reader); else this.m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this); break; } case 4: { this.m_AosAttributes = new AosAttributes(this, reader); this.m_AosArmorAttributes = new AosArmorAttributes(this, reader); goto case 3; } case 3: { this.m_PhysicalBonus = reader.ReadInt(); this.m_FireBonus = reader.ReadInt(); this.m_ColdBonus = reader.ReadInt(); this.m_PoisonBonus = reader.ReadInt(); this.m_EnergyBonus = reader.ReadInt(); goto case 2; } case 2: case 1: { this.m_Identified = reader.ReadBool(); goto case 0; } case 0: { this.m_ArmorBase = reader.ReadInt(); this.m_MaxHitPoints = reader.ReadInt(); this.m_HitPoints = reader.ReadInt(); this.m_Crafter = reader.ReadMobile(); this.m_Quality = (ArmorQuality)reader.ReadInt(); this.m_Durability = (ArmorDurabilityLevel)reader.ReadInt(); this.m_Protection = (ArmorProtectionLevel)reader.ReadInt(); AMT mat = (AMT)reader.ReadInt(); if (this.m_ArmorBase == this.RevertArmorBase) this.m_ArmorBase = -1; /*m_BodyPos = (ArmorBodyType)*/reader.ReadInt(); if (version < 4) { this.m_AosAttributes = new AosAttributes(this); this.m_AosArmorAttributes = new AosArmorAttributes(this); } if (version < 3 && this.m_Quality == ArmorQuality.Exceptional) this.DistributeBonuses(6); if (version >= 2) { this.m_Resource = (CraftResource)reader.ReadInt(); } else { OreInfo info; switch ( reader.ReadInt() ) { default: case 0: info = OreInfo.Iron; break; case 1: info = OreInfo.DullCopper; break; case 2: info = OreInfo.ShadowIron; break; case 3: info = OreInfo.Copper; break; case 4: info = OreInfo.Bronze; break; case 5: info = OreInfo.Gold; break; case 6: info = OreInfo.Agapite; break; case 7: info = OreInfo.Verite; break; case 8: info = OreInfo.Valorite; break; } this.m_Resource = CraftResources.GetFromOreInfo(info, mat); } this.m_StrBonus = reader.ReadInt(); this.m_DexBonus = reader.ReadInt(); this.m_IntBonus = reader.ReadInt(); this.m_StrReq = reader.ReadInt(); this.m_DexReq = reader.ReadInt(); this.m_IntReq = reader.ReadInt(); if (this.m_StrBonus == this.OldStrBonus) this.m_StrBonus = -1; if (this.m_DexBonus == this.OldDexBonus) this.m_DexBonus = -1; if (this.m_IntBonus == this.OldIntBonus) this.m_IntBonus = -1; if (this.m_StrReq == this.OldStrReq) this.m_StrReq = -1; if (this.m_DexReq == this.OldDexReq) this.m_DexReq = -1; if (this.m_IntReq == this.OldIntReq) this.m_IntReq = -1; this.m_Meditate = (AMA)reader.ReadInt(); if (this.m_Meditate == this.OldMedAllowance) this.m_Meditate = (AMA)(-1); if (this.m_Resource == CraftResource.None) { if (mat == ArmorMaterialType.Studded || mat == ArmorMaterialType.Leather) this.m_Resource = CraftResource.RegularLeather; else if (mat == ArmorMaterialType.Spined) this.m_Resource = CraftResource.SpinedLeather; else if (mat == ArmorMaterialType.Horned) this.m_Resource = CraftResource.HornedLeather; else if (mat == ArmorMaterialType.Barbed) this.m_Resource = CraftResource.BarbedLeather; else this.m_Resource = CraftResource.Iron; } if (this.m_MaxHitPoints == 0 && this.m_HitPoints == 0) this.m_HitPoints = this.m_MaxHitPoints = Utility.RandomMinMax(this.InitMinHits, this.InitMaxHits); break; } } #region Mondain's Legacy Sets if (this.m_SetAttributes == null) this.m_SetAttributes = new AosAttributes(this); if (this.m_SetSkillBonuses == null) this.m_SetSkillBonuses = new AosSkillBonuses(this); #endregion if (this.m_AosSkillBonuses == null) this.m_AosSkillBonuses = new AosSkillBonuses(this); if (Core.AOS && this.Parent is Mobile) this.m_AosSkillBonuses.AddTo((Mobile)this.Parent); int strBonus = this.ComputeStatBonus(StatType.Str); int dexBonus = this.ComputeStatBonus(StatType.Dex); int intBonus = this.ComputeStatBonus(StatType.Int); if (this.Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)this.Parent; string modName = this.Serial.ToString(); if (strBonus != 0) m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); if (dexBonus != 0) m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); if (intBonus != 0) m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } if (this.Parent is Mobile) ((Mobile)this.Parent).CheckStatTimers(); if (version < 7) this.m_PlayerConstructed = true; // we don't know, so, assume it's crafted }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 7: { this.m_IsImbued = reader.ReadBool(); goto case 6; } case 6: { m_NegativeAttributes = new NegativeAttributes(this, reader); goto case 5; } case 5: { #region Runic Reforging m_ReforgedPrefix = (ReforgedPrefix)reader.ReadInt(); m_ReforgedSuffix = (ReforgedSuffix)reader.ReadInt(); m_ItemPower = (ItemPower)reader.ReadInt(); m_BlockRepair = reader.ReadBool(); #endregion #region Stygian Abyss m_GorgonLenseCharges = reader.ReadInt(); m_GorgonLenseType = (LenseType)reader.ReadInt(); goto case 4; } case 4: { this.m_TimesImbued = reader.ReadEncodedInt(); this.m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this, reader); #endregion this.m_BlessedBy = reader.ReadMobile(); this.m_LastEquipped = reader.ReadBool(); this.m_SetEquipped = reader.ReadBool(); this.m_SetHue = reader.ReadEncodedInt(); this.m_SetAttributes = new AosAttributes(this, reader); this.m_SetSkillBonuses = new AosSkillBonuses(this, reader); this.m_Crafter = reader.ReadMobile(); this.m_Quality = (ArmorQuality)reader.ReadInt(); goto case 3; } case 3: { this.m_MaxHitPoints = reader.ReadEncodedInt(); this.m_HitPoints = reader.ReadEncodedInt(); goto case 2; } case 2: { this.m_Resource = (CraftResource)reader.ReadEncodedInt(); this.m_GemType = (GemType)reader.ReadEncodedInt(); goto case 1; } case 1: { this.m_AosAttributes = new AosAttributes(this, reader); this.m_AosResistances = new AosElementAttributes(this, reader); this.m_AosSkillBonuses = new AosSkillBonuses(this, reader); if (Core.AOS && this.Parent is Mobile) this.m_AosSkillBonuses.AddTo((Mobile)this.Parent); int strBonus = this.m_AosAttributes.BonusStr; int dexBonus = this.m_AosAttributes.BonusDex; int intBonus = this.m_AosAttributes.BonusInt; if (this.Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)this.Parent; string modName = this.Serial.ToString(); if (strBonus != 0) m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); if (dexBonus != 0) m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); if (intBonus != 0) m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } if (this.Parent is Mobile) ((Mobile)this.Parent).CheckStatTimers(); break; } case 0: { this.m_AosAttributes = new AosAttributes(this); this.m_AosResistances = new AosElementAttributes(this); this.m_AosSkillBonuses = new AosSkillBonuses(this); break; } } if (m_NegativeAttributes == null) m_NegativeAttributes = new NegativeAttributes(this); #region Mondain's Legacy Sets if (this.m_SetAttributes == null) this.m_SetAttributes = new AosAttributes(this); if (this.m_SetSkillBonuses == null) this.m_SetSkillBonuses = new AosSkillBonuses(this); #endregion if (version < 2) { this.m_Resource = CraftResource.Iron; this.m_GemType = GemType.None; } }
public RunicReforgingGump(Mobile from, Item toReforge, BaseRunicTool tool, ReforgingOption options, ReforgedPrefix prefix, ReforgedSuffix suffix) : base(25, 25) { from.CloseGump(typeof(RunicReforgingGump)); from.CloseGump(typeof(ImbuingGumpC)); m_Tool = tool; m_ToReforge = toReforge; m_Options = options; m_Prefix = prefix; m_Suffix = suffix; AddBackground(0, 0, 374, 444, 83); AddHtmlObject(120, 13, 200, 20, 1151952, DarkGreen, false, false); // Runic Crafting Options int buttonHue = White; int buttonID = 0x4005; int y = 40; int idx = 0; for (int i = 0; i < Options.Length; i++) { ReforgingOption option = Options[i]; if ((m_Options & option) != 0) { if (CanReforge(from, option) && HasMetPrerequisite(option)) { buttonHue = LightGreen; buttonID = 4006; } else { buttonHue = Orange; buttonID = 4006; } } else { if (CanReforge(from, option) && HasMetPrerequisite(option)) { buttonHue = White; buttonID = 4005; } else { buttonHue = Orange; buttonID = 4006; } } if (HasMetPrerequisite(option) && CanReforge(from, option)) { AddButton(15, y, buttonID, buttonID, i + 100, GumpButtonType.Reply, 0); } AddHtmlObject(55, y, 250, 20, GetCliloc(option), buttonHue, false, false); y += 25; idx++; } int totalCharges = GetTotalCharges(); if ((m_Options & ReforgingOption.InspiredArtifice) != 0) { AddButton(15, 305, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlObject(55, 305, 250, 20, 1152087, White, false, false); AddHtmlObject(190, 305, 250, 20, RunicReforging.GetName((int)m_Prefix), LightGreen, false, false); } if ((m_Options & ReforgingOption.SublimeArtifice) != 0) { AddButton(15, 330, 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlObject(55, 330, 250, 20, 1152088, White, false, false); AddHtmlObject(190, 330, 250, 20, RunicReforging.GetName((int)m_Suffix), LightGreen, false, false); } AddHtmlObject(30, 360, 200, 20, 1152078, LightGreen, false, false); // CHARGES NEEDED: AddHtmlObject(160, 360, 50, 20, totalCharges.ToString(), LightGreen, false, false); AddHtmlObject(45, 380, 200, 20, 1152077, LightGreen, false, false); // TOOL CHARGES: AddHtmlObject(160, 380, 50, 20, m_Tool.UsesRemaining.ToString(), LightGreen, false, false); AddButton(15, 410, 4017, 4018, 0, GumpButtonType.Reply, 0); AddHtmlObject(55, 410, 200, 20, "CLOSE", White, false, false); AddButton(330, 360, 4014, 4016, 3, GumpButtonType.Reply, 0); AddHtmlObject(230, 360, 200, 20, 1152080, White, false, false); // REFORGE ITEM AddButton(330, 410, 4011, 4013, 4, GumpButtonType.Reply, 0); AddHtmlObject(290, 410, 100, 20, "HELP", White, false, false); }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; switch (info.ButtonID) { case 0: break; case 1: // prefix from.SendGump(new ItemNameGump(m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix, true)); break; case 2: // suffix from.SendGump(new ItemNameGump(m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix, false)); break; case 3: // Reforge Item { if (!RunicReforging.CanReforge(from, m_ToReforge, m_Tool.CraftSystem)) { return; } int totalCharges = GetTotalCharges(); if (m_Tool.UsesRemaining >= totalCharges) { CraftResourceInfo resInfo = CraftResources.GetInfo(m_Tool.Resource); if (resInfo == null) { return; } CraftAttributeInfo attrs = resInfo.AttributeInfo; int budget = GetBudget(); int min = 10; int max = 40; if (attrs != null) { min = attrs.RunicMinIntensity; max = attrs.RunicMaxIntensity; } if (min < 10) { min = 10; } if (max > 100) { max = 100; } if (m_Prefix == ReforgedPrefix.None && (m_Options & ReforgingOption.GrandArtifice) != 0) { m_Prefix = RunicReforging.ChooseRandomPrefix(m_ToReforge); budget = Math.Min(800, budget + 50); } if (m_Suffix == ReforgedSuffix.None && (m_Options & ReforgingOption.ExaltedArtifice) != 0) { m_Suffix = RunicReforging.ChooseRandomSuffix(m_ToReforge, m_Prefix); budget = Math.Min(800, budget + 50); } int maxprops; if (attrs != null) { maxprops = Utility.RandomMinMax(attrs.RunicMinAttributes, attrs.RunicMaxAttributes); } else { maxprops = Math.Min(5, (budget / 110) + 1); } if (maxprops == 5 && 0.25 > Utility.RandomDouble()) { maxprops = 6; } if (maxprops == 6 && budget >= 650 && 0.10 > Utility.RandomDouble()) { maxprops = 7; } RunicReforging.ApplyReforgedProperties(m_ToReforge, m_Prefix, m_Suffix, true, budget, min, max, maxprops, 0, m_Tool, m_Options); OnAfterReforged(m_ToReforge); from.SendLocalizedMessage(1152286); // You re-forge the item! m_Tool.UsesRemaining -= totalCharges; if (m_Tool != null && m_Tool.CraftSystem != null) { m_Tool.CraftSystem.PlayCraftEffect(from); } if (m_Tool.UsesRemaining <= 0) { m_Tool.Delete(); from.SendLocalizedMessage(1044038); // You have worn out your tool! } } break; } case 4: from.SendGump(new ReforgingHelpGump()); break; default: // Option { ReforgingOption option = Options[info.ButtonID - 100]; if (HasMetPrerequisite(option)) { if ((m_Options & option) == 0) { m_Options |= option; } else { m_Options ^= option; InvalidatePrerequisite(option); } } from.SendGump(new RunicReforgingGump(from, m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix)); break; } } }
public static void GenerateRandomItem(Item item, Mobile killer, int basebudget, int luckchance, ReforgedPrefix forcedprefix, ReforgedSuffix forcedsuffix) { if(item != null) { int budget = Utility.RandomMinMax(basebudget - (basebudget / 5), basebudget + Utility.RandomMinMax(0, 100)); if(killer != null && Utility.RandomDouble() < (double)killer.Luck / 2000.0) budget += Utility.RandomMinMax(150, Math.Max(160, 550 - basebudget)); if (budget > 860) budget = 860; bool powerful = budget >= 550; if (powerful || 0.01 > Utility.RandomDouble()) { int amt = budget / 120; for (int i = 0; i < amt; i++) { if (Utility.RandomDouble() < 0.25) { ApplyRandomDisadvantage(item, ref budget); break; } } } ReforgedPrefix prefix = forcedprefix; ReforgedSuffix suffix = forcedsuffix; if (!(item is BaseWeapon) && prefix == ReforgedPrefix.Vampiric) prefix = ReforgedPrefix.None; if (!(item is BaseWeapon) && suffix == ReforgedSuffix.Vampire) suffix = ReforgedSuffix.None; if(forcedprefix == ReforgedPrefix.None && budget >= Utility.Random(2100)) prefix = ChooseRandomPrefix(item); if (forcedsuffix == ReforgedSuffix.None && budget >= Utility.Random(2100)) suffix = ChooseRandomSuffix(item, prefix); int mods; int perclow; int perchigh; if (!powerful) { if (prefix == ReforgedPrefix.None && suffix == ReforgedSuffix.None) mods = Utility.RandomMinMax(4, 5); else mods = Utility.RandomMinMax(2, 4); perchigh = Math.Max(20, (budget / 2) / mods); perclow = 10; } else { int maxmods = Math.Min(6, budget / 110); int minmods = Math.Max(3, maxmods - 1); mods = Utility.RandomMinMax(minmods, maxmods); perchigh = 100; perclow = 30; } if (perchigh > 100) perchigh = 100; if (perclow < 10) perclow = 10; if (LootPack.CheckLuck(luckchance) && mods < 5) mods++; ApplyReforgedProperties(item, prefix, suffix, false, budget, perclow, perchigh, mods, luckchance); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 5: { #region Runic Reforging m_ReforgedPrefix = (ReforgedPrefix)reader.ReadInt(); m_ReforgedSuffix = (ReforgedSuffix)reader.ReadInt(); m_ItemPower = (ItemPower)reader.ReadInt(); m_BlockRepair = reader.ReadBool(); #endregion #region Stygian Abyss m_GorgonLenseCharges = reader.ReadInt(); m_GorgonLenseType = (LenseType)reader.ReadInt(); goto case 4; } case 4: { this.m_TimesImbued = reader.ReadEncodedInt(); this.m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this, reader); #endregion this.m_BlessedBy = reader.ReadMobile(); this.m_LastEquipped = reader.ReadBool(); this.m_SetEquipped = reader.ReadBool(); this.m_SetHue = reader.ReadEncodedInt(); this.m_SetAttributes = new AosAttributes(this, reader); this.m_SetSkillBonuses = new AosSkillBonuses(this, reader); this.m_Crafter = reader.ReadMobile(); this.m_Quality = (ArmorQuality)reader.ReadInt(); goto case 3; } case 3: { this.m_MaxHitPoints = reader.ReadEncodedInt(); this.m_HitPoints = reader.ReadEncodedInt(); goto case 2; } case 2: { this.m_Resource = (CraftResource)reader.ReadEncodedInt(); this.m_GemType = (GemType)reader.ReadEncodedInt(); goto case 1; } case 1: { this.m_AosAttributes = new AosAttributes(this, reader); this.m_AosResistances = new AosElementAttributes(this, reader); this.m_AosSkillBonuses = new AosSkillBonuses(this, reader); if (Core.AOS && this.Parent is Mobile) { this.m_AosSkillBonuses.AddTo((Mobile)this.Parent); } int strBonus = this.m_AosAttributes.BonusStr; int dexBonus = this.m_AosAttributes.BonusDex; int intBonus = this.m_AosAttributes.BonusInt; if (this.Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)this.Parent; string modName = this.Serial.ToString(); if (strBonus != 0) { m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); } if (dexBonus != 0) { m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); } if (intBonus != 0) { m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } } if (this.Parent is Mobile) { ((Mobile)this.Parent).CheckStatTimers(); } break; } case 0: { this.m_AosAttributes = new AosAttributes(this); this.m_AosResistances = new AosElementAttributes(this); this.m_AosSkillBonuses = new AosSkillBonuses(this); break; } } #region Mondain's Legacy Sets if (this.m_SetAttributes == null) { this.m_SetAttributes = new AosAttributes(this); } if (this.m_SetSkillBonuses == null) { this.m_SetSkillBonuses = new AosSkillBonuses(this); } #endregion if (version < 2) { this.m_Resource = CraftResource.Iron; this.m_GemType = GemType.None; } }
public RunicReforgingGump(Mobile from, Item toReforge, BaseRunicTool tool, ReforgingOption options, ReforgedPrefix prefix, ReforgedSuffix suffix) : base(25, 25) { m_Tool = tool; m_ToReforge = toReforge; m_Options = options; m_Prefix = prefix; m_Suffix = suffix; AddBackground(0, 0, 374, 444, 83); AddHtmlObject(120, 13, 200, 20, 1151952, DarkGreen, false, false); // Runic Crafting Options int buttonHue = White; int buttonID = 0x4005; int y = 40; int idx = 0; for(int i = 0; i < Options.Length; i++) { ReforgingOption option = Options[i]; if ((m_Options & option) != 0) { if (CanReforge(from, option) && HasMetPrerequisite(option)) { buttonHue = LightGreen; buttonID = 4006; } else { buttonHue = Orange; buttonID = 4006; } } else { if (CanReforge(from, option) && HasMetPrerequisite(option)) { buttonHue = White; buttonID = 4005; } else { buttonHue = Orange; buttonID = 4006; } } if(HasMetPrerequisite(option) && CanReforge(from, option)) AddButton(15, y, buttonID, buttonID, i + 100, GumpButtonType.Reply, 0); AddHtmlObject(55, y, 250, 20, GetCliloc(option), buttonHue, false, false); y += 25; idx++; } int totalCharges = GetTotalCharges(); if ((m_Options & ReforgingOption.InspiredArtifice) != 0) { AddButton(15, 305, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlObject(55, 305, 250, 20, 1152087, White, false, false); AddHtmlObject(190, 305, 250, 20, RunicReforging.GetName((int)m_Prefix), LightGreen, false, false); } if ((m_Options & ReforgingOption.SublimeArtifice) != 0) { AddButton(15, 330, 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlObject(55, 330, 250, 20, 1152088, White, false, false); AddHtmlObject(190, 330, 250, 20, RunicReforging.GetName((int)m_Suffix), LightGreen, false, false); } AddHtmlObject(30, 360, 200, 20, 1152078, LightGreen, false, false); // CHARGES NEEDED: AddHtmlObject(160, 360, 50, 20, totalCharges.ToString(), LightGreen, false, false); AddHtmlObject(45, 380, 200, 20, 1152077, LightGreen, false, false); // TOOL CHARGES: AddHtmlObject(160, 380, 50, 20, m_Tool.UsesRemaining.ToString(), LightGreen, false, false); AddButton(15, 410, 4017, 4018, 0, GumpButtonType.Reply, 0); AddHtmlObject(55, 410, 200, 20, "CLOSE", White, false, false); AddButton(330, 360, 4014, 4016, 3, GumpButtonType.Reply, 0); AddHtmlObject(230, 360, 200, 20, 1152080, White, false, false); // REFORGE ITEM AddButton(330, 410, 4011, 4013, 4, GumpButtonType.Reply, 0); AddHtmlObject(290, 410, 100, 20, "HELP", White, false, false); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 12: case 11: { m_SetPhysicalBonus = reader.ReadInt(); m_SetFireBonus = reader.ReadInt(); m_SetColdBonus = reader.ReadInt(); m_SetPoisonBonus = reader.ReadInt(); m_SetEnergyBonus = reader.ReadInt(); goto case 10; } case 10: { m_PlayerConstructed = reader.ReadBool(); goto case 9; } case 9: { m_TalismanProtection = new TalismanAttribute(reader); goto case 8; } case 8: { if (version == 11) { reader.ReadBool(); } _Owner = reader.ReadMobile(); _OwnerName = reader.ReadString(); goto case 7; } case 7: { m_IsImbued = reader.ReadBool(); goto case 6; } case 6: { m_NegativeAttributes = new NegativeAttributes(this, reader); goto case 5; } case 5: { #region Runic Reforging m_ReforgedPrefix = (ReforgedPrefix)reader.ReadInt(); m_ReforgedSuffix = (ReforgedSuffix)reader.ReadInt(); m_ItemPower = (ItemPower)reader.ReadInt(); if (version == 11 && reader.ReadBool()) { m_NegativeAttributes.NoRepair = 1; } #endregion #region Stygian Abyss m_GorgonLenseCharges = reader.ReadInt(); m_GorgonLenseType = (LenseType)reader.ReadInt(); goto case 4; } case 4: { m_TimesImbued = reader.ReadEncodedInt(); m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this, reader); #endregion m_BlessedBy = reader.ReadMobile(); m_LastEquipped = reader.ReadBool(); m_SetEquipped = reader.ReadBool(); m_SetHue = reader.ReadEncodedInt(); m_SetAttributes = new AosAttributes(this, reader); m_SetSkillBonuses = new AosSkillBonuses(this, reader); m_Crafter = reader.ReadMobile(); m_Quality = (ItemQuality)reader.ReadInt(); goto case 3; } case 3: { m_MaxHitPoints = reader.ReadEncodedInt(); m_HitPoints = reader.ReadEncodedInt(); goto case 2; } case 2: { m_Resource = (CraftResource)reader.ReadEncodedInt(); m_GemType = (GemType)reader.ReadEncodedInt(); goto case 1; } case 1: { m_AosAttributes = new AosAttributes(this, reader); m_AosResistances = new AosElementAttributes(this, reader); m_AosSkillBonuses = new AosSkillBonuses(this, reader); if (Core.AOS && Parent is Mobile) { m_AosSkillBonuses.AddTo((Mobile)Parent); } int strBonus = m_AosAttributes.BonusStr; int dexBonus = m_AosAttributes.BonusDex; int intBonus = m_AosAttributes.BonusInt; if (Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)Parent; string modName = Serial.ToString(); if (strBonus != 0) { m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); } if (dexBonus != 0) { m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); } if (intBonus != 0) { m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } } if (Parent is Mobile) { ((Mobile)Parent).CheckStatTimers(); } break; } case 0: { m_AosAttributes = new AosAttributes(this); m_AosResistances = new AosElementAttributes(this); m_AosSkillBonuses = new AosSkillBonuses(this); break; } } if (m_NegativeAttributes == null) { m_NegativeAttributes = new NegativeAttributes(this); } if (m_TalismanProtection == null) { m_TalismanProtection = new TalismanAttribute(); } #region Mondain's Legacy Sets if (m_SetAttributes == null) { m_SetAttributes = new AosAttributes(this); } if (m_SetSkillBonuses == null) { m_SetSkillBonuses = new AosSkillBonuses(this); } #endregion if (version < 2) { m_Resource = CraftResource.Iron; m_GemType = GemType.None; } }
public static void ApplyReforgedProperties(Item item, ReforgedPrefix prefix, ReforgedSuffix suffix, bool playermade, int budget, int perclow, int perchigh, int maxmods, int luckchance, BaseRunicTool tool = null, ReforgingOption option = ReforgingOption.None) { if (prefix == ReforgedPrefix.None && suffix == ReforgedSuffix.None) { for (int i = 0; i < maxmods; i++) ApplyRunicAttributes(item, perclow, perchigh, ref budget, i, luckchance); ApplyItemPower(item, playermade); } else { int prefixID = (int)prefix; int suffixID = (int)suffix; int index = GetCollectionIndex(item); int resIndex = -1; int preIndex = -1; if (tool != null) { resIndex = GetResourceIndex(tool.Resource); preIndex = GetPrerequisiteIndex(option); } if (index == -1) return; List<NamedInfoCol> prefixCol = null; List<NamedInfoCol> suffixCol = null; if (prefix != ReforgedPrefix.None) { try { prefixCol = new List<NamedInfoCol>(); prefixCol.AddRange(m_PrefixSuffixInfo[prefixID][index]); } catch { Console.WriteLine("Error: Prefix not in collection: {0}", prefixID); } } if (suffix != ReforgedSuffix.None) { if (suffixCol == null) suffixCol = new List<NamedInfoCol>(); try { suffixCol.AddRange(m_PrefixSuffixInfo[suffixID][index]); } catch { Console.WriteLine("Error: Suffix not in collection: {0}", suffixID); } } //Removes things like blood drinking/balanced/splintering CheckAttributes(item, prefixCol, playermade); CheckAttributes(item, suffixCol, playermade); int i = 0; int mods = 0; bool addedprefix = false; bool addedsuffix = false; int moddedPercLow = CalculateMinIntensity(perclow, perchigh, option); int moddedPercHigh = perchigh; if (prefix != ReforgedPrefix.None && suffix == ReforgedSuffix.None && prefixCol != null) { int specialAdd = GetModsPer(index, prefixID, maxmods, false); while (budget > 25 && mods < maxmods && i < 25) { if (prefixCol.Count > 0 && specialAdd > 0) { int random = Utility.Random(prefixCol.Count); if (ApplyAttribute(item, prefixCol[random].Attribute, prefixCol[random].Min(resIndex, preIndex, item), prefixCol[random].Max(resIndex, preIndex, item), moddedPercLow, moddedPercHigh, ref budget, luckchance)) { addedprefix = true; specialAdd--; mods++; } prefixCol.RemoveAt(random); } else if (ApplyRunicAttributes(item, perclow, perchigh, ref budget, i, luckchance)) mods++; i++; } if (addedprefix) ApplyPrefixName(item, prefix); } else if (prefix == ReforgedPrefix.None && suffix != ReforgedSuffix.None && suffixCol != null) { int specialAdd = GetModsPer(index, suffixID, maxmods, false); while (budget > 25 && mods < maxmods && i < 25) { if (suffixCol.Count > 0 && specialAdd > 0) { int random = Utility.Random(suffixCol.Count); if (ApplyAttribute(item, suffixCol[random].Attribute, suffixCol[random].Min(resIndex, preIndex, item), suffixCol[random].Max(resIndex, preIndex, item), moddedPercLow, moddedPercHigh, ref budget, luckchance)) { addedsuffix = true; specialAdd--; mods++; } suffixCol.RemoveAt(random); } else if (ApplyRunicAttributes(item, perclow, perchigh, ref budget, i, luckchance)) mods++; i++; } if (addedsuffix) ApplySuffixName(item, suffix); } else if (prefix != ReforgedPrefix.None && suffix != ReforgedSuffix.None && prefixCol != null && suffixCol != null) { int specialAddPrefix = GetModsPer(index, prefixID, maxmods, true); int specialAddSuffix = GetModsPer(index, suffixID, maxmods, true); while (budget > 25 && mods < maxmods && i < 25) { if (prefixCol.Count > 0 && specialAddPrefix > 0) { int random = Utility.Random(prefixCol.Count); if (ApplyAttribute(item, prefixCol[random].Attribute, prefixCol[random].Min(resIndex, preIndex, item), prefixCol[random].Max(resIndex, preIndex, item), moddedPercLow, moddedPercHigh, ref budget, luckchance)) { addedprefix = true; specialAddPrefix--; mods++; } prefixCol.RemoveAt(random); } else if (suffixCol.Count > 0 && specialAddSuffix > 0) { int random = Utility.Random(suffixCol.Count); if (ApplyAttribute(item, suffixCol[random].Attribute, suffixCol[random].Min(resIndex, preIndex, item), suffixCol[random].Max(resIndex, preIndex, item), moddedPercLow, moddedPercHigh, ref budget, luckchance)) { addedsuffix = true; specialAddSuffix--; mods++; } suffixCol.RemoveAt(random); } else if (ApplyRunicAttributes(item, perclow, perchigh, ref budget, i, luckchance)) mods++; i++; } if (addedprefix) ApplyPrefixName(item, prefix); if (addedsuffix) ApplySuffixName(item, suffix); } ApplyItemPower(item, playermade); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 12: { #region Runic Reforging m_ReforgedPrefix = (ReforgedPrefix)reader.ReadInt(); m_ReforgedSuffix = (ReforgedSuffix)reader.ReadInt(); m_ItemPower = (ItemPower)reader.ReadInt(); m_BlockRepair = reader.ReadBool(); #endregion #region Stygian Abyss m_DImodded = reader.ReadBool(); m_SearingWeapon = reader.ReadBool(); goto case 11; } case 11: { m_TimesImbued = reader.ReadInt(); #endregion goto case 10; } case 10: { m_BlessedBy = reader.ReadMobile(); m_EngravedText = reader.ReadString(); m_Slayer3 = (TalismanSlayerName)reader.ReadInt(); SetFlag flags = (SetFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SetFlag.Attributes)) { m_SetAttributes = new AosAttributes(this, reader); } else { m_SetAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SetFlag.WeaponAttributes)) { m_SetSelfRepair = (new AosWeaponAttributes(this, reader)).SelfRepair; } if (GetSaveFlag(flags, SetFlag.SkillBonuses)) { m_SetSkillBonuses = new AosSkillBonuses(this, reader); } else { m_SetSkillBonuses = new AosSkillBonuses(this); } if (GetSaveFlag(flags, SetFlag.Hue)) { m_SetHue = reader.ReadInt(); } if (GetSaveFlag(flags, SetFlag.LastEquipped)) { m_LastEquipped = reader.ReadBool(); } if (GetSaveFlag(flags, SetFlag.SetEquipped)) { m_SetEquipped = reader.ReadBool(); } if (GetSaveFlag(flags, SetFlag.SetSelfRepair)) { m_SetSelfRepair = reader.ReadEncodedInt(); } goto case 5; } case 9: case 8: case 7: case 6: case 5: { SaveFlag flags = (SaveFlag)reader.ReadInt(); if (GetSaveFlag(flags, SaveFlag.DamageLevel)) { m_DamageLevel = (WeaponDamageLevel)reader.ReadInt(); if (m_DamageLevel > WeaponDamageLevel.Vanq) { m_DamageLevel = WeaponDamageLevel.Ruin; } } if (GetSaveFlag(flags, SaveFlag.AccuracyLevel)) { m_AccuracyLevel = (WeaponAccuracyLevel)reader.ReadInt(); if (m_AccuracyLevel > WeaponAccuracyLevel.Supremely) { m_AccuracyLevel = WeaponAccuracyLevel.Accurate; } } if (GetSaveFlag(flags, SaveFlag.DurabilityLevel)) { m_DurabilityLevel = (WeaponDurabilityLevel)reader.ReadInt(); if (m_DurabilityLevel > WeaponDurabilityLevel.Indestructible) { m_DurabilityLevel = WeaponDurabilityLevel.Durable; } } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (WeaponQuality)reader.ReadInt(); } else { m_Quality = WeaponQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Hits)) { m_Hits = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.MaxHits)) { m_MaxHits = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Slayer)) { m_Slayer = (SlayerName)reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Poison)) { m_Poison = Poison.Deserialize(reader); } if (GetSaveFlag(flags, SaveFlag.PoisonCharges)) { m_PoisonCharges = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Identified)) { m_Identified = (version >= 6 || reader.ReadBool()); } if (GetSaveFlag(flags, SaveFlag.StrReq)) { m_StrReq = reader.ReadInt(); } else { m_StrReq = -1; } if (GetSaveFlag(flags, SaveFlag.DexReq)) { m_DexReq = reader.ReadInt(); } else { m_DexReq = -1; } if (GetSaveFlag(flags, SaveFlag.IntReq)) { m_IntReq = reader.ReadInt(); } else { m_IntReq = -1; } if (GetSaveFlag(flags, SaveFlag.MinDamage)) { m_MinDamage = reader.ReadInt(); } else { m_MinDamage = -1; } if (GetSaveFlag(flags, SaveFlag.MaxDamage)) { m_MaxDamage = reader.ReadInt(); } else { m_MaxDamage = -1; } if (GetSaveFlag(flags, SaveFlag.HitSound)) { m_HitSound = reader.ReadInt(); } else { m_HitSound = -1; } if (GetSaveFlag(flags, SaveFlag.MissSound)) { m_MissSound = reader.ReadInt(); } else { m_MissSound = -1; } if (GetSaveFlag(flags, SaveFlag.Speed)) { if (version < 9) { m_Speed = reader.ReadInt(); } else { m_Speed = reader.ReadFloat(); } } else { m_Speed = -1; } if (GetSaveFlag(flags, SaveFlag.MaxRange)) { m_MaxRange = reader.ReadInt(); } else { m_MaxRange = -1; } if (GetSaveFlag(flags, SaveFlag.Skill)) { m_Skill = (SkillName)reader.ReadInt(); } else { m_Skill = (SkillName)(-1); } if (GetSaveFlag(flags, SaveFlag.Type)) { m_Type = (WeaponType)reader.ReadInt(); } else { m_Type = (WeaponType)(-1); } if (GetSaveFlag(flags, SaveFlag.Animation)) { m_Animation = (WeaponAnimation)reader.ReadInt(); } else { m_Animation = (WeaponAnimation)(-1); } if (GetSaveFlag(flags, SaveFlag.Resource)) { m_Resource = (CraftResource)reader.ReadInt(); } else { m_Resource = CraftResource.Iron; } if (GetSaveFlag(flags, SaveFlag.xAttributes)) { m_AosAttributes = new AosAttributes(this, reader); } else { m_AosAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.xWeaponAttributes)) { m_AosWeaponAttributes = new AosWeaponAttributes(this, reader); } else { m_AosWeaponAttributes = new AosWeaponAttributes(this); } if (UseSkillMod && m_AccuracyLevel != WeaponAccuracyLevel.Regular && Parent is Mobile) { m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5); ((Mobile)Parent).AddSkillMod(m_SkillMod); } if (version < 7 && m_AosWeaponAttributes.MageWeapon != 0) { m_AosWeaponAttributes.MageWeapon = 30 - m_AosWeaponAttributes.MageWeapon; } if (Core.AOS && m_AosWeaponAttributes.MageWeapon != 0 && m_AosWeaponAttributes.MageWeapon != 30 && Parent is Mobile) { m_MageMod = new DefaultSkillMod(SkillName.Magery, true, -30 + m_AosWeaponAttributes.MageWeapon); ((Mobile)Parent).AddSkillMod(m_MageMod); } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses = new AosSkillBonuses(this, reader); } else { m_AosSkillBonuses = new AosSkillBonuses(this); } if (GetSaveFlag(flags, SaveFlag.Slayer2)) { m_Slayer2 = (SlayerName)reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.ElementalDamages)) { m_AosElementDamages = new AosElementAttributes(this, reader); } else { m_AosElementDamages = new AosElementAttributes(this); } if (GetSaveFlag(flags, SaveFlag.EngravedText)) { m_EngravedText = reader.ReadString(); } #region Stygian Abyss if (version > 9 && GetSaveFlag(flags, SaveFlag.xAbsorptionAttributes)) { m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this, reader); } else { m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this); } #endregion break; } case 4: { m_Slayer = (SlayerName)reader.ReadInt(); goto case 3; } case 3: { m_StrReq = reader.ReadInt(); m_DexReq = reader.ReadInt(); m_IntReq = reader.ReadInt(); goto case 2; } case 2: { m_Identified = reader.ReadBool(); goto case 1; } case 1: { m_MaxRange = reader.ReadInt(); goto case 0; } case 0: { if (version == 0) { m_MaxRange = 1; // default } if (version < 5) { m_Resource = CraftResource.Iron; m_AosAttributes = new AosAttributes(this); m_AosWeaponAttributes = new AosWeaponAttributes(this); m_AosElementDamages = new AosElementAttributes(this); m_AosSkillBonuses = new AosSkillBonuses(this); } m_MinDamage = reader.ReadInt(); m_MaxDamage = reader.ReadInt(); m_Speed = reader.ReadInt(); m_HitSound = reader.ReadInt(); m_MissSound = reader.ReadInt(); m_Skill = (SkillName)reader.ReadInt(); m_Type = (WeaponType)reader.ReadInt(); m_Animation = (WeaponAnimation)reader.ReadInt(); m_DamageLevel = (WeaponDamageLevel)reader.ReadInt(); m_AccuracyLevel = (WeaponAccuracyLevel)reader.ReadInt(); m_DurabilityLevel = (WeaponDurabilityLevel)reader.ReadInt(); m_Quality = (WeaponQuality)reader.ReadInt(); m_Crafter = reader.ReadMobile(); m_Poison = Poison.Deserialize(reader); m_PoisonCharges = reader.ReadInt(); if (m_StrReq == OldStrengthReq) { m_StrReq = -1; } if (m_DexReq == OldDexterityReq) { m_DexReq = -1; } if (m_IntReq == OldIntelligenceReq) { m_IntReq = -1; } if (m_MinDamage == OldMinDamage) { m_MinDamage = -1; } if (m_MaxDamage == OldMaxDamage) { m_MaxDamage = -1; } if (m_HitSound == OldHitSound) { m_HitSound = -1; } if (m_MissSound == OldMissSound) { m_MissSound = -1; } if (m_Speed == OldSpeed) { m_Speed = -1; } if (m_MaxRange == OldMaxRange) { m_MaxRange = -1; } if (m_Skill == OldSkill) { m_Skill = (SkillName)(-1); } if (m_Type == OldType) { m_Type = (WeaponType)(-1); } if (m_Animation == OldAnimation) { m_Animation = (WeaponAnimation)(-1); } if (UseSkillMod && m_AccuracyLevel != WeaponAccuracyLevel.Regular && Parent is Mobile) { m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5); ((Mobile)Parent).AddSkillMod(m_SkillMod); } break; } } #region Mondain's Legacy Sets if (m_SetAttributes == null) { m_SetAttributes = new AosAttributes(this); } if (m_SetSkillBonuses == null) { m_SetSkillBonuses = new AosSkillBonuses(this); } #endregion if (Core.AOS && Parent is Mobile) { m_AosSkillBonuses.AddTo((Mobile)Parent); } int strBonus = m_AosAttributes.BonusStr; int dexBonus = m_AosAttributes.BonusDex; int intBonus = m_AosAttributes.BonusInt; if (Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)Parent; string modName = Serial.ToString(); if (strBonus != 0) { m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); } if (dexBonus != 0) { m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); } if (intBonus != 0) { m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } } if (Parent is Mobile) { ((Mobile)Parent).CheckStatTimers(); } if (m_Hits <= 0 && m_MaxHits <= 0) { m_Hits = m_MaxHits = Utility.RandomMinMax(InitMinHits, InitMaxHits); } if (version < 6) { m_PlayerConstructed = true; // we don't know, so, assume it's crafted } }
/// <summary> /// /// </summary> /// <param name="item">item to mutate</param> /// <param name="killer">who killed the monster, if applicable</param> /// <param name="basebudget">where to we start, regarding the difficulty of the monster we killed</param> /// <param name="luckchance">raw luck</param> /// <param name="forcedprefix"></param> /// <param name="forcedsuffix"></param> /// <param name="map"></param> public static void GenerateRandomItem(Item item, Mobile killer, int basebudget, int luck, ReforgedPrefix forcedprefix, ReforgedSuffix forcedsuffix, Map map = null) { if (map == null && killer != null) map = killer.Map; if (item != null) { int budgetBonus = 0; if (killer != null || luck > 0) { if (map != null && map.Rules == MapRules.FeluccaRules) { luck += RandomItemGenerator.FeluccaLuckBonus; budgetBonus = RandomItemGenerator.FeluccaBudgetBonus; } else { luck += 240; } } if (basebudget > 800) basebudget = 800; // base budget range int divisor = GetDivisor(basebudget); int budget = Utility.RandomMinMax(basebudget - (basebudget / divisor), basebudget + (basebudget <= 400 ? (basebudget / 4) : 0)) + budgetBonus; int luckchance = LootPack.GetLuckChance(luck); // Gives a rare chance for a high end item to drop on a low budgeted monster if (luck > 0 && budget < 550 && LootPack.CheckLuck(luckchance / 6)) { int inc = Utility.RandomMinMax((550 - budget) / 2, 750 - budget); budget += inc; } TryApplyRandomDisadvantage(item, ref budget); if (budget > MaxBudget) budget = MaxBudget; if (budget < 150) budget = 150; bool powerful = budget >= 550; ReforgedPrefix prefix = forcedprefix; ReforgedSuffix suffix = forcedsuffix; if (!(item is BaseWeapon) && prefix == ReforgedPrefix.Vampiric) prefix = ReforgedPrefix.None; if (!(item is BaseWeapon) && suffix == ReforgedSuffix.Vampire) suffix = ReforgedSuffix.None; if (forcedprefix == ReforgedPrefix.None && budget >= Utility.Random(2700)) prefix = ChooseRandomPrefix(item); if (forcedsuffix == ReforgedSuffix.None && budget >= Utility.Random(2700)) suffix = ChooseRandomSuffix(item, prefix); int mods; int perclow; int perchigh; if (!powerful) { mods = Utility.RandomMinMax(2, 5); perchigh = Math.Max(30, Math.Min(500, budget) / (mods - 1)); perclow = Math.Max(20, perchigh / 3); } else { int maxmods = Math.Min(9, budget / Utility.RandomMinMax(100, 140)); int minmods = Math.Max(4, maxmods - 1); mods = Utility.RandomMinMax(minmods, maxmods); perchigh = 100; perclow = Math.Max(50, (budget / 2) / mods); } if (perchigh > 100) perchigh = 100; if (perclow < 10) perclow = 10; if (perclow > 90) perclow = 90; if (LootPack.CheckLuck(luckchance)) mods++; ApplyReforgedProperties(item, prefix, suffix, false, budget, perclow, perchigh, mods, luckchance); } }
public static void ApplySuffixName(Item item, ReforgedSuffix suffix) { if (item is BaseWeapon) ((BaseWeapon)item).ReforgedSuffix = suffix; else if (item is BaseShield) ((BaseShield)item).ReforgedSuffix = suffix; else if (item is BaseArmor) ((BaseArmor)item).ReforgedSuffix = suffix; else if (item is BaseJewel) ((BaseJewel)item).ReforgedSuffix = suffix; else if (item is BaseClothing) ((BaseClothing)item).ReforgedSuffix = suffix; }
public ReforgingInfo(ReforgingOption option, ReforgedPrefix prefix, ReforgedSuffix suffix) { Options = option; Prefix = prefix; Suffix = suffix; }
public static void ApplyReforgedProperties(Item item, ReforgedPrefix prefix, ReforgedSuffix suffix, bool playermade, int budget, int perclow, int perchigh, int maxmods, int powermod, int luckchance) { if(prefix == ReforgedPrefix.None && suffix == ReforgedSuffix.None) { for(int i = 0; i < maxmods; i++) ApplyRunicAttributes(item, perclow, perchigh, ref budget, i, luckchance); ApplyItemPower(item, playermade); } else { int prefixID = (int)prefix; int suffixID = (int)suffix; int index = GetCollectionIndex(item); if(index == -1) return; List<NamedInfoCol> prefixCol = null; List<NamedInfoCol> suffixCol = null; if (prefix != ReforgedPrefix.None) { try { prefixCol = new List<NamedInfoCol>(); prefixCol.AddRange(m_PrefixSuffixInfo[prefixID][index]); } catch { Console.WriteLine("Error: Prefix not in collection: {0}", prefixID); } } if (suffix != ReforgedSuffix.None) { if (suffixCol == null) suffixCol = new List<NamedInfoCol>(); try { suffixCol.AddRange(m_PrefixSuffixInfo[suffixID][index]); } catch { Console.WriteLine("Error: Suffix not in collection: {0}", suffixID); } } //Removes things like blood drinking/balanced/splintering CheckAttributes(item, prefixCol, playermade); CheckAttributes(item, suffixCol, playermade); int i = 0; int mods = 0; bool addedprefix = false; bool addedsuffix = false; int moddedPercLow = perclow - (int)((double)powermod / 2.0); int moddedPercHigh = perchigh - powermod; if (moddedPercLow < 0) moddedPercLow = 0; if (moddedPercHigh > 100) moddedPercHigh = 100; if(prefix != ReforgedPrefix.None && suffix == ReforgedSuffix.None && prefixCol != null) { int specialAdd = GetModsPer(index, prefixID, maxmods, false); while(budget > 0 && mods < maxmods && i < 25) { if (prefixCol.Count > 0 && specialAdd > 0) { int random = Utility.Random(prefixCol.Count); if (ApplyAttribute(item, prefixCol[random].Attribute, moddedPercLow, moddedPercHigh, prefixCol[random].Min, prefixCol[random].Max, ref budget, luckchance)) { addedprefix = true; specialAdd--; mods++; } prefixCol.RemoveAt(random); } else if (ApplyRunicAttributes(item, perclow, perchigh, ref budget, i, luckchance)) mods++; i++; } if(addedprefix) ApplyPrefixName(item, prefix); } else if (prefix == ReforgedPrefix.None && suffix != ReforgedSuffix.None && suffixCol != null) { int specialAdd = GetModsPer(index, suffixID, maxmods, false); while (budget > 0 && mods < maxmods && i < 25) { if(suffixCol.Count > 0 && specialAdd > 0) { int random = Utility.Random(suffixCol.Count); if (ApplyAttribute(item, suffixCol[random].Attribute, moddedPercLow, moddedPercHigh, suffixCol[random].Min, suffixCol[random].Max, ref budget, luckchance)) { addedsuffix = true; specialAdd--; mods++; } suffixCol.RemoveAt(random); } else if (ApplyRunicAttributes(item, perclow, perchigh, ref budget, i, luckchance)) mods++; i++; } if(addedsuffix) ApplySuffixName(item, suffix); } else if (prefix != ReforgedPrefix.None && suffix != ReforgedSuffix.None && prefixCol != null && suffixCol != null) { int specialAddPrefix = GetModsPer(index, prefixID, maxmods, true); int specialAddSuffix = GetModsPer(index, suffixID, maxmods, true); while (budget > 0 && mods < maxmods && i < 25) { if (prefixCol.Count > 0 && specialAddPrefix > 0) { int random = Utility.Random(prefixCol.Count); if (ApplyAttribute(item, prefixCol[random].Attribute, moddedPercLow, moddedPercHigh, prefixCol[random].Min, prefixCol[random].Max, ref budget, luckchance)) { addedprefix = true; specialAddPrefix--; mods++; } prefixCol.RemoveAt(random); } else if (suffixCol.Count > 0 && specialAddSuffix > 0) { int random = Utility.Random(suffixCol.Count); if (ApplyAttribute(item, suffixCol[random].Attribute, moddedPercLow, moddedPercHigh, suffixCol[random].Min, suffixCol[random].Max, ref budget, luckchance)) { addedsuffix = true; specialAddSuffix--; mods++; } suffixCol.RemoveAt(random); } else if (ApplyRunicAttributes(item, perclow, perchigh, ref budget, i, luckchance)) mods++; i++; } if(addedprefix) ApplyPrefixName(item, prefix); if(addedsuffix) ApplySuffixName(item, suffix); } ApplyItemPower(item, playermade); if (prefixCol != null) prefixCol.Clear(); if (suffixCol != null) suffixCol.Clear(); } //item.Hue = 25; }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; if (!BaseTool.CheckAccessible(m_Tool, from, true)) { return; } switch (info.ButtonID) { case 0: break; case 1: // prefix from.SendGump(new ItemNameGump(m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix, true)); break; case 2: // suffix from.SendGump(new ItemNameGump(m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix, false)); break; case 3: // Reforge Item { if (!RunicReforging.CanReforge(from, m_ToReforge, m_Tool.CraftSystem)) { return; } int totalCharges = GetTotalCharges(); if (m_Tool.UsesRemaining >= totalCharges) { CraftResourceInfo resInfo = CraftResources.GetInfo(m_Tool.Resource); if (resInfo == null) { return; } CraftAttributeInfo attrs = resInfo.AttributeInfo; int min = 10; int max = 80; if (min < 10) { min = 10; } if (max > 100) { max = 100; } int budget = GetBudget(); ReforgedPrefix prefix = ReforgedPrefix.None; ReforgedSuffix suffix = ReforgedSuffix.None; if ((m_Options & ReforgingOption.GrandArtifice) != 0) { // choosing name 1 if ((m_Options & ReforgingOption.InspiredArtifice) != 0) { prefix = m_Prefix; if (prefix == ReforgedPrefix.None) { from.SendLocalizedMessage(1152287); // Re-forging failed. You did not choose a name! Please try again. return; } } else { // Not choosing name 1 or 2 if ((m_Options & ReforgingOption.SublimeArtifice) == 0) { // random prefix AND suffix if ((m_Options & ReforgingOption.ExaltedArtifice) != 0) { prefix = RunicReforging.ChooseRandomPrefix(m_ToReforge, budget); suffix = RunicReforging.ChooseRandomSuffix(m_ToReforge, budget, m_Prefix); } else // random prefix OR suffix { if (0.5 > Utility.RandomDouble()) { prefix = RunicReforging.ChooseRandomPrefix(m_ToReforge, budget); } else { suffix = RunicReforging.ChooseRandomSuffix(m_ToReforge, budget, m_Prefix); } } } } } if ((m_Options & ReforgingOption.ExaltedArtifice) != 0) { if ((m_Options & ReforgingOption.SublimeArtifice) != 0) { suffix = m_Suffix; if (suffix == ReforgedSuffix.None) { from.SendLocalizedMessage(1152287); // Re-forging failed. You did not choose a name! Please try again. return; } } else { suffix = RunicReforging.ChooseRandomSuffix(m_ToReforge, budget, m_Prefix); budget = Math.Min(800, budget + 50); } } // 50% chance to switch prefix/suffix around if ((prefix != ReforgedPrefix.None || suffix != ReforgedSuffix.None) && 0.5 > Utility.RandomDouble()) { int pre = (int)prefix; int suf = (int)suffix; prefix = (ReforgedPrefix)suf; suffix = (ReforgedSuffix)pre; } RunicReforging.ApplyReforgedProperties(m_ToReforge, prefix, suffix, budget, min, max, RunicReforging.GetPropertyCount(m_Tool), 0, m_Tool, m_Options); OnAfterReforged(m_ToReforge); from.SendLocalizedMessage(1152286); // You re-forge the item! from.PlaySound(0x665); m_Tool.UsesRemaining -= totalCharges; if (m_Tool.UsesRemaining <= 0) { m_Tool.Delete(); from.SendLocalizedMessage(1044038); // You have worn out your tool! } } break; } case 4: from.SendGump(new ReforgingHelpGump()); break; default: // Option { ReforgingOption option = Options[info.ButtonID - 100]; if (HasMetPrerequisite(option)) { if ((m_Options & option) == 0) { m_Options |= option; if (m_Prefix != ReforgedPrefix.None && !RunicReforging.HasSelection((int)m_Prefix, m_ToReforge, m_Tool, m_Options, -1, -1)) { m_Prefix = ReforgedPrefix.None; m_Context.Prefix = ReforgedPrefix.None; } if (m_Suffix != ReforgedSuffix.None && !RunicReforging.HasSelection((int)m_Suffix, m_ToReforge, m_Tool, m_Options, -1, -1)) { m_Suffix = ReforgedSuffix.None; m_Context.Suffix = ReforgedSuffix.None; } } else { m_Options ^= option; InvalidatePrerequisite(option); } m_Context.Contexts[m_Tool] = m_Options; } from.SendGump(new RunicReforgingGump(from, m_ToReforge, m_Tool)); break; } } }
public static void GenerateRandomItem(Item item, Mobile killer, int basebudget, int luckchance, ReforgedPrefix forcedprefix, ReforgedSuffix forcedsuffix) { int luckbonus = 0; int budgetBonus = 0; if (killer != null) { luckbonus = killer.Luck; if (killer.Map == Map.Felucca) { luckbonus += RandomItemGenerator.FeluccaLuckBonus; budgetBonus += RandomItemGenerator.FeluccaBudgetBonus; } } else { luckbonus = 240; } if (item != null) { // base budget range int budget = Utility.RandomMinMax(basebudget - (basebudget / 4), basebudget); // Gives a rare chance for a high end item to drop on a low budgeted monster if(Utility.RandomDouble() < (double)luckbonus / 2000.0) budget += Utility.RandomMinMax(150, Math.Max(160, 400 - basebudget)); budget += budgetBonus; TryApplyRandomDisadvantage(item, ref budget); if (budget > 900) budget = 900; bool powerful = budget >= 550; ReforgedPrefix prefix = forcedprefix; ReforgedSuffix suffix = forcedsuffix; if (!(item is BaseWeapon) && prefix == ReforgedPrefix.Vampiric) prefix = ReforgedPrefix.None; if (!(item is BaseWeapon) && suffix == ReforgedSuffix.Vampire) suffix = ReforgedSuffix.None; if(forcedprefix == ReforgedPrefix.None && budget >= Utility.Random(2100)) prefix = ChooseRandomPrefix(item); if (forcedsuffix == ReforgedSuffix.None && budget >= Utility.Random(2100)) suffix = ChooseRandomSuffix(item, prefix); int mods; int perclow; int perchigh; if (!powerful) { if (prefix == ReforgedPrefix.None && suffix == ReforgedSuffix.None) mods = Utility.RandomMinMax(4, 5); else mods = Utility.RandomMinMax(2, 4); perchigh = Math.Max(20, Math.Min(500, budget) / mods); perclow = Math.Max(10, perchigh / 3); } else { int maxmods = Math.Min(9, budget / Utility.RandomMinMax(100, 140)); int minmods = Math.Max(5, maxmods - 1); mods = Utility.RandomMinMax(minmods, maxmods); perchigh = 100; perclow = Math.Max(50, (budget / 2) / mods); } if (perchigh > 100) perchigh = 100; if (perclow < 10) perclow = 10; ApplyReforgedProperties(item, prefix, suffix, false, budget, perclow, perchigh, mods, luckchance); } }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; switch (info.ButtonID) { case 0: break; case 1: // prefix from.SendGump(new ItemNameGump(m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix, true)); break; case 2: // suffix from.SendGump(new ItemNameGump(m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix, false)); break; case 3: // Reforge Item { int totalCharges = GetTotalCharges(); if (m_Tool.UsesRemaining >= totalCharges) { CraftResourceInfo resInfo = CraftResources.GetInfo(m_Tool.Resource); if (resInfo == null) return; CraftAttributeInfo attrs = resInfo.AttributeInfo; int budget = GetBudget(); int min = 10; int max = 40; if (attrs != null) { min = attrs.RunicMinIntensity; max = attrs.RunicMaxIntensity; } if (min < 10) min = 10; if (max > 100) max = 100; if (m_Prefix == ReforgedPrefix.None && (m_Options & ReforgingOption.GrandArtifice) != 0) { m_Prefix = RunicReforging.ChooseRandomPrefix(m_ToReforge); budget = Math.Min(800, budget + 50); } if (m_Suffix == ReforgedSuffix.None && (m_Options & ReforgingOption.ExaltedArtifice) != 0) { m_Suffix = RunicReforging.ChooseRandomSuffix(m_ToReforge, m_Prefix); budget = Math.Min(800, budget + 50); } int maxprops; if (attrs != null) maxprops = Utility.RandomMinMax(attrs.RunicMinAttributes, attrs.RunicMaxAttributes); else maxprops = Math.Min(5, (budget / 110) + 1); if (maxprops == 5 && 0.25 > Utility.RandomDouble()) maxprops = 6; if (maxprops == 6 && budget >= 650 && 0.10 > Utility.RandomDouble()) maxprops = 7; RunicReforging.ApplyReforgedProperties(m_ToReforge, m_Prefix, m_Suffix, true, budget, min, max, maxprops, 0, m_Tool, m_Options); OnAfterReforged(m_ToReforge); from.SendLocalizedMessage(1152286); // You re-forge the item! m_Tool.UsesRemaining -= totalCharges; if (m_Tool != null && m_Tool.CraftSystem != null) m_Tool.CraftSystem.PlayCraftEffect(from); if (m_Tool.UsesRemaining <= 0) { m_Tool.Delete(); from.SendLocalizedMessage(1044038); // You have worn out your tool! } } break; } case 4: from.SendGump(new ReforgingHelpGump()); break; default: // Option { ReforgingOption option = Options[info.ButtonID - 100]; if (HasMetPrerequisite(option)) { if ((m_Options & option) == 0) m_Options |= option; else { m_Options ^= option; InvalidatePrerequisite(option); } } from.SendGump(new RunicReforgingGump(from, m_ToReforge, m_Tool, m_Options, m_Prefix, m_Suffix)); break; } } }