Skip to content
Snippets Groups Projects
Commit d99b9553 authored by Duane Robertson's avatar Duane Robertson
Browse files

Add rooms to complexes.

parent 1edd6530
No related branches found
No related tags found
No related merge requests found
......@@ -295,7 +295,8 @@ local function generate(p_minp, p_maxp, seed)
local index = 0
local index3d = 0
local last_biome, last_px, last_py, last_pz, node_top, node_filler, node_water_top, node_water, depth_top, depth_water_top, depth_filler, node_stone, ocean, swamp, beach, dunes, height
local biome, cave_lining
local biome, cave_lining, room_type, room_type_below
for z = minp.z, maxp.z do
local dz = z - minp.z
local fdz = z % fcsize.z
......@@ -310,10 +311,23 @@ local function generate(p_minp, p_maxp, seed)
local ivm = a:index(x, minp.y, z)
local cave_height = 0
last_py = nil
for y = minp.y, maxp.y do
local dy = y - minp.y
local fdy = y % fcsize.y
local py = math_floor(y / fcsize.y)
if biome == 'control' then
local room_px = math_floor((math_abs(fdx - half_pod.x) - 3) / room_size)
local room_py = math_floor(fdy / 5)
local room_pz = math_floor((math_abs(fdz - half_pod.z) - 3) / room_size)
room_type = math_floor((math_abs(room_pz * room_py * room_px * px * py * pz) % 17) / 3)
room_type_below = math_floor((math_abs(room_pz * (room_py - 1) * room_px * px * py * pz) % 17) / 3)
if room_type_below == 1 and room_type == 3 then
room_type = 0
end
end
if py ~= last_py or px ~= last_px or pz ~= last_pz then
biome, cave_lining = get_biome(x, y, z)
end
......@@ -370,14 +384,52 @@ local function generate(p_minp, p_maxp, seed)
end
elseif fdz == 0 and fdz == pod_size.z - 1 or fdx == 0 and fdx == pod_size.x - 1 or fdy == 0 and fdy == pod_size.y - 1 then
data[ivm] = node['loud_walking:scrith']
elseif biome == "control" and fdy % 5 == 0 then
data[ivm] = node["loud_walking:control_floor"]
elseif biome == "control" and (math_abs(fdx - half_pod.x) < 3 or math_abs(fdz - half_pod.z) < 3) then
--data[ivm] = node["air"]
elseif biome == "control" and ((math_abs(fdx - half_pod.x) % room_size == 3 and (math_abs(fdz - half_pod.z) - 12) % room_size > 3) or (math_abs(fdz - half_pod.z) % room_size == 3 and (math_abs(fdx - half_pod.x) - 12) % room_size > 3)) then
data[ivm] = node["loud_walking:control_wall"]
elseif biome == "control" then
--
elseif biome == "control" and fdy < pod_size.y then
if (math_abs(fdx - half_pod.x) < 3 or math_abs(fdz - half_pod.z) < 3) then
-- corridor
if fdy % 5 == 0 then
data[ivm] = node["loud_walking:control_floor"]
end
elseif ((math_abs(fdx - half_pod.x) % room_size == 3) or (math_abs(fdz - half_pod.z) % room_size == 3)) then
if fdy % 5 == 0 then
data[ivm] = node["loud_walking:control_floor"]
elseif ((math_abs(fdx - half_pod.x) % room_size == 3 and (math_abs(fdz - half_pod.z) - (math_floor(room_size / 2) + 2)) % room_size > 3) or (math_abs(fdz - half_pod.z) % room_size == 3 and (math_abs(fdx - half_pod.x) - (math_floor(room_size / 2) + 2)) % room_size > 3)) then
data[ivm] = node["loud_walking:control_wall"]
end
elseif fdy % 5 == 0 then
if room_type == 1 then
if room_type_below == 1 then
data[ivm] = node["loud_walking:control_floor_alert_both"]
else
data[ivm] = node["loud_walking:control_floor_alert_up"]
end
elseif room_type_below == 1 then
data[ivm] = node["loud_walking:control_floor_alert_down"]
elseif room_type == 3 then
data[ivm] = node["loud_walking:control_floor_growth"]
else
data[ivm] = node["loud_walking:control_floor"]
end
elseif room_type == 2 and fdy < pod_size.y then
if math_abs(fdx - half_pod.x) % 4 < 3 and math_abs(fdz - half_pod.z) % 4 < 3 then
data[ivm] = node["loud_walking:air_ladder"]
end
elseif room_type == 3 then
if fdy % 5 == 1 then
local sr2 = math.random(20)
if sr2 == 1 then
data[ivm] = node["loud_walking:control_plant_1"]
elseif sr2 == 2 then
data[ivm] = node["loud_walking:control_plant_2"]
end
end
elseif room_type == 4 then
if fdy % 5 == 4 and (((math_abs(fdx - half_pod.x) % room_size == 4 or math_abs(fdx - half_pod.x) % room_size == 2) and (math_abs(fdz - half_pod.z) - (math_floor(room_size / 2) + 2)) % room_size > 3) or ((math_abs(fdz - half_pod.z) % room_size == 4 or math_abs(fdz - half_pod.z) % room_size == 2) and (math_abs(fdx - half_pod.x) - (math_floor(room_size / 2) + 2)) % room_size > 3)) then
data[ivm] = node["loud_walking:controls"]
end
else
-- nop
end
elseif (((fdx == (half_pod.x - control_off) or fdx == (half_pod.x + control_off)) and fdz >= (half_pod.z - control_off) and fdz <= (half_pod.z + control_off)) or ((fdz == (half_pod.z - control_off) or fdz == (half_pod.z + control_off)) and fdx >= (half_pod.x - control_off) and fdx <= (half_pod.x + control_off))) and fdx ~= half_pod.x and fdz ~= half_pod.z and fdy == pod_size.y - 2 then
data[ivm] = node["loud_walking:controls"]
elseif (((fdx == (half_pod.x - control_off) or fdx == (half_pod.x + control_off)) and fdz >= (half_pod.z - control_off) and fdz <= (half_pod.z + control_off)) or ((fdz == (half_pod.z - control_off) or fdz == (half_pod.z + control_off)) and fdx >= (half_pod.x - control_off) and fdx <= (half_pod.x + control_off))) and fdx ~= half_pod.x and fdz ~= half_pod.z and fdy > pod_size.y - control_off then
......@@ -522,59 +574,6 @@ local function generate(p_minp, p_maxp, seed)
local t3 = os.clock()
if false and pod and biome == "control" then
for dy = 0, 15 do
for dz = 0, 1 do
for dx = 0, 1 do
local x1 = minp.x + dx * 26 + 17
local z1 = minp.z + dz * 26 + 17
local y1 = minp.y + dy * 5
local sr = math.random(6)
for z = 0, 20 do
local ivm = a:index(x1, y1, z1 + z)
for x = 0, 20 do
if sr == 1 then
if dy > 0 then
if data[ivm] == node["loud_walking:control_floor_alert_down"] then
data[ivm] = node["loud_walking:control_floor_alert_both"]
else
data[ivm] = node["loud_walking:control_floor_alert_up"]
end
end
if dy < 15 then
data[ivm + a.ystride * 5] = node["loud_walking:control_floor_alert_down"]
end
elseif sr == 2 then
if x > 1 and x < 19 and z > 1 and z < 19 and (z - 2) % 4 ~= 0 and (x - 2) % 4 ~= 0 then
for y = 1, 4 do
data[ivm + y * a.ystride] = node["loud_walking:air_ladder"]
end
end
elseif sr == 3 then
if dy > 0 and data[ivm] ~= node["loud_walking:control_floor_alert_down"] and x > 0 and z > 0 and x < 20 and z < 20 then
data[ivm] = node["loud_walking:control_floor_growth"]
local sr2 = math.random(20)
if sr2 == 1 then
data[ivm + a.ystride] = node["loud_walking:control_plant_1"]
elseif sr2 == 2 then
data[ivm + a.ystride] = node["loud_walking:control_plant_2"]
end
end
elseif sr == 4 then
if dy < 15 and (x > 0 and x < 20 and z > 0 and z < 20) and (((x == 1 or x == 19) and math_abs(z - 10) > 3) or ((z == 1 or z == 19) and math_abs(x - 10) > 3)) then
data[ivm + 3 * a.ystride] = node["loud_walking:controls"]
end
end
ivm = ivm + 1
end
end
end
end
end
end
local t4 = os.clock()
vm:set_data(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment