Bug Incorrect default for $Effect[Mystically Oiled]

Baden

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:

QuietMisdreavus

New member
Bumping this thread because i just ran into this for Stevedave's Shanty:

Code:
> ash $effect[Stevedave's Shanty of Superiority]

Returned: Stevedave's Shanty of Superiority
name => Stevedave's Shanty of Superiority
default => cargo effect Stevedave's Shanty of Superiority
note =>
all => aggregate boolean [string]
  cast 1 Stevedave's Shanty of Superiority => true
  cargo effect Stevedave's Shanty of Superiority => true
image => superiority.gif
descid => 2e5a803cf1be5b3d2aaa897e60f29138
candy_tier => 0
quality => good
attributes => song
song => true

> ash $effect[Stevedave's Shanty of Superiority].default

Returned: cargo effect Stevedave's Shanty of Superiority

Since i don't have the cargo shorts and i added the effect to my mood without looking, i had a few minutes of confusion because the mood upkeep kept failing. This is in build 26569.

EDIT: This seems to have happened because i didn't have the skill available. I learned the skill and now the default is correctly the "cast" line.
 
Last edited:
Top