diff --git a/doc/NPCs.md b/doc/NPCs.md index 0062c4628488a..37be97bd15082 100644 --- a/doc/NPCs.md +++ b/doc/NPCs.md @@ -559,7 +559,7 @@ Effect | Description ---|--- `message: message_string`, (*optional* `sound: sound_bool`),(*optional* `outdoor_only: outdoor_only_bool`),(*optional* `snippet: snippet_bool`),(*optional* `type: type_string`),(*optional* `popup: popup_bool`) | Displays a message to the player of `message_string`. If `snippet_bool` is true(defaults to false) it will instead display a random snippet from `message_string` category. If `sound` is true(defaults to false) it will only display the message if the player is not deaf. `outdoor_only`(defaults to false) only matters when `sound` is true and will make the message less likely to be heard if the player is underground. Message will display as type of `type_string`. Type affects the color of message and can be any of the following values: good, neutral, bad, mixed, warning, info, debug, headshot, critical, grazing. enums.h has more info on each types use. If `popup_bool` is true the message will be in a modal popup the user has to dismiss to continue. `sound_effect: sound_effect_id_string`, *optional* `sound_effect_variant: variant_string`, *optional* `outdoor_event: outdoor_event`,*optional* `volume: volume_int` | Will play a sound effect of id `sound_effect_id_string` and variant `variant_string`. If `volume_int` is defined it will be used otherwise 80 is the default. If `outdoor_event`(defaults to false) is true this will be less likely to play if the player is underground. - +`assign_mission: mission_type_id string` | Will assign mission `mission_type_id` to the player. #### Deprecated Effect | Description diff --git a/src/dialogue.h b/src/dialogue.h index 0ea3acb49d395..287db2b3ed4f1 100644 --- a/src/dialogue.h +++ b/src/dialogue.h @@ -103,6 +103,7 @@ struct talk_effect_fun_t { void set_mod_pain( const JsonObject &jo, const std::string &member, bool is_npc ); void set_add_wet( const JsonObject &jo, const std::string &member, bool is_npc ); void set_add_power( const JsonObject &jo, const std::string &member, bool is_npc ); + void set_assign_mission( const JsonObject &jo, const std::string &member ); void set_sound_effect( const JsonObject &jo, const std::string &member ); void set_add_var( const JsonObject &jo, const std::string &member, bool is_npc = false ); void set_remove_var( const JsonObject &jo, const std::string &member, bool is_npc = false ); diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 7a7b671266463..54704213ee84d 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -2192,6 +2192,22 @@ void talk_effect_fun_t::set_add_power( const JsonObject &jo, const std::string & }; } +void talk_effect_fun_t::set_assign_mission( const JsonObject &jo, const std::string &member ) +{ + std::string mission_name = jo.get_string( member ); + function = [mission_name]( const dialogue & d ) { + avatar &player_character = get_avatar(); + + const mission_type_id &mission_type = mission_type_id( mission_name ); + tripoint_abs_omt mission_target; + + std::vector missions = player_character.get_active_missions(); + mission *new_mission = mission::reserve_new( mission_type, character_id() ); + new_mission->assign( player_character ); + mission_target = new_mission->get_target(); + }; +} + void talk_effect_t::set_effect_consequence( const talk_effect_fun_t &fun, dialogue_consequence con ) { @@ -2445,6 +2461,8 @@ void talk_effect_t::parse_sub_effect( const JsonObject &jo ) subeffect_fun.set_add_power( jo, "u_add_power", false ); } else if( jo.has_member( "npc_add_power" ) ) { subeffect_fun.set_add_power( jo, "npc_add_power", true ); + } else if( jo.has_member( "assign_mission" ) ) { + subeffect_fun.set_assign_mission( jo, "assign_mission" ); } else { jo.throw_error( "invalid sub effect syntax: " + jo.str() ); }