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

Portable smoking rack #29915

Merged
merged 19 commits into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
44 changes: 44 additions & 0 deletions data/json/furniture.json
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,50 @@
"items": [ { "item": "rock", "count": 8 }, { "item": "stick", "count": [ 8, 12 ] } ]
}
},
{
"type": "furniture",
"id": "f_metal_smoking_rack",
"name": "metal smoking rack",
"description": "A special rack designed to smoke food for better preservation and taste.",
"symbol": "=",
"bgcolor": "light_gray",
"move_cost_mod": 2,
"required_str": -1,
"deployed_item": "metal_smoking_rack",
"flags": [ "TRANSPARENT", "SEALED", "ALLOW_FIELD_EFFECT", "CONTAINER", "NOITEM", "EASY_DECONSTRUCT", "MINEABLE" ],
"crafting_pseudo_item": "char_smoker",
"examine_action": "smoker_options",
"deconstruct": { "items": [ { "item": "metal_smoking_rack", "count": 1 } ] },
"bash": {
"str_min": 18,
"str_max": 50,
"sound": "metal screeching!",
"sound_fail": "clang!",
"items": [ { "item": "scrap", "count": 4 }, { "item": "pipe", "count": [ 3, 5 ] } ]
}
},
{
"type": "furniture",
"id": "f_metal_smoking_rack_active",
"name": "active metal smoking rack",
"description": "A special rack designed to smoke food for better preservation and taste.",
"symbol": "=",
"bgcolor": "light_gray",
"move_cost_mod": 2,
"required_str": -1,
"deployed_item": "metal_smoking_rack",
"flags": [ "TRANSPARENT", "SEALED", "ALLOW_FIELD_EFFECT", "CONTAINER", "NOITEM", "EASY_DECONSTRUCT", "MINEABLE" ],
"crafting_pseudo_item": "char_smoker",
"examine_action": "smoker_options",
"deconstruct": { "items": [ { "item": "metal_smoking_rack", "count": 1 } ] },
"bash": {
"str_min": 18,
"str_max": 50,
"sound": "metal screeching!",
"sound_fail": "clang!",
"items": [ { "item": "scrap", "count": 4 }, { "item": "pipe", "count": [ 3, 5 ] } ]
}
},
{
"type": "furniture",
"id": "f_forge_rock",
Expand Down
15 changes: 15 additions & 0 deletions data/json/items/tool/deployable.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@
"color": "light_gray",
"use_action": { "type": "deploy_furn", "furn_type": "f_metal_butcher_rack" }
},
{
"id": "metal_smoking_rack",
"type": "TOOL",
"name": "metal smoking rack",
"description": "A metal rack designed to smoke food for better preservation and taste. It is folded for easy transportation and can be deployed as a furniture.",
"weight": 5000,
"volume": 100,
"price": 5000,
"to_hit": -4,
"bashing": 7,
"material": [ "steel" ],
"symbol": "=",
"color": "light_gray",
"use_action": { "type": "deploy_furn", "furn_type": "f_metal_smoking_rack" }
},
{
"id": "tourist_table",
"type": "TOOL",
Expand Down
27 changes: 26 additions & 1 deletion data/json/recipes/recipe_others.json
Original file line number Diff line number Diff line change
Expand Up @@ -4289,7 +4289,7 @@
"subcategory": "CSC_OTHER_TOOLS",
"skill_used": "fabrication",
"difficulty": 4,
"time": 8000,
"time": 30000,
"autolearn": true,
"book_learn": [ [ "textbook_fabrication", 2 ], [ "textbook_mechanics", 3 ] ],
"qualities": [
Expand All @@ -4308,6 +4308,31 @@
[ [ "spike", 2 ] ]
]
},
{
"type": "recipe",
"result": "metal_smoking_rack",
"category": "CC_OTHER",
"subcategory": "CSC_OTHER_TOOLS",
"skill_used": "fabrication",
"difficulty": 4,
"time": 30000,
"autolearn": true,
"book_learn": [ [ "textbook_fabrication", 2 ], [ "textbook_mechanics", 3 ] ],
"qualities": [
{ "id": "ANVIL", "level": 1 },
{ "id": "HAMMER", "level": 3 },
{ "id": "SAW_M", "level": 1 },
{ "id": "DRILL", "level": 1 },
{ "id": "SCREW", "level": 1 }
],
"components": [
[ [ "scrap", 6 ] ],
[ [ "pipe", 15 ], [ "cu_pipe", 15 ], [ "frame", 2 ] ],
[ [ "nail", 12 ] ],
[ [ "wire", 6 ], [ "rope_6", 6 ], [ "rope_makeshift_6", 6 ] ],
[ [ "spike", 4 ] ]
]
},
{
"type": "recipe",
"result": "tourist_table",
Expand Down
93 changes: 75 additions & 18 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4210,6 +4210,7 @@ namespace sm_rack
const int MIN_CHARCOAL = 100;
const int CHARCOAL_PER_LITER = 25;
const units::volume MAX_FOOD_VOLUME = units::from_liter( 20 );
const units::volume MAX_FOOD_VOLUME_PORTABLE = units::from_liter( 15 );
}

