#TouhouDanmakufu
#Title[Nonspell 1]
#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;
		let decrease = 500;
		

	@Initialize{
	LoadGraphic(imgBoss);
		SetLife(3000);
		SetTimer(50);
		SetMovePosition03(GetCenterX, GetCenterY, 10,5);
		wait(160);
		maintask;
	}

	@MainLoop{
		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(90);
		yield;
		fire;	
		fire2;

	}

	task fire2{
		loop{
			yield;
			CreateShot01(GetEnemyX, GetEnemyY, 5, GetAngleToPlayer+180, WHITE32, 10);
			CreateShot01(GetEnemyX, GetEnemyY, 5, GetAngleToPlayer+120, WHITE32, 10);
			CreateShot01(GetEnemyX, GetEnemyY, 5, GetAngleToPlayer+60, WHITE32, 10);
			CreateShot01(GetEnemyX, GetEnemyY, 5, GetAngleToPlayer, WHITE32, 10);
			CreateShot01(GetEnemyX, GetEnemyY, 5, GetAngleToPlayer-60, WHITE32, 10);
			CreateShot01(GetEnemyX, GetEnemyY, 5, GetAngleToPlayer-120, WHITE32, 10);
			CreateShot01(GetEnemyX, GetEnemyY, 5, GetAngleToPlayer-180, WHITE32, 10);
		}
	}
	task fire{
		let x = 0;
		let dir = 0;
		
		loop{
			while(x<50){
				CreateShotA(1,GetEnemyX+50*cos(dir), GetEnemyY+50*sin(dir), 15);
				PlaySE(GetCurrentScriptDirectory ~ "se\se_kira01.wav");
				SetShotDataA(1, 15, 10, dir+170, 0, -0.5, 0, RED21);
				SetShotDataA(1, 200, 2, dir-170, -3, 0, 2, GREEN21);
				SetShotDataA(1, 700, 1, dir+10, 2, 0, 7, YELLOW21);
				SetShotDataA(1, 1000, 4, dir, 0, 0, 4, PURPLE21);
			

				FireShot(1);

				dir+=360/36;
				x++;
				decrease--;
			}
			x = 0;
			dir = 0;
			wait(decrease/1.75);
			
			if(decrease == 0){
			decrease = 100;
			}
			yield;
		}
	}

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

}

	