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
Infrastructure "NPCs keep track of total sales"
Purpose of change
This change makes trading NPCs keep track of the total value of everything you ever sold to them.
This sales value can be used in dialogue scripts for dynamic lines and conditional dialogue. It can also be modified via dialogue.
Primarily intended for the new merchant Rubik, but can probably be used to unlock some new options with the Free Merchants as well (#51320).
Describe the solution
Add
sold
tonpc_opinion
, stored innpc::op_of_u
.Modify the "Edit NPC" debug menu to show this value and allow changing it.
Update
op_of_u.sold
intrading_window::update_npc_owed
usingtrading_window::your_sale_value
(also introduced in this PR; computed intrading_window::perform_trade
).Add
talker::sold()
andtalker::add_sold()
and implement them intalker_npc
similar todebt()
andadd_debt()
.Add code to handle
"sold"
in the"u_val"
handler incondition.cpp
.And some code cleanup related to
npc_opinion
.Describe alternatives you've considered
Implementing
u_have_sold
as a special condition similar tou_are_owed
. However, that's much less flexible in terms of possible comparison operations and doesn't allow modification. [Edit: I just realized that I'm using features that were recently added in #50305. This would not have been possible more than 2 weeks ago. Thanks, @Light-Wave!]Testing
Modified the Refugee Center merchant json:
patch.txt
Teleported to the Refugee Center. Traded 1 Hub01 coin for 1 pipe bomb.
Debug menu for the merchant shows:
The conversation changes to:
After selecting the option to forget the sale:
Additional context