Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 1.5/Assemblies/RaidsForMe.dll
Binary file not shown.
3 changes: 2 additions & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<li>1.2</li>
<li>1.3</li>
<li>1.4</li>
<li>1.5</li>
</supportedVersions>
<modDependencies>
<li>
Expand Down Expand Up @@ -41,7 +42,7 @@ Fully customizable !

<color=#FFD800><size=24>Version</size></color>

1.0.6 for Rimworld 1.4
1.0.7 for Rimworld 1.5

<color=#FFD800><size=24>Contributors</size></color>

Expand Down
44 changes: 44 additions & 0 deletions Source/1.5/GC_RFM.cs
Original file line number Diff line number Diff line change
@@ -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<string, int> lastRaidGT = new Dictionary<string, int>();
private Game game;
}
}
117 changes: 117 additions & 0 deletions Source/1.5/Harmony/FactionDialogMaker_Patch.cs
Original file line number Diff line number Diff line change
@@ -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<RulePackDef> list = new List<RulePackDef>();
string text;

//Goodwill decrement
faction.TryAffectGoodwillWith(Faction.OfPlayer, -1 * Rand.Range(1,Settings.goodwillLoss+1) , true, true, null, null);

if (insultTex == null)
insultTex = ContentFinder<Texture2D>.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);
}
}
}
}
19 changes: 19 additions & 0 deletions Source/1.5/Harmony/Patches.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
36 changes: 36 additions & 0 deletions Source/1.5/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]
31 changes: 31 additions & 0 deletions Source/1.5/RaidForMe.cs
Original file line number Diff line number Diff line change
@@ -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<Settings>();
}

public void Save()
{
LoadedModManager.GetMod<RaidForMe>().GetSettings<Settings>().Write();
}

public override string SettingsCategory()
{
return "Raids For Me";
}

public override void DoSettingsWindowContents(Rect inRect)
{
Settings.DoSettingsWindowContents(inRect);
}
}
}
51 changes: 51 additions & 0 deletions Source/1.5/RaidForMe.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>aRandomKiwi.RFM</RootNamespace>
<AssemblyName>RaidsForMe</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\1.5\Assemblies\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.*" />
<PackageReference Include="Lib.Harmony" Version="2.3.3" ExcludeAssets="runtime" />
</ItemGroup>
<ItemGroup>
<Compile Include="GC_RFM.cs" />
<Compile Include="Harmony\FactionDialogMaker_Patch.cs" />
<Compile Include="Harmony\Patches.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RaidForMe.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
25 changes: 25 additions & 0 deletions Source/1.5/RaidForMe.sln
Original file line number Diff line number Diff line change
@@ -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
Loading