trivialskills: Automate casting the "trivial" skills

BigVinnie

Member

What Is This?​

I wrote a simple script to automate casting the so-called trivial skills an arbitrary number of times. These skills are the starting buffs for each class, 1 MP for 5 adventures of a weak buff. I HC-permed all of these skills to claim the trophy. They're not awesome, but they are cheap to use, and I like trophies.

But then... TPTB gave us the April Shower Thoughts shield (hereafter abbreviated ASTS)! Suddenly, these baby buffs became serious business with some serious benefits. So why not make it easy to use them? And why not automate using the ASTS? Therefore, I wrote this script to streamline my play. If you want to use it too, you're welcome to do so.

Usage​

Type "trivialskills NUM" into the KoLmafia gCLI, where NUM is the number of times you want to cast each trivial skill. So "trivialskills 10" will cast each trivial skill ten (10) times. That's it. Simple, right?

Okay, there's a bit more to it. The script will check how many of the trivial skills you can use. If you have none, it'll abort with an error message. It'll confirm you have enough MP to cast each trivial skill as many times as you've chosen. If you don't have enough MP, the script will abort with an error message. It'll also check if you have an ASTS and whether you're currently holding it.
  • If you have an ASTS and it is equipped, or if you don't have an ASTS, then the script will carry on with buffing you.
  • If you have an ASTS and it is notequipped, then the script will:
    • Unequip your current weapon if it requires more than one hand,
    • Equip the ASTS,
    • Cast the trivial skills as many times as you requested, and
    • Re-equip your previous off-hand item and (if it was changed) weapon.

Installation​

Type the following into Mafia's gCLI: git checkout jimdigriz211/trivialskills

Thoughts, Comments, and Suggestions​

It's my first ASH script. I'm sure it could be better, so please point out anything I missed. Along those lines: Credit goes to MCroft, heeheehee, and ckb for their excellent suggestions.

Most of all, thank you for taking the time to check out a new script that has "trivial" right there in the name. ;) If you think it's useful, please feel free to use it. Even if you don't think it's useful, thank you for reading this far!
 
Last edited:
very nice, but I'm having problems with it because I'm in a path that doesn't support permed skills.

Rich (BB code):
> trivialskills help
Saving outfit: Backup
Outfit saved
Taking off candy cane sword cane...
Equipment changed.
Holding April Shower Thoughts shield...
Equipment changed.
Cast each trivial skill 0 times, spending 0 MP in the process.
Putting on outfit: Backup
Equipment changed.
> trivialskills 10
Saving outfit: Backup
Outfit saved
Taking off candy cane sword cane...
Equipment changed.
Holding April Shower Thoughts shield...
Equipment changed.
Could not find a known, usable skill of yours uniquely matching "10 Seal Clubbing Frenzy"



A few things I'd consider.
1: Have a help feature
2: Show the help feature if someone enters the command without entering a number
3: catch errors like the one I found, so it can continue if it encounters it.
In my case I am a Zoot class, so none of my permed skills are available. I will test more after I ascend, but you can either try and fail (also helpful if someone has 5 of the 6) or you can tell Zoots and Ed the Undying (et al) that you can't help them.
4: Speaking of the backup, consider using checkpoint/outfit checkpoint/checkpoint clear instead of the cli command with the backup outfit. It's a well-supported pattern in scripts and it doesn't overwrite anything the user is currently storing in the outfit named backup. Check the ash wiki for details.
5: If you're interested in doing so, this would be a good place to use an Ash aggregate (like a list) and iterate over it, calling the skills inside the foreach iterator.

Rich (BB code):
skill [int] trivial_skills = {
  $skill[Seal Clubbing Frenzy],
  $skill[Patience of the Tortoise],
  $skill[Manicotti Meditation],
  $skill[Sauce Contemplation],
  $skill[Disco Aerobics],
  $skill[Moxie of the Mariachi]
  };
  foreach triv_skill in trivial_skills {
    catch use_skill(num_casts, trivial_skills[triv_skill]);
  };
};
Note: untested code just to show how you'd use a few of these features.
 
Last edited:
Thanks for the feedback, folks! 😁

@MCroft

I thought about the permed skills problem last night. What if someone wants to use the script but only has one (or two, or whatever) of the trivial skills instead of all of them? I think I'll modify the script to detect which trivial skills you have and respond like so:
  • All the trivial skills = Follow the original workflow, AKA cast everything with the ASTS when possible
  • Some of the trivial skills = Cast what you have (with the ASTS when possible) and ignore what you don't have
  • None of the trivial skills = Abort with an error message.
