Best Between Battle Script Ever -- formerly AutoMCD

Theraze

Active member
Nope. What you're trying to do is make it no longer keep your current familiar active if it's already reached it's target, which is not your goal.

What that means is that we count to_int(get_property("_dreamJarDrops")), which should tell us how many Dream Jars have dropped today. As long as mafia sees the drops, you should be fine. Once that count reaches 5, stop switching. Your problem probably lies in that you want a default familiar but only when done farming. And the code is designed for either an override familiar (is_100_run) or familiar farming, but not both.

What you want to add is an additional line between these:
Code:
   foreach f,d in dfams if (d.count < 5) return use_fam(d.fam);
   return true;
Specifically if you always want that override, probably turning it into this:
Code:
   foreach f,d in dfams if (d.count < 5) return use_fam(d.fam);
   if (have_familiar($familiar[angry jung man])) return use_fam($familiar[angry jung man]);
   return true;
Alternatively, you could try this (untested) bit to always use the last farming familiar after:
Code:
   foreach f,d in dfams if (d.count < 5) return use_fam(d.fam);
   if (count(dfams) > 0) return use_fam(dfams[count(dfams)-1]);
   return true;

But your problem is that the current code is completely DONE with a familiar once it drops. It isn't switching to the Angry Jung Man because he's done. He's had his drop. He's no longer relevant to drop-farming.
 

Razorsoup

Member
If I used this
Code:
   foreach f,d in dfams if (d.count < 5) return use_fam(d.fam);
   if (have_familiar($familiar[angry jung man])) return use_fam($familiar[angry jung man]);
   return true;
and then tried changing familiars for some reason would BBB just switch back to the Angry Jung Man? Or would I need to add something that would let it only run that line once per day so it would switch when done farming familiar drops but still allow me to later pull a different familiar from my terrarium?
 

Theraze

Active member
It would switch to the Angry Jung Man after it finished farming your familiar drops. After every fight. Or every time the script was run, at least.
 

Razorsoup

Member
This is what I went with:
Code:
	foreach f,d in dfams if (d.count < 5) return use_fam(d.fam);
	if (to_boolean(get_property("_bbbDoneFamFarming")) != true && vars["bbb_defaultfamiliar"] != "")
		{
		familiar resf = to_familiar(vars["bbb_defaultfamiliar"]);
		if (resf != $familiar[none])
			{
			set_property("_bbbDoneFamFarming", "true");
			return use_fam(resf);
			}
		else
			{
			set_property("_bbbDoneFamFarming", "true");
			return use_fam(best_fam(vars["bbb_defaultfamiliar"]));
			}
		}
	return true;

I added a new zlib var that defines what familiar BBB will try to switch to when it is done farming the familiar drops. It should accept a familiar name or any type accepted by zlib's best_fam function. I used the mafia property "_bbbDoneFamFarming" as a flag to try and make BBB only do that switch once so if I decide to use a different familiar later in the day, BBB shouldn't override that. It seems to work so far.

A lot of this code was stolen from One Click Wossname
 

Theraze

Active member
Eh, you could have done that whole thing with the one line that I posted in 461 and not needing another variable. But... whatever floats your boat. :) Why do it in one line if you can do it in 14?

Though that would switch back to what you'd set as your default rather than using another variable. *shrugs*
 

Razorsoup

Member
Almost half of those lines are curly braces that I tend to put on separate lines to help me keep track of them.

My train of thought was as follows. Starting with
Code:
if (have_familiar($familiar[angry jung man])) return use_fam($familiar[angry jung man]);
that you provided, I then decided that I may want to manually switch to another familiar sometime but with that line BBB would just switch back to the Angry Jung Man right away. So I needed a way to have BBB only switch to the Angry Jung Man once after farming the familiar drops. I decided to use a mafia property to keep track of whether it had done that switch yet today and used one that begins with an underscore so it would automagically be reset each day. I end up with
Code:
if (to_boolean(get_property("_bbbDoneFamFarming")) != true && have_familiar($familiar[angry jung man])) {
    set_property("_bbbDoneFamFarming", "true");
    return use_fam($familiar[angry jung man]); }
