Did you know...? It's a "secret" feature.

Status
Not open for further replies.

holatuwol

Developer
I decided I'd create a post where I talk about features of KoLmafia that I added for personal reasons, just to accumulate some features which people may not know about but might like.  I'm marking this topic as locked so that it only includes features and not comments.
 

holatuwol

Developer
Sometimes, it's nice to take advantage of '*'.  It's a little symbol which is accepted in a few commands and it means "as many as possible".  Things like create * or eat * or adventure *.  Though you have to be careful when using it for eat and stuff, because KoLmafia isn't terribly smart about calculating how much is allowed.  Anyway, check out the following script which handles my muscle class, hardcore PvP multi.


use milk of mag
eat 2 inconnu
eat goat cheese pizza
use 15 twinkly wad

if today is muscle day
adventure * gallery; pulverize * antique greaves; pulverize * antique spear; pulverize * antique shield
if today is moxie day
adventure * pump up moxie

adventure * goatlet
brewery
pvp



Because of the first set of "*"s that handle muscle and moxie day, I'm guaranteed not to use any adventures at the goatlet on those days because I'll have zero adventures when KoLmafia finally reaches that line in the script.  Effectively, this is a straightforward script which does something special on muscle and moxie days and every other day just spends time leveling up a gravy fairy for PvP so I don't get toasted by the mini.

The last lines visit the brewery and prints out a list of booze that's available, and then pops up the PVP interface; it's nothing more than informational commands.  In effect, I can pick and choose which booze I want to balance out my minis, finish my PvP fights for the day, and then drink my nightcap.  So, you don't always have to have a login-through-exit script; you can have a script which has KoLmafia set you up for the day, loads the user interfaces you want loaded separate from the tabbed interface, without having to touch your settings.
 

holatuwol

Developer
One of my favorite zones content-wise is the Penultimate Fantasy Airship, but there are some ascensions (particularly softcore) where it just feels like work to unlock it. So, one option is to use KoLmafia to complete quests you don't really feel like completing.

One of KoLmafia's features is that it unlocks the beanstalk automatically should it ever need to. So all you have to do is select the PFA from the dropdown, watch the conditions autofill, and tell KoLmafia to begin. KoLmafia automatically goes through the motions of unlocking the beanstalk when it finds it can't get there (gathering a bean, using it, etc) before beginning its PFA process.

Now, as a subpart to this, suppose you gathered your three sonars but have been too lazy to bother unlocking the bean location. KoLmafia also automatically uses your sonars in order to unlock that location before visiting. This feature also kicks in when you're about to adventure at the boss bat, if you're looking for bat wings, etc. I make liberal use of it to avoid hitting use links.

Other auto-unlock sections include the valley beyond the orc chasm once you've gathered your abridged dictionary. Here, KoLmafia automatically locates a screwdriver (it asks you first, though, so don't worry too much), untinkers the abridged dictionary, bridges the chasm, and begins adventuring. Unfortunately, you need to not be using a dictionary as your attack method for KoLmafia to do this particular auto-unlock, so it's only useful in softcore with LTSynergy.

KoLmafia also automatically puts on outfits at "in disguise" locations. For example, the pirate cove in disguise, or the cola wars in disguise. Also included is the Knob Goblin king's chamber, where KoLmafia automatically uses a perfume, if needed, and puts on the harem outfit before it goes any further. Thus, my "defeat the king" script looks something like this:

checkpoint
adventure 1 the king's chamber
outfit checkpoint


Basically, the "checkpoint" command tells KoLmafia to remember that you want to have this outfit used later. The king's chamber switches your outfit before the fight, and when done, the "outfit checkpoint" tells KoLmafia to switch back to what it saved in memory before. I usually just type those commands one after another without a script, since it's three steps to defeat the goblin king, but scripting it isn't out of the question.
 

holatuwol

Developer
Now for a totally useless feature that I don't use at all, but which was added as a second thought during the implementation of the relay browser, which might come in handy for some people. :)

Suppose you use the relay browser, but you'd like KoLmafia to start out on a different page.  What do you do?  Well, you have two options.  One, you can hack KoLmafia and write all sorts of messy code to get it to do that for you automatically.  Two ... you take advantage of KoLmafia's override functionality.

