Skip to content
Snippets Groups Projects
Commit 518eb044 authored by dg's avatar dg
Browse files

Level generator now ensures connectivity from entrance to exit and to level guardian usnig A*

Trollshaws switch to "Forest" generator, using fBm noise


git-svn-id: http://svn.net-core.org/repos/t-engine4@669 51575b47-30f0-44d4-a5cc-537603b46e54
parent 4ede8943
No related branches found
No related tags found
No related merge requests found
......@@ -485,8 +485,8 @@ function _M:newLevel(level_data, lev, old_lev, game)
-- Check for connectivity from entrance to exit
local a = Astar.new(map, game:getPlayer())
if ux and uy and dx and dy and not a:calc(ux, uy, dx, dy) then
print("Level unconnected, no way from entrance to exit")
if ux and uy and dx and dy and (ux ~= dx or uy ~= dy) and not a:calc(ux, uy, dx, dy) then
print("Level unconnected, no way from entrance to exit", ux, uy, "to", dx, dy)
level:removed()
return self:newLevel(level_data, lev, old_lev, game)
end
......@@ -499,7 +499,7 @@ function _M:newLevel(level_data, lev, old_lev, game)
else cx, cy = spot.check_connectivity.x, spot.check_connectivity.y
end
if not a:calc(spot.x, spot.y, cx, cy) then
if spot.x and spot.y and cx and cy and (spot.x ~= cx or spot.y ~= cy) and not a:calc(spot.x, spot.y, cx, cy) then
print("Level unconnected, no way from", spot.x, spot.y, "to", cx, cy)
level:removed()
return self:newLevel(level_data, lev, old_lev, game)
......
......@@ -18,19 +18,19 @@
-- darkgod@te4.org
return {
name = "Mines of Moria",
level_range = {20, 30},
name = "TestZone!",
level_range = {1, 1},
level_scheme = "player",
max_level = 4,
decay = {300, 800},
actor_adjust_level = function(zone, level, e) return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) end,
width = 50, height = 50,
-- all_remembered = true,
all_remembered = true,
all_lited = true,
-- persistant = "zone",
generator = {
map = {
class = "engine.generator.map.Forest",
class = "engine.generator.map.GOL",
edge_entrances = {4,6},
floor = "GRASS",
wall = "TREE",
......
......@@ -35,7 +35,7 @@ return {
edge_entrances = {4,6},
zoom = 5,
noise = "fbm_perlin",
floor = function() if rng.chance(20) then return "FLOWER" else return "GRASS" end end,,
floor = function() if rng.chance(20) then return "FLOWER" else return "GRASS" end end,
wall = "TREE",
up = "UP",
down = "DOWN",
......
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