Tailsman

fronobulax

Developer
Staff member
I have been getting a debug log about a null pointer in a single use request for a very long time. It finally bothered me enough to look at. I am 99.44% sure it is the creation of the Talisman from gaudy keys that is the cause.

I added a line to log when items had to be created one at a time.

Log snippet.

Code:
Creating snakehead charrrm (1 of 2)...

Use 1 gaudy key
You acquire an item: snakehead charrrm

Use 1 gaudy key
You acquire an item: snakehead charrrm

Use 1 snakehead charrrm + 1 snakehead charrrm
You acquire an item: Talisman o' Namsilat
Unexpected error, debug log printed.

Use 1 gaudy key
Creating snakehead charrrm (2 of 2)...

Use 1 gaudy key

I don't know how creation was invoked (because I haven't dissected the automation) but I'm pretty sure it triggered mafia's creation logic for a Tailsman rather than explicitly using keys then charrrms.

I'm not quite following the "make" logic yet so I don't know whether the concoction needs to be changed, whether the make implementation is not quite right when it needs two single uses to create one thing or whether there is special handling for the Talisman that needs to be reconsidered.

Anyone have any pointers for me?

I seem to recall that Talisman creation is a long standing hiccup so if this is a known problem that no one wants to fix because doing so is not simple, just remind me.

Thanks.
 

Attachments

  • DEBUG_20180131.txt
    6.1 KB · Views: 75

fronobulax

Developer
Staff member
Managed to catch part of this in the debugger.

I think what happens is

script gets two gaudy keys
script executes make talisman o namsilat
make gets recipe
make uses gaudy key to get charrrm
make uses gaudy key to get charrrm
ResultProcessor sees two charrms and autocreates talisman
make tries to continue the recipe by using charrms but they aren't there anymore, hence null pointer.

If I were the sole arbitrator of what is good for KoLmafia I would just disable the autocreate. But I'm not and there is probably a script out there that relies on the behavior that I would rather not break.

The silence suggests I am the only one who cares about the NPE so in the absence of commentary I can just leave this alone...

;-)
 

ckb

Minion
Staff member
There was a time long ago where I had an AfterAdventurte script that would auto use gaudy keys and create a talisman. And it caused problems, very much like you describe.
I took this out of my script and now let Mafia do it for me, and I have had no issues since.

So I guess the lesson here is to not make talismans in scripts.
 

AlbinoRhino

Active member
My experience was that using create() would give the NPE but changing my script to "use 2 gaudy key" worked fine. Which aligns with frono's analysis.
 
I turned off the autocreate because this gave me many issues. I still do that to this day although I don't know if I still have to.

I still need to.

Code:
You acquire an item: McClusky file (page 5)
Verifying ingredients for McClusky file (complete) (1)...
Creating McClusky file (complete) (1)...
You are currently in a choice.
 
Last edited:

fronobulax

Developer
Staff member
I am thinking this is an unintended feature of having autoCreate TRUE and then a user or script explicitly tries to make an item that would be autocreated. It is an intellectual concern because it is a mafia flaw if there is something a user can do to break mafia. If autoCreate is eliminated as an option then scripts will break. Which scripts break will depend upon the change unconditionally autocreates or never does so.

A robust script will check the value of autoCreate and then pick the make target accordingly. But that requires a script writer to hard code recipe knowledge and which items can be autocreated.

I'm thinking the reasonable solution is to intercept the various places a script can make an item. If the item can be autocreated and the flag is true, clear autoCreate, make the item and then restore autoCreate. An extension would be a proxy field or a function that says whether the creation of the item is effected by the autoCreate flag or not.
 
Top