From ac867f56c09859431f7e7c58c838ea9dcba2e388 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 12 Feb 2019 23:04:24 +0100 Subject: [PATCH] Cleaner implementation of corridor start from dirt --- init.lua | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/init.lua b/init.lua index 445ac33..4d18333 100644 --- a/init.lua +++ b/init.lua @@ -518,7 +518,7 @@ end -- Returns , -- success: true if corridor could be placed entirely -- segments: Number of segments successfully placed -local function corridor_part(start_point, segment_vector, segment_count, wood, post, first_or_final, up_or_down_prev, first_support) +local function corridor_part(start_point, segment_vector, segment_count, wood, post, first_or_final, up_or_down_prev) local p = {x=start_point.x, y=start_point.y, z=start_point.z} local torches = pr:next() < probability_torches_in_segment local dir = {0, 0} @@ -531,9 +531,6 @@ local function corridor_part(start_point, segment_vector, segment_count, wood, p dir = {0, 1} torchdir = {3, 2} end - if first_support == nil then - first_support = false - end for segmentindex = 0, segment_count-1 do local dug if segment_vector.y == 0 then @@ -541,15 +538,6 @@ local function corridor_part(start_point, segment_vector, segment_count, wood, p else dug = Cube(p, 1, {name="air"}, false) end - if first_support then - WoodSupport(p, wood, post, torches, dir, torchdir) - if IsRailSurface({x=p.x,y=p.y-2,z=p.z}) then - PlaceRail({x=p.x,y=p.y-1,z=p.z}, damage) - else - PlaceRail({x=p.x,y=p.y-2,z=p.z}, damage) - end - first_support = false - end if not chaos_mode and segmentindex > 0 and not dug then return false, segmentindex end -- Add wooden platform, if neccessary. To avoid floating rails if segment_vector.y == 0 then @@ -587,7 +575,7 @@ local function corridor_part(start_point, segment_vector, segment_count, wood, p return true, segment_count end -local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next, up_or_down_prev, up, wood, post, first_or_final, damage, no_spawner, first_support) +local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next, up_or_down_prev, up, wood, post, first_or_final, damage, no_spawner) local segamount = 3 if up_or_down then segamount = 1 @@ -619,7 +607,7 @@ local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next, if up_or_down and up == false then Cube(waypoint, 1, {name="air"}, false) end - local corridor_dug, corridor_segments_dug = corridor_part(start, vek, segcount, wood, post, first_or_final, up_or_down_prev, first_support) + local corridor_dug, corridor_segments_dug = corridor_part(start, vek, segcount, wood, post, first_or_final, up_or_down_prev) local corridor_vek = {x=vek.x*segcount, y=vek.y*segcount, z=vek.z*segcount} -- nachträglich Schienen legen @@ -807,7 +795,7 @@ local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next, end end -local function start_corridor(waypoint, coord, sign, length, psra, wood, post, damage, no_spawner, first_support) +local function start_corridor(waypoint, coord, sign, length, psra, wood, post, damage, no_spawner) local wp = waypoint local c = coord local s = sign @@ -851,8 +839,7 @@ local function start_corridor(waypoint, coord, sign, length, psra, wood, post, d elseif i == 1 then first_or_final = "first" end - wp, no_spawner = corridor_func(wp,c,s, ud, udn, udp, up, wood, post, first_or_final, damage, no_spawner, first_support) - first_support = false + wp, no_spawner = corridor_func(wp,c,s, ud, udn, udp, up, wood, post, first_or_final, damage, no_spawner) if wp == false then return end -- Verzweigung? -- Fork? @@ -959,7 +946,12 @@ local function place_corridors(main_cave_coords, psra) if corridors <= 4 and pr:next(1, 20) >= 11 then centered_crossing = true end - local from_center_base = size + pr:next(-1,1) + -- This moves the start of the corridors in the dirt room back and forth + local d_max = 3 + if floor_diff == 1 and height <= 4 then + d_max = d_max + 1 + end + local from_center_base = size - pr:next(1,d_max) for i=1, math.min(4, corridors) do local d = pr:next(1, #dirs) local dir = dirs[d] @@ -975,21 +967,19 @@ local function place_corridors(main_cave_coords, psra) end end local from_center = from_center_base - if not centered_crossing then - if dir.sign then - from_center = -from_center - end + if dir.sign then + from_center = -from_center end if i == 1 then first_corridor = {sign=dir.sign, axis=dir.axis, axis2=dir.axis2, side_offset=side_offset, from_center=from_center} end local coords = vector.add(main_cave_coords, {[dir.axis] = from_center, y=0, [dir.axis2] = side_offset}) - start_corridor(coords, dir.axis, dir.sign, pr:next(way_min,way_max), psra, wood, post, damage, false, true) + start_corridor(coords, dir.axis, dir.sign, pr:next(way_min,way_max), psra, wood, post, damage, false) table.remove(dirs, d) end if corridors == 5 then local special_coords = vector.add(main_cave_coords, {[first_corridor.axis2] = -first_corridor.side_offset, y=0, [first_corridor.axis] = first_corridor.from_center}) - start_corridor(special_coords, first_corridor.axis, first_corridor.sign, pr:next(way_min,way_max), psra, wood, post, damage, false, true) + start_corridor(special_coords, first_corridor.axis, first_corridor.sign, pr:next(way_min,way_max), psra, wood, post, damage, false) end end