From 81bfac6fd6bcc5478a4a42926c021817a03902d7 Mon Sep 17 00:00:00 2001 From: still222 <118853487+still222@users.noreply.github.com> Date: Wed, 19 Aug 2026 12:55:37 +0500 Subject: [PATCH] "NearbyFactionGoodwill" and "TradeRequest" fixes --- Source/Client/Factions/MultifactionPatches.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Source/Client/Factions/MultifactionPatches.cs b/Source/Client/Factions/MultifactionPatches.cs index 9eea5551..a52e0857 100644 --- a/Source/Client/Factions/MultifactionPatches.cs +++ b/Source/Client/Factions/MultifactionPatches.cs @@ -957,3 +957,43 @@ static IEnumerable Transpiler(IEnumerable inst } } } + +// This patch affects ritual outcome "NearbyFactionGoodwill" +// We should exclude other player factions from it, because it does nothing +// With this applied these rituals will target correct npc factions instead +[HarmonyPatch(typeof(Faction), nameof(Faction.CanChangeGoodwillFor))] +public static class Faction_CanChangeGoodwillFor_Patch +{ + [HarmonyPostfix] + public static void Postfix(Faction __instance, Faction other, int goodwillChange, ref bool __result) + { + if (Multiplayer.Client == null || !Multiplayer.GameComp.multifaction || !__result) + return; + + if (__instance.IsPlayer && other.IsPlayer) + __result = false; + } + +} + +// This affects "TradeRequest" quests. Despite how funny it was to see other +// player requesting 50 kids pants, AND IT ACTUALLY WORKS, I doubt it is intended, +// and it consumes a quest "slot" that would be otherwise generated for a correct +// faction. "Visitable" already checks if the settlement is "OfPlayer" factions, +// but we also want to check that it is not "IsPlayer", for multifaction. This +// method is used in quest generation checks and in caravan gizmos. Just in case +// you wonder, it still allows your pawns to get into other players settlements. +[HarmonyPatch(typeof(Settlement), nameof(Settlement.Visitable), MethodType.Getter)] +public static class Settlement_Visitable_Patch +{ + [HarmonyPostfix] + public static void Postfix(Settlement __instance, ref bool __result) + { + if (Multiplayer.Client == null || !Multiplayer.GameComp.multifaction || !__result) + return; + + if (__instance.Faction.IsPlayer) + __result = false; + } + +}