From a11526bf19b1554c321572e5cc4dc25f01a73d7f Mon Sep 17 00:00:00 2001 From: Michael Carter Date: Wed, 30 Jan 2019 07:28:42 -0600 Subject: [PATCH 1/2] Fix NPC dialog around lying and succeeding mission JSON refactoring for dialog changed some outcomes and chances with the mission dialogs. This brings the chances and results back in line with what they were before the JSON refactor. Fixes #27971 --- data/json/npcs/TALK_COMMON_MISSION.json | 82 +++++++++++++++---------- data/json/npcs/TALK_COMMON_OTHER.json | 2 +- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/data/json/npcs/TALK_COMMON_MISSION.json b/data/json/npcs/TALK_COMMON_MISSION.json index ab1dc4cbae502..cad5f5d537a8d 100644 --- a/data/json/npcs/TALK_COMMON_MISSION.json +++ b/data/json/npcs/TALK_COMMON_MISSION.json @@ -128,91 +128,108 @@ "condition": "mission_failed", "trial": { "type": "LIE", "difficulty": 10, "mod": [ [ "TRUST", 3 ] ] }, "success": { "topic": "TALK_NONE" }, - "failure": { "topic": "TALK_MISSION_FAILURE" } + "failure": { "topic": "TALK_MISSION_FAILURE", "opinion": { "trust": -3, "value": -1, "anger": 2 } } }, { "text": "Not yet.", "condition": "mission_incomplete", "topic": "TALK_NONE" }, { - "truefalsetext": { "true": "I killed him.", "false": "I killed it.", "condition": { "mission_goal": "ASSASSINATE" } }, + "truefalsetext": { "true": "I killed him.", "false": "I killed it.", "condition": { "mission_goal": "MGOAL_ASSASSINATE" } }, "condition": { "and": [ "mission_incomplete", { "or": [ - { "mission_goal": "ASSASSINATE" }, - { "mission_goal": "KILL_MONSTER" }, - { "mission_goal": "KILL_MONSTER_SPEC" }, - { "mission_goal": "KILL_MONSTER_TYPE" } + { "mission_goal": "MGOAL_ASSASSINATE" }, + { "mission_goal": "MGOAL_KILL_MONSTER" }, + { "mission_goal": "MGOAL_KILL_MONSTER_SPEC" }, + { "mission_goal": "MGOAL_KILL_MONSTER_TYPE" } ] } ] }, - "trial": { "type": "LIE", "difficulty": 10, "mod": [ [ "TRUST", 3 ] ] }, - "success": { "topic": "TALK_NONE" }, - "failure": { "topic": "TALK_MISSION_FAILURE" } + "trial": { "type": "LIE", "difficulty": 10, "mod": [ [ "TRUST", 5 ] ] }, + "success": { "topic": "TALK_MISSION_SUCCESS", "effect": "mission_success" }, + "failure": { "topic": "TALK_MISSION_SUCCESS_LIE", "opinion": { "trust": -5, "value": -1, "anger": 5 } } }, { "text": "No. I'll get back to it, bye!", "condition": "mission_incomplete", "topic": "TALK_NONE" }, { "text": "Yup! Here it is!", "topic": "TALK_MISSION_SUCCESS", - "condition": { "and": [ { "or": [ { "mission_goal": "FIND_ITEM" }, { "mission_goal": "FIND_ANY_ITEM" } ] }, "mission_complete" ] }, - "switch": true + "condition": { + "and": [ { "or": [ { "mission_goal": "MGOAL_FIND_ITEM" }, { "mission_goal": "MGOAL_FIND_ANY_ITEM" } ] }, "mission_complete" ] + }, + "switch": true, + "effect": "mission_success" }, { "text": "We're here!", "topic": "TALK_MISSION_SUCCESS", - "condition": { "and": [ "mission_complete", { "mission_goal": "GO_TO_TYPE" } ] }, - "switch": true + "condition": { "and": [ "mission_complete", { "mission_goal": "MGOAL_GO_TO_TYPE" } ] }, + "switch": true, + "effect": "mission_success" }, { "text": "Here I am.", "topic": "TALK_MISSION_SUCCESS", - "condition": { "and": [ { "or": [ { "mission_goal": "GO_TO" }, { "mission_goal": "FIND_NPC" } ] }, "mission_complete" ] }, - "switch": true + "condition": { "and": [ { "or": [ { "mission_goal": "MGOAL_GO_TO" }, { "mission_goal": "MGOAL_FIND_NPC" } ] }, "mission_complete" ] }, + "switch": true, + "effect": "mission_success" }, { "text": "Here it is!", "topic": "TALK_MISSION_SUCCESS", - "condition": { "and": [ "mission_complete", { "mission_goal": "FIND_MONSTER" } ] }, - "switch": true + "condition": { "and": [ "mission_complete", { "mission_goal": "MGOAL_FIND_MONSTER" } ] }, + "switch": true, + "effect": "mission_success" }, { "text": "Justice has been served.", "topic": "TALK_MISSION_SUCCESS", - "condition": { "and": [ "mission_complete", { "mission_goal": "ASSASSINATE" } ] }, - "switch": true + "condition": { "and": [ "mission_complete", { "mission_goal": "MGOAL_ASSASSINATE" } ] }, + "switch": true, + "effect": "mission_success" }, { "text": "I killed it.", "topic": "TALK_MISSION_SUCCESS", - "condition": { "and": [ "mission_complete", { "mission_goal": "KILL_MONSTER" } ] }, - "switch": true + "condition": { "and": [ "mission_complete", { "mission_goal": "MGOAL_KILL_MONSTER" } ] }, + "switch": true, + "effect": "mission_success" }, { "text": "I killed them. All of them.", "topic": "TALK_MISSION_SUCCESS", "condition": { - "and": [ { "or": [ { "mission_goal": "KILL_MONSTER_SPEC" }, { "mission_goal": "KILL_MONSTER_TYPE" } ] }, "mission_complete" ] + "and": [ + { "or": [ { "mission_goal": "MGOAL_KILL_MONSTER_SPEC" }, { "mission_goal": "MGOAL_KILL_MONSTER_TYPE" } ] }, + "mission_complete" + ] }, - "switch": true + "switch": true, + "effect": "mission_success" }, { "text": "I brought 'em.", "topic": "TALK_MISSION_SUCCESS", - "condition": { "and": [ "mission_complete", { "mission_goal": "RECRUIT_NPC" }, { "mission_goal": "RECRUIT_NPC_CLASS" } ] }, - "switch": true + "condition": { + "and": [ "mission_complete", { "mission_goal": "MGOAL_RECRUIT_NPC" }, { "mission_goal": "MGOAL_RECRUIT_NPC_CLASS" } ] + }, + "switch": true, + "effect": "mission_success" }, { "text": "I've taken care of it", "topic": "TALK_MISSION_SUCCESS", - "condition": { "and": [ "mission_complete", { "mission_goal": "COMPUTER_TOGGLE" } ] }, - "switch": true + "condition": { "and": [ "mission_complete", { "mission_goal": "MGOAL_COMPUTER_TOGGLE" } ] }, + "switch": true, + "effect": "mission_success" }, { "text": "Mission success! I don't know what else to say.", "topic": "TALK_MISSION_SUCCESS", "condition": "mission_complete", "switch": true, - "default": true + "default": true, + "effect": "mission_success" } ] }, @@ -223,10 +240,8 @@ "responses": [ { "text": "Glad to help. I need no payment.", - "topic": "TALK_NONE", "effect": "clear_mission", - "mission_opinion": { "trust": 4, "value": 3 }, - "opinion": { "fear": -1, "anger": -1 } + "success": { "topic": "TALK_NONE", "mission_opinion": { "trust": 4, "value": 3 }, "opinion": { "fear": -1, "anger": -1 } } }, { "text": "How about some items as payment?", @@ -238,14 +253,13 @@ "text": "Maybe you can teach me something as payment?", "topic": "TALK_TRAIN", "condition": { "or": [ "npc_train_skills", "npc_train_styles" ] }, - "effect": "mission_reward" + "effect": "clear_mission" }, { "text": "Glad to help. I need no payment. Bye!", "topic": "TALK_DONE", "effect": "clear_mission", - "mission_opinion": { "trust": 4, "value": 3 }, - "opinion": { "fear": -1, "anger": -1 } + "success": { "topic": "TALK_DONE", "mission_opinion": { "trust": 4, "value": 3 }, "opinion": { "fear": -1, "anger": -1 } } } ] }, diff --git a/data/json/npcs/TALK_COMMON_OTHER.json b/data/json/npcs/TALK_COMMON_OTHER.json index bf4abb3e2b435..b1abc4e6ea39d 100644 --- a/data/json/npcs/TALK_COMMON_OTHER.json +++ b/data/json/npcs/TALK_COMMON_OTHER.json @@ -291,7 +291,7 @@ "text": "I'll give it back!", "switch": true, "default": true, - "trial": { "type": "LIE", "difficulty": 10, "mod": [ [ "TRUST", 2 ], [ "VALUE", 5 ], [ "ALTRUISM", 3 ] ] }, + "trial": { "type": "LIE", "difficulty": 0, "mod": [ [ "TRUST", 2 ], [ "VALUE", 5 ], [ "ALTRUISM", 3 ] ] }, "success": { "topic": "TALK_GIVE_EQUIPMENT", "effect": [ { "add_debt": [ [ "TRUST", 1 ], [ "VALUE", 3 ], [ "ALTRUISM", 2 ], [ "TOTAL", 300 ] ] }, "give_equipment" ], From af61c237f8b14ee839662daaeb9a6a9d399448ad Mon Sep 17 00:00:00 2001 From: Michael Carter Date: Fri, 1 Feb 2019 02:25:38 -0600 Subject: [PATCH 2/2] Fix some more mission completion dialog bugs Putting the clear_mission effect into the success section of the JSON seems to be required. Also the clear_mission effect was removing a mission reference before the opinion modifiers could be applied. Also, choosing training for a mission reward will automatically clear the mission, and if the JSON forces it to clear with an effect, the player has to pay for the training. references #27972 references #27983 --- data/json/npcs/TALK_COMMON_MISSION.json | 20 +++++++++++++------- src/npctalk.cpp | 4 +++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/data/json/npcs/TALK_COMMON_MISSION.json b/data/json/npcs/TALK_COMMON_MISSION.json index cad5f5d537a8d..1b5bbd0f518ef 100644 --- a/data/json/npcs/TALK_COMMON_MISSION.json +++ b/data/json/npcs/TALK_COMMON_MISSION.json @@ -240,8 +240,12 @@ "responses": [ { "text": "Glad to help. I need no payment.", - "effect": "clear_mission", - "success": { "topic": "TALK_NONE", "mission_opinion": { "trust": 4, "value": 3 }, "opinion": { "fear": -1, "anger": -1 } } + "success": { + "topic": "TALK_NONE", + "effect": "clear_mission", + "mission_opinion": { "trust": 4, "value": 3 }, + "opinion": { "fear": -1, "anger": -1 } + } }, { "text": "How about some items as payment?", @@ -252,14 +256,16 @@ { "text": "Maybe you can teach me something as payment?", "topic": "TALK_TRAIN", - "condition": { "or": [ "npc_train_skills", "npc_train_styles" ] }, - "effect": "clear_mission" + "condition": { "or": [ "npc_train_skills", "npc_train_styles" ] } }, { "text": "Glad to help. I need no payment. Bye!", - "topic": "TALK_DONE", - "effect": "clear_mission", - "success": { "topic": "TALK_DONE", "mission_opinion": { "trust": 4, "value": 3 }, "opinion": { "fear": -1, "anger": -1 } } + "success": { + "topic": "TALK_DONE", + "effect": "clear_mission", + "mission_opinion": { "trust": 4, "value": 3 }, + "opinion": { "fear": -1, "anger": -1 } + } } ] }, diff --git a/src/npctalk.cpp b/src/npctalk.cpp index c2db000d68690..a402ea98ed576 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -1661,11 +1661,13 @@ void talk_effect_t::set_effect( talkfunction_ptr ptr ) talk_topic talk_effect_t::apply( dialogue &d ) const { + // Need to get a reference to the mission before effects are applied, because effects can remove the mission + mission *miss = d.beta->chatbin.mission_selected; + for( const talk_effect_fun_t &effect: effects ) { effect( d ); } d.beta->op_of_u += opinion; - mission *miss = d.beta->chatbin.mission_selected; if( miss && ( mission_opinion.trust || mission_opinion.fear || mission_opinion.value || mission_opinion.anger ) ) { int m_value = cash_to_favor( *d.beta, miss->get_value() );