-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial bare-bones implementation of achievements #39351
Conversation
Light green text instead of usual green to make it more visible? |
this would go well in the codex (#36479). maybe a specific tab for achievements. |
It is light green when it first appears, but shades to darker when the window loses focus (the same as the other messages around it).
My longer term plan is that once we have global state for achievements you'll get a popup the first time you get any achievement, but not on every game you get it. I don't want to spam players too much, so I'll leave it out until then. |
It's only a matter of time before someone makes a "Stats through achievements" mod now. |
Looks like there are some clang-tidy errors I need to fix. |
Allow watchers to unsubscribe from the stats_tracker, and ensure that happens automatically on destruction, so that the stats_tracker doesn't send messages to dangling pointers. Also, ensure that the various watcher classes are non-movable because stats_tracker requires reference stability. Also, clear more things in stats_tracker. When the game is cleared, the set of initial scores is also cleared, all watchers are forcibly unsubscribed, and the state tracking objects are also cleared. This prevents strangeness with scores when running multiple games in a single session of CDDA.
A minimal achievements implementation. This is built on top of the stats_tracker and achievement requirements are defined in terms of event_statistic values managed there. As a proof of concept, added a single json-defined achievement when the player kills their first zombie. Currently the only UI manifestation of achievements is a message in the log. In the long term I plan to add a new tab to the scores window. Also, achievements are currently local to each save. In the future we also want to have a permanent record of what achievements have been obtained in each player's historical games.
Fixed the clang-tidy issues. Some here, and unrelated ones on #39367. |
There is a very cool system based on finding oddities and curios that is implemented in Underrail |
Summary
SUMMARY: Features "Add support for json-defined achievements to provide more goals to strive for"
Purpose of change
Adding achievements to help inspire more varied gameplay and provide goals for those players who wish for them.
Describe the solution
Building on the
event_bus
andstats_tracker
work, this adds a new layerachievements_tracker
that waits for achievements to be completed.Achievements are defined in terms of
event_statistic
s managed by thestats_tracker
, which are in turn derived from events taken from theevent_bus
.As a proof-of-concept I've implemented a very simple first achievement: kill a zombie.
This is a bare-bones absolute minimal implementation for that achievement. It can be expanded in many directions, and I hope to do that.
In particular, the only visible impact of achievements right now is a message in the sidebar log when you get one, which I imagine most players won't even notice. My next step is to add a new tab to the scores screen to show achievements for a particular game.
At the same time, I discovered and fixed some issues with object lifetimes in
stats_tracker
which could cause problems when you played multiple games in a single session of CDDA.Describe alternatives you've considered
There are many ways this could be done. I'm a little concerned that this approach leads to hard-to-follow code flow, but it does have the advantage that it's easy to write tests for, which is nice.
Testing
Added a small unit test, and verified that the achievement works in-game.
Additional context