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);
        }
Example #2
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);
        }
Example #3
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);
        }