script_enemy_main
{

	//Oh god it's so nice to be able to use comments again
	let frame = 0;
	let attack = false;
	
	//DEFINE DEM IMAGES
	let bkg = GetCurrentScriptDirectory ~ "c6/enem2bg2.png";
	let bkg2 = GetCurrentScriptDirectory ~ "c6/enem2bg1.png";
	let boss = GetCurrentScriptDirectory ~ "c6/enem2.png";
	
    @Initialize
	{
		LoadUserShotData(GetCurrentScriptDirectory ~ "c6/c6shots.txt");
		LoadGraphic(bkg);
		LoadGraphic(bkg2);
		LoadGraphic(boss);
		
		SetLife(4000);
		SetTimer(90);
		SetScore(100000);
		SetInvincibility(180);
		SetDamageRate(90, 0);
		//MagicCircle(false);
		CutIn(KOUMA, "Perish Trap", bkg, 0, 0, 0, 0);
		
		SetMovePosition02(-10, -10, 0);
		
		intro;
    }

    @MainLoop
	{
		SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
		
		frame++;
		yield;
    }

    @DrawLoop
	{
		//Background
		SetTexture(bkg);
		SetGraphicAngle(0, 0, 0);
		SetGraphicScale(1, 1);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicRect(0, 0, -1024-frame, -1024-frame);
		DrawGraphic(GetCenterX, GetCenterY);
		
		SetTexture(bkg2);
		SetColor(200,200,255);
		SetGraphicRect(0, 0, 512, 512+2*frame);
		SetAlpha(230);
		DrawGraphic(GetCenterX,GetCenterY);
		
		SetTexture(boss);
		SetAlpha(255);
		SetColor(255,255,255);
		//Yamame
		if(!attack)
		{
			if(GetSpeedX<-0.2 && GetSpeedX>=-1){
				SetGraphicRect(64, 128, 128, 192);
				SetGraphicAngle(180, 0, 0);
			}else if(GetSpeedX<-1){
				SetGraphicRect(192, 128, 256, 192);
				SetGraphicAngle(180, 0, 0);
			}else if(GetSpeedX>0.2 && GetSpeedX<=1){
				SetGraphicRect(64, 128, 128, 192);
				SetGraphicAngle(0, 0, 0);
			}else if(GetSpeedX>1){
				SetGraphicRect(192, 128, 256, 192);
				SetGraphicAngle(0, 0, 0);
			}else{
				SetGraphicRect(0, 128, 64, 192);
			}
		}
		else{SetGraphicRect(192, 192, 255, 255);}
		DrawGraphic(GetX,GetY+5*cos(frame*2));
    }

    @Finalize
	{
		FadeOutMusic(GetCurrentScriptDirectory ~ "bgm/VUVUZATSUZA.mp3", 20);
    }
	
	function Wait(frames){loop(frames){yield;}}
	
	task intro
	{
		PlaySE(GetCurrentScriptDirectory ~ "sfx/crash.wav");
		CreateEnemyFromFile(GetCurrentScriptDirectory ~ "kisume.txt", GetCenterX, 350, 0, 0, 0);
		Wait(10);
		SetMovePosition03(GetCenterX, GetCenterY - 120, 15, 5);
		Wait(60);
		Concentration01(90);
		PlaySE(GetCurrentScriptDirectory ~ "sfx/se_ch00.wav");
		Wait(90);
		attack = true;
		PlayMusic(GetCurrentScriptDirectory ~ "bgm/VUVUZATSUZA.mp3");
		Wait(310);
		CutIn(KOUMA, "Oh fuck it", bkg, 0, 0, 0, 0);
		loop{
			let r = rand(0,10);
			ascent(l in 0..36){CreateShot02(GetX, GetY, 2, GetAngleToPlayer+l*360/36 + r, 1, 10, 50, 10);}
			Wait(3);
		}
	}
}