-- Persona Support --
if not srb2p return end

-- Stats
charStats["pember"] = {
	name = "Ember",
	basehp = 70,
	basesp = 36,
	persona = "elementress",
	melee_natk = "ember_atk1",
	supercolor_start = SKINCOLOR_SUPERORANGE1,
	atk = 50,
	acc = 90,
	crit = 9,
	wep = "stinger_01",
	weptype = WPT_GENERICRANGED,
	anim_stand = {SPR_PLAY, A, 8, "SPR2_STND"},
	anim_stand_hurt = {SPR_PLAY, A, 1, "SPR2_STND"},
	anim_stand_bored = {SPR_PLAY, A, B, A, B, A, B, A, B, 10, "SPR2_WAIT"},
	anim_guard = {SPR_PLAY, A, 1, "SPR2_WALK"},
	anim_move = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_WALK"},
	anim_run = {SPR_PLAY, A, B, 2, "SPR2_RUN_"},
	anim_atk = {SPR_PLAY, A, B, C, 1, "SPR2_ROLL"},
	anim_aoa_end = {SPR_PLAY, C, B, A, 1, "SPR2_ROLL"},
	anim_hurt = {SPR_PLAY, A, 35, "SPR2_PAIN"},
	anim_getdown = {SPR_PLAY, A, 1, "SPR2_PAIN"},
	anim_downloop = {SPR_PLAY, A, 1, "SPR2_PAIN"},
	anim_getup = {SPR_PLAY, A, B, C, 1, "SPR2_ROLL"},
	anim_death = {SPR_PLAY, A, 30, "SPR2_PAIN"},
	anim_revive = {SPR_PLAY, A, B, C, 1, "SPR2_ROLL"},
	anim_evoker = {SPR_PLAY, I, 8, "SPR2_FIRE"},
	anim_evoker_shoot = {SPR_PLAY, I, 8, "SPR2_FIRE"},
	anim_special1 = {SPR_PLAY, I, 1, "SPR2_FIRE"},
	anim_special2 = {SPR_PLAY, A, B, C, D, E, F, G, H, I, 2, "SPR2_FIRE"},
	vfx_summon = {"sfx_emsum1", "sfx_emsum2"},
    vfx_skill = {"sfx_emskl1", "sfx_emskl2"},
    vfx_item = {"sfx_emitm1", "sfx_emitm2"},
    vfx_hurt = {"sfx_emhrt1", "sfx_emhrt2"},
    vfx_hurtx = {"sfx_emxht1", "sfx_emxht2"},
    vfx_die = {"sfx_embdie"},
    vfx_heal = {"sfx_emhel2"},
    vfx_healself = {"sfx_emhel1"},
    vfx_kill = {"sfx_emkll1", "sfx_emkll2"},
    vfx_1more = {"sfx_em1mor"},
    vfx_crit = {"sfx_emcrt1", "sfx_emcrt2"},
    vfx_aoaask = {"sfx_emask1", "sfx_emask2"},
    vfx_aoado = {"sfx_emdo1", "sfx_emdo2"},
    vfx_aoarelent = {"sfx_embrlt"},
    vfx_miss = {"sfx_embmss"},
    vfx_dodge = {"sfx_embdod"},
    vfx_win = {"sfx_emwin1", "sfx_emwin2", "sfx_emwin3"},
    vfx_levelup = {"sfx_emlvlu"},
	icon = "ICO_EMBR",
	hudbust = "H_EMBBAR",
	hudaoa = "H_EMBAOA",
	aoa_quote = "Float like a butterfly, \nsting like a bee!",
	hudcutin = "EMBR_A",
	tip = "A strong Pierce attacker who's high Luck allows her to land criticals and instant kills often. Along with Attack and Crit Rate buffs, she also has HP drains to make her self-sustainable. Her SP is best kept for buffing, though."
}

