-
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
NPC work log - for debugging and feedback #37300
Conversation
This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there: |
This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there: https://discourse.cataclysmdda.org/t/how-does-npc-butchery-work/22654/11 |
aa39539
to
9761f13
Compare
924f105
to
39e00e3
Compare
ad63e77
to
8e68539
Compare
621a68e
to
b7106d0
Compare
0f30a43
to
d432807
Compare
first attempt at making an NPC work log serializing and expanding reasons sent to log clear folded list on display from review : shortern inserts Update src/npc.cpp Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com> Update src/npc.cpp Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com> Update src/npc.h Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com> Update src/npc.cpp Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com> remove unneeded lines test refactor to use enum strings move enum to string definitions to cpp from header Update src/savegame_json.cpp Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com> Update src/savegame_json.cpp Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com> fix up enum to string conversoin and default constructor added work log result for no candidates spaces to move components / cant see Update activity_item_handling.cpp shortern is_npc() checks commit to trigger rebuild
Rebased, cleaned up a bit, tested, working. Still lots of refinements and additions that could be made to this, but the framework is there and the diff is getting big, as a first pass I consider this ready. |
Could you consider also migrating the UI code to use |
Not familiar with that, and UI is my least favourite thing to do lol, but I'll take a look |
if( con_idx ) { | ||
json.member( "con_idx", con_idx->id() ); | ||
} else { | ||
json.member( "con_idx", -1 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json.member( "con_idx", -1 ); | |
json.null_member( "con_idx" ); |
For consistency with how cata::optional
is written.
JsonObject jo = jsin.get_object(); | ||
reason = jo.get_enum_value<do_activity_reason>( "reason" ); | ||
jo.read( "can_do", can_do ); | ||
if( jo.has_int( "index " ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if( jo.has_int( "index " ) ) { | |
if( jo.has_null( "con_idx" ) ) { |
Feel free to reopen when you come back. |
Summary
SUMMARY: Features "NPC work log - for debugging and feedback"
Purpose of change
Adds a work log that lists NPC behaviour changes and mission changes and activity failures and reasons etc, to aid in debugging and giving feedback to the player.
Describe the solution
I kept promising myself I would add something like this before I added any new features to NPCs, debugging them and working out where they were going wrong was an exercise in frustration, I wanted a proper NPC activity test system too, but I thought something like this would help in that endeavour.
What this does is add a std::deque work log , every change in attitude, mission, activity and certian steps in activities, adds an entry to the log, with timestamp, character id, and a description of what changed, sometimes a tripoint and activity_reason_info too.
If debug mode is on, it lists everything, else, it just lists activity stuff.
Two ways to access it currently - from a basecamp bulletin board ,this will prefilter the log to show just the NPCs that are assigned to work at that camp.
You can also ask an NPC directly to tell you what their work log is, itll prefilter to just that NPC.
[WIP] because its rough, I would like to make it easier to read, prettier, easier to filter from within the window that pops up, perhaps add more categories of event, and ways to access it, so as to extract more relevant information and less filler.
Willing to accept guidance in this, but as it stands currently, its still useful for finding out why Bob failed to remove that vehicle part, or why he suddenly decided his mission was to run away or something, just gives a bit of an insight into their mind.
Describe alternatives you've considered
N/A
Testing
Asked NPC to do various things, assigned them to camp, opened work log, did the smae by talking to them directly.
Did this with debug mode on and off.
Tested save/load cycle to see that serial/deserial worked.
Additional context
Basic UI stuff.