#0031: Creating a TF2 themed RimWorld scenario mod

#0031: Creating a TF2 themed RimWorld scenario mod

Preamble

I recently decided that I’d like to try dipping my toes into creating mods for RimWorld. Incase you are unfamiliar with the game: RimWorld is a base builder; where the core objective is to try to create a functioning base or colony.

Building and maintaining this colony is achieved by issuing orders to various pawns. Examples of orders include: building the structures you designed, hunting animals, farming crops, fixing broken items, creating tradable goods, and cooking food to name a few. Additionally, it also includes arming up and engaging in combat.

RimWorld is a game that is in a similar vein to the venerable classic that is Dwarf Fortress. And like DF, once you have built a base that is halfway decent, you can then move on to secondary objectives such as: exploring the world, or actively trading and warring with other factions.

I decided to start modding RimWorld with something very small. Something that could be done in one or two sittings and with minimal research and planning. That way the mod doesn’t risk spiralling out of it’s initial small scope. Which can likely result in an eventual state of demotivation and ultimately project abandonment. Which is primarily caused by ongoing feature creep due to poor project management (scope discipline).

With that in mind: I decided on a simple custom scenario, coupled with a preset roster of pawns. For nostalgia’s sake: I decided to give this scenario a Team Fortress 2 theme. As a rule of thumb (and for obvious motivational purposes) I only really create things that I myself would like to play with. And to me at least: the idea of playing with the TF2 roster within the RimWorld settings sounds pretty fun. I hope you agree.

Creating a custom scenario

Scenario creator tool

Straight off the bat I should mention that the built-in scenario creator tool does not facilitate editing the individual starting pawns itself, just the world conditions and the equipment that they start with. In other words it does not allow for the modification of each individual pawn’s variables such as traits and skills. To specify pawn variables, one has to use an additional mod called “EdB Prepare Carefully”. Which I will discuss in more detail later.

With that said, let’s begin. Creating a custom scenario is a rather straight forward affair. All you need to do is navigate the menus within the RimWorld game, and follow their very simple instructions.

There are several game options available from the scenario editor. However for the most part editing a game scenario consists of choosing how many pawns the player is able to choose from, and then start with. Then choosing their starting load-out of equipment and resources: weapons, tools, food, animals, building materials, etcetera.

Additionally one could also add various world conditions such as periodic events (e.g. meteorite crash), permanent weather conditions (e.g. toxic fallout), a game time limit, as well as more wacky things such as every world pawn exploding upon death.

It seems like a rather fun thing to play with, however I only required an equipment list that vaguely resembled something that the real TF2 cast might have. I tried to give each pawn similar weapons and tools to the characters that I modelled them after. However, the group got little else in terms of general equipment and technology, outside a handful of exceptions for narrative reasons. Namely the ground scanner and a drill; since they are technically (narratively speaking) on this rim world in order to survey it for Australium.

I should also mention that I designed this equipment list with the mod “Simple Sidearms” in mind. In other worlds each character pawn was designed with the intention that they have the ability to carry more than one weapon. For example the Sniper was given either a sniper rifle or recurve bow to equip as a primary weapon, with the gladius (a functional surrogate for his kukri or bush knife) to be used as a secondary weapon (sidearm). Although the mod itself isn’t strictly necessary. If you choose not to use it, you’ll just be saddled with an abundance of surplus weaponry sitting in your stockpiles. That’s all.

Pawn equipment list

Sniper:

  • [x1] sniper rifle
  • [x1] recurve bow
  • [x1] plasteel gladius

Pyro:

  • [x1] incendiary launcher
  • [x1] molotov cocktail
  • [x9] incendiary shells

Scout:

  • [x1] shotgun
  • [x1] wooden Club

Soldier:

  • [x1] shotgun
  • [x1] plasteel breach axe
  • [x3] triple-shot rocket launcher

Engineer:

  • [x1] shotgun
  • [x1] autocannon turret
  • [x1] plasteel mini-turret

Medic:

  • [x1] revive serum
  • [x18] medicine (x18)
  • [x1] vitals monitor

Heavy:

  • [x1] minigun

