#TouhouDanmakufu
#Title[Nonspell 2]
#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 imgBoss = GetCurrentScriptDirectory ~ "img\AkyuSprite.png";
		
	@Initialize{
	LoadGraphic(imgBoss);
		SetLife(4000);
		SetTimer(40);
		maintask;

	}

	@MainLoop{
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 16);
		SetMovePosition03(GetCenterX, GetCenterY-0, 10,5);
		yield;
	}

	@DrawLoop{
	SetTexture(imgBoss);
	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{


	}

	@Finalize{


	}

	task maintask{
		wait(120);
		yield;
		fire;
		movement;
		sound;
	}
	
	task sound{
		loop{
			PlaySE(GetCurrentScriptDirectory ~ "se\se_kira00.wav");
		wait(520);
		}
	}

	task movement{
		loop{
			SetMovePosition01(GetCenterX, GetCenterY-0, 2);
			wait(10000);
			SetMovePosition01(GetCenterX-50, GetCenterY-30, 10);
			wait(100);
			SetMovePosition01(GetCenterX, GetCenterY-60, 10);
			wait(100);
			SetMovePosition01(GetCenterX+50, GetCenterY-30, 10);
			wait(100);
			yield;
		}
	}

	task fire{
		let x = 0;
		let dir = 0;
		let spin = 0;
		
		loop{
			while(x<9){
				CreateShotA(1,GetEnemyX+60*cos(dir+180), GetEnemyY+60*sin(dir+180), 15);
				SetShotDataA(1, 10, 0.0, (spin/3)+dir, 0, 0.1, 4, RED21);
				SetShotDataA(1, 30, 4, NULL, 0, 0.1, 4, ORANGE21);
				SetShotDataA(1, 50, 4, NULL, 0, 0.1, 4, YELLOW21);
				SetShotDataA(1, 70, 4, NULL, 0, 0.1, 4, GREEN21);
				SetShotDataA(1, 90, 4, NULL, 0, 0.1, 4, AQUA21);
				SetShotDataA(1, 110, 4, NULL, 0, 0.1, 4, BLUE21);
				SetShotDataA(1, 130, 4, NULL, 0, 0.1, 4, PURPLE21);
				SetShotDataA(1, 150, 4, NULL, 0, 0.1, 4, RED21);
				SetShotDataA(1, 170, 4, NULL, 0, 0.1, 4, ORANGE21);
				FireShot(1);

				CreateShotA(2,GetEnemyX+60*cos(-dir), GetEnemyY+60*sin(-dir), 15);
				SetShotDataA(2, 10, 4, (spin/3)-dir, 0, 0.1, 3, RED21);
				SetShotDataA(2, 30, 4, NULL, 0, 0.1, 4, ORANGE21);
				SetShotDataA(2, 50, 4, NULL, 0, 0.1, 4, YELLOW21);
				SetShotDataA(2, 70, 4, NULL, 0, 0.1, 4, GREEN21);
				SetShotDataA(2, 90, 4, NULL, 0, 0.1, 4, AQUA21);
				SetShotDataA(2, 110, 4, NULL, 0, 0.1, 4, BLUE21);
				SetShotDataA(2, 130, 4, NULL, 0, 0.1, 4, PURPLE21);
				SetShotDataA(2, 150, 4, NULL, 0, 0.1, 4, RED21);
				SetShotDataA(2, 170, 4, NULL, 0, 0.1, 4, ORANGE21);
				FireShot(2);

				dir+=360/9;
				x++;
				spin++;
			}
			x = 0;
			dir = 0;
			if(spin == 359){
				spin = 0;
				spin++;
				yield;
			}
			wait(8);
			yield;
		}
	}

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

}

	