Bounty Hunting *just* sticky stardust

Heyas, again!

So I'm farming the hole in the sky for stars and lines and star charts. I've heard Icy Mountaintop is better for meat grinding, and Giant Castle is better for making meat in the form of items, but I like hole in the sky. There are only ever 3 outputs, so theyr'e way easier to see at a glance how much you've ground today.

(I know, I know: this is not optimal... but bleh. That's not the point here :p)

What I want to do is, before script grinding there, run and see if the bounty hunter is doing a special on "sticky stardust" today. If he isn't, i don't care, but if he is, I figure I could collect an extra filthy lucre here and there for no extra effort.

But I don't know much. If anyone feels like helping me with even part of this, I would be grateful :) I couldn't steal code from what I needed from bounty.ash

pseudocode:
if not already on a bounty hunt
if bounty hunter wants "sparkling stardust"
then
get "sparkling stardust bounty"

I think Kolmafia auto-hands-in a bounty when it's complete, so I don't need to code that..

Thanks:)
 

lostcalpolydude

Developer
Staff member
It looks like you could just use
visit_url("bhh.php?action=takebounty&whichitem=2471&pwd");
to try to accept it, and you just won't get one if that bounty isn't available.

That could be the start of your script. If mafia doesn't automatically hand it in, your logout script or whatever could have visit_url("bhh.php");
 

Bale

Minion
PHP:
boolean sticky_today() {
	string bhh_page = visit_url("bhh.php");
	switch {
	case bhh_page.contains_text("I can't assign you a new one"):
		print("Bounty hunt already completed today.", "red");
		return false;
	case bhh_page.contains_text("I'm still waiting for you to bring me"):
		print("You're already on a bounty hunt!", "red");
		return false;
	case bhh_page.contains_text("6 bits of sticky stardust"):
		print("Hunting for 6 bits of sticky stardust!", "green");
		visit_url("bhh.php?pwd&action=takebounty&whichitem=2471");
		return true;
	}
	print("Not asking for sticky stardust today. Sigh.", "red");
	return false;
}

I think Kolmafia auto-hands-in a bounty when it's complete, so I don't need to code that..
yup! That works fine.
 
Last edited:

heeheehee

Developer
Staff member
But... that hits the server twice! (Would it be better to hit up Noblesse Oblige's calendar or the game server for the bounty info?)

I also want to see what it returns when the page contains this text: "I'm still waiting for you to bring me 6 bits of sticky stardust" -- true or false? Oh no!
 

Bale

Minion
Yeah, it does hit the server twice if the bounty is likeable, but I like having the extra feedback. I guess I'm just naughty.

I'd rather not hit up the NO Calender since sometimes it isn't updated. That can be troublesome.

I also want to see what it returns when the page contains this text: "I'm still waiting for you to bring me 6 bits of sticky stardust" -- true or false? Oh no!
You think I should have returned true for that case instead of false? Perhaps. I suppose that all depends on how Richo wants to use the return value.
 
Yeah, Bale had the right of it. It doesn't matter if i'm already on a sticky stardust bounty, or any other sort of bounty. I merely want to *get* a sticky bounty if I am otherwise unoccupied.

Cheers :)

(mmm, and there is a sticky stardust bounty today.. time to go home and test it.. :p)
 

fronobulax

Developer
Staff member
Yeah, it does hit the server twice if the bounty is likeable, but I like having the extra feedback. I guess I'm just naughty.

I'd rather not hit up the NO Calender since sometimes it isn't updated. That can be troublesome.
Philosophy questions - One of Hola's stated goals for Kolmafia was to reduce server load. That goal is still respected and honored. How important is that goal when applied to an ash script (as opposed to the mafia code)? Is there a general consensus that if two scripts produce identical results then the one that uses less server hits is "better" or more elegant?

Similarly, if I can accomplish X by hitting KoL or by hitting another site, don't I still prefer to hit KoL even if that increases KoL server hits? Perhaps I just have too many battle scars from the brave new world of Service Oriented Architecture where my service is constantly breaking because the dependent services don't or won't honor their service level agreements and the eventual solution is to re-implement the critical service in house so we are responsible.
 
Also, as I found out last night, if you are already on another bounty and then you give up that bounty, it *offers you the same selection of bounties from the day where you picked that bounty up*. That is, it overrides the "normal" bounties for that day. Whereas Nob Obb will report the ones that are normal. So.... even when updated, NO isn't going to be 100% accurate for a given moment.
 

zarqon

Well-known member
@frono: I would strongly agree that doing the same thing with less server hits is superior. It would run faster as well.

About getting data from outside KoL: if the data can be reliably obtained elsewhere, do it. A script should have a fallback in case the other server fails to provide the needed info (which may something as simple as an abort message), but looking elsewhere first is a conscientious move.
 
Hmm.. how do you guys tell what the item number is (2471 in the example above?)

For instance, if I wanted to set it to discarded pacifiers, how could I tell what item number that is?

(I looked around but couldn't find this on the wiki. Am hoping it's not obvious and i missed it :p )
 

Bale

Minion
'tis not hard. Mafia has a command called to_int(). For instance:

print("Item number for discarded pacifiers is "+to_int($item[discarded pacifier]));

Alternatively you could look it up on the wiki. :)
 

slyz

Developer
You can do an alias:
PHP:
alias itemnum => ashq print($item[%%].to_int());
This will allow you to find out an item's number from the gCLI:
Code:
> itemnum prim beer

2695

You can also look in Help -> Internal Database.
 

zarqon

Well-known member
The best way is the ever-useful itemref alias:

Code:
alias itemref = ash foreach i in $items[] if(i.to_lower_case().contains_text($string[%%].to_lower_case())) print(to_int(i)+": "+i)

> itemref pacifier

2415: discarded pacifier
4195: pacifier necklace
 
Top