
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Youmu_AnimeLib.txt";
	
	tex_enemy=filedir~"Youmu_Main.png";
	
	@Initialize
	{
		SetLife(3500);
		SetTimer(50);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+160,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(160);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let v=rand_int(40,60);
			let i=90+v/2*r;
			loop(2)
			{
				SetAction(ACT_CHARGE,60);
				Concentration01(60);
				wait(60);
				SetAction(ACT_SLASH_H,60);
				
				let angle=90+i;
				Set(GetX,GetY,angle);
				i-=v*r;
				wait(30);
			}
			
			task Set(let sx,let sy,let ag)
			{
				loop
				{
					let spd=10;
					if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
					sx+=spd*cos(ag);
					sy+=spd*sin(ag);
				}
				let angle=ag-180;
				let leng=580;
				SlashEffect(sx,sy,angle,leng,120);
				SetShot(sx,sy,angle);
			}
			task SetShot(let sx,let sy,let ag)
			{
				let spd=15;
				sx+=10*cos(ag);
				sy+=10*sin(ag);
				let stx=sx;
				let sty=sy;
				loop
				{
					CherryEffect(sx,sy);
					if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
					sx+=spd*cos(ag);
					sy+=spd*sin(ag);
					wait(1);
				}
				wait(60);
				sx=stx;
				sy=sty;
				let spd=40;
				let count=0;
				loop
				{
					local
					{
						let way=2;
						let speed=4;
						let gra=116;
						let delay=0;
						while(speed>=0.8)
						{
							let angle=ag-90;
							while(angle<ag+270)
							{
								CreateShot01(sx,sy,speed,angle,gra,delay);
								angle+=360/way;
							}
							speed/=1.4;
						}
						
					}
					
					if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
					sx+=spd*cos(ag);
					sy+=spd*sin(ag);
					count++;
					wait(1);
				}
			}
			let wt=120;
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(150,180),0,0,0,0,wt);
			SetAction(ACT_MOVE,wt);
			let L=8;
			let p=GetAngleToPlayer;
			let way=1;
			let wide=0;
			loop(L)
			{
				let ag=p;
				while(ag<p+360)
				{
					let speed=3;
					let gra=177;
					let delay=10;
					if(way==1)
					{
						let angle=ag;
						CreateShot02(GetX,GetY,0,angle,speed/100,speed,gra,delay);
					}
					else
					{
						let angle=ag-wide/2;
						while(angle<=ag+wide/2+1)
						{
							CreateShot02(GetX,GetY,0,angle,speed/100,speed,gra,delay);
							angle+=wide/(way-1);
						}
					}
					ag+=360/3;
				}
				way++;
				wide+=15;
				wait(wt/L);
			}
			wait(60);
			r=-r;
		}
		
	}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+140,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(160);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let v=rand_int(40,60);
			let i=90+v/2*r;
			let lp=0;
			loop(2)
			{
				SetAction(ACT_CHARGE,60);
				Concentration01(60);
				wait(60);
				SetAction(ACT_SLASH_H,60);
				
				let angle=90+i;
				Set(GetX,GetY,angle,lp);
				i-=v*r;
				lp++;
				wait(30);
			}
			
			task Set(let sx,let sy,let ag,let t)
			{
				loop
				{
					let spd=10;
					if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
					sx+=spd*cos(ag);
					sy+=spd*sin(ag);
				}
				let angle=ag-180;
				let leng=580;
				SlashEffect(sx,sy,angle,leng,120);
				SetShot(sx,sy,angle,t);
			}
			task SetShot(let sx,let sy,let ag,let type)
			{
				let spd=15;
				sx+=10*cos(ag);
				sy+=10*sin(ag);
				let stx=sx;
				let sty=sy;
				loop
				{
					CherryEffect(sx,sy);
					if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
					sx+=spd*cos(ag);
					sy+=spd*sin(ag);
					wait(1);
				}
				wait(60);
				sx=stx;
				sy=sty;
				let spd=30;
				let count=0;
				loop
				{
					let leng=GetGapLength(sx,sy,GetPlayerX,GetPlayerY);
					let px=GetGapX(sx,leng,atan2(GetPlayerY-sy,GetPlayerX-sx));
					let py=GetGapY(sy,leng/1.4,atan2(GetPlayerY-sy,GetPlayerX-sx));
					local
					{
						let p=atan2(py-sy,px-sx);
						let way=3;
						let wide=90;
						if(type)
						{
							way=4;
							wide=90;
						}
						let speed=4.5;
						let gra=[113,118];
						let delay=0;
						while(speed>=1.2)
						{
							let angle=p-wide/2;
							while(angle<=p+wide/2+1)
							{
								CreateShot01(sx,sy,speed,angle,gra[type%length(gra)],delay);
								angle+=wide/(way-1);
							}
							speed/=1.2;
						}
						
					}
					
					if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
					sx+=spd*cos(ag);
					sy+=spd*sin(ag);
					count++;
					wait(1);
				}
			}
			wait(60);
			let wt=150;
			SetMovePosition02(cenX+rand(-80,80),minY+rand(150,180),wt);
			SetAction(ACT_MOVE,wt);
			let L=10;
			let p=GetAngleToPlayer;
			loop(L)
			{
				let wide=20;
				let speed=[3,1];
				let angle=p;
				let gra=[179,181];
				let delay=10;
				CreateShot02(GetX,GetY,0,angle,speed[0]/100,speed[0],gra[0],delay);
				
				let angle=p-wide/2;
				while(angle<=p+wide/2+1)
				{
					CreateShot02(GetX,GetY,0,angle,speed[1]/100,speed[1],gra[1],delay);
					angle+=wide;
				}
				wait(wt/L);
			}
			wait(40);
			r=-r;
		}
	}
	
	
	
	task MainThread_Unlimited{}
	
}