Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix-up prying until builds + works #1

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions data/json/furniture_and_terrain/furniture-storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@
{ "item": "nail", "charges": [ 2, 10 ] },
{ "item": "rag", "count": [ 8, 12 ] }
]
},
"pry": {
"success_message": "You wedge open the coffin.",
"fail_message": "You pry, but the coffin remains closed.",
"pry_quality": 2,
"noisy": true,
"noise": 12,
"difficulty": 5,
"new_furn_type": "f_coffin_o"
}
},
{
Expand Down Expand Up @@ -164,6 +173,15 @@
"sound": "smash!",
"sound_fail": "wham!",
"items": [ { "item": "2x4", "count": [ 1, 5 ] }, { "item": "nail", "charges": [ 2, 10 ] } ]
},
"pry": {
"success_message": "You pop open the crate.",
"fail_message": "You pry, but cannot pop open the crate.",
"pry_quality": 1,
"noisy": true,
"noise": 12,
"difficulty": 5,
"new_furn_type": "f_crate_o"
}
},
{
Expand Down
36 changes: 36 additions & 0 deletions data/json/furniture_and_terrain/terrain-doors.json
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,15 @@
{ "item": "splinter", "count": [ 1, 2 ] },
{ "item": "nail", "charges": [ 0, 2 ] }
]
},
"pry": {
"success_message": "You pry open the door.",
"fail_message": "You pry, but cannot pry open the door.",
"pry_quality": 2,
"noisy": true,
"noise": 12,
"difficulty": 6,
"new_ter_type": "t_door_o"
}
},
{
Expand Down Expand Up @@ -1446,6 +1455,15 @@
{ "item": "splinter", "count": [ 1, 2 ] },
{ "item": "nail", "charges": [ 0, 2 ] }
]
},
"pry": {
"success_message": "You pry open the door.",
"fail_message": "You pry, but cannot pry open the door.",
"pry_quality": 2,
"noisy": true,
"noise": 12,
"difficulty": 6,
"new_ter_type": "t_door_o"
}
},
{
Expand Down Expand Up @@ -1485,6 +1503,15 @@
{ "item": "splinter", "count": [ 1, 2 ] },
{ "item": "nail", "charges": [ 0, 2 ] }
]
},
"pry": {
"success_message": "You pry open the door.",
"fail_message": "You pry, but cannot pry open the door.",
"pry_quality": 2,
"noisy": true,
"noise": 12,
"difficulty": 6,
"new_ter_type": "t_door_o_peep"
}
},
{
Expand Down Expand Up @@ -1514,6 +1541,15 @@
{ "item": "splinter", "count": [ 1, 2 ] },
{ "item": "nail", "charges": [ 0, 2 ] }
]
},
"pry": {
"success_message": "You pry open the door.",
"fail_message": "You pry, but cannot pry open the door.",
"pry_quality": 2,
"noisy": true,
"noise": 12,
"difficulty": 6,
"new_ter_type": "t_door_o"
}
},
{
Expand Down
49 changes: 49 additions & 0 deletions data/json/furniture_and_terrain/terrain-windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@
{ "item": "stick", "count": 1 },
{ "item": "string_36", "count": 1 }
]
},
"pry": {
"success_message": "You pry open the window.",
"fail_message": "You pry, but cannot pry open the window.",
"break_message": "You break the glass.",
"pry_quality": 2,
"noisy": true,
"noise": 12,
"break_noise": 24,
"difficulty": 6,
"new_ter_type": "t_window_open",
"breakable": true,
"break_ter_type": "t_window_frame",
"break_items": [
{ "item": "sheet", "count": 2 },
{ "item": "stick", "count": 1 },
{ "item": "string_36", "count": 1 }
]
}
},
{
Expand Down Expand Up @@ -125,6 +143,20 @@
"sound_fail_vol": 10,
"ter_set": "t_window_frame",
"items": [ { "item": "glass_shard", "count": [ 21, 29 ] } ]
},
"pry": {
"success_message": "You pry open the window.",
"fail_message": "You pry, but cannot pry open the window.",
"pry_quality": 2,
"noisy": true,
"noise": 12,
"difficulty": 6,
"new_ter_type": "t_window_no_curtains_open",
"breakable": true,
"break_ter_type": "t_window_frame",
"break_items": [
{ "item": "stick", "count": 1 }
]
}
},
{
Expand Down Expand Up @@ -296,6 +328,23 @@
{ "item": "stick", "count": 1 },
{ "item": "string_36", "count": 1 }
]
},
"pry": {
"success_message": "You pry open the window.",
"fail_message": "You pry, but cannot pry open the window.",
"pry_quality": 2,
"noisy": true,
"noise": 12,
"break_noise": 24,
"difficulty": 6,
"new_ter_type": "t_window_open",
"breakable": true,
"break_ter_type": "t_window_frame",
"break_items": [
{ "item": "sheet", "count": 2 },
{ "item": "stick", "count": 1 },
{ "item": "string_36", "count": 1 }
]
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@
"symbol": "0",
"color": "dark_gray",
"move_cost": 2,
"flags": [ "TRANSPARENT" ]
"flags": [ "TRANSPARENT" ],
"pry": {
"success_message": "You lift the manhole cover.",
"fail_message": "You pry, but cannot lift the manhole cover.",
"pry_quality": 1,
"difficulty": 4,
"new_ter_type": "t_manhole"
}
},
{
"type": "terrain",
Expand Down
76 changes: 45 additions & 31 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2330,38 +2330,52 @@ int iuse::crowbar( player *p, item *it, bool, const tripoint &pos )
return 0;
}
const pry_result *pry = nullptr;
bool pry_furn;

