freeslot("sfx_chbrn")
enemyList["geoloa"] = { -- This is for the Dungeon cause they don't like arena map changes
		name = "Loa Erebonius",
		skillchance = 95,	
		level = 100,
		hp = 14000,
		sp = 9999,
		strength = 85,
		magic = 85,
		endurance = 70,
		luck = 70,
		agility = 72,
		melee_natk = "clawstrike",	
		thinker = generalEnemyThinker,
		scale = FRACUNIT*2,
		boss = true,
		endboss = true,
		turns = 2,

		anim_stand = 		{SPR_LOAE, A, 4},				-- standing
		anim_stand_hurt =	{SPR_LOAE, A, 4},					-- standing (low HP) *
		anim_stand_bored =	{SPR_LOAE, A, 4},					-- standing (occasionally plays after anim_stand has played several times)
		anim_guard = 		{SPR_LOAE, A, 4},				-- guarding
		anim_move =			{SPR_LOAE, A, 4},	-- moving
		anim_run =			{SPR_LOAE, A, 4},	-- guess what
		anim_atk =			{SPR_LOAE, A, 4},			-- attacking
		anim_aoa_end =		{SPR_LOAE, A, 4},			-- jumping out of all-out attack
		anim_hurt =			{SPR_LOAE, A, 4},				-- taking damage
		anim_getdown =		{SPR_LOAE, A, 4},					-- knocked down from weakness / crit *
		anim_downloop =		{SPR_LOAE, A, 4},					-- is down
		anim_getup =		{SPR_LOAE, A, 4},			-- gets up from down
		anim_death =		{SPR_LOAE, A, 4},					-- dies
		anim_revive =		{SPR_LOAE, A, 4},			-- gets revived
		anim_evoker =		{SPR_LOAE, A, 4},
		anim_evoker_shoot = {SPR_LOAE, A, 4},
		
		vfx_crit = {"sfx_loacrt"},
		
		hudcutin = "LOAE_A",	-- cut in

		
		skills = {"loamusicthing", "garkuti", "blesatu", "kilati", "jukait", "fors", "clawstrike", "vel-da-doop", "vilna-ya", "ark-zok-onkeim", "volzello-anaia", "van-ku-oh", "innocence_arc", "death_scream_alt", "goldenhalo"}
}


enemyList["georeaper"] = {
		name = "Geo Reaper",
		skillchance = 100,	-- /100, probability of using a skill
		level = 100,
		hp = 10000,
		sp = 8888,
		strength = 85,
		magic = 85,
		endurance = 99,
		luck = 90,
		agility = 85,
		melee_natk = "strike_1",	-- enemies don't have crit anims for their attacks.
		thinker = generalEnemyThinker,
		boss = true,
		endboss = true,
		turns = 2,
		scale = FRACUNIT*3/2,

		r_exp = 75000,
		anim_stand = 		{SPR_REAP, A, B, C, D, E, F, G, H, I, J, 4},
		anim_stand_hurt = 	{SPR_REAP, A, B, C, D, E, F, G, H, I, J, 4},
		anim_move =			{SPR_REAP, A, B, C, D, E, F, G, H, I, J, 4},
		anim_run =			{SPR_REAP, A, B, C, D, E, F, G, H, I, J, 4},
		anim_hurt =			{SPR_REAP, A, 10},
		anim_getdown =		{SPR_REAP, A, 1},
		anim_downloop =		{SPR_REAP, A, 1},
		anim_getup =		{SPR_REAP, A, 1},		-- enemies don't need special standing, death or revive anims.
													-- they explode on death, and cannot be revived.
													-- unless it's specified like for players.
													
		hudcutin = "REAP_A",	-- cut in											
													
													
		skills = {"reapermusicthing", "megidolaon", "power charge", "mind charge", "megaton raid", "vicious strike", "heat riser",
					"orbal_down", "chrono_break", "phantom_pain", "lord_inferno", "cocytus",
					"aero_storm", "golden halo", "ragna_dorian", "zeruel_cannon", "lost_eden", "adamantine_guard", "a_reflex",
					"dekaja", "innocence_arc", "death_scream", "ragna_vortex", 
					"seventh caliber", "psycho force", "abyss_fall", "diamond_nova", "crimson_ray", "judgement_bolt", "void boost 7"},
}

