private static void SynthesizeBM() { if (!Globals.Settings.MilitiaSpawn || CalculatedMaxPartySize < Globals.Settings.MinPartySize) { return; } for (var i = 0; i < (Globals.Settings.GlobalPowerPercent - MilitiaPowerPercent) / 24f; i++) { var settlement = Settlement.All.Where(s => !s.IsVisible).GetRandomElementInefficiently(); var clan = Clan.BanditFactions.ToList()[Rng.Next(0, Clan.BanditFactions.Count())]; var mobileParty = settlement.IsHideout ? BanditPartyComponent.CreateBanditParty("Bandit_Militia", clan, settlement.Hideout, false) : BanditPartyComponent.CreateLooterParty("Bandit_Militia", clan, settlement, false); mobileParty.InitializeMobilePartyAroundPosition(clan.DefaultPartyTemplate, settlement.GatePosition, 0); var simulatedMergedRoster = TroopRoster.CreateDummyTroopRoster(); for (var count = 0; count < CalculatedMaxPartySize / Globals.Settings.MinPartySize && simulatedMergedRoster.TotalManCount < CalculatedMaxPartySize && NumMountedTroops(simulatedMergedRoster) <= simulatedMergedRoster.TotalManCount / 2; count++) { simulatedMergedRoster.Add(mobileParty.MemberRoster); } var _ = new Militia(mobileParty.Position2D, simulatedMergedRoster, TroopRoster.CreateDummyTroopRoster()); Trash(mobileParty); DoPowerCalculations(); } }
private static MobileParty CreatePartyInstance(Settlement spawnedSettlement, Clan clan, PartyTemplateObject templateObject, Track.PartyTypeEnum partyType, TextObject partyName = null) { if (clan.IsBanditFaction) { return(BanditPartyComponent.CreateBanditParty(templateObject.StringId + "_" + 1, clan, spawnedSettlement.Hideout, false)); } return(MobileParty.CreateParty(templateObject.StringId + "_" + 1, null)); }
internal void CECaptorHuntPrisoners(MenuCallbackArgs args, int amount = 20) { CEPersistence.animationPlayEvent = false; TroopRoster releasedPrisoners = TroopRoster.CreateDummyTroopRoster(); if (CESettings.Instance != null) { amount = CESettings.Instance.AmountOfTroopsForHunt; } try { for (int i = 0; i < amount; i++) { TroopRosterElement test = MobileParty.MainParty.PrisonRoster.GetTroopRoster().Where(troop => !troop.Character.IsHero).GetRandomElementInefficiently(); if (test.Character == null) { continue; } MobileParty.MainParty.PrisonRoster.RemoveTroop(test.Character); releasedPrisoners.AddToCounts(test.Character, 1, true); } } catch (Exception) { CECustomHandler.LogToFile("Couldn't find anymore prisoners."); } if (!releasedPrisoners.GetTroopRoster().IsEmpty()) { CECaptorContinue(args); try { Clan clan = Clan.BanditFactions.First(clanLooters => clanLooters.StringId == "looters"); clan.Banner.SetBannerVisual(Banner.CreateRandomBanner().BannerVisual); Settlement nearest = SettlementHelper.FindNearestSettlement(settlement => { return(true); }); MobileParty prisonerParty = BanditPartyComponent.CreateBanditParty("CustomPartyCE_Hunt_" + MBRandom.RandomInt(int.MaxValue), clan, nearest.Hideout, false); PartyTemplateObject defaultPartyTemplate = clan.DefaultPartyTemplate; prisonerParty.InitializeMobileParty(defaultPartyTemplate, MobileParty.MainParty.Position2D, 0.5f, 0.1f, -1); prisonerParty.SetCustomName(new TextObject("{=CEEVENTS1107}Escaped Captives")); prisonerParty.MemberRoster.Clear(); prisonerParty.MemberRoster.Add(releasedPrisoners.ToFlattenedRoster()); prisonerParty.RecentEventsMorale = -100; prisonerParty.IsActive = true; prisonerParty.ActualClan = clan; prisonerParty.Party.Owner = clan.Leader; prisonerParty.Party.Visuals.SetMapIconAsDirty(); prisonerParty.HomeSettlement = nearest; prisonerParty.InitializePartyTrade(0); Hero.MainHero.HitPoints += 40; CECustomHandler.LogToFile(prisonerParty.Leader.Name.ToString()); PlayerEncounter.RestartPlayerEncounter(prisonerParty.Party, MobileParty.MainParty.Party, true); StartBattleAction.Apply(MobileParty.MainParty.Party, prisonerParty.Party); PlayerEncounter.Update(); CEPersistence.huntState = CEPersistence.HuntState.StartHunt; CampaignMission.OpenBattleMission(PlayerEncounter.GetBattleSceneForMapPosition(MobileParty.MainParty.Position2D)); } catch (Exception) { CECaptorKillPrisoners(args, amount); } } else { CECaptorContinue(args); } }
internal void CECaptorPrisonerRebel(MenuCallbackArgs args) { CEPersistence.animationPlayEvent = false; TroopRoster releasedPrisoners = TroopRoster.CreateDummyTroopRoster(); try { foreach (TroopRosterElement element in MobileParty.MainParty.PrisonRoster.GetTroopRoster()) { if (element.Character.IsHero) { element.Character.HeroObject.ChangeState(Hero.CharacterStates.Active); } } releasedPrisoners.Add(MobileParty.MainParty.PrisonRoster.ToFlattenedRoster()); MobileParty.MainParty.PrisonRoster.Clear(); } catch (Exception) { CECustomHandler.LogToFile("Couldn't find anymore prisoners."); } if (!releasedPrisoners.GetTroopRoster().IsEmpty()) { try { TroopRosterElement leader = releasedPrisoners.GetTroopRoster().FirstOrDefault(hasHero => hasHero.Character.IsHero); Clan clan = null; Settlement nearest = null; MobileParty prisonerParty = null; if (leader.Character != null) { clan = leader.Character.HeroObject.Clan; nearest = SettlementHelper.FindNearestSettlement(settlement => settlement.OwnerClan == clan) ?? SettlementHelper.FindNearestSettlement(settlement => true); prisonerParty = LordPartyComponent.CreateLordParty("CustomPartyCE_" + MBRandom.RandomInt(int.MaxValue), leader.Character.HeroObject, MobileParty.MainParty.Position2D, 0.5f, nearest); } else { clan = Clan.BanditFactions.First(clanLooters => clanLooters.StringId == "looters"); clan.Banner.SetBannerVisual(Banner.CreateRandomBanner().BannerVisual); nearest = SettlementHelper.FindNearestSettlement(settlement => true); prisonerParty = BanditPartyComponent.CreateBanditParty("CustomPartyCE_" + MBRandom.RandomInt(int.MaxValue), clan, nearest.Hideout, false); } PartyTemplateObject defaultPartyTemplate = clan.DefaultPartyTemplate; prisonerParty.InitializeMobileParty(defaultPartyTemplate, MobileParty.MainParty.Position2D, 0.5f, 0.1f, -1); prisonerParty.SetCustomName(new TextObject("{=CEEVENTS1107}Escaped Captives")); prisonerParty.MemberRoster.Clear(); prisonerParty.ActualClan = clan; prisonerParty.MemberRoster.Add(releasedPrisoners.ToFlattenedRoster()); prisonerParty.IsActive = true; prisonerParty.HomeSettlement = nearest; prisonerParty.SetMovePatrolAroundPoint(nearest.IsTown ? nearest.GatePosition : nearest.Position2D); if (leader.Character != null) { prisonerParty.Party.Owner = leader.Character.HeroObject; #if BETA prisonerParty.ChangePartyLeader(leader.Character); #else prisonerParty.ChangePartyLeader(leader.Character, true); #endif } else { prisonerParty.Party.Owner = clan.Leader; } prisonerParty.RecentEventsMorale = -100; prisonerParty.Aggressiveness = 0.2f; prisonerParty.InitializePartyTrade(0); Hero.MainHero.HitPoints += 40; CECustomHandler.LogToFile(prisonerParty.Leader.Name.ToString()); PlayerEncounter.RestartPlayerEncounter(MobileParty.MainParty.Party, prisonerParty.Party); GameMenu.SwitchToMenu("encounter"); } catch (Exception) { CECaptorContinue(args); } } else { CECaptorContinue(args); } }