Bug - Fixed numeric_modifier incorrectly reports experience for sombrero

AlbinoRhino

Active member
> ash monster_level_adjustment( )

Returned: 92

> ash numeric_modifier($familiar[Hovering Sombrero], "Experience", 26, $item[none]);

Returned: 1.0

Up until fairly recently, the above would return something fairly close to the stat gains to be had from using the sombrero. (The 26 lbs. was just chosen at random.) Location was set to The Black Forest. It seems the experience calculation for the Sombrero is no longer taking ML into account? Testing showed the Sombrero giving 13 stats. A similar calculation for a Volleyball-type predicted ~9 stats and was confirmed. Not sure what has changed.
 

Veracity

Developer
Staff member
I looked at the code in Modifiers.lookupFamiliarModifiers.

It looks like it is looking at "currentML" - which is the average monster level of the zone you are adventuring in.
Using git "blame", that calculation was last changed 6 months ago when we re-formatted the entire source tree.
Looking at the commit before that, the calculation was still there - and git "blame" says it has not been modified for 7 years.

The "average" monster level is calculated in AreaCombatData.getAverageML.

Looking at that from 6 months ago, this little calculation:

Code:
        for ( int i = 0; i < this.monsters.size(); ++i )
        {
            int weighting = this.getWeighting( i );

            // Omit impossible (-2), ultra-rare (-1) and special/banished (0) monsters
            if ( weighting < 1 )
            {
                continue;
            }

            MonsterData monster = this.getMonster( i );
            double weight = (double) weighting * ( 1 - (double) this.getRejection( i ) / 100 ) / this.totalWeighting();
            averageML += weight * monster.getAttack();
        }

has now been replaced by:

Code:
    double averageML =
        monsters.stream()
            .filter(m -> getWeighting(m) > 0)
            .map(
                m ->
                    (double) getWeighting(m)
                        * (1 - (double) this.getRejection(m) / 100)
                        / this.totalWeighting())
            .reduce(0.0, Double::sum);

which is pretty, but you'll notice that the "monster.getAttack()" factor was dropped. (Dec 11, 2021 in PR 326).

I expect this is the issue.

Should be an easy fix.

Edit: As predicted, a one-liner.

 
Last edited:

AlbinoRhino

Active member
Aha! Well, most of that 6 months I was in aftercore meat farming and wouldn't have noticed.....and I'm only on my 18th ascension since the change when I've finally noticed my scripts weren't making the change from volleyball to sombrero...lol
 
Top