To effect

From Kolmafia
Jump to navigation Jump to search

Function Syntax

effect to_effect(int convert )

effect to_effect(string convert )

effect to_effect(skill convert )

  • convert is the int, string or skill to convert

When supplied an int or string, returns the effect that corresponds to the specified parameter convert. When supplied a skill, this returns the effect that is given when the skill convert is cast on a player.
Note: This function can not return effects of items. For that, use effect_modifer(). If you are attempting to see the duration of an effect, use numeric_modifier(item, "effect duration").

Code Samples

Following example shows basic to_effect operations.

//int
print(to_effect(100), "green");
//strings
print(to_effect("Smooth"), "green");
print(to_effect("Smooth Move"), "green");
//skills
print(to_effect($skill[Disco Aerobics]), "green");

For more info about effects from numbers and skills, see Effects.


It gives the following output.

Stabilizing Oiliness
Hella Smooth
Smooth Movements
Disco State of Mind



Following example tells which buffs you are missing but could have.

void buffs_check() {
int amount;
boolean have_buff;
boolean[skill] active_buffs, bot_buffs, castable_buffs;
   foreach it in $skills[] {
      amount = have_effect(to_effect(it));
      if (amount == 0)
         have_buff = false;
      else have_buff = true;
      
      if (have_buff) //Currently have the effect active
         active_buffs[it]=have_buff;
      if (it.buff == true && !have_buff && it.class != $class[none] && it.level != -1 && it.dailylimit == -1 && it != $skill[Spiky Shell] && it != $skill[Antibiotic Saucesphere]) //buff bot buffs
         bot_buffs[it]=have_buff;
      if (have_skill(it) && it.combat != true && !have_buff && to_effect(it) != $effect[none]) //buffs you can cast on yourself
         castable_buffs[it]=have_buff;
   }
   print("You currently have the following buffs active:", "red");
   foreach it in active_buffs
      print(""+it+"", "green");   
   print("");
   print("You could get the following buffs from a buff bot:", "red");
   foreach it in bot_buffs
      print(""+it+"", "blue");   
   print("");
   print("You could cast the following buffs on yourself:", "red");
   foreach it in castable_buffs
      print(""+it+"", "purple");
}
buffs_check();

Special

If convert is an effect that cannot be given by use of a skill, and is supplied as such, or no match is found for a supplied string or int type, this function returns $effect[ none ].