const std::function<bool(const tripoint&)> can_pry = [&p](const tripoint& pnt) {
if ( pnt == p->pos() ) {
return false;
}
const ter_id ter = g->m.ter(pnt);
const furn_id furn = g->m.furn(pnt);

const bool is_allowed = ter->pry.pry_quality != -1 || furn->pry.pry_quality != -1;
return is_allowed;
};

const cata::optional<tripoint> pnt_ = ( pos != p->pos() ) ? pos : choose_adjacent_highlight(
_( "Pry where?" ), _( "There is nothing to pry nearby." ), pos, false );
_( "Pry where?" ), _( "There is nothing to pry nearby." ), can_pry, false );
if( !pnt_ ) {
return 0;
}
const tripoint &pnt = *pnt_;
const ter_id ter = g->m.ter( pnt );
const furn_id furn = g->m.furn( pnt );
if( !pos( pnt ) ) {

if( !can_pry( pnt ) ) {
if( pnt == p->pos() ) {
p->add_msg_if_player( m_info, _( "You attempt to pry open your wallet "
"but alas. You are just too miserly." ) );
} if (ter->pry.new_ter_type || furn->pry.new_furn_type) {
if (pos == g->u.pos()) {
return false;
}

const bool is_allowed = false;
if (furn.obj().pry.pry_quality != -1) {
pry = &ter.obj().pry;
pry_furn = true;
return 0;
}
else if (ter.obj().pry.pry_quality != -1) {
pry = &ter.obj().pry;
return 0;
}
} else {
p->add_msg_if_player(m_info, _("You can't pry that."));
}
else if ( !ter->has_flag("LOCKED") && ter->open ) {
p->add_msg_if_player(m_info, _( "You notice the door is unlocked, so you simply open it." ));
g->m.ter_set( pnt, ter->open );
}
else {
p->add_msg_if_player( m_info, _( "You can't pry that." ) );
}

return 0;
}

if ( furn->pry.pry_quality != -1 ) {
pry_furn = true;
pry = &furn->pry;
}
else {
pry_furn = false;
pry = &ter->pry;
}

// Doors need PRY 2 which is on a crowbar, crates need PRY 1 which is on a crowbar
// & a claw hammer.
Expand Down Expand Up @@ -2390,17 +2404,17 @@ int iuse::crowbar( player *p, item *it, bool, const tripoint &pos )
if( dice( 4, diff ) < dice( 4, p->str_cur ) ) {
p->add_msg_if_player( m_good, pry->success_message );

if( pry_furn = true ) {
g->m.ter_set( pnt, pry->new_furn_type );
if( pry_furn == true ) {
g->m.furn_set( pnt, pry->new_furn_type );
} else {
g->m.ter_set( pnt, pry->new_ter_type );
}

if( pry->noise > 0 ) {
sounds::sound( pnt, pry->noise, sounds::sound_t::combat, pry->sound, true, "tool", "crowbar" );
}
g->m.spawn_items( pnt, item_group::items_from( pry.pry_items, calendar::turn ) );
if( pry->alarm = true ) {
g->m.spawn_items( pnt, item_group::items_from( pry->pry_items, calendar::turn ) );
if( pry->alarm == true ) {
g->events().send<event_type::triggers_alarm>( p->getID() );
sounds::sound( p->pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), true, "environment",
"alarm" );
Expand All @@ -2410,22 +2424,22 @@ int iuse::crowbar( player *p, item *it, bool, const tripoint &pos )
}
}
} else {
if( pry->breakable = true ) {
if( pry->breakable == true ) {
//chance of breaking the glass if pry attempt fails
/** @EFFECT_STR reduces chance of breaking window with crowbar */

/** @EFFECT_MECHANICS reduces chance of breaking window with crowbar */
if( dice( 4, diff ) > dice( 2, p->get_skill_level( skill_mechanics ) ) + dice( 2,
p->str_cur ) ) {
p->add_msg_if_player( m_mixed, pry->breakage_message );
sounds::sound( pnt, pry->noise, sounds::sound_t::combat, pry->breakage_message, true, "smash", "door" );
if( pry_furn = true ) {
g->m.ter_set( pnt, pry->breakage_furn_type );
p->add_msg_if_player( m_mixed, pry->break_message );
sounds::sound( pnt, pry->break_noise, sounds::sound_t::combat, pry->break_sound, true, "smash", "door" );
if( pry_furn == true ) {
g->m.furn_set( pnt, pry->break_furn_type );
} else {
g->m.ter_set( pnt, pry->breakage_ter_type );
g->m.ter_set( pnt, pry->break_ter_type );
}
g->m.spawn_items( pnt, item_group::items_from( pry.break_items, calendar::turn ) );
if( alarm = true ) {
g->m.spawn_items( pnt, item_group::items_from( pry->break_items, calendar::turn ) );
if( pry->alarm == true ) {
g->events().send<event_type::triggers_alarm>( p->getID() );
sounds::sound( p->pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), true, "environment",
"alarm" );
Expand Down
Loading