Skip to content
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

Achievements: add support for time constraints #39686

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions data/json/achievements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"id": "achievement_kill_zombie",
"type": "achievement",
"description": "One down, billions to go\u2026",
"requirements": [ { "event_statistic": "num_avatar_zombie_kills", "is": ">=", "target": 1 } ]
},
{
"id": "achievement_kill_in_first_minute",
"type": "achievement",
"description": "Rude awakening",
"time_constraint": { "since": "game_start", "is": "<=", "target": "1 minute" },
"requirements": [ { "event_statistic": "num_avatar_kills", "is": ">=", "target": 1 } ]
}
]
10 changes: 2 additions & 8 deletions data/json/scores.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"id": "num_avatar_kills",
"type": "event_statistic",
"stat_type": "count",
"event_transformation": "avatar_kills"
"event_transformation": "avatar_kills",
"description": "Number of monsters killed"
},
{
"id": "num_avatar_zombie_kills",
Expand All @@ -42,15 +43,8 @@
{
"id": "score_kills",
"type": "score",
"description": "Number of monsters killed: %s",
"statistic": "num_avatar_kills"
},
{
"id": "achievement_kill_zombie",
"type": "achievement",
"description": "One down, billions to go\u2026",
"requirements": [ { "event_statistic": "num_avatar_zombie_kills", "is": ">=", "target": 1 } ]
},
{
"id": "moves_not_mounted",
"type": "event_transformation",
Expand Down
26 changes: 25 additions & 1 deletion doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,8 @@ given field for that unique event:

Regardless of `stat_type`, each `event_statistic` can also have:
```C++
"description": "Number of things" // Intended for use in describing achievement requirements.
// Intended for use in describing scores and achievement requirements.
"description": "Number of things"
```

#### `score`
Expand All @@ -1193,6 +1194,9 @@ of scores. The `description` specifies a string which is expected to contain a
Note that even though most statistics yield an integer, you should still use
`%s`.

If the underlying statistic has a description, then the score description is
optional. It defaults to "<statistic description>: <value>".

```C++
"id": "score_headshots",
"type": "score",
Expand Down Expand Up @@ -1222,6 +1226,26 @@ an `event_statistic`. For example:
},
```

Currently the `"is"` field must be `">="` or `"<="` and the `"target"` must be
an integer, but these restrictions might loosen in the future.

Another optional field is

```C++
"time_constraint": { "since": "game_start", "is": "<=", "target": "1 minute" }
```

This allows putting a time limit (either a lower or upper bound) on when the
achievement can be claimed. The `"since"` field can be either `"game_start"`
or `"cataclysm"`. The `"target"` describes an amount of time since that
reference point.

Note that achievements can only be captured when a statistic listed in their
requirements changes. So, if you want an achievement such as "survived a
certain amount of time" which effectively only has a time constraint then you
must still place some requirement alongside it; pick some statistic which is
likely to change often, and a vacuous or weak constraint on it.

### Skills

```C++
Expand Down
Loading