Then I considered the fact that only one of my characters has the Angry Jung Man so it might be nice to be able to define that last familiar separately for each character.
Code:
if (to_boolean(get_property("_bbbDoneFamFarming")) != true && vars["bbb_defaultfamiliar"] != "") {
    set_property("_bbbDoneFamFarming", "true");
    return use_fam(to_familiar(vars["bbb_defaultfamiliar"])); }
And if I'm going to define the familiar as a variable, it might be nice to have it able to use the best_fam function from zlib. Since One Click Wossname will allow you to choose a specific familiar or a keyword for best_fam, I stole the code from that and adapted it to the overkill I ended up using.

Anway, after a little more editing today, here is where I'm at.
Code:
if (get_property("_bbbDoneFamFarming") != "true" && vars["bbb_defaultfamiliar"] != "") {
	familiar resf = to_familiar(vars["bbb_defaultfamiliar"]);
	if (resf != $familiar[none]) {
		set_property("_bbbDoneFamFarming", "true");
		return use_fam(resf);}
	else {
		set_property("_bbbDoneFamFarming", "true");
		return use_fam(best_fam(vars["bbb_defaultfamiliar"])); }}
 
Last edited:

Donavin69

Member
It appears that the Lure command has been removed from the CLI, I also don't like that BBB would use up all of my brains:
Code:
if (my_path() == "Zombie Slayer" && my_mp() < 10) {
      if (my_level() > 4 && item_amount($item[crappy brain]) > 0) cli_execute("lure * crappy");
      if (my_level() > 8 && item_amount($item[decent brain]) > 3) cli_execute("lure -3 decent");
   }

PHP:
> lure

Unable to invoke lure

> help lure

No matching commands found!

I've commented this part out in my copy, but when it gets updated my copy will be overwritten...(I use UR to maintain my horde on my Zombie character)
 

zarqon

Well-known member
Yep, sorry, that was a bit of personal code which I'll remove in the next update. I was just in a bit of a hurry to put up a version that didn't generate a bunch of friendly warnings. :)
 

Magus_Prime

Well-known member
Some fuzzy matching warnings from BestBetweenBattle:

Code:
Changing "Menagerie 2" to "Cobb's Knob Menagerie\, Level 2" would get rid of this message (BestBetweenBattle.ash, line 87)
Changing "Sleazy Back Alley" to "The Sleazy Back Alley" would get rid of this message (BestBetweenBattle.ash, line 87)
Changing "batrat and ratbat burrow" to "The Batrat and Ratbat Burrow" would get rid of this message (BestBetweenBattle.ash, line 121)
Changing "beanbat chamber" to "The Beanbat Chamber" would get rid of this message (BestBetweenBattle.ash, line 123)
Changing "black forest" to "The Black Forest" would get rid of this message (BestBetweenBattle.ash, line 125)
Changing "palindome" to "The Palindome" would get rid of this message (BestBetweenBattle.ash, line 263)
Changing "spooky gravy barrow" to "The Spooky Gravy Barrow" would get rid of this message (BestBetweenBattle.ash, line 373)
The string "wartime sonofa beach" no longer matches a location name; use "Sonofa Beach" instead
Changing "wartime sonofa beach" to "Sonofa Beach" would get rid of this message (BestBetweenBattle.ash, line 378)
 
I just found something else this script should do! If your next adventure is at Sonofa Beach and you have pulverize, then if there is a goatskin umbrella or a wool hat in your inventory, smash it promptly!

The adventures that give these items show up more frequently when you do not have them in inventory. By smashing them, you have a much higher output of yummy elemental wads. I'd prefer the wads to Zerg Rush.

However if you don't have pulverize, then keeping the hat and umbrella will increase your chance of getting yummy limes which are a decent booby prize.

Source


Heh...I just finally noticed this. Sweet!

Hooray for lots of wads in HCO!
 

Bale

Minion
I just thought I'd share some sections of my preAdventureScript. zarqon might want to borrow more from me to update this. I'm particularly fond of the Twin Peak code.

