How to lower the negative effect of not having your current fief close by, when the game is looking for candidates to receive a conquered fief.

Users who are viewing this thread

I found the code, but I'm new to coding and am not sure what should be changed by the Distance Factor Equation.
TaleWorlds.CampaignSystem.Election.SettlementClaimantDecision
CalculateMeritOfOutcome
Calculate-Merit-Of-Outcome.png



// TaleWorlds.CampaignSystem.Election.SettlementClaimantDecision
// Token: 0x06002658 RID: 9816 RVA: 0x00096148 File Offset: 0x00094348
public override float CalculateMeritOfOutcome(DecisionOutcome candidateOutcome)
{
SettlementClaimantDecision.ClanAsDecisionOutcome clanAsDecisionOutcome = (SettlementClaimantDecision.ClanAsDecisionOutcome)candidateOutcome;
Clan clan = clanAsDecisionOutcome.Clan;
float num = 0f;
int num2 = 0;
float num3 = Campaign.MapDiagonal + 1f;
float num4 = Campaign.MapDiagonal + 1f;
foreach (Settlement settlement in Settlement.All)
{
if (settlement.OwnerClan == clanAsDecisionOutcome.Clan && settlement.IsFortification && this.Settlement != settlement)
{
num += settlement.GetSettlementValueForFaction(clanAsDecisionOutcome.Clan.Kingdom);
float num5;
if (Campaign.Current.Models.MapDistanceModel.GetDistance(settlement, this.Settlement, num4, out num5))
{
if (num5 < num3)
{
num4 = num3;
num3 = num5;
}
else if (num5 < num4)
{
num4 = num5;
}
}
num2++;
}
}
float num6 = Campaign.AverageDistanceBetweenTwoTowns * 1.5f;
float val = num6 * 0.25f;
float val2 = num6;
if (num4 < Campaign.MapDiagonal)
{
val2 = (num4 + num3) / 2f;
}
else if (num3 < Campaign.MapDiagonal)
{
val2 = num3;
}
float num7 = (float)Math.Pow((double)(num6 / Math.Max(val, Math.Min(400f, val2))), 0.5);
float num8 = clan.TotalStrength;
if (this.Settlement.OwnerClan == clan && this.Settlement.Town != null && this.Settlement.Town.GarrisonParty != null)
{
num8 -= this.Settlement.Town.GarrisonParty.Party.TotalStrength;
if (num8 < 0f)
{
num8 = 0f;
}
}
float settlementValueForFaction = this.Settlement.GetSettlementValueForFaction(clanAsDecisionOutcome.Clan.Kingdom);
bool flag = clanAsDecisionOutcome.Clan.Leader == clanAsDecisionOutcome.Clan.Kingdom.Leader;
float num9 = (num2 == 0) ? 30f : 0f;
float num10 = flag ? 60f : 0f;
float num11 = (this.Settlement.Town != null && this.Settlement.Town.LastCapturedBy == clanAsDecisionOutcome.Clan) ? 30f : 0f;
float num12 = (clanAsDecisionOutcome.Clan.Leader == Hero.MainHero) ? 30f : 0f;
float num13 = (clanAsDecisionOutcome.Clan.Leader.Gold < 0x7530) ? Math.Min(30f, 30f - (float)clanAsDecisionOutcome.Clan.Leader.Gold / 1000f) : 0f;
return ((float)clan.Tier * 30f + num8 / 10f + num9 + num11 + num10 + num13 + num12) / (num + settlementValueForFaction) * num7 * 200000f;
}
 
Last edited:
Solution
Image and the pasted algorithm are different. Probably mexxico added some pro-player factors after the discussion at the link.
num7 (distance factor) is a direct multiplier in the final formula so you should narrow down its possible values to diminish its effects.
Decreasing the Math.Pow constant 0.5 helps.
float num7 = (float)Math.Pow((double)(num6 / Math.Max(val, Math.Min(400f, val2))), 0.5);
Things get interesting after this.
The distance value is clamped between 2 values in those Math.Min and Math.Max functions.
Campaign.AverageDistanceBetweenTwoTowns * 1.5 * 0.25 <= distance <= 400
You can either increase 0.25 or decrease 400 or do both.
float val = num6 * 0.25f;
.
.
.
float num7 =...
Image and the pasted algorithm are different. Probably mexxico added some pro-player factors after the discussion at the link.
num7 (distance factor) is a direct multiplier in the final formula so you should narrow down its possible values to diminish its effects.
Decreasing the Math.Pow constant 0.5 helps.
float num7 = (float)Math.Pow((double)(num6 / Math.Max(val, Math.Min(400f, val2))), 0.5);
Things get interesting after this.
The distance value is clamped between 2 values in those Math.Min and Math.Max functions.
Campaign.AverageDistanceBetweenTwoTowns * 1.5 * 0.25 <= distance <= 400
You can either increase 0.25 or decrease 400 or do both.
float val = num6 * 0.25f;
.
.
.
float num7 = (float)Math.Pow((double)(num6 / Math.Max(val, Math.Min(400f, val2))), 0.5);
But be careful, if two limits of that clamping becomes same, lower limit exceeds the upper or upper limit becomes smaller than the lower one, distance factor is no more a factor.
I advise you to decrease the Math.Pow constant. It's neater.
For 16 and 256:
0.5 creates 4 and 16 (x4 times)
0.25 creates 2 and 4 (x2 times)
It got narrower as you can see.
Edit: Second way narrows down the factor but not in a nice way. It simply ignores some values near the limits. Just change the constant 0.5
 
Last edited:
Upvote 1
Solution
Back
Top Bottom