
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Murasa_AnimeLib.txt";
	
	tex_enemy=filedir~"Murasa_Main.png";
	tex_spellbg=filedir~"Murasa_SpellBG.png";
	bg_rect=[0,0,640,480];
	
	@Initialize
	{
		point=390;
		SetLife(900);
		SetTimer(60);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	task MainThread_Advanced{}
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+150,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("双火「ポリュデウケースとカストール」",41);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		local
		{
			SetAction(ACT_SHOT_B,150);
			ascent(a in 0..2){SetFamilier(a);}
			loop
			{
				wait(400);
				let wt=200;
				SetMove(cenX+rand(-100,100),minY+rand(130,160),wt);
			}
			r=-r;
		}
		
		task SetFamilier(let type)
		{
			type=type%2;
			let sx=GetX;
			let sy=GetY;
			let leng=0;
			let rot=180*type;
			State;
			
			let lgp=2;
			loop(150)
			{
				sx=GetEnemyX+leng*cos(rot);
				sy=GetEnemyY+leng*sin(rot);
				leng+=lgp;
				lgp*=0.98;
				yield;
			}
			SetShot;
			SetShot2;
			let i=0;
			let lp=0;
			loop
			{
				sx=GetEnemyX+leng*cos(rot+i);
				sy=GetEnemyY+leng*sin(rot+i/1.5);
				
				i+=0.9;
				leng+=0.5*cos(lp/2);
				lp++;
				yield;
			}
			
			task SetShot
			{
				let r=1;
				if(type){r=-r;}
				
				let lp=180*type;
				loop
				{
					let way=5;
					let p=atan2(GetEnemyY-sy,GetEnemyX-sx)+45*r;
					let spd=2.5+1*cos(lp);
					let speed=[spd,spd/1.02];
					let angle=p;
					let gra=[65,70];
					let delay=0;
					while(angle<p+360)
					{
						ascent(a in 0..length(speed))
						{
							CreateShot02(sx,sy,0,angle,speed[a]/100,speed[a],gra[type],delay);
						}
						angle+=360/way;
					}
					wait(7);
				}
				
			}
			
			task SetShot2
			{
				wait(80);
				loop
				{
					let p=atan2(GetPlayerY-sy,GetPlayerX-sx);
					let way=15;
					let wide=8;
					let speed=1.5;
					let angleA=p;
					let gra=[25,30];
					let delay=0;
					while(angleA<p+360)
					{
						let angleB=angleA-wide/2;
						while(angleB<=angleA+wide/2+1)
						{
							CreateShot02(sx,sy,0,angleB,speed/60,speed,gra[type],delay);
							angleB+=2;
						}
						angleA+=360/way;
					}
					wait(120);
				}
			}
			
			task State
			{
				let gra=[1,6];
				let delay=10;
				loop
				{
					SetDelayEffect(sx,sy,gra[type],delay);
					yield;
				}
			}
		}
	}
}