renaudbedard / fez-1.12-issues

A public repository for FEZ 1.12 testers to log issues
9 stars 0 forks source link

Add in-game timer for speedruns #99

Closed Gyoo closed 8 years ago

Gyoo commented 8 years ago

Already talked about that several times on Discord, the speedrunning community would like to have an official in-game timer that counts the gameplay time without loading times, similar to what already exists in FEZmod

Basic info :

What happens in between is up to you. Either you just show the plain timer or you can add a few "splits" with milestones, for instance the number of cubes (every 8 cubes maybe ?)

To me, if a timer is implemented, there should be an option to enable/disable it, as well as the other speedrun-related features in case the speedrun "mode" is enabled.

flibitijibibo commented 8 years ago

We might be able to do something like Axiom Verge where we measure in frames, since the game always does logic updates at 60-ish Hz... 99% of the work is just getting it to time during level frames, which I wouldn't be much help with since I just do the FNA side of things.

Whether this goes into FEZ or FEZMod, some notes to consider from a design standpoint:

Note that everything I've written is entirely speculative and doesn't factor in what it'd take to store this in the game, but someone who wants to write this might be able to make use of the UX prototype... if I missed any critical detail, just steal from Axiom Verge since Tom did that really well.

Gyoo commented 8 years ago

That's pretty much the idea we had in mind, and it was actually inspired by Axiom Verge.

I don't exactly know how it is managed in FEZmod (not sure it's done with frames), but the goal here is to have something directly implemented in the legacy game for more "officialness" and ease to use.

You have to know that loading times differ greatly from a computer to another, and even on my own and only computer, loading times are about 30/40 seconds longer (for a 28 minutes long run) when I stream my gameplay with OBS. Removing these loading times "in an official way" would be the best way to increase fairness between runners.

flibitijibibo commented 8 years ago

I've just implemented a prototype speedrun mode for the next update.

How it works is that you pass --gotta-gomez-fast as a launch parameter, and on startup there will be a "SPEEDRUN" option below the 3 saveslots. Select that and it will dump you right into a new game (which we store in saveslot "4" just in case). We add splits for every cube collected, and the time stops on the exact line of code where the ending cutscenes start.

The only thing that might be different from the normal mode is that I actually force singlethreaded mode when enabling speedrun mode. This can save a lot of time, even if the game stutters for slower machines. (Save the frames, kill the loading screens.)

Right now I'm just dumping text onto the screen, but I'm sure there's a way to pretty it up.

flibitijibibo commented 8 years ago

Final TODO before marking this done:

The only real design change since the last post is that I now just give the user a single 'speedrun' option on startup instead of shoving it into the saveslot selection. I may backpedal on this depending on feedback, or if we sneak in a special speedrun image to render instead of a map preview in that space on the screen.

flibitijibibo commented 8 years ago

Just pushed a new build for Linux/Mac that should have this fully functioning now. Still need to make it pretty (and add locale strings), but it should work exactly as it will when this finally goes out.

Gyoo commented 8 years ago

I'll make sure to check it out when I have some time on my hands :)

Gyoo commented 8 years ago

Just tested real quickly to get a first look at your work. It looks very nice so far (except for the [MISSING TEXT] in the menus :> ) You can see the timer well most of the time, except during the reboot cutscenes because of the white background. I only went to 4 cubes, but I assume all the cube splits are shown ? If so, it might get a bit cluttered near the end.

I'll do a full run soon to make sure everything is fine and all.

flibitijibibo commented 8 years ago

The next update will have a monospaced font that works reasonably well. But instead of a real font, it's just this image here:

speedrun

For now you just throw this PNG into the game folder as "SpeedRun.png" and it'll load up (and will crash if you don't). We'll get the font into the pakfiles eventually.

Once we're all happy with how it looks we can mark this as done.

flibitijibibo commented 8 years ago

The next update should have the final menu/graphics for speedrun mode. Even when all 32 cubes are on screen it actually looks pretty good! Basically as long as it doesn't crash somehow this should be all set, but we can keep using this thread if anything particularly bad shows up.

flibitijibibo commented 8 years ago

The latest update adds dropshadows to the run text, which makes it appear in places like the fakereboot title screen. It even makes the cube characters look cool! I gotta remember this for future games.

Gyoo commented 8 years ago

Finally had time to make a full run and I've got some feedback for you ! Next to each point will be a timestamp, that refers to the following video : https://www.youtube.com/watch?v=P21YHJSTzE4

Other than that, I am really pleased with the way this is taking. Keep up the good work !

flibitijibibo commented 8 years ago

I'll have to do '\r'\n' for Windows, we have newlines but Notepad doesn't read them even in 2016...

I did a Ceiling at one point due to integer scaling of the text, I'll just replace that with a Floor.

I'll have to see if I can even track that dupe properly, I'm not sure how the addition happens exactly...

