DCSS pillar dancing script
Automates pillar dancing. Essentially, the user chooses a pillar (or rather, a tile within a pillar), and the script automatically finds a shortest path around that pillar. It then automatically walks the user around the pillar as long as the user is able to walk away from all onscreen monsters until the user is at full HP and MP. As the script is certainly nowhere near a finished state, I have included a "manual" mode in which you can see where the pillar dance plans to take you next and "step" through the pillar dance.
This is a demo of normal use of the script. This shows off the manual mode of pillar dancing. You can see that when the second hobgoblin comes into view on the bottom left, the pillar dance stops, as moving would take me closer to it.
This shows off the automatic direction switching. You can see that when we encounter the rat in the direction we were previously moving, we switch direction automatically.
To use, you have to put the contents of the pillardance.lua
script in your crawl RC file, inside a pair of curly braces {}, like:
<rest of rc file>
{
<contents of pillardance.lua>
}
You have to macro a few keys to Lua functions. To macro the key K to the luafunction funcName, you would put the following line in your crawl RC file: macros += M K ===funcName
The functions that need to be mapped to keys are:
inputTogglePillar -- This is the "find/kill pillar" function. When called, it will prompt the user to choose a (wall) tile of the pillar that they want to use for pillar dancing. First, the current pillar will be killed. If the user selected a wall tile of the current pillar, nothing more will happen, the pillar will just be killed. Otherwise, the function will then find the best path around the pillar and save it, and show the tiles of that best path by excluding them.
dancePillar -- This is the actual "dance pillar" function. When called, if the user is standing on one of the path tiles, a pillar dance will be initiated. If auto mode is enabled, pillar dancing will automatically happen until
- Both directions the user can walk take the user either closer to an enemy or adjacent to an enemy, or
- There are fast/ranged/magic-using enemies on screen, or
- The user is at full HP and MP, or
- It has been 500 turns since the dance began (this is to protect against the possibility the user has no regen near enemies or is a DD or something). If auto mode is disabled, pillar dancing won't start automatically. Note that when manually pillar dancing, above conditions 1 and 2 still cause the pillar dance to end.
If you are going to use manual mode, you will need to also map:
doStep -- If we just started dancing or if we need to switch direction, this will just exclude the next tile we plan to dance onto and return. Otherwise, this will move onto the calculated "next" tile that is currently excluded, un-exclude it, and exclude the next tile we plan to dance onto. NOTE: You can end the manual dance by pressing the button bound to dancePillar.
If you want to dynamically switch between auto and manual mode, map:
invertAuto -- Switches between auto and manual mode.
And to "kill" the pillar, which has the benefit of removing the exclusion tiles around the pillar, map killPillar.
Note: Doing stupid things could have unintended consequences; if you call functions or do things when this script doesn't expect you to, bad things can and will happen. A good example is manually moving while in the middle of a pillar dance, and then trying to keep dancing. Don't do this.
Feel free to give feedback/possible changes for the script by opening an issue or a PR.