
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Ran_AnimeLib.txt";
	
	tex_enemy=filedir~"Ran_Main.png";
	tex_spellbg=filedir~"Ran_SpellBG.png";
	
	bg_rect=[0,0,512,512];
	
	@Initialize
	{
		point=420;
		SetLife(1000);
		SetTimer(50);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+160,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetRoll(100);
		SetSpellCard("五真「不動王生霊返し」",40);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let sp=0;
			let p=GetAngleToPlayer;
			loop(8)
			{
				let way=18;
				let speed=1+sp;
				let angle=p;
				let gra=136;
				let delay=10;
				while(angle<p+360)
				{
					SpecialShot(GetX,GetY,speed,angle,gra,delay);
					angle+=360/way;
				}
				sp+=0.5;
				wait(12);
			}
			wait(120);
			
			SetMovePositionHermite(cenX+rand(-90,90),minY+rand(150,180),0,0,0,0,200);
			SetAction(ACT_MOVE,200);
			SetRoll(200);
			wait(200);
			
			let p=GetAngleToPlayer;
			loop(2)
			{
				let ag=p+90*r;
				
				let wide=180;
				let speed=2;
				let angle=ag-wide/2;
				let gra=136;
				let delay=10;
				while(angle<=ag+wide/2+1)
				{
					SpecialShot(GetX,GetY,speed,angle,gra,delay);
					angle+=3;
				}
				r=-r;
				wait(80);
			}
			SetMovePositionHermite(cenX+rand(-90,90),minY+rand(150,180),0,0,0,0,200);
			SetAction(ACT_MOVE,200);
			SetRoll(200);
			wait(200);
			r=-r;
		}
		
		task SpecialShot(let sx,let sy,let speed,let angle,let gra,let delay)
		{
			let flame=0;
			let obj=Obj_Create(OBJ_SHOT);
			Obj_SetX(obj,sx);
			Obj_SetY(obj,sy);
			Obj_SetSpeed(obj,speed);
			Obj_SetAngle(obj,angle);
			ObjShot_SetGraphic(obj,gra);
			ObjShot_SetDelay(obj,delay);
			ObjShot_SetBombResist(obj,true);
			
			while(!Obj_BeDeleted(obj))
			{
				let sx=Obj_GetX(obj);
				let sy=Obj_GetY(obj);
				if(sx<minX||sx>maxX||sy<minY||sy>maxY)
				{
					let p=atan2(GetPlayerY-sy,GetPlayerX-sx);
					
					let speed=2;
					let angle=p;
					let gra=152;
					let delay=15;
					
					CreateShot02(sx,sy,0,angle,speed/100,speed,gra,delay);
					Obj_Delete(obj);
				}
				yield;
			}
		}
	}
	task MainThread_Unlimited{}
	
}