private static int CalculateGarrisonChangeInternal(
            Settlement settlement,
            StatExplainer explanation = null)
        {
            ExplainedNumber result = new ExplainedNumber(0.0f, explanation, (TextObject)null);

            if (settlement.IsTown || settlement.IsCastle)
            {
                double loyalty = (double)settlement.Town.Loyalty;
                if (settlement.IsStarving)
                {
                    float foodChange = settlement.Town.FoodChange;
                    int   num        = !settlement.Town.Owner.IsStarving || (double)foodChange >= -19.0 ?
                                       0 : (int)(((double)foodChange + 10.0) * SubModule.Settings.garrisonFoodConsumpetionMultiplier / 10.0);

                    result.Add((float)num, LightSettlementGarrisonModel._foodShortageText);
                }
                if (settlement.Town.GarrisonParty != null && ((double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)result.ResultNumber) / (double)settlement.Town.GarrisonParty.Party.PartySizeLimit > (double)settlement.Town.GarrisonParty.PaymentRatio)
                {
                    int num = 0;
                    do
                    {
                        ++num;
                    }while (((double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)result.ResultNumber - (double)num) / (double)settlement.Town.GarrisonParty.Party.PartySizeLimit >= (double)settlement.Town.GarrisonParty.PaymentRatio && (double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)result.ResultNumber - (double)num > 0.0 && num < 20);
                    result.Add((float)-num, LightSettlementGarrisonModel._paymentIsLess);
                }
            }
            LightSettlementGarrisonModel.GetSettlementGarrisonChangeDueToIssues(settlement, ref result);
            return((int)result.ResultNumber);
        }
Beispiel #2
0
        private static void CalculateInfluenceChangePostfix(Clan clan, ref ExplainedNumber __result)
        {
            if (!Settings.Instance !.EnableInfluenceBalancing)
            {
                return;
            }

            /// Corruption

            if (Settings.Instance !.EnableCorruption)
            {
                float corruption = clan.GetCorruption();

                if (corruption >= 0.01f)
                {
                    __result.Add(-corruption, _TCorruption);
                }
            }

            /// Influence Decay

            if (Settings.Instance !.EnableInfluenceDecay && clan.Influence > Settings.Instance !.InfluenceDecayThreshold)
            {
                float decayFactor = Settings.Instance !.InfluenceDecayPercentage / 100f;
                int   decay       = (int)(decayFactor * (clan.Influence - Settings.Instance !.InfluenceDecayThreshold));

                if (decay > 0)
                {
                    __result.Add(-decay, _TInfluenceDecay);
                }
            }

            /// Minimum Influence Gain (Maximum Influence Loss)
            __result.LimitMin(-Settings.Instance !.MaximumInfluenceLoss);
        }
Beispiel #3
0
        public void PatchSpeedDueToFriendiness(ref MobileParty mobileParty, ref ExplainedNumber bonuses, ref Settlement closest_settlement)
        {
            if (closest_settlement.MapFaction == null)
            {
                // Training field.
                return;
            }

            if (mobileParty.MapFaction == null)
            {
                InformationManager.DisplayMessage(new InformationMessage("mobile party faction is null"));
                return;
            }

            if (mobileParty.MapFaction.IsAtWarWith(closest_settlement.MapFaction))
            {
                bonuses.Add(-0.5f, new TextObject("Unfriendly Territory"));
                PatchSpeedDueToCulture(ref mobileParty, ref bonuses, ref closest_settlement);
            }
            if (mobileParty.MapFaction.StringId == closest_settlement.MapFaction.StringId)
            {
                bonuses.Add(0.5f, new TextObject("Friendly Territory"));
                PatchSpeedDueToCulture(ref mobileParty, ref bonuses, ref closest_settlement);
            }
        }
