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

	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+190,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("氷霊「バルナパージ」",67);
		wait(120);
		Sub;
		SetAction(ACT_SHOT_A,200);
		wait(180);
		loop
		{
			SetAction(ACT_SHOT_B,100);
			let wide=12;
			let p=GetAngleToPlayer;
			let sp=0;
			loop(8)
			{
				let way=3;
				let speed=0.7+sp;
				let gra=110;
				let delay=10;
				let ag=p;
				while(ag<p+360)
				{
					let angle=ag-wide/2;
					while(angle<=ag+wide/2+1)
					{
						CreateShot01(GetX,GetY,speed,angle,gra,delay);
						angle+=2;
					}
					ag+=360/way;
				}
				wide+=4;
				sp+=0.3;
				wait(5);
			}
			wait(120);
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(180,200),0,0,0,0,120);
			SetAction(ACT_MOVE,120);
			wait(140);
		}
		
		task Sub
		{
			local
			{
				let wide=80;
				while(wide<360)
				{
					let sx=cenX-wide/2;
					while(sx<=cenX+wide/2+1)
					{
						SetTargeting(sx,maxY-30,0.3,60,1);
						sx+=wide;
					}
					wide+=80;
					wait(10);
				}
			}
			wait(50);
			loop
			{
				IceShot(cenX+rand(-180,180),maxY+40,1.5,-90);
				wait(60);
			}
		}
		
		task IceShot(let sx,let sy,let speed,let angle)
		{
			let count=0;
			let rot=rand(0,360);
			let rp=rand(-2,2);
			while(sx>minX&&sx<maxX&&sy>minY)
			{
				if(!(count%2))
				{
					let way=7;
					let leng=80;
					let width=80;
					let alpha=64;
					let gra=86;
					let del=2;
					let ag=rot;
					while(ag<rot+360)
					{
						SetLaserObject(sx,sy,leng,width,ag,alpha,gra,0,del);
						ag+=360/way;
					}
					
					gra=46;
					leng=90;
					width=90;
					SetLaserObject(sx-leng/2*cos(rot),sy-leng/2*sin(rot),leng,width,rot,192,gra,0,del);
					
				}
				if(GetGapLength(GetPlayerX,GetPlayerY,sx,sy)<=50&&GetTimeOfPlayerInvincibility==0)
				{
					ShootDownPlayer;
				}
				sx+=speed*cos(angle);
				sy+=speed*sin(angle);
				speed*=1.01;
				rot+=rp;
				count++;
				yield;
			}
			local
			{
				let p=rand(0,360);
				let way=30;
				let speed=[2];
				let angle=p;
				let gra=38;
				let delay=20;
				while(angle<p+360)
				{
					ascent(a in 0..length(speed))
					{
						CreateShot02(sx,sy,0,angle,speed[a]/60,speed[a],gra,delay);
					}
					angle+=360/way;
				}
			}
		}
	}
	
	
	
	
	task MainThread_Unlimited{}
	
}