autoBasement.ash - Better basement automation

OK, here is an alternate outfit caching function which works for me:

Code:
void cache_outfits()
{
	if (outfits_cached || (my_basestat($stat[Mysticality]) < 200 || my_basestat($stat[Muscle]) < 200 || my_basestat($stat[Moxie]) < 200))
	{
		return;
	}

	vprint("Caching outfits...", "green", 1);
	string custom_outfits=visit_url("account_manageoutfits.php");
	
	boolean outfit_exists(string page, string o) {
		return contains_text(page,"value=\""+o+"\"");
	}

	boolean save = true;
	if (outfit_exists(custom_outfits, "Mysticality"))
	{
		strip_familiar("Mysticality");
		switch_hand("Mysticality");
		save = !outfit("Mysticality");
	}
	if ( save )
	{
	    outfit( "Birthday Suit" );
	    maximize("Mysticality" + maximize_familiar, false);
	    cli_execute("outfit save Mysticality");
	}
	familiarCache["Mysticality"].f = my_familiar();
	familiarCache["Mysticality"].i = familiar_equipped_equipment(my_familiar());

	save = true;
	if (outfit_exists(custom_outfits, "Muscle"))
	{
		strip_familiar("Muscle");
		switch_hand("Muscle");
		save = !outfit("Muscle");
	}
	if ( save )
	{
	    outfit( "Birthday Suit" );
	    maximize("Muscle" + maximize_familiar, false);
	    cli_execute("outfit save Muscle");
	}
	familiarCache["Muscle"].f = my_familiar();
	familiarCache["Muscle"].i = familiar_equipped_equipment(my_familiar());

	save = true;
	if (outfit_exists(custom_outfits, "Moxie"))
	{
		strip_familiar("Moxie");
		switch_hand("Moxie");
		save = !outfit("Moxie");
	}
	if ( save )
	{
	    outfit( "Birthday Suit" );
	    maximize("Moxie" + maximize_familiar, false);
	    cli_execute("outfit save Moxie");
	}
	familiarCache["Moxie"].f = my_familiar();
	familiarCache["Moxie"].i = familiar_equipped_equipment(my_familiar());

	save = true;
	if (outfit_exists(custom_outfits, "Gauntlet"))
	{
		strip_familiar("Gauntlet");
		switch_hand("Gauntlet");
		save = !outfit("Gauntlet");
	}
	if ( save )
	{
	    outfit( "Birthday Suit" );
	    maximize("HP" + maximize_familiar, false);
	    cli_execute("outfit save Gauntlet");
	}
	familiarCache["Gauntlet"].f = my_familiar();
	familiarCache["Gauntlet"].i = familiar_equipped_equipment(my_familiar());

	save = true;
	if (outfit_exists(custom_outfits, "MPDrain"))
	{
		strip_familiar("MPDrain");
		switch_hand("MPDrain");
		save = !outfit("MPDrain");
	}
	if ( save )
	{
		outfit( "Birthday Suit" );
		string command = "MP" + maximize_familiar;
		foreach it in $items[]
		{
			if (it.boolean_modifier("Moxie May Control MP") || it.boolean_modifier("Moxie Controls MP"))
			{
			    command = command + ", -equip " + it.to_string();
			}
		}
		maximize(command, false);
		cli_execute("outfit save MPDrain");
	}
	familiarCache["MP"].f = my_familiar();
	familiarCache["MP"].i = familiar_equipped_equipment(my_familiar());

	save = true;
	if (outfit_exists(custom_outfits, "MP Regen"))
	{
		strip_familiar("MP Regen");
		switch_hand("MP Regen");
		save = !outfit("MP Regen");
	}
	if ( save )
	{
	    outfit( "Birthday Suit" );
	    maximize("0.5 MP Regen min, 0.5 MP Regen max" + maximize_familiar, false);
	    cli_execute("outfit save MP Regen");
	}
	familiarCache["MP Regen"].f = my_familiar();
	familiarCache["MP Regen"].i = familiar_equipped_equipment(my_familiar());

	save = true;
	if (outfit_exists(custom_outfits, "Damage"))
	{
		strip_familiar("Damage");
		switch_hand("Damage");
		save = !outfit("Damage");
	}
	if ( save )
	{
	    string command = combat_stat.to_string();
	    foreach i in combat_equipment
	    {
		item equipment = combat_equipment[i].to_item();
		if (equipment != $item[none] && available_amount(equipment) > 0 )
		{
			command = command + ", +equip " + equipment.to_string();
		}
	    }

	    command = command + ", -familiar";
	    if(combat_stat.to_string() == "muscle")
		command = command + ", +melee";
	    else if(combat_stat.to_string() == "moxie")
		command = command + ", -melee";

	    outfit( "Birthday Suit" );
	    maximize(command, false);
	    cli_execute("outfit save Damage");
	}
	familiarCache["Damage"].f = $familiar[none];
	familiarCache["Damage"].i = $item[none];

	outfits_cached = true;

	vprint("Outfits caching complete!", "green", 1);
}
 
