diff --git a/1.5/Assemblies/RaidsForMe.dll b/1.5/Assemblies/RaidsForMe.dll new file mode 100644 index 0000000..bc66c7d Binary files /dev/null and b/1.5/Assemblies/RaidsForMe.dll differ diff --git a/About/About.xml b/About/About.xml index cef7f9b..a2a8c64 100644 --- a/About/About.xml +++ b/About/About.xml @@ -8,6 +8,7 @@
  • 1.2
  • 1.3
  • 1.4
  • +
  • 1.5
  • @@ -41,7 +42,7 @@ Fully customizable ! Version -1.0.6 for Rimworld 1.4 +1.0.7 for Rimworld 1.5 Contributors diff --git a/Source/1.5/GC_RFM.cs b/Source/1.5/GC_RFM.cs new file mode 100644 index 0000000..146fe45 --- /dev/null +++ b/Source/1.5/GC_RFM.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RimWorld; +using Verse; +using Verse.AI.Group; +using Verse.AI; +using UnityEngine; + +namespace aRandomKiwi.RFM +{ + public class GC_RFM : GameComponent + { + + public GC_RFM(Game game) + { + this.game = game; + Utils.GCRFM = this; + } + + public override void ExposeData() + { + base.ExposeData(); + + Scribe_Collections.Look(ref this.lastRaidGT, "lastRaidGT", LookMode.Value); + } + + public override void LoadedGame() + { + base.LoadedGame(); + + + } + + public override void StartedNewGame() + { + + } + + public Dictionary lastRaidGT = new Dictionary(); + private Game game; + } +} \ No newline at end of file diff --git a/Source/1.5/Harmony/FactionDialogMaker_Patch.cs b/Source/1.5/Harmony/FactionDialogMaker_Patch.cs new file mode 100644 index 0000000..66f9a7f --- /dev/null +++ b/Source/1.5/Harmony/FactionDialogMaker_Patch.cs @@ -0,0 +1,117 @@ +using Verse; +using Verse.AI; +using Verse.AI.Group; +using HarmonyLib; +using RimWorld; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace aRandomKiwi.RFM +{ + internal class FactionDialogMaker_Patch + { + [HarmonyPatch(typeof(FactionDialogMaker), "FactionDialogFor")] + public class FactionDialogFor + { + private static Texture2D insultTex; + [HarmonyPostfix] + public static void Listener( ref DiaNode __result, Pawn negotiator, Faction faction) + { + DiaOption opt = new DiaOption("RFM_InsultFaction".Translate(faction.leader.LabelCap, faction.Name)); + opt.action = delegate + { + List list = new List(); + string text; + + //Goodwill decrement + faction.TryAffectGoodwillWith(Faction.OfPlayer, -1 * Rand.Range(1,Settings.goodwillLoss+1) , true, true, null, null); + + if (insultTex == null) + insultTex = ContentFinder.Get("Things/Mote/SpeechSymbols/Insult", true); + + //InteractionDefOf.Insult.Worker.Interacted(negotiator, faction.leader, list, out text, out label, out letterDef); + PlayLogEntry_Interaction playLogEntry_Interaction = new PlayLogEntry_Interaction(InteractionDefOf.Insult, negotiator, faction.leader, list); + MoteMaker.MakeInteractionBubble(negotiator, null, InteractionDefOf.Insult.interactionMote, insultTex); + + text = (string) Traverse.Create(playLogEntry_Interaction).Method("ToGameStringFromPOV_Worker", faction.leader, true).GetValue(); + + //If still ally then just display message + if (faction.PlayerRelationKind == FactionRelationKind.Ally || faction.PlayerRelationKind == FactionRelationKind.Neutral) + { + Messages.Message("RFM_InsultAlly".Translate(text, faction.leader.LabelCap, faction.Name), MessageTypeDefOf.NegativeEvent, false); + } + else + { + //If raid + if (Rand.Chance(Settings.chanceGetRaided)) + { + int random = 0; + string sub = ""; + if (Settings.maxHourStartRaid > 0) + random = Rand.Range(Settings.minHourStartRaid, Settings.maxHourStartRaid); + + if (random == 0) + { + sub = "RFM_StartRaidNow".Translate(faction.leader.LabelCap,faction.Name); + } + else + { + sub = "RFM_StartRaidDelayed".Translate(faction.leader.LabelCap,faction.Name,Utils.TranslateTicksToTextIRLSeconds(random * 2500)); + } + + + IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat: IncidentCategoryDefOf.ThreatBig, target: negotiator.Map); + incidentParms.forced = true; + incidentParms.faction = faction; + incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; + incidentParms.target = negotiator.Map; + + int delay = 0; + //Small chance to get an instant drop pod raid if activated and if faction at minimum industrial level + if (Settings.allowChanceAirDrop && faction.def.techLevel >= TechLevel.Industrial && Rand.Chance(0.05f)) + { + if (Rand.Chance(0.75f)) + { + incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeDrop; + } + else + { + incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop; + } + //Execution now + sub = "RFM_StartAirDropRaidNow".Translate(faction.leader.LabelCap, faction.Name); + } + else + { + incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; + delay = (random * 2500); + } + + Messages.Message("RFM_InsultEnemy".Translate(text, sub), MessageTypeDefOf.NegativeEvent, false); + + Find.Storyteller.incidentQueue.Add(IncidentDefOf.RaidEnemy, Find.TickManager.TicksGame + delay, incidentParms, 240000); + //lastRaidGT increment of the time to wait for the raid + the conventional waiting time + Utils.GCRFM.lastRaidGT[faction.GetUniqueLoadID()] = Find.TickManager.TicksGame + delay + (Settings.timeBeforeInsultingAgain * 2500); + } + else + { + Messages.Message("RFM_InsultEnemyWithoutRaid".Translate(text, faction.leader.LabelCap, faction.Name), MessageTypeDefOf.NegativeEvent, false); + } + } + }; + + //If the waiting time is not reached, the control is grayed out + if ( Utils.GCRFM.lastRaidGT.ContainsKey(faction.GetUniqueLoadID()) && Utils.GCRFM.lastRaidGT[faction.GetUniqueLoadID()] > Find.TickManager.TicksGame) + { + opt.disabled = true; + } + + opt.resolveTree = true; + + //Add dialog menu allowing to insult the interlocutor just before the finish button + __result.options.Insert(__result.options.Count-1, opt); + } + } + } +} \ No newline at end of file diff --git a/Source/1.5/Harmony/Patches.cs b/Source/1.5/Harmony/Patches.cs new file mode 100644 index 0000000..446b834 --- /dev/null +++ b/Source/1.5/Harmony/Patches.cs @@ -0,0 +1,19 @@ +using System; +using System.Reflection; +using HarmonyLib; +using Verse; + +namespace aRandomKiwi.KFM +{ + [StaticConstructorOnStartup] + public static class HarmonyPatches + { + static HarmonyPatches() + { + var inst = new Harmony("rimworld.randomKiwi.RFM"); + inst.PatchAll(Assembly.GetExecutingAssembly()); + } + + public static FieldInfo MapFieldInfo; + } +} diff --git a/Source/1.5/Properties/AssemblyInfo.cs b/Source/1.5/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..acfd0ec --- /dev/null +++ b/Source/1.5/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("RaidForMe")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("aRandomKiwi")] +[assembly: AssemblyProduct("RaidForMe")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +[assembly: Guid("0ed2f8ee-3171-4a47-9e23-2eb50d2515b6")] + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.6.0")] +[assembly: AssemblyFileVersion("1.0.6.0")] diff --git a/Source/1.5/RaidForMe.cs b/Source/1.5/RaidForMe.cs new file mode 100644 index 0000000..ef753d6 --- /dev/null +++ b/Source/1.5/RaidForMe.cs @@ -0,0 +1,31 @@ +using HarmonyLib; +using System.Reflection; +using Verse; +using UnityEngine; + +namespace aRandomKiwi.RFM +{ + [StaticConstructorOnStartup] + class RaidForMe : Mod + { + public RaidForMe(ModContentPack content) : base(content) + { + base.GetSettings(); + } + + public void Save() + { + LoadedModManager.GetMod().GetSettings().Write(); + } + + public override string SettingsCategory() + { + return "Raids For Me"; + } + + public override void DoSettingsWindowContents(Rect inRect) + { + Settings.DoSettingsWindowContents(inRect); + } + } +} \ No newline at end of file diff --git a/Source/1.5/RaidForMe.csproj b/Source/1.5/RaidForMe.csproj new file mode 100644 index 0000000..b73d015 --- /dev/null +++ b/Source/1.5/RaidForMe.csproj @@ -0,0 +1,51 @@ + + + + + Debug + AnyCPU + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6} + Library + Properties + aRandomKiwi.RFM + RaidsForMe + v4.7.2 + 512 + true + + + + false + none + false + ..\..\1.5\Assemblies\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/1.5/RaidForMe.sln b/Source/1.5/RaidForMe.sln new file mode 100644 index 0000000..9f87705 --- /dev/null +++ b/Source/1.5/RaidForMe.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2050 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RaidForMe", "RaidForMe.csproj", "{0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C69E7B3B-CCA2-46DB-9A9A-457148E1453B} + EndGlobalSection +EndGlobal diff --git a/Source/1.5/Settings.cs b/Source/1.5/Settings.cs new file mode 100644 index 0000000..9ddb307 --- /dev/null +++ b/Source/1.5/Settings.cs @@ -0,0 +1,73 @@ +using UnityEngine; +using Verse; +using System; +using System.Collections.Generic; + +namespace aRandomKiwi.RFM +{ + public class Settings : ModSettings + { + public static float chanceGetRaided = 1.0f; + public static int timeBeforeInsultingAgain = 0; + public static bool allowRangedAttack = true; + public static int goodwillLoss = 15; + public static int minHourStartRaid = 1; + public static int maxHourStartRaid = 8; + public static bool allowChanceAirDrop = true; + + public static Vector2 scrollPosition = Vector2.zero; + + public static void DoSettingsWindowContents(Rect inRect) + { + inRect.yMin += 15f; + inRect.yMax -= 15f; + + var defaultColumnWidth = (inRect.width - 50); + Listing_Standard list = new Listing_Standard() { ColumnWidth = defaultColumnWidth }; + + + var outRect = new Rect(inRect.x, inRect.y, inRect.width, inRect.height); + var scrollRect = new Rect(0f, 0f, inRect.width - 16f, inRect.height * 2.2f + 300); + Widgets.BeginScrollView(outRect, ref scrollPosition, scrollRect, true); + + list.Begin(scrollRect); + + + list.CheckboxLabeled("RFM_SettingsAllowChanceAirDrop".Translate(), ref allowChanceAirDrop); + //Percentage chance of RAID generation + list.Label("RFM_SettingsChanceGetRaided".Translate((int)(chanceGetRaided * 100))); + chanceGetRaided = list.Slider(chanceGetRaided, 0.01f, 1.0f); + //Minimum time between raids + list.Label("RFM_SettingsTimeBeforeInsultingAgain".Translate(timeBeforeInsultingAgain)); + timeBeforeInsultingAgain = (int) list.Slider(timeBeforeInsultingAgain, 0, 1000); + //Loss of goodwill when insulting + list.Label("RFM_SettingsGoodwillLoss".Translate(goodwillLoss)); + goodwillLoss = (int)list.Slider(goodwillLoss, 0, 100); + //Minimum hour before start of the raid + list.Label("RFM_SettingsMinHourStartRaid".Translate(minHourStartRaid)); + minHourStartRaid = (int)list.Slider(minHourStartRaid, 0, 128); + //maximum hour before start of the raid + list.Label("RFM_SettingsMaxHourStartRaid".Translate(maxHourStartRaid)); + if (maxHourStartRaid < minHourStartRaid) + maxHourStartRaid += 1; + + maxHourStartRaid = (int)list.Slider(maxHourStartRaid, 0, 128); + + list.End(); + Widgets.EndScrollView(); + } + + public override void ExposeData() + { + base.ExposeData(); + + Scribe_Values.Look(ref chanceGetRaided, "chanceGetRaided", 1.0f); + Scribe_Values.Look(ref timeBeforeInsultingAgain, "timeBeforeInsultingAgain", 0); + Scribe_Values.Look(ref goodwillLoss, "goodwillLoss", 15); + Scribe_Values.Look(ref minHourStartRaid, "minHourStartRaid", 1); + Scribe_Values.Look(ref maxHourStartRaid, "maxHourStartRaid", 8); + Scribe_Values.Look(ref allowChanceAirDrop, "allowChanceAirDrop", true); + + } + } +} \ No newline at end of file diff --git a/Source/1.5/Utils.cs b/Source/1.5/Utils.cs new file mode 100644 index 0000000..655d3e9 --- /dev/null +++ b/Source/1.5/Utils.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RimWorld; +using Verse; +using UnityEngine; + +namespace aRandomKiwi.RFM +{ + static class Utils + { + static public GC_RFM GCRFM; + + public static string TranslateTicksToTextIRLSeconds(int ticks) + { + //If less than one hour ingame then display seconds + if (ticks < 2500) + return ticks.ToStringSecondsFromTicks(); + else + return ticks.ToStringTicksToPeriodVerbose(true); + } + } +}