#TouhouDanmakufu
#Title[Last Word: The Empire's Fall]
#Text[...]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

let f = 0; 
	let f2 = 0;
	let f3 = 0;
	let f4 = 0;
	let slide = 0;
	let cut = GetCurrentScriptDirectory ~ "img\Cutin.png";
		let bg = GetCurrentScriptDirectory ~ "img\BG.png";
		let lay = GetCurrentScriptDirectory ~ "img\Lay.png";
		let imgBoss = GetCurrentScriptDirectory ~ "img\AkyuSprite.png";
		
	@Initialize{
	MagicCircle(true);
	LastSpell;
	
	LoadGraphic(imgBoss);
	Concentration01(100);
	PlayMusic(GetCurrentScriptDirectory ~ "bgm\AkyuLW.mp3");
		LoadGraphic(cut);
		LoadGraphic(bg);
		LoadGraphic(lay);
		SetLife(7000);
		SetTimer(110);
		SetScore(10000000);
		CutIn(YOUMU, "The Empire's Fall",cut,0,0,500,449);
		maintask;
	}

	@MainLoop{
		SetMovePosition01(GetCenterX, GetCenterY, 2);
		yield;
	}

	@DrawLoop{
	SetTexture(imgBoss);
		SetRenderState(ALPHA);
		SetAlpha(100);
	SetGraphicScale(1.25,1.25);
	if(f>=0 && f<5){SetGraphicRect(28,29,100,99);}
	if(f>=5 && f<10){SetGraphicRect(28,155,100,229);}
	if(f>=10 && f<20){SetGraphicRect(28,281,100,359);}
	f2 = 0;
	f++;
	if(f==20){
	f=0;
	f3 = 0;
	f4 = 0;
	}
	DrawGraphic(GetX,GetY);
	}

	@BackGround{
	SetTexture(bg);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,774,1032);
		SetGraphicScale(0.5,0.5);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
		
		SetTexture(lay);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,10000+slide,10000+slide);
		SetGraphicScale(0.25,0.25);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
	
		slide+=8;

	}

	@Finalize{
	FadeOutMusic(GetCurrentScriptDirectory ~ "bgm\AkyuSong.mp3",300);
	Explosion01(GetEnemyX,GetEnemyY,100,200,300);
	MotionBlur(ALL,1000,105);
	Slow(7);
	PlaySE(GetCurrentScriptDirectory ~ "se\se_focus.wav");
	wait(100);
	Slow(0);
	DeleteEnemyShotInCircle(ALL,GetCenterX,GetCenterY,240);
	DeleteGraphic(imgBoss);
	DeleteGraphic(cut);
	DeleteGraphic(bg);
	PlaySE(GetCurrentScriptDirectory ~ "se\se_enep01.wav");
	wait(180);
	}

	task maintask{
		fire;
		movement;

	}

	task movement{

			wait(120);
			Concentration01(550);
			PlaySE(GetCurrentScriptDirectory ~ "se\se_ch00.wav");
			wait(120);
			PlaySE(GetCurrentScriptDirectory ~ "se\se_ch00.wav");
			wait(120);
			Concentration02(310);
			PlaySE(GetCurrentScriptDirectory ~ "se\se_ch00.wav");
			wait(120);
			PlaySE(GetCurrentScriptDirectory ~ "se\se_ch00.wav");

	}

	task fire{
		let spin = 0;
		let x = 0;
		let dir = 0;
		let increase = 1;
		loop{
			while(x<36){
			
			CreateLaserA(1,GetCenterX+200*cos(dir),GetCenterY+200*sin(dir),500,6,AQUA05,60);
				SetLaserDataA(1,0,dir,0,1,1,dir*increase+270);
				SetShotKillTime(1,600);
				FireShot(1);
			PlaySE(GetCurrentScriptDirectory ~ "se\se_kira00.wav");
			PlaySE(GetCurrentScriptDirectory ~ "se\se_tan00.wav");
				
			CreateLaserA(2,GetCenterX+200*cos(dir),GetCenterY+200*sin(dir),500,6,AQUA05,60);
				SetLaserDataA(2,0,dir,0,1,1,dir*increase+90);
				SetShotKillTime(2,600);
				FireShot(2);
				
				wait(0);
				spin++;
				x++;
				dir+=360/36;
			}
			increase+=1;
			dir = 0;
			x = 0;
			if(spin==359){
				spin = 0;
			}
			wait(700);
		}
	}

	function wait(w){
		loop(w){yield;}
	}

}