New Content - Implemented Pygmy Shaman item/effect: Lots of new Manuel Potions

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!");
	}
}
 

Crowther

Active member
That's pretty cool. I like how you backed them out from the effect. Cheapest made more sense back when there weren't many 100 meat potions in the mall. It still makes sense in run, but I need to find something else to do in aftercore (once I stop worrying about purity).
 

Bale

Minion
That's a good point about there being a lot of 100 meat avatar potions in the mall now. I've revised my script to choose a random potion from amongst the cheapest. Here's the function that I now have in my logoutScript.

Code:
void avatar_potion() {
	if(!can_interact()) return;
	// Check if there is an Avatar potion currently in affect
	foreach ef in my_effects()
		if(string_modifier(ef, "Avatar") != "") {
			print("Won't imbibe an Avatar Potion because you already look like a "+string_modifier(ef, "Avatar").to_monster()+".", "blue");
			return;
		}

	int price(item it) { return historical_age(it) > 1? mall_price(it): historical_price(it); }

	item av_item(effect av) {
		foreach a in av.all return a.replace_string("use 1 ", "").to_item();
		return $item[none];
	}

	item random_avatar() {
		item [int] avatars;
		foreach ef in $effects[]
			if(string_modifier(ef, "Avatar") != "")
				avatars [count(avatars)] = av_item(ef);
		item [int] short_list;
		sort avatars by price(value);
		int cheapest_price() {
			foreach x,av in avatars if(price(av) > 0) return price(av);
			return 0;
		}
		int min_price = cheapest_price();
		foreach x,av in avatars
			if(price(av) == min_price)
				short_list[count(short_list)] = av;
		return short_list[random(count(short_list))];
	}

	item choice = random_avatar();
	if(retrieve_item(1, choice))
		use(1, choice);
}
 

Veracity

Developer
Staff member
I'm declaring this done. There is item #7601, and 7600 and 7602 are avatar potions, so there might very well be another potion there, but you know - we now have an Avatar modifier for these potions, and if the item is eventually discovered, somebody will tell us about it. I don't think we need to keep this open, just waiting for an item to be eventually found. We support everything that is known.
 

Veracity

Developer
Staff member
(7601 is the temporary yak tattoo - an avatar potion -now available in the mall. That and items from the new IOTM are in, as of revision 14302)
 
Top