#TouhouDanmakufu
#Title[Spellcard 5: Legend of the Gods - Divine Intervention]
#Text[...]
#BackGround[User(.\img\Background.png,1,1)]
#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{
	LoadGraphic(imgBoss);
		LoadGraphic(cut);
		LoadGraphic(bg);
		LoadGraphic(lay);
		SetLife(6000);
		SetTimer(75);
		SetScore(1000000);
		
		CutIn(YOUMU, "Legend of the Gods - Divine Intervention",cut,0,0,500,449);
		maintask;
	}

	@MainLoop{
		SetMovePosition01(GetCenterX, GetCenterY, 5);
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 16);
		yield;
	}

	@DrawLoop{
	SetTexture(imgBoss);
	SetGraphicScale(1,1);
	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);
	DeleteEnemyShotInCircle(ALL,GetCenterX,GetCenterY,240);
	Explosion01(GetEnemyX,GetEnemyY,10,20,1000);
	MotionBlur(ALL,1000,255);
	Slow(7);
	wait(290);
	Slow(0);
	VanishEnemy;
	DeleteGraphic(cut);
	DeleteGraphic(bg);
	wait(180);

	}

	task maintask{
		wait(120);
		yield;
		fire;
		movement;
		sound;
		sound2;
		sound3;

	}
	
	task sound{
		loop{
			PlaySE(GetCurrentScriptDirectory ~ "se\se_kira01.wav");
			wait(300);
		}
	}
	
	task sound2{
		wait(139);
		loop{
			PlaySE(GetCurrentScriptDirectory ~ "se\se_enep02.wav");
			wait(300);
		}
	}
	
	task sound3{
		wait(300);
		loop{
			PlaySE(GetCurrentScriptDirectory ~ "se\se_kira00.wav");
			wait(300);
		}
	}

	task movement{
		loop{
			
			yield;
		}


	}

	task fire{
		let x = 0;
		let dir = 0;
		let spin = 5;
		loop{
		loop(3){
		while(x<100){
			CreateShotA(1,GetCenterX+200*cos(dir+spin/15),GetCenterY+30*sin(dir+spin/15),20);
			SetShotDataA(1,0,spin/spin,dir+spin/15+180,0,0,4,YELLOW05);
			SetShotDataA(1,118,1,rand_int(1,359),2,0,4,PURPLE05);
			SetShotDataA(1,300,0,NULL,0,0.04,2,RED05);
			FireShot(1);
			
			CreateShotA(2,GetCenterX+30*cos(dir+spin/15),GetCenterY+200*sin(dir+spin/15),20);
			SetShotDataA(2,0,spin/spin,dir+spin/15+180,0,0,4,GREEN05);
			SetShotDataA(2,118,1,rand_int(1,359),2,0,4,PURPLE05);
			SetShotDataA(2,300,0,NULL,0,0.04,2,RED05);
			FireShot(2);
			


			spin++;
			x++;
			dir+=360/100;


			wait(0);
		}
		yield;
		dir = 0;
		x = 0;
		if(spin == 359){
				spin = 0;
				yield;
			}
		}
		wait(300);
		}


	}

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

}