KoLmafia Guide: Custom Combat Script
Autoattacking is fine and all, but in many cases you want something a bit more sophisticated. For my example, I am a level 15 Disco Bandit, fighting the Giants in the Cloud Castle with plenty of MP regen. I want to use my Disco Bandit combo skill which makes the fight easier AND gives me a 1 turn +30% meat buff.
1) As an example, this is what I would do: (don't actually do anything for this step) In the Mafia Frame, I click the 'Custom Combat' Bottom Tab when in the Adventure TopTab. I see a script called "Default", and it has several lines: A [Default] folder, followed by a 1: Special Action, and 2: Attack With Weapon. This indicates the following: When encountering a [default] monster, on round 1: it will Use any special action indicated under the Special box, as described in the last lesson. This includes Pickpocketing, or whatever. On Round 2, it will Attack with Weapon. On round 3 and beyond, it repeats the last action commanded, which in this case is Attack with Weapon.
2) We are gonna make our own script now! Click the NEW button at the bottom-right. Give it a name. This script is now selected instead of the "Default" custom script.
Note that we have the exact same 'default code' we saw in step 1. Note that [default] does NOT refer to the name of the script. It is simply a header referring to the series of actions it performs against a default monster. In advanced scripts you can put in a [monster name] with special actions taken against just that monster. This would be great for casting an elemental spell against a physical-resistant foe for example. For now, don't worry about it.
3) Click EDIT and modify our script. For my example, My script I described earlier would look like: [default] 1: steal 2: skill disco dance of doom 3: skill disco dance II: electric boogaloo 4: attack
When you hit OK, it will interpret what you typed. For example, the keyword 'steal' turns into 'try to steal an item'. This script will pickpocket if applicable, do my 2 disco skills, then attack with weapon until end of combat. A more flexible script would be to Use Special Action as the round 1 action. This would allow me to choose whether to pickpocket or not, based on what is in my Special box.
For you, make the following script depending on your class: line 1 - [default] (leave this line alone) line 2 - 1: special action (leave this line alone too) line 3 - add 2: skill <insert skill name here> line 4 - 3: attack. (leave this line alone)
So really, all you did is add line 3 and renumber line 4 from 2: attack to 3: attack.
The only trick is to find the exact name of the desired skill. Pick one of your low-level skills like Thrust-Smack, or a spell, or whatever. Use your Relay Browser and click your top-left character profile to get the exact name. Type it in, Hit OK. The 'attack' command will turn into 'attack with weapon'. Note that the last entry is what the script will keep repeating until the combat is over.
For Reference, the HELP button will give you a list of the script commands. 'steal' is for pickpocketing, 'skill X' will perform the skill, X, you specify. 'item X' uses an item. There are several others to explore later.
4) Make sure the main KolMafia Frame's 'Action:' pulldown shows 'custom combat script' as the active one, as opposed to 'attack with weapon'.
Next, make sure that your named script is selected, as opposed to Default.
5) Time to test it! Go fight something in the Relay Browser and click the Script button at top-left. Watch and see what it does. Did it work? Actually this might be a bit tricky to determine since Scripted attacks tend to skip browser refreshes. Instead, click the 'Graphical CLI' tab and see EXACTLY what your character did.
Bonus) Modify your script and add a 20: abort. This will instruct the script to abort as the 20th action (not necessarily the 20th round). It will pop up a mini-browser and you will finish the fight manually. This is a good catch-all safety feature in case you are fighting a physical immune with no elemental damage, or using a low-power 'disguise outfit' or trying to wield a melee weapon as a moxie-class, or whatever else went wrong.
BOTTOM LINE: Combat Scripts are very flexible and can help you take advantage of stuff you might normally be too lazy to do regularly such as Disco combos, Turtle Tamer Chains, Noodle Summons, and other repetitive things.
Continue to Lesson 6: Auto-Adventuring