Mafia unequips familiar equipment

Status
Not open for further replies.

CherryJ

New member
Hi, so today when I logged in to KoL through mafia this happened. As the last action during breakfast it removed my current familiar equipment and this has never happened before. I can't really find anything in settings that corresponds to this, should I just download a newer version or is there something else I can do to stop it? Also familiar equipment locking does not work for some reason.
 

VladYvhuce

Member
I ran into a similar problem around the same time as you. Specifically: Mafia kept stealing the plastic pumpkin bucket from my Homemade Robot and tried giving it to any familiar I switched to, unless they had equipment already equipped. This kept up until I was out of Ronin and pulled all of my familiar equipment from Hagnk's and equipped all the other familiars accordingly, forcing it to have no choice but to leave the ppb on the robot.
 

Bale

Minion
As the last action during breakfast it removed my current familiar equipment and this has never happened before.
I don't know why that happens. Do you have a loginScript?

Specifically: Mafia kept stealing the plastic pumpkin bucket from my Homemade Robot and tried giving it to any familiar I switched to, unless they had equipment already equipped..
This is a known feature. It exists on purpose and for positive reasons. I consider it to be a good thing and I'm not sure why you want to stop it, but you can program a familiarScript that will make equipment switching on your familiar work the way you desire.
 

Bale

Minion
The following familiarScript is only slightly related to this thread, but might be interesting. At the least, it is an example of the type of script AMVladYvhuce might use to solve his ppb switching concern. (Though I cannot imagine why it is bad to switch the ppb.)

A familiarScript is executed every time the character changes familiars. If it returns true, KoLmafia will not try to switch familiar gear.

PHP:
boolean equip_it(item it) {
	return equipped_item($slot[familiar]) == it || (available_amount(it) > 0 && equip(it));
}

// Primestat to true for Crimbo Shrub choice
int to_int(stat s) {
	switch(s) {
	case $stat[Muscle]:      return 1;
	case $stat[Mysticality]: return 2;
	case $stat[Moxie]:       return 3;
	}
	return 0;
}

// Make a static list of all Generic familiar gear that is not breakable and increases familiar weight
item [int] generic_familiar_gear() {
	item [int] gear;
	foreach it in $items[]
		if(item_type(it) == "familiar equipment" && string_modifier(it, "Modifiers").contains_text("Generic") && !string_modifier(it, "Modifiers").contains_text("Breakable") && numeric_modifier(it, "Familiar Weight") > 0)
			gear[ count(gear) ] = it;
	sort gear by -numeric_modifier(value, "Familiar Weight");
	return gear;
}
static item [int] generics = generic_familiar_gear();

boolean equip_familiar() {

	item specific;
	switch(my_familiar()) {
		case $familiar[Baby Bugged Bugbear]:
			if(equipped_item($slot[familiar]) == $item[none]) {
				if(item_amount($item[bugged balaclava]) > 0)
					specific = $item[bugged balaclava];
				else if(item_amount($item[bugged bön±Ã©t]) > 0)
					specific = $item[bugged bön±Ã©t];
				else if(item_amount($item[bugged beanie]) == 0) {
					visit_url("arena.php");
					cli_execute("fold bugged balaclava");
					specific = $item[bugged balaclava];
				} else
					specific = $item[bugged beanie];
			} else 
				specific = $item[bugged beanie];
			break;
		case $familiar[Mini-Hipster]:
			return false;
		case $familiar[stocking mimic]:
			specific = $item[bag of many confections];
			break;
		case $familiar[artistic goth kid]:
			specific =  $item[little wooden mannequin];
			break;
		case $familiar[Dataspider]:
			specific = $item[solid state loom];
			break;
		case $familiar[Crimbo Shrub]:
			// Decorate my Crimbo Shrub!!
			if(get_property("shrubGifts") == "") {
				visit_url("inv_use.php?pwd&which=3&whichitem=7958");
				// Set lights = prismatic dmg, garland = bloacking, gift = yellow ray, topper = mainstat
				visit_url("choice.php?whichchoice=999&pwd&option=1&lights=1&garland=3&gift=1&topper=" + to_int(my_primestat()));
			}
			break;
		// Never swtich gear for any of the following familiars
		case $familiar[Disembodied Hand]:
		case $familiar[Mad Hatrack]:
		case $familiar[Fancypants Scarecrow]:
		case $familiar[Comma Chameleon]:
			return true;
	}
	
	// This is after setting Crimbo Shrub, but before equipping any other familiar item
	if(my_path() == "One Crazy Random Summer" && equip_it($item[kill screen])) {
		if(!is_familiar_equipment_locked())
			lock_familiar_equipment(true);
		return true;
	}
	
	if(specific != $item[none] && equip_it(specific))
		return true;
	
	sort generics by -numeric_modifier(value, "Familiar Weight"); // Value of Snow Suit changes over time
	foreach x,doodad in generics
		if(equip_it(doodad))
			return true;
	
	return false;
}

