
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Daiyousei_AnimeLib.txt";
	
	tex_enemy=filedir~"Daiyousei_Main.png";
	
	@Initialize
	{
		SetLife(2500);
		SetTimer(25);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(120);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let lp=0;
			let w=3;
			let s=0;
			let i=rand(0,360);
			SetAction(ACT_SHOT_B,50);
			loop(12)
			{
				let way=20;
				let speed=[6-s,2];
				let ag=[-i,i];
				let angle=ag[lp%2];
				let ad=[0.6,-1.5];
				let gra=[68,69];
				let delay=10;
				while(angle<ag[lp%2]+360)
				{
					CreateShotA(1,GetX,GetY,delay);
					SetShotDataA(1,0,speed[0],angle,0,-(speed[0]/60),0,gra[lp%2]);
					SetShotDataA(1,100-lp*w,NULL,NULL,ad[lp%2]*r,speed[1]/80,speed[1],NULL);
					SetShotDataA(1,180,NULL,NULL,0,0,0,NULL);
					FireShot(1);
					angle+=360/way;
				}
				wait(w);
				s+=0.5;
				lp++;
				i+=(360/way)/3*r;
			}
			wait(60);
			let i=0;
			let s=0;
			let random=rand(70,110);
			SetAction(ACT_SHOT_A,60);
			loop(31)
			{
				let wide=[180,160];
				let way=[5,4];
				let ag=[-i,i];
				ascent(a in 0..2)
				{
					let speed=[1+s,2+s/4,3.4-s/4,2.5+s/2];
					let angle=90+ag[a];
					let gra=[24,22,72,70];
					let delay=[10,20];
					CreateShotA(1,GetX,GetY,delay[0]);
					SetShotDataA(1,0,speed[a],angle,0,-speed[a]/40,0,gra[a]);
					SetShotDirectionType(ABSOLUTE);
					
					let angleB=random-wide[a]/2;
					while(angleB<=random+wide[a]/2+1)
					{
						CreateShotA(2,0,0,delay[1]);
						SetShotDataA(2,0,0,angleB,0,speed[2+a]/30,speed[2+a],gra[2+a]);
						AddShot(40,1,2,0);
						angleB+=wide[a]/(way[a]-1);
					}
					
					SetShotKillTime(1,41);
					FireShot(1);
				}
				i+=5*r;
				s+=0.15;
				wait(2);
			}
			wait(70);
			let i=0;
			let s=0;
			loop(40)
			{
				let way=6;
				let speed=[1,2];
				let angle=0;
				let gra=108;
				let delay=10;
				while(angle<360)
				{
					ascent(a in 0..length(speed))
					{
						CreateShot01(GetX,GetY,speed[a]+s,angle+i,gra,delay);
					}
					angle+=360/way;
				}
				i+=10.05*r;
				s+=0.14;
				wait(3);
			}
			SetMove(cenX+rand(-100,100),minY+rand(110,140),120);
			wait(120);
		}
	}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(120);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let lp=0;
			let w=3;
			let s=0;
			let i=rand(0,360);
			SetAction(ACT_SHOT_B,50);
			loop(12)
			{
				let way=20;
				let speed=[5-s,1.2+s*1.5];
				let ag=[-i,i];
				let angle=ag[lp%2];
				let ad=[1.4,-0.6];
				let gra=[82,86];
				let delay=10;
				while(angle<ag[lp%2]+360)
				{
					CreateShotA(1,GetX,GetY,delay);
					SetShotDataA(1,0,speed[0],angle,0,-(speed[0]/60),0,gra[lp%2]);
					SetShotDataA(1,100-lp*w,NULL,NULL,ad[lp%2],(speed[1]-s/2)/120,speed[1]-s/2,NULL);
					SetShotDataA(1,180,NULL,NULL,0,0,0,NULL);
					FireShot(1);
					angle+=360/way;
				}
				wait(w);
				s+=0.3;
				lp++;
				i+=(360/way)/4*r;
			}
			wait(60);
			let i=0;
			let s=0;
			SetAction(ACT_SHOT_A,60);
			let random=rand(70,110);
			loop(15)
			{
				let ag=[-i,i];
				ascent(a in 0..2)
				{
					let way=[8,9];
					let wide=[140,150];
					let speed=[1+s,3+s,3+s,1.5+s];
					let angle=90+ag[a];
					let gra=[24,22,72,70];
					let delay=[10,20];
					CreateShotA(1,GetX,GetY,delay[0]);
					SetShotDataA(1,0,speed[a],angle,0,-speed[a]/40,0,gra[a]);
					SetShotDirectionType(PLAYER);
					let angleB=-wide[a]/2;
					while(angleB<=wide[a]/2)
					{
						CreateShotA(2,0,0,delay[1]);
						SetShotDataA(2,0,0,angleB,0,speed[2+a]/30,speed[2+a],gra[2+a]);
						AddShot(40,1,2,0);
						angleB+=wide[a]/(way[a]-1);
					}
					SetShotKillTime(1,41);
					FireShot(1);
				}
				i+=10;
				s+=0.14;
				wait(3);
			}
			wait(120);
			SetMove(cenX+rand(-100,100),minY+rand(110,140),120);
			let i=0;
			let s=0;
			loop(20)
			{
				let way=4;
				let speed=[1,2.4];
				let angle=0;
				let gra=105;
				let delay=10;
				while(angle<360)
				{
					ascent(a in 0..2)
					{
						CreateShot01(GetX,GetY,speed[a]+s,angle+i,gra,delay);
					}
					angle+=360/way;
				}
				i+=15*r;
				s+=0.12;
				wait(4);
			}
			wait(80);
			r=-r;
		}
	}
	
	
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(120);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let p=GetAngleToPlayer;
			SetAction(ACT_SHOT_B,50);
			loop(2)
			{
				let way=10;
				loop(3)
				{
					let sp=0;
					let wide=0;
					loop(12)
					{
						let speed=4-sp;
						let angle=p;
						let gra=85;
						let delay=10;
						while(angle<p+360)
						{
							WideShot(GetX,GetY,speed,angle,wide,gra,delay);
							angle+=360/way;
						}
						wide+=3;
						sp+=0.3;
					}
					wait(6);
				}
				p+=360/way/2;
				r=-r;
				wait(40);
				function WideShot(x,y,spd,ag,wide,gra,delay)
				{
					if(wide==0)
					{
						CreateShot01(x,y,spd,ag,gra,delay);
					}
					else
					{
						let angle=ag-wide/2;
						while(angle<=ag+wide/2+0.5)
						{
							CreateShot01(x,y,spd,angle,gra,delay);
							angle+=wide;
						}
					}
				}
			}
			wait(60);
			
			local
			{
				let i=0;
				let s=0;
				let p=GetAngleToPlayer;
				let random=[rand(-20,20),rand(-20,20)];
				SetAction(ACT_SHOT_A,60);
				loop(31)
				{
					
					let ag=[-i,i];
					ascent(a in 0..2)
					{
						let wide=[160,180];
						let way=[10,15];
						let speed=[1+s,3+s,1+s,4+s/2];
						let angle=p+ag[a];
						let gra=[19,20,83,84];
						let delay=[10,20];
						let limit=60;
						CreateShotA(1,GetX,GetY,delay[0]);
						SetShotDataA(1,0,speed[a],angle,0,-speed[a]/limit,0,gra[a]);
						SetShotDirectionType(ABSOLUTE);
						
						let angleB=p+random[a]-wide[a]/2;
						while(angleB<=p+random[a]+wide[a]/2+1)
						{
							CreateShotA(2,0,0,delay[1]);
							SetShotDataA(2,0,0,angleB,0,speed[2+a]/30,speed[2+a],gra[2+a]);
							AddShot(40,1,2,0);
							angleB+=wide[a]/(way[a]-1);
						}
						
						SetShotKillTime(1,limit+1);
						FireShot(1);
					}
					i+=5;
					s+=0.05;
					wait(2);
				}
			}
			wait(150);
			SetMove(cenX+rand(-100,100),minY+rand(110,140),120);
			let lp=0;
			loop(5)
			{
				let i=rand(0,360);
				let sp=0;
				loop(15)
				{
					let way=15;
					
					let speed=[2.6,3.6];
					let angle=i;
					let gra=[61,62];
					let delay=10;
					while(angle<i+360)
					{
						ascent(a in 0..2)
						{
							CreateShot01(GetX,GetY,speed[a]+sp,angle,gra[lp%length(gra)],delay);
						}
						angle+=360/way;
					}
					wait(2);
					sp+=0.1;
					i+=0.75*r;
				}
				wait(2);
				lp++;
				r=-r;
			}
			wait(60);
		}
	}
	
}