if not srb2p return end

addHook("PlayerSpawn", function(player)
	player.thhkready = false
	player.thhkpressed = false
	player.airt = 0
end)

addHook("PlayerThink", function(player)
	if player.mo.skin ~= "ruby" then
		player.otherskin = true
		return
	end
	if player.powers[pw_nocontrol] or player.mo.state == S_PLAY_DEAD or player.powers[pw_carry] then
		return
	end
	
	//buttons
	if (player.cmd.buttons & BT_JUMP) then
		if (player.thhkready) then
			player.thhkpressed = true
		else
			player.thhkpressed = false
		end
		player.thhkready = false
	else
		player.thhkpressed = false
		player.thhkready = true
	end
	
	if P_IsObjectOnGround(player.mo) then
		player.airt = 0
		player.hominged = false
		player.doublejumped = false
		player.stompin = false
	else
		player.airt = player.airt + 1
		if player.mo.momz <= 0 then
			player.pflags = $ | PF_JUMPED
		end
	end
	
	if (not P_IsObjectOnGround(player.mo)) and player.airt > 3 /*and not (player.pflags & PF_THOKKED)*/ and (player.pflags & PF_JUMPED) then
				if player.thhkpressed and not player.doublejumped then
					player.doublejumped = true
					player.mo.momx = $ / 5 * 4
					player.mo.momy = $ / 5 * 4
					player.mo.momz = player.mo.scale * 9*P_MobjFlip(player.mo)
					if (player.mo.eflags & MFE_UNDERWATER) then
						player.mo.momz = $ / 2
					end
					player.mo.state = S_PLAY_ROLL
					S_StartSound(player.mo,sfx_arspen)
				end
	end
end)
	
	

freeslot("sfx_rsum1", "sfx_rsum2", "sfx_rsum3", "sfx_rsum4", "sfx_rhrt1", "sfx_rhrt2", "sfx_rhrt3", "sfx_rhrt4", "sfx_rhrt5", "sfx_rhrt6", "sfx_rhrt7", "sfx_rhrt8",
"sfx_rhtx1", "sfx_rhtx2", "sfx_rhtx3", "sfx_rhtx4", "sfx_rhtx5", "sfx_rhtx6", "sfx_rhel1", "sfx_rhel2", "sfx_rhel3", "sfx_rhel1", "sfx_rhel2", "sfx_rhel3", "sfx_rkil1", "sfx_rkil2", "sfx_rkil3", "sfx_rkil4",
"sfx_raoi1", "sfx_raoi2", "sfx_raoa1", "sfx_raor1", "sfx_raor2", "sfx_rmis1", "sfx_rmis2", "sfx_rmis3", "sfx_rdge1", "sfx_rdge2", "sfx_rdge3", "sfx_rdge4",
"sfx_rwin1", "sfx_rwin2", "sfx_rwin3", "sfx_rwin4", "sfx_rwin5", "sfx_rlvl1", "sfx_rlvl2", "sfx_rlvl3")

charStats["ruby"] = {   

  
		-- GENERAL

		name = "Ruby",		-- This is only for bots / enemies
		basehp = 75,			-- base HP for level 1 (Cannot be <= 0)
		basesp = 66,			-- base SP for level 1 (Can be 0, but not < 0!)
		persona = "rubyspersona",		-- Persona to use
		melee_natk = "ruby_atk", -- normal melee attack

		-- Normal attack attributes
		-- Scales with game difficulty
		atk = 35,	-- power (generally < 50)
		acc = 75,	-- accuracy (%)
		crit = 50,	-- crit rate (%)
		
		wep = "r_fists_01",
		weptype = WPT_KNUCKLES,
		-- Note: As of Beta 1.0.0, not all animations are implemented
		-- (* = unimplemented)

		anim_stand = 		{SPR_PLAY, A, 15, "SPR2_STND"},			-- standing
		anim_stand_hurt =	{SPR_PLAY, A, 4, "SPR2_STND"},			-- standing (low HP) *
		anim_stand_bored =	{SPR_PLAY, A, B, C, D, 15, "SPR2_WALK"},			-- standing (occasionally plays after anim_stand has played several times)
		anim_guard = 		{SPR_PLAY, A, 1, "SPR2_STND"},			-- guarding
		anim_move =			{SPR_PLAY, A, B, C, D, 5, "SPR2_WALK"},		-- moving
		anim_run =			{SPR_PLAY, A, B, 3, "SPR2_RUN"},		-- guess what
		anim_atk =			{SPR_PLAY, A, B, C, D, 4, "SPR2_ROLL"},		-- attacking
		anim_aoa_end =		{SPR_PLAY, A, B, C, D, 4, "SPR2_ROLL"},			-- jumping out of all-out attack
		anim_hurt =			{SPR_PLAY, A, 6, "SPR2_PAIN"},			-- taking damage
		anim_getdown =		{SPR_PLAY, A, 6, "SPR2_PAIN"},			-- knocked down from weakness / crit *
		anim_downloop =		{SPR_PLAY, A, 5, "SPR2_PAIN"},			-- is down
		anim_getup =		{SPR_PLAY, A, 5, "SPR2_FALL"},			-- gets up from down
		anim_death =		{SPR_PLAY, A, 30, "SPR2_DEAD"},			-- dies
		anim_revive =		{SPR_PLAY, A, 10, "SPR2_STND"},			-- gets revived
        anim_evoker = 		{SPR_PLAY, A, 8, "SPR2_PNCH"},			-- 
		-- anim_special1 through anim_special32 may also be used for various purposes (ie: attack animations)
		-- HUD DEFINTIIONS
		vfx_summon = {"sfx_rsum1", "sfx_rsum2", "sfx_rsum3", "sfx_rsum4"},
		vfx_skill = {},
		vfx_item = {},
		vfx_hurt = {"sfx_rhrt1", "sfx_rhrt2", "sfx_rhrt3", "sfx_rhrt4", "sfx_rhrt5", "sfx_rhrt6", "sfx_rhrt7", "sfx_rhrt8"}, 
		vfx_hurtx = {"sfx_rhtx1", "sfx_rhtx2", "sfx_rhtx3", "sfx_rhtx4", "sfx_rhtx5", "sfx_rhtx6"},
		vfx_die = {},
		vfx_heal = {"sfx_rhel1", "sfx_rhel2", "sfx_rhel3"},
		vfx_healself = {"sfx_rhel1"},
		vfx_1more = {},
		vfx_crit = {},
		vfx_kill = {"sfx_rkil1", "sfx_rkil2", "sfx_rkil3", "sfx_rkil4"},
		vfx_aoaask = {"sfx_raoi1", "sfx_raoi2"},
		vfx_aoado = {"sfx_raoa1"},
		vfx_aoarelent = {"sfx_raor1", "sfx_raor2"},
		vfx_miss = {"sfx_rmis1", "sfx_rmis2", "sfx_rmis3"},
		vfx_dodge = {"sfx_rdge1", "sfx_rdge2", "sfx_rdge3", "sfx_rdge4"},
		vfx_win = {"sfx_rwin1", "sfx_rwin2", "sfx_rwin3", "sfx_rwin4", "sfx_rwin5"},
		vfx_levelup = {"sfx_rlvl1", "sfx_rlvl2", "sfx_rlvl3"},
        


		icon = "ICO_RUBY",
		hudbust = "H_RUBY",	
		hudaoa = "RUBY_AOA",
		aoa_quote = "Kill Kill Kill Kill Kill",
		hudcutin = "RUBY_A",
		hudspr = "",
		tip = "Ruby is a pretty rounded character with electric attacks, a heal and some buffs. He has a lot of HP and SP so don't be afraid to go all out!"

}
         
