#TouhouDanmakufu
#Title[Nonspell 3]
#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";

		let dir = 0;

	@Initialize{
	LoadGraphic(imgBoss);
		SetLife(4000);
		SetTimer(70);
		maintask;
	}

	@MainLoop{
		SetMovePosition01(GetCenterX, GetCenterY-130, 2);
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 16);
		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;
		movement;
		sound;
		loop{
			fire;
			wait(900);
		}
	}
	
	task sound{
		wait(670);
		loop{
			PlaySE(GetCurrentScriptDirectory ~ "se\se_kira01.wav");
			wait(31);
		}
	}

	task movement{
		SetMovePosition03(GetCenterX, GetCenterY-130, 10,5);
	}

	task fire{
		let x = 0;
		let dir = 0;
		let spin = 0;
		
		loop{
			while(x<2){	
				PlaySE(GetCurrentScriptDirectory ~ "se\se_tan01.wav");
				CreateShotA(1,GetCenterX+spin*3*cos(dir), GetCenterY-300+spin*3*sin(dir), 15);
				SetShotDataA(1, 0, 0, dir+spin*1+180,0, 0.1, 0.0, RED05);
				SetShotDataA(1, 240, 0, dir+spin*3+170,-4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(1, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(1, 700, 0, NULL,0, 0.1, 0.5, PURPLE05);
				FireShot(1);
				
				CreateShotA(6,GetCenterX+spin*3*cos(dir), GetCenterY-200+spin*3*sin(dir), 15);
				SetShotDataA(6, 0, 0, dir+spin*1+180,0, 0.1, 0.0, RED05);
				SetShotDataA(6, 240, 0, dir+spin*3+170,-4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(6, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(6, 700, 0, NULL,0, 0.1, 0.5, PURPLE05);
				FireShot(6);
				
				CreateShotA(7,GetCenterX+spin*3*cos(dir), GetCenterY-100+spin*3*sin(dir), 15);
				SetShotDataA(7, 0, 0, dir+spin*1+180,0, 0.1, 0.0, RED05);
				SetShotDataA(7, 240, 0, dir+spin*3+170,-4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(7, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(7, 700, 0, NULL,0, 0.1, 0.5, PURPLE05);
				FireShot(7);
				
				CreateShotA(8,GetCenterX+spin*3*cos(dir), GetCenterY+spin*3*sin(dir), 15);
				SetShotDataA(8, 0, 0, dir+spin*1+180,0, 0.1, 0.0, RED05);
				SetShotDataA(8, 240, 0, dir+spin*3+170,-4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(8, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(8, 700, 0, NULL,0, 0.1, 0.5, PURPLE05);
				FireShot(8);
				
				CreateShotA(8,GetCenterX+spin*3*cos(dir), GetCenterY+100+spin*3*sin(dir), 15);
				SetShotDataA(8, 0, 0, dir+spin*1+180,0, 0.1, 0.0, RED05);
				SetShotDataA(8, 240, 0, dir+spin*3+170,-4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(8, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(8, 700, 0, NULL,0, 0.1, 0.5, PURPLE05);
				FireShot(8);
				
				CreateShotA(9,GetCenterX+spin*3*cos(dir), GetCenterY+200+spin*3*sin(dir), 15);
				SetShotDataA(9, 0, 0, dir+spin*1+180,0, 0.1, 0.0, RED05);
				SetShotDataA(9, 240, 0, dir+spin*3+170,-4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(9, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(9, 700, 0, NULL,0, 0.1, 0.5, PURPLE05);
				FireShot(9);
				
				CreateShotA(10,GetCenterX+spin*3*cos(dir), GetCenterY+300+spin*3*sin(dir), 15);
				SetShotDataA(10, 0, 0, dir+spin*1+180,0, 0.1, 0.0, WHITE05);
				SetShotDataA(10, 240, 0, dir+spin*3+170,-4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(10, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(10, 700, 0, NULL,0, 0.1, 0.5, PURPLE05);
				FireShot(10);

				CreateShotA(5,GetCenterX+spin*3*cos(dir), GetCenterY-300+spin*3*sin(dir), 15);
				SetShotDataA(5, 0, 0, dir-spin*1-180,0, 0.1, 0, RED05);
				SetShotDataA(5, 240, 0, dir-spin*3-170,4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(5, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(5, 700, 0, NULL,0, -0.1, 0.5, PURPLE05);
				FireShot(5);
				
				CreateShotA(11,GetCenterX+spin*3*cos(dir), GetCenterY-200+spin*3*sin(dir), 15);
				SetShotDataA(11, 0, 0, dir-spin*1-180,0, 0.1, 0, RED05);
				SetShotDataA(11, 240, 0, dir-spin*3-170,4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(11, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(11, 700, 0, NULL,0, -0.1, 0.5, PURPLE05);
				FireShot(11);
				
				CreateShotA(12,GetCenterX+spin*3*cos(dir), GetCenterY-100+spin*3*sin(dir), 15);
				SetShotDataA(12, 0, 0, dir-spin*1-180,0, 0.1, 0, RED05);
				SetShotDataA(12, 240, 0, dir-spin*3-170,4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(12, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(12, 700, 0, NULL,0, -0.1, 0.5, PURPLE05);
				FireShot(12);
				
				CreateShotA(13,GetCenterX+spin*3*cos(dir), GetCenterY+spin*3*sin(dir), 15);
				SetShotDataA(13, 0, 0, dir-spin*1-180,0, 0.1, 0, RED05);
				SetShotDataA(13, 240, 0, dir-spin*3-170,4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(13, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(13, 700, 0, NULL,0, -0.1, 0.5, PURPLE05);
				FireShot(13);
				
				CreateShotA(14,GetCenterX+spin*3*cos(dir), GetCenterY+100+spin*3*sin(dir), 15);
				SetShotDataA(14, 0, 0, dir-spin*1-180,0, 0.1, 0, RED05);
				SetShotDataA(14, 240, 0, dir-spin*3-170,4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(14, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(14, 700, 0, NULL,0, -0.1, 0.5, PURPLE05);
				FireShot(14);
				
				CreateShotA(15,GetCenterX+spin*3*cos(dir), GetCenterY+200+spin*3*sin(dir), 15);
				SetShotDataA(15, 0, 0, dir-spin*1-180,0, 0.1, 0, RED05);
				SetShotDataA(15, 240, 0, dir-spin*3-170,4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(15, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(15, 700, 0, NULL,0, -0.1, 0.5, PURPLE05);
				FireShot(15);
				
				CreateShotA(16,GetCenterX+spin*3*cos(dir), GetCenterY+300+spin*3*sin(dir), 15);
				SetShotDataA(16, 0, 0, dir-spin*1-180,0, 0.1, 0, RED05);
				SetShotDataA(16, 240, 0, dir-spin*3-170,4.1, 0.1, 1.0, YELLOW05);
				SetShotDataA(16, 670, 0, NULL,0, 0, 0, GREEN05);
				SetShotDataA(16, 700, 0, NULL,0, -0.1, 0.5, PURPLE05);
				FireShot(16);

				dir+=360/2;
				x++;
				spin++;
			}
			x = 0;
			dir = 0;
			if(spin == 201){
			spin = 0;
			yield;
			}
			wait(30);
			yield;
		}
	}

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

}

	