Will this work?

muffins

Member
I've currently been a bit... skittish, of including any nightcap drinking in my scripts for fear of not receiving the "required" buff in time. After thinking about it a bit, though, I thought something like this might work... can anyone suggest a more efficient way of doing this (other than ascending into the class that has the buff, heh, that'll come eventually).

After requesting buffs...

Code:
cli_execute("wait 120");
while(have_effect($effect[ode to booze]) < 1) {
cli_execute("effects refresh");
cli_execute("wait 120");
}
if(have_effect($effect[ode to booze]) > 1) {
use(1, $item[mon tiki]);
}

Will this continue to execute the while loop until I have the effect, then move on to drinking the mon tiki, as I think it will, or will it cause any problems?
 
It will work. I would like to point out 2 things though:

First let's follow through what kolmafia will do from begin to end.

first somewhere above you've sent the buff request of course.
now kolmafia waits 120
assume buff recieved in that time.
test for the effect, but remember the buff was recieved and kolmafia does not know it so kolmafia thinks we don't have it yet.
refresh of effects-->yay we got it.
now wait another 120 before testing. then continue.

slight mod which prevents the extra 120 wait:
Code:
while(have_effect($effect[ode to booze]) < 1) {
cli_execute("wait 120");
cli_execute("effects refresh");
}
if(have_effect($effect[ode to booze]) > 1) {
use(1, $item[mon tiki]);
}

Now for the other part...as written kolmafia could wait for 240 seconds and then have the buff and carry on, or it could find that the buffbot changed the price, and wait forever. There is a solution. I will refer you to http://kolmafia.us/index.php/topic,51.0.html a topic which I started about this exact problem.
 

muffins

Member
Ah, taking out that first wait command would probably be best. Can't believe I didn't think of that, heh.

If nothing else, I'll probably end up implementing your code simply because of the

Instead of using break, you could use cli_execute("abort Error: Ode To Booze Not Recieved!"); which would stop the script entirely.

bit you mentioned. As, though the endless loop would provide the same information, the method above would prevent it from hitting KOL's servers every 2 minutes endlessly (or, until I wake up, heh).

Thanks!

Edit: Just to make sure I have this entered correctly...

Code:
void CheckOde(int count)
//possibly have a boolean return in the future
 {
 int iterations;
 if(have_skill($skill[The Ode To Booze]))
  {
  if(have_effect($effect[Ode To Booze]) < 1)
   {
   //must add MP testing here
   use_skill(1, $skill[The Ode To Booze]);
   }
  }
  else
  {
  if(have_effect($effect[Ode To Booze]) < 1)
   {
   if (count == 1)
    cli_execute("send 1 meat to Testudinata");
   if (count == 2)
    cli_execute("send 11 meat to Testudinata");
   iterations = 0;
   while( have_effect($effect[ode to booze]) < 1)
    {
    if (iterations > (25))
     cli_execute("abort Error: Ode To Booze Not Recieved!");
    cli_execute("wait 120");
    cli_execute("effects refresh");
    iterations = (iterations + 1);
    }
   }
  }
 }
//end void CheckOde

void nightcap()
{
if(have_effect($effect[ode to booze]) > 1) {
drink(1, $item[mon tiki]);
}
}

Followed by

Code:
CheckOde();
nightcap();

in the main function should execute this properly, yes?
 
close except when calling checkode the format is:
Code:
CheckOde(1);
or
Code:
CheckOde(2);

where 1 or 2 means this is the first or second time we called checkode in the script. This allows the 1 a day buff to be requested 2 times which was Lukifer's intention when setting up testudinata with 2 low priced 1 a day ode buffs.

Code:
CheckOde(1);
nightcap();

or

Code:
CheckOde(2);
nightcap();

Please remember to send testudinata donations from time to time to help her cover the additional costs beyond what she is charging you for these buffs. without donations almost all really cheap buffbots will go broke and either have to raise prices, or shut down.

Back to the topic of being able to call checkode twice a day...this is also a good option for those who are in pvp because they may want to remove ode for a better at buff like a stat buff.
 

Nightmist

Member
This is probably more of a "advanced" feature but you might want to put in a "AT Song Amount" checks, sure it would only loop 25 times but when you "should know" you cant fit any more songs in your head then you can decide to drop a buff or skip the ode. (As scary as it seems, yes there are people that randomly throw musically magical buffs at you and you unexpectedly lose a slot for that ode.)
 

Metraxis

Member
Here's a snippet from my own code (a function with the imaginative name maintain_AT) which handles this issue (technically, this is for maintaining buffs you cast, but the important bits could be recycled):
Code:
	int [effect] ATBuffList;
	ATBuffList[$effect[Aloysius' Antiphon of Aptitude]] = 1;
	ATBuffList[$effect[The Moxious Madrigal]] = 1;
	ATBuffList[$effect[Cletus's Canticle of Celerity]] = 1;
	ATBuffList[$effect[The Polka of Plenty]] = 1;
	ATBuffList[$effect[The Magical Mojomuscular Melody]] = 1;
	ATBuffList[$effect[The Power Ballad of the Arrowsmith]] = 1;
	ATBuffList[$effect[Brawnee's Anthem of Absorption]] = 1;
	ATBuffList[$effect[Fat Leon's Phat Loot Lyric]] = 1;
	ATBuffList[$effect[The Psalm of Pointiness]] = 1;
	ATBuffList[$effect[Jackasses' Symphony of Destruction]] = 1;
	ATBuffList[$effect[Stevedave's Shanty of Superiority]] = 1;
	ATBuffList[$effect[The Ode to Booze]] = 1;
	ATBuffList[$effect[The Sonata of Sneakiness]] = 1;
	ATBuffList[$effect[Carlweather's Cantata of Confrontation]] = 1;
	ATBuffList[$effect[Ur-Kel's Aria of Annoyance]] = 1;

	int [effect] SelectedBuffs;
...
<Code for selecting which AT Buffs I want active in the current situation by inserting them into the SelectedBuffs map>
...
	foreach Buff in ATBuffList {
		if(SelectedBuffs[Buff] != 1 && have_effect(Buff) > 0) { cli_execute("uneffect " + effect_to_string(Buff)); }
	}
...
<Code for casting Buffs I need>
 
Top