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() );