How a drill plays
The framework adds no buildings itself. When another mod adds a drill built on it, that drill gets a Drill tab in its inspector showing the grid under it (2x2 by default, any size the modder picks). Each cell holds a resource stack, nothing, or a hazard.
An example 3x2 grid. Veins hold double stacks, caverns half. Hidden cells show their contents only when drilled.
The player queues up to 10 actions. Each one takes work, then resolves:
- Drill
- Empties the grid and drops everything next to the drill. Depending on the building, the player can also drill just the leftmost column, the top row, or any single cell, for a matching share of the work. Drilling cells that hold nothing gives stone chunks.
- Move left / right
- Shifts the grid one column. A new column is rolled on one side and the column on the other side is lost. Every move damages the drill by half a percent of its max HP per depth level.
- Drill deeper / drill up
- Changes depth by one and rolls a whole new grid. Going deeper can cost materials, taken from unforbidden stacks anywhere on the map.
Manual drills are worked by pawns through a normal work type. Each pawn adds work at their Deep Drilling Speed, and a building with several interaction spots can take several pawns at once. Automatic drills add a fixed amount of work on a timer, no pawns needed. Both stop without power.
If Vanilla Expanded Framework is loaded, resources that a nearby pipe net can store (through the drill's own pipe comp or a connector next to it) go into the net first. The rest is placed on the ground.
Depth and hazards
Every level deeper changes the trade-off:
- Stacks grow, through
depthYieldMultiplierPerLeveland a log bonus scaled byresourceYield. - Rare resources come up more often. Near
minDepththe normal weights apply, halfway tomaxDepthevery resource is equally likely, and atmaxDepththe weights are inverted. - Every action's work cost is multiplied by the current depth.
- Power draw rises by
powerPerDepthper level. The building's info card shows the draw at its start depth. - Hazards get more common, and 2% per level of cells are hidden.
Hazards replace a cell's contents and trigger when that cell is drilled. Their odds are set in code, not XML:
| Hazard | Chance per cell at depth d | When drilled |
|---|---|---|
| Insect hive | (5 + d)%, max 50% | Infestation tunnels, d hives per cell |
| Mechanoid chamber | (1 + d)%, max 30% | d/2 mechanoids (at least one) that assault the colony |
| Methane pocket | 10% | Explosion at the drill, radius growing with depth |
Rolls run top to bottom, so each hazard's odds apply only if the ones above it missed.
Add a drill to your mod
- Add the framework as a dependency in
About.xml. Its package ID isbambaryla.resourcegeneratorframework, and it needs Harmony. - Give your building the drill comp and the drill inspector tab.
- For a manual drill, add a WorkGiverDef so pawns know to work it. Automatic drills (
isAutomatictrue) skip this.
Building
The drill-specific parts of a ThingDef. The rest (graphics, size, cost, research) is a normal building. A full example is in 1.7/Defs/example.xml.
<ThingDef ParentName="BuildingBase">
<defName>MyMod_Drill</defName>
<tickerType>Normal</tickerType>
<!-- one interaction spot per worker -->
<multipleInteractionCellOffsets>
<li>(0,0,-2)</li>
<li>(1,0,-2)</li>
</multipleInteractionCellOffsets>
<placeWorkers>
<li>PlaceWorker_PreventInteractionSpotOverlap</li>
</placeWorkers>
<inspectorTabs>
<li>BambaResourceGenerator.ITab_ResourceDrill</li>
</inspectorTabs>
<comps>
<li Class="CompProperties_Power">
<compClass>CompPowerTrader</compClass>
<basePowerConsumption>2000</basePowerConsumption>
</li>
<li Class="BambaResourceGenerator.CompProperties_ResourceDrill">
<operateJobDef>Bamba_OperateResourceDrill</operateJobDef>
<gridWidth>3</gridWidth>
<gridHeight>2</gridHeight>
<preciseDrilling>1</preciseDrilling>
<maxDepth>10</maxDepth>
<powerPerDepth>250</powerPerDepth>
<depthYieldMultiplierPerLevel>0.25</depthYieldMultiplierPerLevel>
<expandDownCostDef>Steel</expandDownCostDef>
<expandDownCostCount>50</expandDownCostCount>
<expandDownCostCountPerDepth>25</expandDownCostCountPerDepth>
<drillableResources>
<li>
<thingDef>WoodLog</thingDef>
<amount>25~50</amount>
<weight>1</weight>
</li>
</drillableResources>
</li>
</comps>
</ThingDef>
Work giver
One per manual drill. DrillThingDef points at your building; DrillJobDef is always Bamba_OperateResourceDrill.
<WorkGiverDef>
<defName>MyMod_DrillAtMyDrill</defName>
<label>drill at resource drill</label>
<giverClass>BambaResourceGenerator.WorkGiver_DrillAtResourceDrill</giverClass>
<workType>Mining</workType>
<priorityInType>50</priorityInType>
<verb>drill</verb>
<gerund>drilling</gerund>
<requiredCapacities>
<li>Manipulation</li>
</requiredCapacities>
<canBeDoneByMechs>true</canBeDoneByMechs>
<modExtensions>
<li Class="BambaResourceGenerator.DefModExtension_ResourceDrill">
<DrillThingDef>MyMod_Drill</DrillThingDef>
<DrillJobDef>Bamba_OperateResourceDrill</DrillJobDef>
</li>
</modExtensions>
</WorkGiverDef>
Field reference
Every field on BambaResourceGenerator.CompProperties_ResourceDrill. Leave a field out to keep its default.
Work and automation
| Field | Default | Meaning |
|---|---|---|
operateJobDef | none | Set to Bamba_OperateResourceDrill. Required for manual drills. |
isAutomatic | false | The drill works on its own instead of using pawns. |
tickInterval | 60 | Automatic drills: how often, in ticks, work is added. |
workPerInterval | 1 | Automatic drills: work added each interval. |
workDrill | 600 | Work to drill the whole grid. A column, row or cell costs its share. |
workMoveSideways | 300 | Work to shift the grid left or right. |
workMoveUp | 300 | Work to go up one level. |
workMoveDown | 600 | Work to go down one level. |
All work costs are multiplied by the current depth and by the player's work multiplier setting.
Grid
| Field | Default | Meaning |
|---|---|---|
gridWidth, gridHeight | 2, 2 | Grid size in cells. Both must be at least 1. |
preciseDrilling | 0 | 0: drill the whole grid only. 1: also drill the leftmost column or top row. 2: also click any cell to drill it. |
emptyCellChance | 0.3 | Chance a cell holds nothing. |
veinChance, veinMultiplier | 0.1, 2 | Chance a resource cell is a vein, and its stack multiplier. |
cavernChance, cavernMultiplier | 0.1, 0.5 | Chance a resource cell is a cavern, and its stack multiplier. |
stoneChunkDef, stoneChunkCount | ChunkGranite, 2 | What drops when a drill action finds nothing at all. |
Depth
| Field | Default | Meaning |
|---|---|---|
minDepth, maxDepth | 1, 10 | How high and how deep the drill can go. |
startDepth | 1 | Depth of a newly built drill. |
powerPerDepth | 0 | Extra watts for each level past level 1, on top of basePowerConsumption. |
depthYieldMultiplierPerLevel | 0 | Stacks are multiplied by 1 + depth × value. |
resourceYield | 1 | Stacks are also multiplied by 1 + value × ln(depth), so this does nothing at depth 1. |
expandDownCostDef | none | Material paid to go deeper. Leave empty for free. |
expandDownCostCount, expandDownCostCountPerDepth | 0, 0 | Cost to go deeper is count + perDepth × current depth. |
Resources
| Field | Default | Meaning |
|---|---|---|
allowAnyDeepdrillResource | true | Include every ThingDef with deepCommonality above 0, weighted by it. Stack size is deepCountPerCell × 0.5 to 1.5. |
isInvertWhitelist | false | With the deep-drill pool on, makes drillableResources a blacklist instead of extra entries. |
drillableResources | none | A list of entries with thingDef, amount (range, for example 25~50) and weight (default 1). Added to the deep-drill pool, or the only resources if allowAnyDeepdrillResource is false. |
baseWorkAmount, isFixedWorkAmount, selectResourceUiIcon and the per-entry fixedWorkAmount and workAmount come from the older select-a-resource drill. They still load so old XML doesn't throw errors, but nothing reads them.
Settings and compatibility
Players get a yield multiplier and a work multiplier in the mod settings. Both apply to every drill built on the framework.
With [LFS] UI Rethemed - Core active, the Drill tab is drawn in that mod's theme. The compat code is a separate assembly loaded through LoadFolders.xml only when Core is active, so there is no hard dependency. If the themed tab throws, it falls back to the vanilla look and logs one warning.
Vanilla Expanded Framework's pipe system is picked up through reflection when it is loaded, as described above. It is not required.
Credits
Design and idea by Bambaryla. The first, basic drill was written by Shun The Witch, Sandwish and Taranchuk; the grid system is by Bambaryla. Inspired by Quarry and Omni Core Drill.