From 58d8e1b62916fab5fc2ec89a5858c9009a205398 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Fri, 26 Apr 2013 19:33:10 +0000
Subject: [PATCH] Sometimes the scintillating caves hold too much magic which
 distort them into weird angles

git-svn-id: http://svn.net-core.org/repos/t-engine4@6654 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Game.lua              |  2 +-
 .../data/zones/scintillating-caves/zone.lua   | 86 +++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 7788c1a19b..5e118f69ec 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -1974,7 +1974,7 @@ function _M:placeRandomLoreObjectScale(base, nb, level)
 end
 
 --- Create a random lore object and place it
-function _M:placeRandomLoreObject(define, zone)
+function _M:placeRandomLoreObject(define)
 	if type(define) == "table" then define = rng.table(define) end
 	local o = self.zone:makeEntityByName(self.level, "object", define)
 	if not o then return end
diff --git a/game/modules/tome/data/zones/scintillating-caves/zone.lua b/game/modules/tome/data/zones/scintillating-caves/zone.lua
index 9cb285f34e..92e68a6a4a 100644
--- a/game/modules/tome/data/zones/scintillating-caves/zone.lua
+++ b/game/modules/tome/data/zones/scintillating-caves/zone.lua
@@ -17,6 +17,90 @@
 -- Nicolas Casalini "DarkGod"
 -- darkgod@te4.org
 
+local layout = game.state:alternateZone(short_name, {"TWISTED", 2})
+if layout == "TWISTED" then
+
+return {
+	name = "Scintillating Caves",
+	level_range = {1, 5},
+	level_scheme = "player",
+	max_level = 5,
+	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 = 30, height = 30,
+--	all_remembered = true,
+	tier1 = true,
+	tier1_escort = 2,
+	all_lited = true,
+	persistent = "zone",
+	ambient_music = "Mystery.ogg",
+	max_material_level = 2,
+	generator =  {
+		map = {
+			class = "engine.generator.map.Roomer",
+			nb_rooms = 5,
+			rooms = {"random_room", {"money_vault",5}},
+			lite_room_chance = 20,
+			['.'] = "CRYSTAL_FLOOR",
+			['#'] = {"CRYSTAL_WALL","CRYSTAL_WALL2","CRYSTAL_WALL3","CRYSTAL_WALL4","CRYSTAL_WALL5","CRYSTAL_WALL6","CRYSTAL_WALL7","CRYSTAL_WALL8","CRYSTAL_WALL9","CRYSTAL_WALL10","CRYSTAL_WALL11","CRYSTAL_WALL12","CRYSTAL_WALL13","CRYSTAL_WALL14","CRYSTAL_WALL15","CRYSTAL_WALL16","CRYSTAL_WALL17","CRYSTAL_WALL18","CRYSTAL_WALL19","CRYSTAL_WALL20",},
+			up = "CRYSTAL_LADDER_UP",
+			down = "CRYSTAL_LADDER_DOWN",
+			door = "CRYSTAL_FLOOR",
+		},
+		actor = {
+			class = "mod.class.generator.actor.Random",
+			nb_npc = {12, 16},
+			filters = { {max_ood=2}, },
+			guardian = "SPELLBLAZE_CRYSTAL",
+		},
+		object = {
+			class = "engine.generator.object.Random",
+			nb_object = {6, 9},
+		},
+		trap = {
+			class = "engine.generator.trap.Random",
+			nb_trap = {0, 0},
+		},
+	},
+	levels =
+	{
+		[1] = {
+			generator = { map = {
+				up = "CRYSTAL_LADDER_UP_WILDERNESS",
+			}, },
+		},
+	},
+
+	post_process = function(level)
+		-- Place a lore note on each level
+		game:placeRandomLoreObject("NOTE")
+	end,
+
+	foreground = function(level, dx, dx, nb_keyframes)
+		local tick = core.game.getTime()
+		local sr, sg, sb
+		sr = 4 + math.sin(tick / 2000) / 2
+		sg = 3 + math.sin(tick / 2700)
+		sb = 3 + math.sin(tick / 3200)
+		local max = math.max(sr, sg, sb)
+		sr = sr / max
+		sg = sg / max
+		sb = sb / max
+
+		level.map:setShown(sr, sg, sb, 1)
+		level.map:setObscure(sr * 0.6, sg * 0.6, sb * 0.6, 1)
+	end,
+
+	on_enter = function(lev)
+		if lev == 1 and not game.level.data.warned then
+			game.level.data.warned = true
+			require("engine.ui.Dialog"):simplePopup("Caves...", "As you enter the caves you notice the magic here has distorted the land, making sharp angles and turns.")
+		end
+	end,
+}
+
+else
+
 return {
 	name = "Scintillating Caves",
 	level_range = {1, 5},
@@ -87,3 +171,5 @@ return {
 		level.map:setObscure(sr * 0.6, sg * 0.6, sb * 0.6, 1)
 	end,
 }
+
+end
\ No newline at end of file
-- 
GitLab