Does it Profit?

Gymhgy

New member
I just started learning ASH, and this is one of my first scripts.
What this does:

It calculates if a meat enhancing item is worth the purchase or not.
Just set the base_meat_per_adv variable to the monster you farm. (default is 400)
Type in "doesitprofit" in the CLI and it will start calculating if the item is worth the buy!

Since this is the 2nd script that I have written, it might have some bugs.
I am open to any suggestions.

Happy calculating!

View attachment doesitprofit.ash
 

heeheehee

Developer
Staff member
Neat. Mafia actually exposes its extensive support for various modifiers to ASH, via a whole host of *_modifier() functions.

For instance, you might want to populate theItemList via something like
PHP:
foreach it in $items[] {
  effect e = effect_modifier(it, "Effect");
  if (numeric_modifier(e, "Meat Drop") <= 0 && numeric_modifier(e, "Familiar Weight" <= 0) {
    continue;
  }
  theItemList[it][numeric_modifier(it, "Effect Duration")] ...
}

which will correctly account for things like Sauceror potion (blackberry polite, cranberry cordial) duration. It also will correctly account for Polka Power's scaling with level.

There's a wiki page for these (I don't think it's been updated in a while, but the core functionality should be unchanged)
http://wiki.kolmafia.us/index.php?title=Category:Modifier_Functions

There are a few variable effects that don't work well with this approach -- for instance, Uncle Greenspan's Bathroom Finance Guide yields more +meat% the fewer turns you have; a few others scale as your turns remaining increase go up (e.g. Prunets, love songs, taffy).
 

Gymhgy

New member
Not sure how the following statement works:

theItemList[it][numeric_modifier(it, "Effect Duration")]

I know that the statements before it goes through the list of all items in the game and single the ones that adds meat drop and familiar weight, but I can't find any function in the wiki that adds something to a map.

Forgive me if this is a noob question, since I'm still relatively new to scripting.
 

xKiv

Active member
I think this is autovivification, and intended in ASH?
(autovivification = automatic creation of map elements when accessed)

So theItemList[it] adds "it" to theItemList if it isn't there yet (I think this only works in left-hand-side contexts? (as in, only on left side of "=")).
 

heeheehee

Developer
Staff member
Oh, I meant that to say "theItemList[a] = ..." without writing exactly how you might implement that.

But yes, it does what xKiv says it does.
 
Top