void put_into_vehicle( player &p, const std::list<item> &items, vehicle &veh, int part ) { if( items.empty() ) { return; } const tripoint where = veh.global_part_pos3( part ); const std::string ter_name = g->m.name( where ); int fallen_count = 0; for( auto it : items ) { // cant use constant reference here because of the spill_contents() if( it.is_bucket_nonempty() && !it.spill_contents( p ) ) { p.add_msg_player_or_npc( _( "To avoid spilling its contents, you set your %1$s on the %2$s." ), _( "To avoid spilling its contents, <npcname> sets their %1$s on the %2$s." ), it.display_name().c_str(), ter_name.c_str() ); g->m.add_item_or_charges( where, it ); continue; } if( !veh.add_item( part, it ) ) { if( it.count_by_charges() ) { // Maybe we can add a few charges in the trunk and the rest on the ground. it.mod_charges( -veh.add_charges( part, it ) ); } g->m.add_item_or_charges( where, it ); ++fallen_count; } } const std::string part_name = veh.part_info( part ).name(); if( same_type( items ) ) { const item &it = items.front(); const int dropcount = items.size() * ( it.count_by_charges() ? it.charges : 1 ); p.add_msg_player_or_npc( ngettext( "You put your %1$s in the %2$s's %3$s.", "You put your %1$s in the %2$s's %3$s.", dropcount ), ngettext( "<npcname> puts their %1$s in the %2$s's %3$s.", "<npcname> puts their %1$s in the %2$s's %3$s.", dropcount ), it.tname( dropcount ).c_str(), veh.name.c_str(), part_name.c_str() ); } else { p.add_msg_player_or_npc( _( "You put several items in the %1$s's %2$s." ), _( "<npcname> puts several items in the %1$s's %2$s." ), veh.name.c_str(), part_name.c_str() ); } if( fallen_count > 0 ) { add_msg( m_warning, _( "The trunk is full, so some items fell to the %s." ), ter_name.c_str() ); } }
void drop_on_map( const player &p, const std::list<item> &items, const tripoint &where ) { if( items.empty() ) { return; } const std::string ter_name = g->m.name( where ); const bool can_move_there = g->m.passable( where ); if( same_type( items ) ) { const item &it = items.front(); const int dropcount = items.size() * ( it.count_by_charges() ? it.charges : 1 ); const std::string it_name = it.tname( dropcount ); if( can_move_there ) { p.add_msg_player_or_npc( ngettext( "You drop your %1$s on the %2$s.", "You drop your %1$s on the %2$s.", dropcount ), ngettext( "<npcname> drops their %1$s on the %2$s.", "<npcname> drops their %1$s on the %2$s.", dropcount ), it_name.c_str(), ter_name.c_str() ); } else { p.add_msg_player_or_npc( ngettext( "You put your %1$s in the %2$s.", "You put your %1$s in the %2$s.", dropcount ), ngettext( "<npcname> puts their %1$s in the %2$s.", "<npcname> puts their %1$s in the %2$s.", dropcount ), it_name.c_str(), ter_name.c_str() ); } } else { if( can_move_there ) { p.add_msg_player_or_npc( _( "You drop several items on the %s." ), _( "<npcname> drops several items on the %s." ), ter_name.c_str() ); } else { p.add_msg_player_or_npc( _( "You put several items in the %s." ), _( "<npcname> puts several items in the %s." ), ter_name.c_str() ); } } for( const auto &it : items ) { g->m.add_item_or_charges( where, it ); } }