Bug Creating Talisman o' Nam results in an error

dangerpin

Member
Belowdecks with goal set to "1 Talisman o' Nam" will never complete

Feature or Bug? Since it will never complete I am calling it a bug.

Belowdecks you now get Gaudy Keys and the first two of these keys give you Snakehead Charms.

I did the easy fix for myself and set a new goal of "2 gaudy keys" instead of "1 Talisman o' Nam" but someone else is going to end up with a big pile of gaudy keys and no adventures.
 

Veracity

Developer
Staff member
Adding
Code:
snakehead charrrm	SUSE	gaudy key
to concoctions.txt just might do it. We know you can make Talisman with two charrms, that will tell it you can "use" a gaudy key to get a charrrm, and so...
 

Veracity

Developer
Staff member
I tried this today and it completed after six adventures. Here is the auto-creation of the Talisman after I got the second gaudy key:

Verifying ingredients for Talisman o' Nam (1)...
Verifying ingredients for snakehead charrrm (2)...
Creating snakehead charrrm (1 of 2)...
You acquire an item: snakehead charrrm
Verifying ingredients for Talisman o' Nam (1)...
Verifying ingredients for snakehead charrrm (1)...
Creating snakehead charrrm (1)...
You acquire an item: snakehead charrrm
Verifying ingredients for Talisman o' Nam (1)...
Creating Talisman o' Nam (1)...
You acquire an item: Talisman o' Nam
Successfully created Talisman o' Nam (1)
Successfully created snakehead charrrm (-1)
Creation failed, no results detected.
Creating snakehead charrrm (2 of 2)...
Creation failed, no results detected.
Conditions satisfied after 6 adventures.
That's a little funky, although it worked. I wonder if the "creation failed" messages are a result of the deferred concoction refresh or something?
 

xKiv

Active member
Why is it creating -1 of a snakehead charrm?

Also, maybe there's a problem with the triggering, first it tries to create 2 charrms, but creating the first one triggers autocreation of the talisman (which acquires the second charrm), so there are no gaudy keys left for step "create snakehead charrm (2 of 2)"? I don't think that's from deferred refresh, quite the opposite ...
 

Veracity

Developer
Staff member
That is what it looks like. Auto-crafting kicked in when the first gaudy key was "used" in the process of making the goal.
Looks like auto-crafting should be disabled during crafting.
I'll have to think more on this.
 

StDoodle

Minion
I saw something similar, but figured I'd messed it up when I went to use the gaudy key manually. Is there anything to look out for / test that might help?
 
Talisman o'Nam autocreation

build 8939 (and 8934)

Got 2nd gaudy key (CAB enabled).
Trying to extract snakehead charms...
> use * gaudy key

Using gaudy key (1 of 2)...
You acquire an item: snakehead charrrm
Verifying ingredients for Talisman o' Nam (1)...
Creating 1 meat paste...
You acquire an item: meat paste
You lose 10 Meat
Successfully created meat paste (1)
Verifying ingredients for snakehead charrrm (1)...
Creating snakehead charrrm (1)...
You acquire an item: snakehead charrrm
Verifying ingredients for Talisman o' Nam (1)...
Creating Talisman o' Nam (1)...
You acquire an item: Talisman o' Nam
Successfully created Talisman o' Nam (1)
Successfully created snakehead charrrm (-1)
Creation failed, no results detected.

Talisman o'Nam was successfully created, so maybe "Creation failed, no results detected." should be removed?

---
NightBird
 

Winterbay

Active member
I think the problem is that it thinks that it created -1 snakehead charrm which leads to the error, but I may missinterpret the info...
 

Grotfang

Developer
http://kolmafia.us/showthread.php?5698-Belowdecks-with-goal-set-to-quot-1-Talisman-o-Nam-quot-will-never-complete

This issue is already known, but maybe deserves a separate thread. The problem is that on acquiring the first snakehead, mafia tries to create the talisman. As part of this, it uses a gaudy key, which gives it a second snakehead. This triggers it trying to create the talisman (again), which now works, but when the code returns to the first attempt trying to make the talisman, it fails (since you already have it). Basically, the autocraft code gets triggered twice and BOTH try to run to completion, when only one is capable of doing so.
 

Veracity

Developer
Staff member
I didn't mark the other bug "Fixed" because there was still this little glitch to look at. Therefore, that would make this one a duplicate, I guess, since it reports precisely the same issue discussed in the other one. Grotfang's explanation is correct, so I guess I'll just mark the other bug fixed and use this to track the glitch...
 

Grotfang

Developer
I did actually take a look at this, but since I'm in HC and am dragging my feet (since work is currently taking priority over finishing my ascension), I haven't tested my patch. The code I stuck in is a little dirty, and could probably be made more elegant, but I figured maybe simply preventing multiple autoCreate()s happening on top of each other was the simplest fix. Patch is underneath code.

Code:
Index: src/net/sourceforge/kolmafia/session/ResultProcessor.java
===================================================================
--- src/net/sourceforge/kolmafia/session/ResultProcessor.java	(revision 8939)
+++ src/net/sourceforge/kolmafia/session/ResultProcessor.java	(working copy)
@@ -71,6 +71,7 @@
 
 	private static boolean receivedClover = false;
 	private static boolean receivedDisassembledClover = false;
+	private static boolean autoCrafting = false;
 
 	// This number changes every time an item is processed, and can be used
 	// by other code to tell if an item is received, without necessarily
