get all clovers from hermit

clichecow

New member
This script adventures in the unlucky sewer till you have at least one worthless item, then tries to loot the hermit for 1 clover. It repeats until the hermit does not have any more clovers to give you.

The only problem with this script is that it can not tell that the hermit is out of clover until it tries to get one, so it will always have a left over clover and hermit permit at the end. If anyone knows a way around this, tell me so I can update my script.

edit: added a line to make sure all your clovers are disassembled after you get them from the hermit.
 

Attachments

  • getclovers.ash
    1.1 KB · Views: 261

muffins

Member
This would go into an infinite loop if the character had no adventures...

Cleaned up a wee bit and removed the hermit permit part, as KoLmafia automatically buys a permit if you need one, and it would be a waste of meat for anyone who has used the hermit script. Can't test it right now since there aren't any clovers today and I don't have any characters with spare (non-drunk) adventures, but this should work.

Code:
//getclovers
//A script by Jordan Bentley (clichecow on KOL)

//Will get as many clovers as it can from the hermit.
//will always end with a worthless item in your inventory and no clovers at the hermit

int worthless_items()
{ 
	int total = 0;
	total = total + item_amount($item[worthless trinket]);
	total = total + item_amount($item[worthless knick-knack]);
	total = total + item_amount($item[worthless gewgaw]);
	cli_execute("echo You have " + total + " worthless items.");
	return total;
}

boolean loot_hermit()
{
if(my_adventures() > 0) {
	while (true)
		{
			while (worthless_items() < 1 && my_adventures() > 0)
				{
					adventure(1, $location[Unlucky Sewer]);
				}

			if (!(trade_hermit(1, $item[ten-leaf clover])))
		{
			return true;
		}

			use(item_amount($item[ten-leaf clover]), $item[ten-leaf clover]);
		}
}
}


void main()
{
if(loot_hermit())
	{
		cli_execute("echo worked");
	}
else if(!loot_hermit())
	{
		cli_execute("echo You are out of adventures/worthless items or the hermit has no clovers today.");
	}
}
 

Sako

Member
Uhm. How can this be modified to "spiceloop" all the possible clovers instead of just farming them?
 

Nightmist