You know how KoLmafia automatically loads override files in your data folder, yes?  Well, KoLmafia will do that for .html files it finds in its "relay" folder.  For example, suppose you want to load the weird records instead of the main map.  Suppose you're in compact mode -- then the main index file is called "main_c.html".  Then, to make KoLmafia load the records page first, make sure your "main_c.html" looks like this:


PHP:
<html>
<head><title>The Kingdom of Loathing</title></head>
<frameset id=rootset cols="4*,*">
	<frameset id=menuset rows="30,*">
		<frame name=menupane src="compactmenu.php" scrolling=no></frame>
		<frameset id=mainset cols="120,*">
			<frame name=charpane src="charpane.php"></frame>
			<frame name=mainpane src="records.php"></frame>
		</frameset>
	</frameset>
	<frame name=chatpane src="chatlaunch.php"></frame>
</frameset>
</html>


KoL only uses two .html files (main.html and main_c.html) so this functionality isn't actually super-useful unless you want to change the start page or change the way KoL gets laid out or create your own .html files with special links to make your life easier at times.  Really, it's all up to you.

It's a niche feature which doesn't see much use here, and it was only casually added during the relay browser's initial conception, but someone might find this handy.
 

holatuwol

Developer
Have you ever wandered into a /clan chat completely confused due to lack of context?  Well, as many people know, if you have a clan mate who talks using KoLmafia, whether it be via the relay browser or via the internal interface, KoLmafia logs chat for them.  How would you like to ask them for the last 30 lines of /clan chat to get you up to speed?

If you /msg [player] update, the player watching chat via KoLmafia (whether it be via the relay browser or KoLmafia's internal engine) will transparently scan your clan members list, and if it finds that you, the requester, are on there, it will send you a kmail back documenting the last 30 chat messages, possibly (I can't remember...) with time stamps appropriate to the time zone the player is in.  It also lets you know if /clan has been quiet if you wander in and said clan mate has been there for awhile as it'll be blank. Though that might not be too reliable. ;)

This is mainly provided so that buffbots can sit in chat and be more useful than just providing buffs.  To add onto this, KoLmafia also has buffbot-specific chat commands to help clans maintain their buffbots.  If you /msg [buffbot] restores, the buffbot will tell you how many MP restores it still has in stock so you know if you should bulk-buy more (though if you don't, KoLmafia auto-buys for you anyway).  There's also "help" which replies with a generic "please check my profile" message.

I added another nifty buffbot-specific command I added back when I was testing Testudinata for buffbot errors is "logout".  If you send a buffbot this message, and you're not a member of its clan, it will baleet you and thus you're effectively banned from the buffbot.  If, however, you're a member of the buffbot's clan, it will automatically stop everything it's doing and exit.  This helps when there are multiple people running a buffbot, as it eliminates the synch issue.  Combined with the "update" command, it makes having a buffbot around less of a hassle.
 

holatuwol

Developer
Some people seem to be confused about the nature of between battle scripts, so I figured I'd make an introductory post here explaining how they're supposed to work (they may not work like this from time to time due to changes I make to the codebase without thinking about them).  Anyway, there are three classes of between battle scripts -- actual between battle scripts, unconditional trigger scripts, and KoLmafia's auto-recovery scripts.


betweenBattleScript: This is an undocumented KoLmafia property that you can set to tell KoLmafia that you want to do something between battles.  This script starts up before any other between battle script, and thus, it can be used for mood specification (which is why it continues to exist).  In essence, the idea is all general purpose scripts where you want full control of the end-result is meant to run between battles should run here.  KoLmafia doesn't even swap back equipment when it does purchases.

unconditional trigger: These can be set in the mood interface and they involve anything that you want to run between battles where you don't mind if KoLmafia switches your equipment back if you're done.  They run before KoLmafia's moods trigger, so you can use them to set up equipment that will get swapped back out when moods are done, but their main use is to let you specify use all of an item scripts (fantasy chests, toolboxes) without interfering with between battle scripts.

auto-recovery scripts: These are executed after all of the above have been executed, and they include conditional triggers (mood maintenance), MP burning, autorecovery of HP, and autorecovery of MP, in that order.  You can customize them based on your settings, but since this is KoLmafia's internal routines running, they're kinda invincible to full-blown customization.  A lot of people ask for the ability to specify whole integer values instead of vague percentages, but I disagree with that entirely.


So in review, this is the order of events, as they are intended for the unreleased v10.7 and all releases thereafter:

- KoLmafia runs the script specified by betweenBattleScript
- KoLmafia creates an implicit checkpoint to return to when it's done
- KoLmafia runs your unconditional trigger script
- KoLmafia runs its mood maintenance routine
- KoLmafia attempts to auto-restore your HP
- KoLmafia runs its excess mana burning routine
- KoLmafia attempts to auto-restore your MP
- KoLmafia reverts to the implicit checkpoint it created earlier

In KoLmafia v10.6, steps 1 and 2 are flipped, and you can imagine the problems that creates. :)
 

