auto-equip sugar shield using a consult?

huvanile

New member
I'm trying to get a consult script going that auto-equips my familiar with a sugar shield after the one equipped shatters through use. I've got the code to actually equip the item (below), but I'm wondering if there's a way in ash to see if one is already equipped first.

Is there a function that I can call that would do something like an "is_equipped()" or "wearing()"? I'm thinking that checking to see if one is already equipped first might be quicker than trying to equip one each and every battle. I know I could probably check to see how many sugar shards I have in inventory, but is there a more elegant way to do this?

Thanks!

Code:
# equipSugarShield.ash 
# called from the CSS using:  consult equipSugarShield.ash

void main() {
cli_execute("equip familiar sugar shield");
}
 

slyz

Developer
There are several ways to look for ASH functions. The first one is typing
Code:
ashref <partial name>
in the gCLI, like this:
Code:
> ashref equip

boolean can_equip( item )
boolean equip( item )
boolean equip( slot, item )
int equipped_amount( item )
item equipped_item( slot )
item familiar_equipment( familiar )
item familiar_equipped_equipment( familiar )
boolean have_equipped( item )

You can also search the KoLMafia Wiki. There is a shortcut: typing
Code:
ashwiki familiar_equipment
in the gCLI will also bring up the wiki page for you.

Regarding your script, Mafia can already automatically re-equip breakable equipment (Adventure tab -> Choice Advs middle tab -> Item side tab -> Breakable Equipment).

Oh, and just so you know, the term "consult script" is used for scripts that manage fights. Trying to equip something during a fight is unlikely to work ^^
 
Last edited:

huvanile

New member
sweet, this helps a great deal. "teach a man to fish..." or something. :D thanks!
 
Last edited:

Winterbay

Active member
Isn't there a preference for re-equipping the same kind of thing that just broke?

Ahh, found it: breakableHandling.

Typing "set breakableHandling4183 = 3" in the CLI should make it so that Mafia reequips sugar shields until they are all out and then aborts.

That said, making a script also works :)
 

Bale

Minion
First of all, exactly what slyz and Winterbay just said. I'd also like to point out that this is in the KoLmafia wiki FAQ

Secondly, please don't try to do that with a consult script. Consult scripts run during combat. You shouldn't try to equip gear during combat. I could think of a way to make it work, but it is still extremely bad form.
 
Last edited:

huvanile

New member
Thanks for weighing in on this Bale, PMslyz and Winterbay. (The more I mess around with mafia the less noob-ish questions I'll post.) Setting the preference in the GUI achieved what I was trying to do with ease.

@Bale: Thanks for all the great scripts btw. Your OCD inventory control and your universal_recovery scripts have been a huge help.
 

Bale

Minion
Being told you like my scripts doesn't make me at all happy, you bastard.
happy.png
 

slyz

Developer
Quick, tell Bale you hate the way Universal Recovery handles items that restore full health before he gets too unhappy!
 

Theraze

Active member
Have we reached the point where we get to rail at how it actually considers healing beaten up: how and when it will happen instead of just doing it in a somewhat random fashion?
 

huvanile

New member
Is this a joke? Whatever, I'll send you a stuffed hodgmen instead when I get one. Note to self: shut up on forums. (facepalm)
 

Bale

Minion
Is this a joke?

Yes. Apparently not a very well received one. Ah well, at least slyz seemed to understand it was a joke. It actually makes me very happy to hear people are pleased with my scripts, but that seemed a bit obvious to point out so I went full reverse.
 
Last edited:

Theraze

Active member
I was trying to join in too. :( Apparently it failed. Referring to mafia's attempt at curing BU before it actually lets recovery scripts do it, if people misset their preferences, and... Anyways, sadness.
 

Bale

Minion
Did you know that removeMalignantEffects is a global pref, so if I wanted my script to turn off that property and take over the function itself it would strand other characters who might not be using Universal Recovery? Maybe I could consider that if it was a user property, but global?
 

Theraze

Active member
Depressing... if a global pref is put into a local pref file (is that even possible?) would it stick there?
 

Theraze

Active member
Ah well... so it goes. Unfortunate that it hits before the recovery script, so it can't just be depreciated while using it...
 

huvanile

New member
Hey do any of you know if there's an ash function I can call to check to see if I'm currently wearing one of my custom outfits or not?

Taking slyz's advice, I did an "ashref outfit", "ashwiki outfit" and "ashref equipped" but I can't really find what I'm looking for. I'm thinking something like a "my_outfit()" would do it if such a thing exists. I see there's a "have_outfit()" function, but I think that just checks to see if I have an outfit available but not necessarily if I'm wearing it or not.

I know I could use "have_equipped()" for one of the pieces of my custom outfit, but I don't want to have to change my script if I improve my custom outfit later on down the line.

Any thoughts?
 

slyz

Developer
You could always do outfit( "outfit name" ). If you were using it, nothing happens. If you weren't using it, it will equip it.
 

Theraze

Active member
If the patch for my_outfit gets added, you could use that. Otherwise, you have to try to wear the outfit and see if it changes your gear.
 

Winterbay

Active member
But your patch still doesn't return the name of eventual custom outfit I may or not be wearing. I guess without Mafia storing which outfit contains what that would be difficult.
 
Top