Skip to content

Commit

Permalink
implement EoC effect to return random body part
Browse files Browse the repository at this point in the history
  • Loading branch information
GuardianDll committed Aug 1, 2024
1 parent 0b942b3 commit 2f515cc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6343,6 +6343,30 @@ talk_effect_fun_t::func f_teleport( const JsonObject &jo, std::string_view membe
};
}

talk_effect_fun_t::func f_get_random_bodypart( const JsonObject &jo, std::string_view member,
const std::string_view, bool is_npc )
{
str_or_var type = get_str_or_var( jo.get_member( member ), member );
std::optional<var_info> target_var = read_var_info( jo.get_object( "target_var" ) );

return [is_npc, type, target_var]( dialogue const & d ) {
Character *guy = d.actor( is_npc )->get_character();

if( guy ) {
if( type.evaluate( d ) == "ANY" ) {
std::string bp = guy->get_random_body_part().id().str();
write_var_value( target_var.value().type, target_var.value().name, &d, bp );
return;
} else {
std::string bp = guy->get_random_body_part_of_type( io::string_to_enum<body_part_type::type>
( type.evaluate( d ) ) ).id().str();
write_var_value( target_var.value().type, target_var.value().name, &d, bp );
return;
}
}
};
}

talk_effect_fun_t::func f_wants_to_talk( bool is_npc )
{
return [is_npc]( dialogue const & d ) {
Expand Down
2 changes: 2 additions & 0 deletions src/talker.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ class talker
bool, const std::vector<matec_id> & = {} ) const {
return matec_id();
}
virtual bodypart_id get_random_body_part_of_type(body_part_type::type /* part_type */) const;

Check failure on line 722 in src/talker.h

View workflow job for this annotation

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

incomplete type 'body_part_type' named in nested name specifier
virtual bodypart_id get_random_body_part(bool /* main = false */) const;
virtual void learn_martial_art( const matype_id & ) const {}
virtual void forget_martial_art( const matype_id & ) const {}
virtual bool knows_martial_art( const matype_id & ) const {
Expand Down
10 changes: 10 additions & 0 deletions src/talker_character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,3 +1247,13 @@ int talker_character_const::climate_control_str_chill() const
{
return me_chr_const->climate_control_strength().second;
}

bodypart_id talker::get_random_body_part_of_type( body_part_type::type ) const
{
return bodypart_id();
}

bodypart_id talker::get_random_body_part( bool ) const
{
return bodypart_id();
}

0 comments on commit 2f515cc

Please sign in to comment.