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

feat: item label can save deployable robot nicknames #4230

Merged
merged 1 commit into from
Feb 18, 2024
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/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,10 @@ int place_monster_iuse::use( player &p, item &it, bool, const tripoint &pos ) co
newmon.add_effect( effect_pet, 1_turns, num_bp );
}
}
// Transfer label from the item to monster nickname
if( it.has_var( "item_label" ) ) {
newmon.unique_name = it.get_var( "item_label" );
}
// TODO: add a flag instead of monster id or something?
if( newmon.type->id == mtype_id( "mon_laserturret" ) && !g->is_in_sunlight( newmon.pos() ) ) {
p.add_msg_if_player( _( "A flashing LED on the laser turret appears to indicate low light." ) );
Expand Down
4 changes: 4 additions & 0 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3063,6 +3063,10 @@ detached_ptr<item> monster::to_item() const
detached_ptr<item> result = item::spawn( type->revert_to_itype, calendar::turn );
const int damfac = std::max( 1, ( result->max_damage() + 1 ) * hp / type->hp );
result->set_damage( std::max( 0, ( result->max_damage() + 1 ) - damfac ) );
// If we have a nickname, save it via the item's label
if( !unique_name.empty() ) {
result->set_var( "item_label", unique_name );
}
return result;
}

Expand Down
Loading