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

Searchlights: don't drop items used for settings #63429

Merged
merged 1 commit into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/monattack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 );
}
Expand Down
3 changes: 3 additions & 0 deletions src/monexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 10 additions & 3 deletions src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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<phase_id>( cur_phase );
// override phase if frozen, needed for legacy save
Expand Down