//GetGeneralSupportScore internal - per decision type private float GetGeneralSupportScore(Clan clan, MakePeaceKingdomDecision makePeaceDecision, DecisionOutcome possibleOutcome) { int valueForClan = new PeaceBarterable(makePeaceDecision.Kingdom, makePeaceDecision.FactionToMakePeaceWith, CampaignTime.Years(1f)).GetValueForFaction(clan) - Campaign.Current.Models.DiplomacyModel.GetValueOfDailyTribute(makePeaceDecision.DailyTributeToBePaid); float situationalFactorValue = 0; if (Settings.Instance.PeaceSupportCalculationMethod.SelectedValue.EnumValue.HasFlag(PeaceAndWarConsideration.SituationalFactor)) { situationalFactorValue = ApplySituationalFactor(makePeaceDecision, ref valueForClan); } return(FieldAccessHelper.ShouldPeaceBeDeclaredByRef(possibleOutcome) ? valueForClan * Campaign.Current.Models.DiplomacyModel.DenarsToInfluence() + situationalFactorValue : -valueForClan *Campaign.Current.Models.DiplomacyModel.DenarsToInfluence() - situationalFactorValue); }
//GetSupportScoreOfDecisionMaker internal - per decision type private double GetSupportScoreOfDecisionMaker(DecisionMaker decisionMaker, MakePeaceKingdomDecision makePeaceDecision, DecisionOutcome possibleOutcome) { double traitScore = decisionMaker.Hero.GetTraitLevel(DefaultTraits.Mercy) * 10; double relationshipFactorValue = Settings.Instance.PeaceSupportCalculationMethod.SelectedValue.EnumValue.HasFlag(PeaceAndWarConsideration.RelationshipFactor) ? CalculateRelationshipFactor(decisionMaker, makePeaceDecision.FactionToMakePeaceWith) * Settings.Instance.MakePeaceRelationshipFactorStrength : 0; double tributeFactorValue = Settings.Instance.PeaceSupportCalculationMethod.SelectedValue.EnumValue.HasFlag(PeaceAndWarConsideration.TributeFactor) ? CalculateTributeFactor(decisionMaker, makePeaceDecision.FactionToMakePeaceWith, makePeaceDecision.DailyTributeToBePaid) * Settings.Instance.MakePeaceTributeFactorStrength : 0; return(FieldAccessHelper.ShouldPeaceBeDeclaredByRef(possibleOutcome) ? traitScore + relationshipFactorValue - tributeFactorValue : -traitScore - relationshipFactorValue + tributeFactorValue); }
public static void Postfix(Clan clan, DecisionOutcome possibleOutcome, ref float __result, MakePeaceKingdomDecision __instance) { try { float newResult = Campaign.Current.GetAOGameModels().DecisionSupportScoringModel.DetermineSupport(clan, __instance, possibleOutcome); if (SettingsHelper.SystemDebugEnabled(AOSystems.PoliticsRebalance, DebugType.Technical, clan)) { MessageHelper.TechnicalMessage(string.Format("Support of {0} for {1} making peace with {2}.\nNative result = {3}. Rebalanced result = {4}", clan.Name, FieldAccessHelper.ShouldPeaceBeDeclaredByRef(possibleOutcome) ? "accepting" : "denying", __instance.FactionToMakePeaceWith, __result, newResult)); } if (SettingsHelper.SubSystemEnabled(SubSystemType.MakePeaceSupportRebalance, clan)) { __result = newResult; } } catch (Exception ex) { MethodInfo methodInfo = MethodBase.GetCurrentMethod() as MethodInfo; DebugHelper.HandleException(ex, methodInfo, "Harmony patch for MakePeaceKingdomDecision. DetermineSupport"); } }