Problem with automatic equipment switching

Bale

Minion
There's this preference that allows mafia to switch into gear that lowers mp cost while in hardcore or ronin. It's great, but unfortunately it will do something really dumb like equip a Brimstone Bracelet and cast Cannelloni Cocoon. The -50% muscle will destroy hit points so that the Cocoon doesn't restore enough to be worth saving those 3 MP.

Obviously I'd like to fix the problem for my recovery script, but there are a few things I don't really know how to deal with. Here's a function that replaces use_skill(). mp_gear() tells me what the current best gear is for mp usage and maxhp_wear(item) returns what my max hp would be if I was wearing the item in question.

Code:
boolean cast(int q, skill it) {
	if(can_interact() || get_property("switchEquipmentForBuffs") == "false")
		return use_skill(q, it);
	boolean bb_panic = false;
	item wear = mp_gear();
	if(wear == $item[brimstone bracelet]) {
		int bb_hp = maxhp_wear($item[brimstone bracelet]);
		if(bb_hp < my_hp() || (objective == 0 && bb_hp < hp_autotarget) || (objective > 0 && bb_hp < objective))
			bb_panic = true;
	}
	if(bb_panic && get_property("switchEquipmentForBuffs") == "true") {
		set_property("switchEquipmentForBuffs", "false");
		use_skill(q, it);
		set_property("switchEquipmentForBuffs", "true");
		return true;
	}
	return use_skill(q, it);
}

That was enough fun background, now here are my problems:

1. Is there a better way to stop equipment switching? It seems a bit clunky to set_property("switchEquipmentForBuffs", "false"), use_skill() and then set_property("switchEquipmentForBuffs", "true") like that.

2. How do I tell if I'm under an effect that will stack with equipment (such as festival of Jarlsberg) as opposed to an effect that will not stack with equipment (such as Dreams and Lights). numeric_modifier("Mana Cost") would return -3 for both of those, but I wouldn't equip the bracelet if I was under Dreams and Lights.

3. When mafia auto-switches my accessories like that, how can I tell which accessory will be replaced? This may have an effect on Max HP, so it matters to me.
 

lostcalpolydude

Developer
Staff member
3. When mafia auto-switches my accessories like that, how can I tell which accessory will be replaced? This may have an effect on Max HP, so it matters to me.

I'm pretty sure this is always acc3 (and acc2 if there are multiple "helpful" accessories), and it wouldn't take much testing to confirm this probably.
 

Bale

Minion
I always just assumed that mafia had some way of figuring out which slot was best... If this is true, I haven't been paying sufficient attention. That's one problem down.

Thanks, lostcalpolydude!
 
Top