
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Youmu_AnimeLib.txt";
	
	tex_enemy=filedir~"Youmu_Main.png";
	tex_spellbg=filedir~"Youmu_SpellBG.png";
	
	bg_rect=[0,0,512,768];
	
	@Initialize
	{
		point=450;
		SetLife(600);
		SetTimer(49);
		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);
		SetSpellCard("仏陀剣「四諦八正道」",54);
		wait(100);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let wt=60;
			SetAction(ACT_CHARGE,wt);
			Concentration01(wt);
			wait(wt);
			let p=GetAngleToPlayer;
			SetTargeting(GetPlayerX,GetPlayerY,0.5,120,0);
			local
			{
				SetAction(ACT_SLASH_H,60);
				let leng=580;
				let del=100;
				let wide=140;
				loop(2)
				{
					let angle=p-wide/2;
					while(angle<=p+wide/2+1)
					{
						SlashEffect(GetX,GetY,angle,leng,del);
						SetShot(GetX,GetY,angle);
						angle+=wide;
					}
					
					wide+=100;
				}
				
				task SetShot(let sx,let sy,let ag)
				{
					let stx=sx;
					let sty=sy;
					let spd=10;
					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(40);
					sx=stx;
					sy=sty;
					spd=20;
					loop
					{
						local
						{
							let p=atan2(GetPlayerY-sy,GetPlayerX-sx);
							let way=10;
							let speed=2.5;
							let angle=p;
							let sch=4;
							let gra=119;
							let delay=5;
							while(angle<p+360)
							{
								CreateShotA(1,sx,sy,delay);
								SetShotDataA(1,0,speed,angle,sch,0,0,gra);
								SetShotDataA(1,360/sch,NULL,NULL,0,0,0,gra);
								FireShot(1);
								angle+=360/way;
							}
						}
						if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
						sx+=spd*cos(ag);
						sy+=spd*sin(ag);
						wait(3);
					}
				}
			}
			wait(25);
			let wt=40;
			SetAction(ACT_CHARGE,wt);
			MotionBlurEx(SHOT,wt,120,ADD);
			Slow(1);
			Concentration01(wt);
			wait(wt);
			Slow(0);
			local
			{
				SetAction(ACT_SLASH_V,60);
				let leng=580;
				let del=100;
				let wide=6;
				loop(2)
				{
					let angle=p-wide/2;
					while(angle<=p+wide/2+1)
					{
						SlashEffect(GetX,GetY,angle,leng,del);
						SetShot(GetX,GetY,angle);
						angle+=wide;
					}
					
					wide+=10;
				}
				
				task SetShot(let sx,let sy,let ag)
				{
					let stx=sx;
					let sty=sy;
					let spd=10;
					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(40);
					let r=1;
					if(rand_int(0,1)){r=-r;}
					sx=stx;
					sy=sty;
					spd=15;
					let i=rand(0,360);
					loop
					{
						local
						{
							let way=2;
							let speed=1.1;
							let angle=i;
							let sch=6;
							let gra=116;
							let delay=5;
							while(angle<i+360)
							{
								CreateShotA(1,sx,sy,delay);
								SetShotDataA(1,0,speed,angle,sch,0,0,gra);
								SetShotDataA(1,180/sch,NULL,NULL,0,0,0,gra);
								FireShot(1);
								angle+=360/way;
							}
						}
						if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
						sx+=spd*cos(ag);
						sy+=spd*sin(ag);
						i+=17*r;
						wait(1);
					}
				}
			}
			wait(20);
			let wt=160;
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(110,140),0,0,0,0,wt);
			SetAction(ACT_MOVE,wt);
			wait(wt);
		}
		
	}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("浄土剣「蓮華化生へ至る途」",55);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let bx=cenX+(cenX-32)*r;
		let by=minY;
		let lp=0;
		loop
		{
			let wt=40;
			SetAction(ACT_CHARGE,wt);
			MotionBlurEx(SHOT,wt,120,ADD);
			Slow(1);
			Concentration01(wt);
			wait(wt);
			Slow(0);
			local
			{
				let act=ACT_SLASH_V;
				if(lp%2){act=ACT_SLASH_H;}
				SetAction(act,50);
				let p=atan2(GetPlayerY-by,GetPlayerX-bx);
				SetShot(p);
			}
			wait(50);
			let wt=90;
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(110,140),0,0,0,0,wt);
			SetAction(ACT_MOVE,wt);
			wait(wt);
			lp++;
		}
		
		task SetShot(let ag)
		{
			let spd=10;
			while(bx<minX||bx>maxX||by<minY||by>maxY)
			{
				bx+=spd*cos(ag);
				by+=spd*sin(ag);
			}
			let sx=bx;
			let sy=by;
			let leng=580;
			SlashEffect(bx,by,ag,leng,180);

			loop
			{
				CherryEffect(bx,by);
				if(bx<minX||bx>maxX||by<minY||by>maxY){break;}
				bx+=spd*cos(ag);
				by+=spd*sin(ag);
			}
			wait(70);
			
			let spd=15;
			let i=rand(0,360);
			loop
			{
				local
				{
					let way=3;
					let speed=[1.6,1];
					let p=[i,-i];
					let g=[65,68];
					ascent(a in 0..2)
					{
						let angle=p[a];
						let delay=10;
						let lp=0;
						while(angle<p[a]+360)
						{
							let gra=g[a]+lp;
							CreateShot02(sx,sy,0,angle,speed[a]/100,speed[a],gra,delay);
							lp++;
							angle+=360/way;
						}
					}
					i+=17;
				}
				if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
				sx+=spd*cos(ag);
				sy+=spd*sin(ag);
				wait(1);
			}
		}
	}
	
	
	
	
	task MainThread_Unlimited{}
	
}