Fortune Cookie Counterscript

asturia

Minion
Code:
Revision: 7104
Author: jasonharper
Date: 21:00:52, dinsdag 24 maart 2009
Message:
Adds an override for handling expiring counters during automated adventuring.
Set counterScript to the name of an ASH script containing a function:
  boolean main( string name, int remain )
name - the label of the expired counter, "Fortune Cookie" for example.
remain - the number of turns remaining, typically 0 but can be higher if
adventuring in an area that takes multiple turns.
return value - false to allow the counter warning to appear as normal,
aborting the adventure request; true to continue the request with no warning.
----
Modified : /src/net/sourceforge/kolmafia/request/GenericRequest.java

Revision: 7103
Author: veracity0
Date: 20:36:01, dinsdag 24 maart 2009
Message:
The Clownlord Beelzebozo
----
Modified : /src/data/combats.txt
Modified : /src/data/monsters.txt

Revision: 7102
Author: jasonharper
Date: 8:01:35, dinsdag 24 maart 2009
Message:
Add support for items that require knowledge of a recipe to craft.  Such
items are indicated by a preference of the form "unknownRecipe<itemId>" in
defaults.txt, with a value of true.  The value will be changed to false,
allowing the item to be considered creatable, in the following cases:
* the recipe is read,
* the item was successfully crafted via the relay browser, or
* the item was seen on a crafting discoveries page.
----
Modified : /src/data/defaults.txt
Modified : /src/net/sourceforge/kolmafia/KoLmafiaCLI.java
Modified : /src/net/sourceforge/kolmafia/StaticEntity.java
Modified : /src/net/sourceforge/kolmafia/persistence/ConcoctionDatabase.java
Modified : /src/net/sourceforge/kolmafia/request/CreateItemRequest.java
Modified : /src/net/sourceforge/kolmafia/request/UseItemRequest.java
 
Last edited by a moderator:
Code:
Revision: 7104
Author: jasonharper
Date: 21:00:52, dinsdag 24 maart 2009
Message:
Adds an override for handling expiring counters during automated adventuring.
Set counterScript to the name of an ASH script containing a function:
  boolean main( string name, int remain )
name - the label of the expired counter, "Fortune Cookie" for example.
remain - the number of turns remaining, typically 0 but can be higher if
adventuring in an area that takes multiple turns.
return value - false to allow the counter warning to appear as normal,
aborting the adventure request; true to continue the request with no warning.

To fully support that revision, here's an example of how to automatically farm for semi-rares, including automatic cookie eating. :D

I hope I'm not breaking any rules by posting it here. :eek: Please just delete it and don't hate me if I was bad.

To use this, put it in your /scripts directory and type in the gCLI:
set counterScript = cookie.ash

Edit: Made a small improvement to the script so that it won't try to eat another cookie if you're already full.
 

Attachments

Last edited:
Hi there,

as I do not really know ash (or any other programming language) it is obvious that I am having some difficulties the script to my needs.

So this is the part I adjusted (thanks Bale ;) ):

Code:
	int last = get_property("semirareCounter").to_int();
	switch {
	case !get_property("semirareLocation").contains_text("Purple Light District") && pld_open():
		adventure(1, $location[Purple Light District]); break;
	case !get_property("semirareLocation").contains_text("Limerick Dungeon"):
		adventure(1, $location[Limerick Dungeon]); break;
	case !get_property("semirareLocation").contains_text("Outskirts of Knob"):
		adventure(1, $location[Outskirts of Knob]); break;
	default: adventure(1, $location[Menagerie 2]);
	}

BUT I still want the semi-rare locations to really cycle so I can include other locations like the Harem. Can it be done with adjustments to this script or will that take a whole new script?

Thanks in advance and Cheers
ki77bot
 
It can be done with a few adjustments to that part of the script, but it isn't as simple as just adding a few cases. To make it cycle between a number of options, instead of searching for what the last cookie was not, search for what it was. For instance, if the last one was the limerick dungeon, then the next one can be the outskirts. After the knob you can go to the menagerie. How about something like this...

