Ejemplo n.º 1
0
        public void DistributeArmorBonusEntries(int tier, ArmorProfile armor, int startEntry, int numberOfEntriesToProcess, int numOfRolls, eRandomFormula distribution)
        {
            for (int i = 0; i < numOfRolls; i++)
            {
                int roll = Utils.getRandomNumber(startEntry, startEntry + numberOfEntriesToProcess - 1, distribution, 2, 0);

                armor.Tiers[tier].Bonus[roll].Chance++;
            }
        }
Ejemplo n.º 2
0
 public void BuildArmor(ArmorProfile armor)
 {
     BuildArmorTier(armor, Tier.Tier1, ArmorBonus.Tier1, 0, eRandomFormula.favorMid);
     BuildArmorTier(armor, Tier.Tier2, ArmorBonus.Tier2, 0, eRandomFormula.favorMid);
     BuildArmorTier(armor, Tier.Tier3, ArmorBonus.Tier3, 0, eRandomFormula.favorMid);
     BuildArmorTier(armor, Tier.Tier4, ArmorBonus.Tier4, 0, eRandomFormula.favorMid);
     BuildArmorTier(armor, Tier.Tier5, ArmorBonus.Tier5, 0, eRandomFormula.favorMid);
     BuildArmorTier(armor, Tier.Tier6, ArmorBonus.Tier6, 0, eRandomFormula.favorMid);
     BuildArmorTier(armor, Tier.Tier7, ArmorBonus.Tier7, 150, eRandomFormula.favorLow);
     BuildArmorTier(armor, Tier.Tier8, ArmorBonus.Tier8, 180, eRandomFormula.favorLow);
 }
Ejemplo n.º 3
0
        public void ProcessArmorBonusEntries(ArmorProfile armor, int tier, int minBonus, int maxBonus, int wieldDificulty, int startEntry, int numberOfEntriesToProcess, int numOfRolls)
        {
            for (int i = startEntry; i < startEntry + numberOfEntriesToProcess; i++)
            {
                armor.Tiers[tier].Bonus[i].Chance /= (numOfRolls / 100);
                if (i == startEntry)
                {
                    armor.Tiers[tier].Bonus[i].Value = minBonus;
                }
                else if (i == numberOfEntriesToProcess - 1)
                {
                    armor.Tiers[tier].Bonus[i].Value = maxBonus;
                }
                else
                {
                    armor.Tiers[tier].Bonus[i].Value = (int)Math.Round((((maxBonus - minBonus) / ((float)numberOfEntriesToProcess - 1)) * (i - startEntry)) + minBonus);
                }

                armor.Tiers[tier].wieldDifficulty[i] = wieldDificulty;
            }
        }
Ejemplo n.º 4
0
        public void BuildArmorTier(ArmorProfile armor, Tier tier, ArmorBonus armorBonus, int wieldDifficulty, eRandomFormula distribution)
        {
            int minArmor = armor.MinArmorTier[(int)armorBonus];
            int maxArmor = armor.MaxArmorTier[(int)armorBonus];

            int numberOfEntries = ((maxArmor - minArmor) / 10) + 1;// DetermineNumberOfEntries(minArmor, maxArmor);

            //if (maxArmor <= 30)
            //    numberOfEntries *= 2;

            armor.Tiers[(int)tier].Bonus           = new ChanceEntry[numberOfEntries];
            armor.Tiers[(int)tier].wieldDifficulty = new int[numberOfEntries];

            int numOfRolls = 100000;

            DistributeArmorBonusEntries((int)tier, armor, 0, numberOfEntries, numOfRolls, distribution);

            ArmorBonusDistributionRounding((int)tier, armor, numberOfEntries);

            ProcessArmorBonusEntries(armor, (int)tier, minArmor, maxArmor, wieldDifficulty, 0, numberOfEntries, numOfRolls);

            float totalChance  = 0;
            int   entryCounter = 0;

            for (int i = 0; i < numberOfEntries; i++)
            {
                entryCounter++;
                totalChance += armor.Tiers[(int)tier].Bonus[i].Chance;
                if (DebugLevel > 1)
                {
                    Console.WriteLine($"Entry {entryCounter} Chance: {armor.Tiers[(int)tier].Bonus[i].Chance}% - ArmorBonus += {armor.Tiers[(int)tier].Bonus[i].Value}");
                }
            }

            if (DebugLevel > 1)
            {
                Console.WriteLine($"Total Chance: {totalChance}%");
            }
        }
