@@ -3091,13 +3091,14 @@ std::optional<int> iuse::change_skin( Character *p, item *, const tripoint_bub_m
3091
3091
return std::nullopt ;
3092
3092
}
3093
3093
3094
- static std::optional<int > dig_tool ( Character *p, item *it, const tripoint_bub_ms &pos ,
3094
+ static std::optional<int > dig_tool ( Character *p, item *it, const tripoint_bub_ms &target ,
3095
3095
const activity_id activity,
3096
- const std::string &prompt, const std::string &fail, const std::string &success,
3097
- int extra_moves = 0 )
3096
+ const std::string &prompt, const std::string &fail, const std::string &success )
3098
3097
{
3099
- // use has_enough_charges to check for UPS availability
3100
- // p is assumed to exist for iuse cases
3098
+ if ( !p || !it ) {
3099
+ debugmsg ( " Misconfigured call to dig_tool, invalid character or item pointer" );
3100
+ return std::nullopt ;
3101
+ }
3101
3102
if ( !it->ammo_sufficient ( p ) ) {
3102
3103
return std::nullopt ;
3103
3104
}
@@ -3108,8 +3109,9 @@ static std::optional<int> dig_tool( Character *p, item *it, const tripoint_bub_m
3108
3109
return std::nullopt ;
3109
3110
}
3110
3111
3111
- tripoint_bub_ms pnt ( pos );
3112
- if ( pos == p->pos_bub () ) {
3112
+ tripoint_bub_ms pnt ( target );
3113
+ // This should only be true when called through activating the item directly. That is, the player activated it.
3114
+ if ( target == p->pos_bub () ) {
3113
3115
const std::optional<tripoint_bub_ms> pnt_ = choose_adjacent ( prompt );
3114
3116
if ( !pnt_ ) {
3115
3117
return std::nullopt ;
@@ -3118,40 +3120,38 @@ static std::optional<int> dig_tool( Character *p, item *it, const tripoint_bub_m
3118
3120
}
3119
3121
3120
3122
map &here = get_map ();
3123
+ if ( here.impassable_field_at ( pnt ) ) {
3124
+ std::optional<field_entry> null_zone = here.get_impassable_field_at ( pnt );
3125
+ p->add_msg_if_player ( m_warning, _ ( " You can't make it through the %s there." ),
3126
+ null_zone->name () );
3127
+ return std::nullopt ;
3128
+ }
3121
3129
const bool mineable_furn = here.has_flag_furn ( ter_furn_flag::TFLAG_MINEABLE, pnt );
3122
3130
const bool mineable_ter = here.has_flag_ter ( ter_furn_flag::TFLAG_MINEABLE, pnt );
3123
- const bool impassable_fields = here.impassable_field_at ( pnt );
3124
- const int max_mining_ability = 70 ;
3125
- if ( ( !mineable_furn && !mineable_ter ) || impassable_fields ) {
3131
+ if ( !mineable_furn && !mineable_ter ) {
3126
3132
p->add_msg_if_player ( m_info, fail );
3127
- if ( here.bash_resistance ( pnt ) > max_mining_ability ) {
3128
- p->add_msg_if_player ( m_info,
3129
- _ ( " The material is too hard for you to even make a dent." ) );
3130
- }
3131
3133
return std::nullopt ;
3132
3134
}
3133
3135
if ( here.veh_at ( pnt ) ) {
3134
3136
p->add_msg_if_player ( _ ( " There's a vehicle in the way!" ) );
3135
3137
return std::nullopt ;
3136
3138
}
3137
3139
3138
- int moves = to_moves<int >( 30_minutes );
3139
-
3140
- const std::vector<Character *> helpers = p->get_crafting_helpers ();
3141
- const std::size_t helpersize = p->get_num_crafting_helpers ( 3 );
3142
- moves *= ( 1 .0f - ( helpersize / 10 .0f ) );
3143
- for ( std::size_t i = 0 ; i < helpersize; i++ ) {
3144
- add_msg ( m_info, _ ( " %s helps with this task…" ), helpers[i]->get_name () );
3140
+ const bool using_jackhammer = it->type ->can_use ( " JACKHAMMER" );
3141
+ if ( using_jackhammer && here.has_flag_ter ( ter_furn_flag::TFLAG_WALL, pnt ) ) {
3142
+ p->add_msg_if_player ( _ ( " You can't mine a wall with a %s!" ), it->tname () );
3143
+ return std::nullopt ;
3145
3144
}
3146
3145
3147
- moves += extra_moves;
3146
+ // FIXME: Activity is interruptable but progress is not saved!
3147
+ time_duration digging_time = 30_minutes;
3148
3148
3149
- if ( here.move_cost ( pnt ) == 2 ) {
3149
+ if ( here.has_flag ( ter_furn_flag::TFLAG_FLAT, pnt ) ) {
3150
3150
// We're breaking up some flat surface like pavement, which is much easier
3151
- moves /= 2 ;
3151
+ digging_time /= 2 ;
3152
3152
}
3153
3153
3154
- p->assign_activity ( activity, moves );
3154
+ p->assign_activity ( activity, to_moves< int >( digging_time ) );
3155
3155
p->activity .targets .emplace_back ( *p, it );
3156
3156
p->activity .placement = here.get_abs ( pnt );
3157
3157
@@ -3165,12 +3165,6 @@ static std::optional<int> dig_tool( Character *p, item *it, const tripoint_bub_m
3165
3165
3166
3166
std::optional<int > iuse::jackhammer ( Character *p, item *it, const tripoint_bub_ms &pos )
3167
3167
{
3168
- // use has_enough_charges to check for UPS availability
3169
- // p is assumed to exist for iuse cases
3170
- if ( !it->ammo_sufficient ( p ) ) {
3171
- return std::nullopt ;
3172
- }
3173
-
3174
3168
return dig_tool ( p, it, pos, ACT_JACKHAMMER,
3175
3169
_ ( " Drill where?" ), _ ( " You can't drill there." ),
3176
3170
_ ( " You start drilling into the %1$s with your %2$s." ) );
@@ -3226,16 +3220,8 @@ std::optional<int> iuse::pick_lock( Character *p, item *it, const tripoint_bub_m
3226
3220
3227
3221
std::optional<int > iuse::pickaxe ( Character *p, item *it, const tripoint_bub_ms &pos )
3228
3222
{
3229
- if ( p->is_npc () ) {
3230
- // Long action
3231
- return std::nullopt ;
3232
- }
3233
- /* * @EFFECT_STR decreases time to dig with a pickaxe */
3234
- int extra_moves = ( ( MAX_STAT + 4 ) -
3235
- std::min ( p->get_arm_str (), MAX_STAT ) ) * to_moves<int >( 5_minutes );
3236
3223
return dig_tool ( p, it, pos, ACT_PICKAXE,
3237
- _ ( " Mine where?" ), _ ( " You can't mine there." ), _ ( " You strike the %1$s with your %2$s." ),
3238
- extra_moves );
3224
+ _ ( " Mine where?" ), _ ( " You can't mine there." ), _ ( " You strike the %1$s with your %2$s." ) );
3239
3225
3240
3226
}
3241
3227
0 commit comments