loathers / autoscend

An ascension script for KoLMafia
Other
45 stars 70 forks source link

refactoring equipping code #940

Open taltamir opened 3 years ago

taltamir commented 3 years ago

I would like to discuss my plans for refactoring the equipping code before implementing them. Pushing our equip through maximizer via "equip X" and "-equip X" commands is rather unreliable. It makes for very messy maximizer strings and also can cause the maximizer to mysteriously fail. Moreover when the maximizer fails it does not properly notify us of doing so. and leaves us with an inconsistent outfit that is missing potentially important bits. I created autoForceEquip back in the day as a sort of workaround and to a degree it worked. But I think we can do better than such a jury rigged solution.

My idea is to use an array of _setting properties which get removed at begining of every loop to determine what our next adventure outfit will be. Those will also get auto cleared by mafia on rollover. Have two tiers. the "force" and "normal". (or maybe call it critical and normal?) an attempt to equip a normal when there is a critical will just give a warning and continue. an attempt to equip a critical when there is already a different critical slotted in will abort. criticals should only be used for things that are genuinely critical. And should be cleared on a failure to adventure.

During equipMaximizedGear() we should then go through our various slots and populate them. Any slot populated will then be excluded from maximizer via -slot syntax. for example -hat disables hat slot for maximizer and lets it handle the remaining slots. -slot is quite robust compared to -equip and +equip from my experience.

Also worth noting that we already partially do this. on accessories we use the properties _auto_maximize_equip_acc1 _auto_maximize_equip_acc2 _auto_maximize_equip_acc3 to store the string names of equipment that is slated to go into them via the autoEquip. so this is mostly about extending this method to all slots instead of only accessories oddly enough I am not seeing those 3 values being zeroed anywhere.

taltamir commented 3 years ago

I have an idea. what if instead of using mafia properties. I could use either a literal array or just multiple item variables which gets defined globally in autoscend_record.ash?

it can make for cleaner output to gCLI and also will save us from having to do item -> string -> item conversions by allowing us to store it as actual item values.

item slot_hat_normal;
item slot_hat_essential;
item slot_pants_normal;
item slot_pants_essential;
etc

every time resetMaximize() is called it can zero all of the above back to $item[none]