Esempio n. 1
0
        private static WorldObject CreateWeapon(int tier, bool isMagical)
        {
            int    weaponWeenie       = 0;
            int    damage             = 0;
            double damageVariance     = 0;
            double weaponDefense      = 0;
            double weaponOffense      = 0;
            int    longDescDecoration = 5;

            ///Properties for weapons
            double           magicD           = GetMissileDMod(tier);
            double           missileD         = GetMissileDMod(tier);
            int              gemCount         = ThreadSafeRandom.Next(1, 5);
            int              gemType          = ThreadSafeRandom.Next(10, 50);
            int              materialType     = GetMaterialType(2, tier);
            int              workmanship      = GetWorkmanship(tier);
            int              value            = GetValue(tier, workmanship);
            int              wieldDiff        = GetWield(tier, 3);
            WieldRequirement wieldRequirments = WieldRequirement.RawSkill;

            int eleType    = ThreadSafeRandom.Next(0, 4);
            int weaponType = ThreadSafeRandom.Next(0, 5);

            switch (weaponType)
            {
            case 0:
                // Heavy Weapons
                int heavyWeaponsType = ThreadSafeRandom.Next(0, 22);
                weaponWeenie = LootTables.HeavyWeaponsMatrix[heavyWeaponsType][eleType];

                switch (heavyWeaponsType)
                {
                case 0:
                case 1:
                case 2:
                    weaponDefense  = GetMaxDamageMod(tier, 18);
                    weaponOffense  = GetMaxDamageMod(tier, 22);
                    damage         = GetMaxDamage(1, tier, wieldDiff, 1);
                    damageVariance = GetVariance(1, 1);
                    break;

                case 3:
                case 4:
                case 5:
                    weaponDefense = GetMaxDamageMod(tier, 20);
                    weaponOffense = GetMaxDamageMod(tier, 20);

                    damage = GetMaxDamage(1, tier, wieldDiff, 2);

                    if (heavyWeaponsType == 3)
                    {
                        damageVariance = GetVariance(1, 2);
                    }
                    if (heavyWeaponsType == 4 || heavyWeaponsType == 5)
                    {
                        damage         = GetMaxDamage(1, tier, wieldDiff, 3);
                        damageVariance = GetVariance(1, 3);
                    }
                    break;

                case 6:
                case 7:
                case 8:
                case 9:
                    weaponDefense  = GetMaxDamageMod(tier, 22);
                    weaponOffense  = GetMaxDamageMod(tier, 18);
                    damage         = GetMaxDamage(1, tier, wieldDiff, 4);
                    damageVariance = GetVariance(1, 4);
                    break;

                case 10:
                case 11:
                case 12:
                    weaponDefense  = GetMaxDamageMod(tier, 15);
                    weaponOffense  = GetMaxDamageMod(tier, 25);
                    damage         = GetMaxDamage(1, tier, wieldDiff, 5);
                    damageVariance = GetVariance(1, 5);
                    break;

                case 13:
                case 14:
                    weaponDefense  = GetMaxDamageMod(tier, 25);
                    weaponOffense  = GetMaxDamageMod(tier, 15);
                    damage         = GetMaxDamage(1, tier, wieldDiff, 8);
                    damageVariance = GetVariance(1, 6);
                    break;

                case 15:
                case 16:
                case 17:
                case 18:
                case 19:
                case 20:
                    weaponDefense = GetMaxDamageMod(tier, 20);
                    weaponOffense = GetMaxDamageMod(tier, 20);

                    damage         = GetMaxDamage(1, tier, wieldDiff, 6);
                    damageVariance = GetVariance(1, 7);

                    if (heavyWeaponsType == 20)
                    {
                        damage         = GetMaxDamage(1, tier, wieldDiff, 7);
                        damageVariance = GetVariance(1, 8);
                    }
                    break;

                case 21:
                default:
                    damage         = GetMaxDamage(1, tier, wieldDiff, 9);
                    weaponDefense  = GetMaxDamageMod(tier, 20);
                    weaponOffense  = GetMaxDamageMod(tier, 20);
                    damageVariance = GetVariance(1, 9);
                    break;
                }
                break;

            case 1:
                // Light Weapons;
                int lightWeaponsType = ThreadSafeRandom.Next(0, 19);
                weaponWeenie = LootTables.LightWeaponsMatrix[lightWeaponsType][eleType];

                switch (lightWeaponsType)
                {
                case 0:
                case 1:
                case 2:
                case 3:
                    weaponDefense  = GetMaxDamageMod(tier, 18);
                    weaponOffense  = GetMaxDamageMod(tier, 22);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 1);
                    damageVariance = GetVariance(2, 1);
                    break;

                case 4:
                case 5:
                    weaponDefense = GetMaxDamageMod(tier, 20);
                    weaponOffense = GetMaxDamageMod(tier, 20);

                    if (lightWeaponsType == 4)
                    {
                        damage         = GetMaxDamage(2, tier, wieldDiff, 2);
                        damageVariance = GetVariance(2, 2);
                    }

                    if (lightWeaponsType == 5)
                    {
                        damage         = GetMaxDamage(2, tier, wieldDiff, 3);
                        damageVariance = GetVariance(2, 3);
                    }
                    break;

                case 6:
                case 7:
                case 8:
                    weaponDefense  = GetMaxDamageMod(tier, 22);
                    weaponOffense  = GetMaxDamageMod(tier, 18);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 4);
                    damageVariance = GetVariance(2, 4);
                    break;

                case 9:
                case 10:
                    weaponDefense  = GetMaxDamageMod(tier, 15);
                    weaponOffense  = GetMaxDamageMod(tier, 25);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 5);
                    damageVariance = GetVariance(2, 6);
                    break;

                case 11:
                    weaponDefense  = GetMaxDamageMod(tier, 25);
                    weaponOffense  = GetMaxDamageMod(tier, 15);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 8);
                    damageVariance = GetVariance(2, 7);
                    break;

                case 12:
                case 13:
                case 14:
                case 15:
                case 16:
                case 17:
                    weaponDefense = GetMaxDamageMod(tier, 20);
                    weaponOffense = GetMaxDamageMod(tier, 20);

                    damage         = GetMaxDamage(2, tier, wieldDiff, 6);
                    damageVariance = GetVariance(2, 8);

                    if (lightWeaponsType == 14)
                    {
                        damage         = GetMaxDamage(2, tier, wieldDiff, 7);
                        damageVariance = GetVariance(2, 9);
                    }
                    break;

                case 18:
                default:
                    weaponDefense  = GetMaxDamageMod(tier, 20);
                    weaponOffense  = GetMaxDamageMod(tier, 20);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 9);
                    damageVariance = GetVariance(2, 10);
                    break;
                }
                break;

            case 2:
                // Finesse Weapons;
                int finesseWeaponsType = ThreadSafeRandom.Next(0, 22);
                weaponWeenie = LootTables.FinesseWeaponsMatrix[finesseWeaponsType][eleType];

                switch (finesseWeaponsType)
                {
                case 0:
                case 1:
                case 2:
                    weaponDefense  = GetMaxDamageMod(tier, 18);
                    weaponOffense  = GetMaxDamageMod(tier, 22);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 1);
                    damageVariance = GetVariance(2, 1);
                    break;

                case 3:
                case 4:
                case 5:
                    weaponDefense  = GetMaxDamageMod(tier, 20);
                    weaponOffense  = GetMaxDamageMod(tier, 20);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 2);
                    damageVariance = GetVariance(2, 2);

                    if (finesseWeaponsType == 3 || finesseWeaponsType == 4)
                    {
                        damageVariance = GetVariance(2, 3);
                        damage         = GetMaxDamage(2, tier, wieldDiff, 3);
                    }
                    break;

                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                    weaponDefense  = GetMaxDamageMod(tier, 22);
                    weaponOffense  = GetMaxDamageMod(tier, 18);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 4);
                    damageVariance = GetVariance(2, 4);

                    if (finesseWeaponsType == 9)
                    {
                        damageVariance = GetVariance(2, 5);
                    }
                    break;

                case 11:
                case 12:
                    weaponDefense  = GetMaxDamageMod(tier, 15);
                    weaponOffense  = GetMaxDamageMod(tier, 25);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 5);
                    damageVariance = GetVariance(2, 6);
                    break;

                case 13:
                case 14:
                    weaponDefense  = GetMaxDamageMod(tier, 25);
                    weaponOffense  = GetMaxDamageMod(tier, 15);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 8);
                    damageVariance = GetVariance(2, 7);
                    break;

                case 15:
                case 16:
                case 17:
                case 18:
                case 19:
                case 20:
                    weaponDefense  = GetMaxDamageMod(tier, 20);
                    weaponOffense  = GetMaxDamageMod(tier, 20);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 6);
                    damageVariance = GetVariance(2, 8);

                    if (finesseWeaponsType == 15)
                    {
                        damage         = GetMaxDamage(2, tier, wieldDiff, 7);
                        damageVariance = GetVariance(2, 9);
                    }
                    break;

                case 21:
                default:
                    weaponDefense  = GetMaxDamageMod(tier, 20);
                    weaponOffense  = GetMaxDamageMod(tier, 20);
                    damage         = GetMaxDamage(2, tier, wieldDiff, 9);
                    damageVariance = GetVariance(2, 10);
                    break;
                }
                break;

            case 3:
                // Two handed
                int twoHandedWeaponsType = ThreadSafeRandom.Next(0, 11);
                weaponWeenie = LootTables.TwoHandedWeaponsMatrix[twoHandedWeaponsType][eleType];

                damage         = GetMaxDamage(3, tier, wieldDiff, 1);
                damageVariance = GetVariance(3, 1);

                switch (twoHandedWeaponsType)
                {
                case 0:
                case 1:
                case 2:
                    weaponDefense  = GetMaxDamageMod(tier, 20);
                    weaponOffense  = GetMaxDamageMod(tier, 20);
                    damageVariance = GetVariance(2, 1);
                    break;

                case 3:
                case 4:
                case 5:
                case 6:
                    weaponDefense = GetMaxDamageMod(tier, 22);
                    weaponOffense = GetMaxDamageMod(tier, 18);
                    break;

                case 7:
                    weaponDefense = GetMaxDamageMod(tier, 18);
                    weaponOffense = GetMaxDamageMod(tier, 22);
                    break;

                case 8:
                case 9:
                case 10:
                default:
                    weaponDefense = GetMaxDamageMod(tier, 15);
                    weaponOffense = GetMaxDamageMod(tier, 25);
                    damage        = GetMaxDamage(3, tier, wieldDiff, 2);
                    break;
                }
                break;

            case 4:
                return(CreateMissileWeapon(tier, isMagical));

            default:
                return(CreateCaster(tier, isMagical));
            }

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject((uint)weaponWeenie);

            if (wo == null)
            {
                return(null);
            }

            wo.SetProperty(PropertyInt.AppraisalLongDescDecoration, longDescDecoration);
            wo.SetProperty(PropertyString.LongDesc, wo.GetProperty(PropertyString.Name));

            wo.SetProperty(PropertyInt.GemCount, gemCount);
            wo.SetProperty(PropertyInt.GemType, gemType);
            wo.SetProperty(PropertyInt.Value, value);
            wo.SetProperty(PropertyInt.MaterialType, GetMaterialType(2, tier));
            wo.SetProperty(PropertyInt.ItemWorkmanship, workmanship);

            wo.SetProperty(PropertyInt.Damage, damage);
            wo.SetProperty(PropertyFloat.DamageVariance, damageVariance);

            wo.SetProperty(PropertyFloat.WeaponDefense, weaponDefense);
            wo.SetProperty(PropertyFloat.WeaponOffense, weaponOffense);
            wo.SetProperty(PropertyFloat.WeaponMissileDefense, missileD);
            wo.SetProperty(PropertyFloat.WeaponMagicDefense, magicD);

            wo.SetProperty(PropertyInt.WieldDifficulty, wieldDiff);
            wo.SetProperty(PropertyInt.WieldRequirements, (int)wieldRequirments);

            if (wieldDiff == 0)
            {
                wo.RemoveProperty(PropertyInt.WieldDifficulty);
                wo.RemoveProperty(PropertyInt.WieldRequirements);
                wo.RemoveProperty(PropertyInt.WieldSkillType);
            }

            if (isMagical)
            {
                wo.SetProperty(PropertyInt.UiEffects, (int)UiEffects.Magical);

                int numSpells = GetNumSpells(tier);

                int lowSpellTier      = GetLowSpellTier(tier);
                int highSpellTier     = GetHighSpellTier(tier);
                int minorCantrips     = GetNumMinorCantrips(tier);
                int majorCantrips     = GetNumMajorCantrips(tier);
                int epicCantrips      = GetNumEpicCantrips(tier);
                int legendaryCantrips = GetNumLegendaryCantrips(tier);
                int numCantrips       = minorCantrips + majorCantrips + epicCantrips + legendaryCantrips;

                int spellCraft     = GetSpellcraft(numSpells, tier);
                int itemDifficulty = GetDifficulty(tier, spellCraft);
                int maxMana        = GetMaxMana(numSpells, tier);

                wo.SetProperty(PropertyInt.ItemSpellcraft, spellCraft);

                wo.SetProperty(PropertyInt.ItemDifficulty, itemDifficulty);
                wo.SetProperty(PropertyInt.ItemMaxMana, maxMana);
                wo.SetProperty(PropertyInt.ItemCurMana, maxMana);
                wo.SetProperty(PropertyFloat.ManaRate, GetManaRate());

                int[][] spells         = LootTables.MeleeSpells;
                int[][] cantrips       = LootTables.MeleeCantrips;
                int[]   shuffledValues = new int[spells.Length];
                for (int i = 0; i < spells.Length; i++)
                {
                    shuffledValues[i] = i;
                }
                Shuffle(shuffledValues);

                if (numSpells - numCantrips > 0)
                {
                    for (int a = 0; a < numSpells - numCantrips; a++)
                    {
                        int col     = ThreadSafeRandom.Next(lowSpellTier - 1, highSpellTier - 1);
                        int spellID = spells[shuffledValues[a]][col];
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                }
                if (numCantrips > 0)
                {
                    shuffledValues = new int[cantrips.Length];
                    for (int i = 0; i < cantrips.Length; i++)
                    {
                        shuffledValues[i] = i;
                    }
                    Shuffle(shuffledValues);
                    int shuffledPlace = 0;
                    wo.SetProperty(PropertyInt.UiEffects, 1);
                    //minor cantripps
                    for (int a = 0; a < minorCantrips; a++)
                    {
                        int spellID = cantrips[shuffledValues[shuffledPlace]][0];
                        shuffledPlace++;
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                    //major cantrips
                    for (int a = 0; a < majorCantrips; a++)
                    {
                        int spellID = cantrips[shuffledValues[shuffledPlace]][1];
                        shuffledPlace++;
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                    // epic cantrips
                    for (int a = 0; a < epicCantrips; a++)
                    {
                        int spellID = cantrips[shuffledValues[shuffledPlace]][2];
                        shuffledPlace++;
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                    //legendary cantrips
                    for (int a = 0; a < legendaryCantrips; a++)
                    {
                        int spellID = cantrips[shuffledValues[shuffledPlace]][3];
                        shuffledPlace++;
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                }
            }
            else
            {
                wo.RemoveProperty(PropertyInt.ItemManaCost);
                wo.RemoveProperty(PropertyInt.ItemMaxMana);
                wo.RemoveProperty(PropertyInt.ItemCurMana);
                wo.RemoveProperty(PropertyInt.ItemSpellcraft);
                wo.RemoveProperty(PropertyInt.ItemDifficulty);
            }

            return(wo);
        }
Esempio n. 2
0
        private static WorldObject CreateCaster(int tier, bool isMagical)
        {
            int              casterWeenie       = 0; //done
            double           elementalDamageMod = 0;
            Skill            wieldSkillType     = Skill.None;
            WieldRequirement wieldRequirement   = WieldRequirement.RawSkill;
            int              subType            = 0;
            int              wield = GetWield(tier, 2);

            ////Getting the caster Weenie needed.
            if (wield == 0)
            {
                // Determine plain caster type: 0 - Orb, 1 - Sceptre, 2 - Staff, 3 - Wand
                subType      = ThreadSafeRandom.Next(0, 3);
                casterWeenie = LootTables.CasterWeaponsMatrix[wield][subType];

                if (tier > 6)
                {
                    wieldRequirement = WieldRequirement.Level;
                    wieldSkillType   = Skill.Axe; // Set by examples from PCAP data

                    switch (tier)
                    {
                    case 7:
                        wield = 150;     // In this instance, used for indicating player level, rather than skill level
                        break;

                    default:
                        wield = 180;     // In this instance, used for indicating player level, rather than skill level
                        break;
                    }
                }
            }
            else
            {
                // Determine the Elemental Damage Mod amount
                elementalDamageMod = GetMaxDamageMod(tier, 18);

                // Determine caster type: 1 - Sceptre, 2 - Baton, 3 - Staff
                int casterType = ThreadSafeRandom.Next(1, 3);

                // Determine element type: 0 - Slashing, 1 - Piercing, 2 - Blunt, 3 - Frost, 4 - Fire, 5 - Acid, 6 - Electric, 7 - Nether
                int element = ThreadSafeRandom.Next(0, 7);
                casterWeenie = LootTables.CasterWeaponsMatrix[casterType][element];

                // If element is Nether, Void Magic is required, else War Magic is required for all other elements
                if (element == 7)
                {
                    wieldSkillType = Skill.VoidMagic;
                }
                else
                {
                    wieldSkillType = Skill.WarMagic;
                }
            }

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject((uint)casterWeenie);

            if (wo == null)
            {
                return(null);
            }

            int workmanship = GetWorkmanship(tier);

            wo.SetProperty(PropertyInt.ItemWorkmanship, workmanship);
            int materialType = GetMaterialType(wo, tier);

            if (materialType > 0)
            {
                wo.MaterialType = (MaterialType)materialType;
            }
            wo.SetProperty(PropertyInt.MaterialType, GetMaterialType(wo, tier));
            wo.SetProperty(PropertyInt.GemCount, ThreadSafeRandom.Next(1, 5));

            wo.SetProperty(PropertyInt.GemType, ThreadSafeRandom.Next(10, 50));
            wo.SetProperty(PropertyString.LongDesc, wo.GetProperty(PropertyString.Name));

            double materialMod    = LootTables.getMaterialValueModifier(wo);
            double gemMaterialMod = LootTables.getGemMaterialValueModifier(wo);
            var    value          = GetValue(tier, workmanship, gemMaterialMod, materialMod);

            wo.Value = value;

            if (ThreadSafeRandom.Next(0, 100) > 95)
            {
                double missileDMod = GetMissileDMod(tier);
                if (missileDMod > 0.0f)
                {
                    wo.SetProperty(PropertyFloat.WeaponMissileDefense, missileDMod);
                }
            }
            else
            {
                double meleeDMod = GetMeleeDMod(tier);
                if (meleeDMod > 0.0f)
                {
                    wo.SetProperty(PropertyFloat.WeaponDefense, meleeDMod);
                }
            }

            double manaConMod = GetManaCMod(tier);

            if (manaConMod > 0.0f)
            {
                wo.SetProperty(PropertyFloat.ManaConversionMod, manaConMod);
            }

            if (elementalDamageMod > 1.0f)
            {
                wo.SetProperty(PropertyFloat.ElementalDamageMod, elementalDamageMod);
            }

            if (wield > 0 || wieldRequirement == WieldRequirement.Level)
            {
                wo.SetProperty(PropertyInt.WieldRequirements, (int)wieldRequirement);
                wo.SetProperty(PropertyInt.WieldSkillType, (int)wieldSkillType);
                wo.SetProperty(PropertyInt.WieldDifficulty, wield);
            }
            else
            {
                wo.RemoveProperty(PropertyInt.WieldRequirements);
                wo.RemoveProperty(PropertyInt.WieldSkillType);
                wo.RemoveProperty(PropertyInt.WieldDifficulty);
            }

            wo.RemoveProperty(PropertyInt.ItemSkillLevelLimit);

            if (isMagical)
            {
                wo.SetProperty(PropertyInt.UiEffects, (int)UiEffects.Magical);

                int lowSpellTier  = GetLowSpellTier(tier);
                int highSpellTier = GetHighSpellTier(tier);
                int numSpells     = GetNumSpells(tier);
                int spellcraft    = GetSpellcraft(numSpells, tier);
                int itemMaxMana   = GetMaxMana(numSpells, tier);

                wo.SetProperty(PropertyInt.ItemDifficulty, GetDifficulty(tier, spellcraft));
                wo.SetProperty(PropertyFloat.ManaRate, GetManaRate());

                wo.SetProperty(PropertyInt.ItemMaxMana, itemMaxMana);
                wo.SetProperty(PropertyInt.ItemCurMana, itemMaxMana);
                wo.SetProperty(PropertyInt.AppraisalLongDescDecoration, 7);
                wo.SetProperty(PropertyInt.ItemSpellcraft, spellcraft);

                int minorCantrips     = GetNumMinorCantrips(tier);
                int majorCantrips     = GetNumMajorCantrips(tier);
                int epicCantrips      = GetNumEpicCantrips(tier);
                int legendaryCantrips = GetNumLegendaryCantrips(tier);
                int numCantrips       = minorCantrips + majorCantrips + epicCantrips + legendaryCantrips;

                int[][] spells         = LootTables.WandSpells;
                int[][] cantrips       = LootTables.WandCantrips;
                int[]   shuffledValues = new int[spells.Length];

                for (int i = 0; i < spells.Length; i++)
                {
                    shuffledValues[i] = i;
                }

                Shuffle(shuffledValues);

                if (numSpells - numCantrips > 0)
                {
                    for (int a = 0; a < numSpells - numCantrips; a++)
                    {
                        int col     = ThreadSafeRandom.Next(lowSpellTier - 1, highSpellTier - 1);
                        int spellID = spells[shuffledValues[a]][col];
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                }

                if (numCantrips > 0)
                {
                    shuffledValues = new int[cantrips.Length];
                    for (int i = 0; i < cantrips.Length; i++)
                    {
                        shuffledValues[i] = i;
                    }
                    Shuffle(shuffledValues);
                    int shuffledPlace = 0;

                    //minor cantripps
                    for (int a = 0; a < minorCantrips; a++)
                    {
                        int spellID = cantrips[shuffledValues[shuffledPlace]][0];
                        shuffledPlace++;
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                    //major cantrips
                    for (int a = 0; a < majorCantrips; a++)
                    {
                        int spellID = cantrips[shuffledValues[shuffledPlace]][1];
                        shuffledPlace++;
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                    // epic cantrips
                    for (int a = 0; a < epicCantrips; a++)
                    {
                        int spellID = cantrips[shuffledValues[shuffledPlace]][2];
                        shuffledPlace++;
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                    //legendary cantrips
                    for (int a = 0; a < legendaryCantrips; a++)
                    {
                        int spellID = cantrips[shuffledValues[shuffledPlace]][3];
                        shuffledPlace++;
                        wo.Biota.GetOrAddKnownSpell(spellID, wo.BiotaDatabaseLock, wo.BiotaPropertySpells, out _);
                    }
                }
            }
            else
            {
                wo.RemoveProperty(PropertyInt.ItemManaCost);
                wo.RemoveProperty(PropertyInt.ItemMaxMana);
                wo.RemoveProperty(PropertyInt.ItemCurMana);
                wo.RemoveProperty(PropertyInt.ItemSpellcraft);
                wo.RemoveProperty(PropertyInt.ItemDifficulty);
            }

            wo = RandomizeColor(wo);
            return(wo);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a Melee weapon object.
        /// </summary>
        /// <param name="profile"></param><param name="isMagical"></param>
        /// <returns>Returns Melee Weapon WO</returns>
        public static WorldObject CreateMeleeWeapon(TreasureDeath profile, bool isMagical, int weaponType = -1)
        {
            Skill wieldSkillType = Skill.None;

            int    weaponWeenie       = 0;
            int    damage             = 0;
            double damageVariance     = 0;
            double weaponDefense      = 0;
            double weaponOffense      = 0;
            int    longDescDecoration = 5;

            // Properties for weapons
            double           magicD           = GetMagicMissileDMod(profile.Tier);
            double           missileD         = GetMagicMissileDMod(profile.Tier);
            int              gemCount         = ThreadSafeRandom.Next(1, 5);
            int              gemType          = ThreadSafeRandom.Next(10, 50);
            int              workmanship      = GetWorkmanship(profile.Tier);
            int              wieldDiff        = GetWield(profile.Tier, 3);
            WieldRequirement wieldRequirments = WieldRequirement.RawSkill;

            int eleType = ThreadSafeRandom.Next(0, 4);

            if (weaponType == -1)
            {
                weaponType = ThreadSafeRandom.Next(0, 3);
            }

            // Weapon Types
            // 0 = Heavy
            // 1 = Light
            // 2 = Finesse
            // default = Two Handed
            switch (weaponType)
            {
            case 0:
                // Heavy Weapons
                wieldSkillType = Skill.HeavyWeapons;
                int heavyWeaponsType = ThreadSafeRandom.Next(0, 22);
                weaponWeenie = LootTables.HeavyWeaponsMatrix[heavyWeaponsType][eleType];

                switch (heavyWeaponsType)
                {
                case 0:
                case 1:
                case 2:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 18);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 22);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Axe);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Axe);
                    break;

                case 3:
                case 4:
                case 5:
                    weaponDefense = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense = GetMaxDamageMod(profile.Tier, 20);

                    damage = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Dagger);

                    if (heavyWeaponsType == 3)
                    {
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.Dagger);
                    }
                    if (heavyWeaponsType == 4 || heavyWeaponsType == 5)
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.DaggerMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.DaggerMulti);
                    }
                    break;

                case 6:
                case 7:
                case 8:
                case 9:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 22);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 18);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Mace);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Mace);
                    break;

                case 10:
                case 11:
                case 12:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 15);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 25);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Spear);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Spear);
                    break;

                case 13:
                case 14:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 25);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 15);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Staff);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Staff);
                    break;

                case 15:
                case 16:
                case 17:
                case 18:
                case 19:
                case 20:
                    weaponDefense = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense = GetMaxDamageMod(profile.Tier, 20);

                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Sword);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Sword);

                    if (heavyWeaponsType == 20)
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.SwordMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.SwordMulti);
                    }
                    break;

                case 21:
                default:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.UA);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.UA);
                    break;
                }
                break;

            case 1:
                // Light Weapons;
                wieldSkillType = Skill.LightWeapons;
                int lightWeaponsType = ThreadSafeRandom.Next(0, 19);
                weaponWeenie = LootTables.LightWeaponsMatrix[lightWeaponsType][eleType];

                switch (lightWeaponsType)
                {
                case 0:
                case 1:
                case 2:
                case 3:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 18);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 22);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Axe);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Axe);
                    break;

                case 4:
                case 5:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.DaggerMulti);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.DaggerMulti);
                    break;

                case 6:
                case 7:
                case 8:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 22);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 18);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Mace);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Mace);
                    break;

                case 9:
                case 10:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 15);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 25);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Spear);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Spear);
                    break;

                case 11:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 25);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 15);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Staff);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Staff);
                    break;

                case 12:
                case 13:
                case 14:
                case 15:
                case 16:
                case 17:
                    weaponDefense = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense = GetMaxDamageMod(profile.Tier, 20);

                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Sword);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Sword);

                    if (lightWeaponsType == 14)
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.SwordMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.SwordMulti);
                    }
                    break;

                case 18:
                default:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.UA);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.UA);
                    break;
                }
                break;

            case 2:
                // Finesse Weapons;
                wieldSkillType = Skill.FinesseWeapons;
                int finesseWeaponsType = ThreadSafeRandom.Next(0, 22);
                weaponWeenie = LootTables.FinesseWeaponsMatrix[finesseWeaponsType][eleType];

                switch (finesseWeaponsType)
                {
                case 0:
                case 1:
                case 2:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 18);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 22);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Axe);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Axe);
                    break;

                case 3:
                case 4:
                case 5:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Dagger);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Dagger);

                    if (finesseWeaponsType == 3 || finesseWeaponsType == 4)
                    {
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.DaggerMulti);
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.DaggerMulti);
                    }
                    break;

                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 22);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 18);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Mace);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Mace);

                    if (finesseWeaponsType == 9)
                    {
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.Jitte);
                    }
                    break;

                case 11:
                case 12:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 15);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 25);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Spear);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Spear);
                    break;

                case 13:
                case 14:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 25);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 15);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Staff);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Staff);
                    break;

                case 15:
                case 16:
                case 17:
                case 18:
                case 19:
                case 20:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Sword);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Sword);

                    if (finesseWeaponsType == 15)
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.SwordMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.SwordMulti);
                    }
                    break;

                case 21:
                default:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.UA);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.UA);
                    break;
                }
                break;

            default:
                // Two handed
                wieldSkillType = Skill.TwoHandedCombat;
                int twoHandedWeaponsType = ThreadSafeRandom.Next(0, 11);
                weaponWeenie = LootTables.TwoHandedWeaponsMatrix[twoHandedWeaponsType][eleType];

                damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Cleaving);
                damageVariance = GetVariance(wieldSkillType, LootWeaponType.TwoHanded);

                switch (twoHandedWeaponsType)
                {
                case 0:
                case 1:
                case 2:
                    weaponDefense = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense = GetMaxDamageMod(profile.Tier, 20);
                    break;

                case 3:
                case 4:
                case 5:
                case 6:
                    weaponDefense = GetMaxDamageMod(profile.Tier, 22);
                    weaponOffense = GetMaxDamageMod(profile.Tier, 18);
                    break;

                case 7:
                    weaponDefense = GetMaxDamageMod(profile.Tier, 18);
                    weaponOffense = GetMaxDamageMod(profile.Tier, 22);
                    break;

                case 8:
                case 9:
                case 10:
                default:
                    weaponDefense = GetMaxDamageMod(profile.Tier, 15);
                    weaponOffense = GetMaxDamageMod(profile.Tier, 25);
                    damage        = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Spears);
                    break;
                }
                break;
            }

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject((uint)weaponWeenie);

            if (wo == null)
            {
                return(null);
            }


            // Description
            wo.AppraisalLongDescDecoration = longDescDecoration;
            wo.LongDesc = wo.Name;

            // GemTypes, Material, Workmanship
            wo.GemCount = gemCount;
            wo.GemType  = (MaterialType)gemType;
            int materialType = GetMaterialType(wo, profile.Tier);

            if (materialType > 0)
            {
                wo.MaterialType = (MaterialType)materialType;
            }
            wo.ItemWorkmanship = workmanship;

            // Weapon Stats
            wo.Damage               = damage;
            wo.DamageVariance       = damageVariance;
            wo.WeaponDefense        = weaponDefense;
            wo.WeaponOffense        = weaponOffense;
            wo.WeaponMissileDefense = missileD;
            wo.WeaponMagicDefense   = magicD;

            // Adding Wield Reqs if required
            if (wieldDiff > 0)
            {
                wo.WieldDifficulty   = wieldDiff;
                wo.WieldRequirements = wieldRequirments;
                wo.WieldSkillType    = (int)wieldSkillType;
            }
            else
            {
                // If no wield, remove wield reqs
                wo.WieldDifficulty   = null;
                wo.WieldRequirements = WieldRequirement.Invalid;
                wo.WieldSkillType    = null;
            }

            // Adding Magic Spells
            if (isMagical)
            {
                wo = AssignMagic(wo, profile);
            }
            else
            {
                // If no spells remove magic properites
                wo.ItemManaCost   = null;
                wo.ItemMaxMana    = null;
                wo.ItemCurMana    = null;
                wo.ItemSpellcraft = null;
                wo.ItemDifficulty = null;
            }

            double materialMod    = LootTables.getMaterialValueModifier(wo);
            double gemMaterialMod = LootTables.getGemMaterialValueModifier(wo);
            var    value          = GetValue(profile.Tier, workmanship, gemMaterialMod, materialMod);

            wo.Value = value;

            wo = RandomizeColor(wo);
            return(wo);
        }
