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

working .. working .. the imp is slavering for your pleasure

git-svn-id: http://svn.net-core.org/repos/t-engine4@6647 51575b47-30f0-44d4-a5cc-537603b46e54
parent 59cd4360
No related branches found
No related tags found
No related merge requests found
......@@ -795,6 +795,15 @@ function _M:newLevel(level_data, lev, old_lev, game)
level.default_down = {x=dx, y=dy}
level.spots = spots
-- Call a map finisher
if level_data.post_process_map then
level_data.post_process_map(level, self)
if level.force_recreate then
level:removed()
return self:newLevel(level_data, lev, old_lev, game)
end
end
-- Add the entities we are told to
for i = 0, map.w - 1 do for j = 0, map.h - 1 do
if map.room_map[i] and map.room_map[i][j] and map.room_map[i][j].add_entities then
......
......@@ -1178,32 +1178,10 @@ end
--- Quake a zone
-- Moves randomly each grid to an other grid
function _M:doQuake(tg, x, y)
local w = game.level.map.w
local locs = {}
local ms = {}
self:project(tg, x, y, function(tx, ty)
if not game.level.map.attrs(tx, ty, "no_teleport") and not game.level.map:checkAllEntities(tx, ty, "change_level") and game.level.map(tx, ty, Map.TERRAIN) and (game.level.map(tx, ty, Map.TERRAIN).dig or game.level.map(tx, ty, Map.TERRAIN).grow) then
locs[#locs+1] = {x=tx,y=ty}
ms[#ms+1] = {map=game.level.map.map[tx + ty * w], attrs=game.level.map.attrs[tx + ty * w]}
end
local typ = require("engine.Target"):getType(tg)
return game.zone:doQuake(typ.ball or 1, x, y, function(tx, ty)
return not game.level.map.attrs(tx, ty, "no_teleport") and not game.level.map:checkAllEntities(tx, ty, "change_level") and game.level.map(tx, ty, Map.TERRAIN) and (game.level.map(tx, ty, Map.TERRAIN).dig or game.level.map(tx, ty, Map.TERRAIN).grow)
end)
while #locs > 0 do
local l = rng.tableRemove(locs)
local m = rng.tableRemove(ms)
game.level.map.map[l.x + l.y * w] = m.map
game.level.map.attrs[l.x + l.y * w] = m.attrs
for z, e in pairs(m.map or {}) do
if e.move then
e.x = nil e.y = nil e:move(l.x, l.y, true)
end
game.nicer_tiles:updateAround(game.level, l.x, l.y)
end
end
game.level.map:cleanFOV()
game.level.map.changed = true
game.level.map:redisplay()
end
--- Reveals location surrounding the actor
......
......@@ -19,6 +19,7 @@
require "engine.class"
local Zone = require "engine.Zone"
local Map = require "engine.Map"
module(..., package.seeall, class.inherit(Zone))
......@@ -31,3 +32,45 @@ function _M:onLoadZoneFile(basedir)
self.events = f()
end
end
--- Quake a zone
-- Moves randomly each grid to an other grid
function _M:doQuake(rad, x, y, check)
local w = game.level.map.w
local locs = {}
local ms = {}
core.fov.calc_circle(x, y, game.level.map.w, game.level.map.h, rad,
function(_, lx, ly) if not game.level.map:isBound(lx, ly) then return true end end,
function(_, tx, ty)
if check(tx, ty) then
locs[#locs+1] = {x=tx,y=ty}
ms[#ms+1] = {map=game.level.map.map[tx + ty * w], attrs=game.level.map.attrs[tx + ty * w]}
end
end,
nil)
local savelocs = table.clone(locs)
while #locs > 0 do
local l = rng.tableRemove(locs)
local m = rng.tableRemove(ms)
game.level.map.map[l.x + l.y * w] = m.map
game.level.map.attrs[l.x + l.y * w] = m.attrs
for z, e in pairs(m.map or {}) do
if e.move then
e.x = nil e.y = nil e:move(l.x, l.y, true)
end
end
end
locs = savelocs
while #locs > 0 do
local l = rng.tableRemove(locs)
game.nicer_tiles:updateAround(game.level, l.x, l.y)
end
game.level.map:cleanFOV()
game.level.map.changed = true
game.level.map:redisplay()
end
......@@ -17,6 +17,91 @@
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
local layout = game.state:alternateZone(short_name, {"COLLAPSED", 2})
layout = "COLLAPSED"
if layout == "COLLAPSED" then
return {
name = "The Maze",
level_range = {7, 16},
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 = 40, height = 40,
-- all_remembered = true,
-- all_lited = true,
persistent = "zone",
ambient_music = {"The Ancients.ogg","weather/dungeon_base.ogg"},
min_material_level = function() return game.state:isAdvanced() and 2 or 1 end,
max_material_level = function() return game.state:isAdvanced() and 4 or 3 end,
generator = {
map = {
class = "engine.generator.map.Maze",
up = "UP",
down = "DOWN",
wall = "OLD_WALL",
floor = "OLD_FLOOR",
widen_w = 2, widen_h = 2,
},
actor = {
class = "mod.class.generator.actor.Random",
nb_npc = {50, 60},
guardian = "MINOTAUR_MAZE",
guardian_alert = true,
},
object = {
class = "engine.generator.object.Random",
nb_object = {10, 14},
},
trap = {
class = "engine.generator.trap.Random",
nb_trap = {0, 0},
},
},
levels =
{
[1] = {
generator = { map = {
up = "UP_WILDERNESS",
}, },
},
},
post_process_map = function(level, zone)
for i = 1, 5 do
local x = rng.range(6, level.map.w - 7)
local y = rng.range(6, level.map.w - 7)
game.zone:doQuake(rng.range(4, 6), x, y, function(tx, ty)
return not level.map.attrs(tx, ty, "no_teleport") and not level.map:checkAllEntities(tx, ty, "change_level") and level.map(tx, ty, engine.Map.TERRAIN)
end)
end
end,
post_process = function(level)
-- Place a lore note on each level
game:placeRandomLoreObject("NOTE"..level.level)
local p = game.party:findMember{main=true}
if level.level == 1 and p:knowTalent(p.T_TRAP_MASTERY) then
local l = game.zone:makeEntityByName(level, "object", "NOTE_LEARN_TRAP")
if not l then return end
for _, coord in pairs(util.adjacentCoords(level.default_down.x, level.default_down.y)) do
if game.level.map:isBound(coord[1], coord[2]) and (i ~= 0 or j ~= 0) and not game.level.map:checkEntity(coord[1], coord[2], engine.Map.TERRAIN, "block_move") then
game.zone:addEntity(level, l, "object", coord[1], coord[2])
return
end
end
end
game.state:makeAmbientSounds(level, {
dungeon2={ chance=250, volume_mod=1, pitch=1, random_pos={rad=10}, files={"ambient/dungeon/dungeon1","ambient/dungeon/dungeon2","ambient/dungeon/dungeon3","ambient/dungeon/dungeon4","ambient/dungeon/dungeon5"}},
})
end,
}
elseif layout == "DEFAULT" then
return {
name = "The Maze",
level_range = {7, 16},
......@@ -94,3 +179,5 @@ return {
})
end,
}
end
\ No newline at end of file
......@@ -18,7 +18,6 @@
-- darkgod@te4.org
local layout = game.state:alternateZone(short_name, {"CRYSTALINE", 2})
layout = "CRYSTALINE"
local is_crystaline = layout == "CRYSTALINE"
return {
......
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