Code:
	float foodDrop() {
		float famBonus() {
			switch(my_path()) {
			case "Avatar of Boris":
				return minstrel_instrument() != $item[Clancy's lute]? 0:
					numeric_modifier($familiar[baby gravy fairy], "Item Drop", minstrel_level() * 5, $item[none]);
			case "Avatar of Jarlsberg":
				return my_companion() != "Eggman"? 0: (have_skill($skill[Working Lunch])? 75: 50);
			}
				item fameq = familiar_equipped_equipment(my_familiar());
				int famw = round( familiar_weight(my_familiar()) + weight_adjustment() - numeric_modifier(fameq, "Familiar Weight") ); 
				return numeric_modifier( my_familiar(), "Item Drop", famw , fameq );
		}
		return round(numeric_modifier("Item Drop") - famBonus() + numeric_modifier("Food Drop"));
	}

Code:
	case $location[Twin Peak]:
		int twinPeakProgress = to_int(get_property("twinPeakProgress"));
		if((twinPeakProgress & 1) == 0 && numeric_modifier("Stench Resistance") >= 4) {
			friendlyset(606,1,"Investigate the Stinky Room");
			friendlyset(607,1,"");
		} else if((twinPeakProgress & 2) == 0 && foodDrop() >= 50) {
			friendlyset(606,2,"Search for Food");
			friendlyset(608,1,"");
		} else if((twinPeakProgress & 4) == 0 && item_amount($item[Jar of Oil]) > 0) {
			friendlyset(606,3,"Follow music with Jar of Oil");
			friendlyset(609,1,"");
			friendlyset(616,1,"");
		} else if(twinPeakProgress == 7 && numeric_modifier("Initiative") >= 40) {
			friendlyset(606,4,"Chase your dopppleganger");
			friendlyset(610,1,"");
			friendlyset(617,1,"");
		} else 
			friendlyset(606,0,"What to do here?");
		return;


Code:
	case $location[an octopus's garden]:
		if(item_amount($item[glob of green slime]) > 0 && item_amount($item[soggy seed packet]) > 0)
			for i from 3555 to 3560 if(is_goal(to_item(i)) && have_equipped($item[straw hat])) {
				friendlyset(298, 1,"Plant seeds to get a sea fruit/vegetable goal.");
			}
		else friendlyset(298, 2,"Skip planting seeds. ("+item_amount($item[soggy seed packet])+" seed packets, "+item_amount($item[glob of green slime])+" green slime)");
	case $location[The Coral Corral]:
		if(my_location() == $location[The Coral Corral])
			retrieve_item(3, $item[sea cowbell]);
	case $location[The Marinara Trench]:
		if(my_location() == $location[The Marinara Trench])
			retrieve_item(1, $item[Mer-kin pressureglobe]);
	case $location[The Wreck of the Edgar Fitzsimmons]:
	case $location[The Mer-Kin Outpost]:
	case $location[Anemone Mine]:
	case $location[The Dive Bar]:
	case $location[The Caliginous Abyss]:
		if(get_property("lassoTraining") != "expertly" && item_amount($item[sea lasso]) < 2)
			retrieve_item(3, $item[sea lasso]);
		return;
	case $location[Mer-kin Library]:
		if(get_property("merkinVocabularyMastery") == "100") {
			int choice = 1;
			foreach prop in $strings[dreadScroll1, dreadScroll6, dreadScroll8]
				if(get_property(prop) != "0") choice += 1;
			if(choice == 4)  choice = 0;
			friendlyset(704, choice,"Card Catalog clues found: "+to_string(choice - 1));
		}
		return;

Code:
	case $location[The Penultimate Fantasy Airship]: 	// Handle that fiddly choice adventure for maximal stat gain
		switch {
		case item_amount($item[model airship]) < 1:
			friendlyset(182, 4,"Get a model airship.");
			return;
		case (get_property("currentBountyItem").to_item() == $item[burned-out arcanodiode]
		  || (!($strings[Bees Hate You, Avatar of Boris, Bugbear Invasion, Zombie Slayer, Avatar of Jarlsberg] contains my_path()) && available_amount($item[metallic A]) < 1))
		  && numeric_modifier("Monster Level") >= 20:
			friendlyset(182, 1, "Fight MechaMechs for metallic As or bounties");
			return;
		case is_goal($item[Penultimate Fantasy chest]):
			friendlyset(182, 2,"Get goal of fantasy chests.");
		case get_property("choiceAdventure182") == "2":   // Don't change user preference for chests
			return;
		case my_path() == "BIG!": // Stats are irrelevant in Big!
			friendlyset(182, 1,"Fights have items. Noncombat is just meaningless stats.");
			return;
		case numeric_modifier("Monster Level") >= 20 
		  && min(numeric_modifier("Combat Rate"), 0) /(-2.0) + 20 > (30 + numeric_modifier(my_primestat() + " Experience")) * (numeric_modifier(my_primestat() + " Experience Percent")/100.0 + 1):
			friendlyset(182, 3,"Get stats rather than fight MechaMechs for less.");
			return;
		case (max(-numeric_modifier("Combat Rate"), 0)/ 2 + 20) > (15 + numeric_modifier(my_primestat() + " Experience")) * (numeric_modifier(my_primestat() + " Experience Percent")/100.0 + 1):
			friendlyset(182, 3,"Get stats rather than weak combat.");
			return;
		default:
			friendlyset(182, 1,"Fighting gives more stats.");
		}
		return;

Code:
	case $location[Tavern Cellar]:
		if(numeric_modifier("Stench Damage") < 20)
			friendlyset(514, 1, "Less than +20 Stench Damage");
		else friendlyset(514, 2, "Stink out the Rats");
		
		if(numeric_modifier("Spooky Damage") < 20)
			friendlyset(515, 1, "Less than +20 Spooky Damage");
		else friendlyset(515, 2, "Scare off the Rats");
		
		if(numeric_modifier("Hot Damage") < 20)
			friendlyset(496, 1, "Less than +20 Hot Damage");
		else friendlyset(496, 2, "Burn out the Rats");
		
		if(numeric_modifier("Cold Damage") < 20)
			friendlyset(513, 1, "Less than +20 Cold Damage");
		else friendlyset(513, 2, "Freeze out the Rats");
		break;
 

Theraze

Active member
Notice that you removed the bronze breastplate NC goal-setting from the Airship... was that on purpose?
 

Theraze

Active member
For people who aren't you, keeping that line in would set it to skip if they've ever picked up a bronze breastplate and wouldn't set it as the choice unless they actively set it as a goal.

I think it's good to keep around since it only sets it as an option if you force the goal. :)
 

Bale

Minion
Yeah, that's why I'm not publishing my entire preAdventureScript. Too much of it is simply my taste and I don't want to generalize it for everyone's use. I'm just sharing some code that I think can be adapted for use here.


Bale: Would you be willing to share the entirety of your preAdventureScript?

Only privately. And you're on your own with it.
 

Theraze

Active member
Ah. Also, it's missing this bit which I find quite useful.
Code:
      case $location[The Mer-Kin Outpost]:
         if(my_location() == $location[The Mer-Kin Outpost]) {
            switch (get_property("merkinLockkeyMonster")) {
               case "mer-kin burglar":
                  set_property("choiceAdventure312", "1");
                  break;
               case "mer-kin raider":
                  set_property("choiceAdventure312", "2");
                  break;
               case "mer-kin healer":
                  set_property("choiceAdventure312", "3");
                  break;
               default:
                  break;
            }
         }
Spliced into the middle of your underwater block, hence the if check during a known case. :)
 

Bale

Minion
That's redundant. KoLmafia already does that automatically. It was necessary once, but then lost committed r12130 at the end of May. You can remove that from your script now.

Unfortunately that leads to three options that need to be tested in turn. I haven't come up with a good way to automatically advance to the next when I don't get a stashbox.
 
Last edited:

Theraze

Active member
Nifty. I knew it'd been made to save the monster, but hadn't caught that it also set the adventure for me.

I suppose the best way to do that would be by checking the non-combat queue and incrementing the adventure. Problem there is that there are the 3 different-named adventures as well as trying to make sure we stop trying to change things. Really better done in an after-adventure script, so we can see if we now have a stashbox and change the adventure if not.
 
Top