Help request - Moding a custom infestation event for a modded animal

Started by Lord_Mortimus, October 12, 2020, 11:18:08 PM

Previous topic - Next topic

Lord_Mortimus

I have modded in a beetle, chitin, eggs, armour and all is well. Last thing to do is have them enter the map as a custom infestation (without a hive) instead of a migration/wander-in event.
I feel having a few of them tunnel onto the map in a cave will make the most sense.

I've copied and adjusted the two below defs; (zip to full mod folder attached)
C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Hornbeetle\Defs\Storyteller\Incidents_Map_Threats
C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Hornbeetle\Defs\TaleDefs\Tales_Incident

The latter I'm not sure exactly what it does TBH.
All I've really done here is change 'infestation' to 'hornbeetlesighting'. So of course while it is it's own event it still just triggers a standard infestation.

I've dug through every def file in Core/Defs but can't see how the events trigger things happening in-game or how they link to spawning a hive/pawns. I also looked for the reverse direction (I.E. if the hive or insects anmials link back to the infestation event... no dice)

So close to finishing this mod but at a loss here.

Any help would be greatly appreciated. I've attached a zip of the mod folder for reference. (it's my first time doing any modding/xml so notes are welcome)

Thank you in advance.

Lime_time

Have you tried picking apart other mods?

Vanilla Events Expanded

And

Vanilla Factions Expanded - Insectoids

Are two off the top of my head that I would dissect if I were having your problem.

Lord_Mortimus

Ah I had been pulling apart other mods for other aspects of this mod but hadn't conisdered those two for this problem (maybe because I haven't used them).

I've downloaded them and had a dig round but keep coming back to the <workerClass> tag on the [Incident_Map_Threats] files.
I've googled more into what the workerclass tag actually is and i think I'm going to need to get into the c# files now. I guess?

Downloading Visual Studio now and will have another try, I've just been using notepad++ so far.
I think this will be the missing part to find whatever I'm missing that links the event to actually spawing a hive, which then spawns the pawns.

I've accepted I'll need a thing (i.e. hive) to spawn the beetles. But my plan will be to make it a hole/tunnel which damages itself out of existance after a day (we'll say it's a cave in as the beetles are surfacing to look for food and in their haste they dug a bad tunnel... seems logical enough right?).
But first things first. I guess I'm learning Visual Studio...

LWM

You have used some tool like dnSpy to look at the vanilla code?

The wiki has a bunch of useful tips for getting started with C#.

Lord_Mortimus

Quote from: LWM on October 13, 2020, 09:32:44 AM
You have used some tool like dnSpy to look at the vanilla code?

The wiki has a bunch of useful tips for getting started with C#.

I've only been using notepad++ so far. Tried digging around the C# files with Visual Studio and just today have tried dnSpy but not having much luck, feeling lost.

I'm pretty confident that the missing part is changing the tag <workerClass>IncidentWorker_Infestation</workerClass>. on the Incidents_Map_Threats xml.

But I can't work out there this directs to. It must be the place that triggers a hive, or defines an "infestation" which triggers a hive.
If I can find that and copy and edit to spawn a buidling that spawns beetles I'll be laughing. (already have the building working, just can't spawn it via an event.)

I'm worried I've exhausted my knowledge. I only looked at an XML file for the first time a few days ago!  :-[

Lord_Mortimus

Okay, I'm slamming my head and making a bit of progress. Worked out a bit more about Visual Studio, C#, Assemblies folder, etc.

Current roadblock in Visual Studio is a word (Mathf) should be connecting to UnityEngine (it is in the core's assembly) but I can make that happen... Everything else let me Alt+Enter to link correctly.

I attached an updated mod folder contatining everything so far. More than happy for others to poke around and give advice.

Here's the line:
{
Map map = (Map)parms.target;
Thing t = RimWorld.InfestationUtility.SpawnTunnels(Mathf.Max(GenMath.RoundRandom(parms.points / 220f), 1), map, false, false, null);
base.SendStandardLetter(parms, t, Array.Empty<NamedArgument>());
Find.TickManager.slower.SignalForceNormalSpeedShort();
return true;
}


[Bonus update- this is for my sanity more than you guys]
Work since original post;
- Made an Assemblies & Source folder
- Started a Visual Studio project in the source folder (Assemblies will be empty until I finish that and build it. I think..)
- Made the <workerClass> in the Incidents_Map_Threats XML as "LordMortimus.IncidentWorker_HornBeetleSighting" (ready for the VS project..)
- Got a placeholder image for a tunnel 'building' (will act similar to the hive but for beetles)
-----Need to work out how to have it self destruct after a day.. (bigger problem for later, suspect it'll be less simple than it sounds)
-----Can't make the heal per tick amount negative... dang.
-----Could make it need maintanence quickly, but need to make a new behaviour for the beetles to not repair... hmm.. backburner.