Last active
August 29, 2015 13:55
-
-
Save IndigoFenix/8776696 to your computer and use it in GitHub Desktop.
Creates a pit under the target leading straight to the Underworld.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---Creates a pit under the target leading straight to the Underworld. Type '?' for help. | |
args={...} | |
if args[1] == '?' then | |
print("First parameter is target unit id, or 0 to select a location with the cursor.\n Second parameter is size of the pit in all directions.\n Third parameter is 1 to wall off the sides of the pit on all layers except the underworld, or anything else to leave them open. (Leaving them open may allow flying cave-dwellers to path to your fortress if you have normal access to the caverns)\n Fourth parameter is 1 to add stairs. Note that stairs are a bit buggy, as they will not reveal the bottom until you dig somewhere, but will still allow underworld creatures to path to your fortress.") | |
return | |
end | |
if args[1] ~= nil then | |
local unit = df.unit.find(tonumber(args[1])) | |
end | |
if unit then | |
pos=unit.pos | |
else | |
pos=position or copyall(df.global.cursor) | |
end | |
size = tonumber(args[2]) | |
if size == nil or size < 1 then size = 1 end | |
wallOff = tonumber(args[3]) | |
stairs = tonumber(args[4]) | |
--Get the layer of the underworld | |
for index,value in ipairs(df.global.world.cur_savegame.map_features) do | |
local featureType=value:getType() | |
if featureType==9 then --Underworld | |
underworldLayer = value.layer | |
--print(underworldLayer) | |
end | |
end | |
if pos.x==-30000 then | |
qerror("Select a location") | |
end | |
local x = 0 | |
local y = 0 | |
for x=pos.x-size,pos.x+size,1 do | |
for y=pos.y-size,pos.y+size,1 do | |
z=1 | |
local hitAir = false | |
local hitCeiling = false | |
while z <= pos.z do | |
local block = dfhack.maps.ensureTileBlock(x,y,z) | |
if block then | |
if block.tiletype[x%16][y%16] ~= 335 then | |
hitAir = true | |
end | |
if hitAir == true then | |
if not hitCeiling then | |
if block.global_feature ~= underworldLayer or z > 10 then hitCeiling = true end | |
if stairs == 1 and x == pos.x and y == pos.y then | |
if block.tiletype[x%16][y%16] == 32 then | |
if z == pos.z then | |
block.tiletype[x%16][y%16] = 56 | |
else | |
block.tiletype[x%16][y%16] = 55 | |
end | |
else | |
block.tiletype[x%16][y%16] = 57 | |
end | |
end | |
end | |
if hitCeiling == true then | |
if block.designation[x%16][y%16].flow_size > 0 or wallOff == 1 then needsWall = true else needsWall = false end | |
if (x == pos.x-size or x == pos.x+size or y == pos.y-size or y == pos.y+size) and z==pos.z then | |
--Do nothing, this is the lip of the hole | |
elseif x == pos.x-size and y == pos.y-size then if needsWall == true then block.tiletype[x%16][y%16]=320 end | |
elseif x == pos.x-size and y == pos.y+size then if needsWall == true then block.tiletype[x%16][y%16]=321 end | |
elseif x == pos.x+size and y == pos.y+size then if needsWall == true then block.tiletype[x%16][y%16]=322 end | |
elseif x == pos.x+size and y == pos.y-size then if needsWall == true then block.tiletype[x%16][y%16]=323 end | |
elseif x == pos.x-size or x == pos.x+size then if needsWall == true then block.tiletype[x%16][y%16]=324 end | |
elseif y == pos.y-size or y == pos.y+size then if needsWall == true then block.tiletype[x%16][y%16]=325 end | |
elseif stairs == 1 and x == pos.x and y == pos.y then | |
if z == pos.z then block.tiletype[x%16][y%16]=56 | |
else block.tiletype[x%16][y%16]=55 end | |
else block.tiletype[x%16][y%16]=32 | |
end | |
block.designation[x%16][y%16].hidden = false | |
--block.designation[x%16][y%16].liquid_type = true -- if true, magma. if false, water. | |
block.designation[x%16][y%16].flow_size = 0 | |
dfhack.maps.enableBlockUpdates(block) | |
block.designation[x%16][y%16].flow_forbid = false | |
end | |
end | |
block.designation[x%16][y%16].hidden = false | |
end | |
z = z+1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would merging this into dfhack work as a replacement for needs_porting/hellhole.cpp?