Skip to content

Commit

Permalink
Add assign mission dialog function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 committed Jun 27, 2021
1 parent 43c5efb commit 1cb366c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/NPCs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/dialogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
18 changes: 18 additions & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mission *> 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 )
{
Expand Down Expand Up @@ -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() );
}
Expand Down

0 comments on commit 1cb366c

Please sign in to comment.