Skip to content

Commit 8f51780

Browse files
committed
Add support for new siege update buildings
1 parent 8ef275b commit 8f51780

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
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: 31 additions & 3 deletions
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
@@ -605,7 +609,7 @@ function PlannerOverlay:init()
605609

606610
local main_panel = widgets.Panel{
607611
view_id='main',
608-
frame={t=1, l=0, r=0, h=14},
612+
frame={t=1, l=0, r=0, h=15},
609613
frame_style=gui.FRAME_INTERIOR_MEDIUM,
610614
frame_background=gui.CLEAR_PEN,
611615
visible=self:callback('is_not_minimized'),
@@ -743,6 +747,24 @@ function PlannerOverlay:init()
743747
buildingplan.setSpecial(uibs.building_type, uibs.building_subtype, uibs.custom_type, 'engraved', val)
744748
end,
745749
},
750+
widgets.CycleHotkeyLabel {
751+
view_id='siege_facing',
752+
frame = {b=4, l=1, w=28},
753+
key='CUSTOM_T',
754+
key_back='CUSTOM_SHIFT_T',
755+
label='Facing:',
756+
visible=is_siege_engine,
757+
options={
758+
{label='North',value=0},
759+
{label='Northeast',value=1},
760+
{label='East',value=2},
761+
{label='Southeast',value=3},
762+
{label='South',value=4},
763+
{label='Southwest',value=5},
764+
{label='West',value=6},
765+
{label='Northwest',value=7},
766+
},
767+
},
746768
widgets.ToggleHotkeyLabel {
747769
view_id='empty',
748770
frame={b=4, l=1, w=22},
@@ -829,7 +851,7 @@ function PlannerOverlay:init()
829851
}
830852

831853
local divider_widget = widgets.Divider{
832-
frame={t=10, l=0, r=0, h=1},
854+
frame={t=11, l=0, r=0, h=1},
833855
frame_style=gui.FRAME_INTERIOR_MEDIUM,
834856
visible=self:callback('is_not_minimized'),
835857
}
@@ -1307,10 +1329,16 @@ function PlannerOverlay:place_building(placement_data, chosen_items)
13071329
if is_stairs() then
13081330
subtype = self:get_stairs_subtype(pos, pd)
13091331
end
1332+
local fields = {}
1333+
if is_siege_engine() then
1334+
local val = self.subviews.siege_facing:getOptionValue()
1335+
fields.facing = val
1336+
fields.resting_orientation = val
1337+
end
13101338
local bld, err = dfhack.buildings.constructBuilding{pos=pos,
13111339
type=uibs.building_type, subtype=subtype, custom=uibs.custom_type,
13121340
width=pd.width, height=pd.height,
1313-
direction=uibs.direction, filters=filters}
1341+
direction=uibs.direction, filters=filters, fields=fields}
13141342
if err then
13151343
-- it's ok if some buildings fail to build
13161344
goto continue

0 commit comments

Comments
 (0)