// Lock gamiliar gear if it is hardcore and the gear is generic.
void check_lock() {
	if(!can_interact() && equipped_item($slot[familiar]).string_modifier("Modifiers").contains_text("Generic") && !is_familiar_equipment_locked())
		lock_familiar_equipment(true);
}

boolean main() {
	if(is_familiar_equipment_locked())
		return true;
	boolean ok = equip_familiar();
	check_lock();
	return ok;
}
 

VladYvhuce

Member
This is a known feature. It exists on purpose and for positive reasons. I consider it to be a good thing and I'm not sure why you want to stop it, but you can program a familiarScript that will make equipment switching on your familiar work the way you desire.
Ah. Well, that explains why it's so persistent. It was annoying me because I have generic familiar equipment for all of my familiars without specific equipment, and was trying to equip them with Mafia's gear changer, and kept having to switch equipment and re-equip the robot with the ppb. It may be a nice function for a handful of familiars, but when you have 170+ and Mafia wants to give the ppb to every one of them, it can get a bit frustrating. Since I'm on a 23k dial-up connection, mafia's gear changer tends to be a lot faster than using the "equip familiar X with equipment Y" drop-down in the terrarium. I may just avoid equipping that group of familiars until after ronin, and work up a script I can call to handle them, so I won't have a persistent script arguing with Mafia. Still, it's good to know that I'm not going crazier, and that Mafia isn't broken in that aspect. I was affraid I might have messed something up, since it didn't make any sense to me why it would do that.
 

Bale

Minion
I was affraid I might have messed something up, since it didn't make any sense to me why it would do that.

It makes sense because most people who have generic familiar equipment want to use that item for all their familiars. Mafia helps them out by switching the gear to whatever their active familiar might be.
 

Veracity

Developer
Staff member
If you already have the familiar equipped with any item, it will not switch in a new item.
Unless, you let KoL itself auto-equip your familiar item because you Locked it.
The familiar trainer "equip all familiars" button will equip all of your familiars with their specific familiar items - unless you don't have it, in which case, it will leave it with the generic item (or noe) you have on it right now.

I don't see any problems with what I just described.

If you don't like those actions, then explain very clearly why you you think something else is better. Since this is how it has behaved for many years, you are unlikely to change any minds - in particular, mine - but, do your best. Go wild!

If you believe it is behaving differently than what I just explained, give all the details for a reproducible series of actions which results in something different.

Thanks.
 

lostcalpolydude

Developer
Staff member
It sounds like VladYvhuce prefers different generic equipment for different familiars, and wants at least one of them shared between multiple familiars. There's no sane way for the auto-equipping behavior to handle that, which is why I added familiarScript to make it customizable.
 

VladYvhuce

Member
It sounds like VladYvhuce prefers different generic equipment for different familiars, and wants at least one of them shared between multiple familiars.
That's not it. I have multiple generic familiars, and simply want each to have its own different piece of generic familiar equipment. Familiar A = Equipment A, Familiar B = Equipment B, and so on. I tend to think differently that most people in whatever group I find myself in. I think that assigning equipment the way I do gives more individuality to my generic familiars. It's just personal preference. I simply made the mistake of choosing to pull the generic equipment while I was in ronin during this run, and the further mistake of trying to keep the ppb on the homemade robot. I'll count it as a learning experience.
 

Bale

Minion
You can definitely program a familiarScript to do that for you automatically. Just program it with the information of what gear you want on which familiar and it can equip that gear when you switch to that familiar.

Refer to my earlier example and note that there are several familiars (stocking mimic, artistic goth kid, Dataspider) for which I define their specific gear to always be equipped.
 

VladYvhuce

