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

Enable butchering of very heavy corpses #62326

Merged
merged 1 commit into from
Nov 23, 2022
Merged
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
48 changes: 32 additions & 16 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,35 @@ static double butchery_dissect_yield_mult( int skill_level, int dex, int tool_qu
0.2 * clamp( dex_score, 0.0, 1.0 );
}

static std::vector<item> create_charge_items( const itype *drop, int count,
const harvest_entry &entry, const item *corpse_item, const Character &you )
{
std::vector<item> objs;
while( count > 0 ) {
item obj( drop, calendar::turn, 1 );
obj.charges = std::min( count, 1000_liter / obj.volume() );
count -= obj.charges;

if( obj.has_temperature() ) {
obj.set_item_temperature( corpse_item->temperature );
if( obj.goes_bad() ) {
obj.set_rot( corpse_item->get_rot() );
}
}
for( const flag_id &flg : entry.flags ) {
obj.set_flag( flg );
}
for( const fault_id &flt : entry.faults ) {
obj.faults.emplace( flt );
}
if( !you.backlog.empty() && you.backlog.front().id() == ACT_MULTIPLE_BUTCHER ) {
obj.set_var( "activity_var", you.name );
}
objs.push_back( obj );
}
return objs;
}

// Returns false if the calling function should abort
static bool butchery_drops_harvest( item *corpse_item, const mtype &mt, Character &you,
butcher_type action )
Expand Down Expand Up @@ -948,23 +977,10 @@ static bool butchery_drops_harvest( item *corpse_item, const mtype &mt, Characte
liquid_handler::handle_all_liquid( obj, 1 );
}
} else if( drop->count_by_charges() ) {
item obj( drop, calendar::turn, roll );
if( obj.has_temperature() ) {
obj.set_item_temperature( corpse_item->temperature );
if( obj.goes_bad() ) {
obj.set_rot( corpse_item->get_rot() );
}
}
for( const flag_id &flg : entry.flags ) {
obj.set_flag( flg );
}
for( const fault_id &flt : entry.faults ) {
obj.faults.emplace( flt );
}
if( !you.backlog.empty() && you.backlog.front().id() == ACT_MULTIPLE_BUTCHER ) {
obj.set_var( "activity_var", you.name );
std::vector<item> objs = create_charge_items( drop, roll, entry, corpse_item, you );
for( item &obj : objs ) {
here.add_item_or_charges( you.pos(), obj );
}
here.add_item_or_charges( you.pos(), obj );
} else {
item obj( drop, calendar::turn );
obj.set_mtype( &mt );
Expand Down