Code:
	switch(get_property("semirareLocation")) {
	case "Knob Goblin Harem":
		if(pld_open()) {
			adventure(1, $location[Purple Light District]); 
			break;
		}
	case "The Purple Light District":
		adventure(1, $location[Limerick Dungeon]); break;
	case "Limerick Dungeon":
		adventure(1, $location[Outskirts of the Knob]); break;
	case "Outskirts of The Knob":
		adventure(1, $location[Menagerie 2]); break;
	default:
		adventure(1, $location[Knob Goblin Harem]);
	}

Instead of checking a conditional, I switch up the case statement so that it looks up the property of semirareLocation. Whatever it was last, I then move on to the next item in sequence. Note that you have to list the exact name of the location in the case or it won't work. Capitalization counts.

For the PLD, I check to see if it is open and only go there if it is. Otherwise program flow passes on to the next line and it goes to the Limerick Dungeon.

If your last cookie was at an unexpected place it will pick up at default and go to the harem.
 
Ok, that looks nice.

If I understand that right, it means that the location PLD is ONLY checked IF the last semirare-location was "Knob Goblin Harem", right?

Cheers
ki77bot
 
Hmmm, both versions of the script do not take into account, that you sometimes end up with more than one cookie counter.

In that case the script keeps adventuring at the same location.

Is there some way around that?

Cheers
ki77bot.

PS: at least this version is doing that...

Code:
	int last = get_property("semirareCounter").to_int();
	switch {
	case !get_property("semirareLocation").contains_text("Purple Light District") && pld_open():
		adventure(1, $location[Purple Light District]); break;
	case !get_property("semirareLocation").contains_text("Outskirts of Knob"):
		adventure(1, $location[Outskirts of Knob]); break;
	case !get_property("semirareLocation").contains_text("Limerick Dungeon"):
		adventure(1, $location[Limerick Dungeon]); break;
	default: adventure(1, $location[Knob Goblin Harem]);
	}
 
Last edited:
Hmmm, both versions of the script do not take into account, that you sometimes end up with more than one cookie counter.

In that case the script keeps adventuring at the same location.

Is there some way around that?

Eating a cookie right after getting your semi-rare should somewhat minimize ending up with more than one cookie counter, as the extra values are more likely to be out of bounds. However the script is working as desired in this case, as if it fails to actually gather a semi-rare (because the counter it triggered from was the incorrect one), you still want to go back to the same location the next time.
 
Eating a cookie right after getting your semi-rare should somewhat minimize ending up with more than one cookie counter, as the extra values are more likely to be out of bounds.

It is less likely yes, but still it happens. Sometimes Mafia for some reason loses track of the "real" cookie counter, and it that case the script gets stuck. I had sometimes 5-6 active cookie counters and ALL were incorrect. Because if for whatever reason the expected semi-rare does not occur the script will try again and again. But you can not have the same semi-rare in the same location.

However the script is working as desired in this case, as if it fails to actually gather a semi-rare (because the counter it triggered from was the incorrect one), you still want to go back to the same location the next time.

For the reason I explained above...no. I mean of course do you want to eliminate all possible "wrong" counters and then finally gather the desired semi-rare, BUT if something goes wrong the script should switch to default after three unsuccessful encounters. In my case it doesn't.

Cheers
ki77bot
 
It is less likely yes, but still it happens. Sometimes Mafia for some reason loses track of the "real" cookie counter, and it that case the script gets stuck. I had sometimes 5-6 active cookie counters and ALL were incorrect. Because if for whatever reason the expected semi-rare does not occur the script will try again and again. But you can not have the same semi-rare in the same location.



For the reason I explained above...no. I mean of course do you want to eliminate all possible "wrong" counters and then finally gather the desired semi-rare, BUT if something goes wrong the script should switch to default after three unsuccessful encounters. In my case it doesn't.

The script simply avoids going to the same location as Mafia claims it found the last semi-rare at. There is no reasonable way for it to determine that Mafia's recollection is incorrect. If it is, it's either a Mafia bug, or you collected one outside Mafia. In the later case, "set semirareLocation = somewhereelse" will fix your problem.
 
