Exemplo n.º 1
0
        public static string TurnIntoMagic(MagicAllowed.MagicAllow magicProps, int quality)
        {
            switch (magicProps.MagicType)
            {
            case "cloth":
                return(doClothSkillModifier(magicProps.Name, quality));

            case "armor":
            case "shield":
                return(makeArmorMagical(magicProps, quality));

            case "instrument":
                return(doInstrumentModifier(magicProps.Name, quality));

            case "tool":
            case "wand":
                return(addCharges(magicProps, quality));

            case "weapon":
                return(makeWeaponMagical(magicProps, quality));

            case "jewel":
                return(doJewelSkillModifier(magicProps.Name, quality));
            }

            return(null);
        }
Exemplo n.º 2
0
        private static void MakeMagicItem(string group, int quality, int chance)
        {
            if (Dice.getRandom(1, 100) <= chance)
            {
                ItemGroup itemGroup = getItemGroupByName(group);

                if (itemGroup == null)
                {
                    _warnings.Add("Magic: Could not find item group of '" + group + "'");
                    return;
                }



                MagicAllowed.MagicAllow magicProps = null;
                int iterations = 0;

                string nameOfItemToBeDropped = "";

                // run the loop until finding the item that is allowed to be magic and return what type of magic
                while (magicProps == null)
                {
                    int itemOutOfGroup = Dice.getRandom(0, itemGroup.Items.Count() - 1);
                    nameOfItemToBeDropped = itemGroup.Items[itemOutOfGroup];

                    if (!isValidItem(nameOfItemToBeDropped))
                    {
                        _warnings.Add(string.Format("Magic: Item '{0}' in item group '{1}' is not valid!", nameOfItemToBeDropped, itemGroup.Name));
                    }
                    else
                    {
                        magicProps = Magic.MagicAllowedAndType(itemGroup.Items[itemOutOfGroup]);
                    }

                    iterations++;
                    if (iterations >= 100)
                    {
                        _warnings.Add("Could not find allowed magic item in 100 iterations in item group '" + itemGroup.Name + "' latest item '" + nameOfItemToBeDropped + "'");
                        _warnings.Add("dbg: Items in MagicAllowed.AllowedMagicItems " + MagicAllowed.AllowedMagicItems.Count());
                        //iterations = 0;
                        //magicProps = null;
                        return;
                    }
                }

                if (magicProps != null)
                {
                    string eventualItemName = Magic.TurnIntoMagic(magicProps, quality);

                    if (eventualItemName != null)
                    {
                        addToBag(eventualItemName, 1);
                    }
                    else
                    {
                        _warnings.Add(string.Format("Magic: Item '{0}' in item group '{1}' has configuration error!", nameOfItemToBeDropped, itemGroup.Name));
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static string addCharges(MagicAllowed.MagicAllow magicProps, int quality)
        {
            string itemName = magicProps.Name;

            switch (magicProps.MagicType)
            {
            case "wand":
                int chargeQuality = determineMagicModifier(quality, false);
                int wandCharges   = 0;

                int wandType = Dice.getRandom(1, 17);     // get wand type between 1-16

                switch (wandType)
                {
                case 1:
                    wandCharges = (chargeQuality / 3) + 10;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Nightsight", wandCharges));

                case 2:
                    wandCharges = (chargeQuality / 5) + 10;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Blessing", wandCharges));

                case 3:
                    wandCharges = (chargeQuality / 5) + 10;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Strength", wandCharges));

                case 4:
                    wandCharges = (chargeQuality / 5) + 10;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Agility", wandCharges));

                case 5:
                    wandCharges = (Dice.getRandom(0, chargeQuality) + 20) / 2;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Cunning", wandCharges));

                case 6:
                    wandCharges = (Dice.getRandom(0, chargeQuality) + 20) / 2;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Curing", wandCharges));

                case 7:
                    wandCharges = (Dice.getRandom(0, chargeQuality) + 20) / 2;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Protection", wandCharges));

                case 8:
                    wandCharges = (Dice.getRandom(0, chargeQuality) + 20) / 2;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Healing", wandCharges));

                case 9:
                case 10:
                    wandCharges = (Dice.getRandom(0, chargeQuality) + 20) / 5;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Life", wandCharges));

                case 11:
                case 12:
                    wandCharges = (Dice.getRandom(0, chargeQuality) + 20) / 5;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Fireball", wandCharges));

                case 13:
                case 14:
                case 15:
                    wandCharges = (Dice.getRandom(0, chargeQuality) + 20) / 5;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Lightning", wandCharges));

                case 16:
                case 17:
                    wandCharges = (Dice.getRandom(0, chargeQuality) + 10) / 5;
                    return(string.Format("{0} {1} ({2})", itemName, "Of Hellfire", wandCharges));
                }
                break;

            case "tool":
                // making tools more rare, 10% chance of actually getting one...
                if (Dice.getRandom(1, 100) <= MAGIC_TOOL_CHANCE)
                {
                    int toolModifier = determineMagicModifier(quality, true);

                    // higher modifier equals less charges
                    int toolCharges = 300 - (toolModifier * 30) - Dice.getRandom(0, toolModifier * 40);

                    // limit lowest charges to 10
                    if (toolCharges < 10)
                    {
                        toolCharges = 10;
                    }

                    return(string.Format("{0} {1} ({2})", GetQualityModifierName(toolModifier), itemName, toolCharges));
                }
                else
                {
                    return(itemName);    // Tool won't be modifed to magic
                }
            }

            // should never reach here is config is correct
            return(null);
        }
Exemplo n.º 4
0
        private static string makeArmorMagical(MagicAllowed.MagicAllow magicProps, int quality)
        {
            // quality of an item (subs - indy)
            int qualityModifier = determineMagicModifier(quality, true);

            // suffix of an item (defense - invul)
            int suffixModifier = determineMagicModifier(quality, true);

            // effect quality
            int effectModifier = determineMagicModifier(quality, false);


            bool hasQuality = false;
            bool hasSuffix  = false;

            // you'll have 1 out 6 chance of having quality on an item
            if (Dice.getRandom(1, 6) == 1)
            {
                hasQuality = true;
            }

            string itemName = magicProps.Name;

            // you'll have 1 out of 10 chance of having suffix on an item
            if (Dice.getRandom(1, 10) == 10)
            {
                hasSuffix = true;
            }


            switch (magicProps.Effect)
            {
            case "ore":
                // try and add ore modifier to an item
                itemName = doOreModifier(itemName, effectModifier, hasQuality, (magicProps.MagicType == "armor") ? ARMOR_ORE_COLOR_CHANCE : SHIELD_ORE_COLOR_CHANCE);
                break;

            case "leather":
                // try and add leather modifier to an item
                itemName = doLeatherModifier(itemName, effectModifier, hasQuality, ARMOR_LEATHER_COLOR_CHANCE);
                break;

            case "bone":
                // try and add bone modifier to an item
                itemName = doBoneModifier(itemName, effectModifier, hasQuality, ARMOR_BONE_COLOR_CHANCE);
                break;
            }


            // if we have suffix to be added
            if (hasSuffix)
            {
                if (magicProps.MagicType == "armor")
                {
                    // make forti armors more rare.. having 50% chance of lowering the tier by one
                    if (suffixModifier == 4 && Dice.getRandom(1, 2) != 1)
                    {
                        suffixModifier--;
                    }

                    // make invul armors more rare.. having 90% chance of lowering the tier by one
                    if (suffixModifier == 5 && Dice.getRandom(1, 10) != 1)
                    {
                        suffixModifier--;
                    }
                }

                if (magicProps.MagicType == "shield")
                {
                    // make forti and invul shields more rare, having 90% chance of lowering by 2 tiers
                    if (suffixModifier >= 5 && Dice.getRandom(1, 10) != 1)
                    {
                        suffixModifier -= 2;
                    }
                }

                // add suffix to the item name
                itemName = string.Format("{0} Of {1}", itemName, GetAmorSuffix(suffixModifier));
            }

            if (hasQuality)
            {
                itemName = string.Format("{0} {1}", GetQualityModifierName(qualityModifier), itemName);
            }

            // return item name
            return(itemName);
        }
Exemplo n.º 5
0
        private static string makeWeaponMagical(MagicAllowed.MagicAllow magicProps, int quality)
        {
            string itemName = magicProps.Name;

            // get weapon(quality) modifier
            int weaponModifier = determineMagicModifier(quality, true);

            // remember 75% of determineMagicModifer is random, so we'll
            // generate new number for suffix modifier
            int suffixModifier = determineMagicModifier(quality, true);

            // remember 75% of determineMagicModifer is random, so we'll
            // generate new number for elemental modifier
            int elementalModifier = determineMagicModifier(quality, true);

            int effectQuality = determineMagicModifier(quality, false);

            bool hasQuality = false;

            bool hasElementalMod = false;

            bool hasSuffix = false;

            // 1 out of 15 chance to get only ore modification, otherwise try and add mod's
            if (Dice.getRandom(1, 15) == 1 && magicProps.Effect == "ore")
            {
                return(doOreModifier(itemName, quality, false, 100));
            }
            else
            {
                // ----- 1st modifier --------
                // 2 out of 5 chance for quality,
                // 1 out of 5 for elemental modifier,
                // 2 out of 5 for suffix
                int rand = Dice.getRandom(1, 5);

                switch (rand)
                {
                case 1:
                case 2:
                    // 1-2 == quality
                    hasQuality = true;
                    break;

                case 3:
                    // 3 == elemental
                    hasElementalMod = true;
                    break;

                default:
                    // 4-5 == suffix
                    hasSuffix = true;
                    break;
                }

                // ----- 2nd modifier --------
                // 1 out of 7 chance for having extra upgrade
                if (Dice.getRandom(1, 7) == 7)
                {
                    // goes same, do until we have value that was not added with 1st modifier
                    // 2 out of 5 chance for quality,
                    // 1 out of 5 for elemental modifier,
                    // 2 out of 5 for suffix
                    bool correctValueFound = false;
                    while (!correctValueFound)
                    {
                        rand = Dice.getRandom(1, 5);

                        switch (rand)
                        {
                        case 1:
                        case 2:
                            if (!hasQuality)
                            {
                                correctValueFound = true;     // it did not get quality with 1st modifier, add it now
                            }
                            break;

                        case 3:
                            if (!hasElementalMod)
                            {
                                correctValueFound = true;     // it did not get element with 1st modifier, add it now
                            }
                            break;

                        default:
                            if (!hasSuffix)
                            {
                                correctValueFound = true; // it did not get suffix with 1st modifier, add it now
                            }
                            break;                        // neither mod will be added
                        }
                    }
                }


                // 1 out of 10 chance of getting all upgrades
                if (Dice.getRandom(1, 10) == 10)
                {
                    hasQuality      = true;
                    hasElementalMod = true;
                    hasSuffix       = true;
                }

                switch (magicProps.Effect)
                {
                case "ore":
                    // try and add ore modification
                    itemName = doOreModifier(itemName, effectQuality, (hasQuality || hasElementalMod) ? true : false, WEAPON_ORE_COLOR_CHANCE);
                    break;

                case "wood":
                    // try and add wood modification
                    itemName = doWoodModifier(itemName, effectQuality, (hasQuality || hasElementalMod) ? true : false, WEAPON_WOOD_COLOR_CHANCE);
                    break;
                }


                if (hasElementalMod)
                {
                    itemName = string.Format("{0} {1}", doElementalModifier(elementalModifier, hasQuality), itemName);
                }

                if (hasQuality)
                {
                    // check if we had luck with color roll
                    if (!hasElementalMod)
                    {
                        itemName = string.Format("{0} {1}", GetQualityModifierName(weaponModifier), itemName);
                    }
                    else
                    {
                        itemName = string.Format("{0} And {1}", GetQualityModifierName(weaponModifier), itemName);
                    }
                }

                if (hasSuffix)
                {
                    itemName = string.Format("{0} Of {1}", itemName, getWeaponSuffix(suffixModifier));
                }


                // Will we add charges? 1 out of 10
                if (Dice.getRandom(1, 10) == 1)
                {
                    string chargeSuffix = "";
                    int    charges      = 0;

                    // roll of what charges will be applied
                    switch (Dice.getRandom(1, 14))
                    {
                    case 1:
                    case 2:
                        chargeSuffix = "Feeblemindedness";
                        charges      = 30 + Dice.getRandom(1, quality);
                        break;

                    case 3:
                    case 4:
                        chargeSuffix = "Clumsiness";
                        charges      = 30 + Dice.getRandom(1, quality);
                        break;

                    case 5:
                    case 6:
                        chargeSuffix = "Weakness";
                        charges      = 30 + Dice.getRandom(1, quality);
                        break;

                    case 7:
                        chargeSuffix = "Harming";
                        charges      = 20 + Dice.getRandom(1, quality / 2);
                        break;

                    case 8:
                        chargeSuffix = "Flametoungue";
                        charges      = 20 + Dice.getRandom(1, quality / 2);
                        break;

                    case 9:
                    case 10:
                        chargeSuffix = "Cursing";
                        charges      = 20 + Dice.getRandom(1, quality);
                        break;

                    case 11:
                        chargeSuffix = "Lightning";
                        charges      = 20 + Dice.getRandom(1, quality / 2);
                        break;

                    case 12:
                        chargeSuffix = "Paralyzation";
                        charges      = 20 + Dice.getRandom(1, quality / 2);
                        break;

                    case 13:
                        chargeSuffix = "Dispelling";
                        charges      = 20 + Dice.getRandom(1, quality);
                        break;

                    case 14:
                        chargeSuffix = "Draining";
                        charges      = 20 + Dice.getRandom(1, quality);
                        break;
                    }

                    if (hasSuffix)
                    {
                        itemName = string.Format("{0} And {1} ({2})", itemName, chargeSuffix, charges);
                    }
                    else
                    {
                        itemName = string.Format("{0} Of {1} ({2})", itemName, chargeSuffix, charges);
                    }
                }
            }

            return(itemName);
        }