@@ -1393,10 +1394,12 @@
 
 	private static void autoCreate( final int itemId )
 	{
-		if ( !Preferences.getBoolean( "autoCraft" ) )
+		if ( !Preferences.getBoolean( "autoCraft" ) && !ResultProcessor.autoCrafting )
 		{
 			return;
 		}
+		
+		ResultProcessor.autoCrafting = true;
 
 		// Make sure concoctions haven't been deferred
 		ConcoctionDatabase.deferRefresh( false );
@@ -1412,6 +1415,8 @@
 			creator.setQuantityNeeded( possible );
 			RequestThread.postRequest( creator );
 		}
+		
+		ResultProcessor.autoCrafting = false;
 	}
 
 	/**
View attachment AutoCreate.patch
 

Veracity

Developer
Staff member
Something like your patch looks reasonable. I'd check the autoCrafting flag first, since that's cheaper/easier than looking up a preference. And I wouldn't make it skip autoCrafting only if you WEREN'T already doing it. :)

Fixed in revision 8941

FWI, here is what I submitted:

Code:
Index: src/net/sourceforge/kolmafia/session/ResultProcessor.java
===================================================================
--- src/net/sourceforge/kolmafia/session/ResultProcessor.java	(revision 8940)
+++ src/net/sourceforge/kolmafia/session/ResultProcessor.java	(working copy)
@@ -71,6 +71,7 @@
 
 	private static boolean receivedClover = false;
 	private static boolean receivedDisassembledClover = false;
+	private static boolean autoCrafting = false;
 
 	// This number changes every time an item is processed, and can be used
 	// by other code to tell if an item is received, without necessarily
@@ -1393,7 +1394,7 @@
 
 	private static void autoCreate( final int itemId )
 	{
-		if ( !Preferences.getBoolean( "autoCraft" ) )
+		if ( ResultProcessor.autoCrafting || !Preferences.getBoolean( "autoCraft" ) )
 		{
 			return;
 		}
@@ -1409,8 +1410,10 @@
 		if ( possible > 0 )
 		{
 			// Make as many as you can
+			ResultProcessor.autoCrafting = true;
 			creator.setQuantityNeeded( possible );
 			RequestThread.postRequest( creator );
+			ResultProcessor.autoCrafting = false;
 		}
 	}
 
build 8959:
> use * gaudy key

Using gaudy key (1 of 2)...
You acquire an item: snakehead charrrm
Verifying ingredients for Talisman o' Nam (1)...
Verifying ingredients for snakehead charrrm (1)...
Creating snakehead charrrm (1)...
You acquire an item: snakehead charrrm
Successfully created snakehead charrrm (1)
Creating Talisman o' Nam (1)...
You acquire an item: Talisman o' Nam
Successfully created Talisman o' Nam (1)
You need 1 more gaudy key to continue.
http://195.70.211.9/files/gk.png
---
NightBird
 
Last edited:

Theraze

Active member
Well, it broke my "collect 2 gaudy keys, use them, and paste them into talisman" script yesterday with the same "You need 1 more gaudy key" message he got above. Is it possible to have the check for gaudy key conditions that apparently aren't currently being marked as met because mafia's autocreation is triggering first, either get automatically cleared when it gets created, or have the autocreation happen after the condition check for if you've gotten the item?
 

Veracity

Developer
Staff member
Well, it broke my "collect 2 gaudy keys, use them, and paste them into talisman" script yesterday...
It is trivial for you to fix your script, since you know autoCrafting is taking place.

I do have to wonder how you - and he - managed to get 2 gaudy keys into inventory without autoCrafting kicking in, such that you could "use * gaudy key". The only way that I see that that could happen is to turn off autoCrafting, collect keys, turn autoCrafting back on, and then say "use *" (rather than, say, "use 1").

In other words, jumping through hoops to intentionally fool KoLmafia.

Or am I missing something? What actions could a user to to get in this state naturally?
 
Last edited:

Theraze

Active member
No... the autocrafting is happening, but when it happens, the condition of 2 gaudy keys considers itself not to be completed.

And here's the bit that's collecting gaudy bits.
PHP:
      if (available_amount($item[snakehead charrrm]) < 2)
      {
       cli_execute("conditions clear");
       add_item_condition(2-available_amount($item[snakehead charrrm])-available_amount($item[gaudy key]), $item[gaudy key]);
       adventure(request_monsterlevel(my_adventures()), $location[Belowdecks]);
       use(available_amount($item[gaudy key]), $item[gaudy key]);
      }
 

Veracity

Developer
Staff member
If you have autoCraft on, the condition you want is "Talisman o'Nam", which will be autocreated as soon as you have enough gaudy keys and/or snakehead charrrms.
If you have autoCraft off, you can use gaudy keys as a conditional - if you want to craft yourself - or snakehead charrrm - in which case KoLmafia will make them out of gaudy keys - or Talisman o'Nam - in which case KoLmafia will make the components as needed, just like the condition of "digital key" will create it out of white pixels, and will create those as needed from RGB pixels.

The bug is in your script. Talisman o'Nam will work as a condition, whether or not autoCraft is on, but gaudy key will only work as a condition if you have autoCraft off.
 

Theraze

Active member
Conditions either not met when Autocrafting is enabled, or inventory updates wrong

If you have a script with 2 gaudy keys as a condition, adventure until you get them, and then use available_amount of gaudy keys (should be 0, if autocreate happened, 2 if not), your script will abort with a message that you need 1 more gaudy key.

Either it shouldn't need to abort, because you're trying to use 0 of 0 keys (should just do nothing, right?) or it shouldn't need to abort, because you're using 2 of 2 keys (in which case autocrafting is happening halfway through the usage of the keys, and should abort the second key usage).

It just seems like this shouldn't be aborting, though I might be misunderstanding something badly in the way that autocraft happens. I was under the impression it happened as part of the adventuring, and so the using of available keys should be irrelevant...
 
Top