From 2e2a1397b6a9766b005b9da6f2f3927319a89073 Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Thu, 5 Mar 2026 23:47:10 +0100 Subject: [PATCH 1/9] Allow Salvagers raids regarding of RestrictEvents Salvagers is faction without settlements that raids player in space, like Horax Cultists. So to make space non-peaceful place, we enable Salvagers raids. We probably should also enable mech raids. Signed-off-by: Jakub Raczynski --- Source/RimWar/Harmony/HarmonyPatches.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/RimWar/Harmony/HarmonyPatches.cs b/Source/RimWar/Harmony/HarmonyPatches.cs index f5b44e6..d271a6e 100644 --- a/Source/RimWar/Harmony/HarmonyPatches.cs +++ b/Source/RimWar/Harmony/HarmonyPatches.cs @@ -944,7 +944,8 @@ public static bool CanFireNow_Ambush_EnemyFaction_RemovalPatch_Prefix(IncidentWo Options.SettingsRef settingsRef = new Options.SettingsRef(); if (settingsRef.restrictEvents) { - if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && !__instance.def.defName.Contains("Cult") && parms.quest == null && + if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && + !__instance.def.defName.Contains("Cult") && !__instance.def.defName.Contains("Salvagers") && parms.quest == null && !parms.forced && !__instance.def.workerClass.ToString().StartsWith("Rumor_Code") && !(parms.faction != null && parms.faction.Hidden)) { __result = false; @@ -960,7 +961,8 @@ public static bool CanFireNow_CaravanDemand_RemovalPatch_Prefix(IncidentWorker_C Options.SettingsRef settingsRef = new Options.SettingsRef(); if (settingsRef.restrictEvents) { - if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && !__instance.def.defName.Contains("Cult") && parms.quest == null && + if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && + !__instance.def.defName.Contains("Cult") && !__instance.def.defName.Contains("Salvagers") && parms.quest == null && !parms.forced && !__instance.def.workerClass.ToString().StartsWith("Rumor_Code") && !(parms.faction != null && parms.faction.Hidden)) { __result = false; @@ -976,7 +978,8 @@ public static bool CanFireNow_CaravanMeeting_RemovalPatch_Prefix(IncidentWorker_ Options.SettingsRef settingsRef = new Options.SettingsRef(); if (settingsRef.restrictEvents) { - if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && !__instance.def.defName.Contains("Cult") && parms.quest == null && + if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && + !__instance.def.defName.Contains("Cult") && !__instance.def.defName.Contains("Salvagers") && parms.quest == null && !parms.forced && !__instance.def.workerClass.ToString().StartsWith("Rumor_Code") && !(parms.faction != null && parms.faction.Hidden)) { __result = false; @@ -1014,8 +1017,9 @@ public static bool CanFireNow_PawnsArrive_RemovalPatch_Prefix(IncidentWorker_Paw Options.SettingsRef settingsRef = new Options.SettingsRef(); if (settingsRef.restrictEvents) { - if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && !__instance.def.defName.Contains("Cult") && parms.quest == null && - !parms.forced && !__instance.def.workerClass.ToString().StartsWith("Rumor_Code")) + if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && + !__instance.def.defName.Contains("Cult") && !__instance.def.defName.Contains("Salvagers") && + parms.quest == null &&!parms.forced && !__instance.def.workerClass.ToString().StartsWith("Rumor_Code")) { if(parms.faction != null) { From 39dfc339b7e98b22a37f85da0e2619e354429e94 Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Fri, 20 Mar 2026 21:54:50 +0100 Subject: [PATCH 2/9] Revert RestrictEvents allowing caravans Saw lot of people complaining about that, although it is good change imo. So revert it back, which often results in 0 caravans through whole gameplay. Signed-off-by: Jakub Raczynski --- Source/RimWar/Harmony/HarmonyPatches.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/RimWar/Harmony/HarmonyPatches.cs b/Source/RimWar/Harmony/HarmonyPatches.cs index d271a6e..86ae1ac 100644 --- a/Source/RimWar/Harmony/HarmonyPatches.cs +++ b/Source/RimWar/Harmony/HarmonyPatches.cs @@ -1028,7 +1028,7 @@ public static bool CanFireNow_PawnsArrive_RemovalPatch_Prefix(IncidentWorker_Paw return true; } } - if (__instance.def == IncidentDefOf.RaidEnemy || __instance.def == IncidentDefOf.RaidFriendly) + if (__instance.def == IncidentDefOf.RaidEnemy || __instance.def == IncidentDefOf.RaidFriendly || __instance.def == IncidentDefOf.TraderCaravanArrival) { __result = false; From 9085b2a4ac3294294ca756e14a8ed7e91a50aec4 Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Fri, 20 Mar 2026 21:58:15 +0100 Subject: [PATCH 3/9] Allow mechanoid raids regardless of RestrictEvents This change shouldn't be necessary but it seems that mech raids are blocked in some cases. Not sure why but this change does ensire they happen. Signed-off-by: Jakub Raczynski --- Source/RimWar/Harmony/HarmonyPatches.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/RimWar/Harmony/HarmonyPatches.cs b/Source/RimWar/Harmony/HarmonyPatches.cs index 86ae1ac..97c2e6a 100644 --- a/Source/RimWar/Harmony/HarmonyPatches.cs +++ b/Source/RimWar/Harmony/HarmonyPatches.cs @@ -1018,8 +1018,8 @@ public static bool CanFireNow_PawnsArrive_RemovalPatch_Prefix(IncidentWorker_Paw if (settingsRef.restrictEvents) { if (__instance != null && __instance.def.defName != "VisitorGroup" && __instance.def.defName != "VisitorGroupMax" && - !__instance.def.defName.Contains("Cult") && !__instance.def.defName.Contains("Salvagers") && - parms.quest == null &&!parms.forced && !__instance.def.workerClass.ToString().StartsWith("Rumor_Code")) + !__instance.def.defName.Contains("Cult") && !__instance.def.defName.Contains("Salvagers") && !__instance.def.defName.Contains("Mechanoids") && + parms.quest == null && !parms.forced && !__instance.def.workerClass.ToString().StartsWith("Rumor_Code")) { if(parms.faction != null) { From 6395b20dd4c15eaf2aee4e6fd87d9a4fde165d0f Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Tue, 24 Mar 2026 23:03:42 +0100 Subject: [PATCH 4/9] Change 'GiveGift' patch condition & fix items being kept There is an issue that 'GiveGift' Harmony patch does keep items after giving gift due to return value of 'false' which does not execute main function then. We fix it by returning true and executing original function. Also change behavior to always increase RimWar settlement points when giving gift, not only for allies. Signed-off-by: Jakub Raczynski --- Source/RimWar/Harmony/HarmonyPatches.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Source/RimWar/Harmony/HarmonyPatches.cs b/Source/RimWar/Harmony/HarmonyPatches.cs index 97c2e6a..37bcf2b 100644 --- a/Source/RimWar/Harmony/HarmonyPatches.cs +++ b/Source/RimWar/Harmony/HarmonyPatches.cs @@ -213,18 +213,14 @@ public RimWarMod(ModContentPack content) : base(content) public static bool GiveGiftAsRimWarPoints_Prefix(List tradeables, Faction giveTo, GlobalTargetInfo lookTarget) { - if (giveTo.PlayerRelationKind == FactionRelationKind.Ally) + Settlement s = Find.WorldObjects.SettlementAt(lookTarget.Tile); + if (s != null) { - Settlement s = Find.WorldObjects.SettlementAt(lookTarget.Tile); - if(s != null) + RimWarSettlementComp rwsc = s.GetComponent(); + if (rwsc != null) { - RimWarSettlementComp rwsc = s.GetComponent(); - if (rwsc != null) - { - int goodwillChange = FactionGiftUtility.GetGoodwillChange(tradeables, giveTo); - rwsc.RimWarPoints += goodwillChange * 90; - return false; - } + int goodwillChange = FactionGiftUtility.GetGoodwillChange(tradeables, giveTo); + rwsc.RimWarPoints += goodwillChange * 90; } } return true; From d2b21a517ef28828724c7b5c37d231ac0166ab2c Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Tue, 24 Mar 2026 23:50:15 +0100 Subject: [PATCH 5/9] Block settlements from sending objects when very damaged All current checks regarding sending parties count RimWarPoints, but do not account for PointDamage. That has two bad effects: - settlement can send parties having more points that (settlement - damange) - settlement can send parties when barely alive Address it in indirect way, by ensuring there is enough points to not break math (although it can leave settlement with only damaged points) and block sending parties when having less than half points (meaning half damaged) Signed-off-by: Jakub Raczynski --- Source/RimWar/Planet/WorldComponent_PowerTracker.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/RimWar/Planet/WorldComponent_PowerTracker.cs b/Source/RimWar/Planet/WorldComponent_PowerTracker.cs index 3d9ecce..b211e01 100644 --- a/Source/RimWar/Planet/WorldComponent_PowerTracker.cs +++ b/Source/RimWar/Planet/WorldComponent_PowerTracker.cs @@ -1810,7 +1810,7 @@ public void AttemptScoutMission_UnThreaded(RimWarData rwd, RimWorld.Planet.Settl if (wo is Caravan) { Caravan playerCaravan = wo as Caravan; - if ((playerCaravan.PlayerWealthForStoryteller / 200) <= (rwsComp.RimWarPoints * .5f) && ((Find.WorldGrid.TraversalDistanceBetween(wo.Tile, parentSettlement.Tile) <= Mathf.RoundToInt(targetRange * playerCaravan.Visibility)) || ignoreRestrictions)) + if ((playerCaravan.PlayerWealthForStoryteller / 200) <= ((rwsComp.RimWarPoints - rwsComp.PointDamage) * .5f) && ((Find.WorldGrid.TraversalDistanceBetween(wo.Tile, parentSettlement.Tile) <= Mathf.RoundToInt(targetRange * playerCaravan.Visibility)) || ignoreRestrictions)) { shouldExecute = true; break; @@ -1819,7 +1819,7 @@ public void AttemptScoutMission_UnThreaded(RimWarData rwd, RimWorld.Planet.Settl else if (wo is WarObject) { WarObject warObject = wo as WarObject; - if (warObject.RimWarPoints <= (rwsComp.RimWarPoints * .5f) || ignoreRestrictions) + if (warObject.RimWarPoints <= ((rwsComp.RimWarPoints - rwsComp.PointDamage) * .5f) || ignoreRestrictions) { shouldExecute = true; break; @@ -1828,7 +1828,7 @@ public void AttemptScoutMission_UnThreaded(RimWarData rwd, RimWorld.Planet.Settl else if (wo is RimWorld.Planet.Settlement) { RimWarSettlementComp rwsc = WorldUtility.GetRimWarSettlementAtTile(wo.Tile); - if (rwsc != null && (rwsc.RimWarPoints <= (rwsComp.RimWarPoints * .5f) || ignoreRestrictions)) + if (rwsc != null && (rwsc.RimWarPoints <= ((rwsComp.RimWarPoints - rwsComp.PointDamage) * .5f) || ignoreRestrictions)) { shouldExecute = true; break; From d52c55203d89f38de275377be34c13f12b465cb4 Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Wed, 25 Mar 2026 00:02:20 +0100 Subject: [PATCH 6/9] Ignore space tiles in GetWorldObjectsInRange It should not be generally checked, but we were observing an error of: 'Attempted to access a tile with ID 201789, but it is out of range (count: 2432)' This might be caused by scanning objects in space, but RimWorld debug view does not allow good way of identifying tile ID's (have to manually click all). Adding this checks costs us nothing and might be actual solution. Signed-off-by: Jakub Raczynski --- Source/RimWar/Planet/WorldUtility.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/RimWar/Planet/WorldUtility.cs b/Source/RimWar/Planet/WorldUtility.cs index 649abde..3d434ba 100644 --- a/Source/RimWar/Planet/WorldUtility.cs +++ b/Source/RimWar/Planet/WorldUtility.cs @@ -1400,6 +1400,12 @@ public static List GetWorldObjectsInRange(PlanetTile from, float ra if (objectsInRange.Count >= maxObjectsPerScan) break; + // Probably in future add attacks between same layers + if (to.Layer == Find.WorldGrid.Orbit) + { + continue; + } + if (from == to) { objectsInRange.Add(worldObjects[i]); From e6cbcaebf3720ccdf20fc0431115a3071e0b1e7c Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Wed, 25 Mar 2026 19:05:21 +0100 Subject: [PATCH 7/9] Disable custom omsConsole interfaction in space There has been report of broken ComsConsole in space, which makes sense, since stuff like reinforcement doesn't really work in space. So disable these options while in space. Signed-off-by: Jakub Raczynski --- Source/RimWar/Harmony/HarmonyPatches.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/RimWar/Harmony/HarmonyPatches.cs b/Source/RimWar/Harmony/HarmonyPatches.cs index 37bcf2b..e9558e3 100644 --- a/Source/RimWar/Harmony/HarmonyPatches.cs +++ b/Source/RimWar/Harmony/HarmonyPatches.cs @@ -1066,6 +1066,12 @@ public static class CommsConsole_RimWarOptions_Patch { private static void Postfix(Pawn negotiator, Faction faction, ref DiaNode __result) { + // Do not allow custom options in space + if (negotiator.Map.TileInfo.Layer == Find.WorldGrid.Orbit) + { + return; + } + List removeList = new List(); removeList.Clear(); foreach (DiaOption x in __result.options) From c3ba5755b93bca8c2c8e38d0844f95af7381b53f Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Sat, 28 Mar 2026 19:48:35 +0100 Subject: [PATCH 8/9] Trader: Do not lose points on player faction trade Currently if trader does arrive to player faction it loses half of the points, which is weakening the faction that trades with player. This seems to not be best design, so change it to be profitable to trade with player. Signed-off-by: Jakub Raczynski --- Source/RimWar/Planet/Trader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/RimWar/Planet/Trader.cs b/Source/RimWar/Planet/Trader.cs index fa20a14..dad21f9 100644 --- a/Source/RimWar/Planet/Trader.cs +++ b/Source/RimWar/Planet/Trader.cs @@ -197,8 +197,8 @@ public override void ArrivalAction() IncidentUtility.DoSettlementTradeWithPoints(this, playerSettlement, this.rimwarData, IncidentUtility.PawnsArrivalModeOrRandom(PawnsArrivalModeDefOf.EdgeWalkIn), traderKind); if (this.WarSettlementComp != null) { - this.WarSettlementComp.RimWarPoints += Mathf.RoundToInt((this.RimWarPoints / 2f) * (Rand.Range(1.05f, 1.25f))); - this.WarSettlementComp.PointDamage += Mathf.RoundToInt(this.PointDamage / 2f); + this.WarSettlementComp.RimWarPoints += Mathf.RoundToInt((this.RimWarPoints) * (Rand.Range(1.05f, 1.25f))); + this.WarSettlementComp.PointDamage += Mathf.RoundToInt(this.PointDamage); } base.ArrivalAction(); }); From eea11a1f923a16309e4fc4dc788a301810ab4555 Mon Sep 17 00:00:00 2001 From: Jakub Raczynski Date: Sat, 28 Mar 2026 20:03:41 +0100 Subject: [PATCH 9/9] Re-enable points increase from pod gifts Same as recent GiveGift, re-enable RimWar point increase from gifts for pods. Signed-off-by: Jakub Raczynski --- Source/RimWar/Harmony/HarmonyPatches.cs | 42 +++++++++++-------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/Source/RimWar/Harmony/HarmonyPatches.cs b/Source/RimWar/Harmony/HarmonyPatches.cs index e9558e3..de4f490 100644 --- a/Source/RimWar/Harmony/HarmonyPatches.cs +++ b/Source/RimWar/Harmony/HarmonyPatches.cs @@ -29,6 +29,7 @@ namespace RimWar.Harmony [StaticConstructorOnStartup] public class RimWarMod : Mod { + public static int RimpointsPerGift = 90; private static readonly Type patchType = typeof(RimWarMod); public RimWarMod(ModContentPack content) : base(content) @@ -99,11 +100,11 @@ public RimWarMod(ModContentPack content) : base(content) //Prefix - //harmonyInstance.Patch(AccessTools.Method(typeof(FactionGiftUtility), "GiveGift", new Type[] - // { - // typeof(List), - // typeof(Settlement) - // }, null), new HarmonyMethod(patchType, "GivePodGiftAsRimWarPoints_Prefix", null), null, null); + harmonyInstance.Patch(AccessTools.Method(typeof(FactionGiftUtility), "GiveGift", new Type[] + { + typeof(List), + typeof(Settlement) + }, null), new HarmonyMethod(patchType, "GivePodGiftAsRimWarPoints_Prefix", null), null, null); harmonyInstance.Patch(AccessTools.Method(typeof(FactionGiftUtility), "GiveGift", new Type[] { typeof(List), @@ -192,24 +193,17 @@ public RimWarMod(ModContentPack content) : base(content) // } //} - //public static bool GivePodGiftAsRimWarPoints_Prefix(List pods, Settlement giveTo) - //{ - // if(giveTo.Faction.PlayerRelationKind == FactionRelationKind.Ally) - // { - // RimWarSettlementComp rwsc = giveTo.GetComponent(); - // if(rwsc != null) - // { - // int goodwillChange = FactionGiftUtility.GetGoodwillChange(pods.Cast(), giveTo); - // rwsc.RimWarPoints += goodwillChange * 100; - // return false; - // } - // else - // { - // return true; - // } - // } - // return true; - //} + public static bool GivePodGiftAsRimWarPoints_Prefix(List pods, Settlement giveTo) + { + RimWarSettlementComp rwsc = giveTo.GetComponent(); + if(rwsc != null) + { + int goodwillChange = FactionGiftUtility.GetGoodwillChange(pods.Cast(), giveTo); + rwsc.RimWarPoints += goodwillChange * RimWarMod.RimpointsPerGift; + } + + return true; + } public static bool GiveGiftAsRimWarPoints_Prefix(List tradeables, Faction giveTo, GlobalTargetInfo lookTarget) { @@ -220,7 +214,7 @@ public static bool GiveGiftAsRimWarPoints_Prefix(List tradeables, Fac if (rwsc != null) { int goodwillChange = FactionGiftUtility.GetGoodwillChange(tradeables, giveTo); - rwsc.RimWarPoints += goodwillChange * 90; + rwsc.RimWarPoints += goodwillChange * RimWarMod.RimpointsPerGift; } } return true;