Semi-Rare Counter Expiry Prematurely Ends Farm Script

bfischey

New member
My script (which prepares for a day of adventures, adventures with semi-rare logic, and then debriefs) is having troubles with the built-in semi-rare counter of KoLMafia. I cannot seem to find away around the auto-halt when a fortune cookie counter expires. I was going to go through the source code when I decided to come here first (this was after many hours of searching through the posts here for some information and through the wiki to no avail). This is the gCLI output: "Fortune Cookie counter expired".

It also appears that the visiturl(); command is not working either. It's rather close to the top in the script as it's the first thing that should be done. I'm not sure what about it isn't working but the page never opens and I don't get the buffs.

I'm using v12.5 and db6133 on Vista with SP1 as a side note...

This is the adventuring code which can't get around the semi-rare logic built into KoLMafia:
Code:
void adventure()
{
	int lastSR = -1;
	string foo = "";
	int bar = -1;
	string result = "";
	int resnum = -1;
	int togo = 250;

	while (my_adventures() > 0)
	{
		if (item_amount($item[Mick's IcyVapoHotness Inhaler]) > 0)
		{
			use(item_amount($item[Mick's IcyVapoHotness Inhaler]), $item[Mick's IcyVapoHotness Inhaler]);
			lastSR = my_turncount();
			if(my_fullness() < 14)
			{
				eat(2, $item[fortune cookie]);
				foo = get_property("relayCounters");
				bar = index_of(foo,":Fortune");
				result = substring(foo,0,bar);
				resnum = to_int(result);
				togo = resnum-lastSR;
				set_property("relayCounters", $string[my_turncount() + 250]);
			}
			print($string[SemiRare acquired!], $string[blue]);
		}

		if (togo > 1)
		{
			adventure(1, $location[Giant's Castle]);
			togo = togo - 1;
		}
		else
		{
			print($string[Alternate SemiRare Acquiring Attempt], $string[blue]);
			adventure(3, $location[Menagerie 2]);
			print($string[Alternate SemiRare should be acquired], $string[blue]);
			lastSR = my_turncount();
			if (my_fullness() < 15) 
			{
				eat(1, $item[fortune cookie]);
				foo = get_property("relayCounters");
				bar = index_of(foo,":Fortune");
				result = substring(foo,0,bar);
				resnum = to_int(result);
				togo = resnum-lastSR;
				set_property("relayCounters", $string[my_turncount() + 250]);			
			}
			else
			{
				togo = my_adventures() + 5;
			}
		}
	}
}

Here's my entire script:
Code:
void prepare()
{
	print("Kindom of Buffing", "blue");
	visit_url("[url]http://www.mrkinks.com/buffme/getbuff.pl?6006b=on&6010b=on&6014b=on&6019b=on&2007b=on&2010b=on&2009b=on&2008b=on&2012b=on&4007b=on&4008b=on&4011b=on&4019b=on&0003b=on&sn=bfischey"[/url]);
	print("Check", "green");

	print("Advanced CocktailCrafting", "blue");
	use_skill(5, $skill[Advanced Cocktailcrafting]);
	print("Check", "green");

	print("Twinkly Wads", "blue");
	if (my_spleen_use() == 0)
	{
		if (item_amount($item[twinkly wad]) > 14)
		{
			use(15, $item[twinkly wad]);
		}
		else
		{
			if (item_amount($item[twinkly wad]) > 0)
				use(item_amount($item[twinkly wad]), $item[twinkly wad]);
		}
	}
	print("Check", "green");

	print("Tofu Wontons", "blue");
	if (my_fullness() == 0)
	{	
		if (item_amount($item[tofu wonton]) < 4) 
		{
			buy(4-item_amount($item[tofu wonton]), $item[tofu wonton]);
		}
		eat(4, $item[tofu wonton]);
	}
	print("Check", "green");

	Print($string[Fortune Cookies], "blue");
	if (item_amount($item[fortune cookie]) < 5)
	{
		print($string[buying a fortune cookie], $string[blue]);
		buy(5-item_amount($item[fortune cookie]), $item[fortune cookie]);
		print($string[bought a fortune cookie], $string[blue]);
	}
	print("Check", "green");
	
	print("Drinks", "blue");
	if(my_inebriety() == 0)
	{
		print("Magical Ice Cubes", "blue");
		if (item_amount($item[magical ice cubes]) < 5)
		{
			buy(5-item_amount($item[magical ice cubes]), $item[magical ice cubes]);
		}	
	
		print("Strawberries", "blue");
		if (item_amount($item[strawberry]) < 5)
		{
			buy(5-item_amount($item[strawberry]), $item[strawberry]);
		}	

		print("Bottles of Whiskey", "blue");
		if (item_amount($item[bottle of whiskey]) < 5)
		{
			buy(5-item_amount($item[bottle of whiskey]), $item[bottle of whiskey]);
		}
		
		print("Mae Wests", "blue");
		for x from 1 upto 5
		{
			if(stills_available() > 1)
			{
				print("Bottles of Domesticated Turkey", "blue");		
				create( 1, $item[bottle of domesticated turkey]);
				print("Raspberries", "blue");		
				create( 1, $item[raspberry]);
			}
		}

		if(item_amount($item[bottle of domesticated turkey]) < 5 || item_amount($item[raspberry]) < 5)
		{
			buy(5-item_amount($item[bottle of domesticated turkey]), $item[bottle of domesticated turkey]);
			buy(5-item_amount($item[raspberry]), $item[raspberry]);
		}
		print("Mae Wests", "blue");		
		create(5, $item[mae west]);

		if(item_amount($item[mae west]) > 3)
		{
			drink(4, $item[mae west]);
		}
		else
		{
			buy(4-item_amount($item[mae west]), $item[mae west]);
			drink(4, $item[mae west]);
		}

		print("Cups of Primitive Beer", "blue");			
		if (item_amount($item[cup of primitive beer]) < 3)
		{
			buy(3 - item_amount($item[cup of primitive beer]), $item[cup of primitive beer]);
		}
		drink(3, $item[cup of primitive beer]);	
	}
	print("Check", "green");

	Print("Outfit - Meat Hunter", "blue");
	outfit($string[Meat Hunter]);
	print("Check", "green");	

	print("Bag of Cheat-Os", "blue");
	if (my_adventures() > have_effect($effect[sticky fingers]))
	{
		buy((my_adventures() - have_effect($effect[sticky fingers]))/10, $item[bag of cheat-os]);
	}
	use(item_amount($item[bag of cheat-os]), $item[bag of cheat-os]);
	print("Check", "green");

	print("Knob Goblin Pet-Buffing Spray", "blue");
	if (my_adventures() > have_effect($effect[heavy petting]))
	{
		buy((my_adventures() - have_effect($effect[heavy petting]))/10, $item[Knob Goblin pet-buffing spray]);
	}
	use(item_amount($item[Knob Goblin pet-buffing spray]), $item[Knob Goblin pet-buffing spray]);
	print("Check", "green");

	print("Leash of Linguini", "blue");
	if (my_adventures()/10 > have_effect($effect[leash of linguini]))
	{
		use_skill((my_adventures() - have_effect($effect[leash of linguini]))/10, $skill[leash of linguini]);
	}
	print("Check", "green");

	print("Mick's IcyVapoHotness Inhaler", "blue");
	if (item_amount($item[Mick's IcyVapoHotness Inhaler]) > 0)
	{
		use(item_amount($item[Mick's IcyVapoHotness Inhaler]), $item[Mick's IcyVapoHotness Inhaler]);
	}
	print("Check", "green");

	print("Summoning Demon", "blue");
	cli_execute("summon 2");
	print("Check", "green");
}

void adventure()
{
	int lastSR = -1;
	string foo = "";
	int bar = -1;
	string result = "";
	int resnum = -1;
	int togo = 250;

	while (my_adventures() > 0)
	{
		if (item_amount($item[Mick's IcyVapoHotness Inhaler]) > 0)
		{
			use(item_amount($item[Mick's IcyVapoHotness Inhaler]), $item[Mick's IcyVapoHotness Inhaler]);
			lastSR = my_turncount();
			if(my_fullness() < 14)
			{
				eat(2, $item[fortune cookie]);
				foo = get_property("relayCounters");
				bar = index_of(foo,":Fortune");
				result = substring(foo,0,bar);
				resnum = to_int(result);
				togo = resnum-lastSR;
				set_property("relayCounters", $string[my_turncount() + 250]);
			}
			print($string[SemiRare acquired!], $string[blue]);
		}

		if (togo > 1)
		{
			adventure(1, $location[Giant's Castle]);
			togo = togo - 1;
		}
		else
		{
			print($string[Alternate SemiRare Acquiring Attempt], $string[blue]);
			adventure(3, $location[Menagerie 2]);
			print($string[Alternate SemiRare should be acquired], $string[blue]);
			lastSR = my_turncount();
			if (my_fullness() < 15) 
			{
				eat(1, $item[fortune cookie]);
				foo = get_property("relayCounters");
				bar = index_of(foo,":Fortune");
				result = substring(foo,0,bar);
				resnum = to_int(result);
				togo = resnum-lastSR;
				set_property("relayCounters", $string[my_turncount() + 250]);			
			}
			else
			{
				togo = my_adventures() + 5;
			}
		}
	}
}

void logout()
{
	cli_execute("summary farmResults.txt");
	outfit($string[rollover]);
	drink(1, $item[mae west]);
	if(item_amount($item[irradiated pet snacks]) > 0)
		put_shop(0, 0, $item[irradiated pet snacks]);
#	cli_execute("undercut");	
}

void main()
{
	print($string[Script will start in 15 seconds], $string[blue]);
	wait(15);
	print($string[Part one commencing: prepare for adventures], $string[blue]);
	prepare();
	print($string[Part one complete, 15 second pause], $string[blue]);
	wait(15);
	print($string[Part two commencing: adventuring], $string[blue]);
	adventure();
	print($string[Part two complete, 2 minute pause], $string[blue]);
	wait(120);
	print($string[Part three commencing: closing details], $string[blue]);
	logout();
	print($string[Part three complete, have a nice day], $string[blue]);
}
 

lostcalpolydude

Developer
Staff member
Without actually reading much of your script (it would probably be a waste, since I haven't done any scripting really), I'm guessing that mafia aborts your script when you get to the counter. Therefore, it doesn't matter what your script tries to do when you get to the counter expiring, because mafia is ignoring your script anyway. I could be completely wrong though.
 

bfischey

New member
Yes, Mafia aborts the script when the counter expires. I was trying to find a way around this auto-abort. Perhaps there's an option or a way to clear the counters so that Mafia doesn't abort because the counter will never reach zero.
Thanks for taking the time to respond.
 

zarqon

Well-known member
I'm halfway sure that if you use visit_url() to manually adventure, instead of mafia's built-in adventure(), mafia's counter-expiry abort won't be triggered. Once you're at your counter, try something like this:

Code:
visit_url("adventure.php?snarfblat=X");
run_combat();

Note that the above will fail if you encounter a choiceadventure, and it also doesn't have any failsafes. But it should get you started.

Also be aware that you can use fortune cookies instead of eat them, and determine counters without costing fullness. You may want to edit your script accordingly.
 

EEPiccolo

New member
From post I think Veracity made in another thread, it may be possible to stop the abort by setting a variable to the return value of adventure (it returns a boolean), instead of just calling adventure ignoring the return value as it is currently in your code.
 

lostcalpolydude

Developer
Staff member
[quote author=zarqon link=topic=1787.msg8494#msg8494 date=1216100280]Also be aware that you can use fortune cookies instead of eat them, and determine counters without costing fullness. You may want to edit your script accordingly.
[/quote]
If you use (smash) a fortune cookie, you get the game hint and not the counter. It would be a bit broken if you could get the counter without using up fullness.
 

zarqon

Well-known member
I smashed one once in the relay browser when I noticed the new link and thought I remembered getting lucky numbers... but evidently it's just wishful memories. Sorry to mislead anyone.
 
Top