Member
For familiars with weirdly named equipment, can I switch out the item number for the item name? Such as "4000" instead of "string of dingle balls"?
 

Bale

Minion
Sure. Use $item[4000] if you like, but I promise that it will make your script harder to read. If you make a habit of that, then one day you'll be looking a script, trying to update it for a change to KoL, and not know what item number 7654 might be.
 

Veracity

Developer
Staff member
Why would an item's "weird name" matter? Since it's in a script, you only need to get it right once.
 

VladYvhuce

Member
This was very much an "ask before I go about mucking with something I could screw up terribly" situation. I was worried that "string" might not be a good thing to put in an item name, in addition to wanting a contingency plan for future item use for those things whose names don't work out right in plain text. I don't plan on resorting to item numbers often, but it's nice to know that I can do so if I can't get the item name to work for whatever reason.
 

heeheehee

Developer
Staff member
Oh, right.
Code:
$item[string of dingle balls]
is no more problematic than
Code:
"string"

Now you know!

The biggest reason to use item numbers is in the case where multiple items have the same name (e.g. Staff of Ed).
 

VladYvhuce

Member
Eureka! Let me know if there's anything else I can trim out of this. Sorry for anyone who red the rant that previously occupied this post. I guess getting worked up about a subject is good motivation to find a solution...

Code:
     boolean equip_it(item it) {
        return equipped_item($slot[familiar]) == it || (available_amount(it) > 0 && equip(it));
    }

    // Make a static list of all Generic familiar gear that is not breakable and increases familiar weight
    item [int] generic_familiar_gear() {
        item [int] gear;
        foreach it in $items[]
            if(item_type(it) == "familiar equipment" && string_modifier(it, "Modifiers").contains_text("Generic") && !string_modifier(it, "Modifiers").contains_text("Breakable") && numeric_modifier(it, "Familiar Weight") > 0)
                gear[ count(gear) ] = it;
        sort gear by -numeric_modifier(value, "Familiar Weight");
        return gear;
    }
    static item [int] generics = generic_familiar_gear();

    boolean equip_familiar() {

            // Never swtich gear for any of the following familiars
            case (familiar = my_familiar()):
                return true;
    }
 
Last edited:

Bale

Minion
That script doesn't make any sense to me. It won't pass a syntax check and even if it did, it wouldn't actually do anything.

The biggest problems are that you lack a main() and your equip_familiar() function makes no sense since a switch-case function does not work that way and you never defined the variable familiar.
 

VladYvhuce

Member
I set it to my Familiar Script slot and it does, indeed, keep Mafia from auto-equipping a familiar when that familiar is equipped with no equipment, thus not stealing the PPB. It doesn't throw up any errors, either. I've been using it all night with no problem. Are there some parts I should trim out? Is there stuff I should add to make it more user-friendly to others? I have no idea on either. I'm just as amazed that it works as you are.
 

heeheehee

Developer
Staff member
Re: Bale's comments:
Code:
     boolean equip_it(item it) {
        return equipped_item($slot[familiar]) == it || (available_amount(it) > 0 && equip(it));
    }
could be simplified to
if (available_amount(it) > 0) equip($slot[familiar], it);

Code:
    // Make a static list of all Generic familiar gear that is not breakable and increases familiar weight
    item [int] generic_familiar_gear() {
        item [int] gear;
        foreach it in $items[]
            if(item_type(it) == "familiar equipment" && string_modifier(it, "Modifiers").contains_text("Generic") && !string_modifier(it, "Modifiers").contains_text("Breakable") && numeric_modifier(it, "Familiar Weight") > 0)
                gear[ count(gear) ] = it;
        sort gear by -numeric_modifier(value, "Familiar Weight");
        return gear;
    }
Consider using boolean_modifier(it, "Breakable"), boolean_modifier(it, "Generic").

Code:
    static item [int] generics = generic_familiar_gear();

    boolean equip_familiar() {

            // Never swtich gear for any of the following familiars
            case (familiar = my_familiar()):
                return true;
    }
This is probably what he was complaining about. That's an instance of case without switch, you use = instead of ==, and you don't always return a value. You probably want to do something like
return familiar == my_familiar();

And, as Bale mentioned, you don't have a main function, so your familiarScript is probably implicitly returning something that gets treated as true all the time, so Mafia stops swapping gear.
 
Status
Not open for further replies.
Top