freeslot(
"sfx_pftd1",
"sfx_pftd2",
"sfx_pftd3",
"sfx_pftd4",
"sfx_pftd5",
"sfx_pftd6",
"sfx_pftd8",
"sfx_pftd9",
"sfx_pftd10",
"sfx_pftd11",
"sfx_pftd12",
"sfx_pftd13"
)

if not srb2p return end
-- Due to the exe nature of the mod, this only requires a one-time check.

-- Define our base character's stats!
charStats["flame"] = {

		-- GENERAL

		name = "Flame",		-- This is only for bots / enemies
		basehp = 70,			-- base HP for level 1 (Cannot be <= 0)
		basesp = 35,			-- base SP for level 1 (Can be 0, but not < 0!)
		persona = "phoenix",		-- Persona to use
		melee_natk = "flametd_atk1",	-- normal melee attack
		
		wep = "melee_01",		-- default weapon.
		weptype = WPT_SHOES,	-- Equippable weapon type(s)

		-- Normal attack attributes
		-- Scales with game difficulty
		atk = 42,	-- power (generally < 50)
		acc = 83,	-- accuracy (%)
		crit = 4,	-- crit rate (%)


        supercolor_start = SKINCOLOR_SUPER_BLUEFIRE_1,	-- if super form is applicable: will use this flash

		-- ANIMS
		-- Anims are built like this:
		-- {SPR_SPRITE, frame1, frame2, frame3, ... , duration between each frame, ["SPR2_CONST"]}
		-- (SPR2 must be a string, and is optional. Only for use with SPR_PLAY)

		-- Note: As of Beta 1.0.0, not all animations are implemented
		-- (* = unimplemented)

		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, C, 6, "SPR2_WAIT"},					-- standing (occasionally plays after anim_stand has played several times)
		anim_guard = 		{SPR_PLAY, A, 1, "SPR2_SKID"},					-- guarding
		anim_move =			{SPR_PLAY, A, B, C, D, E, F, G, H, 2, "SPR2_WALK"},	-- moving
		anim_run =			{SPR_PLAY, A, B, C, D, E, F, 2, "SPR2_RUN_"},	-- guess what
		anim_atk =			{SPR_PLAY, A, B, C, D, 2, "SPR2_ROLL"},			-- attacking
		anim_aoa_end =		{SPR_PLAY, A, B, 2, "SPR2_FALL"},			-- jumping out of all-out attack
		anim_hurt =			{SPR_PLAY, A, 35, "SPR2_PAIN"},					-- taking damage
		anim_getdown =		{SPR_PLAY, A, 1, "SPR2_STND"},					-- knocked down from weakness / crit *
		anim_downloop =		{SPR_PLAY, A, 2, "SPR2_PAIN"},					-- is down
		anim_getup =		{SPR_PLAY, A, B, C, D, 1, "SPR2_ROLL"},			-- gets up from down
		anim_death =		{SPR_PLAY, A, 30, "SPR2_DEAD"},					-- dies
		anim_revive =		{SPR_PLAY, A, B, C, D, 1, "SPR2_ROLL"},			-- gets revived
   
		-- anim_special1 through anim_special32 may also be used for various purposes (ie: attack animations)
        anim_special1 = {SPR_PLAY, A, 2, "SPR2_GLID"},                   -- dive

		-- VOICES
		-- Possible list of voices
		-- vfx_action = {"sfx_voice1", "sfx_voice2", [...], "sfx_voicen"}

		-- ...In the case of kanade, she's silent, but I will leave these here for reference!

		vfx_summon = {},	-- Summoning Persona to use a Skill
        vfx_skill = {"sfx_pftd2","sfx_pftd4"},		-- Used a Skill
        vfx_item = {"sfx_pftd3","sfx_pftd13"},		-- Used an item
        vfx_hurt = {"sfx_pftd5"},		-- Sustained damage
        vfx_hurtx = {"sfx_pftd5","sfx_pftd6"},		-- Sustained heavy damage / Critical hit / Weakness
        vfx_die = {"sfx_pftd6"},		-- Death
        vfx_heal = {"sfx_pftd2","sfx_pftd3"},		-- Healed by teammate
        vfx_healself = {"sfx_pftd13"},	-- Healed self
        vfx_kill = {"sfx_pftd1","sfx_pftd3"},		-- Killed an enemy
        vfx_1more = {"sfx_pftd2","sfx_pftd11"},		-- Performed 1more
        vfx_crit = {"sfx_pftd2","sfx_pftd8","sfx_pftd11"},		-- Cut-in for Weakness/Critical Hit
        vfx_aoaask = {"sfx_pftd11"},	-- Ask to All-Out Attack
        vfx_aoado = {"sfx_pftd2"},		-- Performing All-Out Attack
        vfx_aoarelent = {"sfx_pftd13"},	-- Relenting from All-Out Attack
        vfx_miss = {"sfx_pftd9","sfx_pftd12"},		-- Missed attack
        vfx_dodge = {"sfx_pftd3","sfx_pftd5"},		-- Dodged enemy attack
        vfx_win = {"sfx_pftd9","sfx_pftd10","sfx_pftd12"},		-- Battle won
        vfx_levelup = {"sfx_pftd8","sfx_pftd2"},	-- Level Up!


		-- HUD DEFINTIIONS

		icon = "ICO_SONI",	-- icon for net select and other menus
		hudbust = "SONIC_H",			-- patch to draw on the stat hud
		hudaoa = "H_SONAOA",	-- patch for all out attack hud
		hudsbust = "SSONIC_H",
		hudsaoa = "H_SSONAOA",	-- same but for supers
		hudcutin = "SONIC_A",	-- cut in
		aoa_quote = "Let's make this quick!",

		tip = "Dragon",

}


