Beispiel #1
0
 public Item(
     string _name,
     ItemContextInfo info  = ItemContextInfo.None,
     Rarity rare           = Rarity.None,
     ItemType ty           = ItemType.None,
     ItemBonusContext bo   = ItemBonusContext.None,
     ItemExtraStat _st     = null,
     ItemEfficientClass ec = ItemEfficientClass.None,
     ItemData data         = null
     )
 {
     Name   = _name ?? "None";
     Info   = info;
     Rarity = rare;
     Type   = ty;
     Bonus  = bo;
     if (_st is null)
     {
         ExtraStat = ItemExtraStat.NoExtraStat;
     }
     EfficientClass = ec;
     if (data is null)
     {
         Data = ItemData.IncompleteItemData;
     }
 }
Beispiel #2
0
        // todo: names
        public static Item GenerateRandomItem(byte playerLevel, ItemEfficientClass efficientClass)
        {
            double levelAsTenth = playerLevel * 0.01;

            Rarity randomRarity = Globals.GetRandomEnum <Rarity>();

            if (randomRarity == Rarity.Developer || randomRarity == Rarity.None)
            {
                return(GenerateRandomItem(playerLevel, efficientClass));
            }

            ItemContextInfo randomContextInfo = Globals.GetRandomEnum <ItemContextInfo>();

            if (randomContextInfo == ItemContextInfo.None)
            {
                return(GenerateRandomItem(playerLevel, efficientClass));
            }

            ItemType randomType = Globals.GetRandomEnum <ItemType>();

            if (randomType == ItemType.None)
            {
                return(GenerateRandomItem(playerLevel, efficientClass));
            }

            if ((randomType == ItemType.Helmet ||
                 randomType == ItemType.Chestplate ||
                 randomType == ItemType.Gauntlets ||
                 randomType == ItemType.Pants ||
                 randomType == ItemType.Boots) &&
                (randomContextInfo != ItemContextInfo.NormalArmor ||
                 randomContextInfo != ItemContextInfo.OffensiveArmor ||
                 randomContextInfo != ItemContextInfo.TankyArmor))
            {
                if (randomContextInfo == ItemContextInfo.NormalCharm || randomContextInfo == ItemContextInfo.NormalWeapon)
                {
                    randomContextInfo = ItemContextInfo.NormalArmor;
                }
                else if (randomContextInfo == ItemContextInfo.StrongWeapon || randomContextInfo == ItemContextInfo.DamagingCharm)
                {
                    randomContextInfo = ItemContextInfo.OffensiveArmor;
                }
                else if (randomContextInfo == ItemContextInfo.ParryingWeapon || randomContextInfo == ItemContextInfo.ShieldingCharm)
                {
                    randomContextInfo = ItemContextInfo.TankyArmor;
                }
            }
            else if ((randomType == ItemType.Primary || randomType == ItemType.Secondary) &&
                     (randomContextInfo != ItemContextInfo.NormalWeapon ||
                      randomContextInfo != ItemContextInfo.ParryingWeapon ||
                      randomContextInfo != ItemContextInfo.StrongWeapon))
            {
                if (randomContextInfo == ItemContextInfo.NormalArmor || randomContextInfo == ItemContextInfo.NormalCharm)
                {
                    randomContextInfo = ItemContextInfo.NormalWeapon;
                }
                else if (randomContextInfo == ItemContextInfo.OffensiveArmor || randomContextInfo == ItemContextInfo.DamagingCharm)
                {
                    randomContextInfo = ItemContextInfo.StrongWeapon;
                }
                else if (randomContextInfo == ItemContextInfo.TankyArmor || randomContextInfo == ItemContextInfo.ShieldingCharm)
                {
                    randomContextInfo = ItemContextInfo.ParryingWeapon;
                }
            }
            else if ((randomType == ItemType.Charm) &&
                     (randomContextInfo != ItemContextInfo.NormalCharm ||
                      randomContextInfo != ItemContextInfo.DamagingCharm ||
                      randomContextInfo != ItemContextInfo.ShieldingCharm))
            {
                if (randomContextInfo == ItemContextInfo.NormalArmor || randomContextInfo == ItemContextInfo.NormalWeapon)
                {
                    randomContextInfo = ItemContextInfo.NormalCharm;
                }
                else if (randomContextInfo == ItemContextInfo.OffensiveArmor || randomContextInfo == ItemContextInfo.StrongWeapon)
                {
                    randomContextInfo = ItemContextInfo.DamagingCharm;
                }
                else if (randomContextInfo == ItemContextInfo.TankyArmor || randomContextInfo == ItemContextInfo.ParryingWeapon)
                {
                    randomContextInfo = ItemContextInfo.ShieldingCharm;
                }
            }

            ItemBonusContext randomBonusContext = Globals.GetRandomEnum <ItemBonusContext>();

            if (randomBonusContext != ItemBonusContext.None && playerLevel < Globals.Rnd.Next(0, 10) + Globals.Rnd.Next(0, 13))
            {
                randomBonusContext = ItemBonusContext.None;
            }
            else if (randomBonusContext == ItemBonusContext.None && playerLevel > 50)
            {
                randomBonusContext = Globals.GetRandomEnum <ItemBonusContext>();
            }

            if (playerLevel <= 84 && randomRarity == Rarity.Extraordinary)
            {
                DecrementEnum(ref randomRarity);
            }

            if (playerLevel <= 67 && randomRarity == Rarity.Mythical)
            {
                DecrementEnum(ref randomRarity);
            }

            if (playerLevel <= 54 && randomRarity == Rarity.Fabled)
            {
                DecrementEnum(ref randomRarity);
            }

            if (playerLevel <= 39 && randomRarity == Rarity.Legendary)
            {
                DecrementEnum(ref randomRarity);
            }

            if (playerLevel <= 26 && randomRarity == Rarity.Epic)
            {
                DecrementEnum(ref randomRarity);
            }

            if (playerLevel <= 17 && randomRarity == Rarity.Rare)
            {
                DecrementEnum(ref randomRarity);
            }

            if (playerLevel <= 12 && randomRarity == Rarity.Refined)
            {
                DecrementEnum(ref randomRarity);
            }

            if (playerLevel <= 7 && randomRarity == Rarity.Uncommon)
            {
                DecrementEnum(ref randomRarity);
            }

            if (playerLevel <= 3 && randomRarity == Rarity.Common)
            {
                DecrementEnum(ref randomRarity);
            }

            if (Globals.Rnd.NextDouble() - (levelAsTenth / 5) < levelAsTenth * 2 && randomRarity != Rarity.Extraordinary)
            {
                IncrementEnum(ref randomRarity);
            }

            if ((randomContextInfo != ItemContextInfo.NormalArmor ||
                 randomContextInfo != ItemContextInfo.NormalCharm ||
                 randomContextInfo != ItemContextInfo.NormalWeapon) && playerLevel < Globals.Rnd.Next(0, 8) + Globals.Rnd.Next(0, 11))
            {
                if (randomType == ItemType.Helmet ||
                    randomType == ItemType.Chestplate ||
                    randomType == ItemType.Gauntlets ||
                    randomType == ItemType.Pants ||
                    randomType == ItemType.Boots)
                {
                    randomContextInfo = ItemContextInfo.NormalArmor;
                }
                else if (randomType == ItemType.Primary || randomType == ItemType.Secondary)
                {
                    randomContextInfo = ItemContextInfo.NormalWeapon;
                }
                else
                {
                    randomContextInfo = ItemContextInfo.NormalCharm;
                }
            }

            Item toReturn = new Item(
                // Implement random name list
                "placeholdername",
                randomContextInfo,
                randomRarity,
                randomType,
                randomBonusContext,
                ItemExtraStat.GetRandomItemExtraStat(playerLevel), // Item extra stat
                Globals.GetRandomEnum <ItemEfficientClass>(),      // Item efficient class
                ItemData.IncompleteItemData
                );

            return(new Item(toReturn, ItemData.GetItemData(toReturn, playerLevel, efficientClass)));
        }