Ejemplo n.º 5
0
        public void ArmorBonusDistributionRounding(int tier, ArmorProfile armor, int totalNumberOfEntries)
        {
            //Let's do some rounding so it looks better!
            float freeAmount = 0;

            for (int i = 0; i < totalNumberOfEntries; i++)
            {
                if (armor.Tiers[tier].Bonus[i].Chance > 10000)
                {
                    freeAmount += armor.Tiers[tier].Bonus[i].Chance % 1000;
                    armor.Tiers[tier].Bonus[i].Chance = (float)Math.Floor(armor.Tiers[tier].Bonus[i].Chance / 1000) * 1000;
                }
                else
                {
                    freeAmount += armor.Tiers[tier].Bonus[i].Chance % 100;
                    armor.Tiers[tier].Bonus[i].Chance = (float)Math.Floor(armor.Tiers[tier].Bonus[i].Chance / 100) * 100;

                    if ((armor.Tiers[tier].Bonus[i].Chance - 100) % 1000 == 0)
                    {
                        armor.Tiers[tier].Bonus[i].Chance -= 100;
                        freeAmount += 100;
                    }
                }
            }

            while (freeAmount >= 1000)
            {
                int roll = Utils.getRandomNumber(0, totalNumberOfEntries - 1, eRandomFormula.equalDistribution, 2, 0);

                armor.Tiers[tier].Bonus[roll].Chance += 1000;
                freeAmount -= 1000;
            }

            int fails         = 0;
            int fails2        = 0;
            int failThreshold = 10000;

            while (freeAmount >= 100)
            {
                int roll = Utils.getRandomNumber(0, totalNumberOfEntries - 1, eRandomFormula.equalDistribution, 2, 0);

                if (armor.Tiers[tier].Bonus[roll].Chance <3000 || fails> failThreshold * 10)
                {
                    if ((armor.Tiers[tier].Bonus[roll].Chance + 100) % 1000 == 0 || fails2 > failThreshold)
                    {
                        armor.Tiers[tier].Bonus[roll].Chance += 100;
                        freeAmount -= 100;
                        fails       = 0;
                        fails2      = 0;
                        continue;
                    }
                }

                fails++;
                fails2++;
            }

            while (freeAmount >= 10)
            {
                int roll = Utils.getRandomNumber(0, totalNumberOfEntries - 1, eRandomFormula.equalDistribution, 2, 0);

                armor.Tiers[tier].Bonus[roll].Chance += freeAmount;
                freeAmount -= freeAmount;
            }

            for (int i = 0; i < totalNumberOfEntries; i++)
            {
                if (armor.Tiers[(int)tier].Bonus[i].Chance % 100 == 99) // Fixes 1/3 + 1/3 + 1/3 turning into 0.99999 instead of 1.0
                {
                    armor.Tiers[(int)tier].Bonus[i].Chance++;
                }
            }

            if (DebugLevel > 0 && freeAmount > 0)
            {
                Console.WriteLine($"Unused freeAmount: {freeAmount}");
            }
        }
