Viewing Issue Simple Details Jump to Notes ] Wiki ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0010317 [DCSS] Implementables major N/A 2016-03-11 07:09 2016-05-30 21:09
Reporter PleasingFungus View Status public  
Assigned To neil
Priority normal Resolution done  
Status closed   Product Branch longterm development (0.25+)
Summary 0010317: Allow using items from the ground
Description Currently, a player with a full inventory is regularly required to manually drop something, pick up whatever they want to interact with, perform the interaction (identifying, wearing, etc), and then reverse the process as appropriate. It should be possible to reduce the annoyances by letting players use items directly from the ground.

Scrolls, potions, and books can be used as if they were in your inventory. (This is already implemented for food, but in a way that is not trivially generalizable.) Equipment (weapons, armour, jewellery) provide additional complications in the case of full a full inventory, since they of course must enter your inventory to be worn, but in many cases, one can prompt the player to drop whatever they're currently wearing in the corresponding slot (if applicable) before wearing/wielding the item from the floor. One can also imagine an inscription (the inverse of {!d}?) that marks an item to be automatically dropped when space is needed for wearing/wielding an item from the floor.

This can be implemented piecewise rather than all at once; that may be the only practical approach, in fact.

To discourage bad behaviour, ammo, wands, and other evocables should *not* be usable from the floor.
Additional Information
Tags No tags attached.
Attached Files ? file icon use_from_floor_v6.patch [^] (19,490 bytes) 2016-05-26 04:49 [Show Content]
? file icon item_int_fix.patch [^] (711 bytes) 2016-05-30 03:34 [Show Content]
? file icon use_from_floor_upgrade.patch [^] (6,416 bytes) 2016-05-30 07:33 [Show Content]

- Relationships
related to 0009927new UI responses to invalid menu selections are a hot mess 

-  Notes
(0030294)
dpeg (administrator)
2016-03-11 09:12

That's long overdue, good idea! What interface do you have in mind?

I see two possibilities. Suppose your inventory is full and you stand over a potion.

(1) pressing 'q' lists your inventory potions and the potions on the floor (probably best to put potions on the floor at the top). Problem: what keys to assign to floor potions?

(2) pressing ';' anywhere lists the items on the current square (as now), but now gives letter slots to items. Pressing such an item slot uses it (potion -> quaff etc.).

There is a general question about this feature: should floor items be usable also when your inventory is not full? I think it would be better to allow this.
(0030295)
PleasingFungus (administrator)
2016-03-11 18:12

I don't think the two possibilities are exclusive; it seems like having both would be good. For (1) and similar interactions (scrolls etc), it seems like you'd want some kind of toggle between floor and inventory items? '!', maybe, if that's not being used already. (It probably is.)

And yes, of course floor items should be usable even if your inventory isn't full - sorry if I implied otherwise!
(0030296)
PleasingFungus (administrator)
2016-03-11 18:16

I believe there was discussion of something like this a year or two ago, perhaps on c-r-d or the devwiki, but I haven't been able to find it.
(0030393)
Naruni (reporter)
2016-04-25 02:48

I started looking into this, it may be too big for me to handle, but here is what I found:

Using void drink(int slot) from item_use.cc, I see a call to prompt_invent_item from invent.cc. Originally I thought to edit this to be able to include items on ground that had a bool flag use_from_ground being true. After thinking about this for a bit, I don't see it as a clean edit due to adding code that inspects the ground in a function that is designed to be inventory code.

I looked at _choose_mem_spell from spl-book.cc since memorize includes spells from other sources (ground and vehumet). This seems more appropriate to change the drink and read code be behave more like this since we are no longer making the drink and read actions based on inventory, any comments on that?

I'm not very familiar with menu code so before I delve into trying this change I'd like some feedback addressing if this an appropriate approach to implement.
(0030398)
pumpyscump (reporter)
2016-04-26 07:41

Some games have a solution to this already.

You can pick up one (and only one) item or stack from the floor when your inventory is full.

