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

npctalk: add true/false responses and CONDITION trials to JSON #27707

Merged
merged 2 commits into from
Jan 20, 2019

Conversation

mlangsdorf
Copy link
Contributor

Summary

SUMMARY: Infrastructure "npctalk: add true/false responses and CONDITION trials to JSON"

Purpose of change

Fixes #27637 - response snippets will now be logged in their final form
Fixes #27397 - CONDITION trials was the last remaining requested feature
Add two new options for PC responses to NPC dialogues in JSON:

  • a true/false conditional text, so the player has different response texts depending on a condition, but the same trial/effects/next topic
  • a new CONDITION trial, so the player has a single response text, but the effects/next topic change depending on a binary condition

Of course, both these options can be combined.

Also, clear a bug where snippets in a response line were logged in their original form instead of their expanded form.

Describe the solution

Add new fields to talk_response, truetext, falsetext, and truefalse_condition. Add code to the JSON parser to populate these fields if a truefalsetext object is present. When creating an option line, set the text field to the truetext if the truefalse_condition is true and the falsetext otherwise.

Log the final version of the response text after parsing, not the original form.

Add a new type of trial, CONDITION. A CONDITION trial takes a condition field instead of a difficulty field, and sets the chance of the trial passing at 100 if the condition is true and at 0 otherwise.

Update the test cases to use a helper function that calls create_option_line() so that the truefalse_condition will be evaluated.

Additional context

Includes #27706

@mlangsdorf mlangsdorf added <Enhancement / Feature> New features, or enhancements on existing NPC / Factions NPCs, AI, Speech, Factions, Ownership [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Jan 18, 2019
@mlangsdorf mlangsdorf force-pushed the npctalk_tf_conditions branch 2 times, most recently from f4a9eb5 to 7f24d9b Compare January 19, 2019 14:05
letter, // option letter
text // response
);
text = truefalse_condition( d ) ? truetext : falsetext;
Copy link
Member

@kevingranade kevingranade Jan 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spawned in a pair of NPCs, mind controlled both of them, then tried to talk to one to set it as the overseer, then it crashed on this line.
The way it crashed I can't get the backtrace.

I had also merged #27706.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this was something I'd fixed in the final version but didn't make it into the refactoring for submission.

Fixed.

Add a new response option for response text, "truefalsetext", which
takes a condition and displays a "true" text if the condition is true
and false otherwise.  The response trial, effects, etc. are the same
for both texts.
Add a new type of trial, "CONDITION" which always succeeds or fails based
on the value of a condition object.
@mlangsdorf mlangsdorf force-pushed the npctalk_tf_conditions branch from 7f24d9b to e9566ac Compare January 20, 2019 17:57
@kevingranade kevingranade merged commit 9e9d787 into CleverRaven:master Jan 20, 2019
@mlangsdorf mlangsdorf deleted the npctalk_tf_conditions branch January 20, 2019 23:54
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` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style <Enhancement / Feature> New features, or enhancements on existing NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants