Bug Incorrect default for $Effect[Mystically Oiled]

Baden

New member
Examining the proxy record for $Effect[Mystically Oiled] displays the expected default value:

Code:
> ash $Effect[Mystically Oiled]

Returned:    Mystically Oiled
name => Mystically Oiled
default => use either 1    ointment of the occult, 1 evil ointment of the occult
note =>
all    => aggregate boolean [string]
  use 1 ointment of the occult => true
  use    1 evil ointment of the occult => true
  cargo effect Mystically    Oiled => true
image => potion4.gif
descid =>    df21506858f7dfabf69c62d6562dc574
candy_tier => 0
quality => good
attributes    =>

However actually accessing the default value returns something else:

Code:
> ash $Effect[Mystically Oiled].default

Returned:    cargo effect Mystically Oiled
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member

xKiv

Active member
The relevant line in statuseffects.txt is:
> 36 Mystically Oiled potion4.gif df21506858f7dfabf69c62d6562dc574 good none use either 1 ointment of the occult, 1 evil ointment of the occult|cargo effect Mystically Oiled

So one of the defaults is showing the first element of that field, and the other default is showing the last element of the field (split by |). In this case. Maybe it's just "random" (but stable in a given installation) which of the element will be shown in which case? Or maybe it cycles? Or depends on something that changed between the invocations ...
 

MCroft

Developer
Staff member
I don't get that result.

Code:
> ash $Effect[Mystically Oiled]

Returned: Mystically Oiled
name => Mystically Oiled
default => use either 1 ointment of the occult, 1 evil ointment of the occult
note =>
all => aggregate boolean [string]
  use 1 ointment of the occult => true
  use 1 evil ointment of the occult => true
  cargo effect Mystically Oiled => true
image => potion4.gif
descid => df21506858f7dfabf69c62d6562dc574
candy_tier => 0
quality => good
attributes =>

> ash $Effect[Mystically Oiled].default

Returned: use either 1 ointment of the occult, 1 evil ointment of the occult
 

Rinn

Developer
It appears .default does some checks to see if you can use that source to acquire the effect

Code:
public static final String getDefaultAction( final int effectId )
    {
        if ( effectId == -1 )
        {
            return null;
        }
        String rv = StringUtilities.getDisplayName( EffectDatabase.defaultActions.get( IntegerPool.get( effectId ) ) );
        if ( rv == null )
        {
            return null;
        }
        if ( rv.startsWith( "#" ) )
        {   // Callers of this API expect an actual command, not a note.
            return null;
        }
        for ( String it: rv.split( "\\|" ) )
        {
            String[] split = it.split( " ", 2 );
            boolean works = true; // assume the command works if we don't check it here
            if ( it.startsWith( "use" ) || it.startsWith( "eat" ) || it.startsWith( "drink" ) || it.startsWith( "chew" ) )
            {
                works = UseItemCommand.use( split[ 0 ], split[ 1 ], true );
            }
            else if ( it.startsWith( "cast" ) )
            {
                works = UseSkillCommand.cast( split[1], true );
            }
            if ( works )
            {
                return it;
            }
        }
        // if nothing worked, fall through and dispatch the command so that an appropriate failure can be printed
        return rv.split( "\\|" )[0];
    }

And the relevant check in UseItemCommand.use
Code:
                            // UseItemRequest doesn't really have a "sim" mode, but we can do a pretty good approximation
                            // by checking if maximumUses > 0 and we can physically retrieve the item.
                            return  UseItemRequest.maximumUses( currentMatch.getItemId() ) > 0 &&
                                !InventoryManager.simRetrieveItem( currentMatch, true, true, false ).equalsIgnoreCase( "fail" );

So I expect you're in a situation where mafia doesn't think you can retrieve the ointment so it's returning the cargo command as the source. It does appear that default here isn't doing any checks to verify if any command except use\eat\drink\chew\cast is still valid, so it just assumes cargo works, so I expect that's a bug.
 
Last edited:
Top