Esempio n. 4
0
        private static bool MutateMeleeWeapon(WorldObject wo, TreasureDeath profile, bool isMagical)
        {
            if (!(wo is MeleeWeapon))
            {
                return(false);
            }

            Skill wieldSkillType = wo.WeaponSkill;

            int    damage         = 0;
            double damageVariance = 0;
            double weaponDefense  = 0;
            double weaponOffense  = 0;

            // Properties for weapons
            double magicD   = GetMagicMissileDMod(profile.Tier);
            double missileD = GetMagicMissileDMod(profile.Tier);

            int gemCount = 0;

            if (wo.GemCode != null)
            {
                gemCount = GemCountChance.Roll(wo.GemCode.Value, profile.Tier);
            }
            else
            {
                gemCount = ThreadSafeRandom.Next(1, 5);
            }

            MaterialType     gemType          = RollGemType(profile.Tier);
            int              workmanship      = GetWorkmanship(profile.Tier);
            int              wieldDiff        = GetWieldDifficulty(profile.Tier, WieldType.MeleeWeapon);
            WieldRequirement wieldRequirments = WieldRequirement.RawSkill;

            // Weapon Types
            // 0 = Heavy
            // 1 = Light
            // 2 = Finesse
            // default = Two Handed
            switch (wieldSkillType)
            {
            case Skill.HeavyWeapons:
                switch (wo.W_WeaponType)
                {
                case WeaponType.Axe:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 18);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 22);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Axe);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Axe);
                    break;

                case WeaponType.Dagger:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Dagger);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Dagger);

                    if (wo.W_AttackType.IsMultiStrike())
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.DaggerMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.DaggerMulti);
                    }
                    break;

                case WeaponType.Mace:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 22);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 18);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Mace);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Mace);
                    break;

                case WeaponType.Spear:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 15);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 25);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Spear);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Spear);
                    break;

                case WeaponType.Staff:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 25);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 15);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Staff);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Staff);
                    break;

                case WeaponType.Sword:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Sword);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Sword);

                    if (wo.W_AttackType.IsMultiStrike())
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.SwordMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.SwordMulti);
                    }
                    break;

                case WeaponType.Unarmed:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.UA);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.UA);
                    break;

                default:
                    return(false);
                }
                break;

            case Skill.LightWeapons:
                switch (wo.W_WeaponType)
                {
                case WeaponType.Axe:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 18);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 22);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Axe);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Axe);
                    break;

                case WeaponType.Dagger:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.DaggerMulti);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.DaggerMulti);

                    if (!wo.W_AttackType.IsMultiStrike())
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Dagger);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.Dagger);
                    }
                    break;

                case WeaponType.Mace:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 22);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 18);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Mace);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Mace);
                    break;

                case WeaponType.Spear:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 15);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 25);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Spear);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Spear);
                    break;

                case WeaponType.Staff:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 25);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 15);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Staff);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Staff);
                    break;

                case WeaponType.Sword:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Sword);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Sword);

                    if (wo.W_AttackType.IsMultiStrike())
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.SwordMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.SwordMulti);
                    }
                    break;

                case WeaponType.Unarmed:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.UA);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.UA);
                    break;

                default:
                    return(false);
                }
                break;

            case Skill.FinesseWeapons:
                switch (wo.W_WeaponType)
                {
                case WeaponType.Axe:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 18);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 22);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Axe);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Axe);
                    break;

                case WeaponType.Dagger:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Dagger);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Dagger);

                    if (wo.W_AttackType.IsMultiStrike())
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.DaggerMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.DaggerMulti);
                    }
                    break;

                case WeaponType.Mace:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 22);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 18);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Mace);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Mace);

                    if (wo.TsysMutationData == 101188610)         // Unique data to the five Jitte wcids for lootgen, within WeaponType.Mace class weapons
                    {
                        weaponDefense  = GetMaxDamageMod(profile.Tier, 25);
                        weaponOffense  = GetMaxDamageMod(profile.Tier, 15);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.Jitte);
                    }
                    break;

                case WeaponType.Spear:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 15);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 25);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Spear);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Spear);
                    break;

                case WeaponType.Staff:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 25);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 15);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Staff);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Staff);
                    break;

                case WeaponType.Sword:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Sword);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.Sword);

                    if (wo.W_AttackType.IsMultiStrike())
                    {
                        damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.SwordMulti);
                        damageVariance = GetVariance(wieldSkillType, LootWeaponType.SwordMulti);
                    }
                    break;

                case WeaponType.Unarmed:
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.UA);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.UA);
                    break;

                default:
                    return(false);
                }
                break;

            case Skill.TwoHandedCombat:
                if (wo.IsCleaving)
                {
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 18);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 22);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Cleaving);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.TwoHanded);
                }
                else
                {
                    weaponDefense  = GetMaxDamageMod(profile.Tier, 20);
                    weaponOffense  = GetMaxDamageMod(profile.Tier, 20);
                    damage         = GetMeleeMaxDamage(wieldSkillType, wieldDiff, LootWeaponType.Spears);
                    damageVariance = GetVariance(wieldSkillType, LootWeaponType.TwoHanded);
                }
                break;

            default:
                return(false);
            }

            wo.LongDesc = wo.Name;

            // GemTypes, Material, Workmanship
            wo.GemCount = gemCount;
            wo.GemType  = gemType;
            int materialType = GetMaterialType(wo, profile.Tier);

            if (materialType > 0)
            {
                wo.MaterialType = (MaterialType)materialType;
            }
            wo.ItemWorkmanship = workmanship;

            // Burden
            MutateBurden(wo, profile.Tier, true);

            // Weapon Stats
            wo.Damage               = damage;
            wo.DamageVariance       = damageVariance;
            wo.WeaponDefense        = weaponDefense;
            wo.WeaponOffense        = weaponOffense;
            wo.WeaponMissileDefense = missileD;
            wo.WeaponMagicDefense   = magicD;

            // Adding Wield Reqs if required
            if (wieldDiff > 0)
            {
                wo.WieldDifficulty   = wieldDiff;
                wo.WieldRequirements = wieldRequirments;
                wo.WieldSkillType    = (int)wieldSkillType;
            }
            else
            {
                // If no wield, remove wield reqs
                wo.WieldDifficulty   = null;
                wo.WieldRequirements = WieldRequirement.Invalid;
                wo.WieldSkillType    = null;
            }

            // Adding Magic Spells
            if (isMagical)
            {
                wo = AssignMagic(wo, profile);
            }
            else
            {
                // If no spells remove magic properites
                wo.ItemManaCost   = null;
                wo.ItemMaxMana    = null;
                wo.ItemCurMana    = null;
                wo.ItemSpellcraft = null;
                wo.ItemDifficulty = null;
            }

            double materialMod    = LootTables.getMaterialValueModifier(wo);
            double gemMaterialMod = LootTables.getGemMaterialValueModifier(wo);
            var    value          = GetValue(profile.Tier, workmanship, gemMaterialMod, materialMod);

            wo.Value = value;

            RandomizeColor(wo);

            return(true);
        }
        /// <summary>
        /// Creates Caster (Wand, Staff, Orb)
        /// </summary>
        public static WorldObject CreateCaster(int tier, bool isMagical, int wield = -1, bool forceWar = false)
        {
            // Refactored 11/20/19  - HarliQ

            int              casterWeenie       = 0;
            double           elementalDamageMod = 0;
            Skill            wieldSkillType     = Skill.None;
            WieldRequirement wieldRequirement   = WieldRequirement.RawSkill;
            int              subType            = 0;

            if (wield == -1)
            {
                wield = GetWield(tier, 2);
            }

            // Getting the caster Weenie needed.
            if (wield == 0)
            {
                // Determine plain caster type: 0 - Orb, 1 - Sceptre, 2 - Staff, 3 - Wand
                subType      = ThreadSafeRandom.Next(0, 3);
                casterWeenie = LootTables.CasterWeaponsMatrix[wield][subType];

                if (tier > 6)
                {
                    wieldRequirement = WieldRequirement.Level;
                    wieldSkillType   = Skill.Axe; // Set by examples from PCAP data

                    switch (tier)
                    {
                    case 7:
                        wield = 150;     // In this instance, used for indicating player level, rather than skill level
                        break;

                    default:
                        wield = 180;     // In this instance, used for indicating player level, rather than skill level
                        break;
                    }
                }
            }
            else
            {
                // Determine the Elemental Damage Mod amount
                elementalDamageMod = DetermineElementMod(wield);

                // Determine caster type: 1 - Sceptre, 2 - Baton, 3 - Staff
                int casterType = ThreadSafeRandom.Next(1, 3);

                // Determine element type: 0 - Slashing, 1 - Piercing, 2 - Blunt, 3 - Frost, 4 - Fire, 5 - Acid, 6 - Electric, 7 - Nether
                int element = forceWar ? ThreadSafeRandom.Next(0, 6) : ThreadSafeRandom.Next(0, 7);
                casterWeenie = LootTables.CasterWeaponsMatrix[casterType][element];

                // If element is Nether, Void Magic is required, else War Magic is required for all other elements
                if (element == 7)
                {
                    wieldSkillType = Skill.VoidMagic;
                }
                else
                {
                    wieldSkillType = Skill.WarMagic;
                }
            }

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject((uint)casterWeenie);

            // Why is this here?  Should not get a null object
            if (wo == null)
            {
                return(null);
            }