public static void CalculateInfluenceChangePatch(ref ExplainedNumber __result, Clan clan, bool includeDescriptions = false)
        {
            if (Settings.Instance.EnableInfluenceBalancing)
            {
                var influenceChange = __result;

                if (Settings.Instance.EnableCorruption)
                {
                    float corruption = clan.GetCorruption();
                    if (corruption > 0)
                    {
                        influenceChange.Add(-corruption, new TextObject("{=dUCOV7km}Corruption (too many fiefs)"));
                    }
                }

                if (Settings.Instance.EnableInfluenceDecay)
                {
                    int influenceDecayFactor = clan.Influence > Settings.Instance.InfluenceDecayThreshold ? (int)-((clan.Influence - Settings.Instance.InfluenceDecayThreshold) * (Settings.Instance.InfluenceDecayPercentage / 100)) : 0;
                    if (influenceDecayFactor < 0)
                    {
                        influenceChange.Add(influenceDecayFactor, new TextObject("{=koTNaZUX}Influence Decay (too much influence)"));
                    }
                }

                float maximumInfluenceLoss = Settings.Instance.MaximumInfluenceLoss;
                if (influenceChange.ResultNumber < -maximumInfluenceLoss)
                {
                    influenceChange.Add(-maximumInfluenceLoss, new TextObject("{=uZc8Hg01}Maximum Influence Loss"));
                }

                __result = influenceChange;
            }
        }
Example #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);
        }
Example #3
0
        private void ReduceCorruption(Clan clan)
        {
            if (!clan.MapFaction.IsKingdomFaction || clan.GetCorruption() <= 0 || clan.Leader.IsHumanPlayerCharacter)
                return;

            var influenceChange = Campaign.Current.Models.ClanPoliticsModel.CalculateInfluenceChange(clan).ResultNumber;

            if (influenceChange > 0)
                return;

            var fiefBarterable = GetBestFiefBarter(clan, out var targetClan);

            if (fiefBarterable is null || targetClan is null)
                return;

            var goldValue = GetGoldValueForFief(targetClan, fiefBarterable.TargetSettlement);
            var goldBarterable = new GoldBarterable(targetClan.Leader, clan.Leader, null, null, goldValue) { CurrentAmount = goldValue };

            fiefBarterable.Apply();
            goldBarterable.Apply();
        }
        public static void CalculateInfluenceChangePatch(ref float __result, Clan clan, StatExplainer explanation = null)
        {
            if (Settings.Instance.EnableInfluenceBalancing)
            {
                float influenceChange = __result;

                if (Settings.Instance.EnableCorruption)
                {
                    float corruption = clan.GetCorruption();
                    if (corruption > 0)
                    {
                        explanation?.AddLine(new TextObject("{=dUCOV7km}Corruption (too many fiefs)").ToString(), -corruption);
                        influenceChange -= corruption;
                    }
                }

                if (Settings.Instance.EnableInfluenceDecay)
                {
                    int influenceDecayFactor = clan.Influence > Settings.Instance.InfluenceDecayThreshold ? (int)-((clan.Influence - Settings.Instance.InfluenceDecayThreshold) * (Settings.Instance.InfluenceDecayPercentage / 100)) : 0;
                    if (influenceDecayFactor < 0)
                    {
                        explanation?.AddLine(new TextObject("{=koTNaZUX}Influence Decay (too much influence)").ToString(), influenceDecayFactor);
                        influenceChange += influenceDecayFactor;
                    }
                }

                float maximumInfluenceLoss = Settings.Instance.MaximumInfluenceLoss;
                if (influenceChange < -maximumInfluenceLoss)
                {
                    explanation?.AddLine(new TextObject("{=uZc8Hg01}Maximum Influence Loss").ToString(), -maximumInfluenceLoss, StatExplainer.OperationType.LimitMin);
                    influenceChange = -maximumInfluenceLoss;
                }

                __result = influenceChange;
            }
        }
Example #5
0
        private void ReduceCorruption(Clan clan)
        {
            if (clan.MapFaction.IsKingdomFaction && !clan.Leader.IsHumanPlayerCharacter && clan.InfluenceChange < 0 && clan.GetCorruption() > 0)
            {
                FiefBarterable fiefBarterable = GetBestFiefBarter(clan, out Clan targetClan);
                if (fiefBarterable != null)
                {
                    int            goldValue      = GetGoldValueForFief(targetClan, fiefBarterable.TargetSettlement);
                    GoldBarterable goldBarterable = new GoldBarterable(targetClan.Leader, clan.Leader, null, null, goldValue);
                    goldBarterable.CurrentAmount = goldValue;

                    fiefBarterable.Apply();
                    goldBarterable.Apply();
                }
            }
        }