local dng = {
	
	name = "Geofront Sector A",											-- The Dungeon's name
	description = "Explore the Geofront during the Dark Hour",	
	gensize = 5,															-- 1-6 sets how big the generation can get.
	floors = 20,															-- # of floors.
	level = 70,																-- Starting level
	levelcap = 99,															-- Max level
	
	weapon_addpow = 800,													-- power added to the stock equipped weapon (10:1)
	armour_adddef = 500,													-- defence added to the stock equipped wardring (10:1)
	
	dungeonmusic = "AOGEO",												-- Music to play inside the dungeon
	
	floortextures = "ERZBG4",												-- Prefix of the floor texture
	ceilingtexture = "ERZBG1",												-- Ceiling texture
	useautotile = false,													-- wether to change the floor texture based on surrounding tiles. leave to off to only use a single floor texture accross the entire floor
	startwalltexture = "ERZGREY3",											-- 1st wall texture
	texturerange = 0,														-- Texture range: How far from the startwalltexture can we randomize?
	brightness = 200,
	skynum = 9,
	maxep = 6,
	
	allowinterference = true,												-- Chooses to allow generation interference (dark floors, dread floors... etc)
	
	shufflelevel = 9,														-- Maximum shuffle time levels
	shufflepersonas = {
		"trumpeter",
		"lilith",
		"archangel",
		"raphael",
		"sati",
		"loki",
		"alice",
		"daisoujou",
		"anubis",
		"kinki",
		"quezacoatl",
		"belphegor",
		"siegfried",
		"matador",
		"hell biker",
		"byakko",
		"seiryuu",
		"mara",
		"zeit",
		"kea",
		"guy",
		"noel",
		"wazy",
		"renne",
		"earcus",
		
		},
		
		-- List of Sub-Personas.
	
	shop = "tiotrailsshop",												-- Name of the custom shop. Defaults to the regular Velvet Shop
	
	-- Item drop tables:
	itemdrops = {
		{"snuffsoul", 17},
		{"chewing soul", 10},
		{"silverring", 25},
		{"silvercombiring", 10},
		{"hypercombiring", 8},
		{"homunculus", 7},
		{"me patra gem", 10},
		{"megidola gem", 3},
		{"megidolaon gem", 2},
		{"agidyne gem", 5},
		{"bufudyne gem", 5},
		{"ziodyne gem", 5},
		{"garudyne gem", 5},
		{"psiodyne gem", 5},
		{"freidyne gem", 5},
		{"hell magatama", 2},
		{"cyclone magatama", 2},
		{"storm magatama", 2},
		{"frost magatama", 2},
		{"megidolaon gem", 2},
		{"blow bouncer", 9},
		{"magic mirror", 9},
		{"dekaja gem", 15},
		{"dekunda gem", 15},
		{"1up", 10},
		{"super1up", 5},
		{"chaos drive 2", 10},
		{"chaos drive 3", 7},
		{"hyperring", 10},
		{"diamond", 15},
		{"ruby", 13},
		{"painite", 9},
		{"tearalbalm", 10},
		{"spcharge", 16},
		{"spcharge2", 8},
		{"spcharge3", 8},
		{"revbalm", 8},
		{"celbalm", 4},
		{"zerpow", 2},
		{"antidote", 3},
		{"relaxant", 4},
		{"tape", 3},
		{"spray", 4},
		{"warmer", 3},
		{"eye", 3},
		{"mint", 3},
		{"salts", 3},
		{"curiabalm", 4},
		{"stablet", 7},
		{"recuriabalm", 4},
		{"battlescope", 7},
		
		
		{{"series", "novel"}, 12},
		{{"series", "v2-alter"}, 12},
		{{"series", "v2-vitalis"}, 9},
		{{"series", "v2-spirita"}, 9},
		{{"series", "awake"}, 8},
		{{"series", "obliance"}, 7},			
		{{"series", "freifi"}, 5},
		{{"series", "buhn"}, 1},
		{{"ring", "novel rings"}, 10},
		{{"ring", "vitalis rings"}, 5},
		{{"ring", "spirita rings"}, 5},
		{{"ring", "awake rings"}, 5},
		{{"ring", "freifi rings"}, 2},
	},
	
	-- Floor data table:
	floordata = {
		
		-- Floor 1
		[1] = {
			noreaper = nil,
			map = nil,	-- Nil map means that we let the game generate it randomly.
		},
		
		-- Floors 2, 3, and 4 will use the same data as floor 1's!
		
		-- Floor 5
		[7] = {
			map = BOSSFLOOR,
			noreaper = true,
			eventdir = 270,		-- Angle of the in-map enemy spawn
			spawndir = 90,		-- Player spawn angle
			shopdir = 0,		-- This is a boss floor.
		},

		-- Floor 6, go back to normal random floors!
		[8] = {
			noreaper = nil,
			map = nil,	-- Nil map means that we let the game generate it randomly.
		},

		[12] = {
			map = BOSSFLOOR,
			noreaper = true,
			eventdir = 270,		-- Angle of the in-map enemy spawn
			spawndir = 90,		-- Player spawn angle
			shopdir = 0,		-- This is a boss floor.
		},
		
		[13] = {
			map = BOSSFLOOR,
			noreaper = true,
			eventdir = 270,		-- Angle of the in-map enemy spawn
			spawndir = 90,		-- Player spawn angle
			shopdir = 0,		-- This is a boss floor.
		},
		
		
		[14] = {
			noreaper = nil,
			map = nil,	-- Nil map means that we let the game generate it randomly.
		},
		
		-- Floor 10, our final floor, go back to being a boss floor for our final boss
		[17] = {
			map = BOSSFLOOR,
			noreaper = true,
			eventdir = 270,
			spawndir = 90,
			shopdir = 0,		-- This is a boss floor.
		},
		
		[18] = {
			noreaper = nil,
			map = nil,	-- Nil map means that we let the game generate it randomly.
		},
		
		[20] = {
			map = BOSSFLOOR,
			noreaper = true,
			eventdir = 270,
			spawndir = 90,
			shopdir = 0,		-- This is a boss floor.
		},
		
	},
	
	-- Finally, our enemies.
	-- This is a small example, your tables can get a lot bigger than these but I want to keep simple and comprehensive!
	
	enemies = {
		
		-- Enemies from floor 1 onwards:
		[1] = {
			
			-- Enemy waves in floor 1
		{
			"idol_adamah",
			"nyogo_adamah",
			"idol_adamah",
		},

		{
			"giant_adamah",
			"turret_adamah",
			"turret_adamah",
			"twins_adamah",
		},

		{
			"balance_adamah",
			"giant_adamah",
			"balance_adamah",
		},

		{
			"gene_adamah",
			"knight_adamah",
			"gene_adamah",
		},

		{
			"castle_adamah",
			"turret_adamah",
			"turret_adamah",
			"castle_adamah",
		},

		{
			"minotaur_adamah",
			"dice_adamah",
			"minotaur_adamah",
		},

		{
			"dice_adamah",
			"dice_adamah",
			"nyogo_adamah",
			"dice_adamah",
			"dice_adamah",
		},

		{
			"giant_adamah",
			"giant_adamah",
			"giant_adamah",
		},

		{
			"snake_adamah",
			"phantom_adamah",
			"panzer_adamah",
			"phantom_adamah",
		},

		{
			"dice_adamah",
			"nyogo_adamah",
			"phantom_adamah",
			"dice_adamah",
		},

		{
			"sand_adamah",
			"beetle_adamah",
			"drive_adamah",
			"sand_adamah",
		},

		{
			"gene_adamah",
			"hand_adamah",
			"hand_adamah",
			"gene_adamah",
		},

		{
			"idol_adamah",
			"hand_adamah",
			"hand_adamah",
			"idol_adamah",
		},

		{
			"balance_adamah",
			"panzer_adamah",
			"balance_adamah",
		},
		
		{
			"pesce_adamah",
			"nyogo_adamah",
			"pesce_adamah",
		},

		{
			"gigas_adamah",
			"sand_adamah",
			"maya_adamah",
			"gigas_adamah",
		},

		{
			"idol_adamah",
			"idol_adamah",
			"minotaur_adamah",
			"idol_adamah",
		},

		{
			"idol_adamah",
			"hand_adamah",
			"maya_adamah",
			"idol_adamah",
		},

		{
			"minotaur_adamah",
			"minotaur_adamah",
		},

		{
			"snake_adamah",
			"panzer_adamah",
			"snake_adamah",
		},

		{
			"idol_adamah",
			"minotaur_adamah",
			"idol_adamah",
		},

		{
			"snake_adamah",
			"knight_adamah",
			"snake_adamah",
		},

		{
			"drive_adamah",
			"giant_adamah",
			"nyogo_adamah",
		},

		{
			"idol_adamah",
			"idol_adamah",
			"idol_adamah",
			"dice_adamah",
		},
		
			
		},
		
		
		-- Remember? We set floor 5 to be a boss floor above, so let's make the enemies that spawn here bosses!
		-- Mecha Sonichough the game never uses it, you can have multiple waves here to have different bosses spawn!
		
		[7] = {
						
			{	
			
			"eagle_boss1_adamah",
			"eagle_boss1_adamah",
			"eagle_boss1_adamah",
					
			},
			
		},
		
		-- And here, we're back to our normal encounters from floor 6 onwards. They can be different from the encounters we had in 1F.
		[8] = {
			
			-- Enemy waves in floor 1
				{
		"maya_monad",
		"mage_monad",
		"maya_monad",
	},
	
	{
		"maya_monad",
		"hablerie_monad",
		"maya_monad",
	},	
	
	{
		"sand_monad",
		"maya_monad",
		"sand_monad",
	},	

	{
		"eagle_monad",
		"musha_monad",
		"musha_monad",
	},
	
	{
		"maya_monad",
		"tower_monad",
		"maya_monad",
		"maya_monad",
	},	
	
	{
		"musha_monad",
		"giant_monad",
		"mage_monad",
		"mage_monad",
	},		

	{
		"knight_monad",
		"hablerie_monad",
		"knight_monad",
		"maya_monad",
	},
	
	{
		"sand_monad",
		"turret_monad",
		"sand_monad",
	},
	
	{
		"turret_monad",
		"giant_monad",
		"turret_monad",
	},
	
	{
		"turret_monad",
		"tower_monad",
		"turret_monad",
	},	

			
		},
		
	
	[12] = {
						
			{
			
			"knight_boss1_adamah",
			"knight_boss1_adamah",
			"knight_boss1_adamah",
			
			},
			
		},
		
	[13] = {
	
			{
			
			"drive_boss_monad"
			
			},
			
		},
		
		[14] = {
			
	{
		"maya_monad",
		"basalt_monad",
		"maya_monad",
	},

	{
		"maya_monad",
		"machine_monad",
		"maya_monad",
	},

	{
		"maya_monad",
		"okina_monad",
		"maya_monad",
		"turret_monad",
	},
	
	{
		"sand_monad",
		"okina_monad",
		"sand_monad",
		"gigas_monad",
	},	

	{
		"eagle_monad",
		"musha_monad",
		"musha_monad",
		"turret_monad",
	},
	
	{
		"maya_monad",
		"okina_monad",
		"maya_monad",
		"maya_monad",
		"gigas_monad",
	},	
	
	{
		"musha_monad",
		"giant_monad",
		"giant_monad",
		"mage_monad",
		"mage_monad",
	},		

	{
		"knight_monad",
		"giant_monad",
		"knight_monad",
		"maya_monad",
	},
	
	{
		"sand_monad",
		"turret_monad",
		"sand_monad",
		"gigas_monad",
	},
	
	{
		"turret_monad",
		"giant_monad",
		"turret_monad",
		"giant_monad",
	},
	
	{
		"turret_monad",
		"tower_monad",
		"turret_monad",
		"gigas_monad",
		
		
	},				
	
		},	
		
		[17] = {
			
			{
				"maya_boss_monad",	
			},
			
		},
		
		[18] = {
			
	{
		"maya_monad",
		"basalt_monad",
		"maya_monad",
	},

	{
		"maya_monad",
		"machine_monad",
		"maya_monad",
	},

	{
		"maya_monad",
		"okina_monad",
		"maya_monad",
		"turret_monad",
	},
	
	{
		"sand_monad",
		"okina_monad",
		"sand_monad",
		"gigas_monad",
	},	

	{
		"eagle_monad",
		"musha_monad",
		"musha_monad",
		"turret_monad",
	},
	
	{
		"maya_monad",
		"okina_monad",
		"maya_monad",
		"maya_monad",
		"gigas_monad",
	},	
	
	{
		"musha_monad",
		"giant_monad",
		"giant_monad",
		"mage_monad",
		"mage_monad",
	},		

	{
		"knight_monad",
		"giant_monad",
		"knight_monad",
		"maya_monad",
	},
	
	{
		"sand_monad",
		"turret_monad",
		"sand_monad",
		"gigas_monad",
	},
	
	{
		"turret_monad",
		"giant_monad",
		"turret_monad",
		"giant_monad",
	},
	
	{
		"turret_monad",
		"tower_monad",
		"turret_monad",
		"gigas_monad",
		
		
	},	
		
		},	
		
		[20] = {
			
			{
				"georeaper",	-- The rampage drive has an "endboss" field.
			},
			
			{
				"geoloa",	-- Different version of the Vision Quest Loa
			},
			
			
		},
		
	},
}