personaList["phoenix"] = {
		-- GENERAL
		name = "Phoenix",	-- Name of the Persona
		arcana = nil,			-- Arcana (unused in Beta 1.0.0, can be left nil as well)

		sprite = SPR_PSN0,		-- Unused outside of debugging purposes for shortcuts. Can be left nil
		startframe = 0,			-- Unused outside of debugging purposes for shortcuts. Can be left nil

		-- Animations function the same way they do for players. (In Kanade's case, she's so good she doesn't need one, so let's make it invisible)
		anim_idle = 	{SPR_NULL, A},	-- Idle animation when summoned in the menu
		anim_atk = 		{SPR_NULL, A},	-- Animation when attacking

		-- Stats (at level 10)
		-- Remember that stats naturally cap at 99.
		strength = 10,
		magic = 9,
		endurance = 12,
		luck = 5,
		agility = 7,

		-- Affinities (weak, resist, block, drain)
		weak = ATK_ICE|ATK_ELEC,
		resist = ATK_STRIKE|ATK_SLASH,
		block = ATK_FIRE,

		/*Skills learnt and their level:
			{
				{"skillname", level, ["skill_to_replace"]},
				{"skill2name", level, ["skill_to_replace"]},
				[...]
			}

			Documentation for every existing skill name will be available publically at a later date.
			For now, feel free to scout the game files yourself!

			the 3rd argument is only useful on higher difficulties where characters automatically start at
			higher levels, meaning their skills need to be automatically replaced.

			NOTE: Characters can only have 8 skills total! But if you mess this up, the game won't stop you from having 69 skills.
			So pay attention!
		*/

		skills = {
					{"agi", 1}, {"lunge", 4},
					{"rakukaja", 8}, {"maragi", 12},
					{"gale slash", 15}, {"kill rush", 17},
					{"agilao", 22}, {"phoenixgift", 25},

					{"swift strike", 28, "lunge"}, 
					{"regenerate 1", 32, "agi"},
					{"maragion", 35, "maragi"}, 
					{"marakukaja", 38, "rakukaja"},
					{"flame wave", 42, "gale slash"},
					{"regenerate 2", 44, "regenerate 1"},
					{"power charge", 47, "assault dive"},
					{"gigantic fist", 53, "kill rush"},
					{"agidyne", 54, "agilao"},
					{"phoenix strike", 57, "flame wave"},
					{"maragidyne", 67, "maragion"},
					{"god hand", 68, "gigantic fist"},
					{"akasha arts", 72, "phoenix strike"},
				},

}









attackDefs["flametd_atk1"] = {
		name = "Crash Dive",
		type = ATK_STRIKE,
		power = 42,
		accuracy = 83,
		critical = 4, 
		target = TGT_ENEMY,
		cost = CST_HP,
		cost = 0,
		status = COND_BURN,
     	statuschance = 5,
		technical = COND_FREEZE,
		desc = "Dive into the target",
		anim_norepel = true,	-- do not bounce back our ANIMATION
		physical = true,	-- don't play the summoning anim for phys attacks, duh
		anim = 	function(mo, targets, hittargets, timer)
					local target = targets[1]
					local btl = server.P_BattleStatus[mo.battlen]
					local cam = btl.cam

					if timer == 1
						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))
					elseif timer == 10
						ANIM_set(mo, mo.anim_special1)
						P_TeleportMove(mo, target.x + 4*cos(target.angle), target.y + 4*sin(target.angle), target.z + FRACUNIT*256)
						mo.momz = -FRACUNIT*24
					elseif timer >=  10
					and timer < TICRATE + TICRATE/2
						if leveltime & 1
							local g = P_SpawnGhostMobj(mo)
							g.destscale = mo.scale*4
						end

						if mo.z <= target.z + FRACUNIT*32
							mo.z = target.z + FRACUNIT*32
							mo.momz = 0

							if leveltime%5 == 0
								createSplat(mo)
								local shot = P_SpawnMobj(target.x + P_RandomRange(-15, 15)*FRACUNIT, target.y + P_RandomRange(-15, 15)*FRACUNIT, target.z + P_RandomRange(16, 48)*FRACUNIT, MT_DUMMY)
								playSound(mo.battlen, sfx_rail1)
								shot.state = S_SHOT1
								shot.scale = $ + P_RandomRange(0, 65535)*3
								P_StartQuake(FRACUNIT*10, 5)
							end
						end

					elseif timer == TICRATE + TICRATE/2
						damageObject(hittargets[1])
						P_InstaThrust(mo, target.angle, FRACUNIT*10)
						mo.momz = 10*FRACUNIT

					elseif timer == TICRATE*5/2
						mo.z = mo.floorz
						return true
					end
				end,
				
}

