Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ Template for new versions:
## New Features

## Fixes
- `buildingplan`: Building costs for reinforced walls are now correct.

## Misc Improvements
- `buildingplan`: Added support for bolt throwers and siege engine rotation.

## Documentation

Expand Down
26 changes: 25 additions & 1 deletion library/lua/dfhack/buildings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ local building_inputs = {
vector_id=df.job_item_vector_id.PIPE_SECTION
}
},
[df.building_type.Construction] = { { flags2={ building_material=true, non_economic=true } } },
[df.building_type.Hatch] = {
{
item_type=df.item_type.HATCH_COVER,
Expand Down Expand Up @@ -353,6 +352,26 @@ local siegeengine_input = {
quantity=3
}
},
[df.siegeengine_type.BoltThrower] = {
{
item_type=df.item_type.BOLT_THROWER_PARTS,
vector_id=df.job_item_vector_id.BOLT_THROWER_PARTS,
},
{
item_type=df.item_type.BIN,
vector_id=df.job_item_vector_id.BIN,
},
{
name='mechanism',
item_type=df.item_type.TRAPPARTS,
vector_id=df.job_item_vector_id.TRAPPARTS,
},
{
name='chain',
item_type=df.item_type.CHAIN,
vector_id=df.job_item_vector_id.CHAIN
},
},
}
--[[ Functions for lookup in tables. ]]

Expand Down Expand Up @@ -380,6 +399,11 @@ local function get_inputs_by_type(type,subtype,custom)
return trap_inputs[subtype]
elseif type == df.building_type.SiegeEngine then
return siegeengine_input[subtype]
elseif type == df.building_type.Construction then
if subtype == df.construction_type.ReinforcedWall then
return { { flags2={ building_material=true, non_economic=true }, quantity=2 }, { flags3={ metal=true }, item_type=df.item_type.BAR, vector_id=df.job_item_vector_id.BAR } }
end
return { { flags2={ building_material=true, non_economic=true } } }
else
return building_inputs[type]
end
Expand Down
13 changes: 12 additions & 1 deletion plugins/lua/buildingplan/planneroverlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ local function is_construction()
return uibs.building_type == df.building_type.Construction
end

local function is_siege_engine()
return uibs.building_type == df.building_type.SiegeEngine
end

local function tile_is_construction(pos)
local tt = dfhack.maps.getTileType(pos)
if not tt then return false end
Expand Down Expand Up @@ -235,6 +239,7 @@ local direction_panel_types = utils.invert{
df.building_type.WaterWheel,
df.building_type.AxleHorizontal,
df.building_type.Rollers,
df.building_type.SiegeEngine,
}

local function has_direction_panel()
Expand Down Expand Up @@ -1307,10 +1312,16 @@ function PlannerOverlay:place_building(placement_data, chosen_items)
if is_stairs() then
subtype = self:get_stairs_subtype(pos, pd)
end
local fields = {}
if is_siege_engine() then
local facing = df.global.buildreq.direction
fields.facing = facing
fields.resting_orientation = facing
end
local bld, err = dfhack.buildings.constructBuilding{pos=pos,
type=uibs.building_type, subtype=subtype, custom=uibs.custom_type,
width=pd.width, height=pd.height,
direction=uibs.direction, filters=filters}
direction=uibs.direction, filters=filters, fields=fields}
if err then
-- it's ok if some buildings fail to build
goto continue
Expand Down