Skip to content

Commit

Permalink
Merge pull request #866 from myk002/myk_quickfort_construction
Browse files Browse the repository at this point in the history
[quickfort] allow constructions to be built on top of constructions
  • Loading branch information
myk002 authored Oct 16, 2023
2 parents 7450359 + 4afd2f7 commit 6d8276e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Template for new versions:

## Misc Improvements
- `prioritize`: refuse to automatically prioritize dig and smooth/carve job types since it can break the DF job scheduler; instead, print a suggestion that the player use specialized units and vanilla designation priorities
- `quickfort`: now allows constructions to be built on top of constructed floors and ramps, just like vanilla. however, to allow blueprints to be safely reapplied to the same area, for example to fill in buildings whose constructions were canceled due to lost items, floors will not be rebuilt on top of floors and ramps will not be rebuilt on top of ramps

## Removed

Expand Down
11 changes: 8 additions & 3 deletions docs/gui/quickfort.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ This is the graphical interface for the `quickfort` script. Once you load a
blueprint, you will see a highlight over the tiles that will be modified. You
can use the mouse cursor to reposition the blueprint and the hotkeys to
rotate and repeat the blueprint up or down z-levels. Once you are satisfied,
click the mouse or hit :kbd:`Enter` to apply the blueprint to the map. You can
apply the blueprint as many times as you wish to different spots on the map.
Right click or hit :kbd:`Esc` to stop.
click the mouse or hit :kbd:`Enter` to apply the blueprint to the map.

You can apply the blueprint as many times as you wish to different spots on the
map. If a blueprint that you designated was only partially applied (due to job
cancellations, incomplete dig area, or any other reason) you can apply the
blueprint a second time to fill in any gaps. Any part of the blueprint that has
already been completed will be harmlessly skipped. Right click or hit
:kbd:`Esc` to close the `gui/quickfort` UI.

Usage
-----
Expand Down
20 changes: 17 additions & 3 deletions internal/quickfort/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,26 @@ local function is_valid_tile_bridge(pos, db_entry, b)
return is_valid_tile_has_space_or_is_ramp(pos)
end

local function is_valid_tile_construction(pos)
-- although vanilla allows constructions to be built on top of constructed
-- floors or ramps, we want to offer an idempotency guarantee for quickfort.
-- this means that the user should be able to apply the same blueprint to the
-- same area more than once to complete any bits that failed on the first attempt.
-- therefore, we check that we're not building a construction on top of an
-- existing construction of the same shape
local function is_valid_tile_construction(pos, db_entry)
if not is_valid_tile_has_space_or_is_ramp(pos) then return false end
local tileattrs = df.tiletype.attrs[dfhack.maps.getTileType(pos)]
local shape = tileattrs.shape
local mat = tileattrs.material
return is_valid_tile_has_space_or_is_ramp(pos) and
mat ~= df.tiletype_material.CONSTRUCTION
if mat == df.tiletype_material.CONSTRUCTION and
(
(shape == df.tiletype_shape.FLOOR and db_entry.subtype == df.construction_type.Floor) or
(shape == df.tiletype_shape.RAMP and db_entry.subtype == df.construction_type.Ramp)
)
then
return false
end
return true
end

local function is_shape_at(pos, allowed_shapes)
Expand Down

0 comments on commit 6d8276e

Please sign in to comment.