-- Persona
personaList["elementress"] = {
	name = "Hive Elementress",
	arcana = ARCANA_PRIESTRESS,
	sprite = SPR_RSRB,
	startframe = 0,
	anim_idle = {SPR_RSRB, A, B, 8},
	anim_atk = {SPR_RSRB, A, A, C, C, D, E, D, E, D, E, D, 2},
	strength = 9,
	magic = 6,
	endurance = 7,
	luck = 11,
	agility = 7,
	weak = ATK_ELEC,
	resist = ATK_ICE|ATK_CURSE,
	skills = {
		{"skewer", 1}, {"bufu", 3},
		{"tarukaja", 5}, {"mudo", 10},
		{"double fang", 12}, {"bufula", 15},
		{"life drain", 19}, {"apt pupil", 23},
		
		{"cruel attack", 27, "skewer"}, {"rebellion", 30, "bufu"},
		{"matarukaja", 34, "tarukaja"}, {"mudoon", 38, "mudo"},
		{"torrent shot", 41, "double fang"}, {"bufudyne", 43, "bufula"},
		{"life leech", 46, "life drain"}, {"adverse resolve", 49, "apt pupil"},
		
		{"vile assault", 52, "cruel attack"}, {"revolution", 57, "rebellion"},
		{"triple down", 60, "torrent shot"}, {"life siphon", 65, "life leech"},
		{"brave step", 67, "revolution"}, {"one shot kill", 69, "vile assault"},
	},
}

-- Dungeon Ability (see LUA_FLY)

-- Normal Melee Attack
attackDefs["ember_atk1"] = {
	name = "Flame Stinger",
	type = ATK_PIERCE,
	power = 50,
	accuracy = 90,
	critical = 9,
	target = TGT_ENEMY,
	costtype = CST_HP,
	cost = 0,
	desc = "Shoot a fireball at the enemy!",
	physical = true,
	anim = function(mo, targets, hittargets, timer)
		local target = targets[1]
		local btl = server.P_BattleStatus[mo.battlen]
		local cam = btl.cam
		
		if timer == 1
			ANIM_set(mo, mo.anim_special1)
			mo.oldangle = mo.angle
			mo.angle = R_PointToAngle2(mo.x, mo.y, target.x, target.y)
			cam.angle = R_PointToAngle2(cam.x, cam.y, target.x, target.y)
		elseif timer == 5*TICRATE/8
			local cx = target.x + 168*cos(target.angle + ANG1*20)
			local cy = target.y + 168*sin(target.angle + ANG1*20)
			CAM_goto(server.P_BattleStatus[mo.battlen].cam, cx, cy, target.z + FRACUNIT*30, 70*FRACUNIT)
			CAM_angle(server.P_BattleStatus[mo.battlen].cam, R_PointToAngle2(cx, cy, target.x, target.y))
		end
		
		if timer == 1*TICRATE/2
			ANIM_set(mo, mo.anim_special2)
			playSound(mo.battlen, sfx_fire)
		end
		
		if timer == 3*TICRATE/4
			damageObject(hittargets[1])
			playSound(mo.battlen, sfx_fire1)
			P_StartQuake(FRACUNIT*7, 4)
			for i = 1, 2
				createSplat(mo)
			end
		end
		if timer == 3*TICRATE/2
			return true
		end
	end,
}

-- Custom Skills
attackDefs["apt pupil"] = {
	name = "Apt Pupil",
	type = ATK_PASSIVE,
	desc = "Start battles with \na Crit Rate buff.",
	passive = PSV_STARTBATTLE,
	anim = function(mo, targets, hittargets, timer)
			local target = hittargets[1]
			buffStat(target, "crit")
		end,
}

attackDefs["adverse resolve"] = {
	name = "Adverse Resolve",
	type = ATK_PASSIVE,
	target = TGT_ALLALLIES,
	desc = "Party starts battles \nwith a Crit Rate buff.",
	passive = PSV_STARTBATTLE,
	implicit = "fighting spirit",
	anim = function(mo, targets, hittargets, timer)
			for i = 1, #mo.allies do
				local target = mo.allies[i]
				buffStat(target, "crit")
			end
		end,
}

