auto BHH and friends

Bale

Minion
This script has gone through many versions and authors so I am creating this new post to introduce it. The original thread resumes in the next post.


The purpose of this script is to automatically go to the Bounty Hunter Hunter, accept bounties, hunt them and turn in the completed bounties for lucre.

To install this script, please copy/paste the following line into KoLmafia's CLI and press enter:
svn checkout https://svn.code.sf.net/p/autobhh/code/
 
Last edited:

izchak

Member
This post is for my BHH library, and a small script to demonstrate both its usage (for your own scripts), and also to do some automated bountyhunting, if you dont want to write your own script to do so.
The BHH Library is explained below. I started this new thread mostly so I could use degrassi's version checking script.
The auto bountyhunt script features use of the olfaction skill (if you have it) to track the appropriate monster. It also features some interesting 'auto adventuring' code, of a style I've found myself using more and more often. Basically, it over rides mafias built in adventure() method, while still retaining the benefits of your battleaction (whether its a consult ash script, a basic CCS, or just 'attack with weapon'. whatever), your defined HP and MP restoration, and mood maintenance. This has use in a wide variety of places nowadays.
An example of other areas where this is useful

  • [li]Throwing a butterfly at the first duck on the farm, during the islandwar quest[/li]
    [li]Identifying spheres in the hidden city zone by using them in combat[/li]
    [li]Identifying bang potions by using them in combat[/li]
    [li]Using flyers on monsters during the entire islandwar quest, if you have a flyer to use[/li]
Just to name a few.

I also use degrassi's interesting version tracking script, because its a cool script! (thanks, degrassi!)

BTW: I haven't had a chance yet to test the auto bountyhunt script in an area with choice adventures, I'm not 100% sure if those will get handled correctly by the script.

EDIT: Whoops, I forgot to include a string to make the version checking actually work. D'oh!

[current version: 1.0]
 

izchak

Member
About the BHH Library, bountyhunting.ash, bounty.txt, and 'make bountytxt.ash'

These scripts make use of a clever idea by macman to store data about all the potential bountyhunts in a map file, so that you can access metadata about the various bountyhunts (how many items, which items, which zone, etc). This data file uses the following metadata for each bountyhunt.
Code:
record BountyInfo
{
	int bountyTarget;
	location bountyLocation;
	item bountyItem;
	boolean muscleSignSafe;
	# -1 means boost -combats, 0 means leave alone, 1 means boost +combats
	int combats;
	string trackableMob;
	int [int] choiceAdventureChanges;
};
I think it's fairly self descriptive.
"Bounty.txt" is the actual data file used, "make bountytxt.ash" is the script one can use to generate "bounty.txt".

I have also written a script to generally facilitate scripted bountyhunting, although it will not actually do your bountyhunting for you. This script is "bountyhunting.ash". Of particular interest is a function which will report which bountyhunts are available, so you can make 'smart' scripted decisions as to which bountyhunt to take.
I make use of this library file in "auto bountyhunt.ash".
Code:
# returns a map of bountyinfo objects
# each one represents one of todays bounty hunting options
# the first one is the 'easy' one, third one is the 'hard' one
BountyInfo [int] bounty_options ()

There are several other useful bountyhunt related functions.
Code:
# accept a given bounty hunt with the BHH
boolean accept_bounty(item acceptplz)

# return true if you have an outstanding hunt
boolean have_bountyhunt()

# return true if you've completed a hunt today
boolean done_bountyhunt()

# just in case you want to cancel
void cancel_bountyhunt()

# just in case you forget your current bounty
BountyInfo current_bounty()

And finally:
Code:
boolean can_access_hunt(BountyInfo hunt)
This final function attempts to figure out if you can access the particular bountyhunt zone.
 

kain

