
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=480;
		SetLife(900);
		SetTimer(57);
		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("死花「瞬に輝く死狂緋」",73);
		wait(100);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let p=GetAngleToPlayer;
			SetAction(ACT_SHOT_B,120);
			loop(2)
			{
				let way=6;
				local
				{
					let sp=0;
					let wide=0;
					loop(11)
					{
						let speed=[4-sp,3.4-sp];
						let angle=p;
						let gra=81;
						let delay=10;
						while(angle<p+360)
						{
							ascent(a in 0..length(speed))
							{
								WideShot(GetX,GetY+20,speed[a],angle,wide,gra,delay);
							}
							angle+=360/way;
						}
						wide+=6;
						sp+=0.24;
					}
				}
				p+=360/way/2;
				r=-r;
				wait(24);
				function WideShot(x,y,spd,ag,wide,gra,delay)
				{
					if(wide==0)
					{
						CreateShot01(x,y,spd,ag,gra,delay);
					}
					else
					{
						let angle=ag-wide/2;
						while(angle<=ag+wide/2+0.5)
						{
							CreateShot01(x,y,spd,angle,gra,delay);
							angle+=wide;
						}
					}
				}
			}
			local
			{
				let way=12;
				
				let sx=GetX;
				let sy=GetY+20;
				let leng=700;
				let width=35;
				let speed=15;
				let angle=p;
				let gra=41;
				let delay=0;
				while(angle<p+360)
				{
					CreateLaser01(sx,sy,speed,angle,leng,width,gra,delay);
					SetShot(sx,sy,speed,angle);
					angle+=360/way;
				}
				
				task SetShot(let sx,let sy,let spd,let ag)
				{
					let lp=0;
					loop
					{
						if(!(lp%2)){Sub(sx,sy,ag);}
						if(sx<minX||sx>maxX||sy<minY||sy>maxY){break;}
						sx+=spd*cos(ag);
						sy+=spd*sin(ag);
						lp++;
						yield;
					}
				}
				
				
				task Sub(let sx,let sy,let ag)
				{
					let speed=2.5;
					let wide=0;
					let gra=218;
					let delay=4;
					let L=5;
					loop(L)
					{
						let v=25;
						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/120,speed,gra,delay);
						}
						else
						{
							let angle=p-wide/2;
							while(angle<=p+wide/2+1)
							{
								let x=sx+(v-wide/2)*cos(angle);
								let y=sy+(v-wide/2)*sin(angle);
								CreateShot02(x,y,0,angle,speed/120,speed,gra,delay);
								angle+=wide;
							}
						}
						wide+=9;
						speed-=0.3;
						wait(4);
					}
				}
			}
			wait(120);
			SetMovePositionHermite(cenX+rand(-70,70),minY+rand(90,120),0,0,0,0,120);
			SetAction(ACT_MOVE,120);
			wait(200);
		}
	}
	
	
	
	
	task MainThread_Advanced{}
	
	
	
	
	task MainThread_Unlimited{}
	
}
