Skip to content

Commit a07aa8a

Browse files
authored
Merge pull request #5613 from NicksWorld/feat/buildings_53_01
Add support for new siege update buildings
2 parents 8ef275b + dc7057f commit a07aa8a

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

docs/changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ Template for new versions:
5959
## New Features
6060

6161
## Fixes
62+
- `buildingplan`: Building costs for reinforced walls are now correct.
6263

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

6567
## Documentation
6668

library/lua/dfhack/buildings.lua

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ local building_inputs = {
130130
vector_id=df.job_item_vector_id.PIPE_SECTION
131131
}
132132
},
133-
[df.building_type.Construction] = { { flags2={ building_material=true, non_economic=true } } },
134133
[df.building_type.Hatch] = {
135134
{
136135
item_type=df.item_type.HATCH_COVER,
@@ -353,6 +352,26 @@ local siegeengine_input = {
353352
quantity=3
354353
}
355354
},
355+
[df.siegeengine_type.BoltThrower] = {
356+
{
357+
item_type=df.item_type.BOLT_THROWER_PARTS,
358+
vector_id=df.job_item_vector_id.BOLT_THROWER_PARTS,
359+
},
360+
{
361+
item_type=df.item_type.BIN,
362+
vector_id=df.job_item_vector_id.BIN,
363+
},
364+
{
365+
name='mechanism',
366+
item_type=df.item_type.TRAPPARTS,
367+
vector_id=df.job_item_vector_id.TRAPPARTS,
368+
},
369+
{
370+
name='chain',
371+
item_type=df.item_type.CHAIN,
372+
vector_id=df.job_item_vector_id.CHAIN
373+
},
374+
},
356375
}
357376
--[[ Functions for lookup in tables. ]]
358377

@@ -380,6 +399,11 @@ local function get_inputs_by_type(type,subtype,custom)
380399
return trap_inputs[subtype]
381400
elseif type == df.building_type.SiegeEngine then
382401
return siegeengine_input[subtype]
402+
elseif type == df.building_type.Construction then
403+
if subtype == df.construction_type.ReinforcedWall then
404+
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 } }
405+
end
406+
return { { flags2={ building_material=true, non_economic=true } } }
383407
else
384408
return building_inputs[type]
385409
end

plugins/lua/buildingplan/planneroverlay.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ local function is_construction()
119119
return uibs.building_type == df.building_type.Construction
120120
end
121121

122+
local function is_siege_engine()
123+
return uibs.building_type == df.building_type.SiegeEngine
124+
end
125+
122126
local function tile_is_construction(pos)
123127
local tt = dfhack.maps.getTileType(pos)
124128
if not tt then return false end
@@ -235,6 +239,7 @@ local direction_panel_types = utils.invert{
235239
df.building_type.WaterWheel,
236240
df.building_type.AxleHorizontal,
237241
df.building_type.Rollers,
242+
df.building_type.SiegeEngine,
238243
}
239244

240245
local function has_direction_panel()
@@ -1307,10 +1312,16 @@ function PlannerOverlay:place_building(placement_data, chosen_items)
13071312
if is_stairs() then
13081313
subtype = self:get_stairs_subtype(pos, pd)
13091314
end
1315+
local fields = {}
1316+
if is_siege_engine() then
1317+
local facing = df.global.buildreq.direction
1318+
fields.facing = facing
1319+
fields.resting_orientation = facing
1320+
end
13101321
local bld, err = dfhack.buildings.constructBuilding{pos=pos,
13111322
type=uibs.building_type, subtype=subtype, custom=uibs.custom_type,
13121323
width=pd.width, height=pd.height,
1313-
direction=uibs.direction, filters=filters}
1324+
direction=uibs.direction, filters=filters, fields=fields}
13141325
if err then
13151326
-- it's ok if some buildings fail to build
13161327
goto continue

0 commit comments

Comments
 (0)