Fluxxdog
Active member
I made a different one. This is just intended to be use as part of a dessert script, fired once a day, so it doesn't have the checks Bale's code has. It also only looks at what you have in stock. Gonna put some of those potions I've been stockpiling without thinking to use.
Code:
void avatar_chug(){
item[int] ava_potions;
foreach e in $effects[]{
if(string_modifier(e,"Avatar")!=""){
item i=to_item(excise(e.default,"use 1 ",""));
if(item_amount(i)>1) ava_potions[count(ava_potions)]=i;
}
}
int n=0; switch{
case count(ava_potions)>1: n=random(count(ava_potions));
case count(ava_potions)==1: use(1,ava_potions[n]); break;
default:
print("You don't have an avatar potion to spare!");
}
}