private static void MutateValue_Gem(WorldObject wo) { var materialMod = MaterialTable.GetValueMod(wo.MaterialType); var workmanshipMod = WorkmanshipChance.GetModifier(wo.ItemWorkmanship); wo.Value = (int)(wo.Value * materialMod * workmanshipMod); }
private static void MutateSocietyArmor(WorldObject wo, TreasureDeath profile, bool isMagical, TreasureRoll roll = null) { int materialType = GetMaterialType(wo, profile.Tier); if (materialType > 0) { wo.MaterialType = (MaterialType)materialType; } if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 6); } wo.GemType = RollGemType(profile.Tier); wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); wo.Value = Roll_ItemValue(wo, profile.Tier); // wo.WieldSkillType = (int)Skill.Axe; // Set by examples from PCAP data if (isMagical) { // looks like society armor always had impen on it AssignMagic(wo, profile, roll, true); } else { wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; } wo = AssignArmorLevel(wo, profile.Tier, LootTables.ArmorType.SocietyArmor); wo.LongDesc = GetLongDesc(wo); // try mutate burden, if MutateFilter exists if (wo.HasMutateFilter(MutateFilter.EncumbranceVal)) { MutateBurden(wo, profile, false); } }
private static void MutateGem(WorldObject wo, TreasureDeath profile, bool isMagical, TreasureRoll roll = null) { // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // item color MutateColor(wo); if (!isMagical) { // TODO: verify if this is needed wo.ItemUseable = Usable.No; wo.SpellDID = null; wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; wo.ItemSkillLevelLimit = null; wo.ManaRate = null; } else { if (roll == null) { AssignMagic_Gem(wo, profile); } else { AssignMagic_Gem_New(wo, profile, roll); } wo.UiEffects = UiEffects.Magical; wo.ItemUseable = Usable.Contained; } // item value if (wo.HasMutateFilter(MutateFilter.Value)) { MutateValue(wo, profile.Tier, roll); } // long desc wo.LongDesc = GetLongDesc(wo); }
private static void MutateGem(WorldObject wo, TreasureDeath profile, bool isMagical, TreasureRoll roll = null) { // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // item color MutateColor(wo); if (!isMagical) { // TODO: verify if this is needed wo.ItemUseable = Usable.No; wo.SpellDID = null; wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; wo.ItemSkillLevelLimit = null; wo.ManaRate = null; } else { if (roll == null) { AssignMagic_Gem(wo, profile); } else { AssignMagic_Gem_New(wo, profile, roll); } wo.UiEffects = UiEffects.Magical; wo.ItemUseable = Usable.Contained; wo.LongDesc = GetLongDesc(wo); } // item value, review var gemValue = LootTables.gemValues[(int)wo.MaterialType]; wo.Value = gemValue + ThreadSafeRandom.Next(1, gemValue); }
private static void MutateDinnerware(WorldObject wo, TreasureDeath profile, bool isMagical, TreasureRoll roll = null) { // dinnerware did not have its Damage / DamageVariance / WeaponSpeed mutated // material type wo.MaterialType = GetMaterialType(wo, profile.Tier); // item color MutateColor(wo); // gem count / gem material if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 5); } wo.GemType = RollGemType(profile.Tier); // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // "Empty Flask" was the only dinnerware that never received spells if (isMagical && wo.WeenieClassId != (uint)WeenieClassName.flasksimple) { AssignMagic(wo, profile, roll); } // item value if (wo.HasMutateFilter(MutateFilter.Value)) { MutateValue(wo, profile.Tier, roll); } // long desc wo.LongDesc = GetLongDesc(wo); }
private static void MutatePetDevice(WorldObject petDevice, int tier) { if (!(petDevice is PetDevice)) { return; } var ratingChance = 0.5f; // add rng ratings to pet device // linear or biased? if (ratingChance > ThreadSafeRandom.Next(0.0f, 1.0f)) { petDevice.GearDamage = GeneratePetDeviceRating(tier); } if (ratingChance > ThreadSafeRandom.Next(0.0f, 1.0f)) { petDevice.GearDamageResist = GeneratePetDeviceRating(tier); } if (ratingChance > ThreadSafeRandom.Next(0.0f, 1.0f)) { petDevice.GearCritDamage = GeneratePetDeviceRating(tier); } if (ratingChance > ThreadSafeRandom.Next(0.0f, 1.0f)) { petDevice.GearCritDamageResist = GeneratePetDeviceRating(tier); } if (ratingChance > ThreadSafeRandom.Next(0.0f, 1.0f)) { petDevice.GearCrit = GeneratePetDeviceRating(tier); } if (ratingChance > ThreadSafeRandom.Next(0.0f, 1.0f)) { petDevice.GearCritResist = GeneratePetDeviceRating(tier); } petDevice.ItemWorkmanship = WorkmanshipChance.Roll(tier); }
private static void MutateArmor(WorldObject wo, TreasureDeath profile, bool isMagical, LootTables.ArmorType armorType, TreasureRoll roll = null) { // material type var materialType = GetMaterialType(wo, profile.Tier); if (materialType > 0) { wo.MaterialType = materialType; } // item color MutateColor(wo); // gem count / gem material if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 6); } wo.GemType = RollGemType(profile.Tier); // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // burden if (wo.HasMutateFilter(MutateFilter.EncumbranceVal)) // fixme: data { MutateBurden(wo, profile, false); } if (roll == null) { if (armorType == LootTables.ArmorType.CovenantArmor || armorType == LootTables.ArmorType.OlthoiArmor) { int chance = ThreadSafeRandom.Next(1, 3); var wieldSkill = chance switch { 1 => Skill.MagicDefense, 2 => Skill.MissileDefense, _ => Skill.MeleeDefense, }; wo.WieldRequirements = WieldRequirement.RawSkill; wo.WieldSkillType = (int)wieldSkill; wo.WieldDifficulty = GetCovenantWieldReq(profile.Tier, wieldSkill); } else if (profile.Tier > 6) { wo.WieldRequirements = WieldRequirement.Level; wo.WieldSkillType = (int)Skill.Axe; // Set by examples from PCAP data wo.WieldDifficulty = profile.Tier switch { 7 => 150, // In this instance, used for indicating player level, rather than skill level _ => 180, // In this instance, used for indicating player level, rather than skill level }; } } else if (profile.Tier > 6 && !wo.HasArmorLevel()) { // normally this is handled in the mutation script for armor // for clothing, just calling the generic method here RollWieldLevelReq_T7_T8(wo, profile); } if (roll == null) { AssignArmorLevel(wo, profile.Tier, armorType); } else { AssignArmorLevel_New(wo, profile, roll); } if (wo.HasMutateFilter(MutateFilter.ArmorModVsType)) { MutateArmorModVsType(wo, profile); } if (isMagical) { AssignMagic(wo, profile, roll, true); } else { wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; } if (profile.Tier > 6) { TryRollEquipmentSet(wo, profile, roll); } if (roll != null && profile.Tier == 8) { TryMutateGearRating(wo, profile, roll); } // item value //if (wo.HasMutateFilter(MutateFilter.Value)) // fixme: data MutateValue(wo, profile.Tier, roll); wo.LongDesc = GetLongDesc(wo); }
private static void MutateMissileWeapon(WorldObject wo, TreasureDeath profile, bool isMagical, int?wieldDifficulty = null, TreasureRoll roll = null) { if (roll == null) { // previous method // DamageMod wo.DamageMod = GetMissileDamageMod(wieldDifficulty.Value, wo.W_WeaponType); // ElementalDamageBonus if (wo.W_DamageType != DamageType.Undef) { int elementalBonus = GetElementalDamageBonus(wieldDifficulty.Value); if (elementalBonus > 0) { wo.ElementalDamageBonus = elementalBonus; } } // Wield Requirements if (wieldDifficulty > 0) { wo.WieldDifficulty = wieldDifficulty; wo.WieldRequirements = WieldRequirement.RawSkill; wo.WieldSkillType = (int)Skill.MissileWeapons; } else { wo.WieldDifficulty = null; wo.WieldRequirements = WieldRequirement.Invalid; wo.WieldSkillType = null; } // WeaponDefense var meleeDMod = RollWeaponDefense(wieldDifficulty.Value, profile); if (meleeDMod > 0.0f) { wo.WeaponDefense = meleeDMod; } } else { // new method / mutation scripts var isElemental = wo.W_DamageType != DamageType.Undef; var scriptName = GetMissileScript(roll.WeaponType, isElemental); // mutate DamageMod / ElementalDamageBonus / WieldRequirements var mutationFilter = MutationCache.GetMutation(scriptName); mutationFilter.TryMutate(wo, profile.Tier); // mutate WeaponDefense mutationFilter = MutationCache.GetMutation("MissileWeapons.weapon_defense.txt"); mutationFilter.TryMutate(wo, profile.Tier); } // weapon speed if (wo.WeaponTime != null) { var weaponSpeedMod = RollWeaponSpeedMod(profile); wo.WeaponTime = (int)(wo.WeaponTime * weaponSpeedMod); } // material type var materialType = GetMaterialType(wo, profile.Tier); if (materialType > 0) { wo.MaterialType = materialType; } // item color MutateColor(wo); // gem count / gem material if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 5); } wo.GemType = RollGemType(profile.Tier); // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // burden MutateBurden(wo, profile, true); // missile / magic defense wo.WeaponMissileDefense = MissileMagicDefense.Roll(profile.Tier); wo.WeaponMagicDefense = MissileMagicDefense.Roll(profile.Tier); // spells if (!isMagical) { wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; wo.ManaRate = null; } else { AssignMagic(wo, profile, roll); } // item value //if (wo.HasMutateFilter(MutateFilter.Value)) // fixme: data MutateValue(wo, profile.Tier, roll); // long description wo.LongDesc = GetLongDesc(wo); }
private static void MutateArmor(WorldObject wo, TreasureDeath profile, bool isMagical, LootTables.ArmorType armorType, TreasureRoll roll = null) { // material type int materialType = GetMaterialType(wo, profile.Tier); if (materialType > 0) { wo.MaterialType = (MaterialType)materialType; } // item color MutateColor(wo); // gem count / gem material if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 6); } wo.GemType = RollGemType(profile.Tier); // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // try mutate burden, if MutateFilter exists if (wo.HasMutateFilter(MutateFilter.EncumbranceVal)) { MutateBurden(wo, profile, false); } if (profile.Tier > 6 && armorType != LootTables.ArmorType.CovenantArmor && armorType != LootTables.ArmorType.OlthoiArmor) { wo.WieldRequirements = WieldRequirement.Level; wo.WieldSkillType = (int)Skill.Axe; // Set by examples from PCAP data wo.WieldDifficulty = profile.Tier switch { 7 => 150, // In this instance, used for indicating player level, rather than skill level _ => 180, // In this instance, used for indicating player level, rather than skill level }; } if (armorType == LootTables.ArmorType.CovenantArmor || armorType == LootTables.ArmorType.OlthoiArmor) { int chance = ThreadSafeRandom.Next(1, 3); var wieldSkill = chance switch { 1 => Skill.MagicDefense, 2 => Skill.MissileDefense, _ => Skill.MeleeDefense, }; wo.WieldRequirements = WieldRequirement.RawSkill; wo.WieldSkillType = (int)wieldSkill; wo.WieldDifficulty = GetCovenantWieldReq(profile.Tier, wieldSkill); // used by tinkering requirements for copper/silver wo.ItemSkillLimit = wieldSkill; } wo = AssignArmorLevel(wo, profile.Tier, armorType); wo = AssignEquipmentSetId(wo, profile); if (isMagical) { //bool covenantArmor = false || (armorType == LootTables.ArmorType.CovenantArmor || armorType == LootTables.ArmorType.OlthoiArmor); AssignMagic(wo, profile, roll, true); } else { wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; } if (wo.HasMutateFilter(MutateFilter.ArmorModVsType) && wo.ArmorLevel > 0) { // covenant armor and olthoi armor appear to have different mutation methods possibly if (armorType != LootTables.ArmorType.CovenantArmor && armorType != LootTables.ArmorType.OlthoiArmor) { MutateArmorModVsType(wo, profile); } } if (roll != null && profile.Tier == 8) { TryMutateGearRating(wo, profile, roll); } // item value wo.Value = Roll_ItemValue(wo, profile.Tier); wo.LongDesc = GetLongDesc(wo); }
private static void MutateJewelry(WorldObject wo, TreasureDeath profile, bool isMagical, TreasureRoll roll = null) { // material type var materialType = GetMaterialType(wo, profile.Tier); if (materialType > 0) { wo.MaterialType = materialType; } // item color MutateColor(wo); // gem count / gem material if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 5); } wo.GemType = RollGemType(profile.Tier); // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // wield level requirement for t7+ if (profile.Tier > 6) { RollWieldLevelReq_T7_T8(wo, profile); } // assign magic if (isMagical) { AssignMagic(wo, profile, roll); } else { wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; wo.ManaRate = null; } // gear rating (t8) if (roll != null && profile.Tier == 8) { TryMutateGearRating(wo, profile, roll); } // item value // if (wo.HasMutateFilter(MutateFilter.Value)) // fixme: data MutateValue(wo, profile.Tier, roll); wo.LongDesc = GetLongDesc(wo); }
private static void MutateCaster(WorldObject wo, TreasureDeath profile, bool isMagical, int?wieldDifficulty = null, TreasureRoll roll = null) { if (wieldDifficulty != null) { // previous method var wieldRequirement = WieldRequirement.RawSkill; var wieldSkillType = Skill.None; double elementalDamageMod = 0; if (wieldDifficulty == 0) { if (profile.Tier > 6) { wieldRequirement = WieldRequirement.Level; wieldSkillType = Skill.Axe; // Set by examples from PCAP data wieldDifficulty = profile.Tier switch { 7 => 150, // In this instance, used for indicating player level, rather than skill level _ => 180, // In this instance, used for indicating player level, rather than skill level }; } } else { elementalDamageMod = RollElementalDamageMod(wieldDifficulty.Value); if (wo.W_DamageType == DamageType.Nether) { wieldSkillType = Skill.VoidMagic; } else { wieldSkillType = Skill.WarMagic; } } // ManaConversionMod var manaConversionMod = RollManaConversionMod(profile.Tier); if (manaConversionMod > 0.0f) { wo.ManaConversionMod = manaConversionMod; } // ElementalDamageMod if (elementalDamageMod > 1.0f) { wo.ElementalDamageMod = elementalDamageMod; } // WieldRequirements if (wieldDifficulty > 0 || wieldRequirement == WieldRequirement.Level) { wo.WieldRequirements = wieldRequirement; wo.WieldSkillType = (int)wieldSkillType; wo.WieldDifficulty = wieldDifficulty; } else { wo.WieldRequirements = WieldRequirement.Invalid; wo.WieldSkillType = null; wo.WieldDifficulty = null; } // WeaponDefense wo.WeaponDefense = RollWeaponDefense(wieldDifficulty.Value, profile); } else { // new method - mutation scripts // mutate ManaConversionMod var mutationFilter = MutationCache.GetMutation("Casters.caster.txt"); mutationFilter.TryMutate(wo, profile.Tier); // mutate ElementalDamageMod / WieldRequirements var isElemental = wo.W_DamageType != DamageType.Undef; var scriptName = GetCasterScript(isElemental); mutationFilter = MutationCache.GetMutation(scriptName); mutationFilter.TryMutate(wo, profile.Tier); // this part was not handled by mutation filter if (wo.WieldRequirements == WieldRequirement.RawSkill) { if (wo.W_DamageType == DamageType.Nether) { wo.WieldSkillType = (int)Skill.VoidMagic; } else { wo.WieldSkillType = (int)Skill.WarMagic; } } // mutate WeaponDefense mutationFilter = MutationCache.GetMutation("Casters.weapon_defense.txt"); mutationFilter.TryMutate(wo, profile.Tier); } // material type var materialType = GetMaterialType(wo, profile.Tier); if (materialType > 0) { wo.MaterialType = materialType; } // item color MutateColor(wo); // gem count / gem material if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 5); } wo.GemType = RollGemType(profile.Tier); // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // burden? // missile defense / magic defense wo.WeaponMissileDefense = MissileMagicDefense.Roll(profile.Tier); wo.WeaponMagicDefense = MissileMagicDefense.Roll(profile.Tier); // spells if (!isMagical) { wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; } else { // if a caster was from a MagicItem profile, it always had a SpellDID MutateCaster_SpellDID(wo, profile); AssignMagic(wo, profile, roll); } // item value //if (wo.HasMutateFilter(MutateFilter.Value)) // fixme: data MutateValue(wo, profile.Tier, roll); // long description wo.LongDesc = GetLongDesc(wo); }
private static bool MutateMeleeWeapon(WorldObject wo, TreasureDeath profile, bool isMagical, TreasureRoll roll = null) { if (!(wo is MeleeWeapon)) { return(false); } if (roll == null) { // previous method var wieldDifficulty = RollWieldDifficulty(profile.Tier, TreasureWeaponType.MeleeWeapon); if (!MutateStats_OldMethod(wo, profile, wieldDifficulty)) { return(false); } } else { // thanks to 4eyebiped for helping with the data analysis of magloot retail logs // that went into reversing these mutation scripts var weaponSkill = wo.WeaponSkill.ToMeleeWeaponSkill(); // mutate Damage / WieldDifficulty / Variance var scriptName = GetDamageScript(weaponSkill, roll.WeaponType); var mutationFilter = MutationCache.GetMutation(scriptName); mutationFilter.TryMutate(wo, profile.Tier); // mutate WeaponOffense / WeaponDefense scriptName = GetOffenseDefenseScript(weaponSkill, roll.WeaponType); mutationFilter = MutationCache.GetMutation(scriptName); mutationFilter.TryMutate(wo, profile.Tier); } // weapon speed if (wo.WeaponTime != null) { var weaponSpeedMod = RollWeaponSpeedMod(profile); wo.WeaponTime = (int)(wo.WeaponTime * weaponSpeedMod); } // material type var materialType = GetMaterialType(wo, profile.Tier); if (materialType > 0) { wo.MaterialType = materialType; } // item color MutateColor(wo); // gem count / gem material if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 5); } wo.GemType = RollGemType(profile.Tier); // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // burden MutateBurden(wo, profile, true); // missile / magic defense wo.WeaponMissileDefense = MissileMagicDefense.Roll(profile.Tier); wo.WeaponMagicDefense = MissileMagicDefense.Roll(profile.Tier); // spells if (!isMagical) { // clear base wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; } else { AssignMagic(wo, profile, roll); } // item value //if (wo.HasMutateFilter(MutateFilter.Value)) // fixme: data MutateValue(wo, profile.Tier, roll); // long description wo.LongDesc = GetLongDesc(wo); return(true); }
private static void MutateJewelry(WorldObject wo, TreasureDeath profile, bool isMagical, TreasureRoll roll = null) { // material type int materialType = GetMaterialType(wo, profile.Tier); if (materialType > 0) { wo.MaterialType = (MaterialType)materialType; } // item color MutateColor(wo); // gem count / gem material if (wo.GemCode != null) { wo.GemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier); } else { wo.GemCount = ThreadSafeRandom.Next(1, 5); } wo.GemType = RollGemType(profile.Tier); // workmanship wo.ItemWorkmanship = WorkmanshipChance.Roll(profile.Tier); // wield requirements (verify) if (profile.Tier > 6) { wo.WieldRequirements = WieldRequirement.Level; wo.WieldSkillType = (int)Skill.Axe; // Set by examples from PCAP data var wield = profile.Tier switch { 7 => 150, // In this instance, used for indicating player level, rather than skill level _ => 180, // In this instance, used for indicating player level, rather than skill level }; wo.WieldDifficulty = wield; } // assign magic if (isMagical) { AssignMagic(wo, profile, roll); } else { wo.ItemManaCost = null; wo.ItemMaxMana = null; wo.ItemCurMana = null; wo.ItemSpellcraft = null; wo.ItemDifficulty = null; wo.ManaRate = null; } // gear rating (t8) if (roll != null && profile.Tier == 8) { TryMutateGearRating(wo, profile, roll); } // item value wo.Value = Roll_ItemValue(wo, profile.Tier); wo.LongDesc = GetLongDesc(wo); }