diff --git a/Source/RimWar/Harmony/HarmonyPatches.cs b/Source/RimWar/Harmony/HarmonyPatches.cs index f5b44e6..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,39 +193,28 @@ 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) { - 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 * RimWarMod.RimpointsPerGift; } } return true; @@ -944,7 +934,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 +951,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 +968,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 +1007,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") && !__instance.def.defName.Contains("Mechanoids") && + parms.quest == null && !parms.forced && !__instance.def.workerClass.ToString().StartsWith("Rumor_Code")) { if(parms.faction != null) { @@ -1024,7 +1018,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; @@ -1066,6 +1060,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) 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(); }); 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; 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]);