Example #1
0
        public override void CalculateStartSkills()
        {
            for (int j = 0; j < Database.GetProfession(professionKey).SkillProficiencies.Count; j++)
            {
                int value  = Database.GetProfession(professionKey).SkillProficiencies[j].Value;
                int result = GameValue.Roll(new GameValue(1, 2), false) * value;
                int index  = Database.Skills[(int)Database.GetProfession(professionKey).SkillProficiencies[j].Skill].Index;

                Attribute skill = new Attribute(index, AttributeType.Skill, result, 0, 100);

                attributes.SetSkill(skill);
            }

            for (int i = 0; i < Database.GetRace(raceKey).SkillProficiencies.Count; i++)
            {
                int value = Database.GetRace(raceKey).SkillProficiencies[i].Value;
                int index = Database.Skills[(int)Database.GetProfession(professionKey).SkillProficiencies[i].Skill].Index;

                Attribute skill = new Attribute(index, AttributeType.Skill, value, 0, 100);

                attributes.SetSkill(skill);
            }

            CalculateExpCosts();
        }
Example #2
0
        public static SkillProficiency Randomize(GameValue value)
        {
            SkillProficiency sp = new SkillProficiency();

            sp.Skill   = (Skill)Random.Range(0, (int)Skill.Number);
            sp.Value   = value.Roll(false);
            sp.Minimum = 0;
            return(sp);
        }
Example #3
0
        public static PcData Generate(int listIndex, Gender gender, string r, string p)
        {
            //if (availableRaces == null || availableProfessions == null) return null;

            string race_key = "";

            if (r == "")
            {
                race_key = availableRaces[Random.Range(0, availableRaces.Count)];
            }
            else
            {
                race_key = r;
            }

            string professionKey = "";

            if (p == "")
            {
                professionKey = availableProfessions[Random.Range(0, availableProfessions.Count)];
            }
            else
            {
                professionKey = p;
            }

            Race       race       = Database.GetRace(race_key);
            Profession profession = Database.GetProfession(professionKey);

            string hair  = "";
            string beard = "";

            if (gender == Gender.None)
            {
                if (Random.Range(0, 100) < 50)
                {
                    gender = Gender.Male;

                    if (race.maleDefaultHair != "")
                    {
                        hair = "Hair " + Random.Range(1, 9);
                    }

                    if (race.maleDefaultBeard != "" && Random.Range(0, 100) < 50)
                    {
                        beard = "Beard " + Random.Range(1, 8);
                    }
                }
                else
                {
                    gender = Gender.Female;

                    if (race.femaleDefaultHair != "")
                    {
                        hair = "Hair " + Random.Range(1, 17);
                    }

                    beard = race.femaleDefaultBeard;
                }
            }
            else if (gender == Gender.Male)
            {
                gender = Gender.Male;

                if (race.maleDefaultHair != "")
                {
                    hair = "Hair " + Random.Range(1, 9);
                }

                if (race.maleDefaultBeard != "" && Random.Range(0, 100) < 50)
                {
                    beard = "Beard " + Random.Range(1, 8);
                }
            }
            else if (gender == Gender.Female)
            {
                gender = Gender.Female;

                if (race.femaleDefaultHair != "")
                {
                    hair = "Hair " + Random.Range(1, 17);
                }

                beard = race.femaleDefaultBeard;
            }

            PcData pc = new PcData(NameGenerator.Get(gender, race_key, professionKey),
                                   gender, 1, race_key, professionKey, hair, beard, listIndex, -1,
                                   3 + GameValue.Roll(new GameValue(1, 3), false), 3 + GameValue.Roll(new GameValue(1, 3), false));

            pc.Background  = BackgroundGenerator.Generate();
            pc.Personality = GeneratePersonality();
            pc.Description = GenerateDescription(pc);

            pc.LevelUp();
            pc.CalculateExp();
            pc.AddExperience(Random.Range(0, 999), false);

            if (profession.StartingItems.Count > 0)
            {
                for (int i = 0; i < profession.StartingItems.Count; i++)
                {
                    ItemData item = ItemGenerator.CreateItem(profession.StartingItems[i].ItemKey, profession.StartingItems[i].MaterialKey, profession.StartingItems[i].PlusKey,
                                                             profession.StartingItems[i].PreKey, profession.StartingItems[i].PostKey, profession.StartingItems[i].StackSize);

                    if (race.ArmorSlotAllowed((EquipmentSlot)item.Slot) == true)
                    {
                        pc.Inventory.EquipItem(item, ((EquipmentSlot)item.Slot));
                    }
                }
            }
            else
            {
                for (int i = 0; i < pc.Inventory.EquippedItems.Length; i++)
                {
                    if (Database.GetRace(race_key).ArmorSlotAllowed(((EquipmentSlot)i)) == true)
                    {
                        int chanceForItem = 25;

                        if (i == (int)EquipmentSlot.Right_Hand)
                        {
                            chanceForItem = 100;
                        }
                        else if (i == (int)EquipmentSlot.Body)
                        {
                            chanceForItem = 100;
                        }
                        else if (i == (int)EquipmentSlot.Feet)
                        {
                            chanceForItem = 100;
                        }

                        if (Random.Range(1, 101) <= chanceForItem)
                        {
                            ItemData item = ItemGenerator.CreateRandomItem(i, 25, 25);

                            if (item != null)
                            {
                                pc.Inventory.EquippedItems[i] = new ItemData(item);
                            }
                        }
                    }
                }
            }

            int numAccessories = Random.Range(1, 3);

            pc.Inventory.AccessoryLimit = numAccessories + Random.Range(0, 3);

            for (int i = 0; i < numAccessories; i++)
            {
                pc.Inventory.EquipAccessory(ItemGenerator.CreateRandomItem(ItemTypeAllowed.Accessory, 0, 0), -1);
            }

            for (int spell = 0; spell < pc.Abilities.KnownSpells.Count; spell++)
            {
                if (Random.Range(0, 100) < 100)
                {
                    pc.Abilities.KnownSpells[spell].BoostRune = Helper.RandomValues <string, AbilityModifier>(Database.Runes).Key;
                }
            }

            string key = positiveQuirks[Random.Range(0, positiveQuirks.Count)];

            pc.Abilities.AddTrait(new Ability(Database.GetAbility(key)));

            key = neutralQuirks[Random.Range(0, neutralQuirks.Count)];
            pc.Abilities.AddTrait(new Ability(Database.GetAbility(key)));

            key = negativeQuirks[Random.Range(0, negativeQuirks.Count)];
            pc.Abilities.AddTrait(new Ability(Database.GetAbility(key)));

            if (GameValue.Roll(1, 100) < 20)
            {
                key = woundQuirks[Random.Range(0, woundQuirks.Count)];
                pc.Abilities.AddTrait(new Ability(Database.GetAbility(key)));
            }

            pc.CalculateAttributeModifiers();
            pc.CalculateStartAttributes(true);
            pc.CalculateDerivedAttributes();
            pc.CalculateStartSkills();
            pc.CalculateResistances();
            pc.CalculateExpCosts();

            pc.Abilities.PowerSlots = (pc.Attributes.GetAttribute(AttributeListType.Derived, (int)BaseAttribute.Memory).Current / 5) + 1;
            pc.Abilities.SpellSlots = (pc.Attributes.GetAttribute(AttributeListType.Derived, (int)BaseAttribute.Memory).Current / 5) + 1;

            pc.Abilities.FindTraits();
            pc.Abilities.FindAvailableAbilities();

            //pc.AddExperience(Random.Range(0, 500) * 10, false);

            pc.CalculateUpkeep();

            return(pc);
        }