Ok, well, putting the z-machine abuse on the back burner for the time being, I’ve spent some time building on my earlier achievements code snippet.
I haven’t yet added persistence, but I’ve implemented several flavors of achievements:
- Achievement: normal achievements
- CountingAchievement: achievements that require an action to be repeated some number of times
- MultiAchievement: achievements that require a set of distinct tasks to all be performed
- MetaAchievement: achievements that require a set of other achievements to be completed (meta achievements can depend on other meta achievements)
- hidden achievements: don’t show up in the list of available or in-progress achievements (any of the previous types can also be hidden)
The code’s longish, so I’ve zipped it up and attached it. Here’s a brief excerpt showing the creation of several kinds of achievements in the demo program:
Include ">achievements.h";
Achievement SomethingFishy "Something Fishy"
with description "slap the troll fisherman with a fish";
Achievement SelfConscious "Self Conscious"
with description "check your achievements";
CountingAchievement SwatMaster "Swat Master"
with description "swat 10 flies",
target_count 10;
! Tasks for ScratchNSniff achievement:
! 0: scratch fisherman troll
! 1: sniff fisherman troll
! 2: scratch gnome
! 3: sniff gnome
! 4: scratch witness troll
! 5: sniff witness troll
MultiAchievement ScratchNSniff "Scratch 'N' Sniff"
with description "scratch and sniff all other characters",
num_tasks 6;
Achievement BuyAVowel "Buy a Vowel"
with description "say the magic word",
has concealed; ! hidden achievement
Achievement WhatYourMomSays "What Your Mom Says"
with description "greet the fleet",
has concealed;
MetaAchievement SupahSecret "Supah Secret"
with description "earn all hidden achievements",
depends_on BuyAVowel WhatYourMomSays;
MetaAchievement DoItAll "Do It All"
with description "earn all achievements",
depends_on SomethingFishy SelfConscious SwatMaster ScratchNSniff
SupahSecret;
My next step will be implementing persistence. In the meantime, I’m interested in any feedback. Thanks.
Edit: Removed outdated snapshot. Look for a fresher one later in the thread.