That should cover Ed, Zootomist, AoSoL, and other challenge paths that don't allow permed skills.

As for the "help" feature: Good idea! It looks like adding a string (such as "help") will cause the integer parameter to read as zero. So that's an easy condition to check.

Concerning checkpoints: I am unfamiliar with them, but I'll take a look. Are they listed on the Ash wiki?

Lastly, concerning Ash lists and "foreach": I'm mainly a PowerShell scripter, so I'm very familiar with iterating through collections of objects. This structure looks similar. I'll check it out.
 
Rich (BB code):
skill [int] trivial_skills = {
  $skill[Seal Clubbing Frenzy],
  $skill[Patience of the Tortoise],
  $skill[Manicotti Meditation],
  $skill[Sauce Contemplation],
  $skill[Disco Aerobics],
  $skill[Moxie of the Mariachi]
  };
  foreach triv_skill in trivial_skills {
    catch use_skill(num_casts, trivial_skills[triv_skill]);
  };
};
Ah, see, this is where I'd just write:

Code:
// You could write 1000, 2000, 3000, 4000, 5000, 6000 if you wanted, but that's less obvious to the reader.
foreach s in $skills[
    Seal Clubbing Frenzy, Patience of the Tortoise, Manicotti Meditation,
    Sauce Contemplation, Disco Aerobics, Moxie of the Mariachi] {
  if (have_skill(s)) {
    use_skill(num_casts, s);
  }
}
 
Welcome to the Ash scripting club!
I would also iterate over all the skills and check for their availability, then update your mana_total cost as well. Now you just multiply num_casts * 6, but that will change if the number of available skills is not 6.
You can also use Mafia's ash function mp_cost(skill), which will account for things that add or subtract for MP cost to cast a skill.

You actually don't really need to check if the character has enough total available mp, because Mafia will use its mp restore automatically to cast a skill as many times as you ask.

Lastly, outfits are weird sometimes. And you only really need to change the offhand, so it might be better to just swap the weapon (if necessary) and the offhand before casting.

Code:
item weap = equipped_item($slot[weapon]);
item offh = equipped_item($slot[off-hand]);
if (weapon_hands(weap)>1) { equip($slot[weapon],$item[none]); }
equip($slot[off-hand],$item[April Shower Thoughts shield]);

... cast stuff ...

equip($slot[off-hand],offh);
equip($slot[weapon],weap);
 
I've incorporated everyone's suggestions except relying on Mafia's MP restore:
You actually don't really need to check if the character has enough total available mp, because Mafia will use its mp restore automatically to cast a skill as many times as you ask.
I thought about that, but I want to keep the check. If it were my script and character, I wouldn't want to burn expensive consumables to cast a bunch of 1MP buffs. Folks can always use the MP restorers ahead of running the script if they really want to do so.

I shamelessly copied MCroft's code for the aggregate and ckb's code for more graceful inventory handling. The new version has been pushed to Github and is live.

Thank you to everyone for the encouragement and support! I love scripting, especially when there's a friendly community to help out the n00bs. I'm learning a lot from this process, and I appreciate it!
 
Thanks for the feedback, folks! 😁

@MCroft



As for the "help" feature: Good idea! It looks like adding a string (such as "help") will cause the integer parameter to read as zero. So that's an easy condition to check.

I think I've brought it in as a string and used if (! is_integer(parameter) ) {} to display the help if the parameter isn't an int, but lots of options work.
Concerning checkpoints: I am unfamiliar with them, but I'll take a look. Are they listed on the Ash wiki?
They're not-super-well documented on the ash wiki and hard to find. Also, there's no ASH version, it's a CLI command.https://wiki.kolmafia.us/index.php?title=CLI_Reference#Equipment,_Inventory_and_Consumption_Management

From the gCLI:
Code:
> help checkpoint

checkpoint [clear] - remembers [or forgets] current equipment, use "outfit checkpoint" to restore.
outfit [list filter] | save name | checkpoint | name - list, save, restore, or change outfits.
Lastly, concerning Ash lists and "foreach": I'm mainly a PowerShell scripter, so I'm very familiar with iterating through collections of objects. This structure looks similar. I'll check it out.
The catch blah command lets you swallow the errors, and not stop if there's a problem.
 
Back
Top