Tutorial: Custom Paintings in Sims 3
by Snaitf & Srikandi
The method described in this tutorial has been largely superceded by the development of Inge and Peter Jones's Object Cloner, which makes the process far easier. We'd suggest modders use Xanathon's tutorial on making paintings with the cloner. This tut is being retained for advanced modders.
This tut is for catalog paintings; if you want to customize the paintings your sim paints, Tiger has just added that feature to his Neighborhood tool.
Snaitf deserves all the credit for discovering the method documented here; Srikandi just fleshed out the steps. Note: the three-part music "triptych" can't be recolored using this method; there may also be other problematic paintings, please comment if you find any.
Please post questions and comments about this tut here.
What you will need before starting
- a hash generator (to generate a unique instance ID). Snaitf's is perfect for our purposes: Snaitf's FNV Generator
- a hex editor, e.g. Winhex
- an image editor, e.g. Adobe Photoshop (purchase) or GIMP 2.0 (free)
- a DDS Plug-in for Photoshop or GIMP, or you can use The Compressonator (a standalone DDS convertor) with any graphics app. (I'm not going to explain the mechanics of working with graphics applications and .dds files here; it's covered in other tutorials, including DaLuved's CTU tut.)
- You're going to be manipulating a lot of files for this project; make a folder someplace easy to get to to save them all in.
What we are going to do is find the file for the painting object you are going to clone and its image file. You will edit the image file with your new painting, and make the object file point to the new image file. You'll set the object's price in the object file, and create a new string table file containing the painting's name and description. Then you'll make the object file point to the string table and save the new files together as a mod.
Find and extract the .dds file for the picture you want to clone, and modify it
- Open S3PE.
- Click File|Open, and navigate to GameData/Shared/Packages in the folder your game is installed in (e.g. Program Files/Electronic Arts/The Sims 3).
- Fullbuild2.package is the file that contains the images you want. Open it.
- Check Sort and Display resource names, and click on Name to see the names of the resources. The paintings all start with the word "painting". Scroll down till you find the one you want. I went for PaintingAnimalGiraf.
- Each painting has a few files resources with it; select them all, click File|Export, and choose or create a folder to put them in (anywhere you want). They'll be saved with the .dds extension.
- Open the .dds files in your image editor of choice. It should be readily apparent which one has the painting's image in it; close the others.
- Make a note of the part of the painting's filename between underscores right before the world "painting". For paintingAnimalGiraf, it's C1ECA4110BC90E09. This is the instance ID; you'll need it later. (You can use the Paste Bin in Snaitf's FNV generator to save it temporarily, or Notepad if you want a permanent record.)
- Modify the painting image with your art (an inner glow around the picture will give the frame some depth).
- Flatten the file, and save it. We used DXT5 compression, but DXT1 gives a smaller filesize and is probably fine for most images.
- Now you need a new instance ID for your modified painting. Generate one using the hash generator. Using Snaitf's generator, you can just click on Input Text, and then on Generate... that generates a hash based on your name and the date/time. Select the hash under FNV64/Normal.
- Rename the image file, replacing the part of the filename containing the old ID with the new ID you just generated.
Find and modify the corresponding object file to point to your image
- Back to S3PE. Open FullBuild0.package.
- Sort by name again. Scroll till you find a set of resources with a name similar to your image file; in our case, paintingAnimalGiraffe.
- Of those, you want the Object Definition file, which is the one with the value 0x319E4F1D in the Type column. Select that one, click File|Export, and export it to the same folder your image file is in.
- Start your hex editor, and open the object file.
- You are now going to replace every mention of the original texture file with the new texture file. The trick is, the numbers are in the hex file BACKWARDS... and each digit in a hex string is written with two characters... so you have to reverse the order of each pair of characters, keeping the order the same within the pair. Luckily, Snaitf's FNV generator has a function that will reverse the numbers for you.
- So, in our case, we want to replace C1ECA4110BC90E09 (old instance ID) with 8AAFF83C1BB5A6E6 (new instance ID). In WinHex, click Search|Replace Hex Values. In Search For, I put 090EC90B11A4ECC1 (the reverse of the old ID). In Replace With, I put E6A6B51B3CF8AF8A (the reverse of the new ID). Select Replace All Occurrences, and click OK. It should make several replacements. Click File|Save and close the hex editor.
- Now we need a second new instance ID for our modified object file. We pull out the hash generator again. This time I put in Sri_Giraffe_Painting_Object_070709_22:50, and I get out 3EF918961F858995. In Windows, I rename the .object file I just hex edited, replacing the old id part of the filename with the one I just generated.
Make a string table with your painting's name and description
We're going to use Postal to set up your string table.
- Download this file and save it in your Postal folder: http://chii.modthesims.info/getfile.php?file=950518
- Start Postal.
- Go to Plugins | Open Console.
- In the GroovyConsole, click File|Open, and select new_stbl.groovy.
- Find this line in the script: "stbl.strings.put(new Long(Checksum.fnv64("[STRING KEY]")), "[STRING VALUE]")"
- Copy that line and paste the copy right below the original, so you now have two identical lines. You're going to use them to make two entries in your string table, one for the painting name and one for the description.
- In the first copy of the line, replace [STRING KEY] with some text. (Leave the quotes, but replace the brackets.) To make it unique, use your name and the date/time, e.g. "Srikandi 7/14/2009 10:39pm". This will be used to generate an ID for the string table entry.
- Replace [STRING VALUE] with the catalog title of your painting.
- In the second copy of the line, replace [STRING KEY] with slightly different text; e.g. "Srikandi 7/14/2009 10:42pm", to get the ID for the second entry.
- Replace [STRING VALUE] with the catalog description of your painting. The result should look something like this:
- Go to Script|Run, and close the console (you don't need to save the script).
- You should now be able to see your new string table in Postal. Double-click the line in the top pane, and the two lines of your string table should show in the bottom pane.
- Make a note of the two IDs on the two lines. You'll need these values later.
- Click the Hex View tab, and then click the Export button. Save the string table in the same place where your other project files are.
Make your object file point to the new STBL, and set a price
- With your hex editor, open your renamed Object file. Scroll almost to the bottom, where the catalog entry is. In the text pane, you'll see something like "CatalogObjects/Name", with dots in between the letters.
- Put the cursor on the C in Catalog, and hit left arrow 18 times, to move the cursor back 18 bytes in the file. As you move the cursor in the text pane, you should see it moving in the hex pane as well, a pair of characters (one byte) for every text character you move it back. When you're on the right character in the text pane, click the first character of the highlighted hex byte to start typing. (The start of the highlighted area in the picture below shows the position; the characters in your file may differ).
- You are going to type the reverse of the ID of your object's title from the STBL you made (omitting the 0x you saw at the beginning of that line), and immediately after it, the reverse of the catalog description ID (again omitting the 0x). You can use Snaitf's FNV tool to reverse the IDs.
- So, since my title ID is 7c57de5cf2359443 and my description ID is 6163575ce2aad111, I am going to type (without the spaces) 43 94 35 f2 5c de 57 7c 11 d1 aa e2 5c 57 63 61 . You'll see the spaces separating each byte in the hex editor. Your typing will overwrite the data that's already there.
- When you're done, there should be two bytes you haven't changed before the C in "Catalog"; the data you've changed will show blue in the hex editor.
- While we're in this file, we can set a price for our new painting. I want mine to cost $600. The game expects the price to be a floating point number, and to input that value in the hex editor, I need to convert it to hexadecimal format, so I go to this web page: http://babbage.cs.qc.edu/IEEE-754/Decimal.html . I type 600 in the top text box, and then click the "not rounded" button. The result I want is "single precision hexadecimal", i.e. 44160000.
- The price goes right after the end of the "Catalog" section of the object file. In the case of my painting, the text in this section is "CatalogObjects/Name:PaintingAnimalGiraffe CatalogObjectsDiscription:PaintingAnimalGiraffe". I put the cursor on the "e" in the second "Giraffe" in the text pane, and move right one byte; then I click on the first character of the corresponding byte in the hex pane, and type in my value, reversed. So I'm typing in 00 00 16 44.
- Save your changes.
Put the new files together in a package, with multiple language versions of the STBL
- Almost there! First, we're going to rename the string table (.stbl) file with an ID which includes a language identifier. Use the hash generator to generate a new FNV64 hash, and then change the first two characters of the ID part of the filename (the part right before the file extension and after the third underscore) to 00 (the language identifier for English).
- Now, back to S3PE. Click File|New.
- Choose File|Import, and select the .dds file, the .object file and the .stbl file you worked on.
- Now you're going to import the .stbl file 16 more times, replacing the first two characters of the ID every time. Each new copy of the string table corresponds to a different language. The string tables are all going to be in English (or whatever language you wrote your text in), but at least the text will display properly in other language editions of the game. The two-digit language identifiers are 00, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0E, 0F, 10, 11, 12, 13, 15 (you can see what languages those correspond to here: Sims 3:Locales).
- So: Click File|Import, choose the .stbl file you already imported again, click OK, and then you'll see a dialog called "Resource Details". Here you can change the language identifier of your string table. In the "instance" field, replace the third and fourth characters of the ID (after the 0x) with O3. Click OK. Then repeat, importing the same file 15 more times, and putting a different language identifier from the list above at the beginning of the instance ID each time.
- Chose File|Save As, and name your mod whatever you want... for instance, Sri_Puppet_Painting.package.
- Close S3PE, copy the .package file to your mods folder, and test in-game. It should be in the Paintings catalog sorted correctly by the price you set. Make sure the title and description are correct as well.
- Congratulations! You just made a Sims 3 object mod :D