I think the purpose of running the maximizer each time was to check if stat gains had made a better equipment available to you. I don't think this happens in Veracity's version, but I could have misread.

I remember running into this and having a cursory glance. Of course, I didn't have much time to test, so I gave up quickly, but I seem to remember that the problem was Mafia itself getting out of sync with what I was wearing. I couldn't track down when/how that happened though.
 
To answer your question first: I think the reason to try and equip the outfit before maximizing is to save time on the maximizing, if we start out from a more optimal point the maximizer will likely run faster than if we start from scratch.

The caching is only performed if all your stats are above 200 and so running the maximizer if you can equip your outift may not be fully necessary. The problem that may ensue is if someone uses their "muscle" outfit during a run and saves that with in-run items. When we then equip it in aftercore that'll work out fine, but we would be better off maximizing on muscle to get a better outfit, or if even if the outfit is actually from an earlier basement run and thus contains only high-powered items, but the player has acquired better items since then. In that case we would also like to run the maximizer while caching.

Since the script is currently set up to not maximize at all if we have cached outfits we would be stuck with a worse outfit than strictly necessary for the run of the script if we didn't check for a better combination after equipping.
 
I think the purpose of running the maximizer each time was to check if stat gains had made a better equipment available to you. I don't think this happens in Veracity's version, but I could have misread.
As Winterbay points out, it only caches if all your stats are at least 200. Since no equipment has a higher requirement than that, there is no reason to remaximize/recache when your stats are higher than that. I suppose if you've gone and bought some better equipment, it would be useful for it to rebuild the outfits, but I think the normal case is that you simply want to run the script over the course of however many days and have it just use whatever you have without the overhead of re-saving outfits every single run.

I remember running into this and having a cursory glance. Of course, I didn't have much time to test, so I gave up quickly, but I seem to remember that the problem was Mafia itself getting out of sync with what I was wearing. I couldn't track down when/how that happened though.
Yeah, I found that too, but was unable to reproduce it with simple tests.

Equip an outfit containing my super-sweet boom box
maximize Moxie
-> Maximizer tries to equip super-sweet boom box
-> The EquipmentRequest doesn't detect that I already have it equipped and fails because I don't have another in inventory.

That seemed to be the issue when executing the script, but it didn't happen when doing it step by step as listed.
 
The problem that may ensue is if someone uses their "muscle" outfit during a run and saves that with in-run items. When we then equip it in aftercore that'll work out fine, but we would be better off maximizing on muscle to get a better outfit, or if even if the outfit is actually from an earlier basement run and thus contains only high-powered items, but the player has acquired better items since then. In that case we would also like to run the maximizer while caching.
Yes. Of course, that's not how _I_ use your script; I just powerlevel at the Shield Generator until I can use all my "stuff" and THEN worry about the basement.

So, I'll just keep my own version of the script customized to my taste.

I'll let you figure out how to deal with the other bug reports. ;)
 
Yay!I swapped in the previous version of that function, cache_outfits(), for the one posted on this page, and having done that, autobasement is now still going strong after a few dozen turns. Thanks!

edit: spoke too soon. It ran for like a hundred turns this time (yes, I know it says 45; I ran out of love songs after running it for a bit the first time)... maybe I was just unlucky the previous time, and lucky this time:
Basement level 653: Cold & Sleaze Elemental Resistance Test
Maximizing...
199 combinations checked, best score 186.89
Holding Hodgman's whackin' stick...
That's not an item, or it's not something you own.
unable to pass elemental test, quitting
Basement sucessfully automated for 45 out of 239 adventures.
 
Last edited:
The next time that happens could you please run the following CLI-commands:
ash available_amount($item[Hodgman's whackin' stick])
ash item_amount($item[Hodgman's whackin' stick])
ash equipped_amount($item[Hodgman's whackin' stick])
ash familiar_equipment($familiar[Disembodied Hand])

