clementgallet / libTAS

GNU/Linux software to (hopefully) give TAS tools to games
GNU General Public License v3.0
494 stars 56 forks source link

Feature Request - Allow changing the system time during a TAS #474

Open thearst3rd opened 2 years ago

thearst3rd commented 2 years ago

For some speedruns, it can be a requirement that the runner changes their system time mid-run in order to manipulate cycles or get things to spawn. For example, in the clock tower room in FEZ, four anticubes spawn based on time and speedrunners will change their system time to a few different times so they can collect all the cubes.

Currently, libTAS supports setting the system time before the run starts, but once the run has started the system time cannot be changed anymore. It would be great for it to work similar to the "variable framerate" option, where on any given frame, you can change the system time to a new value and that will be stored in the TAS. So when the TAS is played back, it will change the time on those same frames. That would be very useful for making TASes of the kind of runs I described above.

marcelopio commented 2 years ago

I like the idea, but for example, for Unity, I need to set the actual random seed, since the system time won't affect UnityEngine.Random

UnityEngine.Random sets it's initial random value from /dev/urandom, but after that, each call adds entropy to it, so actual random value is not dependent on system time, but on the number of calls do random.

A similar solution on Unity would help a lot with that use case. Currently I am modding the game to set a seed on a method call. If libTAS could set a seed on a frame this would be awesome

clementgallet commented 2 years ago

That is a different issue, but initial system time is actually used to set the values inside the fake /dev/urandom, so modifying the initial time does indeed seed UnityEngine.Random. see:

https://github.com/clementgallet/libTAS/blob/7daa51890b3fef203dec0e1367f9169df9f634aa/src/library/fileio/URandom.cpp#L40-L43

I need to write a proper PRNG instead of filling with characters.