//Ashura's moveset

addHook("PlayerThink", function(player)
	if player.mo and player.mo.valid
		if player.ashuraabildelay == nil
			player.ashuraabildelay = 0
		end
		if player.ashuraabildelay > 0
			player.ashuraabildelay = $-1
		end
		if player.ashuracanteleport == nil
			player.ashuracanteleport = true
		end
		if P_IsObjectOnGround(player.mo)
		and player.ashuracanteleport == false
			player.ashuracanteleport = true
		end
		if player.soniccanashura == true
		and player.isashura == true
		and player.ashuracanteleport == true
		and player.pflags & PF_THOKKED
		and not (player.pflags & PF_SHIELDABILITY)
		and not (player.mo.eflags & MFE_UNDERWATER)
		and not player.ashuraabildelay
		and not player.ashurabouncing
		and player.mo.skin != "modernsonic"
		and player.mo.skin != "xtreme"
		and not (player.pflags & PF_SPINNING)
			P_FlashPal(player, PAL_WHITE, 12)
			S_StartSound(player.mo, 609, player)
			P_InstaThrust(player.mo, player.mo.angle, 80*FRACUNIT)
			player.ashuracanteleport = false
			player.ashuraabildelay = 12
			P_SpawnParaloop(player.mo.x, player.mo.y, player.mo.z, player.mo.scale*256, 20, MT_THOK, player.drawangle, S_SPINDUST_BUBBLE1, true)
		end
		if player.soniccanashura == true
		and player.isashura == true
		and player.ashuraabildelay > 1
			player.mo.flags2 = $|MF2_DONTDRAW
			player.mo.flags = $|MF_NOCLIP
			player.mo.flags = $|MF_NOCLIPTHING
		end
		if player.soniccanashura == true
		and player.isashura == true
		and player.ashuraabildelay == 1
			player.mo.flags2 = $ & ~MF2_DONTDRAW
			player.mo.flags = $ & ~MF_NOCLIP
			player.mo.flags = $ & ~MF_NOCLIPTHING
			P_SpawnParaloop(player.mo.x, player.mo.y, player.mo.z, player.mo.scale*256, 20, MT_THOK, P_RandomRange(0, 359)*ANG1, S_SPINDUST_BUBBLE1, true)
		end
		if player.soniccanashura == true
		and player.isashura == true
		and not (player.mo.eflags & MFE_UNDERWATER)
			if not P_IsObjectOnGround(player.mo)
			and not (player.pflags & PF_JUMPED)
			and (player.cmd.buttons == BT_SPIN)
			and (player.mo.state == S_PLAY_SPRING or player.mo.state == S_PLAY_FALL or player.mo.state == S_PLAY_PAIN) then
				player.pflags = $|PF_JUMPED
				player.mo.state = S_PLAY_JUMP
				S_StartSound(player.mo, sfx_zoom, player)
				P_SpawnThokMobj(player)
			end
		end
		if player.soniccanashura == true
		and player.isashura == true
			if player.ashurabouncing == true
				if player.mo.state == S_PLAY_ROLL
					player.mo.spritexscale = FRACUNIT/2
					player.mo.spriteyscale = FRACUNIT*2
				elseif P_IsObjectOnGround(player.mo)
					player.mo.spritexscale = FRACUNIT*2
					player.mo.spriteyscale = FRACUNIT/2
				end
			else
				player.mo.spritexscale = FRACUNIT
				player.mo.spriteyscale = FRACUNIT
			end
		end
		if not (player.cmd.buttons & BT_USE)
			player.ashuraboinghold = false
		end
		if player.soniccanashura == true
		and player.isashura == true
		and player.ashurabouncing != true
		and player.pflags & PF_JUMPED
		and player.playerstate == PST_LIVE
		and not P_IsObjectOnGround(player.mo)
		and player.cmd.buttons & BT_USE
		and player.ashuraboinghold != true
		and player.mo.skin != "adventuresonic"
		and player.mo.skin != "msonic"
		and player.mo.skin != "pointy"
			player.mo.state = S_PLAY_ROLL
			player.ashurabouncing = true
			player.mo.momz = -23*FRACUNIT*P_MobjFlip(player.mo)
			S_StartSound(player.mo, sfx_zoom, player)
			P_SpawnThokMobj(player)
			P_NukeEnemies(player.mo, player.mo, 1)
			player.ashuraboinghold = true
		end
		if player.ashurabouncing == true
		and P_IsObjectOnGround(player.mo)
			player.mo.state = S_PLAY_ROLL
			player.ashurabouncing = false
			player.mo.momz = 15*FRACUNIT*P_MobjFlip(player.mo)
			player.pflags = $|PF_JUMPED
			S_StartSound(player.mo, sfx_bnce2, player)
			P_NukeEnemies(player.mo, player.mo, 1)
		elseif player.ashurabouncing == true
		and player.mo.state == S_PLAY_ROLL
			if P_MobjFlip(player.mo) <= -1 and player.mo.momz < 0
			or P_MobjFlip(player.mo) >= 1 and player.mo.momz > 0
				player.ashurabouncing = false
				player.pflags = $|PF_JUMPED
				S_StartSound(player.mo, sfx_bnce2, player)
				P_NukeEnemies(player.mo, player.mo, 1)
			end
		elseif player.ashurabouncing == true
		and player.mo.state == S_PLAY_SPRING
			player.ashurabouncing = false
			player.mo.state = S_PLAY_ROLL
			player.pflags = $|PF_JUMPED
			S_StartSound(player.mo, sfx_bnce2, player)
			P_NukeEnemies(player.mo, player.mo, 1)
		end
		if player.soniccanashura == true
		and player.isashura == true
		and player.playerstate == PST_LIVE
			if player.mo.eflags & MFE_UNDERWATER
				if not P_IsObjectOnGround(player.mo)
					player.charability = CA_NONE
					if player.cmd.buttons & BT_JUMP
						if player.ashurajumphold != true
							player.pflags = $ & ~PF_JUMPED
							player.mo.momz = 5*FRACUNIT*P_MobjFlip(player.mo)
							player.mo.state = S_PLAY_SPRING
							S_StartSound(player.mo, sfx_bubbl4, player)
							player.ashurajumphold = true
						end
					else
						player.ashurajumphold = false
					end
				end
			else
				player.charability = CA_THOK
			end
		end
	end
end)