Ejemplo n.º 6
0
        public void BuildScripts()
        {
            Console.WriteLine($"Creating ACEmulator Mutation Scripts...");

            Armor  = new ArmorProfile("Armor");
            Shield = new ArmorProfile("Shield");

            //Armor.SetArmorTiers(  25, 50, 75, 100, 125, 150, 160, 170);
            //Shield.SetArmorTiers( 20, 40, 60,  80, 100, 120, 130, 140);

            // The last 2 tiers are made up for forward compatibility with loot tiers 7 and 8
            //Armor.SetMinArmorTiers(10,  40,  70,  90, 100, 100, 110, 120);
            //Armor.SetMaxArmorTiers(70, 100, 130, 150, 160, 160, 170, 180);

            //Shield.SetMinArmorTiers(10, 20, 30,  40,  50,  60, 70,  80);
            //Shield.SetMaxArmorTiers(50, 80, 90, 100, 110, 120, 130, 140);

            // Adjusted for better low tier balance?
            //Armor.SetMinArmorTiers(0,  10,  40,  70,  90, 100, 110, 120);
            //Armor.SetMaxArmorTiers(30, 70, 100, 130, 150, 160, 170, 180);

            //Shield.SetMinArmorTiers(0,  10, 30,  40,  50,  60,  70,  80);
            //Shield.SetMaxArmorTiers(20, 50, 80, 100, 110, 120, 130, 140);

            //BuildArmor(Armor);
            //BuildArmor(Shield);

            //WriteFile(Armor, 6);
            //WriteFile(Shield, 6);

            //Axe = new WeaponProfile("Axe", 0.40f, 0.50f);
            //Dagger = new WeaponProfile("Dagger", 0.30f, 0.75f);
            //Mace = new WeaponProfile("Mace", 0.25f, 0.50f);
            //Spear = new WeaponProfile("Spear", 0.45f, 0.75f);
            //Staff = new WeaponProfile("Staff", 0.25f, 0.50f);
            //Sword = new WeaponProfile("Sword", 0.40f, 0.50f);
            //Unarmed = new WeaponProfile("Unarmed", 0.50f, 0.75f);
            //Thrown = new WeaponProfile("Thrown", 0.40f, 0.50f);

            //DaggerMS = new WeaponProfile("DaggerMS", 0.71f, 0.75f);
            //SwordMS = new WeaponProfile("SwordMS", 0.40f, 0.50f);
            //MaceJitte = new WeaponProfile("MaceJitte", 0.25f, 0.50f);

            AxeTwoHanded   = new WeaponProfile("two_handed_axe", 0.40f, 0.50f);
            SpearTwoHanded = new WeaponProfile("two_handed_spear", 0.25f, 0.50f);
            SwordTwoHanded = new WeaponProfile("two_handed_sword", 0.40f, 0.50f);

            //// The last tier is made up for forward compatibility with loot tiers 7 and 8
            //Axe.SetDamageTiers(8, 17, 21, 25, 27, 31, 35, 39);
            //Dagger.SetDamageTiers(5, 7, 9, 11, 13, 17, 19, 21);
            ////Dagger.SetDamageTiers(3, 6, 9, 12, 14, 16, 18, 20);
            //Mace.SetDamageTiers(8, 16, 20, 24, 26, 28, 32, 36);
            //Spear.SetDamageTiers(7, 14, 16, 18, 22, 26, 30, 34);
            //Staff.SetDamageTiers(5, 7, 9, 11, 13, 17, 19, 21);
            //Sword.SetDamageTiers(10, 20, 25, 30, 35, 40, 45, 50);
            //Unarmed.SetDamageTiers(4, 7, 9, 12, 16, 18, 22, 24);
            //Thrown.SetDamageTiers(6, 8, 12, 16, 20, 24, 28, 32);

            //DaggerMS.SetDamageTiers(3, 0, 0, 0, 0, 0, 0, 0);
            //SwordMS.SetDamageTiers(5, 0, 0, 0, 0, 0, 0, 0);
            ////SwordMS.SetDamageTiers(9, 6, 8, 10, 13, 15, 18, 20);
            //MaceJitte.SetDamageTiers(8, 16, 20, 24, 26, 28, 32, 36);

            AxeTwoHanded.SetDamageTiers(3, 6, 7, 8, 9, 10, 12, 14);
            SpearTwoHanded.SetDamageTiers(3, 6, 7, 8, 9, 10, 12, 14);
            SwordTwoHanded.SetDamageTiers(4, 7, 8, 10, 11, 13, 15, 17);

            //BuildWeapon(Axe);
            //BuildWeapon(Dagger);
            //BuildWeapon(Mace);
            //BuildWeapon(Spear);
            //BuildWeapon(Staff);
            //BuildWeapon(Sword);
            //BuildWeapon(Unarmed);
            //BuildWeapon(Thrown);

            //BuildWeapon(DaggerMS);
            //BuildWeapon(SwordMS);
            //BuildWeapon(MaceJitte);

            BuildWeapon(AxeTwoHanded);
            BuildWeapon(SpearTwoHanded);
            BuildWeapon(SwordTwoHanded);

            //WriteFile(Axe, 6);
            //WriteFile(Dagger, 6);
            //WriteFile(Mace, 6);
            //WriteFile(Spear, 6);
            //WriteFile(Staff, 6);
            //WriteFile(Sword, 6);
            //WriteFile(Unarmed, 6);
            //WriteFile(Thrown, 6);

            //WriteFile(DaggerMS, 6);
            //WriteFile(SwordMS, 6);
            //WriteFile(MaceJitte, 6);

            WriteFile(AxeTwoHanded, 6);
            WriteFile(SpearTwoHanded, 6);
            WriteFile(SwordTwoHanded, 6);
        }