When you do, it asks if you want to immediately eat, equip, wear, etc the item.

If you do not or you cannot, it prompts you to drop one or more items from your full inventory.

Only when you have done that does the item move from the floor or magical-inventory-limbo into your real inventory (and get assigned an inventory letter)
(0030407)
PleasingFungus (administrator)
2016-04-27 03:08

@Naruni: basing your approach on _choose_mem_spell and _get_mem_list might be reasonable, yeah. Ideally you'd be able to generalize your code enough to allow re-use between spell memorization, drinking, reading, and whatever else you end up doing, but getting something working is the first and most important thing.
(0030518)
Naruni (reporter)
2016-05-23 05:58

After looking at this for a month I believe the best way to handle this is to get the desired functions (drink, read, wear_armour, and wield_weapon) to stop expecting an int representing an inv slot. I've changed drink and read to accept item_def* (commit 1 and 2 in the patch) and have done minor testing, successful.

Next is to add a new menu class (derived from InvMenu) which will get target items (pots for drinking...) and display them in a single menu, identifying which are inventory items and which are floor items. This class will be used by a function (_use_an_item) that will gether proper filtering information (via CMD_QUAFF...) and get the selection returned to the calling function. This has been completed in the 3rd commit in the patch.

So far, nothing is using the UseItemMenu or calling _use_an_item which will return the selected item_def* to the calling function.
(0030520)
PleasingFungus (administrator)
2016-05-23 07:31

Your approach to potions and scrolls seems reasonable, though I'd note that with scrolls, there's much more to do. Every time you call letter_to_index() - for _handle_read_book(), start_delay(DELAY_BLURRY_SCROLL...), and of course read_scroll(), you need to handle items that aren't in the inventory. It's fine to do that in separate commits, just something to keep in mind.

Two other small niggles with the first two commits: your commit messages aren't formatted correctly (the first line should be a short summary, and subsequent lines should be 80-character wrapped), and you left a commented-out line in your scroll commit.

Your third commit (UseItemMenu) has a bunch of missing indentation (e.g. the end of populate_list(), the '// Remove inventory item hotkeys from the tracker' loop), the if (sel.empty()) case in _use_an_item()), but otherwise looks reasonable. The comment on _use_an_item() is perfect - a model for others. Keep that up!
(0030529)
wheals (administrator)
2016-05-25 22:49

Comments:

* UseItemMenu doesn't need the object, cmd, or keyin fields. Additionally, rather than a type, it should take an object selector (one of the OSEL_ enums in invent.h) and use item_is_selected to see whether an object is matched; this will make the 'r' menu allow books properly. Also, you could add the calls to populate_list() and populate_menu() to the constructor, and pass the OSEL to populate_list, so you wouldn't need to store it in the menu either.

