Skip to content

Commit

Permalink
Merge pull request #39686 from jbytheway/achievement_time_constraints
Browse files Browse the repository at this point in the history
Achievements: add support for time constraints
  • Loading branch information
ZhilkinSerg authored Apr 21, 2020
2 parents 449b326 + 9dfdf4f commit 5e936ea
Show file tree
Hide file tree
Showing 15 changed files with 456 additions and 67 deletions.
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 @@ -1187,7 +1187,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 @@ -1199,6 +1200,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 @@ -1228,6 +1232,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

0 comments on commit 5e936ea

Please sign in to comment.