P_registerCustomDungeon(dng)

attackDefs["ragna_dorian"] = {
		name = "Ragna Dorian",
		type = ATK_ELEC,
		power = 350,
		accuracy = 90,
		costtype = CST_SP,
		status = COND_SHOCK,
		statuschance = 2,
		cost = 24,
		desc = "Orbal Art.\nHeavy Elec Damage to all enemies.\nMay Shock",
		target = TGT_ALLENEMIES,
		anim = function(mo, targets, hittargets, timer)
			for i = 1, #hittargets
				local target = hittargets[i]
				if timer == 20 + 10*(i-1)
					playSound(mo.battlen, sfx_elthr)
					lightningblast(target, SKINCOLOR_GREEN, FRACUNIT*3/2)
					localquake(mo.battlen, FRACUNIT*8, 8)
					damageObject(target)
				end
			end
			if timer == 60 + (10*(#hittargets-1))
				return true
			end
		end,
}

attackDefs["lost_eden"] = {
		name = "Lost Eden",
		type = ATK_PSY,
		power = 350,
		accuracy = 90,
		costtype = CST_SP,
		statuschance = 10,
		status = COND_BRAINWASH,
		cost = 30,
		desc = "Lost Art.\nHeavy Psi Damage to all enemies.\nMay Brainwash",
		target = TGT_ALLENEMIES,
		
		hudfunc = 	function(v, mo, timer)
						
						if timer > 130
						and timer < 200
							local t = timer-130
							local p = "H_ATR"..t/2
							if v.patchExists(p)
								drawScreenwidePatch(v, v.cachePatch(p))
							end
						end
					end,
		
		anim =		function(mo, targets, hittargets, timer)

							local avgx, avgy = 0, 0
							for i = 1, #hittargets
								avgx = $ + hittargets[i].x/FRACUNIT
								avgy = $ + hittargets[i].y/FRACUNIT
							end
							avgx = ($/#hittargets)*FRACUNIT
							avgy = ($/#hittargets)*FRACUNIT
							
							if timer == 1
								playSound(mo.battlen, sfx_darmat)
							end
								

							if timer == 1
								mo.megido = {}
								mo.megiz = mo.z

							elseif timer >= 20 and timer < 60

								mo.megiz = $+ FRACUNIT*16
								local m = P_SpawnMobj(avgx + P_RandomRange(-512, 512)*FRACUNIT, avgy + P_RandomRange(-512, 512)*FRACUNIT, mo.megiz, MT_DUMMY)
								m.state = S_MEGISTAR1

								
								if timer == 45
									local m = P_SpawnMobj(avgx, avgy, mo.floorz, MT_DUMMY)
									m.state = S_MEGISTAR1
									m.state = $*2
									playSound(mo.battlen, sfx_hamas2)
								end

							elseif timer >= 60 and timer <= 150
								if timer == 60
									mo.megido2 = {}
									mo.megisphere = P_SpawnMobj(avgx, avgy, mo.floorz, MT_DUMMY)
									mo.megisphere.sprite = SPR_NTHK
									mo.megisphere.frame = D|FF_FULLBRIGHT
									mo.megisphere.tics = 150-60
									mo.megisphere.fuse = 150-60
									mo.megisphere.scale = $/64
									mo.megisphere.destscale = FRACUNIT*24
									mo.megisphere.scalespeed = $*2
									mo.megisphere.color = SKINCOLOR_NEON
									
									local ang = R_PointToAngle(mo.megisphere.x, mo.megisphere.y)
									P_InstaThrust(mo.megisphere, ang, -2*FRACUNIT)
								end

								local m
								-- column going up
								for i = 1, 2
									m = P_SpawnMobj(avgx + P_RandomRange(-64, 64)*FRACUNIT, avgy + P_RandomRange(-64, 64)*FRACUNIT, mo.z, MT_DUMMY)
									m.tics = -1
									m.color = SKINCOLOR_MAGENTA
									m.frame = FF_FULLBRIGHT
									m.scale = FRACUNIT*2
									m.momz = FRACUNIT*64
									m.fuse = TICRATE
								end

								local an = leveltime*ANG1*2
									if leveltime%2
									for i = 1, 3
										m = P_SpawnMobj(avgx, avgy, mo.z, MT_DUMMY)
										m.state = S_MEGITHOK
										m.scale = FRACUNIT*3/2
										m.fuse = TICRATE
										mo.megido2[#mo.megido2+1] = m
										m.extravalue = an + i*(360/8)*ANG1
										m.extravalue2 = 128 + (timer-130)*8
										m.momz = FRACUNIT*56
									end
								end


								m = P_SpawnMobj(avgx + P_RandomRange(-512, 512)*FRACUNIT, avgy + P_RandomRange(-512, 512)*FRACUNIT, mo.z + P_RandomRange(0, 512)*FRACUNIT, MT_DUMMY)
								m.state = S_MEGISTAR1
								m.scale = FRACUNIT*2


								if timer == 140
									for k,v in ipairs(hittargets)
										damageObject(v)
										playSound(mo.battlen, sfx_chbrn)
									end
								end

							end

							local i
							if mo.megido2
								i = #mo.megido2

								while i
									local h = mo.megido2[i]
									if not h or not h.valid
										table.remove(mo.megido2, i)
										i = $-1
										continue
									end

									P_TeleportMove(h, avgx + h.extravalue2*cos(h.extravalue), avgy + h.extravalue2*sin(h.extravalue), h.z)
									h.extravalue = $+ ANG1*64
									h.extravalue2 = $+8

									i = $-1

								end
							end

							if timer == 200
								return true
							end

					end,

	}


attackDefs["reapermusicthing"] = {
        name = "Reaper Music Thing",
        type = ATK_PASSIVE,
        norandom = true,
        desc = "Changes the music",
        passive = PSV_STARTBATTLE,
        anim = function(mo, targets, hittargets, timer)
            server.geobosstimer = 58
            server.fuckingmusic_a = true
        end,
    }
	
attackDefs["loamusicthing"] = {
        name = "Loa Music Thing",
        type = ATK_PASSIVE,
        norandom = true,
        desc = "Changes the music",
        passive = PSV_STARTBATTLE,
        anim = function(mo, targets, hittargets, timer)
            server.geobosstimer = 58
            server.shitmusic_b = true
        end,
    }
    		
local function GeoBossThinker(mo)
    if server and server.valid
        
        if server.geobosstimer == nil then server.geobosstimer = 0 end
        
        if server.geobosstimer > 0 then 
            server.geobosstimer = $1-1 
        end
        
        if server.geobosstimer == 2  
            if server.fuckingmusic_a
                S_ChangeMusic("FORENY",true)
			elseif server.shitmusic_b
				S_ChangeMusic("GREPWR",true)
            end
        elseif server.geobosstimer == 1
            server.fuckingmusic_a = false
			server.shitmusic_b = false
        end
    end
end

addHook("ThinkFrame", GeoBossThinker)