Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 8th Apr 2015 at 7:13 PM Last edited by Aren : 21st Apr 2015 at 6:25 AM.
Default Source code decompiler (with code reformatting)
This is yet another source code decompiler for The Sims 4. Essentially you just set up some variables in a batch file once, and every subsequent run will automatically decompile the source code to the folder you specified.

This script includes TheHologramMan's modified version of unpyc3.py to do the actual decompiling. In addition, I've included a script to automatically reformat the code to make it easier to read. It uses PythonTidy to do this, but unfortunately it hasn't been updated for Python 3. I haven't found any other alternatives that do as good a job as PythonTidy, so you'll need to install Python 2.7 to run it. It doesn't reformat everything; code specific to Python 3 causes it to break, so it just reformats the parts that need it most, like the Tunable descriptions. I may look in to writing my own script to reformat strings without needing Python 2.7, but no promises.

To demonstrate the code reformatting, here's a sample of the source code before and after the reformatting is applied.

Before:
Code:
class FamilyRelationshipTuning:
    __qualname__ = 'FamilyRelationshipTuning'
    MATRIX = TunableList(TunableList(TunableReference(services.get_instance_manager(Types.RELATIONSHIP_BIT))), description="\n                     This matrix is mirrored in RelationshipHelper.cpp in CAS Systems code.\n                     Please discuss with a GPE and CAS engineer if you wish to update\n                     this tuning.\n                     \n                               Sim Y's ancestry depth  ----> \n                        +-------------+-------------+-------------+\n                        |             |             |             |\n                        |   Spouse    |    Parent   | Grandparent |  Sim X's \n                        |             |             |             | ancestry\n                        +-------------+-------------+-------------+  depth\n                        |             |             |             |    |\n                        |   Child     |   Sibling   | Uncle/Aunt  |    |\n                        |             |             |             |    |\n                        +-------------+-------------+-------------+    V   \n                        |             |             |             |\n                        | Grandchild  |   Nephew    |   Cousin    |\n                        |             |             |             |\n                        +-------------+-------------+-------------+\n                     ")


After:
Code:
class FamilyRelationshipTuning:
    __qualname__ = 'FamilyRelationshipTuning'
    MATRIX = \
        TunableList(TunableList(TunableReference(services.get_instance_manager(Types.RELATIONSHIP_BIT))),
                    description="""
                         This matrix is mirrored in RelationshipHelper.cpp in CAS Systems code.
                         Please discuss with a GPE and CAS engineer if you wish to update
                         this tuning.

                                   Sim Y's ancestry depth  ---->
                            +-------------+-------------+-------------+
                            |             |             |             |
                            |   Spouse    |    Parent   | Grandparent |  Sim X's
                            |             |             |             | ancestry
                            +-------------+-------------+-------------+  depth
                            |             |             |             |    |
                            |   Child     |   Sibling   | Uncle/Aunt  |    |
                            |             |             |             |    |
                            +-------------+-------------+-------------+    V
                            |             |             |             |
                            | Grandchild  |   Nephew    |   Cousin    |
                            |             |             |             |
                            +-------------+-------------+-------------+
                         """)


How to use

You'll need to install both Python 3.3 and Python 2.7.

At the time of writing, the latest version of 2.7 can be found here: https://www.python.org/downloads/release/python-279/. The latest version of 3.3 can be found here: https://www.python.org/downloads/release/python-335/

Download the attached code and unzip it, then open decompile.bat in your favorite text editor.

Now you'll need to set a few variables.

Change the first line to set the path where you want the decompiled source code to be extracted. Make sure you put this path between the quotation marks.

Change the second line to set the path where your Sims 4 game is installed. On my computer, this is "C:\Program Files (x86)\Origin Games\The Sims 4", but it may be different for you.

If you installed Python on your C drive in the default location, you shouldn't need to modify the next two lines. But just to be safe, make sure the default paths are correct and make any needed changes.

You should now be able to double-click decompile.bat, and if all goes well the source code should be extracted. Let me know if you have any problems getting this to work.
Attached files:
File Type: zip  decompile.zip (118.8 KB, 359 downloads) - View custom content
1 users say thanks for this. (Who?)
Advertisement
Test Subject
Original Poster
#2 Old 11th Apr 2015 at 8:35 PM
I fixed an issue with the zip extraction code doubling up the folder names (e.g. exporting files to /interactions/interactions instead of just /interactions), so redownload if that was affecting you.
Test Subject
Original Poster
#3 Old 21st Apr 2015 at 6:28 AM
Updated unpyc3 with a fix so it can (hopefully) decompile any files it wasn't able to before, such as core/sims4/tuning/tunable.py. There are still parts of the code that it can't decompile, but now it'll just skip over those parts and decompile the rest, instead of completely failing. Thanks to Scumbumbo for bringing up the error with tunable.py.
Back to top