Suggestion for those Purchasing Buffs from a buffbot

So many scripts contain

Code:
while( have_effect($effect[ode to booze]) < 1)
        {
        cli_execute("wait 120");
        cli_execute("effects refresh");
        }

I have seen many scripts which can lock into an infinite loop if a buffbot is down, :eek: or a duplicate 1 a day buff is requested. Here is a function which shows a way of limiting the wait for a buff. In this example, if you have the skill Ode to Booze, you take care of it yourself, but when you don't it purchases the buff from Testudinata.

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))
          Break;
        cli_execute("wait 120");
        cli_execute("effects refresh");
        iterations = (iterations + 1);
        }
      }
    }
  }
//end void CheckOde

Things to notice:
*count can be 1 or 2, this allows the same function to be used 2 times to request ode. Once at the begining of the day, and again at the end of the day. The end of the day should carry over, but sometimes things go wrong.

*iterations is a counter. It counts the number of times the loop loops. The
Code:
if (iterations > 25)
  Break();
statement puts a 26 time limit on the number of times the loop can occur, then it will carry on as if the buff were recieved. 26 may not be enough, but not having a limit can leave the script in an infinite loop. Instead of using break, you could use cli_execute("abort Error: Ode To Booze Not Recieved!"); which would stop the script entirely.

If someone wanted to, additions could be made to attempt to purchase from another buffbot if the first fails.

Edit: April 18, 2006 another thing to note. using a higher amount of time for the wait command results in lower processor time usage, and fewer hits on KOL's servers. Using a lower wait time may result in the scipt pulling out of the loop, and carrying on much faster. Ultimately you should make a reasonable decision based on you own situation.
 

Sako

Member
So you're gonna wait 50 mins in front of the comp just to have one shot of Ode? It's a nice idea, but for me it's more like 3 iterations @ 60 seconds.
 
[quote author=Sako link=topic=51.msg313#msg313 date=1145300823]
So you're gonna wait 50 mins in front of the comp just to have one shot of Ode? It's a nice idea, but for me it's more like 3 iterations @ 60 seconds.
[/quote]

HaHa, I'm not going to wait at all for a buff. But I was seeing so many scripts written that would wait forever for the buff. You got the point, and made a reasonable decision as I am sure others have done. I just showed the way.

Thanks Alexander, We were typing at the same tipe :)
 

Sako

Member
Yeah, it was just to show how I would change it. Then again, it's me who's on dialup, and my mom would kill me if I just sat there for 50 minutes :D
 
Top