Ejemplo n.º 7
0
        public void WriteFile(ArmorProfile armor, int maxLootTier = 6)
        {
            string armorString        = armor.ArmorName.ToLower();
            string convertedArmorName = armorString;

            if (armorString == "armor")
            {
                convertedArmorName = "armor_level";
            }
            else if (armorString == "shield")
            {
                convertedArmorName = "shield_level";
            }

            string filename = $".\\ACEmulator Mutations\\ArmorLevel\\Infiltration\\{convertedArmorName}.txt";

            StreamWriter outputFile = new StreamWriter(new FileStream(filename, FileMode.Create, FileAccess.Write));

            if (outputFile == null)
            {
                Console.WriteLine($"Unable to open {filename}.");
                return;
            }

            Console.WriteLine($"Writing {filename}.");

            int mutationCounter = 0;

            maxLootTier = Math.Min(armor.Tiers.Length, maxLootTier);
            for (int i = 0; i < maxLootTier; i++)
            {
                mutationCounter++;
                outputFile.WriteLine($"{armor.ArmorName} Mutation #{mutationCounter}:");
                outputFile.WriteLine();
                outputFile.Write("Tier Chances: ");
                for (int tier = 0; tier < maxLootTier; tier++)
                {
                    outputFile.Write(tier == i ? 1 : 0);
                    if (tier + 1 < maxLootTier)
                    {
                        outputFile.Write(", ");
                    }
                    else
                    {
                        outputFile.Write("\n");
                    }
                }
                //outputFile.WriteLine($"Tier Chances: {(i == 0 ? 1 : 0)}, {(i == 1 ? 1 : 0)}, {(i == 2 ? 1 : 0)}, {(i == 3 ? 1 : 0)}, {(i == 4 ? 1 : 0)}, {(i == 5 ? 1 : 0)}, {(i == 6 ? 1 : 0)}, {(i == 7 ? 1 : 0)}");
                outputFile.WriteLine();

                for (int j = 0; j < armor.Tiers[i].Bonus.Length; j++)
                {
                    outputFile.WriteLine($"    - Chance: {armor.Tiers[i].Bonus[j].Chance}%:");
                    outputFile.WriteLine($"        ArmorLevel += {armor.Tiers[i].Bonus[j].Value}");
                    if (armor.Tiers[i].wieldDifficulty[j] > 0)
                    {
                        outputFile.WriteLine($"        WieldRequirements = {armor.Tiers[i].WieldRequirements}");
                        outputFile.WriteLine($"        WieldSkillType = { armor.Tiers[i].WieldSkillType}");
                        outputFile.WriteLine($"        WieldDifficulty = { armor.Tiers[i].wieldDifficulty[j]}");
                    }
                    outputFile.WriteLine();
                }

                outputFile.Flush();
            }

            // Extra armor roll
            mutationCounter++;
            outputFile.WriteLine($"{armor.ArmorName} Mutation #{mutationCounter}:");
            outputFile.WriteLine();
            outputFile.WriteLine($"Tier chances: 1, 1, 1, 1, 1, 1, 1, 1");
            outputFile.WriteLine();

            outputFile.WriteLine($"    - Chance: 100%:");
            outputFile.WriteLine($"        ArmorLevel += Random(-5, 5)");

            outputFile.Close();
        }