Giter Club home page Giter Club logo

opents2's Introduction

OpenTS2

OpenTS2 is an Open-Source Reimplementation of The Sims 2, using the Unity game engine. Also aims to provide a number of modular libraries for working with TS2 formats in a C# environment.

Progress

Currently a basic main menu with a neighborhood chooser is implemented. Neighborhood info can be previewed and a basic neighborhood view can be accessed. image

Acknowledgements

Similar Projects

  • FreeSO - Open Source reimplementation of The Sims Online using C# and Monogame. OpenTS2 borrows a lot of code and structure from this project.
  • Las Marionetas - Similar project, aiming to reimplement The Sims 2 by reverse engineering its binary code into C/C++ source code.
  • SimUnity2 - Earlier attempt at a TS2 reimplementation in the Unity engine. Abandoned, succeeded by this project.
  • OpenTPW - Open Source reimplementation of Sim Theme Park / Theme Park World.
  • OpenRCT2 - Open Source reimplementation of Rollercoaster Tycoon 2.

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Development

Prerequisites

  • Unity 2020.3.32f1 - Can be found under "Unity 2020.x", you could also download the Unity Hub and install from there. Unity version is subject to change, please keep an eye on this!
  • Visual Studio 2019
  • A copy of The Sims 2 Ultimate Collection

Setup

  1. You need to have a "config.json" file in the root folder that provides paths to your Sims 2 UC installation and user directories. Copy the "config.example.json" file and rename it to "config.json" to start off, and type in your own paths.
  2. In Unity, make sure Edit > Preferences > External Tools > External Script Editor is set to Visual Studio. By default it opens files separately as opposed to in a solution.

Project Structure

We follow the layout of a normal Unity project except:

  • Assets/Scripts/OpenTS2 - Contains the bulk of the C# code that deals with TS2 formats and files.
  • Assets/Scripts/OpenTS2/Engine - Unity specific code tends to live in here to keep it separate from the more language-independent code in the directory.
  • Assets/Tests/OpenTS2/ - Unit tests following the same directory structure as the Scripts folder.

Testing

We currently use the Unity Test Runner for unit testing code. These tests can be run inside of unity through the test runner tab or if you use Rider as your C# editor, inside of it.

opents2's People

Contributors

ammaraskar avatar berylliumquestion avatar lazyduchess avatar riperiperi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opents2's Issues

Setup unity skeletons for inverse kinematics

We have basic animations from the game now!

ReclinerFixed.webm