Member
very spiffy ... very very ... I need to work my smell tome into my CCS (I should hit 200 lucres on Wednesday!!) (actually, I think it's your CCS! -- but modified a bit)

I poked through the code, though, but I'm not seeing the "combats" flag activated anywhere. Is the functionality just not implimented? I'll poke into that as well, if not.
 

macman104

Member
[quote author=izchak link=topic=1473.msg6831#msg6831 date=1201313455]
About the BHH Library, bountyhunting.ash, bounty.txt, and 'make bountytxt.ash'

These scripts make use of a clever idea by macman to store data about all the potential bountyhunts in a map file, so that you can access metadata about the various bountyhunts (how many items, which items, which zone, etc).[/quote]You're too kind.
 

Paragon

Member
I was attempting to get three triffid barks from the spooky forest, everytime it hit a choice adventure it got stuck in an infinite loop.
 
[quote author=Paragon link=topic=1473.msg7139#msg7139 date=1202675303]

I was attempting to get three triffid barks from the spooky forest, everytime it hit a choice adventure it got stuck in an infinite loop.
[/quote]

I think, as suggested by izchak in his comments, run_combat doesn't handle the completion of choice adventures.

Edit: I think I was able to fix this by changing

Code:
		} else if(contains_text(data, "choice.php")) {
			# uhhhh, I *hope* this works!
			run_combat();
                }

to

Code:
		} else if(contains_text(data, "choice.php")) {
			adventure( 1, here );
                }
 

Paragon

Member
Oh, you beat me to it... I was just about to say that you could fix it by changing line 100 to
cli_execute("adventure 1 "+to_string(here));
 
My fix apparently didn't quite work. Today in Sleazy Back Alley, the script would stop after hitting a choice adventure that didn't use up an adventure (e.g., Entertainer, Sleazy Back Alley, etc.).

The best I can come with about how to modify the script to deal with that circumstance, is to change the logic of the while loop to remove the spend_to_here check, and just run the loop until the bounty is obtained. Can anyone think of a better way?
 

zarqon

Well-known member
You might be able to try a cli_execute("refresh")... (or "status refresh" or "refresh charsheet" or whatever the cli command is) I know whenever I'm in the middle of something and hit the little refresh button on the character pane, mafia completes what I'm doing before refreshing the info. I sometimes take advantage of that if I'm adventuring in the browser and reach something where I'd rather mafia handle it (like the louvre for instance). Just a thought.
 
Thanks, I'll give that a shot tomorrow.

(I just got my tome yesterday, so I'm excited to try all these Oflaction scripts out).

EDIT: FYI, it didn't work today. It choked on the choiceadventures in the Airship. So the script borks on choiceadvenures, whether or not they are "no cost" choice adventures.

My first adventure was the Random Lack on an Encounter choiceadventure, and I properly got the Mech via the chioceadventure. Olfaction wasn't cast, but I'd expect the script to work that way and only cast Olfaction at the start of a normal combat adventure and not a choice adventure. But after the combat, the script aborted. I thought my session log would contain the error message, but alas, it doesn't, and I've forgotten it. I'll try again

Anyway, I am at a loss. I played around some, calling the go_adventure function on the poop deck and Olfacting the wealthy pirates. That worked fine, and handled the choice adventure fine, getting me El Vibrato Spheres in accord with my choiceadv preference. (I'm using the daily builds, obviously, since a 12.2 hasn't rolled out yet to deal with the KoL item-screen changes).

So, to sum, as it appears to me, adventure(1, here) (and presumably Paragon's cli-execute) appears to handle some choiceadventures fine. But, at least in the context of this script, it doesn't handle those that choose a combat encounter or those that choose a no-adventure-loss option. I can't figure out why. Am I crazy and missing something?

If Veracity is reading this script, I saw somewhere (maybe the main forums) that she thought it would be reasonable to program mafia to not cast Olfaction if On The Trail is up. I haven't seen that in the daily build summaries, but if that programming does make it in, it probably obviates the problem here, since a mature ccs could then handle Olfaction.
 

Veracity

Developer
Staff member
[quote author=Mighty Xerxes link=topic=1473.msg7193#msg7193 date=1202935656]
If Veracity is reading this script, I saw somewhere (maybe the main forums) that she thought it would be reasonable to program mafia to not cast Olfaction if On The Trail is up.  I haven't seen that in the daily build summaries, but if that programming does make it in, it probably obviates the problem here, since a mature ccs could then handle Olfaction.[/quote]
I rarely read peoples' scripts, but I do tend to read forum threads here. Well, I scan them, at least, to see if there's something that needs to be fixed that isn't too much work. :)

OK, revision 5743 will skip casting Trancendent Olfaction in a CCS if you are already On the Trail. I tested it by adding a CCS entry for the raver giant after I selected today's bounty. It worked great. I should augment my CCS file to have the rest of the bounty monsters...
 
[quote author=Veracity link=topic=1473.msg7206#msg7206 date=1203054789]

I rarely read peoples' scripts, but I do tend to read forum threads here. Well, I scan them, at least, to see if there's something that needs to be fixed that isn't too much work. :)

OK, revision 5743 will skip casting Trancendent Olfaction in a CCS if you are already On the Trail. I tested it by adding a CCS entry for the raver giant after I selected today's bounty. It worked great. I should augment my CCS file to have the rest of the bounty monsters...
[/quote]

Thanks much!

And I did mean "this thread", not "this script". A bad proofreader is me.
 
To save others some work, here is something to start with for your ccs file. I made a few assumptions, in that I generally didn't tag a monster for 40 turn bounties, except (I think) dairy goats. I tagged the shaky clown, because that's what I figure I will tag if I'm doing that bounty in low level HC.

Code:
[Knob Goblin Barbecue Team]
1: skill olfaction
2: attack

[shaky clown]
1: skill olfaction
2: attack

[hobo]
1: skill olfaction
2: attack

[gearhead]
1: skill olfaction
2: attack

[albino bat]
1: skill olfaction
2: attack

[possessed can]
1: skill olfaction
2: attack

[triffid]
1: skill olfaction
2: attack

[weretaco]
1: skill olfaction
2: attack

[bean counter]
1: skill olfaction
2: attack

[mariachi calavera]
1: skill olfaction
2: attack

[filthy hippy]
1: skill olfaction
2: attack

[smarmy pirate]
1: skill olfaction
2: attack

[white knight]
1: skill olfaction
2: attack

[kobold]
1: skill olfaction
2: attack

[dairy goat]
1: skill olfaction
2: attack

[MagiMechTech MechaMech]
1: skill olfaction
2: attack

[Raver Giant]
1: skill olfaction
2: attack

[sommelier]
1: skill olfaction
2: attack
 

tyilo

Member
When i used the "auto bountyhunting.ash" it choosed the burned-out arcanodiode and it just used like 20,000 adventures before it was finished. Could you fix this? And how do you choose witch item you should choose first and second and third and... (if it is available)?
 

zarqon

Well-known member
I recently learned you can use "default" in your ccs to make it jump to your [ default ] section. So here's Xerxes' bounty-hunting ccs from above, with "default" subbed in to make it more all-purpose.

Code:
[ default ]
1: attack

[ Knob Goblin Barbecue Team ]
1: skill olfaction
2: default

[ shaky clown ]
1: skill olfaction
2: default

[ hobo ]
1: skill olfaction
2: default

[ gearhead ]
1: skill olfaction
2: default

[ albino bat ]
1: skill olfaction
2: default

[ possessed can ]
1: skill olfaction
2: default

[ triffid ]
1: skill olfaction
2: default

[ weretaco ]
1: skill olfaction
2: default

[ bean counter ]
1: skill olfaction
2: default

[ mariachi calavera ]
1: skill olfaction
2: default

[ filthy hippy ]
1: skill olfaction
2: default

[ smarmy pirate ]
1: skill olfaction
2: default

[ white knight ]
1: skill olfaction
2: default

[ kobold ]
1: skill olfaction
2: default

[ dairy goat ]
1: skill olfaction
2: default

[ MagiMechTech MechaMech ]
1: skill olfaction
2: default

[ Raver Giant ]
1: skill olfaction
2: default

[ sommelier ]
1: skill olfaction
2: default
 

tebee

Member
I was running into problems running out of MP when running the auto bounty hunting script, It's supposed to restore but wasn't for me so I changed it sightly to use the mafia auto-recover figures to decide when to do a restore.

the code changed is around line 104

Code:
		# here, either combat is over, or you hit a noncombat
		# now, lets restore HP and MP, as well as maintaining our mood
		if(check_restore("hpAutoRecovery", my_maxhp(), my_hp())) cli_execute("restore hp");
		if(check_restore("mpAutoRecovery", my_maxmp(), my_mp())) cli_execute("restore mp");
		cli_execute("mood execute");
	}


and also this line(#59) in check_restore commented out.

Code:
boolean check_restore(string property,int max, int current) {
	float threshold = to_float(get_property(property));
#	threshold = threshold * to_float("-1");
	threshold = max * threshold;
	if(current < to_int(threshold)) return true;
	return false;
}
 

dragonslayere

New member
[3077] Orc Chasm
Encounter: Spam Witch
Round 0: theeaznthree wins initiative!
Round 1: theeaznthree attacks!
You gain 32 Meat
You acquire an item: Spam Witch sammich
You acquire an item: sammich crust
You gain 10 Strengthliness
You gain 7 Enchantedness
You gain 5 Roguishness
Mood swing complete.
You acquire an item: filthy lucre
Using 1 31337 scroll...
You acquire an item: hermit script
You acquire an item: stat script
Finished using 1 31337 scroll.
Using 1 stat script...
You gain 124 Strengthliness
You gain 148 Mysteriousness
You gain 128 Roguishness
You gain a Moxie point!
Finished using 1 stat script.
Using 1 hermit script...
Finished using 1 hermit script.

don't know if it was intended or not but the script did the 31337 quest for me... :D
 
Top