RetroAchievements / RAIntegration

The DLL responsible to integrate emulators with RetroAchievements.org
https://retroachievements.org
MIT License
98 stars 23 forks source link

HitCount for leaderboard value #13

Closed meleu closed 5 years ago

meleu commented 6 years ago

From @Jamiras on April 1, 2018 13:30

As a developer, I'd like to create a leaderboard whose value is a HitCount condition, not a memory address.

For example, Mario's coin counter resets at 100, so there's no way to create a leaderboard for most coins collected in a playthrough. I'd like the value to be hitcount(coins != delta(coins))

Copied from original issue: RetroAchievements/RASuite#70

meleu commented 6 years ago

From @Jamiras on April 1, 2018 13:39

The value field currently uses a different syntax than the condition format, which would be incompatible. A prefix would have to switch modes:

Existing format looks like: 0xH1234*10_0xH1235_v1 where the memory address is the same syntax, but * is raw multiplication (not supported by conditions), and _ means add, not and. Additionally, the v indicates a raw value and supports negative values, whereas conditions just have raw numbers without a size indicator.

Suggested format would be something like H:0xH1234!=d0xH1234. The "H:" prefix indicates it's a HitCount value, and the remaining portion of the string is the condition. In an achievement, this would be written 0xH1234!=d0xH1234.10. where the .10. indicates the target HitCount. Since a leaderboard doesn't have a target, that part would be left off.

Jamiras commented 5 years ago

Supported via the referenced rcheevos commit. Here's a leaderboard for total coins collected as suggested in the original description.

image

You can see the current counter is 4, but the total counter is 104. At 100, the current counter was reset, but the leaderboard keeps counting.

For reference, the leaderboard value field was M:0xh75e!=d0xh75e.

From the linked rcheevos PR:

A "M:" prefix or a "C:" (AddHits) prefix indicates that a condition should be parsed instead of a value. The "M:" prefix is required, but may be preceeded by any number of "C:" prefixes. The old value format is still fully supported.

Counters will always start at 0, and there's currently no way to modify the result (i.e. add 2 or count down from some arbitrary value).