* _can_read_scroll, _handle_read_book, and read_scroll could take item_def& rather than item_def*. (It's a minor thing but the former is preferable where possible).

* There's some funky indentation in populate_menu() (where the if statement and the code are on the same line) and populate_list() (just indent the code, not the braces). You should also run util/unbrace and util/checkwhite, that will automatically clean up some of the indentation issues.
(0030530)
Naruni (reporter)
2016-05-26 01:16

v5 should be done.
(0030532)
Naruni (reporter)
2016-05-26 04:50

v6 has some needed functions for converting functions to using item_def instead of (int slot).
(0030563)
wheals (administrator)
2016-05-29 21:10

Pushed the patch to trunk.
(0030564)
Naruni (reporter)
2016-05-30 07:34

Sorry about the crap shoot. The use_from_floor_upgrade.patch is a bit of an olive branch towards making things better.
(0030566)
wheals (administrator)
2016-05-30 15:09

I marked an issue as related, since it deals with the behavior of making an invalid keypress at a menu. As was discussed on IRC last night prompt_invent_item has a different behavior (# 1 on that list) from the current state of this menu. While the other reporter isn't a dev, I agree that # 7 is the best one. See, for example, item_use.cc:_scroll_choose_weapon for an example of the implementation of this.
(0030571)
neil (administrator)
2016-05-30 21:09

Further fixes and improvements can go to new bugs.

- Issue History
Date Modified Username Field Change
2016-03-11 07:09 PleasingFungus New Issue
2016-03-11 09:12 dpeg Note Added: 0030294
2016-03-11 18:12 PleasingFungus Note Added: 0030295
2016-03-11 18:16 PleasingFungus Note Added: 0030296
2016-04-25 02:48 Naruni Note Added: 0030393
2016-04-26 07:41 pumpyscump Note Added: 0030398
2016-04-27 03:08 PleasingFungus Note Added: 0030407
2016-05-03 02:43 Naruni File Added: use_floor_items.patch
2016-05-03 02:45 Naruni Note Added: 0030435
2016-05-03 05:17 Naruni Note Added: 0030436
2016-05-03 05:57 Naruni File Added: 0001-Enable-item-use-from-floor.-Only-potions-currently-i.patch
2016-05-03 05:57 Naruni Note Added: 0030437
2016-05-03 07:35 Naruni Note Added: 0030438
2016-05-05 08:47 Naruni File Added: floor.patch
2016-05-05 08:47 Naruni Note Added: 0030440
2016-05-05 20:56 Naruni Note Deleted: 0030436
2016-05-05 20:56 Naruni Note Deleted: 0030437
2016-05-05 20:56 Naruni Note Deleted: 0030438
2016-05-22 10:58 Naruni Note Added: 0030515
2016-05-23 05:31 Naruni Note Deleted: 0030515
2016-05-23 05:31 Naruni Note Deleted: 0030440
2016-05-23 05:31 Naruni Note Deleted: 0030435
2016-05-23 05:58 Naruni Note Added: 0030518
2016-05-23 05:58 Naruni File Added: use_from_floor.patch
2016-05-23 05:59 neil File Deleted: use_floor_items.patch
2016-05-23 06:00 neil File Deleted: 0001-Enable-item-use-from-floor.-Only-potions-currently-i.patch
2016-05-23 06:00 neil File Deleted: floor.patch
2016-05-23 07:31 PleasingFungus Note Added: 0030520
2016-05-25 19:33 Naruni File Added: use_from_floor_v2.patch
2016-05-25 22:14 Naruni File Added: use_from_floor_v4.patch
2016-05-25 22:49 wheals Note Added: 0030529
2016-05-26 01:16 Naruni File Added: use_from_floor_v5.patch
2016-05-26 01:16 Naruni Note Added: 0030530
2016-05-26 03:10 wheals File Deleted: use_from_floor.patch
2016-05-26 03:10 wheals File Deleted: use_from_floor_v2.patch
2016-05-26 03:10 wheals File Deleted: use_from_floor_v4.patch
2016-05-26 04:49 Naruni File Added: use_from_floor_v6.patch
2016-05-26 04:50 Naruni Note Added: 0030532
2016-05-29 21:10 wheals Note Added: 0030563
2016-05-29 21:10 wheals File Deleted: use_from_floor_v5.patch
2016-05-30 03:34 Naruni File Added: item_int_fix.patch
2016-05-30 07:33 Naruni File Added: use_from_floor_upgrade.patch
2016-05-30 07:34 Naruni Note Added: 0030564
2016-05-30 13:38 wheals Relationship added related to 0009927
2016-05-30 15:09 wheals Note Added: 0030566
2016-05-30 21:09 neil Note Added: 0030571
2016-05-30 21:09 neil Status new => resolved
2016-05-30 21:09 neil Fixed in Branch => 0.19 development branch
2016-05-30 21:09 neil Resolution open => done
2016-05-30 21:09 neil Assigned To => neil
2016-05-30 21:09 neil Status resolved => closed


Mantis 1.1.8[^]
Copyright © 2000 - 2009 Mantis Group
Powered by Mantis Bugtracker