attackDefs["phoenixgift"] = {
		name = "Phoenix's Gift",
		type = ATK_HEAL,
		costtype = CST_EP,
		cost = 1,
		desc = "Revive a fallen ally \nwith half HP",
		target = TGT_DEAD,
		anim = function(mo, targets, hittargets, timer)
			local target = hittargets[1]

			-- first of all, get this boy back in our party
			if timer == 1
				revivePlayer(target)
			end

			if timer == 10
				-- spawn 1up monitor
				local b = P_SpawnMobj(target.x, target.y, target.z+300*FRACUNIT, MT_DUMMY)
				b.state = S_AOADUST1
				b.frame = A|FF_FULLBRIGHT
				b.scale = FRACUNIT*3
				b.destscale = FRACUNIT/12

				mo.recarmtv = P_SpawnMobj(target.x, target.y, target.z + FRACUNIT*300, MT_DUMMY)
				mo.recarmtv.momz = -FRACUNIT*10
				mo.recarmtv.flags = MF_NOBLOCKMAP
				mo.recarmtv.tics = -1
				mo.recarmtv.sprite = SPR_TV1P
				mo.recarmtv.frame = A

			elseif timer >= 10 and timer < 80
				-- tv anim
				if leveltime%3 == 0
					mo.recarmtv.sprite = SPR_MSTV
					mo.recarmtv.frame = A
				else
					mo.recarmtv.sprite = SPR_TV1P
					mo.recarmtv.frame = A
					local ol = P_SpawnMobj(mo.recarmtv.x, mo.recarmtv.y, mo.recarmtv.z, MT_OVERLAY)
					ol.state = S_PLAY_BOX1
					mo.recarmtv.target = ol
					ol.target = mo.recarmtv
					ol.sprite = SPR_PLAY
					ol.sprite2 = target.sprite2
					ol.skin = target.skin
					ol.state = S_PLAY_BOX1
					ol.color = target.color
					ol.fuse = 1
				end
			elseif timer == 80
				-- explode the box and revive us!

				playSound(mo.battlen, sfx_pop)
				for i=1,16
					local b = P_SpawnMobj(target.x, target.y, target.z+20*FRACUNIT, MT_DUMMY)
					b.momx = P_RandomRange(-8, 8)*FRACUNIT
					b.momy = P_RandomRange(-8, 8)*FRACUNIT
					b.momz = P_RandomRange(-8, 8)*FRACUNIT
					b.state = S_AOADUST1
					b.frame = A|FF_FULLBRIGHT
					b.scale = FRACUNIT*3
					b.destscale = FRACUNIT/12
				end
				local heals = target.maxhp/2
				damageObject(target, -heals)
				playSound(mo.battlen, sfx_heal2)

				ANIM_set(target, target.anim_revive, true)
				target.momz = 10*FRACUNIT

				P_RemoveMobj(mo.recarmtv.target)
				P_RemoveMobj(mo.recarmtv)
				mo.recarmtv = nil

			elseif timer == 128
				return true

			elseif timer > 80 and P_IsObjectOnGround(target)
				ANIM_set(target, target.anim_stand, true)
			end
		end,
}
	
attackDefs["flame wave"] = {
		name = "Flame Wave",
		type = ATK_STRIKE,
		power = 230,
		accuracy = 85,
		costtype = CST_HPPERCENT,
		cost = 18,
		critical = 3,
		status = COND_BURN,
     	statuschance = 9,
		desc = "Medium Strike damage to \nall enemies. \nMay inflict burn.",
		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)
				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*3
				return true
			end
		end,
}
	
attackDefs["phoenix strike"] = {
		name = "Phoenix Strike",
		type = ATK_STRIKE,
		power = 410,
		accuracy = 92,
		costtype = CST_HPPERCENT,
		cost = 22,
		critical = 1,
		status = COND_BURN,
     	statuschance = 15,
		desc = "Heavy Strike damage to \nall enemies.\nMay inflict burn.",
		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)
				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*3
				return true
			end
		end,
}