Skip to content

Commit

Permalink
Fix for Fingerpick CBM does not work (CleverRaven#55)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
Firestorm01X2 and Coolthulhu authored Sep 15, 2020
1 parent 439c606 commit 5f6a4a4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 28 deletions.
30 changes: 6 additions & 24 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2568,30 +2568,12 @@ void activity_handlers::lockpicking_finish( player_activity *act, player *p )

const ter_id ter_type = g->m.ter( act->placement );
const furn_id furn_type = g->m.furn( act->placement );
ter_id new_ter_type;
furn_id new_furn_type;
std::string open_message;
if( ter_type == t_chaingate_l ) {
new_ter_type = t_chaingate_c;
open_message = _( "With a satisfying click, the chain-link gate opens." );
} else if( ter_type == t_door_locked || ter_type == t_door_locked_alarm ||
ter_type == t_door_locked_interior ) {
new_ter_type = t_door_c;
open_message = _( "With a satisfying click, the lock on the door opens." );
} else if( ter_type == t_door_locked_peep ) {
new_ter_type = t_door_c_peep;
open_message = _( "With a satisfying click, the lock on the door opens." );
} else if( ter_type == t_door_metal_pickable ) {
new_ter_type = t_door_metal_c;
open_message = _( "With a satisfying click, the lock on the door opens." );
} else if( ter_type == t_door_bar_locked ) {
new_ter_type = t_door_bar_o;
//Bar doors auto-open (and lock if closed again) so show a different message)
open_message = _( "The door swings open…" );
} else if( furn_type == f_gunsafe_ml ) {
new_furn_type = f_safe_o;
open_message = _( "With a satisfying click, the lock on the door opens." );
} else {
lockpicking_open_result lr = get_lockpicking_open_result( ter_type, furn_type );
ter_id new_ter_type = lr.new_ter_type;
furn_id new_furn_type = lr.new_furn_type;
std::string open_message = lr.open_message;

if( new_ter_type == t_null && new_furn_type == f_null ) {
act->set_to_null();
}

Expand Down
24 changes: 20 additions & 4 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,21 +751,37 @@ bool Character::activate_bionic( int b, bool eff_only )

mod_moves( -100 );
} else if( bio.id == bio_lockpick ) {
tmp_item = item( "pseudo_bio_picklock", 0 );
g->refresh_all();
int charges = tmp_item.charges;
bool used = false;
if( invoke_item( &tmp_item ) ) {
if( tmp_item.charges != charges ) {
bool tried_lockpick = false;
const cata::optional<tripoint> pnt = choose_adjacent( _( "Use your lockpick where?" ) );
std::string open_message;
if( pnt ) {
tried_lockpick = true;
ter_id ter_type = g->m.ter( *pnt );
furn_id furn_type = g->m.furn( *pnt );
lockpicking_open_result lr = get_lockpicking_open_result( ter_type, furn_type );
ter_id new_ter_type = lr.new_ter_type;
furn_id new_furn_type = lr.new_furn_type;
open_message = lr.open_message;

if( new_ter_type != t_null || new_furn_type != f_null ) {
g->m.has_furn( *pnt ) ?
g->m.furn_set( *pnt, new_furn_type ) :
static_cast<void>( g->m.ter_set( *pnt, new_ter_type ) );
used = true;
}
}

if( used ) {
add_msg_activate();
add_msg_if_player( m_good, open_message );
mod_moves( -100 );
} else {
refund_power();
if( tried_lockpick ) {
add_msg_if_player( m_info, _( "There is nothing to lockpick nearby." ) );
}
return false;
}
} else if( bio.id == bio_flashbang ) {
Expand Down
35 changes: 35 additions & 0 deletions src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,41 @@ void reset_furn_ter()
furniture_data.reset();
}

lockpicking_open_result get_lockpicking_open_result( ter_id ter_type, furn_id furn_type )
{
lockpicking_open_result result;

ter_id new_ter_type = t_null;
furn_id new_furn_type = f_null;
std::string open_message;
if( ter_type == t_chaingate_l ) {
new_ter_type = t_chaingate_c;
open_message = _( "With a satisfying click, the chain-link gate opens." );
} else if( ter_type == t_door_locked || ter_type == t_door_locked_alarm ||
ter_type == t_door_locked_interior ) {
new_ter_type = t_door_c;
open_message = _( "With a satisfying click, the lock on the door opens." );
} else if( ter_type == t_door_locked_peep ) {
new_ter_type = t_door_c_peep;
open_message = _( "With a satisfying click, the lock on the door opens." );
} else if( ter_type == t_door_metal_pickable ) {
new_ter_type = t_door_metal_c;
open_message = _( "With a satisfying click, the lock on the door opens." );
} else if( ter_type == t_door_bar_locked ) {
new_ter_type = t_door_bar_o;
//Bar doors auto-open (and lock if closed again) so show a different message)
open_message = _( "The door swings open…" );
} else if( furn_type == f_gunsafe_ml ) {
new_furn_type = f_safe_o;
open_message = _( "With a satisfying click, the lock on the door opens." );
}

result.new_ter_type = new_ter_type;
result.new_furn_type = new_furn_type;
result.open_message = open_message;
return result;
}

furn_id f_null,
f_hay,
f_rubble, f_rubble_rock, f_wreckage, f_ash,
Expand Down
8 changes: 8 additions & 0 deletions src/mapdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ struct plant_data {
bool load( const JsonObject &jsobj, const std::string &member );
};

struct lockpicking_open_result {
ter_id new_ter_type;
furn_id new_furn_type;
std::string open_message;
};

/*
* List of known flags, used in both terrain.json and furniture.json.
* TRANSPARENT - Players and monsters can see through/past it. Also sets ter_t.transparent
Expand Down Expand Up @@ -349,6 +355,8 @@ struct ter_t : map_data_common_t {
void set_ter_ids();
void finalize_furn();
void reset_furn_ter();
/** Gets lockpicked object and message */
lockpicking_open_result get_lockpicking_open_result( ter_id ter_type, furn_id furn_type );

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

0 comments on commit 5f6a4a4

Please sign in to comment.