static int get_charcoal_charges( units::volume food )
Expand Down Expand Up @@ -4294,8 +4295,12 @@ void smoker_activate( player &p, const tripoint &examp )
{
furn_id cur_smoker_type = g->m.furn( examp );
furn_id next_smoker_type = f_null;
const bool portable = g->m.furn( examp ) == furn_str_id( "f_metal_smoking_rack" ) ||
g->m.furn( examp ) == furn_str_id( "f_metal_smoking_rack_active" );
if( cur_smoker_type == f_smoking_rack ) {
next_smoker_type = f_smoking_rack_active;
} else if( cur_smoker_type == f_metal_smoking_rack ) {
next_smoker_type = f_metal_smoking_rack_active;
} else {
debugmsg( "Examined furniture has action smoker_activate, but is of type %s",
g->m.furn( examp ).id().c_str() );
Expand Down Expand Up @@ -4344,7 +4349,12 @@ void smoker_activate( player &p, const tripoint &examp )
add_msg( _( "There is no charcoal in the rack." ) );
return;
}
if( food_volume > sm_rack::MAX_FOOD_VOLUME ) {
if( portable && food_volume > sm_rack::MAX_FOOD_VOLUME_PORTABLE ) {
add_msg( _( "This rack is overloaded with food, and it blocks the flow of smoke. Remove some and try again." ) );
add_msg( _( "You think that you can load about %s %s in it." ),
format_volume( sm_rack::MAX_FOOD_VOLUME_PORTABLE ), volume_units_long() );
return;
} else if( food_volume > sm_rack::MAX_FOOD_VOLUME ) {
add_msg( _( "This rack is overloaded with food, and it blocks the flow of smoke. Remove some and try again." ) );
add_msg( _( "You think that you can load about %s %s in it." ),
format_volume( sm_rack::MAX_FOOD_VOLUME ), volume_units_long() );
Expand Down Expand Up @@ -4432,6 +4442,8 @@ void smoker_finalize( player &, const tripoint &examp, const time_point &start_t
furn_id next_smoker_type = f_null;
if( cur_smoker_type == f_smoking_rack_active ) {
next_smoker_type = f_smoking_rack;
} else if( cur_smoker_type == f_metal_smoking_rack_active ) {
next_smoker_type = f_metal_smoking_rack;
} else {
debugmsg( "Furniture executed action smoker_finalize, but is of type %s",
g->m.furn( examp ).id().c_str() );
Expand Down Expand Up @@ -4473,7 +4485,8 @@ void smoker_load_food( player &p, const tripoint &examp, const units::volume &re
{
std::vector<item_comp> comps;

if( g->m.furn( examp ) == furn_str_id( "f_smoking_rack_active" ) ) {
if( g->m.furn( examp ) == furn_str_id( "f_smoking_rack_active" ) ||
g->m.furn( examp ) == furn_str_id( "f_metal_smoking_rack_active" ) ) {
p.add_msg_if_player( _( "You can't place more food while it's smoking." ) );
return;
}
Expand Down Expand Up @@ -4688,7 +4701,8 @@ void mill_load_food( player &p, const tripoint &examp, const units::volume &rema

void iexamine::on_smoke_out( const tripoint &examp, const time_point &start_time )
{
if( g->m.furn( examp ) == furn_str_id( "f_smoking_rack_active" ) ) {
if( g->m.furn( examp ) == furn_str_id( "f_smoking_rack_active" ) ||
g->m.furn( examp ) == furn_str_id( "f_metal_smoking_rack_active" ) ) {
smoker_finalize( g->u, examp, start_time );
}
}
Expand Down Expand Up @@ -4875,16 +4889,27 @@ void iexamine::quern_examine( player &p, const tripoint &examp )

void iexamine::smoker_options( player &p, const tripoint &examp )
{
bool active = g->m.furn( examp ) == furn_str_id( "f_smoking_rack_active" );
const bool active = g->m.furn( examp ) == furn_str_id( "f_smoking_rack_active" ) ||
g->m.furn( examp ) == furn_str_id( "f_metal_smoking_rack_active" );
const bool portable = g->m.furn( examp ) == furn_str_id( "f_metal_smoking_rack" ) ||
g->m.furn( examp ) == furn_str_id( "f_metal_smoking_rack_active" );
auto items_here = g->m.i_at( examp );

if( items_here.empty() && active ) {
if( portable && items_here.empty() && active ) {
debugmsg( "f_metal_smoking_rack_active was empty!" );
g->m.furn_set( examp, f_metal_smoking_rack );
return;
} else if( items_here.empty() && active ) {
debugmsg( "f_smoking_rack_active was empty!" );
g->m.furn_set( examp, f_smoking_rack );
return;
}

if( items_here.size() == 1 && items_here.begin()->typeId() == "fake_smoke_plume" ) {
if( portable && items_here.size() == 1 && items_here.begin()->typeId() == "fake_smoke_plume" ) {
debugmsg( "f_metal_smoking_rack_active was empty, and had fake_smoke_plume!" );
g->m.furn_set( examp, f_metal_smoking_rack );
items_here.erase( items_here.begin() );
return;
} else if( items_here.size() == 1 && items_here.begin()->typeId() == "fake_smoke_plume" ) {
debugmsg( "f_smoking_rack_active was empty, and had fake_smoke_plume!" );
g->m.furn_set( examp, f_smoking_rack );
items_here.erase( items_here.begin() );
Expand Down Expand Up @@ -4914,7 +4939,9 @@ void iexamine::smoker_options( player &p, const tripoint &examp )

const bool empty = f_volume == 0_ml;
const bool full = f_volume >= sm_rack::MAX_FOOD_VOLUME;
const bool full_portable = f_volume >= sm_rack::MAX_FOOD_VOLUME_PORTABLE;
const auto remaining_capacity = sm_rack::MAX_FOOD_VOLUME - f_volume;
const auto remaining_capacity_portable = sm_rack::MAX_FOOD_VOLUME_PORTABLE - f_volume;
const auto has_coal_in_inventory = p.charges_of( "charcoal" ) > 0;
const auto coal_charges = count_charges_in_list( item::find_type( "charcoal" ), items_here );
const auto need_charges = get_charcoal_charges( f_volume );
Expand All @@ -4935,12 +4962,24 @@ void iexamine::smoker_options( player &p, const tripoint &examp )
need_charges - coal_charges ) :
_( "Light up and smoke food" ),
_( "Light up the smoking rack and start smoking. Smoking will take about 6 hours." ) );
if( portable ) {
smenu.addentry_desc( 2, !full_portable, 'f',
full_portable ? _( "Insert food for smoking... smoking rack is full" ) :
string_format( _( "Insert food for smoking... remaining capacity is %s %s" ),
format_volume( remaining_capacity_portable ), volume_units_abbr() ),
_( "Fill the smoking rack with raw meat, fish or sausages for smoking or fruit or vegetable or smoked meat for drying." ) );

smenu.addentry_desc( 2, !full, 'f',
full ? _( "Insert food for smoking... smoking rack is full" ) :
string_format( _( "Insert food for smoking... remaining capacity is %s %s" ),
format_volume( remaining_capacity ), volume_units_abbr() ),
_( "Fill the smoking rack with raw meat, fish or sausages for smoking or fruit or vegetable or smoked meat for drying." ) );
smenu.addentry_desc( 8, !active, 'z',
active ? _( "You cannot disassemble this smoking rack while it is active!" ) :
_( "Disassemble the smoking rack" ), _( "" ) );

} else {
smenu.addentry_desc( 2, !full, 'f',
full ? _( "Insert food for smoking... smoking rack is full" ) :
string_format( _( "Insert food for smoking... remaining capacity is %s %s" ),
format_volume( remaining_capacity ), volume_units_abbr() ),
_( "Fill the smoking rack with raw meat, fish or sausages for smoking or fruit or vegetable or smoked meat for drying." ) );
}

if( f_check ) {
smenu.addentry( 4, f_check, 'e', _( "Remove food from smoking rack" ) );
Expand All @@ -4953,6 +4992,7 @@ void iexamine::smoker_options( player &p, const tripoint &examp )
_( "You need %d charges of charcoal for %s %s of food. Minimal amount of charcoal is %d charges." ),
sm_rack::CHARCOAL_PER_LITER, format_volume( 1000_ml ), volume_units_long(),
sm_rack::MIN_CHARCOAL ) );

} else {
smenu.addentry_desc( 7, true, 'x',
_( "Quench burning charcoal" ),
Expand All @@ -4979,9 +5019,10 @@ void iexamine::smoker_options( player &p, const tripoint &examp )
"It will finish smoking in about %d hours.",
hours_left ), hours_left ) << "\n \n ";
} else if( minutes_left > 30 ) {
pop << _( "It will finish smoking in less than an hour." );
pop << _( "It will finish smoking in less than an hour." ) << "\n ";
} else {
pop << string_format( _( "It should take about %d minutes to finish smoking." ), minutes_left );
pop << string_format( _( "It should take about %d minutes to finish smoking." ),
minutes_left ) << "\n ";
}
}
} else {
Expand Down Expand Up @@ -5013,7 +5054,11 @@ void iexamine::smoker_options( player &p, const tripoint &examp )
}
break;
case 2: // load food
smoker_load_food( p, examp, remaining_capacity );
if( portable ) {
smoker_load_food( p, examp, remaining_capacity_portable );
} else {
smoker_load_food( p, examp, remaining_capacity );
}
break;
case 3: // load charcoal
reload_furniture( p, examp );
Expand All @@ -5035,7 +5080,10 @@ void iexamine::smoker_options( player &p, const tripoint &examp )
i--;
}
}
if( active && rem_f_opt ) {
if( portable && active && rem_f_opt ) {
g->m.furn_set( examp, f_metal_smoking_rack );
add_msg( m_info, _( "You stop the smoking process." ) );
} else if( active && rem_f_opt ) {
g->m.furn_set( examp, f_smoking_rack );
add_msg( m_info, _( "You stop the smoking process." ) );
}
Expand All @@ -5045,8 +5093,17 @@ void iexamine::smoker_options( player &p, const tripoint &examp )
add_msg( m_info, _( "Never mind." ) );
break;
case 7:
g->m.furn_set( examp, f_smoking_rack );
add_msg( m_info, _( "You stop the smoking process." ) );
if( portable ) {
g->m.furn_set( examp, f_metal_smoking_rack );
add_msg( m_info, _( "You stop the smoking process." ) );
} else {
g->m.furn_set( examp, f_smoking_rack );
add_msg( m_info, _( "You stop the smoking process." ) );
}
break;
case 8:
g->m.furn_set( examp, f_metal_smoking_rack );
deployed_furniture( p, examp );
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7469,7 +7469,8 @@ bool item::process_fake_mill( player * /*carrier*/, const tripoint &pos )

bool item::process_fake_smoke( player * /*carrier*/, const tripoint &pos )
{
if( g->m.furn( pos ) != furn_str_id( "f_smoking_rack_active" ) ) {
if( g->m.furn( pos ) != furn_str_id( "f_smoking_rack_active" ) &&
g->m.furn( pos ) != furn_str_id( "f_metal_smoking_rack_active" ) ) {
item_counter = 0;
return true; //destroy fake smoke
}
Expand Down
4 changes: 3 additions & 1 deletion src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ furn_id f_null,
f_floor_canvas,
f_tatami,
f_kiln_empty, f_kiln_full, f_kiln_metal_empty, f_kiln_metal_full,
f_smoking_rack, f_smoking_rack_active,
f_smoking_rack, f_smoking_rack_active, f_metal_smoking_rack, f_metal_smoking_rack_active,
f_water_mill, f_water_mill_active,
f_wind_mill, f_wind_mill_active,
f_robotic_arm, f_vending_reinforced,
Expand Down Expand Up @@ -1029,6 +1029,8 @@ void set_furn_ids()
f_kiln_metal_full = furn_id( "f_kiln_metal_full" );
f_smoking_rack = furn_id( "f_smoking_rack" );
f_smoking_rack_active = furn_id( "f_smoking_rack_active" );
f_metal_smoking_rack = furn_id( "f_metal_smoking_rack" );
f_metal_smoking_rack_active = furn_id( "f_metal_smoking_rack_active" );
f_water_mill = furn_id( "f_water_mill" );
f_water_mill_active = furn_id( "f_water_mill_active" );
f_wind_mill = furn_id( "f_wind_mill" );
Expand Down
2 changes: 1 addition & 1 deletion src/mapdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ extern furn_id f_null,
f_flower_marloss,
f_tatami,
f_kiln_empty, f_kiln_full, f_kiln_metal_empty, f_kiln_metal_full,
f_smoking_rack, f_smoking_rack_active,
f_smoking_rack, f_smoking_rack_active, f_metal_smoking_rack, f_metal_smoking_rack_active,
f_water_mill, f_water_mill_active,
f_wind_mill, f_wind_mill_active,
f_robotic_arm, f_vending_reinforced,
Expand Down