Member
[quote author=Sako link=topic=625.msg3372#msg3372 date=1169375539]
Uhm. How can this be modified to "spiceloop" all the possible clovers instead of just farming them?
[/quote]
I thought the spiceloop got broken ever since the clovers were limited (since the loop uses a clover to get a trinket)?
 

Sako

Member
Yeah, but for this very same reason spices price skyrocketed, so even those 5-6 spices during a clover day are a lifesaver. I'd need a script that, if it's clover day, spiceloops for the number of clovers available.
 
[quote author=Nightmist link=topic=625.msg3373#msg3373 date=1169376979]

I thought the spiceloop got broken ever since the clovers were limited (since the loop uses a clover to get a trinket)?
[/quote]

You can no longer burn all your adventures spice looping. If the hermit has 6 clover though you can turn them into spices today, then tomorrow if he has clovers get them with the trinkets from today, and turn them into spices. The spice loop has been limited, not totally prevented.
 

dangerpin

Member
Thank you muffins and clichecow. I was just trying to figure out how to do this and here it is all laid out in front of me.

[edit] But in use it seems to think it is not a clover day every time.

Oh, and thank you too, efilnikufecin, for reminding me of an album I haven't listened to in a while.
 

muffins

Member
It's not always a clover day, but I have noticed it seems to think there is only one most days now. I saw a change in the SVN regarding purchasing hermit permits, so I think that might have "broken" it since I removed the hermit permit part... that, or the hermit has actually only had 1 clover per day lately.

I'll see if I can write something that checks the quest log to see if you've used the hermit script yet, if not and you have it in your inventory or closet, uses it, and if you don't have it and haven't uaed it, reverts back to hermit permits.

Edit: Okay, I just borrowed and modified efilnikufecin's script from the "Clovers (was Chatbot)" thread. It should be much friendlier for hardcore now, and should obtain at least 1 worthless item and hermit permit (only if needed) at the start of the script, and then only the total amount needed to match the number of clovers available. If you're in hardcore, it will obtain the trinkets via sewer, if you're in softcore, it will obtain 31337 scrolls.

Just tested it with one hardcore character and one softcore character, and both worked as expected! Let me know if you run into any problems.

Thanks efilnikufecin for doing the original!
 

Attachments

  • clovertest.ash
    3.3 KB · Views: 133
In examining your script I noticed a few things. First and foremost is the function void getone() defeats the purpose of:
Code:
if(haxored) {
	if(closet_amount($item[hermit script]) > 0){take_closet(1, $item[hermit script]);}
	if(item_amount($item[hermit script]) > 0){use(1, $item[hermit script]);}
}
which actually should have been moved in your script, but 1 issue in my own script has came into my view.

Code:
boolean haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");
That is obviously a variable declaration that has initialization code, but the above code which will use a hermit script did not change Haxored to true so the day that it uses the hermit script the user will not benefit. Yay! I get an F in scripting for the day I wrote the original script!

OK now it needs fixed. Recommended change:
Code:
int haxinit;

boolean haxored()
{
if(haxinit != 0) {return (haxinit == 1);}
if(closet_amount($item[hermit script]) > 0){take_closet(1, $item[hermit script]);}
if(item_amount($item[hermit script]) > 0){use(1, $item[hermit script]);}
if(contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R"))
  {
  haxinit = 1;
  return true;
  }
  else
  {
  haxinit = -1;
  return false;
  }
}
would replace the haxored variable declaration, and
Code:
if(haxored) {
	if(closet_amount($item[hermit script]) > 0){take_closet(1, $item[hermit script]);}
	if(item_amount($item[hermit script]) > 0){use(1, $item[hermit script]);}
}
else {
	if(item_amount($item[hermit permit]) < cloves) {
		buy(cloves - item_amount($item[hermit permit]), $item[hermit permit]);
	}
would be replaced by:
Code:
if((!haxored) && (item_amount($item[hermit permit]) < cloves))
  {
  buy(cloves - item_amount($item[hermit permit]), $item[hermit permit]);
  }

Well I'm off to do some writing of my own. This making a clover script to work in every possible situation is proving to be quite a task.[br]Posted on: February 06, 2007, 11:27:01 PM
Oh I forgot every reference to haxored will need to be made haxored()
 

muffins

Member
Ah, good points. I had actually just thought of the hermit script thing now, as my hardcorer is about to do the baron quest and, well, okay, it wouldn't have really made any difference as I always sewer at the beginning of the day, in case I run out of adventures before being able to make the 31337... still, a good point. I'll try to clean mine up, if only for myself :p Thanks again!
 

izchak

Member
This is what I did in a recent script for hermit looting. This was done for a character out of hardcore/ronin constraints, so getting worthless trinkets is trivial. I just buy and use 31337 scrolls, they yield enough worthless trinkets to cover their own cost.

Code:
int worthless_items() { 
    int total = 0;
    total = total + item_amount($item[worthless trinket]);
    total = total + item_amount($item[worthless knick-knack]);
    total = total + item_amount($item[worthless gewgaw]);
    print("you have " + total + " worthless items");
    return total;
}

boolean lootHermit() {
	boolean haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");
	boolean cloverday = false;
	int clovers_from_hermit = 0;
	if(! haxored) {
		print("you still need to haxor the hermit");
		return false;
	}
	# 5 is the maximum number of clovers the hermit can have
	# so make sure we have at LEAST five worthless items
	if(worthless_items() < 5) {
		cli_execute("buy 3 668 scroll");
		cli_execute("buy 3 30669 scroll");
		create(3, $item[31337 scroll]);
		use(3, $item[31337 scroll]);
	}
	while(trade_hermit(1, $item[ten-leaf clover])) {
		print("got another clover");
		clovers_from_hermit = (clovers_from_hermit + 1);
		cloverday = true;
	}
	cli_execute("use * ten-leaf clover");
	if(cloverday) {
		print("you got " + clovers_from_hermit + " clovers from the hermit");
		return true;
	} else {
		print("the hermit has no clovers today");
		return false;
	}
}

A careful observer will note that I used muffin's 'int worthless items' function, and I used efilnikufecin's cunning 'boolean haxored' initialization.
To use this function, you can simply go:
Code:
if(lootHermit)
    print("hermit looted successfully!");
 

PazSox

New member
[quote author=izchak link=topic=625.msg3872#msg3872 date=1173009083]
This is what I did in a recent script for hermit looting. This was done for a character out of hardcore/ronin constraints, so getting worthless trinkets is trivial. I just buy and use 31337 scrolls, they yield enough worthless trinkets to cover their own cost.
[/quote]

I tried putting your code into a script of it's own, so that I could test it, and i got this error: Unknown Variable 'int' (clover.ash)

Any help would be appreciated, I would really like to use this script, and i think the idea behind it is awesome!

-PazSox
 

izchak

Member
Well, how exactly did you put my code into your script?
If you just copy-pasted the entire code block into a text file, and saved it as a .ash file, it wouldn't work off the bat. You will need a void main() function, in which you call the loot_hermit() function.

Try this instead (this is good for copy-pasting, saving as an ash file, BTW)
Code:
int worthless_items() { 
    int total = 0;
    total = total + item_amount($item[worthless trinket]);
    total = total + item_amount($item[worthless knick-knack]);
    total = total + item_amount($item[worthless gewgaw]);
    print("you have " + total + " worthless items");
    return total;
}

boolean lootHermit() {
	boolean haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");
	boolean cloverday = false;
	int clovers_from_hermit = 0;
	if(! haxored) {
		print("you still need to haxor the hermit");
		return false;
	}
	# 5 is the maximum number of clovers the hermit can have
	# so make sure we have at LEAST five worthless items
	if(worthless_items() < 5) {
		cli_execute("buy 3 668 scroll");
		cli_execute("buy 3 30669 scroll");
		create(3, $item[31337 scroll]);
		use(3, $item[31337 scroll]);
	}
	while(trade_hermit(1, $item[ten-leaf clover])) {
		print("got another clover");
		clovers_from_hermit = (clovers_from_hermit + 1);
		cloverday = true;
	}
	cli_execute("use * ten-leaf clover");
	if(cloverday) {
		print("you got " + clovers_from_hermit + " clovers from the hermit");
		return true;
	} else {
		print("the hermit has no clovers today");
		return false;
	}
}
void main() {
	if(! lootHermit() )	{ print("failed to loot the hermit!");	 }
}
 

zarqon

Well-known member
I was originally using a variant of one of the above scripts, but I revisited it yesterday and tried to make it both simpler and thorougher. Reading people's comments etc gave me more ideas. I didn't know, for example, that mafia automatically gets hermit permits and worthless items if you need them when executing hermit(). That makes all the above posts needlessly complex.

Why write another version:
[*]I tend to be fairly anal about keeping server hits low, so although izchak's algorithm is nice, it generates 1 server hit per clover, whereas muffins' version visits the hermit once to see how many, parses the page, and goes once more to get everything. I wanted to retain a minimal-server-hit script.
[*]The hermit page can be parsed more simply.
[*]Some people (especially hardcore) may not want to burn unnecessary adventures in the sewer getting 5 worthless items, so I wanted a smart script that only gets the available amount.
[*]the "haxored" thing could be done much more simply.

This version makes use of mafia's built-in stuff, keeps a lot of good ideas from the above scripts but simplifies a lot of things.

Code:
// take all available clovers from the hermit without apologizing
boolean declover_hermit() {
   cli_execute("use * hermit script; use * 31337 scroll");
   boolean haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");
   if (!haxored) retrieve_item(1,$item[hermit permit]);
   cli_execute("acquire 1 worthless item");
   int cloves = 0;
   string source = visit_url("hermit.php");
   if(contains_text(source, "left in stock for today"))
      cloves = to_int(substring(source, index_of(source, " left in stock")-1,index_of(source, " left in stock")));
   print("Hermit has " + cloves + " clovers in stock today.","blue");
   if (cloves > 0) return hermit(cloves, $item[ten-leaf clover]);
//   print("Sorry, hermit.");      apology removed
   return true;
}

void main() {
   declover_hermit();
}

EDIT: added a downloadable version.
EDIT: 31337 scrolls are quest items. Script is now shorter and sweeter.
 

Attachments

  • getclovers.ash
    861 bytes · Views: 109

izchak

Member
Yeah, my previous clover_getting algorithm predates the rampaging adding machine. Since NS13, and the rampaging adding machine, I haven't really needed a declovering script or function, especially since hola made some improvements to mafia, outdating a lot of old code dealing with the hermit.

It's also worth noting that 31337 scrolls are quest items, and cannot be bought, sold, or traded. So, you may want to excise your buy_31337s code...

Nice script, though. Short, simple and sweet!
 

zarqon

Well-known member
Thanks izchak! All 31337 scrolls code reduced to a simple pre-hermit "use * 31337 scroll" above.
 

zarqon

Well-known member
Sorry for the necro, but given the changes to gum/sewer/hermit, this function needed updating and I wanted to share the change.

Unfortunately the optimal method of getting worthless items now needs to use more server hits -- having no worthless items in your inventory can raise your chances of getting one as high as 100% when you use the gum, so getting clovers one by one is optimal. On the plus side, the code is much tinier!

PHP:
// take all available clovers from the hermit
void declover_hermit() {
   cli_execute("use * hermit script; use * 31337 scroll; use * ten-leaf");
   repeat {
      while (item_amount($item[worthless trinket]) + item_amount($item[worthless gewgaw]) + 
          item_amount($item[worthless knick-knack]) == 0 && my_meat() > 50)
         cli_execute("use 1 chewing gum on a string");
   } until (!hermit(1, $item[ten-leaf clover]));
   cli_execute("use * ten-leaf clover; print All clovers done been got.");
}

void main() {
   declover_hermit();
}

EDIT: Also, this is no longer a turn-burning script. :)
 

Attachments

  • getclovers.ash
    559 bytes · Views: 56
Last edited:

slyz

Developer
When the Chewing gum will be multi-usable, you can predict how many you need to use before you can start getting trinkets!

EDIT:
I changed getclovers.ash to:

1) find out how many clovers the hermit has
2) use all available trinkets
3) use enough chewing gums to get all the starter items + 3 trinkets
4) keep getting trinkets until all the clovers have been stolen

Once the chewing gum is marked as multi-useable, this should be efficient.
 

Attachments

  • getclovers.ash
    2.4 KB · Views: 52
Last edited:

fronobulax

Developer
Staff member
I changed getclovers.ash to:
Using Slyz's version...

It told me I had already gotten the day's clovers when I clearly had not. When I manually visited the hermit it gave me the rummage message. I primed it by manually using gum and then it worked. I believe the initial check to get available clovers fails when there are no worthless items in inventory. Hermit has been haxored so I can't think of any other reason why it worked that way for me.
 

slyz

Developer
Oh I didn't think of that case ^^
The URL "hermit.php?autopermit=on" makes Mafia auto-buy a permit if needed, but of course I'll make sure you have a trinket before visiting the hermit.

I'll edit this post to add the updated version.

EDIT: and here it is.
 

Attachments

  • getclovers.ash
    2.6 KB · Views: 63
Last edited:
Top