I think the only thing I can't do is ignore NG+ states only because of how those modes are implemented... the speedrun mode is just a timer, it doesn't actually change gameplay. It might be skippable but it'll take more time than the others.

Gyoo commented 8 years ago

Alright. I understand if you can't remove NG+ from speedrun mode. We'll just have to be more careful :^)

flibitijibibo commented 8 years ago

Everything except the NG+ change will be in the next update. The downside to the cube cutscene skip fix is that the split is now explicitly when cubes are added to the count, so it will happen at the end of the cutscene and not the beginning. It's more accurate but will probably feel weird at first.

Gyoo commented 8 years ago

I started a run fairly quickly to see how things go but I encountered something dramatically important that I should be ashamed not to have found beforehand so I didn't even continue the run to talk about it right now.

First, the good things :

Now, THE thing that needs to be fixed.

Some loading times are not removed. I can see that sometimes the timer stops during small loading times, but for the bigger ones (especially the loading screens where you can see Dot in full screen), the timer keeps going when it shouldn't.

Basically, the 3 crucial loading zones are :

Oh, and one last cosmetic thing : Could you put the "SPEEDRUN" menu at the bottom of the save selection ? Makes more sense since it's more a bonus than anything else

0x0ade commented 8 years ago

Not a dev, but my 2 cents:

FEZMod did the loading check completely wrong.

ahem

The cases you listed additionally to the black screen are actually more transitions than loading screens (loading is hidden) - only the extra time spent loading should be ignored. It's just that the transition itself already triggers the loading flag.

In my tests, the faraway transition cut to the black loading screen when loading took longer than the transition. The Dot transition should just take longer, but it functions as palate cleanser anyway.

Gyoo commented 8 years ago

Well, from what you're telling here, maybe I need to make sure what a loading really is.

I know for fact that, on the 3 elements I've listed, the time can differ from a computer to another. Now, does the whole animations count as loading or just part of them (which would mean, there is a minimal "loading" time that is the same for everyone), this is where I lack data.

flibitijibibo commented 8 years ago

The speedrun mode always runs in singlethreaded mode, so times should now be identical across machines above a certain spec. The boxes that hitch at loading points may be a few ms slower, but I've not found a setup that does this yet.

The only screen I'm not 100% sure on is the dot screen. The async loading screens, like the bottom right cube screen, won't happen because the game loads too fast in singlethreaded mode.

Gyoo commented 8 years ago

On my last run, I notcied that there was no difference between my Real Time timer (using Livesplit) and the In Game Timer. What we noticed with @renaudbedard is that, most likely, the timer freezes during loads, but actually doesn't cut off loading times. Maybe he'll be able to explain it better than me as we witnessed this together on my stream.

flibitijibibo commented 8 years ago

I'm surprised there are any loading times... I can see if there's a way to pause the timer when the engine claims to be loading, but I can't guarantee that the spot that hangs will be exactly when the timer stops; could be a couple microseconds off.

Gyoo commented 8 years ago

If it's only microseconds, we can bear with it :)

flibitijibibo commented 8 years ago

I've pushed a change that adds pauses/resumes for level changes specifically at the points where level loads start and when loading is officially declared finished in the engine. This does indeed shave off a fraction of a second per room, and for the Dot loading screen, you get the added bonus of having the sub-millisecond time to look at while you wait for it to load :P

I think what I wrote covers all scenarios, but Renaud may have better places to put my new timer calls. We'll see in the next build.

Gyoo commented 8 years ago

I'll make sure to test it asap :)

Gyoo commented 8 years ago

Alright, just did another run to test the changes you did to the in-game timer.

Now, what the game considers a loading is being cut off correctly from the time, but I've noticed 2 things at the end of the run, one is less important than the other :

Please don't kill me :(

flibitijibibo commented 8 years ago

Both are a consequence of the loading time fixes - the game starts the cutscene while it's in the load process, so at the end of load it resumes the time even after we're done!

The gravity room cutscene, I've no idea - this may be where I have to defer to Renaud, as I'm not entirely sure what the rules are for when the game is actually loading and when the game is just changing levels. We have an IsLoading check internally, but it's not what you might expect it to mean.

For now I'm just going to revert my latest speedrun change since I'd rather incorporate load times and add a few ms to times rather than be whole minutes off and not have an ending >_>

renaudbedard commented 8 years ago

Reopening so I can take a look later.

renaudbedard commented 8 years ago

Fixed! I did a spot check for "dot loadings", normal level transitions, the beginning cutscenes and the 32-bit end cutscene, everything seemed good. Load times no longer are included in the time counter and it seems to behave like expected everywhere.

Gyoo commented 8 years ago

One last check : what about the 64 cubes ending ? :)

flibitijibibo commented 8 years ago

Looks like the 64-cube ending should work as well, as the new timer pauses are based only on load times (and this time it actually checks to see if time was already called before resuming!).