Skip to content

Commit

Permalink
feat: item label can save deployable robot nicknames
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosvolt committed Feb 15, 2024
1 parent c79e38a commit c304b35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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

0 comments on commit c304b35

Please sign in to comment.