Skip to content

Commit

Permalink
Monsters without corpse drop their loot (#53362)
Browse files Browse the repository at this point in the history
* Monsters without corpse drop their loot

* Empty `inv` of monsters without corpse on the ground
  • Loading branch information
Fris0uman authored Dec 11, 2021
1 parent 00a0caa commit e481839
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2534,12 +2534,18 @@ void monster::die( Creature *nkiller )
if( death_drops && !no_extra_death_drops ) {
drop_items_on_death( corpse );
}
if( death_drops && !is_hallucination() && corpse ) {
if( death_drops && !is_hallucination() ) {
for( const auto &it : inv ) {
corpse->put_in( it, item_pocket::pocket_type::CONTAINER );
if( corpse ) {
corpse->put_in( it, item_pocket::pocket_type::CONTAINER );
} else {
get_map().add_item_or_charges( pos(), it );
}
}
for( item_pocket *pocket : corpse->get_all_contained_pockets().value() ) {
pocket->set_usability( false );
if( corpse ) {
for( item_pocket *pocket : corpse->get_all_contained_pockets().value() ) {
pocket->set_usability( false );
}
}
}
if( death_drops ) {
Expand Down Expand Up @@ -2633,15 +2639,18 @@ void monster::drop_items_on_death( item *corpse )
std::vector<item> new_items = item_group::items_from( type->death_drops,
calendar::start_of_cataclysm,
spawn_flags::use_spawn_rate );
if( corpse ) {
for( item &it : new_items ) {
if( has_flag( MF_FILTHY ) ) {
if( ( it.is_armor() || it.is_pet_armor() ) && !it.is_gun() ) {
// handle wearable guns as a special case
it.set_flag( STATIC( flag_id( "FILTHY" ) ) );
}

for( item &it : new_items ) {
if( has_flag( MF_FILTHY ) ) {
if( ( it.is_armor() || it.is_pet_armor() ) && !it.is_gun() ) {
// handle wearable guns as a special case
it.set_flag( STATIC( flag_id( "FILTHY" ) ) );
}
}
if( corpse ) {
corpse->put_in( it, item_pocket::pocket_type::CONTAINER );
} else {
get_map().add_item_or_charges( pos(), it );
}
}
}
Expand Down

0 comments on commit e481839

Please sign in to comment.