These currently only work on bones and morphs (also I'm using the bone names instead of the bone CRC32) but this will not work for things like the Sims animations, those use a chain of inverse kinematics and basically only encode hand movements and such. This also applies to some more complicated objects like the cowplant with it's 17 neck bones.

image-1

Pick correct road textures

Currently we just use new_roads_ as the road texture prefix. This actually varies between neighborhood, not sure where it's stored.

Is this going to move the screen recorder from Video For Windows codecs?

VFW is still being used, and honestly would this ruin my video recorder settings? I spent some time getting TS2 to output videos via x264vfw and hearing that this reimplements TS2 makes me wonder if this would modernize TS2 as a whole. Will this reimplementation remove the screen recorder or at least change it so it does not use something that was a reaction to Apple's QuickTime?

Use Tasklists?

So a neat little feature with github I found is that you can put a little tasklist with all of your issues

--

For example

Todo

  • Make minimum playable program
  • Finish data parsing methods
  • Make mod api
  • #2
  • #7

etc. etc.
Just do it like this - [ ] Some sort of task or - [ ] #2
You can see more with this video! :D https://www.youtube.com/watch?v=BplF7vHXewA

Figure out JFIF/JPEG ALFA blocks.

The game generates thumbnails as JPEG images, and embeds a custom ALFA block in them to achieve transparency:

alfablock

The image above is a Sim thumbnail opened with a HEX editor. They don't look terribly complicated to figure out, they're Run Length Encoded.

Improve support for the STR format

There are a few rare STR formats that could be found in the game's files, but I haven't seen anyone mention them anywhere. I pulled all of these from the objects.package:

1- STR Format: Zero

Spec:
Name: 64 bytes
Null/Format Code?: 2 bytes

Resources

endtable1 skill table
Type: 0x53545223, Group: 0x7FAB08F6, Instance: 0x00000081, Resource: 0x00000000

Nightstand Expensive skill table
Type: 0x53545223, Group: 0x7F280D6D, Instance: 0x00000081, Resource: 0x00000000

bedstandex attribute labels
Type: 0x53545223, Group: 0x7F280D6D, Instance: 0x00000100, Resource: 0x00000000

2- STR Format: No Format

Spec:
Name: 64 bytes
Null/Format Code?: 1 byte integer
Count: 1 byte integer

Loop Count times:
Length: 1 byte integer
Value: String with length Length

Resources

Behavior editor string set
Type: 0x53545223, Group: 0x7F6D880B, Instance: 0x0000012C, Resource: 0x00000000

Behavior editor string set
Type: 0x53545223, Group: 0x7FBD8997, Instance: 0x0000012C, Resource: 0x00000000

3- STR Format: 0xFFF6
This is a weird format with some weird dividers between the strings, even SimPE won't read it, and I couldn't figure it out the last time I tried. Here is the resources with this format if anyone wants to try to figure them out:

Resources

Suit primitive strings
Type: 0x53545223, Group: 0x7F3D258A, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7FE94D58, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F27193D, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F24F935, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F83D9EC, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F2CAB90, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7FBEBDFE, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7FFAA5E5, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F234024, Instance: 0x00000130, Resource: 0x00000000

4- STR Format: 0xFFFD
Already known.

5- STR Format: 0xFFFE

Spec:
Name: 64 bits
Format Code: 2 bytes integer
Count: 2 bytes integer

Loop Count Times:
Value: Null-terminated String
Null: 1 byte (Description string?)

Resources

Relationships
Type: 0x53545223, Group: 0x7F6D880B, Instance: 0x00000102, Resource: 0x00000000

relationship labels
Type: 0x53545223, Group: 0x7F17187C, Instance: 0x00000102, Resource: 0x00000000

PedPortal relationship labels
Type: 0x53545223, Group: 0x7F19EC55, Instance: 0x00000102, Resource: 0x00000000

Mail Box relationship labels
Type: 0x53545223, Group: 0x7FE4B434, Instance: 0x00000102, Resource: 0x00000000

Relationships
Type: 0x53545223, Group: 0x7FBD8997, Instance: 0x00000102, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F979D47, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7FE9B3DE, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F8ECBFD, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F79C748, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F1FF01F, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F9E24A1, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7FFCB26D, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F1E9307, Instance: 0x00000130, Resource: 0x00000000

Suit primitive strings
Type: 0x53545223, Group: 0x7F694047, Instance: 0x00000130, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7F979D47, Instance: 0x00001000, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7FE9B3DE, Instance: 0x00001000, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7F8ECBFD, Instance: 0x00001000, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7F79C748, Instance: 0x00001000, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7F1FF01F, Instance: 0x00001000, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7F9E24A1, Instance: 0x00001000, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7FFCB26D, Instance: 0x00001000, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7F1E9307, Instance: 0x00001000, Resource: 0x00000000

named trees
Type: 0x53545223, Group: 0x7F694047, Instance: 0x00001000, Resource: 0x00000000

skin colors
Type: 0x53545223, Group: 0x7F01EC29, Instance: 0x00002000, Resource: 0x00000000

6- STR Format: 0xFFFF
This is the same as format 0xFFFD, but STR entries that have this format are always empty/have no strings.

Spec:
Name: 64 bytes
Format Code: 2 bytes integer
Count: 2 bytes integer

Create shaders for different terrain types

Right now only Temperate and Concrete terrain types render accurately, The terrain paint for Desert and Dirt don't have the same behavior as them, which makes them look strange.

Might have to rework the terrain shader a little into a cginc to avoid redundant code.

Figure out .reia video files.

Reia files can be found in each Neighborhood that comes with the game, they have a small compressed video showcasing the neighborhood. They're inside of a RIFF container.

Here's what I've figured out so far:

RIFF Header

CHAR[4] "RIFF"
DWORD file size //size of reia chunk
[REIA]

REIA Header

CHAR[8] "Reiahead"
DWORD unknown //always 24?
DWORD unknown //always 1?
DWORD size of video metadata below
[Video metadata]

Video metadata

DWORD X resolution
DWORD Y resolution
DWORD framerateFraction
DWORD framerate //FPS turns out as framerateFraction / framerate
DWORD length //Final length is this value minus 1, in frames.
[Frame chunks]

Frame Chunks

CHAR[4] "frme"
DWORD size of chunk below
BYTE[size] unknown

Still need to figure out the frame chunks themselves. All I know is that they're Run Length Encoded.

Best Way to Contact?

I was wondering the best way for aspiring contributors to communicate with you? I know issues are one way, but I was wanting to maybe talk in a more conversational style to see what your current goals are, because, and it's a bit embarrassing for me to say, I'm just a bit lost as to how I might able to contribute to this project.

Everything is just white

Screenshot_2
Screenshot_1

I just downloaded the zip and opened it in the unity version provided, but everything is white and nothing works lol. Is there something I was supposed to do?

Fix DBPF Compression

Compression/Decompression code is in Assets/Scripts/OpenTS2/Files/Formats/DBPF/DBPFCompression.cs

Decompression works perfect, but compression works for some things but not for others. STR# resources for example seem to compress ok most of the time, but neighborhood terrain geo throws an exception, so I think compression code should be rewritten to be able to handle all files.

As a workaround currently the CanBeCompressed property in AbstractAsset returns false, skipping compression. This is not a huge deal however as saving works just fine otherwise minus the compression.

Figure out SPX (Speech) Audio format

I have no experience figuring out audio formats, so this is something I will need help with.
In the TSData/Res/Sound folder there are Voice1, Voice2, etc. packages. Inside of them there are audio files that begin with a SPX1 magic number - these are the audio files left to figure out.

Documentation

I'm making this out of the motivation that some of the already existing documentation does not show up in visual studio for me.

Todo List

  • Make current documentation show up for myself
  • Modify current documentation that might not make sense to me
  • Add more documentation

Optimize Reia playback

Right now, the Reia player is really bad at playing bigger videos, like the 512x512 loading screens. Probably the constant Texture2D allocs are to blame.
Performance is very poor when streamed, and they take a ton of memory if not streamed on top of taking forever to load.

While converting these to a more common format like MP4 on first time launch could work, or pooling textures/reducing their creation, I think implementing Reia playback as a compute shader could be a better solution.

About the project and TS3

Hi,
My story is that, after playing a bit with and finally realizing the architecture of Sims 3, this is, most of the actual logic is in .NET libraries and the core native .exe is 'just' an engine which seems to contain little gameplay specific code, I thought it could be relatively easy to recreate the engine part, while using most of the original .NET code and other assets, thus resolving all the long standing issues it has, most notably performance once. (Btw one of them looks like a JIT of the Mono framework they embed to run .NET going crazy for a first half an hour, as I'd expect Mono to be very unoptimized back then. I though about updating it in-place, but doing so with optimized statically linked lib is tough.)

Now, I also found this project of yours and I'm interested to see if what you're trying to achieve here isn't close to the above? I don't have TS2 but I would assume it has similar design as well as many solutions, like file formats etc. And if so, maybe that single engine could serve for TS3 as well? There might be some legal issues though, as unlike TS2, TS3 is still being officially sold. On the other hand, AFAIK at least in US, such an engine replacement can be viewed as just an big mod.

Anyway, I'd be looking forward into such a project and be happy to contribute in case I find some time. I'm not sure about using Unity though due to their latest political moves. Godot may also be an option because AFAIK it too runs .net natively.

Cheers.

Render swarm effects

From #7 we have the data structures for swarm parsed. Now it's time to actually start rendering them with the unity particle system etc.

Load and render lot geometry

Currently we have the ability to read LOT_OBJECT (0xFA1C39F7) files and render out their scenegraphs:

image

But we aren't loading or rendering any of the lot's geometry so we're missing the grass and roads etc. Not sure if the exact formats and file types for these are known but loading these next would be great.

Render Game Fonts

MXF fonts are included in the "TSData\Res\UI\Fonts" folder of the basegame and any DLC that adds new fonts.

Decoding them is pretty easy, as detailed in issue #55, these will produce a PostScript Type 1 Font file (PFB) for TS2 fonts (There might be TTF fonts too? not sure). The problem now is actually importing these fonts for use in the game.

I believe Unity allows you to create custom Font assets using bitmaps, so we'll probably have to find a way to load and render these into a Font asset. We also need to parse the FontStyles.ini file from the latest DLC also found in the Fonts folder to load the proper sizes and styles used for UI elements, this is the easy part.

Garbled text in xml in some dbpf files

I think there are xml files in package files because of the presence of xml tags, however trying to understand it is a bit of challenge because of all this garbage in it. I thought maybe it might be compressed, but then if it were I shouldn't be able to tell it's xml at all. It reminds me of lua files extracted from hpks dlc in Tropico 4, but I don't think you can compile xml?

Here's an example of what I'm talking about:
!����û���ê<?xml version="1.0"?>

<cGZPropertySetString�&�#7"ä
<!--editor paramet� ��--çAnyUint32 key="id" type="0xeb61e�E4fâ0x718c6e9a</�0�?�v�?àfold�Cerã0b8bea18">

EP4Rel�™atàship Is :‘�IánodeText��Kæ10 Simultaneous Pet Best FriŽÀ[end �éprimaryIcon: used in UI when there is a �4s��l�'à sho“�)wn‡�O’�2áfeedcf20��2�Œ�6se›@Žd��a�Štwoás, e.g.,�£ if ð�žs�¯�)�‰ �'“�¬‰�o’�®��0��®A4GBB E ¼á Flag toFG d#+min ‡fàWant$2áuld be l�Öoad �by(¯Aƒa“�¡�bgM¸V��@¤s‘�K64(ç@þ!�:á15 bit G�vUIDàat p�-o '%ÚoL^A-sáresource”A0.�T��‡ŽÁ&515

‹�¾ácheckTre�B¿e’ƒ; /@0•€5baá>

CT - HaBžnd�+Fœ�EásimArrayª�‰àleve�@‚làPowe‘@srˆ�;ˆÀlcoràc264c¶712U_2 .‘�=áinfluenc‘�AŽ�=@�àNodeƒE� ˆ„Ùieˆ�Óàobje�RctT��ØàNoneœ�K�uàeger­�B‰�Ü�BáMultipli‰�)

<&‘�"Ž�ˆ�ðOdQ¥�Œ +c¤Eve‘�,àBool�bean@�àntRec)qui»�câcba908e1"> Fa�dls�:’�Jádeprecat‡FZeš�D�†× </ý>+�

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.