Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New plugin: dig-now #1853

Merged
merged 44 commits into from Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5b960b9
fix comment for Maps::getSize(); add getTileSize()
myk002 May 16, 2021
d3d5a6e
initial implementation of the dig-dug plugin
myk002 May 16, 2021
a4c8677
follow digging rules when converting tiles
myk002 Jun 1, 2021
6cf4085
convert material to layer mat when digging
myk002 Jun 2, 2021
a5b70ba
rename dig-dug to dig-now
myk002 Jun 2, 2021
fc932d2
use reveal.unhideFlood instead of our dup impl
myk002 Jun 3, 2021
02d7d4c
clean up top-level logic
myk002 Jun 3, 2021
52e666a
produce boulders from digging as per game rules
myk002 Jun 4, 2021
5f7dc86
optionally dump generated boulders at pos
myk002 Jun 5, 2021
d7f4170
implement track carving
myk002 Jun 5, 2021
6bc2a2b
implement tile smoothing
myk002 Jun 5, 2021
f1b38fb
fix up comments
myk002 Jun 5, 2021
71c605a
make options configurable and document
myk002 Jun 6, 2021
c1dcaa4
generate gems as ROUGH, not BOULDER
myk002 Jun 6, 2021
61a18b1
fix adjacent smooth walls when smoothing
myk002 Jun 6, 2021
c645cd5
move units and items to ground when it disappears
myk002 Jun 6, 2021
9e8a35d
update changelog
myk002 Jun 6, 2021
8349afa
destroy colonies when digging a ramp underneath
myk002 Jun 12, 2021
7ea8c84
allow digging of surface tiles
myk002 Jun 12, 2021
5c85364
let newly uncontained water flow
myk002 Jun 12, 2021
92656fc
update plugin docs
myk002 Jun 12, 2021
89210a5
add global anchor for dig-now
myk002 Jun 19, 2021
662f2cc
don't dig the undiggable
myk002 Jun 19, 2021
59a34c6
remove ramp tops when channeling
myk002 Jun 19, 2021
dfc938a
omg lua is ruining me
myk002 Jun 19, 2021
1670cfa
also "and" -> "&&"
myk002 Jun 19, 2021
aa1cbc9
skip marker mode dig designations
myk002 Jun 27, 2021
d6c9f99
don't overflow prod->count. it's a measly int16_t
myk002 Jun 27, 2021
1a19c3a
ramp/channel: don't dig into undiggable tiles
myk002 Jun 27, 2021
fc19fb6
add external api: dig_now_tile(out, pos)
myk002 Jun 28, 2021
93d67dd
export dig_now_tile over Lua
myk002 Jun 28, 2021
c807398
remove old reference to dig-now.h
myk002 Jun 28, 2021
48f90da
remove extra return
myk002 Jun 28, 2021
7f0c3cc
document dig-now lua api
myk002 Jun 28, 2021
0b703d9
fix adjacent smooth walls when we dig one out
myk002 Jun 28, 2021
a6c62a0
unhide properly when digging at visible edges
myk002 Jun 28, 2021
95fa9f3
use new library functions in dig-now
myk002 Jul 3, 2021
c1665f3
fix off by one error
myk002 Jul 4, 2021
8fb4563
allow only one positional param to be specified
myk002 Jul 10, 2021
79bdf36
expose link_adjacent_smooth_walls to lua
myk002 Jul 10, 2021
3c8a174
use pillars for wall ends instead of NS or EW
myk002 Jul 17, 2021
92701d6
connect smooth walls to doors
myk002 Jul 20, 2021
98fd6ef
generate random time variants where applicable
myk002 Aug 1, 2021
d8b5ac4
ensure soil tiles get randomized variants
myk002 Aug 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/Lua API.rst
Expand Up @@ -4043,6 +4043,16 @@ Lua plugin classes
- ``shuffle()``: shuffles the sequence of numbers
- ``next()``: returns next number in the sequence

dig-now
=======

The dig-now plugin exposes the following functions to Lua:

* ``dig_now_tile(pos)`` or ``dig_now_tile(x,y,z)``: Runs dig-now for the
specified tile coordinate. Default options apply, as if you were running the
command ``dig-now <pos> <pos>``. See the `dig-now` documentation for details
on default settings.

.. _eventful:

eventful
Expand Down
64 changes: 64 additions & 0 deletions docs/Plugins.rst
Expand Up @@ -2835,6 +2835,70 @@ Options:
:building: Subsequent items will become part of the currently selected building.
Good for loading traps; do not use with workshops (or deconstruct to use the item).

.. _dig-now:

dig-now
=======

