diff --git a/src/monattack.cpp b/src/monattack.cpp index bc93510592f3a..6d3ff5cdfec1e 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -3366,6 +3366,9 @@ bool mattack::check_money_left( monster *z ) if( !z->inv.empty() ) { for( const item &it : z->inv ) { + if( it.has_var( "DESTROY_ITEM_ON_MON_DEATH" ) ) { + continue; + } get_map().add_item_or_charges( z->pos(), it ); } z->inv.clear(); @@ -3809,6 +3812,7 @@ bool mattack::searchlight( monster *z ) settings.set_var( "SL_SPOT_X", 0 ); settings.set_var( "SL_SPOT_Y", 0 ); + settings.set_var( "DESTROY_ITEM_ON_MON_DEATH", "TRUE" ); z->add_item( settings ); } diff --git a/src/monexamine.cpp b/src/monexamine.cpp index e57862ed10d6e..807638ea3b114 100644 --- a/src/monexamine.cpp +++ b/src/monexamine.cpp @@ -196,6 +196,9 @@ void dump_items( monster &z ) Character &player_character = get_player_character(); map &here = get_map(); for( item &it : z.inv ) { + if( it.has_var( "DESTROY_ITEM_ON_MON_DEATH" ) ) { + continue; + } here.add_item_or_charges( player_character.pos(), it ); } z.inv.clear(); diff --git a/src/monster.cpp b/src/monster.cpp index 775fab5add148..c0b01164d1085 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -2671,6 +2671,9 @@ void monster::die( Creature *nkiller ) } if( death_drops && !is_hallucination() ) { for( const item &it : inv ) { + if( it.has_var( "DESTROY_ITEM_ON_MON_DEATH" ) ) { + continue; + } if( corpse ) { corpse->force_insert_item( it, item_pocket::pocket_type::CONTAINER ); } else { diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 7e85ed4658322..749454d637bf6 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -3058,9 +3058,16 @@ void item::io( Archive &archive ) } } - // Remove stored translated gerund in favor of storing the inscription tool type - item_vars.erase( "item_label_type" ); - item_vars.erase( "item_note_type" ); + static const std::set removed_item_vars = { + // Searchlight monster setting vars + "SL_PREFER_UP", "SL_PREFER_DOWN", "SL_PREFER_RIGHT", "SL_PREFER_LEFT", "SL_SPOT_X", "SL_SPOT_Y", "SL_POWER", "SL_DIR", + // Remove stored translated gerund in favor of storing the inscription tool type + "item_label_type", "item_note_type" + }; + + for( const std::string &var : removed_item_vars ) { + item_vars.erase( var ); + } current_phase = static_cast( cur_phase ); // override phase if frozen, needed for legacy save