Feature - Implemented Familiar script

lostcalpolydude

Developer
Staff member
So, I've already coded this feature (except for some GUI stuff that shouldn't be too hard), I just want to see what feedback there is before adding it.

The idea is to have a familiarScript (name subject to feedback) that runs when you switch familiars to determine what equipment to switch to, to augment or override KoLmafia's built-in equipment switching. An example script:

Code:
boolean main()
{
	if ( !can_interact() ) return false;
	switch ( my_familiar() )
	{
		case $familiar[stocking mimic]:
			equip( $item[bag of many confections] );
			return true;
			
		case $familiar[artistic goth kid]:
			equip( $item[little wooden mannequin] );
			return true;
		
		case $familiar[Disembodied Hand]:
		case $familiar[Mad Hatrack]:
		case $familiar[Fancypants Scarecrow]:
		case $familiar[Comma Chameleon]:
			return true;
			
		default:
			equip( $item[li'l businessman kit] );
	}
	return false;

}

Returning false means that normal equipment switching should happen after the script finishes, while true means it should be skipped, so the script has to have a boolean main() function. This isn't actually limited to switching familiar equipment, obviously, but that would be its primary purpose. The GUI part that needs coding still is a box in the Automation section of Preferences.
 

fronobulax

Developer
Staff member
Is this a new capability or just an easier way to do something? I'm thinking the latter since a BBS script could do the same thing but much less efficiently but I'm not quite sure.
 

lostcalpolydude

Developer
Staff member
Is this a new capability or just an easier way to do something? I'm thinking the latter since a BBS script could do the same thing but much less efficiently but I'm not quite sure.

Currently, if you switch from a familiar wearing anything to a familiar wearing nothing, mafia will equip what it thinks is best on the new familiar, with no control over that process. You can have a pre-adventure script (or whatever) switch equipment after that. I wanted this after watching my moveable feast get moved between several familiars that I was using for ~10 turns per day and didn't care what they had equipped, and also after forgetting to equip my goth kid when starting aftercore multiple times.

I could see someone using this to have a moveable feast on stat familiars and sugar shields on fairies, maybe. Or it could be used to "lock" familiar equipment that mafia doesn't switch to (snow suit, kill switch) but not put it on your hatrack or such. A simple script might just prioritize a moveable feast above little box of fireworks for someone who has both (I've had my little box of fireworks closeted for a long time to prevent mafia from choosing it, but now I can uncloset it), though it would have to handle the case of familiars that shouldn't have equipment changed still.
 

Bale

Minion
This is a super amazing idea that I have craved for a long time now, even if I didn't know it.
 

Theraze

Active member
Thank you. If the above had said "what familiar equipment to switch to" I would not have jumped to a wrong conclusion and asked. Now that I understand it sounds reasonable to me :)

Being that it runs a script, it doesn't HAVE to be familiar equipment. If you wanted to wear the whip to boost familiar weight anytime you wear a NPZR, for example, this could do so. Or any other equipment changes based on your familiar. Especially since you can tell it to run the normal mafia familiar equipment handler afterwards.

But yes, equipping alternative familiar equipment is the 'natural' usage of this. It just isn't necessarily the endpoint for all scripts.
 

Bale

Minion
I'm curious how others are using this. It seems like there's a lot of potential I haven't touched yet. At the moment my brand new familiarScript is using:

PHP:
boolean equip_it(item it) {
	if(available_amount(it) > 0)
		return equip(it);
	return false;
}

boolean equip_familiar() {

	if(my_path() == "One Crazy Random Summer" && equip_it($item[kill screen])) {
		lock_familiar_equipment(true);
		return true;
	}
	
	switch(my_familiar()) {
		case $familiar[stocking mimic]:
			return equip_it($item[bag of many confections]);
		case $familiar[artistic goth kid]:
			return equip_it($item[little wooden mannequin]);
		case $familiar[Disembodied Hand]:
		case $familiar[Mad Hatrack]:
		case $familiar[Fancypants Scarecrow]:
		case $familiar[Comma Chameleon]:
			return true;
	}
	
	if(get_property("snowmanTurns").to_int() < 100 && equip_it($item[Snow Suit]))
		return true;
	if(equip_it($item[plastic pumpkin bucket]))
		return true;
	if(equip_it($item[moveable feast]))
		return true;
	
	return false;
}

boolean main() {
	return equip_familiar();
}
 
Last edited:
Top