Creating Premade Sim Relationships
This is the next blog in my series on how to create premade sims in Sims 4 and set their relationships, even with other sims outside of their households. The prior blog (available here) discussed how to create premade sims on new save start, including occults.
Note that this is an intermediate tutorial series that assumes you are familiar with XML modding, Sims4Studio, and Denton47's Premade Household Tool (which I'll refer to as the PHT).
There are a few different ways to set premade sim relationships on new save start. If you are setting these relationships within a single household, then you need a premade household template and premade sim templates for your sims. These should be, of course, inside a package file. You can create and edit these within Sims4Studio.
The premade household template should contain links to the premade sim templates. Generally, the data extracted by the PHT will override most things inside the premade sim templates, so those can be blank so long as you're not creating a two-form occult (or assigning a career NPC to a specific lot, which I'll discuss later.)
As discussed in the occult sim section of the previous blog, to add in premade household and sim templates, you need to extract your sim's household from the save file you created them in using the PHT. Then open the package you just extracted in the PHT, navigate to the Edit Household section, and paste in the instance number for the households' premade household template in the section.
The next step is to go to Sim -> pick the appropriate sim -> Gameplay Data -> Premade Sim Template to add in the instance for their premade sim template. The gameplay data section must be expanded for the premade sim template line to be visible. Repeat for as many sims are in the household. Each needs to have a unique template with a unique tuning ID and instance, even if they're blank.
Once your templates are linked, you can set appropriate relationships within the premade household template, with the premade sim templates specifying who each sim in the relationship is. The PHT will override some of this data, so you may want to create sims in families as unrelated or break these relationships in CAS before extracting.
Please note that the relationships in the premade household template are not packsafe. If you use anything that is associated with a DLC (for example, the Parenthood relationships between family members) a user will experience errors on new save start if they do not own the pack, or have the pack disabled. This is also true of modded relationships, if they are DLC specific or if a user might not have the mod.
Setting Relationships Outside of the Household
If you want to set relationships with sims outside of the household, or set DLC-specific relationships in a packsafe way, then you need to either override the World.Premade_Sim_Relationships file or inject to it using a script mod.
If you are planning on making your mod compatible with my Premade Sim and Relationship Overhaul (PSRO) mod, then you can just copy my injection snippet (just make sure to change the file name and replace the tuning with your own) and have my script file do the work for you. Otherwise you will need to create your own script file. You can copy the Python coding from my script file and edit it appropriately, please just give credit to januksenkosketus for writing it.
Using this method (override or injection snippet), you can set relationships between any two premade sims, provided they have a premade sim template. This is just a loot that travels from sim a to sim b, with the specific sims identified by their premade sim template tuning IDs.
For base game sims - or any sims - that do not have a premade sim template, you will need to add both a premade household template and a premade sim template using the method specified above - or you can require that your users install the PSRO and target your loots to the premade sim templates of the PSRO sims. (I will write more on this in a later blog.)
Sim Fixups with Loots
Because setting relationships with World.Premade_Sim_Relationships is just sending a loot from sim a to sim b, there are many, many things that you can do with this. First, sim a and sim b can be the same sim, which allows you to do certain types of fixups or assign self-deleting traits, etc.
This premade sim is supposed to be a detective, and was given the EP01 (Get to Work) detective career. I wanted to ensure that, if a player did not have EP01, that this sim would still appear as a detective to catch the new burglar. I was able to do that with this fixup loot, which tests if the sim actually has a career on new save start. This is just one example of the many things you can do.
Making Loots Packsafe
For most types of XML modding, you can use something called the "group ID" trick to prevent the game from trying to call coding and files that a user doesn't have installed. The group IDs correspond to specific packs and DLC and if a user doesn't have that pack the game recognizes it and won't fire the coding. This prevents weird errors from occurring.
However, the new save process does not recognize or honor the group ID trick. Neither the premade household template nor the World.Premade_Sim_Relationships loots are packsafe. If anything contained in this first layer is not in the base game, or a DLC that the user has installed and enabled, then they will experience errors on new save start and all loots after the invalid one will not run.
To avoid these errors, you can chain your loots. The first layer of loots, referenced in World.Premade_Sim_Relationships or in the injection snippet, should contain only base game files (relationships, traits, careers, etc). The second layer (and anything after that) will honor the group ID trick and can be freely used to deliver DLC-specific content. You can chain/layer your loots using an Action inside the first loot.
In this example, I use one base game loot to deliver a second loot that sets the Parenthood-specific "Authority" track between a parent and child sim. The second file uses the group ID trick.
If you regularly disable certain DLC to play without some packs, such as for game challenges, or if you regularly disable certain DLC to test your mods, then I would strongly recommend only putting base game files in this first layer. So, only base game relationships in the premade household template, and only base game stuff in the first layer of loots from sim a to sim b.
Everything else should go either into a follow-up loot delivered via an action from the first loot, or should be contained within the extracted household/sim data from the PHT. This is the most packsafe way to structure things.
Testing Your Edits
Please be aware that any errors editing these files (the wrong loot, sim template ID, etc) will result in save errors on new file start and that last exceptions will not be able to diagnose what's wrong. I suggest testing each addition thoroughly before moving on to the next stage.















