Triplis Mods for The Sims 4

Modding Tools

The following are tools that I've built specifically for modding The Sims 4. In the spirit of sharing and open source, you can download the source code if you'd like, as well as the program itself.

Tools

Sims 4 Auto Hash

Download

Download Source Code

Updated January 24, 2019: Most files now default to 64-high-bit, instead of 64-bit, as per recommended hash convention by other, more experienced modders. I also added a few more data templates and added support for Scumbumbo's XmlInjector Class type.

Introduction

I built this program as a way to speed up the process of creating and applying unique hash IDs to custom XML tuning files. Please note that the program may have bugs or be incomplete in some ways, so use at your own risk. The priority here was functionality for an experienced modder, less so than ease-of-use for those with little knowledge of modding.

That said, I have every intention of improving on it where I can and where it makes sense to for its intended purpose, especially as I improve in my knowledge of programming.

Warnings

Results should match other standard hash generators (ex: Sims 4 Studio), provided the internal filename contains no non-english characters. Unlike other hash generators, I have not figured out how to properly handle non-english characters. I built the program in C++, so I couldn't just copy the functionality of other tools (which are written in C#). So if you try to use the tool with a filename that has non-english characters, you will encounter messy results. This is something I desperately wanted to include support for, but support for different languages is an apparently oceanic topic of study in my research so far, so I am putting it aside for now and releasing what I have.

Also, the program will only function properly on Windows. It is not compatible with other operating systems to my knowledge.

Also also, every file type defaults to 64 high bit unless otherwise specified. There may be file types I haven't manually set where 32 bit or 32 high bit is required to get the file to work in game. If you are using the tool and notice something like this, feel free to let me know and I will make it a priority to update the tool with that file type adjusted accordingly.

How to Use (summary)

When you open the program, you should see a standard console interface. You paste in a file path, press enter, and it will do a number of operations on the file: generate a hash for it, insert the hash as its internal file hash in decimal and then apply the hash to its external filename as hexadecimal.

So the simplest usage should look something like the following:

  • Pick a name for your XML file internally and save it with that name. For example: n="Triplis:Interaction_DoThings" -- This is the name that will be used for generating the hash. Make sure the external filename includes "S4_" and is the file type XML.
  • Copy the file path. You can do this by doing shift + right-click while looking at the file in windows explorer. Notepad++ and Atom text editors both have an option to copy file path as well.
  • Paste the file path into the program and press enter.
  • You're done!

When you are finished, you can click the X or type in one of a few standards for quitting the program and press enter: -1, q, or quit

The program is designed to loop, so you can leave it open and do file after file if you wish.

How to Use (advanced)

Multiple Files

You can do more than one file at a time. Simply select more than one in windows explorer, use shift + right-click to copy path, and then paste into the program. When you paste in multiple paths at the same time, it will process all but the last one automatically. You'll have to press enter to get it to proceed on the last one.

What Gets Appended as Name

When choosing an internal filename, consider the example n="Triplis:Interaction_DoThings"

Note the colon, ":" operator in there. That's optional. If included, it will cause the program to ignore anything before ":" when appending the internal filename to the end of the external filename. For example, if you want your external filename to be S4_3C1D8799_00000000_D3613ABC297B23B7_MyZoneModifier even though the internal filename is Triplis:MyZoneModifier, you would include the ":" operator. This is purely a preference thing; it has nothing to do with the hash generation itself. I put it in because I like to use S4PE and S4PE will build a key list for assets that have a name appended to the end of them, making it easier to navigate your projects when looking at them in S4PE, but if my hash generation appended the entire filename, it could get rather long! You might know that your project is only by you and so there is no need to append your modder name to the external name of the file.

Keep in mind, of course, that using a unique modder name does matter for hash generation when it comes to what you choose for the internal filename! You want to make sure the chances of someone using the same hash is as low as possible. MyZoneModifier is not likely to be unique, but TheLastKnightOfBardledom:MyZoneModifier or TheLastKnightOfBardledom_MyZoneModifier probably will be.

Data Template Files

The program comes with a set of template data files. Meaning, existing data files that will be copied for some file types when a hash is generated. This is to speed up the process of hunting down data file types every time you want to make a new tuning file that requires one. Not all data template files have been added yet.

Some, however, have more than one template and you can choose which one will get copied by naming your XML file in the right way.

For example, if you have a buff XML file and you want to generate a data file for the mood Confident, include, somewhere in your internal filename, "BuffConfident." This might look something like: n="Triplis:Buff_StrutAround_BuffConfident"

