private static void HandlePlayerClanReplacements(Settlement settlement) { if ((settlement.IsTown && !settlement.Town.IsRebeling) || (settlement.IsVillage && !settlement.Village.Bound.Town.IsRebeling)) { foreach (Hero notable in settlement.Notables) { if (notable.CanHaveRecruits) { bool flag = false; CultureObject cultureObject = (notable.CurrentSettlement != null) ? notable.CurrentSettlement.Culture : notable.Clan.Culture; // Change cultureObject based on town's loyalty if (ATCSettings.Instance.EnableCCC) { if (settlement.IsTown) { if (MBRandom.RandomInt(0, 100) <= (ATCSettings.Instance.CCCAmount * notable.CurrentSettlement.Town.Loyalty / 100)) { cultureObject = (notable.CurrentSettlement != null) ? notable.CurrentSettlement.MapFaction.Culture : notable.Clan.Culture; } } else if (settlement.IsVillage) { if (MBRandom.RandomInt(0, 100) <= (ATCSettings.Instance.CCCAmount * notable.CurrentSettlement.Village.Bound.Town.Loyalty / 100)) { cultureObject = (notable.CurrentSettlement != null) ? notable.CurrentSettlement.MapFaction.Culture : notable.Clan.Culture; } } } CharacterObject basicTroop = cultureObject.BasicTroop; double num = (notable.IsRuralNotable && notable.Power >= 200) ? 1.0 : 0.5; float num2 = 200f; for (int i = 0; i < 6; i++) { if (MBRandom.RandomFloat < (Campaign.Current.Models.VolunteerProductionModel.GetDailyVolunteerProductionProbability(notable, i, settlement) * ATCSettings.Instance.RecruitSpawnFactor)) { if (notable.VolunteerTypes[i] == null) { notable.VolunteerTypes[i] = ATCconfig.GetReplacement("player_clan_basic", basicTroop); if (ATCSettings.Instance.DebugReplacementMsg && notable.CurrentSettlement.Culture.Name != notable.CurrentSettlement.MapFaction.Culture.Name) { SubModule.log.Add("UpdateVolunteersOfNotables -> Settlement " + notable.CurrentSettlement.Name + "(Culture: " + notable.CurrentSettlement.Culture.Name + ", Owner: " + notable.CurrentSettlement.MapFaction.Name + ") received new recruit: " + notable.VolunteerTypes[i].Name); } flag = true; } else { float num3 = num2 * num2 / (Math.Max(50f, (float)notable.Power) * Math.Max(50f, (float)notable.Power)); int level = notable.VolunteerTypes[i].Level; if (MBRandom.RandomInt((int)Math.Max(2.0, (double)((float)level * num3) * num * 1.5)) == 0 && notable.VolunteerTypes[i].UpgradeTargets != null && notable.VolunteerTypes[i].Level < 20) { if (notable.VolunteerTypes[i] == basicTroop && HeroHelper.HeroShouldGiveEliteTroop(notable)) { notable.VolunteerTypes[i] = ATCconfig.GetReplacement("player_clan_elite", cultureObject.EliteBasicTroop); flag = true; } else { notable.VolunteerTypes[i] = notable.VolunteerTypes[i].UpgradeTargets[MBRandom.RandomInt(notable.VolunteerTypes[i].UpgradeTargets.Length)]; flag = true; } } } } } if (flag) { SortVolunteers(notable.VolunteerTypes); } } } } }
public static async Task SeedAsync(IProjectionRepository projectionRepository, IGenreRepository genreRepository, IActorRepository actorRepository, ICultureObjectRepository cultureObjectRepository, IHallSegmentRepository hallSegmentRepository, ICultureObjectHallRepository cultureObjectHallRepository, IScreeningRepository screeningRepository, ISeatRepository seatRepository, ISeatReservationRepository seatReservationRepository, IAccountRepository accountRepository, IUserRepository userRepository ) { var genre1 = new Genre { GenreName = "Thriler" }; var genre2 = new Genre { GenreName = "Horror" }; var genre3 = new Genre { GenreName = "Drama" }; var genre4 = new Genre { GenreName = "Tragedy" }; var genre5 = new Genre { GenreName = "Commedy" }; var genre6 = new Genre { GenreName = "Action" }; var account1 = new Account { AccountType = "korisnik" }; var account2 = new Account { AccountType = "adminFanZone" }; var account3 = new Account { AccountType = "adminObjekta" }; var account4 = new Account { AccountType = "adminSistema" }; var user1 = new User { AccountId = 1, Password = "******", ConfirmPassword = "******", EmailAddress = "x", FirstName = "x", LastName = "x", Phone = "x", City = "x" }; var user2 = new User { AccountId = 1, Password = "******", ConfirmPassword = "******", EmailAddress = "m", FirstName = "m", LastName = "m", Phone = "m", City = "m" }; var user3 = new User { AccountId = 1, Password = "******", ConfirmPassword = "******", EmailAddress = "a", FirstName = "a", LastName = "a", Phone = "a", City = "a" }; var cultureObject1 = new CultureObject { Address = "Belgrade, Serbia", Name = "Jugoslvensko Dramsko Pozoriste", ObjectDiscriminator = Object.Theater, PromoDescription = "Teatar koji zauvek zivi." }; var cultureObject2 = new CultureObject { Address = "Belgrade, Serbia", Name = "Beogradsko Dramsko Pozoriste", ObjectDiscriminator = Object.Theater, PromoDescription = "Teatar koji zauvek zivi." }; var cultureObject3 = new CultureObject { Address = "Belgrade, Serbia", Name = "Narodno Pozoriste", ObjectDiscriminator = Object.Theater, PromoDescription = "Teatar koji zauvek zivi." }; var cultureObject4 = new CultureObject { Address = "Belgrade, Serbia", Name = "Pozoriste na Terazijama", ObjectDiscriminator = Object.Theater, PromoDescription = "Teatar koji zauvek zivi." }; var cultureObject5 = new CultureObject { Address = "Belgrade, Serbia", Name = "Cineplex", ObjectDiscriminator = Object.Cinema, PromoDescription = "Bioskop 3D" }; var cultureObject6 = new CultureObject { Address = "Belgrade, Serbia", Name = "zvezda", ObjectDiscriminator = Object.Cinema, PromoDescription = "Bioskop 3D" }; var cultureObject7 = new CultureObject { Address = "Belgrade, Serbia", Name = "Roda", ObjectDiscriminator = Object.Cinema, PromoDescription = "Bioskop 3D" }; var cultureObject8 = new CultureObject { Address = "Belgrade, Serbia", Name = "Usce", ObjectDiscriminator = Object.Cinema, PromoDescription = "Bioskop 3D" }; var actor1 = new Actor { FirstName = "Leo", LastName = "DiCaprio" }; var actor2 = new Actor { FirstName = "Katrin Zita", LastName = "Jones" }; var projection1 = new Projection { ProjectionName = "Titanik", Actor = actor1, Duration = decimal.Parse("123.34"), Genre = genre3, ProducerName = "James Cameron", ProjectionType = ProjectionType.Movie, ShortDescirption = "Description" }; var projection2 = new Projection { ProjectionName = "Avatar", Actor = actor2, Duration = decimal.Parse("100"), Genre = genre3, ProducerName = "James Cameron", ProjectionType = ProjectionType.Movie, ShortDescirption = "Description" }; var projection3 = new Projection { ProjectionName = "Seobe", Actor = actor2, Duration = decimal.Parse("120"), Genre = genre3, ProducerName = "Vida Ognjanovic", ProjectionType = ProjectionType.Play, ShortDescirption = "Description" }; var hall1 = new CultureObjectHall { HallName = "Mira Stupica", SeatsNo = 1000, CultureObject = cultureObject1 }; var hall2 = new CultureObjectHall { HallName = "Main Hall", SeatsNo = 1300, CultureObject = cultureObject1 }; var hall3 = new CultureObjectHall { HallName = "Private Hall", SeatsNo = 150, CultureObject = cultureObject1 }; var hall4 = new CultureObjectHall { HallName = "Mala sala", SeatsNo = 100, CultureObject = cultureObject2 }; var hall5 = new CultureObjectHall { HallName = "Velika sala", SeatsNo = 500, CultureObject = cultureObject2 }; var hallSegment1 = new HallSegment { HallSegmentName = "Balkon", SeatsNo = 100, CultureObjecsHall = hall1 }; var hallSegment2 = new HallSegment { HallSegmentName = "Parter", SeatsNo = 500, CultureObjecsHall = hall1 }; var hallSegment3 = new HallSegment { HallSegmentName = "VIP", SeatsNo = 40, CultureObjecsHall = hall1 }; var hallSegment4 = new HallSegment { HallSegmentName = "Balkon", SeatsNo = 100, CultureObjecsHall = hall2 }; var hallSegment5 = new HallSegment { HallSegmentName = "Parter", SeatsNo = 500, CultureObjecsHall = hall2 }; var hallSegment6 = new HallSegment { HallSegmentName = "VIP", SeatsNo = 40, CultureObjecsHall = hall2 }; var hallSegment7 = new HallSegment { HallSegmentName = "Balkon", SeatsNo = 100, CultureObjecsHall = hall4 }; var hallSegment8 = new HallSegment { HallSegmentName = "Parter", SeatsNo = 500, CultureObjecsHall = hall4 }; var hallSegment9 = new HallSegment { HallSegmentName = "VIP", SeatsNo = 40, CultureObjecsHall = hall4 }; var hallSegment10 = new HallSegment { HallSegmentName = "Balkon", SeatsNo = 100, CultureObjecsHall = hall5 }; var hallSegment11 = new HallSegment { HallSegmentName = "Parter", SeatsNo = 500, CultureObjecsHall = hall5 }; var hallSegment12 = new HallSegment { HallSegmentName = "VIP", SeatsNo = 40, CultureObjecsHall = hall5 }; var screening1 = new Screening { ScreenStartDateTime = new System.DateTime(2018, 6, 28, 20, 0, 0), CultureObjecsHall = hall2, Projection = projection1 }; var screening2 = new Screening { ScreenStartDateTime = new System.DateTime(2018, 6, 28, 20, 0, 0), CultureObjecsHall = hall1, Projection = projection2 }; var screening3 = new Screening { ScreenStartDateTime = new System.DateTime(2018, 6, 28, 20, 0, 0), CultureObjecsHall = hall2, Projection = projection1 }; var screening4 = new Screening { ScreenStartDateTime = new System.DateTime(2018, 6, 28, 20, 0, 0), CultureObjecsHall = hall4, Projection = projection2 }; var screening5 = new Screening { ScreenStartDateTime = new System.DateTime(2018, 6, 27, 11, 30, 0), CultureObjecsHall = hall4, Projection = projection2 }; var seat31 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment3 }; var seat32 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment3 }; var seat33 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment3 }; var seat34 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment3 }; var seat35 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment3 }; var seat21 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment2 }; var seat22 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment2 }; var seat23 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment2 }; var seat24 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment2 }; var seat25 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment2 }; var seat11 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment1 }; var seat12 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment1 }; var seat13 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment1 }; var seat14 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment1 }; var seat15 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment1 }; var seat61 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment6 }; var seat62 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment6 }; var seat63 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment6 }; var seat64 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment6 }; var seat65 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment6 }; var seat51 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment5 }; var seat52 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment5 }; var seat53 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment5 }; var seat54 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment5 }; var seat55 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment5 }; var seat41 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment4 }; var seat42 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment4 }; var seat43 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment4 }; var seat44 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment4 }; var seat45 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment4 }; var seat71 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment7 }; var seat72 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment7 }; var seat73 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment7 }; var seat74 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment7 }; var seat75 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment7 }; var seat81 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment8 }; var seat82 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment8 }; var seat83 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment8 }; var seat84 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment8 }; var seat85 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment8 }; var seat91 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment9 }; var seat92 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment9 }; var seat93 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment9 }; var seat94 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment9 }; var seat95 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment9 }; var seat101 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment10 }; var seat102 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment10 }; var seat103 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment10 }; var seat104 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment10 }; var seat105 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment10 }; var seat111 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment11 }; var seat112 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment11 }; var seat113 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment11 }; var seat114 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment11 }; var seat115 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment11 }; var seat121 = new Seat { Row = 1, SeatNumber = "1", HallSegment = hallSegment12 }; var seat122 = new Seat { Row = 2, SeatNumber = "2", HallSegment = hallSegment12 }; var seat123 = new Seat { Row = 3, SeatNumber = "3", HallSegment = hallSegment12 }; var seat124 = new Seat { Row = 4, SeatNumber = "4", HallSegment = hallSegment12 }; var seat125 = new Seat { Row = 5, SeatNumber = "5", HallSegment = hallSegment12 }; var seatReservation1 = new SeatReservation { Screening = screening1, Seat = seat21, User = user1 }; var seatReservation2 = new SeatReservation { Screening = screening1, Seat = seat22, User = user2 }; var seatReservation3 = new SeatReservation { Screening = screening1, Seat = seat23, User = user2 }; var seatReservation4 = new SeatReservation { Screening = screening2, Seat = seat31, User = user1 }; var seatReservation5 = new SeatReservation { Screening = screening2, Seat = seat32, User = user2 }; var seatReservation6 = new SeatReservation { Screening = screening2, Seat = seat33, User = user2 }; await genreRepository.AddAsync(genre1); await genreRepository.AddAsync(genre2); await genreRepository.AddAsync(genre3); await genreRepository.AddAsync(genre4); await genreRepository.AddAsync(genre5); await genreRepository.AddAsync(genre6); await accountRepository.AddAsync(account1); await accountRepository.AddAsync(account2); await accountRepository.AddAsync(account3); await accountRepository.AddAsync(account4); await userRepository.AddAsync(user1); await userRepository.AddAsync(user2); await userRepository.AddAsync(user3); await actorRepository.AddAsync(actor1); await actorRepository.AddAsync(actor2); await projectionRepository.AddAsync(projection1); await projectionRepository.AddAsync(projection2); await projectionRepository.AddAsync(projection3); await cultureObjectRepository.AddAsync(cultureObject1); await cultureObjectRepository.AddAsync(cultureObject2); await cultureObjectRepository.AddAsync(cultureObject3); await cultureObjectRepository.AddAsync(cultureObject4); await cultureObjectRepository.AddAsync(cultureObject5); await cultureObjectRepository.AddAsync(cultureObject6); await cultureObjectRepository.AddAsync(cultureObject7); await cultureObjectRepository.AddAsync(cultureObject8); await cultureObjectHallRepository.AddAsync(hall1); await cultureObjectHallRepository.AddAsync(hall2); await cultureObjectHallRepository.AddAsync(hall3); await cultureObjectHallRepository.AddAsync(hall4); await cultureObjectHallRepository.AddAsync(hall5); await hallSegmentRepository.AddAsync(hallSegment1); await hallSegmentRepository.AddAsync(hallSegment2); await hallSegmentRepository.AddAsync(hallSegment3); await hallSegmentRepository.AddAsync(hallSegment4); await hallSegmentRepository.AddAsync(hallSegment5); await hallSegmentRepository.AddAsync(hallSegment6); await hallSegmentRepository.AddAsync(hallSegment7); await hallSegmentRepository.AddAsync(hallSegment8); await hallSegmentRepository.AddAsync(hallSegment9); await hallSegmentRepository.AddAsync(hallSegment10); await hallSegmentRepository.AddAsync(hallSegment11); await hallSegmentRepository.AddAsync(hallSegment12); await screeningRepository.AddAsync(screening1); await screeningRepository.AddAsync(screening2); await screeningRepository.AddAsync(screening3); await screeningRepository.AddAsync(screening4); await screeningRepository.AddAsync(screening5); await seatRepository.AddAsync(seat11); await seatRepository.AddAsync(seat12); await seatRepository.AddAsync(seat13); await seatRepository.AddAsync(seat14); await seatRepository.AddAsync(seat15); await seatRepository.AddAsync(seat21); await seatRepository.AddAsync(seat22); await seatRepository.AddAsync(seat23); await seatRepository.AddAsync(seat24); await seatRepository.AddAsync(seat25); await seatRepository.AddAsync(seat31); await seatRepository.AddAsync(seat32); await seatRepository.AddAsync(seat33); await seatRepository.AddAsync(seat34); await seatRepository.AddAsync(seat35); await seatRepository.AddAsync(seat41); await seatRepository.AddAsync(seat42); await seatRepository.AddAsync(seat43); await seatRepository.AddAsync(seat44); await seatRepository.AddAsync(seat45); await seatRepository.AddAsync(seat51); await seatRepository.AddAsync(seat52); await seatRepository.AddAsync(seat53); await seatRepository.AddAsync(seat54); await seatRepository.AddAsync(seat55); await seatRepository.AddAsync(seat61); await seatRepository.AddAsync(seat62); await seatRepository.AddAsync(seat63); await seatRepository.AddAsync(seat64); await seatRepository.AddAsync(seat65); await seatRepository.AddAsync(seat71); await seatRepository.AddAsync(seat72); await seatRepository.AddAsync(seat73); await seatRepository.AddAsync(seat74); await seatRepository.AddAsync(seat75); await seatRepository.AddAsync(seat81); await seatRepository.AddAsync(seat82); await seatRepository.AddAsync(seat83); await seatRepository.AddAsync(seat84); await seatRepository.AddAsync(seat85); await seatRepository.AddAsync(seat91); await seatRepository.AddAsync(seat92); await seatRepository.AddAsync(seat93); await seatRepository.AddAsync(seat94); await seatRepository.AddAsync(seat95); await seatRepository.AddAsync(seat101); await seatRepository.AddAsync(seat102); await seatRepository.AddAsync(seat103); await seatRepository.AddAsync(seat104); await seatRepository.AddAsync(seat105); await seatRepository.AddAsync(seat111); await seatRepository.AddAsync(seat112); await seatRepository.AddAsync(seat113); await seatRepository.AddAsync(seat114); await seatRepository.AddAsync(seat115); await seatRepository.AddAsync(seat121); await seatRepository.AddAsync(seat122); await seatRepository.AddAsync(seat123); await seatRepository.AddAsync(seat124); await seatRepository.AddAsync(seat125); await seatReservationRepository.AddAsync(seatReservation1); await seatReservationRepository.AddAsync(seatReservation2); await seatReservationRepository.AddAsync(seatReservation3); await seatReservationRepository.AddAsync(seatReservation4); await seatReservationRepository.AddAsync(seatReservation5); await seatReservationRepository.AddAsync(seatReservation6); }
static void Postfix(bool initialRunning) { if (BannerlordTweaksSettings.Instance is { } settings&& settings.BalancingUpgradeTroopsTweaksEnabled) { foreach (Settlement settlement in from settlement in Campaign.Current.Settlements where settlement.OwnerClan != null && settlement.OwnerClan.Kingdom != null && ((settlement.IsTown && !settlement.Town.InRebelliousState) || (settlement.IsVillage && !settlement.Village.Bound.Town.InRebelliousState)) select settlement) { float num = 0f; if (settings.KingdomBalanceStrengthVanEnabled) { num = settlement.OwnerClan.Kingdom.StringId switch { "vlandia" => settings.VlandiaBoost, "battania" => settings.BattaniaBoost, "empire" => settings.Empire_N_Boost, "empire_s" => settings.Empire_S_Boost, "empire_w" => settings.Empire_W_Boost, "sturgia" => settings.SturgiaBoost, "khuzait" => settings.KhuzaitBoost, "aserai" => settings.AseraiBoost, _ => 0f }; } if (settings.KingdomBalanceStrengthCEKEnabled) { num = settlement.OwnerClan.Kingdom.StringId switch { "nordlings" => settings.NordlingsBoost, "vagir" => settings.VagirBoost, "royalist_vlandia" => settings.RoyalistVlandiaBoost, "apolssaly" => settings.ApolssalyBoost, "lyrion" => settings.LyrionBoost, "rebel_khuzait" => settings.RebelKhuzaitBoost, "paleician" => settings.PaleicianBoost, "ariorum" => settings.AriorumBoost, "vlandia" => settings.Vlandia_CEK_Boost, "battania" => settings.Battania_CEK_Boost, "empire" => settings.Empire_CEK_Boost, "empire_s" => settings.Empire_S_CEK_Boost, "empire_w" => settings.Empire_W_CEK_Boost, "sturgia" => settings.Sturgia_CEK_Boost, "khuzait" => settings.Khuzait_CEK_Boost, "aserai" => settings.Aserai_CEK_Boost, _ => 0f }; } if (num == 0f && settlement.OwnerClan.Kingdom.Leader == Hero.MainHero) { num = (settings.KingdomBalanceStrengthCEKEnabled) ? settings.Player_CEK_Boost : settings.PlayerBoost; } foreach (Hero hero in settlement.Notables) { if (hero.CanHaveRecruits) { for (int i = 0; i < 6; i++) { if (hero.VolunteerTypes[i] != null && MBRandom.RandomFloat < (num * 0.5) && hero.VolunteerTypes[i].UpgradeTargets != null && hero.VolunteerTypes[i].Level < 20) { CultureObject cultureObject = (hero.CurrentSettlement != null) ? hero.CurrentSettlement.Culture : hero.Clan.Culture; CharacterObject basicTroop = cultureObject.BasicTroop; if (hero.VolunteerTypes[i] == basicTroop && HeroHelper.HeroShouldGiveEliteTroop(hero)) { hero.VolunteerTypes[i] = cultureObject.EliteBasicTroop; } else { hero.VolunteerTypes[i] = hero.VolunteerTypes[i].UpgradeTargets[MBRandom.RandomInt(hero.VolunteerTypes[i].UpgradeTargets.Length)]; } } } } } } } }
/// <summary> /// Recalculate influence based on campaign circumstances and save it as "TargetInfluence" /// </summary> /// <param name="firstTimeSetup"></param> /// <returns></returns> public int RecalculateInfluencers(bool firstTimeSetup) { Settlement settlement = Settlement.Find(settlementId); //if (settlement.Name.ToString() == "Syronea") //{ // int u = 0; //} // foreach nearby settlement, sum up the influence of each culture type List <Settlement> influencingSettlements = new List <Settlement>(); // Geographically close settlements influencingSettlements.AddRange(Settlement.FindSettlementsAroundPosition(settlement.Position2D, Settings.Instance.SettlementInfluenceRange).Where(x => x.IsVillage || x.IsCastle || x.IsTown)); if (Settings.Instance.TradeLinkedInfluence) { // Trade-linked settlements if (settlement.IsCastle || settlement.IsTown) { influencingSettlements.AddRange(settlement.BoundVillages.Select(v => v.Settlement)); } // Parent's Trade-linked settlements if (settlement.IsVillage) { influencingSettlements.AddRange(Settlement.FindFirst(s => s.BoundVillages.Contains(settlement.Village)).BoundVillages.Select(v => v.Settlement)); } } // calculate the influence caused by our neighbors int sum = 0; Dictionary <CultureObject, int> influencers = new Dictionary <CultureObject, int>(); foreach (var otherSettlement in influencingSettlements) { int influence = getInfluenceFromSettlement(otherSettlement, settlement, firstTimeSetup); sum += influence; if (!influencers.ContainsKey(otherSettlement.Culture)) { influencers.Add(otherSettlement.Culture, influence); } else { influencers[otherSettlement.Culture] += influence; } } // calculate the influence caused by our owners int ownerInfluence = BASE_INFLUENCE * Settings.Instance.OwnerInfluenceStrength; sum += ownerInfluence; if (ownerInfluence > 0) { var ownerCulture = DynaCultureUtils.GetOwnerCulture(settlement); if (!influencers.ContainsKey(ownerCulture)) { influencers.Add(ownerCulture, ownerInfluence); } else { influencers[ownerCulture] += ownerInfluence; } } // foreach influencing culture, calculate the percent of total influence bool didTargetsChange = false; foreach (var pair in influencers) { CultureObject culture = pair.Key; decimal percent = (decimal)pair.Value / sum; if (!TargetInfluences.ContainsKey(culture.StringId)) { TargetInfluences.Add(culture.StringId, percent); didTargetsChange = true; } else if (percent != TargetInfluences[culture.StringId]) { TargetInfluences[culture.StringId] = percent; didTargetsChange = true; } } // clear out no longer influencing cultures for (int x = 0; x < TargetInfluences.Count; x++)//foreach (var pair in TargetInfluences) { if (!influencers.Select(c => c.Key.StringId).Contains(TargetInfluences.ElementAt(x).Key)) { TargetInfluences[TargetInfluences.ElementAt(x).Key] = 0m; } } if (didTargetsChange) { TargetInfluencesIDKey++; } return(sum); }
public static void ConvertLootersToKingdomCultureRecruits(ref TroopRoster troopRoster, CultureObject culture, int numberToUpgrade) { var recruit = Recruits.Where(x => x.Culture == Clan.All.FirstOrDefault(k => k.Culture == culture)?.Culture) .ToList().GetRandomElement() ?? Recruits.ToList().GetRandomElement(); troopRoster.AddToCounts(recruit, numberToUpgrade); }
// assembly copy rewrite so teams are not identical private static bool Prefix(SandBox.TournamentFightMissionController __instance, TournamentMatch ____match, CultureObject ____culture) { if (GameNetwork.IsClientOrReplay) { return(false); } var qualityMap = new Dictionary <TournamentTeam, float>(); var mountMap = new Dictionary <TournamentTeam, int>(); Log(""); Log(new string('=', 50)); Log("NEW MATCH"); foreach (var team in ____match.Teams) { if (!ModSettings.TournamentBalance) { foreach (var participant in team.Participants) { EquipParticipant(__instance, ____culture, team, mountMap, participant); } continue; } mountMap.Add(team, 0); foreach (var participant in team.Participants) { EquipParticipant(__instance, ____culture, team, mountMap, participant); } qualityMap.Add(team, SumTeamEquipmentValue(team)); // use the first team's random build value as the baseline // act after the first team is populated, re-rolling to find a suitable delta if (qualityMap.Keys.Count > 1) { while (Math.Abs(qualityMap.Values.ElementAt(0) - qualityMap[team]) > ModSettings.DifferenceThreshold || mountMap.Values.ElementAt(0) != mountMap[team]) { Log("RE-ROLLING TEAM"); mountMap[team] = 0; foreach (var participant in team.Participants) { EquipParticipant(__instance, ____culture, team, mountMap, participant); } qualityMap[team] = SumTeamEquipmentValue(team); } } } Log(new string('-', 50)); for (var i = 0; i < ____match.Teams.Count(); i++) { Log($"Team{i + 1} value {qualityMap.Values.ElementAt(i):F2}"); } return(false); }
private void CastleAbandonSettlementMenuOption(CampaignGameStarter campaignGameStarter) { campaignGameStarter.AddGameMenuOption("ruler_castle_menu", "ruler_castle_abandon", "Abandon Rulership of Castle", (GameMenuOption.OnConditionDelegate)(args => { args.optionLeaveType = GameMenuOption.LeaveType.Manage; if (Settlement.CurrentSettlement.OwnerClan.Kingdom != null && Settlement.CurrentSettlement.OwnerClan.Kingdom.Leader != Hero.MainHero) { args.Tooltip = new TextObject("You must be the faction leader to abandon a settlement"); args.IsEnabled = false; } args.Tooltip = new TextObject("A minor noble will take control of the settlement"); return(true); }), (GameMenuOption.OnConsequenceDelegate)(args => { InformationManager.ShowInquiry(new InquiryData("Abandon Castle", "Are you sure you want to abandon this castle?", true, true, "Yes", "No", (Action)(() => { List <CharacterObject> source = new List <CharacterObject>(); CultureObject culture = Settlement.CurrentSettlement.Culture; foreach (CharacterObject characterObject in CharacterObject.Templates.Where <CharacterObject>((Func <CharacterObject, bool>)(x => x.Occupation == Occupation.Lord)).ToList <CharacterObject>()) { if (characterObject.Culture == culture) { source.Add(characterObject); } } CharacterObject template = source[rng.Next(0, source.Count - 1)]; Hero NewHero = HeroCreator.CreateSpecialHero(template, Settlement.CurrentSettlement, null, Hero.MainHero.Clan, rng.Next(25, 30)); NewHero.ChangeState(Hero.CharacterStates.Active); HeroCreationCampaignBehavior herocreationbehavior = new HeroCreationCampaignBehavior(); herocreationbehavior.DeriveSkillsFromTraits(NewHero, template); List <CharacterObject> source2 = new List <CharacterObject>(); foreach (CharacterObject characterObject in CharacterObject.Templates.Where <CharacterObject>((Func <CharacterObject, bool>)(x => x.Occupation == Occupation.Lord)).ToList <CharacterObject>()) { if (characterObject.Culture == culture) { source2.Add(characterObject); } } CharacterObject template2 = source2[rng.Next(0, source2.Count - 1)]; template2.IsFemale = true; Hero NewHero2 = HeroCreator.CreateSpecialHero(template2, Settlement.CurrentSettlement, null, Hero.MainHero.Clan, rng.Next(25, 30)); NewHero2.ChangeState(Hero.CharacterStates.Active); herocreationbehavior.DeriveSkillsFromTraits(NewHero2, template2); template2.IsFemale = false; Clan clan = MBObjectManager.Instance.CreateObject <Clan>(); Banner ClanBanner = Banner.CreateRandomClanBanner(); TextObject clanName = culture.ClanNameList[rng.Next(0, culture.ClanNameList.Count)]; clan.InitializeClan(clanName, clanName, culture, ClanBanner); clan.SetLeader(NewHero); FieldInfo field = clan.GetType().GetField("_tier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if ((FieldInfo)null != field) { field.SetValue((object)clan, rng.Next(2, 4)); } NewHero.Clan = clan; NewHero.IsNoble = true; MobileParty newMobileParty1 = clan.CreateNewMobileParty(NewHero); newMobileParty1.ItemRoster.AddToCounts(DefaultItems.Grain, 10); newMobileParty1.ItemRoster.AddToCounts(DefaultItems.Meat, 5); NewHero2.Clan = clan; NewHero2.IsNoble = true; MobileParty newMobileParty2 = clan.CreateNewMobileParty(NewHero2); newMobileParty2.ItemRoster.AddToCounts(DefaultItems.Grain, 10); newMobileParty2.ItemRoster.AddToCounts(DefaultItems.Meat, 5); ChangeOwnerOfSettlementAction.ApplyByKingDecision(NewHero, Settlement.CurrentSettlement); clan.UpdateHomeSettlement(Settlement.CurrentSettlement); MarriageAction.Apply(NewHero, NewHero2); ChangeRelationAction.ApplyPlayerRelation(NewHero, 40); }), (Action)(() => { GameMenu.SwitchToMenu("castle"); })), true); }), index: 1);;; }
public static bool IsOfCulture(this BaseSettlementInfo settlementInfo, CultureObject culture) { return(settlementInfo.IsOfCulture(culture.StringId)); }