Can I make number of achievements unlock a variable?

More specifically, in my story, I have an unlockable perk that can only be earned if a player unlocks a certain number of achievements. This perk will change how the entire game is played.

My assumption is, in the same string as the achievement being unlocked, I can make another variable for each achievement earned, correct?

Example

*achieve ch1aptwindow

*set achievecount + “1”

*if achievecount >= “[whatever number I decide]” #Perk Name

So, is there a simpler way of doing this? Could I make the “points” that are set when making the achievement a variable itself that can be read?

This isn’t the correct usage of *set for either a string variable or a numeric variable. Nevertheless, what you suggested is the easiest way to do it.

*achieve ch1aptwindow
*set achievecount +1
*if achievecount >= 4
    *set perk true
    *goto perk
*else
    *goto noperk
3 Likes

You have to be mindful as achievements are re-triggerable on multiple playthroughs. Your [achievecount] can bloat to numbers you didn’t expect.

Howeuer, if balance is not something you’re bothered about, there’s no change needed.

3 Likes

That’s true. You can *check_achievements to prevent this.

*check_achievements
*if choice_achieved_ch1aptwindow
    *goto continue
*else
    *set achievecount +1
*achieve ch1aptwindow
2 Likes

It’s not? It’s always worked for me, even when I was doing a pretty complex scene with a countdown timer. I’ll have to look more into this.

I assumed I would have to use *check_achievements, but another issue I’ve come to realize is:

Won’t the variables reset every playthrough? Therefore, the variable tracking the number of achievements will be useless if it resets every run. The “unlockable” perk won’t exactly be unlockable if it doesn’t stay unlocked. My suggestion would be having code towards the beginning that sets the variable based on achievements already gained and retained, running a pass through each one, though I’m not sure if that is at all possible.

You can’t do arithmetic on string variables. If you can, then Choicescript has a few errors from my early games to answer for. :stuck_out_tongue:

If you want it to be unlockable permanently from the beginning, just use that check achievement stuff at the beginning and set the value then, and then only use *achieve during the game if the player hasn’t achieved that achievement prior.

1 Like

Thanks, that’s exactly what I was looking for!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.