You can look at the template folder (it comes with the program) and see what the syntax looks like for these template variations. Right now, most of the variation revolves around different types for buffs and different types for traits. Note that you will still need to edit the data file somehow for modifying things like strings.

^

Sims 4 Auto STBL

Download

Download Source Code

Introduction

Creating new strings and adding them to string tables has always been tedious for me and sometimes challenging, when adding to existing projects, especially ones that are a mixture of english strings and translated strings. I wanted a way to automate most of this process. As I will say with any tool, the program may have bugs or be incomplete in some ways, so use at your own risk. The priority here was functionality for an experienced modder, less so than ease-of-use for those with little knowledge of modding.

Warnings

This program will only function properly on Windows. It is not compatible with other operating systems to my knowledge. It will also only read english strings from XML files, currently (it can handle non-english characters that are in existing stbl files, just not reading in from XML files).

Due to the nature of how it's designed, it comes with some (limited) safeguards. Namely, it will make a backup of XML files inputted and STBL files referenced before editing them. However, with the way it's currently designed, it will ignore files with the same name when making backups. So if you want a "most recent" backup each time, you'll need to clean out the Backup folder on a regular basis.

That said, I can say with confidence that I've used the tool extensively and never run into any unexpected results. As long as you use it as designed, nothing weird should happen and there is some error-checking in case you don't.

How to Use

Example

When you open the program, you should see a standard console interface. You paste in a file path, press enter, and it will do a number of operations on the file. It's similar to the Auto Hash tool in this way. The following is an example to explain how it works.

You have a custom interaction file and you want a unique string name for your interaction that'll show up in-game. Somewhere in the file is a line like the following:

<T n="display_name">0x588ECF04<!--String: "Enchant to Kneel"--></T>

Note that the comment describing what the string should be is important. The formatting the program looks for is precise and is based on strings being commented in the way that standard tools do (like Scumbumbo's XML Extractor - I'm not sure if S4S extraction does the same).

Now let's get the tool to recognize our string. It was Enchant to Kneel, but we're going to change it to Bungalow Banjos. So we do this:

<T n="display_name">0x588ECF04<!--StringCustom: "Bungalow Banjos"--></T>

If we run the program on this XML file, it will find the commented string with the "StringCustom" identifier and create a unique hash for the string in quotes, our "Bungalow Banjos." Note that this hash is created from a combination of the string itself and the internal name of the file (the "n=" value), so for best practice to avoid hash collisions, make sure you've given the file a unique name first!

This also means that you could theoretically put "Bungalow Banjos" in two different files and generate the same string for both, but with a different hash value, which is not ideal. So keep this in mind when making your strings. More info on the limitations of checking for duplicates below.

Next, the program will insert the new hash into the XML file for you. So your line of code might end looking something like this:

<T n="display_name">0xA706DD72<!--StringCustom: "Bungalow Banjos"--></T>

Now all that's left is the string table itself. The program comes with a folder called Edit. If one or more stbl files is in the Edit folder, the program will append our Bungalow Banjos string to each. If no stbl file is in the Edit folder, the program will create a new stbl file, one for each language variation type, with any strings from our XML file added to it.

And that's it! You can add the stbl files from your Edit folder to a package file, add in your interaction, and you're ready to see your string in-game.

Duplicate Checking

The program will check for and remove duplicates from the same inputted XML file. For example, if you have a motive file where a string is repeated, it will only add this string once, even if you have the StringCustom syntax for the same string twice. It should also catch hash duplicates. Strings with the same text, but a different hash, across more than one file, may get through, so be wary of that. You don't need to use the tool on more than one file for the same string anyway. You can just copy/paste the hash value and string from file to file once you've got it working in one file.

File Type Requirements

Like the Auto Hash tool, make sure the external filename includes "S4_" and is the file type XML. I can consider offering support for S4S syntax on request. My habit is using the default syntax from Scumbumbo's XML Extractor along with S4PE, so that's what it was made to support.

Credits

This program would not have been possible without the help of Scumbumbo aiding me in tracking down a mysterious bug that was causing a game crash. As is often the case in programming, it turned out to be an "off by one" error. You don't have to worry about that error though. I've utilized the tool extensively since and there is no crashing from the string tables it makes anymore (I would not be releasing it if there was such an issue still). Thank you to Fogity and Turbodriver as well, who also offered some input and insight in the process of trying to figure out the bug.

^