Bug - Fixed Querying speculated modifiers doesn't seem to work after modifier revamp

Phazic

New member
I'm on KoLMafia v15465 and it seems like the revamped modifiers have broken being able to request speculative ones or at least I can't figure out the magic keyword used to query them.

Here are some tests:
In the CLI:
1) whatif equip viking helmet
2) ash numeric_modifier("_spec", "Buffed HP Maximum")

Result: 0.0

Expected result: Current HP + 1.

I've also tried: numeric_modifier("_spec:Buffed HP Maximum"), numeric_modifier(":_spec", "Buffed HP Maximum") and a plethora of other choices.

I think the problem may be due to SpeculateCommand.java and Maximizer.java calling Modifiers.overrideModifier like this:
Code:
Modifiers.overrideModifier( "_spec", mods );

It looks like other calls to this function were prefixed with "Generated:" although trying: numeric_modifier("Generated:_spec", "Buffed HP Maximum") results in a substring index error of -3.

That error seems to be caused by this line in RuntimeLibrary.java getModifierName:
Code:
return name.substring( index, name.length() - index );

I think in this case we're trying to extract the tail end of the input string although Java's substring takes endIndex and not length as its 2nd argument.
 

Darzil

Developer
Hopefully r15467 fixes this.

The correct syntax to use now is numeric_modifier("Generated:_spec", "Buffed HP Maximum")
 

Bale

Minion
I need to change all my relevant script to use "Generated:_spec" instead of "_spec" ? Is there a reason that backwards compatibility needs to be broken?
 

Theraze

Active member
Because each modifier now has a type. For _spec, that type is Generated. This allows for checking for separate modifiers from identically named, but differentially typed, objects. Also, you can now check for the modifier on a specific object id. Which is really nifty.

And it took all of about 13 seconds to do the replace all for BatBrain, including the typing.
 

Bale

Minion
Because each modifier now has a type. For _spec, that type is generated. This allows for checking for separate modifiers from identically named, but differentially typed, objects. Also, you can now check for the modifier on a specific object id. Which is really nifty.

Clearly I missed something important in the last few days. How does that work? What sort of types are there?
 
Top