
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=420;
		SetLife(800);
		SetTimer(52);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	task MainThread_Standard{}

	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+180,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("地霊「ダーキニーハーム」",61);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_A,60);
			wait(15);
			let sp=0;
			loop(2)
			{
				let p=rand(0,360);
				let way=9;
				
				let sx=GetX+7;
				let sy=GetY-20;
				let speed=7-sp;
				let angle=p;
				let gra=34;
				let delay=0;
				while(angle<p+360)
				{
					SetObjectShot(sx,sy,speed,angle,gra,delay);
					angle+=360/way;
				}
				sp+=3.8;
				wait(20);
			}
			
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(170,190),0,0,0,0,120);
			SetAction(ACT_MOVE,120);
			wait(160);
			SetAction(ACT_SHOT_A,120);
			wait(15);
			let wide=10;
			loop(3)
			{
				let p=GetAngleToPlayer;
				let way=3;
				
				let sx=GetX+7;
				let sy=GetY-20;
				let speed=0;
				let angle=p-wide/2;
				let gra=34;
				let delay=0;
				while(angle<=p+wide/2+1)
				{
					SetObjectShot(sx,sy,speed,angle,gra,delay);
					angle+=wide/(way-1);
				}
				wait(50);
				wide+=15;
			}
			wait(60);
			SetAction(ACT_SHOT_B,180);
			let i=GetAngleToPlayer+180;
			let L=15;
			loop(L)
			{
				let speed=rand(3,7);
				let angle=i;
				let gra=34;
				let delay=0;
				SetObjectShot(GetX,GetY,speed,angle,gra,delay);
				i+=(360/L)*r;
				wait(8);
			}
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(170,190),0,0,0,0,120);
			SetAction(ACT_MOVE,120);
			wait(240);
			r=-r;
		}
		
		task SetObjectShot(let x,let y,let spd,let ag,let gra,let delay)
		{
			let obj=Obj_Create(OBJ_SHOT);
			Obj_SetX(obj,x);
			Obj_SetY(obj,y);
			Obj_SetSpeed(obj,spd);
			Obj_SetAngle(obj,ag);
			ObjShot_SetGraphic(obj,gra);
			ObjShot_SetDelay(obj,delay);
			ObjShot_SetBombResist(obj,true);
			
			let type=0;
			if(spd==0){type=1;}
			let count=0;
			while(!Obj_BeDeleted(obj))
			{
				let sx=Obj_GetX(obj);
				let sy=Obj_GetY(obj);
				let tuning=GetCommonData("Memory_ConfigData");
				Obj_SetSpeed(obj,spd);
				
				if(!tuning[1]&&!(count%2))
				{
					SetLaserObject(sx,sy,36,360,ag,32,gra,100,floor(spd*2));
				}
				
				if(sx>maxX||sx<minX||sy>maxY||sy<minY||(spd<0.4&&type==0))
				{
					let p=rand(0,360);
					let way=12;
					let speed=15;
					let angle=0;
					let size=3;
					let delay=4;
					while(angle<360)
					{
						EarthEffect(sx,sy,speed,angle,size,delay);
						angle+=360/way;
					}
					
					way=8;
					let gra=10;
					angle=p;
					while(angle<p+360)
					{
						speed=rand(1,1.4);
						CreateShot02(sx,sy,0,angle,speed/100,speed,gra,delay);
						angle+=360/way;
					}
					
					Obj_Delete(obj);
				}
				if(count>delay)
				{
					if(type==0){spd/=1.02;}
					if(type==1){spd+=0.1;}
				}
				count++;
				yield;
			}
		}
		

		task EarthEffect(let sx,let sy,let speed,let angle,let size,let delay)
		{
			size=floor(size);
			let del=60;
			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=50;
				let width=20;
				let gra=82;
				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=82;
				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=82;
				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{}
	
}