holatuwol

Developer
At times, people are frustrated with the CLI because of its limitations, but having to create whole new files just to add something written in ASH seems cumbersome.  At other times, you know there's a really easy way to do something in the CLI, but the ASH, with all of its parentheses and formal validating constructs can be frustrating.  If only you could have both in one file...

So, there's a new feature which will be present in v10.7 that I added for my own reasons which maybe people might find handy.  The following is the typical ballroom script, but written in a different form.


Scenario 1

PHP:
acquire 10 olive
make 10 cocktail onion

acquire 4 sleazy hi mein
acquire 15 twinkly wad
eat 4 sleazy hi mein
use 15 twinkly wad


<inline-ash-script>

	while ( my_adventures() >= 4 )
	{
		if ( $item[dance card].item_amount() == 0 )
		{
			add_item_condition( 1, $item[dance card] );
			adventure( my_adventures(), $location[haunted ballroom] );
		}

		while( $item[dance card].item_amount() > 0 && my_adventures() >= 4 )
		{
			use( 1, $item[dance card] );
			adventure( 4, $location[haunted ballroom] );
		}
	}

</inline-ash-script>


drink flute of flat
acquire 4 horizontal tango
drink 4 horizontal tango


Scenario 2

PHP:
cli_execute
{
	acquire 10 olive
	make 10 cocktail onion

	acquire 4 sleazy hi mein
	acquire 15 twinkly wad
	eat 4 sleazy hi mein
	use 15 twinkly wad
}

while ( my_adventures() >= 4 )
{
	if ( $item[dance card].item_amount() == 0 )
	{
		add_item_condition( 1, $item[dance card] );
		adventure( my_adventures(), $location[haunted ballroom] );
	}

	while( $item[dance card].item_amount() > 0 && my_adventures() >= 4 )
	{
		use( 1, $item[dance card] );
		adventure( 4, $location[haunted ballroom] );
	}
}

cli_execute
{
	drink flute of flat
	acquire 4 horizontal tango
	drink 4 horizontal tango
}
 

holatuwol

Developer
You can actually change the image that appears KoLmafia's login window to any JPG/GIF picture you have in your KoLmafia "images" folder typing in the following to the gCLI (and of course restarting KoLmafia, since you can't change it on the fly, since the feature wasn't that developed):

PHP:
set loginWindowLogo=file.jpg
By the same token, you can do so using the set_property method in the ASH.  Files must be in the "images" folder to work, or be a file in KoLmafia's virtual images folder inside the JAR/EXE.  The current logo is "lantern.jpg" and the logo for a long time in KoLmafia was "limeglass.jpg".  KoLmafia's first logo was "penguin.gif".  I don't think Java supports PNGs, so you're limited to GIFs and JPGs.

I added this feature, and I planned on adding an interface to let people customize it, but like many KoLmafia customizations, I never bothered because I liked the status quo.
 

holatuwol

Developer
Because of the addition of "auto-stops" in adventuring, the entire gallery unlock quest can be done using nothing more than basic scripting.  The same is true of the White Citadel, but the gallery unlock is kinda interesting, as it shows how various features can interact in order to take advantage of auto-stop.  I'm going to break this script into its two natural parts.