Edit: Then do a "refresh inv" and re-run them.
 
Got the same style of error as neminem, but while the script i performing Maximizer commands.

Code:
Maximizing...
2564 combinations checked, best score 2488.0
Putting on nurse's hat...
Equipment changed.
Wielding lawn dart...
Equipment changed.
Holding lawn dart...
Equipment changed.
Putting on sea salt scrubs...
Equipment changed.
Putting on sugar shorts...
Equipment changed.
Putting on hopping socks...
Equipment changed.
Putting on Uncle Hobo's epic beard...
Equipment changed.
Putting on lawn dart...
That's not an item, or it's not something you own.

> ash available_amount($item[Lawn Dart])

Returned: 3

> ash item_amount($item[Lawn Dart])

Returned: 1

> ash equipped_amount($item[Lawn Dart])

Returned: 2

> ash familiar_equipment($familiar[Disembodied Hand])

Returned: none
plural => nones
descid =>
image =>
levelreq => 0
quality =>
adventures =>
muscle =>
mysticality =>
moxie =>
fullness => 0
inebriety => 0
spleen => 0
notes =>
combat => false
reusable => false
usable => false
multi => false
fancy => false
candy => false
bounty => none
bounty_count => 0
seller => none
buyer => none
name_length => 0

> refresh inv

Refreshing closet...
Examining consumables in closet...
Examining equipment in closet...
Examining miscellaneous items in closet...
Updating inventory...
Requests complete.

> ash available_amount($item[Lawn Dart])

Returned: 2

> ash item_amount($item[Lawn Dart])

Returned: 0

> ash equipped_amount($item[Lawn Dart])

Returned: 2

> ash familiar_equipment($familiar[Disembodied Hand])

Returned: none
plural => nones
descid =>
image =>
levelreq => 0
quality =>
adventures =>
muscle =>
mysticality =>
moxie =>
fullness => 0
inebriety => 0
spleen => 0
notes =>
combat => false
reusable => false
usable => false
multi => false
fancy => false
candy => false
bounty => none
bounty_count => 0
seller => none
buyer => none
name_length => 0

An earlier attempt yielded me the same error. That time the Lawn dart worked, but not the Scratch 'n' sniff =S

Code:
Maximizing...
148 combinations checked, best score 647.0
Wielding lawn dart...
Equipment changed.
Holding scratch 'n' sniff sword...
That's not an item, or it's not something you own.

> ash available_amount($item[scratch 'n' sniff sword])

Returned: 1

> ash item_amount($item[scratch 'n' sniff sword])

Returned: 1

> ash equipped_amount($item[scratch 'n' sniff sword])

Returned: 0

> ash familiar_equipment($familiar[Disembodied Hand])

Returned: none
plural => nones
descid =>
image =>
levelreq => 0
quality =>
adventures =>
muscle =>
mysticality =>
moxie =>
fullness => 0
inebriety => 0
spleen => 0
notes =>
combat => false
reusable => false
usable => false
multi => false
fancy => false
candy => false
bounty => none
bounty_count => 0
seller => none
buyer => none
name_length => 0

> refresh inv

Refreshing closet...
Examining consumables in closet...
Examining equipment in closet...
Examining miscellaneous items in closet...
Updating inventory...
Requests complete.

> ash available_amount($item[scratch 'n' sniff sword])

Returned: 0

> ash item_amount($item[scratch 'n' sniff sword])

Returned: 0

> ash equipped_amount($item[scratch 'n' sniff sword])

Returned: 0

> ash familiar_equipment($familiar[Disembodied Hand])

Returned: none
plural => nones
descid =>
image =>
levelreq => 0
quality =>
adventures =>
muscle =>
mysticality =>
moxie =>
fullness => 0
inebriety => 0
spleen => 0
notes =>
combat => false
reusable => false
usable => false
multi => false
fancy => false
candy => false
bounty => none
bounty_count => 0
seller => none
buyer => none
name_length => 0

EDIt.
Using Veracity's outfit caching code seem to solve it, at least so far! (knock on wood!) =D
 