Beispiel #4
0
        private void ImperialChange(SettlementInfo settlementInfo, ref ExplainedNumber explainedNumber)
        {
            if (!RevolutionsSettings.Instance.RevoltsImperialLoyaltyMechanic)
            {
                return;
            }

            if (settlementInfo.IsOfImperialCulture)
            {
                if (settlementInfo.IsCurrentFactionOfImperialCulture)
                {
                    explainedNumber.Add(3, new TextObject(GameTexts.RevoltsLoyaltyCalculationImperialLoyalty));
                }
                else
                {
                    explainedNumber.Add(-1, new TextObject(GameTexts.RevoltsLoyaltyCalculationForeignRule));
                }
            }
            else
            {
                if (settlementInfo.IsCurrentFactionOfImperialCulture)
                {
                    explainedNumber.Add(-1, new TextObject(GameTexts.RevoltsLoyaltyCalculationImperialAversion));
                }

                if (settlementInfo.LoyalFaction.StringId != settlementInfo.CurrentFactionId)
                {
                    explainedNumber.Add(1, new TextObject(GameTexts.RevoltsLoyaltyCalculationForeignRule));
                }
            }
        }
        public override float CalculateTownFoodStocksChange(Town town, StatExplainer explanation = null)
        {
            float baseVal = base.CalculateTownFoodStocksChange(town, explanation);

            if (Settings.Instance.SettlementFoodBonusEnabled)
            {
                try
                {
                    ExplainedNumber en = new ExplainedNumber(baseVal, explanation);
                    explanation?.Lines.Remove(explanation.Lines.Last());

                    if (town.IsCastle)
                    {
                        en.Add(Settings.Instance.CastleFoodBonus, new TextObject("Military rations"));
                    }
                    else if (town.IsTown)
                    {
                        en.Add(Settings.Instance.TownFoodBonus, new TextObject("Citizen food drive"));
                    }

                    return(en.ResultNumber);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"An error occurred in TweakedSettlementFoodModel: {ex.ToStringFull()}");
                    return(baseVal);
                }
            }
            else
            {
                return(baseVal);
            }
        }
        public override float CalculateProsperityChange(Town fortification, StatExplainer explanation = null)
        {
            var result = base.CalculateProsperityChange(fortification, explanation);

            if (fortification.Owner.IsStarving || result < 0)
            {
                return(result);
            }

            var prosperity = fortification.Owner.Settlement.Prosperity;

            ExplainedNumber explainedNumber = new ExplainedNumber(0f, explanation, null);
            float           foodChange      = Campaign.Current.Models.SettlementFoodModel.CalculateTownFoodStocksChange(fortification, null);

            if (foodChange < -1 && Math.Abs(fortification.FoodStocks / foodChange) < 20 && prosperity < 1000 && result > 1)
            {
                explainedNumber.Add(-result, _surplusFoodText);
            }
            else if (SettlementSetting.Instance.boostProsperityGrowth > 0)
            {
                var factor = SettlementSetting.Instance.boostProsperityGrowth * result > 1 ? result : 1;
                explainedNumber.Add((float)factor, _surplusFoodText);
            }


            var r = result + explainedNumber.ResultNumber;

            if (prosperity > 11000 && r > 1f)
            {
                explainedNumber.Add((int)Math.Sqrt(r) - r, _surplusFoodText);
            }

            return(result + explainedNumber.ResultNumber);
        }
        public override float CalculateMilitiaChange(Settlement settlement, StatExplainer explanation = null)
        {
            float           baseVal = base.CalculateMilitiaChange(settlement, explanation);
            ExplainedNumber en      = new ExplainedNumber(0f, explanation);

            en.Add(baseVal);
            try
            {
                if (Settings.Instance.SettlementMilitiaBonusEnabled)
                {
                    if (settlement.IsCastle)
                    {
                        en.Add(Settings.Instance.CastleMilitiaBonus, new TextObject("Recruitment drive"));
                    }
                    if (settlement.IsTown)
                    {
                        en.Add(Settings.Instance.TownMilitiaBonus, new TextObject("Citizen militia"));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An error occurred in TweakedSettlementMilitiaModule:\n\n{ex.ToStringFull()}");
            }
            return(en.ResultNumber);
        }
Beispiel #8
0
        private static int CalculateGarrisonChangeInternal(Settlement settlement, StatExplainer explanation = null)
        {
            ExplainedNumber explainedNumber = new ExplainedNumber(0f, explanation, null);

            if (settlement.IsTown || settlement.IsCastle)
            {
                float loyalty = settlement.Town.Loyalty;
                if (settlement.IsStarving)
                {
                    float foodChange = settlement.Town.FoodChange;
                    int   num        = (settlement.Town.Owner.IsStarving && foodChange < -19f) ? ((int)((foodChange + 10f) / 10f)) : 0;
                    explainedNumber.Add((float)num, WangSettlementGarrisonModel._foodShortageText, null);
                }
                if (settlement.Town.GarrisonParty != null && ((float)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + explainedNumber.ResultNumber) / (float)settlement.Town.GarrisonParty.Party.PartySizeLimit > settlement.Town.GarrisonParty.PaymentRatio)
                {
                    int num2 = 0;
                    do
                    {
                        num2++;
                    }while (((float)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + explainedNumber.ResultNumber - (float)num2) / (float)settlement.Town.GarrisonParty.Party.PartySizeLimit >= settlement.Town.GarrisonParty.PaymentRatio && (float)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + explainedNumber.ResultNumber - (float)num2 > 0f && num2 < 20);
                    explainedNumber.Add((float)(-(float)num2), WangSettlementGarrisonModel._paymentIsLess, null);
                }
            }
            WangSettlementGarrisonModel.GetSettlementGarrisonChangeDueToIssues(settlement, ref explainedNumber);
            return((int)explainedNumber.ResultNumber);
        }
Beispiel #9
0
        public void PatchSpeedDueToCulture(ref MobileParty mobileParty, ref ExplainedNumber bonuses, ref Settlement closest_settlement)
        {
            if (closest_settlement.Culture == null)
            {
                // Training field.
                return;
            }

            if (mobileParty.LeaderHero == null)
            {
                return;
            }

            if (mobileParty.LeaderHero.Culture == null)
            {
                InformationManager.DisplayMessage(new InformationMessage("mobile party faction is null"));
                return;
            }

            if (closest_settlement.Culture == mobileParty.Leader.Culture)
            {
                bonuses.Add(0.5f, new TextObject("Friendly Culture"));
            }
            else
            {
                bonuses.Add(-0.5f, new TextObject("Unfriendly Culture"));
            }
        }
 public override void CalculateClanExpenses(Clan clan, ref ExplainedNumber goldChange, bool applyWithdrawals = false)
 {
     foreach (MobileParty party in clan.Parties)
     {
         if (party.IsActive && (party.IsLordParty || party.IsGarrison || party.IsCaravan))
         {
             int partyWage = this.CalculatePartyWage(party, applyWithdrawals);
             int amount    = party.LeaderHero == null || party.LeaderHero == clan.Leader || (party.IsCaravan || party.LeaderHero.Gold > 10000) ? 0 : (party.LeaderHero.Gold < 5000 ? (int)((double)(5000 - party.LeaderHero.Gold) / 10.0) : 0);
             if (applyWithdrawals)
             {
                 float num = (float)clan.Gold + MathF.Abs(goldChange.ResultNumber);
                 int   paymentAmount;
                 if ((double)num > (double)(partyWage + amount))
                 {
                     paymentAmount = partyWage;
                     if (amount > 0)
                     {
                         GiveGoldAction.ApplyBetweenCharacters((Hero)null, party.LeaderHero, amount, true);
                     }
                 }
                 else
                 {
                     paymentAmount = (int)num > 0 ? (int)num : 0;
                     if (paymentAmount > partyWage)
                     {
                         paymentAmount = partyWage;
                     }
                 }
                 HardmodeClanFinanceModel.ApplyMoraleEffect(party, partyWage, paymentAmount);
             }
             TextObject desription1 = new TextObject("{=rhKxsdtz} {PARTY_NAME} wages", (Dictionary <string, TextObject>)null);
             desription1.SetTextVariable("PARTY_NAME", party.Name);
             goldChange.Add((float)-partyWage, desription1);
             if (party.LeaderHero != null && party.LeaderHero != clan.Leader && amount > 0)
             {
                 TextObject desription2 = new TextObject("{=tetGlwTx} {PARTY_NAME} finance help", (Dictionary <string, TextObject>)null);
                 desription2.SetTextVariable("PARTY_NAME", party.Name);
                 goldChange.Add((float)-amount, desription2);
             }
         }
     }
     if (clan.MapFaction == null || !clan.MapFaction.IsKingdomFaction || clan.Leader != clan.MapFaction.Leader)
     {
         return;
     }
     foreach (Clan clan1 in ((Kingdom)clan.MapFaction).Clans)
     {
         if (!clan1.IsUnderMercenaryService && clan1 != clan && clan1.Fortifications.Count == 0)
         {
             TextObject desription = new TextObject("{=*} King's support", (Dictionary <string, TextObject>)null);
             int        num1       = ((clan1 == Clan.PlayerClan ? 1 : 0) + clan1.CommanderHeroes.Count) * 100;
             int        num2       = clan.Leader.Gold > num1 ? num1 : clan.Leader.Gold;
             goldChange.Add((float)-num2, desription);
         }
     }
 }
        private int CalculateGarrisonPartySizeLimit(MobileParty party, StatExplainer explanation)
        {
            ExplainedNumber result = new ExplainedNumber(0.0f, explanation, (TextObject)null);

            result.Add(200f, this._baseSizeText);
            result.Add((float)this.GetLeadershipSkillLevelEffect(party, LimitType.GarrisonPartySizeLimit), this._leadershipSkillLevelBonusText);
            result.Add((float)this.GetTownBonus(party), this._townBonusText);
            this.AddGarrisonOwnerPerkEffects(party.CurrentSettlement, ref result);
            this.AddSettlementProjectBonuses(party.Party, ref result);
            return((int)result.ResultNumber);
        }
        private int CalculateMobilePartyPrisonerSizeLimitInternal(
            PartyBase party,
            StatExplainer explanation)
        {
            ExplainedNumber result = new ExplainedNumber(0.0f, explanation, (TextObject)null);

            result.Add(10f, this._baseSizeText);
            result.Add((float)this.GetCurrentPartySizeEffect(party), this._currentPartySizeBonusText);
            this.AddMobilePartyLeaderPrisonerSizePerkEffects(party, ref result);
            if (FixedPartySizeLimitModel._additionalPrisonerSizeAsCheat != 0 && party.IsMobile && party.MobileParty.IsMainParty)
            {
                result.Add((float)FixedPartySizeLimitModel._additionalPrisonerSizeAsCheat, new TextObject("{=eaSlwKRY}Additional size from extra prisoner cheat", (Dictionary <string, TextObject>)null));
            }
            return((int)result.ResultNumber);
        }
 static bool Prefix(DefaultCharacterDevelopmentModel __instance, int attributeValue, int focusValue, TextObject attributeName, StatExplainer explainer, ref int __result)
 {
     if (explainer != null)
     {
         ExplainedNumber explainedNumber = new ExplainedNumber(0.0f, explainer, (TextObject)null);
         explainedNumber.Add(SKILLLEVEL, _LevelText);
         explainedNumber.Add(attributeValue * Reworked_SkillsSubModule.__ATTR_VALUE, attributeName);
         explainedNumber.Add(focusValue * Reworked_SkillsSubModule.__FOCUS_VALUE, Patch3.desription);
         explainedNumber.LimitMin(0.0f);
         __result = (int)explainedNumber.ResultNumber;
         return(false);
     }
     __result = (int)Reworked_SkillsSubModule.__LEANRINGLIMIT;
     return(false);
 }
        private static void Postfix(ref int __result, MobileParty party, StatExplainer explanation)
        {
            var perk = ActivePatch._perk;
            var hero = party.LeaderHero;

            if (hero == null || hero.Clan?.Kingdom?.RulingClan?.Leader != hero)
            {
                return;
            }

            if (!hero.GetPerkValue(perk))
            {
                return;
            }

            var kingdomClans = hero.Clan?.Kingdom?.Clans;

            if (kingdomClans == null)
            {
                return;
            }

            var extra = (int)Math.Max(0, (kingdomClans.Count() - 1) * perk.PrimaryBonus);

            if (extra <= 0)
            {
                return;
            }

            var explainedNumber = new ExplainedNumber(__result, explanation);

            explainedNumber.Add(extra, perk.Name);
            __result = (int)explainedNumber.ResultNumber;
        }
Beispiel #15
0
        private static void Postfix(Clan clan, ref ExplainedNumber goldChange, bool applyWithdrawals = false)
        {
            foreach (var pair in SlaveEstateBehavior.SlaveEstates)
            {
                int         wage        = 0;
                SlaveEstate slaveEstate = pair.Value;
                Village     village     = pair.Key;
                if (slaveEstate.Guards == null)
                {
                    slaveEstate.Guards = TroopRoster.CreateDummyTroopRoster();
                }
                else
                {
                    foreach (TroopRosterElement troop in slaveEstate.Guards)
                    {
                        wage += troop.Number * troop.Character.TroopWage;
                    }
                }

                if (wage > 0)
                {
                    goldChange.Add(-1 * wage, new TextObject("Wage of slave estate guards at " + village.Name.ToString()));
                }
            }
        }
Beispiel #16
0
        private static void Postfix(ref float __result, Town fortification, StatExplainer explanation)
        {
            var perk = ActivePatch._perk;
            var hero = fortification.Settlement?.OwnerClan?.Leader;

            if (hero == null || !hero.GetPerkValue(perk) ||
                fortification.Settlement.Parties.Count(x => x.LeaderHero == fortification.Settlement.OwnerClan.Leader) <= 0)
            {
                return;
            }

            var explainedNumber = new ExplainedNumber(__result, explanation);

            if (explanation.Lines.Count > 0)
            {
                explanation.Lines.RemoveAt(explanation.Lines.Count - 1);
            }

            var extra = explanation.Lines.Where(line => line.Number > 0).Sum(line => line.Number);

            if (extra < float.Epsilon)
            {
                return;
            }

            explainedNumber.Add(extra * perk.PrimaryBonus - extra, perk.Name);
            __result = explainedNumber.ResultNumber;
        }
Beispiel #17
0
 public static void Postfix(
     Clan clan,
     ref ExplainedNumber goldChange,
     bool applyWithdrawals = false)
 {
     goldChange.Add(EntrepreneurModel.TotalPlayerRevenue, new TextObject("Revenue from acres"));
 }
 private static void Postfix(MobileParty party, ref ExplainedNumber result)
 {
     if (party.ItemRoster.FoodVariety > 10)
     {
         result.Add(party.ItemRoster.FoodVariety - 4f, GameTexts.FindText("str_food_bonus_morale", (string)null));
     }
 }
Beispiel #19
0
        static void Postfix(PartyBase party, float renownValueOfBattle, float contributionShare, ref ExplainedNumber result, ref float __result)
        {
            if ((BannerlordTweaksSettings.Instance is { } settings&& party.LeaderHero != null) && (settings.BattleRewardApplyToAI || party.LeaderHero == Hero.MainHero))
            {
                float battleRenownMultiplier = settings.BattleRenownMultiplier;
                battleRenownMultiplier -= 1f;
                if (party.LeaderHero == Hero.MainHero && settings.BattleRewardShowDebug)
                {
                    String BTTweak = "";

                    if ((float)Math.Round((double)battleRenownMultiplier * 100f, 2) > 0f)
                    {
                        BTTweak = "+";
                    }

                    DebugHelpers.DebugMessage("Renown Value = " + (float)Math.Round((double)renownValueOfBattle, 2) + "| Your share = " + (float)Math.Round((double)renownValueOfBattle * contributionShare, 2) + "(" + (float)Math.Round((double)contributionShare * 100f, 1) + "%)" +
                                              "\nPerkBonus = " + (float)Math.Round((double)result.ResultNumber - result.BaseNumber, 2) +
                                              "(" + (float)Math.Round((double)(result.ResultNumber / result.BaseNumber - 1f) * 100f, 1) + "%)" +
                                              "\nSum = " + (float)Math.Round((double)result.ResultNumber, 2) +
                                              "\nBT Tweak = " + (float)Math.Round((double)battleRenownMultiplier * result.ResultNumber, 2) + "(" + BTTweak + (float)Math.Round((double)battleRenownMultiplier * 100f, 1) + "%)" +
                                              "\n\n");
                }
                __result = result.ResultNumber + (battleRenownMultiplier * result.ResultNumber);
                result.Add(battleRenownMultiplier * result.ResultNumber, new TextObject("BT Renown Tweak"), null);
            }
        }
        private static void Postfix(ref float __result, Village village, StatExplainer explanation)
        {
            var perk = ActivePatch._perk;

            if (!(village.Bound?.OwnerClan?.Leader?.GetPerkValue(perk) ?? false))
            {
                return;
            }

            var explainedNumber = new ExplainedNumber(__result, explanation);

            if (!(__result > -0.0001f) || !(__result < 0.0001f) && explanation.Lines.Count > 0)
            {
                explanation.Lines.RemoveAt(explanation.Lines.Count - 1);
            }

            var extra = explanation.Lines.Where(line => line.Number > 0).Sum(line => line.Number);

            if (extra < float.Epsilon)
            {
                return;
            }

            explainedNumber.Add(extra * perk.PrimaryBonus - extra, perk.Name);
            __result = explainedNumber.ResultNumber;
        }
Beispiel #21
0
        private static void Postfix(ref int __result, MobileParty party, StatExplainer explanation)
        {
            var perk = ActivePatch._perk;

            if (!(party.LeaderHero?.GetPerkValue(perk) ?? false))
            {
                return;
            }

            var extra = party.LeaderHero.Clan.Settlements.Count() * perk.PrimaryBonus;

            if (extra < float.Epsilon)
            {
                return;
            }

            var explainedNumber = new ExplainedNumber(__result, explanation);
            var baseLine        = explanation?.Lines.Find(x => x.Name == "Base");

            if (baseLine != null)
            {
                explanation.Lines.Remove(baseLine);
            }

            explainedNumber.Add(party.LeaderHero.Clan.Settlements.Count() * perk.PrimaryBonus, perk.Name);
            __result = (int)explainedNumber.ResultNumber;
        }
 public override void CalculateClanIncome(
     Clan clan,
     ref ExplainedNumber goldChange,
     bool applyWithdrawals = false)
 {
     goldChange.Add(666, new TextObject("hardcoded 666"));
 }
        public static void Postfix(ref float __result, MobileParty party, StatExplainer explainer)
        {
            //For now only do hero
            if (party.LeaderHero == Hero.MainHero)
            {
                if (party.Scout != null)
                {
                    var sk = party.Scout.GetSkillValue(DefaultSkills.Scouting);
                    if (sk > 0)
                    {
                        var mod = 1.0f - ((float)sk / 300.0f);
                        if (mod < 0.1f)
                        {
                            mod = 0.1f;
                        }

                        mod = MBRandom.RandomFloatRanged(mod, 1.0f);
                        var orig      = __result;
                        var deduction = (orig - ((__result * mod))) * -1f;;

                        ExplainedNumber en = new ExplainedNumber(__result, explainer);
                        explainer?.Lines.Remove(explainer.Lines.Last());
                        var textObject = new TextObject("{FIRST_NAME} scouted for food.", null);
                        textObject.SetTextVariable("FIRST_NAME", party.Scout.FirstName);
                        //textObject.SetTextVariable("REDUCTION_AMOUNT", (orig-__result).ToString());
                        en.Add(deduction, textObject);
                        __result = en.ResultNumber;
                    }
                }
            }
        }
Beispiel #24
0
        public override float CalculateLoyaltyChange(Town town, StatExplainer explanation = null)
        {
            ExplainedNumber explainedNumber = new ExplainedNumber(0.0f, explanation, (TextObject)null);
            SettlementInfo  info            = RevolutionBehaviour.GetSettlementInformation(town.Settlement);

            if (!town.IsTown)
            {
                return(explainedNumber.ResultNumber + base.CalculateLoyaltyChange(town, explanation));
            }

            if (info.Settlement.MapFaction.Leader == Hero.MainHero)
            {
                explainedNumber.Add(_basePlayerLoyalty, GameTexts.FindText("str_loyalty_bannerlord"));

                if (ModOptions.OptionsData.PlayerAffectedByOverextension && ModOptions.OptionsData.OverextensionMechanics)
                {
                    Overextension(info, ref explainedNumber);
                }
            }
            else
            {
                BaseLoyalty(info, ref explainedNumber);

                if (ModOptions.OptionsData.OverextensionMechanics)
                {
                    Overextension(info, ref explainedNumber);
                }
            }

            return(explainedNumber.ResultNumber + base.CalculateLoyaltyChange(town, explanation));
        }
        public override float CalculateTownFoodStocksChange(Town town, StatExplainer explanation = null)
        {
            if (town == null)
            {
                throw new ArgumentNullException(nameof(town));
            }
            float baseVal = base.CalculateTownFoodStocksChange(town, explanation);

            if (Settings.Instance.SettlementFoodBonusEnabled)
            {
                ExplainedNumber en = new ExplainedNumber(baseVal, explanation);
                explanation?.Lines.Remove(explanation.Lines.Last());

                if (town.IsCastle)
                {
                    en.Add(Settings.Instance.CastleFoodBonus, new TextObject("Military rations"));
                }
                else if (town.IsTown)
                {
                    en.Add(Settings.Instance.TownFoodBonus, new TextObject("Citizen food drive"));
                }

                if (Settings.Instance.SettlementProsperityFoodMalusTweakEnabled && Settings.Instance.SettlementProsperityFoodMalusDivisor != 50)
                {
                    float malus = town.Owner.Settlement.Prosperity / 50f;
                    en.Add(malus, new TextObject("shouldn't be seen!"));
                    explanation?.Lines.Remove(explanation.Lines.Last());

                    TextObject prosperityTextObj = GameTexts.FindText("str_prosperity", null);
                    var        line = explanation?.Lines.Where((x) => !string.IsNullOrWhiteSpace(x.Name) && x.Name == prosperityTextObj.ToString()).FirstOrDefault();
                    if (line != null)
                    {
                        explanation?.Lines.Remove(line);
                    }

                    malus = -town.Owner.Settlement.Prosperity / Settings.Instance.SettlementProsperityFoodMalusDivisor;
                    en.Add(malus, prosperityTextObj);
                }

                return(en.ResultNumber);
            }
            else
            {
                return(baseVal);
            }
        }
Beispiel #26
0
 static void Postfix(Army army, bool includeDescriptions, ref ExplainedNumber __result)
 {
     if (BannerlordTweaksSettings.Instance is { } settings&& settings.BTCohesionTweakEnabled)
     {
         float num1 = Math.Abs(__result.ResultNumber) * (1f - settings.BTCohesionTweakv2);
         __result.Add(num1, new TextObject("BT Cohesion Tweak"));
     }
 }
 private void AddUltimateLeaderPerkEffect(MobileParty party, ref ExplainedNumber result)
 {
     if (party.LeaderHero == null || !party.LeaderHero.Clan.IsMapFaction || (party.LeaderHero.Clan.Leader.GetSkillValue(DefaultSkills.Leadership) <= 250 || !party.LeaderHero.Clan.Leader.GetPerkValue(DefaultPerks.Leadership.UltimateLeader)))
     {
         return;
     }
     result.Add((float)(party.LeaderHero.Clan.Leader.GetSkillValue(DefaultSkills.Leadership) - 250) * DefaultPerks.Leadership.UltimateLeader.PrimaryBonus, this._leadershipPerkUltimateLeaderBonusText);
 }
        /*
         * private void GetSettlementProsperityChangeDueToIssues(Settlement settlement, ref ExplainedNumber result, float newBorn)
         * {
         *      float num;
         *      bool flag = !IssueManager.DoesSettlementHasIssueEffect(DefaultIssueEffects.SettlementProsperity, settlement, ref num);
         *      if (!flag)
         *      {
         *              float num2 = num * LightSettlementProsperityModel._vanillaToRatio * newBorn;
         *              result.Add(num2 * SubModule.Settings.ProsperityGrowthMultiplier, this._issueText, null);
         *      }
         * }
         */

        private void GetSettlementProsperityChangeDueToIssues(Settlement settlement, ref ExplainedNumber result, float newBorn)
        {
            Campaign.Current.Models.IssueModel.GetIssueEffectsOfSettlement(DefaultIssueEffects.SettlementProsperity, settlement, ref result);
            float num  = result.ResultNumber;
            float num2 = num * LightSettlementProsperityModel._vanillaToRatio * newBorn;

            result.Add(num2 * SubModule.Settings.ProsperityGrowthMultiplier, this._issueText, null);
        }
        private static void GetSettlementMilitiaChangeDueToIssues(Settlement settlement, ref ExplainedNumber result)
        {
            float value;

            if (IssueManager.DoesSettlementHasIssueEffect(DefaultIssueEffects.SettlementMilitia, settlement, out value))
            {
                result.Add(value, _issues);
            }
        }
        private static void GetSettlementMilitiaChangeDueToPolicies(Settlement settlement, ref ExplainedNumber result)
        {
            Kingdom kingdom = settlement.OwnerClan.Kingdom;

            if (kingdom != null && kingdom.ActivePolicies.Contains(DefaultPolicies.Citizenship))
            {
                result.Add(1f, DefaultPolicies.Citizenship.Name);
            }
        }