-- Persona Support --

if not srb2p return end

charStats["flchan"] = {
	name = "FL Chan",
	basehp = 52,
	basesp = 85,
	persona = "sirius",
	melee_natk = "flchan_atk1",
	supercolor_start = SKINCOLOR_SUPERPERIDOT1,
	atk = 25,
	acc = 75,
	crit = 5,
	anim_stand = {SPR_PLAY, A, 8, "SPR2_STND"},
	anim_stand_hurt = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_stand_bored = {SPR_PLAY, A, B, 15, "SPR2_WAIT"},
	anim_guard = {SPR_PLAY, C, 2, "SPR2_RUN"},
	anim_move = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_WALK"},
	anim_run = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_RUN"},
	anim_atk = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_ROLL"},
	anim_aoa_end = {SPR_PLAY, H, G, F, E, D, C, B, A, 2, "SPR2_ROLL"},
	anim_hurt = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_getdown = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_downloop = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_getup = {SPR_PLAY, A, 1, "SPR2_SPNG"},
	anim_death = {SPR_PLAY, A, 30, "SPR2_DEAD"},
	anim_revive = {SPR_PLAY, A, 1, "SPR2_SPNG"},
	anim_evoker = {SPR_PLAY, A, 20, "SPR2_BACT"},
	anim_evoker_shoot = {SPR_PLAY, B, 20, "SPR2_BACT"},
	anim_special1 = {SPR_PLAY, A, B, C, D, E, 2, "SPR2_MICG"},
	anim_special3 = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_CNT4"},
	
	vfx_summon = {},
    vfx_skill = {},
    vfx_item = {},
    vfx_hurt = {},
    vfx_hurtx = {},
    vfx_die = {},
    vfx_heal = {},
    vfx_healself = {},
    vfx_kill = {},
    vfx_1more = {},
    vfx_crit = {},
    vfx_aoaask = {},
    vfx_aoado = {},
    vfx_aoarelent = {},
    vfx_miss = {},
    vfx_dodge = {},
    vfx_win = {},
    vfx_levelup = {},
	
	icon = "ICO_FLCH",
	hudbust = "H_FLCBAR",
	hudaoa = "H_FLCAOA",
	aoa_quote = "Let's make these guys \nchange their tune!",
	hudcutin = "FLCH_A",
	tip = "This cutie learns Bless, Psy, and Fire \nwith most of her other skills being \nsupports that can inflict various status \nconditions to enemies. She has an \nextremely high SP to make up for her \nlow HP, so go nuts with it!"
}

personaList["sirius"] = {
	name = "Sirius",
	arcana = nil,
	sprite = SPR_SIRI,
	startframe = 0,
	anim_idle = {SPR_SIRI, A, B, C, D, E, F, 10},
	anim_atk = {SPR_SIRI, A, G, H, I, J, K, H, 2},
	strength = 5,
	magic = 3,
	endurance = 10,
	luck = 9,
	agility = 13,
	weak = ATK_SLASH|ATK_ICE, -- She hates it when the music suddenly cuts off/Being frozen interferes with dancing and singing
	resist = ATK_FIRE, -- While the mixtape may be fire, hers will always be even more fire 
	block = ATK_BLESS, -- She's used to partying with bright lights
	repel = ATK_PSY, -- She converts Psy energy into lofi hip-hop

	skills = {
		{"kouha", 1}, {"psio", 2},
		{"agilao", 5}, {"marin karin", 10},
		{"heat riser", 15}, {"pulinpa", 20},
		{"foolish whisper", 25}, {"dormina", 30},
		
		{"makouha", 31, "kouha"}, {"mapsio", 32, "psio"},
		{"maragidyne", 35, "agilao"}, {"sexy dance", 40, "marin karin"},
		{"cheer", 45, "heat riser"}, {"tentarafoo", 50, "pulinpa"},
		{"makajamon", 55, "foolish whisper"}, {"asmr", 60, "dormina"},
	},
}

