From e481839e485744b832e6ecd0504d116a9b6b855a Mon Sep 17 00:00:00 2001 From: Fris0uman <41293484+Fris0uman@users.noreply.github.com> Date: Sat, 11 Dec 2021 18:54:21 +0100 Subject: [PATCH] Monsters without corpse drop their loot (#53362) * Monsters without corpse drop their loot * Empty `inv` of monsters without corpse on the ground --- src/monster.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index ec95adb15397e..18c157fdc6921 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -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 ) { @@ -2633,15 +2639,18 @@ void monster::drop_items_on_death( item *corpse ) std::vector 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 ); } } }