Last edited:
Well, the good news (now that this event is over and I can get back to other things), is that I ran it and it hasn't barfed like it did before, yet. The bad news is, that's cause instead it seems to be barfing by equipping entirely +muscle buffing equipment for elemental tests, instead of anything that reduces elemental damage. Which doesn't seem to be getting it very far, now that I'm well past level 500, even though I could still easily beat the elemental test with just a phial and a single piece of half-decent elemental resistance gear. It's also stopped a couple times with a message that looks like:
mpAutoRecovery => 0.05
mpAutoRecoveryTarget => 0.1

That looks "intentional", though, in the sense that there's some option it's setting that I should toggle off if I don't care about it stopping?
 
mpAutoRecovery => 0.05
mpAutoRecoveryTarget => 0.1

That looks "intentional", though, in the sense that there's some option it's setting that I should toggle off if I don't care about it stopping?

I'm pretty sure it's cleaning up here (restoring settings after changing them while the script was doing other stuff) after stopping for some other reason. I'm just guessing though, since I've never used this script and only briefly glanced at the code a while back.
 
Slight issue when the script maximizes and pulls items from the closet: it shuffles items (usually weapons or accessories) it decides to use more than one of between slots until it encounters an error. It sounds like it might be an issue with mafia's maximize code or the pull from closet function, I guess? It only pulls 1 of the item it wants and doesn't try to pull more than one, and just aborts.

For example, the following with lawn darts

Maximizing...
3414 combinations checked, best score 4103.0
Putting on battered old top-hat...
Equipment changed.
Wielding lawn dart...
Equipment changed.
Taking off lawn dart...
Equipment changed.
Holding lawn dart...
Why bother putting a weapon into your offhand if you don't have anything in your on-hand? "On-hand?" Whatever.

Easily solved by pulling another, but it crops up a fair amount.
 
Probably just a 'feature' of mafia's retrieve_item/acquire, since that will take items you have equipped before it pulls from closet or buys more.
 
On the other hand, "acquire 2 lawn dart" would uncloset 2 of them. The maximizer could take a pass over the equipment it wants and combine like items into a single request, rather than trying to get them one at a time.
 
And that would potentially fix the disembodied hand maximizer issues as well... Less server hits and actually fixing the problem. Would be nice.
 
The scrip worked well for a few levels of the basement, but then it kept on giving me this error
Initializing items and effects...
Taking off sugar shorts...
Equipment changed.
Items and effects initialization complete!
Caching outfits...
Putting on outfit: Mysticality
Equipment changed.
Maximizing...
155 combinations checked, best score 1308.0
Wielding scratch 'n' sniff sword...
You don't have the item you're trying to equip.
Already equipped or not, this message now always comes up and won't continue. Any reason for this and any way to bypass it? I was thinking maybe cause I have double-fisted skull smashing and it was trying to equip two of of them for me?
 
Possibly, which would be the same bug/FReq that Veracity mentioned in post 774. Alternatively, mafia could have gotten out of sync with your inventory and/or equipped items. Try refresh all, and see if it's still stuck.
 
Code:
Basement level 92: Muscle Test
Searching for "cursed scrunchie"...
Search complete.
Purchasing cursed scrunchie (2 @ 2,550)...
You acquire cursed scrunchie (2)
Purchasing cursed scrunchie (6 @ 2,600)...
You acquire cursed scrunchie (6)
Purchasing cursed scrunchie (1 @ 2,600)...
You acquire an item: cursed scrunchie
Purchasing cursed scrunchie (16 @ 2,772)...
You acquire cursed scrunchie (16)
Purchases complete.

Well that can't be right.
 
Code:
Basement level 92: Muscle Test
Searching for "cursed scrunchie"...
Search complete.
Purchasing cursed scrunchie (2 @ 2,550)...
You acquire cursed scrunchie (2)
Purchasing cursed scrunchie (6 @ 2,600)...
You acquire cursed scrunchie (6)
Purchasing cursed scrunchie (1 @ 2,600)...
You acquire an item: cursed scrunchie
Purchasing cursed scrunchie (16 @ 2,772)...
You acquire cursed scrunchie (16)
Purchases complete.

Well that can't be right.

No... I had something similar with the script buying 18 or so pokëmanns of some sort or other (aborted due to buy-limit fortunately). I have no idea why that would happen.
 
It's because Mafia now tries to acquire all the pieces of an outfit before putting it on.

The root of the problem is still here though: Mafia gets out of sync with KoL, for some reason, and thinks the item isn't in your inventory. That's why it tries to retrieve it.
 
Back
Top