-- Bionis support
if bionis then
	personaList["sirius"].drain = ATK_WATER -- Since she dances all the time, she appreciates a drink of water
end

-- Her melee attack (a modified version of Heat Wave)
attackDefs["flchan_atk1"] = {
	name = "Mic Drop",
	type = ATK_STRIKE,
	power = 45,
	accuracy = 999,
	statuschance = 5,
	status = COND_SHOCK,
	costtype = CST_HP,
	cost = 0,
	desc = "A hard-hitting beat in \nthe truest sense.\nMay inflict shock.",
	target = TGT_ALLENEMIES,
	technical = COND_SLEEP,
	physical = true,
	anim_norepel = true,
	anim = function(mo, targets, hittargets, timer)
		if timer == TICRATE/3
			ANIM_set(mo, mo.anim_special1, false)
		end
		if timer == TICRATE/2
		or timer == TICRATE/2 + 8
			if timer == TICRATE/2
				localquake(mo.battlen, 30*FRACUNIT, 5)
				playSound(mo.battlen, sfx_pstop)
			end
			local ang = 0
			for i = 1, 24 do
				local m = P_SpawnMobj(mo.x, mo.y, mo.z, MT_DUMMY)
				m.state = S_MUSICNOTE2
				m.scale = FRACUNIT/2
				m.fuse = TICRATE
				m.destscale = FRACUNIT*4
				m.friction = FRACUNIT
				m.angle = ang
				P_InstaThrust(m, m.angle, 50*FRACUNIT)
				m = P_SpawnMobj(mo.x, mo.y, mo.z, MT_DUMMY)
				m.state = S_QUICKBOOM1
				m.scale = FRACUNIT
				m.fuse = TICRATE
				m.friction = FRACUNIT
				m.destscale = FRACUNIT*4
				m.angle = ang
				m.color = SKINCOLOR_LAVENDER
				P_InstaThrust(m, m.angle, 60*FRACUNIT)
				for i = 1, 8
					m = P_SpawnMobj(mo.x, mo.y, mo.z + (mo.height*2), MT_DUMMY)
					m.state = S_MUSICNOTE1
					m.fuse = TICRATE
					m.friction = FRACUNIT
					m.scale = FRACUNIT
					m.destscale = FRACUNIT*4
					m.angle = ang + P_RandomRange(-15, 15)*ANG1
					P_InstaThrust(m, m.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*2
			return true
		end
	end,
}

-- It's pretty much Heat Riser, but it affects all allies (seriously, how is this NOT in the base game)
attackDefs["cheer"] = {
	name = "Cheer",
	type = ATK_SUPPORT,
	costtype = CST_SP,
	cost = 48,
	desc = "Raise all allies' stats by \n1 stage. GO TEAM!",
	target = TGT_ALLALLIES,
	superbuff = true,
	nocast = 	function(targets, n)
					local target = targets[n]
					if target.buffs["atk"][1] >= 75
					and target.buffs["mag"][1] >= 75
					and target.buffs["agi"][1] >= 75
					and target.buffs["def"][1] >= 75
						BTL_logMessage(targets[1].battlen, "Limit reached!")
						return true
					end
				end,
	anim = function(mo, targets, hittargets, timer)
		for i = 1, #targets do
			local target = targets[i]
			local colors = {SKINCOLOR_ORANGE, SKINCOLOR_TEAL, SKINCOLOR_LAVENDER, SKINCOLOR_EMERALD}
			if timer == 20
				if target.skin ~= "flchan" then
					ANIM_set(mo, mo.anim_special3, true)
				end
			end
			if timer == 20 + (i-1)*16
				playSound(mo.battlen, sfx_buff)
				buffStat(target, "atk")
				buffStat(target, "mag")
				buffStat(target, "def")
				buffStat(target, "agi")
				BTL_logMessage(targets[1].battlen, "All stats increased!")
				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_WHITE
					dust.scale = FRACUNIT*2
				end
			elseif timer > 20 + (i-1)*16 and timer <= 50 + (i-1)*16
				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_WHITE
						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 = colors[P_RandomRange(1, #colors)]
					thok.tics = P_RandomRange(10, 35)
				end
			end
		end
		if timer == 60 + (#targets-1)*16
			return true
		end
	end,
}

-- Yes, I really made this a thing
attackDefs["asmr"] = {
	name = "ASMR",
	type = ATK_SUPPORT,
	power = 0,
	accuracy = 25,
	statuschance = 25,
	status = COND_SLEEP,
	costtype = CST_SP,
	luckbased = true,
	cost = 12,
	desc = "Low chance of inflicting \nSleep on all enemies.",
	target = TGT_ALLENEMIES,
	anim = function(mo, targets, hittargets, timer)
			for i = 1, #hittargets
				local target = hittargets[i]
				local t = timer - (i-1)*6
				if t == 10
					playSound(mo.battlen, sfx_absorb)
				end
				if t <= 30
					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_SILVER
					thok.tics = P_RandomRange(10, 35)
					thok.scale = FRACUNIT*3/2
				end
				if t == 20
					damageObject(target)
				end
			end
			if timer == 42 + (#hittargets-1)*6
				return true
			end
	end,
}

-- Allows other players to use Cheer
itemDefs["pom-poms"] = {
	name = "Pom-Poms",
	desc = "Raise all allies' stats by \n1 stage. GO TEAM!",
	nouse = true,
	attack = "cheer",
}

-- The higher you go, the less chance you have of getting the item
table.insert(tartarus_items[1], {"pom-poms", 30})
table.insert(tartarus_items[blockfloor[BLOCK_YABBASHAH]], {"pom-poms", 20})
table.insert(tartarus_items[blockfloor[BLOCK_HARABAH]], {"pom-poms", 10})

-- Allows other players to be ASMRtists
itemDefs["binaural mic"] = {
	name = "Binaural Mic",
	desc = "Low chance of inflicting \nSleep on all enemies.",
	nouse = true,
	attack = "asmr",
}

table.insert(tartarus_items[1], {"binaural mic", 30})
table.insert(tartarus_items[blockfloor[BLOCK_YABBASHAH]], {"binaural mic", 20})
table.insert(tartarus_items[blockfloor[BLOCK_HARABAH]], {"binaural mic", 10})

-- Stuff for the battles
enemyList["flchan_tier1"] = {
	name = "FL Chan?",
	skillchance = 90,	-- /100, probability of using a skill
	level = 30,
	hp = 2000,
	sp = 1500,
	strength = 25,
	magic = 28,
	endurance = 20,
	agility = 23,
	luck = 29,
	melee_natk = "flchan_atk1",
	boss = true,
	thinker = generalEnemyThinker,
	skin = "flchan",
	color = SKINCOLOR_BLACK,
	hudcutin = "FLCH_A",
	weak = ATK_SLASH|ATK_ICE,
	resist = ATK_FIRE,
	block = ATK_BLESS,
	repel = ATK_PSY,
	persona = "sirius",
	
	anim_stand = {SPR_PLAY, A, 8, "SPR2_STND"},
	anim_stand_hurt = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_stand_bored = {SPR_PLAY, A, B, 15, "SPR2_WAIT"},
	anim_guard = {SPR_PLAY, C, 2, "SPR2_RUN"},
	anim_move = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_WALK"},
	anim_run = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_RUN"},
	anim_atk = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_ROLL"},
	anim_aoa_end = {SPR_PLAY, H, G, F, E, D, C, B, A, 2, "SPR2_ROLL"},
	anim_hurt = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_getdown = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_downloop = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_getup = {SPR_PLAY, A, 1, "SPR2_SPNG"},
	anim_death = {SPR_PLAY, A, 30, "SPR2_DEAD"},
	anim_revive = {SPR_PLAY, A, 1, "SPR2_SPNG"},
	anim_evoker = {SPR_PLAY, A, 20, "SPR2_BACT"},
	anim_evoker_shoot = {SPR_PLAY, B, 20, "SPR2_BACT"},
	anim_special1 = {SPR_PLAY, A, B, C, D, E, 2, "SPR2_MICG"},
	anim_special3 = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_CNT4"},
	
	skills = {"kouga", "psio", "agilao", "marin karin", "heat riser", "pulinpa", "foolish whisper", "dormina"},
	
}

enemyList["flchan_tier2"] = {
	name = "FL Chan?",
	skillchance = 90,	-- /100, probability of using a skill
	level = 60,
	hp = 4000,
	sp = 2500,
	strength = 45,
	magic = 48,
	endurance = 40,
	agility = 43,
	luck = 40,
	melee_natk = "flchan_atk1",
	thinker = generalEnemyThinker,
	boss = true,
	skin = "flchan",
	color = SKINCOLOR_BLACK,
	hudcutin = "FLCH_A",
	weak = ATK_SLASH|ATK_ICE,
	resist = ATK_FIRE,
	block = ATK_BLESS,
	repel = ATK_PSY,
	persona = "sirius",
	
	anim_stand = {SPR_PLAY, A, 8, "SPR2_STND"},
	anim_stand_hurt = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_stand_bored = {SPR_PLAY, A, B, 15, "SPR2_WAIT"},
	anim_guard = {SPR_PLAY, C, 2, "SPR2_RUN"},
	anim_move = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_WALK"},
	anim_run = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_RUN"},
	anim_atk = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_ROLL"},
	anim_aoa_end = {SPR_PLAY, H, G, F, E, D, C, B, A, 2, "SPR2_ROLL"},
	anim_hurt = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_getdown = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_downloop = {SPR_PLAY, A, 8, "SPR2_PAIN"},
	anim_getup = {SPR_PLAY, A, 1, "SPR2_SPNG"},
	anim_death = {SPR_PLAY, A, 30, "SPR2_DEAD"},
	anim_revive = {SPR_PLAY, A, 1, "SPR2_SPNG"},
	anim_evoker = {SPR_PLAY, A, 20, "SPR2_BACT"},
	anim_evoker_shoot = {SPR_PLAY, B, 20, "SPR2_BACT"},
	anim_special1 = {SPR_PLAY, A, B, C, D, E, 2, "SPR2_MICG"},
	anim_special3 = {SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_CNT4"},
	
	skills = {"makougaon", "mapsio", "maragidyne", "sexy dance", "cheer", "tentarafoo", "makajamon", "asmr"},
	
}

enemyList["metalsonic_fl2"] = {
	name = "Metal Sonic?",
	skillchance = 95,	-- /100, probability of using a skill
	level = 60,
	hp = 1950,
	sp = 2000,
	strength = 45,
	magic = 36,
	endurance = 38,
	agility = 30,
	luck = 25,
	melee_natk = "metal_atk1",
	thinker = generalEnemyThinker,
	boss = true,
	skin = "metalsonic",
	color = SKINCOLOR_BLACK,
	hudcutin = "MSON_A",
	weak = ATK_ELEC|ATK_BLESS,
	resist = ATK_STRIKE|ATK_PIERCE|ATK_SLASH|ATK_NUCLEAR,
	persona = "palladion",
	
		anim_stand = 		{SPR_PLAY, A, 8, "SPR2_STND"},		-- standing
		anim_stand_hurt =	{SPR_PLAY, A, 1, "SPR2_STND"},		-- standing (low HP)
		anim_stand_bored =	{SPR_PLAY, A, B, A, B, A, B, A, B, 10, "SPR2_WAIT"},	-- standing (rare anim)
		anim_guard = 		{SPR_PLAY, A, 1, "SPR2_WALK"},		-- guarding
		anim_move =			{SPR_PLAY, A, 2, "SPR2_WALK"},		-- moving
		anim_run =			{SPR_PLAY, A, 2, "SPR2_RUN"},	-- guess what
		anim_atk =			{SPR_PLAY, A, B, C, D, E, 1, "SPR2_ROLL"},	-- attacking
		anim_aoa_end =		{SPR_PLAY, E, D, C, B, A, 1, "SPR2_ROLL"},	-- jumping out of all-out attack
		anim_hurt =			{SPR_PLAY, A, 35, "SPR2_PAIN"},		-- taking damage
		anim_getdown =		{SPR_PLAY, A, 1, "SPR2_PAIN"},		-- knocked down from weakness / crit
		anim_downloop =		{SPR_PLAY, A, 1, "SPR2_PAIN"},		-- is down
		anim_getup =		{SPR_PLAY, A, B, C, D, E, F, 1, "SPR2_ROLL"},		-- gets up from down
		anim_death =		{SPR_PLAY, A, 30, "SPR2_DEAD"},		-- dies
		anim_revive =		{SPR_PLAY, A, B, C, D, E, F, 1, "SPR2_ROLL"},		-- gets revived
		anim_evoker = 		{SPR_PLAY, A, 8, "SPR2_SPNG"},

		anim_special1 =		{SPR_PLAY, A, 2, "SPR2_SPNG"},	-- charge
		anim_sepcial2 =		{SPR_PLAY, A, 2, "SPR2_DASH"},	-- dash
		
		vfx_summon = {"sfx_mssum1", "sfx_mssum2"},
        vfx_skill = {"sfx_msskl1", "sfx_msskl2"},
        vfx_item = {"sfx_mssum1", "sfx_mssum2"},
        vfx_hurt = {"sfx_mshrt1", "sfx_mshrt2"},
        vfx_hurtx = {"sfx_msskl2"},
        vfx_die = {"sfx_msmis1"},
        vfx_heal = {"sfx_mssum1", "sfx_mssum2"},
        vfx_healself = {"sfx_mssum1", "sfx_mssum2"},
        vfx_kill = {"sfx_mssum1", "sfx_mssum2"},
        vfx_1more = {"sfx_msdge1"},
        vfx_crit = {"sfx_msskl2"},
        vfx_aoaask = {"sfx_msaoi1"},
        vfx_aoado = {"sfx_msskl2"},
        vfx_aoarelent = {"sfx_msmis1"},
        vfx_miss = {"sfx_msmis1"},
        vfx_dodge = {"sfx_msdge1"},
        vfx_win = {"sfx_mswin1"},
        vfx_levelup = {"sfx_mswin1"},
	
	skills = {"masukukaja", "freila", "marakukaja", "matarukaja", "dekunda", "gigantic fist", "power charge", "heat wave"},
}

-- Battles
BTL_challengebtllist[#BTL_challengebtllist+1] = {
	name = "FL Chan (Tier I)",
	description = {"Fight FL Chan with all", "of her Tier I skills."},
	level = 30,
	music = "MBOSS1",
	time = TICRATE*600,
	items = {{"dekaja gem", 2}, {"me patra gem", 5}, {"silvercombiring", 1}, {"1up", 4}, {"pom-poms", 3}, {"snuffsoul", 8}},
	subpersonas = nil,
	waves = {
		{"flchan_tier1"}
	},
}

BTL_challengebtllist[#BTL_challengebtllist+1] = {
	name = "FL Chan (Tier II)",
	description = {"Fight FL Chan with all", "of her Tier II skills AND", "with Metal Sonic in tow."},
	level = 60,
	music = "EADVN1",
	time = TICRATE*900,
	items = {{"dekaja gem", 2}, {"me patra gem", 5}, {"hypercombiring", 1}, {"super1up", 4}, {"pom-poms", 3}, {"chewing soul", 8}},
	subpersonas = nil,
	waves = {
		{"flchan_tier2", "metalsonic_fl2"}
	},
}