예제 #1
0
        private static bool AssignArmorLevel_New(WorldObject wo, TreasureDeath profile, TreasureRoll roll)
        {
            // retail was only divied up into a few different mutation scripts here
            // anything with ArmorLevel ran these mutation scripts
            // anything that covered extremities (head / hand / foot wear) started with a slightly higher base AL,
            // but otherwise used the same mutation as anything that covered non-extremities
            // shields also had their own mutation script

            // only exceptions found: covenant armor, olthoi armor, metal cap

            if (!roll.HasArmorLevel(wo))
            {
                return(false);
            }

            var scriptName = GetMutationScript_ArmorLevel(wo, roll);

            if (scriptName == null)
            {
                log.Error($"AssignArmorLevel_New({wo.Name}, {profile.TreasureType}, {roll.ItemType}) - unknown item type");
                return(false);
            }

            //Console.WriteLine($"Mutating {wo.Name} with {scriptName}");

            var mutationFilter = MutationCache.GetMutation(scriptName);

            return(mutationFilter.TryMutate(wo, profile.Tier));
        }
예제 #2
0
        private static bool AssignArmorLevel_New(WorldObject wo, TreasureDeath profile, TreasureRoll roll, LootTables.ArmorType armorType)
        {
            // retail was only divied up into a few different mutation scripts here
            // anything with ArmorLevel ran these mutation scripts
            // anything that covered extremities (head / hand / foot wear) started with a slightly higher base AL,
            // but otherwise used the same mutation as anything that covered non-extremities
            // shields also had their own mutation script

            // only exceptions found: covenant armor, olthoi armor, metal cap

            if (!roll.HasArmorLevel(wo))
            {
                return(false);
            }

            var scriptName = GetMutationScript_ArmorLevel(wo, roll);

            if (scriptName == null)
            {
                log.Error($"AssignArmorLevel_New({wo.Name}, {profile.TreasureType}, {roll.ItemType}) - unknown item type");
                return(false);
            }

            // persist original values for society armor
            var wieldRequirements = wo.WieldRequirements;
            var wieldSkillType    = wo.WieldSkillType;
            var wieldDifficulty   = wo.WieldDifficulty;

            //Console.WriteLine($"Mutating {wo.Name} with {scriptName}");

            var mutationFilter = MutationCache.GetMutation(scriptName);

            var success = mutationFilter.TryMutate(wo, profile.Tier);

            if (armorType == LootTables.ArmorType.SocietyArmor)
            {
                wo.WieldRequirements = wieldRequirements;
                wo.WieldSkillType    = wieldSkillType;
                wo.WieldDifficulty   = wieldDifficulty;
            }

            return(success);
        }
예제 #3
0
        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);
        }
예제 #4
0
        private static bool MutateMeleeWeapon(WorldObject wo, TreasureDeath profile, bool isMagical, TreasureWeaponType weaponType = TreasureWeaponType.Undef)
        {
            if (!(wo is MeleeWeapon))
            {
                return(false);
            }

            if (weaponType == TreasureWeaponType.Undef)
            {
                // previous method
                var wieldDifficulty = RollWieldDifficulty(profile.Tier, WieldType.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, weaponType);

                var mutationFilter = MutationCache.GetMutation(scriptName);

                mutationFilter.TryMutate(wo, profile.Tier);

                // mutate WeaponOffense / WeaponDefense
                scriptName = GetOffenseDefenseScript(weaponSkill, 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)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 = GetWorkmanship(profile.Tier);

            // burden
            MutateBurden(wo, profile, true);

            // item value
            var materialMod    = LootTables.getMaterialValueModifier(wo);
            var gemMaterialMod = LootTables.getGemMaterialValueModifier(wo);

            wo.Value = GetValue(profile.Tier, wo.ItemWorkmanship ?? 0, gemMaterialMod, materialMod);

            // 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);
            }

            // long description
            wo.LongDesc = GetLongDesc(wo);

            return(true);
        }
예제 #5
0
        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);
        }
예제 #6
0
        private static void MutateMissileWeapon(WorldObject wo, TreasureDeath profile, bool isMagical, int?wieldDifficulty = null, TreasureWeaponType?weaponType = null)
        {
            if (wieldDifficulty != 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 if (weaponType != null)
            {
                // new method / mutation scripts
                var isElemental = wo.W_DamageType != DamageType.Undef;

                var scriptName = GetMissileScript(weaponType.Value, 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);
            }
            else
            {
                log.Warn($"LootGenerationFactory_Missile.MutateMissileWeapon({wo.Name}, {profile.TreasureType}, {isMagical}, {wieldDifficulty}, {weaponType}) - unexpected: WieldDifficulty and WeaponType are both null!");
            }

            // weapon speed
            if (wo.WeaponTime != null)
            {
                var weaponSpeedMod = RollWeaponSpeedMod(profile);
                wo.WeaponTime = (int)(wo.WeaponTime * weaponSpeedMod);
            }

            // 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 = GetWorkmanship(profile.Tier);

            // burden
            MutateBurden(wo, profile, true);

            // item value
            var materialMod    = LootTables.getMaterialValueModifier(wo);
            var gemMaterialMod = LootTables.getGemMaterialValueModifier(wo);

            wo.Value = GetValue(profile.Tier, (int)wo.Workmanship, gemMaterialMod, materialMod);

            // missile / magic defense
            wo.WeaponMissileDefense = RollWeapon_MissileMagicDefense(profile.Tier);
            wo.WeaponMagicDefense   = RollWeapon_MissileMagicDefense(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);
            }

            // long description
            wo.LongDesc = GetLongDesc(wo);
        }