Trouble With use_familiar()

pl_walker

New member
Trying to change my familiar from the Baby Sandworm to the Llama Lama once I have 5 agua. This is in the script that runs Between adventures:

Code:
if(!use_familiar($familiar[Llama Lama])){
   print("Error trying to change familiar to Llama Lama.", "red");
   exit;
}

I got "Your Llama Lama can't wear a string of dingle balls" and it kicks me out of my overall script.

What am I doing wrong? The Llama is wearing the Zen Motorcycle in storage and the Sandworm is wearing the Dingleballs.
 

pl_walker

New member
OK, I give up, I'm not sure whether I broke some rule or what. What do I need to do differently in order to get some assistance on this?
 

AlbinoRhino

Active member
It's not clear from what you have posted why that would happen. If you go to Preferences > Automation, do you have anything listed as "Familiar Script"? If so, is what you have listed possibly trying to equip your Lama with the wrong equipment?

Else, you'll need to provide more details, (e.g. more of the code you are using) in order for anyone to help you figure it out.
 

pl_walker

New member
Thank you for the reply. In Automtion, other than log in and log out scripts, I have a post-adventure script. Here is the extent of that script:

Code:
void main(){
	item   familiar_equipment;
	// don't allow this script in Ronin
	if(!can_interact()){
	   exit;
	}
	
	// familiar management
	// ** replace Sandworm with Llama when we have 5 agua
   if(my_familiar() == $familiar[Baby Sandworm]){
   	// count agua
   	if(get_property("_aguaDrops") == 5){
   		// use LLama
   		if(!use_familiar($familiar[Llama Lama])){
   			print("Error trying to change familiar to Llama Lama.", "red");
   			exit;
   		}
   	}
   }
   
	// ** replace Llama with Jumpsuited Hound Dog when we have 5 gongs
   if(my_familiar() == $familiar[Llama Lama]){
   	// count gongs
   	if(get_property("_gongDrops") == 5){
   		// use Hound Dog
   		if(!use_familiar($familiar[Jumpsuited Hound Dog])){
   			print("Error trying to change familiar to Jumpsuited Hound Dog.", "red");
   			exit;
   		}
   	}
   }
}
 

AlbinoRhino

Active member
Hmmm. I assume that the sandworm is already wearing the dingle balls when this happens?

My next advice would be to use the sandworm with the dingle balls and 5 aqua drops.

Go to the Help menu. Click "Start Debug Log".

Run your post-adventure script (and trigger the error).

Help > "Stop Debug Log"

Find the debug log in your mafia directory and attach it to a post here. Hopefully, someone more knowledgeable than me will come along and interpret it for you.
 

pl_walker

New member
Tried that. Unfortunately, I didn't get the error when I ran the script. I'm not sure what is going on.
 

pl_walker

New member
Strange, the error seems to be happening after the script ends. I guess...

Finished ASH script: kmBetween.ash
Your Jumpsuited Hound Dog can't wear a string of dingle balls
Autorecovery failed.
 

AlbinoRhino

Active member
OK...making progress, but it's still a mystery.

Start the debug log, do whatever you need to do to make the error happen. After the error occurs, stop the debug log. Post it here so someone can see what is actually going on.
 

heeheehee

Developer
Staff member
The OP is trying to do this via betweenBattleScript. Isn't there something that checkpoints your equipment before said script and tries to restore it when adventuring resumes?
 

heeheehee

Developer
Staff member
Hm. I see this code:
Code:
        public static void runBetweenBattleChecks( final boolean isScriptCheck, final boolean isMoodCheck,
                final boolean isHealthCheck, final boolean isManaCheck )
        {
                // Do not run between battle checks if you are in the middle
                // of your checks or if you have aborted.

                if ( !RecoveryManager.isRecoveryPossible() || KoLmafia.refusesContinue() )
                {
                        return;
                }

                // First, run the between battle script defined by the
                // user, which may obviate the built in behavior.

                RecoveryManager.recoveryActive = true;

                if ( isScriptCheck )
                {
                        KoLmafia.executeScript( Preferences.getString( "betweenBattleScript" ) );
                }

                // Now, run the built-in behavior to take care of
                // any loose ends.


                SpecialOutfit.createImplicitCheckpoint();
which suggests that there should be no such outfit restore for a betweenBattleScript. recoveryScript, on the other hand, is definitely encapsulated by an instance of outfit checkpoint / restore.

I wonder if use_familiar(fam) fails to update equipment appropriately. That could explain it.
 

heeheehee

Developer
Staff member
I wonder if use_familiar(fam) fails to update equipment appropriately. That could explain it.

Limited manual testing indicates that familiar swapping updates equipment as desired.

Hm. Looking back at the thread, the OP never explicitly mentioned a betweenBattleScript. This post indicates an afterAdventureScript.
Thank you for the reply. In Automtion, other than log in and log out scripts, I have a post-adventure script. Here is the extent of that script:

Strange, the error seems to be happening after the script ends. I guess...

Finished ASH script: kmBetween.ash
Your Jumpsuited Hound Dog can't wear a string of dingle balls
Autorecovery failed.

Sounds like recovery is happening. Perhaps a checkpoint is being created before the afterAdventureScript, and then restored (unsuccessfully) after recovery? I can check to see what the code's doing.
 
afterAdventure scripts are weird anyway: if you enable them on manual adventures, they will run after manual adventures as expected. However total_turns_played() (and possibly other variables like that) doesn't update, so your manual adventure takes a turn and then the afterAdventure script runs based on your turncount before the manual adventure (and you end up looking for a lights out adventure one turn too late, consistently).
 

zarqon

Well-known member
BBB explicitly clears checkpoints if it swaps gear or familiars to avoid these problems, which I also seem to recall happening. But I believe that code also predates the split into beforeBattle and afterBattle scripts, so this could be irrelevant information now.
 

pl_walker

New member
For reference, I was able to capture the error again with more info from the log.

View attachment DEBUG_20181014.txt

For reference, my kmFarm script is just adventuring in the Oasis. This issue happens whether I'm running that script or just automating adventures.

I'm going to try removeing the Post-Adventure script and put the contents in the kmFarm script. If it is indeed related to that particular preference setup.

Thanks again, everyone for the assistance.
 

pl_walker

New member
OK, moving the script to within my Farming script eliminates the error, so something must be happening as part of the Post-Adventure automation.

At least for now I have a work around that works. I can move the familiar management to a "tools" script and just call it after I adventure somewhere. Not the most elegant solution, but it will work.

Thanks again.
 
Top