KoLmafia Guide: Automatic Buffing II

From KoLMafia
Jump to: navigation, search

This script is another buff script. However, we increase the complexity by using a buffBot and we also show you how to wait for an effect to occur. This particular script is for reducing combat frequency.

a) Note the use of void main to input how many tens-of-turns to buff.

b) You've seen the code to buy a certain amount of an item before and use it.

c) Note the usage of the buffBot! You can use this with your guild's bot. I obviously have mine hardcoded based on information about that particular bot. In this case, it gives me the Sonata of Sneakiness. Bonus) You can only have 3 songs going. So an extra step might be to first attempt to shrug off a third song that might interfere with the buff process. For example, you might get rid of an unneeded Ode to Booze.

d) As a Disco Bandit, I can use a skill to reduce my combat frequency. Note the syntax of using one of your innate skills.

e) The print("xx"); statement is great for showing information to the user in a script.

f) Finally, note the have_effect() function. It tests to see if your character has a specific buff/debuff. If so, the result is the number of turns left of having it. If not, it returns 0. In any case, you can see the easy true/false test method is to check for turns of buff greater than 1 (for true), or less than 1 (for not having the buff).

g) You also see the Repeat/Until loop going too. Note the refresh_status is necessary and is similar to clicking the refresh button in Mafia. This is needed when you are waiting for outside events to occur such as messages and other-player's buffs.

h) You can adapt the if <not status>, wait until status OK loop for your own purposes. NOTE: If the buff fails to work (say you already have 3 songs!), then you are STUCK IN AN INFINITE LOOP! Hence, I strongly suggest you remind yourself by adding a print statement beforehand, so you can 'abort' if needed.

## Lower Combat as much as possible.
void main( int numberOfTurnsInTens )
  ## Chunks are cheaper than Deoderant.
  if ( item_amount( $item[Chunk of rock salt] ) < numberOfTurnsInTens )
    buy( numberOfTurnsInTens - item_amount( $item[Chunk of rock salt] ), $item[Chunk of rock salt] );
  use( numberOfTurnsInTens, $item[Chunk of rock salt] );

  ## Sonata of Sneakiness
  cli_execute("csend 23 meat to KolaBuff");

  ##Smooth Movement
  use_skill( numberOfTurnsInTens , $skill[Smooth Movement] );

  print("Done... we're just waiting for the buff to affect us");
  print(" you can type 'abort' if its taking too long");
  if(have_effect($effect[Sonata of Sneakiness]) < 1)
   repeat {wait(5); refresh_status();}
   until (have_effect($effect[Sonata of Sneakiness]) > 1);


Continue to Post-Lesson 4: Logout Scripting for Overdrinking, Adventure Equipment, Librams, etc.