Demoman:

  • [x1] frag grenade
  • [x1] plasteel longsword
  • [x60] beer (x60)

Spy:

  • [x1] revolver
  • [x1] knife

Miscellaneous:

  • [x1] ground penetrating scanner
  • [x1] deep drill
  • [x18] packaged survival meal

Alongside the equipment list, I also wrote some flavour text for the scenario. However, as far as what I wanted to achieve with this mod, this is as far as the scenario editor went. The next thing I needed to do was edit the nine random pawns the scenario provided into the TF2 mercenaries using the Prepare Carefully mod.

Creating custom pawns

In order to create my custom pawns I needed the mod “EdB Prepare carefully”. This mod allows the player to edit their pawns to a far deeper level than the standard RimWorld tool does. Which only really allows rolling a completely new character with randomised stats. Before this mod, I remember having to keep clicking the randomise button repeatedly until I eventually got something halfway decent. A process that honestly gets old rather quickly.

Using this mod I created a custom nine pawn preset. With each pawn having their own unique appearance, backstory, traits, health conditions, and skills. Once finished I saved this configuration locally, in a file named “TF2_crew.pcp”. It saved as a custom XML file that was suffixed with “.pcp”, which I assume stands for “Prepare Carefully Preset”.

And that’s it. That is all that there is to the process. Easily really. Although I must say that: it actually took me several hours to get all nine pawns’ various stats just so. This is because I can be a rather pedantic perfectionist when it comes to the little (read: insignificant) details. Things like which eye is the Demoman missing (left), and whether I should give him a peg (left) leg or not.

That’s not even to mention assigning each pawn’s skills, since they absolutely have to be (in my mind) representative of the character. This was then exacerbated by the fact that I also tried (and mostly failed) to balance the pawns in terms of usefulness and general colony value. That is, as well as retaining each character’s unique flavour; like Pyro’s oddness, or Demoman’s alcoholism. Needless to say it took some time to settle on such things.

This balance of priorities, often working against each other ended with a reasonable compromise in the final version. At least I think so. Still, I learned that Engineer and Medic are by far the most useful pawns in application, and that if you allow the other pawns to drink Demoman’s beer, causing you to completely run out by day four … well let’s just say that I nearly put a bullet in him myself, after his third low mood tantrum due to the alcohol withdrawal debuff coupled with his natural pessimism.

Scenario narrative and expected gameplay

Explaining the narrative premise

Yes, there is indeed a story here. There is reason for these guys to be on an extraterrestrial planet 3000 years in the future. The story is rather simple. 3000ish years ago, after exhausting the Earth’s supply of Australium: TF Industries decided to look for it on other planets.

So they built a fleet of Mann Co. brand low cost space rockets. A thousand of them. Each rocket containing 9 cryogenic life support pods designed to keep it’s occupant in a state of suspended animation. The occupants naturally being clones of the mercenaries. Cheap, useful, and expendable. These clones were then shot into space with the mission to survey any planets that they land on for Australium.

That is if they actually make it to one. And after three thousand years of drifting in space, and against all odds: one rocket managed to actually make it to a habitable planet. It also somehow manages to deposit it’s cargo of crypto-sick mercenaries and their gear; just in time to avoid catching them in the fires of it violently exploding in the planets atmosphere.

Now these mercenaries find themselves on a hostile planet with minimal supplies other than guns. And with no direction other than a 3000 year old order to survey the planet for a rare resource.

Just for the sake of clarity, I should mention that the resource Australium is not implemented within this mod. It is purely a narrative plot device. Funnily enough, implementing an extra resource like this is exactly the type of feature creep I mentioned earlier that end up killing my projects. Its a rabbit-hole that I don’t want to go down, nor need to go down as I simply want to bang out a small mod that consists of a custom scenario and character roster. That’s it.

In-game scenario text

Incentivising gameplay

I designed this setup for a combat heavy game. Since the player only starts with 18 meals (enough to feed a team of nine for about a day), no money for trade, no animals, and only a little medicine – it incentivises more aggressive actions in order to survive the early game. Especially at higher difficulties and challenging world conditions. Keyword: “incentivise”, not force.

