Results 1 to 5 of 5

Thread: Does it Profit?

  1. #1
    Junior Member
    Join Date
    Jun 2018
    Posts
    5

    Default Does it Profit?

    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!

    doesitprofit.ash

  2. #2
    Developer
    Join Date
    Aug 2009
    Posts
    2,796

    Default

    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 Code:
    foreach it in $items[] {
      
    effect e effect_modifier(it"Effect");
      if (
    numeric_modifier(e"Meat Drop") <= && 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?ti...fier_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).

  3. #3
    Junior Member
    Join Date
    Jun 2018
    Posts
    5

    Default

    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.

  4. #4
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,812

    Default

    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 "=")).

  5. #5
    Developer
    Join Date
    Aug 2009
    Posts
    2,796

    Default

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

    But yes, it does what xKiv says it does.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •