SFGrenade/SFCore

Awarded achievements don't stay awarded after restarting the game

Closed this issue · 5 comments

Hello,

I am unable to find a decent way for achievements to stay awarded after restarting the game without any drawbacks.

I can save awarded achievements' key in the global config of my mod and award them back just after adding them into the game with SFCore.AchievementHelper.AddAchievement. But this display an award notification to the player as if they were just newly awarded on the left side of the screen when they start the game.

I tried queuing the awarded achievements with GameManager.instance.QueueAchievement and using GameManager.instance.AwardQueuedAchievements but there is still a notification.

Is there any other way to do this or even a way to hide the achievement notification in the main menu?

Currently on the current patch from Steam and SFCore 1.5.2.0.

Thank you

Hello,

in theory (big word, i know), it should just not display the award text if the game (more specifically the DesktopPlatform and OnlineSubsystem classes) detect that the achievement was acquired.
The DesktopPlatform checks if the online subsystem has been initialized, if so, that is asked if the achievement has been unlocked.
If not, the local encryptedshareddata is asked if the achievement has been unlocked.

And the way you're trying it is the right way to go. It should work, in theory.
You could try latest SFCore (1.5.2.2), even though that should change nothing.

I can test this myself maybe in the next few days.

I'm sorry, I did not look into the issue properly before posting here, the problem was not that I needed to award them back but that the game didn't consider them awarded at all in the first place (or at least the OnlineSubsystem did). To try it, I just did the following :

// public MyMod() : base("Achievements Mod")
AchievementHelper.AddAchievement("AUTO", Sprites["HollowKnightAchievements.Resources.auto_locked.png"], "AUTO_TITLE", "AUTO_DESCRIPTION", false);

// public override void Initialize()
GameManager.instance.AwardAchievement("AUTO");
Modding.Logger.Log("IsAwarded GameManager : " + GameManager.instance.IsAchievementAwarded("AUTO").ToString());
Modding.Logger.Log("IsAwarded AchievementHandler: " + GameManager.instance.achievementHandler.AchievementWasAwarded("AUTO").ToString());
Modding.Logger.Log("IsAwarded Platform : " + Platform.Current.IsAchievementUnlocked("AUTO")?.ToString());
Modding.Logger.Log("IsAwarded DesktopPlatform : " + DesktopPlatform.Current.IsAchievementUnlocked("AUTO")?.ToString());
Modding.Logger.Log("IsAwarded EncryptedSharedData : " + Platform.Current.EncryptedSharedData.GetBool("AUTO", false).ToString());

While this above code display an award text on the left with my sprite and text and add the AUTO achievement to the achievements menu, it also logs these lines :

[INFO]:IsAwarded GameManager : False
[INFO]:IsAwarded AchievementHandler: False
[INFO]:IsAwarded Platform : 
[INFO]:IsAwarded DesktopPlatform : 
[INFO]:IsAwarded EncryptedSharedData : True

Apparently the DesktopOnlineSubsystem instance in the DesktopPlatform instance return null in this method from DesktopPlatform:

    public override bool? IsAchievementUnlocked(string achievementId)
    {
        if (onlineSubsystem != null)
        {
            return onlineSubsystem.IsAchievementUnlocked(achievementId);
        }

        return EncryptedSharedData.GetBool(achievementId, def: false);
    }

While EncryptedSharedData does indeed have it set to true, the AUTO achievement stays as a secret achievement in the menu or stays grayed out when not hidden. It may be my way of using SFCore/the modding API that may be wrong. I also updated SFCore to 1.5.2.2. I still don't know how to fix that. Do you have any idea ?

Oh, true, yea, i know what's the issue is.
the issue is with

if (onlineSubsystem != null)
{
    return onlineSubsystem.IsAchievementUnlocked(achievementId);
}

because the online subsystem exists, but it doesn't know the custom achievement.

will be addressed in release 1.5.2.3

Updated version is now online

Thank you, It works flawlessly now