The players are encouraged to strip the map of resources early. Steel, components, herbal medicine, berries, as well as deconstructing buildings for their materials, and attacking the ancient danger room much earlier than usual. This is because they don’t have the time to build up resources normally; by for example farming and stone cutting blocks. The nine pawns will just eat too much in the mean time.

Additionally the fact that every pawn also has the “psychopath” trait means that many of the drawbacks to bloody play-styles are removed. Such as emotional debuffs due to executing prisoners, butchering humans, or harvesting organs.

All of the above factors leaving early bloody aggression as a very viable and deeply incentivised play-style. Basically, I designed the TF mercenaries to play like the TF mercenaries. In other words: a hostile invasive violent paramilitary force, and not an agrarian farming community. Thank you very much.

Having said all of this good stuff, I should also parenthesis it with this final sentiment. Don’t feel like you have to to play these characters out in the way that I designed them. Feel absolutely free to tinker with them however which way you wish. Is Demoman’s alcoholism annoying you? Remove it. Don’t like how slow Heavy is? remove the Slowpoke trait from him. Pyro burning down your cornfield in the middle of the night for no reason? You get the message. Although I designed things in a way I personally find compelling; it’s your game at the end of the day. Play it your way™

Technical issues explained

RimWorld UI and editing XML files directly

Although creating a scenario using the in-game menus is simple enough, the cumbersome basic user interface for this can get rather frustrating rather quickly; because of this I quickly made an initial save of the scenario with all the basic fields and variables populated. This is in order for the RimWorld binary to create an XML file for the scenario. A file that I then chose to edit directly with a text editor.

I find that editing XML files in this way with a text editor to be a preferential experience, to fiddling with the game’s user interface. For example if I wanted to reorder a list of items, by taking the bottom item to the top of the list or vice versa: using a text editor it is as simple as cutting and pasting the textual data set into it’s desired place.

Whereas doing this within the game requires one to to click on either the up or down arrow button in order to make the list item move a singular place; by swapping positions with it’s respective neighbour. I should also mention that when the item swaps position with it’s neighbour, the list item itself moves on-screen and not the list items around it. This means that you can’t just keep smashing the arrow button to skip several places quickly; because the button moves from under your mouse once clicked. Imagine wanting to order a list alphabetically and then having to do something like that for every item on a 30 item list. Tedious. You’ll have to essentially manually bubble sort the entire list.

Using a text editor to bypass this went fine for the most part. I was able to reorder the populated list of equipment easily enough, as well as change item quantity and material (when applicable). I did however reach a sticking point here. After several edits I found that the RimWorld binary no longer recognised the scenario file. Something within the file was breaking the program’s ability to read data from it.

Naturally I thought that it was a syntax error. Maybe I forgot a character of syntactic punctuation somewhere, or forgot to enclose an XML data set properly with their data syntax. No. After much double checking for errors; followed by more back and forth: changing one thing at a time within the file, then rebooting the RimWorld game to test if it now recognises it. Well after that process, it turned out that adding comments to the data set broke the RimWorld binary’s ability to read the file. Just for clarity when I say comments I mean fully syntactically correct XML comments.

Example:

 <!-- this is my comment -->

I can only conclude that the XML interpreter within the RimWorld binary for whatever reason does not have the functionality to understand comments and skip them. At least when specifically talking about reading data from either files that it originally generated or from scenario files in general (.RSC file format).

After a little additional testing: apparently I may put comments in and have it still load but only if it is not within the <parts>…</parts> section and in between list items <li>data</li>. In other words as long as the comments aren’t in the only useful place to have them, in order to meaningfully separate a run on list of items into recognisable categories.

I’m guessing that the RimWorld interpreter probably has a very rigidly structured read protocol; and why shouldn’t it, since it is only expecting to read files it itself created. Please note that I am not an expert on XML nor the interpreter RimWorld is using, I just can’t help speculating when I observe such behaviours.

Honestly it much doesn’t matter anyway, I only mention my experience here in the case that you choose to add comments to your code base, and then it suddenly stops working despite having no syntax errors. I hope to save you some time needlessly troubleshooting and head scratching.

Text-field character limits

