Familiar Optimizer

Ulfada

New member
Familiar Optimizer 1.0

I have been lurking on this forum for quite some time now and I thought I could give a little back for all the wonderful scripts that I use every day. I have Familiar Optimizer set up in my mood and it has become invaluable. Any feedback on the code is more than welcome.

This script checks your HP and MP levels, if your levels are at or below your low threshold Familiar Optimizer will change to a HP and MP producing familiar, switching back to your previous familiar once you get at or above your high threshold. This works best with zarqon's excellent SmartStasis script.

To use the script place fo_familiars.txt in you data directory. Place familiar-optimizer.ash in you scripts directory. You will also need zargon's zlib. Set familiar-optimizer.ash as an unconditional trigger in your mood settings to run it after each adventure, or if you prefer to have the script run before an adventure set it as a bewtween battle script.
set betweenBattleScript=familiar-optimizer.ash

This script does not take into account familiar equipment or weight.
Changing familiars during the recovery process will result in that familiar being switch out when your HP/MP levels rise above your threshold.

The map file is a tab delimited list of familiars in order of preference.
Feel free to edit it to your own preferences.

Properties are saved in <character-name>_prefs.txt so you can use different settings for each character. Right now the only way to change your HP/MP threshold is by editing your <character-name>_prefs.txt or using the set_property command for example enter into gCLI:
ash set_property("fo_hp_fpercent",.25);
ash set_property("fo_hp_cpercent",.90);
ash set_property("fo_mp_fpercent",.25);
ash set_property("fo_mp_cpercent",.90);

Known bugs:
For some reason KoLmafia tries to equip a new familiar with the current familiar's equipment even if it won't work i.e. trying to equip a Meat detector on a Cocoabo
I don't use familiar items for my main character because of Hardcore, so this is relatively untested

Change Log
6/3/09 Version 0.1
Original concept layed out and tested.
6/4/09 Version 0.2
Added ceiling percent
Added debug function
Code cleaned up and commented
6/4/09 Version 0.3
Added fo_first_run to initialize defaults
Fixed bug that would cause recovery to stop if MP and HP were below threshold and one of them was fully recovered.
Fixed bug that caused an Ancient Yuletide Troll to be equipped after first run.
8/2/09 Version 1.0
Added version checking from zlib
Public release
 

Attachments

  • familiar-optimizer.ash
    6 KB · Views: 86
  • fo_familiars.txt
    195 bytes · Views: 81

Bale

Minion
Always nice to see a new face posting scripts, even if it's not one I'll use. Welcome to the community.
Known bugs:
For some reason KoLmafia tries to equip a new familiar with the current familiar's equipment even if it won't work i.e. trying to equip a Meat detector on a Cocoabo
I don't use familiar items for my main character because of Hardcore, so this is relatively untested
I can explain "for some reason". This is a known problem with using a between battle script to change equipment. http://kolmafia.us/project.php?issueid=543.

Fred Nefler said:
I believe I've seen this sort of issue with a betweenBattleScript back when the Slime Tube was still being spaded out. My script would change outfits, and if at the end of automatic adventuring I wasn't in the same outfit I started in, mafia would start re-equipping me. This would include attempting to put on the familiar equipment I had before the automation, but did NOT include attempting to switch my familiar to what I had before the automation. Thus resulting in errors like this.
 
Last edited:

kain

Member
Since you're already using zlib, do you want to put the preferences in the zlib preference file?
 
I love this script, but now that all my familiars have familiar specific equipment it breaks for me every time it changes famililars. Bummer! Hopefully that aspect of mafia can be fixed soon. Great script though, thanks for sharing!!
 

zarqon

Well-known member
Nice! I'd actually wanted functionality like this before, but never thought to write it into a mood. Since you're already using ZLib, I have three recommendations:

1) You should check vars["is_100_run"], to avoid changing familiars in the case that someone is doing a 100% run.

2) As kain suggested, use ZLib's script settings rather than mafia settings.

3) You could use ZLib's best_familiar() function, which chooses your heaviest familiar in a given category. Right now the only categories are "meat", "items", and "produce", so you would have to add the "hp" and "mp" categories to the bestfamiliars.txt data file. But after doing that, your script would consider weight, and you would not need any additional data files with your script. Also, this function already checks is_100_run so you wouldn't need any additional handling for that. Could be nice.

Thanks for sharing this script!
 

slyz

Developer
I tried to do a familiar-switching script and (of course) had the same problem: after the mood maintenance, Mafia tries to equip the familiar equipment that was saved in the checkpoint on the new familiar, and fails.

I wanted to ask if anyone had a solution for this, before posting a feature request. I tried adding
PHP:
cli_execute("checkpoint");
at the end of the script, to fool Mafia, but Mafia isn't easily fooled by ASH apparently.

EDIT: ah, apparently it simply needs to be a betweenBattle script.
 
Last edited:
Top