
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Komachi_AnimeLib.txt";
	
	tex_enemy=filedir~"Komachi_Main.png";
	
	@Initialize
	{
		SetLife(6500);
		SetTimer(59);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	

	
	
	
	
	task MainThread_Standard{}
	task MainThread_Advanced{}
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+150,0,0,0,0,200);
		wait(220);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let lp=0;
		loop
		{
			
			let lp=0;
			loop(2)
			{
				SetMovePositionHermite(cenX+rand(-30,30),minY+rand(140,160),0,0,0,0,40);
				SetAction(ACT_MOVE,40);
				let sp=0;
				let p=rand(0,360);
				loop(60)
				{
					let way=9;
					
					let speed=0.6+sp;
					let angle=p;
					let gra=[249,248];
					let delay=5;
					while(angle<p+360)
					{
						let v=20;
						let sx=GetX+v*cos(angle);
						let sy=GetY+v*sin(angle);
						CreateShot01(sx,sy,speed,angle,gra[lp%2],delay);
						angle+=360/way;
					}
					p+=8*r;
					sp+=0.2;
					wait(2);
				}
				r=-r;
				lp++;
			}
			//*/
			SetMovePositionHermite(cenX,minY+100,0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			wait(100);
			
			SetAction(ACT_SHOT_A,500);
			Sub;
			let lp=0;
			loop(22)
			{
				let p=rand(80,100);
				let wide=200+20*(lp%2);
				let way=35+lp%2;
				let sp=0;
				loop(9)
				{
					let speed=3+sp;
					let angle=p-wide/2;
					let gra=70;
					let delay=10;
					while(angle<=p+wide/2+1)
					{
						let v=80;
						let sx=GetX+(v*2)*cos(angle);
						let sy=GetY+(v/5)*sin(angle);
						CreateShot01(sx,sy,speed,angle,gra,delay);
						angle+=wide/(way-1);
					}
					sp+=0.2;
					wait(4);
				}
				local
				{
					let p=GetAngleToPlayer;
					let way=45;
					
					let speed=4;
					let angle=p;
					let gra=249;
					let delay=10;
					while(angle<p+360)
					{
						CreateShot01(GetX,GetY,speed,angle,gra,delay);
						angle+=360/way;
					}
				}
				lp++;
	//			wait(12);
			}
			task Sub
			{
				wait(60);
				loop(8)
				{
					let speed=3;
					let angle=90+120*r;
					SetShot(GetX,GetY,speed,angle);
					wait(90);
					r=-r;
				}
				
				task SetShot(let sx,let sy,let spd,let ag)
				{
					let way=30;
					let p=rand(0,360);
					loop(25)
					{
						let speed=[3.5,2.5];
						let angle=p;
						let gra=[248,250];
						let delay=10;
						let a=0;
						while(angle<p+360)
						{
							CreateShot01(sx,sy,speed[a],angle,gra[a],delay);
							a=(a+1)%2;
							angle+=360/way;
						}
						
						sx+=spd*cos(ag);
						sy+=spd*sin(ag);
						wait(2);
					}
				}
			}
			wait(60);
		}
	}
	
}