Fortune Cookie CounterScript

I moved this over so continued discussion on this fine script can go forward properly. I had hoped to move all the messages less the original post but I found myself unable to do it and wrangle a 16 month old.

Daddy induced fail.
 
Last edited:
As StormCrow said. Not a bug with the script.

I think I'll post my latest version. Now it checks current mall prices so that it will get the most expensive semi-rare that it has access to. Note that unless you set the choice adventure for the cube of billiard chalk it may pop up a window to ask you to choose.
 
Last edited:
Thanks for all replies, the insight and the update :D

Cheers
ki77bot.

PS: "set semirareLocation = somewhereelse" couldn't fix my problem, but that was due to the faxct, that the last encountered semi-rare was also the first in line of the script.

I'll go on testing the mall-price version ;)
 
The mall price part works well...
How do you turn off the stop command that mafia sends, I can't find it in my preferences anymore?
It never eats a cookie for me either...

Output while running Wossname.ash:

Step 4: Lighthouse sidequest
Visiting the lighthouse keeper with 1 barrel of gunpowder.
Mood swing complete.
Putting on NowOutfit...
You are already wearing "NowOutfit."
You need 4 more barrel of gunpowder to continue.
Conditions list cleared.
Condition added: barrel of gunpowder (4)

MCD: unavailable

Request 1 of 24 (IsleWar: Wartime Sonofa Beach) in progress...
Sending kmail to Bale...
Checking fortune cookie counters...
Searching for "cube of billiard chalk"...
Searching for "cyclops eyedrops"...

Visit to Dungeon: Limerick Dungeon in progress...

[1982] Limerick Dungeon
Encounter: The Bleary-Eyed Cyclops
You acquire an item: cyclops eyedrops

Conditions not satisfied after 1 adventure.
Fortune Cookie counter expired.

Visiting the lighthouse keeper with 1 barrel of gunpowder.
Visiting the lighthouse keeper with 1 barrel of gunpowder.
Unable to complete step 4
Restoring initial settings...
battleAction => attack with weapon
Putting Uncle Edge's extraspicy baby gravy fairy the Baby Gravy Fairy back into terrarium...
Taking Make Me Rich the Leprechaun out of terrarium...
ant pick is better than (none). Switching items...
Stealing ant pick from Uncle Edge's extraspicy baby gravy fairy the Baby Gravy Fairy...
Putting on ant pick...
Equipment changed.
OCW stopped.
 
The mall price part works well...
How do you turn off the stop command that mafia sends, I can't find it in my preferences anymore?
It never eats a cookie for me either...

You have to catch the return value of adventure() in the script. Replace the line

Code:
adventure(1, expensive_semi(get_property("semirareLocation")));
with
Code:
if ( adventure(1, expensive_semi(get_property("semirareLocation"))) ) {}
 
Good point. The script as stated wasn't designed to work with set conditions since I made it for someone who just farms until adventures run out. I'll have to add that non-conditional as StormCrow suggests since it is such an elegant solution to a potential problem.
 
Here's the current version of my cookie script. I rearranged it a little to make it more adaptable for StormCrow's use.

It now handles setting (and resetting) of properties for getting a cube of billiard chalk. In case you normally like to play a game with the shark, it will reset your choice adventure that way AFTER getting a cube. If you don't agree with that, then change it. The script is optimized for getting meat after all so it wouldn't make sense to do it any other way.
 
Last edited:
Until now everything works fine...

Nevertheless there is a problem, when you are on a bountyhunt. The Script will go to the semi-rare location and stops after that without eating another cookie. (I know it doesn't happen that often, still it breaks off at that point)

Is there some way to go on bountyhunting after eating another cookie?
 
I have been using your script without any problems, until today.

I am using the newest nightly build KoLmafia-7317.jar, and I get this error:

Bad item value: "cube of billiard chalk" (cookie.ash, line 22)
Fortune Cookie counter expired.

Any help would be appreciated, Thanks
 
Back
Top