personaList["rubyspersona"] = {
		-- GENERAL
		name = "None",
		arcana = ARCANA_MAGICIAN,

		-- STATS (@ lv10)

		sprite = SPR_NULL,
		anim_idle = 	{SPR_NULL, A},
		anim_atk = 		{SPR_NULL, A},
		startframe = 0,

		strength = 6,
		magic = 12,
		endurance = 10,
		luck = 4,
		agility = 6,
		weak = ATK_ELEC,
		resist = ATK_FIRE|ATK_STRIKE,
		skills = {
					{"lunge", 1},{"sonic punch", 18, "lunge"},{"assault dive", 25, "sonic punch"},{"gigantic fist", 48, "assault dive"},
					{"zio", 3},{"zionga", 21, "zio"},{"ziodyne", 52, "zionga"},{"thunder reign", 85, "ziodyne"},
					{"mazio", 15},{"mazionga", 37, "mazio"},{"maziodyne", 63, "mazionga"},
					{"dia", 7},{"diarama", 23, "dia"},{"diarahan", 58, "diarama"},
					{"media", 14},{"mediarama", 45, "media"},{"mediarahan", 66, "mediarama"},
					{"tarukaja", 11},{"matarukaja", 38, "tarukaja"},
					{"makakaja", 5},{"mamakakaja", 38, "makakaja"},
					{"rakukaja", 12},{"marakukaja", 38, "rakukaja"}
		}
}

attackDefs["ruby_atk"] = {
		name = "Pnuch",
		type = ATK_STRIKE,
		power = 35,
		accuracy = 85,
		critical = 7, -- was 7
		target = TGT_ENEMY,
		cost = CST_HP,
		cost = 0,
		desc = "Press Jump to epically pnuch the enemy!",
		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 atarget = hittargets[1]
					if timer == 1
						ANIM_set(mo, mo.anim_stand, true)
						mo.reachedtarget = false	-- yeah we can use variables here that you like it or not :^)
						
						mo.stx = mo.x
						mo.sty = mo.y
						mo.stz = mo.z
						S_StartSound(mo, sfx_zoom)
						mo.momz = 10*FRACUNIT
						mo.angle = R_PointToAngle2(mo.x, mo.y, target.x, target.y)
						P_InstaThrust(mo, mo.angle, R_PointToDist2(mo.x, mo.y, target.x, target.y)/45)
					elseif not mo.reachedtarget
						
						
						if R_PointToDist2(mo.x, mo.y, target.x, target.y) < FRACUNIT*10
							mo.momz = 10*FRACUNIT
							mo.reachedtarget = true
							
							damageObject(atarget)
							localquake(mo.battlen, FRACUNIT*7, 4)
							playSound(mo.battlen, sfx_phys)
							mo.hittarget = true
							
							mo.angle = R_PointToAngle2(mo.x, mo.y, mo.stx, mo.sty)
							P_InstaThrust(mo, mo.angle, R_PointToDist2(mo.x, mo.y, mo.stx, mo.sty)/60)
						end
					elseif mo.z > mo.stz
						
					else
						mo.reachedtarget = nil
						mo.stx = nil
						mo.sty = nil
						mo.stz = nil
						return true
					end
				end
	}