public Hero CreateRandomLeader(Clan clan, BaseSettlementInfo settlementInfo) { var templateBase = clan.Leader.CharacterObject; var characterTemplate = CharacterObject.Templates.Where(go => go.Culture == clan.Culture && (go.Occupation == Occupation.Lord || go.Occupation == Occupation.Lady)).GetRandomElement(); characterTemplate.InitializeEquipmentsOnLoad(templateBase.AllEquipments.ToList()); foreach (var attribute in CharacterAttributes.All) { characterTemplate.SetAttributeValue(attribute.AttributeEnum, 255); } foreach (var skill in SkillObject.All) { characterTemplate.SetSkillValue(skill, 255); } characterTemplate.SetSkillValue(SkillObject.GetSkill(13), 1000); var hero = HeroCreator.CreateSpecialHero(characterTemplate, settlementInfo.Settlement); hero.IsNoble = true; hero.IsMinorFactionHero = false; foreach (var perk in PerkObject.All) { hero.SetPerkValue(perk, true); } hero.ChangeState(Hero.CharacterStates.Active); Get(hero.CharacterObject).IsCustomCharacter = true; return(hero); }
private static Hero CreateRandomLeader(Clan clan, Settlement origin) { Hero specialHero = null; try { CharacterObject templateBase = clan.Leader.CharacterObject; CharacterObject template = CharacterObject.Templates.Where(x => origin.Culture == x.Culture && x.Occupation == Occupation.Lord || x.Occupation == Occupation.Lady).GetRandomElement(); template.InitializeEquipmentsOnLoad(templateBase.AllEquipments.ToList()); specialHero = HeroCreator.CreateSpecialHero(template, origin, clan, null, -1); specialHero.StringId = Campaign.Current.Heroes[Campaign.Current.Heroes.Count - 1].StringId + Rand.Next(int.MaxValue); specialHero.Name = NameGenerator.Current.GenerateHeroFirstName(specialHero, true); //TextObject encyclopediaText = new TextObject("{=!}{RULER} has stretched their borders too thin. Usurper {REBEL} from {SETTLEMENT} is taking advantage of it."); //encyclopediaText.SetTextVariable("REBEL", specialHero.Name); //encyclopediaText.SetTextVariable("SETTLEMENT", origin.Name); //encyclopediaText.SetTextVariable("RULER", clan.Kingdom.Leader.Name); //specialHero.EncyclopediaText = encyclopediaText; specialHero.ChangeState(Hero.CharacterStates.NotSpawned); specialHero.IsMinorFactionHero = false; specialHero.IsNoble = true; specialHero.BornSettlement = origin; specialHero.UpdateHomeSettlement(); specialHero.AddSkillXp(SkillObject.GetSkill(0), Rand.Next(80000, 500000)); // One Handed specialHero.AddSkillXp(SkillObject.GetSkill(2), Rand.Next(80000, 500000)); // Pole Arm specialHero.AddSkillXp(SkillObject.GetSkill(6), Rand.Next(80000, 500000)); // Riding specialHero.AddSkillXp(SkillObject.GetSkill(7), Rand.Next(80000, 500000)); // Athletics specialHero.AddSkillXp(SkillObject.GetSkill(9), Rand.Next(80000, 500000)); // Tactics specialHero.AddSkillXp(SkillObject.GetSkill(13), Rand.Next(80000, 500000)); // Leadership specialHero.AddSkillXp(SkillObject.GetSkill(15), Rand.Next(80000, 500000)); // Steward specialHero.AddSkillXp(SkillObject.GetSkill(17), Rand.Next(80000, 500000)); // Engineering specialHero.ChangeState(Hero.CharacterStates.Active); specialHero.Gold += 100000; MBObjectManager.Instance.RegisterObject(specialHero); } catch (Exception e) { Log.Info("Exception when trying to create new Hero"); Log.Error(e); } return(specialHero); }