Item databases?

Geo

New member
So at the moment I'm working on a buff script that has the immediate goal of prebuffing for item drops to get as many of the +item dependant boss loots from hobopolis as possible without bankrupting yourself in the process.

I say immediate because as I wrote out the records I realized how terrible it would be to want to modify for something else and have to create an entirely new record tree. Right now the tree is pretty extensive (and could probably use a couple variable renames) and unfortunately the only way to add an item is individually. If the purpose of the script was solely for pet buffing where the item list is much more manageable hand-coding each wouldn't be as terrible. As it stands I've created my own set of records that holds relevant stats for items and resulting effects. Although I did just realize I need to code relevant buff names as to not let the script try and buff with the same effect twice from separate items.

Currently a "quick" item to code looks like this
Code:
petWeight[1].itemName 			= "irradiated pet snacks";
petWeight[1].itemMiscEffects.famWeight 	= 10;
petWeight[1].itemEffectDur 		= 10;
petWeight[1].itemPrice 			= mall_price(to_item(petWeight[1].itemName));

and a hell item looks like this
Code:
itemDrop[11].itemName 			= "crystal skeleton vodka";
itemDrop[11].itemDropBonus.itemDrop 	= 25.0;
itemDrop[11].itemMiscEffects.monsterLvl = 15;
itemDrop[11].itemEleDmg.spookyDmg 	= 20;
itemDrop[11].itemMiscEffects.advGain 	= 16.0;
itemDrop[11].itemStatBonus.musGain 	= 24.5;
itemDrop[11].itemStatBonus.moxGain 	= 24.5;
itemDrop[11].itemStatBonus.mysGain 	= 24.5;
itemDrop[11].itemReqs.reqSober 		= 3;
itemDrop[11].itemReqs.reqLvl 		= 3;
itemDrop[11].itemEffectDur  	        = 20;
itemDrop[11].itemPrice 	        	= mall_price(to_item(itemDrop[11].itemName));

I was wondering if something exists already to manage/create locally stored item lists so I can search a local file for items opposed to hard-coding in each item with a particular relevant bonus whenever I feel like adding some functionality.

Included my item "record" (I come from c++ so it's a struct as far as I'm concerend) and the base script for input/constructive criticism, not looking for someone to do it for me, but nudges in the right direction are always welcome :D
 

Attachments

  • itemStruct.ash
    1.7 KB · Views: 43
Last edited:

Theraze

Active member
Also, just looking at what's easily available in direct proxy records would probably help. ash to_item("itemname"); or ash $item[itemname]; will get you the proxy records. The difference between to_item("") and $item[] is that you can convert a string to_item...

Example:
This works:
string itemname = "irradiated pet snacks";
print(to_item(itemname));

This doesn't work:
string itemname = "irradiated pet snacks";
print($item[itemname]);

In the second case, you'll probably get $item[null] or an error... I can't remember which because I've got mafia closed hoping that the KoL announcement about the Twitch areas still being available today is true, but I'll wait until the morning before playing to find out. :D
But regardless of if it's an error or item null, it's not what you want. So don't do that. Convert if you're converting.

Regarding pulling out effects, you can use to_effect on an item, even if you need to use to_item on a string first.
 

zekaonar

Member
Here is a mini scriptlet I wrote called Buffup.ash. It lists all consumables available in the mall sorted by price per buff per turn. For Hobo boss buffing you would call "buffup Item Drop" and it would return a list of the following:

Code:
> buffup Item Drop

bottle of bubbles 0.54 meat/value/turn, 5,380 meat, +100 for 100 turns.
Knob Goblin eyedrops 1.33 meat/value/turn, 200 meat, +15 for 10 turns.
resolution: be happier 2.44 meat/value/turn, 733 meat, +15 for 20 turns.
blue-frosted astral cupcake 3.16 meat/value/turn, 1,895 meat, +30 for 20 turns.
Gene Tonic: Penguin 3.86 meat/value/turn, 2,895 meat, +25 for 30 turns.
eagle feather 4.5 meat/value/turn, 1,798 meat, +20 for 20 turns.
resolution: be luckier 4.5 meat/value/turn, 450 meat, +5 for 20 turns.
recording of The Ballad of Richie Thingfinder 5.35 meat/value/turn, 2,141 meat, +20 for 20 turns.
Polka Pop 5.45 meat/value/turn, 3,000 meat, +55 for 10 turns.
...



Code:
import <zlib.ash>;

int get_price( item itm ) {
	if ( historical_age( itm ) < 14 ) return historical_price( itm );
	return mall_price( itm );
}

record potion
{
	item i;
	int value;
	int buff;
	int turns;
	float costPerValue;
};

float costPerValue(potion p) {
	return p.costPerValue;
}

float round2(float f) {
	return round(f*100.0)/100.0;
}

void main(string modifier_name) {

	potion[int] potions;
	int i=0;

	foreach it in $items[] { 
		effect e = effect_modifier(it, "effect");
		if (e != $effect[none] && numeric_modifier(e, modifier_name) > 0 && get_price(it) > 0) {
			potions[i].i = it;
			potions[i].value = get_price(it);
			potions[i].buff = numeric_modifier(e, modifier_name);
			potions[i].turns = numeric_modifier(it, "Effect Duration");
			potions[i].costPerValue = to_float(get_price(it)) / to_float(potions[i].buff * potions[i].turns);
			i = i+1;
		}
	}
	sort potions by costPerValue(value);
	foreach p in potions {
		print_html(potions[p].i + " " + round2(potions[p].costPerValue) + " meat/value/turn, " + rnum(potions[p].value) + " meat, +" + potions[p].buff + " for " + potions[p].turns + " turns.");
	}
}
 

