
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Yuka_AnimeLib.txt";
	
	tex_enemy=filedir~"Yuka_Main.png";
	tex_spellbg=filedir~"Yuka_SpellBG.png";
	
	bg_rect=[0,0,768,512];
	
	@Initialize
	{
		point=420;
		SetLife(700);
		SetTimer(37);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+100,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("魔庭「ファントムガーデン」",12);
		wait(100);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		Sub;
		let lp=0;
		loop
		{
			local
			{
				let i=11;
				let setx=[-150,150,180,-180];
				let sety=[minY,minY,maxY,maxY];
				let py=[i,i,-i,-i];
				SetShot(cenX+setx[lp],sety[lp],py[lp]);
				wait(110);
				lp=(lp+1)%length(setx);
			}
			
			task SetShot(let sx,let sy,let py)
			{
				let i=0;
				while(absolute(i)<460)
				{
					let rd=3;
					Mine(sx+rand(-rd,rd),sy+i+rand(-rd,rd));
					i+=py;
					wait(1);
				}
				
				task Mine(let sx,let sy)
				{
					let limit=90;
					
					let gra=195;
					CreateShotA(1,sx,sy,20);
					SetShotDataA(1,0,0,0,0,0,0,gra);
					SetShotKillTime(1,limit);
					FireShot(1);
					wait(limit);
					let way=4;
					let p=90+rand_int(-1,1)*5;
					let speed=rand(1.2,1.5);
					let angle=p;
					let gra=87;
					let delay=10;
					while(angle<p+360)
					{
						CreateShot02(sx,sy,0,angle,speed/100,speed,gra,delay);
						angle+=360/way;
					}
				}
			}
		}
		
		task Sub
		{
			wait(40);
			let lp=0;
			loop
			{
				SetAction(ACT_SHOT_A,90);
				loop(3)
				{
					let way=36;
					let limit=60;
					let leng=35;
					let p=rand(0,360);
					let speed=[2.5];
					let sch=2*r;
					let angle=p;
					let gra=[33,38];
					let delay=30;
					while(angle<p+360)
					{
						let sx=GetX+leng*cos(angle);
						let sy=GetY+leng*sin(angle);
						CreateShotA(1,sx,sy,delay);
						SetShotDataA(1,0,0,angle-90*r,sch,speed[lp%length(speed)]/limit,speed[lp%length(speed)],gra[lp%length(gra)]);
						SetShotDataA(1,limit,NULL,NULL,0,0,0,NULL);
						FireShot(1);
						angle+=360/way;
					}
					wait(20);
					r=-r;
					lp++;
				}
				
				wait(60);
				SetMove(cenX+rand(-100,100),minY+rand(90,120),180);
				wait(180);
				
				r=-r;
			}
		}
	}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+90,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("燐庭「パラサイトガーデン」",13);
		wait(100);
		
		SubShot;
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetShot(cenX+rand(-80,80),cenY+rand(-80,80),r);
			task SetShot(let px,let py,let rb)
			{
				SetTargeting(px,py,0.75,240,0);
				let way=5;
				let p=rand(0,360);
				let lp=0;
				let leng=340;
				while(leng>0)
				{
					let ag=p;
					while(ag<p+360)
					{
						let sx=px+leng*cos(ag);
						let sy=py+leng*sin(ag);
						
						if(!(lp%2))
						{
							let speed=1;
							let angle=ag+110*rb;
							let gra=66;
							let delay=15;
							CreateShot02(sx,sy,0,angle,speed/120,speed,gra,delay);
						}
						let rd=10;
						Mine(sx+rand(-rd,rd),sy+rand(-rd,rd));
						ag+=360/way;
					}
					leng+=-5;
					p+=4*rb;
					lp++;
					wait(4);
				}
				task Mine(let sx,let sy)
				{
					let way=3;
					let p=rand(0,360);
					let angle=p;
					let gra=83;
					let delay=20;
					let limit=80;
					while(angle<p+360)
					{
						CreateShotA(1,sx,sy,delay);
						SetShotDataA(1,0,0,angle,0,0,0,gra);
						SetShotKillTime(1,limit);
						FireShot(1);
						angle+=360/way;
					}
					wait(limit+delay);
					loop(3)
					{
						CreateShotA(1,sx,sy,10);
						SetShotDataA(1,0,0,0,0,0,0,gra);
						SetShotKillTime(1,0);
						FireShot(1);
					}
				}
			}
			wait(240);
			r=-r;
		}
		task SubShot
		{
			wait(100);
			loop
			{
				SetAction(ACT_SHOT_A,90);
				loop(3)
				{
					let speed=1;
					let angle=GetAngleToPlayer;
					let gra=33;
					let delay=10;
					CreateShot02(GetX,GetY,speed*10,angle,-speed/4,speed,gra,delay);
					wait(30);
				}
				SetMove(cenX+rand(-100,100),minY+rand(90,120),180);
				wait(180);
			}
		}
	}
	
	
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+130,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("死庭「プランターサクリファイス」",14);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_B,100);
			let lp=0;
			loop(2)
			{
				let way=30;
				let limit=60;
				let leng=20;
				let p=rand(0,360);
				let speed=2;
				let sch=4*r;
				let angle=p;
				let gra=[33,38];
				let delay=30;
				while(angle<p+360)
				{
					let sx=GetX+leng*cos(angle);
					let sy=GetY+leng*sin(angle);
					CreateShotA(1,sx,sy,delay);
					SetShotDataA(1,0,0,angle-90*r,sch,speed/limit,speed,gra[lp%length(gra)]);
					SetShotDataA(1,limit,NULL,NULL,0,0,0,NULL);
					FireShot(1);
					angle+=360/way;
				}
				r=-r;
				lp++;
			}
			let i=0;
			let leng=20;
			while(leng<400)
			{
				let way=[2,6];
				
				let p=[i*5,-i];
				let speed=[1.5,1.9];
				let gra=[81,87];
				ascent(a in 0..2)
				{
					let ag=p[a];
					while(ag<p[a]+360)
					{
						let rd=4;
						let limit=90;
						if(!a){rd=0;limit=60;}
						let sx=GetX+leng*cos(ag);
						let sy=(GetY+24)+leng*sin(ag);
						let spd=speed[a]+rand(-0.1,0.1);
						let ag_=[-20*r,160*r];
						let angle=ag+ag_[a]+rand(-rd,rd);
						let delay=20;
						
						
						CreateShotA(1,sx,sy,delay);
						SetShotDataA(1,0,0,angle,0,0,0,gra[a]);
						SetShotDataA(1,limit,NULL,NULL,0,spd/200,spd,NULL);
						FireShot(1);
						
						ag+=360/way[a];
					}
				}
				i+=1*r;
				leng+=1.5;
				wait(1);
			}
			r=-r;
			SetMove(cenX+rand(-100,100),minY+rand(120,140),180);
			wait(180);
		}
	}
	
}
