public static void Prefix(ref TroopRoster rightMemberRoster) { if (Settings.Instance.Enabled && Settings.Instance.ApplyInventoryPatch && rightMemberRoster.Contains(Hero.MainHero.CharacterObject)) { //TroopRoster newRoster = new TroopRoster(); TroopRoster newRoster = TroopRoster.CreateDummyTroopRoster(); newRoster.Add(rightMemberRoster); PatchInventoryDefaults.DefaultCharacterEquipments.Clear(); foreach (Hero hero in Clan.PlayerClan.Heroes) { if (hero.IsAlive && !hero.IsChild && hero != Hero.MainHero && !newRoster.Contains(hero.CharacterObject)) { newRoster.AddToCounts(hero.CharacterObject, 1); PatchInventoryDefaults.SetDefault(hero.CharacterObject); } } foreach (Hero hero in Clan.PlayerClan.Companions) { if (hero.IsAlive && hero.IsPlayerCompanion && !newRoster.Contains(hero.CharacterObject)) { newRoster.AddToCounts(hero.CharacterObject, 1); PatchInventoryDefaults.SetDefault(hero.CharacterObject); } } rightMemberRoster = newRoster; } }
// Helpers.MobilePartyHelper public static FlattenedTroopRoster GetStrongestAndPriorTroops(MobileParty mobileParty, int maxTroopCount, List <Hero> includeList) { TroopRoster troopRoster = TroopRoster.CreateDummyTroopRoster(); FlattenedTroopRoster memberRoster = mobileParty.MemberRoster.ToFlattenedRoster(); memberRoster.RemoveIf((x) => x.IsWounded); List <CharacterObject> list = memberRoster.Select((x) => x.Troop).OrderByDescending((x) => x.Level).ToList <CharacterObject>(); if (null != includeList && includeList.Count > 0) { foreach (Hero hero in includeList) { if (list.Any((x) => x == hero.CharacterObject)) { list.Remove(hero.CharacterObject); troopRoster.AddToCounts(hero.CharacterObject, 1, false, 0, 0, true, -1); maxTroopCount--; } } } List <CharacterObject> heroList = list.Where((x) => x.IsHero).ToList <CharacterObject>(); int num = Math.Min(heroList.Count <CharacterObject>(), maxTroopCount); for (int i = 0; i < num; i++) { troopRoster.AddToCounts(heroList[i], 1, false, 0, 0, true, -1); list.Remove(heroList[i]); } return(troopRoster.ToFlattenedRoster()); }
private static bool OpenAdoptedHeroScreen() { if (!PartyScreenAllowed) { return(false); } if (ScreenManager.TopScreen is not MapScreen) { Game.Current.GameStateManager.PopState(); } var _partyScreenLogic = new PartyScreenLogic(); AccessTools.Field(typeof(PartyScreenManager), "_partyScreenLogic").SetValue(PartyScreenManager.Instance, _partyScreenLogic); AccessTools.Field(typeof(PartyScreenManager), "_currentMode").SetValue(PartyScreenManager.Instance, PartyScreenMode.Normal); var heroRoster = new TroopRoster(null); foreach (var hero in BLTAdoptAHeroCampaignBehavior.GetAllAdoptedHeroes().OrderBy(h => h.Name.Raw().ToLower())) { heroRoster.AddToCounts(hero.CharacterObject, 1); } _partyScreenLogic.Initialize(heroRoster, new(null), MobileParty.MainParty, false, new("Viewers"), 0, (_, _, _, _, _, _, _, _, _) => true, new("BLT Viewer Heroes"), false); _partyScreenLogic.InitializeTrade(PartyScreenLogic.TransferState.NotTransferable, PartyScreenLogic.TransferState.NotTransferable, PartyScreenLogic.TransferState.NotTransferable); _partyScreenLogic.SetTroopTransferableDelegate((_, _, _, _) => false); var partyState = Game.Current.GameStateManager.CreateState <PartyState>(); partyState.InitializeLogic(_partyScreenLogic); Game.Current.GameStateManager.PushState(partyState); return(true); }
private void DailyTick() { MobileParty mainParty = MobileParty.MainParty; TroopRoster memberRoster = mainParty.MemberRoster; if (memberRoster.TotalManCount >= mainParty.Party.PartySizeLimit) { return; } TroopRoster prisonRoster = mainParty.PrisonRoster; if (prisonRoster.TotalManCount == 0) { return; } IRecruitPrisonersCampaignBehavior recruitPrisonerBehavior = Campaign.Current.GetCampaignBehavior <IRecruitPrisonersCampaignBehavior>(); if (recruitPrisonerBehavior == null) { return; } List <Tuple <CharacterObject, int> > recruitablePrisoners = new List <Tuple <CharacterObject, int> >(); for (int i = 0; i < prisonRoster.Count; i++) { CharacterObject prisoner = prisonRoster.GetCharacterAtIndex(i); int numRecruitable = recruitPrisonerBehavior.GetRecruitableNumber(prisoner); if (numRecruitable > 0) { recruitablePrisoners.Add(new Tuple <CharacterObject, int>(prisoner, numRecruitable)); } } recruitablePrisoners.Sort((x, y) => y.Item1.Tier.CompareTo(x.Item1.Tier)); for (int i = 0; i < recruitablePrisoners.Count; i++) { CharacterObject prisoner = recruitablePrisoners[i].Item1; int numRecruitable = recruitablePrisoners[i].Item2; while (numRecruitable > 0) { recruitPrisonerBehavior.SetRecruitableNumber(prisoner, --numRecruitable); prisonRoster.AddToCounts(prisoner, -1, false, 0, 0, true, -1); mainParty.MemberRoster.AddToCounts(prisoner, 1, false, 0, 0, true, -1); if (memberRoster.TotalManCount >= mainParty.Party.PartySizeLimit) { break; } } if (memberRoster.TotalManCount >= mainParty.Party.PartySizeLimit) { break; } } }
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); }
internal static void EndSucceededRevolt(Revolt revolt) { var textObject = new TextObject(GameTexts.RevoltsRevoltEnd); textObject.SetTextVariable("SETTLEMENT", revolt.Settlement.Name); InformationManager.AddQuickInformation(textObject); revolt.SettlementInfo.CurrentFactionInfo.CityRevoltionSucceeded(revolt.Settlement); if (RevolutionsSettings.Instance.RevoltsImperialLoyaltyMechanic && revolt.SettlementInfo.IsCurrentFactionOfImperialCulture && !revolt.SettlementInfo.IsLoyalFactionOfImperialCulture) { revolt.Settlement.OwnerClan.AddRenown(-RevolutionsSettings.Instance.RevoltsImperialRenownLoss); } if (RevolutionsSettings.Instance.RevoltsMinorFactionsMechanic && revolt.IsMinorFaction) { ChangeOwnerOfSettlementAction.ApplyByLeaveFaction(revolt.Party.LeaderHero, revolt.Settlement); revolt.Party.LeaderHero.Clan.AddRenown(RevolutionsSettings.Instance.RevoltsMinorFactionsRenownGainOnWin); foreach (var notable in revolt.Settlement.Notables.Concat(revolt.Settlement.BoundVillages.SelectMany(s => s.Settlement.Notables))) { notable.SetPersonalRelation(revolt.Party.Leader.HeroObject, new Random().Next(5, 25)); } var amountOTroops = (RevolutionsSettings.Instance.RevoltsGeneralBaseSize + (int)(revolt.Settlement.Prosperity * RevolutionsSettings.Instance.RevoltsGeneralProsperityMulitplier)) / 3; var eliteUnits = new TroopRoster(revolt.Party); eliteUnits.AddToCounts(revolt.Party.Leader.Culture.RangedEliteMilitiaTroop, amountOTroops); eliteUnits.AddToCounts(revolt.Party.Leader.Culture.MeleeEliteMilitiaTroop, amountOTroops * 2); revolt.Party.MobileParty.MemberRoster.Add(eliteUnits); SetPartyAiAction.GetActionForPatrollingAroundSettlement(revolt.Party.MobileParty, revolt.Settlement); revolt.Party.MobileParty.Ai.SetDoNotMakeNewDecisions(false); Managers.Revolt.Revolts.Remove(revolt); } if (!RevolutionsSettings.Instance.RevoltsMinorFactionsMechanic || revolt.IsMinorFaction) { return; } revolt.Party.MobileParty.Ai.SetDoNotMakeNewDecisions(false); Managers.Revolt.Revolts.Remove(revolt); }
public static TroopRoster ConstructTroopRoster(PartyTemplateObject template, PartyBase party) { TroopRoster roster = new TroopRoster(party); foreach (PartyTemplateStack stack in template.Stacks) { int num = MBRandom.RandomInt(stack.MinValue, stack.MaxValue); roster.AddToCounts(stack.Character, num); } return(roster); }
private static void SplitRosters(TroopRoster troops1, TroopRoster troops2, TroopRosterElement rosterElement) { // toss a coin (to your Witcher) if (rosterElement.Number == 1) { if (Rng.Next(0, 2) == 0) { troops1.AddToCounts(rosterElement.Character, 1); } else { troops2.AddToCounts(rosterElement.Character, 1); } } else { var half = Math.Max(1, rosterElement.Number / 2); troops1.AddToCounts(rosterElement.Character, half); var remainder = rosterElement.Number % 2; troops2.AddToCounts(rosterElement.Character, Math.Max(1, half + remainder)); } }
private static void OpenScreenAsInventoryOf(CharacterObject character) { var inventoryLogicFieldInfo = AccessTools.Field(typeof(InventoryManager), "_inventoryLogic"); var inventoryLogic = new InventoryLogic(Campaign.Current, null); inventoryLogicFieldInfo.SetValue(InventoryManager.Instance, inventoryLogic); var memberRoster = new TroopRoster(null); memberRoster.AddToCounts(character, 1); inventoryLogic.Initialize(new(), new(), memberRoster, false, true, character, InventoryManager.InventoryCategoryType.None, new FakeMarketData(), false); var state = Game.Current.GameStateManager.CreateState <InventoryState>(); state.InitializeLogic(inventoryLogic); Game.Current.GameStateManager.PushState(state); }
public void Recruit(Settlement settlement) { if (!settlement.IsTown && !settlement.IsCastle) { return; } var town = settlement.Town; if (town.Owner == null || town.Owner.PrisonRoster == null) { return; } if (town.GarrisonParty == null) { town.Settlement.AddGarrisonParty(false); } TroopRoster prisonRoster = town.Owner.PrisonRoster; float[] dailyRecruitedPrisoners = Array.Empty <float>(); PrisonerRecruitmentCalculationModelPatch.GetDailyRecruitedPrisoners(ref dailyRecruitedPrisoners, MobileParty.MainParty); int num = MBRandom.RandomInt(prisonRoster.Count); for (int i = 0; i < prisonRoster.Count; i++) { int index = (i + num) % prisonRoster.Count; CharacterObject characterAtIndex = prisonRoster.GetCharacterAtIndex(index); if (characterAtIndex.Tier > 6 || characterAtIndex.IsHero) { continue; } int tier = characterAtIndex.Tier; if (tier < dailyRecruitedPrisoners.Length && dailyRecruitedPrisoners[tier] > 0f && MBRandom.RandomFloat < dailyRecruitedPrisoners[tier])// { dailyRecruitedPrisoners[tier] -= 1f; if (MBRandom.RandomFloat < (town.Settlement.OwnerClan == Clan.PlayerClan ? 0.8 : 1)) { town.GarrisonParty.MemberRoster.AddToCounts(characterAtIndex, 1); } prisonRoster.AddToCounts(characterAtIndex, -1); } } }
private void SelectMainPartyMember(MenuCallbackArgs args, Action nextStep, int maxNum) { if (null == this._tempMainMobile) { this._tempMainMobile = MBObjectManager.Instance.CreateObject <MobileParty>("sms_sneak_temp_party"); } else { this._tempMainMobile.MemberRoster.Reset(); } int count = MobileParty.MainParty.MemberRoster.Count; TroopRoster strongestTroopRoster = TroopRoster.CreateDummyTroopRoster(); List <Hero> includeHeros = new List <Hero>(); includeHeros.Add(Hero.MainHero); FlattenedTroopRoster strongestAndPriorTroops = GameComponent.GetStrongestAndPriorTroops(MobileParty.MainParty, maxNum, includeHeros); strongestTroopRoster.Add(strongestAndPriorTroops); bool execueted = OpenSlelectTroops(args, strongestTroopRoster, maxNum, new Func <CharacterObject, bool>(this.CanChangeStatusOfTroop), new Action <TroopRoster>((troop) => { DealPatyTroop(troop); nextStep(); })); if (!execueted) { //如果没有执行,就走随机筛选 TroopRoster troopRosters = MobileParty.MainParty.MemberRoster; List <TroopRosterElement> list = troopRosters.GetTroopRoster(); TroopRoster battleTroopRoster = TroopRoster.CreateDummyTroopRoster(); foreach (TroopRosterElement element in list) { if (element.Character.IsHero && !element.Character.IsPlayerCharacter) { if (battleTroopRoster.Count < maxNum) { battleTroopRoster.AddToCounts(element.Character, element.Number); } } } ; DealPatyTroop(battleTroopRoster); nextStep(); } }
private void ExecuteDone() { TroopRoster troopRoster = TroopRoster.CreateDummyTroopRoster(); foreach (SpousesSelectTroopsItemVM current in this.Troops) { if (current.CurrentAmount > 0) { troopRoster.AddToCounts(current.Troop.Character, current.CurrentAmount, false, 0, 0, true, -1); } } this.IsEnabled = false; this._onDone.DynamicInvokeWithLog(new object[] { troopRoster }); }
private static TroopRoster ConstructTroopRoster(PartyTemplateObject pt, int troopNumberLimit = -1) //TODO implement troop number limit. { TroopRoster returned = new TroopRoster(); float gameProcess = MiscHelper.GetGameProcess(); float num = 0.25f + 0.75f * gameProcess; int num2 = MBRandom.RandomInt(2); float num3 = (num2 == 0) ? MBRandom.RandomFloat : (MBRandom.RandomFloat * MBRandom.RandomFloat * MBRandom.RandomFloat * 4f); float num4 = (num2 == 0) ? (num3 * 0.8f + 0.2f) : (1f + num3); float randomFloat = MBRandom.RandomFloat; float randomFloat2 = MBRandom.RandomFloat; float randomFloat3 = MBRandom.RandomFloat; for (int i = 0; i < pt.Stacks.Count; i++) { float f = (pt.Stacks.Count > 0) ? ((float)pt.Stacks[i].MinValue + num * num4 * randomFloat * (float)(pt.Stacks[i].MaxValue - pt.Stacks[i].MinValue)) : 0f; returned.AddToCounts(pt.Stacks[i].Character, MBRandom.RoundRandomized(f), false); } return(returned); }
private static void SortAnyParty(MBBindingList <PartyCharacterVM> toSort, PartyBase party, TroopRoster rosterToSort, PartySort sorter) { if (rosterToSort == null || rosterToSort.Count == 0 || toSort == null || toSort.IsEmpty()) { return; } CharacterObject leaderOfParty = party?.LeaderHero?.CharacterObject; // Sort the list, this is done for the visual unit cards to be properly positioned after the sort // This is not yet persisted to the actual roster, that is done after this. toSort.StableSort(sorter); // Sanity check to ensure the leader is *always* at the top of the party. if (leaderOfParty != null) { var index = toSort.FindIndex((character) => character.Character.Equals(leaderOfParty)); PartyCharacterVM leaderVm = toSort[index]; toSort.RemoveAt(index); toSort.Insert(0, leaderVm); } // Here we manually clear the roster while ignoring the party leader. // Don't use `rosterToSort.Clear()` as that seems to cause the party leader to get unset permanently afterward, which stops upgrades from working. rosterToSort.RemoveIf((item) => item.Character != leaderOfParty); // Re-add the correctly sorted troops to the roster. We need to do it in this janky way due to the fact that we can't easily sort // the underlying roster array. foreach (PartyCharacterVM character in toSort) { if (character.Character != leaderOfParty) { rosterToSort.AddToCounts( character.Troop.Character, character.Troop.Number, false, character.Troop.WoundedNumber, character.Troop.Xp); } } }
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 static void StartRevolt(Settlement settlement) { var textObject = new TextObject(Localization.GameTexts.RevoltsRevoltStart); textObject.SetTextVariable("SETTLEMENT", settlement.Name); InformationManager.AddNotice(new SettlementRebellionMapNotification(settlement, textObject)); InformationManager.AddQuickInformation(textObject); var settlementInfo = Managers.Settlement.Get(settlement); var atWarWithLoyalFaction = settlementInfo.CurrentFaction.IsAtWarWith(settlementInfo.LoyalFaction); Hero leader; if (atWarWithLoyalFaction) { leader = Managers.Faction.GetLordWithLeastFiefs(settlementInfo.LoyalFaction).HeroObject; } else { leader = Managers.Character.CreateRandomLeader(settlementInfo.LoyalFaction?.Leader?.Clan ?? settlement.OwnerClan, settlementInfo); Managers.Character.Get(leader.CharacterObject).IsRevoltKingdomLeader = true; var bannerInfo = Managers.Banner.GetBanner(settlementInfo); var banner = bannerInfo != null ? new Banner(bannerInfo.BannerId) : null; var clan = Managers.Clan.CreateClan(leader, null, null, banner); Managers.Clan.Get(leader.Clan).IsRevoltClan = true; textObject = new TextObject(Localization.GameTexts.RevoltsMinorFactionKingdom); textObject.SetTextVariable("SETTLEMENT", settlement.Name); Managers.Kingdom.CreateKingdom(leader, textObject, textObject, banner ?? clan.Banner, false); Managers.Kingdom.Get(leader.Clan.Kingdom).IsRevoltKingdom = true; } var mobileParty = Managers.Party.CreateMobileParty(leader, null, settlement.GatePosition, settlement, !atWarWithLoyalFaction, true); var amountOfTroops = (RevolutionsSettings.Instance.RevoltsGeneralBaseSize + (int)(settlement.Prosperity * RevolutionsSettings.Instance.RevoltsGeneralProsperityMulitplier)) / 3; var basicUnits = new TroopRoster(); basicUnits.AddToCounts(leader.Culture.RangedMilitiaTroop, amountOfTroops); basicUnits.AddToCounts(leader.Culture.MeleeMilitiaTroop, amountOfTroops * 2); mobileParty.MemberRoster.Add(basicUnits); if (settlement.MilitaParty != null && settlement.MilitaParty.CurrentSettlement == settlement && settlement.MilitaParty.MapEvent == null) { foreach (var troopRosterElement in settlement.MilitaParty.MemberRoster) { mobileParty.AddElementToMemberRoster(troopRosterElement.Character, troopRosterElement.Number, false); } settlement.MilitaParty.RemoveParty(); } mobileParty.ChangePartyLeader(mobileParty.Party.Owner.CharacterObject, false); if (!FactionManager.IsAtWarAgainstFaction(leader.MapFaction, settlement.MapFaction)) { DeclareWarAction.Apply(leader.MapFaction, settlement.MapFaction); } var revolt = new Revolt(mobileParty.Party.Id, settlement, !atWarWithLoyalFaction); Managers.Revolt.Revolts.Add(revolt); settlementInfo.HasRebellionEvent = true; if (settlementInfo.Garrision == null || settlementInfo.Garrision.TotalStrength == 0) { RevoltBehavior.EndSucceededRevolt(revolt); return; } mobileParty.Ai.SetDoNotMakeNewDecisions(true); StartBattleAction.Apply(mobileParty.Party, settlementInfo.Garrision); }
private static MobileParty FillPartyWithTroopsAndInit(Hero leader, Settlement target) { MobileParty rebelParty = MBObjectManager.Instance.CreateObject <MobileParty>(leader.CharacterObject.Name.ToString() + "_" + leader.Id); try { rebelParty.Initialize(); TroopRoster roster = new TroopRoster(); int basicTroopAmount = 128; TroopRoster basicUnits = new TroopRoster(); basicUnits.AddToCounts(leader.Culture.BasicTroop, basicTroopAmount); foreach (var upgrade1 in leader.Culture.BasicTroop.UpgradeTargets) { basicUnits.AddToCounts(upgrade1, basicTroopAmount / 2); foreach (var upgrade2 in upgrade1.UpgradeTargets) { basicUnits.AddToCounts(upgrade2, basicTroopAmount / 2); foreach (var upgrade3 in upgrade2.UpgradeTargets) { basicUnits.AddToCounts(upgrade3, basicTroopAmount / 4); foreach (var upgrade4 in upgrade3.UpgradeTargets) { basicUnits.AddToCounts(upgrade4, basicTroopAmount / 8); } } } } roster.Add(basicUnits); int eliteTroopAmount = 64; TroopRoster eliteUnits = new TroopRoster(); eliteUnits.AddToCounts(leader.Culture.EliteBasicTroop, eliteTroopAmount); foreach (var upgrade1 in leader.Culture.EliteBasicTroop.UpgradeTargets) { eliteUnits.AddToCounts(upgrade1, eliteTroopAmount / 2); foreach (var upgrade2 in upgrade1.UpgradeTargets) { eliteUnits.AddToCounts(upgrade2, eliteTroopAmount / 2); foreach (var upgrade3 in upgrade2.UpgradeTargets) { eliteUnits.AddToCounts(upgrade3, eliteTroopAmount / 4); foreach (var upgrade4 in upgrade3.UpgradeTargets) { eliteUnits.AddToCounts(upgrade4, eliteTroopAmount / 8); } } } } roster.Add(eliteUnits); TroopRoster prisoners = new TroopRoster { IsPrisonRoster = true }; rebelParty.Party.Owner = leader; rebelParty.MemberRoster.AddToCounts(leader.CharacterObject, 1, false, 0, 0, true, 0); rebelParty.SetAsMainParty(); rebelParty.InitializeMobileParty(new TextObject( leader.CharacterObject.GetName().ToString(), null), roster, prisoners, target.GatePosition, 0.0f, 0.0f); foreach (ItemObject item in ItemObject.All) { if (item.IsFood) { rebelParty.ItemRoster.AddToCounts(item, 150); break; } } rebelParty.HomeSettlement = target.BoundVillages[0].Settlement; rebelParty.Quartermaster = leader; } catch (Exception e) { Log.Info("Exception when trying to create new Army"); Log.Error(e); } return(rebelParty); }