diff --git a/data/json/harvest.json b/data/json/harvest.json index c3609a287ac2..64e3e28e760e 100644 --- a/data/json/harvest.json +++ b/data/json/harvest.json @@ -118,8 +118,8 @@ { "drop": "lung", "type": "flesh", "mass_ratio": 0.0035 }, { "drop": "liver", "type": "offal", "mass_ratio": 0.01 }, { "drop": "brain", "type": "flesh", "mass_ratio": 0.005 }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_fur", "type": "skin", "mass_ratio": 0.13 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -138,8 +138,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_fur", "type": "skin", "mass_ratio": 0.08 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.075 } ] @@ -158,8 +158,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_fur", "type": "skin", "mass_ratio": 0.04 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -171,8 +171,8 @@ "entries": [ { "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.34 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hfur", "type": "skin", "mass_ratio": 0.02 }, { "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -185,8 +185,8 @@ { "drop": "cyborg_harvest_uncommon", "type": "bionic_group", "faults": [ "fault_bionic_nonsterile" ] }, { "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.34 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hfur", "type": "skin", "mass_ratio": 0.02 }, { "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -198,8 +198,8 @@ "entries": [ { "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.34 }, { "drop": "hstomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hfur", "type": "skin", "mass_ratio": 0.02 }, { "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -212,8 +212,8 @@ { "drop": "cyborg_harvest_uncommon", "type": "bionic_group", "faults": [ "fault_bionic_nonsterile" ] }, { "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.34 }, { "drop": "hstomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hfur", "type": "skin", "mass_ratio": 0.02 }, { "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -229,8 +229,8 @@ { "drop": "lung", "type": "flesh", "mass_ratio": 0.0035 }, { "drop": "liver", "type": "offal", "mass_ratio": 0.01 }, { "drop": "brain", "type": "flesh", "mass_ratio": 0.005 }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_leather", "type": "skin", "mass_ratio": 0.13 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -245,8 +245,8 @@ { "drop": "mutant_meat_scrap", "type": "flesh", "mass_ratio": 0.05 }, { "drop": "brain", "type": "flesh", "mass_ratio": 0.005 }, { "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_fur", "type": "skin", "mass_ratio": 0.02 }, { "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -265,8 +265,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_leather", "type": "skin", "mass_ratio": 0.08 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -282,8 +282,8 @@ { "drop": "brain", "type": "flesh", "mass_ratio": 0.005 }, { "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 }, { "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_leather", "type": "skin", "mass_ratio": 0.02 }, { "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -302,8 +302,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_leather", "type": "skin", "mass_ratio": 0.04 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -319,8 +319,8 @@ { "drop": "brain", "type": "flesh", "mass_ratio": 0.005 }, { "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 }, { "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_fur", "type": "skin", "mass_ratio": 0.02 }, { "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -339,8 +339,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_leather", "type": "skin", "mass_ratio": 0.04 }, { "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -376,8 +376,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "wool_staple", "type": "skin", "mass_ratio": 0.04 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -392,8 +392,8 @@ { "drop": "brain", "type": "flesh", "mass_ratio": 0.005 }, { "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 }, { "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.2 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.2 }, { "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 }, { "drop": "chitin_piece", "type": "skin", "mass_ratio": 0.1 } ] @@ -409,8 +409,8 @@ { "drop": "brain", "type": "flesh", "mass_ratio": 0.005 }, { "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 }, { "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_fur", "type": "skin", "mass_ratio": 0.02 }, { "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 } ] @@ -429,8 +429,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.07 } ] }, @@ -448,8 +448,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "fat", "type": "flesh", "mass_ratio": 0.07 } ] }, @@ -467,8 +467,8 @@ { "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 }, { "drop": "kidney", "type": "offal", "mass_ratio": 0.002 }, { "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, { "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 } ] }, @@ -557,8 +557,8 @@ { "drop": "mutant_meat", "type": "flesh", "mass_ratio": 0.2 }, { "drop": "meat_scrap", "type": "flesh", "mass_ratio": 0.1 }, { "drop": "stomach", "scale_num": [ 0, 1 ], "max": 1, "type": "offal" }, - { "drop": "bone", "type": "bone", "mass_ratio": 0.15 }, - { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 } + { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone", "type": "bone", "mass_ratio": 0.15 } ] }, { @@ -819,8 +819,8 @@ "//": "spooky scary skeletons", "type": "harvest", "entries": [ - { "drop": "bone_tainted", "type": "flesh", "mass_ratio": 0.5 }, - { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 } + { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_tainted", "type": "flesh", "mass_ratio": 0.5 } ] }, { @@ -832,8 +832,8 @@ { "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, { "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 } ] }, @@ -845,8 +845,8 @@ { "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.2 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, { "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.1 }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 } ] }, @@ -859,8 +859,8 @@ { "drop": "meat", "type": "flesh", "mass_ratio": 0.4 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, { "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_leather", "type": "skin", "mass_ratio": 0.03 }, { "drop": "raw_fur", "type": "skin", "mass_ratio": 0.001 } ] @@ -917,8 +917,8 @@ { "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, { "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 } ] }, @@ -955,8 +955,8 @@ { "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, { "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 } ] }, @@ -981,8 +981,8 @@ { "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, { "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 } ] }, @@ -1031,8 +1031,8 @@ { "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 }, { "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" }, { "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 }, - { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }, + { "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 }, { "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 } ] }, diff --git a/src/item.cpp b/src/item.cpp index 3b74bec83a33..54f91eebff5a 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -9919,11 +9919,15 @@ detached_ptr item::process_internal( detached_ptr &&self, player *ca } // All foods that go bad have temperature if( ( self->is_food() || self->is_corpse() ) ) { - bool comestible = self->is_comestible(); item &obj = *self; self = process_rot( std::move( self ), seals, pos, carrier, flag, weather_generator ); - if( comestible && !self ) { - here.rotten_item_spawn( obj, pos ); + // If the item has rotted away, then self becomes a null pointer. + if( !self ) { + if( obj.is_comestible() ) { + here.rotten_item_spawn( obj, pos ); + } else if( obj.is_corpse() ) { + here.handle_decayed_corpse( obj, pos ); + } } } return std::move( self ); @@ -10127,6 +10131,11 @@ std::string item::type_name( unsigned int quantity ) const return ret_name; } +const mtype *item::get_corpse_mon() const +{ + return corpse; +} + std::string item::get_corpse_name() { if( corpse_name.empty() ) { diff --git a/src/item.h b/src/item.h index 5322fbf40d35..429b19baf22a 100644 --- a/src/item.h +++ b/src/item.h @@ -2325,6 +2325,7 @@ class item : public location_visitable, public game_object void add_component( detached_ptr &&comp ); const location_vector &get_components() const; location_vector &get_components(); + const mtype *get_corpse_mon() const; private: location_vector components; const itype *curammo = nullptr; diff --git a/src/map.cpp b/src/map.cpp index 06169d76eacd..3a6961e19584 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -109,8 +109,11 @@ static const ammo_effect_str_id ammo_effect_LASER( "LASER" ); static const ammo_effect_str_id ammo_effect_LIGHTNING( "LIGHTNING" ); static const ammo_effect_str_id ammo_effect_PLASMA( "PLASMA" ); +static const fault_id fault_bionic_nonsterile( "fault_bionic_nonsterile" ); + static const itype_id itype_autoclave( "autoclave" ); static const itype_id itype_battery( "battery" ); +static const itype_id itype_burnt_out_bionic( "burnt_out_bionic" ); static const itype_id itype_chemistry_set( "chemistry_set" ); static const itype_id itype_dehydrator( "dehydrator" ); static const itype_id itype_electrolysis_kit( "electrolysis_kit" ); @@ -7263,14 +7266,85 @@ void map::loadn( const tripoint &grid, const bool update_vehicles ) template void map::remove_rotten_items( Container &items, const tripoint &pnt, temperature_flag temperature ) { - items.remove_with( [this, &pnt, &temperature]( detached_ptr &&it ) { + std::vector corpses_handle; + items.remove_with( [this, &pnt, &temperature, &corpses_handle]( detached_ptr &&it ) { item &obj = *it; it = item::actualize_rot( std::move( it ), pnt, temperature, get_weather() ); - if( !it && obj.is_comestible() ) { - rotten_item_spawn( obj, pnt ); + // When !it, that means the item was removed from the world, ie: has rotted. + if( !it ) { + if( obj.is_comestible() ) { + rotten_item_spawn( obj, pnt ); + } else if( obj.is_corpse() ) { + // Corpses cannot be handled at this stage, as it causes memory errors by adding + // items to the Container that haven't been accounted for. + corpses_handle.push_back( &obj ); + } } return std::move( it ); } ); + + // Now that all the removing is done, add items from corpse spawns. + for( const item *corpse : corpses_handle ) { + handle_decayed_corpse( *corpse, pnt ); + } + +} + +void map::handle_decayed_corpse( const item &it, const tripoint &pnt ) +{ + const mtype *dead_monster = it.get_corpse_mon(); + if( !dead_monster ) { + debugmsg( "Corpse at tripoint %s has no associated monster?!", getglobal( pnt ).to_string() ); + return; + } + + int decayed_weight_grams = to_gram( dead_monster->weight ); // corpse might have stuff in it! + decayed_weight_grams *= rng_float( 0.5, 0.9 ); + + for( const harvest_entry &entry : dead_monster->harvest.obj() ) { + if( entry.type != "bionic" && entry.type != "bionic_group" ) { + detached_ptr harvest = item::spawn( entry.drop, it.birthday() ); + const float random_decay_modifier = rng_float( 0.0f, static_cast( MAX_SKILL ) ); + const float min_num = entry.scale_num.first * random_decay_modifier + entry.base_num.first; + const float max_num = entry.scale_num.second * random_decay_modifier + entry.base_num.second; + int roll = 0; + if( entry.mass_ratio != 0.00f ) { + roll = static_cast( std::round( entry.mass_ratio * decayed_weight_grams ) ); + roll = std::ceil( static_cast( roll ) / to_gram( harvest->weight() ) ); + } else { + roll = std::min( entry.max, std::round( rng_float( min_num, max_num ) ) ); + } + for( int i = 0; i < roll; i++ ) { + // This sanity-checks harvest yields that have a default stack amount, e.g. copper wire from cyborgs + if( harvest->charges > 1 ) { + harvest->charges = 1; + } + + add_item_or_charges( pnt, item::spawn( *harvest ) ); + } + } + } + for( item * const &comp : it.get_components() ) { + if( comp->is_bionic() ) { + // If CBM, decay successfully at same minimum as dissection + // otherwise, yield burnt-out bionic and remove non-sterile if present + if( !one_in( 10 ) ) { + comp->convert( itype_burnt_out_bionic ); + if( comp->has_fault( fault_bionic_nonsterile ) ) { + comp->faults.erase( fault_bionic_nonsterile ); + } + } + add_item_or_charges( pnt, item::spawn( *comp ) ); + } else { + // Same odds to spawn at all, clearing non-sterile if needed + if( one_in( 10 ) ) { + if( comp->has_fault( fault_bionic_nonsterile ) ) { + comp->faults.erase( fault_bionic_nonsterile ); + } + add_item_or_charges( pnt, item::spawn( *comp ) ); + } + } + } } void map::rotten_item_spawn( const item &item, const tripoint &pnt ) diff --git a/src/map.h b/src/map.h index ec38116d1512..20f5b1ea49c2 100644 --- a/src/map.h +++ b/src/map.h @@ -1666,6 +1666,13 @@ class map */ void spawn_monsters( bool ignore_sight ); + /** + * Checks to see if the corpse that is rotting away generates items when it does. + * @param it item that is spawning creatures + * @param pnt The point on this map where the item is and where bones/etc will be + */ + void handle_decayed_corpse( const item &it, const tripoint &pnt ); + /** * Checks to see if the item that is rotting away generates a creature when it does. * @param item item that is spawning creatures