Autobuy (or prompt to buy) Bowl of Scorpions

For script writing
Post Reply
PaladinWhite
Pie of the Sky
Posts: 49
Joined: Sat Nov 03, 2012 2:24 pm

Autobuy (or prompt to buy) Bowl of Scorpions

Post by PaladinWhite » Thu Feb 27, 2014 10:42 pm

Harumph just mentioned in chat that it would be nice to have a reminder to buy Bowl of Scorpions after each drunk pygmy fight.

It's easy to do! (Assuming you use Mafia).

Alright, I'm gonna explain this real simple-like, so everyone can follow along. Ready?
  1. First, we need to create a script. Open a Notepad document, and save it in YourMafiaFolder\scripts as BoSBuyer.ash. Don't forget the .ash extension!
  2. Now we'll make it run between adventures. You can do this in one of two ways:
    • Mafia's General>Automation menu, and set the script as your Pre-Adventure script. This has the advantage of being mood-independent, but it's exclusive; you won't be able to run more than one pre-adventuring script this way. Or,
    • In your mood, set Trigger on: Unconditional trigger; Check for: (leave blank); Command: BoSBuyer.ash. This has the advantage of being non-exclusive, but it'll only work while you're in this mood. So it's a good choice if you will always be in a particular mood during the Hidden City quest.
  3. Okay, now for the actual meat of the script. Pop BoSBuyer.ash back open, and copy in the following. Again, two options:
    • To automatically buy Bowl of Scorpions as appropriate, copy this:

      Code: Select all

      if(get_property("hiddenBowlingAlleyProgress") > 0 && get_property("hiddenBowlingAlleyProgress" && get_property("hiddenTavernUnlock").to_int() == my_ascensions()) < 6 && item_amount($item[Bowl of Scorpions]) < 1) {
          retrieve_item(1, $item[Bowl of Scorpions]);
      }
    • To make Mafia prompt you to buy Bowl of Scorpions, copy this instead:

      Code: Select all

      if(get_property("hiddenBowlingAlleyProgress") > 0 && get_property("hiddenBowlingAlleyProgress" && get_property("hiddenTavernUnlock").to_int() == my_ascensions()) < 6 && item_amount($item[Bowl of Scorpions]) < 1) {
          if(user_confirm("Want to buy a Bowl of Scorpions?")) retrieve_item(1, $item[Bowl of Scorpions]);
      }
Easy-peasy :thumbs: No more fiddly running back and forth to the Tavern. And it'll only trigger while the Bowling Alley is open, but before you've defeated the protector spirit there.

Enjoy!
Last edited by PaladinWhite on Fri Feb 28, 2014 8:09 am, edited 2 times in total.
Image

User avatar
lostcalpolydude
Forum Maestro
Posts: 2940
Joined: Wed Apr 23, 2008 6:54 pm

Re: Autobuy (or prompt to buy) Bowl of Scorpions

Post by lostcalpolydude » Fri Feb 28, 2014 6:12 am

Two things I would suggest changing. First, add a check to make sure you actually can pick up a bowl of scorpions. This would be

Code: Select all

get_property( "hiddenTavernUnlock" ).to_int() == my_ascensions()
Second, replace buy() with retrieve_item(). This ensures that mafia doesn't purchase from the mall to put it in storage (if you didn't have the tavern open because that first check wasn't there, or maybe you somehow didn't have enough meat on hand, or it's some weird path like Zombie where you just can't use NPCs). This is a good idea in general, really.
bmaher: Softcore character
lostcalpolydude: Hardcore character (abandoned)

PaladinWhite
Pie of the Sky
Posts: 49
Joined: Sat Nov 03, 2012 2:24 pm

Re: Autobuy (or prompt to buy) Bowl of Scorpions

Post by PaladinWhite » Fri Feb 28, 2014 7:58 am

Ah, good suggestions - thanks.

I didn't think to put in a buyable check because my version is actually if(!buy()) abort; since I don't ever want to not buy it. I figured most people wouldn't want to go to that extreme. But it's a good idea.

EDIT: Actually, retrieve_item() can apparently buy from the Mall if it doesn't get the item some other way. Who knew? But it'll get it from a NPC first when possible.
Image

User avatar
lostcalpolydude
Forum Maestro
Posts: 2940
Joined: Wed Apr 23, 2008 6:54 pm

Re: Autobuy (or prompt to buy) Bowl of Scorpions

Post by lostcalpolydude » Fri Feb 28, 2014 9:25 am

PaladinWhite wrote:Ah, good suggestions - thanks.

I didn't think to put in a buyable check because my version is actually if(!buy()) abort; since I don't ever want to not buy it. I figured most people wouldn't want to go to that extreme. But it's a good idea.
How many extra turns are you going to spend getting a book of matches if one didn't already drop?
EDIT: Actually, retrieve_item() can apparently buy from the Mall if it doesn't get the item some other way. Who knew? But it'll get it from a NPC first when possible.
That only applies to aftercore, where using the mall will get it to your inventory.
bmaher: Softcore character
lostcalpolydude: Hardcore character (abandoned)

Post Reply