The RimWorld Scenario editor has an upper limit to the number of characters each text-field box can contain. (As of version 1.3.3117). I first realised this when my initial draft of the scenario description did not fit into the intended text-field box when pasted into RimWorld. What followed was a tedious process of trimming my sentences (narrative) until it finally fit.

To save you having to do the same, I decided to get the character limits of each text box. The process that I used was by inputting the character ‘0’ into each text field until full. Then CTRL+A, CTRL+C, and CTRL+V into an empty text file. I then used Xed text editor’s built-in tool that counts words and characters to get these results.

Text-field character counts:

Title: 55
Summary: 300
Description: 1,000
Game start dialogue: 20,000+*

*doesn’t seem to have a fixed upper limit (possible dynamic text-field)

Character count files:

Equipment parity issues

I spent quite a bit of time going back and forth between the scenario editor and the equipment section of the Prepare Carefully mod; as I wanted to make uniform both lists. Even though technically only the Prepare Carefully equipment list actually matters from a gameplay perspective since that is the one that overrules the scenario’s list and actually makes it’s way to the game. I still wanted both lists to be the same since the scenario list is the first one the player sees, and consequently informs them of what to expect.

I should mention that the reason why the two lists of equipment weren’t always identical is because as I edited the pawns, and looked through the (quite frankly better) Prepare mod’s equipment chooser: I got motivated to give and take equipment. For example I added the Auto-cannon to the list rather late, as only once seeing it’s graphic in the mod’s loadout section: did I get inspired to use it as a surrogate for the Engineer’s big turret.

In order to avoid this tedious back and forth editing, I would recommend that you plan ahead and write down the complete equipment list before initially creating a custom scenario. Alternatively, don’t worry about the scenario editors equipment list at all while making the custom pawn presets. Instead circle back to it at the end and essentially paste in the equipment list from Prepare Carefully.

Instructions for running this scenario (GNU Linux)

1) firstly make sure you have the mod “EdB Prepare Carefully” installed
2) download the file archive here: “rimworld_tf2_scenario.ZIP”
3) unzip the file archive
4) move/copy the file “TF Industries Australium survey force.rsc” to “~/.config/unity3d/Ludeon Studios/RimWorld by Ludeon Studios/Scenarios”
5) move/copy the file “TF2_crew.pcp” to “~/.config/unity3d/Ludeon Studios/RimWorld by Ludeon Studios/PrepareCarefully”
6) boot the game, it should show up as a custom scenario
7) choose it, then click on the “prepare carefully” menu button
8) click the “Load Preset” button and choose “TF2_crew”
9) edit the pawns to taste
10) start game

Note: Windows and Mac instructions are basically the same but with some variation around the location of the RimWorld data directory.

Closing thoughts

Simple one this time round. Like I said I wanted to complete something small in a timely manner, just to dip my toe into the waters of modding RimWorld. I hope you enjoy playing with this mod as much as I did. Hmm, is this thing even technically a mod? Does it matter? I guess not.

Funny. It actually took me longer to do this write up, then it did to create the actual thing that it is about. I guess that’s not that odd, considering the fact that explaining things properly can take it’s time. Especially with my signature caveats and addendums … and waffling.

I hope this article motivates you to at least try out getting into modding games, if you aren’t doing it already. Never be afraid to start something new. But start small. Start with something that can be completed within a timely fashion and with your current skillset. Then iteratively add complexity with each later thing that you complete.

I know this is rich coming from me, but remember that “perfect is the enemy of done”; and that there’s nothing more motivational than finishing something that you set out to do. It’s better to complete 100% of something small, than 66.6% of something big. One can be released out there for people to enjoy, whilst the latter is rotting in your “ongoing_projects” folder. Or maybe that’s just me.

Thanks for reading.

Mod Files

(Please check the downloads page for the most up to date version, incase I forget to update the link here.)

Term Glossary

UI – User Interface
XML – eXtensible Markup Language

Links, references, and further reading

https://rimworldgame.com/
https://steamcommunity.com/sharedfiles/filedetails/?id=735106432
https://steamcommunity.com/sharedfiles/filedetails/?id=927155256
https://rimworldbase.com/prepare-carefully-mod/
https://rimworldbase.com/simple-sidearms-mod/