First, KoLmafia automatically stops when it hits the manor unlock adventure.  Thus, the library can be unlocked using the following simple script:

# Default for Billiard Room: library key
set choiceAdventure77=2
set choiceAdventure78=1
set choiceAdventure79=1

# Unlock Spookyraven Manor
adventure * haunted pantry

# Find a pool cue and some hand chalk
conditions add pool cue, handful of hand chalk
adventure * haunted billiard

# Setup to succeed in the billiard room choice adventure
equip pool cue
use * handful of hand chalk

# Unlock the Haunted Library
conditions add 1 choiceadv
set betweenBattleScript=use * handful of hand chalk
adventure * haunted billiard
set betweenBattleScript=


Here, KoLmafia's auto-stop handles the unlocking of the billiard room.  Between battle scripts were used to handle the automatic usage of hand chalk, and objectives/conditions are used in order to handle getting the first bit of hand chalk and to stop once you hit the billiard room.  Can this script fail?  Yes, if it takes forever for the first pooltergeist choice adventure to show up, but since that requires a lot of RNG screwage, this script usually works. :)

In the second case, we unlock the gallery via the library.  This script is surprisingly simpler, because KoLmafia automatically stops if it hits the library adventure. :)  So, all you have to do is make sure your preferences say "unlock the gallery quest".

# Default for Library 1: unlock the second floor
set choiceAdventure80=99

# Default for Library 2: unlock the gallery quest
set choiceAdventure81=1
set choiceAdventure87=2

# Unlock the Haunted Gallery
adventure * haunted library
adventure 1 haunted conservatory


As noted previously, there is an autostop for the white citadel so that the entire white citadel can be completed using a script as simple as "adventure * whitey's grove; adventure * white citadel". The only other auto-stop in KoLmafia is found in the Sleazy back alley, since the adventure is only once a day, the cobb's knob, where KoLmafia will auto-stop if you don't have a key, and the various parts of the new Fernswarthy tower quest.

Note that auto-stops only trigger if your conditions list is empty when the adventure is encountered. So, if you want to take advantage of the few auto-stops there are, don't use conditions. :)
 

holatuwol

Developer
Because of the prevalence of Greasemonkey scripts which streamline the KoL interface, a lot of people have grown accustomed to using Firefox for playing KoL, regardless of whether or not it's the default browser.  By default, KoLmafia attempts to load your system default browser, but it's possible to change this behavior by setting a KoLmafia property.

set preferredWebBrowser=Firefox

This will cause KoLmafia to load Firefox, no matter what.  For now, the only other valid browsers include Opera, Safari, and Internet Explorer; if you'd like to use something completely different from them, and it's not your default browser, you will need to specify the complete path to the web browser instead.  Please note that if the relay browser has already been started, you will have to restart KoLmafia for it to take effect.

To have KoLmafia revert to the default behavior where KoLmafia asks for your system's default web browser, you will need to use the same set command (drop the Firefox portion) and restart KoLmafia.  Also keep in mind that on Linux (unlike other operating systems), the name of your web browser is case-sensitive.
 

holatuwol

Developer
Sometimes, people will talk in chat and ask what certain items do.  Now, I don't have a great memory, so I need to look it up.  Usually people will go consult the wiki, but the wiki can be a little slow to respond, or it might provide more information than necessary.  So, a long time ago, I added a quick way to do a game description lookup via the CLI.  Use this in conjunction with KoLmafia chat's "/run" handling, and you can type in something like this into chat:

/run lookup name of item

This will give a small pop up window with the in-game description of the item, without forcing you to find the item in the mall or forcing you to wade through thousands of other items in the internal database window (which is another pretty handy feature, in case you need to lookup lots of different things at once).

In theory, I can do a lot of different things with this (augment the information, even give a quick reference of stat gains), but I've never heard of anyone needing the functionality.  If you have any ideas on what's good for a quick CLI/chat reference that isn't provided with the in-game description and is likely to come up in chat (or as you're adventuring and you're too lazy to open up a separate window just to lookup info) feel free to post your suggestions in the KoLmafia thread on the KoL forums.
 
Status
Not open for further replies.
Top