Instantly completes non-marker dig designations, modifying tile shapes and
creating boulders, ores, and gems as if a miner were doing the mining or
engraving. By default, the entire map is processed and boulder generation
follows standard game rules, but the behavior is configurable.

Note that no units will get mining or engraving experience for the dug/engraved
tiles.

Trees and roots are not currently handled by this plugin and will be skipped.
Requests for engravings are also skipped since they would depend on the skill
and creative choices of individual engravers. Other types of engraving (i.e.
smoothing and track carving) are handled.

Usage::

dig-now [<pos> [<pos>]] [<options>]

Where the optional ``<pos>`` pair can be used to specify the coordinate bounds
within which ``dig-now`` will operate. If they are not specified, ``dig-now``
will scan the entire map. If only one ``<pos>`` is specified, only the tile at
that coordinate is processed.

Any ``<pos>`` parameters can either be an ``<x>,<y>,<z>`` triple (e.g.
``35,12,150``) or the string ``here``, which means the position of the active
game cursor should be used.

Examples:

``dig-now``
Dig designated tiles according to standard game rules.

``dig-now --clean``
Dig designated tiles, but don't generate any boulders, ores, or gems.

``dig-now --dump here``
Dig tiles and dump all generated boulders, ores, and gems at the tile under
the game cursor.

Options:

:``-c``, ``--clean``:
Don't generate any boulders, ores, or gems. Equivalent to
``--percentages 0,0,0,0``.
:``-d``, ``--dump <pos>``:
Dump any generated items at the specified coordinates. If the tile at those
coordinates is open space or is a wall, items will be generated on the
closest walkable tile below.
:``-e``, ``--everywhere``:
Generate a boulder, ore, or gem for every tile that can produce one.
Equivalent to ``--percentages 100,100,100,100``.
:``-h``, ``--help``:
Show quick usage help text.
:``-p``, ``--percentages <layer>,<vein>,<small cluster>,<deep>``:
Set item generation percentages for each of the tile categories. The
``vein`` category includes both the large oval clusters and the long stringy
mineral veins. Default is ``25,33,100,100``.
:``-z``, ``--cur-zlevel``:
Restricts the bounds to the currently visible z-level.

.. _diggingInvaders:

diggingInvaders
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.txt
Expand Up @@ -33,6 +33,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:

# Future

## New Plugins
- `dig-now`: instantly completes dig designations (including smoothing and carving tracks)

## Misc Improvements
- `tiletypes-here`, `tiletypes-here-point`: add --cursor and --quiet options to support non-interactive use cases

Expand Down
4 changes: 3 additions & 1 deletion library/include/modules/Maps.h
Expand Up @@ -260,8 +260,10 @@ extern DFHACK_EXPORT bool GetGlobalFeature(t_feature &feature, int32_t index);
* BLOCK DATA
*/

/// get size of the map in tiles
/// get size of the map in blocks
extern DFHACK_EXPORT void getSize(uint32_t& x, uint32_t& y, uint32_t& z);
/// get size of the map in tiles
extern DFHACK_EXPORT void getTileSize(uint32_t& x, uint32_t& y, uint32_t& z);
/// get the position of the map on world map
extern DFHACK_EXPORT void getPosition(int32_t& x, int32_t& y, int32_t& z);

Expand Down
10 changes: 9 additions & 1 deletion library/modules/Maps.cpp
Expand Up @@ -106,7 +106,7 @@ bool Maps::IsValid ()
return (world->map.block_index != NULL);
}

// getter for map size
// getter for map size in blocks
void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z)
{
if (!IsValid())
Expand All @@ -119,6 +119,14 @@ void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z)
z = world->map.z_count_block;
}

// getter for map size in tiles
void Maps::getTileSize (uint32_t& x, uint32_t& y, uint32_t& z)
{
getSize(x, y, z);
x *= 16;
y *= 16;
}

// getter for map position
void Maps::getPosition (int32_t& x, int32_t& y, int32_t& z)
{
Expand Down
1 change: 1 addition & 0 deletions plugins/CMakeLists.txt
Expand Up @@ -111,6 +111,7 @@ if(BUILD_SUPPORTED)
dfhack_plugin(deramp deramp.cpp)
dfhack_plugin(debug debug.cpp LINK_LIBRARIES jsoncpp_lib_static)
dfhack_plugin(dig dig.cpp)
dfhack_plugin(dig-now dig-now.cpp LINK_LIBRARIES lua)
dfhack_plugin(digFlood digFlood.cpp)
add_subdirectory(diggingInvaders)
dfhack_plugin(dwarfvet dwarfvet.cpp)
Expand Down