xKiv

Active member
Does that suggest familiar-weight potions if you have a fairy?
(I used the result of calling maximize(), but I still have a few wrinkles to iron out)
 

digitrev

Member
Does that suggest familiar-weight potions if you have a fairy?
(I used the result of calling maximize(), but I still have a few wrinkles to iron out)

It does not. It also does not properly handle things whose effect depends on its duration (such as the bottle of bubbles, the love songs, etc...). You also have to be exact (as in give it an exact term from the modref list).

I've made some changes:
Code:
import <zlib.ash>;

int get_price( item itm ) {
	if ( historical_age( itm ) < 14 ) return historical_price( itm );
	return mall_price( itm );
}

record potion
{
	item i;
	int value;
	float buff;
	int turns;
	float costPerValue;
};

float costPerValue(potion p) {
	return p.costPerValue;
}

float round2(float f) {
	return round(f*100.0)/100.0;
}

void main(string modifier_name) {
	potion[int] potions;
	int i=0;

	foreach it in $items[] { 
		effect e = effect_modifier(it, "effect");
		if (e != $effect[none] && numeric_modifier(e, modifier_name) > 0 && get_price(it) > 0) {
			potions[i].i = it;
			potions[i].value = get_price(it);
			potions[i].buff = numeric_modifier(e, modifier_name);
			potions[i].turns = numeric_modifier(it, "Effect Duration");
			switch (it) {
				//handle the 100 turn item/meat negative linear buffs
				case $item[bottle of bubbles]:
				case $item[Uncle Greenspan's Bathroom Finance Guide]:
					potions[i].buff *= 0.505;
					break;
				//handle love songs, max effect @ 20 turns, 5 turns per song
				case $item[love song of vague ambiguity]:
				case $item[love song of smoldering passion]:
				case $item[love song of icy revenge]:
				case $item[love song of sugary cuteness]:
				case $item[love song of disturbing obsession]:
				case $item[love song of naughty innuendo]:
					potions[i].value *= 4;
					potions[i].turns *= 4;
					switch(modifier_name.to_lower_case()){
						case "mp regen min":
						case "mp regen max":
						case "familiar weight":
							potions[i].buff *= 10;
							break;
						default:
							print(potions[i].buff);
							potions[i].buff *= 20;
					}
					break;
				//handle taffy, max effect @ 50 turns, 10 turns per taffy
				case $item[pulled red taffy]:
				case $item[pulled orange taffy]:
				case $item[pulled yellow taffy]:
				case $item[pulled green taffy]:
				case $item[pulled blue taffy]:
				case $item[pulled indigo taffy]:
				case $item[pulled violet taffy]:
					potions[i].value *= 5;
					potions[i].turns *= 5;
					switch(modifier_name.to_lower_case()){
						case "moxie experience":
						case "mysticality experience":
						case "muscle experience":
						case "familiar weight":
							potions[i].buff *= 5;
							break;
						case "familiar experience":
							potions[i].buff *= 10;
							break;
						case "moxie":
						case "mysticality":
						case "muscle":
						case "mp regen min":
							potions[i].buff *= 25;
							break;
						default:
							potions[i].buff *= 50;
					}
					break;
			}
			potions[i].costPerValue = to_float(potions[i].value) / to_float(potions[i].buff * potions[i].turns);
			i = i+1;
		}
	}
	sort potions by costPerValue(value);
	foreach p in potions {
		print_html(potions[p].i + " " + round2(potions[p].costPerValue) + " meat/value/turn, " + rnum(potions[p].value) + " meat, +" + potions[p].buff + " for " + potions[p].turns + " turns.");
	}
}

I changed the record to store buff value as a float, not an int. I tried to handle the weird "more turns = less strong" bottle of bubbles by finding the average value over the 100 turns of each, and I also tried to handle the love song & pulled taffy buffs. These needed special handling since their strength goes up as the turns of the buff do, so you need to multiply by a factor of 20/50 (and then divide again to handle the fact that mafia only returns integer values for numeric_modifier). Let me know if there are any other turn-based effects that I need to be worried about.
 
Last edited:

Geo

New member
Thanks for the examples here, it really helped me get a better grasp on the whole idea of the numeric modifier function. While i definitely have a better understanding i might recycle a bit of that scriptlet if you don't mind :D

as my original search script looks like...
Code:
foreach i in itemDrop
{
[INDENT]print(itemDrop[i].itemName + " @ " + itemDrop[i].itemPrice + " meat");
[INDENT]if((itemDrop[i].itemDropBonus.itemDrop*profitPrice) > itemDrop[i].itemPrice)
{
	print("using");
	//retreive_item(1, to_item(itemDrop[i].itemName)); 
	itemBonus += itemDrop[i].itemDropBonus.itemDrop;
	totalCost += itemDrop[i].itemPrice;
}[/INDENT]
else {print("Item not profitable");}	 
print("==========================");
print("   ");[/INDENT]
}

Same general idea but instead of using numeric_modifier() I checked against a table of potions i wrote up. In retrospect I could(and should) have declared it outside of main and just called it for both pet buffs and item drops with some slight modifications so the itemdrop script could handle pet weight. Looking forward to playing around with this more and seeing what it can do
 
Top