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

Unload containers into tile key #52201

Merged
merged 4 commits into from
Oct 19, 2021
Merged

Conversation

Saicchi
Copy link
Contributor

@Saicchi Saicchi commented Oct 9, 2021

Summary

Interface "Unload container in tile keybind"

Purpose of change

Drop contents of a container inside the player inventory into an adjacent tile.

Describe the solution

Does not recursively drop contents.
Due to item_location limitations, currently it can only drop items inside the players inventory ( wielded or wearing ).

Add a new menu for dropping items into a tile.

Describe alternatives you've considered

None

Testing

  • Item B inside container A ( A > B )
  • Players unloads container A
  • Items on the ground: B
    --
  • Item B and C inside container A ( A > B, C )
  • Players unloads container A
  • Items on the ground: B, C
    --
  • Container C inside container B inside container A ( A > B > C )
  • Players unloads container A
  • Items on the ground: B ( contains C )
    --
  • Item D inside container C inside container B inside container A ( A > B > C > D )
  • Players unloads container B and C
  • Items on the ground: B ( C can not be selected due to being inside B )

Additional context

Repurposes the d key since it's essentially D + 5.

I've also changed the insert menu to get items in a 1 tile radius instead of only tiles the player is on top of of.

unload_container.mp4

@Saicchi Saicchi changed the title Unloadcontainer Unload containers into tile key Oct 9, 2021
@BrettDong BrettDong added [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. Items: Containers Things that hold other things labels Oct 10, 2021
@mqrause
Copy link
Contributor

mqrause commented Oct 10, 2021

Due to item_location limitations, currently it can only drop items inside the players inventory ( wielded or wearing ).

It's not actually an item_location limitation. The drop activity only looks at items on character when trying to remove the moved item.

// Take off the item or remove it from the player's inventory
if( who.is_worn( *loc ) ) {
who.takeoff( loc, &res );
} else if( loc->count_by_charges() ) {
res.push_back( who.reduce_charges( &*loc, it->count() ) );
} else {
res.push_back( who.i_rem( &*loc ) );
}

It's probably enough to add another case for items not on character to make it work with that.

Alternatively use the unload activity. You would need to adjust the loop here to allow dropping directly on a tile, with the added benefit that you can also move your special handling code from the menu to there so you only have to pass the selected containers, simplifying the menu code.

for( item *contained : it.all_items_top() ) {
int old_charges = contained->charges;
const bool consumed = who.add_or_drop_with_msg( *contained, true, &it, contained );
if( consumed || contained->charges != old_charges ) {
changed = true;
handler.unseal_pocket_containing( item_location( target, contained ) );
}
if( consumed ) {
it.remove_item( *contained );
}
}

@Entity-y
Copy link
Contributor

Does this solve the problem of accidently pouring liquids into a bathtub when examining?

@Entity-y
Copy link
Contributor

Entity-y commented Oct 11, 2021

What I'm trying to say is that with the addition of this new keybinding, could we remove the option to unload liquids through the examine menu prompt when looking at bathtubs? I've never actually used that feature intentionally and sometimes catches me off guard and wastes a liquid in my inventory.
image

@Saicchi
Copy link
Contributor Author

Saicchi commented Oct 13, 2021

No, as this feature does not drop liquids. Containers with only liquid in them won't even show up.

@ZhilkinSerg ZhilkinSerg merged commit 732faf4 into CleverRaven:master Oct 19, 2021
@Saicchi
Copy link
Contributor Author

Saicchi commented Oct 19, 2021

I saw some people complaining about the key being removed on reddit too.
I'll bring the option back to the keybinding menu for people who want to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. Items: Containers Things that hold other things
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants