-
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
Update events to account for ability to swap avatars (debug or upon death) #63488
Merged
kevingranade
merged 13 commits into
CleverRaven:master
from
cake-pie:events-avatar-swap
Mar 22, 2023
Merged
Update events to account for ability to swap avatars (debug or upon death) #63488
kevingranade
merged 13 commits into
CleverRaven:master
from
cake-pie:events-avatar-swap
Mar 22, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
[C++]
Changes (can be) made in C++. Previously named `Code`
[JSON]
Changes (can be) made in JSON
Game: Achievements / Conducts / Scores
Player goals and how they are tracked.
<Bugfix>
This is a fix for a bug (or closes open issue)
astyled
astyled PR, label is assigned by github actions
json-styled
JSON lint passed, label assigned by github actions
labels
Feb 8, 2023
Closed
github-actions
bot
added
Code: Tests
Measurement, self-control, statistics, balancing.
BasicBuildPassed
This PR builds correctly, label assigned by github actions
labels
Feb 8, 2023
cake-pie
force-pushed
the
events-avatar-swap
branch
from
February 9, 2023 01:39
6570f88
to
d50e432
Compare
Added migration from existing saves that makes best-effort attempt to populate Ready for testing and review. |
cake-pie
force-pushed
the
events-avatar-swap
branch
from
February 9, 2023 14:00
13f3858
to
1a90334
Compare
cake-pie
force-pushed
the
events-avatar-swap
branch
from
March 3, 2023 13:37
1a90334
to
4d708e9
Compare
Rebased to resolve conflicts. E: test failure unrelated, fixed in #63911 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
astyled
astyled PR, label is assigned by github actions
BasicBuildPassed
This PR builds correctly, label assigned by github actions
<Bugfix>
This is a fix for a bug (or closes open issue)
[C++]
Changes (can be) made in C++. Previously named `Code`
Code: Tests
Measurement, self-control, statistics, balancing.
Game: Achievements / Conducts / Scores
Player goals and how they are tracked.
[JSON]
Changes (can be) made in JSON
json-styled
JSON lint passed, label assigned by github actions
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "Update events to account for ability to swap avatars (debug or upon death)"
Purpose of change
Resolves #63455
#51450 and #53606 gave the ability to switch to another character.
Preexisting game events (that feed into memorial, stats, achievements, conducts, scores) are not equipped to handle this, as they only recorded the starting character in
event_type::game_start
and then death and last words inevent_type::game_over
. This oversight causes some things to break.Describe the solution
game_avatar_new
off fromgame_start
andgame_avatar_death
fromgame_over
game_avatar_new
from available informationgame_start
is available, get starting character information from itgame_start
is also not available (pretty old save!) treat current character as starting character.game_avatar_new
at the end ofavatar::control_npc()
when new avatar takes overgame_avatar_death
to record last words of all dead PCsavatar_id
event statistic to pull its value from the most recentgame_avatar_new
eventgame_avatar_death
instead ofgame_over
game_avatar_new
instead ofgame_start
, and will have different text for a character swap rather than a brand new gamegame_avatar_new
entry. Depending on how manygame_avatar_new
entries there are, it will append "et. al." to indicate that there was/were subsequent character(s) that took over from the starting character due to death or debug. If there are nogame_avatar_new
entries, it will fall back on the legacy approach and pull the starting character name fromgame_start
.Behavior of stats after this PR
avatar_id
statistic continue working as they didavatar_id
will switch to the "lifetime" stats of the new avatar when switching to themThis is imperfect, but now we are at least capturing an event whenever player control switches from one character to another. This ensures that save games will contain the information needed when a fuller solution is developed.
Subsequent work can look into a different way for event transformation to filter events (e.g. kills) to match them against the player character
avatar_id
at the time the event occurred rather than the current avatar, so that the affected scores, achievements and conducts are on the basis of player action.Additional context
I can't do anything about information that was lost between #51450 / #53606 and now, because it wasn't able to be captured.
This will probably break some achievements in existing saves, because they'd look foravatar_id
but be unable to resolve a value for it when there are nogame_avatar_new
events yet. There's no way in the event statistics system to "union" two event streams (game_start
withgame_avatar_new
) and implementing such a feature looks like it will get really complex, so I don't think it's worth it just for the sake of this one unusual case. Perhaps some other migration strategy could be devised? In any case, the affected achievements are already broken anyway ( #63455 ) so I'd be satisfied with fixing things so that they work correctly for new saves henceforth.Describe alternatives you've considered
Hijack the existing
game_start
andgame_over
so that they are also emitted whenever there is a character swap, but that seems weird esp. with respect to the game version and total play time fields.Testing
Simple test case: TestLand.zip
Build this PR, load the save in and verify that the score screen shows 5 monsters killed as the first stat on top. Spawn a slow, harmless monster e.g. water strider and kill it; check that the count has increased to 6.
Using the debug menu,
p
,x
to switch to the follower NPC. Check the score screen, which should now shows 0 kills (Antonia Boswell's lifetime stats). Spawn water strider; kill; check that the count has increased to 1.Switch back to the original character. Check score screen, which should list 6 kills.
Fire up a recent experimental build and load up the original save file again. Verify that the score screen shows 5 monsters killed.
Switch to the follower NPC. Check that score screen; it shows 5 kills. Spawn water strider; kill; check the count, which did not increase.
Save the game and transfer it to the PR build. The score screen should reflect Antonia's 1 kill.
Spawn water strider; kill; check count increased to 2.
Switch back to the original character. The score screen should reflect their 5 kills.