ZeroFox5866 / nucleuscoop

An unofficial mod for Nucleus Co-Op, which is an application that starts multiple instances of a game for split-screen multiplayer gaming!
https://nucleus-coop.github.io/
471 stars 45 forks source link

Allow Goldberg to write out achievements.json #31

Open DrMerlin opened 3 years ago

DrMerlin commented 3 years ago

I haven't figured this out fully yet- but it seems that achievements don't work because the goldberg emulator handles all the steam api calls. Goldberg can write all the achievement calls to a file- which would be nice because then it would allow us to use the file to claim our earned achievements later, correct?

I'm a little lost in the way that nucleus calls goldberg- and where that change would need to be made. But I assume it's possible.

DrMerlin commented 3 years ago

A few more details- When a game is launched with Nucleus coop- it seems that the achievements.json has to be created outside of goldberg- with something like achievements watcher. Goldberg instructions say this file should be placed in settings- but the way nucleus works is that settings is created on the fly each time.

Currently, goldberg/nucleus puts the following files in settings: account_name.txt, language.txt, listen_port.txt and user_steam_id.txt. These files seem to be destroyed when nucleus stops running the game.

A lot of files near the settings folder are linked in. The achievements.json file would need to be linked in as well, because you want it to persist after the game is over. For multiple players, it would probably make sense to keep it near the saved games so that player 1 and player 2 can keep their achievements separated.

I think that's all that would be needed to make nucleus coop work with achievemets.json

DrMerlin commented 3 years ago

Would it be possible to dry run this in the game script? How much raw js can I cram in there? Some file linking, for example?

DrMerlin commented 3 years ago

Looking just a little more- it looks like adjusting the script.js to link the achievements file would only be possible if something like Context.MoveFolder were added: https://github.com/ZeroFox5866/nucleuscoop/blob/master/Master/NucleusGaming/Coop/Generic/GenericContext.cs#L1498

Allowing the script to link any file to any destination- CmdUtil.MkLinkFile(origFile, destination)

Of course, that's assuming that it can be put in the script.js so that it runs after the code in the handler that creates the settings/ directory.

This solution would make it scriptable- therefore would only be supported game-by-game/script-by-script. Perhaps a better solution is while the other files are being written in settings/(i.e. account_name.txt), that it checks the savegame folder (for each instance) and links in achievements.json if found from somewhere near there.

Somewhere near here in Play(): https://github.com/ZeroFox5866/nucleuscoop/blob/master/Master/NucleusGaming/Coop/Generic/GenericGameHandler.cs#L3409

This might depend on the knowledge that Play() has of the saved games- or at least the steamid of the instance... which might not be practical... if the user's achievements.json is indeed kept with the saved games.