public void AddNewRecruits(MobileParty party, CharacterObject prisoner, int amount) { var behavior = Campaign.Current.GetCampaignBehavior <RecruitPrisonersCampaignBehavior>(); var recruitable = behavior.GetRecruitableNumber(prisoner); var newTotal = Math.Min(recruitable + amount, party.PrisonRoster.GetTroopCount(prisoner)); behavior.SetRecruitableNumber(prisoner, newTotal); }
public static void PostFix1(ref float __result, MobileParty __instance) { if (__instance != null && __instance.LeaderHero != null && BuffManager.Instance.IsBuffCurrentlyActiveForHero(__instance.LeaderHero, "bannerbuff_partyspeedbuff_1")) { __result += 3f; } }
public static void PostFix2(ref StatExplainer __result, MobileParty __instance) { if (__instance != null && __instance.LeaderHero != null && BuffManager.Instance.IsBuffCurrentlyActiveForHero(__instance.LeaderHero, "bannerbuff_partyspeedbuff_1")) { __result.AddLine("Active Speed Buff", 3f, StatExplainer.OperationType.Add); } }
public static void GetPrice(EquipmentElement itemRosterElement, MobileParty clientParty, PartyBase merchant, bool isSelling, float inStoreValue, float supply, float demand, ref int __result) { if ((clientParty?.IsMainParty ?? false) && isSelling) { __result *= BannerlordCheatsSettings.Instance.SellingPriceMultiplier; } }
private void OnHourlyTickEvent(MobileParty mobileParty) { Hero companion = mobileParty.LeaderHero; if (mobileParty == MobileParty.MainParty || companion == null || !mobileParty.IsLordParty || companion.Clan != Clan.PlayerClan) { return; } Settlement target = mobileParty.TargetSettlement; if (mobileParty.DefaultBehavior != AiBehavior.PatrolAroundPoint || target.OwnerClan != Clan.PlayerClan) { return; } if (mobileParty.Position2D.DistanceSquared(target.Position2D) > MinPatrolDistance) { //InformationManager.DisplayMessage(new InformationMessage(companion.Name + " too far away from " + target.Name)); mobileParty.SetMoveGoToSettlement(target); return; } //InformationManager.DisplayMessage(new InformationMessage(companion.Name + " patrolling around " + target.Name)); int companion_relation; foreach (Hero notable in target.Notables) { companion_relation = CharacterRelationManager.GetHeroRelation(companion, notable) + 1; if (companion_relation % HoursRequirement == 0) { // reset companion personal relation companion_relation = 0; // increase player relation int oldRelation = notable.GetRelation(Hero.MainHero); ChangeRelationAction.ApplyPlayerRelation(notable, 1, false, false); int newRelation = notable.GetRelation(Hero.MainHero); int relation_change = newRelation - oldRelation; if (relation_change > 0) { TextObject textObject = GameTexts.FindText("str_your_relation_increased_with_notable", null); TextObject heroText = new TextObject(); ZenDzeeCompatibilityHelper.SetTextVariable(heroText, "NAME", notable.Name); ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "HERO", heroText); ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "VALUE", newRelation); ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "MAGNITUDE", relation_change); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString())); } } CharacterRelationManager.SetHeroRelation(companion, notable, companion_relation); } }
internal static void PartyDailyTick(MobileParty __instance) { if (!__instance.IsActive) { return; } SubModule.Instance.InternalExpController.DailyTick(__instance); }
private static void Postfix(MobileParty __instance) { if (!IsValidParty(__instance)) { return; } TrySplitParty(__instance); }
public BaseMobileParty(MobileParty mobileParty) { if (mobileParty == null) { return; } Name = mobileParty.Name.ToString(); }
public static void CalculateFinalSpeed(MobileParty mobileParty, float baseSpeed, StatExplainer explanation, ref float __result) { var percentage = BannerlordCheatsSettings.Instance.NpcMapSpeedPercentage / 100f; if (!mobileParty.IsMainParty) { __result *= percentage; } }
public static void CalculateFinalSpeed(MobileParty mobileParty, float baseSpeed, StatExplainer explanation, ref float __result) { var multiplier = BannerlordCheatsSettings.Instance.MapSpeedFactor; if (mobileParty?.IsMainParty ?? false) { __result *= multiplier; } }
private void AddRandomTroopToParty(MobileParty targetParty) { int num = 5 + AlertRate * this._alertCoefficient; CharacterObject character = CharacterObject.All.Where(obj => obj.IsSoldier && obj.Tier >= 4 && obj.Culture == Settlement.CurrentSettlement.Culture).ToList().GetRandomElement(); targetParty.MemberRoster.AddToCounts(character, num); character = CharacterObject.All.Where(obj => obj.IsInfantry && obj.IsSoldier && obj.Tier < 4 && obj.Culture == Settlement.CurrentSettlement.Culture).ToList().GetRandomElement(); targetParty.MemberRoster.AddToCounts(character, num); }
private void MobilePartyDestroyed(MobileParty mobileParty, PartyBase party) { var partyInfo = Managers.Party.GetInfo(party) ?? Managers.Party.GetInfo(mobileParty.Party); if (partyInfo != null && partyInfo.IsCustomParty) { Managers.Party.Remove(mobileParty.Party.Id); } }
public void AddPlayerControllerParty(MobileParty party) { if (party == null) { throw new ArgumentNullException(); } m_PlayerParties.Add(party); }
public void OnSettlementEntered(MobileParty mobileParty, Settlement settlement, Hero hero) { if (mobileParty != MobileParty.MainParty || !settlement.IsTown) { return; } this.AddLoadoutDialogues(this.campaignGame, settlement); }
public Militia(MobileParty mobileParty, TroopRoster party, TroopRoster prisoners) { Banner = Banners.GetRandomElement(); BannerKey = Banner.Serialize(); Spawn(mobileParty, party, prisoners); TrainMilitia(); PartyMilitiaMap.Add(MobileParty, this); LogMilitiaFormed(MobileParty); }
internal void DailyTick(MobileParty party) { var expController = SubModule.Instance.InternalExpController; foreach (var controller in expController.Controllers) { controller.Value.DailyTick(party); } }
private void OnCommonAreaFightOccured(MobileParty p1, MobileParty p2, Hero h, Settlement s) { if (p1 == null || p2 == null || s == null) { return; } ModDebug.ShowMessage("Fight at " + s.Name, DebugMessageType.Development); }
/* * When the lord leaves the settlement, return to dungeon all the prisoners * whom he borrowed for entertainment. */ private static void OnSettlementLeft(MobileParty party, Settlement settlement) { if (party == null || settlement == null || party.LeaderHero == null) { return; } LordLeavesAlonePrisoners(settlement, party); }
private void CalculateFoodVarietyMoraleBonus(MobileParty party, ref ExplainedNumber result) { float num; switch (party.ItemRoster.FoodVariety) { case 0: case 1: num = -2f; break; case 2: num = -1f; break; case 3: num = 0.0f; break; case 4: num = 1f; break; case 5: num = 2f; break; case 6: num = 3f; break; case 7: num = 5f; break; case 8: num = 6f; break; case 9: num = 7f; break; case 10: num = 8f; break; default: num = 2f; break; } if ((double)num == 0.0) { return; } result.Add(num, this._foodBonusMoraleText); }
public static void SetupKingdomParties(MBReadOnlyList <MobileParty> mobileParties) { if (mobileParties == null) { return; } Dictionary <string, MobileParty> existingParties = new Dictionary <string, MobileParty>(); List <MobileParty> tempList = mobileParties.ToList(); tempList.ForEach(p => { // Campaign.Current.MobileParties can have some invalid entries, make sure only valid MobileParties get added for processing if (p.Leader?.Name != null && !existingParties.ContainsKey(p.Leader.Name.ToString())) { existingParties.Add(p.Leader.Name.ToString(), p); } }); if (existingParties.Count > 0 && KingdomConfigs.Any()) { KingdomConfigs.ForEach(kC => { Dictionary <string, KingdomLocation> lordLocations = LoadLocationsForKingdomConfiguration(kC); if (!lordLocations.IsEmpty() && lordLocations.Count > 0) { string[] names = new string[lordLocations.Count]; lordLocations.Keys.CopyTo(names, 0); List <string> lordsToAdd = names.ToList(); lordsToAdd.ForEach(lord => { if (existingParties.ContainsKey(lord)) { MobileParty p = existingParties[lord]; if (p?.Leader?.Name != null) { KingdomLocation location = lordLocations[lord]; Settlement targetSettlement = Settlement.Find(location.SettlementName); // Here we assign ownership of the targetSettlement to the KingdomLeaderId defined in config.xml if (p.Leader.StringId.Equals(kC.kingdomLeaderId)) { TaleWorlds.CampaignSystem.Actions.ChangeOwnerOfSettlementAction.ApplyByDefault(p.LeaderHero, targetSettlement); } // Move the party's position, use the XOffset and YOffset from the relevant locations.xml p.Position2D = new Vec2(targetSettlement.Position2D.X + location.XOffset, targetSettlement.Position2D.Y + location.YOffset); // Make them patrol around their location p.SetMovePatrolAroundSettlement(targetSettlement); } } }); } }); } }
/* * Private functions pulled from decompiled binary (unmodified) */ // Token: 0x06002007 RID: 8199 RVA: 0x00082F98 File Offset: 0x00081198 private static void AddCargoStats(MobileParty mobileParty, ref int numberOfAvailableMounts, ref float totalWeightCarried, ref int herdSize) { ItemRoster itemRoster = mobileParty.ItemRoster; int numberOfPackAnimals = itemRoster.NumberOfPackAnimals; int numberOfLivestockAnimals = itemRoster.NumberOfLivestockAnimals; herdSize += numberOfPackAnimals + numberOfLivestockAnimals; numberOfAvailableMounts += itemRoster.NumberOfMounts; totalWeightCarried += itemRoster.TotalWeight; }
// didnt end up needing this leaving in case I do public static bool Prefix(MobileParty spawnedParty, BannerInvestigationQuestBehavior __instance) { Type t = AccessTools.TypeByName("Storymode.BannerInvestigationQuestBehavior+BannerInvestigationQuest"); Dictionary <Hero, bool> _noblesToTalk = (Dictionary <Hero, bool>)AccessTools.Field(t, "_noblesToTalk").GetValue(__instance); if (spawnedParty.LeaderHero != null && _noblesToTalk.ContainsKey(spawnedParty.LeaderHero) && !_noblesToTalk[spawnedParty.LeaderHero]) { } return(false); }
static bool Prefix(MobileParty party, ref ExplainedNumber result, TextObject ____partySizeMoraleText) { int num = QuestPartySizeHelper.GetPartySize(party) - party.Party.PartySizeLimit; if (num > 0) { result.Add(-1f * (float)Math.Sqrt((double)num), ____partySizeMoraleText); } return(false); }
public static void Prefix(MobileParty sellerParty, TroopRoster prisoners, Settlement currentSettlement, bool applyGoldChange) { if (currentSettlement != null) { currentSettlement.Prosperity += prisoners.TotalRegulars * SubModule.Settings.PrisonerProsperityValue; } }
static void Postfix(MobileParty party, ref ExplainedNumber __result) { if (party.IsCaravan && party.Party?.Owner != null && party.Party.Owner == Hero.MainHero && BannerlordTweaksSettings.Instance is { } settings) { float num = settings.PlayerCaravanPartySize; float num2 = __result.ResultNumber; float num3 = num - num2; __result.Add((int)Math.Ceiling(num3), null); } }
private void AddTroops() { Debug.WriteLine("adding troops, count: " + troopRosterRemovedTroops.Count()); MobileParty heroParty = MobileParty.MainParty; TroopRoster troops = heroParty.MemberRoster; troops.Add(troopRosterRemovedTroops); troopRosterRemovedTroops = new TroopRoster(); areTroopsRemoved = false; }
public override int GetTotalWage(MobileParty mobileParty, StatExplainer explanation = null) { var totalWage = base.GetTotalWage(mobileParty, explanation); if (mobileParty.IsMainParty) { totalWage = (int)Math.Round(totalWage * (CustomCampaignOptionsBehaviour.Instance.Wages / 100f)); } return(totalWage); }
public void InitRecruiterParty(MobileParty recruiter, TextObject name, Clan faction, Settlement homeSettlement) { recruiter.Name = name; recruiter.IsMilitia = true; recruiter.HomeSettlement = homeSettlement; recruiter.Party.Owner = faction.Leader; recruiter.SetInititave(0f, 1f, 1E+08f); recruiter.Party.Visuals.SetMapIconAsDirty(); generateFood(recruiter); }
private void GetPartySizeMoraleEffect(MobileParty party, ref ExplainedNumber result) { int num = party.Party.NumberOfAllMembers - party.Party.PartySizeLimit; if (num <= 0) { return; } result.Add(-1f * (float)Math.Sqrt((double)num), this._partySizeMoraleText); }
public bool CheckUnknownBehavior(MobileParty patrol) { TextObject textObject = new TextObject("{=QXBf26Rv}Unknown Behavior", null); if (CampaignUIHelper.GetMobilePartyBehaviorText(patrol) == textObject.ToString()) { return(true); } return(false); }