Skip to content

Commit

Permalink
Merge pull request CleverRaven#72677 from PatrikLundell/trace_work
Browse files Browse the repository at this point in the history
Improved task activity feedback slightly
  • Loading branch information
Maleclypse authored Mar 31, 2024
2 parents b4877a3 + a4001d7 commit e52633b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 8 deletions.
30 changes: 30 additions & 0 deletions src/activity_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,36 @@ enum class do_activity_reason : int {

};

// Vector because of style demands => no built in consistency check when number of enum elements change.
const std::vector<std::string> do_activity_reason_string = {
"CAN_DO_CONSTRUCTION",
"CAN_DO_FETCH",
"NO_COMPONENTS",
"DONT_HAVE_SKILL",
"NO_ZONE",
"ALREADY_DONE",
"UNKNOWN_ACTIVITY",
"NEEDS_HARVESTING",
"NEEDS_PLANTING",
"NEEDS_TILLING",
"BLOCKING_TILE",
"NEEDS_BOOK_TO_LEARN",
"NEEDS_CHOPPING",
"NEEDS_TREE_CHOPPING",
"NEEDS_BIG_BUTCHERING",
"NEEDS_BUTCHERING",
"NEEDS_CUT_HARVESTING",
"ALREADY_WORKING",
"NEEDS_VEH_DECONST",
"NEEDS_VEH_REPAIR",
"WOULD_PREVENT_VEH_FLYING",
"NEEDS_MINING",
"NEEDS_MOP",
"NEEDS_FISHING",
"NEEDS_CRAFT",
"NEEDS_DISASSEMBLE"
};

struct activity_reason_info {
//reason for success or fail
do_activity_reason reason;
Expand Down
43 changes: 35 additions & 8 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,7 @@ static std::unordered_set<tripoint_abs_ms> generic_multi_activity_locations(
}
const bool post_dark_check = src_set.empty();
if( !pre_dark_check && post_dark_check && !MOP_ACTIVITY ) {
you.add_msg_if_player( m_info, _( "It is too dark to do this activity." ) );
you.add_msg_if_player( m_info, _( "It is too dark to do the %s activity." ), act_id.c_str() );
}
return src_set;
}
Expand Down Expand Up @@ -2730,9 +2730,21 @@ static requirement_check_result generic_multi_activity_check_requirement(
reason == do_activity_reason::UNKNOWN_ACTIVITY ) {
// we can discount this tile, the work can't be done.
if( reason == do_activity_reason::DONT_HAVE_SKILL ) {
you.add_msg_if_player( m_info, _( "You don't have the skill for this task." ) );
if( zone ) {
you.add_msg_if_player( m_info, _( "You don't have the skill for the %s task at zone %s." ),
act_id.c_str(), zone->get_name() );
} else {
you.add_msg_if_player( m_info, _( "You don't have the skill for the %s task." ), act_id.c_str() );
}
} else if( reason == do_activity_reason::BLOCKING_TILE ) {
you.add_msg_if_player( m_info, _( "There is something blocking the location for this task." ) );
if( zone ) {
you.add_msg_if_player( m_info,
_( "There is something blocking the location for the %s task at zone %s." ), act_id.c_str(),
zone->get_name() );
} else {
you.add_msg_if_player( m_info, _( "There is something blocking the location for the %s task." ),
act_id.c_str() );
}
}
return requirement_check_result::SKIP_LOCATION;
} else if( reason == do_activity_reason::NO_COMPONENTS ||
Expand All @@ -2751,8 +2763,15 @@ static requirement_check_result generic_multi_activity_check_requirement(
// we can do it, but we need to fetch some stuff first
// before we set the task to fetch components - is it even worth it? are the components anywhere?
if( you.is_npc() ) {
add_msg_if_player_sees( you, m_info, _( "%s is trying to find necessary items to do the job" ),
you.disp_name() );
if( zone ) {
add_msg_if_player_sees( you, m_info,
_( "%s is trying to find necessary items to do the %s job on zone %s, reason %s" ),
you.disp_name(), act_id.c_str(), zone->get_name(), do_activity_reason_string[int( reason )] );
} else {
add_msg_if_player_sees( you, m_info,
_( "%s is trying to find necessary items to do the %s job, reason %s" ),
you.disp_name(), act_id.c_str(), do_activity_reason_string[int( reason )] );
}
}
requirement_id what_we_need;
std::vector<tripoint_bub_ms> loot_zone_spots;
Expand Down Expand Up @@ -2866,9 +2885,17 @@ static requirement_check_result generic_multi_activity_check_requirement(
// is it even worth fetching anything if there isn't enough nearby?
if( !are_requirements_nearby( tool_pickup ? loot_zone_spots : combined_spots, what_we_need, you,
act_id, tool_pickup, src_loc ) ) {
you.add_msg_player_or_npc( m_info,
_( "The required items are not available to complete this task." ),
_( "The required items are not available to complete this task." ) );
if( zone ) {
you.add_msg_player_or_npc( m_info,
_( "The required items are not available to complete the %s task at zone %s." ), act_id.c_str(),
zone->get_name(),
_( "The required items are not available to complete the %s task at zone %s." ), act_id.c_str(),
zone->get_name() );
} else {
you.add_msg_player_or_npc( m_info,
_( "The required items are not available to complete the %s task." ), act_id.c_str(),
_( "The required items are not available to complete the %s task." ), act_id.c_str() );
}
if( reason == do_activity_reason::NEEDS_VEH_DECONST ||
reason == do_activity_reason::NEEDS_VEH_REPAIR ) {
you.activity_vehicle_part_index = -1;
Expand Down

0 comments on commit e52633b

Please sign in to comment.