attackDefs["brave step"] = {
	name = "Brave Step",
	type = ATK_SUPPORT,
	costtype = CST_SP,
	cost = 16,
	desc = "Raise Party's Critical \nhit rate by 1 stage.",
	target = TGT_ALLALLIES,
	buff = true,
	anim = function(mo, targets, hittargets, timer)
		for i = 1, #targets do
			local target = targets[i]
			if timer == 20 + (i-1)*8
				playSound(mo.battlen, sfx_buff)
				playSound(mo.battlen, sfx_hamas1)
				buffStat(target, "crit")
				for i = 1,16
					local dust = P_SpawnMobj(target.x, target.y, target.z, MT_DUMMY)
					dust.angle = ANGLE_90 + ANG1* (22*(i-1))
					dust.state = S_CDUST1
					P_InstaThrust(dust, dust.angle, 30*FRACUNIT)
					dust.color = SKINCOLOR_YELLOW
					dust.scale = FRACUNIT*2
				end
			elseif timer > 20 + (i-1)*8 and timer <= 50 + (i-1)*8
				if leveltime%2 == 0
					for i = 1,16
						local thok = P_SpawnMobj(target.x+P_RandomRange(-70, 70)*FRACUNIT, target.y+P_RandomRange(-70, 70)*FRACUNIT, target.z+P_RandomRange(0, 50)*FRACUNIT, MT_DUMMY)
						thok.state = S_CDUST1
						thok.momz = P_RandomRange(3, 10)*FRACUNIT
						thok.color = SKINCOLOR_YELLOW
						thok.tics = P_RandomRange(10, 35)
						thok.scale = FRACUNIT*3/2
					end
				end
				for i = 1, 8
					local thok = P_SpawnMobj(target.x+P_RandomRange(-70, 70)*FRACUNIT, target.y+P_RandomRange(-70, 70)*FRACUNIT, target.z+P_RandomRange(0, 50)*FRACUNIT, MT_DUMMY)
					thok.sprite = SPR_SUMN
					thok.frame = F|FF_FULLBRIGHT|TR_TRANS50
					thok.momz = P_RandomRange(6, 16)*FRACUNIT
					thok.color = SKINCOLOR_YELLOW
					thok.tics = P_RandomRange(10, 35)
				end
			end
		end
		if timer == 60 + (#targets-1)*16
			return true
		end
	end,
}

-- NOTE: This one was provided by Wood Man via the SRB2P Discord.
attackDefs["one shot kill"] = {
	name = "One-Shot Kill",
	type = ATK_PIERCE,
	power = 740,
	accuracy = 90,
	costtype = CST_HPPERCENT,
	technical = COND_FREEZE,
	cost = 17,
	critical = 40,
	desc = "Severe Pierce damage to \none enemy. Very high \ncritical rate.",
	target = TGT_ENEMY,
	anim = function(mo, targets, hittargets, timer)
	
		local target = hittargets[1]
		
		if timer >= 18 and timer <= 70 and timer%2 == 0
			local shot = P_SpawnMobj(target.x, target.y, target.z+50*FRACUNIT, MT_THOK)
			shot.sprite = SPR_STAB
			shot.frame = A|FF_FULLBRIGHT|TR_TRANS50
			if timer%4 == 0 shot.color = SKINCOLOR_ORANGE else shot.color = SKINCOLOR_COPPER end
			shot.destscale = FRACUNIT*2
			shot.scalespeed = FRACUNIT/2
			playSound(mo.battlen,sfx_gun)
			local ang = R_PointToAngle(target.x, target.y) + ANG1*120

			for j = 1, 16

				local boom = P_SpawnMobj(target.x + P_RandomRange(-20,20)*FRACUNIT, target.y + P_RandomRange(-20,20)*FRACUNIT, target.z + 64*mo.scale + P_RandomRange(-20,20)*FRACUNIT, MT_DUMMY)
				boom.state = S_SSHOT1
				boom.color = SKINCOLOR_GOLD
				boom.angle = ang
				P_InstaThrust(boom, boom.angle, P_RandomRange(16, 64)*FRACUNIT)
				boom.momz = P_RandomRange(6, 16)*FRACUNIT
				boom.scale = FRACUNIT*3/2
				P_StartQuake(FRACUNIT*3,5)
			end
			
			if timer == 66
				damageObject(target)
				playSound(mo.battlen, sfx_megi6)
			end
		
		elseif timer == 100
			return true
		end
			
	end,
}

-- NOTE: These remaining skills are for the Ultra Elemental fight.
attackDefs["bumblebore swarm"] = {
	name = "Bumblebore Swarm",
	type = ATK_PIERCE,
	power = 2,
	hits = 25,
	accuracy = 80,
	critical = 1,
	costtype = CST_HPPERCENT,
	cost = 20,
	desc = "Sends a swarm of Bumblebores \nto hit the enemy x25.",
	target = TGT_ENEMY,
	anim = function(mo, targets, hittargets, timer)

			local t = hittargets[1]

			if timer == 20
				playSound(mo.battlen, sfx_thok)
				t.hits = 0
			end

			if timer >= TICRATE
			and timer <= TICRATE*5

				if timer%2
					local ang = P_RandomRange(0, 359)*ANG1
					local x = t.x + 256*cos(ang)
					local y = t.y + 256*sin(ang)

					local maso = P_SpawnMobj(x, y, t.z + P_RandomRange(32, 64)*FRACUNIT, MT_DUMMY)
					maso.sprite = SPR_BUMB
					maso.tics = -1
					maso.frame = A
					maso.momx = (t.x - maso.x)/4
					maso.momy = (t.y - maso.y)/4
					maso.momz = (t.z - maso.z)/4
				end

				if timer%10 == 0
					local shot = P_SpawnMobj(t.x + P_RandomRange(-256, 256)*FRACUNIT, t.y + P_RandomRange(-256, 256)*FRACUNIT, t.z + P_RandomRange(0, 128)*FRACUNIT, MT_DUMMY)
					shot.state = S_STAB_1_1
					shot.color = SKINCOLOR_ORANGE
					playSound(mo.battlen, sfx_hit)
				end
			end

			if timer >= TICRATE*3/2
			and t.hits < 25
			and timer%6 == 0
				damageObject(t)
				t.hits = $+1
			end

			if timer == TICRATE*6
				--print(t.hits)
				t.hits = 0
				return true
			end

		end,
}

attackDefs["quake_elemental"] = {
	name = "Quake",
	type = ATK_ALMIGHTY,
	power = 500,
	accuracy = 92,
	costtype = CST_HPPERCENT,
	cost = 22,
	critical = 30,
	desc = "Heavy Almighty damage to \nall enemies.\nMedium critical rate.",
	target = TGT_ALLENEMIES,
	anim = function(mo, targets, hittargets, timer)

		if timer == TICRATE/2
		or timer == TICRATE/2 + 8

			if timer == TICRATE/2
				playSound(mo.battlen, sfx_fire2)
				localquake(mo.battlen, 120*FRACUNIT, 20)
			end
			local ang = 0
			for i = 1, 24 do

				local f = P_SpawnMobj(mo.x, mo.y, mo.z, MT_DUMMY)
				f.state = S_FLAME
				f.scale = FRACUNIT/2
				f.fuse = TICRATE
				f.destscale = FRACUNIT*4
				f.friction = FRACUNIT
				f.angle = ang
				P_InstaThrust(f, f.angle, 50*FRACUNIT)

				f = P_SpawnMobj(mo.x, mo.y, mo.z, MT_DUMMY)
				f.state = S_QUICKBOOM1
				f.scale = FRACUNIT
				f.fuse = TICRATE
				f.friction = FRACUNIT
				f.destscale = FRACUNIT*4
				f.angle = ang
				f.color = SKINCOLOR_RED
				P_InstaThrust(f, f.angle, 60*FRACUNIT)

				for i = 1, 8
					f = P_SpawnMobj(mo.x, mo.y, mo.z, MT_DUMMY)
					f.state = S_SPINFIRE1
					f.fuse = TICRATE
					f.friction = FRACUNIT
					f.scale = FRACUNIT/2
					f.destscale = FRACUNIT*4
					f.angle = ang + P_RandomRange(-15, 15)*ANG1
					P_InstaThrust(f, f.angle, 50*FRACUNIT + P_RandomRange(-16, 16)*FRACUNIT)
				end
				ang = $ + (360/24)*ANG1
			end
		end

		if timer == TICRATE/2 + 10
			for k,v in ipairs(hittargets)
				damageObject(v)
			end
		end

		if timer == TICRATE*5/2
			return true
		end
	end,
}

attackDefs["galgalim eyes"] = {
	name = "Galgalim Eyes",
	type = ATK_ALMIGHTY,
	power = 100,
	accuracy = 25,
	costtype = CST_SP,
	cost = 8,
	desc = "Reduce enemy's HP to 1. \nMedium chance of Hunger.",
	target = TGT_ENEMY,
	status = COND_HUNGER,
	statuschance = 35,
	anim = function(mo, targets, hittargets, timer)
		local target = hittargets[1]

		if timer == 10
			playSound(mo.battlen, sfx_eih1)

			local x = target.x + 48*cos(target.angle)
			local y = target.y + 48*sin(target.angle)

			local m = P_SpawnMobj(x, y, target.z + FRACUNIT*90, MT_DUMMY)
			m.sprite = SPR_GLGM
			m.scale = FRACUNIT*2
			m.frame = A|FF_TRANS20|FF_FULLBRIGHT|FF_PAPERSPRITE
			m.angle = target.angle + ANG1*90
			m.tics = -1
			target.mudo = m

			m = P_SpawnMobj(x, y, target.z + FRACUNIT*90, MT_DUMMY)
			m.sprite = SPR_GLGM
			m.frame = A|FF_TRANS60|FF_FULLBRIGHT|FF_PAPERSPRITE
			m.angle = target.angle + ANG1*90
			m.destscale = FRACUNIT*8
			m.scalespeed = FRACUNIT/6
			m.tics = 8
		elseif timer == 30
			target.mudo.destscale = 1
			target.mudo.scalespeed = FRACUNIT/6
			target.mudo.tics = 12
		elseif timer == 40
			local edgeofdeath = target.hp-1
			damageObject(target, edgeofdeath)
			target.mudo = nil
		elseif timer == 60
			return true
		end
	end,
}

attackDefs["bewildering fog"] = {
	name = "Bewildering Fog",
	type = ATK_SUPPORT,
	power = 0,
	accuracy = 999,
	costtype = CST_SP,
	cost = 30,
	desc = "Evade every attack for 4 turns. \nClears ailments. \nCharges next attack.",
	target = TGT_ALLENEMIES,
	evasionskill = 4,
	evasionwait = "",
	mindcharge = true,
	anim = function(mo, targets, hittargets, timer)

		if timer == 10
			mo.dbs = {}
			playSound(mo.battlen, sfx_cboom)
			if mo.guaranteedevasion
				mo.guaranteedevasion = nil
				BTL_logMessage(mo.battlen, "The Fog has lifted.")
			else
				mo.guaranteedevasion = true
				BTL_logMessage(mo.battlen, mo.name.." is shrouded in fog...")
				cureStatus(mo)
				mo.mindcharge = true
			end
			-- ready smoke table
		end

		-- spawn said smoke:
		if timer >= 10 and timer <= TICRATE + TICRATE/2
		and mo.dbs

			for i = 1, 8
				local s = P_SpawnMobj(mo.x, mo.y, mo.z, MT_DUMMY)
				s.state = S_CDUST1
				s.color = SKINCOLOR_WHITE
				s.angle = P_RandomRange(0, 359)*ANG1
				s.scale = FRACUNIT*3
				s.scalespeed = FRACUNIT/6
				s.destscale = FRACUNIT*12
				s.dist = 0
				s.tics = 18
				mo.dbs[#mo.dbs+1] = s
			end
		end

		-- rotate the smoke
		if mo.dbs and #mo.dbs
			for i = 1, #mo.dbs do
				local s = mo.dbs[i]
				if not s or not s.valid continue end	-- don't care

				s.angle = $+ ANG1*10
				s.dist = min(1024, $+32)

				P_TeleportMove(s, mo.x + s.dist *cos(s.angle), mo.y + s.dist*sin(s.angle), s.floorz)

				if not P_RandomRange(0, 30)
					local t = P_SpawnMobj(s.x, s.y, s.z, MT_THOK)
					t.color = SKINCOLOR_WHITE
					t.frame = $|FF_FULLBRIGHT
					t.momz = P_RandomRange(4, 8)*FRACUNIT
					t.destscale = 1
					t.tics = TICRATE
				end
			end
		end

		-- hit targets
		for i = 1, #hittargets
			local target = hittargets[i]
			local t = timer - 6*(i-1)
		end

		if timer == TICRATE*2 - TICRATE/4 + (#hittargets-1)*6
			return true
		end
	end,
}

attackDefs["goto agz"] = {
	name = "UE's Map Loader",
	type = ATK_PASSIVE,
	desc = "Forces the map to change on the vision quest",
	passive = PSV_STARTBATTLE,
	anim = function(mo, targets, hittargets, timer)
		if G_BuildMapName() ~= "MAPAG" //Nothing in () makes it check current map
			COM_BufInsertText(server, "map ag -f") //Sends you to brazil... Maybe, literally?
		end //We didn't return true?!?! That's because PSV_STARTBATTLE only activates for ONE frame, and dont need no stinkn' returns
	end,
}
-- Team Attack
attackDefs["fighting spirit"] = {
	name = "Fighting Spirit",
	type = ATK_SUPPORT,
	costtype = CST_SP,
	cost = 50,
	desc = "Team-Up (Ember & Vespiquen). \nGives Power Charge \nto all allies.",
	target = TGT_ALLALLIES,
	superbuff = true,
	powercharge = true,
	nocast = function(targets, n)
		local tgt = targets[n]
		local battlen = tgt.battlen
		local skincheck = "vespiquen"
		local checkteam = tgt.allies
		local found
		for i = 1, #checkteam do
			if checkteam[i].skin == skincheck
				found = true
				break
			end
		end
		if not found
			BTL_logMessage(battlen, "Vespiquen's not here!")
			playSound(battlen, sfx_not)
			return true
		end
	end,
	hudfunc = function(v, mo, timer)
		for i = 1, #mo.allies do
			local target = mo.allies[i]
			local firstt = TICRATE - timer
			local t = (TICRATE - (firstt*2))
			local t2 = (t<<FRACBITS)/3
			local t3 = t2
			local scale = t*FRACUNIT/6
			local trflag = V_70TRANS
			if firstt < 15
				trflag = V_90TRANS - (V_10TRANS)
			end
			if scale > 0
			and timer < TICRATE
				v.drawScaled(160<<FRACBITS, 100<<FRACBITS, scale, v.cachePatch("H_1M_B"), trflag)
				v.drawScaled(160<<FRACBITS, 100<<FRACBITS, scale, v.cachePatch("H_1M_C"))
			end
			t3 = FixedMul(t3, t3)
			t3 = $+ FixedMul(t3, t2)
			local pp = v.cachePatch(charStats[mo.skin] and charStats[mo.skin].hudaoa or "")
			if mo.status_condition == COND_SUPER
			and charStats[mo.skin] and charStats[mo.skin].hudsaoa
				pp = v.cachePatch(charStats[mo.skin].hudsaoa)
			end
			if timer <100
				v.drawScaled((150)<<FRACBITS + t3/3, (80)<<FRACBITS +t3/8, FRACUNIT/2, pp, V_SNAPTOLEFT, v.getColormap(TC_DEFAULT, mo.color))
				pp = v.cachePatch(charStats["vespiquen"] and charStats["vespiquen"].hudaoa or "pember")
				if target.skin == "vespiquen"
					v.drawScaled((150)<<FRACBITS - t3/3, (80)<<FRACBITS -t3/7, FRACUNIT/2, pp, V_SNAPTOLEFT, v.getColormap(TC_DEFAULT, target.color))
				end
				--v.drawScaled((120)<<FRACBITS -t3/3, (70)<<FRACBITS +t3/8, FRACUNIT/2, v.cachePatch("H_FPASSLAME1"), V_SNAPTOLEFT)
				--v.drawScaled((113)<<FRACBITS +t3/3, (83)<<FRACBITS -t3/7, FRACUNIT/2, v.cachePatch("H_FPASSLAME2"), V_SNAPTOLEFT)
			end
		end
	end,
	anim = function(mo, targets, hittargets, timer)
		for i = 1, #mo.allies do
			local target = mo.allies[i]
			if timer == 1
				if target.skin == "vespiquen"
					VFX_Play(target, VFX_AOADO)
				end
			end
		end
		if timer == 1
			mo.fangle = 0
			mo.fdist = 400
			mo.columns = {}
			playSound(mo.battlen, sfx_aoado)
			VFX_Play(target, VFX_AOADO)
		end
		for k,v in ipairs(hittargets)
			local target = v
			local time = timer - 6*(k-1)
			if timer == 20
				playSound(mo.battlen, sfx_buff2)
				target.powercharge = true
				BTL_logMessage(targets[1].battlen, target.name.." is building up Strength...")
				for i = 1,16
					local dust = P_SpawnMobj(target.x, target.y, target.z, MT_DUMMY)
					dust.angle = ANGLE_90 + ANG1* (22*(i-1))
					dust.state = S_CDUST1
					P_InstaThrust(dust, dust.angle, 30*FRACUNIT)
					dust.color = SKINCOLOR_RED
					dust.scale = FRACUNIT*2
				end
			elseif timer > 20 and timer <= 50
				if leveltime%2 == 0
					for i = 1,16
						local thok = P_SpawnMobj(target.x+P_RandomRange(-70, 70)*FRACUNIT, target.y+P_RandomRange(-70, 70)*FRACUNIT, target.z+P_RandomRange(0, 50)*FRACUNIT, MT_DUMMY)
						thok.state = S_CDUST1
						thok.momz = P_RandomRange(3, 10)*FRACUNIT
						thok.color = SKINCOLOR_RED
						thok.tics = P_RandomRange(10, 35)
						thok.scale = FRACUNIT*3/2
					end
				end
				for i = 1, 8
					local thok = P_SpawnMobj(target.x+P_RandomRange(-70, 70)*FRACUNIT, target.y+P_RandomRange(-70, 70)*FRACUNIT, target.z+P_RandomRange(0, 50)*FRACUNIT, MT_DUMMY)
					thok.sprite = SPR_SUMN
					thok.frame = F|FF_FULLBRIGHT|TR_TRANS50
					thok.momz = P_RandomRange(6, 16)*FRACUNIT
					thok.color = SKINCOLOR_RED
					thok.tics = P_RandomRange(10, 35)
				end
			elseif timer == 60 + (#hittargets-1)*6
				return true
			end
		end
	end,
}

-- Weapons
weaponsList["stinger_01"] = {
	name = "Flame Stinger",
	type = WPT_GENERICRANGED,
	rarity = 1,
	element = ATK_PIERCE,
	atk = 300,
	desc = "Ember's inherit ability to \nconjure fireballs from \nher index finger.",
	slot = "pinpoint pierce",
}

weaponsList["frost stinger"] = {
	name = "Frost Stinger",
	type = WPT_GENERICRANGED,
	rarity = 3,
	element = ATK_ICE,
	atk = 900,
	desc = "An inherit ability to \nconjure icicles from \none's index finger.",
	st = 1,
	lu = 1,
	slot = "freeze boost",
}

weaponsList["fantom stinger"] = {
	name = "Fantom Stinger",
	type = WPT_GENERICRANGED,
	rarity = 5,
	element = ATK_CURSE,
	atk = 1500,
	desc = "An inherit ability to \nconjure dark energy from \none's index finger.",
	st = 3,
	lu = 3,
	slot = "death boost",
}

-- Velvet Shop
table.insert(shopList["velvet_shop_mp1"].weapons, {makeWeapon("stinger_01", 10), 800, nil, 4})
table.insert(shopList["velvet_shop_mp1"].weapons, {makeWeapon("frost stinger"), 4000, 3})
table.insert(shopList["velvet_shop_mp1"].weapons, {makeWeapon("fantom stinger"), 12500, 6})

-- Void Shop
table.insert(shopList["void_shop"].weapons, {makeWeapon("stinger_01", 10), 700, nil, 6})
table.insert(shopList["void_shop"].weapons, {makeWeapon("frost stinger"), 1500, 6, 12})
table.insert(shopList["void_shop"].weapons, {makeWeapon("fantom stinger"), 2000, 12})

-- Vision Quest Stuff
enemyList["ultra elemental"] = {
	name = "Ultra Elemental",
	skillchance = 100,
	level = 99,
	hp = 9999,
	sp = 9999,
	strength = 78,
	magic = 86,
	endurance = 84,
	agility = 92,
	luck = 66,
	melee_natk = "strike_1",
	noroguerandom = true,
	noroguebuff = true,
	resist = ATK_PSY|ATK_NUCLEAR|ATK_BLESS|ATK_CURSE,
	anim_stand = {SPR_HEBS, A, B, 1},
	anim_hurt = {SPR_HEBS, C, D, C, D, C, D, C, D, C, D, 1},
	anim_evoker = {SPR_HEBS, A, B, 1},
	anim_getdown = {SPR_HEBS, C, D, C, D, C, D, C, D, C, D, 1},
	anim_downloop = {SPR_HEBS, C, D, C, D, C, D, C, D, C, D, 1},
	anim_death = {SPR_HEBS, C, 30},
	turns = 2,
	boss = true,
	endboss = true,
	scale = FRACUNIT,
	skills = {"agneyastra", "agidyne", "maragidyne", "bufudyne", "mabufudyne", "ziodyne", "maziodyne", "garudyne", "magarudyne", "bumblebore swarm", "megidola", "quake_elemental", "heat riser", "debilitate", "dekunda", "makajamon", "galgalim eyes", "goto agz"},
	thinker = 	function(mo)
					local btl = server.P_BattleStatus[mo.battlen]
					mo.thinkturns = $ and $+1 or 1
					local enemies = mo.enemies
					
					-- At the start of the battle, he'll cast Bewildering Fog. After that, it'll be once you chip off quarters of his health.
					if mo.thinkturns == 1
						return attackDefs["bewildering fog"], enemies
					end
					
					if mo.hp < mo.maxhp*3/4
					and not mo.fogged_up
						mo.fogged_up = true
						return attackDefs["bewildering fog"], enemies
					end
					
					if mo.hp < mo.maxhp*2/4
					and not mo.fogged_up2
						mo.fogged_up2 = true
						return attackDefs["bewildering fog"], enemies
					end
					
					if mo.hp < mo.maxhp*1/4
					and not mo.fogged_up3
						mo.fogged_up3 = true
						return attackDefs["bewildering fog"], enemies
					end
					
					return generalEnemyThinker(mo)
				end,
}

BTL_challengebtllist[#BTL_challengebtllist+1] = {
	name = "Threat Over The Horizon",
	description = {"Defeat the granddaddy", "of all robotic bees."},
	level = 99,
	music = "THALM",
	time = TICRATE*3000,
	items = {{"hypercombiring", 4}, {"soul food", 4}, {"super1up", 4}, {"me patra gem", 4}, {"dekunda gem", 4}, {"dekaja gem", 4}},
	subpersonas = {},
	waves = {
		{"ultra elemental"}
	},
}