Beispiel #3
0
        public static ItemData GetItemData(Item item, byte playerLevel, ItemEfficientClass efficientClass = ItemEfficientClass.None)
        {
            ItemData returnValue = new ItemData();

            double rarityMultiplier;
            double scaleMulti = playerLevel * (Globals.ScaleMultiBase - (Globals.Rnd.NextDouble() + 0.1)) / 1.789;

            switch (item.Rarity)
            {
            case Rarity.Trash:
                rarityMultiplier      = 0.5;
                returnValue.ItemValue = playerLevel / 10 > 1 ? playerLevel / 10 : 1.1;
                break;

            case Rarity.Common:
                rarityMultiplier      = 1.0;
                returnValue.ItemValue = playerLevel / 2 > 2 ? playerLevel / 2 : 2.2;
                break;

            case Rarity.Uncommon:
                rarityMultiplier      = 1.09;
                returnValue.ItemValue = playerLevel + Globals.Rnd.Next(1, 3);
                break;

            case Rarity.Refined:
                rarityMultiplier      = 1.14;
                returnValue.ItemValue = playerLevel + (playerLevel / 2) + Globals.Rnd.Next(2, 5);
                break;

            case Rarity.Rare:
                rarityMultiplier      = 1.28;
                returnValue.ItemValue = (playerLevel * 2) + Globals.Rnd.Next(3, 6);
                break;

            case Rarity.Epic:
                rarityMultiplier      = 1.43;
                returnValue.ItemValue = (playerLevel * 3) + Globals.Rnd.Next(4, 8);
                break;

            case Rarity.Legendary:
                rarityMultiplier      = 1.76;
                returnValue.ItemValue = (playerLevel * 5) + Globals.Rnd.Next(7, 13);
                break;

            case Rarity.Fabled:
                rarityMultiplier      = 2.44;
                returnValue.ItemValue = (playerLevel * 6) + Globals.Rnd.Next(10, 19);
                break;

            case Rarity.Mythical:
                rarityMultiplier      = 3.11;
                returnValue.ItemValue = (playerLevel * 7) + Globals.Rnd.Next(15, 26);
                break;

            case Rarity.Extraordinary:
                rarityMultiplier      = 4.22;
                returnValue.ItemValue = (playerLevel * 8) + Globals.Rnd.Next(21, 33);
                break;

            case Rarity.Developer:
                rarityMultiplier      = 12.66;
                returnValue.ItemValue = (playerLevel * 10) + Globals.Rnd.Next(43, 65);
                break;

            case Rarity.None:
                return(null);

            default:
                return(null);
            }

            returnValue.ItemValue += Globals.RoundSlightly(scaleMulti * rarityMultiplier) / 8;

            switch (item.Info)
            {
            case ItemContextInfo.NormalArmor:
                returnValue.Defense = Globals.RoundSlightly(Globals.Rnd.Next(0, playerLevel / 6) + playerLevel / 4 + (playerLevel / 2) * scaleMulti * rarityMultiplier);
                returnValue.Damage  = Globals.RoundSlightly(playerLevel / 6) > 1 ? Globals.RoundSlightly(playerLevel / 8) : 0;
                break;

            case ItemContextInfo.NormalWeapon:
                returnValue.Damage     = Globals.RoundSlightly(playerLevel / 2 * scaleMulti * rarityMultiplier);
                returnValue.CritChance = Globals.RoundSlightly((scaleMulti * rarityMultiplier * 1.14) + 0.18);
                returnValue.CritDamage = Globals.RoundSlightly(scaleMulti * rarityMultiplier * 4.2);
                break;

            case ItemContextInfo.NormalCharm:
                double toChoose = Globals.Rnd.NextDouble();
                if (toChoose <= 0.251)
                {
                    returnValue.Damage = Globals.RoundSlightly(1.55 + (playerLevel / 4) * scaleMulti * rarityMultiplier);
                }
                else if (toChoose > 0.252 && toChoose <= 0.501)
                {
                    returnValue.Defense = Globals.RoundSlightly(0.76 + (playerLevel / 5) * scaleMulti * rarityMultiplier);
                }
                else if (toChoose > 0.502 && toChoose <= 0.751)
                {
                    returnValue.CritChance = Globals.RoundSlightly(0.63 + (playerLevel / 6) * scaleMulti * rarityMultiplier);
                }
                else if (toChoose > 0.752)
                {
                    returnValue.CritDamage = Globals.RoundSlightly(1.22 + (playerLevel / 4.5) * scaleMulti * rarityMultiplier);
                }
                break;

            case ItemContextInfo.TankyArmor:
                returnValue.Defense = Globals.RoundSlightly((Globals.Rnd.Next(0, playerLevel / 4) + playerLevel) * scaleMulti * rarityMultiplier) + Globals.Rnd.Next(0, playerLevel);
                break;

            case ItemContextInfo.OffensiveArmor:
                returnValue.Defense    = Globals.RoundSlightly(playerLevel / 2 * scaleMulti * rarityMultiplier);
                returnValue.CritChance = Globals.RoundSlightly((scaleMulti * rarityMultiplier * 0.59) + 0.06);
                returnValue.CritDamage = Globals.RoundSlightly((scaleMulti * rarityMultiplier) / 3 * 1.45);
                break;

            case ItemContextInfo.ParryingWeapon:
                returnValue.Damage     = Globals.RoundSlightly(playerLevel / 1.6 * scaleMulti * rarityMultiplier);
                returnValue.CritChance = Globals.RoundSlightly((scaleMulti * rarityMultiplier) + 0.12);
                returnValue.CritDamage = Globals.RoundSlightly(scaleMulti * rarityMultiplier * 3.3);
                returnValue.Defense    = Globals.RoundSlightly(playerLevel / 3 * scaleMulti * rarityMultiplier);
                break;

            case ItemContextInfo.StrongWeapon:
                returnValue.Damage     = Globals.RoundSlightly(Globals.Rnd.Next(0, playerLevel / 3) + playerLevel / 3.6 + playerLevel / 1.9 * scaleMulti * rarityMultiplier);
                returnValue.CritChance = Globals.RoundSlightly((scaleMulti * rarityMultiplier * 1.21) + 0.24);
                returnValue.CritDamage = Globals.RoundSlightly(scaleMulti * rarityMultiplier * 4.787);
                break;

            case ItemContextInfo.DamagingCharm:
                returnValue.Damage     = Globals.RoundSlightly(1.989 + (playerLevel / 3.45) * scaleMulti * rarityMultiplier);
                returnValue.CritChance = Globals.RoundSlightly(0.69 + (playerLevel / 5.6789) * scaleMulti * rarityMultiplier);
                returnValue.CritDamage = Globals.RoundSlightly(1.556567 + (playerLevel / 4.2) * scaleMulti * rarityMultiplier);
                break;

            case ItemContextInfo.ShieldingCharm:
                returnValue.Defense = Globals.RoundSlightly(1.43278 + (playerLevel / 4.45678901) * scaleMulti * rarityMultiplier);
                break;

            case ItemContextInfo.None:
                return(null);

            default:
                return(null);
            }


            if (efficientClass == item.EfficientClass)
            {
                returnValue.CritChance += Globals.RoundSlightly(returnValue.CritChance * Globals.ClassEfficiencyPercentBonus);
                returnValue.CritDamage += Globals.RoundSlightly(returnValue.CritDamage * Globals.ClassEfficiencyPercentBonus);
                returnValue.Damage     += Globals.RoundSlightly(returnValue.Damage * Globals.ClassEfficiencyPercentBonus);
                returnValue.Defense    += Globals.RoundSlightly(returnValue.Defense * Globals.ClassEfficiencyPercentBonus);
                returnValue.ItemValue  += returnValue.ItemValue * (Globals.ClassEfficiencyPercentBonus / 2.4);
            }

            return(returnValue);
        }