
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Komachi_AnimeLib.txt";
	
	tex_enemy=filedir~"Komachi_Main.png";
	tex_spellbg=filedir~"Komachi_SpellBG.png";
	
	bg_rect=[0,0,768,512];
	
	@Initialize
	{
		point=450;
		SetLife(900);
		SetTimer(51);
		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+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("忘却「レーテーの川岸」",72);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let lp=0;
		loop
		{
			loop(2)
			{
				let wt=120;
				SetAction(ACT_CHARGE,wt);
				Concentration01(wt);
				let p=GetAngleToPlayer+rand(-25,25);
				let wt=2;
				let sp=0;
				let wide=160;
				while(wide>20)
				{
					let speed=3+sp;
					let angle=p-wide/2;
					let gra=[248,249];
					let delay=0;
					let a=0;
					while(angle<=p+wide/2+1)
					{
						CreateShot01(GetX,GetY,speed,angle,gra[a%length(gra)],delay);
						angle+=wide;
						a++;
					}
					wait(wt);
					sp+=0.04;
					wide-=8;
				}
				loop(7)
				{
					let speed=3+sp;
					let angle=p-wide/2;
					let gra=[248,249];
					let delay=0;
					let a=0;
					while(angle<=p+wide/2+1)
					{
						CreateShot01(GetX,GetY,speed,angle,gra[a%length(gra)],delay);
						angle+=wide;
						a++;
					}
					wait(wt);
				}
				wait(25);
				SetAction(ACT_SHOT_B,90);
				SetShot(p);
				wait(40);
			}
			let wt=120;
			SetMovePositionHermite(GetPlayerX,cenY-rand(100,150),0,0,0,0,wt);
			SetAction(ACT_MOVE,wt);
			let sp=0;
			loop(3)
			{
				let p=rand(0,360);
				let way=50;
				let speed=1.8-sp;
				let angle=p;
				let gra=250;
				let delay=10;
				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,delay);
					angle+=360/way;
				}
				sp+=0.4;
				wait(40);
			}
		}
		
		
		task SetShot(let ag)
		{
			let rot=0;
			let sx=GetX;
			let sy=GetY;
			let leng=10;
			loop
			{
				let v=25;
				leng+=v;
				sx+=v*cos(ag);
				sy+=v*sin(ag);
				let width=20;
				let gra=46;
				SetLaserObject(GetX,GetY,leng,width,ag,255,gra,100,10);
				if(sx<minX){rot=0;break;}
				if(sx>maxX){rot=180;break;}
				if(sy<minY){rot=90;break;}
				if(sy>maxY){rot=270;break;}
				wait(1);
			}
			let wide=2;
			let lbase=260;
			while(lbase>=10)
			{
				let wd=-wide/2;
				while(wd<=wide/2+1)
				{
					let v=0;
					let leng=lbase;
					while(leng>=5)
					{
						let va=[v,-v];
						ascent(a in 0..2)
						{
							let bx=sx;
							let by=sy;
							alternative(rot)
							case(0,180){by=sy+wd+va[a];}
							case(90,270){bx=sx+wd+va[a];}
							others{}
							
							let angle=rot;
							let width=44;
							let gra=46;
							let delay=0;
							let del=10;
							SetLaserObject(bx,by,leng,width,angle,48,gra,delay,del);
						}
						v+=6;
						leng/=1.2;
					}
					wd+=wide;
				}
				wide+=10;
				lbase/=1.05;
				wait(1);
			}
		}
	}
	
}