Skip to content

Commit 5f6a4a4

Browse files
Fix for Fingerpick CBM does not work (CleverRaven#55)
* Fix Fingerpick CBM does not work Fix Fingerpick CBM does not work * Revert "Fix Fingerpick CBM does not work" This reverts commit 8aa1e0b. * extract ter furn and message set extract ter furn and message set * It's working at least It's working at least * Use your lockpick where Use your lockpick where * Astyle Astyle * astyling again astyling again * astyle! astyle! * Astyle!! Astyle!! * add point check add point check * Migrating to mapdata.h Migrating to mapdata.h * remove empty lines remove empty lines * astyling astyling * astyling bionics astyling bionics * Change the symbol to UTF-8 version Co-authored-by: firestorm01x2 <firestorm01x2gmail.com> Co-authored-by: Coolthulhu <Coolthulhu@gmail.com>
1 parent 439c606 commit 5f6a4a4

File tree

4 files changed

+69
-28
lines changed

4 files changed

+69
-28
lines changed

src/activity_handlers.cpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,30 +2568,12 @@ void activity_handlers::lockpicking_finish( player_activity *act, player *p )
25682568

25692569
const ter_id ter_type = g->m.ter( act->placement );
25702570
const furn_id furn_type = g->m.furn( act->placement );
2571-
ter_id new_ter_type;
2572-
furn_id new_furn_type;
2573-
std::string open_message;
2574-
if( ter_type == t_chaingate_l ) {
2575-
new_ter_type = t_chaingate_c;
2576-
open_message = _( "With a satisfying click, the chain-link gate opens." );
2577-
} else if( ter_type == t_door_locked || ter_type == t_door_locked_alarm ||
2578-
ter_type == t_door_locked_interior ) {
2579-
new_ter_type = t_door_c;
2580-
open_message = _( "With a satisfying click, the lock on the door opens." );
2581-
} else if( ter_type == t_door_locked_peep ) {
2582-
new_ter_type = t_door_c_peep;
2583-
open_message = _( "With a satisfying click, the lock on the door opens." );
2584-
} else if( ter_type == t_door_metal_pickable ) {
2585-
new_ter_type = t_door_metal_c;
2586-
open_message = _( "With a satisfying click, the lock on the door opens." );
2587-
} else if( ter_type == t_door_bar_locked ) {
2588-
new_ter_type = t_door_bar_o;
2589-
//Bar doors auto-open (and lock if closed again) so show a different message)
2590-
open_message = _( "The door swings open…" );
2591-
} else if( furn_type == f_gunsafe_ml ) {
2592-
new_furn_type = f_safe_o;
2593-
open_message = _( "With a satisfying click, the lock on the door opens." );
2594-
} else {
2571+
lockpicking_open_result lr = get_lockpicking_open_result( ter_type, furn_type );
2572+
ter_id new_ter_type = lr.new_ter_type;
2573+
furn_id new_furn_type = lr.new_furn_type;
2574+
std::string open_message = lr.open_message;
2575+
2576+
if( new_ter_type == t_null && new_furn_type == f_null ) {
25952577
act->set_to_null();
25962578
}
25972579

src/bionics.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,21 +751,37 @@ bool Character::activate_bionic( int b, bool eff_only )
751751

752752
mod_moves( -100 );
753753
} else if( bio.id == bio_lockpick ) {
754-
tmp_item = item( "pseudo_bio_picklock", 0 );
755754
g->refresh_all();
756-
int charges = tmp_item.charges;
757755
bool used = false;
758-
if( invoke_item( &tmp_item ) ) {
759-
if( tmp_item.charges != charges ) {
756+
bool tried_lockpick = false;
757+
const cata::optional<tripoint> pnt = choose_adjacent( _( "Use your lockpick where?" ) );
758+
std::string open_message;
759+
if( pnt ) {
760+
tried_lockpick = true;
761+
ter_id ter_type = g->m.ter( *pnt );
762+
furn_id furn_type = g->m.furn( *pnt );
763+
lockpicking_open_result lr = get_lockpicking_open_result( ter_type, furn_type );
764+
ter_id new_ter_type = lr.new_ter_type;
765+
furn_id new_furn_type = lr.new_furn_type;
766+
open_message = lr.open_message;
767+
768+
if( new_ter_type != t_null || new_furn_type != f_null ) {
769+
g->m.has_furn( *pnt ) ?
770+
g->m.furn_set( *pnt, new_furn_type ) :
771+
static_cast<void>( g->m.ter_set( *pnt, new_ter_type ) );
760772
used = true;
761773
}
762774
}
763775

764776
if( used ) {
765777
add_msg_activate();
778+
add_msg_if_player( m_good, open_message );
766779
mod_moves( -100 );
767780
} else {
768781
refund_power();
782+
if( tried_lockpick ) {
783+
add_msg_if_player( m_info, _( "There is nothing to lockpick nearby." ) );
784+
}
769785
return false;
770786
}
771787
} else if( bio.id == bio_flashbang ) {

src/mapdata.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,41 @@ void reset_furn_ter()
933933
furniture_data.reset();
934934
}
935935

936+
lockpicking_open_result get_lockpicking_open_result( ter_id ter_type, furn_id furn_type )
937+
{
938+
lockpicking_open_result result;
939+
940+
ter_id new_ter_type = t_null;
941+
furn_id new_furn_type = f_null;
942+
std::string open_message;
943+
if( ter_type == t_chaingate_l ) {
944+
new_ter_type = t_chaingate_c;
945+
open_message = _( "With a satisfying click, the chain-link gate opens." );
946+
} else if( ter_type == t_door_locked || ter_type == t_door_locked_alarm ||
947+
ter_type == t_door_locked_interior ) {
948+
new_ter_type = t_door_c;
949+
open_message = _( "With a satisfying click, the lock on the door opens." );
950+
} else if( ter_type == t_door_locked_peep ) {
951+
new_ter_type = t_door_c_peep;
952+
open_message = _( "With a satisfying click, the lock on the door opens." );
953+
} else if( ter_type == t_door_metal_pickable ) {
954+
new_ter_type = t_door_metal_c;
955+
open_message = _( "With a satisfying click, the lock on the door opens." );
956+
} else if( ter_type == t_door_bar_locked ) {
957+
new_ter_type = t_door_bar_o;
958+
//Bar doors auto-open (and lock if closed again) so show a different message)
959+
open_message = _( "The door swings open…" );
960+
} else if( furn_type == f_gunsafe_ml ) {
961+
new_furn_type = f_safe_o;
962+
open_message = _( "With a satisfying click, the lock on the door opens." );
963+
}
964+
965+
result.new_ter_type = new_ter_type;
966+
result.new_furn_type = new_furn_type;
967+
result.open_message = open_message;
968+
return result;
969+
}
970+
936971
furn_id f_null,
937972
f_hay,
938973
f_rubble, f_rubble_rock, f_wreckage, f_ash,

src/mapdata.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ struct plant_data {
9494
bool load( const JsonObject &jsobj, const std::string &member );
9595
};
9696

97+
struct lockpicking_open_result {
98+
ter_id new_ter_type;
99+
furn_id new_furn_type;
100+
std::string open_message;
101+
};
102+
97103
/*
98104
* List of known flags, used in both terrain.json and furniture.json.
99105
* TRANSPARENT - Players and monsters can see through/past it. Also sets ter_t.transparent
@@ -349,6 +355,8 @@ struct ter_t : map_data_common_t {
349355
void set_ter_ids();
350356
void finalize_furn();
351357
void reset_furn_ter();
358+
/** Gets lockpicked object and message */
359+
lockpicking_open_result get_lockpicking_open_result( ter_id ter_type, furn_id furn_type );
352360

353361
/*
354362
* The terrain list contains the master list of information and metadata for a given type of terrain.

0 commit comments

Comments
 (0)