I'm a novice programmer, but want to try my hand at making a Rimworld mod. I hope to get some help on how to realise my idea.
Epitaphs
For every pawn that enters the map I want to log relevant life events to create an epitaph on the tombstone if the pawn is buried in a grave or sarcophagus. The life events should look something like this:
- <date>: <pawn> entered the map to attack <colony name>
- <date>: <pawn> was taken prisoner by <colony name>
- <date>: <pawn> was recruited by <other pawn> and joined <colony name>
- <date>: <pawn> married <other pawn>
- <date>: <pawn> survived <disease>
- <date>: <pawn> died from <cause of death>
- <date>: <pawn> was put to rest by <other pawn>
The epitaph itself will be loosely based on the life events. Of course, in Rimworld fashion, there should be some creative storytelling.
How to build it?
The last couple of days I spend setting up my environment, doing the tutorials, decompiling and reading the source code and installing the debugger tool. Thanks to everyone on this forum and the wiki for providing massive amounts of information. To get a feel of things I used the 'Tale Log Tab' mod, because it does something similar to what I want to do. This mod is outdated, but I fixed it and managed to get it running in debugger mode.
https://steamcommunity.com/sharedfiles/filedetails/?id=1188524738
So, I have a basic understanding of how to mod and how the game handles storytelling. I studied the TaleRecorder and I think I can use it for my purposes, because lots of events I need are logged in there already. What I did so far:
- made a new MainTabWindow called Epitaph, based on the Tale Log Tab
- made a DefModExtension to extend TaleDef with a new field useForEpitaph, default false
- made a PatchOperation to add the new field to the LandedInPod TaleDef (because it's the first tale that is generated)
- display all events in the Epitaph Tab that have useForEpitaph = true
So far I'm satisfied with my progress, but I'm not sure how to proceed. What I need to do now:
- Patch all existing TaleDefs for the epitaph with the new field useForEpitaph
--> I know how to do this
- Remove the Epitaph MainTabWindow and add an Epitaph tab to graves and sarcophagus
--> I have a vague idea how to do this
- Move functionality to new grave tab and filter for tales concerning the buried pawn
--> Not sure how to pass the buried pawn as input to my new class
- Make sure the TaleManager doesn't purge the tales where useForEpitaph = true
--> I tried to use TaleType.PermanentHistorical but this has too many unwanted consequences (clutters the history graph). I think I need to add a new TaleType, but not sure how to change the existing Tale functionality to take this into account.
- Insert custom Tale events by calling TaleRecorder.RecordTale, for instance when a raider spawns on the map.
--> I have no idea, yet. Do I need Harmony?
- Add more creative storytelling for the epitaph texts
--> of later concern
I'm sure I'll figure things out if I struggle along, but I was hoping to get some advice. Maybe someone can point out a mod that does a similar thing for reference. Is using the TaleManager even a good idea to build this mod? Should I create my own EpitaphManager?
Epitaphs
For every pawn that enters the map I want to log relevant life events to create an epitaph on the tombstone if the pawn is buried in a grave or sarcophagus. The life events should look something like this:
- <date>: <pawn> entered the map to attack <colony name>
- <date>: <pawn> was taken prisoner by <colony name>
- <date>: <pawn> was recruited by <other pawn> and joined <colony name>
- <date>: <pawn> married <other pawn>
- <date>: <pawn> survived <disease>
- <date>: <pawn> died from <cause of death>
- <date>: <pawn> was put to rest by <other pawn>
The epitaph itself will be loosely based on the life events. Of course, in Rimworld fashion, there should be some creative storytelling.
How to build it?
The last couple of days I spend setting up my environment, doing the tutorials, decompiling and reading the source code and installing the debugger tool. Thanks to everyone on this forum and the wiki for providing massive amounts of information. To get a feel of things I used the 'Tale Log Tab' mod, because it does something similar to what I want to do. This mod is outdated, but I fixed it and managed to get it running in debugger mode.
https://steamcommunity.com/sharedfiles/filedetails/?id=1188524738
So, I have a basic understanding of how to mod and how the game handles storytelling. I studied the TaleRecorder and I think I can use it for my purposes, because lots of events I need are logged in there already. What I did so far:
- made a new MainTabWindow called Epitaph, based on the Tale Log Tab
- made a DefModExtension to extend TaleDef with a new field useForEpitaph, default false
- made a PatchOperation to add the new field to the LandedInPod TaleDef (because it's the first tale that is generated)
- display all events in the Epitaph Tab that have useForEpitaph = true
So far I'm satisfied with my progress, but I'm not sure how to proceed. What I need to do now:
- Patch all existing TaleDefs for the epitaph with the new field useForEpitaph
--> I know how to do this
- Remove the Epitaph MainTabWindow and add an Epitaph tab to graves and sarcophagus
--> I have a vague idea how to do this
- Move functionality to new grave tab and filter for tales concerning the buried pawn
--> Not sure how to pass the buried pawn as input to my new class
- Make sure the TaleManager doesn't purge the tales where useForEpitaph = true
--> I tried to use TaleType.PermanentHistorical but this has too many unwanted consequences (clutters the history graph). I think I need to add a new TaleType, but not sure how to change the existing Tale functionality to take this into account.
- Insert custom Tale events by calling TaleRecorder.RecordTale, for instance when a raider spawns on the map.
--> I have no idea, yet. Do I need Harmony?
- Add more creative storytelling for the epitaph texts
--> of later concern
I'm sure I'll figure things out if I struggle along, but I was hoping to get some advice. Maybe someone can point out a mod that does a similar thing for reference. Is using the TaleManager even a good idea to build this mod? Should I create my own EpitaphManager?