Bug - Fixed Multi Usable items

I believe this may be the case for all of the avatar potions, but just a few tests:

I can multi-use plastic jefferson wings, and pygmy papers, but mafia does not currently see them as such when using the `use` command.

EDIT: Just putting other potions I come across here
Not an avatar potion but: `short glass of water is multiusable, but KoLmafia thought it was not`
Same with:
scroll of protection from lycanthropes
glass of warm milk
glass of gnat milk
pitted sheet metal
 
Last edited:

fronobulax

Developer
Staff member
I believe this may be the case for all of the avatar potions, but just a few tests:

I can multi-use plastic jefferson wings, and pygmy papers, but mafia does not currently see them as such when using the `use` command.

Doesn't mafia detect when mafia and KoL disagree about whether something can be multiused?

If mafia reported that then it is an easy fix in the data file. If there is some other source then it is worth elaborating since maybe there is something mafia isn't doing correctly.
 

Veracity

Developer
Staff member
Code:
> pull * dancing fan

Pulling items from storage...
Requests complete.

> closet put * dancing fan

Placing items into closet...
Requests complete.

> closet take * dancing fan

Removing items from closet...
You acquire dancing fan (333)
Requests complete.
Pulling from closet has a normal "You acquire" message with a "rel string", which triggers that check.

ItemDatabase.isMultiUsable:

Code:
  public static final boolean isMultiUsable(final int itemId) {
    // Anything that you can manipulate with multiuse.php

    ConsumptionType useType = ItemDatabase.useTypeById.getOrDefault(itemId, ConsumptionType.NONE);
    EnumSet<Attribute> attributes = ItemDatabase.getAttributes(itemId);

    return switch (useType) {
      case USE_MULTIPLE -> true;
      case POTION, AVATAR_POTION, SPLEEN -> !attributes.contains(Attribute.USABLE);
      default -> attributes.contains(Attribute.MULTIPLE);
    };
  }
Avatar potions are assumed to my multi-usable unless they are explicitly marked as "usable" in items.txt.
Note that potions and avatar potions are not explicitly given Attribute.MULTIPLE
I notice that potions in items.txt are all "potion, usable" or "potion, multiple".
I notice that avatar potions in items.txt are all simply "avatar"; we do not give them the "multiple" attribute explicitly.

UseItemRequest.getConsumptionType:
Code:
...
    EnumSet<Attribute> attrs = ItemDatabase.getAttributes(itemId);
    if (attrs.contains(Attribute.USABLE)) {
      return ConsumptionType.USE;
    }
    if (attrs.contains(Attribute.MULTIPLE)) {
      return ConsumptionType.USE_MULTIPLE;
    }
    if (attrs.contains(Attribute.REUSABLE)) {
      return ConsumptionType.USE_INFINITE;
    }

    return consumptionType;
Items without USABLE or MULTIPLE will end up returning their base type - AVATAR, for example - and that will end up going to inv_use.php to be used one at a time.

UseItemRequest is trying to be "clever" and "efficient" by doings its own Attributes check, rather than calling the special purpose methods in ItemDatabase which do that and other checks.

We could change every "avatar" in items.txt to be "avatar, multiple" (much as we do for "potion").
We could change UseItemRequest.getConsumptionType to call ItemDatabase.isUsable, isMultiUsable, an isReusable - which all check item Attributes.
Or something else.
 
Top