Skip to content
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

Allow mission descriptions to refer to the effects of the mission. #33411

Merged
merged 11 commits into from
Aug 31, 2019

Conversation

Petethegoat
Copy link
Contributor

@Petethegoat Petethegoat commented Aug 20, 2019

SUMMARY: Interface "Allow mission descriptions to refer to the effects of the mission."

Purpose of change

Make written mission descriptions more resilient to becoming outdated if they want to refer to eg. the rewards provided by the mission.

Describe the solution

talk_effect_fun_t now has a simple and specific structure to store likely mission rewards, and it fills this during json loading. mission_type then grabs this and stores it for use by the mission UI later, using simple string replacement.
Currently it's limited to looking for the "u_buy_item" effect, and only when the cost is 0 (unspecified defaults to 0).

The tokens in descriptions look like this: "<reward_count:FMCNote>"
They'll look for a "u_buy_item" effect with a matching item id, and replace the whole token with the count for that item.
This does work correctly for multiple tokens in a single description. So you can reward several things and refer to all their counts correctly.

Describe alternatives you've considered

This is very specific for things that are probably rewards for the mission only- but it's kept it relatively simple rather than trying to guess future use-cases ahead of time, so refactoring it to include other parameters shouldn't be too painful, if need be.

Additional context

Created for #33325.

@Petethegoat Petethegoat changed the title Allow mission descriptions to refer to the effects of the mission. [WIP[CR] Allow mission descriptions to refer to the effects of the mission. Aug 20, 2019
@Petethegoat
Copy link
Contributor Author

To be clear, it's the stuff in mission_util.cpp that makes me question if this is something usable. Maybe that can be implemented more generically somehow, but I don't have any particularly bright ideas regarding that.

@Petethegoat
Copy link
Contributor Author

@ralreegorganon suggested a much less boneheaded way of getting the effect data that I've now implemented, which makes this feel a lot less hacky.

Right now I'm still putting the data into a very specific structure that's probably only going to be useful for my use case.
I'm not sure if I should try to generalize it without really knowing what other people will need, or if I should just keep it simple so someone who knows what they want can easily refactor it in the future.

Leaning towards the latter, lazier option, but I'm open to suggestions.

Petethegoat added a commit to Petethegoat/Cataclysm-DDA that referenced this pull request Aug 21, 2019
Add a structure to talk_effect_fun_t that it can update during it's own json parsing, and then refer to that when setting up the mission_type.
@Petethegoat Petethegoat force-pushed the mission-desc-tokenization branch from d5e5e02 to 33ec840 Compare August 21, 2019 04:23
@ZhilkinSerg ZhilkinSerg added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Missions Quests and missions labels Aug 21, 2019
src/mission_ui.cpp Outdated Show resolved Hide resolved
src/mission.h Outdated Show resolved Hide resolved
@BevapDin
Copy link
Contributor

There needs to be at least once instance that actually uses the new code, so we can see it works as expected. And documentation in some file in the "doc" folder would be nice (when it's finished).

@Petethegoat Petethegoat changed the title [WIP[CR] Allow mission descriptions to refer to the effects of the mission. Allow mission descriptions to refer to the effects of the mission. Aug 21, 2019
@Petethegoat Petethegoat changed the title Allow mission descriptions to refer to the effects of the mission. [WIP] Allow mission descriptions to refer to the effects of the mission. Aug 21, 2019
@Petethegoat
Copy link
Contributor Author

@BevapDin Kevin accidentally merged my Free Merchant descriptions PR that was supposed to wait for this, so there's already descriptions using this in master.

Will work on docs next, and then I think I'm happy with this, assuming the laziness regarding generalizing this is acceptable 🙂

@Petethegoat Petethegoat changed the title [WIP] Allow mission descriptions to refer to the effects of the mission. Allow mission descriptions to refer to the effects of the mission. Aug 21, 2019
@Petethegoat Petethegoat changed the title Allow mission descriptions to refer to the effects of the mission. Allow mission descriptions to refer to the effects of the mission. Aug 21, 2019
@Petethegoat
Copy link
Contributor Author

Docs added and PR description updated.

@ZhilkinSerg
Copy link
Contributor

Some conflicts creeped in. Can you resolve them please?

@ZhilkinSerg ZhilkinSerg self-assigned this Aug 24, 2019
@Petethegoat
Copy link
Contributor Author

Will do shortly.

…into mission-desc-tokenization

# Conflicts:
#	src/dialogue.h
#	src/npctalk.cpp
@Petethegoat
Copy link
Contributor Author

@ZhilkinSerg done, thanks for the heads up. :)

src/mission_ui.cpp Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg merged commit a3b5899 into CleverRaven:master Aug 31, 2019
@ZhilkinSerg ZhilkinSerg added the <Documentation> Design documents, internal info, guides and help. label Aug 31, 2019
@ZhilkinSerg ZhilkinSerg removed their assignment Aug 31, 2019
@Petethegoat Petethegoat deleted the mission-desc-tokenization branch August 31, 2019 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Documentation> Design documents, internal info, guides and help. <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON Missions Quests and missions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants