
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Daiyousei_AnimeLib.txt";
	
	tex_enemy=filedir~"DaiyouseiAnother_Main.png";
	tex_spellbg=filedir~"DaiyouseiAnother_SpellBG.png";
	
	bg_rect=[0,0,386,512];
	
	@Initialize
	{
		point=520;
		SetLife(1500);
		SetTimer(62);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	task MainThread_Standard{}

	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX-6,minY+140,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("聖霊「リヴァイアインデント」",69);
		wait(120);
		let sx=GetX+7;
		let sy=GetY-70;
		SetAction(ACT_SHOT_A,60*62);
		SetEffect;
		wait(60);
		let wide=10;
		let lp=0;
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			local
			{
				let p=rand(0,360);
				let way=10;
				let speed=1.8;
				let ag=p;
				let sch=0.5*r;
				let gra=110;
				let delay=0;
				while(ag<p+360)
				{
					let angle=ag-wide/2;
					while(angle<=ag+wide/2+1)
					{
						SetShot(sx,sy,speed,angle,sch,gra,delay);
						angle+=2;
					}
					ag+=360/way;
				}
				
				let way=12;
				let p=GetAngleToPlayer+((360/way)/2)*lp;
				let speed=2.5;
				let angle=p;
				let gra=54;
				let delay=10;
				while(angle<p+360)
				{
					CreateShot02(sx,sy,0,angle,speed/180,speed,gra,delay);
					angle+=360/way;
				}
			}
			
			lp++;
			r=-r;
			wait(38);
			
			if(GetEnemyLife<=1300){wide=12;}
			if(GetEnemyLife<=1100){wide=14;}
			if(GetEnemyLife<=900){wide=16;}
			if(GetEnemyLife<=700){wide=20;}
			if(GetEnemyLife<=500||GetTimer<20){wide=24;}
			
			task SetShot(let sx,let sy,let speed,let angle,let sch,let gra,let delay)
			{
				let flame=0;
				let leng=0;
				let o=Obj_Create(OBJ_SHOT);
				Obj_SetX(o,sx);
				Obj_SetY(o,sy);
				Obj_SetSpeed(o,0);
				Obj_SetAngle(o,angle);
				ObjShot_SetGraphic(o,gra);
				ObjShot_SetDelay(o,delay);
				Obj_SetAutoDelete(o,false);
				ObjShot_SetBombResist(o,true);
				
				while(!Obj_BeDeleted(o))
				{
					Obj_SetX(o,sx+leng*cos(angle));
					Obj_SetY(o,sy+leng*sin(angle));
					Obj_SetAngle(o,angle);
					
					if(flame>=delay)
					{
						angle+=sch;
						leng+=speed;
					}
					if(leng>=500||Obj_GetY(o)>=maxY+20){Obj_Delete(o);}
					flame++;
					yield;
				}
			}
		}
		
		task SetEffect
		{
			loop
			{
				let way=6;
				let p=rand(0,360);
				let speed=30;
				let angle=p;
				let size=2;
				let delay=7;
				while(angle<p+360)
				{
					IceEffect(sx,sy,speed,angle,size,delay);
					angle+=360/way;
				}
				wait(10);
			}
		}
		
		task IceEffect(let sx,let sy,let speed,let angle,let size,let delay)
		{
			size=floor(size);
			let del=1;
			loop(size)
			{
				Set(sx,sy,angle);
				sx+=speed*cos(angle);
				sy+=speed*sin(angle);
				wait(delay);
			}
			
			task Set(let sx,let sy,let ag)
			{
				let alpha=196;
				let angle=ag+rand(-15,15);
				let leng=absolute(1300-GetEnemyLife)/10;
				let width=70;
				let gra=86;
				let tuning=GetCommonData("Memory_ConfigData");
				SetLaserObject(sx,sy,leng,width,angle,alpha,gra,0,del);
				if(!tuning[1]){Effect(sx,sy,leng,width,angle);}
				
				wait(del);
				if(!tuning[1]){EndEffect(sx,sy,leng,width,angle);}
			}
			
			task Effect(let sx,let sy,let leng,let width,let angle)
			{
				let alpha=48;
				let alpha_=alpha;
				let gra=86;
				let Lp=10;
				while(alpha>0)
				{
					SetLaserObject(sx,sy,leng,width,angle,alpha,gra,0,1);
					alpha-=alpha_/Lp;
					leng*=1.2;
					width*=1.2;
					yield;
				}
			}
			task EndEffect(let sx,let sy,let leng,let width,let angle)
			{
				let alpha=64;
				let alpha_=alpha;
				let gra=86;
				let Lp=5;
				while(alpha>0)
				{
					SetLaserObject(sx,sy,leng,width,angle,alpha,gra,0,1);
					alpha-=alpha_/Lp;
					leng*=1.3;
					width*=1.3;
					yield;
				}
			}
		}
	}
	
	
	task MainThread_Unlimited{}
	
}