
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Suika_AnimeLib.txt";
	
	tex_enemy=filedir~"Suika_Main.png";
	tex_spellbg=filedir~"Suika_SpellBG.png";
	
	bg_rect=[0,0,512,768];
	
	@Initialize
	{
		point=450;
		SetLife(1000);
		SetTimer(60);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+90,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("大力「酒呑童子天手」",82);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let wt=60;
			Concentration01(wt);
			SetAction(ACT_SHOT_A,wt);
			wait(wt);
			SetMovePosition02(GetX,GetY+20,10);
			SetAction(ACT_MOVE,10);
			wait(10);
			local
			{
				let way=10;
				let p=rand(0,360);
				let delay=0;
				let ag=p;
				while(ag<p+360)
				{
					Sub(GetX,GetY,ag,delay);
					ag+=360/way;
					delay+=5;
				}
			}
			local
			{
				let way=18;
				let p=rand(0,360);
				let v=360/way/4;
				let speed=6;
				let gra=78;
				let delay=30;
				while(speed>=0.6)
				{
					let angle=p;
					while(angle<p+360)
					{
						CreateShot01(GetX,GetY,speed,angle,gra,delay);
						angle+=360/way;
					}
					p+=v*r;
					v/=1.06;
					speed/=1.08;
				}
			}
			
			wait(20);
			SetMovePositionHermite(cenX+rand(-80,80),GetY-20,0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			wait(100);
			
			task Sub(let sx,let sy,let ag,let d)
			{
				local
				{
					let leng=1000;
					let width=45;
					let gra=46;
					let delay=30;
					let del=4;
					SetLaserObject(sx,sy,leng,width,ag,255,gra,delay,del);
				}
				wait(60+d);
				local
				{
					let leng=1000;
					let width=75;
					let gra=46;
					let delay=10;
					let del=90;
					SetLaserObject(sx,sy,leng,width,ag,255,gra,delay,del);
					let speed=18;
					let gra=126;
					CreateLaser01(sx,sy,speed,ag,leng,width,gra,0);
				}
				wait(10);
				loop
				{
					let v=10;
					sx+=v*cos(ag);
					sy+=v*sin(ag);
					if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
				}
				
				local
				{
					let way=7;
					
					let p=ag;
					let speed=1;
					let angle=p;
					let gra=55;
					let delay=0;
					while(angle<p+360)
					{
						CreateShot02(sx,sy,0,angle,speed/100,speed,gra,delay);
						angle+=360/way;
					}
				}
			}
			wait(240);
			r=-r;
		}
	}
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+90,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("全放「完全地霊包囲網」",83);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_B,90);
			let px=GetPlayerX;
			let py=GetPlayerY;
			SetTargeting(px,py,0.5,100,0);
			wait(30);
			local
			{
				let p=rand(0,360);
				let way=7;
				let angle=p;
				while(angle<p+360)
				{
					let v=80;
					let sx=px+v*cos(angle);
					let sy=py+v*sin(angle);
					SetShot(sx,sy,angle);
					angle+=360/way;
				}
			}
			wait(240);
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(80,110),0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			wait(100);
			
			task SetShot(let sx,let sy,let ag)
			{
				let lp=1;
				let spd=10;
				loop
				{
					if(!(lp%2)){Sub(sx,sy,ag);}
					if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
					let gra=2;
					let delay=30;
					SetDelayEffect(sx,sy,gra,delay);
					sx+=spd*cos(ag);
					sy+=spd*sin(ag);
					lp++;
					yield;
				}
				local
				{
					let way=12;
					
					let p=ag;
					let speed=1;
					let angle=p;
					let gra=42;
					let delay=40;
					while(angle<p+360)
					{
						CreateShot02(sx,sy,0,angle,speed/100,speed,gra,delay);
						angle+=360/way;
					}
				}
				task Sub(let sx,let sy,let ag)
				{
					let speed=2.5;
					let L=4;
					let wp=25;
					let wide=wp*(L-1);
					let gra=82;
					let delay=4;
					loop(L)
					{
						let v=6;
						let p=ag+180;
						if(wide==0)
						{
							let angle=p;
							let x=sx+v*cos(angle);
							let y=sy+v*sin(angle);
							CreateShot02(x,y,0,angle,speed/200,speed,gra,delay);
						}
						else
						{
							let angle=p-wide/2;
							while(angle<=p+wide/2+1)
							{
								let x=sx+(v-wide/6)*cos(angle);
								let y=sy+(v-wide/6)*sin(angle);
								CreateShot02(x,y,0,angle,speed/200,speed,gra,delay);
								angle+=wide;
							}
						}
						wide+=-wp;
						speed-=0.3;
						wait(8);
					}
				}
			}
		}
	}
	
	
	task MainThread_Unlimited{}
	
}