Not sure why... running bounty * again will hunt, but the aborting without adventuring is somewhat odd and not the way it ran when it had a data file. My guess is that it's not properly populating the 'bounty' data type before the bounty is accepted, but not sure...> bounty *
7 bits of wilted lettuce from Fernswarthy's Ruins
6 worthless pieces of yellow glass from Dungeons of Doom
40 coal buttons from Ninja Snowmen
Accepting the hunt for 40 coal buttons from Ninja Snowmen...
40 coal buttons from Ninja Snowmen
Bounty hunt failed.
string visit_bhh(string query) {
foreach b in bounty remove bounty[b];
string page = visit_url("bhh.php?pwd"+query);
if (page.contains_text("I can't assign you a new one")) { bounty.clear(); return page; }
matcher biggles = create_matcher("(?:bring me |<b>)(\\d+) (.+?)(?:,|</b>)",page);
while (biggles.find()) {
int b = count(bounty);
bounty[b].what = to_singular(biggles.group(2));
bounty[b].amount = biggles.group(1).to_int();
bounty[b].where = bounty_loc(bounty[b].what);
bounty[b].avail = can_has_bounty(b);
vprint(bstring(b), bounty[b].avail ? "green" : "red",3);
}
if (count(bounty) == 1) foreach i,r in bounty
print("Now hunting: "+bstring(i)+" (hunted so far: "+item_amount(r.what)+")","blue");
return page;
}
if (page.contains_text("I can't assign you a new one")) { bounty.clear(); return page; }
visit_bhh("&action=takebounty&whichitem="+bounty[n].what.to_int());
return (count(bounty) == 1);
else if (page.contains_text("All right, then\! Get out there and collect")) { bounty.clear(); }
Believe that obtain might be returning false even though it gets the right result in the end... at least, that's the only reason I can come up with it failing to display the total available lucre.Conditions satisfied after 9 adventures.
Visiting the Bounty Hunter Hunter...
You acquire an item: filthy lucre
Bounty hunt failed.
Requests complete.
string visit_bhh(string query) {
bounty.clear();
string page = visit_url("bhh.php?pwd"+query);
matcher biggles = create_matcher("(?:bring me |<b>)(\\d+) (.+?)(?:,|</b>)",page);
while (biggles.find()) {
int b = count(bounty);
bounty[b].what = to_singular(biggles.group(2));
bounty[b].amount = biggles.group(1).to_int();
bounty[b].where = bounty_loc(bounty[b].what);
bounty[b].avail = can_has_bounty(b);
vprint(bstring(b), bounty[b].avail ? "green" : "red",3);
}
if (count(bounty) == 1) foreach i,r in bounty
print("Now hunting: "+bstring(i)+" (hunted so far: "+item_amount(r.what)+")","blue");
return page;
}
Conditions satisfied after 10 adventures.
Visiting the Bounty Hunter Hunter...
You acquire an item: filthy lucre
Bounty hunt failed.
boolean bountyobtain(int n, string cond, location locale) {
cli_execute("conditions clear");
add_item_condition(n - have_item(cond), to_item(cond));
set_location(locale);
if (adventure(my_adventures(), locale)) return vprint("Out of adventures.",-1);
visit_bhh("");
return (count(bounty) == 0);
}
boolean hunt_bounty() {
if (count(bounty) > 1 && !accept_best_bounty(to_boolean(vars["do_smallest_bounty"]))) return false;
foreach i,r in bounty {
print("Adventuring for "+bstring(i)+"...");
if (!bountyobtain(r.bounty_count,r,r.bounty)) return false;
vprint("You have "+available_amount($item[filthy lucre])+" filthy lucre.",3);
}
return (count(bounty) == 0);
}
Conditions satisfied after 46 adventures.
Visiting the Bounty Hunter Hunter...
You acquire an item: filthy lucre
You have 2 filthy lucre.
Bounty hunt successful.
Requests complete.
boolean hunt_bounty() {
if (count(bounty) > 1 && !accept_best_bounty(to_boolean(vars["do_smallest_bounty"]))) return false;
foreach i,r in bounty {
vprint("Adventuring for "+bstring(i)+"...",2);
obtain(r.bounty_count,r,r.bounty);
if (get_property("currentBountyItem") != "") return false;
}
return vprint("You have "+available_amount($item[filthy lucre])+" filthy lucre.",3);
}
Replaced my copy with yours and got the fail. I think you'd need to capture the obtain... turn it back into this:Conditions satisfied after 4 adventures.
Visiting the Bounty Hunter Hunter...
You acquire an item: filthy lucre
Bounty hunt failed.
Requests complete.
(!obtain(r.bounty_count,r,r.bounty));
Just to clarify, had this (and it didn't work):Conditions satisfied after 33 adventures.
Visiting the Bounty Hunter Hunter...
You acquire an item: filthy lucre
Bounty hunt failed.
Requests complete.
boolean hunt_bounty() {
if (count(bounty) > 1 && !accept_best_bounty(to_boolean(vars["do_smallest_bounty"]))) return false;
foreach i,r in bounty {
vprint("Adventuring for "+bstring(i)+"...",2);
(!obtain(r.bounty_count,r,r.bounty));
if (get_property("currentBountyItem") != "") return false;
}
return vprint("You have "+available_amount($item[filthy lucre])+" filthy lucre.",3);
}
(!obtain(r.bounty_count,r,r.bounty));
vprint("Adventured for "+get_property("currentBountyItem")+"...",2);
if (get_property("currentBountyItem") != "") return false;
Checked and that appears right:Conditions satisfied after 30 adventures.
Visiting the Bounty Hunter Hunter...
You acquire an item: filthy lucre
Adventured for 0...
Bounty hunt failed.
Requests complete.
So instead of looking for "" we should be looking for "0" and then it should work...> pref bounty
currentBountyItem (user, now '0', default 0)
Conditions satisfied after 19 adventures.
Visiting the Bounty Hunter Hunter...
You acquire an item: filthy lucre
You have 2 filthy lucre.
Bounty hunt successful.
Requests complete.
string visit_bhh(string query) {
bounty.clear();
string page = visit_url("bhh.php?pwd"+query);
foreach l in $locations[] {
[COLOR="#FF0000"]if ($locations[Haunted Wine Cellar (Northwest), Haunted Wine Cellar (Northeast), Haunted Wine Cellar (Southwest), Haunted Wine Cellar (Southeast)] contains l) continue;[/COLOR]
if (l.bounty == $item[none] || !contains_text(page,l.bounty.bounty_count+" "+to_plural(l.bounty))) continue;
bounty[count(bounty)] = l.bounty;
avail[l.bounty] = can_has_bounty(count(bounty)-1);
vprint(bstring(count(bounty)-1), avail[l.bounty] ? "green" : "red",3);
}
if (count(bounty) == 1) foreach i,r in bounty
print("Now hunting: "+bstring(i)+" (hunted so far: "+item_amount(r)+")","blue");
return page;
}
visit_bhh("");
I think the current system is better, as it allows for new/unknown bounties to be possibly accepted without needing the script to be modified each time. But that's my opinion... take it as you will.