buying buffs when you don't know the price.

Problem:
With the ever changing buff prices I have many times found myself needlessly spamming the buffbots with invalid buff requests because I forgot (or didn't know) to update my scripts.

This script is the solution.

First let me say that this script will not buy a philanthropic (once a day) buff. This is in respect for Holatuwol's wishes that scripts not do that. There are 2 blocks in place. 1 is obvious, the other not so obvious.

Now on with how to use it. The script is meant to be imported into your own script. You should know what buffbot you want to use, and kolmafia's buffbot interface must be able to purchase buffs from the chosen bot. You should also know how many turns of the buff you want, and of course what buff you want.

boolean buy_buff(int length, skill buff, string bot) returns false if the buffbot is not in kolmafia's database, or if the script is unable to acquire the bot's price list, or if you request a buff length larger than the buffbot's largest single purchase buff length for the given buff is. Returns true under all other circumstances. length is the minimum number of adventures of the buff you want. The function will send the appropriate amount for the next larger length in the bot's list. buff is of course the buff required. bot is the name of the bot to buy the buff from.

What this script does not do:
It does not wait for the buff. This should be written into the calling script.
It does not verify the buff is received. This also is up to the calling script if required.
It does not verify the buffbot is online. This is not possible within a script.
It does not verify the kmail was actually sent. If you are banned, or the buffbot has you baleeted, that is your own issue. It is not possible to verify sending kmails via script.
It does not check ronin, or hardcore status of your character, or the buffbot.
It does not check your AT buff count.
It does not buy one a day buffs.
It does not load information about all of the buffbots. It only loads info about buffbots in which it needs info about.

What this script does do:
Prevents buffbot spam!!! ;D
Reduces the likelihood of unintentional un-buffed adventuring. :)

what this script should do:
work with all of the buffs, and buffbots. I have only tested testudinata and ode to booze for 15 adventures, but my understanding is that the buffbots (in kolmafia's database) all use the same "kolmafia parseable" price list so they should all work.

my test results:
Code:
buy_buff(15, $skill[ode to booze], "testudinata");
resulted in a kmail from testudinata
This buffbot was unable to process your request. Selected target has 3 AT buffs already. Please try again later.
snip snip
You gain 59 Meat.
a quick look at her DC revealed 59 meat was the correct amount to send for 20 adv (non philanthropic) of ode to booze.

edit: a problem has been found Problem fixed. see below
jalepeno and jabanero do not work properly.
presently the script ends up with
Code:
Jaba?ero/Jalape�o Saucesphere
instead of
Code:
Jaba & N t i l d e ero/Jalape & N t i l d e o Saucesphere
or
Code:
Jabañero/Jalapeño Saucesphere

as the name of the buff in it's compiled database. attempting to place the character represented by ? into a script so as to find it and convert it results in other issues because the file ends up saved in a format kolmafia does not seem to like.
(code tags did not work to stop html decoding spaces inserted.)

Edit again: Inserting the following code fixed the script.
Code:
  if(contains_text(temp.name, "o Saucesphere"))
    {
    if(contains_text(temp.name, "Jaba")){temp.name = skill_to_string($skill[Jabañero Saucesphere]);}
    if(contains_text(temp.name, "Jalape")){temp.name = skill_to_string($skill[Jalapeño Saucesphere]);}
    }
Not pretty, but it works. New version uploaded.
 

Attachments

  • buffs.ash
    4 KB · Views: 169

Smello

New member
Thanks for this! This will really be a great help to me, for one.

I'm having a problem with it though; it seemed to work fine running it as a script, but if I try to map it to the gCLI namespace with the "using" command, or importing it into a script that is, it crashes and burns. Since you can't call one ash script from another (that I'm aware of, anyway), that means I can't really use it in my own scripts.

I'm not sure what causes it to crash; here's the debug log if that helps any. I'll keep checking around and messing with it to see if I can figure it out.


vv Awesome! Thanks, Holatuwol!
 

holatuwol

Developer
Thanks, the bug is under investigation. :)[br]Posted on: January 20, 2007, 03:59:29 PM
Nailed it. When invoking functions via the gCLI, KoLmafia wasn't executing the top-level commands in the script. In this case, these top-level commands declared global variables, resulting in weird runtime errors. This issue should be fixed and will be available in the next release.
 
hmm, I never thought of trying to map the script into the gcli namespace, but it sounds quite handy. I did however import it into another script, and it worked perfectly.

Thanks for the fix Holatuwol!
 

th3y

Member
Anybody using this script these days? I'm trying to, but when the script gets to the line

Code:
foreach key in buffbot_data[bot].buffdata.buffdata

there seem to be no keys (because a print statement just inside the opening brace does not execute). I suspect that the line earlier

Code:
file_to_map("buffbots.dat", buffbotlist);

is not populating the map as desired. I added

Code:
print (buffbotlist);

as a check afterwards and get the output

Code:
aggregate botdata_record [string]

I also tried

Code:
file_to_map("buffbots.txt", buffbotlist);

with similar results.

Any suggestions? Do I have to obtain a copy of buffbots.txt from somewhere? (It's not in my data directory)


Also, I did change the "send" to "csend". But the script doesn't seem to be reaching that line.
-TH3Y thank you...
 

Alhifar

Member
Simply changing buffbots.dat to buffbots.txt should work. Otherwise, unless you have some CLI output or a debug log, I'll take a look after rollover as well.

EDIT: The problem is around line 89. For some reason, the substring function there is returning an empty string. I honestly have no idea why.
 
Last edited:
Top